@ecomid/modules 0.0.0-stage → 0.1.0

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/dist/react.js ADDED
@@ -0,0 +1,4497 @@
1
+ "use client";
2
+ import { A as e, B as t, C as n, D as r, E as i, F as a, I as o, L as s, M as c, N as l, O as u, P as d, R as f, S as p, V as m, _ as h, a as g, b as _, c as v, d as y, f as b, g as x, h as S, i as C, k as w, l as T, m as E, n as D, o as O, p as k, t as ee, u as A, v as j, x as M, y as N, z as P } from "./chunks/resultsStore-3P0rGTOF.js";
3
+ import { Component as F, createContext as I, useCallback as L, useContext as R, useEffect as z, useId as te, useLayoutEffect as B, useMemo as V, useRef as H, useState as U, useSyncExternalStore as W } from "react";
4
+ import { Fragment as G, jsx as K, jsxs as q } from "react/jsx-runtime";
5
+ import { createPortal as J } from "react-dom";
6
+ // src/html/pixel/types.ts
7
+ var Y = {
8
+ REQUEST: "search_request",
9
+ ABORT: "search_abort",
10
+ RESPONSE: "search_response",
11
+ CHUNK: "search_chunk",
12
+ END: "search_end",
13
+ ERROR: "search_error"
14
+ }, ne = 1e4, re = 0, ie = () => `search-${Date.now().toString(36)}-${++re}`, ae = new TextEncoder();
15
+ function oe() {
16
+ return Object.assign(/* @__PURE__ */ Error("The operation was aborted"), { name: "AbortError" });
17
+ }
18
+ function se({ cgwUrls: e, isLoggedIn: t, timeoutMs: n = ne }) {
19
+ return {
20
+ isSignedIn: () => t() && d() !== null,
21
+ canRelay: (t) => e.some((e) => !!e && t.startsWith(`${e}/v0/search/`)),
22
+ fetch: (e, t) => new Promise((r, i) => {
23
+ let o = d();
24
+ if (!o) {
25
+ i(/* @__PURE__ */ Error("pixel unavailable"));
26
+ return;
27
+ }
28
+ let s = t.signal;
29
+ if (s?.aborted) {
30
+ i(oe());
31
+ return;
32
+ }
33
+ let c = ie(), l = new URL(e), u = null, f = !1, p, m = () => {
34
+ clearTimeout(p), window.removeEventListener("message", _), s?.removeEventListener("abort", g);
35
+ }, h = () => {
36
+ o.postMessage({
37
+ type: Y.ABORT,
38
+ id: c
39
+ }, "*");
40
+ };
41
+ function g() {
42
+ m(), h(), f ? u?.error(oe()) : i(oe());
43
+ }
44
+ function _(e) {
45
+ let t = e.data;
46
+ if (t && t.id === c && e.source === o && a(e)) {
47
+ if (t.type === Y.RESPONSE) {
48
+ m();
49
+ let e = Number(t.status), n = e === 204 ? null : typeof t.body == "string" ? t.body : JSON.stringify(t.body);
50
+ r(new Response(n, {
51
+ status: e,
52
+ headers: { "Content-Type": "application/json" }
53
+ }));
54
+ } else if (t.type === Y.CHUNK && typeof t.chunk == "string") {
55
+ clearTimeout(p);
56
+ let e = ae.encode(t.chunk);
57
+ if (f) {
58
+ u?.enqueue(e);
59
+ return;
60
+ }
61
+ f = !0, r(new Response(new ReadableStream({
62
+ start(t) {
63
+ u = t, t.enqueue(e);
64
+ },
65
+ cancel() {
66
+ m(), h();
67
+ }
68
+ }), {
69
+ status: 200,
70
+ headers: { "Content-Type": "text/event-stream" }
71
+ }));
72
+ } else if (t.type === Y.END) m(), f ? u?.close() : r(new Response(null, { status: 200 }));
73
+ else if (t.type === Y.ERROR) {
74
+ m();
75
+ let e = Number(t.status);
76
+ f ? u?.error(/* @__PURE__ */ Error("relay stream failed")) : e >= 400 && e <= 599 ? r(new Response(null, { status: e })) : i(/* @__PURE__ */ Error("relay request failed"));
77
+ }
78
+ }
79
+ }
80
+ window.addEventListener("message", _), s?.addEventListener("abort", g, { once: !0 }), p = setTimeout(() => {
81
+ m(), h(), i(/* @__PURE__ */ Error("relay timeout"));
82
+ }, n), o.postMessage({
83
+ type: Y.REQUEST,
84
+ id: c,
85
+ path: l.pathname,
86
+ method: (t.method ?? "GET").toUpperCase(),
87
+ ...l.search ? { query: l.search.slice(1) } : {},
88
+ ...typeof t.body == "string" ? { body: t.body } : {}
89
+ }, "*");
90
+ })
91
+ };
92
+ }
93
+ // src/search/react/relay.ts
94
+ function ce() {
95
+ l(se({
96
+ cgwUrls: Object.values(P).map((e) => e.cgw),
97
+ isLoggedIn: () => typeof window < "u" && m().ecomid?.auth?.getState().loggedIn === !0
98
+ }));
99
+ }
100
+ // src/react/EcomidContext.ts
101
+ var le = I(null), ue = !1;
102
+ function de({ clientId: e, locale: n, environment: r, active: i }) {
103
+ let a = R(le), s = t(r ?? a?.environment), c = V(() => (e, t) => {
104
+ o(e, t, { eventsBaseUrl: s.events });
105
+ }, [s.events]);
106
+ return z(() => {
107
+ if (!i || ue) return;
108
+ let e = () => {
109
+ ue || m().ecomid?.version || (ue = !0, c(/* @__PURE__ */ Error("ecomid loader not found")));
110
+ };
111
+ if (document.readyState === "complete") e();
112
+ else return window.addEventListener("load", e, { once: !0 }), () => window.removeEventListener("load", e);
113
+ }, [i, c]), {
114
+ clientId: e ?? a?.clientId,
115
+ locale: n ?? a?.locale,
116
+ urls: s,
117
+ report: c
118
+ };
119
+ }
120
+ var fe = I((e, t) => {
121
+ o(e, t);
122
+ }), pe = () => R(fe), me = class extends F {
123
+ static contextType = fe;
124
+ state = { hasError: !1 };
125
+ static getDerivedStateFromError() {
126
+ return { hasError: !0 };
127
+ }
128
+ componentDidCatch(e, t) {
129
+ this.context(e, { context: t.componentStack ?? void 0 });
130
+ }
131
+ render() {
132
+ return this.state.hasError ? null : this.props.children;
133
+ }
134
+ };
135
+ function X({ message: e }) {
136
+ let t = pe();
137
+ return z(() => {
138
+ t(Error(e));
139
+ }, [e, t]), null;
140
+ }
141
+ // src/search/components/SearchBoundary.tsx
142
+ function he({ clientId: e, locale: t, children: n }) {
143
+ let r;
144
+ try {
145
+ r = c({
146
+ clientId: e,
147
+ locale: t
148
+ });
149
+ } catch (e) {
150
+ return /* @__PURE__ */ K(X, { message: e instanceof Error ? e.message : String(e) });
151
+ }
152
+ return /* @__PURE__ */ K(me, { children: n(r) });
153
+ }
154
+ // src/search/components/hooks/useGuard.ts
155
+ function ge() {
156
+ let e = pe();
157
+ return L((t) => {
158
+ try {
159
+ t();
160
+ } catch (t) {
161
+ t instanceof Error && e(t);
162
+ }
163
+ }, [e]);
164
+ }
165
+ // src/search/components/hooks/useSyncExternalStoreSsr.ts
166
+ var _e = W, ve = {
167
+ INIT: "init",
168
+ VISIBLE: "visible",
169
+ OPEN: "open",
170
+ CLOSE: "close",
171
+ ADD_TO_CART: "add_to_cart",
172
+ KEEP_SIZE: "keep_size",
173
+ ADD_SIZE_ANYWAY: "add_size_anyway",
174
+ CHANGE_TO_RECOMMENDED_SIZE: "change_to_recommended_size",
175
+ FIND_MY_SIZE: "find_my_size",
176
+ RECOMMENDATION: "recommendation",
177
+ YOUR_SIZE_RECOMMENDATION: "your_size_recommendation",
178
+ STEP: "step",
179
+ RESET: "reset",
180
+ SELECT_SIZE: "select_size",
181
+ FEEDBACK_SUBMIT: "feedback_submit",
182
+ FEEDBACK_SIZE_SUBMIT: "feedback_size_submit",
183
+ SHOW_NO_SIZE_PAGE: "show_no_size_page",
184
+ SHOW_ERROR_PAGE: "show_error_page",
185
+ SHOW_RESET_PAGE: "show_reset_page",
186
+ SHOW_INFO_PAGE: "show_info_page",
187
+ FEEDBACK_VISIBLE: "feedback_visible",
188
+ CURIOSITY_SUBMIT: "curiosity_submit",
189
+ CURIOSITY_VISIBLE: "curiosity_visible",
190
+ SIZE_GUIDE_BUTTON_VISIBLE: "size_guide_button_visible",
191
+ SIZE_GUIDE_OPEN: "size_guide_open",
192
+ FORM_SUBMIT: "form_submit",
193
+ EXPAND: "expand",
194
+ PROMPT_SUBMIT: "prompt_submit",
195
+ SIDEBAR_OPEN: "sidebar_open",
196
+ SIDEBAR_CLOSE: "sidebar_close",
197
+ PRODUCT_CLICK: "product_click",
198
+ PRODUCT_VISIBLE: "product_visible",
199
+ PRODUCT_MENU_OPEN: "product_menu_open",
200
+ PRODUCT_MENU_CLICK_ITEM: "product_menu_click_item",
201
+ PRODUCT_CAROUSEL_LAYOUT_CHANGE: "product_carousel_layout_change",
202
+ PRODUCT_CAROUSEL_PREV_CLICK: "product_carousel_prev_click",
203
+ PRODUCT_CAROUSEL_NEXT_CLICK: "product_carousel_next_click",
204
+ PRE_PROMPT_CLICK: "pre_prompt_click",
205
+ CREATE_MESSAGE: "create_message",
206
+ NEW_CHAT_CLICK: "new_chat_click",
207
+ CREATE_CHAT: "create_chat",
208
+ STOP: "stop",
209
+ SIGNUP: "signup",
210
+ SIGNUP_COMPLETE: "signup_complete",
211
+ LOGIN: "login",
212
+ LOGOUT: "logout",
213
+ USER_EDIT: "user_edit",
214
+ USER_DELETE: "user_delete",
215
+ PROFILE_ADD: "profile_add",
216
+ PROFILE_EDIT: "profile_edit",
217
+ PROFILE_DELETE: "profile_delete",
218
+ PROFILE_SWITCH: "profile_switch",
219
+ PROFILE_PHOTO_UPLOAD: "profile_photo_upload",
220
+ PROFILE_PHOTO_REMOVE: "profile_photo_remove",
221
+ AUTH_OTP_START: "auth_otp_start",
222
+ AUTH_OTP_RESEND: "auth_otp_resend",
223
+ AUTH_OTP_VERIFY: "auth_otp_verify",
224
+ AUTH_OTP_VERIFY_FAIL: "auth_otp_verify_fail",
225
+ AUTH_OTP_ACCOUNT_LOCK: "auth_otp_account_lock",
226
+ ACCOUNT_DETAILS_OPEN: "account_details_open",
227
+ ACCOUNT_DETAILS_PAGE_OPEN: "account_details_page_open",
228
+ ACCOUNT_DETAILS_UPDATE: "account_details_update",
229
+ ACCOUNT_PHOTO_UPLOAD: "account_photo_upload",
230
+ ACCOUNT_PHOTO_REMOVE: "account_photo_remove",
231
+ MEASUREMENTS_OPEN: "measurements_open",
232
+ MEASUREMENTS_PAGE_OPEN: "measurements_page_open",
233
+ MEASUREMENTS_UPDATE: "measurements_update",
234
+ PROFILE_SWITCHER_OPEN: "profile_switcher_open",
235
+ MANAGE_SIZE_PROFILES_OPEN: "manage_size_profiles_open",
236
+ SEARCH_SUBMIT: "search_submit",
237
+ SUGGESTION_CLICK: "suggestion_click",
238
+ FAVORITE_BRANDS_EDIT: "favorite_brands_edit",
239
+ FAVORITE_BRANDS_ADD: "favorite_brands_add",
240
+ FAVORITE_BRANDS_QUICK_ADD: "favorite_brands_quick_add",
241
+ FAVORITE_BRANDS_REMOVE: "favorite_brands_remove",
242
+ FAVORITE_BRANDS_MORE: "favorite_brands_more",
243
+ FAVORITE_BRANDS_SAVE: "favorite_brands_save",
244
+ ACTIVITY_OPEN: "activity_open",
245
+ ACTIVITY_VIEW_ALL: "activity_view_all",
246
+ ACTIVITY_FILTER: "activity_filter",
247
+ ACTIVITY_LOAD_MORE: "activity_load_more",
248
+ ACTIVITY_ROW_EXPAND: "activity_row_expand",
249
+ ACTIVITY_MENU_ACTION: "activity_menu_action"
250
+ }, ye = {
251
+ INFO_MODULE: "info_module",
252
+ USER_INFO_MODULE: "user_info_module",
253
+ SIZE_FINDER_MODULE: "size_finder_module",
254
+ ACCOUNT_MODULE: "account_module",
255
+ BRACKETING_ALERT_MODULE: "bracketing_alert_module",
256
+ AGENT_MODULE: "agent_module",
257
+ SCORE_MODULE: "score_module",
258
+ SMART_PROMPTS_MODULE: "smart_prompts_module",
259
+ SEARCH_MODULE: "search_module"
260
+ };
261
+ // src/search/components/Backdrop.tsx
262
+ function be({ onDismiss: e, ...t }) {
263
+ return /* @__PURE__ */ K("div", {
264
+ ...t,
265
+ onClick: (t) => {
266
+ t.stopPropagation(), t.target === t.currentTarget && e();
267
+ }
268
+ });
269
+ }
270
+ // src/helpers/bodyScrollLock.ts
271
+ var Z = 0, xe = null;
272
+ function Se() {
273
+ let { body: e } = document;
274
+ if (Z === 0) {
275
+ xe = {
276
+ overflowY: e.style.overflowY,
277
+ position: e.style.position,
278
+ top: e.style.top,
279
+ width: e.style.width,
280
+ scrollY: window.scrollY
281
+ };
282
+ let t = window.innerWidth - document.documentElement.clientWidth > 0;
283
+ e.style.overflowY = t ? "scroll" : "hidden", e.style.position = "fixed", e.style.top = `-${xe.scrollY}px`, e.style.width = "100%";
284
+ }
285
+ Z++;
286
+ let t = !1;
287
+ return () => {
288
+ if (t || (t = !0, Z--, Z > 0 || !xe)) return;
289
+ let n = xe;
290
+ xe = null, e.style.overflowY = n.overflowY, e.style.position = n.position, e.style.top = n.top, e.style.width = n.width, window.scrollTo({
291
+ top: n.scrollY,
292
+ behavior: "instant"
293
+ });
294
+ };
295
+ }
296
+ // src/search/components/hooks/useBodyScrollLock.ts
297
+ function Ce(e) {
298
+ z(() => {
299
+ if (e) return Se();
300
+ }, [e]);
301
+ }
302
+ // src/search/components/hooks/useFocusTrap.ts
303
+ var we = "a[href], area[href], input:not([disabled]):not([type=hidden]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex]:not([tabindex=\"-1\"]), [contenteditable]", Te = (e, t = !0) => {
304
+ let [n, r] = U(null), i = H(e);
305
+ i.current = e;
306
+ let a = L((e) => {
307
+ if (e.key === "Escape") {
308
+ e.stopPropagation(), i.current();
309
+ return;
310
+ }
311
+ if (e.key !== "Tab" || !n) return;
312
+ let t = n.querySelectorAll(we), r = t[0], a = t[t.length - 1];
313
+ r && a && (e.shiftKey && document.activeElement === r ? (e.preventDefault(), a.focus()) : !e.shiftKey && document.activeElement === a && (e.preventDefault(), r.focus()), e.stopPropagation());
314
+ }, [n]);
315
+ return z(() => {
316
+ if (n && t) {
317
+ if (!n.contains(document.activeElement)) {
318
+ let e = n.querySelectorAll(we), t = n.querySelector("[data-autofocus]") ?? e[0];
319
+ t ? t.focus({ preventScroll: !0 }) : n.focus({ preventScroll: !0 });
320
+ }
321
+ return n.addEventListener("keydown", a), () => {
322
+ n.removeEventListener("keydown", a);
323
+ };
324
+ }
325
+ }, [
326
+ n,
327
+ a,
328
+ t
329
+ ]), r;
330
+ }, Ee = (e, t) => {
331
+ let [n, r] = U(null);
332
+ return z(() => {
333
+ if (!n || !t || typeof ResizeObserver > "u") return;
334
+ let r = new ResizeObserver((t) => {
335
+ let r = t[t.length - 1].borderBoxSize?.[0]?.blockSize ?? n.getBoundingClientRect().height;
336
+ n.style.setProperty(e, `${r}px`);
337
+ });
338
+ return r.observe(n), () => r.disconnect();
339
+ }, [
340
+ n,
341
+ e,
342
+ t
343
+ ]), r;
344
+ }, De = (e, t) => {
345
+ z(() => {
346
+ if (!e) return;
347
+ let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
348
+ return () => {
349
+ (!t || t()) && n?.focus();
350
+ };
351
+ }, [e, t]);
352
+ }, Oe = class {
353
+ subject;
354
+ meta;
355
+ enabled = !0;
356
+ flushTimeout = null;
357
+ topWindow = f(window);
358
+ constructor(e, t) {
359
+ this.subject = e, this.meta = t || {};
360
+ }
361
+ track = (e, t) => {
362
+ if (!this.topWindow) {
363
+ this.enabled = !1;
364
+ return;
365
+ }
366
+ if (!this.enabled) return;
367
+ let n = {
368
+ type: "ecomid_event",
369
+ event: {
370
+ action: e,
371
+ subject: this.subject,
372
+ clientId: t?.clientId || this.meta.clientId,
373
+ attrs: {
374
+ ...this.meta.attrs,
375
+ ...s(),
376
+ version: "dev_2026-11-18T13:30:07.917Z",
377
+ ...t?.attrs
378
+ },
379
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleString("sv")
380
+ }
381
+ };
382
+ this.topWindow.postMessage(n, "*");
383
+ };
384
+ setMeta = (e) => {
385
+ this.meta = {
386
+ ...this.meta,
387
+ ...e,
388
+ attrs: {
389
+ ...this.meta.attrs,
390
+ ...e.attrs
391
+ }
392
+ };
393
+ };
394
+ };
395
+ // src/search/core/tracking.ts
396
+ function ke(e) {
397
+ let t;
398
+ return (n, r) => {
399
+ t ??= new Oe(ye.SEARCH_MODULE, e).track, t(n, r);
400
+ };
401
+ }
402
+ // src/search/components/hooks/useSearchSession.ts
403
+ function Ae({ clientId: e, lang: t, market: n }) {
404
+ let r = pe(), i = V(() => ke({
405
+ clientId: e,
406
+ attrs: {
407
+ lang: t,
408
+ market: n
409
+ }
410
+ }), [
411
+ e,
412
+ t,
413
+ n
414
+ ]), a = H(!1), o = L((e, t) => {
415
+ a.current || (a.current = !0, r(e, { context: t.componentStack ?? void 0 }));
416
+ }, [r]);
417
+ return z(() => {
418
+ i(ve.INIT);
419
+ }, []), {
420
+ track: i,
421
+ onRenderError: o
422
+ };
423
+ }
424
+ // src/search/components/hooks/useSearchTranslations.ts
425
+ var je = /* #__PURE__ */ Object.assign({
426
+ "/translations/search/widget/cs.json": () => import("./chunks/cs-Dqb_rREp.js"),
427
+ "/translations/search/widget/da.json": () => import("./chunks/da-WYTDtjgg.js"),
428
+ "/translations/search/widget/de.json": () => import("./chunks/de-D6tbcZ82.js"),
429
+ "/translations/search/widget/en.json": () => import("./chunks/en-BJsf6vvY.js"),
430
+ "/translations/search/widget/es.json": () => import("./chunks/es-UCU6bjwJ.js"),
431
+ "/translations/search/widget/fi.json": () => import("./chunks/fi-BZ1TBPKK.js"),
432
+ "/translations/search/widget/fr.json": () => import("./chunks/fr-Bh4svI2n.js"),
433
+ "/translations/search/widget/it.json": () => import("./chunks/it-S3zZ2XyN.js"),
434
+ "/translations/search/widget/nl.json": () => import("./chunks/nl-BskWxJtL.js"),
435
+ "/translations/search/widget/no.json": () => import("./chunks/no-fPEJ7LXi.js"),
436
+ "/translations/search/widget/pl.json": () => import("./chunks/pl-DgFibWpI.js"),
437
+ "/translations/search/widget/pt.json": () => import("./chunks/pt-CZ1aBAcy.js"),
438
+ "/translations/search/widget/sk.json": () => import("./chunks/sk-BVkd-dpe.js"),
439
+ "/translations/search/widget/sv.json": () => import("./chunks/sv-CoiCABF8.js")
440
+ }), Me = /* @__PURE__ */ new Map(), Ne = "en.json", Pe = (e, t) => Object.entries(e).find(([e]) => e.endsWith(`/${t}`))?.[1], Fe = (e, t) => {
441
+ o(new Ie(`Error loading translations for ${e}: ${t instanceof Error ? t.message : String(t)}`));
442
+ }, Ie = class extends Error {
443
+ constructor(e) {
444
+ super(e), this.name = "MissingTranslationError";
445
+ }
446
+ };
447
+ async function Le(e, { loaders: t = je, store: n = Me, isCancelled: r = () => !1 } = {}) {
448
+ let i = `${e}.json`, a = n.get(i);
449
+ if (a) return a;
450
+ try {
451
+ let e = await (Pe(t, i) ?? Pe(t, Ne))?.();
452
+ if (!e) return;
453
+ let r = e;
454
+ return n.set(i, r), r;
455
+ } catch (e) {
456
+ if (r() || (Fe(i, e), i === Ne)) return;
457
+ try {
458
+ let e = await Pe(t, Ne)?.();
459
+ if (!e) return;
460
+ let r = e;
461
+ return n.set(i, r), r;
462
+ } catch (e) {
463
+ r() || Fe(Ne, e);
464
+ return;
465
+ }
466
+ }
467
+ }
468
+ function Q(e) {
469
+ let [t, n] = U(() => Me.get(`${e}.json`) ?? Me.get("en.json"));
470
+ return z(() => {
471
+ let t = !1;
472
+ return Le(e, { isCancelled: () => t }).then((e) => {
473
+ !t && e && n(e);
474
+ }), () => {
475
+ t = !0;
476
+ };
477
+ }, [e]), {
478
+ t: (e, n) => {
479
+ let r = e.split("."), i = t;
480
+ for (let e of r) if (i = i?.[e], !i) return "";
481
+ return typeof i == "string" && n ? i.replace(/{(.*?)}/g, (e, t) => n[t] ?? e) : i;
482
+ },
483
+ isLoading: !t
484
+ };
485
+ }
486
+ // src/search/components/PortalTarget.tsx
487
+ var Re = I(null);
488
+ function ze() {
489
+ return R(Re) ?? document.body;
490
+ }
491
+ // node_modules/clsx/dist/clsx.mjs
492
+ function Be(e) {
493
+ var t, n, r = "";
494
+ if (typeof e == "string" || typeof e == "number") r += e;
495
+ else if (typeof e == "object") {
496
+ if (Array.isArray(e)) {
497
+ var i = e.length;
498
+ for (t = 0; t < i; t++) e[t] && (n = Be(e[t])) && (r && (r += " "), r += n);
499
+ } else for (n in e) e[n] && (r && (r += " "), r += n);
500
+ }
501
+ return r;
502
+ }
503
+ function Ve() {
504
+ for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = Be(e)) && (r && (r += " "), r += t);
505
+ return r;
506
+ }
507
+ // src/components/Wordmark/index.tsx
508
+ var He = 288 / 55;
509
+ function Ue({ height: e = 12, color: t, className: n, standardAttribution: r = !1 }) {
510
+ return /* @__PURE__ */ q("svg", {
511
+ xmlns: "http://www.w3.org/2000/svg",
512
+ viewBox: "0 0 55 12",
513
+ fill: "none",
514
+ style: {
515
+ height: r ? Math.min(e, He) : e,
516
+ color: t,
517
+ overflow: r ? "visible" : void 0
518
+ },
519
+ role: "img",
520
+ "aria-label": "eComID logo",
521
+ "aria-hidden": "true",
522
+ className: Ve("js-ecomid-logo", n),
523
+ children: [
524
+ /* @__PURE__ */ K("path", {
525
+ d: "M0.0224609 7.65191C0.0224609 5.43252 1.39553 3.41919 3.98386 3.41919C6.52482 3.41919 7.86632 5.32153 7.85054 7.36656C7.85054 7.6836 7.81898 8.06407 7.81898 8.06407H1.72696C1.88479 9.57009 2.78439 10.4261 4.11011 10.4261C5.1202 10.4261 5.92509 9.95056 6.11448 9.11036H7.80321C7.51912 10.9017 6.01979 11.9004 4.06276 11.9004C1.47445 11.9004 0.0224609 9.88714 0.0224609 7.65191ZM1.80588 6.70074H6.00401C5.92509 5.59103 5.21489 4.78255 3.98386 4.78255C2.83172 4.78255 2.0584 5.49591 1.80588 6.70074Z",
526
+ fill: "currentColor"
527
+ }),
528
+ /* @__PURE__ */ K("path", {
529
+ d: "M14.3155 11.9004C11.3642 11.9004 8.72852 9.9664 8.72852 6.05076C8.72852 2.15096 11.4115 0.216919 14.3155 0.216919C16.9038 0.216919 18.9555 1.65953 19.287 4.22768H17.3615C17.1248 2.76923 15.8937 1.83391 14.2997 1.83391C12.1849 1.83391 10.5908 3.33993 10.5908 6.05076C10.5908 8.77745 12.1849 10.2676 14.2997 10.2676C15.9095 10.2676 17.0932 9.3957 17.3615 7.88968H19.3027C18.8766 10.5371 16.8249 11.9004 14.3155 11.9004Z",
530
+ fill: "currentColor"
531
+ }),
532
+ /* @__PURE__ */ K("path", {
533
+ d: "M24.3604 11.9004C21.9457 11.9004 20.2412 10.1091 20.2412 7.65191C20.2412 5.21056 21.9457 3.41919 24.3604 3.41919C26.7279 3.41919 28.4797 5.19471 28.4797 7.65191C28.4797 10.1249 26.7279 11.9004 24.3604 11.9004ZM24.3604 10.3944C25.7493 10.3944 26.7121 9.25305 26.7121 7.65191C26.7121 6.05077 25.7336 4.92521 24.3604 4.92521C22.9243 4.92521 21.9931 6.06662 21.9931 7.65191C21.9931 9.25305 22.9243 10.3944 24.3604 10.3944Z",
534
+ fill: "currentColor"
535
+ }),
536
+ /* @__PURE__ */ K("path", {
537
+ d: "M29.4429 11.7736V3.54603H31.1632V4.95693C31.5892 4.03746 32.4099 3.41919 33.5778 3.41919C34.9037 3.41919 35.8506 3.98989 36.1977 5.05205C36.6395 4.13258 37.618 3.41919 38.8808 3.41919C40.6327 3.41919 41.769 4.54474 41.769 6.22515V11.7736H40.0486V6.65317C40.0486 5.60688 39.4488 4.90936 38.4072 4.90936C37.1605 4.90936 36.466 6.01907 36.466 7.62021V11.7736H34.7456V6.65317C34.7456 5.60688 34.1618 4.90936 33.1202 4.90936C31.8732 4.90936 31.1632 6.03492 31.1632 7.62021V11.7736H29.4429Z",
538
+ fill: "currentColor"
539
+ }),
540
+ /* @__PURE__ */ K("path", {
541
+ d: "M42.7407 11.7736V0.34375H44.5715V11.7736H42.7407Z",
542
+ fill: "currentColor"
543
+ }),
544
+ /* @__PURE__ */ K("path", {
545
+ d: "M45.5483 11.7736V0.34375H49.0994C52.2559 0.34375 54.8758 2.29365 54.8758 6.05076C54.8758 9.82375 52.2559 11.7736 49.0994 11.7736H45.5483ZM48.989 10.1408C51.0407 10.1408 52.9977 8.99939 52.9977 6.05076C52.9977 3.11799 51.0407 1.97659 48.989 1.97659H47.3791V10.1408H48.989Z",
546
+ fill: "currentColor"
547
+ })
548
+ ]
549
+ });
550
+ }
551
+ // src/search/components/PoweredBy/index.tsx
552
+ function We() {
553
+ return /* @__PURE__ */ q("div", {
554
+ className: "ecomid-search-powered",
555
+ children: [
556
+ /* @__PURE__ */ K("span", {
557
+ className: "ecomid-search-powered__label",
558
+ children: "Powered by"
559
+ }),
560
+ /* @__PURE__ */ K(Ue, {
561
+ className: "ecomid-search-powered__logo",
562
+ height: 7.93
563
+ }),
564
+ /* @__PURE__ */ K("span", {
565
+ className: "ecomid-search-sr-only",
566
+ children: "eComID"
567
+ })
568
+ ]
569
+ });
570
+ }
571
+ // src/search/components/ComingSoonTab/follower.ts
572
+ var Ge = 10, Ke = 16, qe = .07, Je = 250;
573
+ function Ye(e, t) {
574
+ let n = 0, r = 0, i = 0, a = 0, o = !1, s = 0, c, l = () => {
575
+ let t = e();
576
+ t && (t.style.transform = `translate(${i.toFixed(1)}px, ${a.toFixed(1)}px)`);
577
+ }, u = () => {
578
+ s && cancelAnimationFrame(s), s = 0;
579
+ }, d = () => {
580
+ i += (n + Ge - i) * qe, a += (r + Ke - a) * qe, l(), s = requestAnimationFrame(d);
581
+ };
582
+ return {
583
+ enter(u, f) {
584
+ n = u, r = f, clearTimeout(c), o || (i = u + Ge, a = f + Ke), o = !0;
585
+ let p = e();
586
+ p && (p.style.transition = "opacity 0.12s linear", p.style.opacity = "1"), l(), !t() && !s && (s = requestAnimationFrame(d));
587
+ },
588
+ move(e, s) {
589
+ n = e, r = s, o && t() && (i = e + Ge, a = s + Ke, l());
590
+ },
591
+ leave() {
592
+ o = !1;
593
+ let t = e();
594
+ t && (t.style.transition = "opacity 0.1s linear 0.03s", t.style.opacity = "0"), clearTimeout(c), c = setTimeout(() => {
595
+ o || u();
596
+ }, Je);
597
+ },
598
+ destroy() {
599
+ clearTimeout(c), u(), o = !1;
600
+ }
601
+ };
602
+ }
603
+ // src/search/components/ComingSoonTab/index.tsx
604
+ var Xe = 44, Ze = 3e3, Qe = () => typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, $e = () => typeof window.matchMedia == "function" && window.matchMedia("(hover: hover) and (pointer: fine)").matches;
605
+ function et({ lang: e, label: t }) {
606
+ let { t: n } = Q(e), r = te(), i = H(null), a = H(null), o = H(null), s = H([]), c = H(0), [l, u] = U(null), [d, f] = U(null);
607
+ z(() => {
608
+ f(document.body);
609
+ }, []);
610
+ let p = () => (o.current ||= Ye(() => a.current, Qe), o.current), m = () => {
611
+ for (let e of s.current) clearTimeout(e);
612
+ s.current = [];
613
+ };
614
+ z(() => () => {
615
+ o.current?.destroy();
616
+ for (let e of s.current) clearTimeout(e);
617
+ }, []);
618
+ let h = (e) => {
619
+ e.pointerType !== "touch" && p().enter(e.clientX, e.clientY);
620
+ }, g = (e) => {
621
+ e.pointerType !== "touch" && p().move(e.clientX, e.clientY);
622
+ }, _ = (e) => {
623
+ e.pointerType !== "touch" && p().leave();
624
+ }, v = (e) => {
625
+ let { pointerType: t } = e;
626
+ if (!(t ? t === "touch" : !$e())) return;
627
+ let n = (i.current?.closest(".ecomid-search-shell, .ecomid-search-modal__title-row") ?? i.current)?.getBoundingClientRect();
628
+ n && (m(), c.current += 1, u({
629
+ key: c.current,
630
+ left: n.left + n.width / 2,
631
+ top: n.top + Xe,
632
+ leaving: !1
633
+ }), s.current = [setTimeout(() => {
634
+ u((e) => e && {
635
+ ...e,
636
+ leaving: !0
637
+ });
638
+ }, Ze), setTimeout(() => u(null), 3450)]);
639
+ }, y = n("coming_soon");
640
+ return /* @__PURE__ */ q(G, { children: [
641
+ /* @__PURE__ */ K("button", {
642
+ ref: i,
643
+ type: "button",
644
+ className: "ecomid-search-shell__tab ecomid-search-shell__tab--soon",
645
+ "aria-disabled": "true",
646
+ "aria-describedby": r,
647
+ onPointerEnter: h,
648
+ onPointerMove: g,
649
+ onPointerLeave: _,
650
+ onClick: v,
651
+ children: t
652
+ }),
653
+ /* @__PURE__ */ K("span", {
654
+ id: r,
655
+ className: "ecomid-search-sr-only",
656
+ children: y
657
+ }),
658
+ d && J(/* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("div", {
659
+ ref: a,
660
+ className: "ecomid-search-soon ecomid-search-soon--follow",
661
+ "aria-hidden": "true",
662
+ children: y
663
+ }), l && /* @__PURE__ */ K("div", {
664
+ className: "ecomid-search-soon ecomid-search-soon--toast",
665
+ "data-leaving": l.leaving || void 0,
666
+ style: {
667
+ left: l.left,
668
+ top: l.top
669
+ },
670
+ "aria-hidden": "true",
671
+ children: y
672
+ }, l.key)] }), d)
673
+ ] });
674
+ }
675
+ // src/search/components/HeaderTabs/index.tsx
676
+ function tt({ lang: e }) {
677
+ let { t } = Q(e);
678
+ return /* @__PURE__ */ q("div", {
679
+ className: "ecomid-search-shell__tabs",
680
+ children: [/* @__PURE__ */ K("span", {
681
+ className: "ecomid-search-shell__tab",
682
+ "aria-current": "page",
683
+ children: t("shell.search")
684
+ }), /* @__PURE__ */ K(et, {
685
+ lang: e,
686
+ label: t("shell.for_you")
687
+ })]
688
+ });
689
+ }
690
+ // src/search/components/icons.tsx
691
+ function nt() {
692
+ return /* @__PURE__ */ q("svg", {
693
+ className: "ecomid-search-icon",
694
+ "aria-hidden": "true",
695
+ focusable: "false",
696
+ width: "16",
697
+ height: "16",
698
+ viewBox: "0 0 16 16",
699
+ fill: "none",
700
+ children: [/* @__PURE__ */ K("path", {
701
+ d: "M7 12.5C10.038 12.5 12.5 10.038 12.5 7C12.5 3.962 10.038 1.5 7 1.5C3.962 1.5 1.5 3.962 1.5 7C1.5 10.038 3.962 12.5 7 12.5Z",
702
+ stroke: "currentColor",
703
+ strokeWidth: "1.5",
704
+ strokeLinecap: "round",
705
+ strokeLinejoin: "round"
706
+ }), /* @__PURE__ */ K("path", {
707
+ d: "M14.5 14.5L11 11",
708
+ stroke: "currentColor",
709
+ strokeWidth: "1.5",
710
+ strokeLinecap: "round",
711
+ strokeLinejoin: "round"
712
+ })]
713
+ });
714
+ }
715
+ function rt() {
716
+ return /* @__PURE__ */ q("svg", {
717
+ className: "ecomid-search-icon",
718
+ "aria-hidden": "true",
719
+ focusable: "false",
720
+ width: "20",
721
+ height: "20",
722
+ viewBox: "0 0 20 20",
723
+ fill: "none",
724
+ children: [/* @__PURE__ */ K("path", {
725
+ d: "M17.266 2.74L2.732 17.274",
726
+ stroke: "currentColor",
727
+ strokeWidth: "1.5",
728
+ strokeLinecap: "round",
729
+ strokeLinejoin: "round"
730
+ }), /* @__PURE__ */ K("path", {
731
+ d: "M2.732 2.74L17.266 17.274",
732
+ stroke: "currentColor",
733
+ strokeWidth: "1.5",
734
+ strokeLinecap: "round",
735
+ strokeLinejoin: "round"
736
+ })]
737
+ });
738
+ }
739
+ function it() {
740
+ return /* @__PURE__ */ q("svg", {
741
+ className: "ecomid-search-icon",
742
+ "aria-hidden": "true",
743
+ focusable: "false",
744
+ width: "16",
745
+ height: "16",
746
+ viewBox: "0 0 16 16",
747
+ fill: "none",
748
+ children: [/* @__PURE__ */ K("path", {
749
+ d: "M12.5 7.672L2 7.672",
750
+ stroke: "currentColor",
751
+ strokeWidth: "1.5",
752
+ strokeLinecap: "round"
753
+ }), /* @__PURE__ */ K("path", {
754
+ d: "M7.414 2L13 7.586L7.414 13.172",
755
+ stroke: "currentColor",
756
+ strokeWidth: "1.5",
757
+ strokeMiterlimit: "16",
758
+ strokeLinecap: "round"
759
+ })]
760
+ });
761
+ }
762
+ function at() {
763
+ return /* @__PURE__ */ q("svg", {
764
+ className: "ecomid-search-icon",
765
+ "aria-hidden": "true",
766
+ focusable: "false",
767
+ width: "16",
768
+ height: "16",
769
+ viewBox: "0 0 16 16",
770
+ fill: "none",
771
+ children: [/* @__PURE__ */ K("path", {
772
+ d: "M8 3L8 14",
773
+ stroke: "currentColor",
774
+ strokeWidth: "1.5",
775
+ strokeLinecap: "round"
776
+ }), /* @__PURE__ */ K("path", {
777
+ d: "M2 8L8 2L14 8",
778
+ stroke: "currentColor",
779
+ strokeWidth: "1.5",
780
+ strokeMiterlimit: "16",
781
+ strokeLinecap: "round"
782
+ })]
783
+ });
784
+ }
785
+ function ot() {
786
+ return /* @__PURE__ */ K("svg", {
787
+ className: "ecomid-search-icon",
788
+ "aria-hidden": "true",
789
+ focusable: "false",
790
+ width: "16",
791
+ height: "16",
792
+ viewBox: "0 0 16 16",
793
+ fill: "none",
794
+ children: /* @__PURE__ */ K("path", {
795
+ d: "M6 2L12 8L6 14",
796
+ stroke: "currentColor",
797
+ strokeWidth: "1.5",
798
+ strokeMiterlimit: "16",
799
+ strokeLinecap: "round"
800
+ })
801
+ });
802
+ }
803
+ function st() {
804
+ return /* @__PURE__ */ K("svg", {
805
+ className: "ecomid-search-icon",
806
+ "aria-hidden": "true",
807
+ focusable: "false",
808
+ width: "20",
809
+ height: "20",
810
+ viewBox: "0 0 20 20",
811
+ fill: "none",
812
+ children: /* @__PURE__ */ K("path", {
813
+ d: "M12 16L6 10L12 4",
814
+ stroke: "currentColor",
815
+ strokeWidth: "1.5",
816
+ strokeMiterlimit: "16",
817
+ strokeLinecap: "round"
818
+ })
819
+ });
820
+ }
821
+ function ct() {
822
+ return /* @__PURE__ */ q("svg", {
823
+ className: "ecomid-search-icon ecomid-search-icon--16",
824
+ "aria-hidden": "true",
825
+ focusable: "false",
826
+ width: "16",
827
+ height: "16",
828
+ viewBox: "0 0 16 16",
829
+ fill: "none",
830
+ children: [
831
+ /* @__PURE__ */ K("path", {
832
+ d: "M1.5 5H10.86",
833
+ stroke: "currentColor",
834
+ strokeWidth: "1.5",
835
+ strokeLinecap: "round",
836
+ strokeLinejoin: "round"
837
+ }),
838
+ /* @__PURE__ */ K("path", {
839
+ d: "M12.68 6.64C13.685 6.64 14.5 5.825 14.5 4.82C14.5 3.815 13.685 3 12.68 3C11.675 3 10.86 3.815 10.86 4.82C10.86 5.825 11.675 6.64 12.68 6.64Z",
840
+ stroke: "currentColor",
841
+ strokeWidth: "1.5",
842
+ strokeLinecap: "round",
843
+ strokeLinejoin: "round"
844
+ }),
845
+ /* @__PURE__ */ K("path", {
846
+ d: "M14.499 11.552L9.299 11.552",
847
+ stroke: "currentColor",
848
+ strokeWidth: "1.5",
849
+ strokeLinecap: "round",
850
+ strokeLinejoin: "round"
851
+ }),
852
+ /* @__PURE__ */ K("path", {
853
+ d: "M4.62 11.552H1.5",
854
+ stroke: "currentColor",
855
+ strokeWidth: "1.5",
856
+ strokeLinecap: "round",
857
+ strokeLinejoin: "round"
858
+ }),
859
+ /* @__PURE__ */ K("path", {
860
+ d: "M7.183 13.442C8.188 13.442 9.003 12.627 9.003 11.622C9.003 10.617 8.188 9.802 7.183 9.802C6.178 9.802 5.363 10.617 5.363 11.622C5.363 12.627 6.178 13.442 7.183 13.442Z",
861
+ stroke: "currentColor",
862
+ strokeWidth: "1.5",
863
+ strokeLinecap: "round",
864
+ strokeLinejoin: "round"
865
+ })
866
+ ]
867
+ });
868
+ }
869
+ var lt = {
870
+ 12: [{
871
+ d: "M10.19 3.75L6 7.939L1.811 3.75",
872
+ strokeWidth: 1.2,
873
+ strokeMiterlimit: 16
874
+ }],
875
+ 16: [{
876
+ d: "M13.586 6L8 11.586L2.414 6",
877
+ strokeWidth: 1.5,
878
+ strokeMiterlimit: 16
879
+ }]
880
+ };
881
+ function ut({ size: e = 12 }) {
882
+ return /* @__PURE__ */ K("svg", {
883
+ className: `ecomid-search-icon ecomid-search-icon--${e}`,
884
+ "aria-hidden": "true",
885
+ focusable: "false",
886
+ width: e,
887
+ height: e,
888
+ viewBox: `0 0 ${e} ${e}`,
889
+ fill: "none",
890
+ children: lt[e].map((e) => /* @__PURE__ */ K("path", {
891
+ d: e.d,
892
+ stroke: "currentColor",
893
+ strokeWidth: e.strokeWidth,
894
+ strokeMiterlimit: e.strokeMiterlimit,
895
+ strokeLinecap: "round"
896
+ }, e.d))
897
+ });
898
+ }
899
+ function dt() {
900
+ return /* @__PURE__ */ q("svg", {
901
+ className: "ecomid-search-icon ecomid-search-icon--12",
902
+ "aria-hidden": "true",
903
+ focusable: "false",
904
+ width: "12",
905
+ height: "12",
906
+ viewBox: "0 0 12 12",
907
+ fill: "none",
908
+ children: [/* @__PURE__ */ K("path", {
909
+ d: "M9.607 2.379L2.395 9.591",
910
+ stroke: "currentColor",
911
+ strokeWidth: "1.2",
912
+ strokeLinecap: "round",
913
+ strokeLinejoin: "round"
914
+ }), /* @__PURE__ */ K("path", {
915
+ d: "M2.395 2.379L9.607 9.591",
916
+ stroke: "currentColor",
917
+ strokeWidth: "1.2",
918
+ strokeLinecap: "round",
919
+ strokeLinejoin: "round"
920
+ })]
921
+ });
922
+ }
923
+ function ft({ size: e = 16 }) {
924
+ return /* @__PURE__ */ K("svg", {
925
+ className: `ecomid-search-icon ecomid-search-icon--${e}`,
926
+ "aria-hidden": "true",
927
+ focusable: "false",
928
+ width: e,
929
+ height: e,
930
+ viewBox: "0 0 16 16",
931
+ fill: "none",
932
+ children: /* @__PURE__ */ K("path", {
933
+ d: "M13.24 4.301L5.842 11.699L2.76 8.617",
934
+ stroke: "currentColor",
935
+ strokeWidth: "1.5",
936
+ strokeLinecap: "round",
937
+ strokeLinejoin: "round"
938
+ })
939
+ });
940
+ }
941
+ function pt() {
942
+ return /* @__PURE__ */ q("svg", {
943
+ className: "ecomid-search-icon ecomid-search-icon--12",
944
+ "aria-hidden": "true",
945
+ focusable: "false",
946
+ width: "12",
947
+ height: "12",
948
+ viewBox: "0 0 12 12",
949
+ fill: "none",
950
+ children: [/* @__PURE__ */ K("path", {
951
+ d: "M5.999 5.191C7.182 5.191 8.141 4.232 8.141 3.05C8.141 1.867 7.182 0.908 5.999 0.908C4.816 0.908 3.857 1.867 3.857 3.05C3.857 4.232 4.816 5.191 5.999 5.191Z",
952
+ stroke: "currentColor",
953
+ strokeWidth: "1.2",
954
+ strokeLinecap: "round",
955
+ strokeLinejoin: "round"
956
+ }), /* @__PURE__ */ K("path", {
957
+ d: "M1.716 11.092H6H10.283V10.628C10.276 9.976 10.084 9.336 9.727 8.768C9.37 8.2 8.858 7.723 8.24 7.381C7.622 7.039 6.918 6.844 6.193 6.813C6.129 6.81 6.064 6.809 6 6.809C5.935 6.809 5.87 6.81 5.806 6.813C5.081 6.844 4.377 7.039 3.759 7.381C3.141 7.723 2.629 8.2 2.272 8.768C1.915 9.336 1.723 9.976 1.716 10.628V11.092Z",
958
+ stroke: "currentColor",
959
+ strokeWidth: "1.2",
960
+ strokeLinecap: "round",
961
+ strokeLinejoin: "round"
962
+ })]
963
+ });
964
+ }
965
+ function mt() {
966
+ return /* @__PURE__ */ q("svg", {
967
+ className: "ecomid-search-icon",
968
+ "aria-hidden": "true",
969
+ focusable: "false",
970
+ width: "20",
971
+ height: "20",
972
+ viewBox: "0 0 20 20",
973
+ fill: "none",
974
+ children: [/* @__PURE__ */ K("path", {
975
+ d: "M10.25 9.167C12.321 9.167 14 7.488 14 5.417C14 3.346 12.321 1.667 10.25 1.667C8.179 1.667 6.5 3.346 6.5 5.417C6.5 7.488 8.179 9.167 10.25 9.167Z",
976
+ stroke: "currentColor",
977
+ strokeWidth: "1.5",
978
+ strokeLinecap: "round",
979
+ strokeLinejoin: "round"
980
+ }), /* @__PURE__ */ K("path", {
981
+ d: "M4 18.334H10.25H16.5V17.612C16.489 16.596 16.21 15.6 15.688 14.717C15.167 13.833 14.421 13.09 13.519 12.558C12.618 12.026 11.59 11.722 10.533 11.674C10.438 11.669 10.344 11.667 10.25 11.667C10.156 11.667 10.062 11.669 9.967 11.674C8.91 11.722 7.882 12.026 6.981 12.558C6.079 13.09 5.333 13.833 4.811 14.717C4.29 15.6 4.011 16.596 4 17.612V18.334Z",
982
+ stroke: "currentColor",
983
+ strokeWidth: "1.5",
984
+ strokeLinecap: "round",
985
+ strokeLinejoin: "round"
986
+ })]
987
+ });
988
+ }
989
+ // src/search/components/PersonalizeButton/index.tsx
990
+ function ht({ lang: e, onClick: t, buttonRef: n }) {
991
+ let { t: r } = Q(e);
992
+ return /* @__PURE__ */ q("button", {
993
+ type: "button",
994
+ ref: n,
995
+ className: "ecomid-search-modal__personalize",
996
+ title: r("personalize"),
997
+ "aria-label": r("personalize"),
998
+ onClick: t,
999
+ children: [
1000
+ /* @__PURE__ */ K("span", {
1001
+ className: "ecomid-search-modal__personalize-chip",
1002
+ children: /* @__PURE__ */ K(pt, {})
1003
+ }),
1004
+ /* @__PURE__ */ K("span", {
1005
+ className: "ecomid-search-modal__personalize-button",
1006
+ children: /* @__PURE__ */ K(mt, {})
1007
+ }),
1008
+ /* @__PURE__ */ K("span", {
1009
+ className: "ecomid-search-modal__personalize-label",
1010
+ children: r("personalize")
1011
+ })
1012
+ ]
1013
+ });
1014
+ }
1015
+ // src/search/components/SearchHeader/index.tsx
1016
+ function gt({ lang: e, onClose: t, onPersonalize: n, personalizeRef: r }) {
1017
+ let { t: i } = Q(e);
1018
+ return /* @__PURE__ */ q("div", {
1019
+ className: "ecomid-search-modal__title-row",
1020
+ children: [
1021
+ /* @__PURE__ */ K("div", {
1022
+ className: "ecomid-search-modal__start",
1023
+ children: /* @__PURE__ */ K(ht, {
1024
+ lang: e,
1025
+ onClick: n,
1026
+ buttonRef: r
1027
+ })
1028
+ }),
1029
+ /* @__PURE__ */ K(tt, { lang: e }),
1030
+ /* @__PURE__ */ K("div", {
1031
+ className: "ecomid-search-modal__end",
1032
+ children: /* @__PURE__ */ K("button", {
1033
+ type: "button",
1034
+ className: "ecomid-search-modal__close",
1035
+ title: i("actions.close"),
1036
+ "aria-label": i("actions.close"),
1037
+ onClick: t,
1038
+ children: /* @__PURE__ */ K(rt, {})
1039
+ })
1040
+ })
1041
+ ]
1042
+ });
1043
+ }
1044
+ // node_modules/@ecomid/web-ui/dist/clsx-m_fIYDAy.js
1045
+ function _t(e) {
1046
+ var t, n, r = "";
1047
+ if (typeof e == "string" || typeof e == "number") r += e;
1048
+ else if (typeof e == "object") {
1049
+ if (Array.isArray(e)) {
1050
+ var i = e.length;
1051
+ for (t = 0; t < i; t++) e[t] && (n = _t(e[t])) && (r && (r += " "), r += n);
1052
+ } else for (n in e) e[n] && (r && (r += " "), r += n);
1053
+ }
1054
+ return r;
1055
+ }
1056
+ function vt() {
1057
+ for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = _t(e)) && (r && (r += " "), r += t);
1058
+ return r;
1059
+ }
1060
+ // node_modules/@ecomid/web-ui/dist/components/Icons/helpers.js
1061
+ var yt = ({ color: e, rotate: t, className: n, ...r }) => ({
1062
+ "aria-hidden": r.title || r["aria-label"] || r["aria-labelledby"] ? void 0 : !0,
1063
+ ...r,
1064
+ className: vt("transition-transform duration-150 ease-out", n)
1065
+ }), bt = (e) => {
1066
+ let t = yt(e);
1067
+ return /* @__PURE__ */ q("svg", {
1068
+ xmlns: "http://www.w3.org/2000/svg",
1069
+ width: 16,
1070
+ height: 16,
1071
+ fill: "none",
1072
+ role: "img",
1073
+ "aria-label": t.title,
1074
+ ...t,
1075
+ children: [
1076
+ /* @__PURE__ */ K("path", {
1077
+ fill: "currentColor",
1078
+ d: "M13.25 7c0-.19891-.079-.38968-.2197-.53033-.1406-.14065-.3314-.21967-.5303-.21967s-.3897.07902-.5303.21967c-.1407.14065-.2197.33142-.2197.53033.0001.37463-.0435.7476-.1302 1.10999-.4374 1.93071-2.21179 3.46981-4.1873 3.62061-.14356.0129-.28728.0194-.4325.0194-.77107.0009-1.5354-.1871-2.21431-.5464C3.25243 10.4091 2.23144 8.72925 2.25 7c-.03726-2.13475 1.56198-4.15368 3.64001-4.61978C6.2524 2.29346 6.62537 2.24995 7 2.25c.19891 0 .38968-.07902.53033-.21967S7.75 1.69891 7.75 1.5s-.07902-.38968-.21967-.53033C7.38968.829018 7.19891.75 7 .75c-.49002-.000104-.9813.056992-1.45902.17139C2.79984 1.53721.703717 4.1908.75 7c-.02416 2.27239 1.31952 4.4871 3.33528 5.53.89341.4733 1.90572.7216 2.91472.72.18995 0 .37844-.0084.56706-.0254 2.60604-.2022 4.93214-2.2179 5.51154-4.76558.1144-.47772.1715-.969.1714-1.45902"
1079
+ }),
1080
+ /* @__PURE__ */ K("path", {
1081
+ stroke: "currentColor",
1082
+ strokeLinecap: "round",
1083
+ strokeLinejoin: "round",
1084
+ strokeWidth: 1.5,
1085
+ d: "M14.5 14.5 11 11"
1086
+ }),
1087
+ /* @__PURE__ */ K("path", {
1088
+ fill: "currentColor",
1089
+ d: "M12.5476 3.90403s-.8675.2737-1.2285.63467-.6347 1.22849-.6347 1.22849c-.1847.50791-.5271.50791-.7118 0 0 0-.2737-.86752-.63467-1.22849s-1.22849-.63467-1.22849-.63467c-.5079-.1847-.5079-.52713 0-.71181 0 0 .86752-.27371 1.22849-.63468s.63467-1.22848.63467-1.22848c.1847-.507918.5271-.507918.7118 0 0 0 .2737.86751.6347 1.22848s1.2285.63468 1.2285.63468c.5079.18468.5079.52711 0 .71181"
1090
+ })
1091
+ ]
1092
+ });
1093
+ }, xt = (e) => {
1094
+ let t = yt(e);
1095
+ return /* @__PURE__ */ q("svg", {
1096
+ xmlns: "http://www.w3.org/2000/svg",
1097
+ width: 20,
1098
+ height: 20,
1099
+ fill: "none",
1100
+ role: "img",
1101
+ "aria-label": t.title,
1102
+ ...t,
1103
+ children: [
1104
+ /* @__PURE__ */ K("path", {
1105
+ stroke: "currentColor",
1106
+ strokeLinecap: "round",
1107
+ strokeLinejoin: "round",
1108
+ strokeWidth: 1.5,
1109
+ d: "M9.99996 5.62518v4.99992L6.75 12.2501"
1110
+ }),
1111
+ /* @__PURE__ */ K("path", {
1112
+ stroke: "currentColor",
1113
+ strokeLinecap: "round",
1114
+ strokeWidth: 1.5,
1115
+ d: "M2.09253 11.8749C2.93898 15.4582 6.15809 18.1248 10 18.1248c4.4873 0 8.1249-3.6376 8.1249-8.12491C18.1249 5.51264 14.4873 1.875 10 1.875c-3.1346 0-5.85461 1.77511-7.20963 4.37494"
1116
+ }),
1117
+ /* @__PURE__ */ K("path", {
1118
+ stroke: "currentColor",
1119
+ strokeLinecap: "round",
1120
+ strokeLinejoin: "round",
1121
+ strokeWidth: 1.5,
1122
+ d: "M1.875 3.75012v3.12496h3.12496"
1123
+ })
1124
+ ]
1125
+ });
1126
+ }, St = (e) => {
1127
+ let t = yt(e);
1128
+ return /* @__PURE__ */ K("svg", {
1129
+ xmlns: "http://www.w3.org/2000/svg",
1130
+ width: 12,
1131
+ height: 12,
1132
+ fill: "none",
1133
+ role: "img",
1134
+ "aria-label": t.title,
1135
+ ...t,
1136
+ children: /* @__PURE__ */ K("path", {
1137
+ stroke: "currentColor",
1138
+ strokeLinecap: "round",
1139
+ strokeLinejoin: "round",
1140
+ strokeWidth: 1.2,
1141
+ d: "M5.25 9.375c2.27818 0 4.125-1.84682 4.125-4.125S7.52818 1.125 5.25 1.125 1.125 2.97182 1.125 5.25 2.97182 9.375 5.25 9.375M10.875 10.875 8.25 8.25"
1142
+ })
1143
+ });
1144
+ };
1145
+ // src/search/components/hooks/useMediaQuery.ts
1146
+ function Ct(e) {
1147
+ return _e(L((t) => {
1148
+ if (typeof window.matchMedia != "function") return () => {};
1149
+ let n = window.matchMedia(e);
1150
+ return n.addEventListener("change", t), () => n.removeEventListener("change", t);
1151
+ }, [e]), L(() => typeof window.matchMedia == "function" && window.matchMedia(e).matches, [e]), () => !1);
1152
+ }
1153
+ // src/search/components/Panel.tsx
1154
+ var wt = 8, Tt = 8;
1155
+ function Et(e, t, n, r) {
1156
+ let i = t.getBoundingClientRect(), a = e.offsetWidth, o = document.documentElement.clientWidth, s = n === "end" ? i.right - a : i.left, c = Math.max(Tt, Math.min(s, o - a - Tt)), l = i.bottom + wt, u = i.top - wt - e.offsetHeight, d = r && l + e.offsetHeight > window.innerHeight && u >= 0;
1157
+ e.dataset.placement = d ? "top" : "bottom", e.style.top = `${d ? u : l}px`, e.style.left = `${c}px`;
1158
+ }
1159
+ function Dt({ kind: e, label: t, onClose: n, anchor: r, align: i = "start", flip: a = !1, semantics: o = "dialog", children: s }) {
1160
+ let c = e !== "popover", l = ze(), u = Te(n), d = H(null), f = H(!1), p = H(null);
1161
+ De(!0, L(() => {
1162
+ let e = document.activeElement;
1163
+ return !f.current || e === null || e === document.body || !!p.current?.contains(e);
1164
+ }, [])), Ce(c), z(() => {
1165
+ if (c) return;
1166
+ let e = (e) => {
1167
+ e.target instanceof Node && !r?.contains(e.target) && !d.current?.contains(e.target) && n();
1168
+ };
1169
+ return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
1170
+ }, [
1171
+ c,
1172
+ r,
1173
+ n
1174
+ ]), z(() => {
1175
+ if (c) return;
1176
+ let e = {
1177
+ x: window.scrollX,
1178
+ y: window.scrollY
1179
+ }, t = (t) => {
1180
+ let i = d.current, a = t.target;
1181
+ a instanceof Node && i?.contains(a) || a instanceof Element && r && !a.contains(r) || (a instanceof Element || window.scrollX !== e.x || window.scrollY !== e.y) && (f.current = !0, n());
1182
+ };
1183
+ return window.addEventListener("scroll", t, !0), () => window.removeEventListener("scroll", t, !0);
1184
+ }, [
1185
+ c,
1186
+ r,
1187
+ n
1188
+ ]), B(() => {
1189
+ let e = d.current;
1190
+ if (c || !e || !r) return;
1191
+ let t = 0, n = () => {
1192
+ t = 0, Et(e, r, i, a);
1193
+ }, o = () => {
1194
+ t ||= requestAnimationFrame(n);
1195
+ };
1196
+ return Et(e, r, i, a), window.addEventListener("resize", o), () => {
1197
+ cancelAnimationFrame(t), window.removeEventListener("resize", o);
1198
+ };
1199
+ }, [
1200
+ c,
1201
+ r,
1202
+ i,
1203
+ a
1204
+ ]);
1205
+ let m = L((e) => {
1206
+ d.current = e, e && (p.current = e), u(e);
1207
+ }, [u]), h = /* @__PURE__ */ K("div", {
1208
+ ref: m,
1209
+ ...o === "dialog" ? {
1210
+ role: "dialog",
1211
+ "aria-modal": c ? "true" : void 0,
1212
+ "aria-label": t
1213
+ } : { role: "none" },
1214
+ tabIndex: -1,
1215
+ className: `ecomid-search-overlay ecomid-search-overlay--${e}`,
1216
+ children: s
1217
+ });
1218
+ return J(c ? /* @__PURE__ */ K(be, {
1219
+ className: "ecomid-search-overlay-layer",
1220
+ onDismiss: n,
1221
+ children: h
1222
+ }) : h, l);
1223
+ }
1224
+ // src/search/components/SheetFrame.tsx
1225
+ function Ot({ title: e, allLabel: t, closeLabel: n, onAll: r, onClose: i, children: a }) {
1226
+ return /* @__PURE__ */ q(G, { children: [
1227
+ /* @__PURE__ */ K("div", {
1228
+ className: "ecomid-search-sheet__grabber",
1229
+ "aria-hidden": "true"
1230
+ }),
1231
+ /* @__PURE__ */ q("div", {
1232
+ className: "ecomid-search-sheet__header",
1233
+ children: [
1234
+ r && /* @__PURE__ */ K("button", {
1235
+ type: "button",
1236
+ className: "ecomid-search-sheet__action ecomid-search-sheet__action--start",
1237
+ title: t,
1238
+ "aria-label": t,
1239
+ onClick: r,
1240
+ children: /* @__PURE__ */ K(ct, {})
1241
+ }),
1242
+ /* @__PURE__ */ K("h2", {
1243
+ className: "ecomid-search-sheet__title",
1244
+ children: e
1245
+ }),
1246
+ /* @__PURE__ */ K("button", {
1247
+ type: "button",
1248
+ className: "ecomid-search-sheet__action ecomid-search-sheet__action--end",
1249
+ title: n,
1250
+ "aria-label": n,
1251
+ onClick: i,
1252
+ children: /* @__PURE__ */ K(rt, {})
1253
+ })
1254
+ ]
1255
+ }),
1256
+ /* @__PURE__ */ K("div", {
1257
+ className: "ecomid-search-sheet__body",
1258
+ children: a
1259
+ })
1260
+ ] });
1261
+ }
1262
+ // src/search/components/ProductCard/Menu.tsx
1263
+ var kt = I(null), At = (e) => {
1264
+ e.stopPropagation(), e.preventDefault();
1265
+ }, jt = "[role=\"menuitem\"]";
1266
+ function Mt(e) {
1267
+ let t = R(kt);
1268
+ return t ? /* @__PURE__ */ K(Nt, {
1269
+ ...e,
1270
+ onMoreLikeThis: t
1271
+ }) : null;
1272
+ }
1273
+ function Nt({ product: e, lang: t, onMoreLikeThis: n }) {
1274
+ let { t: r, isLoading: i } = Q(t), a = Ct("(min-width: 768px)"), [o, s] = U(!1), c = H(null), l = L(() => s(!1), []);
1275
+ if (i) return null;
1276
+ let u = r("card_menu.open", { name: e.name }), d = (e) => {
1277
+ At(e), e.currentTarget.focus({ preventScroll: !0 }), s((e) => !e);
1278
+ }, f = (e) => {
1279
+ At(e), l();
1280
+ }, p = /* @__PURE__ */ K("div", {
1281
+ role: "menu",
1282
+ "aria-label": e.name,
1283
+ className: "ecomid-search-card-menu__list",
1284
+ onKeyDown: (e) => {
1285
+ if (![
1286
+ "ArrowDown",
1287
+ "ArrowUp",
1288
+ "Home",
1289
+ "End"
1290
+ ].includes(e.key)) return;
1291
+ let t = Array.from(e.currentTarget.querySelectorAll(jt));
1292
+ if (t.length === 0) return;
1293
+ e.preventDefault();
1294
+ let n = t.indexOf(document.activeElement);
1295
+ t[e.key === "Home" ? 0 : e.key === "End" ? t.length - 1 : e.key === "ArrowDown" ? (n + 1) % t.length : (n - 1 + t.length) % t.length]?.focus();
1296
+ },
1297
+ onClick: At,
1298
+ children: /* @__PURE__ */ q("button", {
1299
+ type: "button",
1300
+ role: "menuitem",
1301
+ className: "ecomid-search-card-menu__item",
1302
+ onClick: () => {
1303
+ s(!1), n(r("card_menu.similar_to", { name: e.name }));
1304
+ },
1305
+ children: [/* @__PURE__ */ K(bt, {
1306
+ "aria-hidden": "true",
1307
+ focusable: "false"
1308
+ }), /* @__PURE__ */ K("span", { children: r("card_menu.more_like_this") })]
1309
+ })
1310
+ });
1311
+ return /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("button", {
1312
+ ref: c,
1313
+ type: "button",
1314
+ className: "ecomid-search-card-menu__button",
1315
+ title: u,
1316
+ "aria-label": u,
1317
+ "aria-haspopup": a ? "menu" : "dialog",
1318
+ "aria-expanded": o,
1319
+ onClick: d,
1320
+ children: /* @__PURE__ */ K(bt, {
1321
+ "aria-hidden": "true",
1322
+ focusable: "false"
1323
+ })
1324
+ }), o && /* @__PURE__ */ K(Dt, {
1325
+ kind: a ? "popover" : "sheet",
1326
+ label: e.name,
1327
+ semantics: a ? "none" : "dialog",
1328
+ onClose: l,
1329
+ anchor: c.current,
1330
+ align: "end",
1331
+ flip: !0,
1332
+ children: a ? p : /* @__PURE__ */ K(Ot, {
1333
+ title: e.name,
1334
+ closeLabel: r("actions.close"),
1335
+ onClose: f,
1336
+ children: p
1337
+ })
1338
+ })] });
1339
+ }
1340
+ // src/search/components/RollingPlaceholder/index.tsx
1341
+ var Pt = 2200, Ft = 4e3;
1342
+ function It({ texts: e }) {
1343
+ let [t, n] = U(0), r = e.length;
1344
+ z(() => {
1345
+ if (n(0), r < 2) return;
1346
+ let e = Date.now() + Ft, t = setInterval(() => {
1347
+ Date.now() < e || n((e) => e + 1);
1348
+ }, Pt);
1349
+ return () => clearInterval(t);
1350
+ }, [r]);
1351
+ let i = e[t % e.length], a = t > 0 ? e[(t - 1) % e.length] : void 0;
1352
+ return /* @__PURE__ */ q("span", {
1353
+ className: "ecomid-search-roll",
1354
+ "aria-hidden": "true",
1355
+ children: [a !== void 0 && /* @__PURE__ */ K("span", {
1356
+ className: "ecomid-search-roll__line ecomid-search-roll__line--out",
1357
+ children: a
1358
+ }, `out-${t}`), /* @__PURE__ */ K("span", {
1359
+ className: "ecomid-search-roll__line",
1360
+ "data-rolling": t > 0 || void 0,
1361
+ children: i
1362
+ }, `in-${t}`)]
1363
+ });
1364
+ }
1365
+ // src/search/core/reveal.ts
1366
+ var Lt = 6, Rt = 60, zt = 300, Bt = 10, Vt = 140, Ht = 70, Ut = 30, Wt = 6, Gt = 60, Kt = 40, qt = 440;
1367
+ function Jt(e) {
1368
+ let t = e.trim();
1369
+ return t ? t.split(/\s+/).length : 0;
1370
+ }
1371
+ function Yt(e, t) {
1372
+ let n = Rt + (Jt(e) + Bt) * Lt + zt, r = n + 150, i = t ? r + 250 : n + 200;
1373
+ return {
1374
+ question: r,
1375
+ chips: t ? r + 120 : n + 100,
1376
+ picks: i,
1377
+ browse: i + 200
1378
+ };
1379
+ }
1380
+ function Xt(e, t, n = 0, r = 0) {
1381
+ return r + Vt + e * Ht + Math.min(Math.max(t - n, 0), Wt) * Ut;
1382
+ }
1383
+ function Zt(e, t = 0) {
1384
+ return Gt + Math.min(Math.max(e - t, 0) * Kt, qt);
1385
+ }
1386
+ function Qt(e, t = !1) {
1387
+ return (t ? Rt : 0) + e * Lt;
1388
+ }
1389
+ function $t(e, t) {
1390
+ return Math.max(e - t, 0);
1391
+ }
1392
+ // src/helpers/productUrl.ts
1393
+ var en = (e, t) => {
1394
+ let n = e.indexOf("#"), r = n === -1 ? e : e.slice(0, n), i = n === -1 ? "" : e.slice(n), a = r.includes("?") ? r : r.replace(/%3F(?=variant=)/i, "?");
1395
+ return new URL(`${a}${i}`.replace(/^\/+/, ""), t);
1396
+ }, tn = "http://relative.invalid";
1397
+ function nn(e) {
1398
+ if (e) try {
1399
+ let t = en(e, tn);
1400
+ return t.origin === tn ? `${t.pathname}${t.search}${t.hash}` : t.toString();
1401
+ } catch {
1402
+ return e;
1403
+ }
1404
+ }
1405
+ // src/search/components/ProductCard/index.tsx
1406
+ var rn = /* @__PURE__ */ new Set(["cdn.ecomid.com", "images.ecomid.com"]), an = "ec_white_background";
1407
+ function on(e) {
1408
+ try {
1409
+ return rn.has(new URL(e).hostname);
1410
+ } catch {
1411
+ return !1;
1412
+ }
1413
+ }
1414
+ function sn({ price: e, baselinePrice: t }) {
1415
+ return e === void 0 || t === void 0 || t <= e ? 0 : Math.round((1 - e / t) * 100);
1416
+ }
1417
+ function cn(e) {
1418
+ if (e) return on(e) ? `${e}-0x600` : e;
1419
+ }
1420
+ function ln(e, t) {
1421
+ return t ? `${e}-${t}` : e;
1422
+ }
1423
+ function un(e, t) {
1424
+ try {
1425
+ return new Intl.NumberFormat(t, {
1426
+ style: "percent",
1427
+ signDisplay: "always"
1428
+ }).format(-e / 100);
1429
+ } catch (e) {
1430
+ e instanceof Error && o(e);
1431
+ return;
1432
+ }
1433
+ }
1434
+ function dn({ product: e, lang: t, market: n, onClick: r, revealDelay: i }) {
1435
+ let [a, o] = U(!1), s = L((e) => {
1436
+ e?.complete && e.naturalWidth > 0 && o(!0);
1437
+ }, []), c = sn(e), l = c > 0 ? un(c, ln(t, n)) : void 0, u = e.imageTags?.includes(an), { t: d } = Q(t), f = e.variantCount !== void 0 && e.variantCount > 1 ? e.variantCount - 1 : 0, p = f ? d(f === 1 ? "more_colors.singular" : "more_colors.plural", { count: String(f) }) : "", m = Ct("(hover: hover)"), h = cn(e.imageUrl), g = m ? cn(e.hoverImageUrl) : void 0, _ = e.hoverImageTags?.includes(an), v = /* @__PURE__ */ q(G, { children: [
1438
+ /* @__PURE__ */ q("span", {
1439
+ className: "ecomid-search-product__image",
1440
+ "data-white-bg": u || void 0,
1441
+ children: [
1442
+ h && /* @__PURE__ */ K("img", {
1443
+ ref: s,
1444
+ className: "ecomid-search-product__img",
1445
+ "data-white-bg": u || void 0,
1446
+ "data-loaded": a || void 0,
1447
+ src: h,
1448
+ alt: "",
1449
+ loading: "lazy",
1450
+ draggable: !1,
1451
+ onLoad: () => o(!0)
1452
+ }),
1453
+ g && /* @__PURE__ */ K("span", {
1454
+ className: "ecomid-search-product__hover",
1455
+ "data-white-bg": _ || void 0,
1456
+ children: /* @__PURE__ */ K("img", {
1457
+ className: "ecomid-search-product__hover-img",
1458
+ "data-white-bg": _ || void 0,
1459
+ src: g,
1460
+ alt: "",
1461
+ "aria-hidden": "true",
1462
+ loading: "lazy",
1463
+ draggable: !1
1464
+ })
1465
+ }),
1466
+ l && /* @__PURE__ */ K("span", {
1467
+ className: "ecomid-search-product__badge",
1468
+ "aria-hidden": "true",
1469
+ children: l
1470
+ })
1471
+ ]
1472
+ }),
1473
+ /* @__PURE__ */ K("span", {
1474
+ className: "ecomid-search-product__name",
1475
+ children: e.name
1476
+ }),
1477
+ /* @__PURE__ */ K(fn, {
1478
+ product: e,
1479
+ lang: t,
1480
+ market: n
1481
+ }),
1482
+ p && /* @__PURE__ */ K("span", {
1483
+ className: "ecomid-search-product__colors",
1484
+ children: p
1485
+ }),
1486
+ e.reason && /* @__PURE__ */ K("span", {
1487
+ className: "ecomid-search-product__reason",
1488
+ children: e.reason
1489
+ })
1490
+ ] }), y = nn(e.url), b = i === void 0 ? "ecomid-search-product" : "ecomid-search-product ecomid-search-tile-enter", x = i === void 0 ? void 0 : { animationDelay: `${i}ms` };
1491
+ return /* @__PURE__ */ q("div", {
1492
+ className: b,
1493
+ style: x,
1494
+ children: [y ? /* @__PURE__ */ K("a", {
1495
+ className: "ecomid-search-product__link",
1496
+ href: y,
1497
+ onClick: r,
1498
+ children: v
1499
+ }) : /* @__PURE__ */ K("div", {
1500
+ className: "ecomid-search-product__link",
1501
+ children: v
1502
+ }), /* @__PURE__ */ K("div", {
1503
+ className: "ecomid-search-product__actions",
1504
+ children: /* @__PURE__ */ K(Mt, {
1505
+ product: e,
1506
+ lang: t
1507
+ })
1508
+ })]
1509
+ });
1510
+ }
1511
+ function fn({ product: e, lang: t, market: n }) {
1512
+ if (e.price === void 0 || !e.currency) return null;
1513
+ try {
1514
+ let r = new Intl.NumberFormat(ln(t, n), {
1515
+ style: "currency",
1516
+ currency: e.currency,
1517
+ currencyDisplay: "narrowSymbol",
1518
+ minimumFractionDigits: 0,
1519
+ maximumFractionDigits: 2
1520
+ });
1521
+ return e.baselinePrice !== void 0 && e.price < e.baselinePrice ? /* @__PURE__ */ K(pn, {
1522
+ lang: t,
1523
+ price: r.format(e.price),
1524
+ baselinePrice: r.format(e.baselinePrice)
1525
+ }) : /* @__PURE__ */ K("span", {
1526
+ className: "ecomid-search-product__price",
1527
+ children: r.format(e.price)
1528
+ });
1529
+ } catch (e) {
1530
+ return e instanceof Error && o(e), null;
1531
+ }
1532
+ }
1533
+ function pn({ lang: e, price: t, baselinePrice: n }) {
1534
+ let { t: r, isLoading: i } = Q(e), a = !i || void 0;
1535
+ return /* @__PURE__ */ q("span", {
1536
+ className: "ecomid-search-product__price",
1537
+ "data-on-sale": "true",
1538
+ children: [
1539
+ !i && /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("span", {
1540
+ className: "ecomid-search-sr-only",
1541
+ children: r("price.sale", { price: t })
1542
+ }), /* @__PURE__ */ K("span", {
1543
+ className: "ecomid-search-sr-only",
1544
+ children: r("price.original", { price: n })
1545
+ })] }),
1546
+ /* @__PURE__ */ K("span", {
1547
+ className: "ecomid-search-product__price-current",
1548
+ "aria-hidden": a,
1549
+ children: t
1550
+ }),
1551
+ /* @__PURE__ */ K("span", {
1552
+ className: "ecomid-search-product__price-baseline",
1553
+ "aria-hidden": a,
1554
+ children: n
1555
+ })
1556
+ ]
1557
+ });
1558
+ }
1559
+ // src/search/components/ProductGrid/index.tsx
1560
+ var mn = class extends F {
1561
+ state = { hasError: !1 };
1562
+ static getDerivedStateFromError() {
1563
+ return { hasError: !0 };
1564
+ }
1565
+ componentDidCatch(e, t) {
1566
+ this.props.onError?.(e, t);
1567
+ }
1568
+ render() {
1569
+ return this.state.hasError ? this.props.fallback : this.props.children;
1570
+ }
1571
+ };
1572
+ function hn(e, t, n) {
1573
+ if (typeof window < "u") return e(t, n);
1574
+ try {
1575
+ return e(t, n);
1576
+ } catch {
1577
+ return null;
1578
+ }
1579
+ }
1580
+ function gn({ product: e, position: t, onProductClick: n, renderProduct: r, fallback: i, revealDelay: a, lang: o }) {
1581
+ let s = hn(r, e, {
1582
+ position: t,
1583
+ menuButton: /* @__PURE__ */ K(Mt, {
1584
+ product: e,
1585
+ lang: o
1586
+ })
1587
+ });
1588
+ return s == null ? i : /* @__PURE__ */ K("div", {
1589
+ className: a === void 0 ? "ecomid-search-grid__item" : "ecomid-search-grid__item ecomid-search-tile-enter",
1590
+ style: a === void 0 ? void 0 : { animationDelay: `${a}ms` },
1591
+ onClickCapture: (r) => {
1592
+ let i = r.target;
1593
+ if (!(i instanceof Element)) return;
1594
+ let a = i.closest("a[href]");
1595
+ i.closest(".ecomid-search-card-menu__button") || a && r.currentTarget.contains(a) && n(e, t)(r, (e) => {
1596
+ setTimeout(e, 0);
1597
+ });
1598
+ },
1599
+ children: s
1600
+ });
1601
+ }
1602
+ function _n({ products: e, lang: t, market: n, variant: r = "panel", reveal: i, onProductClick: a, renderProduct: o, onRenderError: s }) {
1603
+ let c = H(/* @__PURE__ */ new Map());
1604
+ return /* @__PURE__ */ K("div", {
1605
+ className: r === "results" ? "ecomid-search-grid ecomid-search-grid--results" : r === "carousel" ? "ecomid-search-carousel__track" : r === "picks" ? "ecomid-search-grid ecomid-search-grid--picks" : r === "wide" ? "ecomid-search-grid ecomid-search-grid--wide" : "ecomid-search-grid",
1606
+ children: e.map((e, l) => {
1607
+ let u = `${e.id}:${l}`, d;
1608
+ i && (d = c.current.get(u) ?? (r === "results" ? Zt(l, i.from) : Xt(i.section, l, i.from, i.base)), c.current.set(u, d));
1609
+ let f = /* @__PURE__ */ K(dn, {
1610
+ product: e,
1611
+ lang: t,
1612
+ market: n,
1613
+ onClick: a(e, l),
1614
+ revealDelay: d
1615
+ }, u);
1616
+ return o ? /* @__PURE__ */ K(mn, {
1617
+ fallback: f,
1618
+ onError: s,
1619
+ children: /* @__PURE__ */ K(gn, {
1620
+ lang: t,
1621
+ product: e,
1622
+ position: l,
1623
+ onProductClick: a,
1624
+ renderProduct: o,
1625
+ fallback: f,
1626
+ revealDelay: d
1627
+ })
1628
+ }, u) : f;
1629
+ })
1630
+ });
1631
+ }
1632
+ // src/search/components/ProductCarousel/pageTarget.ts
1633
+ var vn = 1;
1634
+ function yn({ direction: e, cards: t, scrollLeft: n, clientWidth: r, scrollWidth: i, padding: a }) {
1635
+ let o = Math.max(0, i - r), s = (e) => Math.min(o, Math.max(0, e));
1636
+ if (e === 1) {
1637
+ let e = n + r - a + vn, i = t.find(({ left: t, width: n }) => t + n > e);
1638
+ return s(i ? i.left - a : n + r);
1639
+ }
1640
+ let c = n + a - vn, l = t.findLast(({ left: e }) => e < c);
1641
+ if (!l) return s(n - r);
1642
+ let u = l.left + l.width + a - r, d = t.find(({ left: e }) => e - a >= u - vn);
1643
+ return s(d ? d.left - a : u);
1644
+ }
1645
+ // src/search/components/ProductCarousel/index.tsx
1646
+ var bn = 1;
1647
+ function xn({ products: e, lang: t, market: n, previousLabel: r, nextLabel: i, onProductClick: a, renderProduct: o, reveal: s, onRenderError: c }) {
1648
+ let l = H(null), u = H(null), d = H(null), [f, p] = U(!1), [m, h] = U(!1), g = L(() => {
1649
+ let e = l.current;
1650
+ if (!e) return;
1651
+ let { scrollLeft: t, scrollWidth: n, clientWidth: r } = e, i = t > bn, a = t + r < n - bn, o = document.activeElement;
1652
+ o === u.current && !i ? (a ? d.current : e)?.focus({ preventScroll: !0 }) : o === d.current && !a && (i ? u.current : e)?.focus({ preventScroll: !0 }), p(i), h(a);
1653
+ }, []);
1654
+ z(() => {
1655
+ g();
1656
+ let e = l.current;
1657
+ if (!e || typeof ResizeObserver > "u") return;
1658
+ let t = new ResizeObserver(g);
1659
+ return t.observe(e), e.firstElementChild && t.observe(e.firstElementChild), () => t.disconnect();
1660
+ }, [g]);
1661
+ let _ = (e) => {
1662
+ let t = l.current;
1663
+ if (!t) return;
1664
+ let n = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, r = Number.parseFloat(getComputedStyle(t).scrollPaddingLeft) || 0, i = t.getBoundingClientRect().left, a = Array.from(t.querySelectorAll(".ecomid-search-carousel__track > *")).map((e) => {
1665
+ let n = e.getBoundingClientRect();
1666
+ return {
1667
+ left: n.left - i + t.scrollLeft,
1668
+ width: n.width
1669
+ };
1670
+ });
1671
+ t.scrollTo({
1672
+ left: yn({
1673
+ direction: e,
1674
+ cards: a,
1675
+ scrollLeft: t.scrollLeft,
1676
+ clientWidth: t.clientWidth,
1677
+ scrollWidth: t.scrollWidth,
1678
+ padding: r
1679
+ }),
1680
+ behavior: n ? "auto" : "smooth"
1681
+ });
1682
+ };
1683
+ return /* @__PURE__ */ q("div", {
1684
+ className: "ecomid-search-carousel",
1685
+ children: [/* @__PURE__ */ K("div", {
1686
+ ref: l,
1687
+ className: "ecomid-search-carousel__scroller",
1688
+ tabIndex: -1,
1689
+ onScroll: g,
1690
+ children: /* @__PURE__ */ K(_n, {
1691
+ variant: "carousel",
1692
+ reveal: s,
1693
+ products: e,
1694
+ lang: t,
1695
+ market: n,
1696
+ onProductClick: a,
1697
+ renderProduct: o,
1698
+ onRenderError: c
1699
+ })
1700
+ }), (f || m) && /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("button", {
1701
+ ref: u,
1702
+ type: "button",
1703
+ className: "ecomid-search-carousel__button ecomid-search-carousel__button--previous",
1704
+ title: r,
1705
+ "aria-label": r,
1706
+ disabled: !f,
1707
+ onClick: () => _(-1),
1708
+ children: /* @__PURE__ */ K(st, {})
1709
+ }), /* @__PURE__ */ K("button", {
1710
+ ref: d,
1711
+ type: "button",
1712
+ className: "ecomid-search-carousel__button ecomid-search-carousel__button--next",
1713
+ title: i,
1714
+ "aria-label": i,
1715
+ disabled: !m,
1716
+ onClick: () => _(1),
1717
+ children: /* @__PURE__ */ K(ot, {})
1718
+ })] })]
1719
+ });
1720
+ }
1721
+ // src/search/components/Skeletons/index.tsx
1722
+ var Sn = [
1723
+ "88px",
1724
+ "112px",
1725
+ "96px",
1726
+ "128px",
1727
+ "72px"
1728
+ ];
1729
+ function Cn() {
1730
+ return /* @__PURE__ */ K("div", {
1731
+ className: "ecomid-search-starters",
1732
+ "aria-hidden": "true",
1733
+ "data-loading": "true",
1734
+ children: Sn.map((e) => /* @__PURE__ */ K("span", {
1735
+ className: "ecomid-search-skeleton ecomid-search-skeleton--pill",
1736
+ style: { width: e }
1737
+ }, e))
1738
+ });
1739
+ }
1740
+ function wn({ variant: e, count: t = 4 }) {
1741
+ return /* @__PURE__ */ K("div", {
1742
+ className: e ? `ecomid-search-grid ecomid-search-grid--${e}` : "ecomid-search-grid",
1743
+ "aria-hidden": "true",
1744
+ "data-loading": "true",
1745
+ children: Array.from({ length: t }, (e, t) => `card-${t}`).map((e) => /* @__PURE__ */ q("div", {
1746
+ className: "ecomid-search-product",
1747
+ children: [/* @__PURE__ */ K("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--image" }), /* @__PURE__ */ K("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--text" })]
1748
+ }, e))
1749
+ });
1750
+ }
1751
+ var Tn = [
1752
+ "a",
1753
+ "b",
1754
+ "c",
1755
+ "d",
1756
+ "e",
1757
+ "f"
1758
+ ];
1759
+ function En() {
1760
+ return /* @__PURE__ */ K("div", {
1761
+ className: "ecomid-search-carousel",
1762
+ "aria-hidden": "true",
1763
+ "data-loading": "true",
1764
+ children: /* @__PURE__ */ K("div", {
1765
+ className: "ecomid-search-carousel__scroller",
1766
+ children: /* @__PURE__ */ K("div", {
1767
+ className: "ecomid-search-carousel__track",
1768
+ children: Tn.map((e) => /* @__PURE__ */ q("div", {
1769
+ className: "ecomid-search-product",
1770
+ children: [
1771
+ /* @__PURE__ */ K("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--image" }),
1772
+ /* @__PURE__ */ K("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--text" }),
1773
+ /* @__PURE__ */ K("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--text ecomid-search-skeleton--short" })
1774
+ ]
1775
+ }, e))
1776
+ })
1777
+ })
1778
+ });
1779
+ }
1780
+ function Dn({ widths: e, className: t }) {
1781
+ return /* @__PURE__ */ K("div", {
1782
+ className: t ? `ecomid-search-skeleton-lines ${t}` : "ecomid-search-skeleton-lines",
1783
+ "aria-hidden": "true",
1784
+ "data-loading": "true",
1785
+ children: e.map((e, t) => /* @__PURE__ */ K("span", {
1786
+ className: "ecomid-search-skeleton-line",
1787
+ children: /* @__PURE__ */ K("span", {
1788
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar",
1789
+ style: {
1790
+ width: e,
1791
+ animationDelay: `${t * .15}s`
1792
+ }
1793
+ })
1794
+ }, e))
1795
+ });
1796
+ }
1797
+ var On = [
1798
+ "40px",
1799
+ "112px",
1800
+ "96px",
1801
+ "120px",
1802
+ "84px"
1803
+ ];
1804
+ function kn() {
1805
+ return /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("div", {
1806
+ className: "ecomid-search-toolbar__pills",
1807
+ "aria-hidden": "true",
1808
+ "data-loading": "true",
1809
+ children: On.map((e, t) => /* @__PURE__ */ K("span", {
1810
+ className: "ecomid-search-skeleton ecomid-search-skeleton--pill",
1811
+ style: {
1812
+ width: e,
1813
+ animationDelay: `${t * .08}s`
1814
+ }
1815
+ }, e))
1816
+ }), /* @__PURE__ */ q("div", {
1817
+ className: "ecomid-search-toolbar__meta",
1818
+ "aria-hidden": "true",
1819
+ "data-loading": "true",
1820
+ children: [/* @__PURE__ */ K("span", {
1821
+ className: "ecomid-search-skeleton-line",
1822
+ children: /* @__PURE__ */ K("span", {
1823
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar",
1824
+ style: { width: "72px" }
1825
+ })
1826
+ }), /* @__PURE__ */ K("span", {
1827
+ className: "ecomid-search-skeleton-line",
1828
+ children: /* @__PURE__ */ K("span", {
1829
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar",
1830
+ style: { width: "56px" }
1831
+ })
1832
+ })]
1833
+ })] });
1834
+ }
1835
+ function An({ count: e = 4 }) {
1836
+ return /* @__PURE__ */ q("section", {
1837
+ className: "ecomid-search-section ecomid-search-compose__section ecomid-search-compose__section--picks",
1838
+ "aria-hidden": "true",
1839
+ "data-loading": "true",
1840
+ children: [/* @__PURE__ */ q("div", {
1841
+ className: "ecomid-search-compose__section-header",
1842
+ children: [/* @__PURE__ */ K("span", {
1843
+ className: "ecomid-search-compose__section-title ecomid-search-skeleton-line",
1844
+ children: /* @__PURE__ */ K("span", {
1845
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar ecomid-search-skeleton--title",
1846
+ style: { width: "180px" }
1847
+ })
1848
+ }), /* @__PURE__ */ K("span", {
1849
+ className: "ecomid-search-compose__count ecomid-search-skeleton-line",
1850
+ children: /* @__PURE__ */ K("span", {
1851
+ className: "ecomid-search-skeleton ecomid-search-skeleton--bar",
1852
+ style: { width: "72px" }
1853
+ })
1854
+ })]
1855
+ }), /* @__PURE__ */ K(wn, {
1856
+ variant: "picks",
1857
+ count: e
1858
+ })]
1859
+ });
1860
+ }
1861
+ // src/helpers/dragScroll.ts
1862
+ var jn = 5;
1863
+ function Mn(e, t = "grab") {
1864
+ let n = {
1865
+ isPointerDown: !1,
1866
+ isDragging: !1,
1867
+ startX: 0,
1868
+ startScrollLeft: 0,
1869
+ suppressNextClick: !1
1870
+ }, r = () => {
1871
+ e.style.cursor = t, e.style.userSelect = "";
1872
+ }, i = (t) => {
1873
+ t.pointerType === "mouse" && (n.isPointerDown = !0, n.isDragging = !1, n.startX = t.clientX, n.startScrollLeft = e.scrollLeft);
1874
+ }, a = (t) => {
1875
+ if (!n.isPointerDown) return;
1876
+ let r = t.clientX - n.startX;
1877
+ if (!n.isDragging) {
1878
+ if (Math.abs(r) <= jn) return;
1879
+ n.isDragging = !0, e.style.cursor = "grabbing", e.style.userSelect = "none";
1880
+ }
1881
+ e.scrollLeft = n.startScrollLeft - r;
1882
+ }, o = (e) => {
1883
+ n.isPointerDown && (n.isPointerDown = !1, n.isDragging && (n.isDragging = !1, e && (n.suppressNextClick = !0), r()));
1884
+ }, s = () => o(!0), c = () => o(!1), l = (e) => {
1885
+ n.suppressNextClick && (n.suppressNextClick = !1, e.stopPropagation(), e.preventDefault());
1886
+ };
1887
+ return e.style.cursor = t, e.addEventListener("pointerdown", i), window.addEventListener("pointermove", a), window.addEventListener("pointerup", s), window.addEventListener("pointercancel", c), e.addEventListener("click", l, { capture: !0 }), () => {
1888
+ e.style.cursor = "", e.style.userSelect = "", e.removeEventListener("pointerdown", i), window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", s), window.removeEventListener("pointercancel", c), e.removeEventListener("click", l, { capture: !0 });
1889
+ };
1890
+ }
1891
+ // src/search/components/hooks/useDragScroll.ts
1892
+ function Nn(e, t = !0) {
1893
+ z(() => {
1894
+ let n = e.current;
1895
+ if (t && n) return Mn(n, "");
1896
+ }, [e, t]);
1897
+ }
1898
+ // src/helpers/cssProperties.ts
1899
+ var Pn = /* @__PURE__ */ new Set(), Fn = (e) => {
1900
+ if (typeof CSS > "u" || typeof CSS.registerProperty != "function") return !1;
1901
+ for (let t of e) if (!Pn.has(t.name)) {
1902
+ try {
1903
+ CSS.registerProperty(t);
1904
+ } catch {}
1905
+ Pn.add(t.name);
1906
+ }
1907
+ return !0;
1908
+ }, In = "--ecomid-fade-start", Ln = "--ecomid-fade-end", Rn = [{
1909
+ name: In,
1910
+ syntax: "<color>",
1911
+ inherits: !1,
1912
+ initialValue: "black"
1913
+ }, {
1914
+ name: Ln,
1915
+ syntax: "<color>",
1916
+ inherits: !1,
1917
+ initialValue: "black"
1918
+ }];
1919
+ function zn(e, t) {
1920
+ Fn(Rn);
1921
+ let n = 0, r = (t, n) => {
1922
+ n ? e.style.removeProperty(t) : e.style.setProperty(t, "transparent");
1923
+ }, i = () => {
1924
+ cancelAnimationFrame(n), n = requestAnimationFrame(() => {
1925
+ let n = t === "horizontal", i = n ? e.scrollLeft : e.scrollTop, a = n ? e.scrollWidth - e.clientWidth : e.scrollHeight - e.clientHeight;
1926
+ r(In, i <= 1), r(Ln, i >= a - 1);
1927
+ });
1928
+ };
1929
+ i(), e.addEventListener("scroll", i, { passive: !0 });
1930
+ let a = typeof ResizeObserver > "u" ? null : new ResizeObserver(i);
1931
+ return a?.observe(e), () => {
1932
+ cancelAnimationFrame(n), e.removeEventListener("scroll", i), a?.disconnect(), e.style.removeProperty(In), e.style.removeProperty(Ln);
1933
+ };
1934
+ }
1935
+ // src/search/components/hooks/useScrollFade.ts
1936
+ function Bn(e, t = "horizontal", n = !0) {
1937
+ z(() => {
1938
+ let r = e.current;
1939
+ if (n && r) return zn(r, t);
1940
+ }, [
1941
+ e,
1942
+ t,
1943
+ n
1944
+ ]);
1945
+ }
1946
+ // src/search/components/hooks/useVisibleCount.ts
1947
+ var Vn = "[data-more]";
1948
+ function Hn(e) {
1949
+ let t = Array.from(e.children).filter((e) => e instanceof HTMLElement && !e.matches(Vn)), n = e.querySelector(Vn);
1950
+ for (let e of t) e.hidden = !1;
1951
+ n && (n.hidden = !0);
1952
+ let r = e.clientWidth;
1953
+ if (e.scrollWidth <= r || t.length < (n ? 2 : 1)) return 0;
1954
+ let i = 0;
1955
+ n && (n.hidden = !1, i = n.offsetWidth, n.hidden = !0);
1956
+ let a = Number.parseFloat(getComputedStyle(e).columnGap) || 0, o = t.map((e) => e.offsetWidth), s = 0, c = 0;
1957
+ for (let e = 0; e < t.length; e++) {
1958
+ let l = c === 0 ? o[0] : s + a + o[e];
1959
+ if (l + (n && e < t.length - 1 ? a + i : 0) > r && (!n || c > 0)) break;
1960
+ s = l, c++;
1961
+ }
1962
+ return t.length - c;
1963
+ }
1964
+ function Un(e, t) {
1965
+ let n = Array.from(e.children).filter((e) => e instanceof HTMLElement && !e.matches(Vn));
1966
+ n.forEach((e, r) => {
1967
+ e.hidden = r >= n.length - t;
1968
+ });
1969
+ let r = e.querySelector(Vn);
1970
+ r && (r.hidden = t === 0);
1971
+ }
1972
+ function Wn(e, t) {
1973
+ let [n, r] = U(0), i = H(() => {});
1974
+ return i.current = () => {
1975
+ let i = e.current;
1976
+ if (!i) return;
1977
+ let a = t ? Hn(i) : 0;
1978
+ Un(i, a), a !== n && r(a);
1979
+ }, B(() => {
1980
+ i.current();
1981
+ }), B(() => {
1982
+ let n = e.current;
1983
+ if (!t || !n || typeof ResizeObserver > "u") return;
1984
+ let r = new ResizeObserver(() => i.current());
1985
+ return r.observe(n.parentElement ?? n), () => r.disconnect();
1986
+ }, [e, t]), n;
1987
+ }
1988
+ // src/search/components/SearchPanel/StarterPills/index.tsx
1989
+ function Gn({ starters: e, onSelect: t, fit: n = !1 }) {
1990
+ let r = H(null), i = Ct("(min-width: 768px)"), a = n && i;
1991
+ return Wn(r, a), Nn(r, !a), Bn(r, "horizontal", !a), /* @__PURE__ */ K("div", {
1992
+ ref: r,
1993
+ className: "ecomid-search-starters",
1994
+ children: e.map((e) => /* @__PURE__ */ K("button", {
1995
+ type: "button",
1996
+ className: "ecomid-search-starters__pill",
1997
+ onClick: () => t(e.text),
1998
+ children: e.text
1999
+ }, e.text))
2000
+ });
2001
+ }
2002
+ // src/search/components/SearchPanel/EmptyState/index.tsx
2003
+ function Kn({ status: e, starters: t, products: n, lang: r, market: i, recommendedLabel: a, countLabel: o, fitStarters: s, previousLabel: c, nextLabel: l, onPillSelect: u, onProductClick: d, renderProduct: f, onRenderError: p }) {
2004
+ return e === "error" ? null : e === "loading" || e === "idle" ? /* @__PURE__ */ q("div", {
2005
+ className: "ecomid-search-panel__empty",
2006
+ children: [/* @__PURE__ */ K(Cn, {}), /* @__PURE__ */ q("section", {
2007
+ className: "ecomid-search-section",
2008
+ "aria-hidden": "true",
2009
+ children: [/* @__PURE__ */ K("span", { className: "ecomid-search-skeleton ecomid-search-skeleton--heading ecomid-search-section__heading" }), /* @__PURE__ */ K(En, {})]
2010
+ })]
2011
+ }) : /* @__PURE__ */ q("div", {
2012
+ className: "ecomid-search-panel__empty",
2013
+ children: [t.length > 0 && /* @__PURE__ */ K(Gn, {
2014
+ starters: t,
2015
+ onSelect: u,
2016
+ fit: s
2017
+ }), n.length > 0 && /* @__PURE__ */ q("section", {
2018
+ className: "ecomid-search-section",
2019
+ children: [o ? /* @__PURE__ */ q("div", {
2020
+ className: "ecomid-search-section__header",
2021
+ children: [/* @__PURE__ */ K("h3", {
2022
+ className: "ecomid-search-section__heading",
2023
+ children: a
2024
+ }), /* @__PURE__ */ K("span", {
2025
+ className: "ecomid-search-section__count",
2026
+ children: o
2027
+ })]
2028
+ }) : /* @__PURE__ */ K("h3", {
2029
+ className: "ecomid-search-section__heading",
2030
+ children: a
2031
+ }), /* @__PURE__ */ K(xn, {
2032
+ products: n,
2033
+ lang: r,
2034
+ market: i,
2035
+ previousLabel: c,
2036
+ nextLabel: l,
2037
+ onProductClick: d,
2038
+ renderProduct: f,
2039
+ onRenderError: p
2040
+ })]
2041
+ })]
2042
+ });
2043
+ }
2044
+ // src/search/components/SearchPanel/Suggestions/index.tsx
2045
+ function qn({ suggestions: e, askLabel: t, query: n, activeIndex: r, listboxId: i, labelledBy: a, getOptionId: o, onSelect: s, leading: c }) {
2046
+ return /* @__PURE__ */ K("div", {
2047
+ id: i,
2048
+ role: "listbox",
2049
+ "aria-labelledby": a,
2050
+ className: "ecomid-search-listbox",
2051
+ children: e.map((e, i) => /* @__PURE__ */ q("button", {
2052
+ type: "button",
2053
+ id: o(i),
2054
+ role: "option",
2055
+ tabIndex: -1,
2056
+ "aria-selected": r === i,
2057
+ "data-active": r === i || void 0,
2058
+ className: "ecomid-search-option",
2059
+ onMouseDown: (e) => e.preventDefault(),
2060
+ onClick: () => s(e.text),
2061
+ children: [c, /* @__PURE__ */ K("span", {
2062
+ className: "ecomid-search-option__text",
2063
+ children: e.ask ? /* @__PURE__ */ K(Yn, {
2064
+ template: t,
2065
+ text: e.text
2066
+ }) : /* @__PURE__ */ K(Xn, {
2067
+ text: e.text,
2068
+ query: n
2069
+ })
2070
+ })]
2071
+ }, e.text))
2072
+ });
2073
+ }
2074
+ var Jn = "{query}";
2075
+ function Yn({ template: e, text: t }) {
2076
+ let n = e.indexOf(Jn);
2077
+ return n === -1 ? /* @__PURE__ */ K(G, { children: t }) : /* @__PURE__ */ q(G, { children: [
2078
+ e.slice(0, n),
2079
+ /* @__PURE__ */ K("span", {
2080
+ className: "ecomid-search-highlight",
2081
+ children: t
2082
+ }),
2083
+ e.slice(n + 7)
2084
+ ] });
2085
+ }
2086
+ function Xn({ text: e, query: t }) {
2087
+ if (!t) return /* @__PURE__ */ K(G, { children: e });
2088
+ let n = e.toLowerCase().indexOf(t.toLowerCase());
2089
+ return n === -1 ? /* @__PURE__ */ K(G, { children: e }) : /* @__PURE__ */ q(G, { children: [
2090
+ e.slice(0, n),
2091
+ /* @__PURE__ */ K("span", {
2092
+ className: "ecomid-search-highlight",
2093
+ children: e.slice(n, n + t.length)
2094
+ }),
2095
+ e.slice(n + t.length)
2096
+ ] });
2097
+ }
2098
+ // src/search/components/SearchPanel/TypingState/index.tsx
2099
+ function Zn({ suggestions: e, starters: t, carousel: n, previousLabel: r, nextLabel: i, onPillSelect: a, products: o, query: s, activeIndex: c, showListbox: l, showNoResults: u, noResultsLabel: d, suggestionsLabel: f, askLabel: p, productsLabel: m, listboxId: h, suggestionsHeadingId: g, getOptionId: _, lang: v, market: y, onSuggestionSelect: b, onProductClick: x, renderProduct: S, onRenderError: C }) {
2100
+ return /* @__PURE__ */ q("div", {
2101
+ className: "ecomid-search-panel__typing",
2102
+ children: [
2103
+ t.length > 0 && /* @__PURE__ */ K(Gn, {
2104
+ starters: t,
2105
+ onSelect: a
2106
+ }),
2107
+ l && /* @__PURE__ */ q("section", {
2108
+ className: "ecomid-search-section",
2109
+ children: [/* @__PURE__ */ K("h3", {
2110
+ id: g,
2111
+ className: "ecomid-search-section__heading",
2112
+ children: f
2113
+ }), /* @__PURE__ */ K(qn, {
2114
+ suggestions: e,
2115
+ askLabel: p,
2116
+ query: s,
2117
+ activeIndex: c,
2118
+ listboxId: h,
2119
+ labelledBy: g,
2120
+ getOptionId: _,
2121
+ onSelect: b
2122
+ })]
2123
+ }),
2124
+ u ? /* @__PURE__ */ K("p", {
2125
+ className: "ecomid-search-no-results",
2126
+ children: d
2127
+ }) : o.length > 0 && /* @__PURE__ */ q("section", {
2128
+ className: "ecomid-search-section",
2129
+ children: [/* @__PURE__ */ K("h3", {
2130
+ className: "ecomid-search-section__heading",
2131
+ children: m
2132
+ }), n ? /* @__PURE__ */ K(xn, {
2133
+ products: o,
2134
+ lang: v,
2135
+ market: y,
2136
+ previousLabel: r,
2137
+ nextLabel: i,
2138
+ onProductClick: x,
2139
+ renderProduct: S,
2140
+ onRenderError: C
2141
+ }) : /* @__PURE__ */ K(_n, {
2142
+ products: o,
2143
+ lang: v,
2144
+ market: y,
2145
+ onProductClick: x,
2146
+ renderProduct: S,
2147
+ onRenderError: C
2148
+ })]
2149
+ })
2150
+ ]
2151
+ });
2152
+ }
2153
+ // src/search/components/SearchPanel/index.tsx
2154
+ var Qn = (e) => e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey;
2155
+ function $n({ store: e, track: t, onDone: n, headerEnd: r, footer: i, onSubmit: a, onProductClick: o, renderProduct: s, onRenderError: c, lang: l, market: u, autoFocus: d = !0, showCount: f = !1, floatingSuggestions: p = !1 }) {
2156
+ let m = te(), h = _e(e.subscribe, e.getState, e.getState), { t: g } = Q(l), v = H(null), y = H(null), [b, x] = U(-1), [S, C] = U(!1), w = Ct("(min-width: 768px)"), T = p && w;
2157
+ z(() => {
2158
+ e.loadEmptyState(), e.resumeSearch();
2159
+ }, [e]), z(() => {
2160
+ h.query || x(-1);
2161
+ }, [h.query]), z(() => {
2162
+ if (!T) return;
2163
+ let e = (e) => {
2164
+ e.target instanceof Node && !y.current?.contains(e.target) && C(!0);
2165
+ };
2166
+ return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
2167
+ }, [T]);
2168
+ let E = L(() => {
2169
+ let r = e.submit();
2170
+ r && (t(ve.SEARCH_SUBMIT, { attrs: { query: r } }), a?.(r), n?.());
2171
+ }, [
2172
+ e,
2173
+ t,
2174
+ a,
2175
+ n
2176
+ ]), D = L((n) => {
2177
+ t(ve.SUGGESTION_CLICK, { attrs: { text: n } }), e.setQuery(n), x(-1), E();
2178
+ }, [
2179
+ e,
2180
+ t,
2181
+ E
2182
+ ]), O = L((t) => {
2183
+ e.setQuery(t), x(-1), E();
2184
+ }, [e, E]), k = L((n) => {
2185
+ t(ve.PRE_PROMPT_CLICK, { attrs: { text: n } }), e.setQuery(n), x(-1), E();
2186
+ }, [
2187
+ e,
2188
+ t,
2189
+ E
2190
+ ]), ee = L((e, r) => (i, a) => {
2191
+ t(ve.PRODUCT_CLICK, { attrs: {
2192
+ variant_id: e.id,
2193
+ name: e.name,
2194
+ url: e.url,
2195
+ position: String(r)
2196
+ } }), o?.(e, i), Qn(i) && (a && n ? a(n) : n?.());
2197
+ }, [
2198
+ t,
2199
+ o,
2200
+ n
2201
+ ]), A = () => {
2202
+ let e = F[b];
2203
+ e ? D(e.text) : E();
2204
+ }, j = (e) => {
2205
+ e.preventDefault(), A();
2206
+ }, M = (e) => {
2207
+ e.key === "Escape" && T && J ? (e.preventDefault(), C(!0), x(-1)) : e.key === "ArrowDown" ? (e.preventDefault(), F.length > 0 && (C(!1), x((e) => Math.min(e + 1, F.length - 1)))) : e.key === "ArrowUp" && (e.preventDefault(), x((e) => Math.max(e - 1, -1)));
2208
+ }, N = h.query.trim(), P = N.length < e.minQueryLength, F = T || h.instant ? [..._(h.query), ...h.instant?.suggestions ?? []] : [], I = h.instant?.products ?? [], R = h.emptyState?.starters ?? [], B = h.emptyState?.recommendedProducts ?? [], V = Ct("(prefers-reduced-motion: reduce)"), W = [g("placeholder"), ...R.map((e) => e.text)].filter(Boolean), G = !V && W.length > 1 && !h.query, J = !P && F.length > 0 && !(T && S), Y = I.length === 0 && B.length > 0, ne = Y ? B : I, re = !P && !T && F.length === 0 && R.length > 0, ie = !P && h.status === "success" && !re && F.length === 0 && ne.length === 0, ae = P || T ? "" : h.status === "success" ? ie ? g("no_results") : g(I.length === 1 ? "results_status.title_singular" : "results_status.title_plural", {
2209
+ count: String(I.length),
2210
+ query: N
2211
+ }) : "", oe = `${m}-listbox`, se = b >= 0 ? `${m}-option-${b}` : void 0, ce = `${m}-suggestions`, le = /* @__PURE__ */ q("div", {
2212
+ className: "ecomid-search-panel__header",
2213
+ children: [
2214
+ /* @__PURE__ */ K("span", {
2215
+ className: "ecomid-search-panel__search-icon",
2216
+ children: /* @__PURE__ */ K(nt, {})
2217
+ }),
2218
+ /* @__PURE__ */ q("form", {
2219
+ className: "ecomid-search-panel__form",
2220
+ onSubmit: j,
2221
+ children: [G && /* @__PURE__ */ K(It, { texts: W }), /* @__PURE__ */ K("input", {
2222
+ ref: v,
2223
+ className: "ecomid-search-panel__input",
2224
+ type: "text",
2225
+ role: "combobox",
2226
+ "data-autofocus": d ? "" : void 0,
2227
+ value: h.query,
2228
+ placeholder: g("placeholder"),
2229
+ "data-rolling": G || void 0,
2230
+ "aria-label": g("placeholder"),
2231
+ "aria-autocomplete": "list",
2232
+ "aria-haspopup": "listbox",
2233
+ "aria-expanded": J,
2234
+ "aria-controls": J ? oe : void 0,
2235
+ "aria-activedescendant": se,
2236
+ enterKeyHint: "search",
2237
+ onChange: (t) => {
2238
+ e.setQuery(t.currentTarget.value), x(-1), C(!1);
2239
+ },
2240
+ onKeyDown: M,
2241
+ autoComplete: "off"
2242
+ })]
2243
+ }),
2244
+ /* @__PURE__ */ K("button", {
2245
+ type: "button",
2246
+ className: "ecomid-search-panel__submit",
2247
+ title: g("actions.submit"),
2248
+ "aria-label": g("actions.submit"),
2249
+ disabled: !N,
2250
+ onClick: A,
2251
+ children: /* @__PURE__ */ K(it, {})
2252
+ }),
2253
+ r
2254
+ ]
2255
+ });
2256
+ return /* @__PURE__ */ q(kt.Provider, {
2257
+ value: O,
2258
+ children: [T ? /* @__PURE__ */ K("div", {
2259
+ ref: y,
2260
+ className: "ecomid-search-panel__field",
2261
+ children: /* @__PURE__ */ q("div", {
2262
+ className: "ecomid-search-panel__box",
2263
+ "data-open": J || void 0,
2264
+ children: [le, J && /* @__PURE__ */ q("div", {
2265
+ className: "ecomid-search-panel__dropdown",
2266
+ children: [/* @__PURE__ */ K("p", {
2267
+ id: ce,
2268
+ className: "ecomid-search-panel__dropdown-title",
2269
+ children: g("suggestions")
2270
+ }), /* @__PURE__ */ K(qn, {
2271
+ suggestions: F,
2272
+ askLabel: g("ask_suggestion", { query: "{query}" }),
2273
+ query: N,
2274
+ activeIndex: b,
2275
+ listboxId: oe,
2276
+ labelledBy: ce,
2277
+ getOptionId: (e) => `${m}-option-${e}`,
2278
+ onSelect: D,
2279
+ leading: /* @__PURE__ */ K(St, {
2280
+ className: "ecomid-search-icon",
2281
+ "aria-hidden": "true"
2282
+ })
2283
+ })]
2284
+ })]
2285
+ })
2286
+ }) : le, /* @__PURE__ */ q("div", {
2287
+ className: "ecomid-search-panel__body",
2288
+ children: [
2289
+ P || T || h.instant === null ? /* @__PURE__ */ K(Kn, {
2290
+ status: h.emptyStateStatus,
2291
+ starters: R,
2292
+ products: B,
2293
+ lang: l,
2294
+ market: u,
2295
+ recommendedLabel: g("empty.popular"),
2296
+ countLabel: f ? g(B.length === 1 ? "results_count.singular" : "results_count.plural", { count: String(B.length) }) : void 0,
2297
+ fitStarters: f,
2298
+ previousLabel: g("actions.previous"),
2299
+ nextLabel: g("actions.next"),
2300
+ onPillSelect: k,
2301
+ onProductClick: ee,
2302
+ renderProduct: s,
2303
+ onRenderError: c
2304
+ }) : /* @__PURE__ */ K(Zn, {
2305
+ suggestions: F,
2306
+ starters: re ? R : [],
2307
+ carousel: re && Y,
2308
+ previousLabel: g("actions.previous"),
2309
+ nextLabel: g("actions.next"),
2310
+ onPillSelect: k,
2311
+ products: ne,
2312
+ query: N,
2313
+ activeIndex: b,
2314
+ showListbox: J,
2315
+ showNoResults: ie,
2316
+ noResultsLabel: g("no_results"),
2317
+ suggestionsLabel: g("suggestions"),
2318
+ askLabel: g("ask_suggestion", { query: "{query}" }),
2319
+ productsLabel: g(Y ? "empty.popular" : "products"),
2320
+ listboxId: oe,
2321
+ suggestionsHeadingId: ce,
2322
+ getOptionId: (e) => `${m}-option-${e}`,
2323
+ lang: l,
2324
+ market: u,
2325
+ onSuggestionSelect: D,
2326
+ onProductClick: ee,
2327
+ renderProduct: s,
2328
+ onRenderError: c
2329
+ }),
2330
+ /* @__PURE__ */ K("p", {
2331
+ role: "status",
2332
+ className: "ecomid-search-sr-only",
2333
+ children: ae
2334
+ }),
2335
+ i
2336
+ ]
2337
+ })]
2338
+ });
2339
+ }
2340
+ // src/search/components/SearchDialog/index.tsx
2341
+ var er = 1e5;
2342
+ function tr({ store: e, open: t, onClose: n, onSubmit: r, onProductClick: i, renderProduct: a, lang: o, market: s, clientId: c }) {
2343
+ let l = _e(e.subscribe, e.getState, e.getState), { t: u } = Q(o), { track: d, onRenderError: f } = Ae({
2344
+ clientId: c,
2345
+ lang: o,
2346
+ market: s
2347
+ }), [p, m] = U(!1), [h, g] = U(!1), _ = H(null), v = H(!1);
2348
+ z(() => {
2349
+ if (t) return d(ve.OPEN), () => d(ve.CLOSE);
2350
+ }, [t, d]);
2351
+ let y = Te(L(() => {
2352
+ l.query ? e.setQuery("") : n();
2353
+ }, [
2354
+ l.query,
2355
+ e,
2356
+ n
2357
+ ]), !h), b = Ee("--ecomid-search-modal-height", !(l.query.trim().length >= e.minQueryLength)), [x, S] = U(null), C = L((e) => {
2358
+ y(e), b(e), S(e?.parentElement ?? null);
2359
+ }, [y, b]);
2360
+ return De(t), Ce(t), z(() => {
2361
+ h ? v.current = !0 : v.current && (v.current = !1, _.current?.focus());
2362
+ }, [h]), z(() => {
2363
+ if (!t) {
2364
+ m(!1), g(!1);
2365
+ return;
2366
+ }
2367
+ let e = 0, n = requestAnimationFrame(() => {
2368
+ e = requestAnimationFrame(() => m(!0));
2369
+ });
2370
+ return () => {
2371
+ cancelAnimationFrame(n), cancelAnimationFrame(e);
2372
+ };
2373
+ }, [t]), t ? J(/* @__PURE__ */ K(be, {
2374
+ className: "ecomid-search-backdrop",
2375
+ "data-visible": p || void 0,
2376
+ onDismiss: n,
2377
+ children: /* @__PURE__ */ K(Re.Provider, {
2378
+ value: x,
2379
+ children: /* @__PURE__ */ q("div", {
2380
+ ref: C,
2381
+ role: "dialog",
2382
+ "aria-modal": "true",
2383
+ "aria-label": u("dialog_label"),
2384
+ className: "ecomid-search-modal",
2385
+ "data-visible": p || void 0,
2386
+ "data-receded": h || void 0,
2387
+ inert: h || void 0,
2388
+ children: [/* @__PURE__ */ K(gt, {
2389
+ lang: o,
2390
+ onClose: n,
2391
+ onPersonalize: (e) => {
2392
+ let t = window.ecomid?.widgets?.account;
2393
+ if (!t) return;
2394
+ let r = e.currentTarget.closest(".ecomid-search-backdrop"), i = r ? Number.parseInt(getComputedStyle(r).zIndex, 10) : NaN, a = !window.matchMedia("(min-width: 768px)").matches;
2395
+ g(!0), t.init({
2396
+ clientId: c,
2397
+ locale: `${o}-${s}`,
2398
+ opts: {
2399
+ stacked: !0,
2400
+ source: "search",
2401
+ callbacks: { onClose: () => {
2402
+ g(!1), a && n();
2403
+ } }
2404
+ },
2405
+ styles: { overlay: { zIndex: (Number.isNaN(i) ? er : i) + 1 } }
2406
+ });
2407
+ },
2408
+ personalizeRef: _
2409
+ }), /* @__PURE__ */ K($n, {
2410
+ store: e,
2411
+ track: d,
2412
+ onDone: n,
2413
+ onSubmit: r,
2414
+ onProductClick: i,
2415
+ renderProduct: a,
2416
+ onRenderError: f,
2417
+ lang: o,
2418
+ market: s,
2419
+ footer: /* @__PURE__ */ K("div", {
2420
+ className: "ecomid-search-modal__footer",
2421
+ children: /* @__PURE__ */ K(We, {})
2422
+ })
2423
+ })]
2424
+ })
2425
+ })
2426
+ }), document.body) : null;
2427
+ }
2428
+ // src/search/components/SearchRoot.tsx
2429
+ var nr = () => () => {}, rr = () => !0, ir = () => !1;
2430
+ function ar(t, n) {
2431
+ let r = new URL(t, window.location.href);
2432
+ return r.search = e(r.search, {
2433
+ kind: "compose",
2434
+ text: n
2435
+ }), r.href;
2436
+ }
2437
+ function or({ clientId: e, lang: t, market: n, baseUrl: r, open: i, onClose: a, onSubmit: o, resultsUrl: s, onProductClick: c, renderProduct: l, onOpen: u }) {
2438
+ let d = _e(nr, rr, ir), f = V(() => p({
2439
+ clientId: e,
2440
+ market: n,
2441
+ lang: t,
2442
+ baseUrl: r
2443
+ }), [
2444
+ e,
2445
+ n,
2446
+ t,
2447
+ r
2448
+ ]);
2449
+ z(() => () => f.destroy(), [f]);
2450
+ let m = ge(), h = H(u);
2451
+ h.current = u;
2452
+ let g = H(a);
2453
+ g.current = a, z(() => {
2454
+ i && m(() => h.current?.());
2455
+ }, [i, m]);
2456
+ let _ = L(() => m(() => g.current()), [m]), v = L((e) => {
2457
+ o ? m(() => o(e)) : s && window.location.assign(ar(s, e));
2458
+ }, [
2459
+ o,
2460
+ s,
2461
+ m
2462
+ ]), y = L((e, t) => {
2463
+ m(() => c?.(e, t));
2464
+ }, [c, m]);
2465
+ return /* @__PURE__ */ K(tr, {
2466
+ store: f,
2467
+ open: i && d,
2468
+ onClose: _,
2469
+ onSubmit: v,
2470
+ onProductClick: y,
2471
+ renderProduct: l,
2472
+ lang: t,
2473
+ market: n,
2474
+ clientId: e
2475
+ });
2476
+ }
2477
+ function sr(e) {
2478
+ return /* @__PURE__ */ K(me, { children: /* @__PURE__ */ K(or, { ...e }) });
2479
+ }
2480
+ // src/search/react/SearchModal.tsx
2481
+ function cr({ clientId: e, locale: t, environment: n, ...r }) {
2482
+ let i = de({
2483
+ clientId: e,
2484
+ locale: t,
2485
+ environment: n,
2486
+ active: r.open
2487
+ });
2488
+ return /* @__PURE__ */ K(fe.Provider, {
2489
+ value: i.report,
2490
+ children: /* @__PURE__ */ K(he, {
2491
+ clientId: i.clientId,
2492
+ locale: i.locale,
2493
+ children: (e) => /* @__PURE__ */ K(sr, {
2494
+ ...r,
2495
+ clientId: e.clientId,
2496
+ lang: e.lang,
2497
+ market: e.market,
2498
+ baseUrl: i.urls.cgw
2499
+ })
2500
+ })
2501
+ });
2502
+ }
2503
+ // src/search/components/hooks/useAccountOverlay.ts
2504
+ function lr({ clientId: e, lang: t, market: n }) {
2505
+ return L(() => {
2506
+ window.ecomid?.widgets?.account?.init({
2507
+ clientId: e,
2508
+ locale: `${t}-${n}`,
2509
+ opts: { source: "search" }
2510
+ });
2511
+ }, [
2512
+ e,
2513
+ t,
2514
+ n
2515
+ ]);
2516
+ }
2517
+ // src/search/components/ResultsShell/index.tsx
2518
+ function ur({ lang: e, onNewSearch: t, onPersonalize: n, history: r, children: i }) {
2519
+ let { t: a } = Q(e);
2520
+ return /* @__PURE__ */ q("div", {
2521
+ className: "ecomid-search-shell",
2522
+ children: [
2523
+ /* @__PURE__ */ K("div", {
2524
+ className: "ecomid-search-shell__start",
2525
+ children: r ?? (n && /* @__PURE__ */ K(ht, {
2526
+ lang: e,
2527
+ onClick: n
2528
+ }))
2529
+ }),
2530
+ /* @__PURE__ */ K(tt, { lang: e }),
2531
+ /* @__PURE__ */ q("div", {
2532
+ className: "ecomid-search-shell__end",
2533
+ children: [t && /* @__PURE__ */ q("button", {
2534
+ type: "button",
2535
+ className: "ecomid-search-shell__new",
2536
+ title: a("shell.new_search"),
2537
+ "aria-label": a("shell.new_search"),
2538
+ onClick: t,
2539
+ children: [/* @__PURE__ */ K(nt, {}), /* @__PURE__ */ K("span", {
2540
+ className: "ecomid-search-shell__new-label",
2541
+ children: a("shell.new_search")
2542
+ })]
2543
+ }), i]
2544
+ })
2545
+ ]
2546
+ });
2547
+ }
2548
+ // src/search/components/FilterOptions/model.ts
2549
+ function dr(e, t = []) {
2550
+ return e.values.filter((e) => e.available || t.includes(e.value));
2551
+ }
2552
+ function fr(e, t = {}) {
2553
+ return v.filter((n) => n === "price" || e.some((e) => e.key === n && dr(e, t[n]).length > 0));
2554
+ }
2555
+ var pr = [
2556
+ "category",
2557
+ "color",
2558
+ "size",
2559
+ "material",
2560
+ "gender",
2561
+ "price"
2562
+ ], mr = [
2563
+ "material",
2564
+ "price",
2565
+ "color",
2566
+ "category"
2567
+ ], hr = 3;
2568
+ function gr(e, t, n) {
2569
+ let r = (e) => e === "price" ? b(n) : (n[e] ?? []).length > 0, i = pr.filter((t) => e.includes(t) && r(t)), a = (e) => e === "price" || (t.find((t) => t.key === e)?.values.filter((e) => e.available).length ?? 0) >= 2, o = mr.filter((t) => e.includes(t) && !r(t) && a(t)).slice(0, hr);
2570
+ return [...i, ...o];
2571
+ }
2572
+ function _r(e) {
2573
+ let t = /* @__PURE__ */ new Map();
2574
+ for (let n of e?.appliedFilters ?? []) n.values.forEach((e, r) => {
2575
+ t.set(`${n.key}:${e}`, n.labels[r] ?? e);
2576
+ });
2577
+ for (let n of e?.facets ?? []) for (let e of n.values) t.set(`${n.key}:${e.value}`, e.label);
2578
+ for (let n of e?.state?.filters ?? []) n.labels?.forEach((e, r) => {
2579
+ t.set(`${n.key}:${n.values[r]}`, e);
2580
+ });
2581
+ return (e, n) => t.get(`${e}:${n}`) ?? M(n);
2582
+ }
2583
+ function vr(e, t) {
2584
+ try {
2585
+ let n = new Intl.NumberFormat(e, {
2586
+ ...t && {
2587
+ style: "currency",
2588
+ currency: t
2589
+ },
2590
+ currencyDisplay: "narrowSymbol",
2591
+ minimumFractionDigits: 0,
2592
+ maximumFractionDigits: 2
2593
+ });
2594
+ return (e) => n.format(e);
2595
+ } catch {
2596
+ return (e) => String(e);
2597
+ }
2598
+ }
2599
+ function yr(e) {
2600
+ return vr(ln(e.lang, e.market), Er(e));
2601
+ }
2602
+ function br(e, t = String, n) {
2603
+ let { priceMin: r, priceMax: i } = e;
2604
+ return r !== void 0 && i !== void 0 ? `${t(r)}–${t(i)}` : r === void 0 ? i === void 0 ? "" : n ? n(t(i)) : `${t(0)}–${t(i)}` : `${t(r)}+`;
2605
+ }
2606
+ function xr(e, t, n, r, i) {
2607
+ if (e === "price") return b(t) ? {
2608
+ values: [],
2609
+ labels: [br(t, r, i)]
2610
+ } : {
2611
+ values: [],
2612
+ labels: []
2613
+ };
2614
+ let a = t[e] ?? [];
2615
+ return {
2616
+ values: a,
2617
+ labels: a.map((t) => n(e, t))
2618
+ };
2619
+ }
2620
+ var Sr = [
2621
+ 1,
2622
+ 2,
2623
+ 5
2624
+ ];
2625
+ function Cr(e) {
2626
+ let t = e / 50;
2627
+ for (let e = 1;; e *= 10) for (let n of Sr) {
2628
+ let r = n * e;
2629
+ if (r >= t) return r;
2630
+ }
2631
+ }
2632
+ function wr(e) {
2633
+ let t = e.flatMap((e) => e.price === void 0 ? [] : [e.price]), n = Math.max(...t);
2634
+ if (!(n > 0)) return null;
2635
+ let r = Cr(n);
2636
+ return {
2637
+ min: Math.min(...t),
2638
+ max: Math.ceil(n / r) * r,
2639
+ step: r
2640
+ };
2641
+ }
2642
+ function Tr(e) {
2643
+ return [...e.products, ...(e.sections ?? []).flatMap((e) => e.products)];
2644
+ }
2645
+ function Er(e) {
2646
+ return Tr(e).find((e) => e.currency)?.currency;
2647
+ }
2648
+ function Dr(e, t) {
2649
+ let { priceMax: n } = t, { step: r } = e;
2650
+ return {
2651
+ min: e.min,
2652
+ max: n !== void 0 && n >= e.max ? Math.floor(n / r) * r + r : e.max,
2653
+ step: r
2654
+ };
2655
+ }
2656
+ // src/search/components/swatches.ts
2657
+ var Or = [
2658
+ [["black"], "#111111"],
2659
+ [["silver"], "#c9ced6"],
2660
+ [["gold"], "#d4a72c"],
2661
+ [[
2662
+ "grey",
2663
+ "gray",
2664
+ "melange"
2665
+ ], "#8a8a8a"],
2666
+ [["navy"], "#1e3a8a"],
2667
+ [["blue"], "#2563eb"],
2668
+ [["brown", "mahogany"], "#7b4a2a"],
2669
+ [[
2670
+ "olive",
2671
+ "green",
2672
+ "moss",
2673
+ "khaki",
2674
+ "mint"
2675
+ ], "#2f9e55"],
2676
+ [["yellow", "lemon"], "#f6c21a"],
2677
+ [[
2678
+ "purple",
2679
+ "lilac",
2680
+ "lavender",
2681
+ "violet",
2682
+ "plum"
2683
+ ], "#8b3fd1"],
2684
+ [[
2685
+ "orange",
2686
+ "coral",
2687
+ "apricot",
2688
+ "rust"
2689
+ ], "#f07a1a"],
2690
+ [["teal", "turquoise"], "#13a3a3"],
2691
+ [["camel"], "#c3965f"],
2692
+ [[
2693
+ "dulce",
2694
+ "pink",
2695
+ "rose",
2696
+ "blush"
2697
+ ], "#ec5f9a"],
2698
+ [[
2699
+ "red",
2700
+ "berry",
2701
+ "cherry",
2702
+ "burgundy",
2703
+ "wine",
2704
+ "bordeaux"
2705
+ ], "#d7263d"],
2706
+ [["white"], "#ffffff"],
2707
+ [["beige", "sand"], "#dcc39b"],
2708
+ [["cream", "ivory"], "#f4ead2"]
2709
+ ];
2710
+ function kr(...e) {
2711
+ let t = e.map((e) => e.toLowerCase());
2712
+ for (let [e, n] of Or) if (t.some((t) => e.some((e) => t.includes(e)))) return n;
2713
+ }
2714
+ // src/search/components/FilterOptions/OptionRow.tsx
2715
+ function Ar({ type: e, variant: t, name: n, label: r, checked: i, swatch: a, onChange: o }) {
2716
+ let s = a ? kr(...a, r) : void 0;
2717
+ return /* @__PURE__ */ q("label", {
2718
+ className: "ecomid-search-option-row",
2719
+ "data-variant": t,
2720
+ "data-checked": i || void 0,
2721
+ children: [
2722
+ /* @__PURE__ */ K("input", {
2723
+ type: e,
2724
+ name: n,
2725
+ className: "ecomid-search-sr-only ecomid-search-option-row__input",
2726
+ checked: i,
2727
+ onChange: o
2728
+ }),
2729
+ t === "drawer" && /* @__PURE__ */ K("span", {
2730
+ className: "ecomid-search-option-row__box",
2731
+ "aria-hidden": "true",
2732
+ children: i && /* @__PURE__ */ K(ft, { size: 14 })
2733
+ }),
2734
+ s && /* @__PURE__ */ K("span", {
2735
+ className: "ecomid-search-swatch",
2736
+ "aria-hidden": "true",
2737
+ style: { backgroundColor: s }
2738
+ }),
2739
+ /* @__PURE__ */ K("span", {
2740
+ className: "ecomid-search-option-row__label",
2741
+ children: r
2742
+ }),
2743
+ t === "menu" && i && /* @__PURE__ */ K("span", {
2744
+ className: "ecomid-search-option-row__check",
2745
+ "aria-hidden": "true",
2746
+ children: /* @__PURE__ */ K(ft, {})
2747
+ })
2748
+ ]
2749
+ });
2750
+ }
2751
+ // src/search/components/FilterOptions/priceCeilings.ts
2752
+ var jr = [
2753
+ 1,
2754
+ 1.5,
2755
+ 2,
2756
+ 2.5,
2757
+ 3,
2758
+ 4,
2759
+ 5,
2760
+ 6,
2761
+ 8
2762
+ ], Mr = 5, Nr = 9, Pr = {
2763
+ SEK: 100,
2764
+ NOK: 100,
2765
+ DKK: 100,
2766
+ CZK: 250,
2767
+ PLN: 25
2768
+ }, Fr = 10;
2769
+ function Ir(e) {
2770
+ let t = [];
2771
+ for (let n = 0; n <= Nr; n++) for (let r of jr) {
2772
+ let i = r * 10 ** n;
2773
+ Number.isInteger(i) && i >= e && t.push(i);
2774
+ }
2775
+ return t;
2776
+ }
2777
+ function Lr(e, t) {
2778
+ if (e.length <= t) return e;
2779
+ let n = e.length - 1;
2780
+ return Array.from({ length: t }, (r, i) => e[Math.round(i * n / (t - 1))]);
2781
+ }
2782
+ function Rr(e, t, n) {
2783
+ if (!(t > 0) || !(e >= 0) || e > t) return [];
2784
+ let r = Ir(n && Pr[n.toUpperCase()] || Fr), i = r.findIndex((t) => t >= e), a = r.findIndex((e) => e >= t);
2785
+ return i === -1 || a === -1 ? [] : Lr(r.slice(i, a + 1), Mr);
2786
+ }
2787
+ // src/search/components/FilterOptions/index.tsx
2788
+ function zr({ group: e, facet: t, label: n, selected: r, variant: i, onToggle: a }) {
2789
+ return /* @__PURE__ */ q("fieldset", {
2790
+ className: "ecomid-search-options",
2791
+ "data-variant": i,
2792
+ children: [/* @__PURE__ */ K("legend", {
2793
+ className: "ecomid-search-sr-only",
2794
+ children: n
2795
+ }), dr(t, r).map((t) => {
2796
+ let n = r.includes(t.value);
2797
+ return /* @__PURE__ */ K(Ar, {
2798
+ type: "checkbox",
2799
+ variant: i,
2800
+ label: t.label,
2801
+ checked: n,
2802
+ swatch: e === "color" ? [t.value] : void 0,
2803
+ onChange: () => a(e, t.value)
2804
+ }, t.value);
2805
+ })]
2806
+ });
2807
+ }
2808
+ function Br({ lang: e, label: t, variant: n, min: r, max: i, bounds: a, currency: o, market: s, onCommit: c }) {
2809
+ let { t: l } = Q(e), u = vr(ln(e, s), o), d = a ? Rr(a.min, a.max, o) : [], f = i !== void 0 && !d.includes(i) ? [...d, i].sort((e, t) => e - t) : d, p = r === void 0 && i === void 0;
2810
+ return /* @__PURE__ */ q("fieldset", {
2811
+ className: "ecomid-search-options",
2812
+ "data-variant": n,
2813
+ children: [
2814
+ /* @__PURE__ */ K("legend", {
2815
+ className: "ecomid-search-sr-only",
2816
+ children: t
2817
+ }),
2818
+ /* @__PURE__ */ K(Ar, {
2819
+ type: "checkbox",
2820
+ variant: n,
2821
+ label: l("filters.any_price"),
2822
+ checked: p,
2823
+ onChange: () => c(void 0, void 0)
2824
+ }),
2825
+ f.map((e) => {
2826
+ let t = r === void 0 && i === e;
2827
+ return /* @__PURE__ */ K(Ar, {
2828
+ type: "checkbox",
2829
+ variant: n,
2830
+ label: l("filters.price_under", { price: u(e) }),
2831
+ checked: t,
2832
+ onChange: () => t ? c(void 0, void 0) : c(void 0, e)
2833
+ }, e);
2834
+ })
2835
+ ]
2836
+ });
2837
+ }
2838
+ // src/search/components/FilterOptions/PriceSlider.tsx
2839
+ function Vr({ bounds: e, low: t, high: n, minLabel: r, maxLabel: i, format: a, onChange: o, onCommit: s }) {
2840
+ let c = H(null), l = H({
2841
+ min: null,
2842
+ max: null
2843
+ }), [u, d] = U(null), f = H(null), { min: p, max: m, step: h } = e, g = m - p, _ = (e, r, i = {
2844
+ low: t,
2845
+ high: n
2846
+ }) => {
2847
+ let a = Math.round((r - p) / h) * h + p;
2848
+ return e === "min" ? {
2849
+ low: Math.min(Math.max(a, p), i.high - h),
2850
+ high: i.high
2851
+ } : {
2852
+ low: i.low,
2853
+ high: Math.max(Math.min(a, m), i.low + h)
2854
+ };
2855
+ }, v = (e) => {
2856
+ let t = c.current?.getBoundingClientRect();
2857
+ if (!t || t.width === 0) return p;
2858
+ let n = Math.min(Math.max((e - t.left) / t.width, 0), 1);
2859
+ return p + n * g;
2860
+ }, y = (e) => {
2861
+ if (e.button !== 0) return;
2862
+ let r = v(e.clientX), i = Math.abs(r - t) < Math.abs(r - n) || t === n && r < t || Math.abs(r - t) === Math.abs(r - n) && r < t ? "min" : "max", a = _(i, r);
2863
+ f.current = {
2864
+ thumb: i,
2865
+ ...a
2866
+ }, e.currentTarget.setPointerCapture(e.pointerId), l.current[i]?.focus({ preventScroll: !0 }), d(i), o(a.low, a.high);
2867
+ }, b = (e) => {
2868
+ let t = f.current;
2869
+ if (!t) return;
2870
+ let n = _(t.thumb, v(e.clientX), t);
2871
+ (n.low !== t.low || n.high !== t.high) && (f.current = {
2872
+ thumb: t.thumb,
2873
+ ...n
2874
+ }, o(n.low, n.high));
2875
+ }, x = () => {
2876
+ let e = f.current;
2877
+ e && (f.current = null, d(null), s(e.low, e.high));
2878
+ }, S = (e) => (r) => {
2879
+ let i = e === "min" ? t : n, a;
2880
+ switch (r.key) {
2881
+ case "ArrowRight":
2882
+ case "ArrowUp":
2883
+ a = i + h;
2884
+ break;
2885
+ case "ArrowLeft":
2886
+ case "ArrowDown":
2887
+ a = i - h;
2888
+ break;
2889
+ case "PageUp":
2890
+ a = i + h * 10;
2891
+ break;
2892
+ case "PageDown":
2893
+ a = i - h * 10;
2894
+ break;
2895
+ case "Home":
2896
+ a = p;
2897
+ break;
2898
+ case "End":
2899
+ a = m;
2900
+ break;
2901
+ default: return;
2902
+ }
2903
+ r.preventDefault();
2904
+ let o = _(e, a);
2905
+ (o.low !== t || o.high !== n) && s(o.low, o.high);
2906
+ }, C = (e) => `${(e - p) / g * 100}%`, w = (e, t, n) => /* @__PURE__ */ K("div", {
2907
+ ref: (t) => {
2908
+ l.current[e] = t;
2909
+ },
2910
+ role: "slider",
2911
+ tabIndex: 0,
2912
+ className: "ecomid-search-price__thumb",
2913
+ "data-active": u === e || void 0,
2914
+ "aria-label": n,
2915
+ "aria-orientation": "horizontal",
2916
+ "aria-valuemin": p,
2917
+ "aria-valuemax": m,
2918
+ "aria-valuenow": t,
2919
+ "aria-valuetext": e === "max" && t >= m ? `${a(t)}+` : a(t),
2920
+ style: { left: C(t) },
2921
+ onKeyDown: S(e)
2922
+ }, e);
2923
+ return /* @__PURE__ */ q("div", {
2924
+ ref: c,
2925
+ className: "ecomid-search-price__slider",
2926
+ onPointerDown: y,
2927
+ onPointerMove: b,
2928
+ onPointerUp: x,
2929
+ onPointerCancel: x,
2930
+ children: [
2931
+ /* @__PURE__ */ K("div", { className: "ecomid-search-price__rail" }),
2932
+ /* @__PURE__ */ K("div", {
2933
+ className: "ecomid-search-price__range",
2934
+ style: {
2935
+ left: C(t),
2936
+ right: `calc(100% - ${C(n)})`
2937
+ }
2938
+ }),
2939
+ w("min", t, r),
2940
+ w("max", n, i)
2941
+ ]
2942
+ });
2943
+ }
2944
+ // src/search/components/FilterOptions/PriceRange.tsx
2945
+ function Hr(e) {
2946
+ if (e.trim() === "") return;
2947
+ let t = Number(e.replace(",", "."));
2948
+ return Number.isFinite(t) && t >= 0 ? t : void 0;
2949
+ }
2950
+ function $(e) {
2951
+ return e === void 0 ? "" : String(e);
2952
+ }
2953
+ function Ur({ lang: e, min: t, max: n, bounds: r, currency: i, market: a, onCommit: o }) {
2954
+ let { t: s } = Q(e), [c, l] = U($(t)), [u, d] = U($(n)), [f, p] = U(null), m = vr(ln(e, a), i), h = H({
2955
+ minText: c,
2956
+ maxText: u
2957
+ });
2958
+ h.current = {
2959
+ minText: c,
2960
+ maxText: u
2961
+ };
2962
+ let g = H({
2963
+ min: t,
2964
+ max: n
2965
+ });
2966
+ z(() => {
2967
+ g.current.min !== t && (g.current.min = t, l($(t)));
2968
+ }, [t]), z(() => {
2969
+ g.current.max !== n && (g.current.max = n, d($(n)));
2970
+ }, [n]);
2971
+ let _ = () => {
2972
+ let e = Hr(h.current.minText);
2973
+ e === 0 && (e = void 0);
2974
+ let r = Hr(h.current.maxText);
2975
+ e !== void 0 && r !== void 0 && e > r && ([e, r] = [r, e], l($(e)), d($(r))), (e !== t || r !== n) && o(e, r);
2976
+ }, v = (e, i) => {
2977
+ if (!r) return;
2978
+ let a = e <= r.min ? void 0 : e, s = i >= r.max ? void 0 : i;
2979
+ l($(a)), d($(s)), h.current = {
2980
+ minText: $(a),
2981
+ maxText: $(s)
2982
+ }, (a !== t || s !== n) && o(a, s);
2983
+ }, y = (e, t) => {
2984
+ if (!r) return;
2985
+ let n = e <= r.min ? void 0 : e, i = t >= r.max ? void 0 : t;
2986
+ l($(n)), d($(i)), h.current = {
2987
+ minText: $(n),
2988
+ maxText: $(i)
2989
+ };
2990
+ }, b = m(Hr(c) ?? 0), x = Hr(u), S = x === void 0 ? r ? `${m(r.max)}+` : "" : m(x), C = (() => {
2991
+ if (!r) return null;
2992
+ let e = (e) => Math.min(Math.max(e, r.min), r.max), t = e(Hr(c) ?? r.min), n = e(Hr(u) ?? r.max);
2993
+ return t <= n ? {
2994
+ low: t,
2995
+ high: n
2996
+ } : {
2997
+ low: n,
2998
+ high: t
2999
+ };
3000
+ })(), w = (e) => {
3001
+ e.key === "Enter" && (e.preventDefault(), _());
3002
+ };
3003
+ return /* @__PURE__ */ q("div", {
3004
+ className: "ecomid-search-price",
3005
+ children: [r && C && /* @__PURE__ */ K(Vr, {
3006
+ bounds: r,
3007
+ low: C.low,
3008
+ high: C.high,
3009
+ minLabel: s("filters.min"),
3010
+ maxLabel: s("filters.max"),
3011
+ format: m,
3012
+ onChange: y,
3013
+ onCommit: v
3014
+ }), /* @__PURE__ */ q("div", {
3015
+ className: "ecomid-search-price__fields",
3016
+ children: [
3017
+ /* @__PURE__ */ q("label", {
3018
+ className: "ecomid-search-price__field",
3019
+ children: [/* @__PURE__ */ K("span", {
3020
+ className: "ecomid-search-price__label",
3021
+ children: s("filters.min")
3022
+ }), /* @__PURE__ */ K("input", {
3023
+ type: "text",
3024
+ inputMode: "decimal",
3025
+ className: "ecomid-search-price__input",
3026
+ value: f === "min" ? c : b,
3027
+ onInput: (e) => {
3028
+ h.current.minText = e.currentTarget.value, l(e.currentTarget.value);
3029
+ },
3030
+ onFocus: () => p("min"),
3031
+ onBlur: () => {
3032
+ p(null), _();
3033
+ },
3034
+ onKeyDown: w
3035
+ })]
3036
+ }),
3037
+ /* @__PURE__ */ K("span", {
3038
+ className: "ecomid-search-price__dash",
3039
+ "aria-hidden": "true"
3040
+ }),
3041
+ /* @__PURE__ */ q("label", {
3042
+ className: "ecomid-search-price__field",
3043
+ children: [/* @__PURE__ */ K("span", {
3044
+ className: "ecomid-search-price__label",
3045
+ children: s("filters.max")
3046
+ }), /* @__PURE__ */ K("input", {
3047
+ type: "text",
3048
+ inputMode: "decimal",
3049
+ className: "ecomid-search-price__input",
3050
+ value: f === "max" ? u : S,
3051
+ onInput: (e) => {
3052
+ h.current.maxText = e.currentTarget.value, d(e.currentTarget.value);
3053
+ },
3054
+ onFocus: () => p("max"),
3055
+ onBlur: () => {
3056
+ p(null), _();
3057
+ },
3058
+ onKeyDown: w
3059
+ })]
3060
+ })
3061
+ ]
3062
+ })]
3063
+ });
3064
+ }
3065
+ // src/search/components/hooks/useSwipeDismiss.ts
3066
+ var Wr = "(max-width: 767px)", Gr = 80;
3067
+ function Kr(e) {
3068
+ let t = H(e);
3069
+ return t.current = e, L((e) => {
3070
+ if (e.button > 0 || !window.matchMedia(Wr).matches) return;
3071
+ let n = e.currentTarget.closest(".ecomid-search-overlay");
3072
+ if (!n) return;
3073
+ let r = e.clientY, i = 0, a = (e) => {
3074
+ i = Math.max(0, e.clientY - r), n.style.transition = "none", n.style.transform = `translateY(${i}px)`;
3075
+ }, o = () => {
3076
+ document.removeEventListener("pointermove", a), document.removeEventListener("pointerup", o), document.removeEventListener("pointercancel", o), n.style.transition = "transform 200ms ease", n.style.transform = "", i >= Gr && t.current();
3077
+ };
3078
+ document.addEventListener("pointermove", a), document.addEventListener("pointerup", o), document.addEventListener("pointercancel", o);
3079
+ }, []);
3080
+ }
3081
+ // src/search/components/FilterDrawer/index.tsx
3082
+ function qr({ lang: e, results: t, filters: n, bounds: r, terms: i, excludedTerms: a, onRemoveTerm: o, onRemoveExcludedTerm: s, onApply: c, onClose: l, count: u }) {
3083
+ let { t: d } = Q(e), f = t.total ?? t.products.length, p = te(), [m, h] = U(() => E(n)), g = H(m);
3084
+ g.current = m;
3085
+ let [_, v] = U(null), [S, C] = U(f), w = H(null), T = Kr(l), D = () => {
3086
+ setTimeout(() => {
3087
+ let e = w.current, t = e?.closest("[role=\"dialog\"]");
3088
+ e && !t?.contains(document.activeElement) && e.focus({ preventScroll: !0 });
3089
+ }, 0);
3090
+ };
3091
+ z(() => {
3092
+ if (x(m, n)) {
3093
+ C(f);
3094
+ return;
3095
+ }
3096
+ let e = new AbortController(), t = setTimeout(() => {
3097
+ u(m, e.signal).then(C).catch(() => void 0);
3098
+ }, 250);
3099
+ return () => {
3100
+ clearTimeout(t), e.abort();
3101
+ };
3102
+ }, [
3103
+ m,
3104
+ n,
3105
+ f,
3106
+ u
3107
+ ]);
3108
+ let O = _r(t), k = yr(t), ee = fr(t.facets ?? [], n), N = (e) => d(`filters.groups.${e}`), P = (e, t) => h((n) => j(n, e, t)), F = [...i.map((e) => ({
3109
+ id: `term:${e}`,
3110
+ label: M(e),
3111
+ remove: () => o(e)
3112
+ })), ...a.map((e) => ({
3113
+ id: `excluded:${e}`,
3114
+ label: M(e),
3115
+ removeLabel: d("filters.remove_exclusion", { filter: M(e) }),
3116
+ struck: !0,
3117
+ remove: () => s(e)
3118
+ }))];
3119
+ for (let e of ee) if (e === "price") b(m) && F.push({
3120
+ id: "price",
3121
+ label: br(m, k),
3122
+ remove: () => h((e) => y(e, "price"))
3123
+ });
3124
+ else for (let t of m[e] ?? []) F.push({
3125
+ id: `${e}:${t}`,
3126
+ label: O(e, t),
3127
+ remove: () => P(e, t)
3128
+ });
3129
+ return m.onSale && F.push({
3130
+ id: "on_sale",
3131
+ label: d("filters.on_sale"),
3132
+ remove: () => h((e) => E({
3133
+ ...e,
3134
+ onSale: !1
3135
+ }))
3136
+ }), /* @__PURE__ */ q(Dt, {
3137
+ kind: "drawer",
3138
+ label: d("filters.title"),
3139
+ onClose: l,
3140
+ children: [
3141
+ /* @__PURE__ */ q("div", {
3142
+ className: "ecomid-search-drawer__header",
3143
+ onPointerDown: T,
3144
+ children: [
3145
+ /* @__PURE__ */ K("div", {
3146
+ className: "ecomid-search-drawer__handle",
3147
+ "aria-hidden": "true"
3148
+ }),
3149
+ /* @__PURE__ */ K("h2", {
3150
+ className: "ecomid-search-drawer__title",
3151
+ children: d("filters.title")
3152
+ }),
3153
+ /* @__PURE__ */ K("button", {
3154
+ type: "button",
3155
+ className: "ecomid-search-drawer__close",
3156
+ title: d("actions.close"),
3157
+ "aria-label": d("actions.close"),
3158
+ onClick: l,
3159
+ children: /* @__PURE__ */ K(rt, {})
3160
+ })
3161
+ ]
3162
+ }),
3163
+ /* @__PURE__ */ q("div", {
3164
+ ref: w,
3165
+ tabIndex: -1,
3166
+ className: "ecomid-search-drawer__body",
3167
+ children: [F.length > 0 && /* @__PURE__ */ K("div", {
3168
+ className: "ecomid-search-chips",
3169
+ children: F.map((e) => /* @__PURE__ */ q("button", {
3170
+ type: "button",
3171
+ className: "ecomid-search-chip",
3172
+ "aria-label": e.removeLabel ?? d("filters.remove", { filter: e.label }),
3173
+ onClick: () => {
3174
+ e.remove(), D();
3175
+ },
3176
+ children: [/* @__PURE__ */ K("span", {
3177
+ className: e.struck ? "ecomid-search-struck" : void 0,
3178
+ children: e.label
3179
+ }), /* @__PURE__ */ K(dt, {})]
3180
+ }, e.id))
3181
+ }), /* @__PURE__ */ q("div", {
3182
+ className: "ecomid-search-accordion",
3183
+ children: [ee.map((n) => {
3184
+ let i = _ === n, a = xr(n, m, O, k).labels.join(", "), o = (t.facets ?? []).find((e) => e.key === n);
3185
+ return /* @__PURE__ */ q("div", {
3186
+ className: "ecomid-search-accordion__item",
3187
+ children: [/* @__PURE__ */ q("button", {
3188
+ type: "button",
3189
+ className: "ecomid-search-accordion__header",
3190
+ "aria-expanded": i,
3191
+ "aria-controls": `${p}-${n}`,
3192
+ onClick: () => v(i ? null : n),
3193
+ children: [
3194
+ /* @__PURE__ */ K("span", {
3195
+ className: "ecomid-search-accordion__name",
3196
+ children: N(n)
3197
+ }),
3198
+ a && /* @__PURE__ */ K("span", {
3199
+ className: "ecomid-search-accordion__value",
3200
+ children: a
3201
+ }),
3202
+ /* @__PURE__ */ K("span", {
3203
+ className: "ecomid-search-accordion__chevron",
3204
+ "data-open": i || void 0,
3205
+ children: /* @__PURE__ */ K(ut, { size: 16 })
3206
+ })
3207
+ ]
3208
+ }), i && /* @__PURE__ */ K("div", {
3209
+ id: `${p}-${n}`,
3210
+ className: "ecomid-search-accordion__panel",
3211
+ children: n === "price" ? /* @__PURE__ */ K(Ur, {
3212
+ lang: e,
3213
+ min: m.priceMin,
3214
+ max: m.priceMax,
3215
+ bounds: r && {
3216
+ ...r,
3217
+ min: 0
3218
+ },
3219
+ currency: Er(t),
3220
+ market: t.market,
3221
+ onCommit: (e, t) => h((n) => E({
3222
+ ...n,
3223
+ priceMin: e,
3224
+ priceMax: t
3225
+ }))
3226
+ }) : o && /* @__PURE__ */ K(zr, {
3227
+ group: n,
3228
+ facet: o,
3229
+ label: N(n),
3230
+ selected: m[n] ?? [],
3231
+ variant: "drawer",
3232
+ onToggle: P
3233
+ })
3234
+ })]
3235
+ }, n);
3236
+ }), /* @__PURE__ */ K("div", {
3237
+ className: "ecomid-search-accordion__item",
3238
+ children: /* @__PURE__ */ K(Ar, {
3239
+ type: "checkbox",
3240
+ variant: "drawer",
3241
+ label: d("filters.on_sale"),
3242
+ checked: !!m.onSale,
3243
+ onChange: () => h((e) => E({
3244
+ ...e,
3245
+ onSale: !e.onSale
3246
+ }))
3247
+ })
3248
+ })]
3249
+ })]
3250
+ }),
3251
+ /* @__PURE__ */ q("div", {
3252
+ className: "ecomid-search-drawer__footer",
3253
+ children: [/* @__PURE__ */ K("button", {
3254
+ type: "button",
3255
+ className: "ecomid-search-button",
3256
+ "data-variant": "outline",
3257
+ disabled: A(m) === 0,
3258
+ onClick: () => {
3259
+ h({}), D();
3260
+ },
3261
+ children: d("filters.clear_all")
3262
+ }), /* @__PURE__ */ K("button", {
3263
+ type: "button",
3264
+ className: "ecomid-search-button",
3265
+ "data-variant": "solid",
3266
+ onClick: () => {
3267
+ c(g.current), l();
3268
+ },
3269
+ children: d(S === 1 ? "filters.show_products.singular" : "filters.show_products.plural", { count: String(S) })
3270
+ })]
3271
+ })
3272
+ ]
3273
+ });
3274
+ }
3275
+ // src/search/components/hooks/usePriceBounds.ts
3276
+ function Jr(e, t) {
3277
+ let n = H(null), { query: r } = e, i = b(t), { priceMin: a, priceMax: o } = t, s = V(() => wr(Tr(e)), [e]);
3278
+ return i || (n.current = {
3279
+ query: r,
3280
+ bounds: s
3281
+ }), V(() => {
3282
+ if (!i) return s;
3283
+ let e = n.current, t = e && e.query === r ? e.bounds : s;
3284
+ return t ? Dr(t, {
3285
+ priceMin: a,
3286
+ priceMax: o
3287
+ }) : null;
3288
+ }, [
3289
+ i,
3290
+ s,
3291
+ r,
3292
+ a,
3293
+ o
3294
+ ]);
3295
+ }
3296
+ // src/search/components/ResultsToolbar/index.tsx
3297
+ var Yr = (e) => e.currentTarget.closest(".ecomid-search-anchor");
3298
+ function Xr({ lang: e, results: t, filters: n, sort: r, terms: i, excludedTerms: a, meta: o = !0, onRemoveTerm: s, onRemoveExcludedTerm: c, onFiltersChange: l, onSortChange: u, count: d }) {
3299
+ let { t: f, isLoading: p } = Q(e), m = Ct("(min-width: 900px)"), h = Ct("(min-width: 768px)"), [g, _] = U(null), v = L(() => _(null), []), b = H(null);
3300
+ Nn(b, !p && !m), Bn(b, "horizontal", !p && !m);
3301
+ let x = Jr(t, n), S = _r(t), C = yr(t), w = gr(fr(t.facets ?? [], n), t.facets ?? [], n), D = Wn(b, !p && m);
3302
+ if (p) return null;
3303
+ let O = (e) => f(`filters.groups.${e}`), ee = (e) => f("filters.price_under", { price: e }), A = h ? "popover" : "sheet", N = (e, t) => l(j(n, e, t)), P = (r) => {
3304
+ if (r === "price") return /* @__PURE__ */ K(Br, {
3305
+ lang: e,
3306
+ label: O(r),
3307
+ variant: "menu",
3308
+ min: n.priceMin,
3309
+ max: n.priceMax,
3310
+ bounds: x,
3311
+ currency: Er(t),
3312
+ market: t.market,
3313
+ onCommit: (e, t) => {
3314
+ l(E({
3315
+ ...y(n, "price"),
3316
+ priceMin: e,
3317
+ priceMax: t
3318
+ })), v();
3319
+ }
3320
+ });
3321
+ let i = (t.facets ?? []).find((e) => e.key === r);
3322
+ return i ? /* @__PURE__ */ K(zr, {
3323
+ group: r,
3324
+ facet: i,
3325
+ label: O(r),
3326
+ selected: n[r] ?? [],
3327
+ variant: "menu",
3328
+ onToggle: N
3329
+ }) : null;
3330
+ }, F = (e, t, n, r) => /* @__PURE__ */ K(Dt, {
3331
+ kind: A,
3332
+ label: e,
3333
+ onClose: v,
3334
+ anchor: n,
3335
+ align: r,
3336
+ children: h ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("div", {
3337
+ className: "ecomid-search-overlay__title",
3338
+ children: e
3339
+ }), t] }) : /* @__PURE__ */ K(Ot, {
3340
+ title: e,
3341
+ allLabel: f("filters.all"),
3342
+ closeLabel: f("actions.close"),
3343
+ onAll: () => _({ type: "drawer" }),
3344
+ onClose: v,
3345
+ children: t
3346
+ })
3347
+ }), I = T.includes(r) && !k(r) ? f(`sort.options.${r}`) : void 0, R = t.total ?? t.products.length, z = (e) => {
3348
+ let t = xr(e, n, S, C, ee), r = g?.type === "group" && g.group === e, [i] = t.values, a = e === "color" && i !== void 0 ? kr(i, S(e, i)) : void 0, [o] = t.labels, s = t.labels.length - 1;
3349
+ return /* @__PURE__ */ q("div", {
3350
+ className: "ecomid-search-anchor",
3351
+ children: [/* @__PURE__ */ q("button", {
3352
+ type: "button",
3353
+ className: "ecomid-search-pill",
3354
+ "data-active": t.labels.length > 0 || void 0,
3355
+ "aria-haspopup": "dialog",
3356
+ "aria-expanded": r,
3357
+ "aria-label": s > 0 ? t.labels.join(", ") : void 0,
3358
+ onClick: (t) => _(r ? null : {
3359
+ type: "group",
3360
+ group: e,
3361
+ anchor: Yr(t)
3362
+ }),
3363
+ children: [
3364
+ a && /* @__PURE__ */ K("span", {
3365
+ className: "ecomid-search-swatch",
3366
+ "aria-hidden": "true",
3367
+ style: { backgroundColor: a }
3368
+ }),
3369
+ /* @__PURE__ */ K("span", {
3370
+ className: "ecomid-search-pill__label",
3371
+ children: o === void 0 ? O(e) : s > 0 ? `${o} +${s}` : o
3372
+ }),
3373
+ /* @__PURE__ */ K(ut, {})
3374
+ ]
3375
+ }), r && F(O(e), P(e), g.anchor)]
3376
+ }, e);
3377
+ }, te = xr("category", n, S, C).labels.length > 0 && w.includes("category");
3378
+ return /* @__PURE__ */ q(G, { children: [
3379
+ /* @__PURE__ */ q("div", {
3380
+ ref: b,
3381
+ className: "ecomid-search-toolbar__pills",
3382
+ children: [
3383
+ /* @__PURE__ */ K("button", {
3384
+ type: "button",
3385
+ className: "ecomid-search-pill",
3386
+ "data-icon": "true",
3387
+ title: f("filters.title"),
3388
+ "aria-label": f("filters.title"),
3389
+ "aria-haspopup": "dialog",
3390
+ "aria-expanded": g?.type === "drawer",
3391
+ onClick: () => _(g?.type === "drawer" ? null : { type: "drawer" }),
3392
+ children: /* @__PURE__ */ K(ct, {})
3393
+ }),
3394
+ te && z("category"),
3395
+ i.map((e) => /* @__PURE__ */ q("button", {
3396
+ type: "button",
3397
+ className: "ecomid-search-pill",
3398
+ "data-active": "true",
3399
+ "aria-label": f("filters.remove", { filter: M(e) }),
3400
+ onClick: () => s(e),
3401
+ children: [/* @__PURE__ */ K("span", {
3402
+ className: "ecomid-search-pill__label",
3403
+ children: M(e)
3404
+ }), /* @__PURE__ */ K(dt, {})]
3405
+ }, `term:${e}`)),
3406
+ a.map((e) => /* @__PURE__ */ q("button", {
3407
+ type: "button",
3408
+ className: "ecomid-search-pill",
3409
+ "data-active": "true",
3410
+ "aria-label": f("filters.remove_exclusion", { filter: M(e) }),
3411
+ onClick: () => c(e),
3412
+ children: [/* @__PURE__ */ K("span", {
3413
+ className: "ecomid-search-pill__label ecomid-search-struck",
3414
+ children: M(e)
3415
+ }), /* @__PURE__ */ K(dt, {})]
3416
+ }, `excluded:${e}`)),
3417
+ w.map((e) => e === "category" && te ? null : z(e)),
3418
+ /* @__PURE__ */ K("button", {
3419
+ type: "button",
3420
+ className: "ecomid-search-pill",
3421
+ "data-more": "true",
3422
+ hidden: D === 0,
3423
+ title: f("filters.more_count", { count: String(D) }),
3424
+ "aria-label": f("filters.more_count", { count: String(D) }),
3425
+ "aria-haspopup": "dialog",
3426
+ "aria-expanded": g?.type === "drawer",
3427
+ onClick: () => _(g?.type === "drawer" ? null : { type: "drawer" }),
3428
+ children: `+${D}`
3429
+ })
3430
+ ]
3431
+ }),
3432
+ o && /* @__PURE__ */ q("div", {
3433
+ className: "ecomid-search-toolbar__meta",
3434
+ children: [/* @__PURE__ */ K("span", {
3435
+ className: "ecomid-search-toolbar__count",
3436
+ children: f(R === 1 ? "results_count.singular" : "results_count.plural", { count: String(R) })
3437
+ }), /* @__PURE__ */ q("div", {
3438
+ className: "ecomid-search-anchor",
3439
+ children: [/* @__PURE__ */ q("button", {
3440
+ type: "button",
3441
+ className: "ecomid-search-sort",
3442
+ "aria-haspopup": "dialog",
3443
+ "aria-expanded": g?.type === "sort",
3444
+ "aria-label": I ? f("sort.selected", { option: I }) : void 0,
3445
+ onClick: (e) => _(g?.type === "sort" ? null : {
3446
+ type: "sort",
3447
+ anchor: Yr(e)
3448
+ }),
3449
+ children: [/* @__PURE__ */ K("span", { children: I ?? f("sort.label") }), /* @__PURE__ */ K(ut, {})]
3450
+ }), g?.type === "sort" && F(f("sort.label"), /* @__PURE__ */ K("div", {
3451
+ role: "radiogroup",
3452
+ "aria-label": f("sort.label"),
3453
+ className: "ecomid-search-options",
3454
+ "data-variant": "menu",
3455
+ children: T.map((e) => /* @__PURE__ */ K(Ar, {
3456
+ type: "radio",
3457
+ variant: "menu",
3458
+ name: "ecomid-search-sort",
3459
+ label: f(`sort.options.${e}`),
3460
+ checked: (k(r) ? "relevance" : r) === e,
3461
+ onChange: () => {
3462
+ u(e), v();
3463
+ }
3464
+ }, e))
3465
+ }), g.anchor, "end")]
3466
+ })]
3467
+ }),
3468
+ g?.type === "drawer" && /* @__PURE__ */ K(qr, {
3469
+ lang: e,
3470
+ results: t,
3471
+ filters: n,
3472
+ bounds: x,
3473
+ count: d,
3474
+ terms: i,
3475
+ excludedTerms: a,
3476
+ onRemoveTerm: s,
3477
+ onRemoveExcludedTerm: c,
3478
+ onApply: l,
3479
+ onClose: v
3480
+ })
3481
+ ] });
3482
+ }
3483
+ // src/search/components/BackToTop/index.tsx
3484
+ var Zr = 600;
3485
+ function Qr({ lang: e }) {
3486
+ let { t } = Q(e), [n, r] = U(null), [i, a] = U(!1);
3487
+ return z(() => {
3488
+ r(document.body);
3489
+ let e = () => a(window.scrollY > Zr);
3490
+ return e(), window.addEventListener("scroll", e, { passive: !0 }), () => window.removeEventListener("scroll", e);
3491
+ }, []), !n || !i ? null : J(/* @__PURE__ */ K("button", {
3492
+ type: "button",
3493
+ className: "ecomid-search-top",
3494
+ title: t("shell.back_to_top"),
3495
+ "aria-label": t("shell.back_to_top"),
3496
+ onClick: () => {
3497
+ let e = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
3498
+ window.scrollTo({
3499
+ top: 0,
3500
+ behavior: e ? "auto" : "smooth"
3501
+ });
3502
+ },
3503
+ children: /* @__PURE__ */ K(at, {})
3504
+ }), n);
3505
+ }
3506
+ // src/search/components/EarlierSteps/index.tsx
3507
+ function $r({ lang: e, steps: t, activeId: n, onSelect: r }) {
3508
+ let { t: i } = Q(e), [a, o] = U(!1), [s, c] = U(null), l = L(() => o(!1), []);
3509
+ if (t.length < 1) return null;
3510
+ let u = t[t.length - 1]?.id, d = i("history.title"), f = /* @__PURE__ */ q("div", {
3511
+ className: "ecomid-search-history__menu",
3512
+ children: [/* @__PURE__ */ K("p", {
3513
+ className: "ecomid-search-history__title",
3514
+ children: d
3515
+ }), t.map((e) => /* @__PURE__ */ q("button", {
3516
+ type: "button",
3517
+ className: "ecomid-search-history__item",
3518
+ "data-autofocus": e.id === n ? "" : void 0,
3519
+ "aria-current": e.id === n ? "step" : void 0,
3520
+ onClick: () => {
3521
+ l(), r(e.id);
3522
+ },
3523
+ children: [/* @__PURE__ */ K("span", {
3524
+ className: "ecomid-search-history__label",
3525
+ children: e.label
3526
+ }), e.id === u && /* @__PURE__ */ K("span", {
3527
+ className: "ecomid-search-history__now",
3528
+ children: i("history.now")
3529
+ })]
3530
+ }, e.id))]
3531
+ });
3532
+ return /* @__PURE__ */ q("div", {
3533
+ className: "ecomid-search-history",
3534
+ children: [/* @__PURE__ */ K("button", {
3535
+ ref: c,
3536
+ type: "button",
3537
+ className: "ecomid-search-history__button",
3538
+ title: d,
3539
+ "aria-label": d,
3540
+ "aria-haspopup": "dialog",
3541
+ "aria-expanded": a,
3542
+ onClick: () => o((e) => !e),
3543
+ children: /* @__PURE__ */ K(xt, {
3544
+ className: "ecomid-search-icon",
3545
+ "aria-hidden": "true",
3546
+ focusable: "false"
3547
+ })
3548
+ }), a && /* @__PURE__ */ K(Dt, {
3549
+ kind: "popover",
3550
+ label: d,
3551
+ onClose: l,
3552
+ anchor: s,
3553
+ children: f
3554
+ })]
3555
+ });
3556
+ }
3557
+ // src/helpers/scrollState.ts
3558
+ function ei(e, t) {
3559
+ let n = !1, r, i = () => {
3560
+ n || (n = !0, e(!0)), clearTimeout(r), r = setTimeout(() => {
3561
+ n = !1, e(!1);
3562
+ }, t);
3563
+ };
3564
+ return window.addEventListener("scroll", i, { passive: !0 }), () => {
3565
+ clearTimeout(r), window.removeEventListener("scroll", i);
3566
+ };
3567
+ }
3568
+ // src/search/components/hooks/useScrolling.ts
3569
+ function ti(e) {
3570
+ let [t, n] = U(!1);
3571
+ return z(() => ei(n, e), [e]), t;
3572
+ }
3573
+ // src/search/components/FloatingBar/index.tsx
3574
+ var ni = 200;
3575
+ function ri({ placeholder: e, sendLabel: t, followUps: n = [], onSend: r }) {
3576
+ let [i, a] = U(null), [o, s] = U(""), c = H(null), l = H(null), u = ti(450);
3577
+ Wn(l, n.length > 0 && i !== null), z(() => {
3578
+ a(document.body);
3579
+ }, []);
3580
+ let d = () => {
3581
+ let e = c.current;
3582
+ e && (e.style.height = "0px", e.style.height = `${e.scrollHeight}px`);
3583
+ }, f = (e) => {
3584
+ let t = o.trim();
3585
+ t && (s(""), c.current && (c.current.style.height = ""), r(t), e?.reset());
3586
+ };
3587
+ return i ? J(/* @__PURE__ */ q("div", {
3588
+ className: "ecomid-search-bar-dock",
3589
+ children: [n.length > 0 && /* @__PURE__ */ K("div", {
3590
+ ref: l,
3591
+ className: "ecomid-search-bar__follow-ups",
3592
+ "data-scrolling": u || void 0,
3593
+ children: n.map((e) => /* @__PURE__ */ K("button", {
3594
+ type: "button",
3595
+ className: "ecomid-search-starters__pill",
3596
+ onClick: () => r(e),
3597
+ children: e
3598
+ }, e))
3599
+ }), /* @__PURE__ */ q("form", {
3600
+ className: "ecomid-search-bar",
3601
+ onSubmit: (e) => {
3602
+ e.preventDefault(), f(e.currentTarget);
3603
+ },
3604
+ children: [/* @__PURE__ */ K("textarea", {
3605
+ ref: c,
3606
+ className: "ecomid-search-bar__input",
3607
+ rows: 1,
3608
+ value: o,
3609
+ maxLength: ni,
3610
+ placeholder: e,
3611
+ "aria-label": e,
3612
+ enterkeyhint: "send",
3613
+ autoComplete: "off",
3614
+ onInput: (e) => {
3615
+ s(e.currentTarget.value), d();
3616
+ },
3617
+ onFocus: d,
3618
+ onBlur: (e) => {
3619
+ e.currentTarget.style.height = "";
3620
+ },
3621
+ onKeyDown: (e) => {
3622
+ e.key !== "Enter" || e.shiftKey || e.isComposing || (e.preventDefault(), e.repeat || f(e.currentTarget.form));
3623
+ }
3624
+ }), /* @__PURE__ */ K("button", {
3625
+ type: "submit",
3626
+ className: "ecomid-search-bar__send",
3627
+ title: t,
3628
+ "aria-label": t,
3629
+ disabled: !o.trim(),
3630
+ children: /* @__PURE__ */ K(at, {})
3631
+ })]
3632
+ })]
3633
+ }), i) : null;
3634
+ }
3635
+ // src/search/components/RevealText/index.tsx
3636
+ function ii({ text: e, className: t, animate: n = !0 }) {
3637
+ let r = H([]), i = H(0);
3638
+ if (!n) return /* @__PURE__ */ K("p", {
3639
+ className: t,
3640
+ children: e
3641
+ });
3642
+ let a = i.current, o = 0, s = e.split(/(\s+)/).map((e) => {
3643
+ if (e === "" || /^\s+$/.test(e)) return e;
3644
+ let t = o;
3645
+ return o += 1, r.current[t] ??= Qt(Math.max(t - a, 0), a === 0), /* @__PURE__ */ K("span", {
3646
+ className: "ecomid-search-reveal-word",
3647
+ style: { animationDelay: `${r.current[t]}ms` },
3648
+ children: e
3649
+ }, t);
3650
+ });
3651
+ return i.current = o, /* @__PURE__ */ K("p", {
3652
+ className: t,
3653
+ children: s
3654
+ });
3655
+ }
3656
+ // src/search/components/ComposedPage/index.tsx
3657
+ function ai({ variant: e, count: t, delay: n }) {
3658
+ let [r, i] = U(!1);
3659
+ return r ? null : /* @__PURE__ */ K("div", {
3660
+ className: "ecomid-search-compose__handoff",
3661
+ style: { animationDelay: `${n}ms` },
3662
+ "aria-hidden": "true",
3663
+ onAnimationEnd: (e) => {
3664
+ e.target === e.currentTarget && i(!0);
3665
+ },
3666
+ children: /* @__PURE__ */ K(wn, {
3667
+ variant: e,
3668
+ count: t
3669
+ })
3670
+ });
3671
+ }
3672
+ var oi = ["min(560px, 92%)", "min(400px, 70%)"];
3673
+ function si(e) {
3674
+ return !!e && (e.terms.length > 0 || e.excludedTerms.length > 0 || e.filters.length > 0);
3675
+ }
3676
+ function ci({ page: e, turnState: t, query: n, lang: r, market: i, store: a, onApply: o }) {
3677
+ let s = V(() => {
3678
+ let a = e.order.flatMap((t) => e.sections[t]?.products ?? []), o = e.facets ?? [], s = Object.entries(h(t.filters)).filter((e) => Array.isArray(e[1]) && !o.some((t) => t.key === e[0])).map(([e, n]) => {
3679
+ let r = t.filters.find((t) => t.key === e);
3680
+ return {
3681
+ key: e,
3682
+ values: n.map((e) => ({
3683
+ value: e,
3684
+ label: r?.labels?.[r.values.indexOf(e)] ?? M(e),
3685
+ available: !0
3686
+ }))
3687
+ };
3688
+ });
3689
+ return C({
3690
+ products: a,
3691
+ total: a.length
3692
+ }, {
3693
+ query: n,
3694
+ lang: r,
3695
+ market: i
3696
+ }, {
3697
+ state: t,
3698
+ facets: [...o, ...s]
3699
+ });
3700
+ }, [
3701
+ e,
3702
+ t,
3703
+ n,
3704
+ r,
3705
+ i
3706
+ ]);
3707
+ return /* @__PURE__ */ K("div", {
3708
+ className: "ecomid-search-compose__filters",
3709
+ children: /* @__PURE__ */ K(Xr, {
3710
+ lang: r,
3711
+ results: s,
3712
+ filters: h(t.filters),
3713
+ sort: S(t.sort),
3714
+ terms: t.terms,
3715
+ excludedTerms: t.excludedTerms,
3716
+ meta: !1,
3717
+ onRemoveTerm: (e) => o({
3718
+ ...t,
3719
+ terms: t.terms.filter((t) => t !== e)
3720
+ }),
3721
+ onRemoveExcludedTerm: (e) => o({
3722
+ ...t,
3723
+ excludedTerms: t.excludedTerms.filter((t) => t !== e)
3724
+ }),
3725
+ onFiltersChange: (e) => o(N(t, e)),
3726
+ onSortChange: (e) => o({
3727
+ ...t,
3728
+ sort: e
3729
+ }),
3730
+ count: (e, n) => a.count(e, n, t)
3731
+ })
3732
+ });
3733
+ }
3734
+ function li({ turn: e, page: t, animate: n, loading: r, bubble: i, filters: a, headingLevel: o, lang: s, market: c, onSend: l, onProductClick: u, renderProduct: d, onRenderError: f }) {
3735
+ let p = te(), { t: m } = Q(s), h = `h${o}`, g = `h${o + 1}`, _ = t.order.map((e) => t.sections[e]).filter((e) => !!e), v = _.find((e) => e.kind === "intro"), y = n, b = O(t), x = v?.text ?? "", S = Ct("(min-width: 768px)"), C = t.mode === "discovery" && S && !b, w = r && !b, T = w && (C || !x), E = H(null);
3736
+ E.current === null && !C && (x || b) && (E.current = performance.now());
3737
+ let D = H(/* @__PURE__ */ new Map()), k = H(/* @__PURE__ */ new Set()), ee = (e, n) => {
3738
+ let r = D.current.get(e);
3739
+ if (r !== void 0) return r;
3740
+ let i = $t(Yt(x, !!t.question)[n], E.current === null ? 0 : performance.now() - E.current);
3741
+ return D.current.set(e, i), i;
3742
+ }, A = (e, t) => ({ animationDelay: `${ee(e, t)}ms` }), j = t.failed ? t.error || m("results_error") : "", N = M(i), P = 0, F = /* @__PURE__ */ new Map();
3743
+ for (let e of _) F.set(e.id, P), P += e.products.length;
3744
+ let I = t.followUps.length > 0 && /* @__PURE__ */ q("div", {
3745
+ className: "ecomid-search-compose__follow-ups",
3746
+ children: [t.question && /* @__PURE__ */ K(g, {
3747
+ className: y ? "ecomid-search-compose__question ecomid-search-seq" : "ecomid-search-compose__question",
3748
+ style: y ? A("question", "question") : void 0,
3749
+ children: t.question
3750
+ }), /* @__PURE__ */ K("div", {
3751
+ className: y ? "ecomid-search-compose__chips ecomid-search-seq" : "ecomid-search-compose__chips",
3752
+ style: y ? A("chips", "chips") : void 0,
3753
+ children: t.followUps.map((e) => /* @__PURE__ */ K("button", {
3754
+ type: "button",
3755
+ className: "ecomid-search-starters__pill",
3756
+ onClick: () => l(e),
3757
+ children: e
3758
+ }, e))
3759
+ })]
3760
+ }, "follow-ups"), L = (e, n = 0) => {
3761
+ if (e.kind === "intro") return C ? null : /* @__PURE__ */ K("div", {
3762
+ className: t.mode === "discovery" ? "ecomid-search-compose__intro ecomid-search-compose__intro--discovery" : "ecomid-search-compose__intro",
3763
+ children: e.text && /* @__PURE__ */ K(ii, {
3764
+ className: "ecomid-search-compose__text",
3765
+ text: e.text,
3766
+ animate: y
3767
+ })
3768
+ }, e.id);
3769
+ let r = `${p}-section-${e.id}`, i = F.get(e.id) ?? 0, a = e.products.length, o = (e, t) => u(e, i + t), l = d && ((e, t) => d(e, {
3770
+ ...t,
3771
+ position: i + t.position
3772
+ })), h = e.kind === "picks" ? "picks" : "wide", _ = e.kind === "picks" ? "picks" : "browse", v = `section:${e.id}`;
3773
+ e.pending && k.current.add(e.id);
3774
+ let b = !e.pending && k.current.has(e.id), x = b ? ee(`content:${e.id}`, _) : void 0, S = y ? {
3775
+ section: n,
3776
+ base: x
3777
+ } : void 0;
3778
+ return /* @__PURE__ */ q("section", {
3779
+ className: [
3780
+ "ecomid-search-section",
3781
+ "ecomid-search-compose__section",
3782
+ `ecomid-search-compose__section--${e.kind}`,
3783
+ y && "ecomid-search-seq"
3784
+ ].filter(Boolean).join(" "),
3785
+ style: y ? A(v, _) : void 0,
3786
+ "aria-labelledby": e.title ? r : void 0,
3787
+ "aria-busy": e.pending,
3788
+ children: [
3789
+ (e.title || !e.pending && a > 0) && /* @__PURE__ */ q("div", {
3790
+ className: "ecomid-search-compose__section-header",
3791
+ children: [e.title && /* @__PURE__ */ K(g, {
3792
+ id: r,
3793
+ className: "ecomid-search-compose__section-title",
3794
+ children: e.title
3795
+ }), !e.pending && a > 0 && /* @__PURE__ */ K("span", {
3796
+ className: "ecomid-search-compose__count",
3797
+ children: m(a === 1 ? "results_count.singular" : "results_count.plural", { count: String(a) })
3798
+ })]
3799
+ }),
3800
+ e.pending && /* @__PURE__ */ K(wn, {
3801
+ variant: h,
3802
+ count: e.kind === "grid" ? 5 : 4
3803
+ }),
3804
+ !e.pending && a > 0 && /* @__PURE__ */ q("div", {
3805
+ className: "ecomid-search-compose__content",
3806
+ children: [b && y && /* @__PURE__ */ K(ai, {
3807
+ variant: h,
3808
+ count: e.kind === "grid" ? 5 : 4,
3809
+ delay: (x ?? 0) + Xt(n, 0)
3810
+ }), e.kind === "carousel" ? /* @__PURE__ */ K(xn, {
3811
+ products: e.products,
3812
+ lang: s,
3813
+ market: c,
3814
+ previousLabel: m("actions.previous"),
3815
+ nextLabel: m("actions.next"),
3816
+ onProductClick: o,
3817
+ renderProduct: l,
3818
+ reveal: S,
3819
+ onRenderError: f
3820
+ }) : /* @__PURE__ */ K(_n, {
3821
+ products: e.products,
3822
+ lang: s,
3823
+ market: c,
3824
+ variant: h,
3825
+ reveal: S,
3826
+ onProductClick: o,
3827
+ renderProduct: l,
3828
+ onRenderError: f
3829
+ })]
3830
+ })
3831
+ ]
3832
+ }, e.id);
3833
+ }, R = v ? L(v) : null, z = b ? _.filter((e) => e !== v).map((e, t) => L(e, t)) : [];
3834
+ return /* @__PURE__ */ q("div", {
3835
+ className: [
3836
+ "ecomid-search-compose__turn",
3837
+ a && "ecomid-search-compose__turn--filtered",
3838
+ y && "ecomid-search-up"
3839
+ ].filter(Boolean).join(" "),
3840
+ "data-turn": e.id,
3841
+ children: [
3842
+ t.mode === "discovery" && /* @__PURE__ */ q("div", {
3843
+ className: "ecomid-search-compose__lead ecomid-search-compose__lead--discovery",
3844
+ children: [/* @__PURE__ */ q("div", {
3845
+ className: "ecomid-search-compose__answer ecomid-search-compose__answer--discovery",
3846
+ children: [/* @__PURE__ */ K(h, {
3847
+ className: "ecomid-search-compose__title",
3848
+ children: N
3849
+ }), T ? /* @__PURE__ */ K(Dn, {
3850
+ className: "ecomid-search-compose__intro ecomid-search-compose__intro--discovery ecomid-search-compose__text",
3851
+ widths: oi
3852
+ }) : R]
3853
+ }), a]
3854
+ }),
3855
+ t.mode === "conversation" && /* @__PURE__ */ q("div", {
3856
+ className: "ecomid-search-compose__lead ecomid-search-compose__lead--conversation",
3857
+ children: [
3858
+ /* @__PURE__ */ q("div", {
3859
+ className: "ecomid-search-compose__answer",
3860
+ children: [/* @__PURE__ */ K("div", {
3861
+ className: "ecomid-search-compose__thread",
3862
+ children: /* @__PURE__ */ K("div", {
3863
+ className: "ecomid-search-compose__bubble-row",
3864
+ children: /* @__PURE__ */ K(h, {
3865
+ className: "ecomid-search-compose__bubble",
3866
+ children: i
3867
+ })
3868
+ })
3869
+ }), T ? /* @__PURE__ */ K(Dn, {
3870
+ className: "ecomid-search-compose__intro ecomid-search-compose__text",
3871
+ widths: oi
3872
+ }) : R]
3873
+ }),
3874
+ I,
3875
+ a
3876
+ ]
3877
+ }),
3878
+ z.length > 0 && /* @__PURE__ */ K("div", {
3879
+ className: "ecomid-search-compose__sections",
3880
+ children: z
3881
+ }),
3882
+ w && t.mode === "discovery" && /* @__PURE__ */ K("div", {
3883
+ className: "ecomid-search-compose__sections",
3884
+ children: /* @__PURE__ */ K(An, {})
3885
+ }),
3886
+ b && j && /* @__PURE__ */ K("p", {
3887
+ className: "ecomid-search-compose__error",
3888
+ children: j
3889
+ })
3890
+ ]
3891
+ });
3892
+ }
3893
+ function ui({ store: e, lang: t, market: n, headingLevel: r, onNewSearch: i, onPersonalize: a, onProductClick: o, renderProduct: s, onRenderError: c }) {
3894
+ let { t: l } = Q(t), [u, d] = U(null), f = H(null), p = _e(e.subscribe, e.getState, e.getState), m = p.turns[p.turns.length - 1], h = u ?? m?.id ?? 0, _ = p.turns.find((e) => e.id === h) ?? m, v = p.status === "loading" && u === null, y = _ && p.archive[_.id] || (_?.id === m?.id ? p.page : void 0) || p.page, b = H(u);
3895
+ B(() => {
3896
+ if (b.current === u) return;
3897
+ b.current = u;
3898
+ let e = f.current;
3899
+ e && e.getBoundingClientRect().top < 0 && e.scrollIntoView({
3900
+ block: "start",
3901
+ behavior: "instant"
3902
+ });
3903
+ }, [u]);
3904
+ let x = (t) => {
3905
+ d(null), e.send(t);
3906
+ }, S = (t) => {
3907
+ d(null), e.applyState(t);
3908
+ }, C = y.failed ? y.error || l("results_error") : "", w = y.sections[y.order.find((e) => y.sections[e]?.kind === "intro") ?? ""], T = C || (y.completed ? w?.text ?? "" : ""), E = p.turns.filter((e) => {
3909
+ let t = p.archive[e.id];
3910
+ return !!t && g(t);
3911
+ }).map((e) => ({
3912
+ id: e.id,
3913
+ label: e.text
3914
+ })), D = p.turns.length > 1 && E.length > 0;
3915
+ return /* @__PURE__ */ K(kt.Provider, {
3916
+ value: x,
3917
+ children: /* @__PURE__ */ q("div", {
3918
+ ref: f,
3919
+ className: "ecomid-search-compose",
3920
+ "aria-busy": v,
3921
+ children: [
3922
+ /* @__PURE__ */ K(ur, {
3923
+ lang: t,
3924
+ onNewSearch: i,
3925
+ onPersonalize: a,
3926
+ history: D ? /* @__PURE__ */ K($r, {
3927
+ lang: t,
3928
+ steps: E,
3929
+ activeId: h,
3930
+ onSelect: (e) => d(e === E[E.length - 1]?.id ? null : e)
3931
+ }) : void 0
3932
+ }),
3933
+ _ && /* @__PURE__ */ K(li, {
3934
+ turn: _,
3935
+ page: y,
3936
+ animate: u === null,
3937
+ loading: u === null && !y.completed,
3938
+ bubble: _.text,
3939
+ filters: y.state && si(y.state) ? /* @__PURE__ */ K(ci, {
3940
+ page: y,
3941
+ turnState: y.state,
3942
+ query: _.text,
3943
+ lang: t,
3944
+ market: n,
3945
+ store: e,
3946
+ onApply: S
3947
+ }) : void 0,
3948
+ headingLevel: r,
3949
+ lang: t,
3950
+ market: n,
3951
+ onSend: x,
3952
+ onProductClick: o,
3953
+ renderProduct: s,
3954
+ onRenderError: c
3955
+ }, _.id),
3956
+ y.completed && /* @__PURE__ */ K("div", {
3957
+ className: "ecomid-search-footer",
3958
+ children: /* @__PURE__ */ K(We, {})
3959
+ }),
3960
+ /* @__PURE__ */ K("p", {
3961
+ role: "status",
3962
+ className: "ecomid-search-sr-only",
3963
+ children: T
3964
+ }),
3965
+ /* @__PURE__ */ K(ri, {
3966
+ placeholder: l("compose.placeholder"),
3967
+ sendLabel: l("compose.send"),
3968
+ followUps: y.mode === "discovery" ? y.followUps : [],
3969
+ onSend: x
3970
+ })
3971
+ ]
3972
+ })
3973
+ });
3974
+ }
3975
+ // src/search/components/EmptyResults/index.tsx
3976
+ var di = 12, fi = 4;
3977
+ function pi({ clientId: e, lang: t, market: r, baseUrl: i, query: a, filtered: o, headingLevel: s, titleId: c, onSearch: l, onProductClick: u, renderProduct: d, onRenderError: f }) {
3978
+ let { t: p } = Q(t), [m, h] = U(null), g = `h${s}`, _ = `h${Math.min(s + 1, 6)}`;
3979
+ z(() => {
3980
+ if (o) return;
3981
+ let a = !1;
3982
+ return n(e, {
3983
+ lang: t,
3984
+ market: r,
3985
+ baseUrl: i
3986
+ }).then((e) => {
3987
+ a || h(e);
3988
+ }, () => {}), () => {
3989
+ a = !0;
3990
+ };
3991
+ }, [
3992
+ o,
3993
+ e,
3994
+ t,
3995
+ r,
3996
+ i
3997
+ ]);
3998
+ let v = (m?.recommendedProducts ?? []).slice(0, di);
3999
+ return o ? /* @__PURE__ */ q("div", {
4000
+ className: "ecomid-search-empty",
4001
+ children: [/* @__PURE__ */ K(g, {
4002
+ id: c,
4003
+ className: "ecomid-search-empty__title",
4004
+ children: p("empty.filtered_title")
4005
+ }), /* @__PURE__ */ K("p", {
4006
+ className: "ecomid-search-empty__hint",
4007
+ children: p("empty.filtered_hint")
4008
+ })]
4009
+ }) : /* @__PURE__ */ q("div", {
4010
+ className: "ecomid-search-empty",
4011
+ children: [
4012
+ /* @__PURE__ */ K(g, {
4013
+ id: c,
4014
+ className: "ecomid-search-empty__title",
4015
+ children: p("empty.title", { query: a })
4016
+ }),
4017
+ /* @__PURE__ */ K("p", {
4018
+ className: "ecomid-search-empty__hint",
4019
+ children: p("empty.hint")
4020
+ }),
4021
+ m && m.starters.length > 0 && /* @__PURE__ */ K("div", {
4022
+ className: "ecomid-search-empty__pills",
4023
+ children: /* @__PURE__ */ K(Gn, {
4024
+ starters: m.starters.slice(0, fi),
4025
+ onSelect: l
4026
+ })
4027
+ }),
4028
+ v.length > 0 && /* @__PURE__ */ q("section", {
4029
+ className: "ecomid-search-section ecomid-search-empty__section",
4030
+ children: [/* @__PURE__ */ q("div", {
4031
+ className: "ecomid-search-compose__section-header",
4032
+ children: [/* @__PURE__ */ K(_, {
4033
+ className: "ecomid-search-compose__section-title",
4034
+ children: p("empty.popular")
4035
+ }), /* @__PURE__ */ K("span", {
4036
+ className: "ecomid-search-compose__count",
4037
+ children: p(v.length === 1 ? "results_count.singular" : "results_count.plural", { count: String(v.length) })
4038
+ })]
4039
+ }), /* @__PURE__ */ K(xn, {
4040
+ products: v,
4041
+ lang: t,
4042
+ market: r,
4043
+ previousLabel: p("actions.previous"),
4044
+ nextLabel: p("actions.next"),
4045
+ onProductClick: u,
4046
+ renderProduct: d,
4047
+ onRenderError: f
4048
+ })]
4049
+ })
4050
+ ]
4051
+ });
4052
+ }
4053
+ // src/search/components/LoadingDots/index.tsx
4054
+ function mi({ className: e }) {
4055
+ return /* @__PURE__ */ q("span", {
4056
+ className: e ? `ecomid-search-loading-more ${e}` : "ecomid-search-loading-more",
4057
+ "aria-hidden": "true",
4058
+ children: [
4059
+ /* @__PURE__ */ K("span", { className: "ecomid-search-loading-more__dot" }),
4060
+ /* @__PURE__ */ K("span", {
4061
+ className: "ecomid-search-loading-more__dot",
4062
+ style: { animationDelay: "0.15s" }
4063
+ }),
4064
+ /* @__PURE__ */ K("span", {
4065
+ className: "ecomid-search-loading-more__dot",
4066
+ style: { animationDelay: "0.3s" }
4067
+ })
4068
+ ]
4069
+ });
4070
+ }
4071
+ // src/search/components/StartView/index.tsx
4072
+ function hi({ clientId: e, lang: t, market: n, baseUrl: r, headingLevel: i, track: a, onClose: o, onSubmit: s, onProductClick: c, renderProduct: l, onRenderError: u }) {
4073
+ let { t: d } = Q(t), f = H(null), m = V(() => p({
4074
+ clientId: e,
4075
+ market: n,
4076
+ lang: t,
4077
+ baseUrl: r
4078
+ }), [
4079
+ e,
4080
+ n,
4081
+ t,
4082
+ r
4083
+ ]), h = `h${i}`;
4084
+ z(() => () => m.destroy(), [m]), z(() => {
4085
+ window.scrollTo?.({ top: 0 }), f.current?.querySelector(".ecomid-search-panel__input")?.focus({ preventScroll: !0 });
4086
+ }, []);
4087
+ let g = lr({
4088
+ clientId: e,
4089
+ lang: t,
4090
+ market: n
4091
+ });
4092
+ return /* @__PURE__ */ q("div", {
4093
+ ref: f,
4094
+ className: "ecomid-search-start",
4095
+ children: [
4096
+ /* @__PURE__ */ K(gt, {
4097
+ lang: t,
4098
+ onClose: o,
4099
+ onPersonalize: g
4100
+ }),
4101
+ /* @__PURE__ */ K(h, {
4102
+ className: "ecomid-search-start__title",
4103
+ children: d("placeholder")
4104
+ }),
4105
+ /* @__PURE__ */ K("div", {
4106
+ className: "ecomid-search-start__panel",
4107
+ children: /* @__PURE__ */ K($n, {
4108
+ store: m,
4109
+ track: a,
4110
+ onSubmit: s,
4111
+ onProductClick: c,
4112
+ renderProduct: l,
4113
+ onRenderError: u,
4114
+ lang: t,
4115
+ market: n,
4116
+ showCount: !0,
4117
+ floatingSuggestions: !0
4118
+ })
4119
+ }),
4120
+ /* @__PURE__ */ K("div", {
4121
+ className: "ecomid-search-footer",
4122
+ children: /* @__PURE__ */ K(We, {})
4123
+ })
4124
+ ]
4125
+ });
4126
+ }
4127
+ // src/search/components/SearchResults/index.tsx
4128
+ function gi({ query: e, lang: t, market: n, limit: r, page: i }) {
4129
+ return `query ${JSON.stringify(e)} lang ${JSON.stringify(t)} market ${JSON.stringify(n)} limit ${JSON.stringify(r)} page ${JSON.stringify(i)}`;
4130
+ }
4131
+ function _i({ clientId: e, lang: t, market: n, baseUrl: a, query: o = "", page: s, onPageChange: c, initialResults: l, limit: d, headingLevel: f = 1, onProductClick: p, renderProduct: m }) {
4132
+ let h = te(), g = pe(), _ = ge(), { t: v } = Q(t), { track: y, onRenderError: b } = Ae({
4133
+ clientId: e,
4134
+ lang: t,
4135
+ market: n
4136
+ }), x = lr({
4137
+ clientId: e,
4138
+ lang: t,
4139
+ market: n
4140
+ }), S = H(o);
4141
+ S.current = o;
4142
+ let C = H(l);
4143
+ C.current = l;
4144
+ let T = H(s);
4145
+ T.current = s;
4146
+ let E = V(() => {
4147
+ let e = s == null ? null : i(s);
4148
+ return e ? r(e) : null;
4149
+ }, [s]), O = V(() => {
4150
+ let o = C.current, s = T.current == null ? null : i(T.current);
4151
+ return {
4152
+ seed: o,
4153
+ expected: {
4154
+ query: s ? w(s) : S.current.trim(),
4155
+ lang: t,
4156
+ market: n,
4157
+ limit: d,
4158
+ page: s ? r(s) : void 0
4159
+ },
4160
+ store: ee({
4161
+ clientId: e,
4162
+ market: n,
4163
+ lang: t,
4164
+ baseUrl: a,
4165
+ limit: d,
4166
+ page: T.current,
4167
+ query: S.current,
4168
+ initialResults: o
4169
+ })
4170
+ };
4171
+ }, [
4172
+ e,
4173
+ n,
4174
+ t,
4175
+ a,
4176
+ d
4177
+ ]), { store: j } = O;
4178
+ z(() => () => j.destroy(), [j]);
4179
+ let N = H(E ? {
4180
+ store: j,
4181
+ query: o
4182
+ } : null);
4183
+ z(() => {
4184
+ let e = N.current;
4185
+ N.current = {
4186
+ store: j,
4187
+ query: o
4188
+ }, (e?.store !== j || e.query !== o) && j.setQuery(o, C.current), j.load();
4189
+ }, [j, o]);
4190
+ let P = H(E !== null), F = H(E);
4191
+ z(() => {
4192
+ (E !== null || P.current) && (P.current = E !== null, F.current = E, j.setPage(T.current ?? null, C.current));
4193
+ }, [j, E]);
4194
+ let I = H(O), R = H(!1);
4195
+ z(() => {
4196
+ if (O !== I.current || R.current) return;
4197
+ let { seed: e, expected: t } = O;
4198
+ e && !D(e, t) && (R.current = !0, g(/* @__PURE__ */ Error(`Search initialResults ignored: expected ${gi(t)}, received ${gi(e)}`)));
4199
+ }, [O, g]);
4200
+ let W = _e(j.subscribe, j.getState, j.getState), G = H(c);
4201
+ G.current = c, z(() => {
4202
+ let e = j.getPage();
4203
+ if (!e) {
4204
+ W.status === "idle" && (F.current = null);
4205
+ return;
4206
+ }
4207
+ let t = r(e);
4208
+ t !== F.current && (F.current = t, _(() => G.current?.(u(e))));
4209
+ }, [
4210
+ j,
4211
+ W,
4212
+ _
4213
+ ]), z(() => {
4214
+ W.status === "error" && W.error && g(W.error);
4215
+ }, [
4216
+ W.status,
4217
+ W.error,
4218
+ g
4219
+ ]), z(() => {
4220
+ W.moreError && g(W.moreError);
4221
+ }, [W.moreError, g]);
4222
+ let J = H(p);
4223
+ J.current = p;
4224
+ let Y = H({
4225
+ contextId: W.contextId,
4226
+ turn: W.turnNumber
4227
+ });
4228
+ Y.current = {
4229
+ contextId: W.contextId,
4230
+ turn: W.turnNumber
4231
+ };
4232
+ let ne = L((e, t) => (n) => {
4233
+ let { contextId: r, turn: i } = Y.current;
4234
+ y(ve.PRODUCT_CLICK, { attrs: {
4235
+ variant_id: e.id,
4236
+ name: e.name,
4237
+ url: e.url,
4238
+ position: String(t),
4239
+ ...r && { context_id: r },
4240
+ ...i !== void 0 && { turn: String(i) }
4241
+ } }), _(() => J.current?.(e, n));
4242
+ }, [y, _]), re = L((e) => {
4243
+ y(ve.PRE_PROMPT_CLICK, { attrs: { text: e } }), j.setQuery(e);
4244
+ }, [y, j]), ie = W.pending, [ae, oe] = U(!1), [se, ce] = U(!1), le = L(() => {
4245
+ ce(!1), oe(!0);
4246
+ }, []), ue = L((e) => {
4247
+ ce(!0), j.setQuery(e);
4248
+ }, [j]), de = W.status === "loading", fe = de && W.mode !== void 0, me = ae && !(se && (!de || fe));
4249
+ z(() => {
4250
+ ae && !me && (oe(!1), ce(!1));
4251
+ }, [ae, me]);
4252
+ let X = W.results, he = W.surface === "compose", ye = W.turns[W.turns.length - 1]?.id ?? 0, be = (X?.sections?.length ? X.sections : [{ products: X?.products ?? [] }]).filter((e) => e.products.length > 0).map((e, t, n) => ({
4253
+ ...e,
4254
+ key: `${e.title ?? ""}:${e.products[0]?.id}`,
4255
+ offset: n.slice(0, t).reduce((e, t) => e + t.products.length, 0)
4256
+ })), Z = be.reduce((e, t) => e + t.products.length, 0), xe = Math.max(X?.total ?? 0, Z), Se = !!X?.nextPageToken, Ce = !!X && !!W.query && (Z > 0 || A(W.filters) > 0 || !k(W.sort)), we = W.status === "success", Te = W.status === "loading", Ee = W.status === "error", De = we && Z === 0, Oe = Ee ? v("results_error") : De ? v("no_results") : we ? v(xe === 1 ? "results_status.title_singular" : "results_status.title_plural", {
4257
+ count: String(xe),
4258
+ query: W.query
4259
+ }) : "", ke = H(null), je = H(ie);
4260
+ B(() => {
4261
+ let e = je.current;
4262
+ if (je.current = ie, e !== "results" || ie === "results") return;
4263
+ let t = ke.current;
4264
+ t && t.getBoundingClientRect().top < 0 && t.scrollIntoView({
4265
+ block: "start",
4266
+ behavior: "instant"
4267
+ });
4268
+ }, [ie]);
4269
+ let Me = H(null), Ne = W.loadingMore;
4270
+ z(() => {
4271
+ let e = Me.current;
4272
+ if (!Se || Z === 0 || !e || typeof IntersectionObserver > "u") return;
4273
+ let t = new IntersectionObserver((e) => {
4274
+ e.some((e) => e.isIntersecting) && j.loadMore();
4275
+ }, { rootMargin: "0px 0px 600px 0px" });
4276
+ return t.observe(e), () => t.disconnect();
4277
+ }, [
4278
+ j,
4279
+ Se,
4280
+ Z
4281
+ ]);
4282
+ let Pe = H({
4283
+ run: ye,
4284
+ count: 0
4285
+ });
4286
+ Pe.current.run !== ye && (Pe.current = {
4287
+ run: ye,
4288
+ count: 0
4289
+ });
4290
+ let Fe = Pe.current.count;
4291
+ z(() => {
4292
+ Pe.current.count = Z;
4293
+ });
4294
+ let Ie = !!X && !!W.query, Le = De && A(W.filters) > 0, Re = ie === "grid", ze = X && (!De || Le) ? M(X.title ?? W.title) : Re ? M(W.title) : "", Be = W.turns.filter((e) => !!W.gridArchive[e.id]).map((e) => ({
4295
+ id: e.id,
4296
+ label: e.text
4297
+ })), Ve = W.turns.length > 1 && Be.length > 0, He = /* @__PURE__ */ K(ur, {
4298
+ lang: t,
4299
+ onNewSearch: le,
4300
+ onPersonalize: x,
4301
+ history: Ve ? /* @__PURE__ */ K($r, {
4302
+ lang: t,
4303
+ steps: Be,
4304
+ activeId: W.activeTurn,
4305
+ onSelect: j.jumpTo
4306
+ }) : void 0
4307
+ }), Ue = `h${f}`, Ge = `h${ze ? f + 1 : f}`, Ke = `${h}-title`;
4308
+ return me ? /* @__PURE__ */ K("section", {
4309
+ ref: ke,
4310
+ className: "ecomid-search-results ecomid-search-results--start",
4311
+ children: /* @__PURE__ */ K(hi, {
4312
+ clientId: e,
4313
+ lang: t,
4314
+ market: n,
4315
+ baseUrl: a,
4316
+ headingLevel: f,
4317
+ track: y,
4318
+ onClose: () => oe(!1),
4319
+ onSubmit: ue,
4320
+ onProductClick: p,
4321
+ renderProduct: m,
4322
+ onRenderError: b
4323
+ })
4324
+ }) : he ? /* @__PURE__ */ q("section", {
4325
+ ref: ke,
4326
+ className: "ecomid-search-results ecomid-search-results--compose ecomid-search-results--bar",
4327
+ children: [/* @__PURE__ */ K(ui, {
4328
+ store: j,
4329
+ lang: t,
4330
+ market: n,
4331
+ headingLevel: f,
4332
+ onNewSearch: le,
4333
+ onPersonalize: x,
4334
+ onProductClick: ne,
4335
+ renderProduct: m,
4336
+ onRenderError: b
4337
+ }), /* @__PURE__ */ K(Qr, { lang: t })]
4338
+ }) : /* @__PURE__ */ K(kt.Provider, {
4339
+ value: j.send,
4340
+ children: /* @__PURE__ */ q("section", {
4341
+ ref: ke,
4342
+ className: Ie ? "ecomid-search-results ecomid-search-results--bar" : "ecomid-search-results",
4343
+ "aria-busy": Te || Ne,
4344
+ "aria-labelledby": ze || De ? Ke : void 0,
4345
+ children: [
4346
+ He,
4347
+ (ze || Ce || Re) && /* @__PURE__ */ q("div", {
4348
+ className: "ecomid-search-results__header ecomid-search-page-enter",
4349
+ children: [
4350
+ ze && /* @__PURE__ */ K(Ue, {
4351
+ id: Ke,
4352
+ className: "ecomid-search-results__title",
4353
+ children: ze
4354
+ }),
4355
+ X && Ce && /* @__PURE__ */ K(Xr, {
4356
+ lang: t,
4357
+ results: X,
4358
+ filters: W.filters,
4359
+ sort: W.sort,
4360
+ terms: X.state?.terms ?? [],
4361
+ excludedTerms: X.state?.excludedTerms ?? [],
4362
+ onRemoveTerm: j.removeTerm,
4363
+ onRemoveExcludedTerm: j.removeExcludedTerm,
4364
+ onFiltersChange: j.setFilters,
4365
+ onSortChange: j.setSort,
4366
+ count: j.count
4367
+ }),
4368
+ Re && /* @__PURE__ */ K(kn, {})
4369
+ ]
4370
+ }, `${ye}:header`),
4371
+ Re && /* @__PURE__ */ K("div", {
4372
+ className: "ecomid-search-section",
4373
+ children: /* @__PURE__ */ K(wn, {
4374
+ variant: "results",
4375
+ count: 20
4376
+ })
4377
+ }),
4378
+ X?.description && /* @__PURE__ */ K("p", {
4379
+ className: "ecomid-search-results__description",
4380
+ children: X.description
4381
+ }),
4382
+ Ee && /* @__PURE__ */ K("p", {
4383
+ className: "ecomid-search-no-results",
4384
+ children: v("results_error")
4385
+ }),
4386
+ De && /* @__PURE__ */ K(pi, {
4387
+ clientId: e,
4388
+ lang: t,
4389
+ market: n,
4390
+ baseUrl: a,
4391
+ query: W.query,
4392
+ filtered: Le,
4393
+ headingLevel: Le ? f + 1 : f,
4394
+ titleId: Le ? `${h}-empty-title` : Ke,
4395
+ onSearch: re,
4396
+ onProductClick: ne,
4397
+ renderProduct: m,
4398
+ onRenderError: b
4399
+ }),
4400
+ be.map((e, r) => {
4401
+ let i = `${h}-section-${r}`;
4402
+ return /* @__PURE__ */ q("section", {
4403
+ className: "ecomid-search-section ecomid-search-page-enter",
4404
+ "aria-labelledby": e.title ? i : void 0,
4405
+ children: [e.title && /* @__PURE__ */ K(Ge, {
4406
+ id: i,
4407
+ className: "ecomid-search-section__heading",
4408
+ children: e.title
4409
+ }), /* @__PURE__ */ K(_n, {
4410
+ products: e.products,
4411
+ lang: t,
4412
+ market: n,
4413
+ variant: "results",
4414
+ reveal: {
4415
+ section: r,
4416
+ from: Math.max(Fe - e.offset, 0)
4417
+ },
4418
+ onProductClick: (t, n) => ne(t, e.offset + n),
4419
+ renderProduct: m && ((t, n) => m(t, {
4420
+ ...n,
4421
+ position: e.offset + n.position
4422
+ })),
4423
+ onRenderError: b
4424
+ })]
4425
+ }, `${ye}:${e.key}`);
4426
+ }),
4427
+ Ne && /* @__PURE__ */ K(mi, {}),
4428
+ Se && /* @__PURE__ */ K("div", {
4429
+ ref: Me,
4430
+ className: "ecomid-search-results__sentinel",
4431
+ "aria-hidden": "true"
4432
+ }),
4433
+ /* @__PURE__ */ K("div", {
4434
+ className: "ecomid-search-footer",
4435
+ children: /* @__PURE__ */ K(We, {})
4436
+ }),
4437
+ /* @__PURE__ */ K("p", {
4438
+ role: "status",
4439
+ className: "ecomid-search-sr-only",
4440
+ children: Oe
4441
+ }),
4442
+ /* @__PURE__ */ K(Qr, { lang: t }),
4443
+ Ie && /* @__PURE__ */ K(ri, {
4444
+ placeholder: v("bar.describe_placeholder"),
4445
+ sendLabel: v("compose.send"),
4446
+ followUps: W.followUps,
4447
+ onSend: j.send
4448
+ })
4449
+ ]
4450
+ })
4451
+ });
4452
+ }
4453
+ function vi(e) {
4454
+ return /* @__PURE__ */ K(me, { children: /* @__PURE__ */ K(_i, { ...e }) });
4455
+ }
4456
+ // src/search/react/SearchResults.tsx
4457
+ function yi({ clientId: e, locale: t, environment: n, ...r }) {
4458
+ let i = de({
4459
+ clientId: e,
4460
+ locale: t,
4461
+ environment: n,
4462
+ active: !0
4463
+ });
4464
+ return /* @__PURE__ */ K(fe.Provider, {
4465
+ value: i.report,
4466
+ children: /* @__PURE__ */ K(he, {
4467
+ clientId: i.clientId,
4468
+ locale: i.locale,
4469
+ children: (e) => /* @__PURE__ */ K(vi, {
4470
+ ...r,
4471
+ clientId: e.clientId,
4472
+ lang: e.lang,
4473
+ market: e.market,
4474
+ baseUrl: i.urls.cgw
4475
+ })
4476
+ })
4477
+ });
4478
+ }
4479
+ // src/search/react/index.ts
4480
+ ce();
4481
+ // src/react/EcomidProvider.tsx
4482
+ function bi({ clientId: e, locale: t, environment: n = "production", children: r }) {
4483
+ let i = V(() => ({
4484
+ clientId: e,
4485
+ locale: t,
4486
+ environment: n
4487
+ }), [
4488
+ e,
4489
+ t,
4490
+ n
4491
+ ]);
4492
+ return /* @__PURE__ */ K(le.Provider, {
4493
+ value: i,
4494
+ children: r
4495
+ });
4496
+ }
4497
+ export { bi as EcomidProvider, cr as SearchModal, yi as SearchResults };