@askdialog/dialog-react 2.6.0 → 2.8.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.
@@ -1,14 +1,59 @@
1
- import { jsxs as g, jsx as n, Fragment as C } from "react/jsx-runtime";
2
- import { useRef as b, useState as v, useEffect as m, useMemo as y, useLayoutEffect as j, useCallback as x, useSyncExternalStore as V } from "react";
3
- import { registerDialogInstallation as D, addAuditCapability as K, resolveTextDirection as F, SearchStatus as L, DialogSearchError as q, createSearchController as z } from "@askdialog/dialog-sdk";
4
- import { createPortal as U } from "react-dom";
5
- const W = ({
1
+ import { jsx as o, jsxs as h, Fragment as C } from "react/jsx-runtime";
2
+ import { useRef as b, useState as v, useEffect as f, useMemo as S, useLayoutEffect as V, useCallback as P, useSyncExternalStore as K } from "react";
3
+ import { registerDialogInstallation as M, addAuditCapability as F, resolveTextDirection as U, SearchStatus as L, DialogSearchError as Q, createSearchController as W } from "@askdialog/dialog-sdk";
4
+ import { createPortal as Z } from "react-dom";
5
+ const R = {
6
+ en: {
7
+ placeholder: "Ask the AI a question",
8
+ aiDisclosure: "You're chatting with an AI assistant. It can make mistakes, so please double-check important information",
9
+ askSomethingElse: "Ask something else"
10
+ },
11
+ fr: {
12
+ placeholder: "Posez une question à l'IA",
13
+ aiDisclosure: "Vous discutez avec un assistant IA. Il peut se tromper, pensez à vérifier les informations importantes",
14
+ askSomethingElse: "Posez une autre question"
15
+ },
16
+ es: {
17
+ placeholder: "Haz una pregunta a la IA",
18
+ aiDisclosure: "Estás chateando con un asistente de IA. Puede cometer errores, así que verifica la información importante",
19
+ askSomethingElse: "Pregunta otra cosa"
20
+ }
21
+ }, T = (e) => {
22
+ var n;
23
+ const t = ((n = e == null ? void 0 : e.split("-")[0]) == null ? void 0 : n.toLowerCase()) ?? "en";
24
+ return R[t] ?? R.en;
25
+ }, X = ({
26
+ client: e,
27
+ questions: t,
28
+ disabled: n,
29
+ productId: s,
30
+ productTitle: r,
31
+ selectedVariantId: a
32
+ }) => /* @__PURE__ */ o(
33
+ "button",
34
+ {
35
+ type: "button",
36
+ className: "dialog-ask-something-else",
37
+ disabled: n,
38
+ onClick: () => {
39
+ e.openAssistantWithSuggestions({
40
+ questions: t ?? [],
41
+ product: {
42
+ id: s,
43
+ title: r,
44
+ selectedVariantId: a
45
+ }
46
+ });
47
+ },
48
+ children: T(e.locale).askSomethingElse
49
+ }
50
+ ), G = ({
6
51
  title: e = "Your expert",
7
52
  description: t = "A question about this product?"
8
- }) => /* @__PURE__ */ g("div", { className: "dialog-block-header-container", children: [
9
- /* @__PURE__ */ n("div", { className: "dialog-block-title", children: e }),
10
- /* @__PURE__ */ n("div", { className: "dialog-block-description", children: t })
11
- ] }), Q = ({ color: e = "#181825" }) => /* @__PURE__ */ g(
53
+ }) => /* @__PURE__ */ h("div", { className: "dialog-block-header-container", children: [
54
+ /* @__PURE__ */ o("div", { className: "dialog-block-title", children: e }),
55
+ /* @__PURE__ */ o("div", { className: "dialog-block-description", children: t })
56
+ ] }), Y = ({ color: e = "#181825" }) => /* @__PURE__ */ h(
12
57
  "svg",
13
58
  {
14
59
  width: "20",
@@ -17,8 +62,8 @@ const W = ({
17
62
  fill: "none",
18
63
  xmlns: "http://www.w3.org/2000/svg",
19
64
  children: [
20
- /* @__PURE__ */ g("g", { clipPath: "url(#clip0_466_934)", children: [
21
- /* @__PURE__ */ n(
65
+ /* @__PURE__ */ h("g", { clipPath: "url(#clip0_466_934)", children: [
66
+ /* @__PURE__ */ o(
22
67
  "path",
23
68
  {
24
69
  d: "M5.41675 10.8333L6.07046 12.1408C6.2917 12.5832 6.40232 12.8045 6.55011 12.9962C6.68124 13.1663 6.83375 13.3188 7.00388 13.45C7.19559 13.5977 7.41684 13.7084 7.85932 13.9296L9.16675 14.5833L7.85932 15.237C7.41684 15.4583 7.19559 15.5689 7.00388 15.7167C6.83375 15.8478 6.68124 16.0003 6.55011 16.1704C6.40232 16.3622 6.2917 16.5834 6.07046 17.0259L5.41675 18.3333L4.76303 17.0259C4.54179 16.5834 4.43117 16.3622 4.28339 16.1704C4.15225 16.0003 3.99974 15.8478 3.82962 15.7167C3.6379 15.5689 3.41666 15.4583 2.97418 15.237L1.66675 14.5833L2.97418 13.9296C3.41666 13.7084 3.6379 13.5977 3.82962 13.45C3.99974 13.3188 4.15225 13.1663 4.28339 12.9962C4.43117 12.8045 4.54179 12.5832 4.76303 12.1408L5.41675 10.8333Z",
@@ -28,7 +73,7 @@ const W = ({
28
73
  strokeLinejoin: "round"
29
74
  }
30
75
  ),
31
- /* @__PURE__ */ n(
76
+ /* @__PURE__ */ o(
32
77
  "path",
33
78
  {
34
79
  d: "M12.5001 1.66666L13.4823 4.22034C13.7173 4.83136 13.8348 5.13688 14.0175 5.39386C14.1795 5.62162 14.3785 5.82061 14.6062 5.98256C14.8632 6.16529 15.1687 6.2828 15.7797 6.5178L18.3334 7.49999L15.7797 8.48217C15.1687 8.71718 14.8632 8.83469 14.6062 9.01742C14.3785 9.17937 14.1795 9.37836 14.0175 9.60612C13.8348 9.8631 13.7173 10.1686 13.4823 10.7796L12.5001 13.3333L11.5179 10.7796C11.2829 10.1686 11.1654 9.8631 10.9827 9.60612C10.8207 9.37836 10.6217 9.17937 10.3939 9.01742C10.137 8.83469 9.83145 8.71718 9.22043 8.48217L6.66675 7.49999L9.22043 6.5178C9.83145 6.28279 10.137 6.16529 10.3939 5.98256C10.6217 5.82061 10.8207 5.62162 10.9827 5.39386C11.1654 5.13688 11.2829 4.83136 11.5179 4.22034L12.5001 1.66666Z",
@@ -39,58 +84,58 @@ const W = ({
39
84
  }
40
85
  )
41
86
  ] }),
42
- /* @__PURE__ */ n("defs", { children: /* @__PURE__ */ n("clipPath", { id: "clip0_466_934", children: /* @__PURE__ */ n("rect", { width: "20", height: "20", fill: "white" }) }) })
87
+ /* @__PURE__ */ o("defs", { children: /* @__PURE__ */ o("clipPath", { id: "clip0_466_934", children: /* @__PURE__ */ o("rect", { width: "20", height: "20", fill: "white" }) }) })
43
88
  ]
44
89
  }
45
- ), Z = ({
90
+ ), J = ({
46
91
  client: e,
47
92
  questions: t,
48
- productId: s,
49
- productTitle: r,
50
- selectedVariantId: o
93
+ productId: n,
94
+ productTitle: s,
95
+ selectedVariantId: r
51
96
  }) => {
52
- const c = (l) => {
97
+ const a = (c) => {
53
98
  e.sendProductMessage({
54
- productId: s,
55
- productTitle: r,
56
- selectedVariantId: o,
57
- question: l,
99
+ productId: n,
100
+ productTitle: s,
101
+ selectedVariantId: r,
102
+ question: c,
58
103
  fromQuestionSuggestion: !0
59
104
  });
60
105
  };
61
- return /* @__PURE__ */ n(C, { children: t.map((l) => /* @__PURE__ */ g(
106
+ return /* @__PURE__ */ o(C, { children: t.map((c) => /* @__PURE__ */ h(
62
107
  "button",
63
108
  {
64
109
  className: "dialog-block-suggestions-item",
65
- onClick: () => c(l.question),
110
+ onClick: () => a(c.question),
66
111
  children: [
67
- /* @__PURE__ */ n(Q, { color: e.theme.primaryColor }),
68
- /* @__PURE__ */ n("span", { className: "dialog-block-suggestions-item-label", children: l.question })
112
+ /* @__PURE__ */ o(Y, { color: e.theme.primaryColor }),
113
+ /* @__PURE__ */ o("span", { className: "dialog-block-suggestions-item-label", children: c.question })
69
114
  ]
70
115
  },
71
- l.question
116
+ c.question
72
117
  )) });
73
- }, X = () => /* @__PURE__ */ g(C, { children: [
74
- /* @__PURE__ */ n("div", { className: "dialog-block-suggestions-skeleton-item" }),
75
- /* @__PURE__ */ n("div", { className: "dialog-block-suggestions-skeleton-item" }),
76
- /* @__PURE__ */ n("div", { className: "dialog-block-suggestions-skeleton-item" })
77
- ] }), G = ({
118
+ }, ee = () => /* @__PURE__ */ h(C, { children: [
119
+ /* @__PURE__ */ o("div", { className: "dialog-block-suggestions-skeleton-item" }),
120
+ /* @__PURE__ */ o("div", { className: "dialog-block-suggestions-skeleton-item" }),
121
+ /* @__PURE__ */ o("div", { className: "dialog-block-suggestions-skeleton-item" })
122
+ ] }), te = ({
78
123
  client: e,
79
124
  questions: t,
80
- isLoading: s,
81
- productId: r,
82
- productTitle: o,
83
- selectedVariantId: c
84
- }) => /* @__PURE__ */ n("div", { className: "dialog-block-suggestions-container", children: s || !t ? /* @__PURE__ */ n(X, {}) : /* @__PURE__ */ n(
85
- Z,
125
+ isLoading: n,
126
+ productId: s,
127
+ productTitle: r,
128
+ selectedVariantId: a
129
+ }) => /* @__PURE__ */ o("div", { className: "dialog-block-suggestions-container", children: n || !t ? /* @__PURE__ */ o(ee, {}) : /* @__PURE__ */ o(
130
+ J,
86
131
  {
87
132
  client: e,
88
133
  questions: t,
89
- productId: r,
90
- productTitle: o,
91
- selectedVariantId: c
134
+ productId: s,
135
+ productTitle: r,
136
+ selectedVariantId: a
92
137
  }
93
- ) }), Y = ({ color: e = "#ffffff" }) => /* @__PURE__ */ n(
138
+ ) }), se = ({ color: e = "#ffffff" }) => /* @__PURE__ */ o(
94
139
  "svg",
95
140
  {
96
141
  width: "20",
@@ -98,7 +143,7 @@ const W = ({
98
143
  viewBox: "0 0 20 20",
99
144
  fill: "none",
100
145
  xmlns: "http://www.w3.org/2000/svg",
101
- children: /* @__PURE__ */ n(
146
+ children: /* @__PURE__ */ o(
102
147
  "path",
103
148
  {
104
149
  d: "M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",
@@ -109,167 +154,183 @@ const W = ({
109
154
  }
110
155
  )
111
156
  }
112
- ), J = ({
157
+ ), ne = ({
113
158
  client: e,
114
- placeholder: t = "Ask anything...",
115
- productId: s,
116
- productTitle: r,
117
- selectedVariantId: o
159
+ productId: t,
160
+ productTitle: n,
161
+ selectedVariantId: s
118
162
  }) => {
119
- const c = b(null), [l, a] = v(""), i = () => {
163
+ const r = b(null), [a, c] = v(""), i = T(e.locale), l = () => {
120
164
  var d;
121
- (d = c.current) == null || d.focus();
165
+ (d = r.current) == null || d.focus();
122
166
  }, u = () => {
123
- const d = l;
167
+ const d = a;
124
168
  d.trim() && (e.sendProductMessage({
125
- productId: s,
126
- productTitle: r,
127
- selectedVariantId: o,
169
+ productId: t,
170
+ productTitle: n,
171
+ selectedVariantId: s,
128
172
  question: d,
129
173
  fromQuestionSuggestion: !0
130
- }), a(""));
174
+ }), c(""));
175
+ }, p = (d) => {
176
+ d.key === "Enter" && u();
131
177
  };
132
- return /* @__PURE__ */ g("div", { className: "dialog-input-wrapper", onClick: i, children: [
133
- /* @__PURE__ */ n(
134
- "input",
135
- {
136
- id: "dialog-ask-anything-input-ai-input",
137
- ref: c,
138
- value: l,
139
- onChange: (d) => a(d.target.value),
140
- className: "dialog-ask-anything-input-ai-input",
141
- placeholder: t,
142
- onKeyDown: (d) => {
143
- d.key === "Enter" && u();
178
+ return /* @__PURE__ */ h("div", { className: "dialog-input-container", children: [
179
+ /* @__PURE__ */ h("div", { className: "dialog-input-wrapper", onClick: l, children: [
180
+ /* @__PURE__ */ o(
181
+ "input",
182
+ {
183
+ id: "dialog-ask-anything-input-ai-input",
184
+ ref: r,
185
+ value: a,
186
+ onChange: (d) => c(d.target.value),
187
+ className: "dialog-ask-anything-input-ai-input",
188
+ placeholder: i.placeholder,
189
+ "aria-describedby": "dialog-input-ai-disclosure",
190
+ onKeyDown: p
144
191
  }
145
- }
146
- ),
147
- /* @__PURE__ */ n(
148
- "button",
149
- {
150
- id: "send-message-button-ai-input",
151
- className: "dialog-input-submit",
152
- disabled: !l.trim(),
153
- onClick: u,
154
- children: /* @__PURE__ */ n(Y, { color: e.theme.ctaTextColor })
155
- }
156
- )
192
+ ),
193
+ /* @__PURE__ */ o(
194
+ "button",
195
+ {
196
+ id: "send-message-button-ai-input",
197
+ className: "dialog-input-submit",
198
+ disabled: !a.trim(),
199
+ onClick: u,
200
+ children: /* @__PURE__ */ o(se, { color: e.theme.ctaTextColor })
201
+ }
202
+ )
203
+ ] }),
204
+ /* @__PURE__ */ o("p", { id: "dialog-input-ai-disclosure", className: "dialog-input-ai-disclosure", children: i.aiDisclosure })
157
205
  ] });
158
- }, E = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), ee = (e) => {
206
+ }, I = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), oe = (e) => {
159
207
  if (!e) return;
160
208
  const t = document.body;
161
- Object.keys(e).forEach((s) => {
162
- const r = s, o = E(s);
163
- if (e[r] !== void 0) {
164
- if (typeof e[r] == "object") {
165
- Object.keys(e[r]).forEach(
166
- (c) => {
167
- var a;
168
- const l = c;
169
- if (l !== void 0) {
170
- const i = E(c), u = e[r];
209
+ Object.keys(e).forEach((n) => {
210
+ const s = n, r = I(n);
211
+ if (e[s] !== void 0) {
212
+ if (typeof e[s] == "object") {
213
+ Object.keys(e[s]).forEach(
214
+ (a) => {
215
+ var i;
216
+ const c = a;
217
+ if (c !== void 0) {
218
+ const l = I(a), u = e[s];
171
219
  t.style.setProperty(
172
- `--dialog-theme-${o}-${i}`,
173
- (a = u[l]) == null ? void 0 : a.toString()
220
+ `--dialog-theme-${r}-${l}`,
221
+ (i = u[c]) == null ? void 0 : i.toString()
174
222
  );
175
223
  }
176
224
  }
177
225
  );
178
226
  return;
179
227
  }
180
- if (r === "ctaBorderType") {
181
- const c = e[r] === "rounded" ? "24px" : "0";
182
- t.style.setProperty(`--dialog-theme-${o}`, c);
228
+ if (s === "ctaBorderType") {
229
+ const a = e[s] === "rounded" ? "24px" : "0";
230
+ t.style.setProperty(`--dialog-theme-${r}`, a);
183
231
  return;
184
232
  }
185
233
  t.style.setProperty(
186
- `--dialog-theme-${o}`,
187
- e[r].toString()
234
+ `--dialog-theme-${r}`,
235
+ e[s].toString()
188
236
  );
189
237
  }
190
238
  });
191
- }, te = ({ theme: e, children: t }) => (m(() => {
192
- e && ee(e);
193
- }, [e]), /* @__PURE__ */ n(C, { children: t })), Fe = ({
239
+ }, re = ({ theme: e, children: t }) => (f(() => {
240
+ e && oe(e);
241
+ }, [e]), /* @__PURE__ */ o(C, { children: t })), ie = 2, ae = 5, Ze = ({
194
242
  client: e,
195
243
  productId: t,
196
- productTitle: s,
197
- selectedVariantId: r,
198
- enableInput: o = !0
244
+ productTitle: n,
245
+ selectedVariantId: s,
246
+ enableInput: r = !1
199
247
  }) => {
200
- const [c, l] = v(!0), [a, i] = v(
248
+ var g;
249
+ const [a, c] = v(!0), [i, l] = v(
201
250
  void 0
202
251
  );
203
- m(() => {
204
- D({
252
+ f(() => {
253
+ M({
205
254
  method: "react",
206
- version: "2.6.0"
207
- }), K("pdp-block");
255
+ version: "2.8.0"
256
+ }), F("pdp-block");
208
257
  }, []);
209
- const u = y(
210
- () => c ? "" : a == null ? void 0 : a.assistantName,
211
- [a, c]
212
- ), p = y(
213
- () => c ? "" : a == null ? void 0 : a.description,
214
- [a, c]
215
- ), d = y(
216
- () => c ? "" : a == null ? void 0 : a.inputPlaceholder,
217
- [a, c]
218
- ), f = y(
258
+ const u = S(
259
+ () => a ? "" : i == null ? void 0 : i.assistantName,
260
+ [i, a]
261
+ ), p = S(
262
+ () => a ? "" : i == null ? void 0 : i.description,
263
+ [i, a]
264
+ ), d = S(
265
+ () => a ? "" : i == null ? void 0 : i.inputPlaceholder,
266
+ [i, a]
267
+ ), m = S(
219
268
  () => {
220
- var h;
221
- return F((h = e.getLocalizationInformations()) == null ? void 0 : h.languageCode);
269
+ var y;
270
+ return U((y = e.getLocalizationInformations()) == null ? void 0 : y.languageCode);
222
271
  },
223
272
  [e]
224
273
  );
225
- return m(() => {
226
- let h = !0;
274
+ return f(() => {
275
+ let y = !0;
227
276
  return (async () => {
228
- l(!0), i(void 0);
277
+ c(!0), l(void 0);
229
278
  try {
230
- const k = await e.getSuggestions(t);
231
- h && i(k);
232
- } catch (k) {
233
- console.error("error", k);
279
+ const E = await e.getSuggestions(t, {
280
+ limit: ae
281
+ });
282
+ y && l(E);
283
+ } catch (E) {
284
+ console.error("error", E);
234
285
  } finally {
235
- h && l(!1);
286
+ y && c(!1);
236
287
  }
237
288
  })(), () => {
238
- h = !1;
289
+ y = !1;
239
290
  };
240
- }, [e, t]), /* @__PURE__ */ n(te, { theme: e.theme, children: /* @__PURE__ */ g(
291
+ }, [e, t]), /* @__PURE__ */ o(re, { theme: e.theme, children: /* @__PURE__ */ h(
241
292
  "div",
242
293
  {
243
294
  id: "dialog-instant",
244
295
  className: "dialog-block-container",
245
- dir: f,
296
+ dir: m,
246
297
  children: [
247
- /* @__PURE__ */ n(W, { title: u, description: p }),
248
- /* @__PURE__ */ n(
249
- G,
298
+ /* @__PURE__ */ o(G, { title: u, description: p }),
299
+ /* @__PURE__ */ o(
300
+ te,
250
301
  {
251
302
  client: e,
252
- questions: a == null ? void 0 : a.questions,
253
- isLoading: c,
303
+ questions: (g = i == null ? void 0 : i.questions) == null ? void 0 : g.slice(0, ie),
304
+ isLoading: a,
254
305
  productId: t,
255
- productTitle: s,
256
- selectedVariantId: r
306
+ productTitle: n,
307
+ selectedVariantId: s
257
308
  }
258
309
  ),
259
- o && /* @__PURE__ */ n(
260
- J,
310
+ r ? /* @__PURE__ */ o(
311
+ ne,
261
312
  {
262
313
  client: e,
263
314
  placeholder: d,
264
315
  productId: t,
265
- productTitle: s,
266
- selectedVariantId: r
316
+ productTitle: n,
317
+ selectedVariantId: s
318
+ }
319
+ ) : /* @__PURE__ */ o(
320
+ X,
321
+ {
322
+ client: e,
323
+ questions: i == null ? void 0 : i.questions,
324
+ disabled: a,
325
+ productId: t,
326
+ productTitle: n,
327
+ selectedVariantId: s
267
328
  }
268
329
  )
269
330
  ]
270
331
  }
271
332
  ) });
272
- }, re = () => /* @__PURE__ */ n(
333
+ }, le = () => /* @__PURE__ */ o(
273
334
  "svg",
274
335
  {
275
336
  width: 16,
@@ -278,7 +339,7 @@ const W = ({
278
339
  fill: "none",
279
340
  xmlns: "http://www.w3.org/2000/svg",
280
341
  "aria-hidden": "true",
281
- children: /* @__PURE__ */ n(
342
+ children: /* @__PURE__ */ o(
282
343
  "path",
283
344
  {
284
345
  d: "M8 13V3M8 3L3 8M8 3L13 8",
@@ -289,9 +350,9 @@ const W = ({
289
350
  }
290
351
  )
291
352
  }
292
- ), se = "M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z", ne = ({
353
+ ), ce = "M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z", de = ({
293
354
  color: e = "currentColor"
294
- }) => /* @__PURE__ */ n(
355
+ }) => /* @__PURE__ */ o(
295
356
  "svg",
296
357
  {
297
358
  width: 16,
@@ -300,53 +361,53 @@ const W = ({
300
361
  fill: "none",
301
362
  xmlns: "http://www.w3.org/2000/svg",
302
363
  "aria-hidden": "true",
303
- children: /* @__PURE__ */ n("path", { d: se, fill: e })
364
+ children: /* @__PURE__ */ o("path", { d: ce, fill: e })
304
365
  }
305
- ), qe = ({
366
+ ), Xe = ({
306
367
  controller: e,
307
368
  placeholder: t = "Search products...",
308
- autoFocus: s = !1,
309
- submitAriaLabel: r = "Search"
369
+ autoFocus: n = !1,
370
+ submitAriaLabel: s = "Search"
310
371
  }) => {
311
- const [o, c] = v("");
312
- return /* @__PURE__ */ g("form", { className: "dialog-search-bar", role: "search", onSubmit: (a) => {
313
- a.preventDefault(), e.submit(o);
372
+ const [r, a] = v("");
373
+ return /* @__PURE__ */ h("form", { className: "dialog-search-bar", role: "search", onSubmit: (i) => {
374
+ i.preventDefault(), e.submit(r);
314
375
  }, children: [
315
- /* @__PURE__ */ g("div", { className: "dialog-search-bar-field", children: [
316
- /* @__PURE__ */ n("span", { className: "dialog-search-bar-icon", children: /* @__PURE__ */ n(ne, {}) }),
317
- /* @__PURE__ */ n(
376
+ /* @__PURE__ */ h("div", { className: "dialog-search-bar-field", children: [
377
+ /* @__PURE__ */ o("span", { className: "dialog-search-bar-icon", children: /* @__PURE__ */ o(de, {}) }),
378
+ /* @__PURE__ */ o(
318
379
  "input",
319
380
  {
320
381
  type: "text",
321
382
  name: "dialog-search-query",
322
383
  className: "dialog-search-bar-input",
323
- value: o,
384
+ value: r,
324
385
  "aria-label": t,
325
386
  placeholder: t,
326
- autoFocus: s,
327
- onChange: (a) => {
328
- c(a.target.value), e.setQuery(a.target.value);
387
+ autoFocus: n,
388
+ onChange: (i) => {
389
+ a(i.target.value), e.setQuery(i.target.value);
329
390
  }
330
391
  }
331
392
  )
332
393
  ] }),
333
- /* @__PURE__ */ n(
394
+ /* @__PURE__ */ o(
334
395
  "button",
335
396
  {
336
397
  type: "submit",
337
398
  className: "dialog-search-bar-submit",
338
- "aria-label": r,
339
- children: /* @__PURE__ */ n(re, {})
399
+ "aria-label": s,
400
+ children: /* @__PURE__ */ o(le, {})
340
401
  }
341
402
  )
342
403
  ] });
343
- }, oe = (e, t) => {
404
+ }, ue = (e, t) => {
344
405
  try {
345
406
  return new Intl.NumberFormat(t).format(e);
346
407
  } catch {
347
408
  return String(e);
348
409
  }
349
- }, A = {
410
+ }, $ = {
350
411
  en: (e) => ({
351
412
  searching: (t) => `Searching “${t}”…`,
352
413
  noResults: "No matching products",
@@ -358,7 +419,7 @@ const W = ({
358
419
  seeAllLabel: (t) => t === 1 ? "See the result" : `See all ${e(t)} results`,
359
420
  previous: "Previous",
360
421
  next: "Next",
361
- pageOf: (t, s) => `Page ${e(t)} / ${e(s)}`
422
+ pageOf: (t, n) => `Page ${e(t)} / ${e(n)}`
362
423
  }),
363
424
  fr: (e) => ({
364
425
  searching: (t) => `Recherche de « ${t} »…`,
@@ -371,7 +432,7 @@ const W = ({
371
432
  seeAllLabel: (t) => t === 1 ? "Voir le résultat" : `Voir les ${e(t)} résultats`,
372
433
  previous: "Précédent",
373
434
  next: "Suivant",
374
- pageOf: (t, s) => `Page ${e(t)} / ${e(s)}`
435
+ pageOf: (t, n) => `Page ${e(t)} / ${e(n)}`
375
436
  }),
376
437
  de: (e) => ({
377
438
  searching: (t) => `Suche nach „${t}“…`,
@@ -384,7 +445,7 @@ const W = ({
384
445
  seeAllLabel: (t) => t === 1 ? "Das Ergebnis anzeigen" : `Alle ${e(t)} Ergebnisse anzeigen`,
385
446
  previous: "Zurück",
386
447
  next: "Weiter",
387
- pageOf: (t, s) => `Seite ${e(t)} / ${e(s)}`
448
+ pageOf: (t, n) => `Seite ${e(t)} / ${e(n)}`
388
449
  }),
389
450
  es: (e) => ({
390
451
  searching: (t) => `Buscando «${t}»…`,
@@ -397,7 +458,7 @@ const W = ({
397
458
  seeAllLabel: (t) => t === 1 ? "Ver el resultado" : `Ver los ${e(t)} resultados`,
398
459
  previous: "Anterior",
399
460
  next: "Siguiente",
400
- pageOf: (t, s) => `Página ${e(t)} / ${e(s)}`
461
+ pageOf: (t, n) => `Página ${e(t)} / ${e(n)}`
401
462
  }),
402
463
  it: (e) => ({
403
464
  searching: (t) => `Ricerca di “${t}”…`,
@@ -410,123 +471,123 @@ const W = ({
410
471
  seeAllLabel: (t) => t === 1 ? "Vedi il risultato" : `Vedi tutti i ${e(t)} risultati`,
411
472
  previous: "Precedente",
412
473
  next: "Successivo",
413
- pageOf: (t, s) => `Pagina ${e(t)} / ${e(s)}`
474
+ pageOf: (t, n) => `Pagina ${e(t)} / ${e(n)}`
414
475
  })
415
- }, I = (e) => {
416
- var r;
417
- const t = ((r = e == null ? void 0 : e.split("-")[0]) == null ? void 0 : r.toLowerCase()) ?? "en";
418
- return (A[t] ?? A.en)((o) => oe(o, e));
419
- }, M = (e) => e.status !== L.LOADING && e.response !== void 0 && e.response.nbPages > 1, ae = ({
476
+ }, O = (e) => {
477
+ var s;
478
+ const t = ((s = e == null ? void 0 : e.split("-")[0]) == null ? void 0 : s.toLowerCase()) ?? "en";
479
+ return ($[t] ?? $.en)((r) => ue(r, e));
480
+ }, _ = (e) => e.status !== L.LOADING && e.response !== void 0 && e.response.nbPages > 1, he = ({
420
481
  controller: e,
421
482
  state: t,
422
- locale: s
483
+ locale: n
423
484
  }) => {
424
- const r = t.response;
425
- if (r === void 0 || !M(t))
485
+ const s = t.response;
486
+ if (s === void 0 || !_(t))
426
487
  return null;
427
- const o = I(s);
428
- return /* @__PURE__ */ g("nav", { "aria-label": "Search results pages", className: "dialog-search-pagination", children: [
429
- /* @__PURE__ */ n(
488
+ const r = O(n);
489
+ return /* @__PURE__ */ h("nav", { "aria-label": "Search results pages", className: "dialog-search-pagination", children: [
490
+ /* @__PURE__ */ o(
430
491
  "button",
431
492
  {
432
493
  type: "button",
433
- disabled: r.page === 0,
434
- onClick: () => e.setPage(r.page - 1),
435
- children: o.previous
494
+ disabled: s.page === 0,
495
+ onClick: () => e.setPage(s.page - 1),
496
+ children: r.previous
436
497
  }
437
498
  ),
438
- /* @__PURE__ */ n("span", { children: o.pageOf(r.page + 1, r.nbPages) }),
439
- /* @__PURE__ */ n(
499
+ /* @__PURE__ */ o("span", { children: r.pageOf(s.page + 1, s.nbPages) }),
500
+ /* @__PURE__ */ o(
440
501
  "button",
441
502
  {
442
503
  type: "button",
443
- disabled: r.page >= r.nbPages - 1,
444
- onClick: () => e.setPage(r.page + 1),
445
- children: o.next
504
+ disabled: s.page >= s.nbPages - 1,
505
+ onClick: () => e.setPage(s.page + 1),
506
+ children: r.next
446
507
  }
447
508
  )
448
509
  ] });
449
- }, $ = (e) => e.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").replace(/ẞ/gu, "ß").toUpperCase().toLowerCase().replace(/ς/g, "σ"), ie = (e, t) => {
450
- const s = { before: "", match: e, after: "" }, r = $(t.trim());
451
- if (r === "")
452
- return s;
453
- const o = [...e], c = [];
454
- let l = "";
455
- o.forEach((p, d) => {
456
- const f = $(p);
457
- for (let h = 0; h < f.length; h += 1)
458
- c.push(d);
459
- l += f;
510
+ }, D = (e) => e.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").replace(/ẞ/gu, "ß").toUpperCase().toLowerCase().replace(/ς/g, "σ"), ge = (e, t) => {
511
+ const n = { before: "", match: e, after: "" }, s = D(t.trim());
512
+ if (s === "")
513
+ return n;
514
+ const r = [...e], a = [];
515
+ let c = "";
516
+ r.forEach((p, d) => {
517
+ const m = D(p);
518
+ for (let g = 0; g < m.length; g += 1)
519
+ a.push(d);
520
+ c += m;
460
521
  });
461
- const a = l.indexOf(r);
462
- if (a === -1)
463
- return s;
464
- const i = c[a], u = c[a + r.length - 1] + 1;
522
+ const i = c.indexOf(s);
523
+ if (i === -1)
524
+ return n;
525
+ const l = a[i], u = a[i + s.length - 1] + 1;
465
526
  return {
466
- before: o.slice(0, i).join(""),
467
- match: o.slice(i, u).join(""),
468
- after: o.slice(u).join("")
527
+ before: r.slice(0, l).join(""),
528
+ match: r.slice(l, u).join(""),
529
+ after: r.slice(u).join("")
469
530
  };
470
- }, T = ({
531
+ }, H = ({
471
532
  title: e,
472
533
  query: t
473
534
  }) => {
474
- const { before: s, match: r, after: o } = ie(e, t);
475
- return /* @__PURE__ */ g(C, { children: [
476
- s !== "" && /* @__PURE__ */ n("span", { className: "dialog-search-muted", children: s }),
477
- /* @__PURE__ */ n("span", { className: "dialog-search-match", children: r }),
478
- o !== "" && /* @__PURE__ */ n("span", { className: "dialog-search-muted", children: o })
535
+ const { before: n, match: s, after: r } = ge(e, t);
536
+ return /* @__PURE__ */ h(C, { children: [
537
+ n !== "" && /* @__PURE__ */ o("span", { className: "dialog-search-muted", children: n }),
538
+ /* @__PURE__ */ o("span", { className: "dialog-search-match", children: s }),
539
+ r !== "" && /* @__PURE__ */ o("span", { className: "dialog-search-muted", children: r })
479
540
  ] });
480
- }, ce = ({ amount: e, currencyCode: t }, s) => t === void 0 ? new Intl.NumberFormat(s).format(Number(e)) : new Intl.NumberFormat(s, {
541
+ }, pe = ({ amount: e, currencyCode: t }, n) => t === void 0 ? new Intl.NumberFormat(n).format(Number(e)) : new Intl.NumberFormat(n, {
481
542
  style: "currency",
482
543
  currency: t
483
- }).format(Number(e)), le = (e, t) => {
544
+ }).format(Number(e)), me = (e, t) => {
484
545
  if (e === void 0)
485
546
  return "";
486
547
  try {
487
- return ce(e.min, t);
548
+ return pe(e.min, t);
488
549
  } catch {
489
550
  return "";
490
551
  }
491
- }, de = (e) => {
552
+ }, fe = (e) => {
492
553
  try {
493
554
  const { protocol: t } = new URL(e, window.location.href);
494
555
  return t === "http:" || t === "https:" ? e : void 0;
495
556
  } catch {
496
557
  return;
497
558
  }
498
- }, O = (e) => e.url === void 0 || e.url === "" ? void 0 : de(e.url), _ = (e) => e.title ?? e.handle ?? e.objectID, ue = ({
559
+ }, q = (e) => e.url === void 0 || e.url === "" ? void 0 : fe(e.url), B = (e) => e.title ?? e.handle ?? e.objectID, be = ({
499
560
  controller: e,
500
561
  hit: t,
501
- index: s,
502
- locale: r,
503
- query: o = ""
562
+ index: n,
563
+ locale: s,
564
+ query: r = ""
504
565
  }) => {
505
- const c = b(null);
506
- m(() => {
507
- c.current !== null && e.observeResult(c.current, s);
508
- }, [e, t, s]);
509
- const l = (d) => {
510
- const f = d.metaKey || d.ctrlKey || d.shiftKey || d.altKey;
511
- e.selectResult(s, { navigate: !f }) && d.preventDefault();
512
- }, a = (d) => {
513
- d.button === 1 && e.selectResult(s, { navigate: !1 });
514
- }, i = le(t.priceRange, r), u = O(t), p = /* @__PURE__ */ g(C, { children: [
515
- /* @__PURE__ */ n("span", { className: "dialog-search-product-thumb", "aria-hidden": !0, children: t.imageUrl !== void 0 && t.imageUrl !== "" && /* @__PURE__ */ n("img", { src: t.imageUrl, alt: "", loading: "lazy" }) }),
516
- /* @__PURE__ */ n("span", { className: "dialog-search-product-title", children: /* @__PURE__ */ n(T, { title: _(t), query: o }) }),
517
- i !== "" && /* @__PURE__ */ n("span", { className: "dialog-search-product-price", children: i })
566
+ const a = b(null);
567
+ f(() => {
568
+ a.current !== null && e.observeResult(a.current, n);
569
+ }, [e, t, n]);
570
+ const c = (d) => {
571
+ const m = d.metaKey || d.ctrlKey || d.shiftKey || d.altKey;
572
+ e.selectResult(n, { navigate: !m }) && d.preventDefault();
573
+ }, i = (d) => {
574
+ d.button === 1 && e.selectResult(n, { navigate: !1 });
575
+ }, l = me(t.priceRange, s), u = q(t), p = /* @__PURE__ */ h(C, { children: [
576
+ /* @__PURE__ */ o("span", { className: "dialog-search-product-thumb", "aria-hidden": !0, children: t.imageUrl !== void 0 && t.imageUrl !== "" && /* @__PURE__ */ o("img", { src: t.imageUrl, alt: "", loading: "lazy" }) }),
577
+ /* @__PURE__ */ o("span", { className: "dialog-search-product-title", children: /* @__PURE__ */ o(H, { title: B(t), query: r }) }),
578
+ l !== "" && /* @__PURE__ */ o("span", { className: "dialog-search-product-price", children: l })
518
579
  ] });
519
- return /* @__PURE__ */ n("li", { ref: c, className: "dialog-search-card", children: u === void 0 ? /* @__PURE__ */ n("div", { className: "dialog-search-product", children: p }) : /* @__PURE__ */ n(
580
+ return /* @__PURE__ */ o("li", { ref: a, className: "dialog-search-card", children: u === void 0 ? /* @__PURE__ */ o("div", { className: "dialog-search-product", children: p }) : /* @__PURE__ */ o(
520
581
  "a",
521
582
  {
522
583
  className: "dialog-search-product",
523
584
  href: u,
524
- onClick: l,
525
- onAuxClick: a,
585
+ onClick: c,
586
+ onAuxClick: i,
526
587
  children: p
527
588
  }
528
589
  ) });
529
- }, he = () => /* @__PURE__ */ n(
590
+ }, ve = () => /* @__PURE__ */ o(
530
591
  "svg",
531
592
  {
532
593
  width: 16,
@@ -535,9 +596,9 @@ const W = ({
535
596
  fill: "currentColor",
536
597
  xmlns: "http://www.w3.org/2000/svg",
537
598
  "aria-hidden": "true",
538
- children: /* @__PURE__ */ n("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" })
599
+ children: /* @__PURE__ */ o("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" })
539
600
  }
540
- ), ge = () => /* @__PURE__ */ n(
601
+ ), Ce = () => /* @__PURE__ */ o(
541
602
  "svg",
542
603
  {
543
604
  width: 12,
@@ -546,100 +607,100 @@ const W = ({
546
607
  fill: "currentColor",
547
608
  xmlns: "http://www.w3.org/2000/svg",
548
609
  "aria-hidden": "true",
549
- children: /* @__PURE__ */ n("path", { d: "M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z" })
610
+ children: /* @__PURE__ */ o("path", { d: "M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z" })
550
611
  }
551
- ), H = (e) => (e ?? []).flatMap((t) => {
552
- const s = O(t);
553
- return s === void 0 ? [] : [{ collection: t, href: s }];
554
- }), pe = ({
612
+ ), j = (e) => (e ?? []).flatMap((t) => {
613
+ const n = q(t);
614
+ return n === void 0 ? [] : [{ collection: t, href: n }];
615
+ }), ye = ({
555
616
  collections: e,
556
617
  query: t,
557
- messages: s
618
+ messages: n
558
619
  }) => {
559
- const r = H(e);
560
- return r.length === 0 ? null : /* @__PURE__ */ g("aside", { className: "dialog-search-collections", children: [
561
- /* @__PURE__ */ g("div", { className: "dialog-search-section-head", children: [
562
- /* @__PURE__ */ n("p", { className: "dialog-search-label", children: s.collectionsLabel }),
563
- /* @__PURE__ */ n("span", { className: "dialog-search-count", children: s.collectionsCount(r.length) })
620
+ const s = j(e);
621
+ return s.length === 0 ? null : /* @__PURE__ */ h("aside", { className: "dialog-search-collections", children: [
622
+ /* @__PURE__ */ h("div", { className: "dialog-search-section-head", children: [
623
+ /* @__PURE__ */ o("p", { className: "dialog-search-label", children: n.collectionsLabel }),
624
+ /* @__PURE__ */ o("span", { className: "dialog-search-count", children: n.collectionsCount(s.length) })
564
625
  ] }),
565
- /* @__PURE__ */ n("ul", { className: "dialog-search-collection-list", children: r.map(({ collection: o, href: c }) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ g("a", { className: "dialog-search-collection", href: c, children: [
566
- /* @__PURE__ */ n("span", { className: "dialog-search-collection-thumb", "aria-hidden": !0, children: o.imageUrl !== void 0 && o.imageUrl !== "" && /* @__PURE__ */ n("img", { src: o.imageUrl, alt: "", loading: "lazy" }) }),
567
- /* @__PURE__ */ n("span", { className: "dialog-search-collection-title", children: /* @__PURE__ */ n(T, { title: _(o), query: t }) }),
568
- /* @__PURE__ */ n("span", { className: "dialog-search-caret", children: /* @__PURE__ */ n(ge, {}) })
569
- ] }) }, o.objectID)) })
626
+ /* @__PURE__ */ o("ul", { className: "dialog-search-collection-list", children: s.map(({ collection: r, href: a }) => /* @__PURE__ */ o("li", { children: /* @__PURE__ */ h("a", { className: "dialog-search-collection", href: a, children: [
627
+ /* @__PURE__ */ o("span", { className: "dialog-search-collection-thumb", "aria-hidden": !0, children: r.imageUrl !== void 0 && r.imageUrl !== "" && /* @__PURE__ */ o("img", { src: r.imageUrl, alt: "", loading: "lazy" }) }),
628
+ /* @__PURE__ */ o("span", { className: "dialog-search-collection-title", children: /* @__PURE__ */ o(H, { title: B(r), query: t }) }),
629
+ /* @__PURE__ */ o("span", { className: "dialog-search-caret", children: /* @__PURE__ */ o(Ce, {}) })
630
+ ] }) }, r.objectID)) })
570
631
  ] });
571
- }, fe = ({
632
+ }, Se = ({
572
633
  controller: e,
573
634
  response: t,
574
- locale: s,
575
- messages: r
576
- }) => /* @__PURE__ */ g("section", { className: "dialog-search-products", children: [
577
- /* @__PURE__ */ n("div", { className: "dialog-search-section-head", children: /* @__PURE__ */ g("p", { className: "dialog-search-label", children: [
578
- r.productsLabel,
579
- t.nbHits > 0 && /* @__PURE__ */ n("span", { className: "dialog-search-label-count", children: ` · ${r.resultsCount(t.nbHits)}` })
635
+ locale: n,
636
+ messages: s
637
+ }) => /* @__PURE__ */ h("section", { className: "dialog-search-products", children: [
638
+ /* @__PURE__ */ o("div", { className: "dialog-search-section-head", children: /* @__PURE__ */ h("p", { className: "dialog-search-label", children: [
639
+ s.productsLabel,
640
+ t.nbHits > 0 && /* @__PURE__ */ o("span", { className: "dialog-search-label-count", children: ` · ${s.resultsCount(t.nbHits)}` })
580
641
  ] }) }),
581
- /* @__PURE__ */ n("ul", { className: "dialog-search-results", children: t.hits.length === 0 ? /* @__PURE__ */ n("li", { className: "dialog-search-empty", role: "status", children: r.noResults }) : t.hits.map((o, c) => /* @__PURE__ */ n(
582
- ue,
642
+ /* @__PURE__ */ o("ul", { className: "dialog-search-results", children: t.hits.length === 0 ? /* @__PURE__ */ o("li", { className: "dialog-search-empty", role: "status", children: s.noResults }) : t.hits.map((r, a) => /* @__PURE__ */ o(
643
+ be,
583
644
  {
584
645
  controller: e,
585
- hit: o,
586
- index: c,
587
- locale: s,
646
+ hit: r,
647
+ index: a,
648
+ locale: n,
588
649
  query: t.query
589
650
  },
590
- o.objectID
651
+ r.objectID
591
652
  )) })
592
- ] }), S = 8, w = 16, me = 200, be = 1440, ve = (e, t) => e.bottom > 0 && e.top < t, Ce = (e, t) => {
593
- const s = Math.min(
594
- be,
653
+ ] }), k = 8, w = 16, we = 200, Le = 1440, ke = (e, t) => e.bottom > 0 && e.top < t, Ne = (e, t) => {
654
+ const n = Math.min(
655
+ Le,
595
656
  t - 2 * w
596
- ), r = e.left + e.width / 2 - s / 2;
657
+ ), s = e.left + e.width / 2 - n / 2;
597
658
  return { left: Math.min(
598
- Math.max(r, w),
599
- t - w - s
600
- ), width: s };
601
- }, ye = (e, t, s) => {
602
- const r = s - e.bottom - S - w, o = e.top - S - w, c = Ce(e, t);
603
- return r < me && o > r ? {
604
- ...c,
605
- bottom: s - e.top + S,
606
- maxHeight: Math.max(o, 0)
607
- } : {
608
- ...c,
609
- top: e.bottom + S,
659
+ Math.max(s, w),
660
+ t - w - n
661
+ ), width: n };
662
+ }, Ee = (e, t, n) => {
663
+ const s = n - e.bottom - k - w, r = e.top - k - w, a = Ne(e, t);
664
+ return s < we && r > s ? {
665
+ ...a,
666
+ bottom: n - e.top + k,
610
667
  maxHeight: Math.max(r, 0)
668
+ } : {
669
+ ...a,
670
+ top: e.bottom + k,
671
+ maxHeight: Math.max(s, 0)
611
672
  };
612
- }, we = (e) => {
673
+ }, Pe = (e) => {
613
674
  const t = e.trim().replace(/^#/, "");
614
675
  if (!/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t))
615
676
  return;
616
- const s = t.length <= 4 ? [...t].map((r) => r + r).join("") : t;
677
+ const n = t.length <= 4 ? [...t].map((s) => s + s).join("") : t;
617
678
  return [0, 2, 4].map(
618
- (r) => Number.parseInt(s.slice(r, r + 2), 16)
679
+ (s) => Number.parseInt(n.slice(s, s + 2), 16)
619
680
  );
620
- }, Le = (e) => {
681
+ }, Ae = (e) => {
621
682
  const t = /^rgba?\((\d+), (\d+), (\d+)(?:, [\d.]+)?\)$/.exec(e);
622
683
  if (t !== null)
623
684
  return [t[1], t[2], t[3]].map(Number);
624
- }, Se = (e) => {
685
+ }, xe = (e) => {
625
686
  if (typeof document > "u")
626
687
  return;
627
688
  const t = document.createElement("span");
628
689
  if (t.style.color = e, t.style.color === "")
629
690
  return;
630
691
  document.body.appendChild(t);
631
- const s = Le(getComputedStyle(t).color);
632
- return t.remove(), s;
633
- }, Ne = (e) => we(e) ?? Se(e), ke = (e) => {
692
+ const n = Ae(getComputedStyle(t).color);
693
+ return t.remove(), n;
694
+ }, Re = (e) => Pe(e) ?? xe(e), Ie = (e) => {
634
695
  const t = e / 255;
635
696
  return t <= 0.03928 ? t / 12.92 : ((t + 0.055) / 1.055) ** 2.4;
636
- }, B = (e) => {
637
- const t = Ne(e);
697
+ }, z = (e) => {
698
+ const t = Re(e);
638
699
  if (t === void 0)
639
700
  return;
640
- const [s, r, o] = t.map(ke);
641
- return 0.2126 * s + 0.7152 * r + 0.0722 * o;
642
- }, xe = "#181825", Pe = "#ffffff", Re = "straight", P = 0.5, R = {
701
+ const [n, s, r] = t.map(Ie);
702
+ return 0.2126 * n + 0.7152 * s + 0.0722 * r;
703
+ }, $e = "#181825", De = "#ffffff", Me = "straight", A = 0.5, x = {
643
704
  light: {
644
705
  panel: "#ffffff",
645
706
  side: "#fafbfc",
@@ -658,7 +719,7 @@ const W = ({
658
719
  hover: "#242830",
659
720
  thumb: "#2b2f38"
660
721
  }
661
- }, Ee = {
722
+ }, Te = {
662
723
  rectangle: {
663
724
  "r-panel": "4px",
664
725
  "r-item": "4px",
@@ -671,220 +732,220 @@ const W = ({
671
732
  "r-thumb": "8px",
672
733
  "r-btn": "10px"
673
734
  }
674
- }, N = (e) => e === void 0 || e.trim() === "" ? void 0 : e.trim(), Ae = (e) => {
675
- const t = e === void 0 ? void 0 : B(e);
676
- return t === void 0 ? "light" : t < P ? "dark" : "light";
677
- }, $e = (e, t) => {
678
- const s = B(e);
679
- return s === void 0 ? R[t].text : (t === "light" ? s < P : s >= P) ? e : R[t].text;
680
- }, De = (e) => {
681
- const t = Ae(N(e == null ? void 0 : e.backgroundColor)), s = (e == null ? void 0 : e.ctaBorderType) === Re ? "rectangle" : "rectangle-rounded", r = N(e == null ? void 0 : e.primaryColor) ?? xe, o = N(e == null ? void 0 : e.fontFamily), c = {
682
- ...R[t],
683
- ...Ee[s],
684
- primary: r,
685
- accent: $e(r, t),
686
- "cta-text": N(e == null ? void 0 : e.ctaTextColor) ?? Pe,
687
- ...o === void 0 ? {} : { font: o }
735
+ }, N = (e) => e === void 0 || e.trim() === "" ? void 0 : e.trim(), Oe = (e) => {
736
+ const t = e === void 0 ? void 0 : z(e);
737
+ return t === void 0 ? "light" : t < A ? "dark" : "light";
738
+ }, _e = (e, t) => {
739
+ const n = z(e);
740
+ return n === void 0 ? x[t].text : (t === "light" ? n < A : n >= A) ? e : x[t].text;
741
+ }, He = (e) => {
742
+ const t = Oe(N(e == null ? void 0 : e.backgroundColor)), n = (e == null ? void 0 : e.ctaBorderType) === Me ? "rectangle" : "rectangle-rounded", s = N(e == null ? void 0 : e.primaryColor) ?? $e, r = N(e == null ? void 0 : e.fontFamily), a = {
743
+ ...x[t],
744
+ ...Te[n],
745
+ primary: s,
746
+ accent: _e(s, t),
747
+ "cta-text": N(e == null ? void 0 : e.ctaTextColor) ?? De,
748
+ ...r === void 0 ? {} : { font: r }
688
749
  };
689
750
  return Object.fromEntries(
690
- Object.entries(c).map(([l, a]) => [`--dso-${l}`, a])
751
+ Object.entries(a).map(([c, i]) => [`--dso-${c}`, i])
691
752
  );
692
- }, Ie = (e) => {
693
- const t = b(null), [s, r] = v(void 0), [o, c] = v({ width: 0, height: 0 });
694
- return j(() => {
753
+ }, qe = (e) => {
754
+ const t = b(null), [n, s] = v(void 0), [r, a] = v({ width: 0, height: 0 });
755
+ return V(() => {
695
756
  if (!e)
696
757
  return;
697
- const l = () => {
698
- const a = t.current;
699
- if (a === null)
758
+ const c = () => {
759
+ const i = t.current;
760
+ if (i === null)
700
761
  return;
701
- const i = a.previousElementSibling ?? a, { top: u, bottom: p, left: d, width: f } = i.getBoundingClientRect();
702
- c(
703
- (h) => h.width === window.innerWidth && h.height === window.innerHeight ? h : { width: window.innerWidth, height: window.innerHeight }
704
- ), r(
705
- (h) => h !== void 0 && h.top === u && h.bottom === p && h.left === d && h.width === f ? h : { top: u, bottom: p, left: d, width: f }
762
+ const l = i.previousElementSibling ?? i, { top: u, bottom: p, left: d, width: m } = l.getBoundingClientRect();
763
+ a(
764
+ (g) => g.width === window.innerWidth && g.height === window.innerHeight ? g : { width: window.innerWidth, height: window.innerHeight }
765
+ ), s(
766
+ (g) => g !== void 0 && g.top === u && g.bottom === p && g.left === d && g.width === m ? g : { top: u, bottom: p, left: d, width: m }
706
767
  );
707
768
  };
708
- return l(), window.addEventListener("scroll", l, !0), window.addEventListener("resize", l), () => {
709
- window.removeEventListener("scroll", l, !0), window.removeEventListener("resize", l);
769
+ return c(), window.addEventListener("scroll", c, !0), window.addEventListener("resize", c), () => {
770
+ window.removeEventListener("scroll", c, !0), window.removeEventListener("resize", c);
710
771
  };
711
- }, [e]), { anchorRef: t, rect: s, viewport: o };
712
- }, Me = (e, t) => {
713
- const [s, r] = v(!1), o = b(null), c = e.status !== L.IDLE && !s;
714
- return m(() => {
715
- r(!1);
716
- }, [e.query]), m(() => {
717
- if (!c)
772
+ }, [e]), { anchorRef: t, rect: n, viewport: r };
773
+ }, Be = (e, t) => {
774
+ const [n, s] = v(!1), r = b(null), a = e.status !== L.IDLE && !n;
775
+ return f(() => {
776
+ s(!1);
777
+ }, [e.query]), f(() => {
778
+ if (!a)
718
779
  return;
719
- const l = (a) => {
720
- var f, h;
721
- const i = a.target;
722
- if (!(i instanceof Node))
780
+ const c = (i) => {
781
+ var m, g;
782
+ const l = i.target;
783
+ if (!(l instanceof Node))
723
784
  return;
724
- const u = (f = t.current) == null ? void 0 : f.previousElementSibling, p = ((h = o.current) == null ? void 0 : h.contains(i)) ?? !1, d = (u == null ? void 0 : u.contains(i)) ?? !1;
725
- !p && !d && r(!0);
785
+ const u = (m = t.current) == null ? void 0 : m.previousElementSibling, p = ((g = r.current) == null ? void 0 : g.contains(l)) ?? !1, d = (u == null ? void 0 : u.contains(l)) ?? !1;
786
+ !p && !d && s(!0);
726
787
  };
727
- return document.addEventListener("pointerdown", l), () => document.removeEventListener("pointerdown", l);
728
- }, [c, t]), m(() => {
729
- var i;
730
- const l = (i = t.current) == null ? void 0 : i.previousElementSibling;
731
- if (l == null)
788
+ return document.addEventListener("pointerdown", c), () => document.removeEventListener("pointerdown", c);
789
+ }, [a, t]), f(() => {
790
+ var l;
791
+ const c = (l = t.current) == null ? void 0 : l.previousElementSibling;
792
+ if (c == null)
732
793
  return;
733
- const a = () => r(!1);
734
- return l.addEventListener("focusin", a), () => l.removeEventListener("focusin", a);
735
- }, [t]), { isOpen: c, panelRef: o };
736
- }, Te = (e) => e instanceof q ? `Search failed (${e.status}${e.code ? ` ${e.code}` : ""}): ${e.message}` : "Search failed: network error. Check your connection and try again.", Oe = (e, t) => {
737
- var f, h;
738
- const { controller: s, state: r, locale: o, seeAllHref: c } = e, { status: l, response: a } = r;
739
- if (l === L.ERROR)
740
- return /* @__PURE__ */ g("div", { className: "dialog-search-error", children: [
741
- /* @__PURE__ */ n(
794
+ const i = () => s(!1);
795
+ return c.addEventListener("focusin", i), () => c.removeEventListener("focusin", i);
796
+ }, [t]), { isOpen: a, panelRef: r };
797
+ }, je = (e) => e instanceof Q ? `Search failed (${e.status}${e.code ? ` ${e.code}` : ""}): ${e.message}` : "Search failed: network error. Check your connection and try again.", ze = (e, t) => {
798
+ var m, g;
799
+ const { controller: n, state: s, locale: r, seeAllHref: a } = e, { status: c, response: i } = s;
800
+ if (c === L.ERROR)
801
+ return /* @__PURE__ */ h("div", { className: "dialog-search-error", children: [
802
+ /* @__PURE__ */ o(
742
803
  "p",
743
804
  {
744
805
  role: "alert",
745
806
  className: "dialog-search-status dialog-search-status-error",
746
- children: Te(r.error)
807
+ children: je(s.error)
747
808
  }
748
809
  ),
749
- /* @__PURE__ */ n(
810
+ /* @__PURE__ */ o(
750
811
  "button",
751
812
  {
752
813
  type: "button",
753
814
  className: "dialog-search-retry",
754
- onClick: () => s.retry(),
815
+ onClick: () => n.retry(),
755
816
  children: t.retry
756
817
  }
757
818
  )
758
819
  ] });
759
- if (a === void 0)
760
- return /* @__PURE__ */ n("p", { role: "status", className: "dialog-search-status", children: t.searching(r.query) });
761
- const i = ((h = (f = r.sections) == null ? void 0 : f.collections) == null ? void 0 : h.hits) ?? [], u = H(i).length > 0, p = c !== void 0 && a.nbHits > 0, d = !p && M(r);
762
- return /* @__PURE__ */ g(C, { children: [
763
- /* @__PURE__ */ g(
820
+ if (i === void 0)
821
+ return /* @__PURE__ */ o("p", { role: "status", className: "dialog-search-status", children: t.searching(s.query) });
822
+ const l = ((g = (m = s.sections) == null ? void 0 : m.collections) == null ? void 0 : g.hits) ?? [], u = j(l).length > 0, p = a !== void 0 && i.nbHits > 0, d = !p && _(s);
823
+ return /* @__PURE__ */ h(C, { children: [
824
+ /* @__PURE__ */ h(
764
825
  "div",
765
826
  {
766
827
  className: `dialog-search-body${u ? "" : " dialog-search-body--no-collections"}`,
767
828
  children: [
768
- /* @__PURE__ */ n(
769
- pe,
829
+ /* @__PURE__ */ o(
830
+ ye,
770
831
  {
771
- collections: i,
772
- query: a.query,
832
+ collections: l,
833
+ query: i.query,
773
834
  messages: t
774
835
  }
775
836
  ),
776
- /* @__PURE__ */ n(
777
- fe,
837
+ /* @__PURE__ */ o(
838
+ Se,
778
839
  {
779
- controller: s,
780
- response: a,
781
- locale: o,
840
+ controller: n,
841
+ response: i,
842
+ locale: r,
782
843
  messages: t
783
844
  }
784
845
  )
785
846
  ]
786
847
  }
787
848
  ),
788
- (p || d) && /* @__PURE__ */ n("div", { className: "dialog-search-footer", children: p ? /* @__PURE__ */ g("a", { className: "dialog-search-cta", href: c(a.query), children: [
789
- t.seeAllLabel(a.nbHits),
790
- /* @__PURE__ */ n(he, {})
791
- ] }) : /* @__PURE__ */ n(
792
- ae,
849
+ (p || d) && /* @__PURE__ */ o("div", { className: "dialog-search-footer", children: p ? /* @__PURE__ */ h("a", { className: "dialog-search-cta", href: a(i.query), children: [
850
+ t.seeAllLabel(i.nbHits),
851
+ /* @__PURE__ */ o(ve, {})
852
+ ] }) : /* @__PURE__ */ o(
853
+ he,
793
854
  {
794
- controller: s,
795
- state: r,
796
- locale: o
855
+ controller: n,
856
+ state: s,
857
+ locale: r
797
858
  }
798
859
  ) })
799
860
  ] });
800
- }, ze = (e) => {
801
- const { state: t, locale: s, theme: r, layout: o = "list" } = e, c = t.status !== L.IDLE, { anchorRef: l, rect: a, viewport: i } = Ie(c), { isOpen: u, panelRef: p } = Me(t, l), d = I(s), f = y(
802
- () => De(r),
803
- [r]
861
+ }, Ge = (e) => {
862
+ const { state: t, locale: n, theme: s, layout: r = "list" } = e, a = t.status !== L.IDLE, { anchorRef: c, rect: i, viewport: l } = qe(a), { isOpen: u, panelRef: p } = Be(t, c), d = O(n), m = S(
863
+ () => He(s),
864
+ [s]
804
865
  );
805
- return /* @__PURE__ */ g(C, { children: [
806
- /* @__PURE__ */ n("div", { ref: l }),
807
- u && a !== void 0 && ve(a, i.height) && U(
808
- /* @__PURE__ */ n(
866
+ return /* @__PURE__ */ h(C, { children: [
867
+ /* @__PURE__ */ o("div", { ref: c }),
868
+ u && i !== void 0 && ke(i, l.height) && Z(
869
+ /* @__PURE__ */ o(
809
870
  "div",
810
871
  {
811
872
  ref: p,
812
- className: `dialog-search-panel dialog-search-panel--${o}`,
873
+ className: `dialog-search-panel dialog-search-panel--${r}`,
813
874
  style: {
814
- ...ye(a, i.width, i.height),
815
- ...f
875
+ ...Ee(i, l.width, l.height),
876
+ ...m
816
877
  },
817
- children: Oe(e, d)
878
+ children: ze(e, d)
818
879
  }
819
880
  ),
820
881
  document.body
821
882
  )
822
883
  ] });
823
- }, _e = {
884
+ }, Ve = {
824
885
  status: L.IDLE,
825
886
  query: "",
826
887
  page: 0
827
- }, Ue = (e) => {
888
+ }, Ye = (e) => {
828
889
  const t = b(e);
829
890
  t.current = e;
830
- const s = b(void 0), r = x(() => {
831
- if (s.current === void 0) {
832
- const { client: i, surface: u = "search_page", ...p } = t.current;
833
- s.current = z({
834
- search: (d, f) => i.search(d, f),
891
+ const n = b(void 0), s = P(() => {
892
+ if (n.current === void 0) {
893
+ const { client: l, surface: u = "search_page", ...p } = t.current;
894
+ n.current = W({
895
+ search: (d, m) => l.search(d, m),
835
896
  analytics: {
836
897
  surface: u,
837
- trackViewSearchResults: (d) => i.trackViewSearchResults(d),
838
- trackSelectSearchResult: (d) => i.trackSelectSearchResult(d)
898
+ trackViewSearchResults: (d) => l.trackViewSearchResults(d),
899
+ trackSelectSearchResult: (d) => l.trackSelectSearchResult(d)
839
900
  },
840
901
  ...p
841
902
  });
842
903
  }
843
- return s.current;
844
- }, []), o = b(void 0);
845
- o.current ?? (o.current = {
846
- setQuery: (i) => r().setQuery(i),
847
- submit: (i) => r().submit(i),
848
- setPage: (i) => r().setPage(i),
849
- retry: () => r().retry(),
850
- observeResult: (i, u) => r().observeResult(i, u),
851
- selectResult: (i, u) => r().selectResult(i, u),
852
- subscribe: (i) => r().subscribe(i),
853
- getState: () => r().getState(),
904
+ return n.current;
905
+ }, []), r = b(void 0);
906
+ r.current ?? (r.current = {
907
+ setQuery: (l) => s().setQuery(l),
908
+ submit: (l) => s().submit(l),
909
+ setPage: (l) => s().setPage(l),
910
+ retry: () => s().retry(),
911
+ observeResult: (l, u) => s().observeResult(l, u),
912
+ selectResult: (l, u) => s().selectResult(l, u),
913
+ subscribe: (l) => s().subscribe(l),
914
+ getState: () => s().getState(),
854
915
  // Create a replacement on next access after disposal.
855
916
  dispose: () => {
856
- var i;
857
- (i = s.current) == null || i.dispose(), s.current = void 0;
917
+ var l;
918
+ (l = n.current) == null || l.dispose(), n.current = void 0;
858
919
  }
859
- }), m(() => {
860
- D({
920
+ }), f(() => {
921
+ M({
861
922
  method: "react",
862
- version: "2.6.0"
923
+ version: "2.8.0"
863
924
  });
864
- const i = r();
925
+ const l = s();
865
926
  return () => {
866
- i.dispose(), s.current === i && (s.current = void 0);
927
+ l.dispose(), n.current === l && (n.current = void 0);
867
928
  };
868
- }, [r]);
869
- const c = x(
870
- (i) => r().subscribe(i),
871
- [r]
872
- ), l = x(
873
- () => r().getState(),
874
- [r]
875
- ), a = V(
929
+ }, [s]);
930
+ const a = P(
931
+ (l) => s().subscribe(l),
932
+ [s]
933
+ ), c = P(
934
+ () => s().getState(),
935
+ [s]
936
+ ), i = K(
937
+ a,
876
938
  c,
877
- l,
878
- () => _e
939
+ () => Ve
879
940
  );
880
- return { controller: o.current, state: a, theme: e.client.theme };
941
+ return { controller: r.current, state: i, theme: e.client.theme };
881
942
  };
882
943
  export {
883
- J as DialogInput,
884
- Fe as DialogProductBlock,
885
- qe as DialogSearchBar,
886
- ae as DialogSearchPagination,
887
- ue as DialogSearchProductCard,
888
- ze as DialogSearchResults,
889
- Ue as useDialogSearch
944
+ ne as DialogInput,
945
+ Ze as DialogProductBlock,
946
+ Xe as DialogSearchBar,
947
+ he as DialogSearchPagination,
948
+ be as DialogSearchProductCard,
949
+ Ge as DialogSearchResults,
950
+ Ye as useDialogSearch
890
951
  };