@ecomid/modules 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +4 -2
- package/dist/chunks/{resultsStore-3P0rGTOF.js → resultsStore-DuG3wQlt.js} +296 -281
- package/dist/chunks/{searchPage-BDL83WXl.d.ts → searchPage-CwY8JW57.d.ts} +1 -7
- package/dist/react.d.ts +5 -1
- package/dist/react.js +1201 -1166
- package/dist/search/styles.css +1 -1
- package/dist/search.d.ts +2 -2
- package/dist/search.js +30 -30
- package/package.json +20 -6
|
@@ -160,9 +160,11 @@ var _ = (e, t) => g(() => fetch(e, t), { shouldRetry: (e) => e instanceof TypeEr
|
|
|
160
160
|
function y(e) {
|
|
161
161
|
v = e;
|
|
162
162
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
var b = class extends Error {
|
|
164
|
+
constructor() {
|
|
165
|
+
super("pixel unavailable"), this.name = "RelayUnavailableError";
|
|
166
|
+
}
|
|
167
|
+
};
|
|
166
168
|
function x() {
|
|
167
169
|
return v?.isSignedIn() ? "user" : "guest";
|
|
168
170
|
}
|
|
@@ -170,7 +172,7 @@ async function S(e, t) {
|
|
|
170
172
|
if (v?.isSignedIn() && v.canRelay(e)) try {
|
|
171
173
|
return await v.fetch(e, t ?? {});
|
|
172
174
|
} catch (e) {
|
|
173
|
-
if (
|
|
175
|
+
if (t?.method === "POST" || !(e instanceof b)) throw e;
|
|
174
176
|
}
|
|
175
177
|
return t?.method === "POST" ? fetch(e, t) : _(e, t);
|
|
176
178
|
}
|
|
@@ -286,7 +288,7 @@ function ee(e, t) {
|
|
|
286
288
|
return r ? `?${r}` : "";
|
|
287
289
|
}
|
|
288
290
|
// src/contexts/Locale/langs.ts
|
|
289
|
-
var
|
|
291
|
+
var te = [
|
|
290
292
|
"en",
|
|
291
293
|
"da",
|
|
292
294
|
"de",
|
|
@@ -301,13 +303,13 @@ var I = [
|
|
|
301
303
|
"cs",
|
|
302
304
|
"sk",
|
|
303
305
|
"pt"
|
|
304
|
-
],
|
|
306
|
+
], I = (e) => te.find((t) => t === e) ?? "en";
|
|
305
307
|
// src/helpers/preview.ts
|
|
306
|
-
function
|
|
308
|
+
function L() {
|
|
307
309
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("preview") === "true";
|
|
308
310
|
}
|
|
309
311
|
// src/helpers/random.ts
|
|
310
|
-
var
|
|
312
|
+
var ne = (e) => {
|
|
311
313
|
let t = [...e];
|
|
312
314
|
for (let e = t.length - 1; e > 0; e--) {
|
|
313
315
|
let n = Math.floor(Math.random() * (e + 1));
|
|
@@ -316,15 +318,15 @@ var te = (e) => {
|
|
|
316
318
|
return t;
|
|
317
319
|
};
|
|
318
320
|
// src/helpers/request/cgw/searchStartQuery.ts
|
|
319
|
-
function
|
|
321
|
+
function re(e) {
|
|
320
322
|
let t = new URLSearchParams();
|
|
321
323
|
t.set("location", e.location), e.surface && t.set("surface", e.surface), e.market && t.set("market", e.market), t.set("locale", e.locale), e.category && t.set("category", e.category);
|
|
322
324
|
for (let n of e.variantIds ?? []) t.append("variant_ids", n);
|
|
323
325
|
for (let n of e.skus ?? []) t.append("skus", n);
|
|
324
|
-
return
|
|
326
|
+
return L() && t.append("preview", "true"), t.toString();
|
|
325
327
|
}
|
|
326
328
|
// src/search/core/api.ts
|
|
327
|
-
function
|
|
329
|
+
function R(e) {
|
|
328
330
|
let t = {
|
|
329
331
|
id: e.variant_id,
|
|
330
332
|
name: e.name
|
|
@@ -335,44 +337,44 @@ function z(e) {
|
|
|
335
337
|
let r = e.images?.[1];
|
|
336
338
|
return r?.url !== void 0 && (t.hoverImageUrl = r.url), r?.tags !== void 0 && (t.hoverImageTags = r.tags), e.current_price_in_cents !== void 0 && (t.price = e.current_price_in_cents / 100), e.baseline_price_in_cents !== void 0 && (t.baselinePrice = e.baseline_price_in_cents / 100), e.currency_code !== void 0 && (t.currency = e.currency_code), e.variant_count !== void 0 && (t.variantCount = e.variant_count), e.reason && (t.reason = e.reason), t;
|
|
337
339
|
}
|
|
338
|
-
function
|
|
340
|
+
function ie(e) {
|
|
339
341
|
return {
|
|
340
342
|
suggestions: (e.suggestions ?? []).map((e) => ({ text: e.text ?? "" })).filter((e) => e.text.length > 0),
|
|
341
|
-
products: (e.products ?? []).map(
|
|
343
|
+
products: (e.products ?? []).map(R)
|
|
342
344
|
};
|
|
343
345
|
}
|
|
344
|
-
function
|
|
346
|
+
function z(e) {
|
|
345
347
|
return e ?? "https://cgw.ecomid.com";
|
|
346
348
|
}
|
|
347
|
-
function
|
|
349
|
+
function ae(e) {
|
|
348
350
|
let t = new URLSearchParams();
|
|
349
|
-
return t.set("q", e.query), t.set("market", e.market), t.set("locale",
|
|
351
|
+
return t.set("q", e.query), t.set("market", e.market), t.set("locale", I(e.lang)), e.limit !== void 0 && t.set("limit", String(e.limit)), L() && t.set("preview", "true"), t.toString();
|
|
350
352
|
}
|
|
351
|
-
async function
|
|
352
|
-
let r = await S(`${
|
|
353
|
+
async function B(e, t, n) {
|
|
354
|
+
let r = await S(`${z(t.baseUrl)}/v0/search/${e}/suggestions?${ae(t)}`, { signal: n });
|
|
353
355
|
if (!r.ok) throw new c(`search suggestions request failed with status ${r.status}`, r.status);
|
|
354
|
-
return
|
|
356
|
+
return ie(await r.json());
|
|
355
357
|
}
|
|
356
358
|
function oe(e) {
|
|
357
359
|
return {
|
|
358
360
|
starters: (e.search_starters ?? []).map((e) => ({ text: e.text })),
|
|
359
|
-
recommendedProducts: (e.recommended_products ?? []).map(
|
|
361
|
+
recommendedProducts: (e.recommended_products ?? []).map(R)
|
|
360
362
|
};
|
|
361
363
|
}
|
|
362
364
|
var se = 10;
|
|
363
365
|
function ce(e) {
|
|
364
|
-
return
|
|
366
|
+
return ne(e).slice(0, se);
|
|
365
367
|
}
|
|
366
|
-
async function
|
|
367
|
-
let n =
|
|
368
|
+
async function le(e, t) {
|
|
369
|
+
let n = re({
|
|
368
370
|
location: t.location ?? "landing",
|
|
369
371
|
surface: "search",
|
|
370
372
|
market: t.market,
|
|
371
|
-
locale:
|
|
373
|
+
locale: I(t.lang),
|
|
372
374
|
category: t.category,
|
|
373
375
|
variantIds: t.variantIds,
|
|
374
376
|
skus: t.skus
|
|
375
|
-
}), r = await S(`${
|
|
377
|
+
}), r = await S(`${z(t.baseUrl)}/v0/search/${e}/start?${n}`);
|
|
376
378
|
if (!r.ok) throw new c(`search start request failed with status ${r.status}`, r.status);
|
|
377
379
|
let i = oe(await r.json());
|
|
378
380
|
return {
|
|
@@ -381,29 +383,29 @@ async function V(e, t) {
|
|
|
381
383
|
};
|
|
382
384
|
}
|
|
383
385
|
// src/helpers/storage.ts
|
|
384
|
-
var
|
|
386
|
+
var ue = () => {
|
|
385
387
|
try {
|
|
386
388
|
return window.localStorage ?? null;
|
|
387
389
|
} catch {
|
|
388
390
|
return null;
|
|
389
391
|
}
|
|
390
392
|
};
|
|
391
|
-
function
|
|
393
|
+
function de(e) {
|
|
392
394
|
if (e instanceof Error) {
|
|
393
395
|
if (e.message.includes("The operation is insecure") || e.message.includes("Access is denied for this document")) return;
|
|
394
396
|
l(e);
|
|
395
397
|
}
|
|
396
398
|
}
|
|
397
|
-
var
|
|
398
|
-
let n =
|
|
399
|
+
var fe = (e, t) => {
|
|
400
|
+
let n = ue();
|
|
399
401
|
if (n) try {
|
|
400
402
|
let r = n.getItem(e);
|
|
401
403
|
if (r) return t ? JSON.parse(r)[t] : JSON.parse(r);
|
|
402
404
|
} catch (e) {
|
|
403
|
-
|
|
405
|
+
de(e);
|
|
404
406
|
}
|
|
405
|
-
},
|
|
406
|
-
let i =
|
|
407
|
+
}, pe = (e, t, n, r = !1) => {
|
|
408
|
+
let i = ue();
|
|
407
409
|
if (i) try {
|
|
408
410
|
if (!r && !d().preferences) return;
|
|
409
411
|
let a = JSON.parse(i.getItem(e) || "{}"), o = a[t] || {}, s = n;
|
|
@@ -415,31 +417,31 @@ var le = (e, t) => {
|
|
|
415
417
|
[t]: s
|
|
416
418
|
}));
|
|
417
419
|
} catch (e) {
|
|
418
|
-
|
|
420
|
+
de(e);
|
|
419
421
|
}
|
|
420
|
-
},
|
|
421
|
-
function
|
|
422
|
+
}, V = "ec_search", me = "recent", he = 5;
|
|
423
|
+
function ge(e) {
|
|
422
424
|
return e.trim().toLowerCase();
|
|
423
425
|
}
|
|
424
|
-
function
|
|
425
|
-
let e =
|
|
426
|
+
function _e() {
|
|
427
|
+
let e = fe(V, me);
|
|
426
428
|
return Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
|
|
427
429
|
}
|
|
428
|
-
function
|
|
429
|
-
let t = e.trim(), n =
|
|
430
|
+
function ve(e) {
|
|
431
|
+
let t = e.trim(), n = _e();
|
|
430
432
|
if (t.length === 0) return n;
|
|
431
|
-
let r = [t, ...n.filter((e) =>
|
|
432
|
-
return
|
|
433
|
+
let r = [t, ...n.filter((e) => ge(e) !== ge(t))].slice(0, he);
|
|
434
|
+
return pe(V, me, r), r;
|
|
433
435
|
}
|
|
434
436
|
// src/search/core/store.ts
|
|
435
|
-
function
|
|
437
|
+
function H(e) {
|
|
436
438
|
return e.trim();
|
|
437
439
|
}
|
|
438
|
-
function
|
|
440
|
+
function ye(e) {
|
|
439
441
|
return e instanceof Error && e.name === "AbortError";
|
|
440
442
|
}
|
|
441
|
-
function
|
|
442
|
-
let { clientId: t, market: n, lang: r, location: i, baseUrl: a, debounceMs: o = 150, minQueryLength: s = 2, suggestLimit: c = 12, cacheLimit: l = 20 } = e, u = e.fetchers?.fetchSuggestions ??
|
|
443
|
+
function be(e) {
|
|
444
|
+
let { clientId: t, market: n, lang: r, location: i, baseUrl: a, debounceMs: o = 150, minQueryLength: s = 2, suggestLimit: c = 12, cacheLimit: l = 20 } = e, u = e.fetchers?.fetchSuggestions ?? B, d = e.fetchers?.fetchEmptyState ?? le, f = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Map(), m = {
|
|
443
445
|
query: "",
|
|
444
446
|
status: "idle",
|
|
445
447
|
instant: null,
|
|
@@ -494,7 +496,7 @@ function ve(e) {
|
|
|
494
496
|
instant: s
|
|
495
497
|
});
|
|
496
498
|
} catch (e) {
|
|
497
|
-
if (i !== _ ||
|
|
499
|
+
if (i !== _ || ye(e)) return;
|
|
498
500
|
y({
|
|
499
501
|
...m,
|
|
500
502
|
status: "error"
|
|
@@ -503,7 +505,7 @@ function ve(e) {
|
|
|
503
505
|
}
|
|
504
506
|
function T(e) {
|
|
505
507
|
S();
|
|
506
|
-
let t =
|
|
508
|
+
let t = H(e);
|
|
507
509
|
t.length < s ? (C(), _ += 1, y({
|
|
508
510
|
...m,
|
|
509
511
|
query: e,
|
|
@@ -519,8 +521,8 @@ function ve(e) {
|
|
|
519
521
|
}
|
|
520
522
|
function E() {
|
|
521
523
|
S(), C(), _ += 1;
|
|
522
|
-
let e =
|
|
523
|
-
return
|
|
524
|
+
let e = H(m.query);
|
|
525
|
+
return ve(e), y({
|
|
524
526
|
...m,
|
|
525
527
|
status: "idle"
|
|
526
528
|
}), e.length > 0 ? e : null;
|
|
@@ -554,7 +556,7 @@ function ve(e) {
|
|
|
554
556
|
}
|
|
555
557
|
}
|
|
556
558
|
function O() {
|
|
557
|
-
let e =
|
|
559
|
+
let e = H(m.query);
|
|
558
560
|
e.length < s || (S(), w(e));
|
|
559
561
|
}
|
|
560
562
|
function k() {
|
|
@@ -584,7 +586,7 @@ function ve(e) {
|
|
|
584
586
|
};
|
|
585
587
|
}
|
|
586
588
|
// src/search/core/text.ts
|
|
587
|
-
var
|
|
589
|
+
var xe = (e) => e.charAt(0).toUpperCase() + e.slice(1), Se = /* @__PURE__ */ new Set([
|
|
588
590
|
"how",
|
|
589
591
|
"what",
|
|
590
592
|
"which",
|
|
@@ -600,7 +602,7 @@ var ye = (e) => e.charAt(0).toUpperCase() + e.slice(1), be = /* @__PURE__ */ new
|
|
|
600
602
|
"varfor",
|
|
601
603
|
"vem",
|
|
602
604
|
"vart"
|
|
603
|
-
]),
|
|
605
|
+
]), Ce = /* @__PURE__ */ new Set([
|
|
604
606
|
"need",
|
|
605
607
|
"needs",
|
|
606
608
|
"want",
|
|
@@ -617,12 +619,12 @@ var ye = (e) => e.charAt(0).toUpperCase() + e.slice(1), be = /* @__PURE__ */ new
|
|
|
617
619
|
"nagon",
|
|
618
620
|
"nagra",
|
|
619
621
|
"tips"
|
|
620
|
-
]),
|
|
622
|
+
]), we = [
|
|
621
623
|
"recommend",
|
|
622
624
|
"suggest",
|
|
623
625
|
"rekommend",
|
|
624
626
|
"foresl"
|
|
625
|
-
],
|
|
627
|
+
], Te = [
|
|
626
628
|
"looking for",
|
|
627
629
|
"show me",
|
|
628
630
|
"give me",
|
|
@@ -631,7 +633,7 @@ var ye = (e) => e.charAt(0).toUpperCase() + e.slice(1), be = /* @__PURE__ */ new
|
|
|
631
633
|
"visa mig",
|
|
632
634
|
"ge mig",
|
|
633
635
|
"hjalp mig"
|
|
634
|
-
],
|
|
636
|
+
], Ee = [
|
|
635
637
|
"jag",
|
|
636
638
|
"vi",
|
|
637
639
|
"we",
|
|
@@ -639,7 +641,7 @@ var ye = (e) => e.charAt(0).toUpperCase() + e.slice(1), be = /* @__PURE__ */ new
|
|
|
639
641
|
"i m",
|
|
640
642
|
"i am",
|
|
641
643
|
"i ve"
|
|
642
|
-
],
|
|
644
|
+
], De = [
|
|
643
645
|
"can",
|
|
644
646
|
"could",
|
|
645
647
|
"do",
|
|
@@ -660,96 +662,96 @@ var ye = (e) => e.charAt(0).toUpperCase() + e.slice(1), be = /* @__PURE__ */ new
|
|
|
660
662
|
"maste",
|
|
661
663
|
"hjalp",
|
|
662
664
|
"gar det"
|
|
663
|
-
],
|
|
664
|
-
function
|
|
665
|
+
], Oe = (e, t) => t.some((t) => e.startsWith(` ${t} `));
|
|
666
|
+
function ke(e) {
|
|
665
667
|
if (e.includes("?")) return !0;
|
|
666
668
|
let t = e.toLowerCase().normalize("NFD").replace(/\p{M}/gu, "").split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
667
669
|
if (t.length < 2) return !1;
|
|
668
670
|
let n = ` ${t.join(" ")} `;
|
|
669
|
-
return t.slice(0, -1).some((e) =>
|
|
671
|
+
return t.slice(0, -1).some((e) => Se.has(e)) || t.some((e) => Ce.has(e) || we.some((t) => e.startsWith(t))) || Te.some((e) => n.includes(` ${e} `)) || Oe(n, Ee) || t.length >= 3 && Oe(n, De);
|
|
670
672
|
}
|
|
671
|
-
function
|
|
673
|
+
function Ae(e) {
|
|
672
674
|
let t = e.trim();
|
|
673
|
-
return t &&
|
|
675
|
+
return t && ke(t) ? [{
|
|
674
676
|
text: t,
|
|
675
677
|
ask: !0
|
|
676
678
|
}] : [];
|
|
677
679
|
}
|
|
678
680
|
// src/search/core/filters.ts
|
|
679
|
-
var
|
|
681
|
+
var U = [
|
|
680
682
|
"category",
|
|
681
683
|
"gender",
|
|
682
684
|
"size",
|
|
683
685
|
"color",
|
|
684
686
|
"material"
|
|
685
|
-
],
|
|
687
|
+
], je = [
|
|
686
688
|
"category",
|
|
687
689
|
"gender",
|
|
688
690
|
"size",
|
|
689
691
|
"color",
|
|
690
692
|
"price",
|
|
691
693
|
"material"
|
|
692
|
-
],
|
|
694
|
+
], Me = [
|
|
693
695
|
"relevance",
|
|
694
696
|
"newest",
|
|
695
697
|
"cheapest",
|
|
696
698
|
"most_expensive"
|
|
697
|
-
],
|
|
698
|
-
function
|
|
699
|
+
], Ne = "relevance";
|
|
700
|
+
function Pe(e) {
|
|
699
701
|
return e === void 0 || e === "relevance";
|
|
700
702
|
}
|
|
701
|
-
function
|
|
703
|
+
function Fe(e) {
|
|
702
704
|
return e ?? "relevance";
|
|
703
705
|
}
|
|
704
|
-
function
|
|
706
|
+
function W(e) {
|
|
705
707
|
let t = {};
|
|
706
708
|
if (!e) return t;
|
|
707
|
-
for (let n of
|
|
709
|
+
for (let n of U) {
|
|
708
710
|
let r = e[n]?.filter((e) => e !== "");
|
|
709
711
|
r?.length && (t[n] = [...new Set(r)]);
|
|
710
712
|
}
|
|
711
713
|
return e.priceMin !== void 0 && Number.isFinite(e.priceMin) && (t.priceMin = e.priceMin), e.priceMax !== void 0 && Number.isFinite(e.priceMax) && (t.priceMax = e.priceMax), e.onSale && (t.onSale = !0), t;
|
|
712
714
|
}
|
|
713
|
-
function
|
|
714
|
-
let t =
|
|
715
|
+
function G(e) {
|
|
716
|
+
let t = W(e);
|
|
715
717
|
return JSON.stringify([
|
|
716
|
-
...
|
|
718
|
+
...U.map((e) => [...t[e] ?? []].sort()),
|
|
717
719
|
t.priceMin ?? null,
|
|
718
720
|
t.priceMax ?? null,
|
|
719
721
|
t.onSale ?? !1
|
|
720
722
|
]);
|
|
721
723
|
}
|
|
722
|
-
function
|
|
723
|
-
return
|
|
724
|
+
function Ie(e, t) {
|
|
725
|
+
return G(e) === G(t);
|
|
724
726
|
}
|
|
725
|
-
function
|
|
727
|
+
function Le(e) {
|
|
726
728
|
return e.priceMin !== void 0 || e.priceMax !== void 0;
|
|
727
729
|
}
|
|
728
|
-
function
|
|
730
|
+
function Re(e, t, n) {
|
|
729
731
|
let r = e[t] ?? [], i = r.includes(n) ? r.filter((e) => e !== n) : [...r, n];
|
|
730
|
-
return
|
|
732
|
+
return W({
|
|
731
733
|
...e,
|
|
732
734
|
[t]: i
|
|
733
735
|
});
|
|
734
736
|
}
|
|
735
|
-
function
|
|
737
|
+
function ze(e, t) {
|
|
736
738
|
if (t === "price") {
|
|
737
739
|
let { priceMin: t, priceMax: n, ...r } = e;
|
|
738
|
-
return
|
|
740
|
+
return W(r);
|
|
739
741
|
}
|
|
740
|
-
return
|
|
742
|
+
return W({
|
|
741
743
|
...e,
|
|
742
744
|
[t]: []
|
|
743
745
|
});
|
|
744
746
|
}
|
|
745
|
-
function
|
|
746
|
-
let t =
|
|
747
|
-
return
|
|
747
|
+
function Be(e) {
|
|
748
|
+
let t = W(e);
|
|
749
|
+
return U.reduce((e, n) => e + (t[n]?.length ?? 0), 0) + +!!Le(t) + +!!t.onSale;
|
|
748
750
|
}
|
|
749
|
-
var
|
|
750
|
-
function
|
|
751
|
-
let t =
|
|
752
|
-
for (let e of
|
|
751
|
+
var K = "price_min", Ve = "price_max", He = "on_sale";
|
|
752
|
+
function Ue(e) {
|
|
753
|
+
let t = W(e), n = [];
|
|
754
|
+
for (let e of U) {
|
|
753
755
|
let r = t[e];
|
|
754
756
|
r?.length && n.push({
|
|
755
757
|
key: e,
|
|
@@ -757,37 +759,37 @@ function He(e) {
|
|
|
757
759
|
});
|
|
758
760
|
}
|
|
759
761
|
return t.priceMin !== void 0 && n.push({
|
|
760
|
-
key:
|
|
762
|
+
key: K,
|
|
761
763
|
values: [String(t.priceMin)]
|
|
762
764
|
}), t.priceMax !== void 0 && n.push({
|
|
763
|
-
key:
|
|
765
|
+
key: Ve,
|
|
764
766
|
values: [String(t.priceMax)]
|
|
765
767
|
}), t.onSale && n.push({
|
|
766
|
-
key:
|
|
768
|
+
key: He,
|
|
767
769
|
values: ["true"]
|
|
768
770
|
}), n;
|
|
769
771
|
}
|
|
770
|
-
function
|
|
772
|
+
function We(e, t) {
|
|
771
773
|
return {
|
|
772
774
|
...e,
|
|
773
|
-
filters: [...e.filters.filter((e) => e.exclude), ...
|
|
775
|
+
filters: [...e.filters.filter((e) => e.exclude), ...Ue(t)]
|
|
774
776
|
};
|
|
775
777
|
}
|
|
776
|
-
function
|
|
778
|
+
function q(e) {
|
|
777
779
|
let t = {};
|
|
778
780
|
for (let n of e) {
|
|
779
781
|
if (n.exclude) continue;
|
|
780
|
-
let e =
|
|
782
|
+
let e = U.find((e) => e === n.key);
|
|
781
783
|
if (e) t[e] = [...t[e] ?? [], ...n.values];
|
|
782
|
-
else if (n.key ===
|
|
784
|
+
else if (n.key === K || n.key === Ve) {
|
|
783
785
|
let e = Number(n.values[0]);
|
|
784
|
-
Number.isFinite(e) && (t[n.key ===
|
|
785
|
-
} else n.key ===
|
|
786
|
+
Number.isFinite(e) && (t[n.key === K ? "priceMin" : "priceMax"] = e);
|
|
787
|
+
} else n.key === He && n.values[0] === "true" && (t.onSale = !0);
|
|
786
788
|
}
|
|
787
|
-
return
|
|
789
|
+
return W(t);
|
|
788
790
|
}
|
|
789
791
|
// src/search/core/composePage.ts
|
|
790
|
-
function
|
|
792
|
+
function J(e = null) {
|
|
791
793
|
return {
|
|
792
794
|
order: [],
|
|
793
795
|
sections: {},
|
|
@@ -799,7 +801,7 @@ function Y(e = null) {
|
|
|
799
801
|
completed: !1
|
|
800
802
|
};
|
|
801
803
|
}
|
|
802
|
-
function
|
|
804
|
+
function Y(e) {
|
|
803
805
|
return e.order.length > 0 || e.followUps.length > 0;
|
|
804
806
|
}
|
|
805
807
|
function Ge(e) {
|
|
@@ -969,7 +971,7 @@ function tt(e) {
|
|
|
969
971
|
title: e.title ?? "",
|
|
970
972
|
pending: e.pending === !0,
|
|
971
973
|
text: e.text ?? "",
|
|
972
|
-
products: (e.products ?? []).map(
|
|
974
|
+
products: (e.products ?? []).map(R)
|
|
973
975
|
};
|
|
974
976
|
return e.see_all && (t.seeAll = Z(e.see_all)), t;
|
|
975
977
|
}
|
|
@@ -1020,7 +1022,7 @@ function rt(e) {
|
|
|
1020
1022
|
};
|
|
1021
1023
|
case "grid": {
|
|
1022
1024
|
let e = {
|
|
1023
|
-
products: (t.products ?? []).map(
|
|
1025
|
+
products: (t.products ?? []).map(R),
|
|
1024
1026
|
total: typeof t.total == "number" ? t.total : 0
|
|
1025
1027
|
};
|
|
1026
1028
|
return typeof t.next_page_token == "string" && t.next_page_token && (e.nextPageToken = t.next_page_token), e.total < e.products.length && (e.total = e.products.length), {
|
|
@@ -1069,10 +1071,10 @@ function it(e) {
|
|
|
1069
1071
|
async function at(e, t, { signal: n, onEvent: r, idleMs: i }) {
|
|
1070
1072
|
let a = t.baseUrl ?? "https://cgw.ecomid.com", o = {
|
|
1071
1073
|
market: t.market,
|
|
1072
|
-
locale:
|
|
1074
|
+
locale: I(t.lang)
|
|
1073
1075
|
};
|
|
1074
1076
|
t.contextId && (o.context_id = t.contextId), t.limit !== void 0 && (o.limit = t.limit), t.pageToken ? o.page_token = t.pageToken : t.state ? o.state = et(t.state) : t.text && (o.text = t.text);
|
|
1075
|
-
let s = await S(`${a}/v0/search/${e}/results${
|
|
1077
|
+
let s = await S(`${a}/v0/search/${e}/results${L() ? "?preview=true" : ""}`, {
|
|
1076
1078
|
method: "POST",
|
|
1077
1079
|
headers: {
|
|
1078
1080
|
"Content-Type": "application/json",
|
|
@@ -1100,7 +1102,7 @@ function Q(e, t, n = {}) {
|
|
|
1100
1102
|
let t = {
|
|
1101
1103
|
key: e.key,
|
|
1102
1104
|
values: e.values,
|
|
1103
|
-
labels: e.labels ?? e.values.map(
|
|
1105
|
+
labels: e.labels ?? e.values.map(xe)
|
|
1104
1106
|
};
|
|
1105
1107
|
return e.exclude && (t.exclude = !0), t;
|
|
1106
1108
|
}),
|
|
@@ -1116,7 +1118,7 @@ async function ot(e, t, n) {
|
|
|
1116
1118
|
limit: t.limit,
|
|
1117
1119
|
baseUrl: t.baseUrl
|
|
1118
1120
|
};
|
|
1119
|
-
r?.kind === "search" ? a.state = r.state : r ? a.text = r.text : i && (a.text = i);
|
|
1121
|
+
r?.kind === "search" ? a.state = r.state : r ? a.text = r.text : i && (a.text = i), n?.throwIfAborted();
|
|
1120
1122
|
let o = new AbortController(), s = () => o.abort();
|
|
1121
1123
|
n?.addEventListener("abort", s, { once: !0 });
|
|
1122
1124
|
let c, l, u = !1, d = {};
|
|
@@ -1173,66 +1175,66 @@ function $(e, { query: t, lang: n, market: r, limit: i, page: a }) {
|
|
|
1173
1175
|
return !!t && !!e && typeof e.query == "string" && e.query.trim() === t && e.lang === n && e.market === r && e.limit === i && (e.page ?? "") === (a ?? "");
|
|
1174
1176
|
}
|
|
1175
1177
|
function ft(e) {
|
|
1176
|
-
let { clientId: t, market: n, lang: r, baseUrl: i, limit: a, initialResults: o } = e, s = e.fetchers?.streamSearch ?? at, c = a ?? 24, l = /* @__PURE__ */ new Set(), u = st(e.page), d = u ? F(u) : e.query.trim(), f = "relevance", p = {}, m = u, h = u ? P(u) : null,
|
|
1178
|
+
let { clientId: t, market: n, lang: r, baseUrl: i, limit: a, initialResults: o } = e, s = e.fetchers?.streamSearch ?? at, c = a ?? 24, l = /* @__PURE__ */ new Set(), u = st(e.page), d = u ? F(u) : e.query.trim(), f = "relevance", p = {}, m = u, h = null, g = u ? P(u) : null, _ = (e, t, i) => $(e, {
|
|
1177
1179
|
query: t,
|
|
1178
1180
|
lang: r,
|
|
1179
1181
|
market: n,
|
|
1180
1182
|
limit: a,
|
|
1181
1183
|
page: i ? P(i) : void 0
|
|
1182
|
-
}),
|
|
1184
|
+
}), v = _(o, d, u) ? o : null, y = {
|
|
1183
1185
|
query: d,
|
|
1184
1186
|
title: d,
|
|
1185
|
-
status: d ?
|
|
1186
|
-
results:
|
|
1187
|
+
status: d ? v ? "success" : "loading" : "idle",
|
|
1188
|
+
results: v,
|
|
1187
1189
|
error: null,
|
|
1188
|
-
sort:
|
|
1189
|
-
filters:
|
|
1190
|
+
sort: v?.state?.sort ?? f,
|
|
1191
|
+
filters: q(v?.state?.filters ?? []),
|
|
1190
1192
|
loadingMore: !1,
|
|
1191
1193
|
moreError: null,
|
|
1192
1194
|
surface: "grid",
|
|
1193
|
-
pending: !d ||
|
|
1195
|
+
pending: !d || v ? null : "results",
|
|
1194
1196
|
turns: [],
|
|
1195
|
-
page:
|
|
1197
|
+
page: J(),
|
|
1196
1198
|
archive: {},
|
|
1197
1199
|
gridArchive: {},
|
|
1198
1200
|
activeTurn: 0,
|
|
1199
1201
|
followUps: []
|
|
1200
|
-
},
|
|
1201
|
-
function
|
|
1202
|
-
|
|
1203
|
-
...
|
|
1202
|
+
}, b, x = 0, S = null;
|
|
1203
|
+
function C(e) {
|
|
1204
|
+
y = {
|
|
1205
|
+
...y,
|
|
1204
1206
|
...e,
|
|
1205
1207
|
...e.page && { archive: {
|
|
1206
|
-
...e.archive ??
|
|
1207
|
-
[
|
|
1208
|
+
...e.archive ?? y.archive,
|
|
1209
|
+
[x]: e.page
|
|
1208
1210
|
} }
|
|
1209
|
-
}, e.results &&
|
|
1210
|
-
...
|
|
1211
|
-
[
|
|
1212
|
-
query:
|
|
1213
|
-
title:
|
|
1211
|
+
}, e.results && y.surface === "grid" && y.activeTurn > 0 && (y.gridArchive = {
|
|
1212
|
+
...y.gridArchive,
|
|
1213
|
+
[y.activeTurn]: {
|
|
1214
|
+
query: y.query,
|
|
1215
|
+
title: y.title,
|
|
1214
1216
|
results: e.results,
|
|
1215
|
-
sort:
|
|
1216
|
-
filters:
|
|
1217
|
+
sort: y.sort,
|
|
1218
|
+
filters: y.filters
|
|
1217
1219
|
}
|
|
1218
1220
|
});
|
|
1219
1221
|
for (let e of l) e();
|
|
1220
1222
|
}
|
|
1221
|
-
function C() {
|
|
1222
|
-
y?.abort(), y = void 0;
|
|
1223
|
-
}
|
|
1224
1223
|
function w() {
|
|
1225
|
-
|
|
1226
|
-
|
|
1224
|
+
b?.abort(), b = void 0;
|
|
1225
|
+
}
|
|
1226
|
+
function T() {
|
|
1227
|
+
return h || (y.surface === "compose" && y.page.state ? y.page.state : y.results?.state ?? {
|
|
1228
|
+
terms: y.query ? [y.query] : [],
|
|
1227
1229
|
excludedTerms: [],
|
|
1228
|
-
filters:
|
|
1229
|
-
sort:
|
|
1230
|
-
};
|
|
1230
|
+
filters: Ue(y.filters),
|
|
1231
|
+
sort: y.sort
|
|
1232
|
+
});
|
|
1231
1233
|
}
|
|
1232
|
-
function
|
|
1233
|
-
return
|
|
1234
|
+
function E(e, t = T()) {
|
|
1235
|
+
return We(t, e);
|
|
1234
1236
|
}
|
|
1235
|
-
function
|
|
1237
|
+
function D(e, t) {
|
|
1236
1238
|
let n = new Set(e.products.map((e) => e.id)), r = t.products.filter((e) => !n.has(e.id)), i = {
|
|
1237
1239
|
...e,
|
|
1238
1240
|
products: [...e.products, ...r],
|
|
@@ -1240,29 +1242,29 @@ function ft(e) {
|
|
|
1240
1242
|
};
|
|
1241
1243
|
return e.sections && r.length > 0 && (i.sections = [...e.sections, { products: r }]), t.nextPageToken && r.length > 0 ? i.nextPageToken = t.nextPageToken : delete i.nextPageToken, i;
|
|
1242
1244
|
}
|
|
1243
|
-
async function
|
|
1244
|
-
|
|
1245
|
-
let a = ++
|
|
1246
|
-
|
|
1247
|
-
let l = e.pageToken !== void 0, u = e.fresh ? void 0 :
|
|
1245
|
+
async function O(e) {
|
|
1246
|
+
w(), m = null, g = e.pageKey ?? null;
|
|
1247
|
+
let a = ++x, o = new AbortController();
|
|
1248
|
+
b = o;
|
|
1249
|
+
let l = e.pageToken !== void 0, u = e.fresh ? void 0 : y.contextId, d = !1, h, _ = !1, v = () => a === x, T = e.text !== void 0, E = T && e.text !== void 0 ? {
|
|
1248
1250
|
text: e.text,
|
|
1249
1251
|
fresh: e.fresh === !0
|
|
1250
1252
|
} : null, O = !1;
|
|
1251
|
-
|
|
1253
|
+
S = E ? E.text : null;
|
|
1252
1254
|
let k = () => {
|
|
1253
|
-
if (!
|
|
1254
|
-
let { text: e, fresh: t } =
|
|
1255
|
-
|
|
1255
|
+
if (!E) return;
|
|
1256
|
+
let { text: e, fresh: t } = E;
|
|
1257
|
+
E = null, S = null;
|
|
1256
1258
|
let n = t || O;
|
|
1257
|
-
|
|
1259
|
+
C({
|
|
1258
1260
|
query: e,
|
|
1259
|
-
title: !n &&
|
|
1260
|
-
turns: [...n ? [] :
|
|
1261
|
+
title: !n && y.surface === "grid" && y.title ? y.title : e,
|
|
1262
|
+
turns: [...n ? [] : y.turns, {
|
|
1261
1263
|
id: a,
|
|
1262
1264
|
text: e
|
|
1263
1265
|
}],
|
|
1264
1266
|
activeTurn: a,
|
|
1265
|
-
page:
|
|
1267
|
+
page: J(!n && y.surface === "compose" ? y.page.mode : null),
|
|
1266
1268
|
...n && {
|
|
1267
1269
|
archive: {},
|
|
1268
1270
|
gridArchive: {}
|
|
@@ -1273,7 +1275,7 @@ function ft(e) {
|
|
|
1273
1275
|
}
|
|
1274
1276
|
});
|
|
1275
1277
|
};
|
|
1276
|
-
|
|
1278
|
+
C(l ? {
|
|
1277
1279
|
loadingMore: !0,
|
|
1278
1280
|
moreError: null
|
|
1279
1281
|
} : {
|
|
@@ -1300,41 +1302,41 @@ function ft(e) {
|
|
|
1300
1302
|
...N.facets && { facets: N.facets }
|
|
1301
1303
|
});
|
|
1302
1304
|
function F(e) {
|
|
1303
|
-
if (
|
|
1305
|
+
if (v()) {
|
|
1304
1306
|
if (e.type === "started") {
|
|
1305
1307
|
d = !0;
|
|
1306
1308
|
let t = !!u && !!e.contextId && e.contextId !== u;
|
|
1307
|
-
t && (O = !0),
|
|
1309
|
+
t && (O = !0), C({
|
|
1308
1310
|
contextId: e.contextId || void 0,
|
|
1309
1311
|
turnNumber: e.turn,
|
|
1310
|
-
...t && !
|
|
1311
|
-
turns:
|
|
1312
|
-
archive:
|
|
1313
|
-
gridArchive:
|
|
1312
|
+
...t && !E && {
|
|
1313
|
+
turns: y.turns.filter((e) => e.id === a),
|
|
1314
|
+
archive: y.archive[a] ? { [a]: y.archive[a] } : {},
|
|
1315
|
+
gridArchive: y.gridArchive[a] ? { [a]: y.gridArchive[a] } : {}
|
|
1314
1316
|
}
|
|
1315
1317
|
});
|
|
1316
1318
|
} else if (e.type === "mode") {
|
|
1317
1319
|
if (l) return;
|
|
1318
|
-
|
|
1320
|
+
C({ mode: e.mode });
|
|
1319
1321
|
let t = lt(e.mode);
|
|
1320
|
-
if (M && t &&
|
|
1321
|
-
|
|
1322
|
-
...
|
|
1322
|
+
if (M && t && y.surface === "compose") {
|
|
1323
|
+
C({ page: {
|
|
1324
|
+
...y.page,
|
|
1323
1325
|
mode: t
|
|
1324
1326
|
} });
|
|
1325
1327
|
return;
|
|
1326
1328
|
}
|
|
1327
|
-
if (!
|
|
1328
|
-
let n = !
|
|
1329
|
+
if (!E || j || M) return;
|
|
1330
|
+
let n = !E.fresh && !O && y.surface === "grid" && !!y.results;
|
|
1329
1331
|
if (!t && n) return;
|
|
1330
|
-
k(), t ? (M = !0,
|
|
1332
|
+
k(), t ? (M = !0, C({
|
|
1331
1333
|
surface: "compose",
|
|
1332
1334
|
pending: null,
|
|
1333
1335
|
page: P({
|
|
1334
|
-
...
|
|
1336
|
+
...y.page,
|
|
1335
1337
|
mode: t
|
|
1336
1338
|
})
|
|
1337
|
-
})) :
|
|
1339
|
+
})) : C({
|
|
1338
1340
|
surface: "grid",
|
|
1339
1341
|
results: null,
|
|
1340
1342
|
pending: "grid"
|
|
@@ -1344,10 +1346,10 @@ function ft(e) {
|
|
|
1344
1346
|
text: e.text,
|
|
1345
1347
|
answers: e.answers
|
|
1346
1348
|
};
|
|
1347
|
-
if (
|
|
1349
|
+
if (y.surface === "compose" || !j) {
|
|
1348
1350
|
k();
|
|
1349
|
-
let n =
|
|
1350
|
-
M = !0,
|
|
1351
|
+
let n = y.surface === "compose" ? y.page : J(), r = !M;
|
|
1352
|
+
M = !0, C({
|
|
1351
1353
|
question: t,
|
|
1352
1354
|
surface: "compose",
|
|
1353
1355
|
pending: null,
|
|
@@ -1362,24 +1364,24 @@ function ft(e) {
|
|
|
1362
1364
|
});
|
|
1363
1365
|
return;
|
|
1364
1366
|
}
|
|
1365
|
-
|
|
1367
|
+
C({ question: t });
|
|
1366
1368
|
} else if (e.type === "state") {
|
|
1367
|
-
if (N.state = e.state, M &&
|
|
1368
|
-
|
|
1369
|
-
...
|
|
1369
|
+
if (N.state = e.state, M && y.surface === "compose") {
|
|
1370
|
+
C({ page: {
|
|
1371
|
+
...y.page,
|
|
1370
1372
|
state: e.state
|
|
1371
1373
|
} });
|
|
1372
1374
|
return;
|
|
1373
1375
|
}
|
|
1374
|
-
if (j && !l &&
|
|
1375
|
-
let t =
|
|
1376
|
-
|
|
1376
|
+
if (j && !l && y.results) {
|
|
1377
|
+
let t = y.results;
|
|
1378
|
+
C({
|
|
1377
1379
|
results: Q({
|
|
1378
1380
|
products: t.products,
|
|
1379
1381
|
total: t.total ?? t.products.length,
|
|
1380
1382
|
nextPageToken: t.nextPageToken
|
|
1381
1383
|
}, {
|
|
1382
|
-
query:
|
|
1384
|
+
query: y.query,
|
|
1383
1385
|
lang: r,
|
|
1384
1386
|
market: n,
|
|
1385
1387
|
limit: c
|
|
@@ -1388,77 +1390,79 @@ function ft(e) {
|
|
|
1388
1390
|
facets: t.facets
|
|
1389
1391
|
}),
|
|
1390
1392
|
sort: e.state.sort,
|
|
1391
|
-
filters:
|
|
1393
|
+
filters: q(e.state.filters)
|
|
1392
1394
|
});
|
|
1393
1395
|
}
|
|
1394
1396
|
} else if (e.type === "facets") {
|
|
1395
|
-
if (N.facets = e.facets, M &&
|
|
1396
|
-
|
|
1397
|
-
...
|
|
1397
|
+
if (N.facets = e.facets, M && y.surface === "compose") {
|
|
1398
|
+
C({ page: {
|
|
1399
|
+
...y.page,
|
|
1398
1400
|
facets: e.facets
|
|
1399
1401
|
} });
|
|
1400
1402
|
return;
|
|
1401
1403
|
}
|
|
1402
|
-
j &&
|
|
1403
|
-
...
|
|
1404
|
+
j && y.results && C({ results: {
|
|
1405
|
+
...y.results,
|
|
1404
1406
|
facets: e.facets
|
|
1405
1407
|
} });
|
|
1406
1408
|
} else if (e.type === "grid") {
|
|
1407
1409
|
j = !0;
|
|
1408
1410
|
let { grid: t } = e;
|
|
1409
|
-
if (l &&
|
|
1410
|
-
|
|
1411
|
-
results:
|
|
1411
|
+
if (l && y.results) {
|
|
1412
|
+
C({
|
|
1413
|
+
results: D(y.results, t),
|
|
1412
1414
|
loadingMore: !1
|
|
1413
1415
|
});
|
|
1414
1416
|
return;
|
|
1415
1417
|
}
|
|
1416
1418
|
k();
|
|
1417
1419
|
let i = Q(t, {
|
|
1418
|
-
query:
|
|
1420
|
+
query: y.query,
|
|
1419
1421
|
lang: r,
|
|
1420
1422
|
market: n,
|
|
1421
1423
|
limit: c
|
|
1422
1424
|
}, N);
|
|
1423
|
-
|
|
1425
|
+
C({
|
|
1424
1426
|
surface: "grid",
|
|
1425
1427
|
pending: null,
|
|
1426
1428
|
status: "success",
|
|
1427
1429
|
results: i,
|
|
1428
|
-
sort: i.state?.sort ??
|
|
1429
|
-
filters:
|
|
1430
|
+
sort: i.state?.sort ?? y.sort,
|
|
1431
|
+
filters: q(i.state?.filters ?? [])
|
|
1430
1432
|
});
|
|
1431
|
-
} else if (e.type === "error")
|
|
1433
|
+
} else if (e.type === "error") h = e.message || e.errorType || "search failed", (y.surface === "compose" || Y(y.page)) && C({ page: X(y.page, e) });
|
|
1432
1434
|
else if (e.type === "completed") {
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1435
|
+
_ = !0, k(), y.pending && C({ pending: null });
|
|
1436
|
+
let t = j || M || Y(y.page);
|
|
1437
|
+
if (y.surface === "compose" && !l && t) {
|
|
1438
|
+
C({
|
|
1439
|
+
page: X(y.page, e),
|
|
1436
1440
|
status: "success"
|
|
1437
1441
|
});
|
|
1438
1442
|
return;
|
|
1439
1443
|
}
|
|
1440
|
-
if (e.failed) {
|
|
1441
|
-
let
|
|
1442
|
-
l ?
|
|
1444
|
+
if (e.failed || !l && !t) {
|
|
1445
|
+
let t = Error(h ?? (e.failed ? "search failed" : "search returned no results"));
|
|
1446
|
+
l ? C({
|
|
1443
1447
|
loadingMore: !1,
|
|
1444
|
-
moreError:
|
|
1445
|
-
}) : (k(),
|
|
1448
|
+
moreError: t
|
|
1449
|
+
}) : (k(), C({
|
|
1446
1450
|
status: "error",
|
|
1447
|
-
error:
|
|
1451
|
+
error: t,
|
|
1448
1452
|
pending: null
|
|
1449
1453
|
}));
|
|
1450
|
-
} else l &&
|
|
1454
|
+
} else l && C({ loadingMore: !1 });
|
|
1451
1455
|
} else if (it(e)) {
|
|
1452
1456
|
if (e.type === "follow_ups" && j) {
|
|
1453
|
-
|
|
1457
|
+
C({ followUps: e.followUps });
|
|
1454
1458
|
return;
|
|
1455
1459
|
}
|
|
1456
1460
|
k();
|
|
1457
|
-
let t = X(
|
|
1461
|
+
let t = X(y.surface === "compose" ? y.page : J(), e), n = lt(y.mode), r = n ? {
|
|
1458
1462
|
...t,
|
|
1459
1463
|
mode: n
|
|
1460
1464
|
} : t, i = !M;
|
|
1461
|
-
M = !0,
|
|
1465
|
+
M = !0, C({
|
|
1462
1466
|
surface: "compose",
|
|
1463
1467
|
pending: null,
|
|
1464
1468
|
status: "success",
|
|
@@ -1472,52 +1476,52 @@ function ft(e) {
|
|
|
1472
1476
|
signal: o.signal,
|
|
1473
1477
|
onEvent: F
|
|
1474
1478
|
});
|
|
1475
|
-
if (!
|
|
1476
|
-
if (
|
|
1479
|
+
if (!v()) return;
|
|
1480
|
+
if (b = void 0, !e && !_) {
|
|
1477
1481
|
let e = /* @__PURE__ */ Error("search stream ended early");
|
|
1478
|
-
l ?
|
|
1482
|
+
l ? C({
|
|
1479
1483
|
loadingMore: !1,
|
|
1480
1484
|
moreError: e
|
|
1481
|
-
}) :
|
|
1482
|
-
page: X(
|
|
1485
|
+
}) : y.surface === "compose" ? C({
|
|
1486
|
+
page: X(y.page, {
|
|
1483
1487
|
type: "completed",
|
|
1484
1488
|
failed: !0
|
|
1485
1489
|
}),
|
|
1486
1490
|
status: "success"
|
|
1487
|
-
}) : (k(),
|
|
1491
|
+
}) : (k(), C({
|
|
1488
1492
|
status: "error",
|
|
1489
1493
|
error: e,
|
|
1490
1494
|
pending: null
|
|
1491
1495
|
}));
|
|
1492
1496
|
}
|
|
1493
1497
|
} catch (e) {
|
|
1494
|
-
if (!
|
|
1498
|
+
if (!v() || ut(e) || (b = void 0, _)) return;
|
|
1495
1499
|
let t = dt(e);
|
|
1496
|
-
l ?
|
|
1500
|
+
l ? C({
|
|
1497
1501
|
loadingMore: !1,
|
|
1498
1502
|
moreError: t
|
|
1499
|
-
}) : d &&
|
|
1500
|
-
page: X(
|
|
1503
|
+
}) : d && y.surface === "compose" ? C({
|
|
1504
|
+
page: X(y.page, {
|
|
1501
1505
|
type: "completed",
|
|
1502
1506
|
failed: !0
|
|
1503
1507
|
}),
|
|
1504
1508
|
status: "success"
|
|
1505
|
-
}) : (k(),
|
|
1509
|
+
}) : (k(), C({
|
|
1506
1510
|
status: "error",
|
|
1507
1511
|
error: t,
|
|
1508
1512
|
pending: null
|
|
1509
1513
|
}));
|
|
1510
1514
|
}
|
|
1511
1515
|
}
|
|
1512
|
-
function
|
|
1513
|
-
|
|
1516
|
+
function k(e, t, n) {
|
|
1517
|
+
w(), x += 1, m = null, g = n, C({
|
|
1514
1518
|
query: e,
|
|
1515
1519
|
title: e,
|
|
1516
1520
|
status: "success",
|
|
1517
1521
|
results: t,
|
|
1518
1522
|
error: null,
|
|
1519
1523
|
sort: t.state?.sort ?? f,
|
|
1520
|
-
filters:
|
|
1524
|
+
filters: q(t.state?.filters ?? []),
|
|
1521
1525
|
loadingMore: !1,
|
|
1522
1526
|
moreError: null,
|
|
1523
1527
|
surface: "grid",
|
|
@@ -1532,8 +1536,8 @@ function ft(e) {
|
|
|
1532
1536
|
question: void 0
|
|
1533
1537
|
});
|
|
1534
1538
|
}
|
|
1535
|
-
function
|
|
1536
|
-
|
|
1539
|
+
function A() {
|
|
1540
|
+
w(), x += 1, m = null, g = null, C({
|
|
1537
1541
|
query: "",
|
|
1538
1542
|
title: "",
|
|
1539
1543
|
status: "idle",
|
|
@@ -1555,44 +1559,44 @@ function ft(e) {
|
|
|
1555
1559
|
question: void 0
|
|
1556
1560
|
});
|
|
1557
1561
|
}
|
|
1558
|
-
function
|
|
1562
|
+
function j(e, t) {
|
|
1559
1563
|
let n = e.trim();
|
|
1560
|
-
if (
|
|
1561
|
-
if (
|
|
1562
|
-
|
|
1563
|
-
} else n !==
|
|
1564
|
+
if (_(t, n)) {
|
|
1565
|
+
if (y.status === "success" && y.query === n && y.results === t) return;
|
|
1566
|
+
k(n, t, null);
|
|
1567
|
+
} else n !== y.query && n !== S && (n ? O({
|
|
1564
1568
|
text: n,
|
|
1565
1569
|
fresh: !0
|
|
1566
|
-
}) :
|
|
1570
|
+
}) : A());
|
|
1567
1571
|
}
|
|
1568
|
-
function
|
|
1569
|
-
return !
|
|
1572
|
+
function M() {
|
|
1573
|
+
return !y.query || y.status !== "success" ? null : y.surface === "compose" ? {
|
|
1570
1574
|
kind: "compose",
|
|
1571
|
-
text:
|
|
1572
|
-
} :
|
|
1575
|
+
text: y.title
|
|
1576
|
+
} : y.results ? {
|
|
1573
1577
|
kind: "search",
|
|
1574
|
-
state:
|
|
1578
|
+
state: y.results.state ?? T()
|
|
1575
1579
|
} : null;
|
|
1576
1580
|
}
|
|
1577
|
-
function
|
|
1581
|
+
function N(e, t) {
|
|
1578
1582
|
let n = st(e);
|
|
1579
1583
|
if (!n) {
|
|
1580
|
-
|
|
1584
|
+
y.query && A();
|
|
1581
1585
|
return;
|
|
1582
1586
|
}
|
|
1583
1587
|
let r = P(n);
|
|
1584
|
-
if (r ===
|
|
1585
|
-
let i =
|
|
1588
|
+
if (r === g) return;
|
|
1589
|
+
let i = M();
|
|
1586
1590
|
if (i && P(i) === r) {
|
|
1587
|
-
|
|
1591
|
+
g = r;
|
|
1588
1592
|
return;
|
|
1589
1593
|
}
|
|
1590
1594
|
let a = F(n);
|
|
1591
|
-
|
|
1595
|
+
_(t, a, n) ? k(a, t, r) : O(ct(n));
|
|
1592
1596
|
}
|
|
1593
|
-
function
|
|
1594
|
-
let a =
|
|
1595
|
-
a &&
|
|
1597
|
+
function ee(e) {
|
|
1598
|
+
let a = y.gridArchive[e];
|
|
1599
|
+
a && y.activeTurn !== e && (w(), x += 1, C({
|
|
1596
1600
|
...a,
|
|
1597
1601
|
status: "success",
|
|
1598
1602
|
error: null,
|
|
@@ -1607,50 +1611,61 @@ function ft(e) {
|
|
|
1607
1611
|
lang: r,
|
|
1608
1612
|
baseUrl: i,
|
|
1609
1613
|
limit: 1,
|
|
1610
|
-
contextId:
|
|
1614
|
+
contextId: y.contextId,
|
|
1611
1615
|
state: a.results.state
|
|
1612
1616
|
}, {
|
|
1613
1617
|
signal: new AbortController().signal,
|
|
1614
1618
|
onEvent: () => {}
|
|
1615
1619
|
}).catch(() => {}));
|
|
1616
1620
|
}
|
|
1617
|
-
function
|
|
1621
|
+
function te(e) {
|
|
1618
1622
|
let t = e.trim();
|
|
1619
|
-
t &&
|
|
1623
|
+
t && O({ text: t });
|
|
1620
1624
|
}
|
|
1621
1625
|
function I(e) {
|
|
1622
|
-
(
|
|
1626
|
+
(y.query || y.results) && (h = e, C({
|
|
1627
|
+
filters: q(e.filters),
|
|
1628
|
+
sort: e.sort
|
|
1629
|
+
}), O({ state: e }).finally(() => {
|
|
1630
|
+
if (h !== e || (h = null, y.status !== "error")) return;
|
|
1631
|
+
let t = T();
|
|
1632
|
+
C({
|
|
1633
|
+
filters: q(t.filters),
|
|
1634
|
+
sort: t.sort
|
|
1635
|
+
});
|
|
1636
|
+
}));
|
|
1623
1637
|
}
|
|
1624
1638
|
function L(e) {
|
|
1625
|
-
let t =
|
|
1639
|
+
let t = T();
|
|
1626
1640
|
t.terms.includes(e) && I({
|
|
1627
1641
|
...t,
|
|
1628
1642
|
terms: t.terms.filter((t) => t !== e)
|
|
1629
1643
|
});
|
|
1630
1644
|
}
|
|
1631
|
-
function
|
|
1632
|
-
let t =
|
|
1645
|
+
function ne(e) {
|
|
1646
|
+
let t = T();
|
|
1633
1647
|
t.excludedTerms.includes(e) && I({
|
|
1634
1648
|
...t,
|
|
1635
1649
|
excludedTerms: t.excludedTerms.filter((t) => t !== e)
|
|
1636
1650
|
});
|
|
1637
1651
|
}
|
|
1638
|
-
function
|
|
1639
|
-
let t =
|
|
1640
|
-
|
|
1641
|
-
...
|
|
1652
|
+
function re(e) {
|
|
1653
|
+
let t = Fe(e);
|
|
1654
|
+
y.query && t !== y.sort && I({
|
|
1655
|
+
...T(),
|
|
1642
1656
|
sort: t
|
|
1643
1657
|
});
|
|
1644
1658
|
}
|
|
1645
|
-
function
|
|
1646
|
-
let t =
|
|
1647
|
-
|
|
1659
|
+
function R(e) {
|
|
1660
|
+
let t = W(e);
|
|
1661
|
+
y.query && !Ie(t, y.filters) && I(E(t));
|
|
1648
1662
|
}
|
|
1649
|
-
function
|
|
1650
|
-
let e =
|
|
1651
|
-
!
|
|
1663
|
+
function ie() {
|
|
1664
|
+
let e = y.results?.nextPageToken;
|
|
1665
|
+
!y.query || !e || y.status !== "success" || y.loadingMore || y.moreError || b || O({ pageToken: e });
|
|
1652
1666
|
}
|
|
1653
|
-
async function
|
|
1667
|
+
async function z(e, a, o) {
|
|
1668
|
+
a?.throwIfAborted();
|
|
1654
1669
|
let c = new AbortController(), l = () => c.abort();
|
|
1655
1670
|
a?.addEventListener("abort", l, { once: !0 });
|
|
1656
1671
|
let u;
|
|
@@ -1660,7 +1675,7 @@ function ft(e) {
|
|
|
1660
1675
|
lang: r,
|
|
1661
1676
|
baseUrl: i,
|
|
1662
1677
|
limit: 1,
|
|
1663
|
-
state:
|
|
1678
|
+
state: E(W(e), o)
|
|
1664
1679
|
}, {
|
|
1665
1680
|
signal: c.signal,
|
|
1666
1681
|
onEvent: (e) => {
|
|
@@ -1675,40 +1690,40 @@ function ft(e) {
|
|
|
1675
1690
|
if (u === void 0) throw Error("count returned no grid");
|
|
1676
1691
|
return u;
|
|
1677
1692
|
}
|
|
1678
|
-
function
|
|
1679
|
-
|
|
1680
|
-
text:
|
|
1693
|
+
function ae() {
|
|
1694
|
+
y.query && y.status !== "success" && y.status !== "error" && !b && O(m ? ct(m) : {
|
|
1695
|
+
text: y.query,
|
|
1681
1696
|
fresh: !0
|
|
1682
1697
|
});
|
|
1683
1698
|
}
|
|
1684
|
-
function
|
|
1685
|
-
|
|
1686
|
-
...
|
|
1687
|
-
status:
|
|
1699
|
+
function B() {
|
|
1700
|
+
w(), x += 1, y = {
|
|
1701
|
+
...y,
|
|
1702
|
+
status: y.status === "loading" ? "idle" : y.status,
|
|
1688
1703
|
loadingMore: !1
|
|
1689
1704
|
}, l.clear();
|
|
1690
1705
|
}
|
|
1691
1706
|
return {
|
|
1692
|
-
getState: () =>
|
|
1707
|
+
getState: () => y,
|
|
1693
1708
|
subscribe(e) {
|
|
1694
1709
|
return l.add(e), () => {
|
|
1695
1710
|
l.delete(e);
|
|
1696
1711
|
};
|
|
1697
1712
|
},
|
|
1698
|
-
setQuery:
|
|
1699
|
-
setPage:
|
|
1700
|
-
getPage:
|
|
1701
|
-
send:
|
|
1702
|
-
jumpTo:
|
|
1703
|
-
setSort:
|
|
1704
|
-
setFilters:
|
|
1713
|
+
setQuery: j,
|
|
1714
|
+
setPage: N,
|
|
1715
|
+
getPage: M,
|
|
1716
|
+
send: te,
|
|
1717
|
+
jumpTo: ee,
|
|
1718
|
+
setSort: re,
|
|
1719
|
+
setFilters: R,
|
|
1705
1720
|
applyState: I,
|
|
1706
1721
|
removeTerm: L,
|
|
1707
|
-
removeExcludedTerm:
|
|
1708
|
-
loadMore:
|
|
1709
|
-
count:
|
|
1710
|
-
load:
|
|
1711
|
-
destroy:
|
|
1722
|
+
removeExcludedTerm: ne,
|
|
1723
|
+
loadMore: ie,
|
|
1724
|
+
count: z,
|
|
1725
|
+
load: ae,
|
|
1726
|
+
destroy: B
|
|
1712
1727
|
};
|
|
1713
1728
|
}
|
|
1714
|
-
export {
|
|
1729
|
+
export { E as A, n as B, le as C, M as D, P as E, h as F, l as I, o as L, b as M, y as N, F as O, p as P, s as R, be as S, N as T, e as V, q as _, Y as a, Ae as b, je as c, ze as d, Le as f, Ie as g, Fe as h, Q as i, D as j, ee as k, Me as l, W as m, $ as n, Ge as o, Pe as p, ot as r, Ne as s, ft as t, Be as u, Re as v, B as w, xe as x, We as y, t as z };
|