@gengage/assistant-fe 0.5.4 → 0.5.6
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/{api-paths-5v4fJh3b.js → api-paths-C__u2yrA.js} +351 -356
- package/dist/{chat-BRKK63lt.js → chat-CrEa2W-e.js} +8 -4
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +45 -45
- package/dist/chat.js +2 -2
- package/dist/{common-jTnp0FYs.js → common-Da3kBFv3.js} +2 -2
- package/dist/common.js +7 -7
- package/dist/{connection-warning-BlkNv3zB.js → connection-warning-DuYLTTBY.js} +1 -1
- package/dist/{fastIntent-CWB807V4.js → fastIntent-CSUjkiTB.js} +1 -1
- package/dist/index.js +12 -12
- package/dist/{native-webview-BQPhKMli.js → native-webview-qfjm4SHx.js} +1 -1
- package/dist/native.iife.js +13 -13
- package/dist/native.js +1 -1
- package/dist/{overlay-C0NSAZoL.js → overlay-CP5A0Hhf.js} +1 -1
- package/dist/overlay.js +1 -1
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +8 -8
- package/dist/qna.js +1 -1
- package/dist/{runtime-Bupw3CaJ.js → runtime-CAg_iN6a.js} +3 -3
- package/dist/{runtime-BD5Aes4y.js → runtime-CFHFFIU0.js} +3179 -3108
- package/dist/{runtime-DDIRZNa4.js → runtime-vEZ7Jp50.js} +3 -3
- package/dist/{simbut-DNxmYY0Q.js → simbut-BzxDRoSM.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-DlmYAGVD.js → simrel-DsIquEK2.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +8 -8
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-DTsBXrHi.js → widget-base-DMiOpmY5.js} +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { i as U } from "./widget-base-
|
|
2
|
-
var
|
|
1
|
+
import { i as U } from "./widget-base-DMiOpmY5.js";
|
|
2
|
+
var z = ({ element: e, renderElement: t }) => {
|
|
3
3
|
if (!e.children || e.children.length === 0) return null;
|
|
4
|
-
const
|
|
4
|
+
const r = document.createElement("div");
|
|
5
5
|
for (const n of e.children) {
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const o = t(n);
|
|
7
|
+
o && r.appendChild(o);
|
|
8
8
|
}
|
|
9
|
-
return
|
|
9
|
+
return r;
|
|
10
10
|
};
|
|
11
11
|
function He(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
|
|
14
|
+
const r = e.unknownRenderer ?? z, n = (i) => {
|
|
15
15
|
const s = e.spec.elements[i];
|
|
16
16
|
if (!s) return null;
|
|
17
17
|
const a = e.registry[s.type];
|
|
@@ -21,60 +21,60 @@ function He(e) {
|
|
|
21
21
|
spec: e.spec,
|
|
22
22
|
context: e.context,
|
|
23
23
|
renderElement: n
|
|
24
|
-
}) :
|
|
24
|
+
}) : r({
|
|
25
25
|
elementId: i,
|
|
26
26
|
element: s,
|
|
27
27
|
spec: e.spec,
|
|
28
28
|
context: e.context,
|
|
29
29
|
renderElement: n
|
|
30
30
|
});
|
|
31
|
-
},
|
|
32
|
-
return
|
|
31
|
+
}, o = n(e.spec.root);
|
|
32
|
+
return o && t.appendChild(o), t;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function Ue(e, t) {
|
|
35
35
|
if (!t) return e;
|
|
36
|
-
const
|
|
37
|
-
for (const [n,
|
|
38
|
-
|
|
39
|
-
return
|
|
36
|
+
const r = { ...e };
|
|
37
|
+
for (const [n, o] of Object.entries(t))
|
|
38
|
+
o && (r[n] = o);
|
|
39
|
+
return r;
|
|
40
40
|
}
|
|
41
41
|
function v(e) {
|
|
42
42
|
return typeof e == "object" && e !== null && typeof e.type == "string";
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function G(e) {
|
|
45
45
|
const t = [];
|
|
46
|
-
let
|
|
46
|
+
let r = 0, n = !1, o = !1, i = 0;
|
|
47
47
|
for (let s = 0; s < e.length; s++) {
|
|
48
48
|
const a = e[s];
|
|
49
|
-
if (
|
|
50
|
-
|
|
49
|
+
if (o) {
|
|
50
|
+
o = !1;
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
53
|
if (a === "\\" && n) {
|
|
54
|
-
|
|
54
|
+
o = !0;
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
57
|
if (a === '"') {
|
|
58
58
|
n = !n;
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
|
-
n || (a === "{" &&
|
|
61
|
+
n || (a === "{" && r++, a === "}" && (r--, r === 0 && (t.push(e.slice(i, s + 1)), i = s + 1)));
|
|
62
62
|
}
|
|
63
63
|
return t.length > 0 ? t : [e];
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
const
|
|
67
|
-
if (!
|
|
68
|
-
const n =
|
|
65
|
+
function I(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
69
|
if (n === "[DONE]")
|
|
70
70
|
return t.onDone?.(), !0;
|
|
71
71
|
try {
|
|
72
|
-
const
|
|
73
|
-
return v(
|
|
72
|
+
const o = JSON.parse(n);
|
|
73
|
+
return v(o) ? (U("stream", `event: ${o.type}`, o), t.onEvent(o), o.type === "done" ? (t.onDone?.(), !0) : !1) : !1;
|
|
74
74
|
} catch {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
for (const i of
|
|
75
|
+
const o = G(n);
|
|
76
|
+
if (o.length > 1) {
|
|
77
|
+
for (const i of o) try {
|
|
78
78
|
const s = JSON.parse(i);
|
|
79
79
|
if (!v(s)) continue;
|
|
80
80
|
if (t.onEvent(s), s.type === "done")
|
|
@@ -86,7 +86,7 @@ function N(e, t) {
|
|
|
86
86
|
return !1;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
89
|
+
async function j(e, t) {
|
|
90
90
|
if (!e.ok) {
|
|
91
91
|
t.onError?.(/* @__PURE__ */ new Error(`HTTP ${e.status}: ${e.statusText}`));
|
|
92
92
|
return;
|
|
@@ -95,107 +95,106 @@ async function G(e, t) {
|
|
|
95
95
|
t.onError?.(/* @__PURE__ */ new Error("Response body is null — streaming not supported"));
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
const
|
|
99
|
-
let
|
|
98
|
+
const r = e.body.getReader(), n = new TextDecoder("utf-8");
|
|
99
|
+
let o = "";
|
|
100
100
|
const i = t.idleTimeoutMs ?? 6e4, s = /* @__PURE__ */ Symbol("idle-timeout");
|
|
101
101
|
let a = !1;
|
|
102
102
|
try {
|
|
103
103
|
for (; ; ) {
|
|
104
|
-
const c =
|
|
104
|
+
const c = r.read();
|
|
105
105
|
let m;
|
|
106
|
-
const
|
|
107
|
-
m = setTimeout(() =>
|
|
106
|
+
const _ = await (i > 0 ? Promise.race([c.then((g) => (clearTimeout(m), g)), new Promise((g) => {
|
|
107
|
+
m = setTimeout(() => g(s), i);
|
|
108
108
|
})]) : c);
|
|
109
|
-
if (
|
|
110
|
-
a = !0, await
|
|
109
|
+
if (_ === s) {
|
|
110
|
+
a = !0, await r.cancel();
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
|
-
const { done:
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
const
|
|
113
|
+
const { done: d, value: p } = _;
|
|
114
|
+
if (d) break;
|
|
115
|
+
o += n.decode(p, { stream: !0 });
|
|
116
|
+
const l = o.split(`
|
|
117
117
|
`);
|
|
118
|
-
|
|
119
|
-
for (const
|
|
118
|
+
o = l.pop() ?? "";
|
|
119
|
+
for (const g of l) if (I(g, t)) return;
|
|
120
120
|
}
|
|
121
|
-
if (
|
|
121
|
+
if (o.trim() && I(o, t))
|
|
122
122
|
return;
|
|
123
123
|
} catch (c) {
|
|
124
124
|
if (c instanceof DOMException && c.name === "AbortError") return;
|
|
125
125
|
t.onError?.(c instanceof Error ? c : new Error(String(c)));
|
|
126
126
|
} finally {
|
|
127
|
-
a ||
|
|
127
|
+
a || r.releaseLock();
|
|
128
128
|
}
|
|
129
129
|
t.onDone?.();
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
const n = new AbortController(),
|
|
131
|
+
function ze(e, t, r) {
|
|
132
|
+
const n = new AbortController(), o = r.signal ? M([r.signal, n.signal]) : n.signal;
|
|
133
133
|
return fetch(e, {
|
|
134
134
|
method: "POST",
|
|
135
135
|
headers: {
|
|
136
136
|
"Content-Type": "application/json",
|
|
137
|
-
...
|
|
137
|
+
...r.headers
|
|
138
138
|
},
|
|
139
139
|
body: JSON.stringify(t),
|
|
140
|
-
signal:
|
|
141
|
-
}).then((i) =>
|
|
142
|
-
...
|
|
143
|
-
signal:
|
|
140
|
+
signal: o
|
|
141
|
+
}).then((i) => j(i, {
|
|
142
|
+
...r,
|
|
143
|
+
signal: o
|
|
144
144
|
})).catch((i) => {
|
|
145
|
-
i instanceof DOMException && i.name === "AbortError" ||
|
|
145
|
+
i instanceof DOMException && i.name === "AbortError" || r.onError?.(i instanceof Error ? i : new Error(String(i)));
|
|
146
146
|
}), n;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
const t = new AbortController(),
|
|
148
|
+
function M(e) {
|
|
149
|
+
const t = new AbortController(), r = [];
|
|
150
150
|
for (const n of e) {
|
|
151
151
|
if (n.aborted)
|
|
152
152
|
return t.abort(n.reason), t.signal;
|
|
153
|
-
const
|
|
154
|
-
n.addEventListener("abort",
|
|
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 n of
|
|
157
|
+
for (const n of r) n();
|
|
158
158
|
}, { once: !0 }), t.signal;
|
|
159
159
|
}
|
|
160
|
-
var
|
|
161
|
-
const
|
|
162
|
-
if (!
|
|
163
|
-
const n = t?.stripLeadingStopWords ?
|
|
160
|
+
var N = 3, $ = (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
164
|
return n ? n.split(/\s+/).slice(0, 3).join(" ").trim() : "";
|
|
165
|
-
}, x = (e, t) => e ? e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map((
|
|
166
|
-
function
|
|
167
|
-
const t = (e.display_keywords ?? []).flatMap((
|
|
168
|
-
if (
|
|
165
|
+
}, x = (e, t) => e ? e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map((r) => $(r, t)).filter(Boolean) : [];
|
|
166
|
+
function B(e) {
|
|
167
|
+
const t = (e.display_keywords ?? []).flatMap((o) => x(o, { stripLeadingStopWords: !0 })), r = t.filter((o, i) => t.indexOf(o) === i);
|
|
168
|
+
if (r.length > 0) return r.slice(0, N);
|
|
169
169
|
const n = [...x(e.chosen_attribute, { stripLeadingStopWords: !0 }), ...x(e.short_name)];
|
|
170
|
-
return n.filter((
|
|
170
|
+
return n.filter((o, i) => n.indexOf(o) === i).slice(0, N);
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
return
|
|
172
|
+
function K(e) {
|
|
173
|
+
return B(e).join(" • ");
|
|
174
174
|
}
|
|
175
|
-
var K = ["beauty_consulting", "watch_expert"];
|
|
176
175
|
function V(e) {
|
|
177
|
-
return
|
|
176
|
+
return e === "beauty_consulting" || e === "account_expert";
|
|
178
177
|
}
|
|
179
178
|
function P(...e) {
|
|
180
179
|
for (const t of e) {
|
|
181
180
|
if (typeof t != "string") continue;
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
181
|
+
const r = t.trim();
|
|
182
|
+
if (r.length > 0) return r;
|
|
184
183
|
}
|
|
185
184
|
}
|
|
186
185
|
function C(e) {
|
|
187
186
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0).map((t) => t.trim()) : [];
|
|
188
187
|
}
|
|
189
188
|
function R(e) {
|
|
190
|
-
const t = { ...e },
|
|
191
|
-
if (
|
|
189
|
+
const t = { ...e }, r = P(t.sku), n = C(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;
|
|
192
191
|
else {
|
|
193
|
-
const
|
|
194
|
-
|
|
192
|
+
const o = P(t.image_url);
|
|
193
|
+
o ? t.image_url = o : delete t.image_url;
|
|
195
194
|
}
|
|
196
195
|
return t;
|
|
197
196
|
}
|
|
198
|
-
function
|
|
197
|
+
function Ge(e) {
|
|
199
198
|
if (typeof e.type != "string") return null;
|
|
200
199
|
if (W(e)) return e;
|
|
201
200
|
const t = e;
|
|
@@ -213,7 +212,7 @@ function je(e) {
|
|
|
213
212
|
case "comparisonTable":
|
|
214
213
|
return Z(t);
|
|
215
214
|
case "context":
|
|
216
|
-
return
|
|
215
|
+
return re(t);
|
|
217
216
|
case "chatStreamEnd":
|
|
218
217
|
return ne();
|
|
219
218
|
case "loading":
|
|
@@ -268,7 +267,7 @@ function je(e) {
|
|
|
268
267
|
case "handoff":
|
|
269
268
|
return Pe(t);
|
|
270
269
|
case "uiSpec":
|
|
271
|
-
return
|
|
270
|
+
return Le(t);
|
|
272
271
|
default:
|
|
273
272
|
return null;
|
|
274
273
|
}
|
|
@@ -282,14 +281,14 @@ function W(e) {
|
|
|
282
281
|
case "text_chunk":
|
|
283
282
|
return typeof e.content == "string";
|
|
284
283
|
case "ui_spec": {
|
|
285
|
-
const
|
|
286
|
-
if (
|
|
287
|
-
const n =
|
|
288
|
-
return n ? typeof n.root == "string" &&
|
|
284
|
+
const r = e.widget;
|
|
285
|
+
if (r !== "chat" && r !== "qna" && r !== "simrel") return !1;
|
|
286
|
+
const n = k(e.spec);
|
|
287
|
+
return n ? typeof n.root == "string" && k(n.elements) !== null : !1;
|
|
289
288
|
}
|
|
290
289
|
case "action": {
|
|
291
|
-
const
|
|
292
|
-
return
|
|
290
|
+
const r = k(e.action);
|
|
291
|
+
return r !== null && typeof r.kind == "string";
|
|
293
292
|
}
|
|
294
293
|
case "error":
|
|
295
294
|
return typeof e.code == "string" && typeof e.message == "string";
|
|
@@ -300,18 +299,18 @@ function W(e) {
|
|
|
300
299
|
}
|
|
301
300
|
}
|
|
302
301
|
function F(e) {
|
|
303
|
-
const t =
|
|
302
|
+
const t = u(e.payload.text, e.payload.plain_text) ?? "", r = u(e.payload.plain_text, e.payload.text) ?? t;
|
|
304
303
|
if (e.payload.is_error) return {
|
|
305
304
|
type: "error",
|
|
306
305
|
code: "BACKEND_ERROR",
|
|
307
|
-
message:
|
|
306
|
+
message: r || "Backend returned an error"
|
|
308
307
|
};
|
|
309
308
|
const n = {
|
|
310
309
|
type: "text_chunk",
|
|
311
310
|
content: t,
|
|
312
311
|
final: !0
|
|
313
|
-
},
|
|
314
|
-
Array.isArray(
|
|
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"));
|
|
315
314
|
const i = e.payload.sku_to_product_item;
|
|
316
315
|
i && typeof i == "object" && !Array.isArray(i) && (n.skuToProductItem = i);
|
|
317
316
|
const s = e.payload.conversation_mode;
|
|
@@ -321,36 +320,36 @@ function F(e) {
|
|
|
321
320
|
}
|
|
322
321
|
function Q(e) {
|
|
323
322
|
return q((e.payload.actions ?? []).map((t) => {
|
|
324
|
-
const
|
|
325
|
-
label:
|
|
323
|
+
const r = u(t.title) ?? "", n = b(t.requestDetails, r), o = n ? {
|
|
324
|
+
label: r,
|
|
326
325
|
action: n
|
|
327
326
|
} : null;
|
|
328
|
-
return
|
|
327
|
+
return o ? (typeof t.icon == "string" && (o.icon = t.icon), typeof t.image == "string" && (o.image = t.image), o) : null;
|
|
329
328
|
}).filter(A), "chat");
|
|
330
329
|
}
|
|
331
330
|
function J(e) {
|
|
332
331
|
const t = (Array.isArray(e.payload.style_variations) ? e.payload.style_variations : []).map((s) => {
|
|
333
|
-
const a =
|
|
332
|
+
const a = u(s.style_label);
|
|
334
333
|
if (!a) return null;
|
|
335
|
-
const c =
|
|
336
|
-
const
|
|
337
|
-
return
|
|
338
|
-
}).filter(A),
|
|
339
|
-
label:
|
|
340
|
-
reason:
|
|
341
|
-
skus: Array.isArray(p.skus) ? p.skus.filter((
|
|
334
|
+
const c = u(s.style_mood), m = u(s.image_url ?? void 0), _ = (Array.isArray(s.product_list) ? s.product_list : []).map((p) => {
|
|
335
|
+
const l = k(p);
|
|
336
|
+
return l ? E(k(l.product_detail) ?? k(l.product) ?? l) : null;
|
|
337
|
+
}).filter(A), d = Array.isArray(s.recommendation_groups) ? s.recommendation_groups.map((p) => ({
|
|
338
|
+
label: u(p.label) ?? "",
|
|
339
|
+
reason: u(p.reason) ?? "",
|
|
340
|
+
skus: Array.isArray(p.skus) ? p.skus.filter((l) => typeof l == "string" && l.trim().length > 0) : []
|
|
342
341
|
})) : [];
|
|
343
342
|
return {
|
|
344
343
|
style_label: a,
|
|
345
344
|
style_mood: c ?? "",
|
|
346
345
|
...m ? { image_url: m } : {},
|
|
347
346
|
...typeof s.status == "string" ? { status: s.status } : {},
|
|
348
|
-
product_list:
|
|
349
|
-
recommendation_groups:
|
|
347
|
+
product_list: _,
|
|
348
|
+
recommendation_groups: d
|
|
350
349
|
};
|
|
351
|
-
}).filter(A),
|
|
352
|
-
|
|
353
|
-
const i =
|
|
350
|
+
}).filter(A), r = e.payload.product_list ?? [], n = V(e.payload.source) && t.length > 0 ? t[0].product_list : null, o = n ? Te(n, "chat") : O(r, "chat");
|
|
351
|
+
o.panelHint = "panel";
|
|
352
|
+
const i = o.spec.elements[o.spec.root];
|
|
354
353
|
if (i) {
|
|
355
354
|
const s = {};
|
|
356
355
|
typeof e.payload.offset == "number" && (s.offset = e.payload.offset), typeof e.payload.end_of_list == "boolean" && (s.endOfList = e.payload.end_of_list), typeof e.payload.title == "string" && (s.panelTitle = e.payload.title), typeof e.payload.source == "string" && (s.source = e.payload.source), t.length > 0 && (s.styleVariations = t), e.payload.replace_panel === !0 && (s.replacePanel = !0), (e.payload.ranking_state === "pending" || e.payload.ranking_state === "final") && (s.rankingState = e.payload.ranking_state);
|
|
@@ -360,12 +359,12 @@ function J(e) {
|
|
|
360
359
|
...s
|
|
361
360
|
});
|
|
362
361
|
}
|
|
363
|
-
return
|
|
362
|
+
return o;
|
|
364
363
|
}
|
|
365
364
|
function Y(e) {
|
|
366
365
|
const t = e.payload.productDetails;
|
|
367
366
|
if (!t) return ve("chat");
|
|
368
|
-
const
|
|
367
|
+
const r = w(t);
|
|
369
368
|
return {
|
|
370
369
|
type: "ui_spec",
|
|
371
370
|
widget: "chat",
|
|
@@ -375,7 +374,7 @@ function Y(e) {
|
|
|
375
374
|
type: "ProductDetailsPanel",
|
|
376
375
|
props: { product: {
|
|
377
376
|
...t,
|
|
378
|
-
...
|
|
377
|
+
...r
|
|
379
378
|
} }
|
|
380
379
|
} }
|
|
381
380
|
},
|
|
@@ -383,9 +382,9 @@ function Y(e) {
|
|
|
383
382
|
};
|
|
384
383
|
}
|
|
385
384
|
function X(e) {
|
|
386
|
-
const t = O(e.payload.similarProducts ?? [], "chat"),
|
|
387
|
-
return
|
|
388
|
-
...
|
|
385
|
+
const t = O(e.payload.similarProducts ?? [], "chat"), r = t.spec.elements[t.spec.root];
|
|
386
|
+
return r && (r.props = {
|
|
387
|
+
...r.props,
|
|
389
388
|
similarsAppend: !0
|
|
390
389
|
}), {
|
|
391
390
|
...t,
|
|
@@ -393,103 +392,103 @@ function X(e) {
|
|
|
393
392
|
};
|
|
394
393
|
}
|
|
395
394
|
function Z(e) {
|
|
396
|
-
const t = e.payload.multiple_product_details ?? [],
|
|
397
|
-
key_differences:
|
|
398
|
-
recommended_choice:
|
|
399
|
-
recommended_choice_sku:
|
|
400
|
-
special_considerations:
|
|
401
|
-
criteria_view:
|
|
402
|
-
criteria_view_short:
|
|
403
|
-
compared_field_names:
|
|
404
|
-
winner_product:
|
|
405
|
-
winner_hits:
|
|
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,
|
|
406
405
|
...e.payload.product_comparison_framework ?? {}
|
|
407
|
-
},
|
|
408
|
-
for (const
|
|
409
|
-
const
|
|
410
|
-
s.push(
|
|
406
|
+
}, o = e.payload.table, i = e.payload.features_list, s = [];
|
|
407
|
+
for (const y of t) {
|
|
408
|
+
const h = w(y);
|
|
409
|
+
s.push(h);
|
|
411
410
|
}
|
|
412
|
-
const a = ee(
|
|
411
|
+
const a = ee(o, s, n, i);
|
|
413
412
|
let c;
|
|
414
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);
|
|
415
|
-
const m = c ? s.find((
|
|
414
|
+
const m = c ? s.find((y) => y.sku === c) ?? s[0] : s[0], _ = [];
|
|
416
415
|
if (Array.isArray(n?.key_differences))
|
|
417
|
-
for (const
|
|
418
|
-
const
|
|
419
|
-
for (const
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
title:
|
|
416
|
+
for (const y of n.key_differences) typeof y == "string" && _.push(y);
|
|
417
|
+
const d = H(n?.special_considerations), p = n?.recommended_choice, l = n?.winner_hits, g = {};
|
|
418
|
+
for (const y of s) {
|
|
419
|
+
const h = y.sku;
|
|
420
|
+
h && (g[h] = {
|
|
421
|
+
title: y.name ?? h,
|
|
423
422
|
type: "launchSingleProduct",
|
|
424
|
-
payload: { sku:
|
|
423
|
+
payload: { sku: h }
|
|
425
424
|
});
|
|
426
425
|
}
|
|
427
|
-
const
|
|
426
|
+
const f = {
|
|
428
427
|
products: s,
|
|
429
428
|
attributes: a,
|
|
430
|
-
highlights:
|
|
431
|
-
productActions:
|
|
429
|
+
highlights: _,
|
|
430
|
+
productActions: g
|
|
432
431
|
};
|
|
433
|
-
return m && (
|
|
432
|
+
return m && (f.recommended = m), d.length > 0 && (f.specialCases = d), p && (f.recommendedText = p), l && (f.winnerHits = l), typeof n?.key_differences == "string" && (f.keyDifferencesHtml = n.key_differences), n?.special_considerations && (f.specialConsiderations = n.special_considerations), {
|
|
434
433
|
type: "ui_spec",
|
|
435
434
|
widget: "chat",
|
|
436
435
|
spec: {
|
|
437
436
|
root: "root",
|
|
438
437
|
elements: { root: {
|
|
439
438
|
type: "ComparisonTable",
|
|
440
|
-
props:
|
|
439
|
+
props: f
|
|
441
440
|
} }
|
|
442
441
|
},
|
|
443
442
|
panelHint: "panel"
|
|
444
443
|
};
|
|
445
444
|
}
|
|
446
|
-
function ee(e, t,
|
|
445
|
+
function ee(e, t, r, n) {
|
|
447
446
|
if (!e) return [];
|
|
448
|
-
const
|
|
449
|
-
if (
|
|
450
|
-
const i =
|
|
447
|
+
const o = Object.entries(e);
|
|
448
|
+
if (o.length === 0) return [];
|
|
449
|
+
const i = o[0]?.[1];
|
|
451
450
|
if (Array.isArray(i)) {
|
|
452
|
-
const
|
|
453
|
-
for (const
|
|
454
|
-
const
|
|
455
|
-
if (!
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
label:
|
|
459
|
-
values:
|
|
451
|
+
const d = r.criteria_view ?? r.criteria_view_short ?? {}, p = r.compared_field_names ?? Object.keys(e), l = [];
|
|
452
|
+
for (const g of p) {
|
|
453
|
+
const f = e[g];
|
|
454
|
+
if (!f || !Array.isArray(f)) continue;
|
|
455
|
+
const y = d[g] ?? g;
|
|
456
|
+
l.push({
|
|
457
|
+
label: y,
|
|
458
|
+
values: f.map((h) => typeof h == "string" ? h : String(h ?? ""))
|
|
460
459
|
});
|
|
461
460
|
}
|
|
462
|
-
return
|
|
461
|
+
return l;
|
|
463
462
|
}
|
|
464
|
-
const s = e, a = t.map((
|
|
465
|
-
for (const
|
|
466
|
-
const p = a.map((
|
|
467
|
-
const
|
|
468
|
-
if (!
|
|
469
|
-
const
|
|
470
|
-
return
|
|
463
|
+
const s = e, a = t.map((d) => String(d.sku ?? "")).filter((d) => d.length > 0), c = r.criteria_view ?? r.criteria_view_short ?? {}, m = (n && n.length > 0 ? n : r.compared_field_names && r.compared_field_names.length > 0 ? r.compared_field_names : te(s)).filter((d) => d !== "name" && d !== "name_short" && !d.endsWith("_short")), _ = [];
|
|
464
|
+
for (const d of m) {
|
|
465
|
+
const p = a.map((g) => {
|
|
466
|
+
const f = s[g];
|
|
467
|
+
if (!f || typeof f != "object") return "";
|
|
468
|
+
const y = f[`${d}_short`], h = f[d];
|
|
469
|
+
return oe(y ?? h);
|
|
471
470
|
});
|
|
472
|
-
if (p.every((
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
label:
|
|
471
|
+
if (p.every((g) => g.length === 0)) continue;
|
|
472
|
+
const l = c[d] ?? d;
|
|
473
|
+
_.push({
|
|
474
|
+
label: l,
|
|
476
475
|
values: p
|
|
477
476
|
});
|
|
478
477
|
}
|
|
479
|
-
return
|
|
478
|
+
return _;
|
|
480
479
|
}
|
|
481
480
|
function te(e) {
|
|
482
|
-
const t = [],
|
|
481
|
+
const t = [], r = /* @__PURE__ */ new Set();
|
|
483
482
|
for (const n of Object.values(e))
|
|
484
483
|
if (!(!n || typeof n != "object"))
|
|
485
|
-
for (const
|
|
486
|
-
|
|
484
|
+
for (const o of Object.keys(n))
|
|
485
|
+
r.has(o) || (r.add(o), t.push(o));
|
|
487
486
|
return t;
|
|
488
487
|
}
|
|
489
|
-
function
|
|
488
|
+
function oe(e) {
|
|
490
489
|
return typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : "";
|
|
491
490
|
}
|
|
492
|
-
function
|
|
491
|
+
function re(e) {
|
|
493
492
|
return {
|
|
494
493
|
type: "metadata",
|
|
495
494
|
sessionId: "",
|
|
@@ -544,7 +543,7 @@ function ae(e) {
|
|
|
544
543
|
};
|
|
545
544
|
}
|
|
546
545
|
function ce(e) {
|
|
547
|
-
const t =
|
|
546
|
+
const t = u(e.payload.url);
|
|
548
547
|
return t ? {
|
|
549
548
|
type: "action",
|
|
550
549
|
action: {
|
|
@@ -558,7 +557,7 @@ function ce(e) {
|
|
|
558
557
|
model: "",
|
|
559
558
|
meta: {
|
|
560
559
|
redirect: e.payload,
|
|
561
|
-
redirectTarget:
|
|
560
|
+
redirectTarget: u(e.payload.to)
|
|
562
561
|
}
|
|
563
562
|
};
|
|
564
563
|
}
|
|
@@ -566,7 +565,7 @@ function ue(e) {
|
|
|
566
565
|
return {
|
|
567
566
|
type: "error",
|
|
568
567
|
code: "BACKEND_ERROR",
|
|
569
|
-
message:
|
|
568
|
+
message: u(e.payload?.text, e.payload?.message, e.payload?.error) ?? "Backend returned an error"
|
|
570
569
|
};
|
|
571
570
|
}
|
|
572
571
|
function de(e) {
|
|
@@ -580,26 +579,26 @@ function de(e) {
|
|
|
580
579
|
function le(e) {
|
|
581
580
|
const t = e.payload ?? {};
|
|
582
581
|
if (Array.isArray(t.action_list)) {
|
|
583
|
-
const
|
|
584
|
-
return i !== void 0 && (
|
|
582
|
+
const o = { action_list: t.action_list }, i = typeof t.type == "string" ? t.type : void 0, s = typeof t.theme == "string" ? t.theme : void 0;
|
|
583
|
+
return i !== void 0 && (o.type = i), s !== void 0 && (o.theme = s), D({
|
|
585
584
|
type: "quick_qna",
|
|
586
|
-
payload:
|
|
585
|
+
payload: o
|
|
587
586
|
});
|
|
588
587
|
}
|
|
589
|
-
const
|
|
590
|
-
if (
|
|
591
|
-
const
|
|
592
|
-
return i !== void 0 && (
|
|
588
|
+
const r = k(t.action);
|
|
589
|
+
if (r) {
|
|
590
|
+
const o = { action: r }, i = typeof t.text == "string" ? t.text : void 0, s = typeof t.image_url == "string" ? t.image_url : void 0, a = typeof t.theme == "string" ? t.theme : void 0;
|
|
591
|
+
return i !== void 0 && (o.text = i), s !== void 0 && (o.image_url = s), a !== void 0 && (o.theme = a), L({
|
|
593
592
|
type: "text_image",
|
|
594
|
-
payload:
|
|
593
|
+
payload: o
|
|
595
594
|
});
|
|
596
595
|
}
|
|
597
596
|
const n = typeof t.text == "string" ? t.text : "";
|
|
598
597
|
if (n) {
|
|
599
|
-
const
|
|
600
|
-
return i !== void 0 && (
|
|
598
|
+
const o = { text: n }, i = typeof t.type == "string" ? t.type : void 0, s = typeof t.theme == "string" ? t.theme : void 0, a = k(t.payload) ?? void 0;
|
|
599
|
+
return i !== void 0 && (o.type = i), a !== void 0 && (o.payload = a), s !== void 0 && (o.theme = s), T({
|
|
601
600
|
type: "text",
|
|
602
|
-
payload:
|
|
601
|
+
payload: o
|
|
603
602
|
});
|
|
604
603
|
}
|
|
605
604
|
return {
|
|
@@ -610,7 +609,7 @@ function le(e) {
|
|
|
610
609
|
};
|
|
611
610
|
}
|
|
612
611
|
function T(e) {
|
|
613
|
-
const t = { text:
|
|
612
|
+
const t = { text: u(e.payload.text) ?? "" };
|
|
614
613
|
return typeof e.payload.theme == "string" && (t.theme = e.payload.theme), e.payload.payload !== void 0 && (t.payload = e.payload.payload), {
|
|
615
614
|
type: "ui_spec",
|
|
616
615
|
widget: "qna",
|
|
@@ -627,20 +626,20 @@ function pe(e) {
|
|
|
627
626
|
return Ee(e.payload, "qna");
|
|
628
627
|
}
|
|
629
628
|
function L(e) {
|
|
630
|
-
const t =
|
|
631
|
-
if (
|
|
632
|
-
const
|
|
633
|
-
label: t ||
|
|
634
|
-
action:
|
|
629
|
+
const t = u(e.payload.text) ?? "", r = b(e.payload.action, t);
|
|
630
|
+
if (r) {
|
|
631
|
+
const o = {
|
|
632
|
+
label: t || r.title,
|
|
633
|
+
action: r
|
|
635
634
|
};
|
|
636
|
-
return typeof e.payload.image_url == "string" && (
|
|
635
|
+
return typeof e.payload.image_url == "string" && (o.image = e.payload.image_url), typeof e.payload.theme == "string" && (o.theme = e.payload.theme), {
|
|
637
636
|
type: "ui_spec",
|
|
638
637
|
widget: "qna",
|
|
639
638
|
spec: {
|
|
640
639
|
root: "root",
|
|
641
640
|
elements: { root: {
|
|
642
641
|
type: "ActionButton",
|
|
643
|
-
props:
|
|
642
|
+
props: o
|
|
644
643
|
} }
|
|
645
644
|
}
|
|
646
645
|
};
|
|
@@ -653,17 +652,17 @@ function L(e) {
|
|
|
653
652
|
}
|
|
654
653
|
function D(e) {
|
|
655
654
|
return q((e.payload.action_list ?? []).map((t) => {
|
|
656
|
-
const
|
|
657
|
-
label:
|
|
655
|
+
const r = u(t.title) ?? "", n = b(t.requestDetails, r), o = n ? {
|
|
656
|
+
label: r,
|
|
658
657
|
action: n
|
|
659
658
|
} : null;
|
|
660
|
-
return
|
|
659
|
+
return o ? (typeof t.icon == "string" && (o.icon = t.icon), typeof t.image == "string" && (o.image = t.image), o) : null;
|
|
661
660
|
}).filter(A), "qna");
|
|
662
661
|
}
|
|
663
662
|
function fe(e) {
|
|
664
|
-
const t = { reviews: (e.payload.reviews ?? []).map((
|
|
663
|
+
const t = { reviews: (e.payload.reviews ?? []).map((r) => {
|
|
665
664
|
const n = {};
|
|
666
|
-
return typeof
|
|
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;
|
|
667
666
|
}) };
|
|
668
667
|
return typeof e.payload.sku == "string" && (t.sku = e.payload.sku), {
|
|
669
668
|
type: "ui_spec",
|
|
@@ -700,16 +699,16 @@ function ge(e) {
|
|
|
700
699
|
};
|
|
701
700
|
}
|
|
702
701
|
function me(e) {
|
|
703
|
-
const t = e.payload.product_suggestions ?? [],
|
|
702
|
+
const t = e.payload.product_suggestions ?? [], r = [];
|
|
704
703
|
for (let n = 0; n < t.length; n++) {
|
|
705
|
-
const
|
|
706
|
-
if (!
|
|
707
|
-
const i =
|
|
704
|
+
const o = t[n];
|
|
705
|
+
if (!o) continue;
|
|
706
|
+
const i = Ie(o);
|
|
708
707
|
if (!i) continue;
|
|
709
|
-
const s = { product: i }, a = b(
|
|
710
|
-
a && (s.action = a), typeof
|
|
708
|
+
const s = { product: i }, a = b(o.requestDetails, i.name);
|
|
709
|
+
a && (s.action = a), typeof o.role == "string" && (s.role = o.role), typeof o.reason == "string" && (s.reason = o.reason), typeof o.review_highlight == "string" && (s.reviewHighlight = o.review_highlight), Array.isArray(o.labels) && (s.labels = o.labels), typeof o.expert_quality_score == "number" && (s.expertQualityScore = o.expert_quality_score), r.push(s);
|
|
711
710
|
}
|
|
712
|
-
return
|
|
711
|
+
return r.length === 0 ? {
|
|
713
712
|
type: "metadata",
|
|
714
713
|
sessionId: "",
|
|
715
714
|
model: "",
|
|
@@ -721,46 +720,42 @@ function me(e) {
|
|
|
721
720
|
root: "root",
|
|
722
721
|
elements: { root: {
|
|
723
722
|
type: "AITopPicks",
|
|
724
|
-
props: { suggestions:
|
|
723
|
+
props: { suggestions: r }
|
|
725
724
|
} }
|
|
726
725
|
}
|
|
727
726
|
};
|
|
728
727
|
}
|
|
729
728
|
function _e(e) {
|
|
730
|
-
const t = e.payload.product_groupings ?? [],
|
|
731
|
-
for (let
|
|
732
|
-
const i = t[
|
|
729
|
+
const t = e.payload.product_groupings ?? [], r = [], n = [];
|
|
730
|
+
for (let o = 0; o < t.length; o++) {
|
|
731
|
+
const i = t[o];
|
|
733
732
|
if (!i) continue;
|
|
734
|
-
const s =
|
|
735
|
-
const
|
|
736
|
-
return
|
|
737
|
-
}).filter(A),
|
|
738
|
-
if (s &&
|
|
739
|
-
const
|
|
733
|
+
const s = u(i.name) ?? "", a = u(i.description), c = u(i.highlight), m = Array.isArray(i.labels) ? H(i.labels) : [], _ = u(i.sku, i.repr_sku), d = u(i.image, i.repr_image), p = he(i, s, _), l = (Array.isArray(i.group_products) ? i.group_products : []).map((y) => {
|
|
734
|
+
const h = k(y);
|
|
735
|
+
return h ? E(h) : null;
|
|
736
|
+
}).filter(A), g = d ?? u(...l.map((y) => y.imageUrl));
|
|
737
|
+
if (s && l.length > 0) {
|
|
738
|
+
const y = {
|
|
740
739
|
groupName: s,
|
|
741
|
-
products:
|
|
740
|
+
products: l
|
|
742
741
|
};
|
|
743
|
-
|
|
742
|
+
g && (y.image = g), a && (y.description = a), c && (y.highlight = c), m.length > 0 && (y.labels = m), r.push(y);
|
|
744
743
|
}
|
|
745
|
-
if (!
|
|
746
|
-
const
|
|
744
|
+
if (!p) continue;
|
|
745
|
+
const f = {
|
|
747
746
|
name: s,
|
|
748
|
-
action:
|
|
747
|
+
action: p
|
|
749
748
|
};
|
|
750
|
-
|
|
751
|
-
const u = i.labels.filter((f) => typeof f == "string");
|
|
752
|
-
u.length > 0 && (p.labels = u);
|
|
753
|
-
}
|
|
754
|
-
c !== void 0 && (p.image = c), n.push(p);
|
|
749
|
+
m.length > 0 && (f.labels = m), d !== void 0 && (f.image = d), n.push(f);
|
|
755
750
|
}
|
|
756
|
-
return
|
|
751
|
+
return r.length > 0 ? {
|
|
757
752
|
type: "ui_spec",
|
|
758
753
|
widget: "chat",
|
|
759
754
|
spec: {
|
|
760
755
|
root: "root",
|
|
761
756
|
elements: { root: {
|
|
762
757
|
type: "CategoriesContainer",
|
|
763
|
-
props: { groups:
|
|
758
|
+
props: { groups: r }
|
|
764
759
|
} }
|
|
765
760
|
},
|
|
766
761
|
panelHint: "panel"
|
|
@@ -781,51 +776,51 @@ function _e(e) {
|
|
|
781
776
|
}
|
|
782
777
|
};
|
|
783
778
|
}
|
|
784
|
-
function he(e, t,
|
|
785
|
-
const n =
|
|
779
|
+
function he(e, t, r) {
|
|
780
|
+
const n = k(e.requestDetails);
|
|
786
781
|
if (n) {
|
|
787
782
|
if (n.type !== "findSimilar") return b(n, t);
|
|
788
|
-
const s = { ...
|
|
789
|
-
|
|
783
|
+
const s = { ...k(n.payload) ?? {} };
|
|
784
|
+
r && !P(s.sku) && (s.sku = r);
|
|
790
785
|
const a = C(e.group_skus);
|
|
791
786
|
return a.length > 0 && (s.group_skus = a), b({
|
|
792
787
|
...n,
|
|
793
788
|
payload: R(s)
|
|
794
789
|
}, t);
|
|
795
790
|
}
|
|
796
|
-
const
|
|
797
|
-
|
|
791
|
+
const o = {};
|
|
792
|
+
r && (o.sku = r);
|
|
798
793
|
const i = C(e.group_skus);
|
|
799
|
-
return i.length > 0 && (
|
|
794
|
+
return i.length > 0 && (o.group_skus = i), Object.keys(o).length === 0 ? null : b({
|
|
800
795
|
type: "findSimilar",
|
|
801
|
-
payload: R(
|
|
796
|
+
payload: R(o)
|
|
802
797
|
}, t);
|
|
803
798
|
}
|
|
804
799
|
function ke(e) {
|
|
805
|
-
const t = e.payload.suggested_searches ?? [],
|
|
800
|
+
const t = e.payload.suggested_searches ?? [], r = [];
|
|
806
801
|
for (let n = 0; n < t.length; n++) {
|
|
807
|
-
const
|
|
808
|
-
if (!
|
|
809
|
-
const i =
|
|
802
|
+
const o = t[n];
|
|
803
|
+
if (!o) continue;
|
|
804
|
+
const i = u(o.short_name, o.chosen_attribute, o.detailed_user_message) ?? `Search ${n + 1}`, s = {}, a = u(o.detailed_user_message);
|
|
810
805
|
a && (s.text = a);
|
|
811
|
-
const c =
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
const
|
|
806
|
+
const c = k(k(o.requestDetails)?.payload), m = c?.group_skus;
|
|
807
|
+
o.group_skus && Array.isArray(o.group_skus) ? s.group_skus = o.group_skus : Array.isArray(m) && (s.group_skus = m.filter((h) => typeof h == "string"));
|
|
808
|
+
const _ = u(o.sku, o.representative_product_sku, c?.sku);
|
|
809
|
+
_ && (s.sku = _), s.is_suggested_text = 1;
|
|
810
|
+
const d = {
|
|
816
811
|
type: "inputText",
|
|
817
812
|
payload: s
|
|
818
|
-
}, p = b(
|
|
819
|
-
if (!
|
|
820
|
-
const
|
|
813
|
+
}, p = b(o.requestDetails, i), l = p?.type === "findSimilar" && typeof s.text == "string" ? b(d, i) : p ?? b(d, i);
|
|
814
|
+
if (!l) continue;
|
|
815
|
+
const g = {
|
|
821
816
|
shortName: i,
|
|
822
|
-
action:
|
|
823
|
-
},
|
|
824
|
-
|
|
825
|
-
const
|
|
826
|
-
|
|
817
|
+
action: l
|
|
818
|
+
}, f = u(o.detailed_user_message);
|
|
819
|
+
f && f !== i && (g.detailedMessage = f);
|
|
820
|
+
const y = K(o);
|
|
821
|
+
y && y !== i && y !== (f ?? "") && (g.whyDifferent = y), typeof o.image == "string" && (g.image = o.image), r.push(g);
|
|
827
822
|
}
|
|
828
|
-
return
|
|
823
|
+
return r.length === 0 ? {
|
|
829
824
|
type: "metadata",
|
|
830
825
|
sessionId: "",
|
|
831
826
|
model: "",
|
|
@@ -837,20 +832,20 @@ function ke(e) {
|
|
|
837
832
|
root: "root",
|
|
838
833
|
elements: { root: {
|
|
839
834
|
type: "AISuggestedSearchCards",
|
|
840
|
-
props: { entries:
|
|
835
|
+
props: { entries: r }
|
|
841
836
|
} }
|
|
842
837
|
}
|
|
843
838
|
};
|
|
844
839
|
}
|
|
845
840
|
function be(e) {
|
|
846
|
-
const t = e.payload,
|
|
847
|
-
if (!
|
|
841
|
+
const t = e.payload, r = b(t.requestDetails ?? t.request_details, u(t.review_count, t.reviewCount, t.text, t.title) ?? "Show product reviews");
|
|
842
|
+
if (!r) return {
|
|
848
843
|
type: "metadata",
|
|
849
844
|
sessionId: "",
|
|
850
845
|
model: "",
|
|
851
846
|
meta: { groundingReview: t }
|
|
852
847
|
};
|
|
853
|
-
const n = { action:
|
|
848
|
+
const n = { action: r };
|
|
854
849
|
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), {
|
|
855
850
|
type: "ui_spec",
|
|
856
851
|
widget: "chat",
|
|
@@ -880,19 +875,19 @@ function Se(e) {
|
|
|
880
875
|
};
|
|
881
876
|
}
|
|
882
877
|
function Ae(e) {
|
|
883
|
-
const t = e.payload.group_list ?? [],
|
|
884
|
-
for (const
|
|
885
|
-
const i =
|
|
886
|
-
|
|
878
|
+
const t = e.payload.group_list ?? [], r = [];
|
|
879
|
+
for (const o of t) {
|
|
880
|
+
const i = o.group_name ?? "", s = (o.product_list ?? []).map(w);
|
|
881
|
+
r.push({
|
|
887
882
|
groupName: i,
|
|
888
883
|
products: s
|
|
889
884
|
});
|
|
890
885
|
}
|
|
891
886
|
const n = [];
|
|
892
|
-
for (const
|
|
893
|
-
const i =
|
|
887
|
+
for (const o of e.payload.filter_tags ?? []) {
|
|
888
|
+
const i = o.title ?? "";
|
|
894
889
|
if (!i) continue;
|
|
895
|
-
const s = b(
|
|
890
|
+
const s = b(o.requestDetails, i), a = { title: i };
|
|
896
891
|
s && (a.action = s), n.push(a);
|
|
897
892
|
}
|
|
898
893
|
return {
|
|
@@ -903,7 +898,7 @@ function Ae(e) {
|
|
|
903
898
|
elements: { root: {
|
|
904
899
|
type: "CategoriesContainer",
|
|
905
900
|
props: {
|
|
906
|
-
groups:
|
|
901
|
+
groups: r,
|
|
907
902
|
filterTags: n
|
|
908
903
|
}
|
|
909
904
|
} }
|
|
@@ -945,29 +940,29 @@ function Ce(e) {
|
|
|
945
940
|
};
|
|
946
941
|
}
|
|
947
942
|
function q(e, t) {
|
|
948
|
-
const
|
|
949
|
-
for (let
|
|
950
|
-
const i = e[
|
|
943
|
+
const r = {}, n = [];
|
|
944
|
+
for (let o = 0; o < e.length; o++) {
|
|
945
|
+
const i = e[o];
|
|
951
946
|
if (!i) continue;
|
|
952
|
-
const s = `action-${
|
|
947
|
+
const s = `action-${o}`;
|
|
953
948
|
n.push(s);
|
|
954
949
|
const a = {
|
|
955
950
|
label: i.label,
|
|
956
951
|
action: i.action
|
|
957
952
|
};
|
|
958
|
-
i.icon !== void 0 && (a.icon = i.icon), i.image !== void 0 && (a.image = i.image), i.description !== void 0 && (a.description = i.description),
|
|
953
|
+
i.icon !== void 0 && (a.icon = i.icon), i.image !== void 0 && (a.image = i.image), i.description !== void 0 && (a.description = i.description), r[s] = {
|
|
959
954
|
type: "ActionButton",
|
|
960
955
|
props: a
|
|
961
956
|
};
|
|
962
957
|
}
|
|
963
|
-
return
|
|
958
|
+
return r.root = {
|
|
964
959
|
type: "ActionButtons",
|
|
965
|
-
props: { buttons: e.map((
|
|
960
|
+
props: { buttons: e.map((o) => {
|
|
966
961
|
const i = {
|
|
967
|
-
label:
|
|
968
|
-
action:
|
|
962
|
+
label: o.label,
|
|
963
|
+
action: o.action
|
|
969
964
|
};
|
|
970
|
-
return
|
|
965
|
+
return o.image !== void 0 && (i.image = o.image), o.description !== void 0 && (i.description = o.description), o.icon !== void 0 && (i.icon = o.icon), i;
|
|
971
966
|
}) },
|
|
972
967
|
children: n
|
|
973
968
|
}, {
|
|
@@ -975,31 +970,31 @@ function q(e, t) {
|
|
|
975
970
|
widget: t,
|
|
976
971
|
spec: {
|
|
977
972
|
root: "root",
|
|
978
|
-
elements:
|
|
973
|
+
elements: r
|
|
979
974
|
}
|
|
980
975
|
};
|
|
981
976
|
}
|
|
982
977
|
function O(e, t) {
|
|
983
|
-
const
|
|
984
|
-
for (let
|
|
985
|
-
const i = e[
|
|
978
|
+
const r = {}, n = [];
|
|
979
|
+
for (let o = 0; o < e.length; o++) {
|
|
980
|
+
const i = e[o];
|
|
986
981
|
if (!i) continue;
|
|
987
|
-
const s = w(i), a = `product-${
|
|
982
|
+
const s = w(i), a = `product-${o}`;
|
|
988
983
|
n.push(a);
|
|
989
984
|
const c = {
|
|
990
985
|
product: s,
|
|
991
|
-
index:
|
|
986
|
+
index: o
|
|
992
987
|
};
|
|
993
988
|
s.sku && (c.action = {
|
|
994
989
|
title: s.name,
|
|
995
990
|
type: "launchSingleProduct",
|
|
996
991
|
payload: { sku: s.sku }
|
|
997
|
-
}),
|
|
992
|
+
}), r[a] = {
|
|
998
993
|
type: "ProductCard",
|
|
999
994
|
props: c
|
|
1000
995
|
};
|
|
1001
996
|
}
|
|
1002
|
-
return
|
|
997
|
+
return r.root = {
|
|
1003
998
|
type: "ProductGrid",
|
|
1004
999
|
props: { layout: "grid" },
|
|
1005
1000
|
children: n
|
|
@@ -1008,31 +1003,31 @@ function O(e, t) {
|
|
|
1008
1003
|
widget: t,
|
|
1009
1004
|
spec: {
|
|
1010
1005
|
root: "root",
|
|
1011
|
-
elements:
|
|
1006
|
+
elements: r
|
|
1012
1007
|
}
|
|
1013
1008
|
};
|
|
1014
1009
|
}
|
|
1015
1010
|
function Te(e, t) {
|
|
1016
|
-
const
|
|
1017
|
-
for (let
|
|
1018
|
-
const i = e[
|
|
1011
|
+
const r = {}, n = [];
|
|
1012
|
+
for (let o = 0; o < e.length; o++) {
|
|
1013
|
+
const i = e[o];
|
|
1019
1014
|
if (!i) continue;
|
|
1020
|
-
const s = `product-${
|
|
1015
|
+
const s = `product-${o}`;
|
|
1021
1016
|
n.push(s);
|
|
1022
1017
|
const a = {
|
|
1023
1018
|
product: i,
|
|
1024
|
-
index:
|
|
1019
|
+
index: o
|
|
1025
1020
|
}, c = i.sku;
|
|
1026
1021
|
c && (a.action = {
|
|
1027
1022
|
title: i.name ?? "",
|
|
1028
1023
|
type: "launchSingleProduct",
|
|
1029
1024
|
payload: { sku: c }
|
|
1030
|
-
}),
|
|
1025
|
+
}), r[s] = {
|
|
1031
1026
|
type: "ProductCard",
|
|
1032
1027
|
props: a
|
|
1033
1028
|
};
|
|
1034
1029
|
}
|
|
1035
|
-
return
|
|
1030
|
+
return r.root = {
|
|
1036
1031
|
type: "ProductGrid",
|
|
1037
1032
|
props: { layout: "grid" },
|
|
1038
1033
|
children: n
|
|
@@ -1041,7 +1036,7 @@ function Te(e, t) {
|
|
|
1041
1036
|
widget: t,
|
|
1042
1037
|
spec: {
|
|
1043
1038
|
root: "root",
|
|
1044
|
-
elements:
|
|
1039
|
+
elements: r
|
|
1045
1040
|
}
|
|
1046
1041
|
};
|
|
1047
1042
|
}
|
|
@@ -1075,63 +1070,63 @@ function ve(e) {
|
|
|
1075
1070
|
}
|
|
1076
1071
|
};
|
|
1077
1072
|
}
|
|
1078
|
-
function
|
|
1079
|
-
const t =
|
|
1080
|
-
return
|
|
1073
|
+
function Ie(e) {
|
|
1074
|
+
const t = u(e.sku), r = u(e.short_name), n = { ...k(e.product_item) ?? e }, o = u(e.discount_reason, e.discountReason);
|
|
1075
|
+
return o && !u(n.discount_reason, n.discountReason) && (n.discount_reason = o), E(n, t, r);
|
|
1081
1076
|
}
|
|
1082
|
-
function E(e, t,
|
|
1083
|
-
const n =
|
|
1084
|
-
if (!n || !
|
|
1077
|
+
function E(e, t, r) {
|
|
1078
|
+
const n = u(e.sku, t), o = u(e.name, r);
|
|
1079
|
+
if (!n || !o) return null;
|
|
1085
1080
|
const i = {
|
|
1086
1081
|
sku: n,
|
|
1087
|
-
name:
|
|
1088
|
-
}, s =
|
|
1082
|
+
name: o
|
|
1083
|
+
}, s = u(e.brand);
|
|
1089
1084
|
s && (i.brand = s);
|
|
1090
|
-
const a =
|
|
1085
|
+
const a = u(e.url);
|
|
1091
1086
|
a && (i.url = a);
|
|
1092
|
-
const c =
|
|
1087
|
+
const c = Ne(e.images);
|
|
1093
1088
|
if (c.length > 0) i.images = c;
|
|
1094
1089
|
else {
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1090
|
+
const f = u(e.image, e.image_url, e.imageUrl);
|
|
1091
|
+
f && (i.images = [f]);
|
|
1097
1092
|
}
|
|
1098
1093
|
const m = S(e.price_discounted);
|
|
1099
1094
|
m !== void 0 && (i.price_discounted = m);
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1102
|
-
const
|
|
1103
|
-
|
|
1095
|
+
const _ = S(e.price);
|
|
1096
|
+
_ !== void 0 && (i.price = _);
|
|
1097
|
+
const d = S(e.rating);
|
|
1098
|
+
d !== void 0 && (i.rating = d);
|
|
1104
1099
|
const p = S(e.review_count) ?? S(e.reviewCount);
|
|
1105
1100
|
p !== void 0 && (i.review_count = p);
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
const
|
|
1109
|
-
return
|
|
1101
|
+
const l = u(e.cart_code, e.cartCode);
|
|
1102
|
+
l && (i.cart_code = l), typeof e.in_stock == "boolean" && (i.in_stock = e.in_stock), typeof e.inStock == "boolean" && (i.in_stock = e.inStock);
|
|
1103
|
+
const g = u(e.discount_reason, e.discountReason);
|
|
1104
|
+
return g && (i.discount_reason = g), w(i);
|
|
1110
1105
|
}
|
|
1111
1106
|
function b(e, t) {
|
|
1112
|
-
const
|
|
1113
|
-
if (!
|
|
1114
|
-
const n =
|
|
1107
|
+
const r = k(e);
|
|
1108
|
+
if (!r) return null;
|
|
1109
|
+
const n = r.type;
|
|
1115
1110
|
if (typeof n != "string" || n.length === 0) return null;
|
|
1116
|
-
const
|
|
1111
|
+
const o = {
|
|
1117
1112
|
title: t || n,
|
|
1118
1113
|
type: n
|
|
1119
1114
|
};
|
|
1120
|
-
return
|
|
1115
|
+
return r.payload !== void 0 && (o.payload = r.payload), o;
|
|
1121
1116
|
}
|
|
1122
|
-
function
|
|
1117
|
+
function k(e) {
|
|
1123
1118
|
return !e || typeof e != "object" || Array.isArray(e) ? null : e;
|
|
1124
1119
|
}
|
|
1125
|
-
function
|
|
1120
|
+
function u(...e) {
|
|
1126
1121
|
for (const t of e) if (typeof t == "string") {
|
|
1127
|
-
const
|
|
1128
|
-
if (
|
|
1122
|
+
const r = t.trim();
|
|
1123
|
+
if (r.length > 0) return r;
|
|
1129
1124
|
}
|
|
1130
1125
|
}
|
|
1131
|
-
function
|
|
1126
|
+
function Ne(e) {
|
|
1132
1127
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.length > 0) : [];
|
|
1133
1128
|
}
|
|
1134
|
-
function
|
|
1129
|
+
function H(e) {
|
|
1135
1130
|
if (typeof e == "string") {
|
|
1136
1131
|
const t = e.trim();
|
|
1137
1132
|
return t ? [t] : [];
|
|
@@ -1143,14 +1138,14 @@ function S(e) {
|
|
|
1143
1138
|
if (typeof e == "string") {
|
|
1144
1139
|
let t;
|
|
1145
1140
|
e.includes(".") && e.includes(",") ? t = e.replace(/\./g, "").replace(",", ".") : t = e.replace(",", ".");
|
|
1146
|
-
const
|
|
1147
|
-
if (Number.isFinite(
|
|
1141
|
+
const r = Number(t);
|
|
1142
|
+
if (Number.isFinite(r)) return r;
|
|
1148
1143
|
}
|
|
1149
1144
|
}
|
|
1150
1145
|
function A(e) {
|
|
1151
1146
|
return e != null;
|
|
1152
1147
|
}
|
|
1153
|
-
var
|
|
1148
|
+
var Re = /* @__PURE__ */ new Set([
|
|
1154
1149
|
"sku",
|
|
1155
1150
|
"name",
|
|
1156
1151
|
"brand",
|
|
@@ -1177,34 +1172,34 @@ var Le = /* @__PURE__ */ new Set([
|
|
|
1177
1172
|
"promotions"
|
|
1178
1173
|
]);
|
|
1179
1174
|
function w(e) {
|
|
1180
|
-
const t = e.price_discounted != null && e.price_discounted > 0,
|
|
1181
|
-
let
|
|
1182
|
-
n != null &&
|
|
1183
|
-
const i =
|
|
1175
|
+
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;
|
|
1176
|
+
let o;
|
|
1177
|
+
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);
|
|
1178
|
+
const i = u(e.brand), s = u(e.name) ?? e.sku, a = i && !s.toLowerCase().startsWith(i.toLowerCase()) ? `${i} ${s}` : s, c = {
|
|
1184
1179
|
sku: e.sku,
|
|
1185
1180
|
name: a,
|
|
1186
|
-
url:
|
|
1181
|
+
url: u(e.url) ?? ""
|
|
1187
1182
|
}, m = e.images?.[0];
|
|
1188
|
-
m && (c.imageUrl = m), e.images && e.images.length > 1 && (c.images = e.images),
|
|
1189
|
-
const
|
|
1183
|
+
m && (c.imageUrl = m), 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), i !== void 0 && (c.brand = i), 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);
|
|
1184
|
+
const _ = e, d = {};
|
|
1190
1185
|
let p = !1;
|
|
1191
|
-
for (const
|
|
1192
|
-
return p && (c.extras =
|
|
1186
|
+
for (const l of Object.keys(_)) Re.has(l) || (d[l] = _[l], p = !0);
|
|
1187
|
+
return p && (c.extras = d), c;
|
|
1193
1188
|
}
|
|
1194
|
-
function
|
|
1189
|
+
function je(e) {
|
|
1195
1190
|
return e.results.map(w);
|
|
1196
1191
|
}
|
|
1197
|
-
function
|
|
1192
|
+
function Me(e) {
|
|
1198
1193
|
return e.product_groupings.map((t) => {
|
|
1199
|
-
const
|
|
1194
|
+
const r = {
|
|
1200
1195
|
name: t.name,
|
|
1201
1196
|
products: (t.group_products ?? []).map(w)
|
|
1202
1197
|
};
|
|
1203
|
-
return t.highlight !== void 0 && (
|
|
1198
|
+
return t.highlight !== void 0 && (r.highlight = t.highlight), r;
|
|
1204
1199
|
});
|
|
1205
1200
|
}
|
|
1206
|
-
function
|
|
1207
|
-
const t = e.payload.type, { type:
|
|
1201
|
+
function Le(e) {
|
|
1202
|
+
const t = e.payload.type, { type: r, ...n } = e.payload;
|
|
1208
1203
|
return {
|
|
1209
1204
|
type: "ui_spec",
|
|
1210
1205
|
widget: "chat",
|
|
@@ -1217,34 +1212,34 @@ function De(e) {
|
|
|
1217
1212
|
}
|
|
1218
1213
|
};
|
|
1219
1214
|
}
|
|
1220
|
-
var
|
|
1215
|
+
var De = {
|
|
1221
1216
|
process_action: "/process_action",
|
|
1222
1217
|
launcher_action: "/launcher_action",
|
|
1223
1218
|
similar_products: "/similar_products",
|
|
1224
1219
|
product_groupings: "/product_groupings"
|
|
1225
1220
|
};
|
|
1226
|
-
function
|
|
1221
|
+
function qe(e) {
|
|
1227
1222
|
if (e === void 0) throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");
|
|
1228
1223
|
const t = e.trim();
|
|
1229
1224
|
return t === "" ? "" : t.replace(/\/+$/, "");
|
|
1230
1225
|
}
|
|
1231
|
-
function
|
|
1232
|
-
return `${
|
|
1226
|
+
function $e(e, t) {
|
|
1227
|
+
return `${qe(t?.middlewareUrl)}/chat${De[e]}`;
|
|
1233
1228
|
}
|
|
1234
1229
|
export {
|
|
1235
|
-
|
|
1230
|
+
je as a,
|
|
1236
1231
|
V as c,
|
|
1237
|
-
|
|
1238
|
-
|
|
1232
|
+
j as d,
|
|
1233
|
+
ze as f,
|
|
1239
1234
|
He as h,
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1235
|
+
Me as i,
|
|
1236
|
+
B as l,
|
|
1237
|
+
z as m,
|
|
1238
|
+
qe as n,
|
|
1244
1239
|
w as o,
|
|
1245
|
-
|
|
1246
|
-
|
|
1240
|
+
Ue as p,
|
|
1241
|
+
Ge as r,
|
|
1247
1242
|
R as s,
|
|
1248
|
-
|
|
1249
|
-
|
|
1243
|
+
$e as t,
|
|
1244
|
+
K as u
|
|
1250
1245
|
};
|