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