@gengage/assistant-fe 0.6.39 → 0.6.41

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.
Files changed (33) hide show
  1. package/dist/chat/catalog.d.ts +1 -1
  2. package/dist/chat/components/ChatDrawer.d.ts +9 -2
  3. package/dist/chat/history-storage.d.ts +3 -0
  4. package/dist/chat/panel-manager.d.ts +7 -0
  5. package/dist/chat/runtime.d.ts +3 -0
  6. package/dist/chat/session-persistence.d.ts +2 -0
  7. package/dist/chat/types.d.ts +1 -0
  8. package/dist/chat-runtime.js +1 -1
  9. package/dist/chat.iife.js +36 -36
  10. package/dist/chat.js +1 -1
  11. package/dist/common/indexed-db.d.ts +3 -0
  12. package/dist/{common-DtgbqWSc.js → common-RLXFcoOo.js} +1 -1
  13. package/dist/common.js +5 -5
  14. package/dist/{connection-warning-CW7FlJH7.js → connection-warning-C1LnYGUH.js} +1 -1
  15. package/dist/{fastIntent-BwG6t8RV.js → fastIntent-BivJoy3l.js} +1 -1
  16. package/dist/index.js +10 -10
  17. package/dist/native.iife.js +14 -14
  18. package/dist/qna-runtime.js +1 -1
  19. package/dist/qna.iife.js +7 -7
  20. package/dist/qna.js +1 -1
  21. package/dist/{request-response-cache-DKf9Fcr5.js → request-response-cache-CVgP72eC.js} +459 -436
  22. package/dist/{runtime-CFzh6Ulc.js → runtime-B0aSQBLM.js} +1557 -1497
  23. package/dist/{runtime-ai391bmA.js → runtime-BemZwmk_.js} +3 -3
  24. package/dist/{runtime-CqgTa5_3.js → runtime-xuhF4izk.js} +3 -3
  25. package/dist/{simbut-BXTh-CaK.js → simbut-CJmAHE6w.js} +1 -1
  26. package/dist/simbut.iife.js +1 -1
  27. package/dist/simbut.js +1 -1
  28. package/dist/{simrel-Cv-eTKho.js → simrel-CwuklQwH.js} +1 -1
  29. package/dist/simrel-runtime.js +1 -1
  30. package/dist/simrel.iife.js +32 -32
  31. package/dist/simrel.js +2 -2
  32. package/dist/{widget-base-DOth8kwX.js → widget-base-C3v87X91.js} +1 -1
  33. package/package.json +1 -1
@@ -1,17 +1,17 @@
1
- import { i as X } from "./widget-base-DOth8kwX.js";
1
+ import { i as X } from "./widget-base-C3v87X91.js";
2
2
  var Z = ({ element: e, renderElement: t }) => {
3
3
  if (!e.children || e.children.length === 0) return null;
4
4
  const r = document.createElement("div");
5
- for (const o of e.children) {
6
- const n = t(o);
7
- n && r.appendChild(n);
5
+ for (const n of e.children) {
6
+ const o = t(n);
7
+ o && r.appendChild(o);
8
8
  }
9
9
  return r;
10
10
  };
11
- function mt(e) {
11
+ function _t(e) {
12
12
  const t = document.createElement("div");
13
13
  if (t.className = e.containerClassName, !e.spec.elements[e.spec.root]) return t;
14
- const r = e.unknownRenderer ?? Z, o = (s) => {
14
+ const r = e.unknownRenderer ?? Z, n = (s) => {
15
15
  const i = e.spec.elements[s];
16
16
  if (!i) return null;
17
17
  const a = e.registry[i.type];
@@ -20,63 +20,63 @@ function mt(e) {
20
20
  element: i,
21
21
  spec: e.spec,
22
22
  context: e.context,
23
- renderElement: o
23
+ renderElement: n
24
24
  }) : r({
25
25
  elementId: s,
26
26
  element: i,
27
27
  spec: e.spec,
28
28
  context: e.context,
29
- renderElement: o
29
+ renderElement: n
30
30
  });
31
- }, n = o(e.spec.root);
32
- return n && t.appendChild(n), t;
31
+ }, o = n(e.spec.root);
32
+ return o && t.appendChild(o), t;
33
33
  }
34
- function _t(e, t) {
34
+ function ht(e, t) {
35
35
  if (!t) return e;
36
36
  const r = { ...e };
37
- for (const [o, n] of Object.entries(t))
38
- n && (r[o] = n);
37
+ for (const [n, o] of Object.entries(t))
38
+ o && (r[n] = o);
39
39
  return r;
40
40
  }
41
- function j(e) {
41
+ function B(e) {
42
42
  return typeof e == "object" && e !== null && typeof e.type == "string";
43
43
  }
44
44
  function ee(e) {
45
45
  const t = [];
46
- let r = 0, o = !1, n = !1, s = 0;
46
+ let r = 0, n = !1, o = !1, s = 0;
47
47
  for (let i = 0; i < e.length; i++) {
48
48
  const a = e[i];
49
- if (n) {
50
- n = !1;
49
+ if (o) {
50
+ o = !1;
51
51
  continue;
52
52
  }
53
- if (a === "\\" && o) {
54
- n = !0;
53
+ if (a === "\\" && n) {
54
+ o = !0;
55
55
  continue;
56
56
  }
57
57
  if (a === '"') {
58
- o = !o;
58
+ n = !n;
59
59
  continue;
60
60
  }
61
- o || (a === "{" && r++, a === "}" && (r--, r === 0 && (t.push(e.slice(s, i + 1)), s = i + 1)));
61
+ n || (a === "{" && r++, a === "}" && (r--, r === 0 && (t.push(e.slice(s, i + 1)), s = i + 1)));
62
62
  }
63
63
  return t.length > 0 ? t : [e];
64
64
  }
65
- function B(e, t) {
65
+ function M(e, t) {
66
66
  const r = e.trim();
67
67
  if (!r || r.startsWith(":")) return !1;
68
- const o = r.startsWith("data: ") ? r.slice(6) : r;
69
- if (o === "[DONE]")
68
+ const n = r.startsWith("data: ") ? r.slice(6) : r;
69
+ if (n === "[DONE]")
70
70
  return t.onDone?.(), !0;
71
71
  try {
72
- const n = JSON.parse(o);
73
- return j(n) ? (X("stream", `event: ${n.type}`, n), t.onEvent(n), n.type === "done" ? (t.onDone?.(), !0) : !1) : !1;
72
+ const o = JSON.parse(n);
73
+ return B(o) ? (X("stream", `event: ${o.type}`, o), t.onEvent(o), o.type === "done" ? (t.onDone?.(), !0) : !1) : !1;
74
74
  } catch {
75
- const n = ee(o);
76
- if (n.length > 1) {
77
- for (const s of n) try {
75
+ const o = ee(n);
76
+ if (o.length > 1) {
77
+ for (const s of o) try {
78
78
  const i = JSON.parse(s);
79
- if (!j(i)) continue;
79
+ if (!B(i)) continue;
80
80
  if (t.onEvent(i), i.type === "done")
81
81
  return t.onDone?.(), !0;
82
82
  } catch {
@@ -95,30 +95,30 @@ async function te(e, t) {
95
95
  t.onError?.(/* @__PURE__ */ new Error("Response body is null — streaming not supported"));
96
96
  return;
97
97
  }
98
- const r = e.body.getReader(), o = new TextDecoder("utf-8");
99
- let n = "";
98
+ const r = e.body.getReader(), n = new TextDecoder("utf-8");
99
+ let o = "";
100
100
  const s = t.idleTimeoutMs ?? 6e4, i = /* @__PURE__ */ Symbol("idle-timeout");
101
101
  let a = !1;
102
102
  try {
103
103
  for (; ; ) {
104
104
  const c = r.read();
105
- let p;
106
- const _ = await (s > 0 ? Promise.race([c.then((d) => (clearTimeout(p), d)), new Promise((d) => {
107
- p = setTimeout(() => d(i), s);
105
+ let l;
106
+ const _ = await (s > 0 ? Promise.race([c.then((p) => (clearTimeout(l), p)), new Promise((p) => {
107
+ l = setTimeout(() => p(i), s);
108
108
  })]) : c);
109
109
  if (_ === i) {
110
110
  a = !0, await r.cancel();
111
111
  break;
112
112
  }
113
- const { done: u, value: m } = _;
113
+ const { done: u, value: g } = _;
114
114
  if (u) break;
115
- n += o.decode(m, { stream: !0 });
116
- const f = n.split(`
115
+ o += n.decode(g, { stream: !0 });
116
+ const f = o.split(`
117
117
  `);
118
- n = f.pop() ?? "";
119
- for (const d of f) if (B(d, t)) return;
118
+ o = f.pop() ?? "";
119
+ for (const p of f) if (M(p, t)) return;
120
120
  }
121
- if (n.trim() && B(n, t))
121
+ if (o.trim() && M(o, t))
122
122
  return;
123
123
  } catch (c) {
124
124
  if (c instanceof DOMException && c.name === "AbortError") return;
@@ -128,8 +128,8 @@ async function te(e, t) {
128
128
  }
129
129
  t.onDone?.();
130
130
  }
131
- function ht(e, t, r) {
132
- const o = new AbortController(), n = r.signal ? re([r.signal, o.signal]) : o.signal;
131
+ function bt(e, t, r) {
132
+ const n = new AbortController(), o = r.signal ? re([r.signal, n.signal]) : n.signal;
133
133
  return fetch(e, {
134
134
  method: "POST",
135
135
  headers: {
@@ -137,64 +137,64 @@ function ht(e, t, r) {
137
137
  ...r.headers
138
138
  },
139
139
  body: JSON.stringify(t),
140
- signal: n
140
+ signal: o
141
141
  }).then((s) => te(s, {
142
142
  ...r,
143
- signal: n
143
+ signal: o
144
144
  })).catch((s) => {
145
145
  s instanceof DOMException && s.name === "AbortError" || r.onError?.(s instanceof Error ? s : new Error(String(s)));
146
- }), o;
146
+ }), n;
147
147
  }
148
148
  function re(e) {
149
149
  const t = new AbortController(), r = [];
150
- for (const o of e) {
151
- if (o.aborted)
152
- return t.abort(o.reason), t.signal;
153
- const n = () => t.abort(o.reason);
154
- o.addEventListener("abort", n, { once: !0 }), r.push(() => o.removeEventListener("abort", n));
150
+ for (const n of e) {
151
+ if (n.aborted)
152
+ return t.abort(n.reason), t.signal;
153
+ const o = () => t.abort(n.reason);
154
+ n.addEventListener("abort", o, { once: !0 }), r.push(() => n.removeEventListener("abort", o));
155
155
  }
156
156
  return t.signal.addEventListener("abort", () => {
157
- for (const o of r) o();
157
+ for (const n of r) n();
158
158
  }, { once: !0 }), t.signal;
159
159
  }
160
- var M = 3, oe = (e, t) => {
160
+ var z = 3, ne = (e, t) => {
161
161
  const r = e.replace(/\s+/g, " ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g, "");
162
162
  if (!r) return "";
163
- const o = t?.stripLeadingStopWords ? r.replace(/^(?:daha|için)\s+/i, "").trim() : r;
164
- return o ? o.split(/\s+/).slice(0, 3).join(" ").trim() : "";
165
- }, C = (e, t) => e ? e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map((r) => oe(r, t)).filter(Boolean) : [];
166
- function ne(e) {
167
- const t = (e.display_keywords ?? []).flatMap((n) => C(n, { stripLeadingStopWords: !0 })), r = t.filter((n, s) => t.indexOf(n) === s);
168
- if (r.length > 0) return r.slice(0, M);
169
- const o = [...C(e.chosen_attribute, { stripLeadingStopWords: !0 }), ...C(e.short_name)];
170
- return o.filter((n, s) => o.indexOf(n) === s).slice(0, M);
163
+ const n = t?.stripLeadingStopWords ? r.replace(/^(?:daha|için)\s+/i, "").trim() : r;
164
+ return n ? n.split(/\s+/).slice(0, 3).join(" ").trim() : "";
165
+ }, N = (e, t) => e ? e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map((r) => ne(r, t)).filter(Boolean) : [];
166
+ function oe(e) {
167
+ const t = (e.display_keywords ?? []).flatMap((o) => N(o, { stripLeadingStopWords: !0 })), r = t.filter((o, s) => t.indexOf(o) === s);
168
+ if (r.length > 0) return r.slice(0, z);
169
+ const n = [...N(e.chosen_attribute, { stripLeadingStopWords: !0 }), ...N(e.short_name)];
170
+ return n.filter((o, s) => n.indexOf(o) === s).slice(0, z);
171
171
  }
172
172
  function se(e) {
173
- return ne(e).join(" • ");
173
+ return oe(e).join(" • ");
174
174
  }
175
175
  function ie(e) {
176
176
  return e === "beauty_consulting" || e === "account_expert";
177
177
  }
178
- function I(...e) {
178
+ function E(...e) {
179
179
  for (const t of e) {
180
180
  if (typeof t != "string") continue;
181
181
  const r = t.trim();
182
182
  if (r.length > 0) return r;
183
183
  }
184
184
  }
185
- function D(e) {
185
+ function T(e) {
186
186
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0).map((t) => t.trim()) : [];
187
187
  }
188
- function z(e) {
189
- const t = { ...e }, r = I(t.sku), o = D(t.group_skus);
190
- if (r ? t.sku = r : delete t.sku, o.length > 0 ? t.group_skus = o : delete t.group_skus, r || o.length > 0) delete t.image_url;
188
+ function I(e) {
189
+ const t = { ...e }, r = E(t.sku), n = T(t.group_skus);
190
+ if (r ? t.sku = r : delete t.sku, n.length > 0 ? t.group_skus = n : delete t.group_skus, r || n.length > 0) delete t.image_url;
191
191
  else {
192
- const n = I(t.image_url);
193
- n ? t.image_url = n : delete t.image_url;
192
+ const o = E(t.image_url);
193
+ o ? t.image_url = o : delete t.image_url;
194
194
  }
195
195
  return t;
196
196
  }
197
- function bt(e) {
197
+ function kt(e) {
198
198
  if (typeof e.type != "string") return null;
199
199
  if (ae(e)) return e;
200
200
  const t = e;
@@ -220,17 +220,17 @@ function bt(e) {
220
220
  case "panelLoading":
221
221
  return ke(t);
222
222
  case "similarLoading":
223
- return Ae(t);
223
+ return Se(t);
224
224
  case "redirect":
225
- return we(t);
225
+ return Ae(t);
226
226
  case "error":
227
- return Se(t);
227
+ return we(t);
228
228
  case "dummy":
229
229
  return xe(t);
230
230
  case "launcherAction":
231
231
  return Pe(t);
232
232
  case "text":
233
- return O(t);
233
+ return v(t);
234
234
  case "productItem":
235
235
  return Ee(t);
236
236
  case "text_image":
@@ -244,30 +244,30 @@ function bt(e) {
244
244
  case "aiProductGroupings":
245
245
  return Ne(t);
246
246
  case "aiSuggestedSearches":
247
- return Le(t);
247
+ return Oe(t);
248
248
  case "prosAndCons":
249
249
  return Ce(t);
250
250
  case "getGroundingReview":
251
- return Oe(t);
252
- case "voice":
253
251
  return ve(t);
252
+ case "voice":
253
+ return je(t);
254
254
  case "visitorDataResponse":
255
255
  return Ie(t);
256
256
  case "productListPreview":
257
257
  return qe();
258
258
  case "groupList":
259
- return je(t);
259
+ return Be(t);
260
260
  case "formGetInfo":
261
261
  case "formTestDrive":
262
262
  case "formServiceRequest":
263
263
  case "launchFormPage":
264
- return Be(t);
264
+ return Me(t);
265
265
  case "launcherContent":
266
- return ze(t);
266
+ return He(t);
267
267
  case "handoff":
268
- return Me(t);
268
+ return ze(t);
269
269
  case "uiSpec":
270
- return We(t);
270
+ return Je(t);
271
271
  default:
272
272
  return null;
273
273
  }
@@ -283,8 +283,8 @@ function ae(e) {
283
283
  case "ui_spec": {
284
284
  const r = e.widget;
285
285
  if (r !== "chat" && r !== "qna" && r !== "simrel") return !1;
286
- const o = b(e.spec);
287
- return o ? typeof o.root == "string" && b(o.elements) !== null : !1;
286
+ const n = b(e.spec);
287
+ return n ? typeof n.root == "string" && b(n.elements) !== null : !1;
288
288
  }
289
289
  case "action": {
290
290
  const r = b(e.action);
@@ -299,55 +299,55 @@ function ae(e) {
299
299
  }
300
300
  }
301
301
  function ce(e) {
302
- const t = l(e.payload.text, e.payload.plain_text) ?? "", r = l(e.payload.plain_text, e.payload.text) ?? t;
302
+ const t = d(e.payload.text, e.payload.plain_text) ?? "", r = d(e.payload.plain_text, e.payload.text) ?? t;
303
303
  if (e.payload.is_error) return {
304
304
  type: "error",
305
305
  code: "BACKEND_ERROR",
306
306
  message: r || "Backend returned an error"
307
307
  };
308
- const o = {
308
+ const n = {
309
309
  type: "text_chunk",
310
310
  content: t,
311
311
  final: !0
312
- }, n = e.payload.product_mentions;
313
- Array.isArray(n) && n.length > 0 && (o.productMentions = n.filter((c) => typeof c == "object" && c !== null && typeof c.sku == "string" && typeof c.short_name == "string"));
312
+ }, o = e.payload.product_mentions;
313
+ Array.isArray(o) && o.length > 0 && (n.productMentions = o.filter((c) => typeof c == "object" && c !== null && typeof c.sku == "string" && typeof c.short_name == "string"));
314
314
  const s = e.payload.sku_to_product_item;
315
- s && typeof s == "object" && !Array.isArray(s) && (o.skuToProductItem = s);
315
+ s && typeof s == "object" && !Array.isArray(s) && (n.skuToProductItem = s);
316
316
  const i = e.payload.conversation_mode;
317
- typeof i == "string" && i && (o.conversationMode = i);
317
+ typeof i == "string" && i && (n.conversationMode = i);
318
318
  const a = e.payload.render_hint;
319
- return typeof a == "string" && a && (o.renderHint = a), e.payload.kvkk === !0 && (o.kvkk = !0), o;
319
+ return typeof a == "string" && a && (n.renderHint = a), e.payload.kvkk === !0 && (n.kvkk = !0), n;
320
320
  }
321
321
  function ue(e) {
322
322
  return V((e.payload.actions ?? []).map((t) => {
323
- const r = l(t.title) ?? "", o = k(t.requestDetails, r), n = o ? {
323
+ const r = d(t.title) ?? "", n = k(t.requestDetails, r), o = n ? {
324
324
  label: r,
325
- action: o
325
+ action: n
326
326
  } : null;
327
- return n ? (typeof t.icon == "string" && (n.icon = t.icon), typeof t.image == "string" && (n.image = t.image), n) : null;
328
- }).filter(E), "chat");
327
+ return o ? (typeof t.icon == "string" && (o.icon = t.icon), typeof t.image == "string" && (o.image = t.image), o) : null;
328
+ }).filter(C), "chat");
329
329
  }
330
330
  function de(e) {
331
331
  const t = Array.isArray(e.payload.grouped_assignment) ? e.payload.grouped_assignment : [], r = (Array.isArray(e.payload.style_variations) ? e.payload.style_variations : []).map((a) => {
332
- const c = l(a.style_label);
332
+ const c = d(a.style_label);
333
333
  if (!c) return null;
334
- const p = l(a.style_mood), _ = l(a.image_url ?? void 0), u = (Array.isArray(a.product_list) ? a.product_list : []).map((f) => {
335
- const d = b(f);
336
- return d ? v(b(d.product_detail) ?? b(d.product) ?? d) : null;
337
- }).filter(E), m = Array.isArray(a.recommendation_groups) ? a.recommendation_groups.map((f) => ({
338
- label: l(f.label) ?? "",
339
- reason: l(f.reason) ?? "",
340
- skus: Array.isArray(f.skus) ? f.skus.filter((d) => typeof d == "string" && d.trim().length > 0) : []
334
+ const l = d(a.style_mood), _ = d(a.image_url ?? void 0), u = (Array.isArray(a.product_list) ? a.product_list : []).map((f) => {
335
+ const p = b(f);
336
+ return p ? j(b(p.product_detail) ?? b(p.product) ?? p) : null;
337
+ }).filter(C), g = Array.isArray(a.recommendation_groups) ? a.recommendation_groups.map((f) => ({
338
+ label: d(f.label) ?? "",
339
+ reason: d(f.reason) ?? "",
340
+ skus: Array.isArray(f.skus) ? f.skus.filter((p) => typeof p == "string" && p.trim().length > 0) : []
341
341
  })) : [];
342
342
  return {
343
343
  style_label: c,
344
- style_mood: p ?? "",
344
+ style_mood: l ?? "",
345
345
  ..._ ? { image_url: _ } : {},
346
346
  ...typeof a.status == "string" ? { status: a.status } : {},
347
347
  product_list: u,
348
- recommendation_groups: m
348
+ recommendation_groups: g
349
349
  };
350
- }).filter(E), o = e.payload.product_list ?? [], n = ie(e.payload.source) && r.length > 0 ? r[0].product_list : null, s = n ? Ue(n, "chat") : t.length > 0 ? He(t, o, "chat") ?? N(o, "chat") : N(o, "chat");
350
+ }).filter(C), n = e.payload.product_list ?? [], o = ie(e.payload.source) && r.length > 0 ? r[0].product_list : null, s = o ? Ge(o, "chat") : t.length > 0 ? Ue(t, n, "chat") ?? R(n, "chat") : R(n, "chat");
351
351
  s.panelHint = "panel";
352
352
  const i = s.spec.elements[s.spec.root];
353
353
  if (i) {
@@ -363,8 +363,8 @@ function de(e) {
363
363
  }
364
364
  function le(e) {
365
365
  const t = e.payload.productDetails;
366
- if (!t) return $e("chat");
367
- const r = S(t);
366
+ if (!t) return Fe("chat");
367
+ const r = w(t);
368
368
  return {
369
369
  type: "ui_spec",
370
370
  widget: "chat",
@@ -382,7 +382,7 @@ function le(e) {
382
382
  };
383
383
  }
384
384
  function pe(e) {
385
- const t = N(e.payload.similarProducts ?? [], "chat"), r = t.spec.elements[t.spec.root];
385
+ const t = R(e.payload.similarProducts ?? [], "chat"), r = t.spec.elements[t.spec.root];
386
386
  return r && (r.props = {
387
387
  ...r.props,
388
388
  similarsAppend: !0
@@ -392,7 +392,7 @@ function pe(e) {
392
392
  };
393
393
  }
394
394
  function fe(e) {
395
- const t = e.payload.multiple_product_details ?? [], r = e.payload, o = {
395
+ const t = e.payload.multiple_product_details ?? [], r = e.payload, n = {
396
396
  key_differences: r.key_differences,
397
397
  recommended_choice: r.recommended_choice,
398
398
  recommended_choice_sku: r.recommended_choice_sku,
@@ -403,22 +403,22 @@ function fe(e) {
403
403
  winner_product: r.winner_product,
404
404
  winner_hits: r.winner_hits,
405
405
  ...e.payload.product_comparison_framework ?? {}
406
- }, n = e.payload.table, s = e.payload.features_list, i = [];
407
- for (const g of t) {
408
- const h = S(g);
406
+ }, o = e.payload.table, s = e.payload.features_list, i = [];
407
+ for (const m of t) {
408
+ const h = w(m);
409
409
  i.push(h);
410
410
  }
411
- const a = ye(n, i, o, s);
411
+ const a = ye(o, i, n, s);
412
412
  let c;
413
- o?.recommended_choice_sku ? c = o.recommended_choice_sku : o?.winner_product && o.winner_product.length > 0 && (c = o.winner_product[0]?.product_detail?.sku ?? o.winner_product[0]?.sku);
414
- const p = c ? i.find((g) => g.sku === c) ?? i[0] : i[0], _ = [];
415
- if (Array.isArray(o?.key_differences))
416
- for (const g of o.key_differences) typeof g == "string" && _.push(g);
417
- const u = W(o?.special_considerations), m = o?.recommended_choice, f = o?.winner_hits, d = {};
418
- for (const g of i) {
419
- const h = g.sku;
420
- h && (d[h] = {
421
- title: g.name ?? h,
413
+ n?.recommended_choice_sku ? c = n.recommended_choice_sku : n?.winner_product && n.winner_product.length > 0 && (c = n.winner_product[0]?.product_detail?.sku ?? n.winner_product[0]?.sku);
414
+ const l = c ? i.find((m) => m.sku === c) ?? i[0] : i[0], _ = [];
415
+ if (Array.isArray(n?.key_differences))
416
+ for (const m of n.key_differences) typeof m == "string" && _.push(m);
417
+ const u = W(n?.special_considerations), g = n?.recommended_choice, f = n?.winner_hits, p = {};
418
+ for (const m of i) {
419
+ const h = m.sku;
420
+ h && (p[h] = {
421
+ title: m.name ?? h,
422
422
  type: "launchSingleProduct",
423
423
  payload: { sku: h }
424
424
  });
@@ -427,9 +427,9 @@ function fe(e) {
427
427
  products: i,
428
428
  attributes: a,
429
429
  highlights: _,
430
- productActions: d
430
+ productActions: p
431
431
  };
432
- return p && (y.recommended = p), u.length > 0 && (y.specialCases = u), m && (y.recommendedText = m), f && (y.winnerHits = f), typeof o?.key_differences == "string" && (y.keyDifferencesHtml = o.key_differences), o?.special_considerations && (y.specialConsiderations = o.special_considerations), {
432
+ return l && (y.recommended = l), u.length > 0 && (y.specialCases = u), g && (y.recommendedText = g), f && (y.winnerHits = f), typeof n?.key_differences == "string" && (y.keyDifferencesHtml = n.key_differences), n?.special_considerations && (y.specialConsiderations = n.special_considerations), {
433
433
  type: "ui_spec",
434
434
  widget: "chat",
435
435
  spec: {
@@ -442,47 +442,47 @@ function fe(e) {
442
442
  panelHint: "panel"
443
443
  };
444
444
  }
445
- function ye(e, t, r, o) {
445
+ function ye(e, t, r, n) {
446
446
  if (!e) return [];
447
- const n = Object.entries(e);
448
- if (n.length === 0) return [];
449
- const s = n[0]?.[1];
447
+ const o = Object.entries(e);
448
+ if (o.length === 0) return [];
449
+ const s = o[0]?.[1];
450
450
  if (Array.isArray(s)) {
451
- const u = r.criteria_view ?? r.criteria_view_short ?? {}, m = r.compared_field_names ?? Object.keys(e), f = [];
452
- for (const d of m) {
453
- const y = e[d];
451
+ const u = r.criteria_view ?? r.criteria_view_short ?? {}, g = r.compared_field_names ?? Object.keys(e), f = [];
452
+ for (const p of g) {
453
+ const y = e[p];
454
454
  if (!y || !Array.isArray(y)) continue;
455
- const g = u[d] ?? d;
455
+ const m = u[p] ?? p;
456
456
  f.push({
457
- label: g,
457
+ label: m,
458
458
  values: y.map((h) => typeof h == "string" ? h : String(h ?? ""))
459
459
  });
460
460
  }
461
461
  return f;
462
462
  }
463
- const i = e, a = t.map((u) => String(u.sku ?? "")).filter((u) => u.length > 0), c = r.criteria_view ?? r.criteria_view_short ?? {}, p = (o && o.length > 0 ? o : r.compared_field_names && r.compared_field_names.length > 0 ? r.compared_field_names : ge(i)).filter((u) => u !== "name" && u !== "name_short" && !u.endsWith("_short")), _ = [];
464
- for (const u of p) {
465
- const m = a.map((d) => {
466
- const y = i[d];
463
+ const i = e, a = t.map((u) => String(u.sku ?? "")).filter((u) => u.length > 0), c = r.criteria_view ?? r.criteria_view_short ?? {}, l = (n && n.length > 0 ? n : r.compared_field_names && r.compared_field_names.length > 0 ? r.compared_field_names : ge(i)).filter((u) => u !== "name" && u !== "name_short" && !u.endsWith("_short")), _ = [];
464
+ for (const u of l) {
465
+ const g = a.map((p) => {
466
+ const y = i[p];
467
467
  if (!y || typeof y != "object") return "";
468
- const g = y[`${u}_short`], h = y[u];
469
- return me(g ?? h);
468
+ const m = y[`${u}_short`], h = y[u];
469
+ return me(m ?? h);
470
470
  });
471
- if (m.every((d) => d.length === 0)) continue;
471
+ if (g.every((p) => p.length === 0)) continue;
472
472
  const f = c[u] ?? u;
473
473
  _.push({
474
474
  label: f,
475
- values: m
475
+ values: g
476
476
  });
477
477
  }
478
478
  return _;
479
479
  }
480
480
  function ge(e) {
481
481
  const t = [], r = /* @__PURE__ */ new Set();
482
- for (const o of Object.values(e))
483
- if (!(!o || typeof o != "object"))
484
- for (const n of Object.keys(o))
485
- r.has(n) || (r.add(n), t.push(n));
482
+ for (const n of Object.values(e))
483
+ if (!(!n || typeof n != "object"))
484
+ for (const o of Object.keys(n))
485
+ r.has(o) || (r.add(o), t.push(o));
486
486
  return t;
487
487
  }
488
488
  function me(e) {
@@ -529,7 +529,7 @@ function ke(e) {
529
529
  }
530
530
  };
531
531
  }
532
- function Ae(e) {
532
+ function Se(e) {
533
533
  return {
534
534
  type: "metadata",
535
535
  sessionId: "",
@@ -542,8 +542,8 @@ function Ae(e) {
542
542
  }
543
543
  };
544
544
  }
545
- function we(e) {
546
- const t = l(e.payload.url);
545
+ function Ae(e) {
546
+ const t = d(e.payload.url);
547
547
  return t ? {
548
548
  type: "action",
549
549
  action: {
@@ -557,15 +557,15 @@ function we(e) {
557
557
  model: "",
558
558
  meta: {
559
559
  redirect: e.payload,
560
- redirectTarget: l(e.payload.to)
560
+ redirectTarget: d(e.payload.to)
561
561
  }
562
562
  };
563
563
  }
564
- function Se(e) {
564
+ function we(e) {
565
565
  return {
566
566
  type: "error",
567
567
  code: "BACKEND_ERROR",
568
- message: l(e.payload?.text, e.payload?.message, e.payload?.error) ?? "Backend returned an error"
568
+ message: d(e.payload?.text, e.payload?.message, e.payload?.error) ?? "Backend returned an error"
569
569
  };
570
570
  }
571
571
  function xe(e) {
@@ -579,26 +579,26 @@ function xe(e) {
579
579
  function Pe(e) {
580
580
  const t = e.payload ?? {};
581
581
  if (Array.isArray(t.action_list)) {
582
- const n = { action_list: t.action_list }, s = typeof t.type == "string" ? t.type : void 0, i = typeof t.theme == "string" ? t.theme : void 0;
583
- return s !== void 0 && (n.type = s), i !== void 0 && (n.theme = i), K({
582
+ const o = { action_list: t.action_list }, s = typeof t.type == "string" ? t.type : void 0, i = typeof t.theme == "string" ? t.theme : void 0;
583
+ return s !== void 0 && (o.type = s), i !== void 0 && (o.theme = i), K({
584
584
  type: "quick_qna",
585
- payload: n
585
+ payload: o
586
586
  });
587
587
  }
588
588
  const r = b(t.action);
589
589
  if (r) {
590
- const n = { action: r }, s = typeof t.text == "string" ? t.text : void 0, i = typeof t.image_url == "string" ? t.image_url : void 0, a = typeof t.theme == "string" ? t.theme : void 0;
591
- return s !== void 0 && (n.text = s), i !== void 0 && (n.image_url = i), a !== void 0 && (n.theme = a), F({
590
+ const o = { action: r }, s = typeof t.text == "string" ? t.text : void 0, i = typeof t.image_url == "string" ? t.image_url : void 0, a = typeof t.theme == "string" ? t.theme : void 0;
591
+ return s !== void 0 && (o.text = s), i !== void 0 && (o.image_url = i), a !== void 0 && (o.theme = a), F({
592
592
  type: "text_image",
593
- payload: n
593
+ payload: o
594
594
  });
595
595
  }
596
- const o = typeof t.text == "string" ? t.text : "";
597
- if (o) {
598
- const n = { text: o }, s = typeof t.type == "string" ? t.type : void 0, i = typeof t.theme == "string" ? t.theme : void 0, a = b(t.payload) ?? void 0;
599
- return s !== void 0 && (n.type = s), a !== void 0 && (n.payload = a), i !== void 0 && (n.theme = i), O({
596
+ const n = typeof t.text == "string" ? t.text : "";
597
+ if (n) {
598
+ const o = { text: n }, s = typeof t.type == "string" ? t.type : void 0, i = typeof t.theme == "string" ? t.theme : void 0, a = b(t.payload) ?? void 0;
599
+ return s !== void 0 && (o.type = s), a !== void 0 && (o.payload = a), i !== void 0 && (o.theme = i), v({
600
600
  type: "text",
601
- payload: n
601
+ payload: o
602
602
  });
603
603
  }
604
604
  return {
@@ -608,8 +608,8 @@ function Pe(e) {
608
608
  meta: { launcherAction: t }
609
609
  };
610
610
  }
611
- function O(e) {
612
- const t = { text: l(e.payload.text) ?? "" };
611
+ function v(e) {
612
+ const t = { text: d(e.payload.text) ?? "" };
613
613
  return typeof e.payload.theme == "string" && (t.theme = e.payload.theme), e.payload.payload !== void 0 && (t.payload = e.payload.payload), {
614
614
  type: "ui_spec",
615
615
  widget: "qna",
@@ -623,46 +623,46 @@ function O(e) {
623
623
  };
624
624
  }
625
625
  function Ee(e) {
626
- return Ge(e.payload, "qna");
626
+ return $e(e.payload, "qna");
627
627
  }
628
628
  function F(e) {
629
- const t = l(e.payload.text) ?? "", r = k(e.payload.action, t);
629
+ const t = d(e.payload.text) ?? "", r = k(e.payload.action, t);
630
630
  if (r) {
631
- const n = {
631
+ const o = {
632
632
  label: t || r.title,
633
633
  action: r
634
634
  };
635
- return typeof e.payload.image_url == "string" && (n.image = e.payload.image_url), typeof e.payload.theme == "string" && (n.theme = e.payload.theme), {
635
+ return typeof e.payload.image_url == "string" && (o.image = e.payload.image_url), typeof e.payload.theme == "string" && (o.theme = e.payload.theme), {
636
636
  type: "ui_spec",
637
637
  widget: "qna",
638
638
  spec: {
639
639
  root: "root",
640
640
  elements: { root: {
641
641
  type: "ActionButton",
642
- props: n
642
+ props: o
643
643
  } }
644
644
  }
645
645
  };
646
646
  }
647
- const o = { text: t };
648
- return typeof e.payload.theme == "string" && (o.theme = e.payload.theme), O({
647
+ const n = { text: t };
648
+ return typeof e.payload.theme == "string" && (n.theme = e.payload.theme), v({
649
649
  type: "text",
650
- payload: o
650
+ payload: n
651
651
  });
652
652
  }
653
653
  function K(e) {
654
654
  return V((e.payload.action_list ?? []).map((t) => {
655
- const r = l(t.title) ?? "", o = k(t.requestDetails, r), n = o ? {
655
+ const r = d(t.title) ?? "", n = k(t.requestDetails, r), o = n ? {
656
656
  label: r,
657
- action: o
657
+ action: n
658
658
  } : null;
659
- return n ? (typeof t.icon == "string" && (n.icon = t.icon), typeof t.image == "string" && (n.image = t.image), n) : null;
660
- }).filter(E), "qna");
659
+ return o ? (typeof t.icon == "string" && (o.icon = t.icon), typeof t.image == "string" && (o.image = t.image), o) : null;
660
+ }).filter(C), "qna");
661
661
  }
662
662
  function Te(e) {
663
663
  const t = { reviews: (e.payload.reviews ?? []).map((r) => {
664
- const o = {};
665
- return typeof r.review_class == "string" && (o.review_class = r.review_class), typeof r.review_text == "string" && (o.review_text = r.review_text), (typeof r.review_rating == "string" || typeof r.review_rating == "number") && (o.review_rating = r.review_rating), typeof r.review_tag == "string" && (o.review_tag = r.review_tag), o;
664
+ const n = {};
665
+ return typeof r.review_class == "string" && (n.review_class = r.review_class), typeof r.review_text == "string" && (n.review_text = r.review_text), (typeof r.review_rating == "string" || typeof r.review_rating == "number") && (n.review_rating = r.review_rating), typeof r.review_tag == "string" && (n.review_tag = r.review_tag), n;
666
666
  }) };
667
667
  return typeof e.payload.sku == "string" && (t.sku = e.payload.sku), {
668
668
  type: "ui_spec",
@@ -700,13 +700,13 @@ function Ie(e) {
700
700
  }
701
701
  function De(e) {
702
702
  const t = e.payload.product_suggestions ?? [], r = [];
703
- for (let o = 0; o < t.length; o++) {
704
- const n = t[o];
705
- if (!n) continue;
706
- const s = Fe(n);
703
+ for (let n = 0; n < t.length; n++) {
704
+ const o = t[n];
705
+ if (!o) continue;
706
+ const s = Ke(o);
707
707
  if (!s) continue;
708
- const i = { product: s }, a = k(n.requestDetails, s.name);
709
- a && (i.action = a), typeof n.role == "string" && (i.role = n.role), typeof n.reason == "string" && (i.reason = n.reason), typeof n.review_highlight == "string" && (i.reviewHighlight = n.review_highlight), Array.isArray(n.labels) && (i.labels = n.labels), typeof n.expert_quality_score == "number" && (i.expertQualityScore = n.expert_quality_score), r.push(i);
708
+ const i = { product: s }, a = k(o.requestDetails, s.name);
709
+ a && (i.action = a), typeof o.role == "string" && (i.role = o.role), typeof o.reason == "string" && (i.reason = o.reason), typeof o.review_highlight == "string" && (i.reviewHighlight = o.review_highlight), Array.isArray(o.labels) && (i.labels = o.labels), typeof o.expert_quality_score == "number" && (i.expertQualityScore = o.expert_quality_score), r.push(i);
710
710
  }
711
711
  return r.length === 0 ? {
712
712
  type: "metadata",
@@ -726,27 +726,27 @@ function De(e) {
726
726
  };
727
727
  }
728
728
  function Ne(e) {
729
- const t = e.payload.product_groupings ?? [], r = [], o = [];
730
- for (let n = 0; n < t.length; n++) {
731
- const s = t[n];
729
+ const t = e.payload.product_groupings ?? [], r = [], n = [];
730
+ for (let o = 0; o < t.length; o++) {
731
+ const s = t[o];
732
732
  if (!s) continue;
733
- const i = l(s.name) ?? "", a = l(s.description), c = l(s.highlight), p = Array.isArray(s.labels) ? W(s.labels) : [], _ = l(s.sku, s.repr_sku), u = l(s.image, s.repr_image), m = Re(s, i, _), f = (Array.isArray(s.group_products) ? s.group_products : []).map((g) => {
734
- const h = b(g);
735
- return h ? v(h) : null;
736
- }).filter(E), d = u ?? l(...f.map((g) => g.imageUrl));
733
+ const i = d(s.name) ?? "", a = d(s.description), c = d(s.highlight), l = Array.isArray(s.labels) ? W(s.labels) : [], _ = d(s.sku, s.repr_sku), u = d(s.image, s.repr_image), g = Re(s, i, _), f = (Array.isArray(s.group_products) ? s.group_products : []).map((m) => {
734
+ const h = b(m);
735
+ return h ? j(h) : null;
736
+ }).filter(C), p = u ?? d(...f.map((m) => m.imageUrl));
737
737
  if (i && f.length > 0) {
738
- const g = {
738
+ const m = {
739
739
  groupName: i,
740
740
  products: f
741
741
  };
742
- d && (g.image = d), a && (g.description = a), c && (g.highlight = c), p.length > 0 && (g.labels = p), r.push(g);
742
+ p && (m.image = p), a && (m.description = a), c && (m.highlight = c), l.length > 0 && (m.labels = l), r.push(m);
743
743
  }
744
- if (!m) continue;
744
+ if (!g) continue;
745
745
  const y = {
746
746
  name: i,
747
- action: m
747
+ action: g
748
748
  };
749
- p.length > 0 && (y.labels = p), u !== void 0 && (y.image = u), o.push(y);
749
+ l.length > 0 && (y.labels = l), u !== void 0 && (y.image = u), n.push(y);
750
750
  }
751
751
  return r.length > 0 ? {
752
752
  type: "ui_spec",
@@ -759,7 +759,7 @@ function Ne(e) {
759
759
  } }
760
760
  },
761
761
  panelHint: "panel"
762
- } : o.length === 0 ? {
762
+ } : n.length === 0 ? {
763
763
  type: "metadata",
764
764
  sessionId: "",
765
765
  model: "",
@@ -771,54 +771,77 @@ function Ne(e) {
771
771
  root: "root",
772
772
  elements: { root: {
773
773
  type: "AIGroupingCards",
774
- props: { entries: o }
774
+ props: { entries: n }
775
775
  } }
776
776
  }
777
777
  };
778
778
  }
779
779
  function Re(e, t, r) {
780
- const o = b(e.requestDetails);
781
- if (o) {
782
- if (o.type !== "findSimilar") return k(o, t);
783
- const i = { ...b(o.payload) ?? {} };
784
- r && !I(i.sku) && (i.sku = r);
785
- const a = D(e.group_skus);
780
+ const n = b(e.requestDetails);
781
+ if (n) {
782
+ if (n.type !== "findSimilar") return k(n, t);
783
+ const i = { ...b(n.payload) ?? {} };
784
+ r && !E(i.sku) && (i.sku = r);
785
+ const a = T(e.group_skus);
786
786
  return a.length > 0 && (i.group_skus = a), k({
787
- ...o,
788
- payload: z(i)
787
+ ...n,
788
+ payload: I(i)
789
789
  }, t);
790
790
  }
791
- const n = {};
792
- r && (n.sku = r);
793
- const s = D(e.group_skus);
794
- return s.length > 0 && (n.group_skus = s), Object.keys(n).length === 0 ? null : k({
791
+ const o = {};
792
+ r && (o.sku = r);
793
+ const s = T(e.group_skus);
794
+ return s.length > 0 && (o.group_skus = s), Object.keys(o).length === 0 ? null : k({
795
795
  type: "findSimilar",
796
- payload: z(n)
796
+ payload: I(o)
797
+ }, t);
798
+ }
799
+ function Le(e, t) {
800
+ const r = b(e.requestDetails), n = b(r?.payload), o = d(e.detailed_user_message), s = e.group_skus && Array.isArray(e.group_skus) ? T(e.group_skus) : T(n?.group_skus), i = d(e.sku, e.representative_product_sku, n?.sku);
801
+ if (r?.type === "findSimilar") {
802
+ const c = { ...n ?? {} };
803
+ return i && (c.sku = i), s.length > 0 && (c.group_skus = s), o && (c.input = o, E(c.text) || (c.text = o)), c.is_search_suggestion = 1, k({
804
+ ...r,
805
+ payload: I(c)
806
+ }, t);
807
+ }
808
+ if (i) {
809
+ const c = {
810
+ sku: i,
811
+ is_search_suggestion: 1
812
+ };
813
+ return s.length > 0 && (c.group_skus = s), o && (c.input = o, c.text = o), k({
814
+ type: "findSimilar",
815
+ payload: I(c)
816
+ }, t);
817
+ }
818
+ const a = {
819
+ ...n ?? {},
820
+ is_suggested_text: 1,
821
+ is_search_suggestion: 1
822
+ };
823
+ return o && !E(a.text) && (a.text = o), s.length > 0 && (a.group_skus = s), k(r?.type === "inputText" ? {
824
+ ...r,
825
+ payload: a
826
+ } : {
827
+ type: "inputText",
828
+ payload: a
797
829
  }, t);
798
830
  }
799
- function Le(e) {
831
+ function Oe(e) {
800
832
  const t = e.payload.suggested_searches ?? [], r = [];
801
- for (let o = 0; o < t.length; o++) {
802
- const n = t[o];
803
- if (!n) continue;
804
- const s = l(n.short_name, n.chosen_attribute, n.detailed_user_message) ?? `Search ${o + 1}`, i = {}, a = l(n.detailed_user_message);
805
- a && (i.text = a);
806
- const c = b(b(n.requestDetails)?.payload), p = c?.group_skus;
807
- n.group_skus && Array.isArray(n.group_skus) ? i.group_skus = n.group_skus : Array.isArray(p) && (i.group_skus = p.filter((h) => typeof h == "string"));
808
- const _ = l(n.sku, n.representative_product_sku, c?.sku);
809
- _ && (i.sku = _), i.is_suggested_text = 1;
810
- const u = {
811
- type: "inputText",
812
- payload: i
813
- }, m = k(n.requestDetails, s), f = m?.type === "findSimilar" && typeof i.text == "string" ? k(u, s) : m ?? k(u, s);
814
- if (!f) continue;
815
- const d = {
833
+ for (let n = 0; n < t.length; n++) {
834
+ const o = t[n];
835
+ if (!o) continue;
836
+ const s = d(o.short_name, o.chosen_attribute, o.detailed_user_message) ?? `Search ${n + 1}`, i = Le(o, s);
837
+ if (!i) continue;
838
+ const a = {
816
839
  shortName: s,
817
- action: f
818
- }, y = l(n.detailed_user_message);
819
- y && y !== s && (d.detailedMessage = y);
820
- const g = se(n);
821
- g && g !== s && g !== (y ?? "") && (d.whyDifferent = g), typeof n.image == "string" && (d.image = n.image), r.push(d);
840
+ action: i
841
+ }, c = d(o.detailed_user_message);
842
+ c && c !== s && (a.detailedMessage = c);
843
+ const l = se(o);
844
+ l && l !== s && l !== (c ?? "") && (a.whyDifferent = l), typeof o.image == "string" && (a.image = o.image), r.push(a);
822
845
  }
823
846
  return r.length === 0 ? {
824
847
  type: "metadata",
@@ -837,23 +860,23 @@ function Le(e) {
837
860
  }
838
861
  };
839
862
  }
840
- function Oe(e) {
841
- const t = e.payload, r = k(t.requestDetails ?? t.request_details, l(t.review_count, t.reviewCount, t.text, t.title) ?? "Show product reviews");
863
+ function ve(e) {
864
+ const t = e.payload, r = k(t.requestDetails ?? t.request_details, d(t.review_count, t.reviewCount, t.text, t.title) ?? "Show product reviews");
842
865
  if (!r) return {
843
866
  type: "metadata",
844
867
  sessionId: "",
845
868
  model: "",
846
869
  meta: { groundingReview: t }
847
870
  };
848
- const o = { action: r };
849
- return t.title && (o.title = t.title), t.text && (o.text = t.text), t.review_count ? o.reviewCount = t.review_count : typeof t.reviewCount == "string" && t.reviewCount.trim() && (o.reviewCount = t.reviewCount), {
871
+ const n = { action: r };
872
+ return t.title && (n.title = t.title), t.text && (n.text = t.text), t.review_count ? n.reviewCount = t.review_count : typeof t.reviewCount == "string" && t.reviewCount.trim() && (n.reviewCount = t.reviewCount), {
850
873
  type: "ui_spec",
851
874
  widget: "chat",
852
875
  spec: {
853
876
  root: "root",
854
877
  elements: { root: {
855
878
  type: "GroundingReviewCard",
856
- props: o
879
+ props: n
857
880
  } }
858
881
  }
859
882
  };
@@ -866,7 +889,7 @@ function qe() {
866
889
  meta: { analyzeAnimation: !0 }
867
890
  };
868
891
  }
869
- function ve(e) {
892
+ function je(e) {
870
893
  return {
871
894
  type: "metadata",
872
895
  sessionId: "",
@@ -874,21 +897,21 @@ function ve(e) {
874
897
  meta: { voice: e.payload }
875
898
  };
876
899
  }
877
- function je(e) {
900
+ function Be(e) {
878
901
  const t = e.payload.group_list ?? [], r = [];
879
- for (const n of t) {
880
- const s = n.group_name ?? "", i = (n.product_list ?? []).map(S);
902
+ for (const o of t) {
903
+ const s = o.group_name ?? "", i = (o.product_list ?? []).map(w);
881
904
  r.push({
882
905
  groupName: s,
883
906
  products: i
884
907
  });
885
908
  }
886
- const o = [];
887
- for (const n of e.payload.filter_tags ?? []) {
888
- const s = n.title ?? "";
909
+ const n = [];
910
+ for (const o of e.payload.filter_tags ?? []) {
911
+ const s = o.title ?? "";
889
912
  if (!s) continue;
890
- const i = k(n.requestDetails, s), a = { title: s };
891
- i && (a.action = i), o.push(a);
913
+ const i = k(o.requestDetails, s), a = { title: s };
914
+ i && (a.action = i), n.push(a);
892
915
  }
893
916
  return {
894
917
  type: "ui_spec",
@@ -899,14 +922,14 @@ function je(e) {
899
922
  type: "CategoriesContainer",
900
923
  props: {
901
924
  groups: r,
902
- filterTags: o
925
+ filterTags: n
903
926
  }
904
927
  } }
905
928
  },
906
929
  panelHint: "panel"
907
930
  };
908
931
  }
909
- function Be(e) {
932
+ function Me(e) {
910
933
  return {
911
934
  type: "metadata",
912
935
  sessionId: "",
@@ -917,7 +940,7 @@ function Be(e) {
917
940
  }
918
941
  };
919
942
  }
920
- function Me(e) {
943
+ function ze(e) {
921
944
  const t = {};
922
945
  return typeof e.payload?.summary == "string" && (t.summary = e.payload.summary), Array.isArray(e.payload?.products_discussed) && (t.products_discussed = e.payload.products_discussed), typeof e.payload?.user_sentiment == "string" && (t.user_sentiment = e.payload.user_sentiment), {
923
946
  type: "ui_spec",
@@ -931,7 +954,7 @@ function Me(e) {
931
954
  }
932
955
  };
933
956
  }
934
- function ze(e) {
957
+ function He(e) {
935
958
  return {
936
959
  type: "metadata",
937
960
  sessionId: "",
@@ -943,23 +966,23 @@ function q(e, t) {
943
966
  const r = {
944
967
  product: e,
945
968
  index: t
946
- }, o = e, n = typeof o.sku == "string" ? o.sku : void 0;
947
- return n && (r.action = {
948
- title: typeof o.name == "string" ? o.name : "",
969
+ }, n = e, o = typeof n.sku == "string" ? n.sku : void 0;
970
+ return o && (r.action = {
971
+ title: typeof n.name == "string" ? n.name : "",
949
972
  type: "launchSingleProduct",
950
- payload: { sku: n }
973
+ payload: { sku: o }
951
974
  }), {
952
975
  type: "ProductCard",
953
976
  props: r
954
977
  };
955
978
  }
956
979
  function V(e, t) {
957
- const r = {}, o = [];
958
- for (let n = 0; n < e.length; n++) {
959
- const s = e[n];
980
+ const r = {}, n = [];
981
+ for (let o = 0; o < e.length; o++) {
982
+ const s = e[o];
960
983
  if (!s) continue;
961
- const i = `action-${n}`;
962
- o.push(i);
984
+ const i = `action-${o}`;
985
+ n.push(i);
963
986
  const a = {
964
987
  label: s.label,
965
988
  action: s.action
@@ -971,14 +994,14 @@ function V(e, t) {
971
994
  }
972
995
  return r.root = {
973
996
  type: "ActionButtons",
974
- props: { buttons: e.map((n) => {
997
+ props: { buttons: e.map((o) => {
975
998
  const s = {
976
- label: n.label,
977
- action: n.action
999
+ label: o.label,
1000
+ action: o.action
978
1001
  };
979
- return n.image !== void 0 && (s.image = n.image), n.description !== void 0 && (s.description = n.description), n.icon !== void 0 && (s.icon = n.icon), s;
1002
+ return o.image !== void 0 && (s.image = o.image), o.description !== void 0 && (s.description = o.description), o.icon !== void 0 && (s.icon = o.icon), s;
980
1003
  }) },
981
- children: o
1004
+ children: n
982
1005
  }, {
983
1006
  type: "ui_spec",
984
1007
  widget: t,
@@ -988,18 +1011,18 @@ function V(e, t) {
988
1011
  }
989
1012
  };
990
1013
  }
991
- function N(e, t) {
992
- const r = {}, o = [];
993
- for (let n = 0; n < e.length; n++) {
994
- const s = e[n];
1014
+ function R(e, t) {
1015
+ const r = {}, n = [];
1016
+ for (let o = 0; o < e.length; o++) {
1017
+ const s = e[o];
995
1018
  if (!s) continue;
996
- const i = S(s), a = `product-${n}`;
997
- o.push(a), r[a] = q(i, n);
1019
+ const i = w(s), a = `product-${o}`;
1020
+ n.push(a), r[a] = q(i, o);
998
1021
  }
999
1022
  return r.root = {
1000
1023
  type: "ProductGrid",
1001
1024
  props: { layout: "grid" },
1002
- children: o
1025
+ children: n
1003
1026
  }, {
1004
1027
  type: "ui_spec",
1005
1028
  widget: t,
@@ -1009,22 +1032,22 @@ function N(e, t) {
1009
1032
  }
1010
1033
  };
1011
1034
  }
1012
- function He(e, t, r) {
1013
- const o = /* @__PURE__ */ new Map();
1014
- for (const p of t)
1015
- p?.sku && o.set(p.sku, p);
1016
- if (o.size === 0) return null;
1017
- const n = /* @__PURE__ */ new Set(), s = {}, i = [], a = [];
1035
+ function Ue(e, t, r) {
1036
+ const n = /* @__PURE__ */ new Map();
1037
+ for (const l of t)
1038
+ l?.sku && n.set(l.sku, l);
1039
+ if (n.size === 0) return null;
1040
+ const o = /* @__PURE__ */ new Set(), s = {}, i = [], a = [];
1018
1041
  let c = 0;
1019
- for (let p = 0; p < e.length; p++) {
1020
- const _ = e[p], u = l(_?.title) ?? "", m = Array.isArray(_?.skus) ? _.skus : [], f = [];
1021
- for (let d = 0; d < m.length; d++) {
1022
- const y = typeof m[d] == "string" ? m[d].trim() : "";
1023
- if (!y || n.has(y)) continue;
1024
- const g = o.get(y);
1025
- if (!g) continue;
1026
- n.add(y);
1027
- const h = `product-${p}-${d}`, Y = S(g);
1042
+ for (let l = 0; l < e.length; l++) {
1043
+ const _ = e[l], u = d(_?.title) ?? "", g = Array.isArray(_?.skus) ? _.skus : [], f = [];
1044
+ for (let p = 0; p < g.length; p++) {
1045
+ const y = typeof g[p] == "string" ? g[p].trim() : "";
1046
+ if (!y || o.has(y)) continue;
1047
+ const m = n.get(y);
1048
+ if (!m) continue;
1049
+ o.add(y);
1050
+ const h = `product-${l}-${p}`, Y = w(m);
1028
1051
  i.push(h), f.push(h), s[h] = q(Y, c), c += 1;
1029
1052
  }
1030
1053
  f.length > 0 && a.push({
@@ -1032,7 +1055,7 @@ function He(e, t, r) {
1032
1055
  children: f
1033
1056
  });
1034
1057
  }
1035
- return a.length === 0 || n.size < o.size ? null : (s.root = {
1058
+ return a.length === 0 || o.size < n.size ? null : (s.root = {
1036
1059
  type: "ProductGrid",
1037
1060
  props: {
1038
1061
  layout: "grouped",
@@ -1048,18 +1071,18 @@ function He(e, t, r) {
1048
1071
  }
1049
1072
  });
1050
1073
  }
1051
- function Ue(e, t) {
1052
- const r = {}, o = [];
1053
- for (let n = 0; n < e.length; n++) {
1054
- const s = e[n];
1074
+ function Ge(e, t) {
1075
+ const r = {}, n = [];
1076
+ for (let o = 0; o < e.length; o++) {
1077
+ const s = e[o];
1055
1078
  if (!s) continue;
1056
- const i = `product-${n}`;
1057
- o.push(i), r[i] = q(s, n);
1079
+ const i = `product-${o}`;
1080
+ n.push(i), r[i] = q(s, o);
1058
1081
  }
1059
1082
  return r.root = {
1060
1083
  type: "ProductGrid",
1061
1084
  props: { layout: "grid" },
1062
- children: o
1085
+ children: n
1063
1086
  }, {
1064
1087
  type: "ui_spec",
1065
1088
  widget: t,
@@ -1069,7 +1092,7 @@ function Ue(e, t) {
1069
1092
  }
1070
1093
  };
1071
1094
  }
1072
- function Ge(e, t) {
1095
+ function $e(e, t) {
1073
1096
  return {
1074
1097
  type: "ui_spec",
1075
1098
  widget: t,
@@ -1078,14 +1101,14 @@ function Ge(e, t) {
1078
1101
  elements: { root: {
1079
1102
  type: "ProductCard",
1080
1103
  props: {
1081
- product: S(e),
1104
+ product: w(e),
1082
1105
  index: 0
1083
1106
  }
1084
1107
  } }
1085
1108
  }
1086
1109
  };
1087
1110
  }
1088
- function $e(e) {
1111
+ function Fe(e) {
1089
1112
  return {
1090
1113
  type: "ui_spec",
1091
1114
  widget: e,
@@ -1099,60 +1122,60 @@ function $e(e) {
1099
1122
  }
1100
1123
  };
1101
1124
  }
1102
- function Fe(e) {
1103
- const t = l(e.sku), r = l(e.short_name), o = { ...b(e.product_item) ?? e }, n = l(e.discount_reason, e.discountReason);
1104
- return n && !l(o.discount_reason, o.discountReason) && (o.discount_reason = n), v(o, t, r);
1125
+ function Ke(e) {
1126
+ const t = d(e.sku), r = d(e.short_name), n = { ...b(e.product_item) ?? e }, o = d(e.discount_reason, e.discountReason);
1127
+ return o && !d(n.discount_reason, n.discountReason) && (n.discount_reason = o), j(n, t, r);
1105
1128
  }
1106
- function v(e, t, r) {
1107
- const o = l(e.sku, t), n = l(e.name, r);
1108
- if (!o || !n) return null;
1129
+ function j(e, t, r) {
1130
+ const n = d(e.sku, t), o = d(e.name, r);
1131
+ if (!n || !o) return null;
1109
1132
  const s = {
1110
- sku: o,
1111
- name: n
1112
- }, i = l(e.brand);
1133
+ sku: n,
1134
+ name: o
1135
+ }, i = d(e.brand);
1113
1136
  i && (s.brand = i);
1114
- const a = l(e.url);
1137
+ const a = d(e.url);
1115
1138
  a && (s.url = a);
1116
- const c = Ke(e.images);
1139
+ const c = Ve(e.images);
1117
1140
  if (c.length > 0) s.images = c;
1118
1141
  else {
1119
- const y = l(e.image, e.image_url, e.imageUrl);
1142
+ const y = d(e.image, e.image_url, e.imageUrl);
1120
1143
  y && (s.images = [y]);
1121
1144
  }
1122
- const p = x(e.price_discounted);
1123
- p !== void 0 && (s.price_discounted = p);
1145
+ const l = x(e.price_discounted);
1146
+ l !== void 0 && (s.price_discounted = l);
1124
1147
  const _ = x(e.price);
1125
1148
  _ !== void 0 && (s.price = _);
1126
1149
  const u = x(e.rating);
1127
1150
  u !== void 0 && (s.rating = u);
1128
- const m = x(e.review_count) ?? x(e.reviewCount);
1129
- m !== void 0 && (s.review_count = m);
1130
- const f = l(e.cart_code, e.cartCode);
1151
+ const g = x(e.review_count) ?? x(e.reviewCount);
1152
+ g !== void 0 && (s.review_count = g);
1153
+ const f = d(e.cart_code, e.cartCode);
1131
1154
  f && (s.cart_code = f), typeof e.in_stock == "boolean" && (s.in_stock = e.in_stock), typeof e.inStock == "boolean" && (s.in_stock = e.inStock);
1132
- const d = l(e.discount_reason, e.discountReason);
1133
- return d && (s.discount_reason = d), S(s);
1155
+ const p = d(e.discount_reason, e.discountReason);
1156
+ return p && (s.discount_reason = p), w(s);
1134
1157
  }
1135
1158
  function k(e, t) {
1136
1159
  const r = b(e);
1137
1160
  if (!r) return null;
1138
- const o = r.type;
1139
- if (typeof o != "string" || o.length === 0) return null;
1140
- const n = {
1141
- title: t || o,
1142
- type: o
1161
+ const n = r.type;
1162
+ if (typeof n != "string" || n.length === 0) return null;
1163
+ const o = {
1164
+ title: t || n,
1165
+ type: n
1143
1166
  };
1144
- return r.payload !== void 0 && (n.payload = r.payload), n;
1167
+ return r.payload !== void 0 && (o.payload = r.payload), o;
1145
1168
  }
1146
1169
  function b(e) {
1147
1170
  return !e || typeof e != "object" || Array.isArray(e) ? null : e;
1148
1171
  }
1149
- function l(...e) {
1172
+ function d(...e) {
1150
1173
  for (const t of e) if (typeof t == "string") {
1151
1174
  const r = t.trim();
1152
1175
  if (r.length > 0) return r;
1153
1176
  }
1154
1177
  }
1155
- function Ke(e) {
1178
+ function Ve(e) {
1156
1179
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.length > 0) : [];
1157
1180
  }
1158
1181
  function W(e) {
@@ -1171,10 +1194,10 @@ function x(e) {
1171
1194
  if (Number.isFinite(r)) return r;
1172
1195
  }
1173
1196
  }
1174
- function E(e) {
1197
+ function C(e) {
1175
1198
  return e != null;
1176
1199
  }
1177
- var Ve = /* @__PURE__ */ new Set([
1200
+ var We = /* @__PURE__ */ new Set([
1178
1201
  "sku",
1179
1202
  "name",
1180
1203
  "brand",
@@ -1200,35 +1223,35 @@ var Ve = /* @__PURE__ */ new Set([
1200
1223
  "facet_hits",
1201
1224
  "promotions"
1202
1225
  ]);
1203
- function S(e) {
1204
- const t = e.price_discounted != null && e.price_discounted > 0, r = t ? e.price_discounted : e.price, o = t && e.price != null ? e.price : void 0;
1205
- let n;
1206
- o != null && r != null && o > 0 ? n = Math.round((o - r) / o * 100) : e.price_discount_rate != null && e.price_discount_rate > 0 && (n = e.price_discount_rate);
1207
- const s = l(e.brand), i = l(e.name) ?? e.sku, a = s && !i.toLowerCase().startsWith(s.toLowerCase()) ? `${s} ${i}` : i, c = {
1226
+ function w(e) {
1227
+ const t = e.price_discounted != null && e.price_discounted > 0, r = t ? e.price_discounted : e.price, n = t && e.price != null ? e.price : void 0;
1228
+ let o;
1229
+ n != null && r != null && n > 0 ? o = Math.round((n - r) / n * 100) : e.price_discount_rate != null && e.price_discount_rate > 0 && (o = e.price_discount_rate);
1230
+ const s = d(e.brand), i = d(e.name) ?? e.sku, a = s && !i.toLowerCase().startsWith(s.toLowerCase()) ? `${s} ${i}` : i, c = {
1208
1231
  sku: e.sku,
1209
1232
  name: a,
1210
- url: l(e.url) ?? ""
1211
- }, p = e.images?.[0];
1212
- p && (c.imageUrl = p), e.images && e.images.length > 1 && (c.images = e.images), r != null && r > 0 && (c.price = String(r)), o != null && o > 0 && (c.originalPrice = String(o)), n !== void 0 && (c.discountPercent = n), s !== void 0 && (c.brand = s), e.rating !== void 0 && (c.rating = e.rating), e.review_count !== void 0 && (c.reviewCount = e.review_count), e.cart_code !== void 0 && (c.cartCode = e.cart_code), e.in_stock !== void 0 && (c.inStock = e.in_stock), e.variants && e.variants.length > 0 && (c.variants = e.variants), e.discount_reason !== void 0 && (c.discountReason = e.discount_reason), e.promotions && e.promotions.length > 0 && (c.promotions = e.promotions), e.description !== void 0 && (c.description = e.description), e.description_html !== void 0 && (c.descriptionHtml = e.description_html), e.features && e.features.length > 0 && (c.features = e.features), e.specifications !== void 0 && (c.specifications = e.specifications), e.facet_hits && (c.facetHits = e.facet_hits), e.category_names && e.category_names.length > 0 && (c.categoryNames = e.category_names), e.short_name !== void 0 && (c.shortName = e.short_name);
1233
+ url: d(e.url) ?? ""
1234
+ }, l = e.images?.[0];
1235
+ l && (c.imageUrl = l), e.images && e.images.length > 1 && (c.images = e.images), r != null && r > 0 && (c.price = String(r)), n != null && n > 0 && (c.originalPrice = String(n)), o !== void 0 && (c.discountPercent = o), s !== void 0 && (c.brand = s), e.rating !== void 0 && (c.rating = e.rating), e.review_count !== void 0 && (c.reviewCount = e.review_count), e.cart_code !== void 0 && (c.cartCode = e.cart_code), e.in_stock !== void 0 && (c.inStock = e.in_stock), e.variants && e.variants.length > 0 && (c.variants = e.variants), e.discount_reason !== void 0 && (c.discountReason = e.discount_reason), e.promotions && e.promotions.length > 0 && (c.promotions = e.promotions), e.description !== void 0 && (c.description = e.description), e.description_html !== void 0 && (c.descriptionHtml = e.description_html), e.features && e.features.length > 0 && (c.features = e.features), e.specifications !== void 0 && (c.specifications = e.specifications), e.facet_hits && (c.facetHits = e.facet_hits), e.category_names && e.category_names.length > 0 && (c.categoryNames = e.category_names), e.short_name !== void 0 && (c.shortName = e.short_name);
1213
1236
  const _ = e, u = {};
1214
- let m = !1;
1215
- for (const f of Object.keys(_)) Ve.has(f) || (u[f] = _[f], m = !0);
1216
- return m && (c.extras = u), c;
1237
+ let g = !1;
1238
+ for (const f of Object.keys(_)) We.has(f) || (u[f] = _[f], g = !0);
1239
+ return g && (c.extras = u), c;
1217
1240
  }
1218
- function kt(e) {
1219
- return e.results.map(S);
1241
+ function St(e) {
1242
+ return e.results.map(w);
1220
1243
  }
1221
1244
  function At(e) {
1222
1245
  return e.product_groupings.map((t) => {
1223
1246
  const r = {
1224
1247
  name: t.name,
1225
- products: (t.group_products ?? []).map(S)
1248
+ products: (t.group_products ?? []).map(w)
1226
1249
  };
1227
1250
  return t.highlight !== void 0 && (r.highlight = t.highlight), r;
1228
1251
  });
1229
1252
  }
1230
- function We(e) {
1231
- const t = e.payload.type, { type: r, ...o } = e.payload;
1253
+ function Je(e) {
1254
+ const t = e.payload.type, { type: r, ...n } = e.payload;
1232
1255
  return {
1233
1256
  type: "ui_spec",
1234
1257
  widget: "chat",
@@ -1236,56 +1259,56 @@ function We(e) {
1236
1259
  root: "root",
1237
1260
  elements: { root: {
1238
1261
  type: t,
1239
- props: o
1262
+ props: n
1240
1263
  } }
1241
1264
  }
1242
1265
  };
1243
1266
  }
1244
- var Je = {
1267
+ var Qe = {
1245
1268
  process_action: "/process_action",
1246
1269
  launcher_action: "/launcher_action",
1247
1270
  similar_products: "/similar_products",
1248
1271
  product_groupings: "/product_groupings"
1249
1272
  };
1250
- function Qe(e) {
1273
+ function Ye(e) {
1251
1274
  if (e === void 0) throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");
1252
1275
  const t = e.trim();
1253
1276
  return t === "" ? "" : t.replace(/\/+$/, "");
1254
1277
  }
1255
1278
  function wt(e, t) {
1256
- return `${Qe(t?.middlewareUrl)}/chat${Je[e]}`;
1257
- }
1258
- var Ye = 7200 * 1e3, J = 200, Xe = 5 * 1024 * 1024, Ze = "gengage_request_response_cache", et = 1, w = "responses", tt = /* @__PURE__ */ new Set(["addToCart", "like"]), A = /* @__PURE__ */ new Map(), H = null;
1259
- async function St(e, t = {}, r = {}) {
1260
- const o = rt(e, t);
1261
- if (!o) return fetch(e, t);
1262
- const n = Date.now(), s = await it(o, n);
1263
- if (s) return ut(s);
1279
+ return `${Ye(t?.middlewareUrl)}/chat${Qe[e]}`;
1280
+ }
1281
+ var Xe = 7200 * 1e3, J = 200, Ze = 5 * 1024 * 1024, et = "gengage_request_response_cache", tt = 1, A = "responses", rt = /* @__PURE__ */ new Set(["addToCart", "like"]), S = /* @__PURE__ */ new Map(), H = null;
1282
+ async function xt(e, t = {}, r = {}) {
1283
+ const n = nt(e, t);
1284
+ if (!n) return fetch(e, t);
1285
+ const o = Date.now(), s = await at(n, o);
1286
+ if (s) return dt(s);
1264
1287
  const i = await fetch(e, t);
1265
- return i.ok && at(o, i.clone(), n, {
1266
- ttlMs: r.ttlMs ?? Ye,
1288
+ return i.ok && ct(n, i.clone(), o, {
1289
+ ttlMs: r.ttlMs ?? Xe,
1267
1290
  maxEntries: r.maxEntries ?? J,
1268
- maxBodyBytes: r.maxBodyBytes ?? Xe
1291
+ maxBodyBytes: r.maxBodyBytes ?? Ze
1269
1292
  }), i;
1270
1293
  }
1271
- function rt(e, t = {}) {
1294
+ function nt(e, t = {}) {
1272
1295
  if (typeof Request < "u" && e instanceof Request) return null;
1273
1296
  const r = String(t.method || "GET").toUpperCase();
1274
1297
  if (r !== "POST" || typeof t.body != "string") return null;
1275
- const o = ot(t.body);
1276
- if (nt(o)) return null;
1277
- const n = st(o);
1278
- if (n) {
1279
- const s = P(o?.action);
1298
+ const n = ot(t.body);
1299
+ if (st(n)) return null;
1300
+ const o = it(n);
1301
+ if (o) {
1302
+ const s = P(n?.action);
1280
1303
  return `rr:${$(G({
1281
1304
  url: String(e),
1282
1305
  method: r,
1283
1306
  headers: U(t.headers),
1284
- type: o?.type ?? s?.type ?? "",
1285
- account_id: o?.account_id ?? o?.accountId ?? "",
1286
- locale: o?.locale ?? "",
1287
- outputLanguage: P(o?.meta)?.outputLanguage ?? "",
1288
- cache_key: n
1307
+ type: n?.type ?? s?.type ?? "",
1308
+ account_id: n?.account_id ?? n?.accountId ?? "",
1309
+ locale: n?.locale ?? "",
1310
+ outputLanguage: P(n?.meta)?.outputLanguage ?? "",
1311
+ cache_key: o
1289
1312
  }))}`;
1290
1313
  }
1291
1314
  return `rr:${$(G({
@@ -1303,44 +1326,44 @@ function ot(e) {
1303
1326
  return null;
1304
1327
  }
1305
1328
  }
1306
- function nt(e) {
1329
+ function st(e) {
1307
1330
  const t = e?.type;
1308
- return typeof t == "string" && tt.has(t);
1331
+ return typeof t == "string" && rt.has(t);
1309
1332
  }
1310
- function st(e) {
1333
+ function it(e) {
1311
1334
  const t = (P(e?.payload) ?? P(P(e?.action)?.payload))?.cache_key;
1312
1335
  return typeof t == "string" && t.trim().length > 0 ? t.trim() : null;
1313
1336
  }
1314
- async function it(e, t) {
1315
- const r = A.get(e);
1316
- if (r) if (r.expiresAt <= t) A.delete(e);
1337
+ async function at(e, t) {
1338
+ const r = S.get(e);
1339
+ if (r) if (r.expiresAt <= t) S.delete(e);
1317
1340
  else
1318
- return r.lastAccessedAt = t, A.delete(e), A.set(e, r), R(r), r;
1319
- const o = await lt(e);
1320
- return o ? o.expiresAt <= t ? (A.delete(e), pt(e), null) : (o.lastAccessedAt = t, A.set(e, o), R(o), Q(J), o) : null;
1341
+ return r.lastAccessedAt = t, S.delete(e), S.set(e, r), L(r), r;
1342
+ const n = await pt(e);
1343
+ return n ? n.expiresAt <= t ? (S.delete(e), ft(e), null) : (n.lastAccessedAt = t, S.set(e, n), L(n), Q(J), n) : null;
1321
1344
  }
1322
- async function at(e, t, r, o) {
1345
+ async function ct(e, t, r, n) {
1323
1346
  try {
1324
- const n = await t.text();
1325
- if (yt(n) > o.maxBodyBytes || ct(n)) return;
1347
+ const o = await t.text();
1348
+ if (gt(o) > n.maxBodyBytes || ut(o)) return;
1326
1349
  const s = {
1327
1350
  key: e,
1328
1351
  status: t.status,
1329
1352
  statusText: t.statusText,
1330
- headers: dt(t.headers),
1331
- body: n,
1353
+ headers: lt(t.headers),
1354
+ body: o,
1332
1355
  createdAt: r,
1333
- expiresAt: r + o.ttlMs,
1356
+ expiresAt: r + n.ttlMs,
1334
1357
  lastAccessedAt: r
1335
1358
  };
1336
- A.set(e, s), Q(o.maxEntries), await R(s), await ft(o.maxEntries, r);
1359
+ S.set(e, s), Q(n.maxEntries), await L(s), await yt(n.maxEntries, r);
1337
1360
  } catch {
1338
1361
  }
1339
1362
  }
1340
- function ct(e) {
1363
+ function ut(e) {
1341
1364
  return /"_error"\s*:/u.test(e) || /"type"\s*:\s*"error"/u.test(e);
1342
1365
  }
1343
- function ut(e) {
1366
+ function dt(e) {
1344
1367
  return new Response(e.body, {
1345
1368
  status: e.status,
1346
1369
  statusText: e.statusText,
@@ -1349,104 +1372,104 @@ function ut(e) {
1349
1372
  }
1350
1373
  function U(e) {
1351
1374
  const t = new Headers(e), r = [];
1352
- return t.forEach((o, n) => {
1353
- const s = n.toLowerCase();
1354
- s !== "authorization" && s !== "cookie" && r.push([s, o]);
1355
- }), r.sort(([o], [n]) => o.localeCompare(n));
1375
+ return t.forEach((n, o) => {
1376
+ const s = o.toLowerCase();
1377
+ s !== "authorization" && s !== "cookie" && r.push([s, n]);
1378
+ }), r.sort(([n], [o]) => n.localeCompare(o));
1356
1379
  }
1357
- function dt(e) {
1380
+ function lt(e) {
1358
1381
  const t = [];
1359
- return e.forEach((r, o) => {
1360
- const n = o.toLowerCase();
1361
- n !== "set-cookie" && t.push([n, r]);
1362
- }), t.sort(([r], [o]) => r.localeCompare(o));
1382
+ return e.forEach((r, n) => {
1383
+ const o = n.toLowerCase();
1384
+ o !== "set-cookie" && t.push([o, r]);
1385
+ }), t.sort(([r], [n]) => r.localeCompare(n));
1363
1386
  }
1364
1387
  function Q(e) {
1365
- for (; A.size > e; ) {
1366
- const t = [...A.values()].sort((r, o) => r.lastAccessedAt - o.lastAccessedAt)[0];
1388
+ for (; S.size > e; ) {
1389
+ const t = [...S.values()].sort((r, n) => r.lastAccessedAt - n.lastAccessedAt)[0];
1367
1390
  if (!t) break;
1368
- A.delete(t.key);
1391
+ S.delete(t.key);
1369
1392
  }
1370
1393
  }
1371
- async function T() {
1394
+ async function D() {
1372
1395
  return typeof indexedDB > "u" ? null : (H ??= new Promise((e) => {
1373
- const t = indexedDB.open(Ze, et);
1396
+ const t = indexedDB.open(et, tt);
1374
1397
  t.onupgradeneeded = () => {
1375
1398
  const r = t.result;
1376
- r.objectStoreNames.contains(w) || r.createObjectStore(w, { keyPath: "key" }).createIndex("lastAccessedAt", "lastAccessedAt", { unique: !1 });
1399
+ r.objectStoreNames.contains(A) || r.createObjectStore(A, { keyPath: "key" }).createIndex("lastAccessedAt", "lastAccessedAt", { unique: !1 });
1377
1400
  }, t.onsuccess = () => e(t.result), t.onerror = () => e(null), t.onblocked = () => e(null);
1378
1401
  }), H);
1379
1402
  }
1380
- async function lt(e) {
1381
- const t = await T();
1403
+ async function pt(e) {
1404
+ const t = await D();
1382
1405
  return t ? new Promise((r) => {
1383
- const o = t.transaction(w, "readonly"), n = o.objectStore(w).get(e);
1384
- n.onsuccess = () => r(n.result ?? null), n.onerror = () => r(null), o.onerror = () => r(null);
1406
+ const n = t.transaction(A, "readonly"), o = n.objectStore(A).get(e);
1407
+ o.onsuccess = () => r(o.result ?? null), o.onerror = () => r(null), n.onerror = () => r(null);
1385
1408
  }) : null;
1386
1409
  }
1387
- async function R(e) {
1388
- const t = await T();
1410
+ async function L(e) {
1411
+ const t = await D();
1389
1412
  t && await new Promise((r) => {
1390
- const o = t.transaction(w, "readwrite");
1391
- o.objectStore(w).put(e), o.oncomplete = () => r(), o.onerror = () => r(), o.onabort = () => r();
1413
+ const n = t.transaction(A, "readwrite");
1414
+ n.objectStore(A).put(e), n.oncomplete = () => r(), n.onerror = () => r(), n.onabort = () => r();
1392
1415
  });
1393
1416
  }
1394
- async function pt(e) {
1395
- const t = await T();
1417
+ async function ft(e) {
1418
+ const t = await D();
1396
1419
  t && await new Promise((r) => {
1397
- const o = t.transaction(w, "readwrite");
1398
- o.objectStore(w).delete(e), o.oncomplete = () => r(), o.onerror = () => r(), o.onabort = () => r();
1420
+ const n = t.transaction(A, "readwrite");
1421
+ n.objectStore(A).delete(e), n.oncomplete = () => r(), n.onerror = () => r(), n.onabort = () => r();
1399
1422
  });
1400
1423
  }
1401
- async function ft(e, t) {
1402
- const r = await T();
1403
- r && await new Promise((o) => {
1404
- const n = r.transaction(w, "readwrite"), s = n.objectStore(w), i = [], a = s.openCursor();
1424
+ async function yt(e, t) {
1425
+ const r = await D();
1426
+ r && await new Promise((n) => {
1427
+ const o = r.transaction(A, "readwrite"), s = o.objectStore(A), i = [], a = s.openCursor();
1405
1428
  a.onsuccess = () => {
1406
1429
  const c = a.result;
1407
1430
  if (!c) {
1408
- const p = i.filter((u) => u.expiresAt <= t), _ = i.filter((u) => u.expiresAt > t).sort((u, m) => u.lastAccessedAt - m.lastAccessedAt).slice(0, Math.max(0, i.length - p.length - e));
1409
- for (const u of [...p, ..._]) s.delete(u.key);
1431
+ const l = i.filter((u) => u.expiresAt <= t), _ = i.filter((u) => u.expiresAt > t).sort((u, g) => u.lastAccessedAt - g.lastAccessedAt).slice(0, Math.max(0, i.length - l.length - e));
1432
+ for (const u of [...l, ..._]) s.delete(u.key);
1410
1433
  return;
1411
1434
  }
1412
1435
  i.push(c.value), c.continue();
1413
- }, a.onerror = () => o(), n.oncomplete = () => o(), n.onerror = () => o(), n.onabort = () => o();
1436
+ }, a.onerror = () => n(), o.oncomplete = () => n(), o.onerror = () => n(), o.onabort = () => n();
1414
1437
  });
1415
1438
  }
1416
1439
  function G(e) {
1417
- return JSON.stringify(L(e));
1440
+ return JSON.stringify(O(e));
1418
1441
  }
1419
1442
  function P(e) {
1420
1443
  return e && typeof e == "object" && !Array.isArray(e) ? e : null;
1421
1444
  }
1422
- function L(e) {
1423
- return Array.isArray(e) ? e.map(L) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => [t, L(r)]));
1445
+ function O(e) {
1446
+ return Array.isArray(e) ? e.map(O) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => [t, O(r)]));
1424
1447
  }
1425
1448
  function $(e) {
1426
1449
  let t = 14695981039346656037n;
1427
1450
  const r = 1099511628211n;
1428
- for (let o = 0; o < e.length; o += 1)
1429
- t ^= BigInt(e.charCodeAt(o)), t = BigInt.asUintN(64, t * r);
1451
+ for (let n = 0; n < e.length; n += 1)
1452
+ t ^= BigInt(e.charCodeAt(n)), t = BigInt.asUintN(64, t * r);
1430
1453
  return t.toString(16).padStart(16, "0");
1431
1454
  }
1432
- function yt(e) {
1455
+ function gt(e) {
1433
1456
  return typeof TextEncoder < "u" ? new TextEncoder().encode(e).byteLength : e.length;
1434
1457
  }
1435
1458
  export {
1436
1459
  At as a,
1437
- z as c,
1460
+ I as c,
1438
1461
  se as d,
1439
1462
  te as f,
1440
- mt as g,
1463
+ _t as g,
1441
1464
  Z as h,
1442
- bt as i,
1465
+ kt as i,
1443
1466
  ie as l,
1444
- _t as m,
1467
+ ht as m,
1445
1468
  wt as n,
1446
- kt as o,
1447
- ht as p,
1448
- Qe as r,
1449
- S as s,
1450
- St as t,
1451
- ne as u
1469
+ St as o,
1470
+ bt as p,
1471
+ Ye as r,
1472
+ w as s,
1473
+ xt as t,
1474
+ oe as u
1452
1475
  };