@indxsearch/intrface 3.13.0 → 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 +38 -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 +478 -465
- package/dist/intrface.css +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -2,8 +2,8 @@ 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
8
|
var q = class e extends Error {
|
|
9
9
|
status;
|
|
@@ -277,8 +277,10 @@ function ue(e, t) {
|
|
|
277
277
|
};
|
|
278
278
|
return r.cancel = () => clearTimeout(n), r;
|
|
279
279
|
}
|
|
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,
|
|
281
|
-
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("");
|
|
282
284
|
o(() => {
|
|
283
285
|
r.isFetchingInitial || t((e) => ({
|
|
284
286
|
...e,
|
|
@@ -300,13 +302,13 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
300
302
|
r.sortableFields,
|
|
301
303
|
t
|
|
302
304
|
]);
|
|
303
|
-
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 }) => {
|
|
304
306
|
if (!r.token) return;
|
|
305
|
-
let o = ++
|
|
307
|
+
let o = ++S.current;
|
|
306
308
|
if (t((e) => ({
|
|
307
309
|
...e,
|
|
308
310
|
isLoading: !0
|
|
309
|
-
})),
|
|
311
|
+
})), b.trim() === "") {
|
|
310
312
|
if (!d) return;
|
|
311
313
|
i = !0;
|
|
312
314
|
}
|
|
@@ -317,115 +319,117 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
317
319
|
}, e.rangeFilters, a, s, u, n, e.valueMatch, {
|
|
318
320
|
...e.bucketFilters,
|
|
319
321
|
[t]: []
|
|
320
|
-
}, e.fieldTypes))]), m = d ||
|
|
321
|
-
text:
|
|
322
|
-
enableCoverage:
|
|
323
|
-
removeDuplicates:
|
|
324
|
-
coverageDepth:
|
|
325
|
-
coverageSetup:
|
|
326
|
-
},
|
|
327
|
-
...
|
|
328
|
-
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,
|
|
329
331
|
enableFacets: i,
|
|
330
332
|
...l ? { filter: l } : {},
|
|
331
|
-
...
|
|
332
|
-
...
|
|
333
|
+
...L ? { sortBy: L } : {},
|
|
334
|
+
...R === void 0 ? {} : { sortAscending: R }
|
|
333
335
|
};
|
|
334
|
-
p && console.log("[performSearch] request body:", JSON.stringify(
|
|
335
|
-
let
|
|
336
|
-
g &&
|
|
337
|
-
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}`, {
|
|
338
342
|
method: "POST",
|
|
339
343
|
headers: { "Content-Type": "application/json" },
|
|
340
344
|
body: JSON.stringify(e)
|
|
341
|
-
}), [
|
|
342
|
-
...
|
|
345
|
+
}), [V, ...H] = await Promise.all([B(C), ...f.map((e) => B({
|
|
346
|
+
...y,
|
|
343
347
|
maxNumberOfRecordsToReturn: 0,
|
|
344
348
|
enableFacets: !0,
|
|
345
349
|
...e ? { filter: e } : {}
|
|
346
350
|
}))]);
|
|
347
|
-
if (!
|
|
348
|
-
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 = {};
|
|
349
353
|
for (let e = 0; e < c.length; e++) {
|
|
350
354
|
let t = c[e];
|
|
351
|
-
if (!
|
|
352
|
-
let n = await
|
|
353
|
-
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]);
|
|
354
358
|
}
|
|
355
|
-
let
|
|
356
|
-
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) {
|
|
357
361
|
let e = await n(`${a}/api/teams/${s}/datasets/${u}/documents/lookup`, {
|
|
358
362
|
method: "POST",
|
|
359
363
|
headers: { "Content-Type": "application/json" },
|
|
360
|
-
body: JSON.stringify(
|
|
364
|
+
body: JSON.stringify(K)
|
|
361
365
|
});
|
|
362
366
|
if (!e.ok) throw await q.fromResponse("Document lookup", e);
|
|
363
|
-
|
|
367
|
+
re = (await e.json()).map((e, t) => ({
|
|
364
368
|
document: e,
|
|
365
|
-
documentKey:
|
|
366
|
-
score:
|
|
369
|
+
documentKey: K[t],
|
|
370
|
+
score: ne[t]
|
|
367
371
|
}));
|
|
368
372
|
}
|
|
369
|
-
let
|
|
370
|
-
if (i &&
|
|
371
|
-
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) {
|
|
372
376
|
let n = t.map((e) => Number(e.key)).filter((e) => !isNaN(e));
|
|
373
|
-
n.length > 0 && (
|
|
377
|
+
n.length > 0 && (ie[e] = {
|
|
374
378
|
min: Math.min(...n),
|
|
375
379
|
max: Math.max(...n)
|
|
376
380
|
});
|
|
377
381
|
}
|
|
378
382
|
}
|
|
379
|
-
if (o !==
|
|
380
|
-
let
|
|
381
|
-
if (
|
|
383
|
+
if (o !== S.current) return;
|
|
384
|
+
let J = b !== D, ae = b !== k, oe = e.facetStats ?? {};
|
|
385
|
+
if (J ? (oe = {
|
|
382
386
|
...r.initialFacetStats,
|
|
383
|
-
...
|
|
384
|
-
},
|
|
385
|
-
...
|
|
386
|
-
...
|
|
387
|
-
},
|
|
387
|
+
...ie
|
|
388
|
+
}, E(oe), O(b)) : oe = {
|
|
389
|
+
...T,
|
|
390
|
+
...ie
|
|
391
|
+
}, ae && i) {
|
|
388
392
|
let n = { ...e.rangeBounds };
|
|
389
|
-
for (let [e, t] of Object.entries(
|
|
393
|
+
for (let [e, t] of Object.entries(ie)) n[e] = t;
|
|
390
394
|
t((e) => ({
|
|
391
395
|
...e,
|
|
392
396
|
rangeBounds: n
|
|
393
|
-
})),
|
|
397
|
+
})), A(b);
|
|
394
398
|
}
|
|
395
|
-
let
|
|
396
|
-
...
|
|
397
|
-
...
|
|
398
|
-
} :
|
|
399
|
-
if (i && (!
|
|
400
|
-
|
|
401
|
-
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) => ({
|
|
402
406
|
key: e,
|
|
403
407
|
value: null
|
|
404
408
|
}));
|
|
405
409
|
}
|
|
406
|
-
let
|
|
407
|
-
let t =
|
|
408
|
-
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;
|
|
409
413
|
}).map((e, t) => ({
|
|
410
414
|
...e,
|
|
411
415
|
position: t + 1
|
|
412
416
|
}));
|
|
413
417
|
t((e) => ({
|
|
414
418
|
...e,
|
|
415
|
-
results:
|
|
419
|
+
results: ce,
|
|
416
420
|
error: void 0,
|
|
417
421
|
errorInfo: void 0,
|
|
418
422
|
resultsSuppressed: !m,
|
|
419
423
|
...i ? {
|
|
420
|
-
facets:
|
|
421
|
-
facetStats:
|
|
424
|
+
facets: se,
|
|
425
|
+
facetStats: oe
|
|
422
426
|
} : {},
|
|
423
427
|
isLoading: !1,
|
|
424
|
-
truncationIndex:
|
|
425
|
-
queryId:
|
|
428
|
+
truncationIndex: ee,
|
|
429
|
+
queryId: W
|
|
426
430
|
}));
|
|
427
431
|
} catch (e) {
|
|
428
|
-
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;
|
|
429
433
|
t((t) => ({
|
|
430
434
|
...t,
|
|
431
435
|
results: null,
|
|
@@ -439,27 +443,27 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
439
443
|
}));
|
|
440
444
|
}
|
|
441
445
|
}, [
|
|
442
|
-
|
|
446
|
+
b,
|
|
443
447
|
e.filters,
|
|
444
448
|
e.valueMatch,
|
|
445
449
|
e.rangeFilters,
|
|
446
450
|
e.bucketFilters,
|
|
447
451
|
e.facetStats,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
k,
|
|
451
|
-
A,
|
|
452
|
+
L,
|
|
453
|
+
R,
|
|
452
454
|
j,
|
|
453
455
|
M,
|
|
454
|
-
P,
|
|
455
456
|
N,
|
|
457
|
+
P,
|
|
458
|
+
I,
|
|
459
|
+
F,
|
|
456
460
|
n,
|
|
457
461
|
r.initialFacetStats,
|
|
458
462
|
r.initialFacetKeys,
|
|
459
463
|
r.token,
|
|
460
|
-
C,
|
|
461
464
|
T,
|
|
462
465
|
D,
|
|
466
|
+
k,
|
|
463
467
|
e.rangeBounds,
|
|
464
468
|
a,
|
|
465
469
|
s,
|
|
@@ -469,26 +473,27 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
469
473
|
t,
|
|
470
474
|
h,
|
|
471
475
|
g,
|
|
472
|
-
_
|
|
476
|
+
_,
|
|
477
|
+
v
|
|
473
478
|
]);
|
|
474
479
|
o(() => {
|
|
475
|
-
|
|
476
|
-
}, [
|
|
477
|
-
let
|
|
478
|
-
o(() => (
|
|
479
|
-
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 });
|
|
480
485
|
}, e.facetDebounceDelayMillis ?? 500), () => {
|
|
481
|
-
|
|
486
|
+
B.current?.cancel();
|
|
482
487
|
}), [e.facetDebounceDelayMillis]), o(() => {
|
|
483
|
-
!r.isFetchingInitial && r.token && !
|
|
488
|
+
!r.isFetchingInitial && r.token && !w.current && (d && C.current?.({ enableFacets: f }), w.current = !0);
|
|
484
489
|
}, [
|
|
485
490
|
r.isFetchingInitial,
|
|
486
491
|
r.token,
|
|
487
492
|
d,
|
|
488
493
|
f
|
|
489
494
|
]), o(() => {
|
|
490
|
-
if (!r.token || !
|
|
491
|
-
let n =
|
|
495
|
+
if (!r.token || !w.current) return;
|
|
496
|
+
let n = b.trim(), i = n === "" && d;
|
|
492
497
|
if (n === "" && !d) {
|
|
493
498
|
e.resultsSuppressed || t((e) => ({
|
|
494
499
|
...e,
|
|
@@ -496,63 +501,67 @@ function de({ state: e, setState: t, authenticatedFetch: n, auth: r, url: a, tea
|
|
|
496
501
|
}));
|
|
497
502
|
return;
|
|
498
503
|
}
|
|
499
|
-
return i ? (
|
|
500
|
-
|
|
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();
|
|
501
506
|
};
|
|
502
507
|
}, [
|
|
503
|
-
|
|
508
|
+
b,
|
|
504
509
|
d,
|
|
505
510
|
f
|
|
506
511
|
]), o(() => {
|
|
507
|
-
if (!
|
|
508
|
-
let t =
|
|
509
|
-
!d && t === "" ||
|
|
512
|
+
if (!w.current || !r.token || e.filterRevision === 0) return;
|
|
513
|
+
let t = b.trim();
|
|
514
|
+
!d && t === "" || C.current?.({ enableFacets: f });
|
|
510
515
|
}, [e.filterRevision]), o(() => {
|
|
511
|
-
if (!
|
|
512
|
-
let e =
|
|
513
|
-
!d && e === "" ||
|
|
514
|
-
}, [
|
|
515
|
-
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);
|
|
516
521
|
return o(() => {
|
|
517
|
-
if (
|
|
518
|
-
|
|
522
|
+
if (V.current) {
|
|
523
|
+
V.current = !1;
|
|
519
524
|
return;
|
|
520
525
|
}
|
|
521
|
-
if (
|
|
526
|
+
if (H.current !== b || !w.current || !r.token) return;
|
|
522
527
|
if (m.current) {
|
|
523
|
-
m.current = !1,
|
|
528
|
+
m.current = !1, C.current?.({ enableFacets: !1 });
|
|
524
529
|
return;
|
|
525
530
|
}
|
|
526
|
-
let e =
|
|
527
|
-
!d && e === "" ||
|
|
531
|
+
let e = b.trim();
|
|
532
|
+
!d && e === "" || C.current?.({ enableFacets: f });
|
|
528
533
|
}, [
|
|
529
|
-
k,
|
|
530
|
-
A,
|
|
531
534
|
j,
|
|
532
535
|
M,
|
|
536
|
+
N,
|
|
533
537
|
P,
|
|
534
|
-
|
|
538
|
+
I,
|
|
539
|
+
F
|
|
535
540
|
]), o(() => {
|
|
536
|
-
|
|
537
|
-
}, [
|
|
538
|
-
|
|
541
|
+
H.current = b;
|
|
542
|
+
}, [b]), { retrySearch: i(() => {
|
|
543
|
+
C.current?.({ enableFacets: f });
|
|
539
544
|
}, [f]) };
|
|
540
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
|
+
}
|
|
541
550
|
//#endregion
|
|
542
551
|
//#region src/context/SearchContext.tsx
|
|
543
|
-
function
|
|
552
|
+
function pe() {
|
|
544
553
|
let e = globalThis.crypto;
|
|
545
554
|
return e?.randomUUID ? e.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
546
555
|
}
|
|
547
|
-
var
|
|
548
|
-
let
|
|
549
|
-
let t =
|
|
550
|
-
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);
|
|
551
560
|
}, [
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
]),
|
|
561
|
+
S,
|
|
562
|
+
T,
|
|
563
|
+
D
|
|
564
|
+
]), A = i((e) => E({ fn: e }), []), j = c(s), [M, N] = l({
|
|
556
565
|
query: "",
|
|
557
566
|
results: null,
|
|
558
567
|
isLoading: !1,
|
|
@@ -577,61 +586,62 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
577
586
|
removeDuplicates: m,
|
|
578
587
|
minimumScore: 0,
|
|
579
588
|
showScore: !0,
|
|
580
|
-
placeholderText:
|
|
589
|
+
placeholderText: me,
|
|
581
590
|
coverageSetup: { ...g }
|
|
582
591
|
}
|
|
583
592
|
});
|
|
584
593
|
o(() => {
|
|
585
594
|
_ && console.log("SearchContext mounted on client");
|
|
586
595
|
}, [_]), o(() => {
|
|
587
|
-
|
|
596
|
+
N((e) => ({
|
|
588
597
|
...e,
|
|
589
598
|
facetDebounceDelayMillis: u
|
|
590
599
|
}));
|
|
591
600
|
}, [u]);
|
|
592
|
-
let [
|
|
601
|
+
let [P] = l(d), F = oe({
|
|
593
602
|
url: t,
|
|
594
603
|
team: n,
|
|
595
604
|
dataset: r,
|
|
596
605
|
preAuthenticatedToken: v,
|
|
597
606
|
enableDebugLogs: _
|
|
598
|
-
}),
|
|
599
|
-
if (!
|
|
607
|
+
}), I = i((e, t = {}) => {
|
|
608
|
+
if (!F.token) throw Error("No authentication token available");
|
|
600
609
|
return fetch(e, {
|
|
601
610
|
...t,
|
|
602
611
|
headers: {
|
|
603
612
|
...t.headers,
|
|
604
|
-
Authorization: `Bearer ${
|
|
613
|
+
Authorization: `Bearer ${F.token}`
|
|
605
614
|
}
|
|
606
615
|
});
|
|
607
|
-
}, [
|
|
608
|
-
state:
|
|
609
|
-
setState:
|
|
610
|
-
authenticatedFetch:
|
|
611
|
-
auth:
|
|
616
|
+
}, [F.token]), { retrySearch: L } = de({
|
|
617
|
+
state: M,
|
|
618
|
+
setState: N,
|
|
619
|
+
authenticatedFetch: I,
|
|
620
|
+
auth: F,
|
|
612
621
|
url: t,
|
|
613
622
|
team: n,
|
|
614
623
|
dataset: r,
|
|
615
624
|
allowEmptySearch: a,
|
|
616
|
-
facetsEnabled:
|
|
625
|
+
facetsEnabled: P,
|
|
617
626
|
enableDebugLogs: _,
|
|
618
|
-
shouldFetchMore:
|
|
619
|
-
sessionId:
|
|
627
|
+
shouldFetchMore: C,
|
|
628
|
+
sessionId: w,
|
|
620
629
|
source: y,
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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`, {
|
|
628
638
|
method: "POST",
|
|
629
639
|
headers: { "Content-Type": "application/json" },
|
|
630
640
|
body: JSON.stringify({
|
|
631
|
-
queryId:
|
|
641
|
+
queryId: R.current,
|
|
632
642
|
documentKey: e.documentKey,
|
|
633
643
|
position: e.position,
|
|
634
|
-
...
|
|
644
|
+
...x ? {} : { count: !1 }
|
|
635
645
|
})
|
|
636
646
|
});
|
|
637
647
|
_ && (i.ok ? console.log(`[select] document ${e.documentKey} at position ${e.position}`) : console.warn(`[select] not recorded: ${i.status}`));
|
|
@@ -639,15 +649,15 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
639
649
|
_ && console.warn("[select] failed:", e);
|
|
640
650
|
}
|
|
641
651
|
}, [
|
|
642
|
-
|
|
643
|
-
|
|
652
|
+
F.token,
|
|
653
|
+
I,
|
|
644
654
|
t,
|
|
645
655
|
n,
|
|
646
656
|
r,
|
|
647
657
|
_,
|
|
648
|
-
|
|
649
|
-
]),
|
|
650
|
-
|
|
658
|
+
x
|
|
659
|
+
]), B = i((e) => {
|
|
660
|
+
N((t) => {
|
|
651
661
|
let n = Object.keys(t.filters).length > 0, r = Object.keys(t.rangeFilters).length > 0, i = Object.keys(t.bucketFilters).length > 0;
|
|
652
662
|
return {
|
|
653
663
|
...t,
|
|
@@ -657,17 +667,17 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
657
667
|
bucketFilters: i ? {} : t.bucketFilters,
|
|
658
668
|
searchSettings: {
|
|
659
669
|
...t.searchSettings,
|
|
660
|
-
maxNumberOfRecordsToReturn:
|
|
670
|
+
maxNumberOfRecordsToReturn: j.current
|
|
661
671
|
}
|
|
662
672
|
};
|
|
663
673
|
});
|
|
664
|
-
}, []),
|
|
665
|
-
|
|
674
|
+
}, []), V = i((e) => {
|
|
675
|
+
N((t) => ({
|
|
666
676
|
...t,
|
|
667
677
|
facetDebounceDelayMillis: e
|
|
668
678
|
}));
|
|
669
|
-
}, []),
|
|
670
|
-
typeof e.maxNumberOfRecordsToReturn == "number" && (
|
|
679
|
+
}, []), H = i((e) => {
|
|
680
|
+
typeof e.maxNumberOfRecordsToReturn == "number" && (j.current = e.maxNumberOfRecordsToReturn), N((t) => {
|
|
671
681
|
let n = {
|
|
672
682
|
...t.searchSettings,
|
|
673
683
|
...e
|
|
@@ -680,16 +690,16 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
680
690
|
searchSettings: n
|
|
681
691
|
};
|
|
682
692
|
});
|
|
683
|
-
}, []),
|
|
684
|
-
|
|
693
|
+
}, []), U = i((e) => {
|
|
694
|
+
C.current = !0, N((t) => ({
|
|
685
695
|
...t,
|
|
686
696
|
searchSettings: {
|
|
687
697
|
...t.searchSettings,
|
|
688
698
|
maxNumberOfRecordsToReturn: e
|
|
689
699
|
}
|
|
690
700
|
}));
|
|
691
|
-
}, []),
|
|
692
|
-
|
|
701
|
+
}, []), W = i((e, t, n = !1) => {
|
|
702
|
+
N((r) => {
|
|
693
703
|
let i = { ...r.filters }, a = i[e] || [], o = a.includes(t) ? a.filter((e) => e !== t) : n ? [t] : [...a, t];
|
|
694
704
|
return o.length ? i[e] = o : delete i[e], {
|
|
695
705
|
...r,
|
|
@@ -697,16 +707,16 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
697
707
|
filterRevision: r.filterRevision + 1
|
|
698
708
|
};
|
|
699
709
|
});
|
|
700
|
-
}, []),
|
|
701
|
-
|
|
710
|
+
}, []), ee = i((e, t) => {
|
|
711
|
+
N((n) => n.valueMatch[e] === t ? n : {
|
|
702
712
|
...n,
|
|
703
713
|
valueMatch: {
|
|
704
714
|
...n.valueMatch,
|
|
705
715
|
[e]: t
|
|
706
716
|
}
|
|
707
717
|
});
|
|
708
|
-
}, []),
|
|
709
|
-
|
|
718
|
+
}, []), G = i((e, t, n) => {
|
|
719
|
+
N((r) => ({
|
|
710
720
|
...r,
|
|
711
721
|
rangeFilters: {
|
|
712
722
|
...r.rangeFilters,
|
|
@@ -717,16 +727,16 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
717
727
|
},
|
|
718
728
|
filterRevision: r.filterRevision + 1
|
|
719
729
|
}));
|
|
720
|
-
}, []),
|
|
721
|
-
|
|
730
|
+
}, []), te = i(() => {
|
|
731
|
+
N((e) => ({
|
|
722
732
|
...e,
|
|
723
733
|
filters: {},
|
|
724
734
|
rangeFilters: {},
|
|
725
735
|
bucketFilters: {},
|
|
726
736
|
filterRevision: e.filterRevision + 1
|
|
727
737
|
}));
|
|
728
|
-
}, []),
|
|
729
|
-
|
|
738
|
+
}, []), K = i((e, t, n = !0) => {
|
|
739
|
+
N((r) => {
|
|
730
740
|
let i = { ...r.filters }, a = (i[e] || []).filter((e) => e !== t);
|
|
731
741
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
732
742
|
...r,
|
|
@@ -734,8 +744,8 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
734
744
|
filterRevision: r.filterRevision + +!!n
|
|
735
745
|
};
|
|
736
746
|
});
|
|
737
|
-
}, []),
|
|
738
|
-
|
|
747
|
+
}, []), ne = i((e, t = !0) => {
|
|
748
|
+
N((n) => {
|
|
739
749
|
if (!(e in n.rangeFilters)) return n;
|
|
740
750
|
let r = { ...n.rangeFilters };
|
|
741
751
|
return delete r[e], {
|
|
@@ -744,112 +754,112 @@ var pe = "Type to search", me = n(void 0), he = ({ children: e, url: t, team: n,
|
|
|
744
754
|
filterRevision: n.filterRevision + +!!t
|
|
745
755
|
};
|
|
746
756
|
});
|
|
747
|
-
}, []),
|
|
748
|
-
|
|
749
|
-
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 };
|
|
750
760
|
return a.length > 0 ? o[e] = a : delete o[e], {
|
|
751
761
|
...r,
|
|
752
762
|
bucketFilters: o,
|
|
753
763
|
filterRevision: r.filterRevision + 1
|
|
754
764
|
};
|
|
755
765
|
});
|
|
756
|
-
}, []),
|
|
757
|
-
|
|
758
|
-
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)) : [];
|
|
759
769
|
return a.length > 0 ? i[e] = a : delete i[e], {
|
|
760
770
|
...r,
|
|
761
771
|
bucketFilters: i,
|
|
762
772
|
filterRevision: r.filterRevision + +!!n
|
|
763
773
|
};
|
|
764
774
|
});
|
|
765
|
-
}, []),
|
|
766
|
-
|
|
775
|
+
}, []), J = i((e, t) => {
|
|
776
|
+
N((n) => ({
|
|
767
777
|
...n,
|
|
768
778
|
sortBy: e || void 0,
|
|
769
779
|
sortAscending: e ? t : void 0
|
|
770
780
|
}));
|
|
771
781
|
}, []);
|
|
772
|
-
return /* @__PURE__ */ f(
|
|
782
|
+
return /* @__PURE__ */ f(he.Provider, {
|
|
773
783
|
value: {
|
|
774
|
-
state:
|
|
775
|
-
isFetchingInitial:
|
|
776
|
-
authError:
|
|
777
|
-
authErrorInfo:
|
|
778
|
-
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,
|
|
779
789
|
allowEmptySearch: a,
|
|
780
|
-
facetsEnabled:
|
|
781
|
-
datasetBounds:
|
|
790
|
+
facetsEnabled: P,
|
|
791
|
+
datasetBounds: F.initialFacetStats,
|
|
782
792
|
url: t,
|
|
783
793
|
team: n,
|
|
784
794
|
dataset: r,
|
|
785
|
-
authenticatedFetch:
|
|
786
|
-
setQuery:
|
|
787
|
-
toggleFilter:
|
|
788
|
-
setValueMatch:
|
|
789
|
-
setRangeFilter:
|
|
790
|
-
resetFilters:
|
|
791
|
-
resetSingleFilter:
|
|
792
|
-
resetRangeFilter:
|
|
793
|
-
toggleBucketFilter:
|
|
794
|
-
resetBucketFilter:
|
|
795
|
-
setSort:
|
|
796
|
-
setDebounceDelay:
|
|
797
|
-
setSearchSettings:
|
|
798
|
-
fetchMoreResults:
|
|
799
|
-
selectResult:
|
|
800
|
-
sessionId:
|
|
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,
|
|
805
|
+
setSort: J,
|
|
806
|
+
setDebounceDelay: V,
|
|
807
|
+
setSearchSettings: H,
|
|
808
|
+
fetchMoreResults: U,
|
|
809
|
+
selectResult: z,
|
|
810
|
+
sessionId: w,
|
|
801
811
|
source: y,
|
|
802
|
-
count:
|
|
803
|
-
searchText:
|
|
804
|
-
searchAsTyped: () =>
|
|
805
|
-
setSearchRewrite:
|
|
812
|
+
count: x,
|
|
813
|
+
searchText: k(M.query),
|
|
814
|
+
searchAsTyped: () => O(M.query),
|
|
815
|
+
setSearchRewrite: A
|
|
806
816
|
},
|
|
807
817
|
children: e
|
|
808
818
|
});
|
|
809
819
|
}, Y = () => {
|
|
810
|
-
let e = a(
|
|
820
|
+
let e = a(he);
|
|
811
821
|
if (!e) throw Error("useSearchContext must be used within a SearchProvider");
|
|
812
822
|
return e;
|
|
813
|
-
},
|
|
823
|
+
}, _e = {
|
|
814
824
|
strong: .65,
|
|
815
825
|
strongHide: .45,
|
|
816
826
|
invite: .4,
|
|
817
827
|
inviteHide: .3
|
|
818
|
-
},
|
|
819
|
-
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) {
|
|
820
830
|
let t = e.trim();
|
|
821
|
-
return t.length > 0 && !t.includes(" ") &&
|
|
831
|
+
return t.length > 0 && !t.includes(" ") && ye.test(t);
|
|
822
832
|
}
|
|
823
|
-
function
|
|
833
|
+
function xe(e) {
|
|
824
834
|
let t = e.trim();
|
|
825
|
-
if (!t ||
|
|
835
|
+
if (!t || be(t)) return !1;
|
|
826
836
|
let n = t.split(/\s+/);
|
|
827
|
-
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;
|
|
828
838
|
}
|
|
829
|
-
function
|
|
839
|
+
function Se(e, t, n = _e) {
|
|
830
840
|
return t >= n.strong || e === "strong" && t >= n.strongHide ? "strong" : t >= n.invite || e !== "none" && t >= n.inviteHide ? "invite" : "none";
|
|
831
841
|
}
|
|
832
|
-
var
|
|
842
|
+
var Ce = {
|
|
833
843
|
shareOfTop: .5,
|
|
834
844
|
topFloor: .2
|
|
835
|
-
},
|
|
845
|
+
}, we = {
|
|
836
846
|
coverFuzzyWords: !1,
|
|
837
847
|
coverPrefixSuffix: !1,
|
|
838
848
|
coverJoinedWords: !1,
|
|
839
849
|
minWordSize: 3
|
|
840
|
-
},
|
|
841
|
-
function
|
|
850
|
+
}, Te = 65535;
|
|
851
|
+
function Ee(e, t, n, r = Ce) {
|
|
842
852
|
if (!n || e.length === 0) return e;
|
|
843
853
|
let i = e[0].score;
|
|
844
854
|
if (i < r.topFloor * 65535) return [];
|
|
845
855
|
let a = t == null ? e : t < 0 ? [] : e.slice(0, t + 1), o = r.shareOfTop * i, s = a.findIndex((e) => e.score < o);
|
|
846
856
|
return s < 0 ? a : a.slice(0, s);
|
|
847
857
|
}
|
|
848
|
-
function
|
|
858
|
+
function De(e) {
|
|
849
859
|
let t = e.trim();
|
|
850
860
|
return t.includes(" ") || t.endsWith("?");
|
|
851
861
|
}
|
|
852
|
-
async function*
|
|
862
|
+
async function* Oe(e) {
|
|
853
863
|
let t = e.getReader(), n = new TextDecoder(), r = "";
|
|
854
864
|
try {
|
|
855
865
|
for (;;) {
|
|
@@ -872,7 +882,7 @@ async function* De(e) {
|
|
|
872
882
|
t.releaseLock();
|
|
873
883
|
}
|
|
874
884
|
}
|
|
875
|
-
function
|
|
885
|
+
function ke(e) {
|
|
876
886
|
let t = new URLSearchParams();
|
|
877
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");
|
|
878
888
|
let n = t.toString();
|
|
@@ -880,28 +890,28 @@ function Oe(e) {
|
|
|
880
890
|
}
|
|
881
891
|
//#endregion
|
|
882
892
|
//#region src/utils/askPhrases.ts
|
|
883
|
-
var
|
|
884
|
-
function
|
|
893
|
+
var Ae = (e) => e.toLowerCase().replace(/’/g, "'").split(/\s+/).filter(Boolean), je = /[?!.,]+$/, Me = 2;
|
|
894
|
+
function Ne(e, t) {
|
|
885
895
|
let n = 0;
|
|
886
896
|
for (let r of t) {
|
|
887
|
-
let t =
|
|
888
|
-
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);
|
|
889
899
|
}
|
|
890
900
|
return n;
|
|
891
901
|
}
|
|
892
|
-
function
|
|
902
|
+
function Pe(e, t, n) {
|
|
893
903
|
let r = 0;
|
|
894
904
|
for (let i of n) {
|
|
895
|
-
let n =
|
|
896
|
-
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);
|
|
897
907
|
}
|
|
898
908
|
return r;
|
|
899
909
|
}
|
|
900
|
-
function
|
|
901
|
-
let n = e.trim().split(/\s+/).filter(Boolean), r =
|
|
902
|
-
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);
|
|
903
913
|
return t && (a.push(n.slice(i, i + t).join(" ")), i += t), t > 0;
|
|
904
|
-
}, s =
|
|
914
|
+
}, s = Pe(r, 0, t.leadIns), c = o(t.leadIns), l = o(t.frames), u = o(t.links);
|
|
905
915
|
if (!(c && (s > 1 || l) || l && u)) return {
|
|
906
916
|
text: e,
|
|
907
917
|
taken: []
|
|
@@ -912,8 +922,8 @@ function Pe(e, t) {
|
|
|
912
922
|
text: e,
|
|
913
923
|
taken: []
|
|
914
924
|
};
|
|
915
|
-
let f = d.split(/\s+/).filter(Boolean), p =
|
|
916
|
-
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) {
|
|
917
927
|
let e = f.slice(0, f.length - p).join(" ");
|
|
918
928
|
if (/\p{L}{3,}/u.test(e)) return {
|
|
919
929
|
text: e,
|
|
@@ -927,7 +937,7 @@ function Pe(e, t) {
|
|
|
927
937
|
}
|
|
928
938
|
//#endregion
|
|
929
939
|
//#region src/hooks/useSearchOrAsk.ts
|
|
930
|
-
var
|
|
940
|
+
var Ie = {
|
|
931
941
|
available: !1,
|
|
932
942
|
offer: "none",
|
|
933
943
|
p: null,
|
|
@@ -936,15 +946,15 @@ var Fe = {
|
|
|
936
946
|
criteria: null,
|
|
937
947
|
describes: !1,
|
|
938
948
|
cutResults: !1,
|
|
939
|
-
cutRule:
|
|
949
|
+
cutRule: Ce,
|
|
940
950
|
strictCoverage: !1,
|
|
941
951
|
filtersWhileTyping: "off",
|
|
942
952
|
stands: !1
|
|
943
953
|
};
|
|
944
|
-
function
|
|
954
|
+
function Le(e = {}) {
|
|
945
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);
|
|
946
956
|
m.current = r;
|
|
947
|
-
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);
|
|
948
958
|
k.current = v.offer;
|
|
949
959
|
let N = `${i}/api/teams/${a}/datasets/${s}/search-or-ask`, P = t && !d && !f;
|
|
950
960
|
o(() => {
|
|
@@ -957,11 +967,11 @@ function Ie(e = {}) {
|
|
|
957
967
|
let n = await t.json();
|
|
958
968
|
if (e || !n.available || !n.settings?.enabled) return;
|
|
959
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 = {
|
|
960
|
-
...
|
|
970
|
+
..._e,
|
|
961
971
|
...n.settings.thresholds
|
|
962
972
|
}, x.current = n.settings.cutWhileAsking ?? !0, C.current = n.settings.strictCoverageWhileAsking ?? !0, S.current = {
|
|
963
|
-
shareOfTop: n.settings.cutShareOfTop ??
|
|
964
|
-
topFloor: n.settings.cutTopFloor ??
|
|
973
|
+
shareOfTop: n.settings.cutShareOfTop ?? Ce.shareOfTop,
|
|
974
|
+
topFloor: n.settings.cutTopFloor ?? Ce.topFloor
|
|
965
975
|
}, _(!0);
|
|
966
976
|
} catch {}
|
|
967
977
|
})(), () => {
|
|
@@ -973,21 +983,21 @@ function Ie(e = {}) {
|
|
|
973
983
|
u
|
|
974
984
|
]), o(() => {
|
|
975
985
|
let { setSearchRewrite: e } = m.current, t = T.current;
|
|
976
|
-
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);
|
|
977
987
|
}, [g]), o(() => {
|
|
978
988
|
if (!g) {
|
|
979
|
-
y(
|
|
989
|
+
y(Ie);
|
|
980
990
|
return;
|
|
981
991
|
}
|
|
982
992
|
if (!h) {
|
|
983
993
|
A.current = "", y({
|
|
984
|
-
...
|
|
994
|
+
...Ie,
|
|
985
995
|
available: g
|
|
986
996
|
});
|
|
987
997
|
return;
|
|
988
998
|
}
|
|
989
|
-
if (!
|
|
990
|
-
|
|
999
|
+
if (!xe(h)) {
|
|
1000
|
+
be(h) && y((e) => ({
|
|
991
1001
|
...e,
|
|
992
1002
|
available: g,
|
|
993
1003
|
offer: "none",
|
|
@@ -995,7 +1005,7 @@ function Ie(e = {}) {
|
|
|
995
1005
|
}));
|
|
996
1006
|
return;
|
|
997
1007
|
}
|
|
998
|
-
D.current && T.current &&
|
|
1008
|
+
D.current && T.current && Fe(h, T.current).taken.length > 0 && y((e) => e.offer === "none" ? {
|
|
999
1009
|
...e,
|
|
1000
1010
|
available: g,
|
|
1001
1011
|
offer: "invite",
|
|
@@ -1013,7 +1023,7 @@ function Ie(e = {}) {
|
|
|
1013
1023
|
let e = ++j.current;
|
|
1014
1024
|
A.current = h;
|
|
1015
1025
|
try {
|
|
1016
|
-
let t = await u(`${N}/intent${
|
|
1026
|
+
let t = await u(`${N}/intent${ke(m.current)}`, {
|
|
1017
1027
|
method: "POST",
|
|
1018
1028
|
headers: { "Content-Type": "application/json" },
|
|
1019
1029
|
body: JSON.stringify({ text: h })
|
|
@@ -1034,7 +1044,7 @@ function Ie(e = {}) {
|
|
|
1034
1044
|
shareOfTop: o,
|
|
1035
1045
|
topFloor: s
|
|
1036
1046
|
}), y((e) => {
|
|
1037
|
-
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);
|
|
1038
1048
|
return {
|
|
1039
1049
|
available: !0,
|
|
1040
1050
|
offer: c,
|
|
@@ -1066,55 +1076,57 @@ function Ie(e = {}) {
|
|
|
1066
1076
|
if (F) {
|
|
1067
1077
|
if (O.current) return;
|
|
1068
1078
|
let n = t.searchSettings.coverageSetup ?? {};
|
|
1069
|
-
O.current = Object.fromEntries(Object.keys(
|
|
1079
|
+
O.current = Object.fromEntries(Object.keys(we).map((e) => [e, n[e]])), e({ coverageSetup: { ...we } });
|
|
1070
1080
|
} else O.current &&= (e({ coverageSetup: { ...O.current } }), null);
|
|
1071
1081
|
}, [F]), g ? {
|
|
1072
1082
|
...v,
|
|
1073
1083
|
stands: !!v.text && h.startsWith(v.text)
|
|
1074
|
-
} :
|
|
1084
|
+
} : Ie;
|
|
1075
1085
|
}
|
|
1076
|
-
var
|
|
1077
|
-
withOffer: "
|
|
1078
|
-
offerRow: "
|
|
1079
|
-
offerHint: "
|
|
1080
|
-
kbd: "
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
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 = () => {
|
|
1085
1096
|
C(""), T > 0 && w();
|
|
1086
|
-
},
|
|
1097
|
+
}, z = () => o(m.trim()), B = /* @__PURE__ */ p(k, {
|
|
1087
1098
|
type: "text",
|
|
1088
1099
|
value: m,
|
|
1089
1100
|
onChange: (e) => C(e.target.value),
|
|
1090
|
-
placeholder:
|
|
1101
|
+
placeholder: P,
|
|
1091
1102
|
autoFocus: t,
|
|
1092
1103
|
className: e,
|
|
1093
1104
|
showSearchIcon: !0,
|
|
1094
1105
|
inputSize: n,
|
|
1095
1106
|
showFocusBorder: i,
|
|
1096
1107
|
clearable: !1,
|
|
1097
|
-
onKeyDown:
|
|
1108
|
+
onKeyDown: I,
|
|
1098
1109
|
...u,
|
|
1099
1110
|
children: [
|
|
1100
|
-
|
|
1101
|
-
variant:
|
|
1111
|
+
N && c === "chip" && /* @__PURE__ */ f(y, {
|
|
1112
|
+
variant: M.offer === "strong" ? "primary" : "ghost",
|
|
1113
|
+
className: M.offer === "strong" ? Re.askStrong : void 0,
|
|
1102
1114
|
size: "micro",
|
|
1103
|
-
iconLeft: /* @__PURE__ */ f(
|
|
1104
|
-
iconRight:
|
|
1105
|
-
onClick:
|
|
1106
|
-
title:
|
|
1107
|
-
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"
|
|
1108
1120
|
}),
|
|
1109
|
-
a &&
|
|
1110
|
-
a &&
|
|
1121
|
+
a && O && /* @__PURE__ */ f(x, { children: "No results" }),
|
|
1122
|
+
a && A && /* @__PURE__ */ f(F, {
|
|
1111
1123
|
content: "No direct match. Showing the nearest results.",
|
|
1112
1124
|
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(x, {
|
|
1113
1125
|
icon: /* @__PURE__ */ f(H, {}),
|
|
1114
1126
|
children: "Nearest"
|
|
1115
1127
|
}) })
|
|
1116
1128
|
}),
|
|
1117
|
-
a && T > 0 && /* @__PURE__ */ f(
|
|
1129
|
+
a && T > 0 && /* @__PURE__ */ f(F, {
|
|
1118
1130
|
content: `${T} filter${T === 1 ? "" : "s"} active`,
|
|
1119
1131
|
children: /* @__PURE__ */ f("span", { children: /* @__PURE__ */ f(x, {
|
|
1120
1132
|
icon: /* @__PURE__ */ f(V, {}),
|
|
@@ -1126,43 +1138,44 @@ var Le = {
|
|
|
1126
1138
|
r && (E || T > 0) && /* @__PURE__ */ f(y, {
|
|
1127
1139
|
variant: "ghost",
|
|
1128
1140
|
size: "micro",
|
|
1129
|
-
onClick:
|
|
1141
|
+
onClick: R,
|
|
1130
1142
|
"aria-label": T > 0 ? "Clear search and filters" : "Clear search",
|
|
1131
1143
|
children: "Clear"
|
|
1132
1144
|
})
|
|
1133
1145
|
]
|
|
1134
1146
|
});
|
|
1135
|
-
if (c !== "below" || !o || !
|
|
1136
|
-
let U =
|
|
1147
|
+
if (c !== "below" || !o || !M.available) return B;
|
|
1148
|
+
let U = M.offer === "strong";
|
|
1137
1149
|
return /* @__PURE__ */ p("div", {
|
|
1138
|
-
className:
|
|
1139
|
-
children: [
|
|
1140
|
-
className:
|
|
1150
|
+
className: Re.withOffer,
|
|
1151
|
+
children: [B, /* @__PURE__ */ f("div", {
|
|
1152
|
+
className: Re.offerRow,
|
|
1141
1153
|
"aria-live": "polite",
|
|
1142
|
-
children:
|
|
1154
|
+
children: N && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(y, {
|
|
1143
1155
|
variant: U ? "primary" : "ghost",
|
|
1144
|
-
|
|
1145
|
-
|
|
1156
|
+
className: U ? Re.askStrong : void 0,
|
|
1157
|
+
iconLeft: /* @__PURE__ */ f(L, {}),
|
|
1158
|
+
onClick: z,
|
|
1146
1159
|
children: U ? "Ask the assistant" : "Ask about this"
|
|
1147
1160
|
}), U && /* @__PURE__ */ p("span", {
|
|
1148
|
-
className:
|
|
1161
|
+
className: Re.offerHint,
|
|
1149
1162
|
children: [/* @__PURE__ */ f("kbd", {
|
|
1150
|
-
className:
|
|
1163
|
+
className: Re.kbd,
|
|
1151
1164
|
children: "↵"
|
|
1152
1165
|
}), " to ask"]
|
|
1153
1166
|
})] })
|
|
1154
1167
|
})]
|
|
1155
1168
|
});
|
|
1156
|
-
},
|
|
1169
|
+
}, Be = {
|
|
1157
1170
|
message: "_message_1mgfk_1",
|
|
1158
1171
|
icon: "_icon_1mgfk_10",
|
|
1159
1172
|
title: "_title_1mgfk_15",
|
|
1160
1173
|
detail: "_detail_1mgfk_20",
|
|
1161
1174
|
technical: "_technical_1mgfk_25",
|
|
1162
1175
|
button: "_button_1mgfk_33"
|
|
1163
|
-
},
|
|
1176
|
+
}, Ve = {
|
|
1164
1177
|
unreachable: {
|
|
1165
|
-
icon:
|
|
1178
|
+
icon: B,
|
|
1166
1179
|
title: "Search is unavailable",
|
|
1167
1180
|
detail: "The search server can’t be reached right now."
|
|
1168
1181
|
},
|
|
@@ -1211,8 +1224,8 @@ var Le = {
|
|
|
1211
1224
|
title: "Something went wrong",
|
|
1212
1225
|
detail: "The search couldn’t be completed."
|
|
1213
1226
|
}
|
|
1214
|
-
},
|
|
1215
|
-
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];
|
|
1216
1229
|
o(() => {
|
|
1217
1230
|
if (e.kind !== "notReady" || !t) return;
|
|
1218
1231
|
let n = setTimeout(t, (e.retryAfterSeconds ?? 2) * 1e3);
|
|
@@ -1220,65 +1233,65 @@ var Le = {
|
|
|
1220
1233
|
}, [e, t]);
|
|
1221
1234
|
let s = e.retryable && e.kind !== "notReady" && t;
|
|
1222
1235
|
return /* @__PURE__ */ p("div", {
|
|
1223
|
-
className:
|
|
1236
|
+
className: Be.message,
|
|
1224
1237
|
role: "alert",
|
|
1225
1238
|
children: [
|
|
1226
1239
|
/* @__PURE__ */ f("span", {
|
|
1227
|
-
className:
|
|
1240
|
+
className: Be.icon,
|
|
1228
1241
|
children: /* @__PURE__ */ f(r, {
|
|
1229
1242
|
size: 70,
|
|
1230
1243
|
color: "var(--lv4)"
|
|
1231
1244
|
})
|
|
1232
1245
|
}),
|
|
1233
1246
|
/* @__PURE__ */ f("div", {
|
|
1234
|
-
className:
|
|
1247
|
+
className: Be.title,
|
|
1235
1248
|
children: i
|
|
1236
1249
|
}),
|
|
1237
1250
|
/* @__PURE__ */ f("div", {
|
|
1238
|
-
className:
|
|
1251
|
+
className: Be.detail,
|
|
1239
1252
|
children: a
|
|
1240
1253
|
}),
|
|
1241
1254
|
!n && /* @__PURE__ */ f("code", {
|
|
1242
|
-
className:
|
|
1255
|
+
className: Be.technical,
|
|
1243
1256
|
children: e.technical
|
|
1244
1257
|
}),
|
|
1245
1258
|
s && /* @__PURE__ */ f(y, {
|
|
1246
1259
|
variant: "secondary",
|
|
1247
1260
|
size: "micro",
|
|
1248
|
-
className:
|
|
1261
|
+
className: Be.button,
|
|
1249
1262
|
onClick: t,
|
|
1250
1263
|
children: "Try again"
|
|
1251
1264
|
})
|
|
1252
1265
|
]
|
|
1253
1266
|
});
|
|
1254
|
-
},
|
|
1267
|
+
}, Ue = {
|
|
1255
1268
|
placeholder: "_placeholder_1qr5o_1",
|
|
1256
1269
|
invalid: "_invalid_1qr5o_11",
|
|
1257
1270
|
searchedFor: "_searchedFor_1qr5o_17"
|
|
1258
|
-
},
|
|
1271
|
+
}, We = {
|
|
1259
1272
|
row: "_row_11svi_1",
|
|
1260
1273
|
content: "_content_11svi_22",
|
|
1261
1274
|
indexNumber: "_indexNumber_11svi_36",
|
|
1262
1275
|
scoreNumber: "_scoreNumber_11svi_44",
|
|
1263
1276
|
skeletonBars: "_skeletonBars_11svi_53"
|
|
1264
|
-
},
|
|
1265
|
-
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,
|
|
1266
1279
|
children: [
|
|
1267
1280
|
t !== void 0 && /* @__PURE__ */ f("div", {
|
|
1268
|
-
className:
|
|
1281
|
+
className: We.indexNumber,
|
|
1269
1282
|
children: t
|
|
1270
1283
|
}),
|
|
1271
1284
|
/* @__PURE__ */ f("div", {
|
|
1272
|
-
className:
|
|
1285
|
+
className: We.content,
|
|
1273
1286
|
children: e ? /* @__PURE__ */ p("div", {
|
|
1274
|
-
className:
|
|
1275
|
-
children: [/* @__PURE__ */ f(
|
|
1287
|
+
className: We.skeletonBars,
|
|
1288
|
+
children: [/* @__PURE__ */ f(j, {
|
|
1276
1289
|
level: 3,
|
|
1277
1290
|
height: 12,
|
|
1278
1291
|
width: `${o[0]}%`,
|
|
1279
1292
|
delay: a,
|
|
1280
1293
|
appear: !1
|
|
1281
|
-
}), /* @__PURE__ */ f(
|
|
1294
|
+
}), /* @__PURE__ */ f(j, {
|
|
1282
1295
|
level: 3,
|
|
1283
1296
|
height: 8,
|
|
1284
1297
|
width: `${o[1]}%`,
|
|
@@ -1288,14 +1301,14 @@ var Le = {
|
|
|
1288
1301
|
}) : i
|
|
1289
1302
|
}),
|
|
1290
1303
|
r && n !== void 0 && /* @__PURE__ */ f("div", {
|
|
1291
|
-
className:
|
|
1304
|
+
className: We.scoreNumber,
|
|
1292
1305
|
children: n
|
|
1293
1306
|
})
|
|
1294
1307
|
]
|
|
1295
|
-
}),
|
|
1308
|
+
}), Ke = {
|
|
1296
1309
|
wrapper: "_wrapper_f970z_6",
|
|
1297
1310
|
skeletonAppear: "_skeletonAppear_f970z_1"
|
|
1298
|
-
},
|
|
1311
|
+
}, qe = [
|
|
1299
1312
|
[62, 38],
|
|
1300
1313
|
[75, 45],
|
|
1301
1314
|
[58, 33],
|
|
@@ -1304,27 +1317,27 @@ var Le = {
|
|
|
1304
1317
|
[55, 35],
|
|
1305
1318
|
[72, 40],
|
|
1306
1319
|
[60, 30]
|
|
1307
|
-
],
|
|
1308
|
-
className:
|
|
1309
|
-
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, {
|
|
1310
1323
|
skeleton: !0,
|
|
1311
1324
|
skeletonDelay: t * .1,
|
|
1312
|
-
skeletonWidths:
|
|
1325
|
+
skeletonWidths: qe[t % qe.length]
|
|
1313
1326
|
}, t))
|
|
1314
|
-
}),
|
|
1315
|
-
function
|
|
1327
|
+
}), Ye = /^\[\s*(?:'[^']*'(?:\s*,\s*'[^']*')*)?\s*\]$/;
|
|
1328
|
+
function Xe(e) {
|
|
1316
1329
|
let t = e.trim();
|
|
1317
1330
|
if (!t.startsWith("[") || !t.endsWith("]")) return;
|
|
1318
1331
|
try {
|
|
1319
1332
|
let e = JSON.parse(t);
|
|
1320
1333
|
if (Array.isArray(e)) return e.map((e) => String(e));
|
|
1321
1334
|
} catch {}
|
|
1322
|
-
if (!
|
|
1335
|
+
if (!Ye.test(t)) return;
|
|
1323
1336
|
let n = [], r = /'([^']*)'/g, i;
|
|
1324
1337
|
for (; (i = r.exec(t)) !== null;) n.push(i[1]);
|
|
1325
1338
|
return n;
|
|
1326
1339
|
}
|
|
1327
|
-
var
|
|
1340
|
+
var Ze = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk: r, showScore: i, children: a }) => {
|
|
1328
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("");
|
|
1329
1342
|
o(() => {
|
|
1330
1343
|
let e = g !== N.current;
|
|
@@ -1334,19 +1347,19 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1334
1347
|
k,
|
|
1335
1348
|
g
|
|
1336
1349
|
]);
|
|
1337
|
-
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 = () => {
|
|
1338
1351
|
let e = A + k;
|
|
1339
1352
|
j(e), s && e >= s.length && (!h || h === -1 || h > s.length) && T(s.length + k);
|
|
1340
1353
|
};
|
|
1341
|
-
if (b) return w ? /* @__PURE__ */ f(
|
|
1342
|
-
className:
|
|
1354
|
+
if (b) return w ? /* @__PURE__ */ f(Je, { rows: k }) : /* @__PURE__ */ f("div", {
|
|
1355
|
+
className: Ue.placeholder,
|
|
1343
1356
|
children: /* @__PURE__ */ f(W, {
|
|
1344
1357
|
size: 200,
|
|
1345
1358
|
color: "var(--lv5)"
|
|
1346
1359
|
})
|
|
1347
1360
|
});
|
|
1348
1361
|
let R = x ?? _;
|
|
1349
|
-
return R ? /* @__PURE__ */ f(
|
|
1362
|
+
return R ? /* @__PURE__ */ f(He, {
|
|
1350
1363
|
error: (x ? S : v) ?? {
|
|
1351
1364
|
kind: "unknown",
|
|
1352
1365
|
message: R,
|
|
@@ -1355,14 +1368,14 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1355
1368
|
},
|
|
1356
1369
|
onRetry: C
|
|
1357
1370
|
}) : u || s === null ? /* @__PURE__ */ f("div", {
|
|
1358
|
-
className:
|
|
1371
|
+
className: Ue.placeholder,
|
|
1359
1372
|
children: /* @__PURE__ */ f(W, {
|
|
1360
1373
|
size: 200,
|
|
1361
1374
|
color: "var(--lv5)"
|
|
1362
1375
|
})
|
|
1363
1376
|
}) : P.length === 0 ? null : /* @__PURE__ */ p(d, { children: [
|
|
1364
1377
|
F && /* @__PURE__ */ p("div", {
|
|
1365
|
-
className:
|
|
1378
|
+
className: Ue.searchedFor,
|
|
1366
1379
|
"aria-live": "polite",
|
|
1367
1380
|
children: [/* @__PURE__ */ p("span", { children: ["Searching for ", /* @__PURE__ */ f("strong", { children: F })] }), O && /* @__PURE__ */ f(y, {
|
|
1368
1381
|
variant: "ghost",
|
|
@@ -1377,7 +1390,7 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1377
1390
|
c = typeof o == "string" ? JSON.parse(o) : o;
|
|
1378
1391
|
} catch {
|
|
1379
1392
|
return /* @__PURE__ */ f("div", {
|
|
1380
|
-
className:
|
|
1393
|
+
className: Ue.invalid,
|
|
1381
1394
|
children: /* @__PURE__ */ f("p", { children: "Invalid JSON" })
|
|
1382
1395
|
}, r);
|
|
1383
1396
|
}
|
|
@@ -1389,11 +1402,11 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1389
1402
|
if (n) for (let e in l) {
|
|
1390
1403
|
let t = l[e];
|
|
1391
1404
|
if (typeof t == "string") {
|
|
1392
|
-
let n =
|
|
1405
|
+
let n = Xe(t);
|
|
1393
1406
|
n && (l[e] = n);
|
|
1394
1407
|
}
|
|
1395
1408
|
}
|
|
1396
|
-
return /* @__PURE__ */ f(
|
|
1409
|
+
return /* @__PURE__ */ f(Ge, {
|
|
1397
1410
|
index: r,
|
|
1398
1411
|
score: s,
|
|
1399
1412
|
showScore: i ?? m.showScore,
|
|
@@ -1416,18 +1429,18 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1416
1429
|
})
|
|
1417
1430
|
})
|
|
1418
1431
|
] });
|
|
1419
|
-
},
|
|
1432
|
+
}, Qe = {
|
|
1420
1433
|
row: "_row_ujwhc_1",
|
|
1421
1434
|
title: "_title_ujwhc_8"
|
|
1422
|
-
},
|
|
1423
|
-
className: [
|
|
1435
|
+
}, $e = ({ variant: e = "default", children: t }) => /* @__PURE__ */ f("div", {
|
|
1436
|
+
className: [Qe.row, e === "title" ? Qe.title : ""].filter(Boolean).join(" "),
|
|
1424
1437
|
children: t
|
|
1425
|
-
}),
|
|
1438
|
+
}), et = {
|
|
1426
1439
|
listRows: "_listRows_13obt_2",
|
|
1427
1440
|
sliderArea: "_sliderArea_13obt_8",
|
|
1428
1441
|
inputRow: "_inputRow_13obt_15",
|
|
1429
1442
|
histogramRow: "_histogramRow_13obt_22"
|
|
1430
|
-
},
|
|
1443
|
+
}, tt = [
|
|
1431
1444
|
65,
|
|
1432
1445
|
80,
|
|
1433
1446
|
55,
|
|
@@ -1436,22 +1449,22 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1436
1449
|
75,
|
|
1437
1450
|
50,
|
|
1438
1451
|
68
|
|
1439
|
-
],
|
|
1452
|
+
], nt = ({ title: e, rows: t = 5, variant: n = "list", withHistogram: r = !1, collapsible: i = !0, startCollapsed: a = !1 }) => /* @__PURE__ */ f(T, {
|
|
1440
1453
|
title: e,
|
|
1441
1454
|
collapsible: i,
|
|
1442
1455
|
collapsed: a,
|
|
1443
1456
|
children: n === "slider" ? /* @__PURE__ */ p("div", {
|
|
1444
|
-
className:
|
|
1457
|
+
className: et.sliderArea,
|
|
1445
1458
|
children: [
|
|
1446
|
-
r && /* @__PURE__ */ f("div", { className:
|
|
1447
|
-
/* @__PURE__ */ f(
|
|
1459
|
+
r && /* @__PURE__ */ f("div", { className: et.histogramRow }),
|
|
1460
|
+
/* @__PURE__ */ f(j, { height: 6 }),
|
|
1448
1461
|
/* @__PURE__ */ p("div", {
|
|
1449
|
-
className:
|
|
1450
|
-
children: [/* @__PURE__ */ f(
|
|
1462
|
+
className: et.inputRow,
|
|
1463
|
+
children: [/* @__PURE__ */ f(j, {
|
|
1451
1464
|
width: 40,
|
|
1452
1465
|
height: 20,
|
|
1453
1466
|
delay: .1
|
|
1454
|
-
}), /* @__PURE__ */ f(
|
|
1467
|
+
}), /* @__PURE__ */ f(j, {
|
|
1455
1468
|
width: 40,
|
|
1456
1469
|
height: 20,
|
|
1457
1470
|
delay: .15
|
|
@@ -1459,9 +1472,9 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1459
1472
|
})
|
|
1460
1473
|
]
|
|
1461
1474
|
}) : /* @__PURE__ */ f("div", {
|
|
1462
|
-
className:
|
|
1463
|
-
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f(
|
|
1464
|
-
width: `${
|
|
1475
|
+
className: et.listRows,
|
|
1476
|
+
children: Array.from({ length: t }).map((e, t) => /* @__PURE__ */ f(j, {
|
|
1477
|
+
width: `${tt[t % tt.length]}%`,
|
|
1465
1478
|
delay: t * .05
|
|
1466
1479
|
}, t))
|
|
1467
1480
|
})
|
|
@@ -1473,10 +1486,10 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1473
1486
|
chipLabel: "_chipLabel_18vbb_32",
|
|
1474
1487
|
grid: "_grid_18vbb_40",
|
|
1475
1488
|
active: "_active_18vbb_54"
|
|
1476
|
-
},
|
|
1489
|
+
}, rt = {
|
|
1477
1490
|
notice: "_notice_4sel0_1",
|
|
1478
1491
|
technical: "_technical_4sel0_9"
|
|
1479
|
-
},
|
|
1492
|
+
}, it = ({ label: e, field: t, missing: n }) => {
|
|
1480
1493
|
let r = n.map((e) => e[0].toUpperCase() + e.slice(1)).join(" and ");
|
|
1481
1494
|
return o(() => {
|
|
1482
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).`);
|
|
@@ -1484,9 +1497,9 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1484
1497
|
title: e ?? t,
|
|
1485
1498
|
collapsible: !1,
|
|
1486
1499
|
children: /* @__PURE__ */ p("div", {
|
|
1487
|
-
className:
|
|
1500
|
+
className: rt.notice,
|
|
1488
1501
|
children: [/* @__PURE__ */ f("span", { children: "Not available" }), /* @__PURE__ */ p("code", {
|
|
1489
|
-
className:
|
|
1502
|
+
className: rt.technical,
|
|
1490
1503
|
children: [
|
|
1491
1504
|
t,
|
|
1492
1505
|
": not ",
|
|
@@ -1495,8 +1508,8 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1495
1508
|
})]
|
|
1496
1509
|
})
|
|
1497
1510
|
});
|
|
1498
|
-
},
|
|
1499
|
-
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;
|
|
1500
1513
|
o(() => {
|
|
1501
1514
|
M(e, R);
|
|
1502
1515
|
}, [
|
|
@@ -1507,11 +1520,11 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1507
1520
|
let z = c(null), [B, V] = l(a);
|
|
1508
1521
|
if (o(() => {
|
|
1509
1522
|
V(a);
|
|
1510
|
-
}, [w?.[e], a]), !I && !A ||
|
|
1511
|
-
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, {
|
|
1512
1525
|
rows: 1,
|
|
1513
1526
|
collapsible: !1
|
|
1514
|
-
}) : /* @__PURE__ */ f(
|
|
1527
|
+
}) : /* @__PURE__ */ f(nt, {
|
|
1515
1528
|
title: t,
|
|
1516
1529
|
rows: Math.min(a, 6),
|
|
1517
1530
|
collapsible: s,
|
|
@@ -1522,9 +1535,9 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1522
1535
|
filters: k,
|
|
1523
1536
|
facets: w
|
|
1524
1537
|
}) || !S && !A && Object.keys(k).length < 1) return null;
|
|
1525
|
-
if (!E?.includes(e) || !
|
|
1538
|
+
if (!E?.includes(e) || !D?.includes(e)) {
|
|
1526
1539
|
let n = [];
|
|
1527
|
-
return E?.includes(e) || n.push("filterable"),
|
|
1540
|
+
return E?.includes(e) || n.push("filterable"), D?.includes(e) || n.push("facetable"), /* @__PURE__ */ f(it, {
|
|
1528
1541
|
label: t,
|
|
1529
1542
|
field: e,
|
|
1530
1543
|
missing: n
|
|
@@ -1553,7 +1566,7 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1553
1566
|
collapsible: !1,
|
|
1554
1567
|
children: /* @__PURE__ */ f("div", {
|
|
1555
1568
|
className: X.count,
|
|
1556
|
-
children: /* @__PURE__ */ f(
|
|
1569
|
+
children: /* @__PURE__ */ f(P, {
|
|
1557
1570
|
label: t,
|
|
1558
1571
|
checked: !1,
|
|
1559
1572
|
onChange: () => {},
|
|
@@ -1568,7 +1581,7 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1568
1581
|
children: /* @__PURE__ */ p("div", {
|
|
1569
1582
|
className: X.count,
|
|
1570
1583
|
children: [
|
|
1571
|
-
/* @__PURE__ */ f(
|
|
1584
|
+
/* @__PURE__ */ f(P, {
|
|
1572
1585
|
label: t,
|
|
1573
1586
|
checked: i,
|
|
1574
1587
|
onChange: () => j(e, "true"),
|
|
@@ -1627,14 +1640,14 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1627
1640
|
children: `${t}${a}`
|
|
1628
1641
|
})
|
|
1629
1642
|
});
|
|
1630
|
-
case "toggle": return /* @__PURE__ */ f(
|
|
1643
|
+
case "toggle": return /* @__PURE__ */ f(P, {
|
|
1631
1644
|
label: t,
|
|
1632
1645
|
checked: r,
|
|
1633
1646
|
onChange: s,
|
|
1634
1647
|
disabled: i
|
|
1635
1648
|
});
|
|
1636
1649
|
case "radio": {
|
|
1637
|
-
let n = /* @__PURE__ */ f(
|
|
1650
|
+
let n = /* @__PURE__ */ f(O, {
|
|
1638
1651
|
id: `${e}-${t}`,
|
|
1639
1652
|
name: e,
|
|
1640
1653
|
value: t,
|
|
@@ -1712,37 +1725,37 @@ var Xe = ({ fields: e, resultsPerPage: t, parseArrayStrings: n = !1, searchOrAsk
|
|
|
1712
1725
|
};
|
|
1713
1726
|
//#endregion
|
|
1714
1727
|
//#region src/utils/numeric.ts
|
|
1715
|
-
function
|
|
1728
|
+
function ot(e) {
|
|
1716
1729
|
if (!Number.isFinite(e)) return 0;
|
|
1717
1730
|
let t = String(e), n = t.indexOf(".");
|
|
1718
1731
|
return n === -1 ? 0 : Math.min(6, t.length - n - 1);
|
|
1719
1732
|
}
|
|
1720
|
-
function
|
|
1733
|
+
function st(e) {
|
|
1721
1734
|
let t = 0;
|
|
1722
|
-
for (let n of e) t = Math.max(t,
|
|
1735
|
+
for (let n of e) t = Math.max(t, ot(n));
|
|
1723
1736
|
return t === 0 ? 1 : Number((10 ** -t).toFixed(t));
|
|
1724
1737
|
}
|
|
1725
1738
|
function Q(e, t) {
|
|
1726
|
-
return Number(e.toFixed(
|
|
1739
|
+
return Number(e.toFixed(ot(t)));
|
|
1727
1740
|
}
|
|
1728
1741
|
//#endregion
|
|
1729
1742
|
//#region src/components/RangeFilterPanel.tsx
|
|
1730
|
-
function
|
|
1743
|
+
function ct(e, t, n) {
|
|
1731
1744
|
let r = t + Math.round((e - t) / n) * n;
|
|
1732
|
-
return Number(r.toFixed(
|
|
1745
|
+
return Number(r.toFixed(ot(n)));
|
|
1733
1746
|
}
|
|
1734
|
-
function
|
|
1747
|
+
function lt(e, t, n) {
|
|
1735
1748
|
let r = Math.ceil(Number(((e - t) / n).toFixed(6)));
|
|
1736
|
-
return Number((t + r * n).toFixed(
|
|
1749
|
+
return Number((t + r * n).toFixed(ot(n)));
|
|
1737
1750
|
}
|
|
1738
|
-
var
|
|
1739
|
-
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(),
|
|
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] ?? {
|
|
1740
1753
|
min: r,
|
|
1741
1754
|
max: i
|
|
1742
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(() => {
|
|
1743
1756
|
if (m) return m;
|
|
1744
|
-
let e = Math.max(
|
|
1745
|
-
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)));
|
|
1746
1759
|
return e === 0 ? 1 : Number((10 ** -e).toFixed(e));
|
|
1747
1760
|
}, [
|
|
1748
1761
|
m,
|
|
@@ -1750,8 +1763,8 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1750
1763
|
I,
|
|
1751
1764
|
y,
|
|
1752
1765
|
t
|
|
1753
|
-
]), V = N && F === I, H = V ? r : F, U = V ? i : I, W =
|
|
1754
|
-
let e =
|
|
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);
|
|
1755
1768
|
return { width: `calc(${Math.max(3, F.toFixed(e).length, I.toFixed(e).length, le.length, de.length) + 1}ch + 20px)` };
|
|
1756
1769
|
}, [
|
|
1757
1770
|
B,
|
|
@@ -1843,7 +1856,7 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1843
1856
|
xe.current = null, J([F, I]), D(t, !0);
|
|
1844
1857
|
return;
|
|
1845
1858
|
}
|
|
1846
|
-
let i =
|
|
1859
|
+
let i = ct(Math.max(F, R, e), F, B), a = Math.max(i, ct(Math.min(I, z, n), F, B));
|
|
1847
1860
|
xe.current = {
|
|
1848
1861
|
start: e,
|
|
1849
1862
|
last: n
|
|
@@ -1939,13 +1952,13 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
1939
1952
|
B,
|
|
1940
1953
|
W
|
|
1941
1954
|
]), Ae = e.useMemo(() => Math.max(...ke.map((e) => e.count), 1), [ke]);
|
|
1942
|
-
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(
|
|
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, {
|
|
1943
1956
|
title: n,
|
|
1944
1957
|
variant: "slider",
|
|
1945
1958
|
withHistogram: u,
|
|
1946
1959
|
collapsible: c,
|
|
1947
1960
|
startCollapsed: l
|
|
1948
|
-
}) : !O && !S ? null : b?.includes(t) ?
|
|
1961
|
+
}) : !O && !S ? null : b?.includes(t) ? j === "slider" ? /* @__PURE__ */ p(T, {
|
|
1949
1962
|
title: n,
|
|
1950
1963
|
collapsed: l,
|
|
1951
1964
|
collapsible: c,
|
|
@@ -2026,12 +2039,12 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2026
2039
|
})(),
|
|
2027
2040
|
/* @__PURE__ */ f("div", {
|
|
2028
2041
|
style: { padding: "10px 10px 20px 10px" },
|
|
2029
|
-
children: /* @__PURE__ */ f(
|
|
2042
|
+
children: /* @__PURE__ */ f(M, {
|
|
2030
2043
|
min: H,
|
|
2031
2044
|
max: W,
|
|
2032
2045
|
step: B,
|
|
2033
2046
|
stepMarks: h,
|
|
2034
|
-
value: V ? [H, W] : [ee(
|
|
2047
|
+
value: V ? [H, W] : [ee(ct(me, H, B)), ee(ct(he + B, H, B))],
|
|
2035
2048
|
isRange: !0,
|
|
2036
2049
|
onChange: (e) => ye(e),
|
|
2037
2050
|
onFinalChange: (e) => be(e),
|
|
@@ -2119,12 +2132,12 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2119
2132
|
isValid: V || !se
|
|
2120
2133
|
})]
|
|
2121
2134
|
})]
|
|
2122
|
-
}) : /* @__PURE__ */ f(
|
|
2135
|
+
}) : /* @__PURE__ */ f(it, {
|
|
2123
2136
|
label: n,
|
|
2124
2137
|
field: t,
|
|
2125
2138
|
missing: ["filterable"]
|
|
2126
2139
|
});
|
|
2127
|
-
},
|
|
2140
|
+
}, dt = {
|
|
2128
2141
|
list: "_list_9je85_2",
|
|
2129
2142
|
grid: "_grid_9je85_9",
|
|
2130
2143
|
count: "_count_9je85_22",
|
|
@@ -2134,7 +2147,7 @@ var lt = ({ field: t, label: n, expectedMin: r = 0, expectedMax: i = 1e3, contro
|
|
|
2134
2147
|
};
|
|
2135
2148
|
//#endregion
|
|
2136
2149
|
//#region src/components/BucketFilterPanel.tsx
|
|
2137
|
-
function
|
|
2150
|
+
function ft(e, t) {
|
|
2138
2151
|
if (!t) return null;
|
|
2139
2152
|
let n = 0, r = !1;
|
|
2140
2153
|
for (let i of t) {
|
|
@@ -2146,15 +2159,15 @@ function dt(e, t) {
|
|
|
2146
2159
|
}
|
|
2147
2160
|
return r ? n : 0;
|
|
2148
2161
|
}
|
|
2149
|
-
var
|
|
2150
|
-
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);
|
|
2151
2164
|
o(() => {
|
|
2152
2165
|
L(m ?? Infinity);
|
|
2153
2166
|
}, [m, P]);
|
|
2154
2167
|
let R = w?.[e] ?? E?.[e], z = s(() => {
|
|
2155
2168
|
let e = [];
|
|
2156
2169
|
if (R && e.push(R.min, R.max), Array.isArray(P)) for (let t of P) e.push(Number(t.key));
|
|
2157
|
-
return
|
|
2170
|
+
return st(e.filter(Number.isFinite));
|
|
2158
2171
|
}, [R, P]), B = s(() => {
|
|
2159
2172
|
let e = R?.min ?? -Number.MAX_VALUE, t = R?.max ?? Number.MAX_VALUE, i = (n, r, i) => ({
|
|
2160
2173
|
label: i ?? (n === void 0 ? `up to ${r}` : r === void 0 ? `${n} and up` : `${n}-${r}`),
|
|
@@ -2183,27 +2196,27 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2183
2196
|
z
|
|
2184
2197
|
]);
|
|
2185
2198
|
if (A) return null;
|
|
2186
|
-
if (j || !v) return /* @__PURE__ */ f(
|
|
2199
|
+
if (j || !v) return /* @__PURE__ */ f(nt, {
|
|
2187
2200
|
title: t,
|
|
2188
2201
|
rows: Math.max(1, Math.min(B.length || 5, 8)),
|
|
2189
2202
|
collapsible: g,
|
|
2190
2203
|
startCollapsed: _
|
|
2191
2204
|
});
|
|
2192
|
-
if (!M && !
|
|
2193
|
-
if (!x?.includes(e)) return /* @__PURE__ */ f(
|
|
2205
|
+
if (!M && !D) return null;
|
|
2206
|
+
if (!x?.includes(e)) return /* @__PURE__ */ f(it, {
|
|
2194
2207
|
label: t,
|
|
2195
2208
|
field: e,
|
|
2196
2209
|
missing: ["filterable"]
|
|
2197
2210
|
});
|
|
2198
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) => ({
|
|
2199
2212
|
bucket: e,
|
|
2200
|
-
count: V ?
|
|
2213
|
+
count: V ? ft(e, P) : null
|
|
2201
2214
|
}));
|
|
2202
2215
|
if (d || (U = U.filter((e) => e.count !== 0 || H(e.bucket))), U.length === 0) return null;
|
|
2203
2216
|
let W = U.slice(0, I), ee = (t, n) => {
|
|
2204
2217
|
let r = H(t), i = n === 0 && !r, a = u && (n ?? 0) > 0 ? `${n}` : "", o = () => k(e, t.range, N === "radio");
|
|
2205
2218
|
if (N === "radio") {
|
|
2206
|
-
let n = /* @__PURE__ */ f(
|
|
2219
|
+
let n = /* @__PURE__ */ f(O, {
|
|
2207
2220
|
id: `${e}-${t.range.min}-${t.range.max}`,
|
|
2208
2221
|
name: e,
|
|
2209
2222
|
value: t.label,
|
|
@@ -2213,9 +2226,9 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2213
2226
|
disabled: i
|
|
2214
2227
|
});
|
|
2215
2228
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
2216
|
-
className:
|
|
2229
|
+
className: dt.count,
|
|
2217
2230
|
children: [n, /* @__PURE__ */ f("span", {
|
|
2218
|
-
className:
|
|
2231
|
+
className: dt.countValue,
|
|
2219
2232
|
children: a
|
|
2220
2233
|
})]
|
|
2221
2234
|
}) : n;
|
|
@@ -2226,19 +2239,19 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2226
2239
|
onClick: o,
|
|
2227
2240
|
disabled: i,
|
|
2228
2241
|
size: "micro",
|
|
2229
|
-
className:
|
|
2242
|
+
className: dt.chip,
|
|
2230
2243
|
children: c === "grid" && a ? `${t.label} (${a})` : t.label
|
|
2231
2244
|
});
|
|
2232
2245
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
2233
|
-
className:
|
|
2246
|
+
className: dt.count,
|
|
2234
2247
|
children: [e, /* @__PURE__ */ f("span", {
|
|
2235
|
-
className:
|
|
2248
|
+
className: dt.countValue,
|
|
2236
2249
|
children: a
|
|
2237
2250
|
})]
|
|
2238
2251
|
}) : e;
|
|
2239
2252
|
}
|
|
2240
2253
|
return c === "list" ? /* @__PURE__ */ p("div", {
|
|
2241
|
-
className:
|
|
2254
|
+
className: dt.count,
|
|
2242
2255
|
children: [/* @__PURE__ */ f(b, {
|
|
2243
2256
|
label: t.label,
|
|
2244
2257
|
score: "",
|
|
@@ -2246,7 +2259,7 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2246
2259
|
onChange: o,
|
|
2247
2260
|
disabled: i
|
|
2248
2261
|
}), /* @__PURE__ */ f("span", {
|
|
2249
|
-
className:
|
|
2262
|
+
className: dt.countValue,
|
|
2250
2263
|
children: a
|
|
2251
2264
|
})]
|
|
2252
2265
|
}) : /* @__PURE__ */ f(b, {
|
|
@@ -2261,9 +2274,9 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2261
2274
|
title: t,
|
|
2262
2275
|
collapsible: g,
|
|
2263
2276
|
collapsed: g ? _ : !1,
|
|
2264
|
-
className: h && F.length > 0 ?
|
|
2277
|
+
className: h && F.length > 0 ? dt.active : void 0,
|
|
2265
2278
|
children: /* @__PURE__ */ p("ul", {
|
|
2266
|
-
className: c === "grid" ?
|
|
2279
|
+
className: c === "grid" ? dt.grid : dt.list,
|
|
2267
2280
|
style: {
|
|
2268
2281
|
listStyle: "none",
|
|
2269
2282
|
padding: 0,
|
|
@@ -2277,34 +2290,34 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2277
2290
|
}) })]
|
|
2278
2291
|
})
|
|
2279
2292
|
});
|
|
2280
|
-
},
|
|
2293
|
+
}, mt = {
|
|
2281
2294
|
grid: "_grid_1xjna_2",
|
|
2282
2295
|
chip: "_chip_1xjna_21",
|
|
2283
2296
|
chipLabel: "_chipLabel_1xjna_32"
|
|
2284
|
-
},
|
|
2297
|
+
}, ht = r(({ field: e, value: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2285
2298
|
onClick: n,
|
|
2286
2299
|
iconRight: /* @__PURE__ */ f(ie, {}),
|
|
2287
2300
|
variant: "primary",
|
|
2288
2301
|
size: "micro",
|
|
2289
|
-
className:
|
|
2302
|
+
className: mt.chip,
|
|
2290
2303
|
title: `${e}: ${t}`,
|
|
2291
2304
|
children: /* @__PURE__ */ p("span", {
|
|
2292
|
-
className:
|
|
2305
|
+
className: mt.chipLabel,
|
|
2293
2306
|
children: [
|
|
2294
2307
|
e,
|
|
2295
2308
|
": ",
|
|
2296
2309
|
t
|
|
2297
2310
|
]
|
|
2298
2311
|
})
|
|
2299
|
-
}) })),
|
|
2312
|
+
}) })), gt = r(({ field: e, min: t, max: n, onReset: r }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2300
2313
|
onClick: r,
|
|
2301
2314
|
iconRight: /* @__PURE__ */ f(ie, {}),
|
|
2302
2315
|
variant: "primary",
|
|
2303
2316
|
size: "micro",
|
|
2304
|
-
className:
|
|
2317
|
+
className: mt.chip,
|
|
2305
2318
|
title: `${e}: ${t} – ${n}`,
|
|
2306
2319
|
children: /* @__PURE__ */ p("span", {
|
|
2307
|
-
className:
|
|
2320
|
+
className: mt.chipLabel,
|
|
2308
2321
|
children: [
|
|
2309
2322
|
e,
|
|
2310
2323
|
": ",
|
|
@@ -2313,15 +2326,15 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2313
2326
|
n
|
|
2314
2327
|
]
|
|
2315
2328
|
})
|
|
2316
|
-
}) })),
|
|
2329
|
+
}) })), _t = r(({ field: e, label: t, onReset: n }) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2317
2330
|
onClick: n,
|
|
2318
2331
|
iconRight: /* @__PURE__ */ f(ie, {}),
|
|
2319
2332
|
variant: "primary",
|
|
2320
2333
|
size: "micro",
|
|
2321
|
-
className:
|
|
2334
|
+
className: mt.chip,
|
|
2322
2335
|
title: `${e}: ${t}`,
|
|
2323
2336
|
children: /* @__PURE__ */ p("span", {
|
|
2324
|
-
className:
|
|
2337
|
+
className: mt.chipLabel,
|
|
2325
2338
|
children: [
|
|
2326
2339
|
e,
|
|
2327
2340
|
": ",
|
|
@@ -2329,7 +2342,7 @@ var ft = ({ field: e, label: t, width: n, buckets: r, control: i, displayType: a
|
|
|
2329
2342
|
]
|
|
2330
2343
|
})
|
|
2331
2344
|
}) }));
|
|
2332
|
-
function
|
|
2345
|
+
function vt() {
|
|
2333
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) => ({
|
|
2334
2347
|
field: e,
|
|
2335
2348
|
value: t
|
|
@@ -2350,20 +2363,20 @@ function _t() {
|
|
|
2350
2363
|
collapsible: !1,
|
|
2351
2364
|
title: "Active filters",
|
|
2352
2365
|
children: /* @__PURE__ */ p("ul", {
|
|
2353
|
-
className:
|
|
2366
|
+
className: mt.grid,
|
|
2354
2367
|
children: [
|
|
2355
|
-
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(
|
|
2368
|
+
c.map(({ field: e, value: t }) => /* @__PURE__ */ f(ht, {
|
|
2356
2369
|
field: e,
|
|
2357
2370
|
value: t,
|
|
2358
2371
|
onReset: () => i(e, t)
|
|
2359
2372
|
}, `${e}-${t}`)),
|
|
2360
|
-
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(
|
|
2373
|
+
l.map(({ field: e, min: t, max: n }) => /* @__PURE__ */ f(gt, {
|
|
2361
2374
|
field: e,
|
|
2362
2375
|
min: t,
|
|
2363
2376
|
max: n,
|
|
2364
2377
|
onReset: () => a(e)
|
|
2365
2378
|
}, e)),
|
|
2366
|
-
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(
|
|
2379
|
+
u.map(({ field: e, range: t, label: n }) => /* @__PURE__ */ f(_t, {
|
|
2367
2380
|
field: e,
|
|
2368
2381
|
label: n,
|
|
2369
2382
|
onReset: () => o(e, t)
|
|
@@ -2378,12 +2391,12 @@ function _t() {
|
|
|
2378
2391
|
})
|
|
2379
2392
|
}) : null;
|
|
2380
2393
|
}
|
|
2381
|
-
var
|
|
2394
|
+
var yt = {
|
|
2382
2395
|
select: "_select_nwf7i_1",
|
|
2383
2396
|
radioGroup: "_radioGroup_nwf7i_6"
|
|
2384
|
-
},
|
|
2397
|
+
}, bt = ({ options: e, noneLabel: t = "None", control: n, displayType: r, collapsible: i = !0, startCollapsed: a = !1 }) => {
|
|
2385
2398
|
let o = n ?? (r === "radio" ? "radio" : "select"), { state: { sortableFields: s, sortBy: c, sortAscending: l }, setSort: u, isFetchingInitial: d } = Y();
|
|
2386
|
-
if (d) return /* @__PURE__ */ f(
|
|
2399
|
+
if (d) return /* @__PURE__ */ f(nt, {
|
|
2387
2400
|
title: "Sort by",
|
|
2388
2401
|
rows: o === "radio" ? 3 : 1,
|
|
2389
2402
|
collapsible: i,
|
|
@@ -2413,15 +2426,15 @@ var vt = {
|
|
|
2413
2426
|
title: "Sort by",
|
|
2414
2427
|
collapsible: i,
|
|
2415
2428
|
collapsed: i ? a : !1,
|
|
2416
|
-
children: o === "select" ? /* @__PURE__ */ f(
|
|
2429
|
+
children: o === "select" ? /* @__PURE__ */ f(A, {
|
|
2417
2430
|
value: p,
|
|
2418
2431
|
onValueChange: g,
|
|
2419
2432
|
options: h,
|
|
2420
2433
|
placeholder: "Select sort...",
|
|
2421
2434
|
"aria-label": "Sort by"
|
|
2422
2435
|
}) : /* @__PURE__ */ f("div", {
|
|
2423
|
-
className:
|
|
2424
|
-
children: h.map((e) => /* @__PURE__ */ f(
|
|
2436
|
+
className: yt.radioGroup,
|
|
2437
|
+
children: h.map((e) => /* @__PURE__ */ f(O, {
|
|
2425
2438
|
id: `sort-${e.value}`,
|
|
2426
2439
|
name: "sort-by",
|
|
2427
2440
|
value: e.value,
|
|
@@ -2431,7 +2444,7 @@ var vt = {
|
|
|
2431
2444
|
}, e.value))
|
|
2432
2445
|
})
|
|
2433
2446
|
});
|
|
2434
|
-
},
|
|
2447
|
+
}, xt = { list: "_list_1y4fk_1" }, St = {
|
|
2435
2448
|
coverageDepth: 500,
|
|
2436
2449
|
coverWholeQuery: !0,
|
|
2437
2450
|
coverWholeWords: !0,
|
|
@@ -2446,7 +2459,7 @@ var vt = {
|
|
|
2446
2459
|
truncateWordHitTolerance: 0,
|
|
2447
2460
|
truncationScore: 65024
|
|
2448
2461
|
};
|
|
2449
|
-
function
|
|
2462
|
+
function Ct() {
|
|
2450
2463
|
let { state: { searchSettings: e }, setSearchSettings: t, url: n, team: r, dataset: i, authenticatedFetch: a } = Y(), [s, c] = l(!1), [u, m] = l(null);
|
|
2451
2464
|
o(() => {
|
|
2452
2465
|
let e = !0;
|
|
@@ -2464,7 +2477,7 @@ function St() {
|
|
|
2464
2477
|
i,
|
|
2465
2478
|
a
|
|
2466
2479
|
]);
|
|
2467
|
-
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) => {
|
|
2468
2481
|
let r = parseInt(n, 10);
|
|
2469
2482
|
isNaN(r) || t({ [e]: r });
|
|
2470
2483
|
}, w = (e, n) => {
|
|
@@ -2485,7 +2498,7 @@ function St() {
|
|
|
2485
2498
|
collapsed: !0,
|
|
2486
2499
|
title: "Settings",
|
|
2487
2500
|
children: /* @__PURE__ */ p("ul", {
|
|
2488
|
-
className:
|
|
2501
|
+
className: xt.list,
|
|
2489
2502
|
children: [
|
|
2490
2503
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(E, {
|
|
2491
2504
|
label: "Max Results",
|
|
@@ -2511,7 +2524,7 @@ function St() {
|
|
|
2511
2524
|
}
|
|
2512
2525
|
}), /* @__PURE__ */ f("div", {
|
|
2513
2526
|
style: { padding: "10px 10px 20px 10px" },
|
|
2514
|
-
children: /* @__PURE__ */ f(
|
|
2527
|
+
children: /* @__PURE__ */ f(M, {
|
|
2515
2528
|
min: 0,
|
|
2516
2529
|
max: 65535,
|
|
2517
2530
|
step: 1,
|
|
@@ -2530,17 +2543,17 @@ function St() {
|
|
|
2530
2543
|
t({ placeholderText: e.target.value });
|
|
2531
2544
|
}
|
|
2532
2545
|
}) }),
|
|
2533
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2546
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2534
2547
|
label: "Show score",
|
|
2535
2548
|
checked: e.showScore,
|
|
2536
2549
|
onChange: (e) => w("showScore", e)
|
|
2537
2550
|
}) }),
|
|
2538
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2551
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2539
2552
|
label: "Enable Coverage",
|
|
2540
2553
|
checked: e.enableCoverage,
|
|
2541
2554
|
onChange: (e) => w("enableCoverage", e)
|
|
2542
2555
|
}) }),
|
|
2543
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2556
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2544
2557
|
label: "Remove Duplicates",
|
|
2545
2558
|
checked: e.removeDuplicates,
|
|
2546
2559
|
onChange: (e) => w("removeDuplicates", e)
|
|
@@ -2548,42 +2561,42 @@ function St() {
|
|
|
2548
2561
|
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(y, {
|
|
2549
2562
|
variant: "ghost",
|
|
2550
2563
|
size: "micro",
|
|
2551
|
-
iconRight: f(s ?
|
|
2564
|
+
iconRight: f(s ? R : z, {}),
|
|
2552
2565
|
onClick: () => c((e) => !e),
|
|
2553
2566
|
children: s ? "Hide Coverage Setup" : "Show Coverage Setup"
|
|
2554
2567
|
}) }),
|
|
2555
2568
|
s && /* @__PURE__ */ p(d, { children: [
|
|
2556
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2569
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2557
2570
|
label: x("Cover Whole Query", g("coverWholeQuery")),
|
|
2558
2571
|
checked: _("coverWholeQuery"),
|
|
2559
2572
|
onChange: (e) => O("coverWholeQuery", e)
|
|
2560
2573
|
}) }),
|
|
2561
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2574
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2562
2575
|
label: x("Cover Whole Words", g("coverWholeWords")),
|
|
2563
2576
|
checked: _("coverWholeWords"),
|
|
2564
2577
|
onChange: (e) => O("coverWholeWords", e)
|
|
2565
2578
|
}) }),
|
|
2566
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2579
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2567
2580
|
label: x("Cover Fuzzy Words", g("coverFuzzyWords")),
|
|
2568
2581
|
checked: _("coverFuzzyWords"),
|
|
2569
2582
|
onChange: (e) => O("coverFuzzyWords", e)
|
|
2570
2583
|
}) }),
|
|
2571
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2584
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2572
2585
|
label: x("Cover Joined Words", g("coverJoinedWords")),
|
|
2573
2586
|
checked: _("coverJoinedWords"),
|
|
2574
2587
|
onChange: (e) => O("coverJoinedWords", e)
|
|
2575
2588
|
}) }),
|
|
2576
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2589
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2577
2590
|
label: x("Cover Prefix Suffix", g("coverPrefixSuffix")),
|
|
2578
2591
|
checked: _("coverPrefixSuffix"),
|
|
2579
2592
|
onChange: (e) => O("coverPrefixSuffix", e)
|
|
2580
2593
|
}) }),
|
|
2581
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2594
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2582
2595
|
label: x("Truncate", g("truncate")),
|
|
2583
2596
|
checked: _("truncate"),
|
|
2584
2597
|
onChange: (e) => O("truncate", e)
|
|
2585
2598
|
}) }),
|
|
2586
|
-
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(
|
|
2599
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f(P, {
|
|
2587
2600
|
label: x("Include Pattern Matches", g("includePatternMatches")),
|
|
2588
2601
|
checked: _("includePatternMatches"),
|
|
2589
2602
|
onChange: (e) => O("includePatternMatches", e)
|
|
@@ -2628,7 +2641,7 @@ function St() {
|
|
|
2628
2641
|
}
|
|
2629
2642
|
//#endregion
|
|
2630
2643
|
//#region src/components/SearchErrorBoundary.tsx
|
|
2631
|
-
var
|
|
2644
|
+
var wt = class extends t {
|
|
2632
2645
|
constructor(e) {
|
|
2633
2646
|
super(e), this.state = {
|
|
2634
2647
|
hasError: !1,
|
|
@@ -2710,7 +2723,7 @@ var Ct = class extends t {
|
|
|
2710
2723
|
};
|
|
2711
2724
|
//#endregion
|
|
2712
2725
|
//#region src/hooks/useVectorSearch.ts
|
|
2713
|
-
function
|
|
2726
|
+
function Tt(e, t) {
|
|
2714
2727
|
let { url: n, team: r, dataset: a, authenticatedFetch: o } = Y(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2715
2728
|
return {
|
|
2716
2729
|
results: s,
|
|
@@ -2766,7 +2779,7 @@ function wt(e, t) {
|
|
|
2766
2779
|
}
|
|
2767
2780
|
//#endregion
|
|
2768
2781
|
//#region src/hooks/useHybridSearch.ts
|
|
2769
|
-
function
|
|
2782
|
+
function Et(e, t) {
|
|
2770
2783
|
let { url: n, team: r, dataset: a, authenticatedFetch: o } = Y(), [s, c] = l(null), [u, d] = l(!1), [f, p] = l(void 0);
|
|
2771
2784
|
return {
|
|
2772
2785
|
results: s,
|
|
@@ -2826,14 +2839,14 @@ function Tt(e, t) {
|
|
|
2826
2839
|
}
|
|
2827
2840
|
//#endregion
|
|
2828
2841
|
//#region src/hooks/useFilterSuggestion.ts
|
|
2829
|
-
function
|
|
2842
|
+
function Dt(e) {
|
|
2830
2843
|
let t = e.trim().toLowerCase();
|
|
2831
2844
|
return t === "true" || t === "false" || t !== "" && !Number.isNaN(Number(t));
|
|
2832
2845
|
}
|
|
2833
|
-
function
|
|
2846
|
+
function Ot(e, t) {
|
|
2834
2847
|
if (!t) return null;
|
|
2835
2848
|
let n = [];
|
|
2836
|
-
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({
|
|
2837
2850
|
field: e,
|
|
2838
2851
|
value: t.key
|
|
2839
2852
|
});
|
|
@@ -2852,14 +2865,14 @@ function Dt(e, t) {
|
|
|
2852
2865
|
sort: null
|
|
2853
2866
|
};
|
|
2854
2867
|
}
|
|
2855
|
-
function
|
|
2868
|
+
function kt(e = {}) {
|
|
2856
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);
|
|
2857
2870
|
h.current = t;
|
|
2858
2871
|
let [g, _] = l(null), [v, y] = l(""), [b, x] = l(!1), S = c(0), C = i(async (e) => {
|
|
2859
2872
|
let t = ++S.current;
|
|
2860
2873
|
x(!0);
|
|
2861
2874
|
try {
|
|
2862
|
-
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)}`, {
|
|
2863
2876
|
method: "POST",
|
|
2864
2877
|
headers: { "Content-Type": "application/json" },
|
|
2865
2878
|
body: JSON.stringify({ text: e })
|
|
@@ -2898,7 +2911,7 @@ function Ot(e = {}) {
|
|
|
2898
2911
|
return o(() => {
|
|
2899
2912
|
if (!A || !j || P || E.current.has(j)) return;
|
|
2900
2913
|
E.current.add(j);
|
|
2901
|
-
let e =
|
|
2914
|
+
let e = Ot(j, N);
|
|
2902
2915
|
if (e && (E.current.add(e.text), w(e), O(j)), k !== "model") return;
|
|
2903
2916
|
let t = e ? e.text : j;
|
|
2904
2917
|
if (!t) return;
|
|
@@ -2907,7 +2920,7 @@ function Ot(e = {}) {
|
|
|
2907
2920
|
let o = ++S.current;
|
|
2908
2921
|
x(!0);
|
|
2909
2922
|
try {
|
|
2910
|
-
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)}`, {
|
|
2911
2924
|
method: "POST",
|
|
2912
2925
|
headers: { "Content-Type": "application/json" },
|
|
2913
2926
|
body: JSON.stringify({ text: t })
|
|
@@ -2946,17 +2959,17 @@ function Ot(e = {}) {
|
|
|
2946
2959
|
}
|
|
2947
2960
|
//#endregion
|
|
2948
2961
|
//#region src/hooks/useAsk.ts
|
|
2949
|
-
var
|
|
2962
|
+
var At = {
|
|
2950
2963
|
question: "",
|
|
2951
2964
|
status: "idle",
|
|
2952
2965
|
answer: "",
|
|
2953
2966
|
sources: [],
|
|
2954
2967
|
steps: []
|
|
2955
2968
|
};
|
|
2956
|
-
function
|
|
2969
|
+
function jt() {
|
|
2957
2970
|
let e = Y(), { url: t, team: n, dataset: r, authenticatedFetch: a } = e, s = c(e);
|
|
2958
2971
|
s.current = e;
|
|
2959
|
-
let [u, d] = l(
|
|
2972
|
+
let [u, d] = l(At), f = c(u);
|
|
2960
2973
|
f.current = u;
|
|
2961
2974
|
let p = c(null), m = i(async (e, i = []) => {
|
|
2962
2975
|
let o = e.trim();
|
|
@@ -2988,7 +3001,7 @@ function At() {
|
|
|
2988
3001
|
}
|
|
2989
3002
|
}));
|
|
2990
3003
|
try {
|
|
2991
|
-
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)}`, {
|
|
2992
3005
|
method: "POST",
|
|
2993
3006
|
headers: {
|
|
2994
3007
|
"Content-Type": "application/json",
|
|
@@ -3018,7 +3031,7 @@ function At() {
|
|
|
3018
3031
|
h(t.code ?? `http${e.status}`, t.detail ?? "The question could not be asked.");
|
|
3019
3032
|
return;
|
|
3020
3033
|
}
|
|
3021
|
-
for await (let { event: t, data: n } of
|
|
3034
|
+
for await (let { event: t, data: n } of Oe(e.body)) switch (t) {
|
|
3022
3035
|
case "status": {
|
|
3023
3036
|
let e = n.step;
|
|
3024
3037
|
e && d((t) => ({
|
|
@@ -3094,7 +3107,7 @@ function At() {
|
|
|
3094
3107
|
r,
|
|
3095
3108
|
a
|
|
3096
3109
|
]), g = i(() => p.current?.abort(), []), _ = i(() => {
|
|
3097
|
-
p.current?.abort(), d(
|
|
3110
|
+
p.current?.abort(), d(At);
|
|
3098
3111
|
}, []);
|
|
3099
3112
|
return o(() => () => p.current?.abort(), []), {
|
|
3100
3113
|
...u,
|
|
@@ -3121,18 +3134,18 @@ var $ = {
|
|
|
3121
3134
|
searchedLabel: "_searchedLabel_gjc13_23",
|
|
3122
3135
|
steps: "_steps_gjc13_26",
|
|
3123
3136
|
stepDone: "_stepDone_gjc13_27"
|
|
3124
|
-
},
|
|
3125
|
-
function
|
|
3137
|
+
}, Mt = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*|_[^_\n]+_)|(\[[^\]\n]+\]\(https?:\/\/[^)\s]+\))|(\[\d+\])/g;
|
|
3138
|
+
function Nt(t, n, r) {
|
|
3126
3139
|
let i = [], a = 0, o = 0;
|
|
3127
|
-
for (let s of t.matchAll(
|
|
3140
|
+
for (let s of t.matchAll(Mt)) {
|
|
3128
3141
|
s.index > a && i.push(t.slice(a, s.index));
|
|
3129
3142
|
let c = `${r}-${o++}`, [l, u, d, p, m, h] = s;
|
|
3130
3143
|
if (u) i.push(/* @__PURE__ */ f("code", {
|
|
3131
3144
|
className: $.inlineCode,
|
|
3132
3145
|
children: u.slice(1, -1)
|
|
3133
3146
|
}, c));
|
|
3134
|
-
else if (d) i.push(/* @__PURE__ */ f("strong", { children:
|
|
3135
|
-
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));
|
|
3136
3149
|
else if (m) {
|
|
3137
3150
|
let [, e, t] = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(m);
|
|
3138
3151
|
i.push(/* @__PURE__ */ f("a", {
|
|
@@ -3146,7 +3159,7 @@ function Mt(t, n, r) {
|
|
|
3146
3159
|
}
|
|
3147
3160
|
return a < t.length && i.push(t.slice(a)), i;
|
|
3148
3161
|
}
|
|
3149
|
-
function
|
|
3162
|
+
function Pt(e) {
|
|
3150
3163
|
let t = e.replace(/\r\n/g, "\n").split("\n"), n = [], r = [], i = () => {
|
|
3151
3164
|
r.length && (n.push({
|
|
3152
3165
|
kind: "paragraph",
|
|
@@ -3199,8 +3212,8 @@ function Nt(e) {
|
|
|
3199
3212
|
}
|
|
3200
3213
|
return i(), n;
|
|
3201
3214
|
}
|
|
3202
|
-
function
|
|
3203
|
-
return
|
|
3215
|
+
function Ft(e, t) {
|
|
3216
|
+
return Pt(e).map((e, n) => {
|
|
3204
3217
|
let r = `b${n}`;
|
|
3205
3218
|
switch (e.kind) {
|
|
3206
3219
|
case "code": return /* @__PURE__ */ f("pre", {
|
|
@@ -3210,28 +3223,28 @@ function Pt(e, t) {
|
|
|
3210
3223
|
}, r);
|
|
3211
3224
|
case "heading": return /* @__PURE__ */ f("p", {
|
|
3212
3225
|
className: $.heading,
|
|
3213
|
-
children:
|
|
3226
|
+
children: Nt(e.text, t, r)
|
|
3214
3227
|
}, r);
|
|
3215
3228
|
case "list": return /* @__PURE__ */ f(e.ordered ? "ol" : "ul", {
|
|
3216
3229
|
className: $.list,
|
|
3217
|
-
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))
|
|
3218
3231
|
}, r);
|
|
3219
3232
|
default: return /* @__PURE__ */ f("p", {
|
|
3220
3233
|
className: $.paragraph,
|
|
3221
|
-
children:
|
|
3234
|
+
children: Nt(e.text, t, r)
|
|
3222
3235
|
}, r);
|
|
3223
3236
|
}
|
|
3224
3237
|
});
|
|
3225
3238
|
}
|
|
3226
3239
|
//#endregion
|
|
3227
3240
|
//#region src/components/AskPanel.tsx
|
|
3228
|
-
var
|
|
3229
|
-
function
|
|
3241
|
+
var It = /\[(\d+)\]/g;
|
|
3242
|
+
function Lt(e) {
|
|
3230
3243
|
let t = e.field.split(".")[0];
|
|
3231
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;
|
|
3232
3245
|
}
|
|
3233
|
-
var
|
|
3234
|
-
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);
|
|
3235
3248
|
o(() => {
|
|
3236
3249
|
L([]), B.current = [], e?.trim() ? D(e) : O();
|
|
3237
3250
|
}, [
|
|
@@ -3252,7 +3265,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3252
3265
|
E.answer,
|
|
3253
3266
|
E.steps.length,
|
|
3254
3267
|
A,
|
|
3255
|
-
|
|
3268
|
+
F.length
|
|
3256
3269
|
]);
|
|
3257
3270
|
let ee = () => {
|
|
3258
3271
|
let e = H.current;
|
|
@@ -3285,7 +3298,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3285
3298
|
})
|
|
3286
3299
|
]
|
|
3287
3300
|
});
|
|
3288
|
-
if (A === "idle" &&
|
|
3301
|
+
if (A === "idle" && F.length === 0) return null;
|
|
3289
3302
|
let K = (e, t) => (r) => {
|
|
3290
3303
|
r.preventDefault(), j(e, t), n?.(e);
|
|
3291
3304
|
}, ne = (e, t) => (r) => {
|
|
@@ -3296,7 +3309,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3296
3309
|
onClick: i && n ? K(i, t) : void 0
|
|
3297
3310
|
});
|
|
3298
3311
|
}, re = (e, t, n) => {
|
|
3299
|
-
let r = new Set([...e.matchAll(
|
|
3312
|
+
let r = new Set([...e.matchAll(It)].map((e) => Number(e[1])));
|
|
3300
3313
|
return n && r.size > 0 ? t.filter((e) => r.has(e.n)) : t.slice(0, 3);
|
|
3301
3314
|
}, ie = (e, t, r, i) => {
|
|
3302
3315
|
let a = re(e, t, r);
|
|
@@ -3306,7 +3319,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3306
3319
|
onClick: n ? K(e, i) : void 0
|
|
3307
3320
|
})) });
|
|
3308
3321
|
}, q = () => {
|
|
3309
|
-
navigator.clipboard?.writeText(E.answer.replace(
|
|
3322
|
+
navigator.clipboard?.writeText(E.answer.replace(It, "")).catch(() => {}), P(!0), setTimeout(() => P(!1), 2e3);
|
|
3310
3323
|
}, J = (e) => {
|
|
3311
3324
|
if (!(E.busy || !e.trim())) {
|
|
3312
3325
|
if (A === "answered" && E.answer) {
|
|
@@ -3338,9 +3351,9 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3338
3351
|
ref: H,
|
|
3339
3352
|
className: $.thread,
|
|
3340
3353
|
onScroll: b ? ee : void 0,
|
|
3341
|
-
children: [
|
|
3354
|
+
children: [F.map((e, t) => /* @__PURE__ */ p("div", {
|
|
3342
3355
|
className: $.turn,
|
|
3343
|
-
children: [/* @__PURE__ */ f(
|
|
3356
|
+
children: [/* @__PURE__ */ f(I, { children: e.question }), /* @__PURE__ */ p(v, {
|
|
3344
3357
|
label: r,
|
|
3345
3358
|
children: [
|
|
3346
3359
|
G(e.filters),
|
|
@@ -3353,7 +3366,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3353
3366
|
})]
|
|
3354
3367
|
}, t)), A !== "idle" && /* @__PURE__ */ p("div", {
|
|
3355
3368
|
className: $.turn,
|
|
3356
|
-
children: [/* @__PURE__ */ f(
|
|
3369
|
+
children: [/* @__PURE__ */ f(I, { children: E.question }), /* @__PURE__ */ p(v, {
|
|
3357
3370
|
label: r,
|
|
3358
3371
|
children: [
|
|
3359
3372
|
G(E.filters),
|
|
@@ -3366,10 +3379,10 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3366
3379
|
children: [E.steps.slice(0, -1).map((e, t) => /* @__PURE__ */ f("span", {
|
|
3367
3380
|
className: $.stepDone,
|
|
3368
3381
|
children: e
|
|
3369
|
-
}, t)), /* @__PURE__ */ p(
|
|
3382
|
+
}, t)), /* @__PURE__ */ p(N, { children: [E.steps[E.steps.length - 1], "…"] })]
|
|
3370
3383
|
}),
|
|
3371
|
-
A === "searching" && E.steps.length === 0 && /* @__PURE__ */ f(
|
|
3372
|
-
A === "writing" && /* @__PURE__ */ f(
|
|
3384
|
+
A === "searching" && E.steps.length === 0 && /* @__PURE__ */ f(N, { children: "Searching…" }),
|
|
3385
|
+
A === "writing" && /* @__PURE__ */ f(N, {
|
|
3373
3386
|
spinner: "grow",
|
|
3374
3387
|
children: "Writing…"
|
|
3375
3388
|
}),
|
|
@@ -3403,7 +3416,7 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3403
3416
|
A !== "error" && A !== "limited" && ie(E.answer, E.sources, A === "answered"),
|
|
3404
3417
|
A === "answered" && /* @__PURE__ */ f(_, {
|
|
3405
3418
|
onCopy: q,
|
|
3406
|
-
copied:
|
|
3419
|
+
copied: M,
|
|
3407
3420
|
onFollowUp: ae
|
|
3408
3421
|
})
|
|
3409
3422
|
]
|
|
@@ -3422,4 +3435,4 @@ var Lt = ({ question: e, followUps: t = !1, onSourceClick: n, label: r = "Answer
|
|
|
3422
3435
|
});
|
|
3423
3436
|
};
|
|
3424
3437
|
//#endregion
|
|
3425
|
-
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 };
|