@indxsearch/intrface 3.13.1 β 3.13.2
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 +30 -0
- package/dist/components/SearchInput.d.ts +4 -2
- package/dist/context/SearchContext.d.ts +2 -0
- package/dist/context/useSearchExecution.d.ts +3 -1
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +669 -658
- package/dist/intrface.css +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -2,10 +2,10 @@ 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
3
|
import { SystemState as u } from "@indxsearch/indx-types";
|
|
4
4
|
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
|
-
import { Alert as m, AlertDescription as h, AlertTitle as g, AnswerActions as _, AssistantMessage as v, Button as y, Checkbox as b, Chip as x, CitationList as S, CitationRef as C, Composer as w, FilterPanelBase as T, InputField as E,
|
|
6
|
-
import { Ai_agent as
|
|
5
|
+
import { Alert as m, AlertDescription as h, AlertTitle as g, AnswerActions as _, AssistantMessage as v, Button as y, Checkbox as b, Chip as x, CitationList as S, CitationRef as C, Composer as w, FilterPanelBase as T, InputField as E, Kbd as D, RadioButton as O, SearchField as k, Select as A, Skeleton as j, Slider as M, StreamStatus as N, ToggleSwitch as P, Tooltip as F, UserMessage as I } from "@indxsearch/systm";
|
|
6
|
+
import { Ai_agent as L, ArrowDown as R, ArrowRight as z, Cloud as B, Filter as V, Fuzzy_search as H, Hour_glass as U, Indx as W, Key as ee, Lock as G, Refresh as te, Search as K, Speedometer as ne, Warning as re, X_or_error as ie } from "@indxsearch/pixl";
|
|
7
7
|
//#region src/context/IndxApiError.ts
|
|
8
|
-
var
|
|
8
|
+
var q = class e extends Error {
|
|
9
9
|
status;
|
|
10
10
|
code;
|
|
11
11
|
problem;
|
|
@@ -29,14 +29,14 @@ var J = 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
|
+
}, J = class extends Error {
|
|
33
33
|
constructor(e) {
|
|
34
34
|
super(e), this.name = "SearchSetupError";
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
function
|
|
37
|
+
function ae(e, t) {
|
|
38
38
|
let n = e instanceof Error ? e.message : String(e);
|
|
39
|
-
if (e instanceof
|
|
39
|
+
if (e instanceof J) return {
|
|
40
40
|
kind: "setup",
|
|
41
41
|
message: n,
|
|
42
42
|
technical: n,
|
|
@@ -48,7 +48,7 @@ function ie(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 q) {
|
|
52
52
|
let r = {
|
|
53
53
|
message: n,
|
|
54
54
|
status: e.status,
|
|
@@ -115,15 +115,15 @@ function ie(e, t) {
|
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/context/useIndxAuth.ts
|
|
118
|
-
function
|
|
118
|
+
function oe({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebugLogs: i = !1 }) {
|
|
119
119
|
let [a, s] = l(null), [c, d] = l(!0), [f, 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);
|
|
120
120
|
return o(() => {
|
|
121
121
|
(async () => {
|
|
122
122
|
D(null), k(null), d(!0);
|
|
123
123
|
try {
|
|
124
|
-
if (!r) throw console.error("[Auth] β Missing bearer token"), console.error("[Auth] π‘ Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new
|
|
125
|
-
if (!e) throw console.error("[Auth] β Missing INDX server URL"), console.error("[Auth] π‘ Pass a url to SearchProvider"), new
|
|
126
|
-
if (!n) throw console.error("[Auth] β Missing dataset name"), console.error("[Auth] π‘ Pass dataset=\"your-dataset-name\" to SearchProvider"), new
|
|
124
|
+
if (!r) throw console.error("[Auth] β Missing bearer token"), console.error("[Auth] π‘ Pass preAuthenticatedToken to SearchProvider (create a token on the Indx Dashboard)"), new J("A bearer token is required. Check console for instructions.");
|
|
125
|
+
if (!e) throw console.error("[Auth] β Missing INDX server URL"), console.error("[Auth] π‘ Pass a url to SearchProvider"), new J("INDX server URL is required. Check console for instructions.");
|
|
126
|
+
if (!n) throw console.error("[Auth] β Missing dataset name"), console.error("[Auth] π‘ Pass dataset=\"your-dataset-name\" to SearchProvider"), new J("Dataset name is required. Check console for instructions.");
|
|
127
127
|
i && console.log("[Auth] β
Using bearer token");
|
|
128
128
|
let a = r, o = (e) => fetch(e, {
|
|
129
129
|
method: "GET",
|
|
@@ -134,7 +134,7 @@ function ae({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
134
134
|
});
|
|
135
135
|
i && console.log("[Auth] π Checking dataset status...");
|
|
136
136
|
let c = await o(`${e}/api/teams/${t}/datasets/${n}/status`);
|
|
137
|
-
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
|
|
137
|
+
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 q.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 q.fromResponse("Dataset status", c)) : (console.error("[Auth] β Failed to get dataset status:", c.status), await q.fromResponse("Dataset status", c));
|
|
138
138
|
let l = await c.json();
|
|
139
139
|
i && console.log("[Auth] π Dataset status:", l), s(a), i && console.log("[Auth] β
Dataset session established"), l.systemState !== void 0 && l.systemState !== u.Ready && (console.warn("[Auth] β οΈ Dataset is not ready yet. Current state:", u[l.systemState]), console.warn("[Auth] π‘ Wait for indexing to complete before searching"));
|
|
140
140
|
let d = l.documentCount ?? l.numberOfRecords ?? 0;
|
|
@@ -145,9 +145,9 @@ function ae({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
145
145
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/sortable`),
|
|
146
146
|
o(`${e}/api/teams/${t}/datasets/${n}/fields/configuration`).catch(() => null)
|
|
147
147
|
]);
|
|
148
|
-
if (!f.ok) throw console.error("[Auth] β GetFilterableFields failed:", f.status), await
|
|
149
|
-
if (!m.ok) throw console.error("[Auth] β GetFacetableFields failed:", m.status), await
|
|
150
|
-
if (!g.ok) throw console.error("[Auth] β GetSortableFields failed:", g.status), await
|
|
148
|
+
if (!f.ok) throw console.error("[Auth] β GetFilterableFields failed:", f.status), await q.fromResponse("Filterable fields", f);
|
|
149
|
+
if (!m.ok) throw console.error("[Auth] β GetFacetableFields failed:", m.status), await q.fromResponse("Facetable fields", m);
|
|
150
|
+
if (!g.ok) throw console.error("[Auth] β GetSortableFields failed:", g.status), await q.fromResponse("Sortable fields", g);
|
|
151
151
|
let [b, S, w] = await Promise.all([
|
|
152
152
|
f.json().catch((e) => (console.error("Failed to parse GetFilterableFields response:", e), [])),
|
|
153
153
|
m.json().catch((e) => (console.error("Failed to parse GetFacetableFields response:", e), [])),
|
|
@@ -192,7 +192,7 @@ function ae({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
192
192
|
if (D.facets) for (let [e, t] of Object.entries(D.facets)) Array.isArray(t) && (k[e] = t.map((e) => e.key));
|
|
193
193
|
x(O), C(k), i && console.log("[Auth] β
Initialization complete");
|
|
194
194
|
} catch (r) {
|
|
195
|
-
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(
|
|
195
|
+
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(ae(r, {
|
|
196
196
|
team: t,
|
|
197
197
|
dataset: n
|
|
198
198
|
}));
|
|
@@ -222,30 +222,30 @@ function ae({ url: e, team: t, dataset: n, preAuthenticatedToken: r, enableDebug
|
|
|
222
222
|
}
|
|
223
223
|
//#endregion
|
|
224
224
|
//#region src/context/buildFilterProxy.ts
|
|
225
|
-
async function
|
|
225
|
+
async function se(e, t, n, r, i, a, o) {
|
|
226
226
|
let s = await o(`${r}/api/teams/${i}/datasets/${a}/filters/${e}`, {
|
|
227
227
|
method: "POST",
|
|
228
228
|
headers: { "Content-Type": "application/json" },
|
|
229
229
|
body: JSON.stringify(t)
|
|
230
230
|
});
|
|
231
|
-
if (!s.ok) throw await
|
|
231
|
+
if (!s.ok) throw await q.fromResponse(n, s);
|
|
232
232
|
let c = await s.json();
|
|
233
233
|
if (!c || typeof c.hashString != "string") throw Error(`${n} failed: server returned no filter token`);
|
|
234
234
|
return c;
|
|
235
235
|
}
|
|
236
|
-
async function
|
|
236
|
+
async function ce(e, t, n, r, i, a) {
|
|
237
237
|
if (e.length === 0) return null;
|
|
238
238
|
if (e.length === 1) return e[0];
|
|
239
239
|
let o = e[0];
|
|
240
|
-
for (let s = 1; s < e.length; s++) o = await
|
|
240
|
+
for (let s = 1; s < e.length; s++) o = await se("combine", {
|
|
241
241
|
a: o,
|
|
242
242
|
b: e[s],
|
|
243
243
|
useAndOperation: t === "and"
|
|
244
244
|
}, "CombineFilters", n, r, i, a);
|
|
245
245
|
return o;
|
|
246
246
|
}
|
|
247
|
-
async function
|
|
248
|
-
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 }) =>
|
|
247
|
+
async function le(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
248
|
+
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 }) => se("range", {
|
|
249
249
|
fieldName: e,
|
|
250
250
|
lowerLimit: t,
|
|
251
251
|
upperLimit: o
|
|
@@ -254,16 +254,16 @@ async function ce(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
254
254
|
return Number.isFinite(o) ? f(e, {
|
|
255
255
|
min: o,
|
|
256
256
|
max: o
|
|
257
|
-
}) :
|
|
257
|
+
}) : se("value", {
|
|
258
258
|
fieldName: e,
|
|
259
259
|
value: t
|
|
260
260
|
}, `Value filter '${e}'`, n, r, i, a);
|
|
261
261
|
}, [m, h, g] = await Promise.all([
|
|
262
|
-
Promise.all(l.map(async ([e, t]) =>
|
|
262
|
+
Promise.all(l.map(async ([e, t]) => ce(await Promise.all(t.map((t) => p(e, t))), o[e] === "any" ? "or" : "and", n, r, i, a))),
|
|
263
263
|
Promise.all(u.map(([e, t]) => f(e, t))),
|
|
264
|
-
Promise.all(d.map(async ([e, t]) =>
|
|
264
|
+
Promise.all(d.map(async ([e, t]) => ce(await Promise.all(t.map((t) => f(e, t))), "or", n, r, i, a)))
|
|
265
265
|
]);
|
|
266
|
-
return
|
|
266
|
+
return ce([
|
|
267
267
|
...m,
|
|
268
268
|
...h,
|
|
269
269
|
...g
|
|
@@ -271,16 +271,16 @@ async function ce(e, t, n, r, i, a, o = {}, s = {}, c = {}) {
|
|
|
271
271
|
}
|
|
272
272
|
//#endregion
|
|
273
273
|
//#region src/context/useSearchExecution.ts
|
|
274
|
-
function
|
|
274
|
+
function ue(e, t) {
|
|
275
275
|
let n, r = (...r) => {
|
|
276
276
|
clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
277
277
|
};
|
|
278
278
|
return r.cancel = () => clearTimeout(n), r;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
281
|
-
let
|
|
282
|
-
|
|
283
|
-
let
|
|
280
|
+
function de({ 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 }) {
|
|
281
|
+
let b = y ? y(e.query) : e.query, x = c(e.query);
|
|
282
|
+
x.current = e.query;
|
|
283
|
+
let S = c(0), C = c(void 0), w = c(!1), [T, E] = l({}), [D, O] = l(""), [k, A] = l("");
|
|
284
284
|
o(() => {
|
|
285
285
|
r.isFetchingInitial || t((e) => ({
|
|
286
286
|
...e,
|
|
@@ -302,166 +302,168 @@ function ue({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
302
302
|
r.sortableFields,
|
|
303
303
|
t
|
|
304
304
|
]);
|
|
305
|
-
let
|
|
305
|
+
let j = e.searchSettings.maxNumberOfRecordsToReturn, M = e.searchSettings.enableCoverage, N = e.searchSettings.removeDuplicates, P = e.searchSettings.coverageDepth, F = e.searchSettings.minimumScore, I = e.searchSettings.coverageSetup, L = e.sortBy, R = e.sortAscending, z = i(async ({ enableFacets: i }) => {
|
|
306
306
|
if (!r.token) return;
|
|
307
|
-
let o = ++
|
|
307
|
+
let o = ++S.current;
|
|
308
308
|
if (t((e) => ({
|
|
309
309
|
...e,
|
|
310
310
|
isLoading: !0
|
|
311
|
-
})),
|
|
311
|
+
})), b.trim() === "") {
|
|
312
312
|
if (!d) return;
|
|
313
313
|
i = !0;
|
|
314
314
|
}
|
|
315
315
|
try {
|
|
316
|
-
let c = i ? Array.from(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([
|
|
316
|
+
let c = i ? Array.from(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([le(e.filters, e.rangeFilters, a, s, u, n, e.valueMatch, e.bucketFilters, e.fieldTypes), ...c.map((t) => le({
|
|
317
317
|
...e.filters,
|
|
318
318
|
[t]: []
|
|
319
319
|
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
320
320
|
...e.bucketFilters,
|
|
321
321
|
[t]: []
|
|
322
|
-
}, e.fieldTypes))]), m = d ||
|
|
323
|
-
text:
|
|
324
|
-
enableCoverage:
|
|
325
|
-
removeDuplicates:
|
|
326
|
-
coverageDepth:
|
|
327
|
-
coverageSetup:
|
|
328
|
-
},
|
|
329
|
-
...
|
|
330
|
-
maxNumberOfRecordsToReturn: m ?
|
|
322
|
+
}, e.fieldTypes))]), m = d || b.trim() !== "", y = {
|
|
323
|
+
text: b,
|
|
324
|
+
enableCoverage: M,
|
|
325
|
+
removeDuplicates: N,
|
|
326
|
+
coverageDepth: P,
|
|
327
|
+
coverageSetup: I
|
|
328
|
+
}, C = {
|
|
329
|
+
...y,
|
|
330
|
+
maxNumberOfRecordsToReturn: m ? j : 0,
|
|
331
331
|
enableFacets: i,
|
|
332
332
|
...l ? { filter: l } : {},
|
|
333
|
-
...
|
|
334
|
-
...
|
|
333
|
+
...L ? { sortBy: L } : {},
|
|
334
|
+
...R === void 0 ? {} : { sortAscending: R }
|
|
335
335
|
};
|
|
336
|
-
p && console.log("[performSearch] request body:", JSON.stringify(
|
|
337
|
-
let
|
|
338
|
-
g &&
|
|
339
|
-
let
|
|
336
|
+
p && console.log("[performSearch] request body:", JSON.stringify(C, null, 2));
|
|
337
|
+
let w = new URLSearchParams({ session: h });
|
|
338
|
+
g && w.set("source", g);
|
|
339
|
+
let z = _ ?? fe();
|
|
340
|
+
z && w.set("locale", z), v || w.set("count", "false"), x.current.trim() !== b.trim() && w.set("typed", x.current);
|
|
341
|
+
let B = (e) => n(`${a}/api/teams/${s}/datasets/${u}/search?${w}`, {
|
|
340
342
|
method: "POST",
|
|
341
343
|
headers: { "Content-Type": "application/json" },
|
|
342
344
|
body: JSON.stringify(e)
|
|
343
|
-
}), [
|
|
344
|
-
...
|
|
345
|
+
}), [V, ...H] = await Promise.all([B(C), ...f.map((e) => B({
|
|
346
|
+
...y,
|
|
345
347
|
maxNumberOfRecordsToReturn: 0,
|
|
346
348
|
enableFacets: !0,
|
|
347
349
|
...e ? { filter: e } : {}
|
|
348
350
|
}))]);
|
|
349
|
-
if (!
|
|
350
|
-
let
|
|
351
|
+
if (!V.ok) throw await q.fromResponse("Search", V);
|
|
352
|
+
let U = await V.json(), W = V.headers.get("Indx-Query-Id") ?? void 0, ee = U.truncationIndex ?? -1, G = {};
|
|
351
353
|
for (let e = 0; e < c.length; e++) {
|
|
352
354
|
let t = c[e];
|
|
353
|
-
if (!
|
|
354
|
-
let n = await
|
|
355
|
-
n.facets?.[t] !== void 0 && (
|
|
355
|
+
if (!H[e].ok) throw await q.fromResponse(`Facets for '${t}'`, H[e]);
|
|
356
|
+
let n = await H[e].json();
|
|
357
|
+
n.facets?.[t] !== void 0 && (G[t] = n.facets[t]);
|
|
356
358
|
}
|
|
357
|
-
let
|
|
358
|
-
if (m &&
|
|
359
|
+
let te = U.records || [], K = te.map((e) => e.documentKey), ne = te.map((e) => e.score), re = [];
|
|
360
|
+
if (m && K.length > 0) {
|
|
359
361
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
360
362
|
method: "POST",
|
|
361
363
|
headers: { "Content-Type": "application/json" },
|
|
362
|
-
body: JSON.stringify(
|
|
364
|
+
body: JSON.stringify(K)
|
|
363
365
|
});
|
|
364
|
-
if (!e.ok) throw await
|
|
365
|
-
|
|
366
|
+
if (!e.ok) throw await q.fromResponse("Document lookup", e);
|
|
367
|
+
re = (await e.json()).map((e, t) => ({
|
|
366
368
|
document: e,
|
|
367
|
-
documentKey:
|
|
368
|
-
score:
|
|
369
|
+
documentKey: K[t],
|
|
370
|
+
score: ne[t]
|
|
369
371
|
}));
|
|
370
372
|
}
|
|
371
|
-
let
|
|
372
|
-
if (i &&
|
|
373
|
-
for (let [e, t] of Object.entries(
|
|
373
|
+
let ie = {};
|
|
374
|
+
if (i && U.facets) {
|
|
375
|
+
for (let [e, t] of Object.entries(U.facets)) if (Array.isArray(t) && t.length > 0) {
|
|
374
376
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
375
|
-
n.length > 0 && (
|
|
377
|
+
n.length > 0 && (ie[e] = {
|
|
376
378
|
min: Math.min(...n),
|
|
377
379
|
max: Math.max(...n)
|
|
378
380
|
});
|
|
379
381
|
}
|
|
380
382
|
}
|
|
381
|
-
if (o !==
|
|
382
|
-
let
|
|
383
|
-
if (
|
|
383
|
+
if (o !== S.current) return;
|
|
384
|
+
let J = b !== D, ae = b !== k, oe = e.facetStats ?? {};
|
|
385
|
+
if (J ? (oe = {
|
|
384
386
|
...r.initialFacetStats,
|
|
385
|
-
...
|
|
386
|
-
},
|
|
387
|
-
...
|
|
388
|
-
...
|
|
389
|
-
},
|
|
387
|
+
...ie
|
|
388
|
+
}, E(oe), O(b)) : oe = {
|
|
389
|
+
...T,
|
|
390
|
+
...ie
|
|
391
|
+
}, ae && i) {
|
|
390
392
|
let n = { ...e.rangeBounds };
|
|
391
|
-
for (let [e, t] of Object.entries(
|
|
393
|
+
for (let [e, t] of Object.entries(ie)) n[e] = t;
|
|
392
394
|
t((e) => ({
|
|
393
395
|
...e,
|
|
394
396
|
rangeBounds: n
|
|
395
|
-
})),
|
|
397
|
+
})), A(b);
|
|
396
398
|
}
|
|
397
|
-
let
|
|
398
|
-
...
|
|
399
|
-
...
|
|
400
|
-
} :
|
|
401
|
-
if (i && (!
|
|
402
|
-
|
|
403
|
-
for (let [e, t] of Object.entries(r.initialFacetKeys))
|
|
399
|
+
let se = Object.keys(G).length > 0 ? {
|
|
400
|
+
...U.facets ?? {},
|
|
401
|
+
...G
|
|
402
|
+
} : U.facets;
|
|
403
|
+
if (i && (!se || Object.keys(se).length === 0)) {
|
|
404
|
+
se = {};
|
|
405
|
+
for (let [e, t] of Object.entries(r.initialFacetKeys)) se[e] = t.map((e) => ({
|
|
404
406
|
key: e,
|
|
405
407
|
value: null
|
|
406
408
|
}));
|
|
407
409
|
}
|
|
408
|
-
let
|
|
409
|
-
let t =
|
|
410
|
-
return t === "" || t.length === 1 ? !0 : e.score >=
|
|
410
|
+
let ce = re.filter((e) => {
|
|
411
|
+
let t = b.trim();
|
|
412
|
+
return t === "" || t.length === 1 ? !0 : e.score >= F;
|
|
411
413
|
}).map((e, t) => ({
|
|
412
414
|
...e,
|
|
413
415
|
position: t + 1
|
|
414
416
|
}));
|
|
415
417
|
t((e) => ({
|
|
416
418
|
...e,
|
|
417
|
-
results:
|
|
419
|
+
results: ce,
|
|
418
420
|
error: void 0,
|
|
419
421
|
errorInfo: void 0,
|
|
420
422
|
resultsSuppressed: !m,
|
|
421
423
|
...i ? {
|
|
422
|
-
facets:
|
|
423
|
-
facetStats:
|
|
424
|
+
facets: se,
|
|
425
|
+
facetStats: oe
|
|
424
426
|
} : {},
|
|
425
427
|
isLoading: !1,
|
|
426
|
-
truncationIndex:
|
|
427
|
-
queryId:
|
|
428
|
+
truncationIndex: ee,
|
|
429
|
+
queryId: W
|
|
428
430
|
}));
|
|
429
431
|
} catch (e) {
|
|
430
|
-
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)), o !==
|
|
432
|
+
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)), o !== S.current) return;
|
|
431
433
|
t((t) => ({
|
|
432
434
|
...t,
|
|
433
435
|
results: null,
|
|
434
436
|
isLoading: !1,
|
|
435
437
|
resultsSuppressed: !1,
|
|
436
438
|
error: e instanceof Error ? e.message : "Search failed",
|
|
437
|
-
errorInfo:
|
|
439
|
+
errorInfo: ae(e, {
|
|
438
440
|
team: s,
|
|
439
441
|
dataset: u
|
|
440
442
|
})
|
|
441
443
|
}));
|
|
442
444
|
}
|
|
443
445
|
}, [
|
|
444
|
-
|
|
446
|
+
b,
|
|
445
447
|
e.filters,
|
|
446
448
|
e.valueMatch,
|
|
447
449
|
e.rangeFilters,
|
|
448
450
|
e.bucketFilters,
|
|
449
451
|
e.facetStats,
|
|
450
|
-
I,
|
|
451
452
|
L,
|
|
452
|
-
|
|
453
|
+
R,
|
|
453
454
|
j,
|
|
454
455
|
M,
|
|
455
456
|
N,
|
|
456
|
-
F,
|
|
457
457
|
P,
|
|
458
|
+
I,
|
|
459
|
+
F,
|
|
458
460
|
n,
|
|
459
461
|
r.initialFacetStats,
|
|
460
462
|
r.initialFacetKeys,
|
|
461
463
|
r.token,
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
464
|
+
T,
|
|
465
|
+
D,
|
|
466
|
+
k,
|
|
465
467
|
e.rangeBounds,
|
|
466
468
|
a,
|
|
467
469
|
s,
|
|
@@ -471,26 +473,27 @@ function ue({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
471
473
|
t,
|
|
472
474
|
h,
|
|
473
475
|
g,
|
|
474
|
-
_
|
|
476
|
+
_,
|
|
477
|
+
v
|
|
475
478
|
]);
|
|
476
479
|
o(() => {
|
|
477
|
-
|
|
478
|
-
}, [
|
|
479
|
-
let
|
|
480
|
-
o(() => (
|
|
481
|
-
p && console.log("Debounced searchWithFacets fired"),
|
|
480
|
+
C.current = z;
|
|
481
|
+
}, [z]);
|
|
482
|
+
let B = c(null);
|
|
483
|
+
o(() => (B.current?.cancel(), B.current = ue(() => {
|
|
484
|
+
p && console.log("Debounced searchWithFacets fired"), C.current?.({ enableFacets: !0 });
|
|
482
485
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
483
|
-
|
|
486
|
+
B.current?.cancel();
|
|
484
487
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
485
|
-
!r.isFetchingInitial && r.token && !
|
|
488
|
+
!r.isFetchingInitial && r.token && !w.current && (d && C.current?.({ enableFacets: f }), w.current = !0);
|
|
486
489
|
}, [
|
|
487
490
|
r.isFetchingInitial,
|
|
488
491
|
r.token,
|
|
489
492
|
d,
|
|
490
493
|
f
|
|
491
494
|
]), o(() => {
|
|
492
|
-
if (!r.token || !
|
|
493
|
-
let n =
|
|
495
|
+
if (!r.token || !w.current) return;
|
|
496
|
+
let n = b.trim(), i = n === "" && d;
|
|
494
497
|
if (n === "" && !d) {
|
|
495
498
|
e.resultsSuppressed || t((e) => ({
|
|
496
499
|
...e,
|
|
@@ -498,63 +501,67 @@ function ue({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
498
501
|
}));
|
|
499
502
|
return;
|
|
500
503
|
}
|
|
501
|
-
return i ? (
|
|
502
|
-
|
|
504
|
+
return i ? (B.current?.cancel(), C.current?.({ enableFacets: f })) : f ? (p && console.log("Search fired"), C.current?.({ enableFacets: !1 }), B.current?.()) : C.current?.({ enableFacets: !1 }), () => {
|
|
505
|
+
B.current?.cancel();
|
|
503
506
|
};
|
|
504
507
|
}, [
|
|
505
|
-
|
|
508
|
+
b,
|
|
506
509
|
d,
|
|
507
510
|
f
|
|
508
511
|
]), o(() => {
|
|
509
|
-
if (!
|
|
510
|
-
let t =
|
|
511
|
-
!d && t === "" ||
|
|
512
|
+
if (!w.current || !r.token || e.filterRevision === 0) return;
|
|
513
|
+
let t = b.trim();
|
|
514
|
+
!d && t === "" || C.current?.({ enableFacets: f });
|
|
512
515
|
}, [e.filterRevision]), o(() => {
|
|
513
|
-
if (!
|
|
514
|
-
let e =
|
|
515
|
-
!d && e === "" ||
|
|
516
|
-
}, [
|
|
517
|
-
let
|
|
516
|
+
if (!w.current || !r.token) return;
|
|
517
|
+
let e = b.trim();
|
|
518
|
+
!d && e === "" || C.current?.({ enableFacets: f });
|
|
519
|
+
}, [L, R]);
|
|
520
|
+
let V = c(!0), H = c(b);
|
|
518
521
|
return o(() => {
|
|
519
|
-
if (
|
|
520
|
-
|
|
522
|
+
if (V.current) {
|
|
523
|
+
V.current = !1;
|
|
521
524
|
return;
|
|
522
525
|
}
|
|
523
|
-
if (
|
|
526
|
+
if (H.current !== b || !w.current || !r.token) return;
|
|
524
527
|
if (m.current) {
|
|
525
|
-
m.current = !1,
|
|
528
|
+
m.current = !1, C.current?.({ enableFacets: !1 });
|
|
526
529
|
return;
|
|
527
530
|
}
|
|
528
|
-
let e =
|
|
529
|
-
!d && e === "" ||
|
|
531
|
+
let e = b.trim();
|
|
532
|
+
!d && e === "" || C.current?.({ enableFacets: f });
|
|
530
533
|
}, [
|
|
531
|
-
A,
|
|
532
534
|
j,
|
|
533
535
|
M,
|
|
534
536
|
N,
|
|
535
|
-
|
|
536
|
-
|
|
537
|
+
P,
|
|
538
|
+
I,
|
|
539
|
+
F
|
|
537
540
|
]), o(() => {
|
|
538
|
-
|
|
539
|
-
}, [
|
|
540
|
-
|
|
541
|
+
H.current = b;
|
|
542
|
+
}, [b]), { retrySearch: i(() => {
|
|
543
|
+
C.current?.({ enableFacets: f });
|
|
541
544
|
}, [f]) };
|
|
542
545
|
}
|
|
546
|
+
function fe() {
|
|
547
|
+
if (typeof document < "u" && document.documentElement.lang) return document.documentElement.lang;
|
|
548
|
+
if (typeof navigator < "u" && navigator.language) return navigator.language;
|
|
549
|
+
}
|
|
543
550
|
//#endregion
|
|
544
551
|
//#region src/context/SearchContext.tsx
|
|
545
|
-
function
|
|
552
|
+
function pe() {
|
|
546
553
|
let e = globalThis.crypto;
|
|
547
554
|
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
548
555
|
}
|
|
549
|
-
var
|
|
550
|
-
let
|
|
551
|
-
let t =
|
|
552
|
-
return !t || e ===
|
|
556
|
+
var me = "Type to search", he = n(void 0), ge = ({ children: e, url: t, team: n, dataset: r, allowEmptySearch: a = !1, maxResults: s = 10, facetDebounceDelayMillis: u = 500, enableFacets: d = !0, coverageDepth: p, removeDuplicates: m = !0, enableCoverage: h = !0, initialCoverageSetup: g = {}, enableDebugLogs: _ = !1, preAuthenticatedToken: v, source: y, locale: b, count: x = !0, searchTextOf: S }) => {
|
|
557
|
+
let C = c(!1), w = c(pe()).current, [T, E] = l({ fn: null }), [D, O] = l(null), k = i((e) => {
|
|
558
|
+
let t = S ?? T.fn;
|
|
559
|
+
return !t || e === D ? e : t(e);
|
|
553
560
|
}, [
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
]),
|
|
561
|
+
S,
|
|
562
|
+
T,
|
|
563
|
+
D
|
|
564
|
+
]), A = i((e) => E({ fn: e }), []), j = c(s), [M, N] = l({
|
|
558
565
|
query: "",
|
|
559
566
|
results: null,
|
|
560
567
|
isLoading: !1,
|
|
@@ -579,61 +586,62 @@ var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n,
|
|
|
579
586
|
removeDuplicates: m,
|
|
580
587
|
minimumScore: 0,
|
|
581
588
|
showScore: !0,
|
|
582
|
-
placeholderText:
|
|
589
|
+
placeholderText: me,
|
|
583
590
|
coverageSetup: { ...g }
|
|
584
591
|
}
|
|
585
592
|
});
|
|
586
593
|
o(() => {
|
|
587
594
|
_ && console.log("SearchContext mounted on client");
|
|
588
595
|
}, [_]), o(() => {
|
|
589
|
-
|
|
596
|
+
N((e) => ({
|
|
590
597
|
...e,
|
|
591
598
|
facetDebounceDelayMillis: u
|
|
592
599
|
}));
|
|
593
600
|
}, [u]);
|
|
594
|
-
let [
|
|
601
|
+
let [P] = l(d), F = oe({
|
|
595
602
|
url: t,
|
|
596
603
|
team: n,
|
|
597
604
|
dataset: r,
|
|
598
605
|
preAuthenticatedToken: v,
|
|
599
606
|
enableDebugLogs: _
|
|
600
|
-
}),
|
|
601
|
-
if (!
|
|
607
|
+
}), I = i((e, t = {}) => {
|
|
608
|
+
if (!F.token) throw Error("No authentication token available");
|
|
602
609
|
return fetch(e, {
|
|
603
610
|
...t,
|
|
604
611
|
headers: {
|
|
605
612
|
...t.headers,
|
|
606
|
-
Authorization: `Bearer ${
|
|
613
|
+
Authorization: `Bearer ${F.token}`
|
|
607
614
|
}
|
|
608
615
|
});
|
|
609
|
-
}, [
|
|
610
|
-
state:
|
|
611
|
-
setState:
|
|
612
|
-
authenticatedFetch:
|
|
613
|
-
auth:
|
|
616
|
+
}, [F.token]), { retrySearch: L } = de({
|
|
617
|
+
state: M,
|
|
618
|
+
setState: N,
|
|
619
|
+
authenticatedFetch: I,
|
|
620
|
+
auth: F,
|
|
614
621
|
url: t,
|
|
615
622
|
team: n,
|
|
616
623
|
dataset: r,
|
|
617
624
|
allowEmptySearch: a,
|
|
618
|
-
facetsEnabled:
|
|
625
|
+
facetsEnabled: P,
|
|
619
626
|
enableDebugLogs: _,
|
|
620
|
-
shouldFetchMore:
|
|
621
|
-
sessionId:
|
|
627
|
+
shouldFetchMore: C,
|
|
628
|
+
sessionId: w,
|
|
622
629
|
source: y,
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
+
locale: b,
|
|
631
|
+
count: x,
|
|
632
|
+
searchTextOf: k
|
|
633
|
+
}), R = c(void 0);
|
|
634
|
+
R.current = M.queryId;
|
|
635
|
+
let z = i(async (e) => {
|
|
636
|
+
if (F.token) try {
|
|
637
|
+
let i = await I(`${t}/api/teams/${n}/datasets/${r}/events/select`, {
|
|
630
638
|
method: "POST",
|
|
631
639
|
headers: { "Content-Type": "application/json" },
|
|
632
640
|
body: JSON.stringify({
|
|
633
|
-
queryId:
|
|
641
|
+
queryId: R.current,
|
|
634
642
|
documentKey: e.documentKey,
|
|
635
643
|
position: e.position,
|
|
636
|
-
...
|
|
644
|
+
...x ? {} : { count: !1 }
|
|
637
645
|
})
|
|
638
646
|
});
|
|
639
647
|
_ && (i.ok ? console.log(`[select] document ${e.documentKey} at position ${e.position}`) : console.warn(`[select] not recorded: ${i.status}`));
|
|
@@ -641,15 +649,15 @@ var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n,
|
|
|
641
649
|
_ && console.warn("[select] failed:", e);
|
|
642
650
|
}
|
|
643
651
|
}, [
|
|
644
|
-
|
|
645
|
-
|
|
652
|
+
F.token,
|
|
653
|
+
I,
|
|
646
654
|
t,
|
|
647
655
|
n,
|
|
648
656
|
r,
|
|
649
657
|
_,
|
|
650
|
-
|
|
651
|
-
]),
|
|
652
|
-
|
|
658
|
+
x
|
|
659
|
+
]), B = i((e) => {
|
|
660
|
+
N((t) => {
|
|
653
661
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
|
|
654
662
|
return {
|
|
655
663
|
...t,
|
|
@@ -659,17 +667,17 @@ var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n,
|
|
|
659
667
|
bucketFilters: i ? {} : t.bucketFilters,
|
|
660
668
|
searchSettings: {
|
|
661
669
|
...t.searchSettings,
|
|
662
|
-
maxNumberOfRecordsToReturn:
|
|
670
|
+
maxNumberOfRecordsToReturn: j.current
|
|
663
671
|
}
|
|
664
672
|
};
|
|
665
673
|
});
|
|
666
|
-
}, []),
|
|
667
|
-
|
|
674
|
+
}, []), V = i((e) => {
|
|
675
|
+
N((t) => ({
|
|
668
676
|
...t,
|
|
669
677
|
facetDebounceDelayMillis: e
|
|
670
678
|
}));
|
|
671
|
-
}, []),
|
|
672
|
-
typeof e.maxNumberOfRecordsToReturn == "number" && (
|
|
679
|
+
}, []), H = i((e) => {
|
|
680
|
+
typeof e.maxNumberOfRecordsToReturn == "number" && (j.current = e.maxNumberOfRecordsToReturn), N((t) => {
|
|
673
681
|
let n = {
|
|
674
682
|
...t.searchSettings,
|
|
675
683
|
...e
|
|
@@ -682,16 +690,16 @@ var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n,
|
|
|
682
690
|
searchSettings: n
|
|
683
691
|
};
|
|
684
692
|
});
|
|
685
|
-
}, []),
|
|
686
|
-
|
|
693
|
+
}, []), U = i((e) => {
|
|
694
|
+
C.current = !0, N((t) => ({
|
|
687
695
|
...t,
|
|
688
696
|
searchSettings: {
|
|
689
697
|
...t.searchSettings,
|
|
690
698
|
maxNumberOfRecordsToReturn: e
|
|
691
699
|
}
|
|
692
700
|
}));
|
|
693
|
-
}, []),
|
|
694
|
-
|
|
701
|
+
}, []), W = i((e, t, n = !1) => {
|
|
702
|
+
N((r) => {
|
|
695
703
|
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
696
704
|
return o.length ? i[e] = o : delete i[e], {
|
|
697
705
|
...r,
|
|
@@ -699,16 +707,16 @@ var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n,
|
|
|
699
707
|
filterRevision: r.filterRevision + 1
|
|
700
708
|
};
|
|
701
709
|
});
|
|
702
|
-
}, []),
|
|
703
|
-
|
|
710
|
+
}, []), ee = i((e, t) => {
|
|
711
|
+
N((n) => n.valueMatch[e] === t ? n : {
|
|
704
712
|
...n,
|
|
705
713
|
valueMatch: {
|
|
706
714
|
...n.valueMatch,
|
|
707
715
|
[e]: t
|
|
708
716
|
}
|
|
709
717
|
});
|
|
710
|
-
}, []),
|
|
711
|
-
|
|
718
|
+
}, []), G = i((e, t, n) => {
|
|
719
|
+
N((r) => ({
|
|
712
720
|
...r,
|
|
713
721
|
rangeFilters: {
|
|
714
722
|
...r.rangeFilters,
|
|
@@ -719,16 +727,16 @@ var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n,
|
|
|
719
727
|
},
|
|
720
728
|
filterRevision: r.filterRevision + 1
|
|
721
729
|
}));
|
|
722
|
-
}, []),
|
|
723
|
-
|
|
730
|
+
}, []), te = i(() => {
|
|
731
|
+
N((e) => ({
|
|
724
732
|
...e,
|
|
725
733
|
filters: {},
|
|
726
734
|
rangeFilters: {},
|
|
727
735
|
bucketFilters: {},
|
|
728
736
|
filterRevision: e.filterRevision + 1
|
|
729
737
|
}));
|
|
730
|
-
}, []),
|
|
731
|
-
|
|
738
|
+
}, []), K = i((e, t, n = !0) => {
|
|
739
|
+
N((r) => {
|
|
732
740
|
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
733
741
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
734
742
|
...r,
|
|
@@ -736,8 +744,8 @@ var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n,
|
|
|
736
744
|
filterRevision: r.filterRevision + +!!n
|
|
737
745
|
};
|
|
738
746
|
});
|
|
739
|
-
}, []),
|
|
740
|
-
|
|
747
|
+
}, []), ne = i((e, t = !0) => {
|
|
748
|
+
N((n) => {
|
|
741
749
|
if (!(e in n.rangeFilters)) return n;
|
|
742
750
|
let r = { ...n.rangeFilters };
|
|
743
751
|
return delete r[e], {
|
|
@@ -746,18 +754,18 @@ var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n,
|
|
|
746
754
|
filterRevision: n.filterRevision + +!!t
|
|
747
755
|
};
|
|
748
756
|
});
|
|
749
|
-
}, []),
|
|
750
|
-
|
|
751
|
-
let i = r.bucketFilters[e] ?? [], a = i.some((e) =>
|
|
757
|
+
}, []), re = (e, t) => e.min === t.min && e.max === t.max, ie = i((e, t, n = !1) => {
|
|
758
|
+
N((r) => {
|
|
759
|
+
let i = r.bucketFilters[e] ?? [], a = i.some((e) => re(e, t)) ? i.filter((e) => !re(e, t)) : n ? [t] : [...i, t], o = { ...r.bucketFilters };
|
|
752
760
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
753
761
|
...r,
|
|
754
762
|
bucketFilters: o,
|
|
755
763
|
filterRevision: r.filterRevision + 1
|
|
756
764
|
};
|
|
757
765
|
});
|
|
758
|
-
}, []),
|
|
759
|
-
|
|
760
|
-
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !
|
|
766
|
+
}, []), q = i((e, t, n = !0) => {
|
|
767
|
+
N((r) => {
|
|
768
|
+
let i = { ...r.bucketFilters }, a = t ? (i[e] ?? []).filter((e) => !re(e, t)) : [];
|
|
761
769
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
762
770
|
...r,
|
|
763
771
|
bucketFilters: i,
|
|
@@ -765,93 +773,93 @@ var fe = "Type to search", pe = n(void 0), me = ({ children: e, url: t, team: n,
|
|
|
765
773
|
};
|
|
766
774
|
});
|
|
767
775
|
}, []), J = i((e, t) => {
|
|
768
|
-
|
|
776
|
+
N((n) => ({
|
|
769
777
|
...n,
|
|
770
778
|
sortBy: e || void 0,
|
|
771
779
|
sortAscending: e ? t : void 0
|
|
772
780
|
}));
|
|
773
781
|
}, []);
|
|
774
|
-
return /* @__PURE__ */ f(
|
|
782
|
+
return /* @__PURE__ */ f(he.Provider, {
|
|
775
783
|
value: {
|
|
776
|
-
state:
|
|
777
|
-
isFetchingInitial:
|
|
778
|
-
authError:
|
|
779
|
-
authErrorInfo:
|
|
780
|
-
retry:
|
|
784
|
+
state: M,
|
|
785
|
+
isFetchingInitial: F.isFetchingInitial || !M.fieldsSeeded,
|
|
786
|
+
authError: F.authError ?? void 0,
|
|
787
|
+
authErrorInfo: F.authErrorInfo ?? void 0,
|
|
788
|
+
retry: F.authError ? F.retry : L,
|
|
781
789
|
allowEmptySearch: a,
|
|
782
|
-
facetsEnabled:
|
|
783
|
-
datasetBounds:
|
|
790
|
+
facetsEnabled: P,
|
|
791
|
+
datasetBounds: F.initialFacetStats,
|
|
784
792
|
url: t,
|
|
785
793
|
team: n,
|
|
786
794
|
dataset: r,
|
|
787
|
-
authenticatedFetch:
|
|
788
|
-
setQuery:
|
|
789
|
-
toggleFilter:
|
|
790
|
-
setValueMatch:
|
|
791
|
-
setRangeFilter:
|
|
792
|
-
resetFilters:
|
|
793
|
-
resetSingleFilter:
|
|
794
|
-
resetRangeFilter:
|
|
795
|
-
toggleBucketFilter:
|
|
796
|
-
resetBucketFilter:
|
|
795
|
+
authenticatedFetch: I,
|
|
796
|
+
setQuery: B,
|
|
797
|
+
toggleFilter: W,
|
|
798
|
+
setValueMatch: ee,
|
|
799
|
+
setRangeFilter: G,
|
|
800
|
+
resetFilters: te,
|
|
801
|
+
resetSingleFilter: K,
|
|
802
|
+
resetRangeFilter: ne,
|
|
803
|
+
toggleBucketFilter: ie,
|
|
804
|
+
resetBucketFilter: q,
|
|
797
805
|
setSort: J,
|
|
798
|
-
setDebounceDelay:
|
|
799
|
-
setSearchSettings:
|
|
800
|
-
fetchMoreResults:
|
|
801
|
-
selectResult:
|
|
802
|
-
sessionId:
|
|
806
|
+
setDebounceDelay: V,
|
|
807
|
+
setSearchSettings: H,
|
|
808
|
+
fetchMoreResults: U,
|
|
809
|
+
selectResult: z,
|
|
810
|
+
sessionId: w,
|
|
803
811
|
source: y,
|
|
804
|
-
count:
|
|
805
|
-
searchText:
|
|
806
|
-
searchAsTyped: () =>
|
|
807
|
-
setSearchRewrite:
|
|
812
|
+
count: x,
|
|
813
|
+
searchText: k(M.query),
|
|
814
|
+
searchAsTyped: () => O(M.query),
|
|
815
|
+
setSearchRewrite: A
|
|
808
816
|
},
|
|
809
817
|
children: e
|
|
810
818
|
});
|
|
811
|
-
},
|
|
812
|
-
let e = a(
|
|
819
|
+
}, Y = () => {
|
|
820
|
+
let e = a(he);
|
|
813
821
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
814
822
|
return e;
|
|
815
|
-
},
|
|
823
|
+
}, _e = {
|
|
816
824
|
strong: .65,
|
|
817
825
|
strongHide: .45,
|
|
818
826
|
invite: .4,
|
|
819
827
|
inviteHide: .3
|
|
820
|
-
},
|
|
821
|
-
function
|
|
828
|
+
}, ve = new Set(/* @__PURE__ */ "hvordan.hva.hvorfor.hvor.hvilken.hvilke.hvilket.hvem.nΓ₯r.kan.skal.mΓ₯.bΓΈr.er.gΓ₯r.finnes.trenger.how.what.why.where.which.who.when.can.should.does.do.is.are.will.could.would".split(".")), ye = /^[\d\s\-_.:/]+$|^\w+\.\w+|^[A-Za-z]*[a-z][A-Z]\w*$|^[A-Za-z]+[-_]?\d[\w-]*$/;
|
|
829
|
+
function be(e) {
|
|
822
830
|
let t = e.trim();
|
|
823
|
-
return t.length > 0 && !t.includes(" ") &&
|
|
831
|
+
return t.length > 0 && !t.includes(" ") && ye.test(t);
|
|
824
832
|
}
|
|
825
|
-
function
|
|
833
|
+
function xe(e) {
|
|
826
834
|
let t = e.trim();
|
|
827
|
-
if (!t ||
|
|
835
|
+
if (!t || be(t)) return !1;
|
|
828
836
|
let n = t.split(/\s+/);
|
|
829
|
-
return t.endsWith("?") || n.length > 1 &&
|
|
837
|
+
return t.endsWith("?") || n.length > 1 && ve.has(n[0].toLowerCase()) || n.length >= 3 ? !0 : t.length >= 4;
|
|
830
838
|
}
|
|
831
|
-
function
|
|
839
|
+
function Se(e, t, n = _e) {
|
|
832
840
|
return t >= n.strong || e === "strong" && t >= n.strongHide ? "strong" : t >= n.invite || e !== "none" && t >= n.inviteHide ? "invite" : "none";
|
|
833
841
|
}
|
|
834
|
-
var
|
|
842
|
+
var Ce = {
|
|
835
843
|
shareOfTop: .5,
|
|
836
844
|
topFloor: .2
|
|
837
|
-
},
|
|
845
|
+
}, we = {
|
|
838
846
|
coverFuzzyWords: !1,
|
|
839
847
|
coverPrefixSuffix: !1,
|
|
840
848
|
coverJoinedWords: !1,
|
|
841
849
|
minWordSize: 3
|
|
842
|
-
},
|
|
843
|
-
function
|
|
850
|
+
}, Te = 65535;
|
|
851
|
+
function Ee(e, t, n, r = Ce) {
|
|
844
852
|
if (!n || e.length === 0) return e;
|
|
845
853
|
let i = e[0].score;
|
|
846
854
|
if (i < r.topFloor * 65535) return [];
|
|
847
855
|
let a = t == null ? e : t < 0 ? [] : e.slice(0, t + 1), o = r.shareOfTop * i, s = a.findIndex((e) => e.score < o);
|
|
848
856
|
return s < 0 ? a : a.slice(0, s);
|
|
849
857
|
}
|
|
850
|
-
function
|
|
858
|
+
function De(e) {
|
|
851
859
|
let t = e.trim();
|
|
852
860
|
return t.includes(" ") || t.endsWith("?");
|
|
853
861
|
}
|
|
854
|
-
async function*
|
|
862
|
+
async function* Oe(e) {
|
|
855
863
|
let t = e.getReader(), n = new TextDecoder(), r = "";
|
|
856
864
|
try {
|
|
857
865
|
for (;;) {
|
|
@@ -874,7 +882,7 @@ async function* Ee(e) {
|
|
|
874
882
|
t.releaseLock();
|
|
875
883
|
}
|
|
876
884
|
}
|
|
877
|
-
function
|
|
885
|
+
function ke(e) {
|
|
878
886
|
let t = new URLSearchParams();
|
|
879
887
|
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");
|
|
880
888
|
let n = t.toString();
|
|
@@ -882,28 +890,28 @@ function De(e) {
|
|
|
882
890
|
}
|
|
883
891
|
//#endregion
|
|
884
892
|
//#region src/utils/askPhrases.ts
|
|
885
|
-
var
|
|
886
|
-
function
|
|
893
|
+
var Ae = (e) => e.toLowerCase().replace(/β/g, "'").split(/\s+/).filter(Boolean), je = /[?!.,]+$/, Me = 2;
|
|
894
|
+
function Ne(e, t) {
|
|
887
895
|
let n = 0;
|
|
888
896
|
for (let r of t) {
|
|
889
|
-
let t =
|
|
890
|
-
t.length > n && t.length <= e.length && t.every((n, r) => e[e.length - t.length + r].replace(
|
|
897
|
+
let t = Ae(r);
|
|
898
|
+
t.length > n && t.length <= e.length && t.every((n, r) => e[e.length - t.length + r].replace(je, "") === n) && (n = t.length);
|
|
891
899
|
}
|
|
892
900
|
return n;
|
|
893
901
|
}
|
|
894
|
-
function
|
|
902
|
+
function Pe(e, t, n) {
|
|
895
903
|
let r = 0;
|
|
896
904
|
for (let i of n) {
|
|
897
|
-
let n =
|
|
898
|
-
n.length > r && t + n.length <= e.length && n.every((n, r) => e[t + r].replace(
|
|
905
|
+
let n = Ae(i);
|
|
906
|
+
n.length > r && t + n.length <= e.length && n.every((n, r) => e[t + r].replace(je, "") === n) && (r = n.length);
|
|
899
907
|
}
|
|
900
908
|
return r;
|
|
901
909
|
}
|
|
902
|
-
function
|
|
903
|
-
let n = e.trim().split(/\s+/).filter(Boolean), r =
|
|
904
|
-
let t =
|
|
910
|
+
function Fe(e, t) {
|
|
911
|
+
let n = e.trim().split(/\s+/).filter(Boolean), r = Ae(e), i = 0, a = [], o = (e) => {
|
|
912
|
+
let t = Pe(r, i, e);
|
|
905
913
|
return t && (a.push(n.slice(i, i + t).join(" ")), i += t), t > 0;
|
|
906
|
-
}, s =
|
|
914
|
+
}, s = Pe(r, 0, t.leadIns), c = o(t.leadIns), l = o(t.frames), u = o(t.links);
|
|
907
915
|
if (!(c && (s > 1 || l) || l && u)) return {
|
|
908
916
|
text: e,
|
|
909
917
|
taken: []
|
|
@@ -914,8 +922,8 @@ function Ne(e, t) {
|
|
|
914
922
|
text: e,
|
|
915
923
|
taken: []
|
|
916
924
|
};
|
|
917
|
-
let f = d.split(/\s+/).filter(Boolean), p =
|
|
918
|
-
if (p > 0 && f.length - p >=
|
|
925
|
+
let f = d.split(/\s+/).filter(Boolean), p = Ne(Ae(d), t.frames);
|
|
926
|
+
if (p > 0 && f.length - p >= Me) {
|
|
919
927
|
let e = f.slice(0, f.length - p).join(" ");
|
|
920
928
|
if (/\p{L}{3,}/u.test(e)) return {
|
|
921
929
|
text: e,
|
|
@@ -929,7 +937,7 @@ function Ne(e, t) {
|
|
|
929
937
|
}
|
|
930
938
|
//#endregion
|
|
931
939
|
//#region src/hooks/useSearchOrAsk.ts
|
|
932
|
-
var
|
|
940
|
+
var Ie = {
|
|
933
941
|
available: !1,
|
|
934
942
|
offer: "none",
|
|
935
943
|
p: null,
|
|
@@ -938,15 +946,15 @@ var Pe = {
|
|
|
938
946
|
criteria: null,
|
|
939
947
|
describes: !1,
|
|
940
948
|
cutResults: !1,
|
|
941
|
-
cutRule:
|
|
949
|
+
cutRule: Ce,
|
|
942
950
|
strictCoverage: !1,
|
|
943
951
|
filtersWhileTyping: "off",
|
|
944
952
|
stands: !1
|
|
945
953
|
};
|
|
946
|
-
function
|
|
947
|
-
let { enabled: t = !0, pauseMs: n = 300 } = e, r =
|
|
954
|
+
function Le(e = {}) {
|
|
955
|
+
let { enabled: t = !0, pauseMs: n = 300 } = e, r = Y(), { url: i, team: a, dataset: s, authenticatedFetch: u, isFetchingInitial: d, authError: f, state: p } = r, m = c(r);
|
|
948
956
|
m.current = r;
|
|
949
|
-
let h = (e.text ?? p.query).trim(), [g, _] = l(!1), [v, y] = l(
|
|
957
|
+
let h = (e.text ?? p.query).trim(), [g, _] = l(!1), [v, y] = l(Ie), b = c(_e), x = c(!0), S = c(Ce), C = c(!0), w = c("off"), T = c(null), E = c(!0), D = c(!0), O = c(null), k = c("none"), A = c(""), j = c(0), M = c(0);
|
|
950
958
|
k.current = v.offer;
|
|
951
959
|
let N = `${i}/api/teams/${a}/datasets/${s}/search-or-ask`, P = t && !d && !f;
|
|
952
960
|
o(() => {
|
|
@@ -959,11 +967,11 @@ function Fe(e = {}) {
|
|
|
959
967
|
let n = await t.json();
|
|
960
968
|
if (e || !n.available || !n.settings?.enabled) return;
|
|
961
969
|
T.current = n.effective?.askPhrases ?? null, E.current = n.settings.refocusWhileTyping ?? !0, D.current = n.settings.inviteOnAskPhrase ?? !0, w.current = n.settings.filtersWhileTyping ?? "off", b.current = {
|
|
962
|
-
...
|
|
970
|
+
..._e,
|
|
963
971
|
...n.settings.thresholds
|
|
964
972
|
}, x.current = n.settings.cutWhileAsking ?? !0, C.current = n.settings.strictCoverageWhileAsking ?? !0, S.current = {
|
|
965
|
-
shareOfTop: n.settings.cutShareOfTop ??
|
|
966
|
-
topFloor: n.settings.cutTopFloor ??
|
|
973
|
+
shareOfTop: n.settings.cutShareOfTop ?? Ce.shareOfTop,
|
|
974
|
+
topFloor: n.settings.cutTopFloor ?? Ce.topFloor
|
|
967
975
|
}, _(!0);
|
|
968
976
|
} catch {}
|
|
969
977
|
})(), () => {
|
|
@@ -975,21 +983,21 @@ function Fe(e = {}) {
|
|
|
975
983
|
u
|
|
976
984
|
]), o(() => {
|
|
977
985
|
let { setSearchRewrite: e } = m.current, t = T.current;
|
|
978
|
-
if (!(!g || !t || !E.current || !e)) return e((e) =>
|
|
986
|
+
if (!(!g || !t || !E.current || !e)) return e((e) => Fe(e, t).text), () => e(null);
|
|
979
987
|
}, [g]), o(() => {
|
|
980
988
|
if (!g) {
|
|
981
|
-
y(
|
|
989
|
+
y(Ie);
|
|
982
990
|
return;
|
|
983
991
|
}
|
|
984
992
|
if (!h) {
|
|
985
993
|
A.current = "", y({
|
|
986
|
-
...
|
|
994
|
+
...Ie,
|
|
987
995
|
available: g
|
|
988
996
|
});
|
|
989
997
|
return;
|
|
990
998
|
}
|
|
991
|
-
if (!
|
|
992
|
-
|
|
999
|
+
if (!xe(h)) {
|
|
1000
|
+
be(h) && y((e) => ({
|
|
993
1001
|
...e,
|
|
994
1002
|
available: g,
|
|
995
1003
|
offer: "none",
|
|
@@ -997,7 +1005,7 @@ function Fe(e = {}) {
|
|
|
997
1005
|
}));
|
|
998
1006
|
return;
|
|
999
1007
|
}
|
|
1000
|
-
D.current && T.current &&
|
|
1008
|
+
D.current && T.current && Fe(h, T.current).taken.length > 0 && y((e) => e.offer === "none" ? {
|
|
1001
1009
|
...e,
|
|
1002
1010
|
available: g,
|
|
1003
1011
|
offer: "invite",
|
|
@@ -1015,7 +1023,7 @@ function Fe(e = {}) {
|
|
|
1015
1023
|
let e = ++j.current;
|
|
1016
1024
|
A.current = h;
|
|
1017
1025
|
try {
|
|
1018
|
-
let t = await u(`${N}/intent${
|
|
1026
|
+
let t = await u(`${N}/intent${ke(m.current)}`, {
|
|
1019
1027
|
method: "POST",
|
|
1020
1028
|
headers: { "Content-Type": "application/json" },
|
|
1021
1029
|
body: JSON.stringify({ text: h })
|
|
@@ -1036,7 +1044,7 @@ function Fe(e = {}) {
|
|
|
1036
1044
|
shareOfTop: o,
|
|
1037
1045
|
topFloor: s
|
|
1038
1046
|
}), y((e) => {
|
|
1039
|
-
let t =
|
|
1047
|
+
let t = Se(e.offer, n, b.current), a = i ?? null, o = a != null && a >= b.current.strong, s = t === "strong" && !De(h) ? "invite" : t, c = o ? "strong" : s, l = c === "strong" && !(o && a > n);
|
|
1040
1048
|
return {
|
|
1041
1049
|
available: !0,
|
|
1042
1050
|
offer: c,
|
|
@@ -1068,55 +1076,57 @@ function Fe(e = {}) {
|
|
|
1068
1076
|
if (F) {
|
|
1069
1077
|
if (O.current) return;
|
|
1070
1078
|
let n = t.searchSettings.coverageSetup ?? {};
|
|
1071
|
-
O.current = Object.fromEntries(Object.keys(
|
|
1079
|
+
O.current = Object.fromEntries(Object.keys(we).map((e) => [e, n[e]])), e({ coverageSetup: { ...we } });
|
|
1072
1080
|
} else O.current &&= (e({ coverageSetup: { ...O.current } }), null);
|
|
1073
1081
|
}, [F]), g ? {
|
|
1074
1082
|
...v,
|
|
1075
1083
|
stands: !!v.text && h.startsWith(v.text)
|
|
1076
|
-
} :
|
|
1084
|
+
} : Ie;
|
|
1077
1085
|
}
|
|
1078
|
-
var
|
|
1079
|
-
withOffer: "
|
|
1080
|
-
offerRow: "
|
|
1081
|
-
offerHint: "
|
|
1082
|
-
kbd: "
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1086
|
+
var Re = {
|
|
1087
|
+
withOffer: "_withOffer_1074j_2",
|
|
1088
|
+
offerRow: "_offerRow_1074j_10",
|
|
1089
|
+
offerHint: "_offerHint_1074j_18",
|
|
1090
|
+
kbd: "_kbd_1074j_27",
|
|
1091
|
+
askStrong: "_askStrong_1074j_42"
|
|
1092
|
+
}, ze = ({ className: e = "", autoFocus: t = !1, inputSize: n = "default", showClear: r = !0, showFocus: i = !1, showStatus: a = !0, onAsk: o, searchOrAsk: s, askOffer: c = "chip", onKeyDown: l, ...u }) => {
|
|
1093
|
+
let { state: { query: m, filters: h, rangeFilters: g, bucketFilters: _, results: v, truncationIndex: b, searchSettings: S }, setQuery: C, resetFilters: w } = Y(), T = Object.values(h).reduce((e, t) => e + t.length, 0) + Object.keys(g).length + Object.values(_ ?? {}).reduce((e, t) => e + t.length, 0), E = m.length > 0, O = E && v !== null && v.length === 0, A = E && S.enableCoverage && v !== null && v.length > 0 && b === -1, j = Le({ enabled: !!o && !s }), M = s ?? j, N = !!o && E && M.offer !== "none" && M.stands, P = M.available && S.placeholderText === "Type to search" ? "Search or ask" : S.placeholderText, I = (e) => {
|
|
1094
|
+
l?.(e), !(e.defaultPrevented || e.key !== "Enter" || !o || M.offer !== "strong" || !M.stands || !m.trim()) && (e.preventDefault(), o(m.trim()));
|
|
1095
|
+
}, R = () => {
|
|
1087
1096
|
C(""), T > 0 && w();
|
|
1088
|
-
},
|
|
1097
|
+
}, z = () => o(m.trim()), B = /* @__PURE__ */ p(k, {
|
|
1089
1098
|
type: "text",
|
|
1090
1099
|
value: m,
|
|
1091
1100
|
onChange: (e) => C(e.target.value),
|
|
1092
|
-
placeholder:
|
|
1101
|
+
placeholder: P,
|
|
1093
1102
|
autoFocus: t,
|
|
1094
1103
|
className: e,
|
|
1095
1104
|
showSearchIcon: !0,
|
|
1096
1105
|
inputSize: n,
|
|
1097
1106
|
showFocusBorder: i,
|
|
1098
1107
|
clearable: !1,
|
|
1099
|
-
onKeyDown:
|
|
1108
|
+
onKeyDown: I,
|
|
1100
1109
|
...u,
|
|
1101
1110
|
children: [
|
|
1102
|
-
|
|
1103
|
-
variant:
|
|
1111
|
+
N && c === "chip" && /* @__PURE__ */ f(y, {
|
|
1112
|
+
variant: M.offer === "strong" ? "primary" : "ghost",
|
|
1113
|
+
className: M.offer === "strong" ? Re.askStrong : void 0,
|
|
1104
1114
|
size: "micro",
|
|
1105
|
-
iconLeft: /* @__PURE__ */ f(
|
|
1106
|
-
iconRight:
|
|
1107
|
-
onClick:
|
|
1108
|
-
title:
|
|
1109
|
-
children:
|
|
1115
|
+
iconLeft: /* @__PURE__ */ f(L, {}),
|
|
1116
|
+
iconRight: M.offer === "strong" ? /* @__PURE__ */ f(D, { children: "Enter β΅" }) : void 0,
|
|
1117
|
+
onClick: z,
|
|
1118
|
+
title: M.offer === "strong" ? "Enter asks" : void 0,
|
|
1119
|
+
children: M.offer === "strong" ? "Ask" : "Ask about this"
|
|
1110
1120
|
}),
|
|
1111
|
-
a &&
|
|
1112
|
-
a &&
|
|
1121
|
+
a && O && /* @__PURE__ */ f(x, { children: "No results" }),
|
|
1122
|
+
a && A && /* @__PURE__ */ f(F, {
|
|
1113
1123
|
content: "No direct match. Showing the nearest results.",
|
|
1114
1124
|
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(x, {
|
|
1115
1125
|
icon: /* @__PURE__ */ f(H, {}),
|
|
1116
1126
|
children: "Nearest"
|
|
1117
1127
|
}) })
|
|
1118
1128
|
}),
|
|
1119
|
-
a && T > 0 && /* @__PURE__ */ f(
|
|
1129
|
+
a && T > 0 && /* @__PURE__ */ f(F, {
|
|
1120
1130
|
content: `${T} filter${T === 1 ? "" : "s"} active`,
|
|
1121
1131
|
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(x, {
|
|
1122
1132
|
icon: /* @__PURE__ */ f(V, {}),
|
|
@@ -1128,43 +1138,44 @@ var Ie = {
|
|
|
1128
1138
|
r && (E || T > 0) && /* @__PURE__ */ f(y, {
|
|
1129
1139
|
variant: "ghost",
|
|
1130
1140
|
size: "micro",
|
|
1131
|
-
onClick:
|
|
1141
|
+
onClick: R,
|
|
1132
1142
|
"aria-label": T > 0 ? "Clear search and filters" : "Clear search",
|
|
1133
1143
|
children: "Clear"
|
|
1134
1144
|
})
|
|
1135
1145
|
]
|
|
1136
1146
|
});
|
|
1137
|
-
if (c !== "below" || !o || !
|
|
1138
|
-
let U =
|
|
1147
|
+
if (c !== "below" || !o || !M.available) return B;
|
|
1148
|
+
let U = M.offer === "strong";
|
|
1139
1149
|
return /* @__PURE__ */ p("div", {
|
|
1140
|
-
className:
|
|
1141
|
-
children: [
|
|
1142
|
-
className:
|
|
1150
|
+
className: Re.withOffer,
|
|
1151
|
+
children: [B, /* @__PURE__ */ f("div", {
|
|
1152
|
+
className: Re.offerRow,
|
|
1143
1153
|
"aria-live": "polite",
|
|
1144
|
-
children:
|
|
1154
|
+
children: N && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(y, {
|
|
1145
1155
|
variant: U ? "primary" : "ghost",
|
|
1146
|
-
|
|
1147
|
-
|
|
1156
|
+
className: U ? Re.askStrong : void 0,
|
|
1157
|
+
iconLeft: /* @__PURE__ */ f(L, {}),
|
|
1158
|
+
onClick: z,
|
|
1148
1159
|
children: U ? "Ask the assistant" : "Ask about this"
|
|
1149
1160
|
}), U && /* @__PURE__ */ p("span", {
|
|
1150
|
-
className:
|
|
1161
|
+
className: Re.offerHint,
|
|
1151
1162
|
children: [/* @__PURE__ */ f("kbd", {
|
|
1152
|
-
className:
|
|
1163
|
+
className: Re.kbd,
|
|
1153
1164
|
children: "β΅"
|
|
1154
1165
|
}), " to ask"]
|
|
1155
1166
|
})] })
|
|
1156
1167
|
})]
|
|
1157
1168
|
});
|
|
1158
|
-
},
|
|
1169
|
+
}, Be = {
|
|
1159
1170
|
message: "_message_1mgfk_1",
|
|
1160
1171
|
icon: "_icon_1mgfk_10",
|
|
1161
1172
|
title: "_title_1mgfk_15",
|
|
1162
1173
|
detail: "_detail_1mgfk_20",
|
|
1163
1174
|
technical: "_technical_1mgfk_25",
|
|
1164
1175
|
button: "_button_1mgfk_33"
|
|
1165
|
-
},
|
|
1176
|
+
}, Ve = {
|
|
1166
1177
|
unreachable: {
|
|
1167
|
-
icon:
|
|
1178
|
+
icon: B,
|
|
1168
1179
|
title: "Search is unavailable",
|
|
1169
1180
|
detail: "The search server canβt be reached right now."
|
|
1170
1181
|
},
|
|
@@ -1189,32 +1200,32 @@ var Ie = {
|
|
|
1189
1200
|
detail: "Results will appear in a moment."
|
|
1190
1201
|
},
|
|
1191
1202
|
unavailable: {
|
|
1192
|
-
icon:
|
|
1203
|
+
icon: re,
|
|
1193
1204
|
title: "Search is unavailable",
|
|
1194
1205
|
detail: "The collection canβt be searched right now."
|
|
1195
1206
|
},
|
|
1196
1207
|
rateLimited: {
|
|
1197
|
-
icon:
|
|
1208
|
+
icon: ne,
|
|
1198
1209
|
title: "Too many searches",
|
|
1199
1210
|
detail: "Wait a moment, then try again."
|
|
1200
1211
|
},
|
|
1201
1212
|
server: {
|
|
1202
|
-
icon:
|
|
1213
|
+
icon: re,
|
|
1203
1214
|
title: "Something went wrong",
|
|
1204
1215
|
detail: "The search server ran into a problem."
|
|
1205
1216
|
},
|
|
1206
1217
|
setup: {
|
|
1207
|
-
icon:
|
|
1218
|
+
icon: re,
|
|
1208
1219
|
title: "Search isnβt set up",
|
|
1209
1220
|
detail: "This page is missing part of its search setup."
|
|
1210
1221
|
},
|
|
1211
1222
|
unknown: {
|
|
1212
|
-
icon:
|
|
1223
|
+
icon: re,
|
|
1213
1224
|
title: "Something went wrong",
|
|
1214
1225
|
detail: "The search couldnβt be completed."
|
|
1215
1226
|
}
|
|
1216
|
-
},
|
|
1217
|
-
let { icon: r, title: i, detail: a } =
|
|
1227
|
+
}, He = ({ error: e, onRetry: t, hideTechnical: n = !1 }) => {
|
|
1228
|
+
let { icon: r, title: i, detail: a } = Ve[e.kind];
|
|
1218
1229
|
o(() => {
|
|
1219
1230
|
if (e.kind !== "notReady" || !t) return;
|
|
1220
1231
|
let n = setTimeout(t, (e.retryAfterSeconds ?? 2) * 1e3);
|
|
@@ -1222,65 +1233,65 @@ var Ie = {
|
|
|
1222
1233
|
}, [e, t]);
|
|
1223
1234
|
let s = e.retryable && e.kind !== "notReady" && t;
|
|
1224
1235
|
return /* @__PURE__ */ p("div", {
|
|
1225
|
-
className:
|
|
1236
|
+
className: Be.message,
|
|
1226
1237
|
role: "alert",
|
|
1227
1238
|
children: [
|
|
1228
1239
|
/* @__PURE__ */ f("span", {
|
|
1229
|
-
className:
|
|
1240
|
+
className: Be.icon,
|
|
1230
1241
|
children: /* @__PURE__ */ f(r, {
|
|
1231
1242
|
size: 70,
|
|
1232
1243
|
color: "var(--lv4)"
|
|
1233
1244
|
})
|
|
1234
1245
|
}),
|
|
1235
1246
|
/* @__PURE__ */ f("div", {
|
|
1236
|
-
className:
|
|
1247
|
+
className: Be.title,
|
|
1237
1248
|
children: i
|
|
1238
1249
|
}),
|
|
1239
1250
|
/* @__PURE__ */ f("div", {
|
|
1240
|
-
className:
|
|
1251
|
+
className: Be.detail,
|
|
1241
1252
|
children: a
|
|
1242
1253
|
}),
|
|
1243
1254
|
!n && /* @__PURE__ */ f("code", {
|
|
1244
|
-
className:
|
|
1255
|
+
className: Be.technical,
|
|
1245
1256
|
children: e.technical
|
|
1246
1257
|
}),
|
|
1247
1258
|
s && /* @__PURE__ */ f(y, {
|
|
1248
1259
|
variant: "secondary",
|
|
1249
1260
|
size: "micro",
|
|
1250
|
-
className:
|
|
1261
|
+
className: Be.button,
|
|
1251
1262
|
onClick: t,
|
|
1252
1263
|
children: "Try again"
|
|
1253
1264
|
})
|
|
1254
1265
|
]
|
|
1255
1266
|
});
|
|
1256
|
-
},
|
|
1267
|
+
}, Ue = {
|
|
1257
1268
|
placeholder: "_placeholder_1qr5o_1",
|
|
1258
1269
|
invalid: "_invalid_1qr5o_11",
|
|
1259
1270
|
searchedFor: "_searchedFor_1qr5o_17"
|
|
1260
|
-
},
|
|
1271
|
+
}, We = {
|
|
1261
1272
|
row: "_row_11svi_1",
|
|
1262
1273
|
content: "_content_11svi_22",
|
|
1263
1274
|
indexNumber: "_indexNumber_11svi_36",
|
|
1264
1275
|
scoreNumber: "_scoreNumber_11svi_44",
|
|
1265
1276
|
skeletonBars: "_skeletonBars_11svi_53"
|
|
1266
|
-
},
|
|
1267
|
-
className:
|
|
1277
|
+
}, Ge = ({ skeleton: e = !1, index: t, score: n, showScore: r = !1, children: i, skeletonDelay: a = 0, skeletonWidths: o = [62, 38] }) => /* @__PURE__ */ p("div", {
|
|
1278
|
+
className: We.row,
|
|
1268
1279
|
children: [
|
|
1269
1280
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
1270
|
-
className:
|
|
1281
|
+
className: We.indexNumber,
|
|
1271
1282
|
children: t
|
|
1272
1283
|
}),
|
|
1273
1284
|
/* @__PURE__ */ f("div", {
|
|
1274
|
-
className:
|
|
1285
|
+
className: We.content,
|
|
1275
1286
|
children: e ? /* @__PURE__ */ p("div", {
|
|
1276
|
-
className:
|
|
1277
|
-
children: [/* @__PURE__ */ f(
|
|
1287
|
+
className: We.skeletonBars,
|
|
1288
|
+
children: [/* @__PURE__ */ f(j, {
|
|
1278
1289
|
level: 3,
|
|
1279
1290
|
height: 12,
|
|
1280
1291
|
width: `${o[0]}%`,
|
|
1281
1292
|
delay: a,
|
|
1282
1293
|
appear: !1
|
|
1283
|
-
}), /* @__PURE__ */ f(
|
|
1294
|
+
}), /* @__PURE__ */ f(j, {
|
|
1284
1295
|
level: 3,
|
|
1285
1296
|
height: 8,
|
|
1286
1297
|
width: `${o[1]}%`,
|
|
@@ -1290,14 +1301,14 @@ var Ie = {
|
|
|
1290
1301
|
}) : i
|
|
1291
1302
|
}),
|
|
1292
1303
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
1293
|
-
className:
|
|
1304
|
+
className: We.scoreNumber,
|
|
1294
1305
|
children: n
|
|
1295
1306
|
})
|
|
1296
1307
|
]
|
|
1297
|
-
}),
|
|
1308
|
+
}), Ke = {
|
|
1298
1309
|
wrapper: "_wrapper_f970z_6",
|
|
1299
1310
|
skeletonAppear: "_skeletonAppear_f970z_1"
|
|
1300
|
-
},
|
|
1311
|
+
}, qe = [
|
|
1301
1312
|
[62, 38],
|
|
1302
1313
|
[75, 45],
|
|
1303
1314
|
[58, 33],
|
|
@@ -1306,28 +1317,28 @@ var Ie = {
|
|
|
1306
1317
|
[55, 35],
|
|
1307
1318
|
[72, 40],
|
|
1308
1319
|
[60, 30]
|
|
1309
|
-
],
|
|
1310
|
-
className:
|
|
1311
|
-
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(
|
|
1320
|
+
], Je = ({ rows: e = 6 }) => /* @__PURE__ */ f("div", {
|
|
1321
|
+
className: Ke.wrapper,
|
|
1322
|
+
children: Array.from({ length: e }).map((e, t) => /* @__PURE__ */ f(Ge, {
|
|
1312
1323
|
skeleton: !0,
|
|
1313
1324
|
skeletonDelay: t * .1,
|
|
1314
|
-
skeletonWidths:
|
|
1325
|
+
skeletonWidths: qe[t % qe.length]
|
|
1315
1326
|
}, t))
|
|
1316
|
-
}),
|
|
1317
|
-
function
|
|
1327
|
+
}), Ye = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
1328
|
+
function Xe(e) {
|
|
1318
1329
|
let t = e.trim();
|
|
1319
1330
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
1320
1331
|
try {
|
|
1321
1332
|
let e = JSON.parse(t);
|
|
1322
1333
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
1323
1334
|
} catch {}
|
|
1324
|
-
if (!
|
|
1335
|
+
if (!Ye.test(t)) return;
|
|
1325
1336
|
let n = [], r = /'([^']*)'/g, i;
|
|
1326
1337
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
1327
1338
|
return n;
|
|
1328
1339
|
}
|
|
1329
|
-
var
|
|
1330
|
-
let { state: { results: s, resultsSuppressed: u, searchSettings: m, truncationIndex: h, query: g, error: _, errorInfo: v }, isFetchingInitial: b, authError: x, authErrorInfo: S, retry: C, allowEmptySearch: w, fetchMoreResults: T, selectResult: E, searchText: D, searchAsTyped: O } =
|
|
1340
|
+
var Ze = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk: r, showScore: i, children: a }) => {
|
|
1341
|
+
let { state: { results: s, resultsSuppressed: u, searchSettings: m, truncationIndex: h, query: g, error: _, errorInfo: v }, isFetchingInitial: b, authError: x, authErrorInfo: S, retry: C, allowEmptySearch: w, fetchMoreResults: T, selectResult: E, searchText: D, searchAsTyped: O } = Y(), k = t ?? 30, [A, j] = l(k), M = c(0), N = c("");
|
|
1331
1342
|
o(() => {
|
|
1332
1343
|
let e = g !== N.current;
|
|
1333
1344
|
(!s || s.length < M.current || e) && j(k), M.current = s?.length ?? 0, N.current = g;
|
|
@@ -1336,19 +1347,19 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1336
1347
|
k,
|
|
1337
1348
|
g
|
|
1338
1349
|
]);
|
|
1339
|
-
let P = s ?
|
|
1350
|
+
let P = s ? Ee(s, h, !!r?.cutResults, r?.cutRule) : [], F = D != null && D.trim() !== g.trim() ? D : null, I = s && P.length > A, L = () => {
|
|
1340
1351
|
let e = A + k;
|
|
1341
1352
|
j(e), s && e >= s.length && (!h || h === -1 || h > s.length) && T(s.length + k);
|
|
1342
1353
|
};
|
|
1343
|
-
if (b) return w ? /* @__PURE__ */ f(
|
|
1344
|
-
className:
|
|
1354
|
+
if (b) return w ? /* @__PURE__ */ f(Je, { rows: k }) : /* @__PURE__ */ f("div", {
|
|
1355
|
+
className: Ue.placeholder,
|
|
1345
1356
|
children: /* @__PURE__ */ f(W, {
|
|
1346
1357
|
size: 200,
|
|
1347
1358
|
color: "var(--lv5)"
|
|
1348
1359
|
})
|
|
1349
1360
|
});
|
|
1350
1361
|
let R = x ?? _;
|
|
1351
|
-
return R ? /* @__PURE__ */ f(
|
|
1362
|
+
return R ? /* @__PURE__ */ f(He, {
|
|
1352
1363
|
error: (x ? S : v) ?? {
|
|
1353
1364
|
kind: "unknown",
|
|
1354
1365
|
message: R,
|
|
@@ -1357,14 +1368,14 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1357
1368
|
},
|
|
1358
1369
|
onRetry: C
|
|
1359
1370
|
}) : u || s === null ? /* @__PURE__ */ f("div", {
|
|
1360
|
-
className:
|
|
1371
|
+
className: Ue.placeholder,
|
|
1361
1372
|
children: /* @__PURE__ */ f(W, {
|
|
1362
1373
|
size: 200,
|
|
1363
1374
|
color: "var(--lv5)"
|
|
1364
1375
|
})
|
|
1365
1376
|
}) : P.length === 0 ? null : /* @__PURE__ */ p(d, { children: [
|
|
1366
1377
|
F && /* @__PURE__ */ p("div", {
|
|
1367
|
-
className:
|
|
1378
|
+
className: Ue.searchedFor,
|
|
1368
1379
|
"aria-live": "polite",
|
|
1369
1380
|
children: [/* @__PURE__ */ p("span", { children: ["Searching for ", /* @__PURE__ */ f("strong", { children: F })] }), O && /* @__PURE__ */ f(y, {
|
|
1370
1381
|
variant: "ghost",
|
|
@@ -1379,7 +1390,7 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1379
1390
|
c = typeof o == "string" ? JSON.parse(o) : o;
|
|
1380
1391
|
} catch {
|
|
1381
1392
|
return /* @__PURE__ */ f("div", {
|
|
1382
|
-
className:
|
|
1393
|
+
className: Ue.invalid,
|
|
1383
1394
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
1384
1395
|
}, r);
|
|
1385
1396
|
}
|
|
@@ -1391,11 +1402,11 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1391
1402
|
if (n) for (let e in l) {
|
|
1392
1403
|
let t = l[e];
|
|
1393
1404
|
if (typeof t == "string") {
|
|
1394
|
-
let n =
|
|
1405
|
+
let n = Xe(t);
|
|
1395
1406
|
n && (l[e] = n);
|
|
1396
1407
|
}
|
|
1397
1408
|
}
|
|
1398
|
-
return /* @__PURE__ */ f(
|
|
1409
|
+
return /* @__PURE__ */ f(Ge, {
|
|
1399
1410
|
index: r,
|
|
1400
1411
|
score: s,
|
|
1401
1412
|
showScore: i ?? m.showScore,
|
|
@@ -1418,18 +1429,18 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1418
1429
|
})
|
|
1419
1430
|
})
|
|
1420
1431
|
] });
|
|
1421
|
-
},
|
|
1432
|
+
}, Qe = {
|
|
1422
1433
|
row: "_row_ujwhc_1",
|
|
1423
1434
|
title: "_title_ujwhc_8"
|
|
1424
|
-
},
|
|
1425
|
-
className: [
|
|
1435
|
+
}, $e = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
1436
|
+
className: [Qe.row, e === "title" ? Qe.title : ""].filter(Boolean).join(" "),
|
|
1426
1437
|
children: t
|
|
1427
|
-
}),
|
|
1438
|
+
}), et = {
|
|
1428
1439
|
listRows: "_listRows_13obt_2",
|
|
1429
1440
|
sliderArea: "_sliderArea_13obt_8",
|
|
1430
1441
|
inputRow: "_inputRow_13obt_15",
|
|
1431
1442
|
histogramRow: "_histogramRow_13obt_22"
|
|
1432
|
-
},
|
|
1443
|
+
}, tt = [
|
|
1433
1444
|
65,
|
|
1434
1445
|
80,
|
|
1435
1446
|
55,
|
|
@@ -1438,22 +1449,22 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1438
1449
|
75,
|
|
1439
1450
|
50,
|
|
1440
1451
|
68
|
|
1441
|
-
],
|
|
1452
|
+
], nt = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ f(T, {
|
|
1442
1453
|
title: e,
|
|
1443
1454
|
collapsible: i,
|
|
1444
1455
|
collapsed: a,
|
|
1445
1456
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
1446
|
-
className:
|
|
1457
|
+
className: et.sliderArea,
|
|
1447
1458
|
children: [
|
|
1448
|
-
r && /* @__PURE__ */ f("div", { className:
|
|
1449
|
-
/* @__PURE__ */ f(
|
|
1459
|
+
r && /* @__PURE__ */ f("div", { className: et.histogramRow }),
|
|
1460
|
+
/* @__PURE__ */ f(j, { height: 6 }),
|
|
1450
1461
|
/* @__PURE__ */ p("div", {
|
|
1451
|
-
className:
|
|
1452
|
-
children: [/* @__PURE__ */ f(
|
|
1462
|
+
className: et.inputRow,
|
|
1463
|
+
children: [/* @__PURE__ */ f(j, {
|
|
1453
1464
|
width: 40,
|
|
1454
1465
|
height: 20,
|
|
1455
1466
|
delay: .1
|
|
1456
|
-
}), /* @__PURE__ */ f(
|
|
1467
|
+
}), /* @__PURE__ */ f(j, {
|
|
1457
1468
|
width: 40,
|
|
1458
1469
|
height: 20,
|
|
1459
1470
|
delay: .15
|
|
@@ -1461,13 +1472,13 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1461
1472
|
})
|
|
1462
1473
|
]
|
|
1463
1474
|
}) : /* @__PURE__ */ f("div", {
|
|
1464
|
-
className:
|
|
1465
|
-
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f(
|
|
1466
|
-
width: `${
|
|
1475
|
+
className: et.listRows,
|
|
1476
|
+
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f(j, {
|
|
1477
|
+
width: `${tt[t % tt.length]}%`,
|
|
1467
1478
|
delay: t * .05
|
|
1468
1479
|
}, t))
|
|
1469
1480
|
})
|
|
1470
|
-
}),
|
|
1481
|
+
}), X = {
|
|
1471
1482
|
list: "_list_18vbb_2",
|
|
1472
1483
|
count: "_count_18vbb_7",
|
|
1473
1484
|
countValue: "_countValue_18vbb_17",
|
|
@@ -1475,10 +1486,10 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1475
1486
|
chipLabel: "_chipLabel_18vbb_32",
|
|
1476
1487
|
grid: "_grid_18vbb_40",
|
|
1477
1488
|
active: "_active_18vbb_54"
|
|
1478
|
-
},
|
|
1489
|
+
}, rt = {
|
|
1479
1490
|
notice: "_notice_4sel0_1",
|
|
1480
1491
|
technical: "_technical_4sel0_9"
|
|
1481
|
-
},
|
|
1492
|
+
}, it = ({ label: e, field: t, missing: n }) => {
|
|
1482
1493
|
let r = n.map((e) => e[0].toUpperCase() + e.slice(1)).join(" and ");
|
|
1483
1494
|
return o(() => {
|
|
1484
1495
|
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).`);
|
|
@@ -1486,9 +1497,9 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1486
1497
|
title: e ?? t,
|
|
1487
1498
|
collapsible: !1,
|
|
1488
1499
|
children: /* @__PURE__ */ p("div", {
|
|
1489
|
-
className:
|
|
1500
|
+
className: rt.notice,
|
|
1490
1501
|
children: [/* @__PURE__ */ f("span", { children: "Not available" }), /* @__PURE__ */ p("code", {
|
|
1491
|
-
className:
|
|
1502
|
+
className: rt.technical,
|
|
1492
1503
|
children: [
|
|
1493
1504
|
t,
|
|
1494
1505
|
": not ",
|
|
@@ -1497,8 +1508,8 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1497
1508
|
})]
|
|
1498
1509
|
})
|
|
1499
1510
|
});
|
|
1500
|
-
},
|
|
1501
|
-
let { state: { facets: w, filterableFields: E, facetableFields:
|
|
1511
|
+
}, at = ({ 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: m, layout: h = "list", showActivePanel: g = !1, showCount: _ = !0, showNull: v = !1, match: x = "all", displayIfEmptyQuery: S = !0, displayCondition: C = (e) => !0 }) => {
|
|
1512
|
+
let { state: { facets: w, filterableFields: E, facetableFields: D, filters: k, query: A }, toggleFilter: j, setValueMatch: M, authError: N, isFetchingInitial: F, allowEmptySearch: I } = Y(), L = d ?? m ?? "checkbox", R = L === "radio" ? "any" : x;
|
|
1502
1513
|
o(() => {
|
|
1503
1514
|
M(e, R);
|
|
1504
1515
|
}, [
|
|
@@ -1509,11 +1520,11 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1509
1520
|
let z = c(null), [B, V] = l(a);
|
|
1510
1521
|
if (o(() => {
|
|
1511
1522
|
V(a);
|
|
1512
|
-
}, [w?.[e], a]), !I && !A ||
|
|
1513
|
-
if (F || !w) return L === "toggle" ? /* @__PURE__ */ f(
|
|
1523
|
+
}, [w?.[e], a]), !I && !A || N) return null;
|
|
1524
|
+
if (F || !w) return L === "toggle" ? /* @__PURE__ */ f(nt, {
|
|
1514
1525
|
rows: 1,
|
|
1515
1526
|
collapsible: !1
|
|
1516
|
-
}) : /* @__PURE__ */ f(
|
|
1527
|
+
}) : /* @__PURE__ */ f(nt, {
|
|
1517
1528
|
title: t,
|
|
1518
1529
|
rows: Math.min(a, 6),
|
|
1519
1530
|
collapsible: s,
|
|
@@ -1524,9 +1535,9 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1524
1535
|
filters: k,
|
|
1525
1536
|
facets: w
|
|
1526
1537
|
}) || !S && !A && Object.keys(k).length < 1) return null;
|
|
1527
|
-
if (!E?.includes(e) || !
|
|
1538
|
+
if (!E?.includes(e) || !D?.includes(e)) {
|
|
1528
1539
|
let n = [];
|
|
1529
|
-
return E?.includes(e) || n.push("filterable"),
|
|
1540
|
+
return E?.includes(e) || n.push("filterable"), D?.includes(e) || n.push("facetable"), /* @__PURE__ */ f(it, {
|
|
1530
1541
|
label: t,
|
|
1531
1542
|
field: e,
|
|
1532
1543
|
missing: n
|
|
@@ -1554,8 +1565,8 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1554
1565
|
if (L === "toggle" && !te) return /* @__PURE__ */ f(T, {
|
|
1555
1566
|
collapsible: !1,
|
|
1556
1567
|
children: /* @__PURE__ */ f("div", {
|
|
1557
|
-
className:
|
|
1558
|
-
children: /* @__PURE__ */ f(
|
|
1568
|
+
className: X.count,
|
|
1569
|
+
children: /* @__PURE__ */ f(P, {
|
|
1559
1570
|
label: t,
|
|
1560
1571
|
checked: !1,
|
|
1561
1572
|
onChange: () => {},
|
|
@@ -1568,9 +1579,9 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1568
1579
|
return /* @__PURE__ */ f(T, {
|
|
1569
1580
|
collapsible: !1,
|
|
1570
1581
|
children: /* @__PURE__ */ p("div", {
|
|
1571
|
-
className:
|
|
1582
|
+
className: X.count,
|
|
1572
1583
|
children: [
|
|
1573
|
-
/* @__PURE__ */ f(
|
|
1584
|
+
/* @__PURE__ */ f(P, {
|
|
1574
1585
|
label: t,
|
|
1575
1586
|
checked: i,
|
|
1576
1587
|
onChange: () => j(e, "true"),
|
|
@@ -1597,24 +1608,24 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1597
1608
|
let e = K.filter(([, e]) => typeof e == "number" && e > 0), t = K.filter(([, e]) => e === 0 || e === null);
|
|
1598
1609
|
K = [...e, ...t];
|
|
1599
1610
|
}
|
|
1600
|
-
let
|
|
1611
|
+
let ne = typeof a == "number" && K.length > a, re = ne ? K.slice(0, B) : K, ie = (t, n) => {
|
|
1601
1612
|
let r = U.includes(t), i = n === 0, a = _ && (n ?? 0) > 0 ? ` (${n})` : "", o = _ && (n ?? 0) > 0 ? n : "", s = () => j(e, t, L === "radio");
|
|
1602
1613
|
switch (L) {
|
|
1603
1614
|
case "button": return h === "list" ? /* @__PURE__ */ p("div", {
|
|
1604
|
-
className:
|
|
1615
|
+
className: X.count,
|
|
1605
1616
|
children: [/* @__PURE__ */ f(y, {
|
|
1606
1617
|
variant: r ? "primary" : "secondary",
|
|
1607
1618
|
onClick: s,
|
|
1608
1619
|
disabled: i,
|
|
1609
1620
|
size: "micro",
|
|
1610
|
-
className:
|
|
1621
|
+
className: X.chip,
|
|
1611
1622
|
title: t,
|
|
1612
1623
|
children: /* @__PURE__ */ f("span", {
|
|
1613
|
-
className:
|
|
1624
|
+
className: X.chipLabel,
|
|
1614
1625
|
children: t
|
|
1615
1626
|
})
|
|
1616
1627
|
}), /* @__PURE__ */ f("span", {
|
|
1617
|
-
className:
|
|
1628
|
+
className: X.countValue,
|
|
1618
1629
|
children: o
|
|
1619
1630
|
})]
|
|
1620
1631
|
}) : /* @__PURE__ */ f(y, {
|
|
@@ -1622,21 +1633,21 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1622
1633
|
onClick: s,
|
|
1623
1634
|
disabled: i,
|
|
1624
1635
|
size: "micro",
|
|
1625
|
-
className:
|
|
1636
|
+
className: X.chip,
|
|
1626
1637
|
title: `${t}${a}`,
|
|
1627
1638
|
children: /* @__PURE__ */ f("span", {
|
|
1628
|
-
className:
|
|
1639
|
+
className: X.chipLabel,
|
|
1629
1640
|
children: `${t}${a}`
|
|
1630
1641
|
})
|
|
1631
1642
|
});
|
|
1632
|
-
case "toggle": return /* @__PURE__ */ f(
|
|
1643
|
+
case "toggle": return /* @__PURE__ */ f(P, {
|
|
1633
1644
|
label: t,
|
|
1634
1645
|
checked: r,
|
|
1635
1646
|
onChange: s,
|
|
1636
1647
|
disabled: i
|
|
1637
1648
|
});
|
|
1638
1649
|
case "radio": {
|
|
1639
|
-
let n = /* @__PURE__ */ f(
|
|
1650
|
+
let n = /* @__PURE__ */ f(O, {
|
|
1640
1651
|
id: `${e}-${t}`,
|
|
1641
1652
|
name: e,
|
|
1642
1653
|
value: t,
|
|
@@ -1646,15 +1657,15 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1646
1657
|
disabled: i
|
|
1647
1658
|
});
|
|
1648
1659
|
return h === "list" ? /* @__PURE__ */ p("div", {
|
|
1649
|
-
className:
|
|
1660
|
+
className: X.count,
|
|
1650
1661
|
children: [n, /* @__PURE__ */ f("span", {
|
|
1651
|
-
className:
|
|
1662
|
+
className: X.countValue,
|
|
1652
1663
|
children: o
|
|
1653
1664
|
})]
|
|
1654
1665
|
}) : n;
|
|
1655
1666
|
}
|
|
1656
1667
|
default: return h === "list" ? /* @__PURE__ */ p("div", {
|
|
1657
|
-
className:
|
|
1668
|
+
className: X.count,
|
|
1658
1669
|
children: [/* @__PURE__ */ f(b, {
|
|
1659
1670
|
label: t,
|
|
1660
1671
|
score: "",
|
|
@@ -1662,7 +1673,7 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1662
1673
|
onChange: s,
|
|
1663
1674
|
disabled: i
|
|
1664
1675
|
}), /* @__PURE__ */ f("span", {
|
|
1665
|
-
className:
|
|
1676
|
+
className: X.countValue,
|
|
1666
1677
|
children: o
|
|
1667
1678
|
})]
|
|
1668
1679
|
}) : /* @__PURE__ */ f(b, {
|
|
@@ -1678,18 +1689,18 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1678
1689
|
title: t,
|
|
1679
1690
|
collapsible: s,
|
|
1680
1691
|
collapsed: s ? u : !1,
|
|
1681
|
-
className: g && U.length > 0 ?
|
|
1692
|
+
className: g && U.length > 0 ? X.active : void 0,
|
|
1682
1693
|
children: /* @__PURE__ */ p("ul", {
|
|
1683
|
-
className: h === "grid" ?
|
|
1694
|
+
className: h === "grid" ? X.grid : X.list,
|
|
1684
1695
|
style: {
|
|
1685
1696
|
listStyle: "none",
|
|
1686
1697
|
padding: 0,
|
|
1687
1698
|
margin: 0
|
|
1688
1699
|
},
|
|
1689
|
-
children: [
|
|
1700
|
+
children: [re.map(([e, t]) => /* @__PURE__ */ f("li", { children: ie(e, t) }, e)), ne && B < K.length && (() => {
|
|
1690
1701
|
let e = K.length - B, t = Math.min(50, e);
|
|
1691
1702
|
return /* @__PURE__ */ f("li", {
|
|
1692
|
-
className:
|
|
1703
|
+
className: X.toggleItem,
|
|
1693
1704
|
children: /* @__PURE__ */ f(y, {
|
|
1694
1705
|
variant: "ghost",
|
|
1695
1706
|
size: "micro",
|
|
@@ -1700,7 +1711,7 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1700
1711
|
})()]
|
|
1701
1712
|
})
|
|
1702
1713
|
});
|
|
1703
|
-
},
|
|
1714
|
+
}, Z = {
|
|
1704
1715
|
disabledMessage: "_disabledMessage_adany_1",
|
|
1705
1716
|
histogram: "_histogram_adany_6",
|
|
1706
1717
|
histogramLayer: "_histogramLayer_adany_14",
|
|
@@ -1714,37 +1725,37 @@ var Ye = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1714
1725
|
};
|
|
1715
1726
|
//#endregion
|
|
1716
1727
|
//#region src/utils/numeric.ts
|
|
1717
|
-
function
|
|
1728
|
+
function ot(e) {
|
|
1718
1729
|
if (!Number.isFinite(e)) return 0;
|
|
1719
1730
|
let t = String(e), n = t.indexOf(".");
|
|
1720
1731
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1721
1732
|
}
|
|
1722
|
-
function
|
|
1733
|
+
function st(e) {
|
|
1723
1734
|
let t = 0;
|
|
1724
|
-
for (let n of e) t = Math.max(t,
|
|
1735
|
+
for (let n of e) t = Math.max(t, ot(n));
|
|
1725
1736
|
return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
|
|
1726
1737
|
}
|
|
1727
|
-
function
|
|
1728
|
-
return Number(e.toFixed(
|
|
1738
|
+
function Q(e, t) {
|
|
1739
|
+
return Number(e.toFixed(ot(t)));
|
|
1729
1740
|
}
|
|
1730
1741
|
//#endregion
|
|
1731
1742
|
//#region src/components/RangeFilterPanel.tsx
|
|
1732
|
-
function
|
|
1743
|
+
function ct(e, t, n) {
|
|
1733
1744
|
let r = t + Math.round((e - t) / n) * n;
|
|
1734
|
-
return Number(r.toFixed(
|
|
1745
|
+
return Number(r.toFixed(ot(n)));
|
|
1735
1746
|
}
|
|
1736
|
-
function
|
|
1747
|
+
function lt(e, t, n) {
|
|
1737
1748
|
let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
|
|
1738
|
-
return Number((t + r * n).toFixed(
|
|
1749
|
+
return Number((t + r * n).toFixed(ot(n)));
|
|
1739
1750
|
}
|
|
1740
|
-
var
|
|
1741
|
-
let { state: { rangeFilters: g, rangeBounds: _, facetStats: v, facets: y, filterableFields: b, facetableFields: x, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: D, allowEmptySearch: O, authError: k, isFetchingInitial: A } =
|
|
1751
|
+
var ut = ({ 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: m, stepMarks: h }) => {
|
|
1752
|
+
let { state: { rangeFilters: g, rangeBounds: _, facetStats: v, facets: y, filterableFields: b, facetableFields: x, query: S, facetDebounceDelayMillis: C }, setRangeFilter: w, resetRangeFilter: D, allowEmptySearch: O, authError: k, isFetchingInitial: A } = Y(), j = a ?? o ?? "input", N = _?.[t] !== void 0, P = _?.[t] ?? {
|
|
1742
1753
|
min: r,
|
|
1743
1754
|
max: i
|
|
1744
1755
|
}, F = P.min, I = P.max, L = v?.[t] ?? P, R = Math.max(F, Math.min(I, L.min)), z = Math.max(F, Math.min(I, L.max)), B = e.useMemo(() => {
|
|
1745
1756
|
if (m) return m;
|
|
1746
|
-
let e = Math.max(
|
|
1747
|
-
if (Array.isArray(n)) for (let t of n) e = Math.max(e,
|
|
1757
|
+
let e = Math.max(ot(F), ot(I)), n = y?.[t];
|
|
1758
|
+
if (Array.isArray(n)) for (let t of n) e = Math.max(e, ot(Number(t.key)));
|
|
1748
1759
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1749
1760
|
}, [
|
|
1750
1761
|
m,
|
|
@@ -1752,21 +1763,21 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1752
1763
|
I,
|
|
1753
1764
|
y,
|
|
1754
1765
|
t
|
|
1755
|
-
]), V = N && F === I, H = V ? r : F, U = V ? i : I, W =
|
|
1756
|
-
let e =
|
|
1757
|
-
return { width: `calc(${Math.max(3, F.toFixed(e).length, I.toFixed(e).length,
|
|
1766
|
+
]), V = N && F === I, H = V ? r : F, U = V ? i : I, W = lt(U + B, H, B), ee = (e) => Math.min(W, Math.max(H, e)), G = g?.[t], te = s && G !== void 0 ? Z.active : void 0, K = G ? G.min : F, ne = G ? G.max : I, re = G !== void 0, ie = R !== F || z !== I, [q, J] = e.useState([K, ne]), [ae, oe] = e.useState(!1), [se, ce] = e.useState(!1), [le, ue] = e.useState(String(K)), [de, fe] = e.useState(String(ne)), pe = e.useMemo(() => {
|
|
1767
|
+
let e = ot(B);
|
|
1768
|
+
return { width: `calc(${Math.max(3, F.toFixed(e).length, I.toFixed(e).length, le.length, de.length) + 1}ch + 20px)` };
|
|
1758
1769
|
}, [
|
|
1759
1770
|
B,
|
|
1760
1771
|
F,
|
|
1761
1772
|
I,
|
|
1762
|
-
|
|
1763
|
-
|
|
1773
|
+
le,
|
|
1774
|
+
de
|
|
1764
1775
|
]);
|
|
1765
1776
|
e.useEffect(() => {
|
|
1766
|
-
|
|
1767
|
-
}, [
|
|
1768
|
-
let { finalMin:
|
|
1769
|
-
let [e, t] =
|
|
1777
|
+
ue(String(q[0])), fe(String(q[1]));
|
|
1778
|
+
}, [q]);
|
|
1779
|
+
let { finalMin: me, finalMax: he, isValidMin: ge, isValidMax: _e } = e.useMemo(() => {
|
|
1780
|
+
let [e, t] = q, n = Math.max(F, Math.min(I, e)), r = Math.max(F, Math.min(I, t)), i = Math.min(n, r), a = Math.max(n, r);
|
|
1770
1781
|
return {
|
|
1771
1782
|
finalMin: i,
|
|
1772
1783
|
finalMax: a,
|
|
@@ -1774,29 +1785,29 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1774
1785
|
isValidMax: a <= I && a >= i
|
|
1775
1786
|
};
|
|
1776
1787
|
}, [
|
|
1777
|
-
|
|
1788
|
+
q,
|
|
1778
1789
|
F,
|
|
1779
1790
|
I
|
|
1780
1791
|
]);
|
|
1781
1792
|
e.useEffect(() => {
|
|
1782
1793
|
if (V) return;
|
|
1783
|
-
if (
|
|
1784
|
-
|
|
1794
|
+
if (q[0] === F && q[1] === I) {
|
|
1795
|
+
oe(!1), ce(!1);
|
|
1785
1796
|
return;
|
|
1786
1797
|
}
|
|
1787
1798
|
let e = C ?? 500, n = setTimeout(() => {
|
|
1788
|
-
|
|
1799
|
+
oe(!ge), ce(!_e);
|
|
1789
1800
|
}, 300), r = setTimeout(() => {
|
|
1790
|
-
|
|
1801
|
+
ge && _e && (me === F && he === I ? D(t, !1) : w(t, me, he));
|
|
1791
1802
|
}, e);
|
|
1792
1803
|
return () => {
|
|
1793
1804
|
clearTimeout(n), clearTimeout(r);
|
|
1794
1805
|
};
|
|
1795
1806
|
}, [
|
|
1796
|
-
pe,
|
|
1797
1807
|
me,
|
|
1798
1808
|
he,
|
|
1799
1809
|
ge,
|
|
1810
|
+
_e,
|
|
1800
1811
|
F,
|
|
1801
1812
|
I,
|
|
1802
1813
|
t,
|
|
@@ -1805,51 +1816,51 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1805
1816
|
C,
|
|
1806
1817
|
V
|
|
1807
1818
|
]), e.useEffect(() => {
|
|
1808
|
-
|
|
1819
|
+
J([K, ne]), oe(!1), ce(!1);
|
|
1809
1820
|
}, [
|
|
1810
1821
|
K,
|
|
1811
|
-
|
|
1822
|
+
ne,
|
|
1812
1823
|
t
|
|
1813
1824
|
]);
|
|
1814
|
-
let
|
|
1815
|
-
let t =
|
|
1816
|
-
return [t,
|
|
1817
|
-
}, [B]),
|
|
1825
|
+
let ve = e.useCallback((e) => {
|
|
1826
|
+
let t = Q(Math.min(e[0], e[1] - B), B);
|
|
1827
|
+
return [t, Q(Math.max(e[1] - B, t), B)];
|
|
1828
|
+
}, [B]), ye = e.useCallback((e) => {
|
|
1818
1829
|
if (V) return;
|
|
1819
|
-
let [t, n] =
|
|
1820
|
-
|
|
1830
|
+
let [t, n] = ve(e);
|
|
1831
|
+
J([Math.max(F, Math.min(z, t)), Math.max(R, Math.min(I, n))]);
|
|
1821
1832
|
}, [
|
|
1822
1833
|
V,
|
|
1823
|
-
|
|
1834
|
+
ve,
|
|
1824
1835
|
F,
|
|
1825
1836
|
I,
|
|
1826
1837
|
R,
|
|
1827
1838
|
z
|
|
1828
|
-
]),
|
|
1839
|
+
]), be = e.useCallback((e) => {
|
|
1829
1840
|
if (V) return;
|
|
1830
|
-
let [n, r] =
|
|
1831
|
-
i === F && a === I ? (
|
|
1841
|
+
let [n, r] = ve(e), i = Math.max(F, Math.min(z, n)), a = Math.max(R, Math.min(I, r));
|
|
1842
|
+
i === F && a === I ? (J([F, I]), D(t, !0)) : J([i, a]);
|
|
1832
1843
|
}, [
|
|
1833
1844
|
V,
|
|
1834
|
-
|
|
1845
|
+
ve,
|
|
1835
1846
|
F,
|
|
1836
1847
|
I,
|
|
1837
1848
|
R,
|
|
1838
1849
|
z,
|
|
1839
1850
|
t,
|
|
1840
1851
|
D
|
|
1841
|
-
]),
|
|
1852
|
+
]), xe = e.useRef(null), Se = e.useCallback((e, n) => {
|
|
1842
1853
|
if (V) return;
|
|
1843
|
-
let r =
|
|
1854
|
+
let r = xe.current;
|
|
1844
1855
|
if (G && r && r.start === e && r.last === n) {
|
|
1845
|
-
|
|
1856
|
+
xe.current = null, J([F, I]), D(t, !0);
|
|
1846
1857
|
return;
|
|
1847
1858
|
}
|
|
1848
|
-
let i =
|
|
1849
|
-
|
|
1859
|
+
let i = ct(Math.max(F, R, e), F, B), a = Math.max(i, ct(Math.min(I, z, n), F, B));
|
|
1860
|
+
xe.current = {
|
|
1850
1861
|
start: e,
|
|
1851
1862
|
last: n
|
|
1852
|
-
},
|
|
1863
|
+
}, J([i, a]);
|
|
1853
1864
|
}, [
|
|
1854
1865
|
V,
|
|
1855
1866
|
G,
|
|
@@ -1860,50 +1871,50 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1860
1871
|
B,
|
|
1861
1872
|
t,
|
|
1862
1873
|
D
|
|
1863
|
-
]),
|
|
1874
|
+
]), Ce = e.useCallback(() => {
|
|
1864
1875
|
if (V) return;
|
|
1865
|
-
let e =
|
|
1876
|
+
let e = le.trim(), t = e === "" ? NaN : Number(e);
|
|
1866
1877
|
if (isNaN(t)) {
|
|
1867
|
-
|
|
1878
|
+
ue(String(q[0]));
|
|
1868
1879
|
return;
|
|
1869
1880
|
}
|
|
1870
1881
|
let n = Math.max(F, Math.min(z, t));
|
|
1871
|
-
n <
|
|
1882
|
+
n < q[1] ? J([n, q[1]]) : J([F, q[1]]), ue(String(n < q[1] ? n : F));
|
|
1872
1883
|
}, [
|
|
1873
1884
|
V,
|
|
1874
|
-
|
|
1875
|
-
|
|
1885
|
+
le,
|
|
1886
|
+
q,
|
|
1876
1887
|
F,
|
|
1877
1888
|
z
|
|
1878
|
-
]),
|
|
1889
|
+
]), we = e.useCallback(() => {
|
|
1879
1890
|
if (V) return;
|
|
1880
|
-
let e =
|
|
1891
|
+
let e = de.trim(), t = e === "" ? NaN : Number(e);
|
|
1881
1892
|
if (isNaN(t)) {
|
|
1882
|
-
|
|
1893
|
+
fe(String(q[1]));
|
|
1883
1894
|
return;
|
|
1884
1895
|
}
|
|
1885
1896
|
let n = Math.max(R, Math.min(I, t));
|
|
1886
|
-
n >
|
|
1897
|
+
n > q[0] ? J([q[0], n]) : J([q[0], I]), fe(String(n > q[0] ? n : I));
|
|
1887
1898
|
}, [
|
|
1888
1899
|
V,
|
|
1889
|
-
|
|
1890
|
-
|
|
1900
|
+
de,
|
|
1901
|
+
q,
|
|
1891
1902
|
R,
|
|
1892
1903
|
I
|
|
1893
|
-
]),
|
|
1904
|
+
]), Te = (e) => (t) => {
|
|
1894
1905
|
t.key === "Enter" && e();
|
|
1895
|
-
}, [
|
|
1906
|
+
}, [Ee, De] = e.useState(null), Oe = e.useRef(null);
|
|
1896
1907
|
e.useEffect(() => {
|
|
1897
1908
|
if (!u) return;
|
|
1898
1909
|
let e = `${F}:${I}`;
|
|
1899
|
-
if (e ===
|
|
1910
|
+
if (e === Oe.current && Oe.current !== null) return;
|
|
1900
1911
|
let n = y?.[t];
|
|
1901
1912
|
if (!Array.isArray(n) || n.length === 0) return;
|
|
1902
1913
|
let r = n.filter((e) => e.value != null && !isNaN(Number(e.key))).map((e) => ({
|
|
1903
1914
|
key: e.key,
|
|
1904
1915
|
value: e.value
|
|
1905
1916
|
}));
|
|
1906
|
-
r.length > 0 && (
|
|
1917
|
+
r.length > 0 && (Oe.current = e, De(r));
|
|
1907
1918
|
}, [
|
|
1908
1919
|
F,
|
|
1909
1920
|
I,
|
|
@@ -1911,22 +1922,22 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1911
1922
|
t,
|
|
1912
1923
|
u
|
|
1913
1924
|
]);
|
|
1914
|
-
let
|
|
1915
|
-
if (!u || !
|
|
1925
|
+
let ke = e.useMemo(() => {
|
|
1926
|
+
if (!u || !Ee || Ee.length === 0) return [];
|
|
1916
1927
|
let e = I - F;
|
|
1917
1928
|
if (e <= 0) return [];
|
|
1918
|
-
let t = d ?? Math.max(B,
|
|
1929
|
+
let t = d ?? Math.max(B, Q(Math.ceil(e / 20 / B) * B, B)), n = Math.ceil(e / t);
|
|
1919
1930
|
return Array.from({ length: n }, (e, r) => {
|
|
1920
|
-
let i = F + r * t, a = F + (r + 1) * t, o = r === n - 1, s =
|
|
1931
|
+
let i = F + r * t, a = F + (r + 1) * t, o = r === n - 1, s = Ee.filter((e) => {
|
|
1921
1932
|
let t = Number(e.key);
|
|
1922
1933
|
return t >= i && (t < a || o && t <= I);
|
|
1923
|
-
}).reduce((e, t) => e + t.value, 0), c = o ? I :
|
|
1934
|
+
}).reduce((e, t) => e + t.value, 0), c = o ? I : Q(a - B, B);
|
|
1924
1935
|
return {
|
|
1925
1936
|
bucketStart: i,
|
|
1926
1937
|
bucketEnd: a,
|
|
1927
1938
|
count: s,
|
|
1928
1939
|
last: c,
|
|
1929
|
-
barEnd:
|
|
1940
|
+
barEnd: Q(c + B, B)
|
|
1930
1941
|
};
|
|
1931
1942
|
}).map((e, t, n) => ({
|
|
1932
1943
|
...e,
|
|
@@ -1934,92 +1945,92 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1934
1945
|
}));
|
|
1935
1946
|
}, [
|
|
1936
1947
|
u,
|
|
1937
|
-
|
|
1948
|
+
Ee,
|
|
1938
1949
|
F,
|
|
1939
1950
|
I,
|
|
1940
1951
|
d,
|
|
1941
1952
|
B,
|
|
1942
1953
|
W
|
|
1943
|
-
]),
|
|
1944
|
-
return u && !A && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), k ? null : A ? /* @__PURE__ */ f(
|
|
1954
|
+
]), Ae = e.useMemo(() => Math.max(...ke.map((e) => e.count), 1), [ke]);
|
|
1955
|
+
return u && !A && !x?.includes(t) && console.warn(`RangeFilterPanel: showHistogram=true but field "${t}" is not facetable. Add .Facetable = true to this field.`), k ? null : A ? /* @__PURE__ */ f(nt, {
|
|
1945
1956
|
title: n,
|
|
1946
1957
|
variant: "slider",
|
|
1947
1958
|
withHistogram: u,
|
|
1948
1959
|
collapsible: c,
|
|
1949
1960
|
startCollapsed: l
|
|
1950
|
-
}) : !O && !S ? null : b?.includes(t) ?
|
|
1961
|
+
}) : !O && !S ? null : b?.includes(t) ? j === "slider" ? /* @__PURE__ */ p(T, {
|
|
1951
1962
|
title: n,
|
|
1952
1963
|
collapsed: l,
|
|
1953
1964
|
collapsible: c,
|
|
1954
1965
|
className: te,
|
|
1955
1966
|
children: [
|
|
1956
1967
|
V && /* @__PURE__ */ p("div", {
|
|
1957
|
-
className:
|
|
1968
|
+
className: Z.disabledMessage,
|
|
1958
1969
|
children: [
|
|
1959
1970
|
"No adjustable range (all results have the same value: ",
|
|
1960
1971
|
F,
|
|
1961
1972
|
")."
|
|
1962
1973
|
]
|
|
1963
1974
|
}),
|
|
1964
|
-
u &&
|
|
1965
|
-
u &&
|
|
1966
|
-
let [e, t] = z > R && (R > F || z < I) ? [R, z] : [H, U], n = Math.max(
|
|
1975
|
+
u && ke.length === 0 && /* @__PURE__ */ f("div", { className: Z.histogram }),
|
|
1976
|
+
u && ke.length > 0 && (() => {
|
|
1977
|
+
let [e, t] = z > R && (R > F || z < I) ? [R, z] : [H, U], n = Math.max(me, e), r = Math.min(he, 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)})`, m = `inset(0 ${u(s(t))} 0 ${u(o(e))})`, h = (n) => n.last < e || n.bucketStart > t, g = ke.slice(1).map((e) => u((e.bucketStart - H) / a)), _ = ke.map((e) => ({
|
|
1967
1978
|
...e,
|
|
1968
|
-
height: Math.max(1, Math.ceil(e.count /
|
|
1979
|
+
height: Math.max(1, Math.ceil(e.count / Ae * 20))
|
|
1969
1980
|
}));
|
|
1970
1981
|
return /* @__PURE__ */ p("div", {
|
|
1971
|
-
className:
|
|
1982
|
+
className: Z.histogram,
|
|
1972
1983
|
children: [
|
|
1973
1984
|
/* @__PURE__ */ f("div", {
|
|
1974
|
-
className:
|
|
1985
|
+
className: Z.histogramLayer,
|
|
1975
1986
|
children: _.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1976
1987
|
type: "button",
|
|
1977
|
-
className:
|
|
1988
|
+
className: Z.histogramBar,
|
|
1978
1989
|
style: { flexGrow: e.span },
|
|
1979
1990
|
"data-testid": "histogram-bar",
|
|
1980
1991
|
disabled: V || h(e),
|
|
1981
1992
|
"aria-label": `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1982
1993
|
title: `${e.bucketStart} to ${e.last}: ${e.count}`,
|
|
1983
|
-
onClick: () =>
|
|
1994
|
+
onClick: () => Se(e.bucketStart, e.last),
|
|
1984
1995
|
children: /* @__PURE__ */ f("span", {
|
|
1985
|
-
className:
|
|
1996
|
+
className: Z.histogramFill,
|
|
1986
1997
|
style: { height: `${e.height}px` }
|
|
1987
1998
|
})
|
|
1988
1999
|
}, t))
|
|
1989
2000
|
}),
|
|
1990
2001
|
/* @__PURE__ */ f("div", {
|
|
1991
|
-
className: `${
|
|
2002
|
+
className: `${Z.histogramLayer} ${Z.histogramLive}`,
|
|
1992
2003
|
"aria-hidden": "true",
|
|
1993
2004
|
"data-testid": "histogram-live",
|
|
1994
2005
|
style: { clipPath: m },
|
|
1995
2006
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
1996
|
-
className:
|
|
2007
|
+
className: Z.histogramBar,
|
|
1997
2008
|
style: { flexGrow: e.span },
|
|
1998
2009
|
children: /* @__PURE__ */ f("span", {
|
|
1999
|
-
className:
|
|
2010
|
+
className: Z.histogramFill,
|
|
2000
2011
|
style: { height: `${e.height}px` }
|
|
2001
2012
|
})
|
|
2002
2013
|
}, t))
|
|
2003
2014
|
}),
|
|
2004
2015
|
/* @__PURE__ */ f("div", {
|
|
2005
|
-
className: `${
|
|
2016
|
+
className: `${Z.histogramLayer} ${Z.histogramLit}`,
|
|
2006
2017
|
"aria-hidden": "true",
|
|
2007
2018
|
"data-testid": "histogram-lit",
|
|
2008
2019
|
style: { clipPath: d },
|
|
2009
2020
|
children: _.map((e, t) => /* @__PURE__ */ f("span", {
|
|
2010
|
-
className:
|
|
2021
|
+
className: Z.histogramBar,
|
|
2011
2022
|
style: { flexGrow: e.span },
|
|
2012
2023
|
children: /* @__PURE__ */ f("span", {
|
|
2013
|
-
className:
|
|
2024
|
+
className: Z.histogramFill,
|
|
2014
2025
|
style: { height: `${e.height}px` }
|
|
2015
2026
|
})
|
|
2016
2027
|
}, t))
|
|
2017
2028
|
}),
|
|
2018
2029
|
/* @__PURE__ */ f("div", {
|
|
2019
|
-
className:
|
|
2030
|
+
className: Z.histogramSeparators,
|
|
2020
2031
|
"aria-hidden": "true",
|
|
2021
2032
|
children: g.map((e, t) => /* @__PURE__ */ f("span", {
|
|
2022
|
-
className:
|
|
2033
|
+
className: Z.histogramSeparator,
|
|
2023
2034
|
style: { left: e }
|
|
2024
2035
|
}, t))
|
|
2025
2036
|
})
|
|
@@ -2028,20 +2039,20 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2028
2039
|
})(),
|
|
2029
2040
|
/* @__PURE__ */ f("div", {
|
|
2030
2041
|
style: { padding: "10px 10px 20px 10px" },
|
|
2031
|
-
children: /* @__PURE__ */ f(
|
|
2042
|
+
children: /* @__PURE__ */ f(M, {
|
|
2032
2043
|
min: H,
|
|
2033
2044
|
max: W,
|
|
2034
2045
|
step: B,
|
|
2035
2046
|
stepMarks: h,
|
|
2036
|
-
value: V ? [H, W] : [ee(
|
|
2047
|
+
value: V ? [H, W] : [ee(ct(me, H, B)), ee(ct(he + B, H, B))],
|
|
2037
2048
|
isRange: !0,
|
|
2038
|
-
onChange: (e) =>
|
|
2039
|
-
onFinalChange: (e) =>
|
|
2049
|
+
onChange: (e) => ye(e),
|
|
2050
|
+
onFinalChange: (e) => be(e),
|
|
2040
2051
|
disabled: V,
|
|
2041
2052
|
activeMin: R,
|
|
2042
|
-
activeMax: ee(
|
|
2043
|
-
isFaceted:
|
|
2044
|
-
highlightFaceted:
|
|
2053
|
+
activeMax: ee(Q(z + B, B)),
|
|
2054
|
+
isFaceted: ie,
|
|
2055
|
+
highlightFaceted: re,
|
|
2045
2056
|
"aria-label": n || `Filter by ${t}`
|
|
2046
2057
|
})
|
|
2047
2058
|
}),
|
|
@@ -2055,27 +2066,27 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2055
2066
|
children: [/* @__PURE__ */ f(E, {
|
|
2056
2067
|
label: "Min:",
|
|
2057
2068
|
type: "number",
|
|
2058
|
-
style:
|
|
2059
|
-
value: V ? String(F) :
|
|
2069
|
+
style: pe,
|
|
2070
|
+
value: V ? String(F) : le,
|
|
2060
2071
|
min: F,
|
|
2061
|
-
max:
|
|
2062
|
-
onChange: (e) =>
|
|
2063
|
-
onBlur:
|
|
2064
|
-
onKeyDown:
|
|
2072
|
+
max: Q(Math.min(z, q[1] - B), B),
|
|
2073
|
+
onChange: (e) => ue(e.target.value),
|
|
2074
|
+
onBlur: Ce,
|
|
2075
|
+
onKeyDown: Te(Ce),
|
|
2065
2076
|
disabled: V,
|
|
2066
|
-
isValid: V || !
|
|
2077
|
+
isValid: V || !ae
|
|
2067
2078
|
}), /* @__PURE__ */ f(E, {
|
|
2068
2079
|
label: "Max:",
|
|
2069
2080
|
type: "number",
|
|
2070
|
-
style:
|
|
2071
|
-
value: V ? String(I) :
|
|
2072
|
-
min:
|
|
2081
|
+
style: pe,
|
|
2082
|
+
value: V ? String(I) : de,
|
|
2083
|
+
min: Q(Math.max(R, q[0] + B), B),
|
|
2073
2084
|
max: I,
|
|
2074
|
-
onChange: (e) =>
|
|
2075
|
-
onBlur:
|
|
2076
|
-
onKeyDown: we
|
|
2085
|
+
onChange: (e) => fe(e.target.value),
|
|
2086
|
+
onBlur: we,
|
|
2087
|
+
onKeyDown: Te(we),
|
|
2077
2088
|
disabled: V,
|
|
2078
|
-
isValid: V || !
|
|
2089
|
+
isValid: V || !se
|
|
2079
2090
|
})]
|
|
2080
2091
|
})
|
|
2081
2092
|
]
|
|
@@ -2083,7 +2094,7 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2083
2094
|
title: n,
|
|
2084
2095
|
className: te,
|
|
2085
2096
|
children: [V && /* @__PURE__ */ p("div", {
|
|
2086
|
-
className:
|
|
2097
|
+
className: Z.disabledMessage,
|
|
2087
2098
|
children: [
|
|
2088
2099
|
"No adjustable range (all results have the same value: ",
|
|
2089
2100
|
F,
|
|
@@ -2098,35 +2109,35 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2098
2109
|
children: [/* @__PURE__ */ f(E, {
|
|
2099
2110
|
label: "Min:",
|
|
2100
2111
|
type: "number",
|
|
2101
|
-
style:
|
|
2102
|
-
value: V ? String(F) :
|
|
2112
|
+
style: pe,
|
|
2113
|
+
value: V ? String(F) : le,
|
|
2103
2114
|
min: F,
|
|
2104
|
-
max:
|
|
2105
|
-
onChange: (e) =>
|
|
2106
|
-
onBlur:
|
|
2107
|
-
onKeyDown:
|
|
2115
|
+
max: Q(Math.min(z, q[1] - B), B),
|
|
2116
|
+
onChange: (e) => ue(e.target.value),
|
|
2117
|
+
onBlur: Ce,
|
|
2118
|
+
onKeyDown: Te(Ce),
|
|
2108
2119
|
disabled: V,
|
|
2109
|
-
isValid: V || !
|
|
2120
|
+
isValid: V || !ae
|
|
2110
2121
|
}), /* @__PURE__ */ f(E, {
|
|
2111
2122
|
label: "Max:",
|
|
2112
2123
|
type: "number",
|
|
2113
|
-
style:
|
|
2114
|
-
value: V ? String(I) :
|
|
2115
|
-
min:
|
|
2124
|
+
style: pe,
|
|
2125
|
+
value: V ? String(I) : de,
|
|
2126
|
+
min: Q(Math.max(R, q[0] + B), B),
|
|
2116
2127
|
max: I,
|
|
2117
|
-
onChange: (e) =>
|
|
2118
|
-
onBlur:
|
|
2119
|
-
onKeyDown: we
|
|
2128
|
+
onChange: (e) => fe(e.target.value),
|
|
2129
|
+
onBlur: we,
|
|
2130
|
+
onKeyDown: Te(we),
|
|
2120
2131
|
disabled: V,
|
|
2121
|
-
isValid: V || !
|
|
2132
|
+
isValid: V || !se
|
|
2122
2133
|
})]
|
|
2123
2134
|
})]
|
|
2124
|
-
}) : /* @__PURE__ */ f(
|
|
2135
|
+
}) : /* @__PURE__ */ f(it, {
|
|
2125
2136
|
label: n,
|
|
2126
2137
|
field: t,
|
|
2127
2138
|
missing: ["filterable"]
|
|
2128
2139
|
});
|
|
2129
|
-
},
|
|
2140
|
+
}, dt = {
|
|
2130
2141
|
list: "_list_9je85_2",
|
|
2131
2142
|
grid: "_grid_9je85_9",
|
|
2132
2143
|
count: "_count_9je85_22",
|
|
@@ -2136,7 +2147,7 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2136
2147
|
};
|
|
2137
2148
|
//#endregion
|
|
2138
2149
|
//#region src/components/BucketFilterPanel.tsx
|
|
2139
|
-
function
|
|
2150
|
+
function ft(e, t) {
|
|
2140
2151
|
if (!t) return null;
|
|
2141
2152
|
let n = 0, r = !1;
|
|
2142
2153
|
for (let i of t) {
|
|
@@ -2148,15 +2159,15 @@ function dt(e, t) {
|
|
|
2148
2159
|
}
|
|
2149
2160
|
return r ? n : 0;
|
|
2150
2161
|
}
|
|
2151
|
-
var
|
|
2152
|
-
let { state: { facets: v, filterableFields: x, facetableFields: S, bucketFilters: C, rangeBounds: w, facetStats: E, query:
|
|
2162
|
+
var pt = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a, layout: c = "list", showCount: u = !0, showEmpty: d = !1, limit: m, showActivePanel: h = !1, collapsible: g = !0, startCollapsed: _ = !1 }) => {
|
|
2163
|
+
let { state: { facets: v, filterableFields: x, facetableFields: S, bucketFilters: C, rangeBounds: w, facetStats: E, query: D }, toggleBucketFilter: k, authError: A, isFetchingInitial: j, allowEmptySearch: M } = Y(), N = i ?? a ?? "checkbox", P = v?.[e], F = C[e] ?? [], [I, L] = l(m ?? Infinity);
|
|
2153
2164
|
o(() => {
|
|
2154
2165
|
L(m ?? Infinity);
|
|
2155
2166
|
}, [m, P]);
|
|
2156
2167
|
let R = w?.[e] ?? E?.[e], z = s(() => {
|
|
2157
2168
|
let e = [];
|
|
2158
2169
|
if (R && e.push(R.min, R.max), Array.isArray(P)) for (let t of P) e.push(Number(t.key));
|
|
2159
|
-
return
|
|
2170
|
+
return st(e.filter(Number.isFinite));
|
|
2160
2171
|
}, [R, P]), B = s(() => {
|
|
2161
2172
|
let e = R?.min ?? -Number.MAX_VALUE, t = R?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
|
|
2162
2173
|
label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
|
|
@@ -2169,12 +2180,12 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2169
2180
|
if (r && r.length > 0) return r.map((e) => i(e.min, e.max, e.label));
|
|
2170
2181
|
if (Array.isArray(n)) {
|
|
2171
2182
|
let e = [...n].sort((e, t) => e - t), t = [];
|
|
2172
|
-
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n],
|
|
2183
|
+
for (let n = 0; n < e.length - 1; n++) t.push(i(e[n], Q(e[n + 1] - z, z)));
|
|
2173
2184
|
return t;
|
|
2174
2185
|
}
|
|
2175
2186
|
if (typeof n == "number" && n > 0 && R) {
|
|
2176
2187
|
let e = [], t = Math.floor(R.min / n) * n;
|
|
2177
|
-
for (let r = t; r <= R.max; r =
|
|
2188
|
+
for (let r = t; r <= R.max; r = Q(r + n, z)) e.push(i(Q(r, z), Q(r + n - z, z)));
|
|
2178
2189
|
return e;
|
|
2179
2190
|
}
|
|
2180
2191
|
return [];
|
|
@@ -2185,27 +2196,27 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2185
2196
|
z
|
|
2186
2197
|
]);
|
|
2187
2198
|
if (A) return null;
|
|
2188
|
-
if (j || !v) return /* @__PURE__ */ f(
|
|
2199
|
+
if (j || !v) return /* @__PURE__ */ f(nt, {
|
|
2189
2200
|
title: t,
|
|
2190
2201
|
rows: Math.max(1, Math.min(B.length || 5, 8)),
|
|
2191
2202
|
collapsible: g,
|
|
2192
2203
|
startCollapsed: _
|
|
2193
2204
|
});
|
|
2194
|
-
if (!M && !
|
|
2195
|
-
if (!x?.includes(e)) return /* @__PURE__ */ f(
|
|
2205
|
+
if (!M && !D) return null;
|
|
2206
|
+
if (!x?.includes(e)) return /* @__PURE__ */ f(it, {
|
|
2196
2207
|
label: t,
|
|
2197
2208
|
field: e,
|
|
2198
2209
|
missing: ["filterable"]
|
|
2199
2210
|
});
|
|
2200
2211
|
let V = S?.includes(e) && Array.isArray(P), H = (e) => F.some((t) => t.min === e.range.min && t.max === e.range.max), U = B.map((e) => ({
|
|
2201
2212
|
bucket: e,
|
|
2202
|
-
count: V ?
|
|
2213
|
+
count: V ? ft(e, P) : null
|
|
2203
2214
|
}));
|
|
2204
2215
|
if (d || (U = U.filter((e) => e.count !== 0 || H(e.bucket))), U.length === 0) return null;
|
|
2205
2216
|
let W = U.slice(0, I), ee = (t, n) => {
|
|
2206
2217
|
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range, N === "radio");
|
|
2207
2218
|
if (N === "radio") {
|
|
2208
|
-
let n = /* @__PURE__ */ f(
|
|
2219
|
+
let n = /* @__PURE__ */ f(O, {
|
|
2209
2220
|
id: `${e}-${t.range.min}-${t.range.max}`,
|
|
2210
2221
|
name: e,
|
|
2211
2222
|
value: t.label,
|
|
@@ -2215,9 +2226,9 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2215
2226
|
disabled: i
|
|
2216
2227
|
});
|
|
2217
2228
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
2218
|
-
className:
|
|
2229
|
+
className: dt.count,
|
|
2219
2230
|
children: [n, /* @__PURE__ */ f("span", {
|
|
2220
|
-
className:
|
|
2231
|
+
className: dt.countValue,
|
|
2221
2232
|
children: a
|
|
2222
2233
|
})]
|
|
2223
2234
|
}) : n;
|
|
@@ -2228,19 +2239,19 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2228
2239
|
onClick: o,
|
|
2229
2240
|
disabled: i,
|
|
2230
2241
|
size: "micro",
|
|
2231
|
-
className:
|
|
2242
|
+
className: dt.chip,
|
|
2232
2243
|
children: c === "grid" && a ? `${t.label} (${a})` : t.label
|
|
2233
2244
|
});
|
|
2234
2245
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
2235
|
-
className:
|
|
2246
|
+
className: dt.count,
|
|
2236
2247
|
children: [e, /* @__PURE__ */ f("span", {
|
|
2237
|
-
className:
|
|
2248
|
+
className: dt.countValue,
|
|
2238
2249
|
children: a
|
|
2239
2250
|
})]
|
|
2240
2251
|
}) : e;
|
|
2241
2252
|
}
|
|
2242
2253
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
2243
|
-
className:
|
|
2254
|
+
className: dt.count,
|
|
2244
2255
|
children: [/* @__PURE__ */ f(b, {
|
|
2245
2256
|
label: t.label,
|
|
2246
2257
|
score: "",
|
|
@@ -2248,7 +2259,7 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2248
2259
|
onChange: o,
|
|
2249
2260
|
disabled: i
|
|
2250
2261
|
}), /* @__PURE__ */ f("span", {
|
|
2251
|
-
className:
|
|
2262
|
+
className: dt.countValue,
|
|
2252
2263
|
children: a
|
|
2253
2264
|
})]
|
|
2254
2265
|
}) : /* @__PURE__ */ f(b, {
|
|
@@ -2263,9 +2274,9 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2263
2274
|
title: t,
|
|
2264
2275
|
collapsible: g,
|
|
2265
2276
|
collapsed: g ? _ : !1,
|
|
2266
|
-
className: h && F.length > 0 ?
|
|
2277
|
+
className: h && F.length > 0 ? dt.active : void 0,
|
|
2267
2278
|
children: /* @__PURE__ */ p("ul", {
|
|
2268
|
-
className: c === "grid" ?
|
|
2279
|
+
className: c === "grid" ? dt.grid : dt.list,
|
|
2269
2280
|
style: {
|
|
2270
2281
|
listStyle: "none",
|
|
2271
2282
|
padding: 0,
|
|
@@ -2279,34 +2290,34 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2279
2290
|
}) })]
|
|
2280
2291
|
})
|
|
2281
2292
|
});
|
|
2282
|
-
},
|
|
2293
|
+
}, mt = {
|
|
2283
2294
|
grid: "_grid_1xjna_2",
|
|
2284
2295
|
chip: "_chip_1xjna_21",
|
|
2285
2296
|
chipLabel: "_chipLabel_1xjna_32"
|
|
2286
|
-
},
|
|
2297
|
+
}, ht = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2287
2298
|
onClick: n,
|
|
2288
|
-
iconRight: /* @__PURE__ */ f(
|
|
2299
|
+
iconRight: /* @__PURE__ */ f(ie, {}),
|
|
2289
2300
|
variant: "primary",
|
|
2290
2301
|
size: "micro",
|
|
2291
|
-
className:
|
|
2302
|
+
className: mt.chip,
|
|
2292
2303
|
title: `${e}: ${t}`,
|
|
2293
2304
|
children: /* @__PURE__ */ p("span", {
|
|
2294
|
-
className:
|
|
2305
|
+
className: mt.chipLabel,
|
|
2295
2306
|
children: [
|
|
2296
2307
|
e,
|
|
2297
2308
|
": ",
|
|
2298
2309
|
t
|
|
2299
2310
|
]
|
|
2300
2311
|
})
|
|
2301
|
-
}) })),
|
|
2312
|
+
}) })), gt = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2302
2313
|
onClick: r,
|
|
2303
|
-
iconRight: /* @__PURE__ */ f(
|
|
2314
|
+
iconRight: /* @__PURE__ */ f(ie, {}),
|
|
2304
2315
|
variant: "primary",
|
|
2305
2316
|
size: "micro",
|
|
2306
|
-
className:
|
|
2317
|
+
className: mt.chip,
|
|
2307
2318
|
title: `${e}: ${t} β ${n}`,
|
|
2308
2319
|
children: /* @__PURE__ */ p("span", {
|
|
2309
|
-
className:
|
|
2320
|
+
className: mt.chipLabel,
|
|
2310
2321
|
children: [
|
|
2311
2322
|
e,
|
|
2312
2323
|
": ",
|
|
@@ -2315,15 +2326,15 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2315
2326
|
n
|
|
2316
2327
|
]
|
|
2317
2328
|
})
|
|
2318
|
-
}) })),
|
|
2329
|
+
}) })), _t = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2319
2330
|
onClick: n,
|
|
2320
|
-
iconRight: /* @__PURE__ */ f(
|
|
2331
|
+
iconRight: /* @__PURE__ */ f(ie, {}),
|
|
2321
2332
|
variant: "primary",
|
|
2322
2333
|
size: "micro",
|
|
2323
|
-
className:
|
|
2334
|
+
className: mt.chip,
|
|
2324
2335
|
title: `${e}: ${t}`,
|
|
2325
2336
|
children: /* @__PURE__ */ p("span", {
|
|
2326
|
-
className:
|
|
2337
|
+
className: mt.chipLabel,
|
|
2327
2338
|
children: [
|
|
2328
2339
|
e,
|
|
2329
2340
|
": ",
|
|
@@ -2331,8 +2342,8 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2331
2342
|
]
|
|
2332
2343
|
})
|
|
2333
2344
|
}) }));
|
|
2334
|
-
function
|
|
2335
|
-
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } =
|
|
2345
|
+
function vt() {
|
|
2346
|
+
let { state: { filters: e, rangeFilters: t, bucketFilters: n }, resetFilters: r, resetSingleFilter: i, resetRangeFilter: a, resetBucketFilter: o } = Y(), c = s(() => Object.entries(e).map(([e, t]) => t.map((t) => ({
|
|
2336
2347
|
field: e,
|
|
2337
2348
|
value: t
|
|
2338
2349
|
}))).flat(), [e]), l = s(() => Object.entries(t).map(([e, { min: t, max: n }]) => ({
|
|
@@ -2352,20 +2363,20 @@ function _t() {
|
|
|
2352
2363
|
collapsible: !1,
|
|
2353
2364
|
title: "Active filters",
|
|
2354
2365
|
children: /* @__PURE__ */ p("ul", {
|
|
2355
|
-
className:
|
|
2366
|
+
className: mt.grid,
|
|
2356
2367
|
children: [
|
|
2357
|
-
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
2368
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(ht, {
|
|
2358
2369
|
field: e,
|
|
2359
2370
|
value: t,
|
|
2360
2371
|
onReset: () => i(e, t)
|
|
2361
2372
|
}, `${e}-${t}`)),
|
|
2362
|
-
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
2373
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(gt, {
|
|
2363
2374
|
field: e,
|
|
2364
2375
|
min: t,
|
|
2365
2376
|
max: n,
|
|
2366
2377
|
onReset: () => a(e)
|
|
2367
2378
|
}, e)),
|
|
2368
|
-
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(
|
|
2379
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(_t, {
|
|
2369
2380
|
field: e,
|
|
2370
2381
|
label: n,
|
|
2371
2382
|
onReset: () => o(e, t)
|
|
@@ -2380,12 +2391,12 @@ function _t() {
|
|
|
2380
2391
|
})
|
|
2381
2392
|
}) : null;
|
|
2382
2393
|
}
|
|
2383
|
-
var
|
|
2394
|
+
var yt = {
|
|
2384
2395
|
select: "_select_nwf7i_1",
|
|
2385
2396
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
2386
|
-
},
|
|
2387
|
-
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } =
|
|
2388
|
-
if (d) return /* @__PURE__ */ f(
|
|
2397
|
+
}, bt = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
|
|
2398
|
+
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = Y();
|
|
2399
|
+
if (d) return /* @__PURE__ */ f(nt, {
|
|
2389
2400
|
title: "Sort by",
|
|
2390
2401
|
rows: o === "radio" ? 3 : 1,
|
|
2391
2402
|
collapsible: i,
|
|
@@ -2415,15 +2426,15 @@ var vt = {
|
|
|
2415
2426
|
title: "Sort by",
|
|
2416
2427
|
collapsible: i,
|
|
2417
2428
|
collapsed: i ? a : !1,
|
|
2418
|
-
children: o === "select" ? /* @__PURE__ */ f(
|
|
2429
|
+
children: o === "select" ? /* @__PURE__ */ f(A, {
|
|
2419
2430
|
value: p,
|
|
2420
2431
|
onValueChange: g,
|
|
2421
2432
|
options: h,
|
|
2422
2433
|
placeholder: "Select sort...",
|
|
2423
2434
|
"aria-label": "Sort by"
|
|
2424
2435
|
}) : /* @__PURE__ */ f("div", {
|
|
2425
|
-
className:
|
|
2426
|
-
children: h.map((e) => /* @__PURE__ */ f(
|
|
2436
|
+
className: yt.radioGroup,
|
|
2437
|
+
children: h.map((e) => /* @__PURE__ */ f(O, {
|
|
2427
2438
|
id: `sort-${e.value}`,
|
|
2428
2439
|
name: "sort-by",
|
|
2429
2440
|
value: e.value,
|
|
@@ -2433,7 +2444,7 @@ var vt = {
|
|
|
2433
2444
|
}, e.value))
|
|
2434
2445
|
})
|
|
2435
2446
|
});
|
|
2436
|
-
},
|
|
2447
|
+
}, xt = { list: "_list_1y4fk_1" }, St = {
|
|
2437
2448
|
coverageDepth: 500,
|
|
2438
2449
|
coverWholeQuery: !0,
|
|
2439
2450
|
coverWholeWords: !0,
|
|
@@ -2448,8 +2459,8 @@ var vt = {
|
|
|
2448
2459
|
truncateWordHitTolerance: 0,
|
|
2449
2460
|
truncationScore: 65024
|
|
2450
2461
|
};
|
|
2451
|
-
function
|
|
2452
|
-
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } =
|
|
2462
|
+
function Ct() {
|
|
2463
|
+
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } = Y(), [s, c] = l(!1), [u, m] = l(null);
|
|
2453
2464
|
o(() => {
|
|
2454
2465
|
let e = !0;
|
|
2455
2466
|
try {
|
|
@@ -2466,7 +2477,7 @@ function St() {
|
|
|
2466
2477
|
i,
|
|
2467
2478
|
a
|
|
2468
2479
|
]);
|
|
2469
|
-
let h = e.coverageSetup, g = (e) => h[e] !== void 0 && h[e] !== null, _ = (e) => h[e] ?? u?.coverageSetup?.[e] ??
|
|
2480
|
+
let h = e.coverageSetup, g = (e) => h[e] !== void 0 && h[e] !== null, _ = (e) => h[e] ?? u?.coverageSetup?.[e] ?? St[e], v = e.coverageDepth ?? u?.coverageDepth ?? St.coverageDepth, b = u ? "dataset" : "default", x = (e, t) => t ? e : `${e} (${b})`, S = e.coverageDepth !== void 0 || Object.keys(h).some((e) => g(e)), C = (e, n) => {
|
|
2470
2481
|
let r = parseInt(n, 10);
|
|
2471
2482
|
isNaN(r) || t({ [e]: r });
|
|
2472
2483
|
}, w = (e, n) => {
|
|
@@ -2487,7 +2498,7 @@ function St() {
|
|
|
2487
2498
|
collapsed: !0,
|
|
2488
2499
|
title: "Settings",
|
|
2489
2500
|
children: /* @__PURE__ */ p("ul", {
|
|
2490
|
-
className:
|
|
2501
|
+
className: xt.list,
|
|
2491
2502
|
children: [
|
|
2492
2503
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
2493
2504
|
label: "Max Results",
|
|
@@ -2513,7 +2524,7 @@ function St() {
|
|
|
2513
2524
|
}
|
|
2514
2525
|
}), /* @__PURE__ */ f("div", {
|
|
2515
2526
|
style: { padding: "10px 10px 20px 10px" },
|
|
2516
|
-
children: /* @__PURE__ */ f(
|
|
2527
|
+
children: /* @__PURE__ */ f(M, {
|
|
2517
2528
|
min: 0,
|
|
2518
2529
|
max: 65535,
|
|
2519
2530
|
step: 1,
|
|
@@ -2532,17 +2543,17 @@ function St() {
|
|
|
2532
2543
|
t({ placeholderText: e.target.value });
|
|
2533
2544
|
}
|
|
2534
2545
|
}) }),
|
|
2535
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2546
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2536
2547
|
label: "Show score",
|
|
2537
2548
|
checked: e.showScore,
|
|
2538
2549
|
onChange: (e) => w("showScore", e)
|
|
2539
2550
|
}) }),
|
|
2540
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2551
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2541
2552
|
label: "Enable Coverage",
|
|
2542
2553
|
checked: e.enableCoverage,
|
|
2543
2554
|
onChange: (e) => w("enableCoverage", e)
|
|
2544
2555
|
}) }),
|
|
2545
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2556
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2546
2557
|
label: "Remove Duplicates",
|
|
2547
2558
|
checked: e.removeDuplicates,
|
|
2548
2559
|
onChange: (e) => w("removeDuplicates", e)
|
|
@@ -2550,42 +2561,42 @@ function St() {
|
|
|
2550
2561
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2551
2562
|
variant: "ghost",
|
|
2552
2563
|
size: "micro",
|
|
2553
|
-
iconRight: f(s ?
|
|
2564
|
+
iconRight: f(s ? R : z, {}),
|
|
2554
2565
|
onClick: () => c((e) => !e),
|
|
2555
2566
|
children: s ? "Hide Coverage Setup" : "Show Coverage Setup"
|
|
2556
2567
|
}) }),
|
|
2557
2568
|
s && /* @__PURE__ */ p(d, { children: [
|
|
2558
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2569
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2559
2570
|
label: x("Cover Whole Query", g("coverWholeQuery")),
|
|
2560
2571
|
checked: _("coverWholeQuery"),
|
|
2561
2572
|
onChange: (e) => O("coverWholeQuery", e)
|
|
2562
2573
|
}) }),
|
|
2563
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2574
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2564
2575
|
label: x("Cover Whole Words", g("coverWholeWords")),
|
|
2565
2576
|
checked: _("coverWholeWords"),
|
|
2566
2577
|
onChange: (e) => O("coverWholeWords", e)
|
|
2567
2578
|
}) }),
|
|
2568
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2579
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2569
2580
|
label: x("Cover Fuzzy Words", g("coverFuzzyWords")),
|
|
2570
2581
|
checked: _("coverFuzzyWords"),
|
|
2571
2582
|
onChange: (e) => O("coverFuzzyWords", e)
|
|
2572
2583
|
}) }),
|
|
2573
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2584
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2574
2585
|
label: x("Cover Joined Words", g("coverJoinedWords")),
|
|
2575
2586
|
checked: _("coverJoinedWords"),
|
|
2576
2587
|
onChange: (e) => O("coverJoinedWords", e)
|
|
2577
2588
|
}) }),
|
|
2578
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2589
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2579
2590
|
label: x("Cover Prefix Suffix", g("coverPrefixSuffix")),
|
|
2580
2591
|
checked: _("coverPrefixSuffix"),
|
|
2581
2592
|
onChange: (e) => O("coverPrefixSuffix", e)
|
|
2582
2593
|
}) }),
|
|
2583
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2594
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2584
2595
|
label: x("Truncate", g("truncate")),
|
|
2585
2596
|
checked: _("truncate"),
|
|
2586
2597
|
onChange: (e) => O("truncate", e)
|
|
2587
2598
|
}) }),
|
|
2588
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2599
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2589
2600
|
label: x("Include Pattern Matches", g("includePatternMatches")),
|
|
2590
2601
|
checked: _("includePatternMatches"),
|
|
2591
2602
|
onChange: (e) => O("includePatternMatches", e)
|
|
@@ -2630,7 +2641,7 @@ function St() {
|
|
|
2630
2641
|
}
|
|
2631
2642
|
//#endregion
|
|
2632
2643
|
//#region src/components/SearchErrorBoundary.tsx
|
|
2633
|
-
var
|
|
2644
|
+
var wt = class extends t {
|
|
2634
2645
|
constructor(e) {
|
|
2635
2646
|
super(e), this.state = {
|
|
2636
2647
|
hasError: !1,
|
|
@@ -2712,8 +2723,8 @@ var Ct = class extends t {
|
|
|
2712
2723
|
};
|
|
2713
2724
|
//#endregion
|
|
2714
2725
|
//#region src/hooks/useVectorSearch.ts
|
|
2715
|
-
function
|
|
2716
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2726
|
+
function Tt(e, t) {
|
|
2727
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = Y(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2717
2728
|
return {
|
|
2718
2729
|
results: s,
|
|
2719
2730
|
isLoading: u,
|
|
@@ -2732,7 +2743,7 @@ function wt(e, t) {
|
|
|
2732
2743
|
headers: { "Content-Type": "application/json" },
|
|
2733
2744
|
body: JSON.stringify(l)
|
|
2734
2745
|
});
|
|
2735
|
-
if (!u.ok) throw await
|
|
2746
|
+
if (!u.ok) throw await q.fromResponse("VectorSearch", u);
|
|
2736
2747
|
let d = await u.json();
|
|
2737
2748
|
if (d.length === 0) {
|
|
2738
2749
|
c([]);
|
|
@@ -2743,7 +2754,7 @@ function wt(e, t) {
|
|
|
2743
2754
|
headers: { "Content-Type": "application/json" },
|
|
2744
2755
|
body: JSON.stringify(f)
|
|
2745
2756
|
});
|
|
2746
|
-
if (!p.ok) throw await
|
|
2757
|
+
if (!p.ok) throw await q.fromResponse("GetJson", p);
|
|
2747
2758
|
c((await p.json()).map((e, t) => ({
|
|
2748
2759
|
document: e,
|
|
2749
2760
|
documentKey: f[t],
|
|
@@ -2768,8 +2779,8 @@ function wt(e, t) {
|
|
|
2768
2779
|
}
|
|
2769
2780
|
//#endregion
|
|
2770
2781
|
//#region src/hooks/useHybridSearch.ts
|
|
2771
|
-
function
|
|
2772
|
-
let { url: n, team: r, dataset: a, authenticatedFetch: o } =
|
|
2782
|
+
function Et(e, t) {
|
|
2783
|
+
let { url: n, team: r, dataset: a, authenticatedFetch: o } = Y(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2773
2784
|
return {
|
|
2774
2785
|
results: s,
|
|
2775
2786
|
isLoading: u,
|
|
@@ -2790,7 +2801,7 @@ function Tt(e, t) {
|
|
|
2790
2801
|
headers: { "Content-Type": "application/json" },
|
|
2791
2802
|
body: JSON.stringify(l)
|
|
2792
2803
|
});
|
|
2793
|
-
if (!u.ok) throw await
|
|
2804
|
+
if (!u.ok) throw await q.fromResponse("HybridSearch", u);
|
|
2794
2805
|
let d = await u.json();
|
|
2795
2806
|
if (d.length === 0) {
|
|
2796
2807
|
c([]);
|
|
@@ -2801,7 +2812,7 @@ function Tt(e, t) {
|
|
|
2801
2812
|
headers: { "Content-Type": "application/json" },
|
|
2802
2813
|
body: JSON.stringify(f)
|
|
2803
2814
|
});
|
|
2804
|
-
if (!p.ok) throw await
|
|
2815
|
+
if (!p.ok) throw await q.fromResponse("GetJson", p);
|
|
2805
2816
|
c((await p.json()).map((e, t) => ({
|
|
2806
2817
|
document: e,
|
|
2807
2818
|
documentKey: f[t],
|
|
@@ -2828,14 +2839,14 @@ function Tt(e, t) {
|
|
|
2828
2839
|
}
|
|
2829
2840
|
//#endregion
|
|
2830
2841
|
//#region src/hooks/useFilterSuggestion.ts
|
|
2831
|
-
function
|
|
2842
|
+
function Dt(e) {
|
|
2832
2843
|
let t = e.trim().toLowerCase();
|
|
2833
2844
|
return t === "true" || t === "false" || t !== "" && !Number.isNaN(Number(t));
|
|
2834
2845
|
}
|
|
2835
|
-
function
|
|
2846
|
+
function Ot(e, t) {
|
|
2836
2847
|
if (!t) return null;
|
|
2837
2848
|
let n = [];
|
|
2838
|
-
for (let [e, r] of Object.entries(t)) for (let t of r ?? []) t?.key && t.key.trim().length >= 2 && !
|
|
2849
|
+
for (let [e, r] of Object.entries(t)) for (let t of r ?? []) t?.key && t.key.trim().length >= 2 && !Dt(t.key) && n.push({
|
|
2839
2850
|
field: e,
|
|
2840
2851
|
value: t.key
|
|
2841
2852
|
});
|
|
@@ -2854,14 +2865,14 @@ function Dt(e, t) {
|
|
|
2854
2865
|
sort: null
|
|
2855
2866
|
};
|
|
2856
2867
|
}
|
|
2857
|
-
function
|
|
2858
|
-
let t =
|
|
2868
|
+
function kt(e = {}) {
|
|
2869
|
+
let t = Y(), { url: n, team: r, dataset: a, authenticatedFetch: s, setQuery: u, toggleFilter: d, setRangeFilter: f, setSort: p } = t, { auto: m } = e, h = c(t);
|
|
2859
2870
|
h.current = t;
|
|
2860
2871
|
let [g, _] = l(null), [v, y] = l(""), [b, x] = l(!1), S = c(0), C = i(async (e) => {
|
|
2861
2872
|
let t = ++S.current;
|
|
2862
2873
|
x(!0);
|
|
2863
2874
|
try {
|
|
2864
|
-
let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${
|
|
2875
|
+
let i = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${ke(h.current)}`, {
|
|
2865
2876
|
method: "POST",
|
|
2866
2877
|
headers: { "Content-Type": "application/json" },
|
|
2867
2878
|
body: JSON.stringify({ text: e })
|
|
@@ -2900,7 +2911,7 @@ function Ot(e = {}) {
|
|
|
2900
2911
|
return o(() => {
|
|
2901
2912
|
if (!A || !j || P || E.current.has(j)) return;
|
|
2902
2913
|
E.current.add(j);
|
|
2903
|
-
let e =
|
|
2914
|
+
let e = Ot(j, N);
|
|
2904
2915
|
if (e && (E.current.add(e.text), w(e), O(j)), k !== "model") return;
|
|
2905
2916
|
let t = e ? e.text : j;
|
|
2906
2917
|
if (!t) return;
|
|
@@ -2909,7 +2920,7 @@ function Ot(e = {}) {
|
|
|
2909
2920
|
let o = ++S.current;
|
|
2910
2921
|
x(!0);
|
|
2911
2922
|
try {
|
|
2912
|
-
let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${
|
|
2923
|
+
let c = await s(`${n}/api/teams/${r}/datasets/${a}/search-or-ask/filters${ke(h.current)}`, {
|
|
2913
2924
|
method: "POST",
|
|
2914
2925
|
headers: { "Content-Type": "application/json" },
|
|
2915
2926
|
body: JSON.stringify({ text: t })
|
|
@@ -2948,17 +2959,17 @@ function Ot(e = {}) {
|
|
|
2948
2959
|
}
|
|
2949
2960
|
//#endregion
|
|
2950
2961
|
//#region src/hooks/useAsk.ts
|
|
2951
|
-
var
|
|
2962
|
+
var At = {
|
|
2952
2963
|
question: "",
|
|
2953
2964
|
status: "idle",
|
|
2954
2965
|
answer: "",
|
|
2955
2966
|
sources: [],
|
|
2956
2967
|
steps: []
|
|
2957
2968
|
};
|
|
2958
|
-
function
|
|
2959
|
-
let e =
|
|
2969
|
+
function jt() {
|
|
2970
|
+
let e = Y(), { url: t, team: n, dataset: r, authenticatedFetch: a } = e, s = c(e);
|
|
2960
2971
|
s.current = e;
|
|
2961
|
-
let [u, d] = l(
|
|
2972
|
+
let [u, d] = l(At), f = c(u);
|
|
2962
2973
|
f.current = u;
|
|
2963
2974
|
let p = c(null), m = i(async (e, i = []) => {
|
|
2964
2975
|
let o = e.trim();
|
|
@@ -2990,7 +3001,7 @@ function At() {
|
|
|
2990
3001
|
}
|
|
2991
3002
|
}));
|
|
2992
3003
|
try {
|
|
2993
|
-
let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${
|
|
3004
|
+
let e = await a(`${t}/api/teams/${n}/datasets/${r}/search-or-ask/ask${ke(s.current)}`, {
|
|
2994
3005
|
method: "POST",
|
|
2995
3006
|
headers: {
|
|
2996
3007
|
"Content-Type": "application/json",
|
|
@@ -3020,7 +3031,7 @@ function At() {
|
|
|
3020
3031
|
h(t.code ?? `http${e.status}`, t.detail ?? "The question could not be asked.");
|
|
3021
3032
|
return;
|
|
3022
3033
|
}
|
|
3023
|
-
for await (let { event: t, data: n } of
|
|
3034
|
+
for await (let { event: t, data: n } of Oe(e.body)) switch (t) {
|
|
3024
3035
|
case "status": {
|
|
3025
3036
|
let e = n.step;
|
|
3026
3037
|
e && d((t) => ({
|
|
@@ -3096,7 +3107,7 @@ function At() {
|
|
|
3096
3107
|
r,
|
|
3097
3108
|
a
|
|
3098
3109
|
]), g = i(() => p.current?.abort(), []), _ = i(() => {
|
|
3099
|
-
p.current?.abort(), d(
|
|
3110
|
+
p.current?.abort(), d(At);
|
|
3100
3111
|
}, []);
|
|
3101
3112
|
return o(() => () => p.current?.abort(), []), {
|
|
3102
3113
|
...u,
|
|
@@ -3123,18 +3134,18 @@ var $ = {
|
|
|
3123
3134
|
searchedLabel: "_searchedLabel_gjc13_23",
|
|
3124
3135
|
steps: "_steps_gjc13_26",
|
|
3125
3136
|
stepDone: "_stepDone_gjc13_27"
|
|
3126
|
-
},
|
|
3127
|
-
function
|
|
3137
|
+
}, Mt = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*|_[^_\n]+_)|(\[[^\]\n]+\]\(https?:\/\/[^)\s]+\))|(\[\d+\])/g;
|
|
3138
|
+
function Nt(t, n, r) {
|
|
3128
3139
|
let i = [], a = 0, o = 0;
|
|
3129
|
-
for (let s of t.matchAll(
|
|
3140
|
+
for (let s of t.matchAll(Mt)) {
|
|
3130
3141
|
s.index > a && i.push(t.slice(a, s.index));
|
|
3131
3142
|
let c = `${r}-${o++}`, [l, u, d, p, m, h] = s;
|
|
3132
3143
|
if (u) i.push(/* @__PURE__ */ f("code", {
|
|
3133
3144
|
className: $.inlineCode,
|
|
3134
3145
|
children: u.slice(1, -1)
|
|
3135
3146
|
}, c));
|
|
3136
|
-
else if (d) i.push(/* @__PURE__ */ f("strong", { children:
|
|
3137
|
-
else if (p) i.push(/* @__PURE__ */ f("em", { children:
|
|
3147
|
+
else if (d) i.push(/* @__PURE__ */ f("strong", { children: Nt(d.slice(2, -2), n, c) }, c));
|
|
3148
|
+
else if (p) i.push(/* @__PURE__ */ f("em", { children: Nt(p.slice(1, -1), n, c) }, c));
|
|
3138
3149
|
else if (m) {
|
|
3139
3150
|
let [, e, t] = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(m);
|
|
3140
3151
|
i.push(/* @__PURE__ */ f("a", {
|
|
@@ -3148,7 +3159,7 @@ function Mt(t, n, r) {
|
|
|
3148
3159
|
}
|
|
3149
3160
|
return a < t.length && i.push(t.slice(a)), i;
|
|
3150
3161
|
}
|
|
3151
|
-
function
|
|
3162
|
+
function Pt(e) {
|
|
3152
3163
|
let t = e.replace(/\r\n/g, "\n").split("\n"), n = [], r = [], i = () => {
|
|
3153
3164
|
r.length && (n.push({
|
|
3154
3165
|
kind: "paragraph",
|
|
@@ -3201,8 +3212,8 @@ function Nt(e) {
|
|
|
3201
3212
|
}
|
|
3202
3213
|
return i(), n;
|
|
3203
3214
|
}
|
|
3204
|
-
function
|
|
3205
|
-
return
|
|
3215
|
+
function Ft(e, t) {
|
|
3216
|
+
return Pt(e).map((e, n) => {
|
|
3206
3217
|
let r = `b${n}`;
|
|
3207
3218
|
switch (e.kind) {
|
|
3208
3219
|
case "code": return /* @__PURE__ */ f("pre", {
|
|
@@ -3212,28 +3223,28 @@ function Pt(e, t) {
|
|
|
3212
3223
|
}, r);
|
|
3213
3224
|
case "heading": return /* @__PURE__ */ f("p", {
|
|
3214
3225
|
className: $.heading,
|
|
3215
|
-
children:
|
|
3226
|
+
children: Nt(e.text, t, r)
|
|
3216
3227
|
}, r);
|
|
3217
3228
|
case "list": return /* @__PURE__ */ f(e.ordered ? "ol" : "ul", {
|
|
3218
3229
|
className: $.list,
|
|
3219
|
-
children: e.items.map((e, n) => /* @__PURE__ */ f("li", { children:
|
|
3230
|
+
children: e.items.map((e, n) => /* @__PURE__ */ f("li", { children: Nt(e, t, `${r}-${n}`) }, n))
|
|
3220
3231
|
}, r);
|
|
3221
3232
|
default: return /* @__PURE__ */ f("p", {
|
|
3222
3233
|
className: $.paragraph,
|
|
3223
|
-
children:
|
|
3234
|
+
children: Nt(e.text, t, r)
|
|
3224
3235
|
}, r);
|
|
3225
3236
|
}
|
|
3226
3237
|
});
|
|
3227
3238
|
}
|
|
3228
3239
|
//#endregion
|
|
3229
3240
|
//#region src/components/AskPanel.tsx
|
|
3230
|
-
var
|
|
3231
|
-
function
|
|
3241
|
+
var It = /\[(\d+)\]/g;
|
|
3242
|
+
function Lt(e) {
|
|
3232
3243
|
let t = e.field.split(".")[0];
|
|
3233
3244
|
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;
|
|
3234
3245
|
}
|
|
3235
|
-
var
|
|
3236
|
-
let E =
|
|
3246
|
+
var Rt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer", renderAnswer: i = Ft, onFollowUp: a, onStatusChange: s, onFilters: u, filterLabel: d = Lt, fill: b = !1, className: T = "" }) => {
|
|
3247
|
+
let E = jt(), { ask: D, reset: O, stop: k, status: A, openSource: j } = E, [M, P] = l(!1), [F, L] = l([]), [R, z] = l(""), B = c([]), V = c(null), H = c(null), U = c(!0);
|
|
3237
3248
|
o(() => {
|
|
3238
3249
|
L([]), B.current = [], e?.trim() ? D(e) : O();
|
|
3239
3250
|
}, [
|
|
@@ -3254,7 +3265,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3254
3265
|
E.answer,
|
|
3255
3266
|
E.steps.length,
|
|
3256
3267
|
A,
|
|
3257
|
-
|
|
3268
|
+
F.length
|
|
3258
3269
|
]);
|
|
3259
3270
|
let ee = () => {
|
|
3260
3271
|
let e = H.current;
|
|
@@ -3287,29 +3298,29 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3287
3298
|
})
|
|
3288
3299
|
]
|
|
3289
3300
|
});
|
|
3290
|
-
if (A === "idle" &&
|
|
3301
|
+
if (A === "idle" && F.length === 0) return null;
|
|
3291
3302
|
let K = (e, t) => (r) => {
|
|
3292
3303
|
r.preventDefault(), j(e, t), n?.(e);
|
|
3293
|
-
},
|
|
3304
|
+
}, ne = (e, t) => (r) => {
|
|
3294
3305
|
let i = e.find((e) => e.n === r);
|
|
3295
3306
|
return /* @__PURE__ */ f(C, {
|
|
3296
3307
|
n: r,
|
|
3297
3308
|
title: i?.title,
|
|
3298
3309
|
onClick: i && n ? K(i, t) : void 0
|
|
3299
3310
|
});
|
|
3300
|
-
},
|
|
3301
|
-
let r = new Set([...e.matchAll(
|
|
3311
|
+
}, re = (e, t, n) => {
|
|
3312
|
+
let r = new Set([...e.matchAll(It)].map((e) => Number(e[1])));
|
|
3302
3313
|
return n && r.size > 0 ? t.filter((e) => r.has(e.n)) : t.slice(0, 3);
|
|
3303
|
-
},
|
|
3304
|
-
let a =
|
|
3314
|
+
}, ie = (e, t, r, i) => {
|
|
3315
|
+
let a = re(e, t, r);
|
|
3305
3316
|
return a.length > 0 && /* @__PURE__ */ f(S, { items: a.map((e) => ({
|
|
3306
3317
|
n: e.n,
|
|
3307
3318
|
title: e.title,
|
|
3308
3319
|
onClick: n ? K(e, i) : void 0
|
|
3309
3320
|
})) });
|
|
3310
|
-
},
|
|
3311
|
-
navigator.clipboard?.writeText(E.answer.replace(
|
|
3312
|
-
},
|
|
3321
|
+
}, q = () => {
|
|
3322
|
+
navigator.clipboard?.writeText(E.answer.replace(It, "")).catch(() => {}), P(!0), setTimeout(() => P(!1), 2e3);
|
|
3323
|
+
}, J = (e) => {
|
|
3313
3324
|
if (!(E.busy || !e.trim())) {
|
|
3314
3325
|
if (A === "answered" && E.answer) {
|
|
3315
3326
|
let e = {
|
|
@@ -3331,7 +3342,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3331
3342
|
}
|
|
3332
3343
|
z(""), D(e, B.current);
|
|
3333
3344
|
}
|
|
3334
|
-
},
|
|
3345
|
+
}, ae = t ? () => V.current?.focus() : a;
|
|
3335
3346
|
return /* @__PURE__ */ p("div", {
|
|
3336
3347
|
className: `${$.panel} ${b ? $.fill : ""} ${T}`,
|
|
3337
3348
|
"aria-live": "polite",
|
|
@@ -3340,38 +3351,38 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3340
3351
|
ref: H,
|
|
3341
3352
|
className: $.thread,
|
|
3342
3353
|
onScroll: b ? ee : void 0,
|
|
3343
|
-
children: [
|
|
3354
|
+
children: [F.map((e, t) => /* @__PURE__ */ p("div", {
|
|
3344
3355
|
className: $.turn,
|
|
3345
|
-
children: [/* @__PURE__ */ f(
|
|
3356
|
+
children: [/* @__PURE__ */ f(I, { children: e.question }), /* @__PURE__ */ p(v, {
|
|
3346
3357
|
label: r,
|
|
3347
3358
|
children: [
|
|
3348
3359
|
G(e.filters),
|
|
3349
3360
|
/* @__PURE__ */ f("div", {
|
|
3350
3361
|
className: $.answer,
|
|
3351
|
-
children: i(e.answer,
|
|
3362
|
+
children: i(e.answer, ne(e.sources, e.askId))
|
|
3352
3363
|
}),
|
|
3353
|
-
|
|
3364
|
+
ie(e.answer, e.sources, !0, e.askId)
|
|
3354
3365
|
]
|
|
3355
3366
|
})]
|
|
3356
3367
|
}, t)), A !== "idle" && /* @__PURE__ */ p("div", {
|
|
3357
3368
|
className: $.turn,
|
|
3358
|
-
children: [/* @__PURE__ */ f(
|
|
3369
|
+
children: [/* @__PURE__ */ f(I, { children: E.question }), /* @__PURE__ */ p(v, {
|
|
3359
3370
|
label: r,
|
|
3360
3371
|
children: [
|
|
3361
3372
|
G(E.filters),
|
|
3362
3373
|
E.answer && /* @__PURE__ */ f("div", {
|
|
3363
3374
|
className: $.answer,
|
|
3364
|
-
children: i(E.answer,
|
|
3375
|
+
children: i(E.answer, ne(E.sources))
|
|
3365
3376
|
}),
|
|
3366
3377
|
A === "searching" && E.steps.length > 0 && /* @__PURE__ */ p("div", {
|
|
3367
3378
|
className: $.steps,
|
|
3368
3379
|
children: [E.steps.slice(0, -1).map((e, t) => /* @__PURE__ */ f("span", {
|
|
3369
3380
|
className: $.stepDone,
|
|
3370
3381
|
children: e
|
|
3371
|
-
}, t)), /* @__PURE__ */ p(
|
|
3382
|
+
}, t)), /* @__PURE__ */ p(N, { children: [E.steps[E.steps.length - 1], "β¦"] })]
|
|
3372
3383
|
}),
|
|
3373
|
-
A === "searching" && E.steps.length === 0 && /* @__PURE__ */ f(
|
|
3374
|
-
A === "writing" && /* @__PURE__ */ f(
|
|
3384
|
+
A === "searching" && E.steps.length === 0 && /* @__PURE__ */ f(N, { children: "Searchingβ¦" }),
|
|
3385
|
+
A === "writing" && /* @__PURE__ */ f(N, {
|
|
3375
3386
|
spinner: "grow",
|
|
3376
3387
|
children: "Writingβ¦"
|
|
3377
3388
|
}),
|
|
@@ -3402,11 +3413,11 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3402
3413
|
". Search still works in the meantime."
|
|
3403
3414
|
] })]
|
|
3404
3415
|
}),
|
|
3405
|
-
A !== "error" && A !== "limited" &&
|
|
3416
|
+
A !== "error" && A !== "limited" && ie(E.answer, E.sources, A === "answered"),
|
|
3406
3417
|
A === "answered" && /* @__PURE__ */ f(_, {
|
|
3407
|
-
onCopy:
|
|
3408
|
-
copied:
|
|
3409
|
-
onFollowUp:
|
|
3418
|
+
onCopy: q,
|
|
3419
|
+
copied: M,
|
|
3420
|
+
onFollowUp: ae
|
|
3410
3421
|
})
|
|
3411
3422
|
]
|
|
3412
3423
|
})]
|
|
@@ -3415,7 +3426,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3415
3426
|
ref: V,
|
|
3416
3427
|
value: R,
|
|
3417
3428
|
onChange: z,
|
|
3418
|
-
onSend:
|
|
3429
|
+
onSend: J,
|
|
3419
3430
|
onStop: k,
|
|
3420
3431
|
streaming: E.busy,
|
|
3421
3432
|
placeholder: "Ask a follow-upβ¦",
|
|
@@ -3424,4 +3435,4 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3424
3435
|
});
|
|
3425
3436
|
};
|
|
3426
3437
|
//#endregion
|
|
3427
|
-
export {
|
|
3438
|
+
export { vt as ActiveFiltersPanel, Rt as AskPanel, pt as BucketFilterPanel, Ce as DEFAULT_CUT, _e as DEFAULT_THRESHOLDS, nt as FilterPanelSkeleton, q as IndxApiError, ut as RangeFilterPanel, Te as SCORE_SCALE, we as STRICT_COVERAGE, he as SearchContext, wt as SearchErrorBoundary, ze as SearchInput, ge as SearchProvider, Ge as SearchResult, $e as SearchResultRow, Ze as SearchResults, He as SearchResultsMessage, Je as SearchResultsSkeleton, Ct as SearchSettingsPanel, J as SearchSetupError, bt as SortByPanel, at as ValueFilterPanel, ae as describeSearchError, be as isIdentifier, Ot as localFilters, Se as nextOffer, Fe as stripAskPhrases, xe as triggers, jt as useAsk, kt as useFilterSuggestion, Et as useHybridSearch, Y as useSearch, Y as useSearchContext, Le as useSearchOrAsk, Tt as useVectorSearch, Ee as visibleResults };
|