@indxsearch/intrface 3.15.1 β 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/README.md +4 -4
- package/dist/components/AskPanel.d.ts +8 -1
- package/dist/components/QuickAnswer.d.ts +4 -2
- package/dist/components/SearchInput.d.ts +5 -3
- package/dist/components/SearchResults.d.ts +20 -3
- package/dist/context/SearchContext.d.ts +40 -16
- package/dist/hooks/useAsk.d.ts +41 -5
- package/dist/hooks/useSearchOrAsk.d.ts +25 -11
- package/dist/index.cjs.js +3 -3
- package/dist/index.d.ts +3 -5
- package/dist/index.es.js +1526 -1286
- package/dist/intrface.css +1 -1
- package/dist/utils/searchOrAsk.d.ts +20 -42
- package/package.json +3 -3
- package/dist/utils/askPhrases.d.ts +0 -24
package/dist/index.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "@indxsearch/systm/styles.css";
|
|
2
2
|
import e, { Component as t, createContext as n, memo as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { Alert as
|
|
6
|
-
import { Ai_agent as
|
|
3
|
+
import { Rungs as u, SearchMode as d, SystemState as f, Tolerance as p } from "@indxsearch/indx-types";
|
|
4
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
5
|
+
import { Alert as _, AlertDescription as v, AlertTitle as y, AnswerActions as b, AssistantMessage as x, Button as S, Checkbox as C, Chip as w, CitationList as T, CitationRef as E, Composer as D, FilterPanelBase as O, InputField as k, Kbd as A, Popover as j, RadioButton as M, SearchField as N, Select as P, ShimmerText as F, Skeleton as I, Slider as L, StreamStatus as R, ToggleSwitch as z, Tooltip as B, UserMessage as V } from "@indxsearch/systm";
|
|
6
|
+
import { Ai_agent as H, ArrowDown as U, ArrowRight as W, Cloud as G, Filter as K, Fuzzy_search as ee, Hour_glass as q, Indx as te, Key as ne, Lock as J, Refresh as Y, Search as X, Speedometer as re, Warning as ie, X_or_error as ae } from "@indxsearch/pixl";
|
|
7
7
|
// src/context/IndxApiError.ts
|
|
8
|
-
var
|
|
8
|
+
var Z = class e extends Error {
|
|
9
9
|
status;
|
|
10
10
|
code;
|
|
11
11
|
problem;
|
|
@@ -29,14 +29,14 @@ var Y = class e extends Error {
|
|
|
29
29
|
let i = n.headers?.get?.("Retry-After"), a = i != null && /^\d+$/.test(i) ? Number(i) : void 0;
|
|
30
30
|
return new e(t, n.status, r, a);
|
|
31
31
|
}
|
|
32
|
-
},
|
|
32
|
+
}, oe = class extends Error {
|
|
33
33
|
constructor(e) {
|
|
34
34
|
super(e), this.name = "SearchSetupError";
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
function
|
|
37
|
+
function se(e, t) {
|
|
38
38
|
let n = e instanceof Error ? e.message : String(e);
|
|
39
|
-
if (e instanceof
|
|
39
|
+
if (e instanceof oe) return {
|
|
40
40
|
kind: "setup",
|
|
41
41
|
message: n,
|
|
42
42
|
technical: n,
|
|
@@ -48,7 +48,7 @@ function ae(e, t) {
|
|
|
48
48
|
technical: "Network error: no response from the server. Check that it is running and that the url is right.",
|
|
49
49
|
retryable: !0
|
|
50
50
|
};
|
|
51
|
-
if (e instanceof
|
|
51
|
+
if (e instanceof Z) {
|
|
52
52
|
let r = {
|
|
53
53
|
message: n,
|
|
54
54
|
status: e.status,
|
|
@@ -114,15 +114,15 @@ function ae(e, t) {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
// src/context/useIndxAuth.ts
|
|
117
|
-
function
|
|
118
|
-
let [a, s] = l(null), [c,
|
|
117
|
+
function ce({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugLogs: i = !1 }) {
|
|
118
|
+
let [a, s] = l(null), [c, u] = l(!0), [d, p] = l([]), [m, h] = l([]), [g, _] = l([]), [v, y] = l({}), [b, x] = l({}), [S, C] = l({}), [w, T] = l(0), [E, D] = l(null), [O, k] = l(null), [A, j] = l(0);
|
|
119
119
|
return o(() => {
|
|
120
120
|
(async () => {
|
|
121
|
-
D(null), k(null),
|
|
121
|
+
D(null), k(null), u(!0);
|
|
122
122
|
try {
|
|
123
|
-
if (!r) throw console.error("[Auth] β Missing bearer token"), console.error("[Auth] π‘ Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new
|
|
124
|
-
if (!e) throw console.error("[Auth] β Missing INDX server URL"), console.error("[Auth] π‘ Pass a url to SearchProvider"), new
|
|
125
|
-
if (!n) throw console.error("[Auth] β Missing dataset name"), console.error("[Auth] π‘ Pass dataset=\"your-dataset-name\" to SearchProvider"), new
|
|
123
|
+
if (!r) throw console.error("[Auth] β Missing bearer token"), console.error("[Auth] π‘ Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new oe("A bearer token is required. Check console for instructions.");
|
|
124
|
+
if (!e) throw console.error("[Auth] β Missing INDX server URL"), console.error("[Auth] π‘ Pass a url to SearchProvider"), new oe("INDX server URL is required. Check console for instructions.");
|
|
125
|
+
if (!n) throw console.error("[Auth] β Missing dataset name"), console.error("[Auth] π‘ Pass dataset=\"your-dataset-name\" to SearchProvider"), new oe("Dataset name is required. Check console for instructions.");
|
|
126
126
|
i && console.log("[Auth] β
Using bearer token");
|
|
127
127
|
let a = r, o = (e) => fetch(e, {
|
|
128
128
|
method: "GET",
|
|
@@ -133,26 +133,26 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
133
133
|
});
|
|
134
134
|
i && console.log("[Auth] π Checking dataset status...");
|
|
135
135
|
let c = await o(`${e}/api/teams/${t}/datasets/${n}/status`);
|
|
136
|
-
if (!c.ok) throw c.status === 401 ? (console.error("[Auth] β Authentication failed (401 Unauthorized)"), console.error("[Auth] π‘ Your token may be expired or invalid"), console.error("[Auth] π‘ Create or refresh your token on the Indx Dashboard"), await
|
|
136
|
+
if (!c.ok) throw c.status === 401 ? (console.error("[Auth] β Authentication failed (401 Unauthorized)"), console.error("[Auth] π‘ Your token may be expired or invalid"), console.error("[Auth] π‘ Create or refresh your token on the Indx Dashboard"), await Z.fromResponse("Dataset status", c)) : c.status === 404 ? (console.error("[Auth] β Dataset \"" + n + "\" not found (404)"), console.error("[Auth] π‘ Available datasets can be checked with: curl -X GET \"" + e + "/api/me/datasets\" -H \"Authorization: Bearer YOUR_TOKEN\""), console.error("[Auth] π‘ Make sure you spelled the dataset name correctly"), await Z.fromResponse("Dataset status", c)) : (console.error("[Auth] β Failed to get dataset status:", c.status), await Z.fromResponse("Dataset status", c));
|
|
137
137
|
let l = await c.json();
|
|
138
|
-
i && console.log("[Auth] π Dataset status:", l), s(a), i && console.log("[Auth] β
Dataset session established"), l.systemState !== void 0 && l.systemState !==
|
|
139
|
-
let
|
|
140
|
-
|
|
141
|
-
let [
|
|
138
|
+
i && console.log("[Auth] π Dataset status:", l), s(a), i && console.log("[Auth] β
Dataset session established"), l.systemState !== void 0 && l.systemState !== f.Ready && (console.warn("[Auth] β οΈ Dataset is not ready yet. Current state:", l.systemState), console.warn("[Auth] π‘ Wait for indexing to complete before searching"));
|
|
139
|
+
let u = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
140
|
+
u === 0 ? (console.warn("[Auth] β οΈ Dataset \"" + n + "\" is empty (0 records)"), console.warn("[Auth] π‘ Add documents to your dataset before searching"), console.warn("[Auth] π‘ Search will work but return no results")) : i && console.log("[Auth] β
Dataset has", u, "records");
|
|
141
|
+
let [d, m, g, v] = await Promise.all([
|
|
142
142
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/filterable`),
|
|
143
143
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/facetable`),
|
|
144
144
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/sortable`),
|
|
145
145
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/configuration`).catch(() => null)
|
|
146
146
|
]);
|
|
147
|
-
if (!
|
|
148
|
-
if (!m.ok) throw console.error("[Auth] β GetFacetableFields failed:", m.status), await
|
|
149
|
-
if (!g.ok) throw console.error("[Auth] β GetSortableFields failed:", g.status), await
|
|
147
|
+
if (!d.ok) throw console.error("[Auth] β GetFilterableFields failed:", d.status), await Z.fromResponse("Filterable fields", d);
|
|
148
|
+
if (!m.ok) throw console.error("[Auth] β GetFacetableFields failed:", m.status), await Z.fromResponse("Facetable fields", m);
|
|
149
|
+
if (!g.ok) throw console.error("[Auth] β GetSortableFields failed:", g.status), await Z.fromResponse("Sortable fields", g);
|
|
150
150
|
let [b, S, w] = await Promise.all([
|
|
151
|
-
|
|
151
|
+
d.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
|
|
152
152
|
m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
|
|
153
153
|
g.json().catch((e) => (console.error("Failed to parse GetSortableFields response:", e), []))
|
|
154
154
|
]);
|
|
155
|
-
p(b || []), h(S || []), _(w || []), T(
|
|
155
|
+
p(b || []), h(S || []), _(w || []), T(u);
|
|
156
156
|
let E = {};
|
|
157
157
|
if (v?.ok) {
|
|
158
158
|
let e = await v.json().catch((e) => (console.error("Failed to parse GetFieldConfiguration response:", e), []));
|
|
@@ -191,12 +191,12 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
191
191
|
if (D.facets) for (let [e, t] of Object.entries(D.facets)) Array.isArray(t) && (k[e] = t.map((e) => e.key));
|
|
192
192
|
x(O), C(k), i && console.log("[Auth] β
Initialization complete");
|
|
193
193
|
} catch (r) {
|
|
194
|
-
console.error("[Auth] β Initialization failed:", r), (r instanceof Error || typeof r == "object" && r && "message" in r) && console.error("[Auth] π‘ Error:", r.message), r instanceof TypeError && r.message.includes("fetch") && (console.error("[Auth] β Network error - cannot connect to INDX server"), console.error("[Auth] π‘ Check if the server is running at:", e), console.error("[Auth] π‘ Check the url you passed to SearchProvider"), console.error("[Auth] π‘ For local development, it should be: http://localhost:5001")), D(r instanceof Error ? r.message : String(r)), k(
|
|
194
|
+
console.error("[Auth] β Initialization failed:", r), (r instanceof Error || typeof r == "object" && r && "message" in r) && console.error("[Auth] π‘ Error:", r.message), r instanceof TypeError && r.message.includes("fetch") && (console.error("[Auth] β Network error - cannot connect to INDX server"), console.error("[Auth] π‘ Check if the server is running at:", e), console.error("[Auth] π‘ Check the url you passed to SearchProvider"), console.error("[Auth] π‘ For local development, it should be: http://localhost:5001")), D(r instanceof Error ? r.message : String(r)), k(se(r, {
|
|
195
195
|
team: t,
|
|
196
196
|
dataset: n
|
|
197
197
|
}));
|
|
198
198
|
} finally {
|
|
199
|
-
|
|
199
|
+
u(!1);
|
|
200
200
|
}
|
|
201
201
|
})();
|
|
202
202
|
}, [
|
|
@@ -212,7 +212,7 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
212
212
|
retry: () => j((e) => e + 1),
|
|
213
213
|
initialFacetStats: b,
|
|
214
214
|
initialFacetKeys: S,
|
|
215
|
-
filterableFields:
|
|
215
|
+
filterableFields: d,
|
|
216
216
|
facetableFields: m,
|
|
217
217
|
sortableFields: g,
|
|
218
218
|
fieldTypes: v,
|
|
@@ -220,30 +220,25 @@ function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
222
|
// src/context/buildFilterProxy.ts
|
|
223
|
-
async function
|
|
223
|
+
async function le(e, t, n, r, i, a, o) {
|
|
224
224
|
let s = await o(`${r}/api/teams/${i}/datasets/${a}/filters/${e}`, {
|
|
225
225
|
method: "POST",
|
|
226
226
|
headers: { "Content-Type": "application/json" },
|
|
227
227
|
body: JSON.stringify(t)
|
|
228
228
|
});
|
|
229
|
-
if (!s.ok) throw await
|
|
229
|
+
if (!s.ok) throw await Z.fromResponse(n, s);
|
|
230
230
|
let c = await s.json();
|
|
231
231
|
if (!c || typeof c.hashString != "string") throw Error(`${n} failed: server returned no filter token`);
|
|
232
232
|
return c;
|
|
233
233
|
}
|
|
234
|
-
async function
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
let o = e[0];
|
|
238
|
-
for (let s = 1; s < e.length; s++) o = await se("combine", {
|
|
239
|
-
a: o,
|
|
240
|
-
b: e[s],
|
|
234
|
+
async function ue(e, t, n, r, i, a) {
|
|
235
|
+
return e.length === 0 ? null : e.length === 1 ? e[0] : le("combine", {
|
|
236
|
+
filters: e,
|
|
241
237
|
useAndOperation: t === "and"
|
|
242
238
|
}, "CombineFilters", n, r, i, a);
|
|
243
|
-
return o;
|
|
244
239
|
}
|
|
245
|
-
async function
|
|
246
|
-
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) =>
|
|
240
|
+
async function de(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
241
|
+
let l = Object.entries(e ?? {}).filter(([, e]) => e.length > 0), u = Object.entries(t ?? {}), d = Object.entries(s ?? {}).filter(([, e]) => e.length > 0), f = (e, { min: t, max: o }) => le("range", {
|
|
247
242
|
fieldName: e,
|
|
248
243
|
lowerLimit: t,
|
|
249
244
|
upperLimit: o
|
|
@@ -252,29 +247,29 @@ async function le(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
252
247
|
return Number.isFinite(o) ? f(e, {
|
|
253
248
|
min: o,
|
|
254
249
|
max: o
|
|
255
|
-
}) :
|
|
250
|
+
}) : le("value", {
|
|
256
251
|
fieldName: e,
|
|
257
252
|
value: t
|
|
258
253
|
}, `Value filter '${e}'`, n, r, i, a);
|
|
259
254
|
}, [m, h, g] = await Promise.all([
|
|
260
|
-
Promise.all(l.map(async ([e, t]) =>
|
|
255
|
+
Promise.all(l.map(async ([e, t]) => ue(await Promise.all(t.map((t) => p(e, t))), o[e] === "any" ? "or" : "and", n, r, i, a))),
|
|
261
256
|
Promise.all(u.map(([e, t]) => f(e, t))),
|
|
262
|
-
Promise.all(d.map(async ([e, t]) =>
|
|
257
|
+
Promise.all(d.map(async ([e, t]) => ue(await Promise.all(t.map((t) => f(e, t))), "or", n, r, i, a)))
|
|
263
258
|
]);
|
|
264
|
-
return
|
|
259
|
+
return ue([
|
|
265
260
|
...m,
|
|
266
261
|
...h,
|
|
267
262
|
...g
|
|
268
263
|
], "and", n, r, i, a);
|
|
269
264
|
}
|
|
270
265
|
// src/context/useSearchExecution.ts
|
|
271
|
-
function
|
|
266
|
+
function fe(e, t) {
|
|
272
267
|
let n, r = (...r) => {
|
|
273
268
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
274
269
|
};
|
|
275
270
|
return r.cancel = () => clearTimeout(n), r;
|
|
276
271
|
}
|
|
277
|
-
function
|
|
272
|
+
function pe({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, team: s, dataset: u, allowEmptySearch: d, facetsEnabled: f, enableDebugLogs: p, shouldFetchMore: m, sessionId: h, source: g, locale: _, count: v, searchTextOf: y }) {
|
|
278
273
|
let b = y ? y(e.query) : e.query, x = c(e.query);
|
|
279
274
|
x.current = e.query;
|
|
280
275
|
let S = c(0), C = c(void 0), w = c(!1), [T, E] = l({}), [D, O] = l(""), [k, A] = l("");
|
|
@@ -299,7 +294,7 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
299
294
|
r.sortableFields,
|
|
300
295
|
t
|
|
301
296
|
]);
|
|
302
|
-
let j = e.searchSettings.maxNumberOfRecordsToReturn, M = e.searchSettings.
|
|
297
|
+
let j = e.searchSettings.maxNumberOfRecordsToReturn, M = e.searchSettings.mode, N = e.searchSettings.refocus, P = e.searchSettings.match, F = e.searchSettings.candidates, I = e.searchSettings.ranking, L = e.searchSettings.minimumScore, R = e.sortBy, z = e.sortAscending, B = i(async ({ enableFacets: i }) => {
|
|
303
298
|
if (!r.token) return;
|
|
304
299
|
let o = b.trim() === "";
|
|
305
300
|
if (o && !d) return;
|
|
@@ -309,7 +304,7 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
309
304
|
isLoading: !0
|
|
310
305
|
})), o && (i = !0);
|
|
311
306
|
try {
|
|
312
|
-
let o = i ? Array.from(/* @__PURE__ */ new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([
|
|
307
|
+
let o = i ? Array.from(/* @__PURE__ */ new Set([...Object.keys(e.filters).filter((t) => e.valueMatch[t] === "any" && (e.filters[t]?.length ?? 0) > 0), ...Object.keys(e.bucketFilters).filter((t) => (e.bucketFilters[t]?.length ?? 0) > 0)])) : [], [l, ...f] = await Promise.all([de(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch, e.bucketFilters, e.fieldTypes), ...o.map((t) => de({
|
|
313
308
|
...e.filters,
|
|
314
309
|
[t]: []
|
|
315
310
|
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
@@ -317,112 +312,124 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
317
312
|
[t]: []
|
|
318
313
|
}, e.fieldTypes))]), m = d || b.trim() !== "", y = {
|
|
319
314
|
text: b,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
315
|
+
mode: M,
|
|
316
|
+
match: P,
|
|
317
|
+
candidates: F,
|
|
318
|
+
ranking: I
|
|
324
319
|
}, C = {
|
|
325
320
|
...y,
|
|
326
321
|
maxNumberOfRecordsToReturn: m ? j : 0,
|
|
327
322
|
enableFacets: i,
|
|
323
|
+
...m ? { includeDocuments: !0 } : {},
|
|
328
324
|
...l ? { filter: l } : {},
|
|
329
|
-
...
|
|
330
|
-
...
|
|
325
|
+
...R ? { sortBy: R } : {},
|
|
326
|
+
...z === void 0 ? {} : { sortAscending: z }
|
|
331
327
|
};
|
|
332
328
|
p && console.log("[performSearch] request body:", JSON.stringify(C, null, 2));
|
|
333
329
|
let w = new URLSearchParams({ session: h });
|
|
334
330
|
g && w.set("source", g);
|
|
335
|
-
let
|
|
336
|
-
|
|
337
|
-
let
|
|
331
|
+
let B = _ ?? me();
|
|
332
|
+
B && w.set("locale", B), v || w.set("count", "false"), N && w.set("refocus", "true"), x.current.trim() !== b.trim() && w.set("typed", x.current);
|
|
333
|
+
let V = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?${w}`, {
|
|
338
334
|
method: "POST",
|
|
339
335
|
headers: { "Content-Type": "application/json" },
|
|
340
336
|
body: JSON.stringify(e)
|
|
341
|
-
}), [
|
|
337
|
+
}), [H, ...U] = await Promise.all([V(C), ...f.map((e) => V({
|
|
342
338
|
...y,
|
|
343
339
|
maxNumberOfRecordsToReturn: 0,
|
|
344
340
|
enableFacets: !0,
|
|
345
341
|
...e ? { filter: e } : {}
|
|
346
342
|
}))]);
|
|
347
|
-
if (!
|
|
348
|
-
let
|
|
343
|
+
if (!H.ok) throw await Z.fromResponse("Search", H);
|
|
344
|
+
let W = await H.json(), G = H.headers.get("Indx-Query-Id") ?? void 0, K = W.isFallback ? void 0 : W.count, ee = W.isFallback === !0, q = W.toleranceCounts ?? null, te = W.countedTolerance ?? null, ne = W.ranked, J = W.reranked, Y = W.fill ?? null, X = {};
|
|
349
345
|
for (let e = 0; e < o.length; e++) {
|
|
350
346
|
let t = o[e];
|
|
351
|
-
if (!
|
|
352
|
-
let n = await
|
|
353
|
-
n.facets?.[t] !== void 0 && (
|
|
347
|
+
if (!U[e].ok) throw await Z.fromResponse(`Facets for '${t}'`, U[e]);
|
|
348
|
+
let n = await U[e].json();
|
|
349
|
+
n.facets?.[t] !== void 0 && (X[t] = n.facets[t]);
|
|
354
350
|
}
|
|
355
|
-
let
|
|
356
|
-
if (m &&
|
|
357
|
-
let e
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
351
|
+
let re = W.records || [], ie = re.map((e) => e.documentKey), ae = re.map((e) => e.score), oe = [];
|
|
352
|
+
if (m && ie.length > 0) {
|
|
353
|
+
let e;
|
|
354
|
+
if (Array.isArray(W.documents) && W.documents.length === ie.length) e = W.documents;
|
|
355
|
+
else {
|
|
356
|
+
let t = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
357
|
+
method: "POST",
|
|
358
|
+
headers: { "Content-Type": "application/json" },
|
|
359
|
+
body: JSON.stringify(ie)
|
|
360
|
+
});
|
|
361
|
+
if (!t.ok) throw await Z.fromResponse("Document lookup", t);
|
|
362
|
+
e = await t.json();
|
|
363
|
+
}
|
|
364
|
+
oe = e.map((e, t) => ({
|
|
364
365
|
document: e,
|
|
365
|
-
documentKey:
|
|
366
|
-
score:
|
|
366
|
+
documentKey: ie[t],
|
|
367
|
+
score: ae[t]
|
|
367
368
|
}));
|
|
368
369
|
}
|
|
369
|
-
let
|
|
370
|
-
if (i &&
|
|
371
|
-
for (let [e, t] of Object.entries(
|
|
370
|
+
let se = {};
|
|
371
|
+
if (i && W.facets) {
|
|
372
|
+
for (let [e, t] of Object.entries(W.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
372
373
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
373
|
-
n.length > 0 && (
|
|
374
|
+
n.length > 0 && (se[e] = {
|
|
374
375
|
min: Math.min(...n),
|
|
375
376
|
max: Math.max(...n)
|
|
376
377
|
});
|
|
377
378
|
}
|
|
378
379
|
}
|
|
379
380
|
if (c !== S.current) return;
|
|
380
|
-
let
|
|
381
|
-
if (
|
|
381
|
+
let ce = b !== D, le = b !== k, ue = e.facetStats ?? {};
|
|
382
|
+
if (ce ? (ue = {
|
|
382
383
|
...r.initialFacetStats,
|
|
383
|
-
...
|
|
384
|
-
}, E(
|
|
384
|
+
...se
|
|
385
|
+
}, E(ue), O(b)) : ue = {
|
|
385
386
|
...T,
|
|
386
|
-
...
|
|
387
|
-
},
|
|
387
|
+
...se
|
|
388
|
+
}, le && i) {
|
|
388
389
|
let n = { ...e.rangeBounds };
|
|
389
|
-
for (let [e, t] of Object.entries(
|
|
390
|
+
for (let [e, t] of Object.entries(se)) n[e] = t;
|
|
390
391
|
t((e) => ({
|
|
391
392
|
...e,
|
|
392
393
|
rangeBounds: n
|
|
393
394
|
})), A(b);
|
|
394
395
|
}
|
|
395
|
-
let
|
|
396
|
-
...
|
|
397
|
-
...
|
|
398
|
-
} :
|
|
399
|
-
if (i && (!
|
|
400
|
-
|
|
401
|
-
for (let [e, t] of Object.entries(r.initialFacetKeys))
|
|
396
|
+
let fe = Object.keys(X).length > 0 ? {
|
|
397
|
+
...W.facets ?? {},
|
|
398
|
+
...X
|
|
399
|
+
} : W.facets;
|
|
400
|
+
if (i && (!fe || Object.keys(fe).length === 0)) {
|
|
401
|
+
fe = {};
|
|
402
|
+
for (let [e, t] of Object.entries(r.initialFacetKeys)) fe[e] = t.map((e) => ({
|
|
402
403
|
key: e,
|
|
403
404
|
value: null
|
|
404
405
|
}));
|
|
405
406
|
}
|
|
406
|
-
let
|
|
407
|
+
let pe = oe.filter((e) => {
|
|
407
408
|
let t = b.trim();
|
|
408
|
-
return t === "" || t.length === 1 || e.score >=
|
|
409
|
+
return t === "" || t.length === 1 || e.score >= L;
|
|
409
410
|
}).map((e, t) => ({
|
|
410
411
|
...e,
|
|
411
412
|
position: t + 1
|
|
412
413
|
}));
|
|
413
414
|
t((e) => ({
|
|
414
415
|
...e,
|
|
415
|
-
results:
|
|
416
|
+
results: pe,
|
|
416
417
|
error: void 0,
|
|
417
418
|
errorInfo: void 0,
|
|
418
419
|
resultsSuppressed: !m,
|
|
419
420
|
...i ? {
|
|
420
|
-
facets:
|
|
421
|
-
facetStats:
|
|
421
|
+
facets: fe,
|
|
422
|
+
facetStats: ue
|
|
422
423
|
} : {},
|
|
423
424
|
isLoading: !1,
|
|
424
|
-
|
|
425
|
-
|
|
425
|
+
countedTotal: K,
|
|
426
|
+
isFallback: ee,
|
|
427
|
+
toleranceCounts: q,
|
|
428
|
+
countedTolerance: te,
|
|
429
|
+
ranked: ne,
|
|
430
|
+
reranked: J,
|
|
431
|
+
fill: Y,
|
|
432
|
+
queryId: G
|
|
426
433
|
}));
|
|
427
434
|
} catch (e) {
|
|
428
435
|
if (console.error("[Search] β Search failed:", e), e instanceof TypeError && e.message.includes("fetch") ? (console.error("[Search] β Network error - cannot reach INDX server"), console.error("[Search] π‘ Check if server is running at:", a)) : e instanceof Error && (e.message.includes("401") ? (console.error("[Search] β Authentication failed"), console.error("[Search] π‘ Your token may have expired. Create or refresh it on the Indx Dashboard.")) : e.message.includes("404") ? (console.error("[Search] β Dataset not found"), console.error("[Search] π‘ Check that dataset \"" + u + "\" exists")) : console.error("[Search] π‘ Error:", e.message)), c !== S.current) return;
|
|
@@ -432,7 +439,7 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
432
439
|
isLoading: !1,
|
|
433
440
|
resultsSuppressed: !1,
|
|
434
441
|
error: e instanceof Error ? e.message : "Search failed",
|
|
435
|
-
errorInfo:
|
|
442
|
+
errorInfo: se(e, {
|
|
436
443
|
team: s,
|
|
437
444
|
dataset: u
|
|
438
445
|
})
|
|
@@ -445,14 +452,15 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
445
452
|
e.rangeFilters,
|
|
446
453
|
e.bucketFilters,
|
|
447
454
|
e.facetStats,
|
|
448
|
-
L,
|
|
449
455
|
R,
|
|
456
|
+
z,
|
|
450
457
|
j,
|
|
451
458
|
M,
|
|
452
459
|
N,
|
|
453
460
|
P,
|
|
454
|
-
I,
|
|
455
461
|
F,
|
|
462
|
+
I,
|
|
463
|
+
L,
|
|
456
464
|
n,
|
|
457
465
|
r.initialFacetStats,
|
|
458
466
|
r.initialFacetKeys,
|
|
@@ -473,13 +481,13 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
473
481
|
v
|
|
474
482
|
]);
|
|
475
483
|
o(() => {
|
|
476
|
-
C.current =
|
|
477
|
-
}, [
|
|
478
|
-
let
|
|
479
|
-
o(() => (
|
|
484
|
+
C.current = B;
|
|
485
|
+
}, [B]);
|
|
486
|
+
let V = c(null);
|
|
487
|
+
o(() => (V.current?.cancel(), V.current = fe(() => {
|
|
480
488
|
p && console.log("Debounced searchWithFacets fired"), C.current?.({ enableFacets: !0 });
|
|
481
489
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
482
|
-
|
|
490
|
+
V.current?.cancel();
|
|
483
491
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
484
492
|
!r.isFetchingInitial && r.token && !w.current && ((d || b.trim() !== "") && C.current?.({ enableFacets: f }), w.current = !0);
|
|
485
493
|
}, [
|
|
@@ -490,13 +498,13 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
490
498
|
]), o(() => {
|
|
491
499
|
if (!r.token || !w.current) return;
|
|
492
500
|
let e = b.trim(), n = e === "" && d;
|
|
493
|
-
if (e === "" && !d) S.current++,
|
|
501
|
+
if (e === "" && !d) S.current++, V.current?.cancel(), t((e) => e.resultsSuppressed && !e.isLoading ? e : {
|
|
494
502
|
...e,
|
|
495
503
|
resultsSuppressed: !0,
|
|
496
504
|
isLoading: !1
|
|
497
505
|
});
|
|
498
|
-
else return n ? (
|
|
499
|
-
|
|
506
|
+
else return n ? (V.current?.cancel(), C.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), C.current?.({ enableFacets: !1 }), V.current?.()) : C.current?.({ enableFacets: !1 }), () => {
|
|
507
|
+
V.current?.cancel();
|
|
500
508
|
};
|
|
501
509
|
}, [
|
|
502
510
|
b,
|
|
@@ -510,14 +518,14 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
510
518
|
if (!w.current || !r.token) return;
|
|
511
519
|
let e = b.trim();
|
|
512
520
|
(d || e !== "") && C.current?.({ enableFacets: f });
|
|
513
|
-
}, [
|
|
514
|
-
let
|
|
521
|
+
}, [R, z]);
|
|
522
|
+
let H = c(!0), U = c(b);
|
|
515
523
|
return o(() => {
|
|
516
|
-
if (
|
|
517
|
-
|
|
524
|
+
if (H.current) {
|
|
525
|
+
H.current = !1;
|
|
518
526
|
return;
|
|
519
527
|
}
|
|
520
|
-
if (
|
|
528
|
+
if (U.current !== b || !w.current || !r.token) return;
|
|
521
529
|
if (m.current) {
|
|
522
530
|
m.current = !1, C.current?.({ enableFacets: !1 });
|
|
523
531
|
return;
|
|
@@ -529,32 +537,26 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
529
537
|
M,
|
|
530
538
|
N,
|
|
531
539
|
P,
|
|
540
|
+
F,
|
|
532
541
|
I,
|
|
533
|
-
|
|
542
|
+
L
|
|
534
543
|
]), o(() => {
|
|
535
|
-
|
|
544
|
+
U.current = b;
|
|
536
545
|
}, [b]), { retrySearch: i(() => {
|
|
537
546
|
C.current?.({ enableFacets: f });
|
|
538
547
|
}, [f]) };
|
|
539
548
|
}
|
|
540
|
-
function
|
|
549
|
+
function me() {
|
|
541
550
|
if (typeof document < "u" && document.documentElement.lang) return document.documentElement.lang;
|
|
542
551
|
if (typeof navigator < "u" && navigator.language) return navigator.language;
|
|
543
552
|
}
|
|
544
553
|
// src/context/SearchContext.tsx
|
|
545
|
-
function
|
|
554
|
+
function he() {
|
|
546
555
|
let e = globalThis.crypto;
|
|
547
556
|
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
548
557
|
}
|
|
549
|
-
var
|
|
550
|
-
let C = c(!1), w = c(
|
|
551
|
-
let t = S ?? T.fn;
|
|
552
|
-
return !t || e === D ? e : t(e);
|
|
553
|
-
}, [
|
|
554
|
-
S,
|
|
555
|
-
T,
|
|
556
|
-
D
|
|
557
|
-
]), A = i((e) => E({ fn: e }), []), j = c(s), [M, N] = l({
|
|
558
|
+
var ge = "Type to search", _e = n(void 0), ve = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, mode: f, match: p = {}, candidates: m = {}, ranking: g = {}, enableDebugLogs: _ = !1, preAuthenticatedToken: v, source: y, locale: b, count: x = !0, searchTextOf: S }) => {
|
|
559
|
+
let C = c(!1), w = c(he()).current, [T, E] = l(null), [D, O] = l(null), k = i((e) => !S || e === T ? e : S(e), [S, T]), A = c(s), [j, M] = l({
|
|
558
560
|
query: "",
|
|
559
561
|
results: null,
|
|
560
562
|
isLoading: !1,
|
|
@@ -574,48 +576,48 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
574
576
|
rangeBounds: {},
|
|
575
577
|
searchSettings: {
|
|
576
578
|
maxNumberOfRecordsToReturn: s,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
579
|
+
mode: f,
|
|
580
|
+
match: p,
|
|
581
|
+
candidates: m,
|
|
582
|
+
ranking: g,
|
|
580
583
|
minimumScore: 0,
|
|
581
584
|
showScore: !0,
|
|
582
|
-
placeholderText:
|
|
583
|
-
coverageSetup: { ...g }
|
|
585
|
+
placeholderText: ge
|
|
584
586
|
}
|
|
585
587
|
});
|
|
586
588
|
o(() => {
|
|
587
589
|
_ && console.log("SearchContext mounted on client");
|
|
588
590
|
}, [_]), o(() => {
|
|
589
|
-
|
|
591
|
+
M((e) => ({
|
|
590
592
|
...e,
|
|
591
593
|
facetDebounceDelayMillis: u
|
|
592
594
|
}));
|
|
593
595
|
}, [u]);
|
|
594
|
-
let [
|
|
596
|
+
let [N] = l(d), P = ce({
|
|
595
597
|
url: t,
|
|
596
598
|
team: n,
|
|
597
599
|
dataset: r,
|
|
598
600
|
preAuthenticatedToken: v,
|
|
599
601
|
enableDebugLogs: _
|
|
600
|
-
}),
|
|
601
|
-
if (!
|
|
602
|
+
}), F = i((e, t = {}) => {
|
|
603
|
+
if (!P.token) throw Error("No authentication token available");
|
|
602
604
|
return fetch(e, {
|
|
603
605
|
...t,
|
|
604
606
|
headers: {
|
|
605
607
|
...t.headers,
|
|
606
|
-
Authorization: `Bearer ${
|
|
608
|
+
Authorization: `Bearer ${P.token}`
|
|
607
609
|
}
|
|
608
610
|
});
|
|
609
|
-
}, [
|
|
610
|
-
state:
|
|
611
|
-
setState:
|
|
612
|
-
authenticatedFetch:
|
|
613
|
-
auth:
|
|
611
|
+
}, [P.token]), { retrySearch: I } = pe({
|
|
612
|
+
state: j,
|
|
613
|
+
setState: M,
|
|
614
|
+
authenticatedFetch: F,
|
|
615
|
+
auth: P,
|
|
614
616
|
url: t,
|
|
615
617
|
team: n,
|
|
616
618
|
dataset: r,
|
|
617
619
|
allowEmptySearch: a,
|
|
618
|
-
facetsEnabled:
|
|
620
|
+
facetsEnabled: N,
|
|
619
621
|
enableDebugLogs: _,
|
|
620
622
|
shouldFetchMore: C,
|
|
621
623
|
sessionId: w,
|
|
@@ -623,17 +625,17 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
623
625
|
locale: b,
|
|
624
626
|
count: x,
|
|
625
627
|
searchTextOf: k
|
|
626
|
-
}),
|
|
627
|
-
|
|
628
|
-
let
|
|
629
|
-
if (
|
|
630
|
-
|
|
628
|
+
}), L = c(void 0);
|
|
629
|
+
L.current = j.queryId;
|
|
630
|
+
let R = c(/* @__PURE__ */ new Map()), z = i(async (e) => {
|
|
631
|
+
if (P.token) {
|
|
632
|
+
R.current.set(e.documentKey, L.current);
|
|
631
633
|
try {
|
|
632
|
-
let i = await
|
|
634
|
+
let i = await F(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
|
|
633
635
|
method: "POST",
|
|
634
636
|
headers: { "Content-Type": "application/json" },
|
|
635
637
|
body: JSON.stringify({
|
|
636
|
-
queryId:
|
|
638
|
+
queryId: L.current,
|
|
637
639
|
documentKey: e.documentKey,
|
|
638
640
|
position: e.position,
|
|
639
641
|
...x ? {} : { count: !1 }
|
|
@@ -645,18 +647,18 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
645
647
|
}
|
|
646
648
|
}
|
|
647
649
|
}, [
|
|
648
|
-
|
|
649
|
-
|
|
650
|
+
P.token,
|
|
651
|
+
F,
|
|
650
652
|
t,
|
|
651
653
|
n,
|
|
652
654
|
r,
|
|
653
655
|
_,
|
|
654
656
|
x
|
|
655
|
-
]),
|
|
656
|
-
if (!
|
|
657
|
-
let o = a?.queryId ??
|
|
657
|
+
]), B = i(async (e, i, a) => {
|
|
658
|
+
if (!P.token || !i.trim()) return;
|
|
659
|
+
let o = a?.queryId ?? R.current.get(e) ?? L.current;
|
|
658
660
|
try {
|
|
659
|
-
let s = await
|
|
661
|
+
let s = await F(`${t}/api/teams/${n}/datasets/${r}/events/convert`, {
|
|
660
662
|
method: "POST",
|
|
661
663
|
headers: { "Content-Type": "application/json" },
|
|
662
664
|
body: JSON.stringify({
|
|
@@ -672,15 +674,15 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
672
674
|
_ && console.warn("[convert] failed:", e);
|
|
673
675
|
}
|
|
674
676
|
}, [
|
|
675
|
-
|
|
676
|
-
|
|
677
|
+
P.token,
|
|
678
|
+
F,
|
|
677
679
|
t,
|
|
678
680
|
n,
|
|
679
681
|
r,
|
|
680
682
|
_,
|
|
681
683
|
x
|
|
682
|
-
]),
|
|
683
|
-
|
|
684
|
+
]), V = i((e) => {
|
|
685
|
+
M((t) => {
|
|
684
686
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
|
|
685
687
|
return {
|
|
686
688
|
...t,
|
|
@@ -690,31 +692,31 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
690
692
|
bucketFilters: i ? {} : t.bucketFilters,
|
|
691
693
|
searchSettings: {
|
|
692
694
|
...t.searchSettings,
|
|
693
|
-
maxNumberOfRecordsToReturn:
|
|
695
|
+
maxNumberOfRecordsToReturn: A.current
|
|
694
696
|
}
|
|
695
697
|
};
|
|
696
698
|
});
|
|
697
|
-
}, []),
|
|
698
|
-
|
|
699
|
+
}, []), H = i((e) => {
|
|
700
|
+
M((t) => ({
|
|
699
701
|
...t,
|
|
700
702
|
facetDebounceDelayMillis: e
|
|
701
703
|
}));
|
|
702
|
-
}, []),
|
|
703
|
-
typeof e.maxNumberOfRecordsToReturn == "number" && (
|
|
704
|
+
}, []), U = i((e) => {
|
|
705
|
+
typeof e.maxNumberOfRecordsToReturn == "number" && (A.current = e.maxNumberOfRecordsToReturn), M((t) => {
|
|
704
706
|
let n = {
|
|
705
707
|
...t.searchSettings,
|
|
706
708
|
...e
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
...
|
|
710
|
-
|
|
711
|
-
|
|
709
|
+
}, r = (n) => n in e ? e[n] === void 0 ? {} : {
|
|
710
|
+
...t.searchSettings[n],
|
|
711
|
+
...e[n]
|
|
712
|
+
} : t.searchSettings[n];
|
|
713
|
+
return n.match = r("match"), n.candidates = r("candidates"), n.ranking = r("ranking"), {
|
|
712
714
|
...t,
|
|
713
715
|
searchSettings: n
|
|
714
716
|
};
|
|
715
717
|
});
|
|
716
|
-
}, []),
|
|
717
|
-
C.current = !0,
|
|
718
|
+
}, []), W = i((e) => {
|
|
719
|
+
C.current = !0, M((t) => ({
|
|
718
720
|
...t,
|
|
719
721
|
searchSettings: {
|
|
720
722
|
...t.searchSettings,
|
|
@@ -722,7 +724,7 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
722
724
|
}
|
|
723
725
|
}));
|
|
724
726
|
}, []), G = i((e, t, n = !1) => {
|
|
725
|
-
|
|
727
|
+
M((r) => {
|
|
726
728
|
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
727
729
|
return o.length ? i[e] = o : delete i[e], {
|
|
728
730
|
...r,
|
|
@@ -730,16 +732,16 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
730
732
|
filterRevision: r.filterRevision + 1
|
|
731
733
|
};
|
|
732
734
|
});
|
|
733
|
-
}, []),
|
|
734
|
-
|
|
735
|
+
}, []), K = i((e, t) => {
|
|
736
|
+
M((n) => n.valueMatch[e] === t ? n : {
|
|
735
737
|
...n,
|
|
736
738
|
valueMatch: {
|
|
737
739
|
...n.valueMatch,
|
|
738
740
|
[e]: t
|
|
739
741
|
}
|
|
740
742
|
});
|
|
741
|
-
}, []),
|
|
742
|
-
|
|
743
|
+
}, []), ee = i((e, t, n) => {
|
|
744
|
+
M((r) => ({
|
|
743
745
|
...r,
|
|
744
746
|
rangeFilters: {
|
|
745
747
|
...r.rangeFilters,
|
|
@@ -750,16 +752,16 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
750
752
|
},
|
|
751
753
|
filterRevision: r.filterRevision + 1
|
|
752
754
|
}));
|
|
753
|
-
}, []),
|
|
754
|
-
|
|
755
|
+
}, []), q = i(() => {
|
|
756
|
+
M((e) => ({
|
|
755
757
|
...e,
|
|
756
758
|
filters: {},
|
|
757
759
|
rangeFilters: {},
|
|
758
760
|
bucketFilters: {},
|
|
759
761
|
filterRevision: e.filterRevision + 1
|
|
760
762
|
}));
|
|
761
|
-
}, []),
|
|
762
|
-
|
|
763
|
+
}, []), te = i((e, t, n = !0) => {
|
|
764
|
+
M((r) => {
|
|
763
765
|
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
764
766
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
765
767
|
...r,
|
|
@@ -767,8 +769,8 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
767
769
|
filterRevision: r.filterRevision + +!!n
|
|
768
770
|
};
|
|
769
771
|
});
|
|
770
|
-
}, []),
|
|
771
|
-
|
|
772
|
+
}, []), ne = i((e, t = !0) => {
|
|
773
|
+
M((n) => {
|
|
772
774
|
if (!(e in n.rangeFilters)) return n;
|
|
773
775
|
let r = { ...n.rangeFilters };
|
|
774
776
|
return delete r[e], {
|
|
@@ -777,122 +779,117 @@ var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n,
|
|
|
777
779
|
filterRevision: n.filterRevision + +!!t
|
|
778
780
|
};
|
|
779
781
|
});
|
|
780
|
-
}, []),
|
|
781
|
-
|
|
782
|
-
let i = r.bucketFilters[e] ?? [], a = i.some((e) =>
|
|
782
|
+
}, []), J = (e, t) => e.min === t.min && e.max === t.max, Y = i((e, t, n = !1) => {
|
|
783
|
+
M((r) => {
|
|
784
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => J(e, t)) ? i.filter((e) => !J(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
783
785
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
784
786
|
...r,
|
|
785
787
|
bucketFilters: o,
|
|
786
788
|
filterRevision: r.filterRevision + 1
|
|
787
789
|
};
|
|
788
790
|
});
|
|
789
|
-
}, []),
|
|
790
|
-
|
|
791
|
-
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !
|
|
791
|
+
}, []), X = i((e, t, n = !0) => {
|
|
792
|
+
M((r) => {
|
|
793
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !J(e, t)) : [];
|
|
792
794
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
793
795
|
...r,
|
|
794
796
|
bucketFilters: i,
|
|
795
797
|
filterRevision: r.filterRevision + +!!n
|
|
796
798
|
};
|
|
797
799
|
});
|
|
798
|
-
}, []),
|
|
799
|
-
|
|
800
|
+
}, []), re = i((e, t) => {
|
|
801
|
+
M((n) => ({
|
|
800
802
|
...n,
|
|
801
803
|
sortBy: e || void 0,
|
|
802
804
|
sortAscending: e ? t : void 0
|
|
803
805
|
}));
|
|
804
806
|
}, []);
|
|
805
|
-
return /* @__PURE__ */
|
|
807
|
+
return /* @__PURE__ */ h(_e.Provider, {
|
|
806
808
|
value: {
|
|
807
|
-
state:
|
|
808
|
-
isFetchingInitial:
|
|
809
|
-
authError:
|
|
810
|
-
authErrorInfo:
|
|
811
|
-
retry:
|
|
809
|
+
state: j,
|
|
810
|
+
isFetchingInitial: P.isFetchingInitial || !j.fieldsSeeded,
|
|
811
|
+
authError: P.authError ?? void 0,
|
|
812
|
+
authErrorInfo: P.authErrorInfo ?? void 0,
|
|
813
|
+
retry: P.authError ? P.retry : I,
|
|
812
814
|
allowEmptySearch: a,
|
|
813
|
-
facetsEnabled:
|
|
814
|
-
datasetBounds:
|
|
815
|
+
facetsEnabled: N,
|
|
816
|
+
datasetBounds: P.initialFacetStats,
|
|
815
817
|
url: t,
|
|
816
818
|
team: n,
|
|
817
819
|
dataset: r,
|
|
818
|
-
authenticatedFetch:
|
|
819
|
-
setQuery:
|
|
820
|
+
authenticatedFetch: F,
|
|
821
|
+
setQuery: V,
|
|
820
822
|
toggleFilter: G,
|
|
821
|
-
setValueMatch:
|
|
822
|
-
setRangeFilter:
|
|
823
|
-
resetFilters:
|
|
824
|
-
resetSingleFilter:
|
|
825
|
-
resetRangeFilter:
|
|
826
|
-
toggleBucketFilter:
|
|
827
|
-
resetBucketFilter:
|
|
828
|
-
setSort:
|
|
829
|
-
setDebounceDelay:
|
|
830
|
-
setSearchSettings:
|
|
831
|
-
fetchMoreResults:
|
|
832
|
-
selectResult:
|
|
833
|
-
convertResult:
|
|
823
|
+
setValueMatch: K,
|
|
824
|
+
setRangeFilter: ee,
|
|
825
|
+
resetFilters: q,
|
|
826
|
+
resetSingleFilter: te,
|
|
827
|
+
resetRangeFilter: ne,
|
|
828
|
+
toggleBucketFilter: Y,
|
|
829
|
+
resetBucketFilter: X,
|
|
830
|
+
setSort: re,
|
|
831
|
+
setDebounceDelay: H,
|
|
832
|
+
setSearchSettings: U,
|
|
833
|
+
fetchMoreResults: W,
|
|
834
|
+
selectResult: z,
|
|
835
|
+
convertResult: B,
|
|
834
836
|
sessionId: w,
|
|
835
837
|
source: y,
|
|
836
838
|
count: x,
|
|
837
|
-
searchText: k(
|
|
838
|
-
|
|
839
|
-
|
|
839
|
+
searchText: k(j.query),
|
|
840
|
+
picks: D && D.query === j.query ? D.picks : null,
|
|
841
|
+
showPicks: (e) => O(e ? {
|
|
842
|
+
picks: e,
|
|
843
|
+
query: j.query
|
|
844
|
+
} : null),
|
|
845
|
+
searchAsTyped: () => E(j.query)
|
|
840
846
|
},
|
|
841
847
|
children: e
|
|
842
848
|
});
|
|
843
|
-
},
|
|
844
|
-
let e = a(
|
|
849
|
+
}, ye = () => {
|
|
850
|
+
let e = a(_e);
|
|
845
851
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
846
852
|
return e;
|
|
847
853
|
};
|
|
848
854
|
// src/utils/searchOrAsk.ts
|
|
849
|
-
function
|
|
855
|
+
function be(e, t) {
|
|
850
856
|
return t ? t === "proactive" && e !== "proactive" ? "inviting" : t : e;
|
|
851
857
|
}
|
|
852
|
-
var
|
|
858
|
+
var xe = {
|
|
853
859
|
strong: .65,
|
|
854
860
|
strongHide: .45,
|
|
855
861
|
invite: .4,
|
|
856
862
|
inviteHide: .3,
|
|
857
863
|
hint: .31,
|
|
858
|
-
finished: .5
|
|
859
|
-
|
|
860
|
-
|
|
864
|
+
finished: .5,
|
|
865
|
+
found: .3,
|
|
866
|
+
refocus: 0
|
|
867
|
+
}, Se = /^[\d\s\-_.:/]+$|^\w+\.\w+|^[A-Za-z]*[a-z][A-Z]\w*$|^[A-Za-z]+[-_]?\d[\w-]*$/;
|
|
868
|
+
function Ce(e) {
|
|
861
869
|
let t = e.trim();
|
|
862
|
-
return t.length > 0 && !t.includes(" ") &&
|
|
870
|
+
return t.length > 0 && !t.includes(" ") && Se.test(t);
|
|
863
871
|
}
|
|
864
|
-
function
|
|
872
|
+
function we(e) {
|
|
865
873
|
let t = e.trim();
|
|
866
|
-
return !!t && !
|
|
874
|
+
return !!t && !Ce(t) && (t.endsWith("?") || t.split(/\s+/).length >= 3);
|
|
867
875
|
}
|
|
868
|
-
function
|
|
876
|
+
function Te(e, t = 4) {
|
|
869
877
|
let n = e.trim();
|
|
870
|
-
return !n ||
|
|
878
|
+
return !n || Ce(n) ? !1 : we(n) || n.length >= t;
|
|
871
879
|
}
|
|
872
|
-
function
|
|
880
|
+
function Ee(e, t, n = xe) {
|
|
873
881
|
return t >= n.strong || e === "strong" && t >= n.strongHide ? "strong" : t >= n.invite || e !== "none" && t >= n.inviteHide ? "invite" : "none";
|
|
874
882
|
}
|
|
875
|
-
var
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
coverJoinedWords: !1,
|
|
882
|
-
minWordSize: 3
|
|
883
|
-
}, De = 65535;
|
|
884
|
-
function Oe(e, t, n, r = Te) {
|
|
885
|
-
if (!n || e.length === 0) return e;
|
|
886
|
-
let i = e[0].score;
|
|
887
|
-
if (i < r.topFloor * 65535) return [];
|
|
888
|
-
let a = t == null ? e : t < 0 ? [] : e.slice(0, t + 1), o = r.shareOfTop * i, s = a.findIndex((e) => e.score < o);
|
|
889
|
-
return s < 0 ? a : a.slice(0, s);
|
|
890
|
-
}
|
|
891
|
-
function ke(e) {
|
|
883
|
+
var De = {
|
|
884
|
+
tolerance: p.Exact,
|
|
885
|
+
typingPrefixFrom: 0,
|
|
886
|
+
joinedWords: !1
|
|
887
|
+
};
|
|
888
|
+
function Oe(e) {
|
|
892
889
|
let t = e.trim();
|
|
893
890
|
return t.includes(" ") || t.endsWith("?");
|
|
894
891
|
}
|
|
895
|
-
async function*
|
|
892
|
+
async function* ke(e) {
|
|
896
893
|
let t = e.getReader(), n = new TextDecoder(), r = "";
|
|
897
894
|
try {
|
|
898
895
|
for (;;) {
|
|
@@ -915,68 +912,24 @@ async function* Ae(e) {
|
|
|
915
912
|
t.releaseLock();
|
|
916
913
|
}
|
|
917
914
|
}
|
|
918
|
-
function
|
|
915
|
+
function Ae(e) {
|
|
919
916
|
let t = new URLSearchParams();
|
|
920
917
|
e.state.queryId && t.set("queryId", e.state.queryId), e.sessionId && t.set("session", e.sessionId), e.source && t.set("source", e.source), e.count === !1 && t.set("count", "false");
|
|
921
918
|
let n = t.toString();
|
|
922
919
|
return n ? `?${n}` : "";
|
|
923
920
|
}
|
|
924
|
-
// src/utils/askPhrases.ts
|
|
925
|
-
var Me = (e) => e.toLowerCase().replace(/β/g, "'").split(/\s+/).filter(Boolean), Ne = /[?!.,]+$/, Pe = 2;
|
|
926
|
-
function Fe(e, t) {
|
|
927
|
-
let n = 0;
|
|
928
|
-
for (let r of t) {
|
|
929
|
-
let t = Me(r);
|
|
930
|
-
t.length > n && t.length <= e.length && t.every((n, r) => e[e.length - t.length + r].replace(Ne, "") === n) && (n = t.length);
|
|
931
|
-
}
|
|
932
|
-
return n;
|
|
933
|
-
}
|
|
934
|
-
function Ie(e, t, n) {
|
|
935
|
-
let r = 0;
|
|
936
|
-
for (let i of n) {
|
|
937
|
-
let n = Me(i);
|
|
938
|
-
n.length > r && t + n.length <= e.length && n.every((n, r) => e[t + r].replace(Ne, "") === n) && (r = n.length);
|
|
939
|
-
}
|
|
940
|
-
return r;
|
|
941
|
-
}
|
|
942
|
-
function Le(e, t) {
|
|
943
|
-
let n = e.trim().split(/\s+/).filter(Boolean), r = Me(e), i = 0, a = [], o = (e) => {
|
|
944
|
-
let t = Ie(r, i, e);
|
|
945
|
-
return t && (a.push(n.slice(i, i + t).join(" ")), i += t), t > 0;
|
|
946
|
-
}, s = Ie(r, 0, t.leadIns), c = o(t.leadIns), l = o(t.frames), u = o(t.links);
|
|
947
|
-
if (!(c && (s > 1 || l) || l && u)) return {
|
|
948
|
-
text: e,
|
|
949
|
-
taken: []
|
|
950
|
-
};
|
|
951
|
-
o(t.articles);
|
|
952
|
-
let d = n.slice(i).join(" ").replace(/[?!.]+$/, "").trim();
|
|
953
|
-
if (!/\p{L}{3,}/u.test(d)) return {
|
|
954
|
-
text: e,
|
|
955
|
-
taken: []
|
|
956
|
-
};
|
|
957
|
-
let f = d.split(/\s+/).filter(Boolean), p = Fe(Me(d), t.frames);
|
|
958
|
-
if (p > 0 && f.length - p >= Pe) {
|
|
959
|
-
let e = f.slice(0, f.length - p).join(" ");
|
|
960
|
-
if (/\p{L}{3,}/u.test(e)) return {
|
|
961
|
-
text: e,
|
|
962
|
-
taken: [...a, f.slice(-p).join(" ")]
|
|
963
|
-
};
|
|
964
|
-
}
|
|
965
|
-
return {
|
|
966
|
-
text: d,
|
|
967
|
-
taken: a
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
921
|
// src/hooks/useSearchOrAsk.ts
|
|
971
|
-
function
|
|
922
|
+
function je(e) {
|
|
972
923
|
return {
|
|
973
|
-
...
|
|
924
|
+
...xe,
|
|
974
925
|
...e,
|
|
975
|
-
hint: e?.hint ??
|
|
976
|
-
finished: e?.finished ??
|
|
926
|
+
hint: e?.hint ?? xe.hint,
|
|
927
|
+
finished: e?.finished ?? xe.finished,
|
|
928
|
+
found: e?.found ?? xe.found,
|
|
929
|
+
refocus: e?.refocus ?? xe.refocus
|
|
977
930
|
};
|
|
978
931
|
}
|
|
979
|
-
var
|
|
932
|
+
var Me = .1, Ne = {
|
|
980
933
|
available: !1,
|
|
981
934
|
offer: "none",
|
|
982
935
|
p: null,
|
|
@@ -984,9 +937,11 @@ var ze = {
|
|
|
984
937
|
text: "",
|
|
985
938
|
criteria: null,
|
|
986
939
|
describes: !1,
|
|
987
|
-
|
|
988
|
-
|
|
940
|
+
found: null,
|
|
941
|
+
notFound: !1,
|
|
942
|
+
held: !1,
|
|
989
943
|
strictCoverage: !1,
|
|
944
|
+
refocus: !1,
|
|
990
945
|
filtersWhileTyping: "off",
|
|
991
946
|
mode: "soft",
|
|
992
947
|
askAnytime: !1,
|
|
@@ -995,48 +950,51 @@ var ze = {
|
|
|
995
950
|
quick: "none",
|
|
996
951
|
stands: !1
|
|
997
952
|
};
|
|
998
|
-
function
|
|
999
|
-
let { enabled: t = !0, pauseMs: n = 300, prefetch: r = !0, mode: i, answerAfterMs: a = 1e3 } = e, s =
|
|
953
|
+
function Pe(e = {}) {
|
|
954
|
+
let { enabled: t = !0, pauseMs: n = 300, prefetch: r = !0, mode: i, answerAfterMs: a = 1e3 } = e, s = ye(), { url: u, team: d, dataset: f, authenticatedFetch: p, isFetchingInitial: m, authError: h, state: g } = s, _ = c(s);
|
|
1000
955
|
_.current = s;
|
|
1001
|
-
let v = (e.text ?? g.query).trim(), [y, b] = l(!1), [x, S] = l(
|
|
1002
|
-
|
|
1003
|
-
let
|
|
1004
|
-
return
|
|
1005
|
-
} },
|
|
1006
|
-
|
|
1007
|
-
let
|
|
1008
|
-
|
|
1009
|
-
let
|
|
1010
|
-
|
|
1011
|
-
let
|
|
956
|
+
let v = (e.text ?? g.query).trim(), [y, b] = l(!1), [x, S] = l(Ne), C = c(xe), w = c(!0), T = c("off"), E = c("soft"), D = c(i);
|
|
957
|
+
D.current = i;
|
|
958
|
+
let O = { get current() {
|
|
959
|
+
return be(E.current, D.current);
|
|
960
|
+
} }, k = c(null), A = c("none"), j = c(""), M = c(0), N = c(0);
|
|
961
|
+
A.current = x.offer;
|
|
962
|
+
let P = c(null), F = c(/* @__PURE__ */ new Set()), I = c(0), L = c(v);
|
|
963
|
+
L.current = v;
|
|
964
|
+
let R = c(!1);
|
|
965
|
+
R.current = y;
|
|
966
|
+
let [z, B] = l(0);
|
|
1012
967
|
o(() => {
|
|
1013
|
-
if (
|
|
968
|
+
if (!z) return;
|
|
969
|
+
let e = setTimeout(() => B(0), Math.max(0, z - Date.now()));
|
|
970
|
+
return () => clearTimeout(e);
|
|
971
|
+
}, [z]);
|
|
972
|
+
let V = `${u}/api/teams/${d}/datasets/${f}/search-or-ask`, H = () => O.current === "inviting" || O.current === "proactive" ? 3 : 4, U = (e) => e != null && e >= (C.current.finished ?? .5), W = (e) => O.current !== "proactive" && A.current === "strong" && !!j.current && e.startsWith(j.current), G = t && !m && !h;
|
|
973
|
+
o(() => {
|
|
974
|
+
if (b(!1), !G) return;
|
|
1014
975
|
let e = !1;
|
|
1015
976
|
return (async () => {
|
|
1016
977
|
try {
|
|
1017
|
-
let t = await p(
|
|
978
|
+
let t = await p(V);
|
|
1018
979
|
if (!t.ok) return;
|
|
1019
980
|
let n = await t.json();
|
|
1020
981
|
if (e || !n.available || !n.settings?.enabled) return;
|
|
1021
|
-
|
|
1022
|
-
shareOfTop: n.settings.cutShareOfTop ?? Te.shareOfTop,
|
|
1023
|
-
topFloor: n.settings.cutTopFloor ?? Te.topFloor
|
|
1024
|
-
}, b(!0);
|
|
982
|
+
T.current = n.settings.filtersWhileTyping ?? "off", E.current = n.settings.mode ?? "soft", C.current = je(n.settings.thresholds), w.current = n.settings.strictCoverageWhileAsking ?? !0, b(!0);
|
|
1025
983
|
} catch {}
|
|
1026
984
|
})(), () => {
|
|
1027
985
|
e = !0;
|
|
1028
986
|
};
|
|
1029
987
|
}, [
|
|
1030
|
-
|
|
1031
|
-
|
|
988
|
+
G,
|
|
989
|
+
V,
|
|
1032
990
|
p
|
|
1033
991
|
]);
|
|
1034
|
-
let
|
|
1035
|
-
|
|
1036
|
-
if (!r || !
|
|
992
|
+
let K = c(() => {});
|
|
993
|
+
K.current = (e) => {
|
|
994
|
+
if (!r || !R.current || P.current || !e || !Te(e, H()) || F.current.has(e) || W(e) || Date.now() < N.current || Date.now() < I.current) return;
|
|
1037
995
|
let t = (async () => {
|
|
1038
996
|
try {
|
|
1039
|
-
let t = await p(`${
|
|
997
|
+
let t = await p(`${V}/intent`, {
|
|
1040
998
|
method: "POST",
|
|
1041
999
|
headers: { "Content-Type": "application/json" },
|
|
1042
1000
|
body: JSON.stringify({
|
|
@@ -1046,35 +1004,32 @@ function Be(e = {}) {
|
|
|
1046
1004
|
});
|
|
1047
1005
|
if (t.status === 429) {
|
|
1048
1006
|
let e = Number(t.headers.get("Retry-After"));
|
|
1049
|
-
|
|
1007
|
+
I.current = Date.now() + (Number.isFinite(e) && e > 0 ? e : 60) * 1e3;
|
|
1050
1008
|
return;
|
|
1051
1009
|
}
|
|
1052
|
-
t.ok && (
|
|
1010
|
+
t.ok && (F.current.size > 200 && F.current.clear(), F.current.add(e));
|
|
1053
1011
|
} catch {}
|
|
1054
1012
|
})();
|
|
1055
|
-
|
|
1013
|
+
P.current = {
|
|
1056
1014
|
text: e,
|
|
1057
1015
|
done: t
|
|
1058
1016
|
}, t.then(() => {
|
|
1059
|
-
|
|
1017
|
+
P.current?.done === t && (P.current = null), L.current !== e && K.current(L.current);
|
|
1060
1018
|
});
|
|
1061
1019
|
}, o(() => {
|
|
1062
|
-
let { setSearchRewrite: e } = _.current, t = j.current;
|
|
1063
|
-
if (y && t && M.current && e) return e((e) => Le(e, t).text), () => e(null);
|
|
1064
|
-
}, [y]), o(() => {
|
|
1065
1020
|
if (!y) {
|
|
1066
|
-
S(
|
|
1021
|
+
S(Ne);
|
|
1067
1022
|
return;
|
|
1068
1023
|
}
|
|
1069
1024
|
if (!v) {
|
|
1070
|
-
|
|
1071
|
-
...
|
|
1025
|
+
j.current = "", S({
|
|
1026
|
+
...Ne,
|
|
1072
1027
|
available: y
|
|
1073
1028
|
});
|
|
1074
1029
|
return;
|
|
1075
1030
|
}
|
|
1076
|
-
if (!
|
|
1077
|
-
|
|
1031
|
+
if (!Te(v, H())) {
|
|
1032
|
+
Ce(v) && S((e) => ({
|
|
1078
1033
|
...e,
|
|
1079
1034
|
available: y,
|
|
1080
1035
|
offer: "none",
|
|
@@ -1082,63 +1037,66 @@ function Be(e = {}) {
|
|
|
1082
1037
|
}));
|
|
1083
1038
|
return;
|
|
1084
1039
|
}
|
|
1085
|
-
|
|
1086
|
-
...e,
|
|
1087
|
-
available: y,
|
|
1088
|
-
offer: "invite",
|
|
1089
|
-
text: v
|
|
1090
|
-
} : e), ne.current(v);
|
|
1040
|
+
K.current(v);
|
|
1091
1041
|
let e = !1, t = setTimeout(async () => {
|
|
1092
|
-
if (
|
|
1042
|
+
if (W(v)) {
|
|
1093
1043
|
S((e) => ({
|
|
1094
1044
|
...e,
|
|
1095
1045
|
text: v
|
|
1096
1046
|
}));
|
|
1097
1047
|
return;
|
|
1098
1048
|
}
|
|
1099
|
-
if (Date.now() <
|
|
1100
|
-
let t = ++
|
|
1101
|
-
|
|
1049
|
+
if (Date.now() < N.current || (P.current?.text === v && await P.current.done, e)) return;
|
|
1050
|
+
let t = ++M.current;
|
|
1051
|
+
j.current = v;
|
|
1102
1052
|
try {
|
|
1103
|
-
let e = await p(`${
|
|
1053
|
+
let e = await p(`${V}/intent${Ae(_.current)}`, {
|
|
1104
1054
|
method: "POST",
|
|
1105
1055
|
headers: { "Content-Type": "application/json" },
|
|
1106
1056
|
body: JSON.stringify({ text: v })
|
|
1107
1057
|
});
|
|
1108
1058
|
if (e.status === 429) {
|
|
1109
|
-
let
|
|
1110
|
-
|
|
1059
|
+
let n = Number(e.headers.get("Retry-After"));
|
|
1060
|
+
N.current = Date.now() + (Number.isFinite(n) && n > 0 ? n : 60) * 1e3;
|
|
1061
|
+
let { code: r } = await e.json().catch(() => ({}));
|
|
1062
|
+
r === "searchOrAskBudgetSpent" && t === M.current && (B(N.current), S((e) => ({
|
|
1063
|
+
...e,
|
|
1064
|
+
offer: "none",
|
|
1065
|
+
answerNow: null,
|
|
1066
|
+
strictCoverage: !1,
|
|
1067
|
+
refocus: !1,
|
|
1068
|
+
notFound: !1
|
|
1069
|
+
})));
|
|
1111
1070
|
return;
|
|
1112
1071
|
}
|
|
1113
|
-
if (e.status === 409) {
|
|
1072
|
+
if (e.status === 409 || e.status === 404) {
|
|
1114
1073
|
b(!1);
|
|
1115
1074
|
return;
|
|
1116
1075
|
}
|
|
1117
1076
|
if (!e.ok) return;
|
|
1118
|
-
let { p: n, answerable: r, criteria: i, finished: a,
|
|
1119
|
-
if (
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
topFloor: l
|
|
1123
|
-
}), S((e) => {
|
|
1124
|
-
let t = we(e.offer, n, C.current), o = i ?? null, s = o != null && o >= C.current.strong, c = t === "strong" && !ke(v) ? "invite" : t, l = s ? "strong" : c, u = A.current === "strict" && l === "invite" ? "none" : l, d = u === "strong" && !(s && o > n);
|
|
1077
|
+
let { p: n, answerable: r, criteria: i, finished: a, found: o, reason: s, thresholds: c, strictCoverageWhileAsking: l, filtersWhileTyping: u, mode: d, refocus: f } = await e.json();
|
|
1078
|
+
if (u != null && (T.current = u), t !== M.current) return;
|
|
1079
|
+
l != null && (w.current = l), d != null && (E.current = d), c && (C.current = je(c)), S((e) => {
|
|
1080
|
+
let t = Ee(e.offer, n, C.current), c = i ?? null, l = c != null && c >= C.current.strong, u = e.offer === "strong" && !!e.text && v.startsWith(e.text) || Oe(v) && (a == null || U(a)), d = l && u ? "strong" : l || t === "strong" && !u ? "invite" : t, p = O.current === "strict" && d === "invite" ? "none" : d, m = p === "strong" && !(l && c > n), h = o ?? null, g = C.current.found ?? 0, _ = C.current.refocus ?? 0, y = e.refocus && _ > 0 && !!e.text && v.startsWith(e.text) && Math.max(n, c ?? 0) >= _ - Me;
|
|
1125
1081
|
return {
|
|
1126
1082
|
available: !0,
|
|
1127
|
-
offer:
|
|
1083
|
+
offer: p,
|
|
1128
1084
|
p: n,
|
|
1129
1085
|
answerable: r ?? null,
|
|
1130
1086
|
text: v,
|
|
1131
|
-
criteria:
|
|
1132
|
-
describes:
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1087
|
+
criteria: c,
|
|
1088
|
+
describes: l,
|
|
1089
|
+
found: h,
|
|
1090
|
+
notFound: m && h != null && g > 0 && h < g,
|
|
1091
|
+
held: s === "paused",
|
|
1092
|
+
strictCoverage: w.current && m,
|
|
1093
|
+
refocus: !!f || y,
|
|
1094
|
+
filtersWhileTyping: T.current,
|
|
1095
|
+
mode: O.current,
|
|
1138
1096
|
askAnytime: !1,
|
|
1139
1097
|
quick: "none",
|
|
1140
1098
|
finished: a ?? null,
|
|
1141
|
-
answerNow:
|
|
1099
|
+
answerNow: O.current === "proactive" && p === "strong" && U(a) ? v : null,
|
|
1142
1100
|
stands: !0
|
|
1143
1101
|
};
|
|
1144
1102
|
});
|
|
@@ -1150,16 +1108,16 @@ function Be(e = {}) {
|
|
|
1150
1108
|
}, [
|
|
1151
1109
|
v,
|
|
1152
1110
|
y,
|
|
1153
|
-
|
|
1111
|
+
V,
|
|
1154
1112
|
p,
|
|
1155
1113
|
n
|
|
1156
1114
|
]);
|
|
1157
|
-
let [
|
|
1115
|
+
let [ee, q] = l(null);
|
|
1158
1116
|
o(() => {
|
|
1159
|
-
|
|
1117
|
+
q(null);
|
|
1160
1118
|
let e = x.answerNow;
|
|
1161
1119
|
if (!e || e !== v) return;
|
|
1162
|
-
let t = setTimeout(() =>
|
|
1120
|
+
let t = setTimeout(() => q(e), Math.max(0, a - n));
|
|
1163
1121
|
return () => clearTimeout(t);
|
|
1164
1122
|
}, [
|
|
1165
1123
|
x.answerNow,
|
|
@@ -1167,27 +1125,47 @@ function Be(e = {}) {
|
|
|
1167
1125
|
a,
|
|
1168
1126
|
n
|
|
1169
1127
|
]);
|
|
1170
|
-
let
|
|
1171
|
-
|
|
1128
|
+
let te = y && x.strictCoverage;
|
|
1129
|
+
o(() => {
|
|
1172
1130
|
let { setSearchSettings: e, state: t } = _.current;
|
|
1173
|
-
if (
|
|
1174
|
-
if (
|
|
1175
|
-
let n = t.searchSettings.
|
|
1176
|
-
|
|
1177
|
-
} else
|
|
1178
|
-
}, [
|
|
1179
|
-
let
|
|
1131
|
+
if (te) {
|
|
1132
|
+
if (k.current) return;
|
|
1133
|
+
let n = t.searchSettings.match ?? {};
|
|
1134
|
+
k.current = Object.fromEntries(Object.keys(De).map((e) => [e, n[e]])), e({ match: { ...De } });
|
|
1135
|
+
} else k.current &&= (e({ match: { ...k.current } }), null);
|
|
1136
|
+
}, [te]);
|
|
1137
|
+
let ne = y && x.refocus && !x.held && z === 0 && !!x.text && v.startsWith(x.text);
|
|
1138
|
+
if (o(() => {
|
|
1139
|
+
_.current.setSearchSettings({ refocus: ne });
|
|
1140
|
+
}, [ne]), !y) return Ne;
|
|
1141
|
+
let J = O.current, Y = !!x.text && v.startsWith(x.text), X = x.held || z > 0;
|
|
1142
|
+
if (X) return {
|
|
1143
|
+
...x,
|
|
1144
|
+
mode: J,
|
|
1145
|
+
held: X,
|
|
1146
|
+
offer: "none",
|
|
1147
|
+
askAnytime: !1,
|
|
1148
|
+
answerNow: null,
|
|
1149
|
+
quick: "none",
|
|
1150
|
+
notFound: !1,
|
|
1151
|
+
strictCoverage: !1,
|
|
1152
|
+
refocus: !1,
|
|
1153
|
+
stands: Y
|
|
1154
|
+
};
|
|
1155
|
+
let re = J === "inviting" || J === "proactive", ie = re && !!v && (Y && x.p != null && x.p >= (C.current.hint ?? 1) || we(v)), ae = v ? Y && x.offer === "strong" ? J === "proactive" ? U(x.finished) ? "thinking" : "hint" : "ready" : Y && x.offer === "invite" ? re ? "hint" : "invite" : ie ? "hint" : J === "open" || re ? "ask" : "none" : "none";
|
|
1180
1156
|
return {
|
|
1181
1157
|
...x,
|
|
1158
|
+
refocus: ne,
|
|
1182
1159
|
mode: J,
|
|
1183
|
-
askAnytime: J === "open" ||
|
|
1184
|
-
answerNow:
|
|
1185
|
-
text:
|
|
1186
|
-
|
|
1160
|
+
askAnytime: J === "open" || re,
|
|
1161
|
+
answerNow: ee !== null && ee === v && x.answerNow === v ? ee : null,
|
|
1162
|
+
text: (ae === "hint" || ae === "ask") && !Y ? v : x.text,
|
|
1163
|
+
notFound: Y && x.notFound,
|
|
1164
|
+
quick: ae,
|
|
1187
1165
|
stands: Y
|
|
1188
1166
|
};
|
|
1189
1167
|
}
|
|
1190
|
-
var
|
|
1168
|
+
var Fe = {
|
|
1191
1169
|
row: "_row_epo6h_3",
|
|
1192
1170
|
icon: "_icon_epo6h_17",
|
|
1193
1171
|
line: "_line_epo6h_24",
|
|
@@ -1195,55 +1173,71 @@ var Ve = {
|
|
|
1195
1173
|
question: "_question_epo6h_43",
|
|
1196
1174
|
actions: "_actions_epo6h_52",
|
|
1197
1175
|
enter: "_enter_epo6h_59"
|
|
1198
|
-
},
|
|
1176
|
+
}, Ie = {
|
|
1199
1177
|
invite: "Ask about this",
|
|
1200
1178
|
hint: "For a quick answer, type a bit more",
|
|
1201
1179
|
ready: "Ask the assistant",
|
|
1202
|
-
thinking: "Thinking"
|
|
1203
|
-
|
|
1180
|
+
thinking: "Thinking",
|
|
1181
|
+
ask: "Ask"
|
|
1182
|
+
}, Le = ({ searchOrAsk: e, onAsk: t, labels: n, className: r = "" }) => {
|
|
1204
1183
|
let i = {
|
|
1205
|
-
...
|
|
1184
|
+
...Ie,
|
|
1206
1185
|
...n
|
|
1207
1186
|
}, a = e.text.trim();
|
|
1208
1187
|
if (!e.available || e.quick === "none" || !a) return null;
|
|
1209
1188
|
let o = () => t(a);
|
|
1210
|
-
return /* @__PURE__ */
|
|
1211
|
-
className: `${
|
|
1189
|
+
return /* @__PURE__ */ g("div", {
|
|
1190
|
+
className: `${Fe.row} ${Fe[e.quick]} ${r}`,
|
|
1212
1191
|
"aria-live": "polite",
|
|
1213
1192
|
children: [
|
|
1214
|
-
/* @__PURE__ */
|
|
1215
|
-
className:
|
|
1193
|
+
/* @__PURE__ */ h("span", {
|
|
1194
|
+
className: Fe.icon,
|
|
1216
1195
|
"aria-hidden": "true",
|
|
1217
|
-
children: /* @__PURE__ */
|
|
1196
|
+
children: /* @__PURE__ */ h(H, {
|
|
1218
1197
|
size: 14,
|
|
1219
1198
|
color: "currentColor"
|
|
1220
1199
|
})
|
|
1221
1200
|
}),
|
|
1222
|
-
e.quick === "thinking" && /* @__PURE__ */
|
|
1223
|
-
className:
|
|
1201
|
+
e.quick === "thinking" && /* @__PURE__ */ h(F, {
|
|
1202
|
+
className: Fe.text,
|
|
1224
1203
|
children: i.thinking
|
|
1225
1204
|
}),
|
|
1226
|
-
e.quick === "hint" && /* @__PURE__ */
|
|
1205
|
+
e.quick === "hint" && /* @__PURE__ */ h("button", {
|
|
1227
1206
|
type: "button",
|
|
1228
|
-
className:
|
|
1207
|
+
className: Fe.line,
|
|
1229
1208
|
onClick: o,
|
|
1230
|
-
children: /* @__PURE__ */
|
|
1209
|
+
children: /* @__PURE__ */ h(F, { children: i.hint })
|
|
1231
1210
|
}),
|
|
1232
|
-
e.quick === "invite" && /* @__PURE__ */
|
|
1211
|
+
e.quick === "invite" && /* @__PURE__ */ h("button", {
|
|
1233
1212
|
type: "button",
|
|
1234
|
-
className:
|
|
1213
|
+
className: Fe.line,
|
|
1235
1214
|
onClick: o,
|
|
1236
1215
|
children: i.invite
|
|
1237
1216
|
}),
|
|
1238
|
-
e.quick === "
|
|
1239
|
-
className:
|
|
1217
|
+
e.quick === "ask" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
|
|
1218
|
+
className: Fe.question,
|
|
1240
1219
|
children: a
|
|
1241
|
-
}), /* @__PURE__ */
|
|
1242
|
-
className:
|
|
1243
|
-
children: [/* @__PURE__ */
|
|
1244
|
-
className:
|
|
1245
|
-
children: [/* @__PURE__ */
|
|
1246
|
-
}), /* @__PURE__ */
|
|
1220
|
+
}), /* @__PURE__ */ g("span", {
|
|
1221
|
+
className: Fe.actions,
|
|
1222
|
+
children: [/* @__PURE__ */ g("span", {
|
|
1223
|
+
className: Fe.enter,
|
|
1224
|
+
children: [/* @__PURE__ */ h(A, { children: "β΅" }), " to ask"]
|
|
1225
|
+
}), /* @__PURE__ */ h(S, {
|
|
1226
|
+
variant: "ghost",
|
|
1227
|
+
size: "micro",
|
|
1228
|
+
onClick: o,
|
|
1229
|
+
children: i.ask
|
|
1230
|
+
})]
|
|
1231
|
+
})] }),
|
|
1232
|
+
e.quick === "ready" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
|
|
1233
|
+
className: Fe.question,
|
|
1234
|
+
children: a
|
|
1235
|
+
}), /* @__PURE__ */ g("span", {
|
|
1236
|
+
className: Fe.actions,
|
|
1237
|
+
children: [/* @__PURE__ */ g("span", {
|
|
1238
|
+
className: Fe.enter,
|
|
1239
|
+
children: [/* @__PURE__ */ h(A, { children: "β΅" }), " to ask"]
|
|
1240
|
+
}), /* @__PURE__ */ h(S, {
|
|
1247
1241
|
variant: "primary",
|
|
1248
1242
|
size: "micro",
|
|
1249
1243
|
onClick: o,
|
|
@@ -1252,34 +1246,34 @@ var Ve = {
|
|
|
1252
1246
|
})] })
|
|
1253
1247
|
]
|
|
1254
1248
|
});
|
|
1255
|
-
},
|
|
1249
|
+
}, Re = {
|
|
1256
1250
|
grid: "_grid_1xjna_2",
|
|
1257
1251
|
chip: "_chip_1xjna_21",
|
|
1258
1252
|
chipLabel: "_chipLabel_1xjna_32"
|
|
1259
|
-
},
|
|
1253
|
+
}, ze = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
1260
1254
|
onClick: n,
|
|
1261
|
-
iconRight: /* @__PURE__ */
|
|
1255
|
+
iconRight: /* @__PURE__ */ h(ae, {}),
|
|
1262
1256
|
variant: "primary",
|
|
1263
1257
|
size: "micro",
|
|
1264
|
-
className:
|
|
1258
|
+
className: Re.chip,
|
|
1265
1259
|
title: `${e}: ${t}`,
|
|
1266
|
-
children: /* @__PURE__ */
|
|
1267
|
-
className:
|
|
1260
|
+
children: /* @__PURE__ */ g("span", {
|
|
1261
|
+
className: Re.chipLabel,
|
|
1268
1262
|
children: [
|
|
1269
1263
|
e,
|
|
1270
1264
|
": ",
|
|
1271
1265
|
t
|
|
1272
1266
|
]
|
|
1273
1267
|
})
|
|
1274
|
-
}) })),
|
|
1268
|
+
}) })), Be = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
1275
1269
|
onClick: r,
|
|
1276
|
-
iconRight: /* @__PURE__ */
|
|
1270
|
+
iconRight: /* @__PURE__ */ h(ae, {}),
|
|
1277
1271
|
variant: "primary",
|
|
1278
1272
|
size: "micro",
|
|
1279
|
-
className:
|
|
1273
|
+
className: Re.chip,
|
|
1280
1274
|
title: `${e}: ${t} β ${n}`,
|
|
1281
|
-
children: /* @__PURE__ */
|
|
1282
|
-
className:
|
|
1275
|
+
children: /* @__PURE__ */ g("span", {
|
|
1276
|
+
className: Re.chipLabel,
|
|
1283
1277
|
children: [
|
|
1284
1278
|
e,
|
|
1285
1279
|
": ",
|
|
@@ -1288,15 +1282,15 @@ var Ve = {
|
|
|
1288
1282
|
n
|
|
1289
1283
|
]
|
|
1290
1284
|
})
|
|
1291
|
-
}) })),
|
|
1285
|
+
}) })), Ve = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
1292
1286
|
onClick: n,
|
|
1293
|
-
iconRight: /* @__PURE__ */
|
|
1287
|
+
iconRight: /* @__PURE__ */ h(ae, {}),
|
|
1294
1288
|
variant: "primary",
|
|
1295
1289
|
size: "micro",
|
|
1296
|
-
className:
|
|
1290
|
+
className: Re.chip,
|
|
1297
1291
|
title: `${e}: ${t}`,
|
|
1298
|
-
children: /* @__PURE__ */
|
|
1299
|
-
className:
|
|
1292
|
+
children: /* @__PURE__ */ g("span", {
|
|
1293
|
+
className: Re.chipLabel,
|
|
1300
1294
|
children: [
|
|
1301
1295
|
e,
|
|
1302
1296
|
": ",
|
|
@@ -1304,8 +1298,8 @@ var Ve = {
|
|
|
1304
1298
|
]
|
|
1305
1299
|
})
|
|
1306
1300
|
}) }));
|
|
1307
|
-
function
|
|
1308
|
-
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } =
|
|
1301
|
+
function He() {
|
|
1302
|
+
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = ye(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
1309
1303
|
field: e,
|
|
1310
1304
|
value: t
|
|
1311
1305
|
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -1321,29 +1315,29 @@ function Je() {
|
|
|
1321
1315
|
e,
|
|
1322
1316
|
t,
|
|
1323
1317
|
u
|
|
1324
|
-
]) ? /* @__PURE__ */
|
|
1318
|
+
]) ? /* @__PURE__ */ h(O, {
|
|
1325
1319
|
collapsible: !1,
|
|
1326
1320
|
title: "Active filters",
|
|
1327
|
-
children: /* @__PURE__ */
|
|
1328
|
-
className:
|
|
1321
|
+
children: /* @__PURE__ */ g("ul", {
|
|
1322
|
+
className: Re.grid,
|
|
1329
1323
|
children: [
|
|
1330
|
-
c.map(({ field: e, value: t }) => /* @__PURE__ */
|
|
1324
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ h(ze, {
|
|
1331
1325
|
field: e,
|
|
1332
1326
|
value: t,
|
|
1333
1327
|
onReset: () => i(e, t)
|
|
1334
1328
|
}, `${e}-${t}`)),
|
|
1335
|
-
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */
|
|
1329
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ h(Be, {
|
|
1336
1330
|
field: e,
|
|
1337
1331
|
min: t,
|
|
1338
1332
|
max: n,
|
|
1339
1333
|
onReset: () => a(e)
|
|
1340
1334
|
}, e)),
|
|
1341
|
-
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */
|
|
1335
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ h(Ve, {
|
|
1342
1336
|
field: e,
|
|
1343
1337
|
label: n,
|
|
1344
1338
|
onReset: () => o(e, t)
|
|
1345
1339
|
}, `${e}-${t.min}-${t.max}`)),
|
|
1346
|
-
/* @__PURE__ */
|
|
1340
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
1347
1341
|
onClick: r,
|
|
1348
1342
|
size: "micro",
|
|
1349
1343
|
variant: "ghost",
|
|
@@ -1353,7 +1347,7 @@ function Je() {
|
|
|
1353
1347
|
})
|
|
1354
1348
|
}) : null;
|
|
1355
1349
|
}
|
|
1356
|
-
var
|
|
1350
|
+
var Ue = {
|
|
1357
1351
|
withOffer: "_withOffer_1zrln_2",
|
|
1358
1352
|
offerRow: "_offerRow_1zrln_10",
|
|
1359
1353
|
offerHint: "_offerHint_1zrln_18",
|
|
@@ -1363,231 +1357,238 @@ var Ye = {
|
|
|
1363
1357
|
offerQuick: "_offerQuick_1zrln_56",
|
|
1364
1358
|
filterChip: "_filterChip_1zrln_59",
|
|
1365
1359
|
filtersPopover: "_filtersPopover_1zrln_63"
|
|
1366
|
-
},
|
|
1367
|
-
let { state: { query:
|
|
1360
|
+
}, We = ({ className: t = "", autoFocus: n = !1, inputSize: r = "default", showClear: i = !0, showFocus: a = !1, showStatus: o = !0, onAsk: s, searchOrAsk: c, askOffer: l = "chip", onKeyDown: u, ...d }) => {
|
|
1361
|
+
let { state: { query: f, filters: p, rangeFilters: m, bucketFilters: _, results: v, isFallback: y, searchSettings: b }, setQuery: x, resetFilters: C, picks: T, showPicks: E } = ye(), D = !!T, O = Object.values(p).reduce((e, t) => e + t.length, 0) + Object.keys(m).length + Object.values(_ ?? {}).reduce((e, t) => e + t.length, 0), k = f.length > 0, M = k && !D && v !== null && v.length === 0, P = k && !D && v !== null && v.length > 0 && y === !0, I = Pe({ enabled: !!s && !c }), L = c ?? I, R = L.quick === "ready" || L.askAnytime, z = e.useRef(null);
|
|
1368
1362
|
e.useEffect(() => {
|
|
1369
|
-
let e =
|
|
1370
|
-
s && e && e ===
|
|
1363
|
+
let e = L.answerNow;
|
|
1364
|
+
s && e && e === f.trim() && z.current !== e && (z.current = e, s(e, { proactive: !0 }));
|
|
1371
1365
|
}, [
|
|
1372
|
-
|
|
1373
|
-
|
|
1366
|
+
L.answerNow,
|
|
1367
|
+
f,
|
|
1374
1368
|
s
|
|
1375
1369
|
]);
|
|
1376
|
-
let
|
|
1377
|
-
u?.(e), !e.defaultPrevented && e.key === "Enter" && s &&
|
|
1378
|
-
}, [
|
|
1370
|
+
let V = z.current !== null && z.current === f.trim(), U = !s || !k || V ? "none" : L.quick, W = L.available && b.placeholderText === "Type to search" ? "Search or ask" : b.placeholderText, G = (e) => {
|
|
1371
|
+
u?.(e), !e.defaultPrevented && e.key === "Enter" && s && R && f.trim() && (e.preventDefault(), J());
|
|
1372
|
+
}, [q, te] = e.useState(!1);
|
|
1379
1373
|
e.useEffect(() => {
|
|
1380
|
-
|
|
1381
|
-
}, [
|
|
1382
|
-
let
|
|
1383
|
-
|
|
1384
|
-
},
|
|
1385
|
-
|
|
1386
|
-
},
|
|
1374
|
+
O === 0 && te(!1);
|
|
1375
|
+
}, [O]);
|
|
1376
|
+
let ne = () => {
|
|
1377
|
+
E?.(null), x(""), O > 0 && C();
|
|
1378
|
+
}, J = () => {
|
|
1379
|
+
z.current = f.trim(), s(f.trim());
|
|
1380
|
+
}, Y = /* @__PURE__ */ g(N, {
|
|
1387
1381
|
type: "text",
|
|
1388
|
-
value:
|
|
1389
|
-
onChange: (e) =>
|
|
1390
|
-
placeholder:
|
|
1382
|
+
value: f,
|
|
1383
|
+
onChange: (e) => x(e.target.value),
|
|
1384
|
+
placeholder: W,
|
|
1391
1385
|
autoFocus: n,
|
|
1392
1386
|
className: t,
|
|
1393
1387
|
showSearchIcon: !0,
|
|
1394
1388
|
inputSize: r,
|
|
1395
1389
|
showFocusBorder: a,
|
|
1396
1390
|
clearable: !1,
|
|
1397
|
-
onKeyDown:
|
|
1391
|
+
onKeyDown: G,
|
|
1398
1392
|
...d,
|
|
1399
1393
|
children: [
|
|
1400
|
-
l === "chip" &&
|
|
1401
|
-
className:
|
|
1394
|
+
l === "chip" && U === "thinking" && /* @__PURE__ */ g("span", {
|
|
1395
|
+
className: Ue.thinking,
|
|
1402
1396
|
"aria-live": "polite",
|
|
1403
|
-
children: [/* @__PURE__ */
|
|
1397
|
+
children: [/* @__PURE__ */ h(H, {}), /* @__PURE__ */ h(F, { children: "Thinking" })]
|
|
1404
1398
|
}),
|
|
1405
|
-
l === "chip" && (
|
|
1406
|
-
variant:
|
|
1407
|
-
className:
|
|
1399
|
+
l === "chip" && (U === "ready" || U === "invite" || U === "hint" || U === "ask") && /* @__PURE__ */ h(S, {
|
|
1400
|
+
variant: U === "ready" ? "primary" : "ghost",
|
|
1401
|
+
className: U === "ready" ? Ue.askStrong : void 0,
|
|
1408
1402
|
size: "micro",
|
|
1409
|
-
iconLeft: /* @__PURE__ */
|
|
1410
|
-
iconRight:
|
|
1411
|
-
onClick:
|
|
1412
|
-
title:
|
|
1413
|
-
children:
|
|
1403
|
+
iconLeft: /* @__PURE__ */ h(H, {}),
|
|
1404
|
+
iconRight: U === "ready" ? /* @__PURE__ */ h(A, { children: "Enter β΅" }) : void 0,
|
|
1405
|
+
onClick: J,
|
|
1406
|
+
title: R ? "Enter asks" : void 0,
|
|
1407
|
+
children: U === "ready" ? "Ask" : U === "hint" ? /* @__PURE__ */ h(F, { children: "For a quick answer, type a bit more" }) : U === "invite" ? "Ask about this" : "Ask"
|
|
1414
1408
|
}),
|
|
1415
|
-
o &&
|
|
1416
|
-
o &&
|
|
1409
|
+
o && M && /* @__PURE__ */ h(w, { children: "No results" }),
|
|
1410
|
+
o && P && /* @__PURE__ */ h(B, {
|
|
1417
1411
|
content: "No direct match. Showing the nearest results.",
|
|
1418
|
-
children: /* @__PURE__ */
|
|
1419
|
-
icon: /* @__PURE__ */
|
|
1412
|
+
children: /* @__PURE__ */ h("span", { children: /* @__PURE__ */ h(w, {
|
|
1413
|
+
icon: /* @__PURE__ */ h(ee, {}),
|
|
1420
1414
|
children: "Nearest"
|
|
1421
1415
|
}) })
|
|
1422
1416
|
}),
|
|
1423
|
-
o &&
|
|
1424
|
-
open:
|
|
1425
|
-
onOpenChange:
|
|
1417
|
+
o && O > 0 && /* @__PURE__ */ h(j, {
|
|
1418
|
+
open: q,
|
|
1419
|
+
onOpenChange: te,
|
|
1426
1420
|
align: "end",
|
|
1427
1421
|
sideOffset: 6,
|
|
1428
|
-
className:
|
|
1422
|
+
className: Ue.filtersPopover,
|
|
1429
1423
|
"aria-label": "Active filters",
|
|
1430
|
-
trigger: /* @__PURE__ */
|
|
1424
|
+
trigger: /* @__PURE__ */ h(S, {
|
|
1431
1425
|
variant: "ghost",
|
|
1432
1426
|
size: "micro",
|
|
1433
|
-
className:
|
|
1434
|
-
"aria-label": `${
|
|
1435
|
-
title: `${
|
|
1436
|
-
children: /* @__PURE__ */
|
|
1437
|
-
icon: /* @__PURE__ */
|
|
1427
|
+
className: Ue.filterChip,
|
|
1428
|
+
"aria-label": `${O} filter${O === 1 ? "" : "s"} active: show them`,
|
|
1429
|
+
title: `${O} filter${O === 1 ? "" : "s"} active`,
|
|
1430
|
+
children: /* @__PURE__ */ h(w, {
|
|
1431
|
+
icon: /* @__PURE__ */ h(K, {}),
|
|
1438
1432
|
color: "var(--CLightBlue)",
|
|
1439
1433
|
textColor: "#080809",
|
|
1440
|
-
children:
|
|
1434
|
+
children: O
|
|
1441
1435
|
})
|
|
1442
1436
|
}),
|
|
1443
|
-
children: /* @__PURE__ */
|
|
1437
|
+
children: /* @__PURE__ */ h(He, {})
|
|
1444
1438
|
}),
|
|
1445
|
-
i && (
|
|
1439
|
+
i && (k || O > 0) && /* @__PURE__ */ h(S, {
|
|
1446
1440
|
variant: "ghost",
|
|
1447
1441
|
size: "micro",
|
|
1448
|
-
onClick:
|
|
1449
|
-
"aria-label":
|
|
1442
|
+
onClick: ne,
|
|
1443
|
+
"aria-label": O > 0 ? "Clear search and filters" : "Clear search",
|
|
1450
1444
|
children: "Clear"
|
|
1451
1445
|
})
|
|
1452
1446
|
]
|
|
1453
1447
|
});
|
|
1454
|
-
return l !== "below" || !s || !
|
|
1455
|
-
className:
|
|
1456
|
-
children: [
|
|
1457
|
-
className:
|
|
1458
|
-
children: !
|
|
1459
|
-
searchOrAsk:
|
|
1460
|
-
onAsk:
|
|
1461
|
-
className:
|
|
1448
|
+
return l !== "below" || !s || !L.available ? Y : /* @__PURE__ */ g("div", {
|
|
1449
|
+
className: Ue.withOffer,
|
|
1450
|
+
children: [Y, /* @__PURE__ */ h("div", {
|
|
1451
|
+
className: Ue.offerRow,
|
|
1452
|
+
children: !V && /* @__PURE__ */ h(Le, {
|
|
1453
|
+
searchOrAsk: L,
|
|
1454
|
+
onAsk: J,
|
|
1455
|
+
className: Ue.offerQuick
|
|
1462
1456
|
})
|
|
1463
1457
|
})]
|
|
1464
1458
|
});
|
|
1465
|
-
},
|
|
1459
|
+
}, Ge = {
|
|
1466
1460
|
message: "_message_1mgfk_1",
|
|
1467
1461
|
icon: "_icon_1mgfk_10",
|
|
1468
1462
|
title: "_title_1mgfk_15",
|
|
1469
1463
|
detail: "_detail_1mgfk_20",
|
|
1470
1464
|
technical: "_technical_1mgfk_25",
|
|
1471
1465
|
button: "_button_1mgfk_33"
|
|
1472
|
-
},
|
|
1466
|
+
}, Ke = {
|
|
1473
1467
|
unreachable: {
|
|
1474
|
-
icon:
|
|
1468
|
+
icon: G,
|
|
1475
1469
|
title: "Search is unavailable",
|
|
1476
1470
|
detail: "The search server canβt be reached right now."
|
|
1477
1471
|
},
|
|
1478
1472
|
unauthorized: {
|
|
1479
|
-
icon:
|
|
1473
|
+
icon: ne,
|
|
1480
1474
|
title: "Search is unavailable",
|
|
1481
1475
|
detail: "The search key was not accepted."
|
|
1482
1476
|
},
|
|
1483
1477
|
forbidden: {
|
|
1484
|
-
icon:
|
|
1478
|
+
icon: J,
|
|
1485
1479
|
title: "Search is unavailable",
|
|
1486
1480
|
detail: "This search key doesnβt have access to these results."
|
|
1487
1481
|
},
|
|
1488
1482
|
notFound: {
|
|
1489
|
-
icon:
|
|
1483
|
+
icon: X,
|
|
1490
1484
|
title: "Nothing to search here",
|
|
1491
1485
|
detail: "The collection this page searches doesnβt exist."
|
|
1492
1486
|
},
|
|
1493
1487
|
notReady: {
|
|
1494
|
-
icon:
|
|
1488
|
+
icon: q,
|
|
1495
1489
|
title: "Search is getting ready",
|
|
1496
1490
|
detail: "Results will appear in a moment."
|
|
1497
1491
|
},
|
|
1498
1492
|
unavailable: {
|
|
1499
|
-
icon:
|
|
1493
|
+
icon: ie,
|
|
1500
1494
|
title: "Search is unavailable",
|
|
1501
1495
|
detail: "The collection canβt be searched right now."
|
|
1502
1496
|
},
|
|
1503
1497
|
rateLimited: {
|
|
1504
|
-
icon:
|
|
1498
|
+
icon: re,
|
|
1505
1499
|
title: "Too many searches",
|
|
1506
1500
|
detail: "Wait a moment, then try again."
|
|
1507
1501
|
},
|
|
1508
1502
|
server: {
|
|
1509
|
-
icon:
|
|
1503
|
+
icon: ie,
|
|
1510
1504
|
title: "Something went wrong",
|
|
1511
1505
|
detail: "The search server ran into a problem."
|
|
1512
1506
|
},
|
|
1513
1507
|
setup: {
|
|
1514
|
-
icon:
|
|
1508
|
+
icon: ie,
|
|
1515
1509
|
title: "Search isnβt set up",
|
|
1516
1510
|
detail: "This page is missing part of its search setup."
|
|
1517
1511
|
},
|
|
1518
1512
|
unknown: {
|
|
1519
|
-
icon:
|
|
1513
|
+
icon: ie,
|
|
1520
1514
|
title: "Something went wrong",
|
|
1521
1515
|
detail: "The search couldnβt be completed."
|
|
1522
1516
|
}
|
|
1523
|
-
},
|
|
1524
|
-
let { icon: r, title: i, detail: a } =
|
|
1517
|
+
}, qe = ({ error: e, onRetry: t, hideTechnical: n = !1 }) => {
|
|
1518
|
+
let { icon: r, title: i, detail: a } = Ke[e.kind];
|
|
1525
1519
|
o(() => {
|
|
1526
1520
|
if (e.kind !== "notReady" || !t) return;
|
|
1527
1521
|
let n = setTimeout(t, (e.retryAfterSeconds ?? 2) * 1e3);
|
|
1528
1522
|
return () => clearTimeout(n);
|
|
1529
1523
|
}, [e, t]);
|
|
1530
1524
|
let s = e.retryable && e.kind !== "notReady" && t;
|
|
1531
|
-
return /* @__PURE__ */
|
|
1532
|
-
className:
|
|
1525
|
+
return /* @__PURE__ */ g("div", {
|
|
1526
|
+
className: Ge.message,
|
|
1533
1527
|
role: "alert",
|
|
1534
1528
|
children: [
|
|
1535
|
-
/* @__PURE__ */
|
|
1536
|
-
className:
|
|
1537
|
-
children: /* @__PURE__ */
|
|
1529
|
+
/* @__PURE__ */ h("span", {
|
|
1530
|
+
className: Ge.icon,
|
|
1531
|
+
children: /* @__PURE__ */ h(r, {
|
|
1538
1532
|
size: 70,
|
|
1539
1533
|
color: "var(--lv4)"
|
|
1540
1534
|
})
|
|
1541
1535
|
}),
|
|
1542
|
-
/* @__PURE__ */
|
|
1543
|
-
className:
|
|
1536
|
+
/* @__PURE__ */ h("div", {
|
|
1537
|
+
className: Ge.title,
|
|
1544
1538
|
children: i
|
|
1545
1539
|
}),
|
|
1546
|
-
/* @__PURE__ */
|
|
1547
|
-
className:
|
|
1540
|
+
/* @__PURE__ */ h("div", {
|
|
1541
|
+
className: Ge.detail,
|
|
1548
1542
|
children: a
|
|
1549
1543
|
}),
|
|
1550
|
-
!n && /* @__PURE__ */
|
|
1551
|
-
className:
|
|
1544
|
+
!n && /* @__PURE__ */ h("code", {
|
|
1545
|
+
className: Ge.technical,
|
|
1552
1546
|
children: e.technical
|
|
1553
1547
|
}),
|
|
1554
|
-
s && /* @__PURE__ */
|
|
1548
|
+
s && /* @__PURE__ */ h(S, {
|
|
1555
1549
|
variant: "secondary",
|
|
1556
1550
|
size: "micro",
|
|
1557
|
-
className:
|
|
1551
|
+
className: Ge.button,
|
|
1558
1552
|
onClick: t,
|
|
1559
1553
|
children: "Try again"
|
|
1560
1554
|
})
|
|
1561
1555
|
]
|
|
1562
1556
|
});
|
|
1563
|
-
},
|
|
1564
|
-
placeholder: "
|
|
1565
|
-
invalid: "
|
|
1566
|
-
searchedFor: "
|
|
1567
|
-
|
|
1557
|
+
}, Je = {
|
|
1558
|
+
placeholder: "_placeholder_1m5kj_1",
|
|
1559
|
+
invalid: "_invalid_1m5kj_11",
|
|
1560
|
+
searchedFor: "_searchedFor_1m5kj_17",
|
|
1561
|
+
notFound: "_notFound_1m5kj_21",
|
|
1562
|
+
dimmed: "_dimmed_1m5kj_22",
|
|
1563
|
+
picksHead: "_picksHead_1m5kj_25",
|
|
1564
|
+
picksTitle: "_picksTitle_1m5kj_26",
|
|
1565
|
+
picksCount: "_picksCount_1m5kj_27",
|
|
1566
|
+
picksSpacer: "_picksSpacer_1m5kj_28",
|
|
1567
|
+
why: "_why_1m5kj_29"
|
|
1568
|
+
}, Ye = {
|
|
1568
1569
|
row: "_row_11svi_1",
|
|
1569
1570
|
content: "_content_11svi_22",
|
|
1570
1571
|
indexNumber: "_indexNumber_11svi_36",
|
|
1571
1572
|
scoreNumber: "_scoreNumber_11svi_44",
|
|
1572
1573
|
skeletonBars: "_skeletonBars_11svi_53"
|
|
1573
|
-
},
|
|
1574
|
-
className:
|
|
1574
|
+
}, Xe = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ g("div", {
|
|
1575
|
+
className: Ye.row,
|
|
1575
1576
|
children: [
|
|
1576
|
-
t !== void 0 && /* @__PURE__ */
|
|
1577
|
-
className:
|
|
1577
|
+
t !== void 0 && /* @__PURE__ */ h("div", {
|
|
1578
|
+
className: Ye.indexNumber,
|
|
1578
1579
|
children: t
|
|
1579
1580
|
}),
|
|
1580
|
-
/* @__PURE__ */
|
|
1581
|
-
className:
|
|
1582
|
-
children: e ? /* @__PURE__ */
|
|
1583
|
-
className:
|
|
1584
|
-
children: [/* @__PURE__ */
|
|
1581
|
+
/* @__PURE__ */ h("div", {
|
|
1582
|
+
className: Ye.content,
|
|
1583
|
+
children: e ? /* @__PURE__ */ g("div", {
|
|
1584
|
+
className: Ye.skeletonBars,
|
|
1585
|
+
children: [/* @__PURE__ */ h(I, {
|
|
1585
1586
|
level: 3,
|
|
1586
1587
|
height: 12,
|
|
1587
1588
|
width: `${o[0]}%`,
|
|
1588
1589
|
delay: a,
|
|
1589
1590
|
appear: !1
|
|
1590
|
-
}), /* @__PURE__ */
|
|
1591
|
+
}), /* @__PURE__ */ h(I, {
|
|
1591
1592
|
level: 3,
|
|
1592
1593
|
height: 8,
|
|
1593
1594
|
width: `${o[1]}%`,
|
|
@@ -1596,15 +1597,15 @@ var Ye = {
|
|
|
1596
1597
|
})]
|
|
1597
1598
|
}) : i
|
|
1598
1599
|
}),
|
|
1599
|
-
r && n !== void 0 && /* @__PURE__ */
|
|
1600
|
-
className:
|
|
1600
|
+
r && n !== void 0 && /* @__PURE__ */ h("div", {
|
|
1601
|
+
className: Ye.scoreNumber,
|
|
1601
1602
|
children: n
|
|
1602
1603
|
})
|
|
1603
1604
|
]
|
|
1604
|
-
}),
|
|
1605
|
+
}), Ze = {
|
|
1605
1606
|
wrapper: "_wrapper_f970z_6",
|
|
1606
1607
|
skeletonAppear: "_skeletonAppear_f970z_1"
|
|
1607
|
-
},
|
|
1608
|
+
}, Qe = [
|
|
1608
1609
|
[62, 38],
|
|
1609
1610
|
[75, 45],
|
|
1610
1611
|
[58, 33],
|
|
@@ -1613,130 +1614,363 @@ var Ye = {
|
|
|
1613
1614
|
[55, 35],
|
|
1614
1615
|
[72, 40],
|
|
1615
1616
|
[60, 30]
|
|
1616
|
-
],
|
|
1617
|
-
className:
|
|
1618
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */
|
|
1617
|
+
], $e = ({ rows: e = 6 }) => /* @__PURE__ */ h("div", {
|
|
1618
|
+
className: Ze.wrapper,
|
|
1619
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ h(Xe, {
|
|
1619
1620
|
skeleton: !0,
|
|
1620
1621
|
skeletonDelay: t * .1,
|
|
1621
|
-
skeletonWidths:
|
|
1622
|
+
skeletonWidths: Qe[t % Qe.length]
|
|
1622
1623
|
}, t))
|
|
1623
|
-
})
|
|
1624
|
-
|
|
1624
|
+
});
|
|
1625
|
+
// src/hooks/useFilterSuggestion.ts
|
|
1626
|
+
function et(e) {
|
|
1627
|
+
let t = e.trim().toLowerCase();
|
|
1628
|
+
return t === "true" || t === "false" || t !== "" && !Number.isNaN(Number(t));
|
|
1629
|
+
}
|
|
1630
|
+
function tt(e, t) {
|
|
1631
|
+
if (!t) return null;
|
|
1632
|
+
let n = [];
|
|
1633
|
+
for (let [e, r] of Object.entries(t)) for (let t of r ?? []) t?.key && t.key.trim().length >= 2 && !et(t.key) && n.push({
|
|
1634
|
+
field: e,
|
|
1635
|
+
value: t.key
|
|
1636
|
+
});
|
|
1637
|
+
n.sort((e, t) => t.value.length - e.value.length);
|
|
1638
|
+
let r = " " + e.toLowerCase() + " ", i = [];
|
|
1639
|
+
for (let e of n) {
|
|
1640
|
+
let t = " " + e.value.toLowerCase().trim() + " ", n = r.indexOf(t);
|
|
1641
|
+
n < 0 || (i.push({
|
|
1642
|
+
field: e.field,
|
|
1643
|
+
value: e.value
|
|
1644
|
+
}), r = r.slice(0, n) + " " + r.slice(n + t.length));
|
|
1645
|
+
}
|
|
1646
|
+
return i.length === 0 ? null : {
|
|
1647
|
+
filters: i,
|
|
1648
|
+
text: r.replace(/[?!.,]+\s*$/, "").replace(/\s+/g, " ").trim(),
|
|
1649
|
+
sort: null
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
function nt(e = {}) {
|
|
1653
|
+
let t = ye(), { url: n, team: r, dataset: a, authenticatedFetch: s, setQuery: u, toggleFilter: d, setRangeFilter: f, setSort: p } = t, { auto: m } = e, h = c(t);
|
|
1654
|
+
h.current = t;
|
|
1655
|
+
let [g, _] = l(null), [v, y] = l(""), [b, x] = l(!1), S = c(0), C = i(async (e) => {
|
|
1656
|
+
let t = ++S.current;
|
|
1657
|
+
x(!0);
|
|
1658
|
+
try {
|
|
1659
|
+
let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Ae(h.current)}`, {
|
|
1660
|
+
method: "POST",
|
|
1661
|
+
headers: { "Content-Type": "application/json" },
|
|
1662
|
+
body: JSON.stringify({ text: e })
|
|
1663
|
+
});
|
|
1664
|
+
if (t !== S.current) return;
|
|
1665
|
+
let o = i.ok ? await i.json() : null;
|
|
1666
|
+
_(o && o.filters.length > 0 ? o : null), y(e);
|
|
1667
|
+
} catch {
|
|
1668
|
+
t === S.current && _(null);
|
|
1669
|
+
} finally {
|
|
1670
|
+
t === S.current && x(!1);
|
|
1671
|
+
}
|
|
1672
|
+
}, [
|
|
1673
|
+
n,
|
|
1674
|
+
r,
|
|
1675
|
+
a,
|
|
1676
|
+
s
|
|
1677
|
+
]), w = i((e) => {
|
|
1678
|
+
u(e.text);
|
|
1679
|
+
let t = {
|
|
1680
|
+
...h.current.state.rangeBounds,
|
|
1681
|
+
...h.current.datasetBounds
|
|
1682
|
+
};
|
|
1683
|
+
for (let n of e.filters) n.value == null ? f(n.field, n.min ?? t[n.field]?.min ?? 0, n.max ?? t[n.field]?.max ?? 2 ** 53 - 1) : d(n.field, n.value);
|
|
1684
|
+
e.sort && p(e.sort.field, !e.sort.descending), _(null);
|
|
1685
|
+
}, [
|
|
1686
|
+
u,
|
|
1687
|
+
d,
|
|
1688
|
+
f,
|
|
1689
|
+
p
|
|
1690
|
+
]), T = i(() => {
|
|
1691
|
+
S.current++, _(null), x(!1);
|
|
1692
|
+
}, []), E = c(/* @__PURE__ */ new Set()), [D, O] = l(null), k = m?.filtersWhileTyping ?? "off", A = !!m && m.available && m.describes && m.offer === "strong" && k !== "off", j = m?.text ?? "", M = c(j);
|
|
1693
|
+
M.current = j;
|
|
1694
|
+
let N = t.state.facets, P = t.state.isLoading || t.facetsEnabled && N == null;
|
|
1695
|
+
return o(() => {
|
|
1696
|
+
if (!A || !j || P || E.current.has(j)) return;
|
|
1697
|
+
E.current.add(j);
|
|
1698
|
+
let e = tt(j, N);
|
|
1699
|
+
if (e && (E.current.add(e.text), w(e), O(j)), k !== "model") return;
|
|
1700
|
+
let t = e ? e.text : j;
|
|
1701
|
+
if (!t) return;
|
|
1702
|
+
let i = () => M.current === j || M.current === t;
|
|
1703
|
+
(async () => {
|
|
1704
|
+
let o = ++S.current;
|
|
1705
|
+
x(!0);
|
|
1706
|
+
try {
|
|
1707
|
+
let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${Ae(h.current)}`, {
|
|
1708
|
+
method: "POST",
|
|
1709
|
+
headers: { "Content-Type": "application/json" },
|
|
1710
|
+
body: JSON.stringify({ text: t })
|
|
1711
|
+
});
|
|
1712
|
+
if (o !== S.current || !i()) return;
|
|
1713
|
+
let l = c.ok ? await c.json() : null;
|
|
1714
|
+
l && l.filters.length > 0 && (E.current.add(l.text), w({
|
|
1715
|
+
filters: [...e?.filters ?? [], ...l.filters],
|
|
1716
|
+
text: l.text,
|
|
1717
|
+
sort: l.sort
|
|
1718
|
+
}), O(j));
|
|
1719
|
+
} catch {} finally {
|
|
1720
|
+
o === S.current && x(!1);
|
|
1721
|
+
}
|
|
1722
|
+
})();
|
|
1723
|
+
}, [
|
|
1724
|
+
A,
|
|
1725
|
+
j,
|
|
1726
|
+
k,
|
|
1727
|
+
P,
|
|
1728
|
+
N,
|
|
1729
|
+
w,
|
|
1730
|
+
n,
|
|
1731
|
+
r,
|
|
1732
|
+
a,
|
|
1733
|
+
s
|
|
1734
|
+
]), {
|
|
1735
|
+
suggestion: g,
|
|
1736
|
+
forText: v,
|
|
1737
|
+
loading: b,
|
|
1738
|
+
suggest: C,
|
|
1739
|
+
apply: w,
|
|
1740
|
+
clear: T,
|
|
1741
|
+
appliedText: D
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
// src/components/SearchResults.tsx
|
|
1745
|
+
var rt = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
1746
|
+
function it(e) {
|
|
1625
1747
|
let t = e.trim();
|
|
1626
1748
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
1627
1749
|
try {
|
|
1628
1750
|
let e = JSON.parse(t);
|
|
1629
1751
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
1630
1752
|
} catch {}
|
|
1631
|
-
if (!
|
|
1753
|
+
if (!rt.test(t)) return;
|
|
1632
1754
|
let n = [], r = /'([^']*)'/g, i;
|
|
1633
1755
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
1634
1756
|
return n;
|
|
1635
1757
|
}
|
|
1636
|
-
|
|
1637
|
-
let
|
|
1758
|
+
function at(e, t, n) {
|
|
1759
|
+
let r;
|
|
1760
|
+
try {
|
|
1761
|
+
r = typeof e == "string" ? JSON.parse(e) : e;
|
|
1762
|
+
} catch {
|
|
1763
|
+
return null;
|
|
1764
|
+
}
|
|
1765
|
+
let i;
|
|
1766
|
+
if (t && t.length > 0) {
|
|
1767
|
+
i = {};
|
|
1768
|
+
for (let e of t) e in r && (i[e] = r[e]);
|
|
1769
|
+
} else i = { ...r };
|
|
1770
|
+
if (n) for (let e in i) {
|
|
1771
|
+
let t = i[e];
|
|
1772
|
+
if (typeof t == "string") {
|
|
1773
|
+
let n = it(t);
|
|
1774
|
+
n && (i[e] = n);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
return i;
|
|
1778
|
+
}
|
|
1779
|
+
var ot = ({ picks: e, fields: t, parseArrayStrings: n, label: r, onShowSearch: i, children: a }) => {
|
|
1780
|
+
let { url: s, team: c, dataset: u, authenticatedFetch: d, count: f } = ye(), [p, _] = l(null);
|
|
1638
1781
|
o(() => {
|
|
1639
|
-
let
|
|
1640
|
-
(
|
|
1782
|
+
let t = !1;
|
|
1783
|
+
_(null);
|
|
1784
|
+
let n = e.picks.map((e) => e.documentKey);
|
|
1785
|
+
return (async () => {
|
|
1786
|
+
try {
|
|
1787
|
+
let e = await d(`${s}/api/teams/${c}/datasets/${u}/documents/lookup`, {
|
|
1788
|
+
method: "POST",
|
|
1789
|
+
headers: { "Content-Type": "application/json" },
|
|
1790
|
+
body: JSON.stringify(n)
|
|
1791
|
+
}), r = e.ok ? await e.json() : [];
|
|
1792
|
+
t || _(new Map(n.map((e, t) => [e, r[t]])));
|
|
1793
|
+
} catch {
|
|
1794
|
+
t || _(/* @__PURE__ */ new Map());
|
|
1795
|
+
}
|
|
1796
|
+
})(), () => {
|
|
1797
|
+
t = !0;
|
|
1798
|
+
};
|
|
1641
1799
|
}, [
|
|
1800
|
+
e,
|
|
1642
1801
|
s,
|
|
1643
|
-
|
|
1644
|
-
|
|
1802
|
+
c,
|
|
1803
|
+
u,
|
|
1804
|
+
d
|
|
1645
1805
|
]);
|
|
1646
|
-
let
|
|
1647
|
-
|
|
1648
|
-
|
|
1806
|
+
let v = (t, n) => async () => {
|
|
1807
|
+
if (e.askId) try {
|
|
1808
|
+
await d(`${s}/api/teams/${c}/datasets/${u}/events/select`, {
|
|
1809
|
+
method: "POST",
|
|
1810
|
+
headers: { "Content-Type": "application/json" },
|
|
1811
|
+
body: JSON.stringify({
|
|
1812
|
+
queryId: e.askId,
|
|
1813
|
+
documentKey: t,
|
|
1814
|
+
position: n,
|
|
1815
|
+
...f === !1 ? { count: !1 } : {}
|
|
1816
|
+
})
|
|
1817
|
+
});
|
|
1818
|
+
} catch {}
|
|
1819
|
+
}, y = e.search;
|
|
1820
|
+
return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g("div", {
|
|
1821
|
+
className: Je.picksHead,
|
|
1822
|
+
children: [
|
|
1823
|
+
/* @__PURE__ */ g("span", {
|
|
1824
|
+
className: Je.picksTitle,
|
|
1825
|
+
children: [/* @__PURE__ */ h(H, {
|
|
1826
|
+
size: 14,
|
|
1827
|
+
color: "currentColor"
|
|
1828
|
+
}), r]
|
|
1829
|
+
}),
|
|
1830
|
+
/* @__PURE__ */ h("span", {
|
|
1831
|
+
className: Je.picksCount,
|
|
1832
|
+
children: e.picks.length
|
|
1833
|
+
}),
|
|
1834
|
+
/* @__PURE__ */ h("span", { className: Je.picksSpacer }),
|
|
1835
|
+
i && /* @__PURE__ */ h(S, {
|
|
1836
|
+
variant: "ghost",
|
|
1837
|
+
size: "micro",
|
|
1838
|
+
onClick: i,
|
|
1839
|
+
children: y ? `Show all ${y.found}${y.more ? "+" : ""} found` : "Show the search instead"
|
|
1840
|
+
})
|
|
1841
|
+
]
|
|
1842
|
+
}), p === null ? /* @__PURE__ */ h($e, { rows: Math.max(1, e.picks.length) }) : /* @__PURE__ */ h("div", { children: e.picks.map((e) => {
|
|
1843
|
+
let r = p.get(e.documentKey), i = r == null ? null : at(r, t, n);
|
|
1844
|
+
return i ? /* @__PURE__ */ g(Xe, {
|
|
1845
|
+
index: e.n,
|
|
1846
|
+
showScore: !1,
|
|
1847
|
+
children: [a(i, {
|
|
1848
|
+
result: {
|
|
1849
|
+
document: r,
|
|
1850
|
+
documentKey: e.documentKey,
|
|
1851
|
+
score: 0,
|
|
1852
|
+
position: e.n
|
|
1853
|
+
},
|
|
1854
|
+
select: v(e.documentKey, e.n)
|
|
1855
|
+
}), e.why && /* @__PURE__ */ g("div", {
|
|
1856
|
+
className: Je.why,
|
|
1857
|
+
children: [/* @__PURE__ */ h(H, {
|
|
1858
|
+
size: 12,
|
|
1859
|
+
color: "currentColor"
|
|
1860
|
+
}), /* @__PURE__ */ h("span", { children: e.why })]
|
|
1861
|
+
})]
|
|
1862
|
+
}, e.documentKey) : null;
|
|
1863
|
+
}) })] });
|
|
1864
|
+
}, st = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk: r, notFoundLabel: i = "These results may not hold what you are asking about", picks: a, onShowSearch: s, picksLabel: u = "Picked by the assistant", showScore: d, children: f }) => {
|
|
1865
|
+
let { state: { results: p, resultsSuppressed: _, searchSettings: v, countedTotal: y, query: b, error: x, errorInfo: C }, isFetchingInitial: w, authError: T, authErrorInfo: E, retry: D, allowEmptySearch: O, fetchMoreResults: k, selectResult: A, searchText: j, searchAsTyped: M, picks: N, showPicks: P } = ye(), { apply: F } = nt(), I = a === void 0 ? N : a, L = s ?? (() => {
|
|
1866
|
+
I?.search && F(I.search), P?.(null);
|
|
1867
|
+
}), R = c(null);
|
|
1868
|
+
I && R.current?.picks !== I && (R.current = {
|
|
1869
|
+
picks: I,
|
|
1870
|
+
query: b
|
|
1871
|
+
});
|
|
1872
|
+
let z = !!I && R.current?.query === b, B = t ?? 30, [V, H] = l(B), U = c(0), W = c("");
|
|
1873
|
+
o(() => {
|
|
1874
|
+
let e = b !== W.current;
|
|
1875
|
+
(!p || p.length < U.current || e) && H(B), U.current = p?.length ?? 0, W.current = b;
|
|
1876
|
+
}, [
|
|
1877
|
+
p,
|
|
1878
|
+
B,
|
|
1879
|
+
b
|
|
1880
|
+
]);
|
|
1881
|
+
let G = p ?? [], K = !!r?.notFound, ee = j != null && j.trim() !== b.trim() ? j : null, q = !!p && p.length >= v.maxNumberOfRecordsToReturn && (y === void 0 || y > p.length), ne = !!p && (G.length > V || q), J = () => {
|
|
1882
|
+
let e = V + B;
|
|
1883
|
+
H(e), p && e >= p.length && q && k(p.length + B);
|
|
1649
1884
|
};
|
|
1650
|
-
if (
|
|
1651
|
-
|
|
1652
|
-
|
|
1885
|
+
if (I && z && !w && !T) return /* @__PURE__ */ h(ot, {
|
|
1886
|
+
picks: I,
|
|
1887
|
+
fields: e,
|
|
1888
|
+
parseArrayStrings: n,
|
|
1889
|
+
label: u,
|
|
1890
|
+
onShowSearch: L,
|
|
1891
|
+
children: f
|
|
1892
|
+
});
|
|
1893
|
+
if (w) return O ? /* @__PURE__ */ h($e, { rows: B }) : /* @__PURE__ */ h("div", {
|
|
1894
|
+
className: Je.placeholder,
|
|
1895
|
+
children: /* @__PURE__ */ h(te, {
|
|
1653
1896
|
size: 200,
|
|
1654
1897
|
color: "var(--lv5)"
|
|
1655
1898
|
})
|
|
1656
1899
|
});
|
|
1657
|
-
let
|
|
1658
|
-
return
|
|
1659
|
-
error: (
|
|
1900
|
+
let Y = T ?? x;
|
|
1901
|
+
return Y ? /* @__PURE__ */ h(qe, {
|
|
1902
|
+
error: (T ? E : C) ?? {
|
|
1660
1903
|
kind: "unknown",
|
|
1661
|
-
message:
|
|
1662
|
-
technical:
|
|
1904
|
+
message: Y,
|
|
1905
|
+
technical: Y,
|
|
1663
1906
|
retryable: !1
|
|
1664
1907
|
},
|
|
1665
|
-
onRetry:
|
|
1666
|
-
}) :
|
|
1667
|
-
className:
|
|
1668
|
-
children: /* @__PURE__ */
|
|
1908
|
+
onRetry: D
|
|
1909
|
+
}) : _ || p === null ? /* @__PURE__ */ h("div", {
|
|
1910
|
+
className: Je.placeholder,
|
|
1911
|
+
children: /* @__PURE__ */ h(te, {
|
|
1669
1912
|
size: 200,
|
|
1670
1913
|
color: "var(--lv5)"
|
|
1671
1914
|
})
|
|
1672
|
-
}) :
|
|
1673
|
-
|
|
1674
|
-
className:
|
|
1915
|
+
}) : G.length === 0 ? null : /* @__PURE__ */ g(m, { children: [
|
|
1916
|
+
ee && /* @__PURE__ */ g("div", {
|
|
1917
|
+
className: Je.searchedFor,
|
|
1675
1918
|
"aria-live": "polite",
|
|
1676
|
-
children: [/* @__PURE__ */
|
|
1919
|
+
children: [/* @__PURE__ */ g("span", { children: ["Searching for ", /* @__PURE__ */ h("strong", { children: ee })] }), M && /* @__PURE__ */ h(S, {
|
|
1677
1920
|
variant: "ghost",
|
|
1678
1921
|
size: "micro",
|
|
1679
|
-
onClick:
|
|
1922
|
+
onClick: M,
|
|
1680
1923
|
children: "Search for your exact words"
|
|
1681
1924
|
})]
|
|
1682
1925
|
}),
|
|
1683
|
-
/* @__PURE__ */
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1926
|
+
K && /* @__PURE__ */ h("p", {
|
|
1927
|
+
className: Je.notFound,
|
|
1928
|
+
"aria-live": "polite",
|
|
1929
|
+
children: i
|
|
1930
|
+
}),
|
|
1931
|
+
/* @__PURE__ */ h("div", {
|
|
1932
|
+
className: K ? Je.dimmed : void 0,
|
|
1933
|
+
children: G.slice(0, V).map((t, r) => {
|
|
1934
|
+
let i = t.score, a = at(t.document, e, n);
|
|
1935
|
+
return a ? /* @__PURE__ */ h(Xe, {
|
|
1936
|
+
index: r,
|
|
1937
|
+
score: i,
|
|
1938
|
+
showScore: d ?? v.showScore,
|
|
1939
|
+
children: f(a, {
|
|
1940
|
+
result: t,
|
|
1941
|
+
select: () => A?.(t) ?? Promise.resolve()
|
|
1942
|
+
})
|
|
1943
|
+
}, r) : /* @__PURE__ */ h("div", {
|
|
1944
|
+
className: Je.invalid,
|
|
1945
|
+
children: /* @__PURE__ */ h("p", { children: "Invalid JSON" })
|
|
1691
1946
|
}, r);
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
l = {};
|
|
1696
|
-
for (let t of e) t in c && (l[t] = c[t]);
|
|
1697
|
-
} else l = { ...c };
|
|
1698
|
-
if (n) for (let e in l) {
|
|
1699
|
-
let t = l[e];
|
|
1700
|
-
if (typeof t == "string") {
|
|
1701
|
-
let n = st(t);
|
|
1702
|
-
n && (l[e] = n);
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
return /* @__PURE__ */ f(nt, {
|
|
1706
|
-
index: r,
|
|
1707
|
-
score: s,
|
|
1708
|
-
showScore: i ?? m.showScore,
|
|
1709
|
-
children: a(l, {
|
|
1710
|
-
result: t,
|
|
1711
|
-
select: () => E?.(t) ?? Promise.resolve()
|
|
1712
|
-
})
|
|
1713
|
-
}, r);
|
|
1714
|
-
}) }),
|
|
1715
|
-
L && /* @__PURE__ */ f("div", {
|
|
1947
|
+
})
|
|
1948
|
+
}),
|
|
1949
|
+
ne && /* @__PURE__ */ h("div", {
|
|
1716
1950
|
style: {
|
|
1717
1951
|
textAlign: "center",
|
|
1718
1952
|
marginTop: "20px"
|
|
1719
1953
|
},
|
|
1720
|
-
children: /* @__PURE__ */
|
|
1954
|
+
children: /* @__PURE__ */ h(S, {
|
|
1721
1955
|
variant: "secondary",
|
|
1722
1956
|
size: "micro",
|
|
1723
|
-
onClick:
|
|
1724
|
-
children:
|
|
1957
|
+
onClick: J,
|
|
1958
|
+
children: b.trim() === "" ? "Load more" : y !== void 0 && y > 0 ? `Load results ${V + 1}-${Math.min(V + B, p.length, y)} of ${y}` : "Load more"
|
|
1725
1959
|
})
|
|
1726
1960
|
})
|
|
1727
1961
|
] });
|
|
1728
|
-
},
|
|
1962
|
+
}, ct = {
|
|
1729
1963
|
row: "_row_ujwhc_1",
|
|
1730
1964
|
title: "_title_ujwhc_8"
|
|
1731
|
-
},
|
|
1732
|
-
className: [
|
|
1965
|
+
}, lt = ({ variant: e = "default", children: t }) => /* @__PURE__ */ h("div", {
|
|
1966
|
+
className: [ct.row, e === "title" ? ct.title : ""].filter(Boolean).join(" "),
|
|
1733
1967
|
children: t
|
|
1734
|
-
}),
|
|
1968
|
+
}), ut = {
|
|
1735
1969
|
listRows: "_listRows_13obt_2",
|
|
1736
1970
|
sliderArea: "_sliderArea_13obt_8",
|
|
1737
1971
|
inputRow: "_inputRow_13obt_15",
|
|
1738
1972
|
histogramRow: "_histogramRow_13obt_22"
|
|
1739
|
-
},
|
|
1973
|
+
}, dt = [
|
|
1740
1974
|
65,
|
|
1741
1975
|
80,
|
|
1742
1976
|
55,
|
|
@@ -1745,36 +1979,36 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1745
1979
|
75,
|
|
1746
1980
|
50,
|
|
1747
1981
|
68
|
|
1748
|
-
],
|
|
1982
|
+
], ft = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ h(O, {
|
|
1749
1983
|
title: e,
|
|
1750
1984
|
collapsible: i,
|
|
1751
1985
|
collapsed: a,
|
|
1752
|
-
children: n === "slider" ? /* @__PURE__ */
|
|
1753
|
-
className:
|
|
1986
|
+
children: n === "slider" ? /* @__PURE__ */ g("div", {
|
|
1987
|
+
className: ut.sliderArea,
|
|
1754
1988
|
children: [
|
|
1755
|
-
r && /* @__PURE__ */
|
|
1756
|
-
/* @__PURE__ */
|
|
1757
|
-
/* @__PURE__ */
|
|
1758
|
-
className:
|
|
1759
|
-
children: [/* @__PURE__ */
|
|
1989
|
+
r && /* @__PURE__ */ h("div", { className: ut.histogramRow }),
|
|
1990
|
+
/* @__PURE__ */ h(I, { height: 6 }),
|
|
1991
|
+
/* @__PURE__ */ g("div", {
|
|
1992
|
+
className: ut.inputRow,
|
|
1993
|
+
children: [/* @__PURE__ */ h(I, {
|
|
1760
1994
|
width: 40,
|
|
1761
1995
|
height: 20,
|
|
1762
1996
|
delay: .1
|
|
1763
|
-
}), /* @__PURE__ */
|
|
1997
|
+
}), /* @__PURE__ */ h(I, {
|
|
1764
1998
|
width: 40,
|
|
1765
1999
|
height: 20,
|
|
1766
2000
|
delay: .15
|
|
1767
2001
|
})]
|
|
1768
2002
|
})
|
|
1769
2003
|
]
|
|
1770
|
-
}) : /* @__PURE__ */
|
|
1771
|
-
className:
|
|
1772
|
-
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */
|
|
1773
|
-
width: `${
|
|
2004
|
+
}) : /* @__PURE__ */ h("div", {
|
|
2005
|
+
className: ut.listRows,
|
|
2006
|
+
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ h(I, {
|
|
2007
|
+
width: `${dt[t % dt.length]}%`,
|
|
1774
2008
|
delay: t * .05
|
|
1775
2009
|
}, t))
|
|
1776
2010
|
})
|
|
1777
|
-
}),
|
|
2011
|
+
}), pt = {
|
|
1778
2012
|
list: "_list_18vbb_2",
|
|
1779
2013
|
count: "_count_18vbb_7",
|
|
1780
2014
|
countValue: "_countValue_18vbb_17",
|
|
@@ -1789,12 +2023,12 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1789
2023
|
let r = n.map((e) => e[0].toUpperCase() + e.slice(1)).join(" and ");
|
|
1790
2024
|
return o(() => {
|
|
1791
2025
|
console.warn(`[intrface] The panel for "${t}" is hidden: the field is not ${r}. Mark it ${r} in the dataset's field configuration (web console β Fields).`);
|
|
1792
|
-
}, [t, r]), /* @__PURE__ */
|
|
2026
|
+
}, [t, r]), /* @__PURE__ */ h(O, {
|
|
1793
2027
|
title: e ?? t,
|
|
1794
2028
|
collapsible: !1,
|
|
1795
|
-
children: /* @__PURE__ */
|
|
2029
|
+
children: /* @__PURE__ */ g("div", {
|
|
1796
2030
|
className: mt.notice,
|
|
1797
|
-
children: [/* @__PURE__ */
|
|
2031
|
+
children: [/* @__PURE__ */ h("span", { children: "Not available" }), /* @__PURE__ */ g("code", {
|
|
1798
2032
|
className: mt.technical,
|
|
1799
2033
|
children: [
|
|
1800
2034
|
t,
|
|
@@ -1804,65 +2038,65 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1804
2038
|
})]
|
|
1805
2039
|
})
|
|
1806
2040
|
});
|
|
1807
|
-
}, gt = ({ field: e, label: t, preserveBlankFacetState: n = !1, preserveBlankFacetStateOrder: r = !1, sortFacetsBy: i = "histogram", limit: a = 10, collapsible: s = !0, startCollapsed: u = !1, control: d, displayType:
|
|
1808
|
-
let { state: { facets: w, filterableFields:
|
|
2041
|
+
}, gt = ({ field: e, label: t, preserveBlankFacetState: n = !1, preserveBlankFacetStateOrder: r = !1, sortFacetsBy: i = "histogram", limit: a = 10, collapsible: s = !0, startCollapsed: u = !1, control: d, displayType: f, layout: p = "list", showActivePanel: m = !1, showCount: _ = !0, showNull: v = !1, match: y = "all", displayIfEmptyQuery: b = !0, displayCondition: x = (e) => !0 }) => {
|
|
2042
|
+
let { state: { facets: w, filterableFields: T, facetableFields: E, filters: D, query: k }, toggleFilter: A, setValueMatch: j, authError: N, isFetchingInitial: P, allowEmptySearch: F } = ye(), I = d ?? f ?? "checkbox", L = I === "radio" ? "any" : y;
|
|
1809
2043
|
o(() => {
|
|
1810
|
-
|
|
2044
|
+
j(e, L);
|
|
1811
2045
|
}, [
|
|
1812
2046
|
e,
|
|
1813
|
-
|
|
1814
|
-
|
|
2047
|
+
L,
|
|
2048
|
+
j
|
|
1815
2049
|
]);
|
|
1816
|
-
let
|
|
2050
|
+
let R = c(null), [B, V] = l(a);
|
|
1817
2051
|
if (o(() => {
|
|
1818
2052
|
V(a);
|
|
1819
|
-
}, [w?.[e], a]), !F && !
|
|
1820
|
-
if (P || !w) return
|
|
2053
|
+
}, [w?.[e], a]), !F && !k || N) return null;
|
|
2054
|
+
if (P || !w) return I === "toggle" ? /* @__PURE__ */ h(ft, {
|
|
1821
2055
|
rows: 1,
|
|
1822
2056
|
collapsible: !1
|
|
1823
|
-
}) : /* @__PURE__ */
|
|
2057
|
+
}) : /* @__PURE__ */ h(ft, {
|
|
1824
2058
|
title: t,
|
|
1825
2059
|
rows: Math.min(a, 6),
|
|
1826
2060
|
collapsible: s,
|
|
1827
2061
|
startCollapsed: u
|
|
1828
2062
|
});
|
|
1829
|
-
if (!
|
|
1830
|
-
query:
|
|
1831
|
-
filters:
|
|
2063
|
+
if (!x({
|
|
2064
|
+
query: k ?? "",
|
|
2065
|
+
filters: D,
|
|
1832
2066
|
facets: w
|
|
1833
|
-
}) || !
|
|
1834
|
-
if (!
|
|
2067
|
+
}) || !b && !k && Object.keys(D).length < 1) return null;
|
|
2068
|
+
if (!T?.includes(e) || !E?.includes(e)) {
|
|
1835
2069
|
let n = [];
|
|
1836
|
-
return
|
|
2070
|
+
return T?.includes(e) || n.push("filterable"), E?.includes(e) || n.push("facetable"), /* @__PURE__ */ h(ht, {
|
|
1837
2071
|
label: t,
|
|
1838
2072
|
field: e,
|
|
1839
2073
|
missing: n
|
|
1840
2074
|
});
|
|
1841
2075
|
}
|
|
1842
|
-
let H = w?.[e] ?? (
|
|
2076
|
+
let H = w?.[e] ?? (I === "toggle" ? [] : void 0);
|
|
1843
2077
|
if (!H || !Array.isArray(H)) return null;
|
|
1844
|
-
let U =
|
|
1845
|
-
n && !
|
|
2078
|
+
let U = D?.[e] ?? [];
|
|
2079
|
+
n && !R.current && H.length > 0 && (R.current = H.reduce((e, t) => (e[t.key] = t.value, e), {}));
|
|
1846
2080
|
let W = /* @__PURE__ */ new Map();
|
|
1847
|
-
n &&
|
|
2081
|
+
n && R.current && Object.keys(R.current).forEach((e) => {
|
|
1848
2082
|
W.set(e, 0);
|
|
1849
2083
|
}), H.forEach((e) => {
|
|
1850
2084
|
W.set(e.key, e.value);
|
|
1851
2085
|
});
|
|
1852
|
-
let
|
|
2086
|
+
let G = /* @__PURE__ */ new Set([
|
|
1853
2087
|
"true",
|
|
1854
2088
|
"false",
|
|
1855
2089
|
"null"
|
|
1856
|
-
]),
|
|
1857
|
-
if (
|
|
2090
|
+
]), K = Array.from(W.keys()), ee = I === "toggle" && (K.length > 0 && K.every((e) => G.has(e)) || K.length === 0 && U.length > 0);
|
|
2091
|
+
if (ee && W.has("null")) {
|
|
1858
2092
|
let e = W.get("null") ?? 0, t = W.get("false") ?? 0;
|
|
1859
2093
|
W.set("false", t + e), W.delete("null");
|
|
1860
2094
|
}
|
|
1861
|
-
if (
|
|
2095
|
+
if (I === "toggle" && !ee) return /* @__PURE__ */ h(O, {
|
|
1862
2096
|
collapsible: !1,
|
|
1863
|
-
children: /* @__PURE__ */
|
|
1864
|
-
className:
|
|
1865
|
-
children: /* @__PURE__ */
|
|
2097
|
+
children: /* @__PURE__ */ h("div", {
|
|
2098
|
+
className: pt.count,
|
|
2099
|
+
children: /* @__PURE__ */ h(z, {
|
|
1866
2100
|
label: t,
|
|
1867
2101
|
checked: !1,
|
|
1868
2102
|
onChange: () => {},
|
|
@@ -1870,17 +2104,17 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1870
2104
|
})
|
|
1871
2105
|
})
|
|
1872
2106
|
});
|
|
1873
|
-
if (
|
|
2107
|
+
if (ee) {
|
|
1874
2108
|
let n = W.get("true"), r = typeof n == "number" ? n : null, i = U.includes("true"), a = r === 0 && !i, o = _ && (r ?? 0) > 0 ? `${r}` : "";
|
|
1875
|
-
return /* @__PURE__ */
|
|
2109
|
+
return /* @__PURE__ */ h(O, {
|
|
1876
2110
|
collapsible: !1,
|
|
1877
|
-
children: /* @__PURE__ */
|
|
1878
|
-
className:
|
|
2111
|
+
children: /* @__PURE__ */ g("div", {
|
|
2112
|
+
className: pt.count,
|
|
1879
2113
|
children: [
|
|
1880
|
-
/* @__PURE__ */
|
|
2114
|
+
/* @__PURE__ */ h(z, {
|
|
1881
2115
|
label: t,
|
|
1882
2116
|
checked: i,
|
|
1883
|
-
onChange: () =>
|
|
2117
|
+
onChange: () => A(e, "true"),
|
|
1884
2118
|
disabled: a
|
|
1885
2119
|
}),
|
|
1886
2120
|
" ",
|
|
@@ -1889,92 +2123,92 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1889
2123
|
})
|
|
1890
2124
|
});
|
|
1891
2125
|
}
|
|
1892
|
-
let
|
|
1893
|
-
if (v || (
|
|
2126
|
+
let q = Array.from(W.entries());
|
|
2127
|
+
if (v || (q = q.filter(([e]) => e !== "null")), q.length === 0 && !n) return null;
|
|
1894
2128
|
if (!r) {
|
|
1895
2129
|
if (i === "alphabetical") {
|
|
1896
|
-
let e =
|
|
1897
|
-
|
|
2130
|
+
let e = q.filter(([, e]) => typeof e == "number" && e > 0).sort(([e], [t]) => e.localeCompare(t)), t = q.filter(([, e]) => e === 0 || e === null).sort(([e], [t]) => e.localeCompare(t));
|
|
2131
|
+
q = [...e, ...t];
|
|
1898
2132
|
} else if (i === "numeric") {
|
|
1899
2133
|
let e = (e, t) => {
|
|
1900
2134
|
let n = Number(e), r = Number(t);
|
|
1901
2135
|
return !isNaN(n) && !isNaN(r) ? n - r : e.localeCompare(t);
|
|
1902
|
-
}, t =
|
|
1903
|
-
|
|
2136
|
+
}, t = q.filter(([, e]) => typeof e == "number" && e > 0).sort(([t], [n]) => e(t, n)), n = q.filter(([, e]) => e === 0 || e === null).sort(([t], [n]) => e(t, n));
|
|
2137
|
+
q = [...t, ...n];
|
|
1904
2138
|
} else {
|
|
1905
|
-
let e =
|
|
1906
|
-
|
|
2139
|
+
let e = q.filter(([, e]) => typeof e == "number" && e > 0), t = q.filter(([, e]) => e === 0 || e === null);
|
|
2140
|
+
q = [...e, ...t];
|
|
1907
2141
|
}
|
|
1908
2142
|
}
|
|
1909
|
-
let
|
|
1910
|
-
let r = U.includes(t), i = n === 0, a = _ && (n ?? 0) > 0 ? ` (${n})` : "", o = _ && (n ?? 0) > 0 ? n : "", s = () =>
|
|
1911
|
-
switch (
|
|
1912
|
-
case "button": return
|
|
1913
|
-
className:
|
|
1914
|
-
children: [/* @__PURE__ */
|
|
2143
|
+
let te = typeof a == "number" && q.length > a, ne = te ? q.slice(0, B) : q, J = (t, n) => {
|
|
2144
|
+
let r = U.includes(t), i = n === 0, a = _ && (n ?? 0) > 0 ? ` (${n})` : "", o = _ && (n ?? 0) > 0 ? n : "", s = () => A(e, t, I === "radio");
|
|
2145
|
+
switch (I) {
|
|
2146
|
+
case "button": return p === "list" ? /* @__PURE__ */ g("div", {
|
|
2147
|
+
className: pt.count,
|
|
2148
|
+
children: [/* @__PURE__ */ h(S, {
|
|
1915
2149
|
variant: r ? "primary" : "secondary",
|
|
1916
2150
|
onClick: s,
|
|
1917
2151
|
disabled: i,
|
|
1918
2152
|
size: "micro",
|
|
1919
|
-
className:
|
|
2153
|
+
className: pt.chip,
|
|
1920
2154
|
title: t,
|
|
1921
|
-
children: /* @__PURE__ */
|
|
1922
|
-
className:
|
|
2155
|
+
children: /* @__PURE__ */ h("span", {
|
|
2156
|
+
className: pt.chipLabel,
|
|
1923
2157
|
children: t
|
|
1924
2158
|
})
|
|
1925
|
-
}), /* @__PURE__ */
|
|
1926
|
-
className:
|
|
2159
|
+
}), /* @__PURE__ */ h("span", {
|
|
2160
|
+
className: pt.countValue,
|
|
1927
2161
|
children: o
|
|
1928
2162
|
})]
|
|
1929
|
-
}) : /* @__PURE__ */
|
|
2163
|
+
}) : /* @__PURE__ */ h(S, {
|
|
1930
2164
|
variant: r ? "primary" : "secondary",
|
|
1931
2165
|
onClick: s,
|
|
1932
2166
|
disabled: i,
|
|
1933
2167
|
size: "micro",
|
|
1934
|
-
className:
|
|
2168
|
+
className: pt.chip,
|
|
1935
2169
|
title: `${t}${a}`,
|
|
1936
|
-
children: /* @__PURE__ */
|
|
1937
|
-
className:
|
|
2170
|
+
children: /* @__PURE__ */ h("span", {
|
|
2171
|
+
className: pt.chipLabel,
|
|
1938
2172
|
children: `${t}${a}`
|
|
1939
2173
|
})
|
|
1940
2174
|
});
|
|
1941
|
-
case "toggle": return /* @__PURE__ */
|
|
2175
|
+
case "toggle": return /* @__PURE__ */ h(z, {
|
|
1942
2176
|
label: t,
|
|
1943
2177
|
checked: r,
|
|
1944
2178
|
onChange: s,
|
|
1945
2179
|
disabled: i
|
|
1946
2180
|
});
|
|
1947
2181
|
case "radio": {
|
|
1948
|
-
let n = /* @__PURE__ */
|
|
2182
|
+
let n = /* @__PURE__ */ h(M, {
|
|
1949
2183
|
id: `${e}-${t}`,
|
|
1950
2184
|
name: e,
|
|
1951
2185
|
value: t,
|
|
1952
|
-
label:
|
|
2186
|
+
label: p === "grid" ? `${t}${a}` : t,
|
|
1953
2187
|
checked: r,
|
|
1954
2188
|
onChange: s,
|
|
1955
2189
|
disabled: i
|
|
1956
2190
|
});
|
|
1957
|
-
return
|
|
1958
|
-
className:
|
|
1959
|
-
children: [n, /* @__PURE__ */
|
|
1960
|
-
className:
|
|
2191
|
+
return p === "list" ? /* @__PURE__ */ g("div", {
|
|
2192
|
+
className: pt.count,
|
|
2193
|
+
children: [n, /* @__PURE__ */ h("span", {
|
|
2194
|
+
className: pt.countValue,
|
|
1961
2195
|
children: o
|
|
1962
2196
|
})]
|
|
1963
2197
|
}) : n;
|
|
1964
2198
|
}
|
|
1965
|
-
default: return
|
|
1966
|
-
className:
|
|
1967
|
-
children: [/* @__PURE__ */
|
|
2199
|
+
default: return p === "list" ? /* @__PURE__ */ g("div", {
|
|
2200
|
+
className: pt.count,
|
|
2201
|
+
children: [/* @__PURE__ */ h(C, {
|
|
1968
2202
|
label: t,
|
|
1969
2203
|
score: "",
|
|
1970
2204
|
checked: r,
|
|
1971
2205
|
onChange: s,
|
|
1972
2206
|
disabled: i
|
|
1973
|
-
}), /* @__PURE__ */
|
|
1974
|
-
className:
|
|
2207
|
+
}), /* @__PURE__ */ h("span", {
|
|
2208
|
+
className: pt.countValue,
|
|
1975
2209
|
children: o
|
|
1976
2210
|
})]
|
|
1977
|
-
}) : /* @__PURE__ */
|
|
2211
|
+
}) : /* @__PURE__ */ h(C, {
|
|
1978
2212
|
label: t,
|
|
1979
2213
|
score: a,
|
|
1980
2214
|
checked: r,
|
|
@@ -1983,27 +2217,27 @@ var ct = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1983
2217
|
});
|
|
1984
2218
|
}
|
|
1985
2219
|
};
|
|
1986
|
-
return /* @__PURE__ */
|
|
2220
|
+
return /* @__PURE__ */ h(O, {
|
|
1987
2221
|
title: t,
|
|
1988
2222
|
collapsible: s,
|
|
1989
2223
|
collapsed: s ? u : !1,
|
|
1990
|
-
className:
|
|
1991
|
-
children: /* @__PURE__ */
|
|
1992
|
-
className:
|
|
2224
|
+
className: m && U.length > 0 ? pt.active : void 0,
|
|
2225
|
+
children: /* @__PURE__ */ g("ul", {
|
|
2226
|
+
className: p === "grid" ? pt.grid : pt.list,
|
|
1993
2227
|
style: {
|
|
1994
2228
|
listStyle: "none",
|
|
1995
2229
|
padding: 0,
|
|
1996
2230
|
margin: 0
|
|
1997
2231
|
},
|
|
1998
|
-
children: [
|
|
1999
|
-
let e =
|
|
2000
|
-
return /* @__PURE__ */
|
|
2001
|
-
className:
|
|
2002
|
-
children: /* @__PURE__ */
|
|
2232
|
+
children: [ne.map(([e, t]) => /* @__PURE__ */ h("li", { children: J(e, t) }, e)), te && B < q.length && (() => {
|
|
2233
|
+
let e = q.length - B, t = Math.min(50, e);
|
|
2234
|
+
return /* @__PURE__ */ h("li", {
|
|
2235
|
+
className: pt.toggleItem,
|
|
2236
|
+
children: /* @__PURE__ */ h(S, {
|
|
2003
2237
|
variant: "ghost",
|
|
2004
2238
|
size: "micro",
|
|
2005
2239
|
onClick: () => V((e) => e + 50),
|
|
2006
|
-
children: `Show ${t} more of ${
|
|
2240
|
+
children: `Show ${t} more of ${q.length} total`
|
|
2007
2241
|
})
|
|
2008
2242
|
});
|
|
2009
2243
|
})()]
|
|
@@ -2044,190 +2278,190 @@ function xt(e, t, n) {
|
|
|
2044
2278
|
let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
|
|
2045
2279
|
return Number((t + r * n).toFixed(_t(n)));
|
|
2046
2280
|
}
|
|
2047
|
-
var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, control: a, displayType: o, showActivePanel: s = !1, collapsible: c = !0, startCollapsed: l = !1, showHistogram: u = !1, resolution: d, step:
|
|
2048
|
-
let { state: { rangeFilters:
|
|
2281
|
+
var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, control: a, displayType: o, showActivePanel: s = !1, collapsible: c = !0, startCollapsed: l = !1, showHistogram: u = !1, resolution: d, step: f, stepMarks: p }) => {
|
|
2282
|
+
let { state: { rangeFilters: m, rangeBounds: _, facetStats: v, facets: y, filterableFields: b, facetableFields: x, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: T, allowEmptySearch: E, authError: D, isFetchingInitial: A } = ye(), j = a ?? o ?? "input", M = _?.[t] !== void 0, N = _?.[t] ?? {
|
|
2049
2283
|
min: r,
|
|
2050
2284
|
max: i
|
|
2051
|
-
},
|
|
2052
|
-
if (
|
|
2053
|
-
let e = Math.max(_t(
|
|
2285
|
+
}, P = N.min, F = N.max, I = v?.[t] ?? N, R = Math.max(P, Math.min(F, I.min)), z = Math.max(P, Math.min(F, I.max)), B = e.useMemo(() => {
|
|
2286
|
+
if (f) return f;
|
|
2287
|
+
let e = Math.max(_t(P), _t(F)), n = y?.[t];
|
|
2054
2288
|
if (Array.isArray(n)) for (let t of n) e = Math.max(e, _t(Number(t.key)));
|
|
2055
2289
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
2056
2290
|
}, [
|
|
2057
|
-
|
|
2291
|
+
f,
|
|
2292
|
+
P,
|
|
2058
2293
|
F,
|
|
2059
|
-
I,
|
|
2060
2294
|
y,
|
|
2061
2295
|
t
|
|
2062
|
-
]), V = M &&
|
|
2296
|
+
]), V = M && P === F, H = V ? r : P, U = V ? i : F, W = xt(U + B, H, B), G = (e) => Math.min(W, Math.max(H, e)), K = m?.[t], ee = s && K !== void 0 ? Q.active : void 0, q = K ? K.min : P, te = K ? K.max : F, ne = K !== void 0, J = R !== P || z !== F, [Y, X] = e.useState([q, te]), [re, ie] = e.useState(!1), [ae, Z] = e.useState(!1), [oe, se] = e.useState(String(q)), [ce, le] = e.useState(String(te)), ue = e.useMemo(() => {
|
|
2063
2297
|
let e = _t(B);
|
|
2064
|
-
return { width: `calc(${Math.max(3,
|
|
2298
|
+
return { width: `calc(${Math.max(3, P.toFixed(e).length, F.toFixed(e).length, oe.length, ce.length) + 1}ch + 20px)` };
|
|
2065
2299
|
}, [
|
|
2066
2300
|
B,
|
|
2301
|
+
P,
|
|
2067
2302
|
F,
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
le
|
|
2303
|
+
oe,
|
|
2304
|
+
ce
|
|
2071
2305
|
]);
|
|
2072
2306
|
e.useEffect(() => {
|
|
2073
|
-
|
|
2074
|
-
}, [
|
|
2075
|
-
let { finalMin:
|
|
2076
|
-
let [e, t] =
|
|
2307
|
+
se(String(Y[0])), le(String(Y[1]));
|
|
2308
|
+
}, [Y]);
|
|
2309
|
+
let { finalMin: de, finalMax: fe, isValidMin: pe, isValidMax: me } = e.useMemo(() => {
|
|
2310
|
+
let [e, t] = Y, n = Math.max(P, Math.min(F, e)), r = Math.max(P, Math.min(F, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
2077
2311
|
return {
|
|
2078
2312
|
finalMin: i,
|
|
2079
2313
|
finalMax: a,
|
|
2080
|
-
isValidMin: i >=
|
|
2081
|
-
isValidMax: a <=
|
|
2314
|
+
isValidMin: i >= P && i <= a,
|
|
2315
|
+
isValidMax: a <= F && a >= i
|
|
2082
2316
|
};
|
|
2083
2317
|
}, [
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2318
|
+
Y,
|
|
2319
|
+
P,
|
|
2320
|
+
F
|
|
2087
2321
|
]);
|
|
2088
2322
|
e.useEffect(() => {
|
|
2089
2323
|
if (V) return;
|
|
2090
|
-
if (
|
|
2091
|
-
|
|
2324
|
+
if (Y[0] === P && Y[1] === F) {
|
|
2325
|
+
ie(!1), Z(!1);
|
|
2092
2326
|
return;
|
|
2093
2327
|
}
|
|
2094
2328
|
let e = C ?? 500, n = setTimeout(() => {
|
|
2095
|
-
|
|
2329
|
+
ie(!pe), Z(!me);
|
|
2096
2330
|
}, 300), r = setTimeout(() => {
|
|
2097
|
-
|
|
2331
|
+
pe && me && (de === P && fe === F ? T(t, !1) : w(t, de, fe));
|
|
2098
2332
|
}, e);
|
|
2099
2333
|
return () => {
|
|
2100
2334
|
clearTimeout(n), clearTimeout(r);
|
|
2101
2335
|
};
|
|
2102
2336
|
}, [
|
|
2337
|
+
de,
|
|
2103
2338
|
fe,
|
|
2104
2339
|
pe,
|
|
2105
2340
|
me,
|
|
2106
|
-
|
|
2341
|
+
P,
|
|
2107
2342
|
F,
|
|
2108
|
-
I,
|
|
2109
2343
|
t,
|
|
2110
|
-
|
|
2344
|
+
T,
|
|
2111
2345
|
w,
|
|
2112
2346
|
C,
|
|
2113
2347
|
V
|
|
2114
2348
|
]), e.useEffect(() => {
|
|
2115
|
-
|
|
2349
|
+
X([q, te]), ie(!1), Z(!1);
|
|
2116
2350
|
}, [
|
|
2117
|
-
|
|
2118
|
-
|
|
2351
|
+
q,
|
|
2352
|
+
te,
|
|
2119
2353
|
t
|
|
2120
2354
|
]);
|
|
2121
|
-
let
|
|
2355
|
+
let he = e.useCallback((e) => {
|
|
2122
2356
|
let t = yt(Math.min(e[0], e[1] - B), B);
|
|
2123
2357
|
return [t, yt(Math.max(e[1] - B, t), B)];
|
|
2124
|
-
}, [B]),
|
|
2358
|
+
}, [B]), ge = e.useCallback((e) => {
|
|
2125
2359
|
if (V) return;
|
|
2126
|
-
let [t, n] =
|
|
2127
|
-
|
|
2360
|
+
let [t, n] = he(e);
|
|
2361
|
+
X([Math.max(P, Math.min(z, t)), Math.max(R, Math.min(F, n))]);
|
|
2128
2362
|
}, [
|
|
2129
2363
|
V,
|
|
2130
|
-
|
|
2364
|
+
he,
|
|
2365
|
+
P,
|
|
2131
2366
|
F,
|
|
2132
|
-
I,
|
|
2133
2367
|
R,
|
|
2134
2368
|
z
|
|
2135
|
-
]),
|
|
2369
|
+
]), _e = e.useCallback((e) => {
|
|
2136
2370
|
if (V) return;
|
|
2137
|
-
let [n, r] =
|
|
2138
|
-
i ===
|
|
2371
|
+
let [n, r] = he(e), i = Math.max(P, Math.min(z, n)), a = Math.max(R, Math.min(F, r));
|
|
2372
|
+
i === P && a === F ? (X([P, F]), T(t, !0)) : X([i, a]);
|
|
2139
2373
|
}, [
|
|
2140
2374
|
V,
|
|
2141
|
-
|
|
2375
|
+
he,
|
|
2376
|
+
P,
|
|
2142
2377
|
F,
|
|
2143
|
-
I,
|
|
2144
2378
|
R,
|
|
2145
2379
|
z,
|
|
2146
2380
|
t,
|
|
2147
|
-
|
|
2148
|
-
]),
|
|
2381
|
+
T
|
|
2382
|
+
]), ve = e.useRef(null), be = e.useCallback((e, n) => {
|
|
2149
2383
|
if (V) return;
|
|
2150
|
-
let r =
|
|
2151
|
-
if (
|
|
2152
|
-
|
|
2384
|
+
let r = ve.current;
|
|
2385
|
+
if (K && r && r.start === e && r.last === n) {
|
|
2386
|
+
ve.current = null, X([P, F]), T(t, !0);
|
|
2153
2387
|
return;
|
|
2154
2388
|
}
|
|
2155
|
-
let i = bt(Math.max(
|
|
2156
|
-
|
|
2389
|
+
let i = bt(Math.max(P, R, e), P, B), a = Math.max(i, bt(Math.min(F, z, n), P, B));
|
|
2390
|
+
ve.current = {
|
|
2157
2391
|
start: e,
|
|
2158
2392
|
last: n
|
|
2159
|
-
},
|
|
2393
|
+
}, X([i, a]);
|
|
2160
2394
|
}, [
|
|
2161
2395
|
V,
|
|
2162
|
-
|
|
2396
|
+
K,
|
|
2397
|
+
P,
|
|
2163
2398
|
F,
|
|
2164
|
-
I,
|
|
2165
2399
|
R,
|
|
2166
2400
|
z,
|
|
2167
2401
|
B,
|
|
2168
2402
|
t,
|
|
2169
|
-
|
|
2170
|
-
]),
|
|
2403
|
+
T
|
|
2404
|
+
]), xe = e.useCallback(() => {
|
|
2171
2405
|
if (V) return;
|
|
2172
|
-
let e =
|
|
2406
|
+
let e = oe.trim(), t = e === "" ? NaN : Number(e);
|
|
2173
2407
|
if (isNaN(t)) {
|
|
2174
|
-
|
|
2408
|
+
se(String(Y[0]));
|
|
2175
2409
|
return;
|
|
2176
2410
|
}
|
|
2177
|
-
let n = Math.max(
|
|
2178
|
-
n <
|
|
2411
|
+
let n = Math.max(P, Math.min(z, t));
|
|
2412
|
+
n < Y[1] ? X([n, Y[1]]) : X([P, Y[1]]), se(String(n < Y[1] ? n : P));
|
|
2179
2413
|
}, [
|
|
2180
2414
|
V,
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2415
|
+
oe,
|
|
2416
|
+
Y,
|
|
2417
|
+
P,
|
|
2184
2418
|
z
|
|
2185
|
-
]),
|
|
2419
|
+
]), Se = e.useCallback(() => {
|
|
2186
2420
|
if (V) return;
|
|
2187
|
-
let e =
|
|
2421
|
+
let e = ce.trim(), t = e === "" ? NaN : Number(e);
|
|
2188
2422
|
if (isNaN(t)) {
|
|
2189
|
-
|
|
2423
|
+
le(String(Y[1]));
|
|
2190
2424
|
return;
|
|
2191
2425
|
}
|
|
2192
|
-
let n = Math.max(R, Math.min(
|
|
2193
|
-
n >
|
|
2426
|
+
let n = Math.max(R, Math.min(F, t));
|
|
2427
|
+
n > Y[0] ? X([Y[0], n]) : X([Y[0], F]), le(String(n > Y[0] ? n : F));
|
|
2194
2428
|
}, [
|
|
2195
2429
|
V,
|
|
2196
|
-
|
|
2197
|
-
|
|
2430
|
+
ce,
|
|
2431
|
+
Y,
|
|
2198
2432
|
R,
|
|
2199
|
-
|
|
2200
|
-
]),
|
|
2433
|
+
F
|
|
2434
|
+
]), Ce = (e) => (t) => {
|
|
2201
2435
|
t.key === "Enter" && e();
|
|
2202
|
-
}, [
|
|
2436
|
+
}, [we, Te] = e.useState(null), Ee = e.useRef(null);
|
|
2203
2437
|
e.useEffect(() => {
|
|
2204
2438
|
if (!u) return;
|
|
2205
|
-
let e = `${
|
|
2206
|
-
if (e ===
|
|
2439
|
+
let e = `${P}:${F}`;
|
|
2440
|
+
if (e === Ee.current && Ee.current !== null) return;
|
|
2207
2441
|
let n = y?.[t];
|
|
2208
2442
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
2209
2443
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
2210
2444
|
key: e.key,
|
|
2211
2445
|
value: e.value
|
|
2212
2446
|
}));
|
|
2213
|
-
r.length > 0 && (
|
|
2447
|
+
r.length > 0 && (Ee.current = e, Te(r));
|
|
2214
2448
|
}, [
|
|
2449
|
+
P,
|
|
2215
2450
|
F,
|
|
2216
|
-
I,
|
|
2217
2451
|
y,
|
|
2218
2452
|
t,
|
|
2219
2453
|
u
|
|
2220
2454
|
]);
|
|
2221
|
-
let
|
|
2222
|
-
if (!u || !
|
|
2223
|
-
let e =
|
|
2455
|
+
let De = e.useMemo(() => {
|
|
2456
|
+
if (!u || !we || we.length === 0) return [];
|
|
2457
|
+
let e = F - P;
|
|
2224
2458
|
if (e <= 0) return [];
|
|
2225
2459
|
let t = d ?? Math.max(B, yt(Math.ceil(e / 20 / B) * B, B)), n = Math.ceil(e / t);
|
|
2226
2460
|
return Array.from({ length: n }, (e, r) => {
|
|
2227
|
-
let i =
|
|
2461
|
+
let i = P + r * t, a = P + (r + 1) * t, o = r === n - 1, s = we.filter((e) => {
|
|
2228
2462
|
let t = Number(e.key);
|
|
2229
|
-
return t >= i && (t < a || o && t <=
|
|
2230
|
-
}).reduce((e, t) => e + t.value, 0), c = o ?
|
|
2463
|
+
return t >= i && (t < a || o && t <= F);
|
|
2464
|
+
}).reduce((e, t) => e + t.value, 0), c = o ? F : yt(a - B, B);
|
|
2231
2465
|
return {
|
|
2232
2466
|
bucketStart: i,
|
|
2233
2467
|
bucketEnd: a,
|
|
@@ -2241,91 +2475,91 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2241
2475
|
}));
|
|
2242
2476
|
}, [
|
|
2243
2477
|
u,
|
|
2244
|
-
|
|
2478
|
+
we,
|
|
2479
|
+
P,
|
|
2245
2480
|
F,
|
|
2246
|
-
I,
|
|
2247
2481
|
d,
|
|
2248
2482
|
B,
|
|
2249
2483
|
W
|
|
2250
|
-
]),
|
|
2251
|
-
return u && !A && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`),
|
|
2484
|
+
]), Oe = e.useMemo(() => Math.max(...De.map((e) => e.count), 1), [De]);
|
|
2485
|
+
return u && !A && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), D ? null : A ? /* @__PURE__ */ h(ft, {
|
|
2252
2486
|
title: n,
|
|
2253
2487
|
variant: "slider",
|
|
2254
2488
|
withHistogram: u,
|
|
2255
2489
|
collapsible: c,
|
|
2256
2490
|
startCollapsed: l
|
|
2257
|
-
}) : !
|
|
2491
|
+
}) : !E && !S ? null : b?.includes(t) ? j === "slider" ? /* @__PURE__ */ g(O, {
|
|
2258
2492
|
title: n,
|
|
2259
2493
|
collapsed: l,
|
|
2260
2494
|
collapsible: c,
|
|
2261
|
-
className:
|
|
2495
|
+
className: ee,
|
|
2262
2496
|
children: [
|
|
2263
|
-
V && /* @__PURE__ */
|
|
2497
|
+
V && /* @__PURE__ */ g("div", {
|
|
2264
2498
|
className: Q.disabledMessage,
|
|
2265
2499
|
children: [
|
|
2266
2500
|
"No adjustable range (all results have the same value: ",
|
|
2267
|
-
|
|
2501
|
+
P,
|
|
2268
2502
|
")."
|
|
2269
2503
|
]
|
|
2270
2504
|
}),
|
|
2271
|
-
u &&
|
|
2272
|
-
u &&
|
|
2273
|
-
let [e, t] = z > R && (R >
|
|
2505
|
+
u && De.length === 0 && /* @__PURE__ */ h("div", { className: Q.histogram }),
|
|
2506
|
+
u && De.length > 0 && (() => {
|
|
2507
|
+
let [e, t] = z > R && (R > P || z < F) ? [R, z] : [H, U], n = Math.max(de, e), r = Math.min(fe, t), i = W, a = i - H || 1, o = (e) => Math.max(0, Math.min(1, (e - H) / a)), s = (e) => e >= U ? 0 : Math.max(0, Math.min(1, (i - (e + B)) / a)), c = o(n), l = r < n ? 1 - c : s(r), u = (e) => `calc(10px + (100% - 20px) * ${e})`, d = `inset(0 ${u(l)} 0 ${u(c)})`, f = `inset(0 ${u(s(t))} 0 ${u(o(e))})`, p = (n) => n.last < e || n.bucketStart > t, m = De.slice(1).map((e) => u((e.bucketStart - H) / a)), _ = De.map((e) => ({
|
|
2274
2508
|
...e,
|
|
2275
|
-
height: Math.max(1, Math.ceil(e.count /
|
|
2509
|
+
height: Math.max(1, Math.ceil(e.count / Oe * 20))
|
|
2276
2510
|
}));
|
|
2277
|
-
return /* @__PURE__ */
|
|
2511
|
+
return /* @__PURE__ */ g("div", {
|
|
2278
2512
|
className: Q.histogram,
|
|
2279
2513
|
children: [
|
|
2280
|
-
/* @__PURE__ */
|
|
2514
|
+
/* @__PURE__ */ h("div", {
|
|
2281
2515
|
className: Q.histogramLayer,
|
|
2282
|
-
children: _.map((e, t) => /* @__PURE__ */
|
|
2516
|
+
children: _.map((e, t) => /* @__PURE__ */ h("button", {
|
|
2283
2517
|
type: "button",
|
|
2284
2518
|
className: Q.histogramBar,
|
|
2285
2519
|
style: { flexGrow: e.span },
|
|
2286
2520
|
"data-testid": "histogram-bar",
|
|
2287
|
-
disabled: V ||
|
|
2521
|
+
disabled: V || p(e),
|
|
2288
2522
|
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
2289
2523
|
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
2290
|
-
onClick: () =>
|
|
2291
|
-
children: /* @__PURE__ */
|
|
2524
|
+
onClick: () => be(e.bucketStart, e.last),
|
|
2525
|
+
children: /* @__PURE__ */ h("span", {
|
|
2292
2526
|
className: Q.histogramFill,
|
|
2293
2527
|
style: { height: `${e.height}px` }
|
|
2294
2528
|
})
|
|
2295
2529
|
}, t))
|
|
2296
2530
|
}),
|
|
2297
|
-
/* @__PURE__ */
|
|
2531
|
+
/* @__PURE__ */ h("div", {
|
|
2298
2532
|
className: `${Q.histogramLayer} ${Q.histogramLive}`,
|
|
2299
2533
|
"aria-hidden": "true",
|
|
2300
2534
|
"data-testid": "histogram-live",
|
|
2301
|
-
style: { clipPath:
|
|
2302
|
-
children: _.map((e, t) => /* @__PURE__ */
|
|
2535
|
+
style: { clipPath: f },
|
|
2536
|
+
children: _.map((e, t) => /* @__PURE__ */ h("span", {
|
|
2303
2537
|
className: Q.histogramBar,
|
|
2304
2538
|
style: { flexGrow: e.span },
|
|
2305
|
-
children: /* @__PURE__ */
|
|
2539
|
+
children: /* @__PURE__ */ h("span", {
|
|
2306
2540
|
className: Q.histogramFill,
|
|
2307
2541
|
style: { height: `${e.height}px` }
|
|
2308
2542
|
})
|
|
2309
2543
|
}, t))
|
|
2310
2544
|
}),
|
|
2311
|
-
/* @__PURE__ */
|
|
2545
|
+
/* @__PURE__ */ h("div", {
|
|
2312
2546
|
className: `${Q.histogramLayer} ${Q.histogramLit}`,
|
|
2313
2547
|
"aria-hidden": "true",
|
|
2314
2548
|
"data-testid": "histogram-lit",
|
|
2315
2549
|
style: { clipPath: d },
|
|
2316
|
-
children: _.map((e, t) => /* @__PURE__ */
|
|
2550
|
+
children: _.map((e, t) => /* @__PURE__ */ h("span", {
|
|
2317
2551
|
className: Q.histogramBar,
|
|
2318
2552
|
style: { flexGrow: e.span },
|
|
2319
|
-
children: /* @__PURE__ */
|
|
2553
|
+
children: /* @__PURE__ */ h("span", {
|
|
2320
2554
|
className: Q.histogramFill,
|
|
2321
2555
|
style: { height: `${e.height}px` }
|
|
2322
2556
|
})
|
|
2323
2557
|
}, t))
|
|
2324
2558
|
}),
|
|
2325
|
-
/* @__PURE__ */
|
|
2559
|
+
/* @__PURE__ */ h("div", {
|
|
2326
2560
|
className: Q.histogramSeparators,
|
|
2327
2561
|
"aria-hidden": "true",
|
|
2328
|
-
children:
|
|
2562
|
+
children: m.map((e, t) => /* @__PURE__ */ h("span", {
|
|
2329
2563
|
className: Q.histogramSeparator,
|
|
2330
2564
|
style: { left: e }
|
|
2331
2565
|
}, t))
|
|
@@ -2333,102 +2567,102 @@ var St = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2333
2567
|
]
|
|
2334
2568
|
});
|
|
2335
2569
|
})(),
|
|
2336
|
-
/* @__PURE__ */
|
|
2570
|
+
/* @__PURE__ */ h("div", {
|
|
2337
2571
|
style: { padding: "10px 10px 20px 10px" },
|
|
2338
|
-
children: /* @__PURE__ */
|
|
2572
|
+
children: /* @__PURE__ */ h(L, {
|
|
2339
2573
|
min: H,
|
|
2340
2574
|
max: W,
|
|
2341
2575
|
step: B,
|
|
2342
|
-
stepMarks:
|
|
2343
|
-
value: V ? [H, W] : [
|
|
2576
|
+
stepMarks: p,
|
|
2577
|
+
value: V ? [H, W] : [G(bt(de, H, B)), G(bt(fe + B, H, B))],
|
|
2344
2578
|
isRange: !0,
|
|
2345
|
-
onChange: (e) =>
|
|
2346
|
-
onFinalChange: (e) =>
|
|
2579
|
+
onChange: (e) => ge(e),
|
|
2580
|
+
onFinalChange: (e) => _e(e),
|
|
2347
2581
|
disabled: V,
|
|
2348
2582
|
activeMin: R,
|
|
2349
|
-
activeMax:
|
|
2350
|
-
isFaceted:
|
|
2351
|
-
highlightFaceted:
|
|
2583
|
+
activeMax: G(yt(z + B, B)),
|
|
2584
|
+
isFaceted: J,
|
|
2585
|
+
highlightFaceted: ne,
|
|
2352
2586
|
"aria-label": n || `Filter by ${t}`
|
|
2353
2587
|
})
|
|
2354
2588
|
}),
|
|
2355
|
-
/* @__PURE__ */
|
|
2589
|
+
/* @__PURE__ */ g("div", {
|
|
2356
2590
|
style: {
|
|
2357
2591
|
display: "flex",
|
|
2358
2592
|
gap: "10px",
|
|
2359
2593
|
alignItems: "flex-start",
|
|
2360
2594
|
justifyContent: "space-between"
|
|
2361
2595
|
},
|
|
2362
|
-
children: [/* @__PURE__ */
|
|
2596
|
+
children: [/* @__PURE__ */ h(k, {
|
|
2363
2597
|
label: "Min:",
|
|
2364
2598
|
type: "number",
|
|
2365
|
-
style:
|
|
2366
|
-
value: V ? String(
|
|
2367
|
-
min:
|
|
2368
|
-
max: yt(Math.min(z,
|
|
2369
|
-
onChange: (e) =>
|
|
2370
|
-
onBlur:
|
|
2371
|
-
onKeyDown:
|
|
2599
|
+
style: ue,
|
|
2600
|
+
value: V ? String(P) : oe,
|
|
2601
|
+
min: P,
|
|
2602
|
+
max: yt(Math.min(z, Y[1] - B), B),
|
|
2603
|
+
onChange: (e) => se(e.target.value),
|
|
2604
|
+
onBlur: xe,
|
|
2605
|
+
onKeyDown: Ce(xe),
|
|
2372
2606
|
disabled: V,
|
|
2373
|
-
isValid: V || !
|
|
2374
|
-
}), /* @__PURE__ */
|
|
2607
|
+
isValid: V || !re
|
|
2608
|
+
}), /* @__PURE__ */ h(k, {
|
|
2375
2609
|
label: "Max:",
|
|
2376
2610
|
type: "number",
|
|
2377
|
-
style:
|
|
2378
|
-
value: V ? String(
|
|
2379
|
-
min: yt(Math.max(R,
|
|
2380
|
-
max:
|
|
2381
|
-
onChange: (e) =>
|
|
2382
|
-
onBlur:
|
|
2383
|
-
onKeyDown:
|
|
2611
|
+
style: ue,
|
|
2612
|
+
value: V ? String(F) : ce,
|
|
2613
|
+
min: yt(Math.max(R, Y[0] + B), B),
|
|
2614
|
+
max: F,
|
|
2615
|
+
onChange: (e) => le(e.target.value),
|
|
2616
|
+
onBlur: Se,
|
|
2617
|
+
onKeyDown: Ce(Se),
|
|
2384
2618
|
disabled: V,
|
|
2385
2619
|
isValid: V || !ae
|
|
2386
2620
|
})]
|
|
2387
2621
|
})
|
|
2388
2622
|
]
|
|
2389
|
-
}) : /* @__PURE__ */
|
|
2623
|
+
}) : /* @__PURE__ */ g(O, {
|
|
2390
2624
|
title: n,
|
|
2391
|
-
className:
|
|
2392
|
-
children: [V && /* @__PURE__ */
|
|
2625
|
+
className: ee,
|
|
2626
|
+
children: [V && /* @__PURE__ */ g("div", {
|
|
2393
2627
|
className: Q.disabledMessage,
|
|
2394
2628
|
children: [
|
|
2395
2629
|
"No adjustable range (all results have the same value: ",
|
|
2396
|
-
|
|
2630
|
+
P,
|
|
2397
2631
|
")."
|
|
2398
2632
|
]
|
|
2399
|
-
}), /* @__PURE__ */
|
|
2633
|
+
}), /* @__PURE__ */ g("div", {
|
|
2400
2634
|
style: {
|
|
2401
2635
|
display: "flex",
|
|
2402
2636
|
gap: "10px",
|
|
2403
2637
|
alignItems: "flex-start"
|
|
2404
2638
|
},
|
|
2405
|
-
children: [/* @__PURE__ */
|
|
2639
|
+
children: [/* @__PURE__ */ h(k, {
|
|
2406
2640
|
label: "Min:",
|
|
2407
2641
|
type: "number",
|
|
2408
|
-
style:
|
|
2409
|
-
value: V ? String(
|
|
2410
|
-
min:
|
|
2411
|
-
max: yt(Math.min(z,
|
|
2412
|
-
onChange: (e) =>
|
|
2413
|
-
onBlur:
|
|
2414
|
-
onKeyDown:
|
|
2642
|
+
style: ue,
|
|
2643
|
+
value: V ? String(P) : oe,
|
|
2644
|
+
min: P,
|
|
2645
|
+
max: yt(Math.min(z, Y[1] - B), B),
|
|
2646
|
+
onChange: (e) => se(e.target.value),
|
|
2647
|
+
onBlur: xe,
|
|
2648
|
+
onKeyDown: Ce(xe),
|
|
2415
2649
|
disabled: V,
|
|
2416
|
-
isValid: V || !
|
|
2417
|
-
}), /* @__PURE__ */
|
|
2650
|
+
isValid: V || !re
|
|
2651
|
+
}), /* @__PURE__ */ h(k, {
|
|
2418
2652
|
label: "Max:",
|
|
2419
2653
|
type: "number",
|
|
2420
|
-
style:
|
|
2421
|
-
value: V ? String(
|
|
2422
|
-
min: yt(Math.max(R,
|
|
2423
|
-
max:
|
|
2424
|
-
onChange: (e) =>
|
|
2425
|
-
onBlur:
|
|
2426
|
-
onKeyDown:
|
|
2654
|
+
style: ue,
|
|
2655
|
+
value: V ? String(F) : ce,
|
|
2656
|
+
min: yt(Math.max(R, Y[0] + B), B),
|
|
2657
|
+
max: F,
|
|
2658
|
+
onChange: (e) => le(e.target.value),
|
|
2659
|
+
onBlur: Se,
|
|
2660
|
+
onKeyDown: Ce(Se),
|
|
2427
2661
|
disabled: V,
|
|
2428
2662
|
isValid: V || !ae
|
|
2429
2663
|
})]
|
|
2430
2664
|
})]
|
|
2431
|
-
}) : /* @__PURE__ */
|
|
2665
|
+
}) : /* @__PURE__ */ h(ht, {
|
|
2432
2666
|
label: n,
|
|
2433
2667
|
field: t,
|
|
2434
2668
|
missing: ["filterable"]
|
|
@@ -2454,12 +2688,12 @@ function wt(e, t) {
|
|
|
2454
2688
|
}
|
|
2455
2689
|
return r ? n : 0;
|
|
2456
2690
|
}
|
|
2457
|
-
var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit:
|
|
2458
|
-
let { state: { facets: v, filterableFields:
|
|
2691
|
+
var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit: f, showActivePanel: p = !1, collapsible: m = !0, startCollapsed: _ = !1 }) => {
|
|
2692
|
+
let { state: { facets: v, filterableFields: y, facetableFields: b, bucketFilters: x, rangeBounds: w, facetStats: T, query: E }, toggleBucketFilter: D, authError: k, isFetchingInitial: A, allowEmptySearch: j } = ye(), N = i ?? a ?? "checkbox", P = v?.[e], F = x[e] ?? [], [I, L] = l(f ?? Infinity);
|
|
2459
2693
|
o(() => {
|
|
2460
|
-
L(
|
|
2461
|
-
}, [
|
|
2462
|
-
let R = w?.[e] ??
|
|
2694
|
+
L(f ?? Infinity);
|
|
2695
|
+
}, [f, P]);
|
|
2696
|
+
let R = w?.[e] ?? T?.[e], z = s(() => {
|
|
2463
2697
|
let e = [];
|
|
2464
2698
|
if (R && e.push(R.min, R.max), Array.isArray(P)) for (let t of P) e.push(Number(t.key));
|
|
2465
2699
|
return vt(e.filter(Number.isFinite));
|
|
@@ -2490,28 +2724,28 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2490
2724
|
R,
|
|
2491
2725
|
z
|
|
2492
2726
|
]);
|
|
2493
|
-
if (
|
|
2494
|
-
if (
|
|
2727
|
+
if (k) return null;
|
|
2728
|
+
if (A || !v) return /* @__PURE__ */ h(ft, {
|
|
2495
2729
|
title: t,
|
|
2496
2730
|
rows: Math.max(1, Math.min(B.length || 5, 8)),
|
|
2497
|
-
collapsible:
|
|
2731
|
+
collapsible: m,
|
|
2498
2732
|
startCollapsed: _
|
|
2499
2733
|
});
|
|
2500
|
-
if (!
|
|
2501
|
-
if (!
|
|
2734
|
+
if (!j && !E) return null;
|
|
2735
|
+
if (!y?.includes(e)) return /* @__PURE__ */ h(ht, {
|
|
2502
2736
|
label: t,
|
|
2503
2737
|
field: e,
|
|
2504
2738
|
missing: ["filterable"]
|
|
2505
2739
|
});
|
|
2506
|
-
let V =
|
|
2740
|
+
let V = b?.includes(e) && Array.isArray(P), H = (e) => F.some((t) => t.min === e.range.min && t.max === e.range.max), U = B.map((e) => ({
|
|
2507
2741
|
bucket: e,
|
|
2508
2742
|
count: V ? wt(e, P) : null
|
|
2509
2743
|
}));
|
|
2510
2744
|
if (d || (U = U.filter((e) => e.count !== 0 || H(e.bucket))), U.length === 0) return null;
|
|
2511
|
-
let W = U.slice(0, I),
|
|
2512
|
-
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () =>
|
|
2745
|
+
let W = U.slice(0, I), G = (t, n) => {
|
|
2746
|
+
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => D(e, t.range, N === "radio");
|
|
2513
2747
|
if (N === "radio") {
|
|
2514
|
-
let n = /* @__PURE__ */
|
|
2748
|
+
let n = /* @__PURE__ */ h(M, {
|
|
2515
2749
|
id: `${e}-${t.range.min}-${t.range.max}`,
|
|
2516
2750
|
name: e,
|
|
2517
2751
|
value: t.label,
|
|
@@ -2520,16 +2754,16 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2520
2754
|
onChange: o,
|
|
2521
2755
|
disabled: i
|
|
2522
2756
|
});
|
|
2523
|
-
return c === "list" ? /* @__PURE__ */
|
|
2757
|
+
return c === "list" ? /* @__PURE__ */ g("div", {
|
|
2524
2758
|
className: Ct.count,
|
|
2525
|
-
children: [n, /* @__PURE__ */
|
|
2759
|
+
children: [n, /* @__PURE__ */ h("span", {
|
|
2526
2760
|
className: Ct.countValue,
|
|
2527
2761
|
children: a
|
|
2528
2762
|
})]
|
|
2529
2763
|
}) : n;
|
|
2530
2764
|
}
|
|
2531
2765
|
if (N === "button") {
|
|
2532
|
-
let e = /* @__PURE__ */
|
|
2766
|
+
let e = /* @__PURE__ */ h(S, {
|
|
2533
2767
|
variant: r ? "primary" : "secondary",
|
|
2534
2768
|
onClick: o,
|
|
2535
2769
|
disabled: i,
|
|
@@ -2537,27 +2771,27 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2537
2771
|
className: Ct.chip,
|
|
2538
2772
|
children: c === "grid" && a ? `${t.label} (${a})` : t.label
|
|
2539
2773
|
});
|
|
2540
|
-
return c === "list" ? /* @__PURE__ */
|
|
2774
|
+
return c === "list" ? /* @__PURE__ */ g("div", {
|
|
2541
2775
|
className: Ct.count,
|
|
2542
|
-
children: [e, /* @__PURE__ */
|
|
2776
|
+
children: [e, /* @__PURE__ */ h("span", {
|
|
2543
2777
|
className: Ct.countValue,
|
|
2544
2778
|
children: a
|
|
2545
2779
|
})]
|
|
2546
2780
|
}) : e;
|
|
2547
2781
|
}
|
|
2548
|
-
return c === "list" ? /* @__PURE__ */
|
|
2782
|
+
return c === "list" ? /* @__PURE__ */ g("div", {
|
|
2549
2783
|
className: Ct.count,
|
|
2550
|
-
children: [/* @__PURE__ */
|
|
2784
|
+
children: [/* @__PURE__ */ h(C, {
|
|
2551
2785
|
label: t.label,
|
|
2552
2786
|
score: "",
|
|
2553
2787
|
checked: r,
|
|
2554
2788
|
onChange: o,
|
|
2555
2789
|
disabled: i
|
|
2556
|
-
}), /* @__PURE__ */
|
|
2790
|
+
}), /* @__PURE__ */ h("span", {
|
|
2557
2791
|
className: Ct.countValue,
|
|
2558
2792
|
children: a
|
|
2559
2793
|
})]
|
|
2560
|
-
}) : /* @__PURE__ */
|
|
2794
|
+
}) : /* @__PURE__ */ h(C, {
|
|
2561
2795
|
label: t.label,
|
|
2562
2796
|
score: a ? ` (${a})` : "",
|
|
2563
2797
|
checked: r,
|
|
@@ -2565,19 +2799,19 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2565
2799
|
disabled: i
|
|
2566
2800
|
});
|
|
2567
2801
|
};
|
|
2568
|
-
return /* @__PURE__ */
|
|
2802
|
+
return /* @__PURE__ */ h(O, {
|
|
2569
2803
|
title: t,
|
|
2570
|
-
collapsible:
|
|
2571
|
-
collapsed:
|
|
2572
|
-
className:
|
|
2573
|
-
children: /* @__PURE__ */
|
|
2804
|
+
collapsible: m,
|
|
2805
|
+
collapsed: m ? _ : !1,
|
|
2806
|
+
className: p && F.length > 0 ? Ct.active : void 0,
|
|
2807
|
+
children: /* @__PURE__ */ g("ul", {
|
|
2574
2808
|
className: c === "grid" ? Ct.grid : Ct.list,
|
|
2575
2809
|
style: {
|
|
2576
2810
|
listStyle: "none",
|
|
2577
2811
|
padding: 0,
|
|
2578
2812
|
margin: 0
|
|
2579
2813
|
},
|
|
2580
|
-
children: [W.map(({ bucket: e, count: t }) => /* @__PURE__ */
|
|
2814
|
+
children: [W.map(({ bucket: e, count: t }) => /* @__PURE__ */ h("li", { children: G(e, t) }, `${e.range.min}-${e.range.max}`)), W.length < U.length && /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
2581
2815
|
variant: "ghost",
|
|
2582
2816
|
size: "micro",
|
|
2583
2817
|
onClick: () => L(U.length),
|
|
@@ -2589,15 +2823,15 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2589
2823
|
select: "_select_nwf7i_1",
|
|
2590
2824
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
2591
2825
|
}, Dt = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
|
|
2592
|
-
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } =
|
|
2593
|
-
if (d) return /* @__PURE__ */
|
|
2826
|
+
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = ye();
|
|
2827
|
+
if (d) return /* @__PURE__ */ h(ft, {
|
|
2594
2828
|
title: "Sort by",
|
|
2595
2829
|
rows: o === "radio" ? 3 : 1,
|
|
2596
2830
|
collapsible: i,
|
|
2597
2831
|
startCollapsed: a
|
|
2598
2832
|
});
|
|
2599
2833
|
if (!s || s.length === 0) return null;
|
|
2600
|
-
let
|
|
2834
|
+
let f = c ? `${c}:${l ? "asc" : "desc"}` : "none", p = e ? e.filter((e) => s.includes(e.field) ? !0 : (console.warn(`[SortByPanel] '${e.field}' is not sortable, so "${e.label}" is left out. Mark the field Sortable in the dataset's field configuration.`), !1)).map((e) => ({
|
|
2601
2835
|
label: e.label,
|
|
2602
2836
|
value: `${e.field}:${e.ascending ? "asc" : "desc"}`
|
|
2603
2837
|
})) : s.flatMap((e) => [{
|
|
@@ -2606,60 +2840,64 @@ var Tt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2606
2840
|
}, {
|
|
2607
2841
|
label: `${e} (desc)`,
|
|
2608
2842
|
value: `${e}:desc`
|
|
2609
|
-
}]),
|
|
2843
|
+
}]), m = t === null ? p : [{
|
|
2610
2844
|
label: t,
|
|
2611
2845
|
value: "none"
|
|
2612
|
-
}, ...
|
|
2846
|
+
}, ...p], g = (e) => {
|
|
2613
2847
|
if (e === "none" || e === "") u(null, !0);
|
|
2614
2848
|
else {
|
|
2615
2849
|
let [t, n] = e.split(":");
|
|
2616
2850
|
u(t, n === "asc");
|
|
2617
2851
|
}
|
|
2618
2852
|
};
|
|
2619
|
-
return /* @__PURE__ */
|
|
2853
|
+
return /* @__PURE__ */ h(O, {
|
|
2620
2854
|
title: "Sort by",
|
|
2621
2855
|
collapsible: i,
|
|
2622
2856
|
collapsed: i ? a : !1,
|
|
2623
|
-
children: o === "select" ? /* @__PURE__ */
|
|
2624
|
-
value:
|
|
2857
|
+
children: o === "select" ? /* @__PURE__ */ h(P, {
|
|
2858
|
+
value: f,
|
|
2625
2859
|
onValueChange: g,
|
|
2626
|
-
options:
|
|
2860
|
+
options: m,
|
|
2627
2861
|
placeholder: "Select sort...",
|
|
2628
2862
|
"aria-label": "Sort by"
|
|
2629
|
-
}) : /* @__PURE__ */
|
|
2863
|
+
}) : /* @__PURE__ */ h("div", {
|
|
2630
2864
|
className: Et.radioGroup,
|
|
2631
|
-
children:
|
|
2865
|
+
children: m.map((e) => /* @__PURE__ */ h(M, {
|
|
2632
2866
|
id: `sort-${e.value}`,
|
|
2633
2867
|
name: "sort-by",
|
|
2634
2868
|
value: e.value,
|
|
2635
2869
|
label: e.label,
|
|
2636
|
-
checked:
|
|
2870
|
+
checked: f === e.value,
|
|
2637
2871
|
onChange: (e) => g(e.target.value)
|
|
2638
2872
|
}, e.value))
|
|
2639
2873
|
})
|
|
2640
2874
|
});
|
|
2641
2875
|
}, Ot = { list: "_list_1y4fk_1" }, kt = {
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2876
|
+
tolerance: p.TwoEdits,
|
|
2877
|
+
rungs: u.Fewest,
|
|
2878
|
+
oneEditFrom: 3,
|
|
2879
|
+
twoEditsFrom: 6,
|
|
2880
|
+
threeEditsFrom: 9,
|
|
2881
|
+
typingPrefixFrom: 3,
|
|
2882
|
+
typingPrefixOneEditFrom: 6,
|
|
2883
|
+
joinedWords: !0
|
|
2884
|
+
}, At = {
|
|
2885
|
+
candidatesPerRow: 4,
|
|
2886
|
+
fallback: !0,
|
|
2887
|
+
rest: !1
|
|
2888
|
+
}, jt = {
|
|
2889
|
+
rerank: !0,
|
|
2890
|
+
share: .2,
|
|
2891
|
+
typingShift: .5,
|
|
2892
|
+
wholeQueryFloor: !0
|
|
2655
2893
|
};
|
|
2656
|
-
function
|
|
2657
|
-
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } =
|
|
2894
|
+
function Mt() {
|
|
2895
|
+
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } = ye(), [s, c] = l(!1), { match: f, candidates: _, ranking: v } = e, [y, b] = l(null);
|
|
2658
2896
|
o(() => {
|
|
2659
2897
|
let e = !0;
|
|
2660
2898
|
try {
|
|
2661
2899
|
a(`${n}/api/teams/${r}/datasets/${i}/query-parameters`).then((e) => e.ok ? e.json() : null).then((t) => {
|
|
2662
|
-
e && t?.effective &&
|
|
2900
|
+
e && t?.effective && b(t.effective);
|
|
2663
2901
|
}).catch(() => {});
|
|
2664
2902
|
} catch {}
|
|
2665
2903
|
return () => {
|
|
@@ -2671,42 +2909,62 @@ function At() {
|
|
|
2671
2909
|
i,
|
|
2672
2910
|
a
|
|
2673
2911
|
]);
|
|
2674
|
-
let
|
|
2912
|
+
let x = (e) => Object.fromEntries(Object.entries(e ?? {}).filter(([, e]) => e != null)), C = {
|
|
2913
|
+
...kt,
|
|
2914
|
+
...x(y?.match)
|
|
2915
|
+
}, w = {
|
|
2916
|
+
...At,
|
|
2917
|
+
...x(y?.candidates)
|
|
2918
|
+
}, T = {
|
|
2919
|
+
...jt,
|
|
2920
|
+
...x(y?.ranking)
|
|
2921
|
+
}, E = e.mode ?? y?.mode ?? d.EditDistance, D = E === d.Bm25f, A = v.rerank ?? T.rerank, j = D && !A, M = e.mode !== void 0 || [
|
|
2922
|
+
f,
|
|
2923
|
+
_,
|
|
2924
|
+
v
|
|
2925
|
+
].some((e) => Object.values(e ?? {}).some((e) => e != null)), N = (e, n) => {
|
|
2675
2926
|
let r = parseInt(n, 10);
|
|
2676
2927
|
isNaN(r) || t({ [e]: r });
|
|
2677
|
-
},
|
|
2928
|
+
}, F = (e, n) => {
|
|
2678
2929
|
t({ [e]: n });
|
|
2679
|
-
},
|
|
2680
|
-
let
|
|
2681
|
-
isNaN(
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
}, O = (n, r) => {
|
|
2686
|
-
t({ coverageSetup: {
|
|
2687
|
-
...e.coverageSetup,
|
|
2688
|
-
[n]: r
|
|
2689
|
-
} });
|
|
2930
|
+
}, I = (e) => t({ match: e }), R = (e) => t({ candidates: e }), B = (e) => t({ ranking: e }), V = (e, t) => {
|
|
2931
|
+
let n = parseInt(e, 10);
|
|
2932
|
+
isNaN(n) || t(n);
|
|
2933
|
+
}, H = (e, t) => {
|
|
2934
|
+
let n = parseFloat(e);
|
|
2935
|
+
isNaN(n) || t(Math.max(0, Math.min(100, n)) / 100);
|
|
2690
2936
|
};
|
|
2691
|
-
return /* @__PURE__ */
|
|
2937
|
+
return /* @__PURE__ */ h(O, {
|
|
2692
2938
|
collapsed: !0,
|
|
2693
2939
|
title: "Settings",
|
|
2694
|
-
children: /* @__PURE__ */
|
|
2940
|
+
children: /* @__PURE__ */ g("ul", {
|
|
2695
2941
|
className: Ot.list,
|
|
2696
2942
|
children: [
|
|
2697
|
-
/* @__PURE__ */
|
|
2943
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(P, {
|
|
2944
|
+
label: "Mode",
|
|
2945
|
+
size: "micro",
|
|
2946
|
+
value: E,
|
|
2947
|
+
onValueChange: (e) => t({ mode: e }),
|
|
2948
|
+
options: [{
|
|
2949
|
+
label: "Edit distance",
|
|
2950
|
+
value: d.EditDistance
|
|
2951
|
+
}, {
|
|
2952
|
+
label: "BM25F",
|
|
2953
|
+
value: d.Bm25f
|
|
2954
|
+
}]
|
|
2955
|
+
}) }),
|
|
2956
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
2957
|
+
label: "Rerank (Coverage)",
|
|
2958
|
+
checked: A,
|
|
2959
|
+
onChange: (e) => B({ rerank: e })
|
|
2960
|
+
}) }),
|
|
2961
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
2698
2962
|
label: "Max Results",
|
|
2699
2963
|
type: "number",
|
|
2700
2964
|
value: e.maxNumberOfRecordsToReturn.toString(),
|
|
2701
|
-
onChange: (e) =>
|
|
2965
|
+
onChange: (e) => N("maxNumberOfRecordsToReturn", e.target.value)
|
|
2702
2966
|
}) }),
|
|
2703
|
-
/* @__PURE__ */
|
|
2704
|
-
label: x("Coverage Depth", e.coverageDepth !== void 0),
|
|
2705
|
-
type: "number",
|
|
2706
|
-
value: v.toString(),
|
|
2707
|
-
onChange: (e) => C("coverageDepth", e.target.value)
|
|
2708
|
-
}) }),
|
|
2709
|
-
/* @__PURE__ */ p("li", { children: [/* @__PURE__ */ f(E, {
|
|
2967
|
+
/* @__PURE__ */ g("li", { children: [/* @__PURE__ */ h(k, {
|
|
2710
2968
|
label: "Minimum Score (16 bit)",
|
|
2711
2969
|
type: "number",
|
|
2712
2970
|
value: e.minimumScore.toString(),
|
|
@@ -2716,9 +2974,9 @@ function At() {
|
|
|
2716
2974
|
let n = parseFloat(e.target.value);
|
|
2717
2975
|
isNaN(n) || t({ minimumScore: n });
|
|
2718
2976
|
}
|
|
2719
|
-
}), /* @__PURE__ */
|
|
2977
|
+
}), /* @__PURE__ */ h("div", {
|
|
2720
2978
|
style: { padding: "10px 10px 20px 10px" },
|
|
2721
|
-
children: /* @__PURE__ */
|
|
2979
|
+
children: /* @__PURE__ */ h(L, {
|
|
2722
2980
|
min: 0,
|
|
2723
2981
|
max: 65535,
|
|
2724
2982
|
step: 1,
|
|
@@ -2729,7 +2987,7 @@ function At() {
|
|
|
2729
2987
|
"aria-label": "Minimum score"
|
|
2730
2988
|
})
|
|
2731
2989
|
})] }),
|
|
2732
|
-
/* @__PURE__ */
|
|
2990
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
2733
2991
|
label: "Placeholder text",
|
|
2734
2992
|
type: "text",
|
|
2735
2993
|
value: e.placeholderText,
|
|
@@ -2737,94 +2995,138 @@ function At() {
|
|
|
2737
2995
|
t({ placeholderText: e.target.value });
|
|
2738
2996
|
}
|
|
2739
2997
|
}) }),
|
|
2740
|
-
/* @__PURE__ */
|
|
2998
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
2741
2999
|
label: "Show score",
|
|
2742
3000
|
checked: e.showScore,
|
|
2743
|
-
onChange: (e) =>
|
|
2744
|
-
}) }),
|
|
2745
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(I, {
|
|
2746
|
-
label: "Enable Coverage",
|
|
2747
|
-
checked: e.enableCoverage,
|
|
2748
|
-
onChange: (e) => w("enableCoverage", e)
|
|
3001
|
+
onChange: (e) => F("showScore", e)
|
|
2749
3002
|
}) }),
|
|
2750
|
-
/* @__PURE__ */
|
|
2751
|
-
label: "Remove Duplicates",
|
|
2752
|
-
checked: e.removeDuplicates,
|
|
2753
|
-
onChange: (e) => w("removeDuplicates", e)
|
|
2754
|
-
}) }),
|
|
2755
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
3003
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
2756
3004
|
variant: "ghost",
|
|
2757
3005
|
size: "micro",
|
|
2758
|
-
iconRight:
|
|
3006
|
+
iconRight: h(s ? U : W, {}),
|
|
2759
3007
|
onClick: () => c((e) => !e),
|
|
2760
|
-
children: s ? "Hide
|
|
3008
|
+
children: s ? "Hide Match, Candidates and Ranking" : "Show Match, Candidates and Ranking"
|
|
2761
3009
|
}) }),
|
|
2762
|
-
s && /* @__PURE__ */
|
|
2763
|
-
/* @__PURE__ */
|
|
2764
|
-
label:
|
|
2765
|
-
|
|
2766
|
-
|
|
3010
|
+
s && /* @__PURE__ */ g(m, { children: [
|
|
3011
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(P, {
|
|
3012
|
+
label: "Tolerance",
|
|
3013
|
+
size: "micro",
|
|
3014
|
+
disabled: D,
|
|
3015
|
+
value: f.tolerance ?? C.tolerance,
|
|
3016
|
+
onValueChange: (e) => I({ tolerance: e }),
|
|
3017
|
+
options: [
|
|
3018
|
+
{
|
|
3019
|
+
label: "Exact",
|
|
3020
|
+
value: p.Exact
|
|
3021
|
+
},
|
|
3022
|
+
{
|
|
3023
|
+
label: "One edit",
|
|
3024
|
+
value: p.OneEdit
|
|
3025
|
+
},
|
|
3026
|
+
{
|
|
3027
|
+
label: "Two edits",
|
|
3028
|
+
value: p.TwoEdits
|
|
3029
|
+
},
|
|
3030
|
+
{
|
|
3031
|
+
label: "Three edits",
|
|
3032
|
+
value: p.ThreeEdits
|
|
3033
|
+
}
|
|
3034
|
+
]
|
|
2767
3035
|
}) }),
|
|
2768
|
-
/* @__PURE__ */
|
|
2769
|
-
label:
|
|
2770
|
-
|
|
2771
|
-
|
|
3036
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3037
|
+
label: "Every rung",
|
|
3038
|
+
disabled: D,
|
|
3039
|
+
checked: (f.rungs ?? C.rungs) === u.All,
|
|
3040
|
+
onChange: (e) => I({ rungs: e ? u.All : u.Fewest })
|
|
2772
3041
|
}) }),
|
|
2773
|
-
/* @__PURE__ */
|
|
2774
|
-
label:
|
|
2775
|
-
|
|
2776
|
-
|
|
3042
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3043
|
+
label: "One edit from",
|
|
3044
|
+
type: "number",
|
|
3045
|
+
disabled: D,
|
|
3046
|
+
value: (f.oneEditFrom ?? C.oneEditFrom).toString(),
|
|
3047
|
+
onChange: (e) => V(e.target.value, (e) => I({ oneEditFrom: e }))
|
|
2777
3048
|
}) }),
|
|
2778
|
-
/* @__PURE__ */
|
|
2779
|
-
label:
|
|
2780
|
-
|
|
2781
|
-
|
|
3049
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3050
|
+
label: "Two edits from",
|
|
3051
|
+
type: "number",
|
|
3052
|
+
disabled: D,
|
|
3053
|
+
value: (f.twoEditsFrom ?? C.twoEditsFrom).toString(),
|
|
3054
|
+
onChange: (e) => V(e.target.value, (e) => I({ twoEditsFrom: e }))
|
|
2782
3055
|
}) }),
|
|
2783
|
-
/* @__PURE__ */
|
|
2784
|
-
label:
|
|
2785
|
-
|
|
2786
|
-
|
|
3056
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3057
|
+
label: "Three edits from",
|
|
3058
|
+
type: "number",
|
|
3059
|
+
disabled: D,
|
|
3060
|
+
value: (f.threeEditsFrom ?? C.threeEditsFrom).toString(),
|
|
3061
|
+
onChange: (e) => V(e.target.value, (e) => I({ threeEditsFrom: e }))
|
|
2787
3062
|
}) }),
|
|
2788
|
-
/* @__PURE__ */
|
|
2789
|
-
label:
|
|
2790
|
-
|
|
2791
|
-
|
|
3063
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3064
|
+
label: "Typing prefix from",
|
|
3065
|
+
type: "number",
|
|
3066
|
+
disabled: D,
|
|
3067
|
+
value: (f.typingPrefixFrom ?? C.typingPrefixFrom).toString(),
|
|
3068
|
+
onChange: (e) => V(e.target.value, (e) => I({ typingPrefixFrom: e }))
|
|
2792
3069
|
}) }),
|
|
2793
|
-
/* @__PURE__ */
|
|
2794
|
-
label:
|
|
2795
|
-
|
|
2796
|
-
|
|
3070
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3071
|
+
label: "Joined words",
|
|
3072
|
+
disabled: D,
|
|
3073
|
+
checked: f.joinedWords ?? C.joinedWords,
|
|
3074
|
+
onChange: (e) => I({ joinedWords: e })
|
|
2797
3075
|
}) }),
|
|
2798
|
-
/* @__PURE__ */
|
|
2799
|
-
label:
|
|
3076
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3077
|
+
label: "Candidates per row",
|
|
2800
3078
|
type: "number",
|
|
2801
|
-
|
|
2802
|
-
|
|
3079
|
+
disabled: j,
|
|
3080
|
+
value: (_.candidatesPerRow ?? w.candidatesPerRow).toString(),
|
|
3081
|
+
onChange: (e) => V(e.target.value, (e) => R({ candidatesPerRow: e }))
|
|
2803
3082
|
}) }),
|
|
2804
|
-
/* @__PURE__ */
|
|
2805
|
-
label:
|
|
3083
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3084
|
+
label: "Max candidates (0: per row)",
|
|
2806
3085
|
type: "number",
|
|
2807
|
-
|
|
2808
|
-
|
|
3086
|
+
disabled: j,
|
|
3087
|
+
value: (_.maxCandidates ?? 0).toString(),
|
|
3088
|
+
onChange: (e) => V(e.target.value, (e) => R({ maxCandidates: e > 0 ? e : null }))
|
|
2809
3089
|
}) }),
|
|
2810
|
-
/* @__PURE__ */
|
|
2811
|
-
label:
|
|
3090
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3091
|
+
label: "Fallback (most words when none holds every word)",
|
|
3092
|
+
disabled: D,
|
|
3093
|
+
checked: _.fallback ?? w.fallback,
|
|
3094
|
+
onChange: (e) => R({ fallback: e })
|
|
3095
|
+
}) }),
|
|
3096
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3097
|
+
label: "Rest (BM25F below the counted set)",
|
|
3098
|
+
disabled: D,
|
|
3099
|
+
checked: _.rest ?? w.rest,
|
|
3100
|
+
onChange: (e) => R({ rest: e })
|
|
3101
|
+
}) }),
|
|
3102
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3103
|
+
label: "Coverage share %",
|
|
2812
3104
|
type: "number",
|
|
2813
|
-
|
|
2814
|
-
|
|
3105
|
+
disabled: !A,
|
|
3106
|
+
value: Math.round((v.share ?? T.share) * 100).toString(),
|
|
3107
|
+
onChange: (e) => H(e.target.value, (e) => B({ share: e }))
|
|
2815
3108
|
}) }),
|
|
2816
|
-
/* @__PURE__ */
|
|
2817
|
-
label:
|
|
3109
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(k, {
|
|
3110
|
+
label: "Typing shift %",
|
|
2818
3111
|
type: "number",
|
|
2819
|
-
|
|
2820
|
-
|
|
3112
|
+
disabled: !A,
|
|
3113
|
+
value: Math.round((v.typingShift ?? T.typingShift) * 100).toString(),
|
|
3114
|
+
onChange: (e) => H(e.target.value, (e) => B({ typingShift: e }))
|
|
2821
3115
|
}) }),
|
|
2822
|
-
|
|
3116
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(z, {
|
|
3117
|
+
label: "Whole query floor",
|
|
3118
|
+
disabled: !A,
|
|
3119
|
+
checked: v.wholeQueryFloor ?? T.wholeQueryFloor,
|
|
3120
|
+
onChange: (e) => B({ wholeQueryFloor: e })
|
|
3121
|
+
}) }),
|
|
3122
|
+
M && /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h(S, {
|
|
2823
3123
|
variant: "ghost",
|
|
2824
3124
|
size: "micro",
|
|
2825
3125
|
onClick: () => t({
|
|
2826
|
-
|
|
2827
|
-
|
|
3126
|
+
mode: void 0,
|
|
3127
|
+
match: void 0,
|
|
3128
|
+
candidates: void 0,
|
|
3129
|
+
ranking: void 0
|
|
2828
3130
|
}),
|
|
2829
3131
|
children: "Use the dataset's values"
|
|
2830
3132
|
}) })
|
|
@@ -2834,7 +3136,7 @@ function At() {
|
|
|
2834
3136
|
});
|
|
2835
3137
|
}
|
|
2836
3138
|
// src/components/SearchErrorBoundary.tsx
|
|
2837
|
-
var
|
|
3139
|
+
var Nt = class extends t {
|
|
2838
3140
|
constructor(e) {
|
|
2839
3141
|
super(e), this.state = {
|
|
2840
3142
|
hasError: !1,
|
|
@@ -2857,7 +3159,7 @@ var jt = class extends t {
|
|
|
2857
3159
|
});
|
|
2858
3160
|
};
|
|
2859
3161
|
render() {
|
|
2860
|
-
return this.state.hasError && this.state.error ? this.props.fallback ? this.props.fallback(this.state.error, this.reset) : /* @__PURE__ */
|
|
3162
|
+
return this.state.hasError && this.state.error ? this.props.fallback ? this.props.fallback(this.state.error, this.reset) : /* @__PURE__ */ g("div", {
|
|
2861
3163
|
style: {
|
|
2862
3164
|
padding: "2rem",
|
|
2863
3165
|
backgroundColor: "#fee",
|
|
@@ -2867,22 +3169,22 @@ var jt = class extends t {
|
|
|
2867
3169
|
margin: "2rem auto"
|
|
2868
3170
|
},
|
|
2869
3171
|
children: [
|
|
2870
|
-
/* @__PURE__ */
|
|
3172
|
+
/* @__PURE__ */ h("h2", {
|
|
2871
3173
|
style: {
|
|
2872
3174
|
color: "#c33",
|
|
2873
3175
|
marginTop: 0
|
|
2874
3176
|
},
|
|
2875
3177
|
children: "β οΈ Search Initialization Error"
|
|
2876
3178
|
}),
|
|
2877
|
-
/* @__PURE__ */
|
|
3179
|
+
/* @__PURE__ */ g("p", {
|
|
2878
3180
|
style: { marginBottom: "1rem" },
|
|
2879
3181
|
children: [
|
|
2880
|
-
/* @__PURE__ */
|
|
3182
|
+
/* @__PURE__ */ h("strong", { children: "Error:" }),
|
|
2881
3183
|
" ",
|
|
2882
3184
|
this.state.error.message
|
|
2883
3185
|
]
|
|
2884
3186
|
}),
|
|
2885
|
-
/* @__PURE__ */
|
|
3187
|
+
/* @__PURE__ */ g("div", {
|
|
2886
3188
|
style: {
|
|
2887
3189
|
backgroundColor: "#fff",
|
|
2888
3190
|
padding: "1rem",
|
|
@@ -2890,21 +3192,21 @@ var jt = class extends t {
|
|
|
2890
3192
|
marginBottom: "1rem",
|
|
2891
3193
|
fontSize: "0.9rem"
|
|
2892
3194
|
},
|
|
2893
|
-
children: [/* @__PURE__ */
|
|
3195
|
+
children: [/* @__PURE__ */ h("strong", { children: "π‘ Common fixes:" }), /* @__PURE__ */ g("ul", {
|
|
2894
3196
|
style: {
|
|
2895
3197
|
marginBottom: 0,
|
|
2896
3198
|
paddingLeft: "1.5rem"
|
|
2897
3199
|
},
|
|
2898
3200
|
children: [
|
|
2899
|
-
/* @__PURE__ */
|
|
2900
|
-
/* @__PURE__ */
|
|
2901
|
-
/* @__PURE__ */
|
|
2902
|
-
/* @__PURE__ */
|
|
2903
|
-
/* @__PURE__ */
|
|
3201
|
+
/* @__PURE__ */ h("li", { children: "Check browser console for detailed error messages" }),
|
|
3202
|
+
/* @__PURE__ */ h("li", { children: "Verify the url passed to SearchProvider is correct" }),
|
|
3203
|
+
/* @__PURE__ */ h("li", { children: "Verify your bearer token is valid (create or check it on the Indx Dashboard)" }),
|
|
3204
|
+
/* @__PURE__ */ h("li", { children: "Ensure INDX server is running" }),
|
|
3205
|
+
/* @__PURE__ */ h("li", { children: "Check dataset name spelling" })
|
|
2904
3206
|
]
|
|
2905
3207
|
})]
|
|
2906
3208
|
}),
|
|
2907
|
-
/* @__PURE__ */
|
|
3209
|
+
/* @__PURE__ */ h(S, {
|
|
2908
3210
|
variant: "primary",
|
|
2909
3211
|
size: "micro",
|
|
2910
3212
|
onClick: this.reset,
|
|
@@ -2915,8 +3217,8 @@ var jt = class extends t {
|
|
|
2915
3217
|
}
|
|
2916
3218
|
};
|
|
2917
3219
|
// src/hooks/useVectorSearch.ts
|
|
2918
|
-
function
|
|
2919
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: s } =
|
|
3220
|
+
function Pt(e, t) {
|
|
3221
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: s } = ye(), [u, d] = l(null), [f, p] = l(!1), [m, h] = l(void 0), g = c(0);
|
|
2920
3222
|
return o(() => () => {
|
|
2921
3223
|
g.current++;
|
|
2922
3224
|
}, [
|
|
@@ -2942,7 +3244,7 @@ function Mt(e, t) {
|
|
|
2942
3244
|
headers: { "Content-Type": "application/json" },
|
|
2943
3245
|
body: JSON.stringify(l)
|
|
2944
3246
|
});
|
|
2945
|
-
if (!u.ok) throw await
|
|
3247
|
+
if (!u.ok) throw await Z.fromResponse("VectorSearch", u);
|
|
2946
3248
|
let f = await u.json();
|
|
2947
3249
|
if (!c()) return;
|
|
2948
3250
|
if (f.length === 0) {
|
|
@@ -2954,7 +3256,7 @@ function Mt(e, t) {
|
|
|
2954
3256
|
headers: { "Content-Type": "application/json" },
|
|
2955
3257
|
body: JSON.stringify(p)
|
|
2956
3258
|
});
|
|
2957
|
-
if (!m.ok) throw await
|
|
3259
|
+
if (!m.ok) throw await Z.fromResponse("GetJson", m);
|
|
2958
3260
|
let h = await m.json();
|
|
2959
3261
|
if (!c()) return;
|
|
2960
3262
|
d(h.map((e, t) => ({
|
|
@@ -2981,8 +3283,8 @@ function Mt(e, t) {
|
|
|
2981
3283
|
};
|
|
2982
3284
|
}
|
|
2983
3285
|
// src/hooks/useHybridSearch.ts
|
|
2984
|
-
function
|
|
2985
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: s } =
|
|
3286
|
+
function Ft(e, t) {
|
|
3287
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: s } = ye(), [u, d] = l(null), [f, p] = l(!1), [m, h] = l(void 0), g = c(0);
|
|
2986
3288
|
return o(() => () => {
|
|
2987
3289
|
g.current++;
|
|
2988
3290
|
}, [
|
|
@@ -3010,7 +3312,7 @@ function Nt(e, t) {
|
|
|
3010
3312
|
headers: { "Content-Type": "application/json" },
|
|
3011
3313
|
body: JSON.stringify(l)
|
|
3012
3314
|
});
|
|
3013
|
-
if (!u.ok) throw await
|
|
3315
|
+
if (!u.ok) throw await Z.fromResponse("HybridSearch", u);
|
|
3014
3316
|
let f = await u.json();
|
|
3015
3317
|
if (!c()) return;
|
|
3016
3318
|
if (f.length === 0) {
|
|
@@ -3022,7 +3324,7 @@ function Nt(e, t) {
|
|
|
3022
3324
|
headers: { "Content-Type": "application/json" },
|
|
3023
3325
|
body: JSON.stringify(p)
|
|
3024
3326
|
});
|
|
3025
|
-
if (!m.ok) throw await
|
|
3327
|
+
if (!m.ok) throw await Z.fromResponse("GetJson", m);
|
|
3026
3328
|
let h = await m.json();
|
|
3027
3329
|
if (!c()) return;
|
|
3028
3330
|
d(h.map((e, t) => ({
|
|
@@ -3050,137 +3352,18 @@ function Nt(e, t) {
|
|
|
3050
3352
|
])
|
|
3051
3353
|
};
|
|
3052
3354
|
}
|
|
3053
|
-
// src/hooks/useFilterSuggestion.ts
|
|
3054
|
-
function Pt(e) {
|
|
3055
|
-
let t = e.trim().toLowerCase();
|
|
3056
|
-
return t === "true" || t === "false" || t !== "" && !Number.isNaN(Number(t));
|
|
3057
|
-
}
|
|
3058
|
-
function Ft(e, t) {
|
|
3059
|
-
if (!t) return null;
|
|
3060
|
-
let n = [];
|
|
3061
|
-
for (let [e, r] of Object.entries(t)) for (let t of r ?? []) t?.key && t.key.trim().length >= 2 && !Pt(t.key) && n.push({
|
|
3062
|
-
field: e,
|
|
3063
|
-
value: t.key
|
|
3064
|
-
});
|
|
3065
|
-
n.sort((e, t) => t.value.length - e.value.length);
|
|
3066
|
-
let r = " " + e.toLowerCase() + " ", i = [];
|
|
3067
|
-
for (let e of n) {
|
|
3068
|
-
let t = " " + e.value.toLowerCase().trim() + " ", n = r.indexOf(t);
|
|
3069
|
-
n < 0 || (i.push({
|
|
3070
|
-
field: e.field,
|
|
3071
|
-
value: e.value
|
|
3072
|
-
}), r = r.slice(0, n) + " " + r.slice(n + t.length));
|
|
3073
|
-
}
|
|
3074
|
-
return i.length === 0 ? null : {
|
|
3075
|
-
filters: i,
|
|
3076
|
-
text: r.replace(/[?!.,]+\s*$/, "").replace(/\s+/g, " ").trim(),
|
|
3077
|
-
sort: null
|
|
3078
|
-
};
|
|
3079
|
-
}
|
|
3080
|
-
function It(e = {}) {
|
|
3081
|
-
let t = _e(), { url: n, team: r, dataset: a, authenticatedFetch: s, setQuery: u, toggleFilter: d, setRangeFilter: f, setSort: p } = t, { auto: m } = e, h = c(t);
|
|
3082
|
-
h.current = t;
|
|
3083
|
-
let [g, _] = l(null), [v, y] = l(""), [b, x] = l(!1), S = c(0), C = i(async (e) => {
|
|
3084
|
-
let t = ++S.current;
|
|
3085
|
-
x(!0);
|
|
3086
|
-
try {
|
|
3087
|
-
let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${je(h.current)}`, {
|
|
3088
|
-
method: "POST",
|
|
3089
|
-
headers: { "Content-Type": "application/json" },
|
|
3090
|
-
body: JSON.stringify({ text: e })
|
|
3091
|
-
});
|
|
3092
|
-
if (t !== S.current) return;
|
|
3093
|
-
let o = i.ok ? await i.json() : null;
|
|
3094
|
-
_(o && o.filters.length > 0 ? o : null), y(e);
|
|
3095
|
-
} catch {
|
|
3096
|
-
t === S.current && _(null);
|
|
3097
|
-
} finally {
|
|
3098
|
-
t === S.current && x(!1);
|
|
3099
|
-
}
|
|
3100
|
-
}, [
|
|
3101
|
-
n,
|
|
3102
|
-
r,
|
|
3103
|
-
a,
|
|
3104
|
-
s
|
|
3105
|
-
]), w = i((e) => {
|
|
3106
|
-
u(e.text);
|
|
3107
|
-
let t = {
|
|
3108
|
-
...h.current.state.rangeBounds,
|
|
3109
|
-
...h.current.datasetBounds
|
|
3110
|
-
};
|
|
3111
|
-
for (let n of e.filters) n.value == null ? f(n.field, n.min ?? t[n.field]?.min ?? 0, n.max ?? t[n.field]?.max ?? 2 ** 53 - 1) : d(n.field, n.value);
|
|
3112
|
-
e.sort && p(e.sort.field, !e.sort.descending), _(null);
|
|
3113
|
-
}, [
|
|
3114
|
-
u,
|
|
3115
|
-
d,
|
|
3116
|
-
f,
|
|
3117
|
-
p
|
|
3118
|
-
]), T = i(() => {
|
|
3119
|
-
S.current++, _(null), x(!1);
|
|
3120
|
-
}, []), E = c(/* @__PURE__ */ new Set()), [D, O] = l(null), k = m?.filtersWhileTyping ?? "off", A = !!m && m.available && m.describes && m.offer === "strong" && k !== "off", j = m?.text ?? "", M = c(j);
|
|
3121
|
-
M.current = j;
|
|
3122
|
-
let N = t.state.facets, P = t.state.isLoading || t.facetsEnabled && N == null;
|
|
3123
|
-
return o(() => {
|
|
3124
|
-
if (!A || !j || P || E.current.has(j)) return;
|
|
3125
|
-
E.current.add(j);
|
|
3126
|
-
let e = Ft(j, N);
|
|
3127
|
-
if (e && (E.current.add(e.text), w(e), O(j)), k !== "model") return;
|
|
3128
|
-
let t = e ? e.text : j;
|
|
3129
|
-
if (!t) return;
|
|
3130
|
-
let i = () => M.current === j || M.current === t;
|
|
3131
|
-
(async () => {
|
|
3132
|
-
let o = ++S.current;
|
|
3133
|
-
x(!0);
|
|
3134
|
-
try {
|
|
3135
|
-
let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${je(h.current)}`, {
|
|
3136
|
-
method: "POST",
|
|
3137
|
-
headers: { "Content-Type": "application/json" },
|
|
3138
|
-
body: JSON.stringify({ text: t })
|
|
3139
|
-
});
|
|
3140
|
-
if (o !== S.current || !i()) return;
|
|
3141
|
-
let l = c.ok ? await c.json() : null;
|
|
3142
|
-
l && l.filters.length > 0 && (E.current.add(l.text), w({
|
|
3143
|
-
filters: [...e?.filters ?? [], ...l.filters],
|
|
3144
|
-
text: l.text,
|
|
3145
|
-
sort: l.sort
|
|
3146
|
-
}), O(j));
|
|
3147
|
-
} catch {} finally {
|
|
3148
|
-
o === S.current && x(!1);
|
|
3149
|
-
}
|
|
3150
|
-
})();
|
|
3151
|
-
}, [
|
|
3152
|
-
A,
|
|
3153
|
-
j,
|
|
3154
|
-
k,
|
|
3155
|
-
P,
|
|
3156
|
-
N,
|
|
3157
|
-
w,
|
|
3158
|
-
n,
|
|
3159
|
-
r,
|
|
3160
|
-
a,
|
|
3161
|
-
s
|
|
3162
|
-
]), {
|
|
3163
|
-
suggestion: g,
|
|
3164
|
-
forText: v,
|
|
3165
|
-
loading: b,
|
|
3166
|
-
suggest: C,
|
|
3167
|
-
apply: w,
|
|
3168
|
-
clear: T,
|
|
3169
|
-
appliedText: D
|
|
3170
|
-
};
|
|
3171
|
-
}
|
|
3172
3355
|
// src/hooks/useAsk.ts
|
|
3173
|
-
var
|
|
3356
|
+
var It = {
|
|
3174
3357
|
question: "",
|
|
3175
3358
|
status: "idle",
|
|
3176
3359
|
answer: "",
|
|
3177
3360
|
sources: [],
|
|
3178
3361
|
steps: []
|
|
3179
3362
|
};
|
|
3180
|
-
function
|
|
3181
|
-
let e =
|
|
3363
|
+
function Lt() {
|
|
3364
|
+
let e = ye(), { url: t, team: n, dataset: r, authenticatedFetch: a } = e, s = c(e);
|
|
3182
3365
|
s.current = e;
|
|
3183
|
-
let [u, d] = l(
|
|
3366
|
+
let [u, d] = l(It), f = c(u);
|
|
3184
3367
|
f.current = u;
|
|
3185
3368
|
let p = c(null), m = i(async (e, i = [], o = {}) => {
|
|
3186
3369
|
let c = e.trim();
|
|
@@ -3212,7 +3395,7 @@ function Rt() {
|
|
|
3212
3395
|
}
|
|
3213
3396
|
}));
|
|
3214
3397
|
try {
|
|
3215
|
-
let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${
|
|
3398
|
+
let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${Ae(s.current)}`, {
|
|
3216
3399
|
method: "POST",
|
|
3217
3400
|
headers: {
|
|
3218
3401
|
"Content-Type": "application/json",
|
|
@@ -3226,10 +3409,16 @@ function Rt() {
|
|
|
3226
3409
|
signal: l.signal
|
|
3227
3410
|
});
|
|
3228
3411
|
if (e.status === 429) {
|
|
3229
|
-
let t = await e.json().catch(() => ({}))
|
|
3412
|
+
let t = await e.json().catch(() => ({}));
|
|
3413
|
+
if (o.proactive) {
|
|
3414
|
+
d(It);
|
|
3415
|
+
return;
|
|
3416
|
+
}
|
|
3417
|
+
let n = Number(e.headers.get("Retry-After"));
|
|
3230
3418
|
d((e) => ({
|
|
3231
3419
|
...e,
|
|
3232
3420
|
status: "limited",
|
|
3421
|
+
limit: t.code === "searchOrAskBudgetSpent" ? "budget" : "address",
|
|
3233
3422
|
retryAfterSeconds: t.retryAfterSeconds ?? (Number.isFinite(n) ? n : void 0)
|
|
3234
3423
|
}));
|
|
3235
3424
|
return;
|
|
@@ -3240,10 +3429,15 @@ function Rt() {
|
|
|
3240
3429
|
askId: p
|
|
3241
3430
|
})), !e.ok || !e.body) {
|
|
3242
3431
|
let t = await e.json().catch(() => ({}));
|
|
3243
|
-
|
|
3432
|
+
if (o.proactive) {
|
|
3433
|
+
d(It);
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
let n = e.status === 409 || e.status === 404;
|
|
3437
|
+
g(t.code ?? `http${e.status}`, n ? "Answers are not available here right now. Search still works." : "The question could not be asked.");
|
|
3244
3438
|
return;
|
|
3245
3439
|
}
|
|
3246
|
-
for await (let { event: t, data: n } of
|
|
3440
|
+
for await (let { event: t, data: n } of ke(e.body)) switch (t) {
|
|
3247
3441
|
case "status": {
|
|
3248
3442
|
let e = n.step;
|
|
3249
3443
|
e && d((t) => ({
|
|
@@ -3258,6 +3452,15 @@ function Rt() {
|
|
|
3258
3452
|
filters: n
|
|
3259
3453
|
}));
|
|
3260
3454
|
break;
|
|
3455
|
+
case "picks":
|
|
3456
|
+
d((e) => ({
|
|
3457
|
+
...e,
|
|
3458
|
+
picks: {
|
|
3459
|
+
...n,
|
|
3460
|
+
askId: e.askId
|
|
3461
|
+
}
|
|
3462
|
+
}));
|
|
3463
|
+
break;
|
|
3261
3464
|
case "sources":
|
|
3262
3465
|
d((e) => ({
|
|
3263
3466
|
...e,
|
|
@@ -3322,7 +3525,7 @@ function Rt() {
|
|
|
3322
3525
|
r,
|
|
3323
3526
|
a
|
|
3324
3527
|
]), g = i(() => p.current?.abort(), []), _ = i(() => {
|
|
3325
|
-
p.current?.abort(), d(
|
|
3528
|
+
p.current?.abort(), d(It);
|
|
3326
3529
|
}, []);
|
|
3327
3530
|
return o(() => () => p.current?.abort(), []), {
|
|
3328
3531
|
...u,
|
|
@@ -3349,32 +3552,32 @@ var $ = {
|
|
|
3349
3552
|
searchedLabel: "_searchedLabel_gjc13_23",
|
|
3350
3553
|
steps: "_steps_gjc13_26",
|
|
3351
3554
|
stepDone: "_stepDone_gjc13_27"
|
|
3352
|
-
},
|
|
3353
|
-
function
|
|
3555
|
+
}, Rt = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*|_[^_\n]+_)|(\[[^\]\n]+\]\(https?:\/\/[^)\s]+\))|(\[\d+\])/g;
|
|
3556
|
+
function zt(t, n, r) {
|
|
3354
3557
|
let i = [], a = 0, o = 0;
|
|
3355
|
-
for (let s of t.matchAll(
|
|
3558
|
+
for (let s of t.matchAll(Rt)) {
|
|
3356
3559
|
s.index > a && i.push(t.slice(a, s.index));
|
|
3357
|
-
let c = `${r}-${o++}`, [l, u, d, p, m
|
|
3358
|
-
if (u) i.push(/* @__PURE__ */
|
|
3560
|
+
let c = `${r}-${o++}`, [l, u, d, f, p, m] = s;
|
|
3561
|
+
if (u) i.push(/* @__PURE__ */ h("code", {
|
|
3359
3562
|
className: $.inlineCode,
|
|
3360
3563
|
children: u.slice(1, -1)
|
|
3361
3564
|
}, c));
|
|
3362
|
-
else if (d) i.push(/* @__PURE__ */
|
|
3363
|
-
else if (
|
|
3364
|
-
else if (
|
|
3365
|
-
let [, e, t] = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(
|
|
3366
|
-
i.push(/* @__PURE__ */
|
|
3565
|
+
else if (d) i.push(/* @__PURE__ */ h("strong", { children: zt(d.slice(2, -2), n, c) }, c));
|
|
3566
|
+
else if (f) i.push(/* @__PURE__ */ h("em", { children: zt(f.slice(1, -1), n, c) }, c));
|
|
3567
|
+
else if (p) {
|
|
3568
|
+
let [, e, t] = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(p);
|
|
3569
|
+
i.push(/* @__PURE__ */ h("a", {
|
|
3367
3570
|
href: t,
|
|
3368
3571
|
target: "_blank",
|
|
3369
3572
|
rel: "noopener noreferrer",
|
|
3370
3573
|
children: e
|
|
3371
3574
|
}, c));
|
|
3372
|
-
} else
|
|
3575
|
+
} else m ? i.push(/* @__PURE__ */ h(e.Fragment, { children: n(Number(m.slice(1, -1))) }, c)) : i.push(l);
|
|
3373
3576
|
a = s.index + l.length;
|
|
3374
3577
|
}
|
|
3375
3578
|
return a < t.length && i.push(t.slice(a)), i;
|
|
3376
3579
|
}
|
|
3377
|
-
function
|
|
3580
|
+
function Bt(e) {
|
|
3378
3581
|
let t = e.replace(/\r\n/g, "\n").split("\n"), n = [], r = [], i = () => {
|
|
3379
3582
|
r.length && (n.push({
|
|
3380
3583
|
kind: "paragraph",
|
|
@@ -3423,75 +3626,100 @@ function Vt(e) {
|
|
|
3423
3626
|
}
|
|
3424
3627
|
return i(), n;
|
|
3425
3628
|
}
|
|
3426
|
-
function
|
|
3427
|
-
return
|
|
3629
|
+
function Vt(e, t) {
|
|
3630
|
+
return Bt(e).map((e, n) => {
|
|
3428
3631
|
let r = `b${n}`;
|
|
3429
3632
|
switch (e.kind) {
|
|
3430
|
-
case "code": return /* @__PURE__ */
|
|
3633
|
+
case "code": return /* @__PURE__ */ h("pre", {
|
|
3431
3634
|
className: $.codeBlock,
|
|
3432
3635
|
"data-lang": e.lang || void 0,
|
|
3433
|
-
children: /* @__PURE__ */
|
|
3636
|
+
children: /* @__PURE__ */ h("code", { children: e.text })
|
|
3434
3637
|
}, r);
|
|
3435
|
-
case "heading": return /* @__PURE__ */
|
|
3638
|
+
case "heading": return /* @__PURE__ */ h("p", {
|
|
3436
3639
|
className: $.heading,
|
|
3437
|
-
children:
|
|
3640
|
+
children: zt(e.text, t, r)
|
|
3438
3641
|
}, r);
|
|
3439
3642
|
case "list": {
|
|
3440
3643
|
let n = e.ordered ? "ol" : "ul";
|
|
3441
|
-
return /* @__PURE__ */
|
|
3644
|
+
return /* @__PURE__ */ h(n, {
|
|
3442
3645
|
className: $.list,
|
|
3443
|
-
children: e.items.map((e, n) => /* @__PURE__ */
|
|
3646
|
+
children: e.items.map((e, n) => /* @__PURE__ */ h("li", { children: zt(e, t, `${r}-${n}`) }, n))
|
|
3444
3647
|
}, r);
|
|
3445
3648
|
}
|
|
3446
|
-
default: return /* @__PURE__ */
|
|
3649
|
+
default: return /* @__PURE__ */ h("p", {
|
|
3447
3650
|
className: $.paragraph,
|
|
3448
|
-
children:
|
|
3651
|
+
children: zt(e.text, t, r)
|
|
3449
3652
|
}, r);
|
|
3450
3653
|
}
|
|
3451
3654
|
});
|
|
3452
3655
|
}
|
|
3453
3656
|
// src/components/AskPanel.tsx
|
|
3454
|
-
var
|
|
3657
|
+
var Ht = /\[(\d+)\]/g, Ut = /* @__PURE__ */ new Set([
|
|
3658
|
+
"nothingFound",
|
|
3659
|
+
"searchOrAskDisabled",
|
|
3660
|
+
"searchOrAskUnavailable",
|
|
3661
|
+
"http404"
|
|
3662
|
+
]);
|
|
3455
3663
|
function Wt(e) {
|
|
3456
3664
|
let t = e.field.split(".")[0];
|
|
3457
3665
|
return e.value === "true" ? t : e.value === "false" ? `not ${t}` : e.value == null ? e.min != null && e.max != null ? e.min === e.max ? `${t} ${e.min}` : `${t} ${e.min}β${e.max}` : e.min == null ? `${t} β€ ${e.max}` : `${t} β₯ ${e.min}` : e.value;
|
|
3458
3666
|
}
|
|
3459
|
-
var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r, label: i = "Answer", renderAnswer: a =
|
|
3460
|
-
let
|
|
3667
|
+
var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r, label: i = "Answer", renderAnswer: a = Vt, onFollowUp: s, onStatusChange: u, onFilters: d, onPicks: f, listPicks: p = !0, filterLabel: m = Wt, fill: C = !1, className: O = "" }) => {
|
|
3668
|
+
let k = Lt(), { showPicks: A } = ye(), j = c(A);
|
|
3669
|
+
j.current = A, o(() => () => j.current?.(null), []);
|
|
3670
|
+
let { ask: M, reset: N, stop: P, status: F, openSource: I } = k, [L, z] = l(!1), [B, H] = l([]), [U, W] = l(""), G = c([]), K = c(null), ee = c(null), q = c(!0);
|
|
3461
3671
|
o(() => {
|
|
3462
|
-
|
|
3672
|
+
H([]), G.current = [], j.current?.(null), e?.trim() ? M(e, [], { proactive: t }) : N();
|
|
3463
3673
|
}, [
|
|
3464
3674
|
e,
|
|
3465
|
-
|
|
3466
|
-
|
|
3675
|
+
M,
|
|
3676
|
+
N
|
|
3467
3677
|
]), o(() => {
|
|
3468
|
-
u?.(
|
|
3469
|
-
}, [
|
|
3470
|
-
let
|
|
3678
|
+
u?.(F);
|
|
3679
|
+
}, [F, u]);
|
|
3680
|
+
let te = c(void 0);
|
|
3681
|
+
o(() => {
|
|
3682
|
+
k.filters && k.filters !== te.current && (te.current = k.filters, d?.(k.filters));
|
|
3683
|
+
}, [k.filters, d]);
|
|
3684
|
+
let ne = c(void 0);
|
|
3471
3685
|
o(() => {
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3686
|
+
if (k.picks && k.picks !== ne.current) {
|
|
3687
|
+
ne.current = k.picks;
|
|
3688
|
+
let e = {
|
|
3689
|
+
...k.picks,
|
|
3690
|
+
askId: k.picks.askId ?? k.askId
|
|
3691
|
+
};
|
|
3692
|
+
f?.(e), p && !t && A?.(e);
|
|
3693
|
+
}
|
|
3476
3694
|
}, [
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3695
|
+
k.picks,
|
|
3696
|
+
k.askId,
|
|
3697
|
+
f,
|
|
3698
|
+
p,
|
|
3699
|
+
t,
|
|
3700
|
+
A
|
|
3701
|
+
]), o(() => {
|
|
3702
|
+
let e = ee.current;
|
|
3703
|
+
C && e && q.current && (e.scrollTop = e.scrollHeight);
|
|
3704
|
+
}, [
|
|
3705
|
+
C,
|
|
3706
|
+
k.answer,
|
|
3707
|
+
k.steps.length,
|
|
3708
|
+
F,
|
|
3709
|
+
B.length
|
|
3482
3710
|
]);
|
|
3483
|
-
let
|
|
3484
|
-
let e =
|
|
3485
|
-
e && (
|
|
3486
|
-
},
|
|
3711
|
+
let J = () => {
|
|
3712
|
+
let e = ee.current;
|
|
3713
|
+
e && (q.current = e.scrollHeight - e.scrollTop - e.clientHeight < 40);
|
|
3714
|
+
}, X = (e) => e && /* @__PURE__ */ g("div", {
|
|
3487
3715
|
className: $.searched,
|
|
3488
3716
|
children: [
|
|
3489
|
-
/* @__PURE__ */
|
|
3717
|
+
/* @__PURE__ */ g("span", {
|
|
3490
3718
|
className: $.searchedLabel,
|
|
3491
3719
|
children: [e.more ? `${e.found}+` : e.found, " found"]
|
|
3492
3720
|
}),
|
|
3493
|
-
e.filters.map((e, t) => /* @__PURE__ */
|
|
3494
|
-
e.text && /* @__PURE__ */
|
|
3721
|
+
e.filters.map((e, t) => /* @__PURE__ */ h(w, { children: m(e) }, t)),
|
|
3722
|
+
e.text && /* @__PURE__ */ g("span", {
|
|
3495
3723
|
className: $.searchedLabel,
|
|
3496
3724
|
children: [
|
|
3497
3725
|
"β",
|
|
@@ -3499,7 +3727,7 @@ var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r,
|
|
|
3499
3727
|
"β"
|
|
3500
3728
|
]
|
|
3501
3729
|
}),
|
|
3502
|
-
e.sort && /* @__PURE__ */
|
|
3730
|
+
e.sort && /* @__PURE__ */ g("span", {
|
|
3503
3731
|
className: $.searchedLabel,
|
|
3504
3732
|
children: [
|
|
3505
3733
|
"sorted by ",
|
|
@@ -3511,140 +3739,152 @@ var Gt = ({ question: e, proactive: t = !1, followUps: n = !1, onSourceClick: r,
|
|
|
3511
3739
|
})
|
|
3512
3740
|
]
|
|
3513
3741
|
});
|
|
3514
|
-
if (
|
|
3515
|
-
let
|
|
3516
|
-
n.preventDefault(),
|
|
3517
|
-
},
|
|
3742
|
+
if (F === "idle" && B.length === 0) return null;
|
|
3743
|
+
let re = (e, t) => (n) => {
|
|
3744
|
+
n.preventDefault(), I(e, t), r?.(e);
|
|
3745
|
+
}, ie = (e, t) => (n) => {
|
|
3518
3746
|
let i = e.find((e) => e.n === n);
|
|
3519
|
-
return /* @__PURE__ */
|
|
3747
|
+
return /* @__PURE__ */ h(E, {
|
|
3520
3748
|
n,
|
|
3521
3749
|
title: i?.title,
|
|
3522
|
-
onClick: i && r ?
|
|
3750
|
+
onClick: i && r ? re(i, t) : void 0
|
|
3523
3751
|
});
|
|
3524
|
-
},
|
|
3525
|
-
let r = new Set([...e.matchAll(
|
|
3752
|
+
}, ae = (e, t, n) => {
|
|
3753
|
+
let r = new Set([...e.matchAll(Ht)].map((e) => Number(e[1])));
|
|
3526
3754
|
return n && r.size > 0 ? t.filter((e) => r.has(e.n)) : t.slice(0, 3);
|
|
3527
|
-
},
|
|
3528
|
-
let
|
|
3529
|
-
return
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3755
|
+
}, Z = (e, t, n, i, a = !1) => {
|
|
3756
|
+
let o = a ? t : ae(e, t, n);
|
|
3757
|
+
return o.length > 0 && /* @__PURE__ */ h(T, {
|
|
3758
|
+
label: a ? "Picked" : void 0,
|
|
3759
|
+
items: o.map((e) => ({
|
|
3760
|
+
n: e.n,
|
|
3761
|
+
title: e.title,
|
|
3762
|
+
onClick: r ? re(e, i) : void 0
|
|
3763
|
+
}))
|
|
3764
|
+
});
|
|
3765
|
+
}, oe = () => {
|
|
3766
|
+
navigator.clipboard?.writeText(k.answer.replace(Ht, "")).catch(() => {}), z(!0), setTimeout(() => z(!1), 2e3);
|
|
3767
|
+
}, se = (e) => {
|
|
3768
|
+
if (!k.busy && e.trim()) {
|
|
3769
|
+
if (F === "answered" && k.answer) {
|
|
3539
3770
|
let e = {
|
|
3540
|
-
question:
|
|
3541
|
-
answer:
|
|
3542
|
-
sources:
|
|
3543
|
-
askId:
|
|
3544
|
-
filters:
|
|
3771
|
+
question: k.question,
|
|
3772
|
+
answer: k.answer,
|
|
3773
|
+
sources: k.sources,
|
|
3774
|
+
askId: k.askId,
|
|
3775
|
+
filters: k.filters,
|
|
3776
|
+
picks: k.picks
|
|
3545
3777
|
};
|
|
3546
|
-
|
|
3778
|
+
H((t) => [...t, e]), G.current = [...G.current, {
|
|
3547
3779
|
question: e.question,
|
|
3548
3780
|
answer: e.answer,
|
|
3549
|
-
...e.
|
|
3781
|
+
...e.picks ? { shown: { picks: e.picks.picks.map((e) => ({
|
|
3782
|
+
documentKey: e.documentKey,
|
|
3783
|
+
title: e.title
|
|
3784
|
+
})) } } : e.filters ? { shown: {
|
|
3550
3785
|
filters: e.filters.filters,
|
|
3551
3786
|
text: e.filters.text,
|
|
3552
3787
|
sort: e.filters.sort ?? null
|
|
3553
3788
|
} } : {}
|
|
3554
3789
|
}];
|
|
3555
3790
|
}
|
|
3556
|
-
|
|
3791
|
+
W(""), M(e, G.current);
|
|
3557
3792
|
}
|
|
3558
|
-
},
|
|
3559
|
-
return /* @__PURE__ */
|
|
3560
|
-
className: `${$.panel} ${
|
|
3793
|
+
}, ce = n ? () => K.current?.focus() : s;
|
|
3794
|
+
return /* @__PURE__ */ g("div", {
|
|
3795
|
+
className: `${$.panel} ${C ? $.fill : ""} ${O}`,
|
|
3561
3796
|
"aria-live": "polite",
|
|
3562
|
-
"aria-busy":
|
|
3563
|
-
children: [/* @__PURE__ */
|
|
3564
|
-
ref:
|
|
3797
|
+
"aria-busy": k.busy,
|
|
3798
|
+
children: [/* @__PURE__ */ g("div", {
|
|
3799
|
+
ref: ee,
|
|
3565
3800
|
className: $.thread,
|
|
3566
|
-
onScroll:
|
|
3567
|
-
children: [
|
|
3801
|
+
onScroll: C ? J : void 0,
|
|
3802
|
+
children: [B.map((e, t) => /* @__PURE__ */ g("div", {
|
|
3568
3803
|
className: $.turn,
|
|
3569
|
-
children: [/* @__PURE__ */
|
|
3804
|
+
children: [/* @__PURE__ */ h(V, { children: e.question }), /* @__PURE__ */ g(x, {
|
|
3570
3805
|
label: i,
|
|
3571
3806
|
children: [
|
|
3572
|
-
|
|
3573
|
-
/* @__PURE__ */
|
|
3807
|
+
X(e.filters),
|
|
3808
|
+
/* @__PURE__ */ h("div", {
|
|
3574
3809
|
className: $.answer,
|
|
3575
|
-
children: a(e.answer,
|
|
3810
|
+
children: a(e.answer, ie(e.sources, e.askId))
|
|
3576
3811
|
}),
|
|
3577
|
-
|
|
3812
|
+
Z(e.answer, e.sources, !0, e.askId, !!e.picks)
|
|
3578
3813
|
]
|
|
3579
3814
|
})]
|
|
3580
|
-
}, t)),
|
|
3815
|
+
}, t)), F !== "idle" && /* @__PURE__ */ g("div", {
|
|
3581
3816
|
className: $.turn,
|
|
3582
|
-
children: [/* @__PURE__ */
|
|
3817
|
+
children: [/* @__PURE__ */ h(V, { children: k.question }), /* @__PURE__ */ g(x, {
|
|
3583
3818
|
label: i,
|
|
3584
3819
|
children: [
|
|
3585
|
-
|
|
3586
|
-
|
|
3820
|
+
X(k.filters),
|
|
3821
|
+
k.answer && /* @__PURE__ */ h("div", {
|
|
3587
3822
|
className: $.answer,
|
|
3588
|
-
children: a(
|
|
3823
|
+
children: a(k.answer, ie(k.sources))
|
|
3589
3824
|
}),
|
|
3590
|
-
|
|
3825
|
+
F === "searching" && k.steps.length > 0 && /* @__PURE__ */ g("div", {
|
|
3591
3826
|
className: $.steps,
|
|
3592
|
-
children: [
|
|
3827
|
+
children: [k.steps.slice(0, -1).map((e, t) => /* @__PURE__ */ h("span", {
|
|
3593
3828
|
className: $.stepDone,
|
|
3594
3829
|
children: e
|
|
3595
|
-
}, t)), /* @__PURE__ */
|
|
3830
|
+
}, t)), /* @__PURE__ */ g(R, { children: [k.steps[k.steps.length - 1], "β¦"] })]
|
|
3596
3831
|
}),
|
|
3597
|
-
|
|
3598
|
-
|
|
3832
|
+
F === "searching" && k.steps.length === 0 && /* @__PURE__ */ h(R, { children: "Searchingβ¦" }),
|
|
3833
|
+
F === "writing" && /* @__PURE__ */ h(R, {
|
|
3599
3834
|
spinner: "grow",
|
|
3600
3835
|
children: "Writingβ¦"
|
|
3601
3836
|
}),
|
|
3602
|
-
|
|
3837
|
+
F === "error" && /* @__PURE__ */ g(_, {
|
|
3603
3838
|
variant: "default",
|
|
3604
3839
|
icon: null,
|
|
3605
3840
|
children: [
|
|
3606
|
-
/* @__PURE__ */
|
|
3607
|
-
/* @__PURE__ */
|
|
3608
|
-
|
|
3841
|
+
/* @__PURE__ */ h(y, { children: k.error?.code === "nothingFound" ? "Nothing to answer from" : "The answer did not come through" }),
|
|
3842
|
+
/* @__PURE__ */ h(v, { children: k.error?.code === "nothingFound" ? "The search found no records about this. Try other words, or search instead." : k.error?.message }),
|
|
3843
|
+
!Ut.has(k.error?.code ?? "") && /* @__PURE__ */ h("div", {
|
|
3609
3844
|
className: $.action,
|
|
3610
|
-
children: /* @__PURE__ */
|
|
3845
|
+
children: /* @__PURE__ */ h(S, {
|
|
3611
3846
|
variant: "secondary",
|
|
3612
3847
|
size: "micro",
|
|
3613
|
-
iconLeft: /* @__PURE__ */
|
|
3614
|
-
onClick: () =>
|
|
3848
|
+
iconLeft: /* @__PURE__ */ h(Y, {}),
|
|
3849
|
+
onClick: () => M(k.question, G.current),
|
|
3615
3850
|
children: "Try again"
|
|
3616
3851
|
})
|
|
3617
3852
|
})
|
|
3618
3853
|
]
|
|
3619
3854
|
}),
|
|
3620
|
-
|
|
3855
|
+
F === "limited" && k.limit === "budget" && /* @__PURE__ */ g(_, {
|
|
3856
|
+
variant: "default",
|
|
3857
|
+
icon: null,
|
|
3858
|
+
children: [/* @__PURE__ */ h(y, { children: "No more answers today" }), /* @__PURE__ */ h(v, { children: "This site has answered all the questions it can for today. Search still works, and asking is back tomorrow." })]
|
|
3859
|
+
}),
|
|
3860
|
+
F === "limited" && k.limit !== "budget" && /* @__PURE__ */ g(_, {
|
|
3621
3861
|
variant: "default",
|
|
3622
3862
|
icon: null,
|
|
3623
|
-
children: [/* @__PURE__ */
|
|
3863
|
+
children: [/* @__PURE__ */ h(y, { children: "Too many questions for now" }), /* @__PURE__ */ g(v, { children: [
|
|
3624
3864
|
"You can ask again in about ",
|
|
3625
|
-
|
|
3865
|
+
k.retryAfterSeconds && k.retryAfterSeconds > 90 ? `${Math.ceil(k.retryAfterSeconds / 60)} minutes` : "a minute",
|
|
3626
3866
|
". Search still works in the meantime."
|
|
3627
3867
|
] })]
|
|
3628
3868
|
}),
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
onCopy:
|
|
3632
|
-
copied:
|
|
3633
|
-
onFollowUp:
|
|
3869
|
+
F !== "error" && F !== "limited" && Z(k.answer, k.sources, F === "answered", void 0, !!k.picks),
|
|
3870
|
+
F === "answered" && /* @__PURE__ */ h(b, {
|
|
3871
|
+
onCopy: oe,
|
|
3872
|
+
copied: L,
|
|
3873
|
+
onFollowUp: ce
|
|
3634
3874
|
})
|
|
3635
3875
|
]
|
|
3636
3876
|
})]
|
|
3637
3877
|
})]
|
|
3638
|
-
}), n && /* @__PURE__ */
|
|
3639
|
-
ref:
|
|
3640
|
-
value:
|
|
3641
|
-
onChange:
|
|
3642
|
-
onSend:
|
|
3643
|
-
onStop:
|
|
3644
|
-
streaming:
|
|
3878
|
+
}), n && /* @__PURE__ */ h(D, {
|
|
3879
|
+
ref: K,
|
|
3880
|
+
value: U,
|
|
3881
|
+
onChange: W,
|
|
3882
|
+
onSend: se,
|
|
3883
|
+
onStop: P,
|
|
3884
|
+
streaming: k.busy,
|
|
3645
3885
|
placeholder: "Ask a follow-upβ¦",
|
|
3646
3886
|
"aria-label": "Ask a follow-up"
|
|
3647
3887
|
})]
|
|
3648
3888
|
});
|
|
3649
3889
|
};
|
|
3650
|
-
export {
|
|
3890
|
+
export { He as ActiveFiltersPanel, Gt as AskPanel, Tt as BucketFilterPanel, xe as DEFAULT_THRESHOLDS, ft as FilterPanelSkeleton, Z as IndxApiError, Le as QuickAnswer, St as RangeFilterPanel, De as STRICT_MATCH, _e as SearchContext, Nt as SearchErrorBoundary, We as SearchInput, ve as SearchProvider, Xe as SearchResult, lt as SearchResultRow, st as SearchResults, qe as SearchResultsMessage, $e as SearchResultsSkeleton, Mt as SearchSettingsPanel, oe as SearchSetupError, Dt as SortByPanel, gt as ValueFilterPanel, se as describeSearchError, Ce as isIdentifier, tt as localFilters, Ee as nextOffer, be as pageMode, Te as triggers, Lt as useAsk, nt as useFilterSuggestion, Ft as useHybridSearch, ye as useSearch, ye as useSearchContext, Pe as useSearchOrAsk, Pt as useVectorSearch };
|