@gengage/assistant-fe 0.6.44 → 0.6.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/components/productMentionLinker.d.ts +5 -5
- package/dist/chat/runtime.d.ts +3 -0
- package/dist/chat/types.d.ts +6 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +26 -26
- package/dist/chat.js +1 -1
- package/dist/common/transport.d.ts +1 -0
- package/dist/common/types.d.ts +1 -0
- package/dist/{common-B_QhTwRK.js → common-BYaIofv0.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-DjGsAS1h.js → connection-warning-BWCgMHwN.js} +1 -1
- package/dist/{fastIntent-DOgXE46i.js → fastIntent-BfYLNhFF.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +8 -8
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +10 -10
- package/dist/qna.js +1 -1
- package/dist/request-response-cache-DxtNGhlh.js +1491 -0
- package/dist/{runtime-BJiDilHj.js → runtime-B9k46n2p.js} +3 -3
- package/dist/{runtime-D39A30T-.js → runtime-DBmJg9TG.js} +613 -579
- package/dist/{runtime-Cr3f6wjm.js → runtime-IlZ-GH68.js} +3 -3
- package/dist/{simbut-C-2-g2V1.js → simbut-CobYs9jE.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-BaahIAgs.js → simrel-BEyFl3Ec.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +2 -2
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-DRNUkp-i.js → widget-base-BsHKmSMq.js} +1 -1
- package/package.json +1 -1
- package/dist/request-response-cache-Ddw59jGs.js +0 -1475
|
@@ -1,1475 +0,0 @@
|
|
|
1
|
-
import { i as X } from "./widget-base-DRNUkp-i.js";
|
|
2
|
-
var Z = ({ element: e, renderElement: t }) => {
|
|
3
|
-
if (!e.children || e.children.length === 0) return null;
|
|
4
|
-
const r = document.createElement("div");
|
|
5
|
-
for (const n of e.children) {
|
|
6
|
-
const o = t(n);
|
|
7
|
-
o && r.appendChild(o);
|
|
8
|
-
}
|
|
9
|
-
return r;
|
|
10
|
-
};
|
|
11
|
-
function _t(e) {
|
|
12
|
-
const t = document.createElement("div");
|
|
13
|
-
if (t.className = e.containerClassName, !e.spec.elements[e.spec.root]) return t;
|
|
14
|
-
const r = e.unknownRenderer ?? Z, n = (s) => {
|
|
15
|
-
const i = e.spec.elements[s];
|
|
16
|
-
if (!i) return null;
|
|
17
|
-
const a = e.registry[i.type];
|
|
18
|
-
return a ? a({
|
|
19
|
-
elementId: s,
|
|
20
|
-
element: i,
|
|
21
|
-
spec: e.spec,
|
|
22
|
-
context: e.context,
|
|
23
|
-
renderElement: n
|
|
24
|
-
}) : r({
|
|
25
|
-
elementId: s,
|
|
26
|
-
element: i,
|
|
27
|
-
spec: e.spec,
|
|
28
|
-
context: e.context,
|
|
29
|
-
renderElement: n
|
|
30
|
-
});
|
|
31
|
-
}, o = n(e.spec.root);
|
|
32
|
-
return o && t.appendChild(o), t;
|
|
33
|
-
}
|
|
34
|
-
function ht(e, t) {
|
|
35
|
-
if (!t) return e;
|
|
36
|
-
const r = { ...e };
|
|
37
|
-
for (const [n, o] of Object.entries(t))
|
|
38
|
-
o && (r[n] = o);
|
|
39
|
-
return r;
|
|
40
|
-
}
|
|
41
|
-
function B(e) {
|
|
42
|
-
return typeof e == "object" && e !== null && typeof e.type == "string";
|
|
43
|
-
}
|
|
44
|
-
function ee(e) {
|
|
45
|
-
const t = [];
|
|
46
|
-
let r = 0, n = !1, o = !1, s = 0;
|
|
47
|
-
for (let i = 0; i < e.length; i++) {
|
|
48
|
-
const a = e[i];
|
|
49
|
-
if (o) {
|
|
50
|
-
o = !1;
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (a === "\\" && n) {
|
|
54
|
-
o = !0;
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (a === '"') {
|
|
58
|
-
n = !n;
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
n || (a === "{" && r++, a === "}" && (r--, r === 0 && (t.push(e.slice(s, i + 1)), s = i + 1)));
|
|
62
|
-
}
|
|
63
|
-
return t.length > 0 ? t : [e];
|
|
64
|
-
}
|
|
65
|
-
function M(e, t) {
|
|
66
|
-
const r = e.trim();
|
|
67
|
-
if (!r || r.startsWith(":")) return !1;
|
|
68
|
-
const n = r.startsWith("data: ") ? r.slice(6) : r;
|
|
69
|
-
if (n === "[DONE]")
|
|
70
|
-
return t.onDone?.(), !0;
|
|
71
|
-
try {
|
|
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
|
-
} catch {
|
|
75
|
-
const o = ee(n);
|
|
76
|
-
if (o.length > 1) {
|
|
77
|
-
for (const s of o) try {
|
|
78
|
-
const i = JSON.parse(s);
|
|
79
|
-
if (!B(i)) continue;
|
|
80
|
-
if (t.onEvent(i), i.type === "done")
|
|
81
|
-
return t.onDone?.(), !0;
|
|
82
|
-
} catch {
|
|
83
|
-
}
|
|
84
|
-
return !1;
|
|
85
|
-
}
|
|
86
|
-
return !1;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function te(e, t) {
|
|
90
|
-
if (!e.ok) {
|
|
91
|
-
t.onError?.(/* @__PURE__ */ new Error(`HTTP ${e.status}: ${e.statusText}`));
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (!e.body) {
|
|
95
|
-
t.onError?.(/* @__PURE__ */ new Error("Response body is null — streaming not supported"));
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const r = e.body.getReader(), n = new TextDecoder("utf-8");
|
|
99
|
-
let o = "";
|
|
100
|
-
const s = t.idleTimeoutMs ?? 6e4, i = /* @__PURE__ */ Symbol("idle-timeout");
|
|
101
|
-
let a = !1;
|
|
102
|
-
try {
|
|
103
|
-
for (; ; ) {
|
|
104
|
-
const c = r.read();
|
|
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
|
-
})]) : c);
|
|
109
|
-
if (_ === i) {
|
|
110
|
-
a = !0, await r.cancel();
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
const { done: u, value: g } = _;
|
|
114
|
-
if (u) break;
|
|
115
|
-
o += n.decode(g, { stream: !0 });
|
|
116
|
-
const f = o.split(`
|
|
117
|
-
`);
|
|
118
|
-
o = f.pop() ?? "";
|
|
119
|
-
for (const p of f) if (M(p, t)) return;
|
|
120
|
-
}
|
|
121
|
-
if (o.trim() && M(o, t))
|
|
122
|
-
return;
|
|
123
|
-
} catch (c) {
|
|
124
|
-
if (c instanceof DOMException && c.name === "AbortError") return;
|
|
125
|
-
t.onError?.(c instanceof Error ? c : new Error(String(c)));
|
|
126
|
-
} finally {
|
|
127
|
-
a || r.releaseLock();
|
|
128
|
-
}
|
|
129
|
-
t.onDone?.();
|
|
130
|
-
}
|
|
131
|
-
function bt(e, t, r) {
|
|
132
|
-
const n = new AbortController(), o = r.signal ? re([r.signal, n.signal]) : n.signal;
|
|
133
|
-
return fetch(e, {
|
|
134
|
-
method: "POST",
|
|
135
|
-
headers: {
|
|
136
|
-
"Content-Type": "application/json",
|
|
137
|
-
...r.headers
|
|
138
|
-
},
|
|
139
|
-
body: JSON.stringify(t),
|
|
140
|
-
signal: o
|
|
141
|
-
}).then((s) => te(s, {
|
|
142
|
-
...r,
|
|
143
|
-
signal: o
|
|
144
|
-
})).catch((s) => {
|
|
145
|
-
s instanceof DOMException && s.name === "AbortError" || r.onError?.(s instanceof Error ? s : new Error(String(s)));
|
|
146
|
-
}), n;
|
|
147
|
-
}
|
|
148
|
-
function re(e) {
|
|
149
|
-
const t = new AbortController(), r = [];
|
|
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
|
-
}
|
|
156
|
-
return t.signal.addEventListener("abort", () => {
|
|
157
|
-
for (const n of r) n();
|
|
158
|
-
}, { once: !0 }), t.signal;
|
|
159
|
-
}
|
|
160
|
-
var z = 3, ne = (e, t) => {
|
|
161
|
-
const r = e.replace(/\s+/g, " ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g, "");
|
|
162
|
-
if (!r) return "";
|
|
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
|
-
}
|
|
172
|
-
function se(e) {
|
|
173
|
-
return oe(e).join(" • ");
|
|
174
|
-
}
|
|
175
|
-
function ie(e) {
|
|
176
|
-
return e === "beauty_consulting" || e === "account_expert";
|
|
177
|
-
}
|
|
178
|
-
function E(...e) {
|
|
179
|
-
for (const t of e) {
|
|
180
|
-
if (typeof t != "string") continue;
|
|
181
|
-
const r = t.trim();
|
|
182
|
-
if (r.length > 0) return r;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function T(e) {
|
|
186
|
-
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0).map((t) => t.trim()) : [];
|
|
187
|
-
}
|
|
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
|
-
else {
|
|
192
|
-
const o = E(t.image_url);
|
|
193
|
-
o ? t.image_url = o : delete t.image_url;
|
|
194
|
-
}
|
|
195
|
-
return t;
|
|
196
|
-
}
|
|
197
|
-
function kt(e) {
|
|
198
|
-
if (typeof e.type != "string") return null;
|
|
199
|
-
if (ae(e)) return e;
|
|
200
|
-
const t = e;
|
|
201
|
-
switch (t.type) {
|
|
202
|
-
case "outputText":
|
|
203
|
-
return ce(t);
|
|
204
|
-
case "suggestedActions":
|
|
205
|
-
return ue(t);
|
|
206
|
-
case "productList":
|
|
207
|
-
return de(t);
|
|
208
|
-
case "productDetails":
|
|
209
|
-
return le(t);
|
|
210
|
-
case "productDetailsSimilars":
|
|
211
|
-
return pe(t);
|
|
212
|
-
case "comparisonTable":
|
|
213
|
-
return fe(t);
|
|
214
|
-
case "context":
|
|
215
|
-
return _e(t);
|
|
216
|
-
case "chatStreamEnd":
|
|
217
|
-
return he();
|
|
218
|
-
case "loading":
|
|
219
|
-
return be(t);
|
|
220
|
-
case "panelLoading":
|
|
221
|
-
return ke(t);
|
|
222
|
-
case "similarLoading":
|
|
223
|
-
return Se(t);
|
|
224
|
-
case "redirect":
|
|
225
|
-
return Ae(t);
|
|
226
|
-
case "error":
|
|
227
|
-
return we(t);
|
|
228
|
-
case "dummy":
|
|
229
|
-
return xe(t);
|
|
230
|
-
case "launcherAction":
|
|
231
|
-
return Pe(t);
|
|
232
|
-
case "text":
|
|
233
|
-
return v(t);
|
|
234
|
-
case "productItem":
|
|
235
|
-
return Ee(t);
|
|
236
|
-
case "text_image":
|
|
237
|
-
return F(t);
|
|
238
|
-
case "quick_qna":
|
|
239
|
-
return K(t);
|
|
240
|
-
case "reviewHighlights":
|
|
241
|
-
return Te(t);
|
|
242
|
-
case "aiProductSuggestions":
|
|
243
|
-
return De(t);
|
|
244
|
-
case "aiProductGroupings":
|
|
245
|
-
return Ne(t);
|
|
246
|
-
case "aiSuggestedSearches":
|
|
247
|
-
return Oe(t);
|
|
248
|
-
case "prosAndCons":
|
|
249
|
-
return Ce(t);
|
|
250
|
-
case "getGroundingReview":
|
|
251
|
-
return ve(t);
|
|
252
|
-
case "voice":
|
|
253
|
-
return je(t);
|
|
254
|
-
case "visitorDataResponse":
|
|
255
|
-
return Ie(t);
|
|
256
|
-
case "productListPreview":
|
|
257
|
-
return qe();
|
|
258
|
-
case "groupList":
|
|
259
|
-
return Be(t);
|
|
260
|
-
case "formGetInfo":
|
|
261
|
-
case "formTestDrive":
|
|
262
|
-
case "formServiceRequest":
|
|
263
|
-
case "launchFormPage":
|
|
264
|
-
return Me(t);
|
|
265
|
-
case "launcherContent":
|
|
266
|
-
return He(t);
|
|
267
|
-
case "handoff":
|
|
268
|
-
return ze(t);
|
|
269
|
-
case "uiSpec":
|
|
270
|
-
return Je(t);
|
|
271
|
-
default:
|
|
272
|
-
return null;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
function ae(e) {
|
|
276
|
-
const t = e.type;
|
|
277
|
-
if (typeof t != "string") return !1;
|
|
278
|
-
switch (t) {
|
|
279
|
-
case "metadata":
|
|
280
|
-
return typeof e.sessionId == "string" && typeof e.model == "string";
|
|
281
|
-
case "text_chunk":
|
|
282
|
-
return typeof e.content == "string";
|
|
283
|
-
case "ui_spec": {
|
|
284
|
-
const r = e.widget;
|
|
285
|
-
if (r !== "chat" && r !== "qna" && r !== "simrel") return !1;
|
|
286
|
-
const n = b(e.spec);
|
|
287
|
-
return n ? typeof n.root == "string" && b(n.elements) !== null : !1;
|
|
288
|
-
}
|
|
289
|
-
case "action": {
|
|
290
|
-
const r = b(e.action);
|
|
291
|
-
return r !== null && typeof r.kind == "string";
|
|
292
|
-
}
|
|
293
|
-
case "error":
|
|
294
|
-
return typeof e.code == "string" && typeof e.message == "string";
|
|
295
|
-
case "done":
|
|
296
|
-
return !0;
|
|
297
|
-
default:
|
|
298
|
-
return !1;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function ce(e) {
|
|
302
|
-
const t = d(e.payload.text, e.payload.plain_text) ?? "", r = d(e.payload.plain_text, e.payload.text) ?? t;
|
|
303
|
-
if (e.payload.is_error) return {
|
|
304
|
-
type: "error",
|
|
305
|
-
code: "BACKEND_ERROR",
|
|
306
|
-
message: r || "Backend returned an error"
|
|
307
|
-
};
|
|
308
|
-
const n = {
|
|
309
|
-
type: "text_chunk",
|
|
310
|
-
content: t,
|
|
311
|
-
final: !0
|
|
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
|
-
const s = e.payload.sku_to_product_item;
|
|
315
|
-
s && typeof s == "object" && !Array.isArray(s) && (n.skuToProductItem = s);
|
|
316
|
-
const i = e.payload.conversation_mode;
|
|
317
|
-
typeof i == "string" && i && (n.conversationMode = i);
|
|
318
|
-
const a = e.payload.render_hint;
|
|
319
|
-
return typeof a == "string" && a && (n.renderHint = a), e.payload.kvkk === !0 && (n.kvkk = !0), n;
|
|
320
|
-
}
|
|
321
|
-
function ue(e) {
|
|
322
|
-
return V((e.payload.actions ?? []).map((t) => {
|
|
323
|
-
const r = d(t.title) ?? "", n = k(t.requestDetails, r), o = n ? {
|
|
324
|
-
label: r,
|
|
325
|
-
action: n
|
|
326
|
-
} : null;
|
|
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
|
-
}
|
|
330
|
-
function de(e) {
|
|
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 = d(a.style_label);
|
|
333
|
-
if (!c) return null;
|
|
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
|
-
})) : [];
|
|
342
|
-
return {
|
|
343
|
-
style_label: c,
|
|
344
|
-
style_mood: l ?? "",
|
|
345
|
-
..._ ? { image_url: _ } : {},
|
|
346
|
-
...typeof a.status == "string" ? { status: a.status } : {},
|
|
347
|
-
product_list: u,
|
|
348
|
-
recommendation_groups: g
|
|
349
|
-
};
|
|
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
|
-
s.panelHint = "panel";
|
|
352
|
-
const i = s.spec.elements[s.spec.root];
|
|
353
|
-
if (i) {
|
|
354
|
-
const a = {};
|
|
355
|
-
typeof e.payload.offset == "number" && (a.offset = e.payload.offset), typeof e.payload.end_of_list == "boolean" && (a.endOfList = e.payload.end_of_list), typeof e.payload.title == "string" && (a.panelTitle = e.payload.title), typeof e.payload.source == "string" && (a.source = e.payload.source), r.length > 0 && (a.styleVariations = r), e.payload.replace_panel === !0 && (a.replacePanel = !0), (e.payload.ranking_state === "pending" || e.payload.ranking_state === "final") && (a.rankingState = e.payload.ranking_state);
|
|
356
|
-
const c = e.payload.sequence_id ?? e.payload.search_id;
|
|
357
|
-
typeof c == "string" && c.length > 0 && (a.sequenceId = c), Object.keys(a).length > 0 && (i.props = {
|
|
358
|
-
...i.props,
|
|
359
|
-
...a
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
return s;
|
|
363
|
-
}
|
|
364
|
-
function le(e) {
|
|
365
|
-
const t = e.payload.productDetails;
|
|
366
|
-
if (!t) return Fe("chat");
|
|
367
|
-
const r = w(t);
|
|
368
|
-
return {
|
|
369
|
-
type: "ui_spec",
|
|
370
|
-
widget: "chat",
|
|
371
|
-
spec: {
|
|
372
|
-
root: "root",
|
|
373
|
-
elements: { root: {
|
|
374
|
-
type: "ProductDetailsPanel",
|
|
375
|
-
props: { product: {
|
|
376
|
-
...t,
|
|
377
|
-
...r
|
|
378
|
-
} }
|
|
379
|
-
} }
|
|
380
|
-
},
|
|
381
|
-
panelHint: "panel"
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
function pe(e) {
|
|
385
|
-
const t = R(e.payload.similarProducts ?? [], "chat"), r = t.spec.elements[t.spec.root];
|
|
386
|
-
return r && (r.props = {
|
|
387
|
-
...r.props,
|
|
388
|
-
similarsAppend: !0
|
|
389
|
-
}), {
|
|
390
|
-
...t,
|
|
391
|
-
panelHint: "panel"
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
function fe(e) {
|
|
395
|
-
const t = e.payload.multiple_product_details ?? [], r = e.payload, n = {
|
|
396
|
-
key_differences: r.key_differences,
|
|
397
|
-
recommended_choice: r.recommended_choice,
|
|
398
|
-
recommended_choice_sku: r.recommended_choice_sku,
|
|
399
|
-
special_considerations: r.special_considerations,
|
|
400
|
-
criteria_view: r.criteria_view,
|
|
401
|
-
criteria_view_short: r.criteria_view_short,
|
|
402
|
-
compared_field_names: r.compared_field_names,
|
|
403
|
-
winner_product: r.winner_product,
|
|
404
|
-
winner_hits: r.winner_hits,
|
|
405
|
-
...e.payload.product_comparison_framework ?? {}
|
|
406
|
-
}, o = e.payload.table, s = e.payload.features_list, i = [];
|
|
407
|
-
for (const m of t) {
|
|
408
|
-
const h = w(m);
|
|
409
|
-
i.push(h);
|
|
410
|
-
}
|
|
411
|
-
const a = ye(o, i, n, s);
|
|
412
|
-
let c;
|
|
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
|
-
type: "launchSingleProduct",
|
|
423
|
-
payload: { sku: h }
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
const y = {
|
|
427
|
-
products: i,
|
|
428
|
-
attributes: a,
|
|
429
|
-
highlights: _,
|
|
430
|
-
productActions: p
|
|
431
|
-
};
|
|
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
|
-
type: "ui_spec",
|
|
434
|
-
widget: "chat",
|
|
435
|
-
spec: {
|
|
436
|
-
root: "root",
|
|
437
|
-
elements: { root: {
|
|
438
|
-
type: "ComparisonTable",
|
|
439
|
-
props: y
|
|
440
|
-
} }
|
|
441
|
-
},
|
|
442
|
-
panelHint: "panel"
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
function ye(e, t, r, n) {
|
|
446
|
-
if (!e) return [];
|
|
447
|
-
const o = Object.entries(e);
|
|
448
|
-
if (o.length === 0) return [];
|
|
449
|
-
const s = o[0]?.[1];
|
|
450
|
-
if (Array.isArray(s)) {
|
|
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
|
-
if (!y || !Array.isArray(y)) continue;
|
|
455
|
-
const m = u[p] ?? p;
|
|
456
|
-
f.push({
|
|
457
|
-
label: m,
|
|
458
|
-
values: y.map((h) => typeof h == "string" ? h : String(h ?? ""))
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
return f;
|
|
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 ?? {}, 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
|
-
if (!y || typeof y != "object") return "";
|
|
468
|
-
const m = y[`${u}_short`], h = y[u];
|
|
469
|
-
return me(m ?? h);
|
|
470
|
-
});
|
|
471
|
-
if (g.every((p) => p.length === 0)) continue;
|
|
472
|
-
const f = c[u] ?? u;
|
|
473
|
-
_.push({
|
|
474
|
-
label: f,
|
|
475
|
-
values: g
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
return _;
|
|
479
|
-
}
|
|
480
|
-
function ge(e) {
|
|
481
|
-
const t = [], r = /* @__PURE__ */ new Set();
|
|
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
|
-
return t;
|
|
487
|
-
}
|
|
488
|
-
function me(e) {
|
|
489
|
-
return typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : "";
|
|
490
|
-
}
|
|
491
|
-
function _e(e) {
|
|
492
|
-
return {
|
|
493
|
-
type: "metadata",
|
|
494
|
-
sessionId: "",
|
|
495
|
-
model: "",
|
|
496
|
-
meta: {
|
|
497
|
-
panel: e.payload.panel,
|
|
498
|
-
messages: e.payload.messages,
|
|
499
|
-
message_id: e.payload.message_id
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
function he() {
|
|
504
|
-
return { type: "done" };
|
|
505
|
-
}
|
|
506
|
-
function be(e) {
|
|
507
|
-
return {
|
|
508
|
-
type: "metadata",
|
|
509
|
-
sessionId: "",
|
|
510
|
-
model: "",
|
|
511
|
-
meta: {
|
|
512
|
-
loading: !0,
|
|
513
|
-
loadingText: e.payload.text,
|
|
514
|
-
thinkingMessages: e.payload.thinking_messages,
|
|
515
|
-
dynamicLoading: e.payload.is_dynamic === !0
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
function ke(e) {
|
|
520
|
-
return {
|
|
521
|
-
type: "metadata",
|
|
522
|
-
sessionId: "",
|
|
523
|
-
model: "",
|
|
524
|
-
meta: {
|
|
525
|
-
loading: !0,
|
|
526
|
-
panelLoading: !0,
|
|
527
|
-
panelPendingType: e.payload?.pending_type,
|
|
528
|
-
loadingText: e.payload?.text
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
function Se(e) {
|
|
533
|
-
return {
|
|
534
|
-
type: "metadata",
|
|
535
|
-
sessionId: "",
|
|
536
|
-
model: "",
|
|
537
|
-
meta: {
|
|
538
|
-
loading: !0,
|
|
539
|
-
similarPanelLoading: !0,
|
|
540
|
-
panelPendingType: e.payload?.pending_type,
|
|
541
|
-
loadingText: e.payload?.text
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
function Ae(e) {
|
|
546
|
-
const t = d(e.payload.url);
|
|
547
|
-
return t ? {
|
|
548
|
-
type: "action",
|
|
549
|
-
action: {
|
|
550
|
-
kind: "navigate",
|
|
551
|
-
url: t,
|
|
552
|
-
newTab: e.payload.new_tab === !0
|
|
553
|
-
}
|
|
554
|
-
} : {
|
|
555
|
-
type: "metadata",
|
|
556
|
-
sessionId: "",
|
|
557
|
-
model: "",
|
|
558
|
-
meta: {
|
|
559
|
-
redirect: e.payload,
|
|
560
|
-
redirectTarget: d(e.payload.to)
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
function we(e) {
|
|
565
|
-
return {
|
|
566
|
-
type: "error",
|
|
567
|
-
code: "BACKEND_ERROR",
|
|
568
|
-
message: d(e.payload?.text, e.payload?.message, e.payload?.error) ?? "Backend returned an error"
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
function xe(e) {
|
|
572
|
-
return {
|
|
573
|
-
type: "metadata",
|
|
574
|
-
sessionId: "",
|
|
575
|
-
model: "",
|
|
576
|
-
meta: { noop: !0 }
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
function Pe(e) {
|
|
580
|
-
const t = e.payload ?? {};
|
|
581
|
-
if (Array.isArray(t.action_list)) {
|
|
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
|
-
type: "quick_qna",
|
|
585
|
-
payload: o
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
const r = b(t.action);
|
|
589
|
-
if (r) {
|
|
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
|
-
type: "text_image",
|
|
593
|
-
payload: o
|
|
594
|
-
});
|
|
595
|
-
}
|
|
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
|
-
type: "text",
|
|
601
|
-
payload: o
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
return {
|
|
605
|
-
type: "metadata",
|
|
606
|
-
sessionId: "",
|
|
607
|
-
model: "",
|
|
608
|
-
meta: { launcherAction: t }
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
function v(e) {
|
|
612
|
-
const t = { text: d(e.payload.text) ?? "" };
|
|
613
|
-
return typeof e.payload.theme == "string" && (t.theme = e.payload.theme), e.payload.payload !== void 0 && (t.payload = e.payload.payload), {
|
|
614
|
-
type: "ui_spec",
|
|
615
|
-
widget: "qna",
|
|
616
|
-
spec: {
|
|
617
|
-
root: "root",
|
|
618
|
-
elements: { root: {
|
|
619
|
-
type: "QuestionHeading",
|
|
620
|
-
props: t
|
|
621
|
-
} }
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
function Ee(e) {
|
|
626
|
-
return $e(e.payload, "qna");
|
|
627
|
-
}
|
|
628
|
-
function F(e) {
|
|
629
|
-
const t = d(e.payload.text) ?? "", r = k(e.payload.action, t);
|
|
630
|
-
if (r) {
|
|
631
|
-
const o = {
|
|
632
|
-
label: t || r.title,
|
|
633
|
-
action: r
|
|
634
|
-
};
|
|
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
|
-
type: "ui_spec",
|
|
637
|
-
widget: "qna",
|
|
638
|
-
spec: {
|
|
639
|
-
root: "root",
|
|
640
|
-
elements: { root: {
|
|
641
|
-
type: "ActionButton",
|
|
642
|
-
props: o
|
|
643
|
-
} }
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
const n = { text: t };
|
|
648
|
-
return typeof e.payload.theme == "string" && (n.theme = e.payload.theme), v({
|
|
649
|
-
type: "text",
|
|
650
|
-
payload: n
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
function K(e) {
|
|
654
|
-
return V((e.payload.action_list ?? []).map((t) => {
|
|
655
|
-
const r = d(t.title) ?? "", n = k(t.requestDetails, r), o = n ? {
|
|
656
|
-
label: r,
|
|
657
|
-
action: n
|
|
658
|
-
} : null;
|
|
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
|
-
}
|
|
662
|
-
function Te(e) {
|
|
663
|
-
const t = { reviews: (e.payload.reviews ?? []).map((r) => {
|
|
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
|
-
}) };
|
|
667
|
-
return typeof e.payload.sku == "string" && (t.sku = e.payload.sku), {
|
|
668
|
-
type: "ui_spec",
|
|
669
|
-
widget: "chat",
|
|
670
|
-
spec: {
|
|
671
|
-
root: "root",
|
|
672
|
-
elements: { root: {
|
|
673
|
-
type: "ReviewHighlights",
|
|
674
|
-
props: t
|
|
675
|
-
} }
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
function Ce(e) {
|
|
680
|
-
const t = {};
|
|
681
|
-
return Array.isArray(e.payload.pros) && (t.pros = e.payload.pros), Array.isArray(e.payload.cons) && (t.cons = e.payload.cons), typeof e.payload.product_name == "string" && (t.productName = e.payload.product_name), {
|
|
682
|
-
type: "ui_spec",
|
|
683
|
-
widget: "chat",
|
|
684
|
-
spec: {
|
|
685
|
-
root: "root",
|
|
686
|
-
elements: { root: {
|
|
687
|
-
type: "ProsAndCons",
|
|
688
|
-
props: t
|
|
689
|
-
} }
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
function Ie(e) {
|
|
694
|
-
return {
|
|
695
|
-
type: "metadata",
|
|
696
|
-
sessionId: "",
|
|
697
|
-
model: "",
|
|
698
|
-
meta: { visitorDataResponse: e.payload }
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
function De(e) {
|
|
702
|
-
const t = e.payload.product_suggestions ?? [], r = [];
|
|
703
|
-
for (let n = 0; n < t.length; n++) {
|
|
704
|
-
const o = t[n];
|
|
705
|
-
if (!o) continue;
|
|
706
|
-
const s = Ke(o);
|
|
707
|
-
if (!s) continue;
|
|
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
|
-
}
|
|
711
|
-
return r.length === 0 ? {
|
|
712
|
-
type: "metadata",
|
|
713
|
-
sessionId: "",
|
|
714
|
-
model: "",
|
|
715
|
-
meta: { aiProductSuggestions: e.payload.product_suggestions ?? [] }
|
|
716
|
-
} : {
|
|
717
|
-
type: "ui_spec",
|
|
718
|
-
widget: "chat",
|
|
719
|
-
spec: {
|
|
720
|
-
root: "root",
|
|
721
|
-
elements: { root: {
|
|
722
|
-
type: "AITopPicks",
|
|
723
|
-
props: { suggestions: r }
|
|
724
|
-
} }
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
function Ne(e) {
|
|
729
|
-
const t = e.payload.product_groupings ?? [], r = [], n = [];
|
|
730
|
-
for (let o = 0; o < t.length; o++) {
|
|
731
|
-
const s = t[o];
|
|
732
|
-
if (!s) continue;
|
|
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
|
-
if (i && f.length > 0) {
|
|
738
|
-
const m = {
|
|
739
|
-
groupName: i,
|
|
740
|
-
products: f
|
|
741
|
-
};
|
|
742
|
-
p && (m.image = p), a && (m.description = a), c && (m.highlight = c), l.length > 0 && (m.labels = l), r.push(m);
|
|
743
|
-
}
|
|
744
|
-
if (!g) continue;
|
|
745
|
-
const y = {
|
|
746
|
-
name: i,
|
|
747
|
-
action: g
|
|
748
|
-
};
|
|
749
|
-
l.length > 0 && (y.labels = l), u !== void 0 && (y.image = u), n.push(y);
|
|
750
|
-
}
|
|
751
|
-
return r.length > 0 ? {
|
|
752
|
-
type: "ui_spec",
|
|
753
|
-
widget: "chat",
|
|
754
|
-
spec: {
|
|
755
|
-
root: "root",
|
|
756
|
-
elements: { root: {
|
|
757
|
-
type: "CategoriesContainer",
|
|
758
|
-
props: { groups: r }
|
|
759
|
-
} }
|
|
760
|
-
},
|
|
761
|
-
panelHint: "panel"
|
|
762
|
-
} : n.length === 0 ? {
|
|
763
|
-
type: "metadata",
|
|
764
|
-
sessionId: "",
|
|
765
|
-
model: "",
|
|
766
|
-
meta: { aiProductGroupings: e.payload.product_groupings ?? [] }
|
|
767
|
-
} : {
|
|
768
|
-
type: "ui_spec",
|
|
769
|
-
widget: "chat",
|
|
770
|
-
spec: {
|
|
771
|
-
root: "root",
|
|
772
|
-
elements: { root: {
|
|
773
|
-
type: "AIGroupingCards",
|
|
774
|
-
props: { entries: n }
|
|
775
|
-
} }
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
function Re(e, t, r) {
|
|
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
|
-
return a.length > 0 && (i.group_skus = a), k({
|
|
787
|
-
...n,
|
|
788
|
-
payload: I(i)
|
|
789
|
-
}, t);
|
|
790
|
-
}
|
|
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
|
-
type: "findSimilar",
|
|
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
|
|
829
|
-
}, t);
|
|
830
|
-
}
|
|
831
|
-
function Oe(e) {
|
|
832
|
-
const t = e.payload.suggested_searches ?? [], r = [];
|
|
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 = {
|
|
839
|
-
shortName: s,
|
|
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);
|
|
845
|
-
}
|
|
846
|
-
return r.length === 0 ? {
|
|
847
|
-
type: "metadata",
|
|
848
|
-
sessionId: "",
|
|
849
|
-
model: "",
|
|
850
|
-
meta: { aiSuggestedSearches: e.payload.suggested_searches ?? [] }
|
|
851
|
-
} : {
|
|
852
|
-
type: "ui_spec",
|
|
853
|
-
widget: "chat",
|
|
854
|
-
spec: {
|
|
855
|
-
root: "root",
|
|
856
|
-
elements: { root: {
|
|
857
|
-
type: "AISuggestedSearchCards",
|
|
858
|
-
props: { entries: r }
|
|
859
|
-
} }
|
|
860
|
-
}
|
|
861
|
-
};
|
|
862
|
-
}
|
|
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");
|
|
865
|
-
if (!r) return {
|
|
866
|
-
type: "metadata",
|
|
867
|
-
sessionId: "",
|
|
868
|
-
model: "",
|
|
869
|
-
meta: { groundingReview: t }
|
|
870
|
-
};
|
|
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), {
|
|
873
|
-
type: "ui_spec",
|
|
874
|
-
widget: "chat",
|
|
875
|
-
spec: {
|
|
876
|
-
root: "root",
|
|
877
|
-
elements: { root: {
|
|
878
|
-
type: "GroundingReviewCard",
|
|
879
|
-
props: n
|
|
880
|
-
} }
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
function qe() {
|
|
885
|
-
return {
|
|
886
|
-
type: "metadata",
|
|
887
|
-
sessionId: "",
|
|
888
|
-
model: "",
|
|
889
|
-
meta: { analyzeAnimation: !0 }
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
function je(e) {
|
|
893
|
-
return {
|
|
894
|
-
type: "metadata",
|
|
895
|
-
sessionId: "",
|
|
896
|
-
model: "",
|
|
897
|
-
meta: { voice: e.payload }
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
function Be(e) {
|
|
901
|
-
const t = e.payload.group_list ?? [], r = [];
|
|
902
|
-
for (const o of t) {
|
|
903
|
-
const s = o.group_name ?? "", i = (o.product_list ?? []).map(w);
|
|
904
|
-
r.push({
|
|
905
|
-
groupName: s,
|
|
906
|
-
products: i
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
|
-
const n = [];
|
|
910
|
-
for (const o of e.payload.filter_tags ?? []) {
|
|
911
|
-
const s = o.title ?? "";
|
|
912
|
-
if (!s) continue;
|
|
913
|
-
const i = k(o.requestDetails, s), a = { title: s };
|
|
914
|
-
i && (a.action = i), n.push(a);
|
|
915
|
-
}
|
|
916
|
-
return {
|
|
917
|
-
type: "ui_spec",
|
|
918
|
-
widget: "chat",
|
|
919
|
-
spec: {
|
|
920
|
-
root: "root",
|
|
921
|
-
elements: { root: {
|
|
922
|
-
type: "CategoriesContainer",
|
|
923
|
-
props: {
|
|
924
|
-
groups: r,
|
|
925
|
-
filterTags: n
|
|
926
|
-
}
|
|
927
|
-
} }
|
|
928
|
-
},
|
|
929
|
-
panelHint: "panel"
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
function Me(e) {
|
|
933
|
-
return {
|
|
934
|
-
type: "metadata",
|
|
935
|
-
sessionId: "",
|
|
936
|
-
model: "",
|
|
937
|
-
meta: {
|
|
938
|
-
formType: e.type,
|
|
939
|
-
formPayload: e.payload ?? {}
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
function ze(e) {
|
|
944
|
-
const t = {};
|
|
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), {
|
|
946
|
-
type: "ui_spec",
|
|
947
|
-
widget: "chat",
|
|
948
|
-
spec: {
|
|
949
|
-
root: "root",
|
|
950
|
-
elements: { root: {
|
|
951
|
-
type: "HandoffNotice",
|
|
952
|
-
props: t
|
|
953
|
-
} }
|
|
954
|
-
}
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
function He(e) {
|
|
958
|
-
return {
|
|
959
|
-
type: "metadata",
|
|
960
|
-
sessionId: "",
|
|
961
|
-
model: "",
|
|
962
|
-
meta: { launcherContent: e.payload ?? {} }
|
|
963
|
-
};
|
|
964
|
-
}
|
|
965
|
-
function q(e, t) {
|
|
966
|
-
const r = {
|
|
967
|
-
product: e,
|
|
968
|
-
index: t
|
|
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 : "",
|
|
972
|
-
type: "launchSingleProduct",
|
|
973
|
-
payload: { sku: o }
|
|
974
|
-
}), {
|
|
975
|
-
type: "ProductCard",
|
|
976
|
-
props: r
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
function V(e, t) {
|
|
980
|
-
const r = {}, n = [];
|
|
981
|
-
for (let o = 0; o < e.length; o++) {
|
|
982
|
-
const s = e[o];
|
|
983
|
-
if (!s) continue;
|
|
984
|
-
const i = `action-${o}`;
|
|
985
|
-
n.push(i);
|
|
986
|
-
const a = {
|
|
987
|
-
label: s.label,
|
|
988
|
-
action: s.action
|
|
989
|
-
};
|
|
990
|
-
s.icon !== void 0 && (a.icon = s.icon), s.image !== void 0 && (a.image = s.image), s.description !== void 0 && (a.description = s.description), r[i] = {
|
|
991
|
-
type: "ActionButton",
|
|
992
|
-
props: a
|
|
993
|
-
};
|
|
994
|
-
}
|
|
995
|
-
return r.root = {
|
|
996
|
-
type: "ActionButtons",
|
|
997
|
-
props: { buttons: e.map((o) => {
|
|
998
|
-
const s = {
|
|
999
|
-
label: o.label,
|
|
1000
|
-
action: o.action
|
|
1001
|
-
};
|
|
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;
|
|
1003
|
-
}) },
|
|
1004
|
-
children: n
|
|
1005
|
-
}, {
|
|
1006
|
-
type: "ui_spec",
|
|
1007
|
-
widget: t,
|
|
1008
|
-
spec: {
|
|
1009
|
-
root: "root",
|
|
1010
|
-
elements: r
|
|
1011
|
-
}
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
|
-
function R(e, t) {
|
|
1015
|
-
const r = {}, n = [];
|
|
1016
|
-
for (let o = 0; o < e.length; o++) {
|
|
1017
|
-
const s = e[o];
|
|
1018
|
-
if (!s) continue;
|
|
1019
|
-
const i = w(s), a = `product-${o}`;
|
|
1020
|
-
n.push(a), r[a] = q(i, o);
|
|
1021
|
-
}
|
|
1022
|
-
return r.root = {
|
|
1023
|
-
type: "ProductGrid",
|
|
1024
|
-
props: { layout: "grid" },
|
|
1025
|
-
children: n
|
|
1026
|
-
}, {
|
|
1027
|
-
type: "ui_spec",
|
|
1028
|
-
widget: t,
|
|
1029
|
-
spec: {
|
|
1030
|
-
root: "root",
|
|
1031
|
-
elements: r
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
}
|
|
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 = [];
|
|
1041
|
-
let c = 0;
|
|
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);
|
|
1051
|
-
i.push(h), f.push(h), s[h] = q(Y, c), c += 1;
|
|
1052
|
-
}
|
|
1053
|
-
f.length > 0 && a.push({
|
|
1054
|
-
title: u,
|
|
1055
|
-
children: f
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
return a.length === 0 || o.size < n.size ? null : (s.root = {
|
|
1059
|
-
type: "ProductGrid",
|
|
1060
|
-
props: {
|
|
1061
|
-
layout: "grouped",
|
|
1062
|
-
productSections: a
|
|
1063
|
-
},
|
|
1064
|
-
children: i
|
|
1065
|
-
}, {
|
|
1066
|
-
type: "ui_spec",
|
|
1067
|
-
widget: r,
|
|
1068
|
-
spec: {
|
|
1069
|
-
root: "root",
|
|
1070
|
-
elements: s
|
|
1071
|
-
}
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
function Ge(e, t) {
|
|
1075
|
-
const r = {}, n = [];
|
|
1076
|
-
for (let o = 0; o < e.length; o++) {
|
|
1077
|
-
const s = e[o];
|
|
1078
|
-
if (!s) continue;
|
|
1079
|
-
const i = `product-${o}`;
|
|
1080
|
-
n.push(i), r[i] = q(s, o);
|
|
1081
|
-
}
|
|
1082
|
-
return r.root = {
|
|
1083
|
-
type: "ProductGrid",
|
|
1084
|
-
props: { layout: "grid" },
|
|
1085
|
-
children: n
|
|
1086
|
-
}, {
|
|
1087
|
-
type: "ui_spec",
|
|
1088
|
-
widget: t,
|
|
1089
|
-
spec: {
|
|
1090
|
-
root: "root",
|
|
1091
|
-
elements: r
|
|
1092
|
-
}
|
|
1093
|
-
};
|
|
1094
|
-
}
|
|
1095
|
-
function $e(e, t) {
|
|
1096
|
-
return {
|
|
1097
|
-
type: "ui_spec",
|
|
1098
|
-
widget: t,
|
|
1099
|
-
spec: {
|
|
1100
|
-
root: "root",
|
|
1101
|
-
elements: { root: {
|
|
1102
|
-
type: "ProductCard",
|
|
1103
|
-
props: {
|
|
1104
|
-
product: w(e),
|
|
1105
|
-
index: 0
|
|
1106
|
-
}
|
|
1107
|
-
} }
|
|
1108
|
-
}
|
|
1109
|
-
};
|
|
1110
|
-
}
|
|
1111
|
-
function Fe(e) {
|
|
1112
|
-
return {
|
|
1113
|
-
type: "ui_spec",
|
|
1114
|
-
widget: e,
|
|
1115
|
-
spec: {
|
|
1116
|
-
root: "root",
|
|
1117
|
-
elements: { root: {
|
|
1118
|
-
type: "ActionButtons",
|
|
1119
|
-
props: { buttons: [] },
|
|
1120
|
-
children: []
|
|
1121
|
-
} }
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
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);
|
|
1128
|
-
}
|
|
1129
|
-
function j(e, t, r) {
|
|
1130
|
-
const n = d(e.sku, t), o = d(e.name, r);
|
|
1131
|
-
if (!n || !o) return null;
|
|
1132
|
-
const s = {
|
|
1133
|
-
sku: n,
|
|
1134
|
-
name: o
|
|
1135
|
-
}, i = d(e.brand);
|
|
1136
|
-
i && (s.brand = i);
|
|
1137
|
-
const a = d(e.url);
|
|
1138
|
-
a && (s.url = a);
|
|
1139
|
-
const c = Ve(e.images);
|
|
1140
|
-
if (c.length > 0) s.images = c;
|
|
1141
|
-
else {
|
|
1142
|
-
const y = d(e.image, e.image_url, e.imageUrl);
|
|
1143
|
-
y && (s.images = [y]);
|
|
1144
|
-
}
|
|
1145
|
-
const l = x(e.price_discounted);
|
|
1146
|
-
l !== void 0 && (s.price_discounted = l);
|
|
1147
|
-
const _ = x(e.price);
|
|
1148
|
-
_ !== void 0 && (s.price = _);
|
|
1149
|
-
const u = x(e.rating);
|
|
1150
|
-
u !== void 0 && (s.rating = u);
|
|
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);
|
|
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);
|
|
1155
|
-
const p = d(e.discount_reason, e.discountReason);
|
|
1156
|
-
return p && (s.discount_reason = p), w(s);
|
|
1157
|
-
}
|
|
1158
|
-
function k(e, t) {
|
|
1159
|
-
const r = b(e);
|
|
1160
|
-
if (!r) return null;
|
|
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
|
|
1166
|
-
};
|
|
1167
|
-
return r.payload !== void 0 && (o.payload = r.payload), o;
|
|
1168
|
-
}
|
|
1169
|
-
function b(e) {
|
|
1170
|
-
return !e || typeof e != "object" || Array.isArray(e) ? null : e;
|
|
1171
|
-
}
|
|
1172
|
-
function d(...e) {
|
|
1173
|
-
for (const t of e) if (typeof t == "string") {
|
|
1174
|
-
const r = t.trim();
|
|
1175
|
-
if (r.length > 0) return r;
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
function Ve(e) {
|
|
1179
|
-
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.length > 0) : [];
|
|
1180
|
-
}
|
|
1181
|
-
function W(e) {
|
|
1182
|
-
if (typeof e == "string") {
|
|
1183
|
-
const t = e.trim();
|
|
1184
|
-
return t ? [t] : [];
|
|
1185
|
-
}
|
|
1186
|
-
return Array.isArray(e) ? e.filter((t) => typeof t == "string").map((t) => t.trim()).filter((t) => t.length > 0) : [];
|
|
1187
|
-
}
|
|
1188
|
-
function x(e) {
|
|
1189
|
-
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
1190
|
-
if (typeof e == "string") {
|
|
1191
|
-
let t;
|
|
1192
|
-
e.includes(".") && e.includes(",") ? t = e.replace(/\./g, "").replace(",", ".") : t = e.replace(",", ".");
|
|
1193
|
-
const r = Number(t);
|
|
1194
|
-
if (Number.isFinite(r)) return r;
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
function C(e) {
|
|
1198
|
-
return e != null;
|
|
1199
|
-
}
|
|
1200
|
-
var We = /* @__PURE__ */ new Set([
|
|
1201
|
-
"sku",
|
|
1202
|
-
"name",
|
|
1203
|
-
"brand",
|
|
1204
|
-
"images",
|
|
1205
|
-
"price",
|
|
1206
|
-
"price_discounted",
|
|
1207
|
-
"price_discount_rate",
|
|
1208
|
-
"price_currency",
|
|
1209
|
-
"discount_reason",
|
|
1210
|
-
"url",
|
|
1211
|
-
"rating",
|
|
1212
|
-
"review_count",
|
|
1213
|
-
"cart_code",
|
|
1214
|
-
"in_stock",
|
|
1215
|
-
"description",
|
|
1216
|
-
"description_html",
|
|
1217
|
-
"features",
|
|
1218
|
-
"specifications",
|
|
1219
|
-
"short_name",
|
|
1220
|
-
"category_ids",
|
|
1221
|
-
"category_names",
|
|
1222
|
-
"variants",
|
|
1223
|
-
"facet_hits",
|
|
1224
|
-
"promotions"
|
|
1225
|
-
]);
|
|
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 = {
|
|
1231
|
-
sku: e.sku,
|
|
1232
|
-
name: a,
|
|
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);
|
|
1236
|
-
const _ = e, u = {};
|
|
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;
|
|
1240
|
-
}
|
|
1241
|
-
function St(e) {
|
|
1242
|
-
return e.results.map(w);
|
|
1243
|
-
}
|
|
1244
|
-
function At(e) {
|
|
1245
|
-
return e.product_groupings.map((t) => {
|
|
1246
|
-
const r = {
|
|
1247
|
-
name: t.name,
|
|
1248
|
-
products: (t.group_products ?? []).map(w)
|
|
1249
|
-
};
|
|
1250
|
-
return t.highlight !== void 0 && (r.highlight = t.highlight), r;
|
|
1251
|
-
});
|
|
1252
|
-
}
|
|
1253
|
-
function Je(e) {
|
|
1254
|
-
const t = e.payload.type, { type: r, ...n } = e.payload;
|
|
1255
|
-
return {
|
|
1256
|
-
type: "ui_spec",
|
|
1257
|
-
widget: "chat",
|
|
1258
|
-
spec: {
|
|
1259
|
-
root: "root",
|
|
1260
|
-
elements: { root: {
|
|
1261
|
-
type: t,
|
|
1262
|
-
props: n
|
|
1263
|
-
} }
|
|
1264
|
-
}
|
|
1265
|
-
};
|
|
1266
|
-
}
|
|
1267
|
-
var Qe = {
|
|
1268
|
-
process_action: "/process_action",
|
|
1269
|
-
launcher_action: "/launcher_action",
|
|
1270
|
-
similar_products: "/similar_products",
|
|
1271
|
-
product_groupings: "/product_groupings"
|
|
1272
|
-
};
|
|
1273
|
-
function Ye(e) {
|
|
1274
|
-
if (e === void 0) throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");
|
|
1275
|
-
const t = e.trim();
|
|
1276
|
-
return t === "" ? "" : t.replace(/\/+$/, "");
|
|
1277
|
-
}
|
|
1278
|
-
function wt(e, t) {
|
|
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);
|
|
1287
|
-
const i = await fetch(e, t);
|
|
1288
|
-
return i.ok && ct(n, i.clone(), o, {
|
|
1289
|
-
ttlMs: r.ttlMs ?? Xe,
|
|
1290
|
-
maxEntries: r.maxEntries ?? J,
|
|
1291
|
-
maxBodyBytes: r.maxBodyBytes ?? Ze
|
|
1292
|
-
}), i;
|
|
1293
|
-
}
|
|
1294
|
-
function nt(e, t = {}) {
|
|
1295
|
-
if (typeof Request < "u" && e instanceof Request) return null;
|
|
1296
|
-
const r = String(t.method || "GET").toUpperCase();
|
|
1297
|
-
if (r !== "POST" || typeof t.body != "string") return null;
|
|
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);
|
|
1303
|
-
return `rr:${$(G({
|
|
1304
|
-
url: String(e),
|
|
1305
|
-
method: r,
|
|
1306
|
-
headers: U(t.headers),
|
|
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
|
|
1312
|
-
}))}`;
|
|
1313
|
-
}
|
|
1314
|
-
return `rr:${$(G({
|
|
1315
|
-
url: String(e),
|
|
1316
|
-
method: r,
|
|
1317
|
-
headers: U(t.headers),
|
|
1318
|
-
body: t.body
|
|
1319
|
-
}))}`;
|
|
1320
|
-
}
|
|
1321
|
-
function ot(e) {
|
|
1322
|
-
try {
|
|
1323
|
-
const t = JSON.parse(e);
|
|
1324
|
-
return !t || typeof t != "object" || Array.isArray(t) ? null : t;
|
|
1325
|
-
} catch {
|
|
1326
|
-
return null;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
function st(e) {
|
|
1330
|
-
const t = e?.type;
|
|
1331
|
-
return typeof t == "string" && rt.has(t);
|
|
1332
|
-
}
|
|
1333
|
-
function it(e) {
|
|
1334
|
-
const t = (P(e?.payload) ?? P(P(e?.action)?.payload))?.cache_key;
|
|
1335
|
-
return typeof t == "string" && t.trim().length > 0 ? t.trim() : null;
|
|
1336
|
-
}
|
|
1337
|
-
async function at(e, t) {
|
|
1338
|
-
const r = S.get(e);
|
|
1339
|
-
if (r) if (r.expiresAt <= t) S.delete(e);
|
|
1340
|
-
else
|
|
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;
|
|
1344
|
-
}
|
|
1345
|
-
async function ct(e, t, r, n) {
|
|
1346
|
-
try {
|
|
1347
|
-
const o = await t.text();
|
|
1348
|
-
if (gt(o) > n.maxBodyBytes || ut(o)) return;
|
|
1349
|
-
const s = {
|
|
1350
|
-
key: e,
|
|
1351
|
-
status: t.status,
|
|
1352
|
-
statusText: t.statusText,
|
|
1353
|
-
headers: lt(t.headers),
|
|
1354
|
-
body: o,
|
|
1355
|
-
createdAt: r,
|
|
1356
|
-
expiresAt: r + n.ttlMs,
|
|
1357
|
-
lastAccessedAt: r
|
|
1358
|
-
};
|
|
1359
|
-
S.set(e, s), Q(n.maxEntries), await L(s), await yt(n.maxEntries, r);
|
|
1360
|
-
} catch {
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
function ut(e) {
|
|
1364
|
-
return /"_error"\s*:/u.test(e) || /"type"\s*:\s*"error"/u.test(e);
|
|
1365
|
-
}
|
|
1366
|
-
function dt(e) {
|
|
1367
|
-
return new Response(e.body, {
|
|
1368
|
-
status: e.status,
|
|
1369
|
-
statusText: e.statusText,
|
|
1370
|
-
headers: new Headers(e.headers)
|
|
1371
|
-
});
|
|
1372
|
-
}
|
|
1373
|
-
function U(e) {
|
|
1374
|
-
const t = new Headers(e), r = [];
|
|
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));
|
|
1379
|
-
}
|
|
1380
|
-
function lt(e) {
|
|
1381
|
-
const t = [];
|
|
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));
|
|
1386
|
-
}
|
|
1387
|
-
function Q(e) {
|
|
1388
|
-
for (; S.size > e; ) {
|
|
1389
|
-
const t = [...S.values()].sort((r, n) => r.lastAccessedAt - n.lastAccessedAt)[0];
|
|
1390
|
-
if (!t) break;
|
|
1391
|
-
S.delete(t.key);
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
async function D() {
|
|
1395
|
-
return typeof indexedDB > "u" ? null : (H ??= new Promise((e) => {
|
|
1396
|
-
const t = indexedDB.open(et, tt);
|
|
1397
|
-
t.onupgradeneeded = () => {
|
|
1398
|
-
const r = t.result;
|
|
1399
|
-
r.objectStoreNames.contains(A) || r.createObjectStore(A, { keyPath: "key" }).createIndex("lastAccessedAt", "lastAccessedAt", { unique: !1 });
|
|
1400
|
-
}, t.onsuccess = () => e(t.result), t.onerror = () => e(null), t.onblocked = () => e(null);
|
|
1401
|
-
}), H);
|
|
1402
|
-
}
|
|
1403
|
-
async function pt(e) {
|
|
1404
|
-
const t = await D();
|
|
1405
|
-
return t ? new Promise((r) => {
|
|
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);
|
|
1408
|
-
}) : null;
|
|
1409
|
-
}
|
|
1410
|
-
async function L(e) {
|
|
1411
|
-
const t = await D();
|
|
1412
|
-
t && await new Promise((r) => {
|
|
1413
|
-
const n = t.transaction(A, "readwrite");
|
|
1414
|
-
n.objectStore(A).put(e), n.oncomplete = () => r(), n.onerror = () => r(), n.onabort = () => r();
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1417
|
-
async function ft(e) {
|
|
1418
|
-
const t = await D();
|
|
1419
|
-
t && await new Promise((r) => {
|
|
1420
|
-
const n = t.transaction(A, "readwrite");
|
|
1421
|
-
n.objectStore(A).delete(e), n.oncomplete = () => r(), n.onerror = () => r(), n.onabort = () => r();
|
|
1422
|
-
});
|
|
1423
|
-
}
|
|
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();
|
|
1428
|
-
a.onsuccess = () => {
|
|
1429
|
-
const c = a.result;
|
|
1430
|
-
if (!c) {
|
|
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);
|
|
1433
|
-
return;
|
|
1434
|
-
}
|
|
1435
|
-
i.push(c.value), c.continue();
|
|
1436
|
-
}, a.onerror = () => n(), o.oncomplete = () => n(), o.onerror = () => n(), o.onabort = () => n();
|
|
1437
|
-
});
|
|
1438
|
-
}
|
|
1439
|
-
function G(e) {
|
|
1440
|
-
return JSON.stringify(O(e));
|
|
1441
|
-
}
|
|
1442
|
-
function P(e) {
|
|
1443
|
-
return e && typeof e == "object" && !Array.isArray(e) ? e : null;
|
|
1444
|
-
}
|
|
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)]));
|
|
1447
|
-
}
|
|
1448
|
-
function $(e) {
|
|
1449
|
-
let t = 14695981039346656037n;
|
|
1450
|
-
const r = 1099511628211n;
|
|
1451
|
-
for (let n = 0; n < e.length; n += 1)
|
|
1452
|
-
t ^= BigInt(e.charCodeAt(n)), t = BigInt.asUintN(64, t * r);
|
|
1453
|
-
return t.toString(16).padStart(16, "0");
|
|
1454
|
-
}
|
|
1455
|
-
function gt(e) {
|
|
1456
|
-
return typeof TextEncoder < "u" ? new TextEncoder().encode(e).byteLength : e.length;
|
|
1457
|
-
}
|
|
1458
|
-
export {
|
|
1459
|
-
At as a,
|
|
1460
|
-
I as c,
|
|
1461
|
-
se as d,
|
|
1462
|
-
te as f,
|
|
1463
|
-
_t as g,
|
|
1464
|
-
Z as h,
|
|
1465
|
-
kt as i,
|
|
1466
|
-
ie as l,
|
|
1467
|
-
ht as m,
|
|
1468
|
-
wt as n,
|
|
1469
|
-
St as o,
|
|
1470
|
-
bt as p,
|
|
1471
|
-
Ye as r,
|
|
1472
|
-
w as s,
|
|
1473
|
-
xt as t,
|
|
1474
|
-
oe as u
|
|
1475
|
-
};
|