@gengage/assistant-fe 0.2.3 → 0.2.5
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/assistant-fe.css +1 -1
- package/dist/chat/api.d.ts.map +1 -1
- package/dist/chat/catalog.d.ts +2 -0
- package/dist/chat/catalog.d.ts.map +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +47 -2
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
- package/dist/chat/components/ChoicePrompter.d.ts +3 -1
- package/dist/chat/components/ChoicePrompter.d.ts.map +1 -1
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
- package/dist/chat/components/GroundingReviewCard.d.ts.map +1 -1
- package/dist/chat/components/PanelTopBar.d.ts +1 -0
- package/dist/chat/components/PanelTopBar.d.ts.map +1 -1
- package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -1
- package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
- package/dist/chat/components/renderUISpec.d.ts.map +1 -1
- package/dist/chat/index.d.ts +22 -0
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/locales/en.d.ts.map +1 -1
- package/dist/chat/locales/tr.d.ts.map +1 -1
- package/dist/chat/panel-manager.d.ts +6 -4
- package/dist/chat/panel-manager.d.ts.map +1 -1
- package/dist/chat/session-persistence.d.ts +6 -1
- package/dist/chat/session-persistence.d.ts.map +1 -1
- package/dist/chat/types.d.ts +23 -1
- package/dist/chat/types.d.ts.map +1 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +29 -29
- package/dist/chat.iife.js.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/common/action-router.d.ts.map +1 -1
- package/dist/common/communication-bridge.d.ts.map +1 -1
- package/dist/common/ga-datalayer.d.ts.map +1 -1
- package/dist/common/price-formatter.d.ts +1 -1
- package/dist/common/price-formatter.d.ts.map +1 -1
- package/dist/common/product-utils.d.ts.map +1 -1
- package/dist/common/quantity-stepper.d.ts +1 -1
- package/dist/common/quantity-stepper.d.ts.map +1 -1
- package/dist/common/skeleton.d.ts +9 -0
- package/dist/common/skeleton.d.ts.map +1 -0
- package/dist/common/widget-base.d.ts.map +1 -1
- package/dist/common.cjs +1 -1
- package/dist/common.js +5 -5
- package/dist/{index-Bctbyou5.cjs → index-B6xRdkMq.cjs} +2 -2
- package/dist/{index-Bctbyou5.cjs.map → index-B6xRdkMq.cjs.map} +1 -1
- package/dist/{index-BaG-fiAK.js → index-BsvmfVa1.js} +3 -3
- package/dist/{index-BaG-fiAK.js.map → index-BsvmfVa1.js.map} +1 -1
- package/dist/index-BzCc2DCm.cjs +13 -0
- package/dist/index-BzCc2DCm.cjs.map +1 -0
- package/dist/index-D5UPIXIA.js +4831 -0
- package/dist/index-D5UPIXIA.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/native.cjs +1 -1
- package/dist/native.iife.js +29 -29
- package/dist/native.iife.js.map +1 -1
- package/dist/native.js +1 -1
- package/dist/qna/index.d.ts.map +1 -1
- package/dist/qna.cjs +1 -1
- package/dist/qna.cjs.map +1 -1
- package/dist/qna.css +1 -1
- package/dist/qna.iife.js +14 -14
- package/dist/qna.iife.js.map +1 -1
- package/dist/qna.js +57 -48
- package/dist/qna.js.map +1 -1
- package/dist/quantity-stepper-CQWgexMO.cjs +2 -0
- package/dist/quantity-stepper-CQWgexMO.cjs.map +1 -0
- package/dist/quantity-stepper-CjY_cpgJ.js +80 -0
- package/dist/quantity-stepper-CjY_cpgJ.js.map +1 -0
- package/dist/{schemas-DOxyUYVA.cjs → schemas-CNzyBhf7.cjs} +8 -8
- package/dist/schemas-CNzyBhf7.cjs.map +1 -0
- package/dist/{schemas-D1Kd4wn8.js → schemas-Fiaobs4L.js} +306 -308
- package/dist/schemas-Fiaobs4L.js.map +1 -0
- package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
- package/dist/simrel/components/ProductCard.d.ts.map +1 -1
- package/dist/simrel/components/ProductGrid.d.ts.map +1 -1
- package/dist/simrel/index.d.ts.map +1 -1
- package/dist/simrel/locales/en.d.ts.map +1 -1
- package/dist/simrel/locales/tr.d.ts.map +1 -1
- package/dist/simrel/types.d.ts +6 -0
- package/dist/simrel/types.d.ts.map +1 -1
- package/dist/simrel.cjs +1 -1
- package/dist/simrel.cjs.map +1 -1
- package/dist/simrel.css +1 -1
- package/dist/simrel.iife.js +11 -11
- package/dist/simrel.iife.js.map +1 -1
- package/dist/simrel.js +163 -158
- package/dist/simrel.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-BHaQLt-o.js +0 -4468
- package/dist/index-BHaQLt-o.js.map +0 -1
- package/dist/index-CO5VnxEn.cjs +0 -13
- package/dist/index-CO5VnxEn.cjs.map +0 -1
- package/dist/quantity-stepper-BKtPQUR1.js +0 -78
- package/dist/quantity-stepper-BKtPQUR1.js.map +0 -1
- package/dist/quantity-stepper-DU6va4sS.cjs +0 -2
- package/dist/quantity-stepper-DU6va4sS.cjs.map +0 -1
- package/dist/schemas-D1Kd4wn8.js.map +0 -1
- package/dist/schemas-DOxyUYVA.cjs.map +0 -1
package/dist/index-BHaQLt-o.js
DELETED
|
@@ -1,4468 +0,0 @@
|
|
|
1
|
-
import { D as He, E as O, b as Oe, c as je, a as Ve, v as G, x as K, F, r as We, o as B, s as x, f as U, G as re, d as ge, u as de, y as Z, e as Q, _ as Se, B as $e, H as Ge, j as W, t as Ye, i as Ke, I as Qe, J as Xe, g as Je, K as Ze, L as et, M as be, m as tt, N as at, A as nt, z as it, n as ot, O as rt, P as xe, h as st, Q as ct, R as lt, l as gt, S as dt, T as pt, U as ht, V as ut, W as mt, X as ft } from "./schemas-D1Kd4wn8.js";
|
|
2
|
-
import { f as H, c as pe, a as J, b as Te, e as bt, d as Le } from "./quantity-stepper-BKtPQUR1.js";
|
|
3
|
-
function xt() {
|
|
4
|
-
const o = Date.now(), e = new Uint8Array(16);
|
|
5
|
-
crypto.getRandomValues(e), e[0] = o / 2 ** 40 & 255, e[1] = o / 2 ** 32 & 255, e[2] = o / 2 ** 24 & 255, e[3] = o / 2 ** 16 & 255, e[4] = o / 2 ** 8 & 255, e[5] = o & 255, e[6] = e[6] & 15 | 112, e[8] = e[8] & 63 | 128;
|
|
6
|
-
const t = Array.from(e, (a) => a.toString(16).padStart(2, "0")).join("");
|
|
7
|
-
return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
|
|
8
|
-
}
|
|
9
|
-
class vt {
|
|
10
|
-
constructor(e) {
|
|
11
|
-
this._handlers = /* @__PURE__ */ new Map(), this._destroyed = !1, this._namespace = e.namespace, this._allowedOrigins = e.allowedOrigins ?? ["*"], this._onMessage = e.onMessage, this._allowedOrigins.includes("*"), this._messageListener = (t) => this._handlePostMessage(t), window.addEventListener("message", this._messageListener);
|
|
12
|
-
}
|
|
13
|
-
/** Send a message to the host page via CustomEvent on window. */
|
|
14
|
-
send(e, t) {
|
|
15
|
-
if (this._destroyed) return;
|
|
16
|
-
const a = {
|
|
17
|
-
namespace: this._namespace,
|
|
18
|
-
type: e
|
|
19
|
-
};
|
|
20
|
-
t !== void 0 && (a.payload = t), window.dispatchEvent(
|
|
21
|
-
new CustomEvent("gengage:bridge:message", {
|
|
22
|
-
detail: a,
|
|
23
|
-
bubbles: !1
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Register a handler for a specific message type.
|
|
29
|
-
* Returns an unsubscribe function.
|
|
30
|
-
*/
|
|
31
|
-
on(e, t) {
|
|
32
|
-
this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set());
|
|
33
|
-
const a = this._handlers.get(e);
|
|
34
|
-
return a.add(t), () => {
|
|
35
|
-
a.delete(t), a.size === 0 && this._handlers.delete(e);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/** Clean up all event listeners and handlers. */
|
|
39
|
-
destroy() {
|
|
40
|
-
this._destroyed || (this._destroyed = !0, window.removeEventListener("message", this._messageListener), this._handlers.clear());
|
|
41
|
-
}
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
// Private
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
_handlePostMessage(e) {
|
|
46
|
-
if (this._destroyed || !this._isOriginAllowed(e.origin)) return;
|
|
47
|
-
const t = e.data;
|
|
48
|
-
if (!wt(t) || t.gengage !== this._namespace) return;
|
|
49
|
-
const a = { type: t.type };
|
|
50
|
-
t.payload !== void 0 && (a.payload = t.payload), this._onMessage?.(a);
|
|
51
|
-
const n = this._handlers.get(a.type);
|
|
52
|
-
if (n)
|
|
53
|
-
for (const i of n)
|
|
54
|
-
i(a.payload);
|
|
55
|
-
}
|
|
56
|
-
_isOriginAllowed(e) {
|
|
57
|
-
return this._allowedOrigins.includes("*") ? !0 : this._allowedOrigins.includes(e);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function wt(o) {
|
|
61
|
-
if (typeof o != "object" || o === null) return !1;
|
|
62
|
-
const e = o;
|
|
63
|
-
return typeof e.gengage == "string" && typeof e.type == "string";
|
|
64
|
-
}
|
|
65
|
-
const yt = console;
|
|
66
|
-
function _t(o, e, t = {}) {
|
|
67
|
-
const a = o.action, n = t.logger ?? yt;
|
|
68
|
-
switch (He("action", `routing action: ${a.kind}`, a), a.kind) {
|
|
69
|
-
case "open_chat": {
|
|
70
|
-
e.openChat?.(a.payload);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
case "navigate": {
|
|
74
|
-
if (typeof a.url != "string") {
|
|
75
|
-
te(a, e, t, n);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const i = typeof a.newTab == "boolean" ? a.newTab : void 0;
|
|
79
|
-
if (e.navigate) {
|
|
80
|
-
e.navigate({ url: a.url, ...i !== void 0 && { newTab: i } });
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
kt(a.url, i);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
case "save_session": {
|
|
87
|
-
if (typeof a.sessionId != "string" || typeof a.sku != "string") {
|
|
88
|
-
te(a, e, t, n);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
e.saveSession?.({ sessionId: a.sessionId, sku: a.sku });
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
case "add_to_cart": {
|
|
95
|
-
if (typeof a.sku != "string" || typeof a.quantity != "number" || typeof a.cartCode != "string") {
|
|
96
|
-
te(a, e, t, n);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
e.addToCart?.({
|
|
100
|
-
sku: a.sku,
|
|
101
|
-
quantity: a.quantity,
|
|
102
|
-
cartCode: a.cartCode
|
|
103
|
-
});
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
case "script_call": {
|
|
107
|
-
if (t.allowScriptCall === !1) {
|
|
108
|
-
te(a, e, t, n);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (typeof a.name != "string") {
|
|
112
|
-
te(a, e, t, n);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const i = Ct(a.payload) ? a.payload : void 0;
|
|
116
|
-
e.scriptCall?.({ name: a.name, ...i !== void 0 && { payload: i } });
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
default:
|
|
120
|
-
te(a, e, t, n);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function te(o, e, t, a) {
|
|
124
|
-
const n = t.unknownActionPolicy ?? "log-and-ignore";
|
|
125
|
-
if (n === "delegate") {
|
|
126
|
-
e.unknown?.(o), e.unknown || a.warn("[gengage] Unknown action received without delegate handler", o);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (n === "throw")
|
|
130
|
-
throw new Error(`[gengage] Unknown action kind: ${o.kind}`);
|
|
131
|
-
a.warn("[gengage] Unknown action ignored", o);
|
|
132
|
-
}
|
|
133
|
-
function kt(o, e) {
|
|
134
|
-
if (!(typeof window > "u")) {
|
|
135
|
-
if (!O(o)) {
|
|
136
|
-
console.warn("[gengage] Blocked navigation to unsafe URL:", o);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (e) {
|
|
140
|
-
window.open(o, "_blank", "noopener,noreferrer");
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
window.location.href = o;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function Ct(o) {
|
|
147
|
-
return typeof o == "object" && o !== null && !Array.isArray(o);
|
|
148
|
-
}
|
|
149
|
-
const Et = ["image/jpeg", "image/png", "image/webp"], St = 5 * 1024 * 1024;
|
|
150
|
-
function Tt(o) {
|
|
151
|
-
return Et.includes(o.type) ? o.size > St ? { ok: !1, reason: "too_large" } : { ok: !0 } : { ok: !1, reason: "invalid_type" };
|
|
152
|
-
}
|
|
153
|
-
function Lt(o, e) {
|
|
154
|
-
const t = o.type, a = o.payload != null && typeof o.payload == "object" && !Array.isArray(o.payload) ? o.payload : {}, n = (i) => {
|
|
155
|
-
const s = { ...a };
|
|
156
|
-
for (const [l, d] of Object.entries(i))
|
|
157
|
-
l in s || (s[l] = d);
|
|
158
|
-
return s;
|
|
159
|
-
};
|
|
160
|
-
switch (t) {
|
|
161
|
-
case "inputText": {
|
|
162
|
-
const i = {
|
|
163
|
-
is_launcher: 0
|
|
164
|
-
};
|
|
165
|
-
return e.pageContext?.extra && (i.page_details = e.pageContext.extra), "is_suggested_text" in a || (i.is_suggested_text = 0), { ...o, payload: n(i) };
|
|
166
|
-
}
|
|
167
|
-
case "findSimilar": {
|
|
168
|
-
const i = {
|
|
169
|
-
is_launcher: 0
|
|
170
|
-
};
|
|
171
|
-
return o.title && (i.text = o.title), o.title && (i.input = o.title), { ...o, payload: n(i) };
|
|
172
|
-
}
|
|
173
|
-
case "getComparisonTable":
|
|
174
|
-
return o;
|
|
175
|
-
case "addToCart": {
|
|
176
|
-
const i = {};
|
|
177
|
-
return "error_message" in a || (i.error_message = ""), { ...o, payload: n(i) };
|
|
178
|
-
}
|
|
179
|
-
case "reviewSummary": {
|
|
180
|
-
const i = {};
|
|
181
|
-
return e.pageContext?.sku && !("sku" in a) && (i.sku = e.pageContext.sku), Object.keys(i).length === 0 ? o : { ...o, payload: n(i) };
|
|
182
|
-
}
|
|
183
|
-
default:
|
|
184
|
-
return o;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const It = {
|
|
188
|
-
user_message: "inputText"
|
|
189
|
-
};
|
|
190
|
-
function At(o) {
|
|
191
|
-
const { action: e, type: t, payload: a, ...n } = o, i = t ?? e?.type ?? "inputText", s = a ?? e?.payload, l = It[i] ?? i, d = {
|
|
192
|
-
...n,
|
|
193
|
-
type: l
|
|
194
|
-
};
|
|
195
|
-
return s !== void 0 && (d.payload = typeof s == "string" ? { text: s } : s), JSON.stringify(d);
|
|
196
|
-
}
|
|
197
|
-
function Pt(o, e, t) {
|
|
198
|
-
const a = Oe("process_action", t), n = new AbortController();
|
|
199
|
-
return (async () => {
|
|
200
|
-
try {
|
|
201
|
-
const s = At(o), l = t.attachment !== void 0;
|
|
202
|
-
let d;
|
|
203
|
-
if (l) {
|
|
204
|
-
const m = new FormData();
|
|
205
|
-
m.append("request", s), t.attachment !== void 0 && m.append("attachment", t.attachment), d = {
|
|
206
|
-
method: "POST",
|
|
207
|
-
body: m,
|
|
208
|
-
signal: n.signal
|
|
209
|
-
};
|
|
210
|
-
} else
|
|
211
|
-
d = {
|
|
212
|
-
method: "POST",
|
|
213
|
-
headers: { "Content-Type": "application/json" },
|
|
214
|
-
body: s,
|
|
215
|
-
signal: n.signal
|
|
216
|
-
};
|
|
217
|
-
const c = await fetch(a, d);
|
|
218
|
-
if (!c.ok) {
|
|
219
|
-
let m = c.statusText;
|
|
220
|
-
try {
|
|
221
|
-
const h = await c.json(), y = h.detail ?? h.message ?? h.error;
|
|
222
|
-
typeof y == "string" && (m = y);
|
|
223
|
-
} catch {
|
|
224
|
-
}
|
|
225
|
-
e.onError(new Error(`HTTP ${c.status}: ${m}`));
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
let g = !1;
|
|
229
|
-
const r = () => {
|
|
230
|
-
g || (g = !0, e.onDone());
|
|
231
|
-
};
|
|
232
|
-
await je(c, {
|
|
233
|
-
onEvent: (m) => {
|
|
234
|
-
const h = Ve(m);
|
|
235
|
-
if (h)
|
|
236
|
-
switch (h.type) {
|
|
237
|
-
case "text_chunk":
|
|
238
|
-
e.onTextChunk(h.content, h.final === !0, {
|
|
239
|
-
productMentions: h.productMentions,
|
|
240
|
-
skuToProductItem: h.skuToProductItem,
|
|
241
|
-
conversationMode: h.conversationMode
|
|
242
|
-
});
|
|
243
|
-
break;
|
|
244
|
-
case "ui_spec":
|
|
245
|
-
e.onUISpec(h.spec, h.widget, h.panelHint);
|
|
246
|
-
break;
|
|
247
|
-
case "action":
|
|
248
|
-
e.onAction(h);
|
|
249
|
-
break;
|
|
250
|
-
case "metadata":
|
|
251
|
-
e.onMetadata(h);
|
|
252
|
-
break;
|
|
253
|
-
case "error":
|
|
254
|
-
e.onError(new Error(h.message));
|
|
255
|
-
break;
|
|
256
|
-
case "done":
|
|
257
|
-
r();
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
onError: e.onError,
|
|
262
|
-
signal: n.signal
|
|
263
|
-
}), r();
|
|
264
|
-
} catch (s) {
|
|
265
|
-
if (s instanceof DOMException && s.name === "AbortError") return;
|
|
266
|
-
e.onError(s instanceof Error ? s : new Error(String(s)));
|
|
267
|
-
}
|
|
268
|
-
})(), n;
|
|
269
|
-
}
|
|
270
|
-
const he = {
|
|
271
|
-
headerTitle: "Ürün Uzmanı",
|
|
272
|
-
inputPlaceholder: "Ürün ara, soru sor",
|
|
273
|
-
sendButton: "Gönder",
|
|
274
|
-
closeButton: "Kapat",
|
|
275
|
-
openButton: "Sohbeti aç",
|
|
276
|
-
newChatButton: "Yeni sohbet",
|
|
277
|
-
poweredBy: "Powered by Gengage",
|
|
278
|
-
errorMessage: "Bir hata oluştu. Lütfen tekrar deneyin.",
|
|
279
|
-
retryButton: "Tekrar Dene",
|
|
280
|
-
loadingMessage: "Düşünüyorum...",
|
|
281
|
-
productCtaLabel: "İncele",
|
|
282
|
-
attachImageButton: "Resim ekle",
|
|
283
|
-
removeAttachmentButton: "Resmi kaldır",
|
|
284
|
-
invalidFileType: "Sadece JPEG, PNG ve WebP dosyaları destekleniyor.",
|
|
285
|
-
fileTooLarge: "Dosya boyutu 5 MB'dan küçük olmalıdır.",
|
|
286
|
-
aiTopPicksTitle: "Sizin İçin En İyiler",
|
|
287
|
-
roleWinner: "En Beğendiğim",
|
|
288
|
-
roleBestValue: "En Uygun Fiyatlı",
|
|
289
|
-
roleBestAlternative: "En İyi Alternatif",
|
|
290
|
-
viewDetails: "Detayları Gör",
|
|
291
|
-
groundingReviewCta: "Yorumları Oku",
|
|
292
|
-
groundingReviewSubtitle: "{count} yorum mevcut",
|
|
293
|
-
variantsLabel: "Varyantlar",
|
|
294
|
-
sortRelated: "Önerilen",
|
|
295
|
-
sortPriceAsc: "Fiyat ↑",
|
|
296
|
-
sortPriceDesc: "Fiyat ↓",
|
|
297
|
-
compareSelected: "Karşılaştır",
|
|
298
|
-
compareMinHint: "En az 2 ürün seçin",
|
|
299
|
-
panelTitleProductDetails: "Ürün Detayı",
|
|
300
|
-
panelTitleSimilarProducts: "Benzer Ürünler",
|
|
301
|
-
panelTitleComparisonResults: "Karşılaştırma Sonuçları",
|
|
302
|
-
panelTitleCategories: "Kategoriler",
|
|
303
|
-
panelTitleSearchResults: "Arama Sonuçları",
|
|
304
|
-
inStockLabel: "Stokta",
|
|
305
|
-
outOfStockLabel: "Tükendi",
|
|
306
|
-
findSimilarLabel: "Benzerlerini Bul",
|
|
307
|
-
choicePrompterHeading: "Kararsız mı kaldın?",
|
|
308
|
-
choicePrompterSuggestion: "Ürünleri seçip karşılaştırabilirsin",
|
|
309
|
-
choicePrompterCta: "Seç ve Karşılaştır",
|
|
310
|
-
viewMoreLabel: "Daha Fazla Göster",
|
|
311
|
-
similarProductsLabel: "Benzer Ürünler",
|
|
312
|
-
addToCartButton: "Sepete Ekle",
|
|
313
|
-
shareButton: "Paylaş",
|
|
314
|
-
productInfoTab: "Ürün Bilgileri",
|
|
315
|
-
specificationsTab: "Teknik Özellikler",
|
|
316
|
-
recommendedChoiceLabel: "Önerilen Seçim",
|
|
317
|
-
highlightsLabel: "Öne Çıkan Özellikler",
|
|
318
|
-
keyDifferencesLabel: "Temel Farklar",
|
|
319
|
-
specialCasesLabel: "Özel Durumlar İçin",
|
|
320
|
-
emptyReviewsMessage: "Yorum özeti bulunamadı.",
|
|
321
|
-
closeAriaLabel: "Kapat",
|
|
322
|
-
startChatLabel: "Sohbete Başla",
|
|
323
|
-
voiceButton: "Sesli giriş",
|
|
324
|
-
voiceListening: "Dinleniyor...",
|
|
325
|
-
voiceNotSupported: "Sesli giriş bu tarayıcıda desteklenmiyor.",
|
|
326
|
-
voicePermissionDenied: "Mikrofon erişimi reddedildi.",
|
|
327
|
-
voiceError: "Sesli giriş hatası.",
|
|
328
|
-
handoffHeading: "Destek temsilcisine aktarılıyor",
|
|
329
|
-
productNotFoundMessage: "Bu ürün bilgisi şu an kullanılamıyor. Başka bir konuda yardımcı olabilirim.",
|
|
330
|
-
stopGenerating: "Yanıtı Durdur",
|
|
331
|
-
offlineMessage: "Çevrimdışısınız — bağlantı kurulduğunda mesajlar gönderilecek.",
|
|
332
|
-
stillWorkingMessage: "İsteğiniz üzerinde hâlâ çalışılıyor...",
|
|
333
|
-
cartAriaLabel: "Sepetim",
|
|
334
|
-
favoritesAriaLabel: "Favorilerim",
|
|
335
|
-
addToFavoritesLabel: "Favorilere ekle",
|
|
336
|
-
customerReviewsTitle: "Müşteri Yorumları",
|
|
337
|
-
togglePanelAriaLabel: "Paneli aç/kapat",
|
|
338
|
-
chatMessagesAriaLabel: "Sohbet mesajları",
|
|
339
|
-
suggestionsAriaLabel: "Öneriler",
|
|
340
|
-
moreSuggestionsAriaLabel: "Daha fazla öneri",
|
|
341
|
-
rollbackAriaLabel: "Bu mesaja geri dön",
|
|
342
|
-
backAriaLabel: "Geri",
|
|
343
|
-
forwardAriaLabel: "İleri",
|
|
344
|
-
dismissAriaLabel: "Kapat",
|
|
345
|
-
cartAddErrorMessage: "Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.",
|
|
346
|
-
reviewFilterAll: "Tümü",
|
|
347
|
-
reviewFilterPositive: "Olumlu",
|
|
348
|
-
reviewFilterNegative: "Olumsuz",
|
|
349
|
-
decreaseLabel: "Azalt",
|
|
350
|
-
increaseLabel: "Artır"
|
|
351
|
-
}, Nt = {
|
|
352
|
-
headerTitle: "Product Expert",
|
|
353
|
-
inputPlaceholder: "Search products, ask questions",
|
|
354
|
-
sendButton: "Send",
|
|
355
|
-
closeButton: "Close",
|
|
356
|
-
openButton: "Open chat",
|
|
357
|
-
newChatButton: "New chat",
|
|
358
|
-
poweredBy: "Powered by Gengage",
|
|
359
|
-
errorMessage: "Something went wrong. Please try again.",
|
|
360
|
-
retryButton: "Retry",
|
|
361
|
-
loadingMessage: "Thinking...",
|
|
362
|
-
productCtaLabel: "View",
|
|
363
|
-
attachImageButton: "Attach image",
|
|
364
|
-
removeAttachmentButton: "Remove image",
|
|
365
|
-
invalidFileType: "Only JPEG, PNG and WebP files are supported.",
|
|
366
|
-
fileTooLarge: "File must be smaller than 5 MB.",
|
|
367
|
-
aiTopPicksTitle: "Top Picks for You",
|
|
368
|
-
roleWinner: "Top Pick",
|
|
369
|
-
roleBestValue: "Best Value",
|
|
370
|
-
roleBestAlternative: "Best Alternative",
|
|
371
|
-
viewDetails: "View Details",
|
|
372
|
-
groundingReviewCta: "Read Reviews",
|
|
373
|
-
groundingReviewSubtitle: "{count} reviews available",
|
|
374
|
-
variantsLabel: "Variants",
|
|
375
|
-
sortRelated: "Related",
|
|
376
|
-
sortPriceAsc: "Price ↑",
|
|
377
|
-
sortPriceDesc: "Price ↓",
|
|
378
|
-
compareSelected: "Compare",
|
|
379
|
-
compareMinHint: "Select at least 2 products",
|
|
380
|
-
panelTitleProductDetails: "Product Details",
|
|
381
|
-
panelTitleSimilarProducts: "Similar Products",
|
|
382
|
-
panelTitleComparisonResults: "Comparison Results",
|
|
383
|
-
panelTitleCategories: "Categories",
|
|
384
|
-
panelTitleSearchResults: "Search Results",
|
|
385
|
-
inStockLabel: "In Stock",
|
|
386
|
-
outOfStockLabel: "Out of Stock",
|
|
387
|
-
findSimilarLabel: "Find Similar",
|
|
388
|
-
choicePrompterHeading: "Can't decide?",
|
|
389
|
-
choicePrompterSuggestion: "Select products to compare them",
|
|
390
|
-
choicePrompterCta: "Select & Compare",
|
|
391
|
-
viewMoreLabel: "Show More",
|
|
392
|
-
similarProductsLabel: "Similar Products",
|
|
393
|
-
addToCartButton: "Add to Cart",
|
|
394
|
-
shareButton: "Share",
|
|
395
|
-
productInfoTab: "Product Info",
|
|
396
|
-
specificationsTab: "Specifications",
|
|
397
|
-
recommendedChoiceLabel: "Recommended Choice",
|
|
398
|
-
highlightsLabel: "Key Highlights",
|
|
399
|
-
keyDifferencesLabel: "Key Differences",
|
|
400
|
-
specialCasesLabel: "For Special Cases",
|
|
401
|
-
emptyReviewsMessage: "No review summary found.",
|
|
402
|
-
closeAriaLabel: "Close",
|
|
403
|
-
startChatLabel: "Start Chat",
|
|
404
|
-
voiceButton: "Voice input",
|
|
405
|
-
voiceListening: "Listening...",
|
|
406
|
-
voiceNotSupported: "Voice input is not supported in this browser.",
|
|
407
|
-
voicePermissionDenied: "Microphone access denied.",
|
|
408
|
-
voiceError: "Voice input error.",
|
|
409
|
-
handoffHeading: "Transferring to a support agent",
|
|
410
|
-
productNotFoundMessage: "Product information is currently unavailable. I can help with something else.",
|
|
411
|
-
stopGenerating: "Stop generating",
|
|
412
|
-
offlineMessage: "You're offline — messages will send when you reconnect.",
|
|
413
|
-
stillWorkingMessage: "Still working on your request...",
|
|
414
|
-
cartAriaLabel: "My cart",
|
|
415
|
-
favoritesAriaLabel: "My favorites",
|
|
416
|
-
addToFavoritesLabel: "Add to favorites",
|
|
417
|
-
customerReviewsTitle: "Customer Reviews",
|
|
418
|
-
togglePanelAriaLabel: "Toggle panel",
|
|
419
|
-
chatMessagesAriaLabel: "Chat messages",
|
|
420
|
-
suggestionsAriaLabel: "Suggestions",
|
|
421
|
-
moreSuggestionsAriaLabel: "More suggestions",
|
|
422
|
-
rollbackAriaLabel: "Rollback to this message",
|
|
423
|
-
backAriaLabel: "Back",
|
|
424
|
-
forwardAriaLabel: "Forward",
|
|
425
|
-
dismissAriaLabel: "Dismiss",
|
|
426
|
-
cartAddErrorMessage: "Sorry, I couldn't add that to your cart. Something went wrong.",
|
|
427
|
-
reviewFilterAll: "All",
|
|
428
|
-
reviewFilterPositive: "Positive",
|
|
429
|
-
reviewFilterNegative: "Negative",
|
|
430
|
-
decreaseLabel: "Decrease",
|
|
431
|
-
increaseLabel: "Increase"
|
|
432
|
-
};
|
|
433
|
-
function Mt(o) {
|
|
434
|
-
return o ? o.toLowerCase().split("-")[0] ?? "tr" : "tr";
|
|
435
|
-
}
|
|
436
|
-
function Bt(o) {
|
|
437
|
-
return Mt(o) === "en" ? Nt : he;
|
|
438
|
-
}
|
|
439
|
-
function zt() {
|
|
440
|
-
return Ie() !== null;
|
|
441
|
-
}
|
|
442
|
-
function Ie() {
|
|
443
|
-
const o = globalThis;
|
|
444
|
-
return o.SpeechRecognition ?? o.webkitSpeechRecognition ?? null;
|
|
445
|
-
}
|
|
446
|
-
class Rt {
|
|
447
|
-
constructor(e, t) {
|
|
448
|
-
this.recognition = null, this._state = "idle", this.silenceTimer = null, this.accumulatedTranscript = "", this.intentionalStop = !1, this._lastRestartAt = 0, this.callbacks = e, this.lang = t?.lang ?? "tr-TR", this.silenceTimeoutMs = t?.silenceTimeoutMs ?? 1500, this.autoSubmit = t?.autoSubmit ?? !0;
|
|
449
|
-
}
|
|
450
|
-
get state() {
|
|
451
|
-
return this._state;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Start listening. Requests microphone permission on first call.
|
|
455
|
-
*/
|
|
456
|
-
start() {
|
|
457
|
-
if (this._state === "listening") return;
|
|
458
|
-
const e = Ie();
|
|
459
|
-
if (!e) {
|
|
460
|
-
this.setState("error"), this.callbacks.onError?.("not-supported", "Web Speech API is not supported in this browser.");
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (typeof globalThis.isSecureContext < "u" && !globalThis.isSecureContext) {
|
|
464
|
-
this.setState("error"), this.callbacks.onError?.("not-allowed", "Voice input requires HTTPS.");
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
this.accumulatedTranscript = "", this.intentionalStop = !1;
|
|
468
|
-
const t = new e();
|
|
469
|
-
t.continuous = !0, t.interimResults = !0, t.lang = this.lang, t.maxAlternatives = 1, t.onstart = () => {
|
|
470
|
-
this.setState("listening");
|
|
471
|
-
}, t.onresult = (a) => {
|
|
472
|
-
this.clearSilenceTimer();
|
|
473
|
-
let n = "", i = "";
|
|
474
|
-
for (let s = a.resultIndex; s < a.results.length; s++) {
|
|
475
|
-
const l = a.results[s];
|
|
476
|
-
if (!l) continue;
|
|
477
|
-
const d = l[0];
|
|
478
|
-
d && (l.isFinal ? i += d.transcript : n += d.transcript);
|
|
479
|
-
}
|
|
480
|
-
i && (this.accumulatedTranscript += i, this.callbacks.onFinal?.(this.accumulatedTranscript)), n && this.callbacks.onInterim?.(this.accumulatedTranscript + n), this.autoSubmit && this.accumulatedTranscript && this.startSilenceTimer();
|
|
481
|
-
}, t.onerror = (a) => {
|
|
482
|
-
const n = Dt(a.error);
|
|
483
|
-
this.intentionalStop && (a.error === "no-speech" || a.error === "aborted") || (this.setState("error"), this.callbacks.onError?.(n, a.message || a.error));
|
|
484
|
-
}, t.onend = () => {
|
|
485
|
-
if (this.clearSilenceTimer(), this._state === "listening" && !this.intentionalStop) {
|
|
486
|
-
const a = Date.now();
|
|
487
|
-
if (a - this._lastRestartAt < 500) {
|
|
488
|
-
this.setState("idle");
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
this._lastRestartAt = a;
|
|
492
|
-
try {
|
|
493
|
-
t.start();
|
|
494
|
-
} catch {
|
|
495
|
-
this.setState("idle");
|
|
496
|
-
}
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
this.setState("idle");
|
|
500
|
-
}, this.recognition = t;
|
|
501
|
-
try {
|
|
502
|
-
t.start();
|
|
503
|
-
} catch {
|
|
504
|
-
this.setState("error"), this.callbacks.onError?.("unknown", "Failed to start speech recognition.");
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Stop listening. Returns the accumulated transcript.
|
|
509
|
-
*/
|
|
510
|
-
stop() {
|
|
511
|
-
if (this.intentionalStop = !0, this.clearSilenceTimer(), this.recognition) {
|
|
512
|
-
try {
|
|
513
|
-
this.recognition.stop();
|
|
514
|
-
} catch {
|
|
515
|
-
}
|
|
516
|
-
this.recognition = null;
|
|
517
|
-
}
|
|
518
|
-
return this.setState("idle"), this.accumulatedTranscript;
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Abort listening. Discards any accumulated transcript.
|
|
522
|
-
*/
|
|
523
|
-
abort() {
|
|
524
|
-
if (this.intentionalStop = !0, this.clearSilenceTimer(), this.accumulatedTranscript = "", this.recognition) {
|
|
525
|
-
try {
|
|
526
|
-
this.recognition.abort();
|
|
527
|
-
} catch {
|
|
528
|
-
}
|
|
529
|
-
this.recognition = null;
|
|
530
|
-
}
|
|
531
|
-
this.setState("idle");
|
|
532
|
-
}
|
|
533
|
-
/** Destroy the instance and release resources. */
|
|
534
|
-
destroy() {
|
|
535
|
-
this.abort();
|
|
536
|
-
}
|
|
537
|
-
setState(e) {
|
|
538
|
-
this._state !== e && (this._state = e, this.callbacks.onStateChange?.(e));
|
|
539
|
-
}
|
|
540
|
-
startSilenceTimer() {
|
|
541
|
-
this.clearSilenceTimer(), this.silenceTimer = setTimeout(() => {
|
|
542
|
-
const e = this.stop();
|
|
543
|
-
e.trim() && this.callbacks.onAutoSubmit?.(e.trim());
|
|
544
|
-
}, this.silenceTimeoutMs);
|
|
545
|
-
}
|
|
546
|
-
clearSilenceTimer() {
|
|
547
|
-
this.silenceTimer !== null && (clearTimeout(this.silenceTimer), this.silenceTimer = null);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
function Dt(o) {
|
|
551
|
-
switch (o) {
|
|
552
|
-
case "not-allowed":
|
|
553
|
-
return "not-allowed";
|
|
554
|
-
case "no-speech":
|
|
555
|
-
return "no-speech";
|
|
556
|
-
case "audio-capture":
|
|
557
|
-
return "no-microphone";
|
|
558
|
-
case "network":
|
|
559
|
-
return "network";
|
|
560
|
-
case "aborted":
|
|
561
|
-
return "aborted";
|
|
562
|
-
default:
|
|
563
|
-
return "unknown";
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
function Ut(o) {
|
|
567
|
-
const e = document.createElement("div");
|
|
568
|
-
e.className = "gengage-chat-kvkk-banner", e.setAttribute("role", "alert");
|
|
569
|
-
const t = document.createElement("div");
|
|
570
|
-
t.className = "gengage-chat-kvkk-content", t.innerHTML = G(o.htmlContent), e.appendChild(t);
|
|
571
|
-
const a = document.createElement("button");
|
|
572
|
-
return a.className = "gengage-chat-kvkk-dismiss", a.type = "button", a.setAttribute("aria-label", o.closeAriaLabel ?? "Close privacy notice"), a.textContent = "×", a.addEventListener("click", o.onDismiss), e.appendChild(a), e;
|
|
573
|
-
}
|
|
574
|
-
class Ft {
|
|
575
|
-
constructor(e) {
|
|
576
|
-
this._el = document.createElement("div"), this._el.className = "gengage-chat-panel-topbar", this._backBtn = document.createElement("button"), this._backBtn.className = "gengage-chat-panel-topbar-back", this._backBtn.type = "button", this._backBtn.disabled = !0, this._backBtn.setAttribute("aria-label", e.backAriaLabel ?? "Back"), this._backBtn.textContent = "←", this._backBtn.addEventListener("click", () => e.onBack()), this._titleEl = document.createElement("span"), this._titleEl.className = "gengage-chat-panel-topbar-title", this._forwardBtn = document.createElement("button"), this._forwardBtn.className = "gengage-chat-panel-topbar-forward", this._forwardBtn.type = "button", this._forwardBtn.disabled = !0, this._forwardBtn.setAttribute("aria-label", e.forwardAriaLabel ?? "Forward"), this._forwardBtn.textContent = "→", this._forwardBtn.addEventListener("click", () => e.onForward()), this._el.appendChild(this._backBtn), this._el.appendChild(this._titleEl), this._el.appendChild(this._forwardBtn);
|
|
577
|
-
}
|
|
578
|
-
update(e, t, a) {
|
|
579
|
-
this._backBtn.disabled = !e, this._forwardBtn.disabled = !t, this._titleEl.textContent = a;
|
|
580
|
-
}
|
|
581
|
-
getElement() {
|
|
582
|
-
return this._el;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
class qt {
|
|
586
|
-
constructor(e) {
|
|
587
|
-
this._onThumbnailClick = e.onThumbnailClick, this._el = document.createElement("div"), this._el.className = "gengage-chat-thumbnails-column", this._el.style.display = "none";
|
|
588
|
-
}
|
|
589
|
-
getElement() {
|
|
590
|
-
return this._el;
|
|
591
|
-
}
|
|
592
|
-
setEntries(e) {
|
|
593
|
-
const t = /* @__PURE__ */ new Set(), a = [];
|
|
594
|
-
for (const n of e)
|
|
595
|
-
t.has(n.sku) || (t.add(n.sku), a.push(n));
|
|
596
|
-
this._el.innerHTML = "";
|
|
597
|
-
for (const n of a) {
|
|
598
|
-
const i = document.createElement("button");
|
|
599
|
-
if (i.type = "button", i.className = "gengage-chat-thumbnail-btn", i.title = n.sku, K(n.imageUrl)) {
|
|
600
|
-
const s = document.createElement("img");
|
|
601
|
-
s.className = "gengage-chat-thumbnail-img", s.src = n.imageUrl, s.alt = n.sku, s.width = 40, s.height = 40, i.appendChild(s);
|
|
602
|
-
}
|
|
603
|
-
i.addEventListener("click", () => {
|
|
604
|
-
this._onThumbnailClick(n.threadId);
|
|
605
|
-
}), this._el.appendChild(i);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
show() {
|
|
609
|
-
this._el.style.display = "";
|
|
610
|
-
}
|
|
611
|
-
hide() {
|
|
612
|
-
this._el.style.display = "none";
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
const ve = {
|
|
616
|
-
search: '<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="6.5" cy="6.5" r="5" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="10" y1="10" x2="15" y2="15" stroke="currentColor" stroke-width="1.5"/></svg>',
|
|
617
|
-
review: '<svg viewBox="0 0 16 16" class="gengage-chat-icon"><polygon points="8,1 10,6 15,6 11,9 12.5,14 8,11 3.5,14 5,9 1,6 6,6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',
|
|
618
|
-
info: '<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="8" y1="7" x2="8" y2="12" stroke="currentColor" stroke-width="1.5"/><circle cx="8" cy="4.5" r="0.8" fill="currentColor"/></svg>',
|
|
619
|
-
similar: '<svg viewBox="0 0 16 16" class="gengage-chat-icon"><rect x="1" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="9" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>'
|
|
620
|
-
}, Ht = he;
|
|
621
|
-
class Ot {
|
|
622
|
-
constructor(e, t) {
|
|
623
|
-
this._panelVisible = !1, this._panelCollapsed = !1, this._onPanelToggle = void 0, this._pendingAttachment = null, this._onAttachment = void 0, this._onRollback = void 0, this._onLinkClick = void 0, this._userScrolledUp = !1, this._scrollLockedUntil = 0, this._thinkingSteps = [], this._firstBotMessageIds = /* @__PURE__ */ new Set(), this._voiceInput = null, this._micBtn = null, this._voiceEnabled = !1, this._voiceLang = "tr-TR", this._ignoreNextDividerClick = !1, this._cleanups = [], this._focusTrapHandler = null, this._previouslyFocusedElement = null, this._stillWorkingTimer = null, this.i18n = { ...Ht, ...t.i18n }, this.onSend = t.onSend, t.onPanelToggle !== void 0 && (this._onPanelToggle = t.onPanelToggle), t.onAttachment !== void 0 && (this._onAttachment = t.onAttachment), t.onRollback !== void 0 && (this._onRollback = t.onRollback), t.onLinkClick !== void 0 && (this._onLinkClick = t.onLinkClick), t.voiceEnabled && (this._voiceEnabled = !0), t.voiceLang !== void 0 && (this._voiceLang = t.voiceLang), this.root = document.createElement("div"), this.root.className = "gengage-chat-drawer", this.root.setAttribute("role", "dialog"), this.root.setAttribute("aria-label", this.i18n.headerTitle ?? "Chat"), this.root.setAttribute("aria-modal", "true");
|
|
624
|
-
const a = document.createElement("div");
|
|
625
|
-
a.className = "gengage-chat-header";
|
|
626
|
-
const n = document.createElement("div");
|
|
627
|
-
if (n.className = "gengage-chat-header-left", t.headerAvatarUrl) {
|
|
628
|
-
const u = document.createElement("img");
|
|
629
|
-
u.className = "gengage-chat-header-avatar", u.src = t.headerAvatarUrl, u.alt = t.headerTitle ?? "Assistant", n.appendChild(u);
|
|
630
|
-
}
|
|
631
|
-
const i = document.createElement("div");
|
|
632
|
-
i.className = "gengage-chat-header-info";
|
|
633
|
-
const s = document.createElement("div");
|
|
634
|
-
s.className = "gengage-chat-header-title-row";
|
|
635
|
-
const l = document.createElement("span");
|
|
636
|
-
if (l.className = "gengage-chat-header-title", l.textContent = t.headerTitle ?? this.i18n.headerTitle ?? "Product Expert", s.appendChild(l), t.headerBadge) {
|
|
637
|
-
const u = document.createElement("span");
|
|
638
|
-
u.className = "gengage-chat-header-badge", u.textContent = t.headerBadge, s.appendChild(u);
|
|
639
|
-
}
|
|
640
|
-
i.appendChild(s);
|
|
641
|
-
const d = document.createElement("a");
|
|
642
|
-
d.className = "gengage-chat-header-powered", d.href = "https://gengage.ai/", d.target = "_blank", d.rel = "noopener noreferrer", d.innerHTML = '<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a7 7 0 110 14A7 7 0 018 1zm0 1.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"/></svg>Powered by Gengage', i.appendChild(d), n.appendChild(i), a.appendChild(n);
|
|
643
|
-
const c = document.createElement("div");
|
|
644
|
-
if (c.className = "gengage-chat-header-right", t.headerCartUrl) {
|
|
645
|
-
const u = document.createElement("a");
|
|
646
|
-
u.className = "gengage-chat-header-btn", F(u, "href", t.headerCartUrl), u.target = "_blank", u.rel = "noopener noreferrer", u.setAttribute("aria-label", this.i18n.cartAriaLabel), u.innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>', c.appendChild(u);
|
|
647
|
-
}
|
|
648
|
-
if (t.headerFavoritesToggle) {
|
|
649
|
-
const u = document.createElement("button");
|
|
650
|
-
u.className = "gengage-chat-header-btn", u.type = "button", u.setAttribute("aria-label", this.i18n.favoritesAriaLabel), u.innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>', u.addEventListener("click", () => t.onFavoritesClick?.()), c.appendChild(u);
|
|
651
|
-
}
|
|
652
|
-
const g = document.createElement("button");
|
|
653
|
-
g.className = "gengage-chat-close", g.type = "button", g.setAttribute("aria-label", this.i18n.closeButton), g.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>', g.addEventListener("click", t.onClose), c.appendChild(g), a.appendChild(c);
|
|
654
|
-
{
|
|
655
|
-
let u = null, P = 0;
|
|
656
|
-
const Y = 80, ee = (se) => {
|
|
657
|
-
if (window.innerWidth > 768) return;
|
|
658
|
-
const ie = se.changedTouches?.[0];
|
|
659
|
-
ie && (u = ie.clientY, P = 0, this.root.style.transition = "none");
|
|
660
|
-
}, ne = (se) => {
|
|
661
|
-
if (u === null) return;
|
|
662
|
-
const ie = se.changedTouches?.[0];
|
|
663
|
-
ie && (P = Math.max(0, ie.clientY - u), this.root.style.transform = `translateY(${P}px)`, this.root.style.opacity = String(1 - P / 300));
|
|
664
|
-
}, me = () => {
|
|
665
|
-
u !== null && (u = null, this.root.style.transition = "", P >= Y && t.onClose(), this.root.style.transform = "", this.root.style.opacity = "", P = 0);
|
|
666
|
-
}, fe = () => {
|
|
667
|
-
u !== null && (u = null, this.root.style.transition = "", this.root.style.transform = "", this.root.style.opacity = "", P = 0);
|
|
668
|
-
};
|
|
669
|
-
a.addEventListener("touchstart", ee, { passive: !0 }), a.addEventListener("touchmove", ne, { passive: !0 }), a.addEventListener("touchend", me, { passive: !0 }), a.addEventListener("touchcancel", fe, { passive: !0 }), this._cleanups.push(() => {
|
|
670
|
-
a.removeEventListener("touchstart", ee), a.removeEventListener("touchmove", ne), a.removeEventListener("touchend", me), a.removeEventListener("touchcancel", fe);
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
const r = document.createElement("div");
|
|
674
|
-
r.className = "gengage-chat-body", this._panelEl = document.createElement("div"), this._panelEl.className = "gengage-chat-panel", this._panelTopBar = new Ft({
|
|
675
|
-
onBack: () => t.onPanelBack?.(),
|
|
676
|
-
onForward: () => t.onPanelForward?.(),
|
|
677
|
-
backAriaLabel: this.i18n.backAriaLabel,
|
|
678
|
-
forwardAriaLabel: this.i18n.forwardAriaLabel
|
|
679
|
-
}), this._panelEl.appendChild(this._panelTopBar.getElement()), r.appendChild(this._panelEl), this._dividerEl = document.createElement("div"), this._dividerEl.className = "gengage-chat-panel-divider gengage-chat-panel-divider--hidden", this._dividerEl.setAttribute("role", "separator"), this._dividerEl.setAttribute("aria-label", this.i18n.togglePanelAriaLabel);
|
|
680
|
-
const m = document.createElement("button");
|
|
681
|
-
m.className = "gengage-chat-panel-divider-toggle", m.type = "button", m.setAttribute("aria-label", this.i18n.togglePanelAriaLabel), m.textContent = "»", m.addEventListener("click", () => {
|
|
682
|
-
if (this._ignoreNextDividerClick) {
|
|
683
|
-
this._ignoreNextDividerClick = !1;
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
this.togglePanel(), this._onPanelToggle?.();
|
|
687
|
-
});
|
|
688
|
-
let h = null, y = null;
|
|
689
|
-
const _ = 24, v = (u) => {
|
|
690
|
-
if (window.innerWidth > 768) return;
|
|
691
|
-
const P = u.changedTouches?.[0];
|
|
692
|
-
P && (h = P.clientX, y = P.clientY);
|
|
693
|
-
}, C = (u) => {
|
|
694
|
-
if (window.innerWidth > 768 || h === null || y === null) return;
|
|
695
|
-
const P = u.changedTouches?.[0];
|
|
696
|
-
if (!P) return;
|
|
697
|
-
const Y = P.clientX - h, ee = P.clientY - y;
|
|
698
|
-
if (h = null, y = null, Math.abs(ee) < _ || Math.abs(ee) < Math.abs(Y)) return;
|
|
699
|
-
const ne = ee < 0;
|
|
700
|
-
ne !== this._panelCollapsed && (this._ignoreNextDividerClick = !0, this.setPanelCollapsed(ne), this._onPanelToggle?.());
|
|
701
|
-
};
|
|
702
|
-
this._dividerEl.addEventListener("touchstart", v, { passive: !0 }), this._dividerEl.addEventListener("touchend", C, { passive: !0 }), this._cleanups.push(() => {
|
|
703
|
-
this._dividerEl.removeEventListener("touchstart", v), this._dividerEl.removeEventListener("touchend", C);
|
|
704
|
-
}), this._dividerEl.appendChild(m), r.appendChild(this._dividerEl);
|
|
705
|
-
const E = document.createElement("div");
|
|
706
|
-
E.className = "gengage-chat-conversation", E.appendChild(a);
|
|
707
|
-
const S = document.createElement("div");
|
|
708
|
-
S.className = "gengage-chat-offline-bar", S.setAttribute("role", "status"), S.setAttribute("aria-live", "polite"), S.textContent = this.i18n.offlineMessage, typeof navigator < "u" && !navigator.onLine && S.classList.add("gengage-chat-offline-bar--visible"), E.appendChild(S);
|
|
709
|
-
const w = () => S.classList.add("gengage-chat-offline-bar--visible"), L = () => S.classList.remove("gengage-chat-offline-bar--visible");
|
|
710
|
-
window.addEventListener("offline", w), window.addEventListener("online", L), this._cleanups.push(() => {
|
|
711
|
-
window.removeEventListener("offline", w), window.removeEventListener("online", L);
|
|
712
|
-
}), this._kvkkSlot = document.createElement("div"), this._kvkkSlot.className = "gengage-chat-kvkk-slot", E.appendChild(this._kvkkSlot), this.messagesEl = document.createElement("div"), this.messagesEl.className = "gengage-chat-messages", this.messagesEl.setAttribute("role", "log"), this.messagesEl.setAttribute("aria-live", "polite"), this.messagesEl.setAttribute("aria-label", this.i18n.chatMessagesAriaLabel);
|
|
713
|
-
let R = !1;
|
|
714
|
-
const q = () => {
|
|
715
|
-
R || (R = !0, requestAnimationFrame(() => {
|
|
716
|
-
R = !1;
|
|
717
|
-
const { scrollTop: u, scrollHeight: P, clientHeight: Y } = this.messagesEl;
|
|
718
|
-
this._userScrolledUp = P - u - Y > 10;
|
|
719
|
-
}));
|
|
720
|
-
};
|
|
721
|
-
this.messagesEl.addEventListener("scroll", q, { passive: !0 }), this._cleanups.push(() => {
|
|
722
|
-
this.messagesEl.removeEventListener("scroll", q);
|
|
723
|
-
}), E.appendChild(this.messagesEl), this._thumbnailsColumn = new qt({
|
|
724
|
-
onThumbnailClick: (u) => t.onThumbnailClick?.(u)
|
|
725
|
-
}), this._panelEl.appendChild(this._thumbnailsColumn.getElement()), this._pillsEl = document.createElement("div"), this._pillsEl.className = "gengage-chat-pills", this._pillsEl.setAttribute("role", "toolbar"), this._pillsEl.setAttribute("aria-label", this.i18n.suggestionsAriaLabel), this._pillsEl.style.display = "none";
|
|
726
|
-
const p = document.createElement("div");
|
|
727
|
-
p.className = "gengage-chat-pills-scroll", this._pillsEl.appendChild(p);
|
|
728
|
-
const b = document.createElement("button");
|
|
729
|
-
b.className = "gengage-chat-pills-arrow", b.type = "button", b.setAttribute("aria-label", this.i18n.moreSuggestionsAriaLabel), b.textContent = "›", b.addEventListener("click", () => {
|
|
730
|
-
p.scrollBy({ left: 150, behavior: "smooth" });
|
|
731
|
-
}), this._pillsEl.appendChild(b);
|
|
732
|
-
let f = !1;
|
|
733
|
-
const k = () => {
|
|
734
|
-
f || (f = !0, requestAnimationFrame(() => {
|
|
735
|
-
f = !1;
|
|
736
|
-
const u = p.scrollLeft + p.clientWidth >= p.scrollWidth - 4;
|
|
737
|
-
b.style.display = u ? "none" : "";
|
|
738
|
-
}));
|
|
739
|
-
};
|
|
740
|
-
p.addEventListener("scroll", k, { passive: !0 }), this._cleanups.push(() => {
|
|
741
|
-
p.removeEventListener("scroll", k);
|
|
742
|
-
}), E.appendChild(this._pillsEl), this._inputChipsEl = document.createElement("div"), this._inputChipsEl.className = "gengage-chat-input-chips", this._inputChipsEl.style.display = "none", E.appendChild(this._inputChipsEl);
|
|
743
|
-
const T = document.createElement("div");
|
|
744
|
-
T.className = "gengage-chat-input-area", this.inputEl = document.createElement("textarea"), this.inputEl.className = "gengage-chat-input", this.inputEl.rows = 1, this.inputEl.placeholder = this.i18n.inputPlaceholder, this.inputEl.addEventListener("input", () => {
|
|
745
|
-
requestAnimationFrame(() => {
|
|
746
|
-
this.inputEl.style.height = "auto", this.inputEl.style.height = `${Math.min(this.inputEl.scrollHeight, 120)}px`;
|
|
747
|
-
});
|
|
748
|
-
}), this.inputEl.addEventListener("keydown", (u) => {
|
|
749
|
-
u.key === "Enter" && (window.innerWidth < 768 || !u.shiftKey) && (u.preventDefault(), this._submit());
|
|
750
|
-
}), this.inputEl.addEventListener("paste", (u) => {
|
|
751
|
-
const P = u.clipboardData?.files[0];
|
|
752
|
-
P && P.type.startsWith("image/") && (u.preventDefault(), this._onAttachment ? this._onAttachment(P) : this.stageAttachment(P));
|
|
753
|
-
}), this._fileInput = document.createElement("input"), this._fileInput.type = "file", this._fileInput.accept = "image/jpeg,image/png,image/webp", this._fileInput.style.display = "none", this._fileInput.addEventListener("change", () => {
|
|
754
|
-
const u = this._fileInput.files?.[0];
|
|
755
|
-
u && (this._onAttachment ? this._onAttachment(u) : this.stageAttachment(u)), this._fileInput.value = "";
|
|
756
|
-
});
|
|
757
|
-
const I = document.createElement("button");
|
|
758
|
-
I.className = "gengage-chat-attach-btn", I.type = "button", I.setAttribute("aria-label", this.i18n.attachImageButton), I.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>', I.addEventListener("click", () => this._fileInput.click()), this._previewStrip = document.createElement("div"), this._previewStrip.className = "gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";
|
|
759
|
-
const z = document.createElement("img");
|
|
760
|
-
z.className = "gengage-chat-attachment-preview-thumb", z.alt = "", this._previewName = document.createElement("span"), this._previewName.className = "gengage-chat-attachment-name";
|
|
761
|
-
const D = document.createElement("button");
|
|
762
|
-
D.className = "gengage-chat-attachment-remove", D.type = "button", D.setAttribute("aria-label", this.i18n.removeAttachmentButton), D.textContent = "×", D.addEventListener("click", () => this.clearAttachment()), this._previewStrip.appendChild(z), this._previewStrip.appendChild(this._previewName), this._previewStrip.appendChild(D), this.sendBtn = document.createElement("button"), this.sendBtn.className = "gengage-chat-send", this.sendBtn.type = "button", this.sendBtn.setAttribute("aria-label", this.i18n.sendButton), this.sendBtn.innerHTML = '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>', this.sendBtn.addEventListener("click", () => this._submit()), T.addEventListener("dragover", (u) => {
|
|
763
|
-
u.preventDefault(), T.classList.add("gengage-chat-input-area--dragover");
|
|
764
|
-
}), T.addEventListener("dragleave", () => {
|
|
765
|
-
T.classList.remove("gengage-chat-input-area--dragover");
|
|
766
|
-
}), T.addEventListener("drop", (u) => {
|
|
767
|
-
u.preventDefault(), T.classList.remove("gengage-chat-input-area--dragover");
|
|
768
|
-
const P = u.dataTransfer?.files[0];
|
|
769
|
-
P && (this._onAttachment ? this._onAttachment(P) : this.stageAttachment(P));
|
|
770
|
-
});
|
|
771
|
-
const N = document.createElement("div");
|
|
772
|
-
N.className = "gengage-chat-input-pill", N.appendChild(I), N.appendChild(this.inputEl), this._voiceEnabled && zt() && (this._micBtn = document.createElement("button"), this._micBtn.className = "gengage-chat-mic-btn", this._micBtn.type = "button", this._micBtn.setAttribute("aria-label", this.i18n.voiceButton), this._micBtn.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>', this._micBtn.addEventListener("click", () => this._toggleVoice()), N.appendChild(this._micBtn), this._voiceInput = new Rt(
|
|
773
|
-
{
|
|
774
|
-
onInterim: (u) => {
|
|
775
|
-
this.inputEl.value = u, this.inputEl.style.height = "auto", this.inputEl.style.height = `${Math.min(this.inputEl.scrollHeight, 120)}px`;
|
|
776
|
-
},
|
|
777
|
-
onFinal: (u) => {
|
|
778
|
-
this.inputEl.value = u;
|
|
779
|
-
},
|
|
780
|
-
onAutoSubmit: (u) => {
|
|
781
|
-
this.inputEl.value = u, this._micBtn?.classList.remove("gengage-chat-mic-btn--active"), this._submit();
|
|
782
|
-
},
|
|
783
|
-
onStateChange: (u) => {
|
|
784
|
-
u === "listening" ? this._micBtn?.classList.add("gengage-chat-mic-btn--active") : this._micBtn?.classList.remove("gengage-chat-mic-btn--active");
|
|
785
|
-
},
|
|
786
|
-
onError: (u, P) => {
|
|
787
|
-
this._micBtn?.classList.remove("gengage-chat-mic-btn--active");
|
|
788
|
-
}
|
|
789
|
-
},
|
|
790
|
-
{ lang: this._voiceLang }
|
|
791
|
-
)), N.appendChild(this.sendBtn), T.appendChild(this._previewStrip), T.appendChild(this._fileInput), T.appendChild(N), E.appendChild(T), r.appendChild(E), this.root.appendChild(r);
|
|
792
|
-
const A = document.createElement("div");
|
|
793
|
-
A.className = "gengage-chat-footer", A.textContent = this.i18n.poweredBy, this.root.appendChild(A);
|
|
794
|
-
const M = (u) => {
|
|
795
|
-
u.key === "Escape" && t.onClose();
|
|
796
|
-
};
|
|
797
|
-
this.root.addEventListener("keydown", M), this._cleanups.push(() => this.root.removeEventListener("keydown", M)), e.appendChild(this.root);
|
|
798
|
-
}
|
|
799
|
-
addMessage(e) {
|
|
800
|
-
const t = document.createElement("div");
|
|
801
|
-
if (t.className = `gengage-chat-bubble gengage-chat-bubble--${e.role}`, t.dataset.messageId = e.id, e.threadId && (t.dataset.threadId = e.threadId), this._firstBotMessageIds.has(e.id) && t.classList.add("gengage-chat-bubble--first"), e.attachment) {
|
|
802
|
-
const a = document.createElement("img");
|
|
803
|
-
a.className = "gengage-chat-attachment-thumb";
|
|
804
|
-
const n = URL.createObjectURL(e.attachment);
|
|
805
|
-
a.src = n, a.alt = e.attachment.name, a.addEventListener("load", () => URL.revokeObjectURL(n), { once: !0 }), a.addEventListener("error", () => URL.revokeObjectURL(n), { once: !0 }), t.insertBefore(a, t.firstChild);
|
|
806
|
-
}
|
|
807
|
-
if (e.content) {
|
|
808
|
-
const a = document.createElement("div");
|
|
809
|
-
if (a.className = "gengage-chat-bubble-text", e.role === "assistant") {
|
|
810
|
-
if (a.innerHTML = G(e.content), this._onLinkClick) {
|
|
811
|
-
const n = a.querySelectorAll("a[href]");
|
|
812
|
-
for (const i of n)
|
|
813
|
-
i.addEventListener("click", (s) => {
|
|
814
|
-
s.preventDefault();
|
|
815
|
-
const l = i.getAttribute("href");
|
|
816
|
-
l && this._onLinkClick?.(l);
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
} else
|
|
820
|
-
a.textContent = e.content;
|
|
821
|
-
t.appendChild(a);
|
|
822
|
-
}
|
|
823
|
-
if (e.role === "user" && this._onRollback) {
|
|
824
|
-
const a = document.createElement("button");
|
|
825
|
-
a.className = "gengage-chat-rollback-btn", a.type = "button", a.setAttribute("aria-label", this.i18n.rollbackAriaLabel), a.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>', a.addEventListener("click", (n) => {
|
|
826
|
-
n.stopPropagation(), this._onRollback?.(e.id);
|
|
827
|
-
}), t.appendChild(a);
|
|
828
|
-
}
|
|
829
|
-
this.messagesEl.appendChild(t), this._scrollToBottom(e.role === "user");
|
|
830
|
-
}
|
|
831
|
-
showTypingIndicator(e) {
|
|
832
|
-
this.removeTypingIndicator();
|
|
833
|
-
const t = document.createElement("div");
|
|
834
|
-
if (t.className = "gengage-chat-typing", t.dataset.typing = "true", this._thinkingSteps.length > 0)
|
|
835
|
-
this._renderThinkingStepsInto(t);
|
|
836
|
-
else {
|
|
837
|
-
const a = document.createElement("div");
|
|
838
|
-
a.className = "gengage-chat-typing-dots";
|
|
839
|
-
for (let n = 0; n < 3; n++) a.appendChild(document.createElement("span"));
|
|
840
|
-
if (t.appendChild(a), e) {
|
|
841
|
-
const n = document.createElement("span");
|
|
842
|
-
n.className = "gengage-chat-typing-sparkle", n.textContent = "✨", t.appendChild(n);
|
|
843
|
-
const i = document.createElement("span");
|
|
844
|
-
i.className = "gengage-chat-typing-text", i.textContent = e, t.appendChild(i);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
this.messagesEl.appendChild(t), this._scrollToBottom(!0), this._clearStillWorkingTimer(), this._stillWorkingTimer = setTimeout(() => {
|
|
848
|
-
this._stillWorkingTimer = null;
|
|
849
|
-
const a = this.messagesEl.querySelector(".gengage-chat-typing");
|
|
850
|
-
if (!a || a.querySelector(".gengage-chat-still-working")) return;
|
|
851
|
-
const n = document.createElement("div");
|
|
852
|
-
n.className = "gengage-chat-still-working", n.textContent = this.i18n.stillWorkingMessage, a.appendChild(n), this._scrollToBottom(!0);
|
|
853
|
-
}, 1e4);
|
|
854
|
-
}
|
|
855
|
-
/** Accumulate a new thinking step (shown as a checklist in the typing indicator). */
|
|
856
|
-
addThinkingStep(e) {
|
|
857
|
-
this._thinkingSteps.push(e), this._renderThinkingSteps();
|
|
858
|
-
}
|
|
859
|
-
removeTypingIndicator() {
|
|
860
|
-
this._clearStillWorkingTimer(), this.messagesEl.querySelector(".gengage-chat-typing")?.remove(), this._thinkingSteps = [], this.hideStopButton();
|
|
861
|
-
}
|
|
862
|
-
_clearStillWorkingTimer() {
|
|
863
|
-
this._stillWorkingTimer !== null && (clearTimeout(this._stillWorkingTimer), this._stillWorkingTimer = null);
|
|
864
|
-
}
|
|
865
|
-
/** Show a "Stop generating" button below the typing indicator. */
|
|
866
|
-
showStopButton(e) {
|
|
867
|
-
this.hideStopButton();
|
|
868
|
-
const t = document.createElement("button");
|
|
869
|
-
t.className = "gengage-chat-stop-btn", t.type = "button", t.setAttribute("aria-label", this.i18n.stopGenerating);
|
|
870
|
-
const a = document.createElement("span");
|
|
871
|
-
a.className = "gengage-chat-stop-icon", a.setAttribute("aria-hidden", "true"), t.appendChild(a);
|
|
872
|
-
const n = document.createElement("span");
|
|
873
|
-
n.textContent = this.i18n.stopGenerating, t.appendChild(n), t.addEventListener("click", () => {
|
|
874
|
-
this.hideStopButton(), e();
|
|
875
|
-
}), this.messagesEl.appendChild(t), this._scrollToBottom(!0);
|
|
876
|
-
}
|
|
877
|
-
/** Remove the stop-generating button if present. */
|
|
878
|
-
hideStopButton() {
|
|
879
|
-
this.messagesEl.querySelector(".gengage-chat-stop-btn")?.remove();
|
|
880
|
-
}
|
|
881
|
-
showError(e, t) {
|
|
882
|
-
const a = document.createElement("div");
|
|
883
|
-
a.className = "gengage-chat-error";
|
|
884
|
-
const n = document.createElement("span");
|
|
885
|
-
if (n.textContent = e ?? this.i18n.errorMessage, a.appendChild(n), t) {
|
|
886
|
-
const i = document.createElement("button");
|
|
887
|
-
i.className = "gengage-chat-error-retry", i.textContent = this.i18n.retryButton ?? "Retry", i.addEventListener("click", () => {
|
|
888
|
-
a.remove(), t();
|
|
889
|
-
}), a.appendChild(i);
|
|
890
|
-
}
|
|
891
|
-
this.messagesEl.appendChild(a), this._scrollToBottom(!0);
|
|
892
|
-
}
|
|
893
|
-
clearMessages() {
|
|
894
|
-
this.messagesEl.innerHTML = "";
|
|
895
|
-
}
|
|
896
|
-
/** Replace suggestion pills. Pass empty array to hide. */
|
|
897
|
-
setPills(e) {
|
|
898
|
-
const t = this._pillsEl.querySelector(".gengage-chat-pills-scroll");
|
|
899
|
-
if (!t) return;
|
|
900
|
-
for (; t.firstChild; ) t.removeChild(t.firstChild);
|
|
901
|
-
if (e.length === 0) {
|
|
902
|
-
this._pillsEl.style.display = "none";
|
|
903
|
-
return;
|
|
904
|
-
}
|
|
905
|
-
this._pillsEl.style.display = "";
|
|
906
|
-
for (const n of e) {
|
|
907
|
-
const i = document.createElement("button");
|
|
908
|
-
if (i.className = n.image ? "gengage-chat-pill gengage-chat-pill--rich" : "gengage-chat-pill", i.type = "button", n.icon) {
|
|
909
|
-
const l = ve[n.icon];
|
|
910
|
-
if (l) {
|
|
911
|
-
const d = document.createElement("span");
|
|
912
|
-
d.className = "gengage-chat-pill-icon", d.innerHTML = l, i.appendChild(d);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
if (n.image && K(n.image)) {
|
|
916
|
-
const l = document.createElement("img");
|
|
917
|
-
l.className = "gengage-chat-pill-img", l.src = n.image, l.alt = "", i.appendChild(l);
|
|
918
|
-
}
|
|
919
|
-
const s = document.createElement("span");
|
|
920
|
-
if (s.className = "gengage-chat-pill-text", s.textContent = n.label, i.appendChild(s), n.description) {
|
|
921
|
-
const l = document.createElement("span");
|
|
922
|
-
l.className = "gengage-chat-pill-desc", l.textContent = n.description, i.appendChild(l);
|
|
923
|
-
}
|
|
924
|
-
i.addEventListener("click", () => n.onAction()), t.appendChild(i);
|
|
925
|
-
}
|
|
926
|
-
const a = this._pillsEl.querySelector(".gengage-chat-pills-arrow");
|
|
927
|
-
a && requestAnimationFrame(() => {
|
|
928
|
-
a.style.display = t.scrollWidth > t.clientWidth ? "" : "none";
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
focusInput() {
|
|
932
|
-
this.inputEl.focus();
|
|
933
|
-
}
|
|
934
|
-
showKvkkBanner(e, t) {
|
|
935
|
-
this._kvkkSlot.innerHTML = "";
|
|
936
|
-
const a = Ut({ htmlContent: e, onDismiss: t, closeAriaLabel: this.i18n.closeAriaLabel });
|
|
937
|
-
this._kvkkSlot.appendChild(a);
|
|
938
|
-
}
|
|
939
|
-
hideKvkkBanner() {
|
|
940
|
-
this._kvkkSlot.innerHTML = "";
|
|
941
|
-
}
|
|
942
|
-
getElement() {
|
|
943
|
-
return this.root;
|
|
944
|
-
}
|
|
945
|
-
/** Stage a file attachment for sending. Shows preview. */
|
|
946
|
-
stageAttachment(e) {
|
|
947
|
-
this._pendingAttachment = e, this._previewName.textContent = e.name;
|
|
948
|
-
const t = this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");
|
|
949
|
-
t && (t.src && t.src.startsWith("blob:") && URL.revokeObjectURL(t.src), t.src = URL.createObjectURL(e)), this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden");
|
|
950
|
-
}
|
|
951
|
-
/** Remove the staged attachment and hide preview. */
|
|
952
|
-
clearAttachment() {
|
|
953
|
-
const e = this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");
|
|
954
|
-
e?.src && (URL.revokeObjectURL(e.src), e.src = ""), this._pendingAttachment = null, this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden");
|
|
955
|
-
}
|
|
956
|
-
/** Get the currently staged attachment file, or null. */
|
|
957
|
-
getPendingAttachment() {
|
|
958
|
-
return this._pendingAttachment;
|
|
959
|
-
}
|
|
960
|
-
/** Replace panel content and show the panel. */
|
|
961
|
-
setPanelContent(e) {
|
|
962
|
-
this._panelEl.innerHTML = "", this._panelEl.appendChild(this._panelTopBar.getElement()), this._panelEl.appendChild(e), this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"), this._panelVisible || (this._panelVisible = !0, this._panelEl.classList.add("gengage-chat-panel--visible"), this.root.classList.add("gengage-chat-drawer--with-panel")), this._panelCollapsed && this._panelEl.classList.add("gengage-chat-panel--collapsed");
|
|
963
|
-
}
|
|
964
|
-
/** Append content to the panel without replacing existing content. */
|
|
965
|
-
appendPanelContent(e) {
|
|
966
|
-
this._panelEl.appendChild(e), this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"), this._panelVisible || (this._panelVisible = !0, this._panelEl.classList.add("gengage-chat-panel--visible"), this.root.classList.add("gengage-chat-drawer--with-panel"));
|
|
967
|
-
}
|
|
968
|
-
/** Return the panel element's content child (after topbar), or null. */
|
|
969
|
-
getPanelContentElement() {
|
|
970
|
-
const e = this._panelEl.children;
|
|
971
|
-
for (let t = 0; t < e.length; t++) {
|
|
972
|
-
const a = e[t];
|
|
973
|
-
if (!(a.classList.contains("gengage-chat-panel-topbar") || a.classList.contains("gengage-chat-thumbnails-column")))
|
|
974
|
-
return a;
|
|
975
|
-
}
|
|
976
|
-
return null;
|
|
977
|
-
}
|
|
978
|
-
/** Whether the panel is currently visible and has rendered content (beyond topbar + thumbnails column). */
|
|
979
|
-
hasPanelContent() {
|
|
980
|
-
return this._panelVisible && this.getPanelContentElement() !== null;
|
|
981
|
-
}
|
|
982
|
-
/** Whether panel currently shows loading skeleton blocks. */
|
|
983
|
-
isPanelLoading() {
|
|
984
|
-
return this._panelEl.querySelector(".gengage-chat-panel-skeleton") !== null;
|
|
985
|
-
}
|
|
986
|
-
/** Show loading skeleton in the panel. Variant depends on contentType hint. */
|
|
987
|
-
showPanelLoading(e) {
|
|
988
|
-
this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"), this._panelEl.innerHTML = "", this._panelEl.appendChild(this._panelTopBar.getElement());
|
|
989
|
-
const t = document.createElement("div");
|
|
990
|
-
switch (t.className = "gengage-chat-panel-skeleton", e) {
|
|
991
|
-
case "productDetails": {
|
|
992
|
-
const a = document.createElement("div");
|
|
993
|
-
a.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image", t.appendChild(a);
|
|
994
|
-
for (let n = 0; n < 3; n++) {
|
|
995
|
-
const i = document.createElement("div");
|
|
996
|
-
i.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text", t.appendChild(i);
|
|
997
|
-
}
|
|
998
|
-
break;
|
|
999
|
-
}
|
|
1000
|
-
case "productList":
|
|
1001
|
-
case "groupList": {
|
|
1002
|
-
const a = document.createElement("div");
|
|
1003
|
-
a.className = "gengage-chat-panel-skeleton-grid";
|
|
1004
|
-
for (let n = 0; n < 6; n++) {
|
|
1005
|
-
const i = document.createElement("div");
|
|
1006
|
-
i.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card", a.appendChild(i);
|
|
1007
|
-
}
|
|
1008
|
-
t.appendChild(a);
|
|
1009
|
-
break;
|
|
1010
|
-
}
|
|
1011
|
-
case "comparisonTable": {
|
|
1012
|
-
for (let a = 0; a < 4; a++) {
|
|
1013
|
-
const n = document.createElement("div");
|
|
1014
|
-
n.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--row", t.appendChild(n);
|
|
1015
|
-
}
|
|
1016
|
-
break;
|
|
1017
|
-
}
|
|
1018
|
-
default: {
|
|
1019
|
-
for (let a = 0; a < 3; a++) {
|
|
1020
|
-
const n = document.createElement("div");
|
|
1021
|
-
n.className = "gengage-chat-panel-skeleton-block", t.appendChild(n);
|
|
1022
|
-
}
|
|
1023
|
-
break;
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
this._panelEl.appendChild(t), this._panelVisible || (this._panelVisible = !0, this._panelEl.classList.add("gengage-chat-panel--visible"), this.root.classList.add("gengage-chat-drawer--with-panel"));
|
|
1027
|
-
}
|
|
1028
|
-
/** Update the panel top bar navigation state. */
|
|
1029
|
-
updatePanelTopBar(e, t, a) {
|
|
1030
|
-
this._panelTopBar.update(e, t, a);
|
|
1031
|
-
}
|
|
1032
|
-
/**
|
|
1033
|
-
* Hide the panel and clear its content. Always hides — even in force-expanded mode.
|
|
1034
|
-
* Callers: _hideDrawer (stale panel cleanup), stream onDone (loading skeleton cleanup),
|
|
1035
|
-
* thread navigation (no snapshot to restore). All require full hide.
|
|
1036
|
-
* Keeps `_panelCollapsed` untouched so user collapse preference survives future panel renders.
|
|
1037
|
-
*/
|
|
1038
|
-
clearPanel() {
|
|
1039
|
-
this._panelEl.innerHTML = "", this._panelEl.appendChild(this._panelTopBar.getElement()), this._panelVisible = !1, this._panelEl.classList.remove("gengage-chat-panel--visible", "gengage-chat-panel--collapsed"), this.root.classList.remove("gengage-chat-drawer--with-panel"), this._dividerEl.classList.add("gengage-chat-panel-divider--hidden");
|
|
1040
|
-
}
|
|
1041
|
-
/** Expand panel without locking — user can still toggle via divider. */
|
|
1042
|
-
expandPanel() {
|
|
1043
|
-
this._panelCollapsed = !1, this._panelEl.classList.remove("gengage-chat-panel--collapsed"), this._panelVisible || (this._panelVisible = !0, this._panelEl.classList.add("gengage-chat-panel--visible"), this.root.classList.add("gengage-chat-drawer--with-panel"));
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Ensure the panel starts expanded (panelMode: 'expanded').
|
|
1047
|
-
* Users can still collapse/expand via the divider chevron.
|
|
1048
|
-
*/
|
|
1049
|
-
setForceExpanded() {
|
|
1050
|
-
this._panelCollapsed = !1, this._panelEl.classList.remove("gengage-chat-panel--collapsed"), this._panelVisible || (this._panelVisible = !0, this._panelEl.classList.add("gengage-chat-panel--visible"), this.root.classList.add("gengage-chat-drawer--with-panel")), this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden");
|
|
1051
|
-
}
|
|
1052
|
-
/** Toggle panel between collapsed and expanded. */
|
|
1053
|
-
togglePanel() {
|
|
1054
|
-
this.setPanelCollapsed(!this._panelCollapsed);
|
|
1055
|
-
}
|
|
1056
|
-
/** Whether the panel is currently collapsed by the user. */
|
|
1057
|
-
isPanelCollapsed() {
|
|
1058
|
-
return this._panelCollapsed;
|
|
1059
|
-
}
|
|
1060
|
-
/** Programmatically set panel collapsed state. */
|
|
1061
|
-
setPanelCollapsed(e) {
|
|
1062
|
-
this._panelCollapsed = e, e ? this._panelEl.classList.add("gengage-chat-panel--collapsed") : this._panelEl.classList.remove("gengage-chat-panel--collapsed");
|
|
1063
|
-
const t = this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");
|
|
1064
|
-
t && (t.textContent = e ? "«" : "»");
|
|
1065
|
-
}
|
|
1066
|
-
/** Save panel collapsed state to sessionStorage. */
|
|
1067
|
-
persistPanelState(e) {
|
|
1068
|
-
try {
|
|
1069
|
-
const t = `gengage:panel:${e}`;
|
|
1070
|
-
this._panelCollapsed ? sessionStorage.setItem(t, "collapsed") : sessionStorage.removeItem(t);
|
|
1071
|
-
} catch {
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
/** Restore panel collapsed state from sessionStorage. Returns true when restored as collapsed. */
|
|
1075
|
-
restorePanelState(e) {
|
|
1076
|
-
try {
|
|
1077
|
-
const t = `gengage:panel:${e}`;
|
|
1078
|
-
if (sessionStorage.getItem(t) === "collapsed")
|
|
1079
|
-
return this._panelCollapsed = !0, !0;
|
|
1080
|
-
} catch {
|
|
1081
|
-
}
|
|
1082
|
-
return !1;
|
|
1083
|
-
}
|
|
1084
|
-
/** Re-render thinking steps inside the existing typing indicator container. */
|
|
1085
|
-
_renderThinkingSteps() {
|
|
1086
|
-
const e = this.messagesEl.querySelector('[data-typing="true"]');
|
|
1087
|
-
if (!e) {
|
|
1088
|
-
this.showTypingIndicator();
|
|
1089
|
-
return;
|
|
1090
|
-
}
|
|
1091
|
-
e.innerHTML = "", this._renderThinkingStepsInto(e), this._scrollToBottom(!1);
|
|
1092
|
-
}
|
|
1093
|
-
/** Render the accumulated thinking-step checklist into a container element. */
|
|
1094
|
-
_renderThinkingStepsInto(e) {
|
|
1095
|
-
const t = document.createElement("div");
|
|
1096
|
-
t.className = "gengage-chat-thinking-steps";
|
|
1097
|
-
for (let a = 0; a < this._thinkingSteps.length; a++) {
|
|
1098
|
-
const n = document.createElement("div");
|
|
1099
|
-
n.className = "gengage-chat-thinking-step";
|
|
1100
|
-
const i = document.createElement("span");
|
|
1101
|
-
i.className = "gengage-chat-thinking-step-marker", a < this._thinkingSteps.length - 1 ? (i.textContent = "✓", i.classList.add("gengage-chat-thinking-step-marker--done")) : (i.textContent = "●", i.classList.add("gengage-chat-thinking-step-marker--active")), n.appendChild(i);
|
|
1102
|
-
const s = document.createElement("span");
|
|
1103
|
-
s.className = "gengage-chat-thinking-step-text", s.textContent = this._thinkingSteps[a], n.appendChild(s), t.appendChild(n);
|
|
1104
|
-
}
|
|
1105
|
-
e.appendChild(t);
|
|
1106
|
-
}
|
|
1107
|
-
_submit() {
|
|
1108
|
-
const e = this.inputEl.value.trim(), t = this._pendingAttachment;
|
|
1109
|
-
!e && !t || (this.onSend(e, t ?? void 0), this.inputEl.value = "", this.inputEl.style.height = "auto", this.clearAttachment());
|
|
1110
|
-
}
|
|
1111
|
-
_toggleVoice() {
|
|
1112
|
-
if (this._voiceInput)
|
|
1113
|
-
if (this._voiceInput.state === "listening") {
|
|
1114
|
-
const e = this._voiceInput.stop();
|
|
1115
|
-
e.trim() && (this.inputEl.value = e, this._submit());
|
|
1116
|
-
} else
|
|
1117
|
-
this.inputEl.value = "", this._voiceInput.start();
|
|
1118
|
-
}
|
|
1119
|
-
/** Lock auto-scroll for 500ms after session history restore to prevent visual jump. */
|
|
1120
|
-
lockScrollForRestore() {
|
|
1121
|
-
this._scrollLockedUntil = Date.now() + 500;
|
|
1122
|
-
}
|
|
1123
|
-
/** Scroll to bottom only if user hasn't scrolled up. Force=true always scrolls. */
|
|
1124
|
-
_scrollToBottom(e = !1) {
|
|
1125
|
-
!e && this._userScrolledUp || !e && Date.now() < this._scrollLockedUntil || requestAnimationFrame(() => {
|
|
1126
|
-
this.messagesEl.scrollTop = this.messagesEl.scrollHeight, this._userScrolledUp = !1;
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
/** Public method for typewriter ticks — scrolls only if user is near bottom. */
|
|
1130
|
-
scrollToBottomIfNeeded() {
|
|
1131
|
-
this._scrollToBottom(!1);
|
|
1132
|
-
}
|
|
1133
|
-
/** Update a bot message's text content in the DOM (e.g. for fallback messages). */
|
|
1134
|
-
updateBotMessage(e, t) {
|
|
1135
|
-
const a = this.messagesEl.querySelector(`[data-message-id="${CSS.escape(e)}"]`);
|
|
1136
|
-
if (!a) return;
|
|
1137
|
-
let n = a.querySelector(".gengage-chat-bubble-text");
|
|
1138
|
-
n || (n = document.createElement("div"), n.className = "gengage-chat-bubble-text", a.appendChild(n)), n.innerHTML = G(t), this._scrollToBottom(!1);
|
|
1139
|
-
}
|
|
1140
|
-
/** Mark a message as the first bot message in its thread (for special styling). */
|
|
1141
|
-
markFirstBotMessage(e) {
|
|
1142
|
-
this._firstBotMessageIds.add(e);
|
|
1143
|
-
const t = this.messagesEl.querySelector(`[data-message-id="${CSS.escape(e)}"]`);
|
|
1144
|
-
t && t.classList.add("gengage-chat-bubble--first");
|
|
1145
|
-
}
|
|
1146
|
-
/** Scroll to the first message of the last thread (for restore targeting). */
|
|
1147
|
-
scrollToLastThread() {
|
|
1148
|
-
const e = this.messagesEl.querySelectorAll("[data-thread-id]");
|
|
1149
|
-
if (e.length === 0) {
|
|
1150
|
-
this._scrollToBottom(!0);
|
|
1151
|
-
return;
|
|
1152
|
-
}
|
|
1153
|
-
const t = e[e.length - 1].getAttribute("data-thread-id");
|
|
1154
|
-
if (!t) {
|
|
1155
|
-
this._scrollToBottom(!0);
|
|
1156
|
-
return;
|
|
1157
|
-
}
|
|
1158
|
-
const a = this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(t)}"]`);
|
|
1159
|
-
a ? requestAnimationFrame(() => {
|
|
1160
|
-
a.scrollIntoView({ block: "start", behavior: "auto" }), this._userScrolledUp = !1;
|
|
1161
|
-
}) : this._scrollToBottom(!0);
|
|
1162
|
-
}
|
|
1163
|
-
/** Set compact input-area chips (search/info/review shortcuts above input). */
|
|
1164
|
-
setInputAreaChips(e) {
|
|
1165
|
-
if (this._inputChipsEl.innerHTML = "", e.length === 0) {
|
|
1166
|
-
this._inputChipsEl.style.display = "none";
|
|
1167
|
-
return;
|
|
1168
|
-
}
|
|
1169
|
-
this._inputChipsEl.style.display = "";
|
|
1170
|
-
for (const t of e) {
|
|
1171
|
-
const a = document.createElement("button");
|
|
1172
|
-
if (a.className = "gengage-chat-input-chip", a.type = "button", t.icon) {
|
|
1173
|
-
const i = ve[t.icon];
|
|
1174
|
-
if (i) {
|
|
1175
|
-
const s = document.createElement("span");
|
|
1176
|
-
s.className = "gengage-chat-input-chip-icon", s.innerHTML = i, a.appendChild(s);
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
const n = document.createElement("span");
|
|
1180
|
-
n.textContent = t.label, a.appendChild(n), a.addEventListener("click", () => t.onAction()), this._inputChipsEl.appendChild(a);
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
/** Clear input-area chips. */
|
|
1184
|
-
clearInputAreaChips() {
|
|
1185
|
-
this._inputChipsEl.innerHTML = "", this._inputChipsEl.style.display = "none";
|
|
1186
|
-
}
|
|
1187
|
-
setThumbnails(e) {
|
|
1188
|
-
this._thumbnailsColumn.setEntries(e), e.length > 0 ? this._thumbnailsColumn.show() : this._thumbnailsColumn.hide();
|
|
1189
|
-
}
|
|
1190
|
-
hideThumbnails() {
|
|
1191
|
-
this._thumbnailsColumn.hide();
|
|
1192
|
-
}
|
|
1193
|
-
/** Activate focus trap — Tab/Shift+Tab cycles within the drawer. */
|
|
1194
|
-
trapFocus() {
|
|
1195
|
-
this._previouslyFocusedElement = document.activeElement, this.releaseFocus();
|
|
1196
|
-
const e = (t) => {
|
|
1197
|
-
if (t.key !== "Tab") return;
|
|
1198
|
-
const a = this.root.querySelectorAll(
|
|
1199
|
-
'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
1200
|
-
);
|
|
1201
|
-
if (a.length === 0) return;
|
|
1202
|
-
const n = a[0], i = a[a.length - 1], s = this.root.getRootNode(), l = s instanceof ShadowRoot ? s.activeElement : document.activeElement;
|
|
1203
|
-
t.shiftKey ? (l === n || !this.root.contains(l)) && (t.preventDefault(), i.focus()) : (l === i || !this.root.contains(l)) && (t.preventDefault(), n.focus());
|
|
1204
|
-
};
|
|
1205
|
-
this._focusTrapHandler = e, this.root.addEventListener("keydown", e);
|
|
1206
|
-
}
|
|
1207
|
-
/** Release the focus trap and restore previously focused element. */
|
|
1208
|
-
releaseFocus() {
|
|
1209
|
-
if (this._focusTrapHandler && (this.root.removeEventListener("keydown", this._focusTrapHandler), this._focusTrapHandler = null), this._previouslyFocusedElement) {
|
|
1210
|
-
try {
|
|
1211
|
-
this._previouslyFocusedElement.focus();
|
|
1212
|
-
} catch {
|
|
1213
|
-
}
|
|
1214
|
-
this._previouslyFocusedElement = null;
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
/** Clean up event listeners and child resources (VoiceInput, timers). */
|
|
1218
|
-
destroy() {
|
|
1219
|
-
this.releaseFocus(), this._clearStillWorkingTimer();
|
|
1220
|
-
for (const e of this._cleanups) e();
|
|
1221
|
-
this._cleanups.length = 0, this._voiceInput?.destroy(), this._voiceInput = null;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
const jt = `<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1225
|
-
<rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>
|
|
1226
|
-
<rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
|
|
1227
|
-
<circle cx="9" cy="13" r="1.5" fill="currentColor"/>
|
|
1228
|
-
<circle cx="15" cy="13" r="1.5" fill="currentColor"/>
|
|
1229
|
-
<path d="M9.5 17C10.3 17.6 11.1 18 12 18C12.9 18 13.7 17.6 14.5 17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1230
|
-
<path d="M12 7V4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1231
|
-
<circle cx="12" cy="3" r="1" fill="currentColor"/>
|
|
1232
|
-
<path d="M1 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1233
|
-
<path d="M23 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1234
|
-
</svg>`;
|
|
1235
|
-
function Vt(o) {
|
|
1236
|
-
const e = document.createElement("div");
|
|
1237
|
-
e.className = "gengage-chat-launcher-container";
|
|
1238
|
-
const t = document.createElement("div");
|
|
1239
|
-
t.className = "gengage-chat-launcher-content-area", e.appendChild(t);
|
|
1240
|
-
const a = document.createElement("button");
|
|
1241
|
-
if (a.type = "button", a.setAttribute("aria-label", o.ariaLabel ?? "Open chat"), o.imageUrl) {
|
|
1242
|
-
a.className = "gengage-chat-launcher gengage-chat-launcher--image-mode";
|
|
1243
|
-
const i = document.createElement("img");
|
|
1244
|
-
i.src = o.imageUrl, i.alt = "", i.draggable = !1, a.appendChild(i);
|
|
1245
|
-
} else
|
|
1246
|
-
a.className = "gengage-chat-launcher", a.innerHTML = o.svgMarkup ?? jt;
|
|
1247
|
-
if (o.tooltip !== void 0) {
|
|
1248
|
-
const i = document.createElement("span");
|
|
1249
|
-
i.className = "gengage-chat-launcher-tooltip", i.textContent = o.tooltip, a.appendChild(i);
|
|
1250
|
-
}
|
|
1251
|
-
o.hideMobile && (e.dataset.hideMobile = "1"), o.mobileBreakpoint !== void 0 && (e.dataset.mobileBreakpoint = String(o.mobileBreakpoint)), a.addEventListener("click", o.onClick), e.appendChild(a);
|
|
1252
|
-
const n = document.createElement("div");
|
|
1253
|
-
return n.className = "gengage-chat-launcher-content-area-bottom", e.appendChild(n), { container: e, button: a, contentArea: t, contentAreaBottom: n };
|
|
1254
|
-
}
|
|
1255
|
-
const Wt = /* @__PURE__ */ new Set([
|
|
1256
|
-
"audio/ogg",
|
|
1257
|
-
"audio/mpeg",
|
|
1258
|
-
"audio/mp3",
|
|
1259
|
-
"audio/wav",
|
|
1260
|
-
"audio/webm",
|
|
1261
|
-
"audio/aac",
|
|
1262
|
-
"audio/mp4"
|
|
1263
|
-
]), Ae = /* @__PURE__ */ new Set();
|
|
1264
|
-
function ce(o) {
|
|
1265
|
-
o.pause(), o.removeAttribute("src"), o.load(), Ae.delete(o);
|
|
1266
|
-
}
|
|
1267
|
-
function $t(o, e = "audio/ogg") {
|
|
1268
|
-
const t = e.split(";")[0].trim();
|
|
1269
|
-
if (!Wt.has(t)) return null;
|
|
1270
|
-
try {
|
|
1271
|
-
const a = new Audio(`data:${e};base64,${o}`);
|
|
1272
|
-
return Ae.add(a), a.addEventListener("ended", () => ce(a), { once: !0 }), a.play().catch(() => {
|
|
1273
|
-
ce(a);
|
|
1274
|
-
}), {
|
|
1275
|
-
stop: () => ce(a)
|
|
1276
|
-
};
|
|
1277
|
-
} catch {
|
|
1278
|
-
return null;
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
const Gt = {
|
|
1282
|
-
screen_size: "Screen Size",
|
|
1283
|
-
weight: "Weight",
|
|
1284
|
-
battery_capacity: "Battery Capacity",
|
|
1285
|
-
battery_life: "Battery Life",
|
|
1286
|
-
storage: "Storage",
|
|
1287
|
-
memory: "Memory",
|
|
1288
|
-
ram: "RAM",
|
|
1289
|
-
processor: "Processor",
|
|
1290
|
-
camera: "Camera",
|
|
1291
|
-
resolution: "Resolution",
|
|
1292
|
-
display_type: "Display Type",
|
|
1293
|
-
refresh_rate: "Refresh Rate",
|
|
1294
|
-
color: "Color",
|
|
1295
|
-
material: "Material",
|
|
1296
|
-
dimensions: "Dimensions",
|
|
1297
|
-
warranty: "Warranty",
|
|
1298
|
-
connectivity: "Connectivity",
|
|
1299
|
-
water_resistance: "Water Resistance",
|
|
1300
|
-
operating_system: "Operating System",
|
|
1301
|
-
brand: "Brand",
|
|
1302
|
-
model: "Model",
|
|
1303
|
-
price: "Price",
|
|
1304
|
-
energy_class: "Energy Class",
|
|
1305
|
-
noise_level: "Noise Level",
|
|
1306
|
-
capacity: "Capacity",
|
|
1307
|
-
power: "Power",
|
|
1308
|
-
voltage: "Voltage",
|
|
1309
|
-
width: "Width",
|
|
1310
|
-
height: "Height",
|
|
1311
|
-
depth: "Depth"
|
|
1312
|
-
};
|
|
1313
|
-
function Yt(o, e) {
|
|
1314
|
-
return e?.[o] ?? Gt[o] ?? o.replace(/_/g, " ").replace(/^\w/, (t) => t.toUpperCase());
|
|
1315
|
-
}
|
|
1316
|
-
function Kt(o) {
|
|
1317
|
-
const { recommended: e, products: t, attributes: a, highlights: n, specialCases: i, onProductClick: s, i18n: l } = o, d = document.createElement("div");
|
|
1318
|
-
d.className = "gengage-chat-comparison";
|
|
1319
|
-
const c = document.createElement("h3");
|
|
1320
|
-
if (c.className = "gengage-chat-comparison-heading", c.textContent = l?.comparisonHeading ?? "COMPARISON RESULTS", d.appendChild(c), e) {
|
|
1321
|
-
const g = document.createElement("div");
|
|
1322
|
-
g.className = "gengage-chat-comparison-recommended";
|
|
1323
|
-
const r = document.createElement("div");
|
|
1324
|
-
r.className = "gengage-chat-comparison-recommended-label", r.textContent = l?.recommendedChoiceLabel ?? "Recommended Choice", g.appendChild(r);
|
|
1325
|
-
const m = document.createElement("div");
|
|
1326
|
-
if (m.className = "gengage-chat-comparison-recommended-body", e.imageUrl && K(e.imageUrl)) {
|
|
1327
|
-
const v = document.createElement("img");
|
|
1328
|
-
v.src = e.imageUrl, v.alt = e.name, v.loading = "lazy", v.addEventListener(
|
|
1329
|
-
"error",
|
|
1330
|
-
() => {
|
|
1331
|
-
v.style.display = "none";
|
|
1332
|
-
},
|
|
1333
|
-
{ once: !0 }
|
|
1334
|
-
), m.appendChild(v);
|
|
1335
|
-
}
|
|
1336
|
-
const h = document.createElement("div");
|
|
1337
|
-
h.className = "gengage-chat-comparison-recommended-info";
|
|
1338
|
-
const y = document.createElement("div");
|
|
1339
|
-
y.className = "gengage-chat-comparison-recommended-title", y.textContent = e.name, h.appendChild(y);
|
|
1340
|
-
const _ = document.createElement("div");
|
|
1341
|
-
if (_.className = "gengage-chat-comparison-recommended-price", _.textContent = H(e.price, o.pricing), h.appendChild(_), m.appendChild(h), m.addEventListener("click", () => {
|
|
1342
|
-
s(e.sku);
|
|
1343
|
-
}), m.style.cursor = "pointer", g.appendChild(m), n.length > 0) {
|
|
1344
|
-
const v = document.createElement("div");
|
|
1345
|
-
v.className = "gengage-chat-comparison-highlights";
|
|
1346
|
-
const C = document.createElement("div");
|
|
1347
|
-
C.className = "gengage-chat-comparison-highlights-label", C.textContent = l?.highlightsLabel ?? "Key Highlights", v.appendChild(C);
|
|
1348
|
-
const E = document.createElement("ul");
|
|
1349
|
-
for (const S of n) {
|
|
1350
|
-
const w = document.createElement("li");
|
|
1351
|
-
w.textContent = S, E.appendChild(w);
|
|
1352
|
-
}
|
|
1353
|
-
v.appendChild(E), g.appendChild(v);
|
|
1354
|
-
}
|
|
1355
|
-
if (o.recommendedText) {
|
|
1356
|
-
const v = document.createElement("div");
|
|
1357
|
-
v.className = "gengage-chat-comparison-recommended-text", v.innerHTML = G(o.recommendedText), g.appendChild(v);
|
|
1358
|
-
}
|
|
1359
|
-
d.appendChild(g);
|
|
1360
|
-
}
|
|
1361
|
-
if (o.keyDifferencesHtml) {
|
|
1362
|
-
const g = document.createElement("div");
|
|
1363
|
-
g.className = "gengage-chat-comparison-key-differences";
|
|
1364
|
-
const r = document.createElement("h4");
|
|
1365
|
-
r.textContent = l?.keyDifferencesLabel ?? "Key Differences", g.appendChild(r);
|
|
1366
|
-
const m = document.createElement("div");
|
|
1367
|
-
m.className = "gengage-chat-comparison-key-differences-content", m.innerHTML = G(Qt(o.keyDifferencesHtml)), g.appendChild(m), d.appendChild(g);
|
|
1368
|
-
}
|
|
1369
|
-
if (i && i.length > 0) {
|
|
1370
|
-
const g = document.createElement("details");
|
|
1371
|
-
g.className = "gengage-chat-comparison-special";
|
|
1372
|
-
const r = document.createElement("summary");
|
|
1373
|
-
r.textContent = l?.specialCasesLabel ?? "For Special Cases", g.appendChild(r);
|
|
1374
|
-
const m = document.createElement("ul");
|
|
1375
|
-
for (const h of i)
|
|
1376
|
-
Xt(m, h);
|
|
1377
|
-
m.childElementCount > 0 && g.appendChild(m), d.appendChild(g);
|
|
1378
|
-
}
|
|
1379
|
-
if (t.length > 0 && a.length > 0) {
|
|
1380
|
-
const g = document.createElement("table");
|
|
1381
|
-
g.className = "gengage-chat-comparison-table";
|
|
1382
|
-
const r = document.createElement("thead"), m = document.createElement("tr"), h = document.createElement("th");
|
|
1383
|
-
m.appendChild(h);
|
|
1384
|
-
for (const _ of t) {
|
|
1385
|
-
const v = document.createElement("th");
|
|
1386
|
-
if (_.sku === e?.sku && (v.className = "gengage-chat-comparison-selected"), _.imageUrl && K(_.imageUrl)) {
|
|
1387
|
-
const S = document.createElement("img");
|
|
1388
|
-
S.src = _.imageUrl, S.alt = _.name, S.loading = "lazy", S.addEventListener(
|
|
1389
|
-
"error",
|
|
1390
|
-
() => {
|
|
1391
|
-
S.style.display = "none";
|
|
1392
|
-
},
|
|
1393
|
-
{ once: !0 }
|
|
1394
|
-
), v.appendChild(S);
|
|
1395
|
-
}
|
|
1396
|
-
const C = document.createElement("div");
|
|
1397
|
-
C.textContent = _.name, v.appendChild(C);
|
|
1398
|
-
const E = document.createElement("div");
|
|
1399
|
-
E.className = "gengage-chat-comparison-table-price", E.textContent = H(_.price, o.pricing), v.appendChild(E), m.appendChild(v);
|
|
1400
|
-
}
|
|
1401
|
-
r.appendChild(m), g.appendChild(r);
|
|
1402
|
-
const y = document.createElement("tbody");
|
|
1403
|
-
for (const _ of a) {
|
|
1404
|
-
const v = document.createElement("tr"), C = document.createElement("td");
|
|
1405
|
-
C.className = "gengage-chat-comparison-label", C.textContent = Yt(_.label, l?.criteriaLabels), v.appendChild(C);
|
|
1406
|
-
for (let E = 0; E < _.values.length; E++) {
|
|
1407
|
-
const S = document.createElement("td");
|
|
1408
|
-
t[E]?.sku === e?.sku && (S.className = "gengage-chat-comparison-selected"), S.textContent = _.values[E] ?? "", v.appendChild(S);
|
|
1409
|
-
}
|
|
1410
|
-
y.appendChild(v);
|
|
1411
|
-
}
|
|
1412
|
-
g.appendChild(y), d.appendChild(g);
|
|
1413
|
-
}
|
|
1414
|
-
if (o.productActions) {
|
|
1415
|
-
const g = document.createElement("div");
|
|
1416
|
-
g.className = "gengage-chat-comparison-product-actions";
|
|
1417
|
-
for (const r of t)
|
|
1418
|
-
if (o.productActions[r.sku]) {
|
|
1419
|
-
const h = document.createElement("button");
|
|
1420
|
-
h.className = "gengage-chat-comparison-view-btn", h.type = "button", h.textContent = r.name, h.addEventListener("click", () => s(r.sku)), g.appendChild(h);
|
|
1421
|
-
}
|
|
1422
|
-
g.childElementCount > 0 && d.appendChild(g);
|
|
1423
|
-
}
|
|
1424
|
-
return d;
|
|
1425
|
-
}
|
|
1426
|
-
function Qt(o) {
|
|
1427
|
-
if (/<[uo]l[\s>]/i.test(o) || /<li[\s>]/i.test(o)) return o;
|
|
1428
|
-
const e = o.split(`
|
|
1429
|
-
`).filter((t) => t.trim());
|
|
1430
|
-
return e.length <= 1 ? o : "<ul>" + e.map((t) => `<li>${t.trim()}</li>`).join("") + "</ul>";
|
|
1431
|
-
}
|
|
1432
|
-
function Xt(o, e) {
|
|
1433
|
-
const t = G(e);
|
|
1434
|
-
if (!t) return;
|
|
1435
|
-
const a = document.createElement("template");
|
|
1436
|
-
a.innerHTML = t;
|
|
1437
|
-
const n = Array.from(a.content.querySelectorAll("li"));
|
|
1438
|
-
if (n.length > 0) {
|
|
1439
|
-
for (const s of n) {
|
|
1440
|
-
const l = document.createElement("li");
|
|
1441
|
-
l.innerHTML = G(s.innerHTML), o.appendChild(l);
|
|
1442
|
-
}
|
|
1443
|
-
return;
|
|
1444
|
-
}
|
|
1445
|
-
const i = document.createElement("li");
|
|
1446
|
-
Jt(e) ? i.innerHTML = t : i.textContent = e, o.appendChild(i);
|
|
1447
|
-
}
|
|
1448
|
-
function Jt(o) {
|
|
1449
|
-
return /<\/?[a-z][\s\S]*>/i.test(o);
|
|
1450
|
-
}
|
|
1451
|
-
function Zt(o, e) {
|
|
1452
|
-
const t = document.createElement("div");
|
|
1453
|
-
t.className = "gengage-chat-review-highlights";
|
|
1454
|
-
const a = o.props?.reviews;
|
|
1455
|
-
if (!Array.isArray(a) || a.length === 0) {
|
|
1456
|
-
const _ = document.createElement("div");
|
|
1457
|
-
return _.className = "gengage-chat-review-empty", _.textContent = e?.emptyReviewsMessage ?? "No review summary found.", t.appendChild(_), t;
|
|
1458
|
-
}
|
|
1459
|
-
const n = a.filter(
|
|
1460
|
-
(_) => _ !== null && typeof _ == "object"
|
|
1461
|
-
), i = { all: n.length, positive: 0, negative: 0, neutral: 0 };
|
|
1462
|
-
for (const _ of n)
|
|
1463
|
-
_.review_class === "positive" ? i.positive++ : _.review_class === "negative" ? i.negative++ : i.neutral++;
|
|
1464
|
-
const s = document.createElement("div");
|
|
1465
|
-
s.className = "gengage-chat-review-tabs";
|
|
1466
|
-
const l = e?.reviewFilterAll ?? "All", d = e?.reviewFilterPositive ?? "Positive", c = e?.reviewFilterNegative ?? "Negative", g = [{ label: `${l} (${i.all})`, filter: "all" }];
|
|
1467
|
-
i.positive > 0 && g.push({ label: `${d} (${i.positive})`, filter: "positive" }), i.negative > 0 && g.push({ label: `${c} (${i.negative})`, filter: "negative" });
|
|
1468
|
-
let r = "all";
|
|
1469
|
-
const m = document.createElement("div");
|
|
1470
|
-
m.className = "gengage-chat-review-items";
|
|
1471
|
-
function h() {
|
|
1472
|
-
for (; m.firstChild; ) m.removeChild(m.firstChild);
|
|
1473
|
-
const _ = r === "all" ? n : n.filter((v) => v.review_class === r);
|
|
1474
|
-
for (const v of _) {
|
|
1475
|
-
const C = document.createElement("article");
|
|
1476
|
-
C.className = "gengage-chat-review-item";
|
|
1477
|
-
const E = v.review_class;
|
|
1478
|
-
if ((E === "positive" || E === "negative" || E === "neutral") && (C.dataset.tone = E), typeof v.review_tag == "string" && v.review_tag.length > 0) {
|
|
1479
|
-
const S = document.createElement("div");
|
|
1480
|
-
S.className = "gengage-chat-review-tag", S.textContent = v.review_tag, C.appendChild(S);
|
|
1481
|
-
}
|
|
1482
|
-
if (typeof v.review_text == "string" && v.review_text.length > 0) {
|
|
1483
|
-
const S = document.createElement("div");
|
|
1484
|
-
S.className = "gengage-chat-review-text", S.textContent = v.review_text, C.appendChild(S);
|
|
1485
|
-
}
|
|
1486
|
-
if (v.review_rating !== void 0 && String(v.review_rating).length > 0) {
|
|
1487
|
-
const S = document.createElement("div");
|
|
1488
|
-
S.className = "gengage-chat-review-rating", S.textContent = String(v.review_rating), C.appendChild(S);
|
|
1489
|
-
}
|
|
1490
|
-
m.appendChild(C);
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
for (const _ of g) {
|
|
1494
|
-
const v = document.createElement("button");
|
|
1495
|
-
v.className = "gengage-chat-review-tab", v.type = "button", v.textContent = _.label, _.filter === r && v.classList.add("gengage-chat-review-tab--active"), v.addEventListener("click", () => {
|
|
1496
|
-
r = _.filter;
|
|
1497
|
-
for (const C of s.querySelectorAll(".gengage-chat-review-tab"))
|
|
1498
|
-
C.classList.toggle("gengage-chat-review-tab--active", C === v);
|
|
1499
|
-
h();
|
|
1500
|
-
}), s.appendChild(v);
|
|
1501
|
-
}
|
|
1502
|
-
t.appendChild(s);
|
|
1503
|
-
const y = /* @__PURE__ */ new Map();
|
|
1504
|
-
for (const _ of n)
|
|
1505
|
-
if (typeof _.review_tag == "string" && _.review_tag.length > 0) {
|
|
1506
|
-
const v = y.get(_.review_tag);
|
|
1507
|
-
v ? v.count++ : y.set(_.review_tag, { count: 1, sentiment: _.review_class ?? "neutral" });
|
|
1508
|
-
}
|
|
1509
|
-
if (y.size > 0) {
|
|
1510
|
-
const _ = document.createElement("div");
|
|
1511
|
-
_.className = "gengage-chat-review-pills";
|
|
1512
|
-
for (const [v, C] of y) {
|
|
1513
|
-
const E = document.createElement("span");
|
|
1514
|
-
E.className = "gengage-chat-review-pill", E.dataset.tone = C.sentiment;
|
|
1515
|
-
const S = document.createElement("span");
|
|
1516
|
-
S.className = "gengage-chat-review-pill-icon", S.textContent = C.sentiment === "positive" ? "✓" : C.sentiment === "negative" ? "✕" : "●", E.appendChild(S);
|
|
1517
|
-
const w = document.createElement("span");
|
|
1518
|
-
if (w.textContent = v, E.appendChild(w), C.count > 1) {
|
|
1519
|
-
const L = document.createElement("span");
|
|
1520
|
-
L.className = "gengage-chat-review-pill-count", L.textContent = String(C.count), E.appendChild(L);
|
|
1521
|
-
}
|
|
1522
|
-
_.appendChild(E);
|
|
1523
|
-
}
|
|
1524
|
-
t.appendChild(_);
|
|
1525
|
-
}
|
|
1526
|
-
return h(), t.appendChild(m), t;
|
|
1527
|
-
}
|
|
1528
|
-
function Pe(o) {
|
|
1529
|
-
const e = o.product.sku;
|
|
1530
|
-
if (typeof e == "string" && e.length > 0) return e;
|
|
1531
|
-
const t = o.action?.payload;
|
|
1532
|
-
return t && typeof t == "object" && "sku" in t && typeof t.sku == "string" ? t.sku : null;
|
|
1533
|
-
}
|
|
1534
|
-
const ea = {
|
|
1535
|
-
winner: "roleWinner",
|
|
1536
|
-
best_value: "roleBestValue",
|
|
1537
|
-
best_alternative: "roleBestAlternative"
|
|
1538
|
-
};
|
|
1539
|
-
function Ne(o, e) {
|
|
1540
|
-
if (!o || !e) return null;
|
|
1541
|
-
const t = ea[o];
|
|
1542
|
-
return t ? e[t] ?? o : o;
|
|
1543
|
-
}
|
|
1544
|
-
function ta(o, e) {
|
|
1545
|
-
const t = document.createElement("div");
|
|
1546
|
-
t.className = "gengage-chat-ai-top-picks";
|
|
1547
|
-
const a = o.props?.suggestions ?? [];
|
|
1548
|
-
if (a.length === 0) return t;
|
|
1549
|
-
const n = document.createElement("h3");
|
|
1550
|
-
n.className = "gengage-chat-ai-top-picks-title", n.textContent = e.i18n?.aiTopPicksTitle ?? "Top Picks", t.appendChild(n);
|
|
1551
|
-
const i = document.createElement("div");
|
|
1552
|
-
i.className = "gengage-chat-ai-top-picks-cards";
|
|
1553
|
-
for (let s = 0; s < a.length; s++) {
|
|
1554
|
-
const l = a[s], c = l.role === "winner" || s === 0 ? aa(l, e) : na(l, e);
|
|
1555
|
-
i.appendChild(c);
|
|
1556
|
-
}
|
|
1557
|
-
return t.appendChild(i), t;
|
|
1558
|
-
}
|
|
1559
|
-
function aa(o, e) {
|
|
1560
|
-
const t = document.createElement("div");
|
|
1561
|
-
t.className = "gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner";
|
|
1562
|
-
const a = document.createElement("span");
|
|
1563
|
-
a.className = "gengage-chat-ai-toppick-badge", a.textContent = Ne(o.role, e.i18n) ?? e.i18n?.roleWinner ?? "TOP MATCH", t.appendChild(a);
|
|
1564
|
-
const n = o.product, i = n.discountPercent;
|
|
1565
|
-
if (typeof i == "number" && i > 0) {
|
|
1566
|
-
const r = document.createElement("span");
|
|
1567
|
-
r.className = "gengage-chat-ai-toppick-discount-badge", r.textContent = `%${pe(i)}`, t.appendChild(r);
|
|
1568
|
-
}
|
|
1569
|
-
const s = n.imageUrl;
|
|
1570
|
-
if (s && K(s)) {
|
|
1571
|
-
const r = document.createElement("img");
|
|
1572
|
-
r.className = "gengage-chat-ai-toppick-img", F(r, "src", s), r.loading = "lazy", r.alt = n.name || "Product image", J(r), t.appendChild(r);
|
|
1573
|
-
}
|
|
1574
|
-
const l = document.createElement("div");
|
|
1575
|
-
l.className = "gengage-chat-ai-toppick-body";
|
|
1576
|
-
const d = n.name;
|
|
1577
|
-
if (d) {
|
|
1578
|
-
const r = document.createElement("div");
|
|
1579
|
-
r.className = "gengage-chat-ai-toppick-name", r.textContent = d, l.appendChild(r);
|
|
1580
|
-
}
|
|
1581
|
-
if (o.reason) {
|
|
1582
|
-
const r = document.createElement("div");
|
|
1583
|
-
r.className = "gengage-chat-ai-toppick-reason", r.textContent = o.reason, l.appendChild(r);
|
|
1584
|
-
}
|
|
1585
|
-
if (o.labels && o.labels.length > 0 && l.appendChild(Me(o.labels)), typeof o.expertQualityScore == "number") {
|
|
1586
|
-
const r = document.createElement("div");
|
|
1587
|
-
r.className = "gengage-chat-ai-toppick-score";
|
|
1588
|
-
let m = o.expertQualityScore, h = 10;
|
|
1589
|
-
m > 10 ? m = Math.round(m) / 10 : m <= 5 && (h = 5), r.textContent = `${m}/${h}`, l.appendChild(r);
|
|
1590
|
-
}
|
|
1591
|
-
if (o.reviewHighlight) {
|
|
1592
|
-
const r = document.createElement("blockquote");
|
|
1593
|
-
r.className = "gengage-chat-ai-toppick-review", r.textContent = o.reviewHighlight, l.appendChild(r);
|
|
1594
|
-
}
|
|
1595
|
-
const c = n.price, g = n.originalPrice;
|
|
1596
|
-
if (c) {
|
|
1597
|
-
const r = document.createElement("div");
|
|
1598
|
-
if (r.className = "gengage-chat-ai-toppick-price", g && g !== c) {
|
|
1599
|
-
const h = document.createElement("span");
|
|
1600
|
-
h.className = "gengage-chat-ai-toppick-original-price", h.textContent = H(g, e.pricing), r.appendChild(h), r.appendChild(document.createTextNode(" "));
|
|
1601
|
-
}
|
|
1602
|
-
const m = document.createElement("span");
|
|
1603
|
-
m.textContent = H(c, e.pricing), r.appendChild(m), l.appendChild(r);
|
|
1604
|
-
}
|
|
1605
|
-
if (t.appendChild(l), o.action) {
|
|
1606
|
-
const r = Pe(o), m = n.url ?? "", h = document.createElement("div");
|
|
1607
|
-
h.className = "gengage-chat-ai-toppick-spinner", h.style.display = r && e.topPicksLoadingSku === r ? "" : "none", t.appendChild(h);
|
|
1608
|
-
const y = document.createElement("button");
|
|
1609
|
-
y.className = "gengage-chat-ai-toppick-cta", y.type = "button", y.textContent = e.i18n?.viewDetails ?? "View Details", y.addEventListener("click", () => {
|
|
1610
|
-
if (o.action?.type === "findSimilar" && r && e.onProductClick) {
|
|
1611
|
-
e.onProductClick({ sku: r, url: m });
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1614
|
-
e.onAction(o.action);
|
|
1615
|
-
}), t.appendChild(y);
|
|
1616
|
-
}
|
|
1617
|
-
return t;
|
|
1618
|
-
}
|
|
1619
|
-
function na(o, e) {
|
|
1620
|
-
const t = document.createElement("div");
|
|
1621
|
-
t.className = "gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact";
|
|
1622
|
-
const a = o.product, n = a.discountPercent;
|
|
1623
|
-
if (typeof n == "number" && n > 0) {
|
|
1624
|
-
const g = document.createElement("span");
|
|
1625
|
-
g.className = "gengage-chat-ai-toppick-discount-badge", g.textContent = `%${pe(n)}`, t.appendChild(g);
|
|
1626
|
-
}
|
|
1627
|
-
const i = a.imageUrl;
|
|
1628
|
-
if (i && K(i)) {
|
|
1629
|
-
const g = document.createElement("img");
|
|
1630
|
-
g.className = "gengage-chat-ai-toppick-img", F(g, "src", i), g.loading = "lazy", g.alt = a.name || "Product image", J(g), t.appendChild(g);
|
|
1631
|
-
}
|
|
1632
|
-
const s = document.createElement("div");
|
|
1633
|
-
s.className = "gengage-chat-ai-toppick-body";
|
|
1634
|
-
const l = Ne(o.role, e.i18n);
|
|
1635
|
-
if (l) {
|
|
1636
|
-
const g = document.createElement("div");
|
|
1637
|
-
g.className = "gengage-chat-ai-toppick-role", g.textContent = l, s.appendChild(g);
|
|
1638
|
-
}
|
|
1639
|
-
const d = a.name;
|
|
1640
|
-
if (d) {
|
|
1641
|
-
const g = document.createElement("div");
|
|
1642
|
-
g.className = "gengage-chat-ai-toppick-name", g.textContent = d, s.appendChild(g);
|
|
1643
|
-
}
|
|
1644
|
-
if (o.reason) {
|
|
1645
|
-
const g = document.createElement("div");
|
|
1646
|
-
g.className = "gengage-chat-ai-toppick-reason", g.textContent = o.reason, s.appendChild(g);
|
|
1647
|
-
}
|
|
1648
|
-
o.labels && o.labels.length > 0 && s.appendChild(Me(o.labels));
|
|
1649
|
-
const c = a.price;
|
|
1650
|
-
if (c) {
|
|
1651
|
-
const g = document.createElement("div");
|
|
1652
|
-
g.className = "gengage-chat-ai-toppick-price", g.textContent = H(c, e.pricing), s.appendChild(g);
|
|
1653
|
-
}
|
|
1654
|
-
if (t.appendChild(s), o.action) {
|
|
1655
|
-
const g = Pe(o), r = a.url ?? "", m = document.createElement("div");
|
|
1656
|
-
m.className = "gengage-chat-ai-toppick-spinner", m.style.display = g && e.topPicksLoadingSku === g ? "" : "none", t.appendChild(m);
|
|
1657
|
-
const h = document.createElement("button");
|
|
1658
|
-
h.className = "gengage-chat-ai-toppick-cta", h.type = "button", h.textContent = e.i18n?.viewDetails ?? "View Details", h.addEventListener("click", () => {
|
|
1659
|
-
if (o.action?.type === "findSimilar" && g && e.onProductClick) {
|
|
1660
|
-
e.onProductClick({ sku: g, url: r });
|
|
1661
|
-
return;
|
|
1662
|
-
}
|
|
1663
|
-
e.onAction(o.action);
|
|
1664
|
-
}), t.appendChild(h);
|
|
1665
|
-
}
|
|
1666
|
-
return t;
|
|
1667
|
-
}
|
|
1668
|
-
function Me(o) {
|
|
1669
|
-
const e = document.createElement("div");
|
|
1670
|
-
e.className = "gengage-chat-ai-toppick-labels";
|
|
1671
|
-
for (const t of o) {
|
|
1672
|
-
const a = document.createElement("span");
|
|
1673
|
-
a.className = "gengage-chat-ai-toppick-label", a.dataset.sentiment = t.sentiment ?? "neutral", a.textContent = t.label, e.appendChild(a);
|
|
1674
|
-
}
|
|
1675
|
-
return e;
|
|
1676
|
-
}
|
|
1677
|
-
function ia(o, e) {
|
|
1678
|
-
const t = document.createElement("div");
|
|
1679
|
-
t.className = "gengage-chat-grounding-review";
|
|
1680
|
-
const a = o.props ?? {}, n = a.title, i = a.reviewCount, s = a.action, l = e.i18n?.groundingReviewCta ?? "Read Reviews", d = document.createElement("span");
|
|
1681
|
-
d.className = "gengage-chat-grounding-review-icon", d.textContent = "📋", t.appendChild(d);
|
|
1682
|
-
const c = document.createElement("div");
|
|
1683
|
-
c.className = "gengage-chat-grounding-review-body";
|
|
1684
|
-
const g = document.createElement("div");
|
|
1685
|
-
if (g.className = "gengage-chat-grounding-review-title", g.textContent = n ?? e.i18n?.customerReviewsTitle ?? "Customer Reviews", c.appendChild(g), i) {
|
|
1686
|
-
const m = document.createElement("div");
|
|
1687
|
-
m.className = "gengage-chat-grounding-review-subtitle";
|
|
1688
|
-
const h = e.i18n?.groundingReviewSubtitle ?? "{count} yorum mevcut";
|
|
1689
|
-
m.textContent = h.replace("{count}", i), c.appendChild(m);
|
|
1690
|
-
}
|
|
1691
|
-
t.appendChild(c);
|
|
1692
|
-
const r = document.createElement("span");
|
|
1693
|
-
return r.className = "gengage-chat-grounding-review-cta", r.textContent = `${l} →`, t.appendChild(r), s && (t.style.cursor = "pointer", t.addEventListener("click", () => e.onAction(s))), t;
|
|
1694
|
-
}
|
|
1695
|
-
function oa(o) {
|
|
1696
|
-
if (o.action.type !== "findSimilar") return o.action;
|
|
1697
|
-
const e = o.action.payload && typeof o.action.payload == "object" ? o.action.payload : null, t = typeof e?.input == "string" && e.input.trim() || typeof e?.text == "string" && e.text.trim() || o.name.trim();
|
|
1698
|
-
if (!t) return o.action;
|
|
1699
|
-
const a = {
|
|
1700
|
-
text: t,
|
|
1701
|
-
is_suggested_text: 1
|
|
1702
|
-
};
|
|
1703
|
-
if (typeof e?.sku == "string" && e.sku.trim() && (a.sku = e.sku), Array.isArray(e?.group_skus)) {
|
|
1704
|
-
const n = e.group_skus.filter((i) => typeof i == "string" && i.length > 0);
|
|
1705
|
-
n.length > 0 && (a.group_skus = n);
|
|
1706
|
-
}
|
|
1707
|
-
return {
|
|
1708
|
-
title: o.action.title,
|
|
1709
|
-
type: "inputText",
|
|
1710
|
-
payload: a
|
|
1711
|
-
};
|
|
1712
|
-
}
|
|
1713
|
-
function ra(o, e) {
|
|
1714
|
-
const t = document.createElement("div");
|
|
1715
|
-
t.className = "gengage-chat-grouping-cards";
|
|
1716
|
-
const a = o.props?.entries ?? [];
|
|
1717
|
-
if (a.length === 0) return t;
|
|
1718
|
-
for (const n of a) {
|
|
1719
|
-
const i = document.createElement("div");
|
|
1720
|
-
if (i.className = "gengage-chat-grouping-card", i.style.cursor = "pointer", i.addEventListener("click", () => e.onAction(oa(n))), n.image && K(n.image)) {
|
|
1721
|
-
const c = document.createElement("img");
|
|
1722
|
-
c.className = "gengage-chat-grouping-card-img", c.src = n.image, c.alt = n.name, c.width = 20, c.height = 20, i.appendChild(c);
|
|
1723
|
-
}
|
|
1724
|
-
const s = document.createElement("div");
|
|
1725
|
-
s.className = "gengage-chat-grouping-card-body";
|
|
1726
|
-
const l = document.createElement("span");
|
|
1727
|
-
if (l.className = "gengage-chat-grouping-card-name", l.textContent = n.name, s.appendChild(l), n.description) {
|
|
1728
|
-
const c = document.createElement("span");
|
|
1729
|
-
c.className = "gengage-chat-grouping-card-desc", c.textContent = n.description, s.appendChild(c);
|
|
1730
|
-
}
|
|
1731
|
-
if (n.labels && n.labels.length > 0) {
|
|
1732
|
-
const c = document.createElement("span");
|
|
1733
|
-
c.className = "gengage-chat-grouping-card-labels", c.textContent = n.labels.slice(0, 3).join(" · "), s.appendChild(c);
|
|
1734
|
-
}
|
|
1735
|
-
i.appendChild(s);
|
|
1736
|
-
const d = document.createElement("span");
|
|
1737
|
-
d.className = "gengage-chat-grouping-card-arrow", d.textContent = "↳", i.insertBefore(d, i.firstChild), t.appendChild(i);
|
|
1738
|
-
}
|
|
1739
|
-
return t;
|
|
1740
|
-
}
|
|
1741
|
-
function sa(o, e) {
|
|
1742
|
-
const t = document.createElement("div");
|
|
1743
|
-
t.className = "gengage-chat-suggested-search-cards";
|
|
1744
|
-
const a = o.props?.entries ?? [];
|
|
1745
|
-
if (a.length === 0) return t;
|
|
1746
|
-
for (const n of a) {
|
|
1747
|
-
const i = document.createElement("div");
|
|
1748
|
-
if (i.className = "gengage-chat-suggested-search-card", i.style.cursor = "pointer", i.addEventListener("click", () => e.onAction(n.action)), n.image && K(n.image)) {
|
|
1749
|
-
const d = document.createElement("img");
|
|
1750
|
-
d.className = "gengage-chat-suggested-search-card-img", d.src = n.image, d.alt = n.shortName, d.width = 40, d.height = 40, i.appendChild(d);
|
|
1751
|
-
}
|
|
1752
|
-
const s = document.createElement("div");
|
|
1753
|
-
s.className = "gengage-chat-suggested-search-card-body";
|
|
1754
|
-
const l = document.createElement("div");
|
|
1755
|
-
if (l.className = "gengage-chat-suggested-search-card-name", l.textContent = n.shortName, s.appendChild(l), n.detailedMessage) {
|
|
1756
|
-
const d = document.createElement("div");
|
|
1757
|
-
d.className = "gengage-chat-suggested-search-card-desc", d.textContent = n.detailedMessage, s.appendChild(d);
|
|
1758
|
-
}
|
|
1759
|
-
if (n.whyDifferent) {
|
|
1760
|
-
const d = document.createElement("div");
|
|
1761
|
-
d.className = "gengage-chat-suggested-search-card-diff", d.textContent = n.whyDifferent, s.appendChild(d);
|
|
1762
|
-
}
|
|
1763
|
-
i.appendChild(s), t.appendChild(i);
|
|
1764
|
-
}
|
|
1765
|
-
return t;
|
|
1766
|
-
}
|
|
1767
|
-
function ca(o, e) {
|
|
1768
|
-
const t = document.createElement("button");
|
|
1769
|
-
t.className = "gengage-chat-comparison-floating-btn", t.type = "button";
|
|
1770
|
-
const a = e.i18n?.compareSelected ?? "Compare";
|
|
1771
|
-
return t.textContent = `${a} (${o.length})`, t.addEventListener("click", () => {
|
|
1772
|
-
e.onAction({
|
|
1773
|
-
title: a,
|
|
1774
|
-
type: "getComparisonTable",
|
|
1775
|
-
payload: { sku_list: [...o] }
|
|
1776
|
-
});
|
|
1777
|
-
}), t;
|
|
1778
|
-
}
|
|
1779
|
-
function la(o) {
|
|
1780
|
-
const e = document.createElement("div");
|
|
1781
|
-
e.className = "gengage-chat-pros-cons";
|
|
1782
|
-
const t = o.props?.productName;
|
|
1783
|
-
if (t) {
|
|
1784
|
-
const i = document.createElement("h4");
|
|
1785
|
-
i.className = "gengage-chat-pros-cons-heading", i.textContent = t, e.appendChild(i);
|
|
1786
|
-
}
|
|
1787
|
-
const a = o.props?.pros, n = o.props?.cons;
|
|
1788
|
-
if (a && a.length > 0) {
|
|
1789
|
-
const i = document.createElement("ul");
|
|
1790
|
-
i.className = "gengage-chat-pros-cons-list";
|
|
1791
|
-
for (const s of a) {
|
|
1792
|
-
const l = document.createElement("li");
|
|
1793
|
-
l.className = "gengage-chat-pros-cons-item";
|
|
1794
|
-
const d = document.createElement("span");
|
|
1795
|
-
d.className = "gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro", d.textContent = "✓", l.appendChild(d);
|
|
1796
|
-
const c = document.createElement("span");
|
|
1797
|
-
c.textContent = s, l.appendChild(c), i.appendChild(l);
|
|
1798
|
-
}
|
|
1799
|
-
e.appendChild(i);
|
|
1800
|
-
}
|
|
1801
|
-
if (n && n.length > 0) {
|
|
1802
|
-
const i = document.createElement("ul");
|
|
1803
|
-
i.className = "gengage-chat-pros-cons-list";
|
|
1804
|
-
for (const s of n) {
|
|
1805
|
-
const l = document.createElement("li");
|
|
1806
|
-
l.className = "gengage-chat-pros-cons-item";
|
|
1807
|
-
const d = document.createElement("span");
|
|
1808
|
-
d.className = "gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con", d.textContent = "✗", l.appendChild(d);
|
|
1809
|
-
const c = document.createElement("span");
|
|
1810
|
-
c.textContent = s, l.appendChild(c), i.appendChild(l);
|
|
1811
|
-
}
|
|
1812
|
-
e.appendChild(i);
|
|
1813
|
-
}
|
|
1814
|
-
return e;
|
|
1815
|
-
}
|
|
1816
|
-
function ga(o, e) {
|
|
1817
|
-
const t = o.props?.groups ?? [], a = o.props?.filterTags ?? [], n = document.createElement("div");
|
|
1818
|
-
if (n.className = "gengage-chat-categories", t.length === 0) return n;
|
|
1819
|
-
const i = document.createElement("div");
|
|
1820
|
-
i.className = "gengage-chat-categories-tabs", i.setAttribute("role", "tablist");
|
|
1821
|
-
const s = [], l = [], d = (c) => {
|
|
1822
|
-
for (let g = 0; g < s.length; g++) {
|
|
1823
|
-
const r = g === c;
|
|
1824
|
-
s[g].classList.toggle("gengage-chat-categories-tab--active", r), s[g].setAttribute("aria-selected", String(r)), s[g].tabIndex = r ? 0 : -1, l[g].style.display = r ? "" : "none";
|
|
1825
|
-
}
|
|
1826
|
-
};
|
|
1827
|
-
for (let c = 0; c < t.length; c++) {
|
|
1828
|
-
const g = t[c], r = `gengage-cat-tab-${c}`, m = `gengage-cat-panel-${c}`, h = document.createElement("button");
|
|
1829
|
-
h.className = "gengage-chat-categories-tab", h.type = "button", h.id = r, h.setAttribute("role", "tab"), h.setAttribute("aria-controls", m), h.setAttribute("aria-selected", String(c === 0)), h.tabIndex = c === 0 ? 0 : -1, c === 0 && h.classList.add("gengage-chat-categories-tab--active"), h.textContent = g.groupName, h.addEventListener("click", () => d(c)), h.addEventListener("keydown", (_) => {
|
|
1830
|
-
let v = -1;
|
|
1831
|
-
_.key === "ArrowRight" || _.key === "ArrowDown" ? v = (c + 1) % t.length : _.key === "ArrowLeft" || _.key === "ArrowUp" ? v = (c - 1 + t.length) % t.length : _.key === "Home" ? v = 0 : _.key === "End" && (v = t.length - 1), v >= 0 && (_.preventDefault(), d(v), s[v].focus());
|
|
1832
|
-
}), s.push(h), i.appendChild(h);
|
|
1833
|
-
const y = document.createElement("div");
|
|
1834
|
-
y.className = "gengage-chat-categories-grid", y.id = m, y.setAttribute("role", "tabpanel"), y.setAttribute("aria-labelledby", r), c !== 0 && (y.style.display = "none");
|
|
1835
|
-
for (const _ of g.products) {
|
|
1836
|
-
const v = da(_, e);
|
|
1837
|
-
y.appendChild(v);
|
|
1838
|
-
}
|
|
1839
|
-
l.push(y);
|
|
1840
|
-
}
|
|
1841
|
-
n.appendChild(i);
|
|
1842
|
-
for (const c of l) n.appendChild(c);
|
|
1843
|
-
if (a.length > 0) {
|
|
1844
|
-
const c = document.createElement("div");
|
|
1845
|
-
c.className = "gengage-chat-categories-filter-tags";
|
|
1846
|
-
for (const g of a) {
|
|
1847
|
-
const r = document.createElement("button");
|
|
1848
|
-
r.className = "gengage-chat-categories-filter-tag", r.type = "button", r.textContent = g.title, g.action && r.addEventListener("click", () => {
|
|
1849
|
-
e.onAction(g.action);
|
|
1850
|
-
}), c.appendChild(r);
|
|
1851
|
-
}
|
|
1852
|
-
n.appendChild(c);
|
|
1853
|
-
}
|
|
1854
|
-
return n;
|
|
1855
|
-
}
|
|
1856
|
-
function da(o, e) {
|
|
1857
|
-
const t = document.createElement("div");
|
|
1858
|
-
if (t.className = "gengage-chat-product-card", o.imageUrl && K(o.imageUrl)) {
|
|
1859
|
-
const i = document.createElement("img");
|
|
1860
|
-
i.className = "gengage-chat-product-card-img", i.src = o.imageUrl, i.alt = o.name, i.loading = "lazy", J(i), t.appendChild(i);
|
|
1861
|
-
}
|
|
1862
|
-
const a = document.createElement("div");
|
|
1863
|
-
a.className = "gengage-chat-product-card-body";
|
|
1864
|
-
const n = document.createElement("div");
|
|
1865
|
-
if (n.className = "gengage-chat-product-card-name", n.textContent = o.name, a.appendChild(n), o.price) {
|
|
1866
|
-
const i = document.createElement("div");
|
|
1867
|
-
i.className = "gengage-chat-product-card-price", i.textContent = H(o.price, e.pricing), a.appendChild(i);
|
|
1868
|
-
}
|
|
1869
|
-
return t.appendChild(a), e.onProductSelect && (t.style.cursor = "pointer", t.addEventListener("click", () => {
|
|
1870
|
-
e.onProductSelect?.(o);
|
|
1871
|
-
})), t;
|
|
1872
|
-
}
|
|
1873
|
-
function pa(o, e) {
|
|
1874
|
-
const t = document.createElement("div");
|
|
1875
|
-
t.className = "gengage-chat-handoff-notice", t.setAttribute("role", "alert");
|
|
1876
|
-
const a = document.createElement("span");
|
|
1877
|
-
a.className = "gengage-chat-handoff-notice-icon", a.textContent = "👤", a.setAttribute("aria-hidden", "true"), t.appendChild(a);
|
|
1878
|
-
const n = document.createElement("h4");
|
|
1879
|
-
n.className = "gengage-chat-handoff-notice-heading", n.textContent = e.i18n?.handoffHeading ?? "Transferring to a support agent", t.appendChild(n);
|
|
1880
|
-
const i = o.props?.summary;
|
|
1881
|
-
if (i) {
|
|
1882
|
-
const s = document.createElement("p");
|
|
1883
|
-
s.className = "gengage-chat-handoff-notice-summary", s.textContent = i, t.appendChild(s);
|
|
1884
|
-
}
|
|
1885
|
-
return t;
|
|
1886
|
-
}
|
|
1887
|
-
function ha(o, e) {
|
|
1888
|
-
const t = o.props?.product ?? o.props, a = document.createElement("div");
|
|
1889
|
-
if (a.className = "gengage-chat-product-summary", !t) return a;
|
|
1890
|
-
a.style.cursor = "pointer", a.addEventListener("click", (h) => {
|
|
1891
|
-
h.target.closest("a") || e.onProductSelect?.(t);
|
|
1892
|
-
});
|
|
1893
|
-
const n = t.imageUrl;
|
|
1894
|
-
if (n && O(n)) {
|
|
1895
|
-
const h = document.createElement("div");
|
|
1896
|
-
h.className = "gengage-chat-product-summary__image";
|
|
1897
|
-
const y = document.createElement("img");
|
|
1898
|
-
y.loading = "lazy", F(y, "src", n);
|
|
1899
|
-
const _ = t.name;
|
|
1900
|
-
y.alt = _ || "Product image", J(y), h.appendChild(y), a.appendChild(h);
|
|
1901
|
-
}
|
|
1902
|
-
const i = document.createElement("div");
|
|
1903
|
-
i.className = "gengage-chat-product-summary__content";
|
|
1904
|
-
const s = t.brand, l = t.name;
|
|
1905
|
-
if (l) {
|
|
1906
|
-
const h = document.createElement("div");
|
|
1907
|
-
h.className = "gengage-chat-product-summary__name";
|
|
1908
|
-
const y = s && !l.toLowerCase().startsWith(s.toLowerCase());
|
|
1909
|
-
h.textContent = y ? `${s} ${l}` : l, i.appendChild(h);
|
|
1910
|
-
}
|
|
1911
|
-
const d = t.rating, c = t.reviewCount;
|
|
1912
|
-
if (typeof d == "number" && Number.isFinite(d) && d > 0) {
|
|
1913
|
-
const h = document.createElement("div");
|
|
1914
|
-
if (h.className = "gengage-chat-product-summary__rating", h.appendChild(Te(d)), typeof c == "number" && Number.isFinite(c)) {
|
|
1915
|
-
const y = document.createElement("span");
|
|
1916
|
-
y.className = "gengage-chat-product-summary__review-count", y.textContent = ` (${c})`, h.appendChild(y);
|
|
1917
|
-
}
|
|
1918
|
-
i.appendChild(h);
|
|
1919
|
-
}
|
|
1920
|
-
const g = t.price, r = t.originalPrice;
|
|
1921
|
-
if (g) {
|
|
1922
|
-
const h = document.createElement("div");
|
|
1923
|
-
if (h.className = "gengage-chat-product-summary__price", r && r !== g) {
|
|
1924
|
-
const _ = document.createElement("span");
|
|
1925
|
-
_.className = "gengage-chat-product-summary__price-original", _.textContent = H(r, e.pricing), h.appendChild(_), h.appendChild(document.createTextNode(" "));
|
|
1926
|
-
}
|
|
1927
|
-
const y = document.createElement("span");
|
|
1928
|
-
y.className = "gengage-chat-product-summary__price-current", y.textContent = H(g, e.pricing), h.appendChild(y), i.appendChild(h);
|
|
1929
|
-
}
|
|
1930
|
-
a.appendChild(i);
|
|
1931
|
-
const m = t.url;
|
|
1932
|
-
if (m && O(m)) {
|
|
1933
|
-
const h = document.createElement("a");
|
|
1934
|
-
h.className = "gengage-chat-product-summary__cta", F(h, "href", m), F(h, "target", "_blank"), F(h, "rel", "noopener noreferrer"), h.textContent = e.i18n?.productCtaLabel ?? "View", a.appendChild(h);
|
|
1935
|
-
}
|
|
1936
|
-
return a;
|
|
1937
|
-
}
|
|
1938
|
-
function Be() {
|
|
1939
|
-
return window.innerWidth < 768;
|
|
1940
|
-
}
|
|
1941
|
-
const ze = {
|
|
1942
|
-
ActionButtons: ({ element: o, context: e }) => fa(o, e),
|
|
1943
|
-
ActionButton: ({ element: o, context: e }) => ba(o, e),
|
|
1944
|
-
ProductCard: ({ element: o, context: e }) => xa(o, e),
|
|
1945
|
-
ProductDetailsPanel: ({ element: o, context: e }) => va(o, e),
|
|
1946
|
-
ProductGrid: ({ element: o, spec: e, renderElement: t, context: a }) => _a(o, e, t, a),
|
|
1947
|
-
ReviewHighlights: ({ element: o, context: e }) => Zt(o, {
|
|
1948
|
-
emptyReviewsMessage: e.i18n?.emptyReviewsMessage,
|
|
1949
|
-
reviewFilterAll: e.i18n?.reviewFilterAll,
|
|
1950
|
-
reviewFilterPositive: e.i18n?.reviewFilterPositive,
|
|
1951
|
-
reviewFilterNegative: e.i18n?.reviewFilterNegative
|
|
1952
|
-
}),
|
|
1953
|
-
ComparisonTable: ({ element: o, context: e }) => ka(o, e),
|
|
1954
|
-
AITopPicks: ({ element: o, context: e }) => ta(o, e),
|
|
1955
|
-
GroundingReviewCard: ({ element: o, context: e }) => ia(o, e),
|
|
1956
|
-
AIGroupingCards: ({ element: o, context: e }) => ra(o, e),
|
|
1957
|
-
AISuggestedSearchCards: ({ element: o, context: e }) => sa(o, e),
|
|
1958
|
-
ProsAndCons: ({ element: o }) => la(o),
|
|
1959
|
-
CategoriesContainer: ({ element: o, context: e }) => ga(o, e),
|
|
1960
|
-
HandoffNotice: ({ element: o, context: e }) => pa(o, e),
|
|
1961
|
-
ProductSummaryCard: ({ element: o, context: e }) => ha(o, e),
|
|
1962
|
-
Divider: ({ element: o }) => Ca(o)
|
|
1963
|
-
}, Re = ({
|
|
1964
|
-
element: o,
|
|
1965
|
-
renderElement: e
|
|
1966
|
-
}) => {
|
|
1967
|
-
if (!o.children || o.children.length === 0)
|
|
1968
|
-
return null;
|
|
1969
|
-
const t = document.createElement("div");
|
|
1970
|
-
for (const a of o.children) {
|
|
1971
|
-
const n = e(a);
|
|
1972
|
-
n && t.appendChild(n);
|
|
1973
|
-
}
|
|
1974
|
-
return t;
|
|
1975
|
-
};
|
|
1976
|
-
function ua() {
|
|
1977
|
-
return { ...ze };
|
|
1978
|
-
}
|
|
1979
|
-
function ma(o, e, t = ze, a = Re) {
|
|
1980
|
-
return We({
|
|
1981
|
-
spec: o,
|
|
1982
|
-
context: e,
|
|
1983
|
-
registry: t,
|
|
1984
|
-
containerClassName: "gengage-chat-uispec",
|
|
1985
|
-
unknownRenderer: a
|
|
1986
|
-
});
|
|
1987
|
-
}
|
|
1988
|
-
function fa(o, e) {
|
|
1989
|
-
const t = document.createElement("div");
|
|
1990
|
-
t.className = "gengage-chat-action-buttons";
|
|
1991
|
-
const a = o.props?.buttons;
|
|
1992
|
-
if (a)
|
|
1993
|
-
for (const n of a) {
|
|
1994
|
-
const i = document.createElement("button");
|
|
1995
|
-
i.className = "gengage-chat-action-btn", i.textContent = n.label, i.addEventListener("click", () => e.onAction(n.action)), t.appendChild(i);
|
|
1996
|
-
}
|
|
1997
|
-
return t;
|
|
1998
|
-
}
|
|
1999
|
-
function ba(o, e) {
|
|
2000
|
-
const t = document.createElement("button");
|
|
2001
|
-
t.className = "gengage-chat-action-btn";
|
|
2002
|
-
const a = o.props?.label;
|
|
2003
|
-
typeof a == "string" && (t.textContent = a);
|
|
2004
|
-
const n = o.props?.action;
|
|
2005
|
-
return n && t.addEventListener("click", () => e.onAction(n)), t;
|
|
2006
|
-
}
|
|
2007
|
-
function xa(o, e) {
|
|
2008
|
-
const t = document.createElement("div");
|
|
2009
|
-
t.className = "gengage-chat-product-card";
|
|
2010
|
-
const a = o.props?.product ?? o.props;
|
|
2011
|
-
if (!a) return t;
|
|
2012
|
-
const n = a.sku;
|
|
2013
|
-
n && (t.dataset.sku = n), e.onProductSelect && (t.style.cursor = "pointer", t.addEventListener("click", (w) => {
|
|
2014
|
-
w.target.closest(".gengage-chat-product-card-atc") || w.target.closest(".gengage-chat-product-card-cta") || e.onProductSelect?.(a);
|
|
2015
|
-
}));
|
|
2016
|
-
const i = a.imageUrl;
|
|
2017
|
-
if (i && O(i)) {
|
|
2018
|
-
const w = document.createElement("div");
|
|
2019
|
-
w.className = "gengage-chat-product-card-img-wrapper";
|
|
2020
|
-
const L = document.createElement("img");
|
|
2021
|
-
L.className = "gengage-chat-product-card-img", L.loading = "lazy", F(L, "src", i);
|
|
2022
|
-
const R = a.name;
|
|
2023
|
-
R && (L.alt = R), J(L), w.appendChild(L);
|
|
2024
|
-
const q = a.discountPercent;
|
|
2025
|
-
if (typeof q == "number" && q > 0) {
|
|
2026
|
-
const f = document.createElement("span");
|
|
2027
|
-
f.className = "gengage-chat-product-card-discount-badge", f.textContent = `%${pe(q)}`, w.appendChild(f);
|
|
2028
|
-
}
|
|
2029
|
-
const p = a.sku;
|
|
2030
|
-
if (p) {
|
|
2031
|
-
const f = document.createElement("button");
|
|
2032
|
-
f.className = "gengage-chat-find-similar-pill", f.type = "button", f.textContent = e.i18n?.findSimilarLabel ?? "Find Similar", f.addEventListener("click", (k) => {
|
|
2033
|
-
k.stopPropagation(), e.onAction({
|
|
2034
|
-
title: e.i18n?.findSimilarLabel ?? "Find Similar",
|
|
2035
|
-
type: "findSimilar",
|
|
2036
|
-
payload: { sku: p, ...i ? { image_url: i } : {} }
|
|
2037
|
-
});
|
|
2038
|
-
}), w.appendChild(f);
|
|
2039
|
-
}
|
|
2040
|
-
const b = a.sku;
|
|
2041
|
-
if (b && e.onFavoriteToggle) {
|
|
2042
|
-
const f = document.createElement("button");
|
|
2043
|
-
f.className = "gengage-chat-favorite-btn", f.type = "button", f.setAttribute("aria-label", e.i18n?.addToFavoritesLabel ?? "Add to favorites");
|
|
2044
|
-
const k = e.favoritedSkus?.has(b) ?? !1;
|
|
2045
|
-
k && f.classList.add("gengage-chat-favorite-btn--active");
|
|
2046
|
-
const T = k ? "currentColor" : "none";
|
|
2047
|
-
f.innerHTML = `<svg width="16" height="16" viewBox="0 0 24 24" fill="${T}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`, f.addEventListener("click", (I) => {
|
|
2048
|
-
I.stopPropagation(), f.classList.toggle("gengage-chat-favorite-btn--active");
|
|
2049
|
-
const z = f.querySelector("svg");
|
|
2050
|
-
z && z.setAttribute(
|
|
2051
|
-
"fill",
|
|
2052
|
-
f.classList.contains("gengage-chat-favorite-btn--active") ? "currentColor" : "none"
|
|
2053
|
-
), e.onFavoriteToggle(b, a);
|
|
2054
|
-
}), w.appendChild(f);
|
|
2055
|
-
}
|
|
2056
|
-
t.appendChild(w);
|
|
2057
|
-
}
|
|
2058
|
-
const s = document.createElement("div");
|
|
2059
|
-
s.className = "gengage-chat-product-card-body";
|
|
2060
|
-
const l = a.brand;
|
|
2061
|
-
if (l) {
|
|
2062
|
-
const w = document.createElement("div");
|
|
2063
|
-
w.className = "gengage-chat-product-card-brand", w.textContent = l, s.appendChild(w);
|
|
2064
|
-
}
|
|
2065
|
-
const d = a.name;
|
|
2066
|
-
if (d) {
|
|
2067
|
-
const w = document.createElement("div");
|
|
2068
|
-
w.className = "gengage-chat-product-card-name", w.textContent = d, s.appendChild(w);
|
|
2069
|
-
}
|
|
2070
|
-
const c = a.rating, g = a.reviewCount;
|
|
2071
|
-
if (typeof c == "number" && Number.isFinite(c)) {
|
|
2072
|
-
const w = document.createElement("div");
|
|
2073
|
-
if (w.className = "gengage-chat-product-card-rating", w.appendChild(Te(c)), typeof g == "number" && Number.isFinite(g)) {
|
|
2074
|
-
const L = document.createElement("span");
|
|
2075
|
-
L.className = "gengage-chat-product-card-review-count", L.textContent = ` (${g})`, w.appendChild(L);
|
|
2076
|
-
}
|
|
2077
|
-
s.appendChild(w);
|
|
2078
|
-
}
|
|
2079
|
-
const r = a.price, m = a.originalPrice;
|
|
2080
|
-
if (a.price_async === !0) {
|
|
2081
|
-
const w = document.createElement("div");
|
|
2082
|
-
w.className = "gengage-chat-product-card-price";
|
|
2083
|
-
const L = document.createElement("span");
|
|
2084
|
-
L.className = "gengage-chat-price-skeleton", w.appendChild(L), s.appendChild(w), setTimeout(() => {
|
|
2085
|
-
L.parentElement && (r ? L.replaceWith(document.createTextNode(H(r, e.pricing))) : L.remove());
|
|
2086
|
-
}, 300);
|
|
2087
|
-
} else if (r) {
|
|
2088
|
-
const w = document.createElement("div");
|
|
2089
|
-
if (w.className = "gengage-chat-product-card-price", m && m !== r) {
|
|
2090
|
-
const R = document.createElement("span");
|
|
2091
|
-
R.className = "gengage-chat-product-card-original-price", R.textContent = H(m, e.pricing), w.appendChild(R), w.appendChild(document.createTextNode(" "));
|
|
2092
|
-
}
|
|
2093
|
-
const L = document.createElement("span");
|
|
2094
|
-
L.textContent = H(r, e.pricing), w.appendChild(L), s.appendChild(w);
|
|
2095
|
-
}
|
|
2096
|
-
const y = a.inStock;
|
|
2097
|
-
if (typeof y == "boolean") {
|
|
2098
|
-
const w = document.createElement("div");
|
|
2099
|
-
w.className = `gengage-chat-product-card-stock ${y ? "is-in-stock" : "is-out-of-stock"}`, w.textContent = y ? e.i18n?.inStockLabel ?? "In Stock" : e.i18n?.outOfStockLabel ?? "Out of Stock", s.appendChild(w);
|
|
2100
|
-
}
|
|
2101
|
-
const _ = a.promotions;
|
|
2102
|
-
if (_ && _.length > 0) {
|
|
2103
|
-
const w = document.createElement("div");
|
|
2104
|
-
w.className = "gengage-chat-product-card-promos";
|
|
2105
|
-
for (const L of _) {
|
|
2106
|
-
const R = document.createElement("span");
|
|
2107
|
-
R.className = "gengage-chat-product-card-promo-badge", R.textContent = L, w.appendChild(R);
|
|
2108
|
-
}
|
|
2109
|
-
s.appendChild(w);
|
|
2110
|
-
}
|
|
2111
|
-
t.appendChild(s);
|
|
2112
|
-
const v = a.url, C = a.sku, E = o.props?.action;
|
|
2113
|
-
if (E) {
|
|
2114
|
-
const w = document.createElement("button");
|
|
2115
|
-
w.className = "gengage-chat-product-card-cta", w.type = "button", w.textContent = E.title || e.i18n?.productCtaLabel || "View", w.addEventListener("click", () => e.onAction(E)), t.appendChild(w);
|
|
2116
|
-
} else if (v && O(v)) {
|
|
2117
|
-
const w = document.createElement("a");
|
|
2118
|
-
w.className = "gengage-chat-product-card-cta", F(w, "href", v), F(w, "target", "_blank"), F(w, "rel", "noopener noreferrer"), w.textContent = e.i18n?.productCtaLabel ?? "View", w.addEventListener("click", (L) => {
|
|
2119
|
-
e.onProductClick && C && (L.preventDefault(), e.onProductClick({ sku: C, url: v }));
|
|
2120
|
-
}), t.appendChild(w);
|
|
2121
|
-
}
|
|
2122
|
-
const S = a.cartCode;
|
|
2123
|
-
if (S && C && y !== !1) {
|
|
2124
|
-
const w = Le({
|
|
2125
|
-
compact: !0,
|
|
2126
|
-
label: e.i18n?.addToCartButton ?? "Add to Cart",
|
|
2127
|
-
decreaseLabel: e.i18n?.decreaseLabel,
|
|
2128
|
-
increaseLabel: e.i18n?.increaseLabel,
|
|
2129
|
-
onSubmit: (L) => {
|
|
2130
|
-
e.onAction({
|
|
2131
|
-
title: e.i18n?.addToCartButton ?? "Add to Cart",
|
|
2132
|
-
type: "addToCart",
|
|
2133
|
-
payload: { sku: C, cartCode: S, quantity: L }
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
});
|
|
2137
|
-
w.classList.add("gengage-chat-product-card-atc"), t.appendChild(w);
|
|
2138
|
-
}
|
|
2139
|
-
if (e.comparisonSelectMode && C && e.onToggleComparisonSku) {
|
|
2140
|
-
const w = document.createElement("div");
|
|
2141
|
-
w.className = "gengage-chat-comparison-select-wrapper";
|
|
2142
|
-
const L = document.createElement("input");
|
|
2143
|
-
return L.type = "checkbox", L.className = "gengage-chat-comparison-checkbox", L.checked = e.comparisonSelectedSkus?.includes(C) ?? !1, L.addEventListener("change", () => {
|
|
2144
|
-
e.onToggleComparisonSku?.(C);
|
|
2145
|
-
}), w.appendChild(L), w.appendChild(t), w;
|
|
2146
|
-
}
|
|
2147
|
-
return t;
|
|
2148
|
-
}
|
|
2149
|
-
function va(o, e) {
|
|
2150
|
-
const t = document.createElement("article");
|
|
2151
|
-
t.className = "gengage-chat-product-details-panel";
|
|
2152
|
-
const a = o.props?.product ?? o.props;
|
|
2153
|
-
if (!a) return t;
|
|
2154
|
-
const n = a.images, i = a.imageUrl, s = a.sku;
|
|
2155
|
-
if (n && n.length > 1) {
|
|
2156
|
-
const p = document.createElement("div");
|
|
2157
|
-
p.className = "gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";
|
|
2158
|
-
const b = document.createElement("img");
|
|
2159
|
-
b.className = "gengage-chat-product-details-img";
|
|
2160
|
-
const f = n.find((A) => O(A));
|
|
2161
|
-
f && F(b, "src", f);
|
|
2162
|
-
const k = a.name;
|
|
2163
|
-
k && (b.alt = k), J(b), p.appendChild(b);
|
|
2164
|
-
const T = document.createElement("div");
|
|
2165
|
-
T.className = "gengage-chat-product-gallery-thumbs";
|
|
2166
|
-
let I = null, z = 0;
|
|
2167
|
-
for (let A = 0; A < n.length; A++) {
|
|
2168
|
-
const M = n[A];
|
|
2169
|
-
if (!M || !O(M)) continue;
|
|
2170
|
-
const u = document.createElement("img");
|
|
2171
|
-
u.className = "gengage-chat-product-gallery-thumb", A === 0 && (u.classList.add("gengage-chat-product-gallery-thumb--active"), I = u), F(u, "src", M), u.alt = `${k ?? "Product"} ${A + 1}`, u.width = 48, u.height = 48, J(u), u.addEventListener("click", () => {
|
|
2172
|
-
F(b, "src", M), I && I.classList.remove("gengage-chat-product-gallery-thumb--active"), u.classList.add("gengage-chat-product-gallery-thumb--active"), I = u, z = A;
|
|
2173
|
-
}), T.appendChild(u);
|
|
2174
|
-
}
|
|
2175
|
-
let D = 0;
|
|
2176
|
-
const N = 50;
|
|
2177
|
-
if (b.addEventListener(
|
|
2178
|
-
"touchstart",
|
|
2179
|
-
(A) => {
|
|
2180
|
-
D = A.changedTouches[0].clientX;
|
|
2181
|
-
},
|
|
2182
|
-
{ passive: !0 }
|
|
2183
|
-
), b.addEventListener("touchend", (A) => {
|
|
2184
|
-
const M = A.changedTouches[0].clientX, u = D - M;
|
|
2185
|
-
if (Math.abs(u) < N) return;
|
|
2186
|
-
const P = T.querySelectorAll(".gengage-chat-product-gallery-thumb"), Y = u > 0 ? Math.min(z + 1, P.length - 1) : Math.max(z - 1, 0);
|
|
2187
|
-
Y !== z && P[Y] && P[Y].click();
|
|
2188
|
-
}), p.appendChild(T), s) {
|
|
2189
|
-
const A = document.createElement("button");
|
|
2190
|
-
A.className = "gengage-chat-find-similar-pill", A.type = "button", A.textContent = e.i18n?.findSimilarLabel ?? "Find Similar", A.addEventListener("click", () => {
|
|
2191
|
-
e.onAction({
|
|
2192
|
-
title: e.i18n?.findSimilarLabel ?? "Find Similar",
|
|
2193
|
-
type: "findSimilar",
|
|
2194
|
-
payload: { sku: s, ...f ? { image_url: f } : {} }
|
|
2195
|
-
});
|
|
2196
|
-
}), p.appendChild(A);
|
|
2197
|
-
}
|
|
2198
|
-
t.appendChild(p);
|
|
2199
|
-
} else if (i && O(i)) {
|
|
2200
|
-
const p = document.createElement("div");
|
|
2201
|
-
p.className = "gengage-chat-product-details-media gengage-chat-product-details-img-wrap";
|
|
2202
|
-
const b = document.createElement("img");
|
|
2203
|
-
b.className = "gengage-chat-product-details-img", b.loading = "lazy", F(b, "src", i), J(b);
|
|
2204
|
-
const f = a.name;
|
|
2205
|
-
if (f && (b.alt = f), p.appendChild(b), s) {
|
|
2206
|
-
const k = document.createElement("button");
|
|
2207
|
-
k.className = "gengage-chat-find-similar-pill", k.type = "button", k.textContent = e.i18n?.findSimilarLabel ?? "Find Similar", k.addEventListener("click", () => {
|
|
2208
|
-
e.onAction({
|
|
2209
|
-
title: e.i18n?.findSimilarLabel ?? "Find Similar",
|
|
2210
|
-
type: "findSimilar",
|
|
2211
|
-
payload: { sku: s, ...i ? { image_url: i } : {} }
|
|
2212
|
-
});
|
|
2213
|
-
}), p.appendChild(k);
|
|
2214
|
-
}
|
|
2215
|
-
t.appendChild(p);
|
|
2216
|
-
}
|
|
2217
|
-
const l = document.createElement("div");
|
|
2218
|
-
l.className = "gengage-chat-product-details-content";
|
|
2219
|
-
const d = a.name;
|
|
2220
|
-
if (d) {
|
|
2221
|
-
const p = document.createElement("h3");
|
|
2222
|
-
p.className = "gengage-chat-product-details-title", p.textContent = d, l.appendChild(p);
|
|
2223
|
-
}
|
|
2224
|
-
const c = a.rating, g = a.reviewCount;
|
|
2225
|
-
if (typeof c == "number" && Number.isFinite(c)) {
|
|
2226
|
-
const p = document.createElement("div");
|
|
2227
|
-
if (p.className = "gengage-chat-product-details-rating", p.textContent = `★ ${bt(c).toFixed(1)}`, typeof g == "number" && Number.isFinite(g)) {
|
|
2228
|
-
const b = document.createElement("span");
|
|
2229
|
-
b.className = "gengage-chat-product-details-review-count", b.textContent = ` (${g})`, p.appendChild(b);
|
|
2230
|
-
}
|
|
2231
|
-
l.appendChild(p);
|
|
2232
|
-
}
|
|
2233
|
-
const r = a.price, m = a.originalPrice;
|
|
2234
|
-
if (a.price_async === !0) {
|
|
2235
|
-
const p = document.createElement("div");
|
|
2236
|
-
p.className = "gengage-chat-product-details-price";
|
|
2237
|
-
const b = document.createElement("span");
|
|
2238
|
-
b.className = "gengage-chat-price-skeleton", p.appendChild(b), l.appendChild(p), setTimeout(() => {
|
|
2239
|
-
if (b.parentElement)
|
|
2240
|
-
if (r) {
|
|
2241
|
-
const f = document.createElement("span");
|
|
2242
|
-
f.className = "gengage-chat-product-details-current-price", f.textContent = H(r, e.pricing), b.replaceWith(f);
|
|
2243
|
-
} else
|
|
2244
|
-
b.remove();
|
|
2245
|
-
}, 300);
|
|
2246
|
-
} else if (r) {
|
|
2247
|
-
const p = document.createElement("div");
|
|
2248
|
-
if (p.className = "gengage-chat-product-details-price", m && m !== r) {
|
|
2249
|
-
const f = document.createElement("span");
|
|
2250
|
-
f.className = "gengage-chat-product-details-original-price", f.textContent = H(m, e.pricing), p.appendChild(f), p.appendChild(document.createTextNode(" "));
|
|
2251
|
-
}
|
|
2252
|
-
const b = document.createElement("span");
|
|
2253
|
-
b.className = "gengage-chat-product-details-current-price", b.textContent = H(r, e.pricing), p.appendChild(b), l.appendChild(p);
|
|
2254
|
-
}
|
|
2255
|
-
const y = a.inStock;
|
|
2256
|
-
if (typeof y == "boolean") {
|
|
2257
|
-
const p = document.createElement("div");
|
|
2258
|
-
p.className = `gengage-chat-product-details-stock ${y ? "is-in-stock" : "is-out-of-stock"}`, p.textContent = y ? e.i18n?.inStockLabel ?? "In Stock" : e.i18n?.outOfStockLabel ?? "Out of Stock", l.appendChild(p);
|
|
2259
|
-
}
|
|
2260
|
-
const _ = a.promotions;
|
|
2261
|
-
if (_ && _.length > 0) {
|
|
2262
|
-
const p = document.createElement("div");
|
|
2263
|
-
p.className = "gengage-chat-product-details-promos";
|
|
2264
|
-
for (const b of _) {
|
|
2265
|
-
const f = document.createElement("span");
|
|
2266
|
-
f.className = "gengage-chat-product-details-promo-badge", f.textContent = b, p.appendChild(f);
|
|
2267
|
-
}
|
|
2268
|
-
l.appendChild(p);
|
|
2269
|
-
}
|
|
2270
|
-
const v = a.variants;
|
|
2271
|
-
if (v && v.length > 0) {
|
|
2272
|
-
const p = document.createElement("div");
|
|
2273
|
-
p.className = "gengage-chat-product-variants";
|
|
2274
|
-
const b = document.createElement("div");
|
|
2275
|
-
b.className = "gengage-chat-product-variants-label", b.textContent = e.i18n?.variantsLabel ?? "Variants", p.appendChild(b);
|
|
2276
|
-
const f = document.createElement("div");
|
|
2277
|
-
f.className = "gengage-chat-product-variants-list";
|
|
2278
|
-
for (const k of v) {
|
|
2279
|
-
const T = k.name ?? k.variant_name, I = k.sku;
|
|
2280
|
-
if (!T && !I) continue;
|
|
2281
|
-
const z = document.createElement("button");
|
|
2282
|
-
z.className = "gengage-chat-product-variant-btn", z.type = "button";
|
|
2283
|
-
const D = T ?? I ?? "", N = k.price;
|
|
2284
|
-
N && String(N) !== String(r) ? z.textContent = `${D} - ${H(String(N), e.pricing)}` : z.textContent = D, I && z.addEventListener("click", () => {
|
|
2285
|
-
e.onAction({
|
|
2286
|
-
title: D,
|
|
2287
|
-
type: "launchVariant",
|
|
2288
|
-
payload: { sku: I }
|
|
2289
|
-
});
|
|
2290
|
-
}), f.appendChild(z);
|
|
2291
|
-
}
|
|
2292
|
-
p.appendChild(f), l.appendChild(p);
|
|
2293
|
-
}
|
|
2294
|
-
const C = a.sku, E = a.cartCode, S = document.createElement("div");
|
|
2295
|
-
S.className = "gengage-chat-product-details-actions";
|
|
2296
|
-
const w = o.props?.action;
|
|
2297
|
-
if (w) {
|
|
2298
|
-
const p = document.createElement("button");
|
|
2299
|
-
p.className = "gengage-chat-product-details-cta", p.type = "button", p.textContent = w.title || e.i18n?.productCtaLabel || "View", p.addEventListener("click", () => e.onAction(w)), S.appendChild(p);
|
|
2300
|
-
} else {
|
|
2301
|
-
const p = a.url;
|
|
2302
|
-
if (p && O(p)) {
|
|
2303
|
-
const b = document.createElement("a");
|
|
2304
|
-
b.className = "gengage-chat-product-details-cta", F(b, "href", p), F(b, "target", "_blank"), F(b, "rel", "noopener noreferrer"), b.textContent = e.i18n?.productCtaLabel ?? "View", b.addEventListener("click", (f) => {
|
|
2305
|
-
e.onProductClick && C && (f.preventDefault(), e.onProductClick({ sku: C, url: p }));
|
|
2306
|
-
}), S.appendChild(b);
|
|
2307
|
-
}
|
|
2308
|
-
}
|
|
2309
|
-
if (E && C && y !== !1) {
|
|
2310
|
-
const p = Le({
|
|
2311
|
-
compact: !1,
|
|
2312
|
-
label: e.i18n?.addToCartButton ?? "Add to Cart",
|
|
2313
|
-
decreaseLabel: e.i18n?.decreaseLabel,
|
|
2314
|
-
increaseLabel: e.i18n?.increaseLabel,
|
|
2315
|
-
onSubmit: (b) => {
|
|
2316
|
-
e.onAction({
|
|
2317
|
-
title: e.i18n?.addToCartButton ?? "Add to Cart",
|
|
2318
|
-
type: "addToCart",
|
|
2319
|
-
payload: { sku: C, cartCode: E, quantity: b }
|
|
2320
|
-
});
|
|
2321
|
-
}
|
|
2322
|
-
});
|
|
2323
|
-
p.classList.add("gengage-chat-product-details-atc-stepper"), S.appendChild(p);
|
|
2324
|
-
}
|
|
2325
|
-
const L = a.url;
|
|
2326
|
-
if (L && O(L)) {
|
|
2327
|
-
let p = function(z, D) {
|
|
2328
|
-
const N = document.createElementNS(T, "circle");
|
|
2329
|
-
N.setAttribute("cx", z), N.setAttribute("cy", D), N.setAttribute("r", "3"), I.appendChild(N);
|
|
2330
|
-
}, b = function(z, D, N, A) {
|
|
2331
|
-
const M = document.createElementNS(T, "line");
|
|
2332
|
-
M.setAttribute("x1", z), M.setAttribute("y1", D), M.setAttribute("x2", N), M.setAttribute("y2", A), I.appendChild(M);
|
|
2333
|
-
};
|
|
2334
|
-
const f = document.createElement("button");
|
|
2335
|
-
f.className = "gengage-chat-product-details-share", f.type = "button";
|
|
2336
|
-
const k = e.i18n?.shareButton ?? "Share";
|
|
2337
|
-
f.title = k, f.setAttribute("aria-label", k);
|
|
2338
|
-
const T = "http://www.w3.org/2000/svg", I = document.createElementNS(T, "svg");
|
|
2339
|
-
I.setAttribute("width", "18"), I.setAttribute("height", "18"), I.setAttribute("viewBox", "0 0 24 24"), I.setAttribute("fill", "none"), I.setAttribute("stroke", "currentColor"), I.setAttribute("stroke-width", "2"), I.setAttribute("stroke-linecap", "round"), I.setAttribute("stroke-linejoin", "round"), p("18", "5"), p("6", "12"), p("18", "19"), b("8.59", "13.51", "15.42", "17.49"), b("15.41", "6.51", "8.59", "10.49"), f.appendChild(I), f.addEventListener("click", async () => {
|
|
2340
|
-
const z = a.name;
|
|
2341
|
-
try {
|
|
2342
|
-
navigator.share ? await navigator.share({ title: z ?? "", url: L }) : navigator.clipboard && (await navigator.clipboard.writeText(L), f.classList.add("gengage-chat-product-details-share--copied"), setTimeout(() => f.classList.remove("gengage-chat-product-details-share--copied"), 1500));
|
|
2343
|
-
} catch {
|
|
2344
|
-
}
|
|
2345
|
-
}), S.appendChild(f);
|
|
2346
|
-
}
|
|
2347
|
-
S.childElementCount > 0 && l.appendChild(S), t.appendChild(l);
|
|
2348
|
-
const R = a.description, q = a.specifications;
|
|
2349
|
-
return (R || q) && t.appendChild(wa(R, q, e)), t;
|
|
2350
|
-
}
|
|
2351
|
-
function wa(o, e, t) {
|
|
2352
|
-
const a = document.createElement("div");
|
|
2353
|
-
a.className = "gengage-chat-product-detail-tabs";
|
|
2354
|
-
const n = document.createElement("div");
|
|
2355
|
-
n.className = "gengage-chat-product-detail-tab-bar";
|
|
2356
|
-
const i = [];
|
|
2357
|
-
if (o) {
|
|
2358
|
-
const l = document.createElement("button");
|
|
2359
|
-
l.className = "gengage-chat-product-detail-tab gengage-chat-product-detail-tab--active", l.type = "button", l.textContent = t.i18n?.productInfoTab ?? "Product Info", n.appendChild(l);
|
|
2360
|
-
const d = document.createElement("div");
|
|
2361
|
-
d.className = "gengage-chat-product-detail-tab-panel", d.textContent = o, i.push(d);
|
|
2362
|
-
}
|
|
2363
|
-
if (e) {
|
|
2364
|
-
const l = document.createElement("button");
|
|
2365
|
-
l.className = `gengage-chat-product-detail-tab${o ? "" : " gengage-chat-product-detail-tab--active"}`, l.type = "button", l.textContent = t.i18n?.specificationsTab ?? "Specifications", n.appendChild(l);
|
|
2366
|
-
const d = document.createElement("div");
|
|
2367
|
-
d.className = "gengage-chat-product-detail-tab-panel", o && (d.style.display = "none");
|
|
2368
|
-
const c = document.createElement("table");
|
|
2369
|
-
c.className = "gengage-chat-product-specs-table";
|
|
2370
|
-
const g = Array.isArray(e) ? e : Object.entries(e).map(([r, m]) => ({ key: r, value: m }));
|
|
2371
|
-
for (const r of g) {
|
|
2372
|
-
const m = document.createElement("tr"), h = document.createElement("td");
|
|
2373
|
-
h.className = "gengage-chat-product-specs-key", h.textContent = r.key;
|
|
2374
|
-
const y = document.createElement("td");
|
|
2375
|
-
y.className = "gengage-chat-product-specs-value", y.textContent = r.value, m.appendChild(h), m.appendChild(y), c.appendChild(m);
|
|
2376
|
-
}
|
|
2377
|
-
d.appendChild(c), i.push(d);
|
|
2378
|
-
}
|
|
2379
|
-
const s = n.querySelectorAll(".gengage-chat-product-detail-tab");
|
|
2380
|
-
s.forEach((l, d) => {
|
|
2381
|
-
l.addEventListener("click", () => {
|
|
2382
|
-
s.forEach((c) => c.classList.remove("gengage-chat-product-detail-tab--active")), l.classList.add("gengage-chat-product-detail-tab--active"), i.forEach((c, g) => {
|
|
2383
|
-
c.style.display = g === d ? "" : "none";
|
|
2384
|
-
});
|
|
2385
|
-
});
|
|
2386
|
-
}), a.appendChild(n);
|
|
2387
|
-
for (const l of i) a.appendChild(l);
|
|
2388
|
-
return a;
|
|
2389
|
-
}
|
|
2390
|
-
function De(o, e, t) {
|
|
2391
|
-
if (!t || t.type === "related") return o;
|
|
2392
|
-
const a = o.map((n) => {
|
|
2393
|
-
const s = e.elements[n]?.props?.product, l = s ? Number(s.price) : NaN;
|
|
2394
|
-
return { id: n, price: Number.isFinite(l) ? l : 1 / 0 };
|
|
2395
|
-
});
|
|
2396
|
-
return a.sort((n, i) => n.price === 1 / 0 && i.price === 1 / 0 ? 0 : n.price === 1 / 0 ? 1 : i.price === 1 / 0 ? -1 : t.direction === "desc" ? i.price - n.price : n.price - i.price), a.map((n) => n.id);
|
|
2397
|
-
}
|
|
2398
|
-
function ya(o, e, t, a) {
|
|
2399
|
-
const n = De(e, t, a), i = /* @__PURE__ */ new Map();
|
|
2400
|
-
for (const s of Array.from(o.children)) {
|
|
2401
|
-
const l = s.dataset.elementId;
|
|
2402
|
-
l && i.set(l, s);
|
|
2403
|
-
}
|
|
2404
|
-
for (const s of n) {
|
|
2405
|
-
const l = i.get(s);
|
|
2406
|
-
l && o.appendChild(l);
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
function _a(o, e, t, a) {
|
|
2410
|
-
const n = document.createElement("div");
|
|
2411
|
-
n.className = "gengage-chat-product-grid-wrapper";
|
|
2412
|
-
const i = o.children ?? [];
|
|
2413
|
-
if (i.length > 1 && a?.onSortChange) {
|
|
2414
|
-
const c = document.createElement("div");
|
|
2415
|
-
c.className = "gengage-chat-product-sort-toolbar";
|
|
2416
|
-
const g = a.productSort ?? { type: "related" }, r = [
|
|
2417
|
-
{ label: a.i18n?.sortRelated ?? "Related", sortState: { type: "related" } },
|
|
2418
|
-
{ label: a.i18n?.sortPriceAsc ?? "Price ↑", sortState: { type: "price", direction: "asc" } },
|
|
2419
|
-
{ label: a.i18n?.sortPriceDesc ?? "Price ↓", sortState: { type: "price", direction: "desc" } }
|
|
2420
|
-
];
|
|
2421
|
-
for (const m of r) {
|
|
2422
|
-
const h = document.createElement("button");
|
|
2423
|
-
h.className = "gengage-chat-product-sort-btn", h.type = "button", g.type === m.sortState.type && g.direction === m.sortState.direction && h.classList.add("gengage-chat-product-sort-btn--active"), h.textContent = m.label, h.addEventListener("click", () => {
|
|
2424
|
-
a.onSortChange?.(m.sortState), ya(s, i, e, m.sortState), c.querySelectorAll(".gengage-chat-product-sort-btn").forEach((_) => _.classList.remove("gengage-chat-product-sort-btn--active")), h.classList.add("gengage-chat-product-sort-btn--active");
|
|
2425
|
-
}), c.appendChild(h);
|
|
2426
|
-
}
|
|
2427
|
-
if (a.onToggleComparisonSku) {
|
|
2428
|
-
const m = document.createElement("div");
|
|
2429
|
-
m.className = "gengage-chat-product-sort-separator", c.appendChild(m);
|
|
2430
|
-
const h = document.createElement("button");
|
|
2431
|
-
h.className = "gengage-chat-comparison-toggle-btn", h.type = "button", a.comparisonSelectMode && h.classList.add("gengage-chat-comparison-toggle-btn--active"), h.textContent = a.i18n?.compareSelected ?? "Compare", h.addEventListener("click", () => {
|
|
2432
|
-
a.onToggleComparisonSku?.("");
|
|
2433
|
-
}), c.appendChild(h);
|
|
2434
|
-
}
|
|
2435
|
-
n.appendChild(c);
|
|
2436
|
-
}
|
|
2437
|
-
const s = document.createElement("div");
|
|
2438
|
-
s.className = "gengage-chat-product-grid";
|
|
2439
|
-
const l = De(i, e, a?.productSort);
|
|
2440
|
-
for (const c of l) {
|
|
2441
|
-
if (!e.elements[c]) continue;
|
|
2442
|
-
const g = t(c);
|
|
2443
|
-
g && (g.dataset.elementId = c, s.appendChild(g));
|
|
2444
|
-
}
|
|
2445
|
-
if (Be() && s.classList.add("gengage-chat-product-grid--mobile"), n.appendChild(s), o.props?.endOfList !== !0 && i.length > 0) {
|
|
2446
|
-
const c = document.createElement("button");
|
|
2447
|
-
c.className = "gengage-chat-product-grid-view-more", c.type = "button", c.textContent = a?.i18n?.viewMoreLabel ?? "Show More", c.addEventListener("click", () => {
|
|
2448
|
-
a?.onAction({ title: "More", type: "moreProductList", payload: {} });
|
|
2449
|
-
}), n.appendChild(c);
|
|
2450
|
-
}
|
|
2451
|
-
if (a?.comparisonSelectMode && a.comparisonSelectedSkus && a.comparisonSelectedSkus.length >= 2) {
|
|
2452
|
-
const c = ca(a.comparisonSelectedSkus, a);
|
|
2453
|
-
n.appendChild(c);
|
|
2454
|
-
}
|
|
2455
|
-
return n;
|
|
2456
|
-
}
|
|
2457
|
-
function ka(o, e) {
|
|
2458
|
-
const t = o.props ?? {}, a = t.keyDifferencesHtml, n = t.recommended, i = t.products ?? [], s = t.attributes ?? [], l = t.highlights ?? [], d = t.specialCases, c = t.recommendedText, g = t.winnerHits, r = t.productActions;
|
|
2459
|
-
if (!n)
|
|
2460
|
-
return document.createElement("div");
|
|
2461
|
-
const m = {
|
|
2462
|
-
recommended: n,
|
|
2463
|
-
products: i,
|
|
2464
|
-
attributes: s,
|
|
2465
|
-
highlights: l,
|
|
2466
|
-
specialCases: d,
|
|
2467
|
-
onProductClick: (y) => {
|
|
2468
|
-
e.onProductClick?.({ sku: y, url: "" });
|
|
2469
|
-
},
|
|
2470
|
-
pricing: e.pricing
|
|
2471
|
-
};
|
|
2472
|
-
c !== void 0 && (m.recommendedText = c), g !== void 0 && (m.winnerHits = g), r !== void 0 && (m.productActions = r), a !== void 0 && (m.keyDifferencesHtml = a), e.i18n && (m.i18n = {
|
|
2473
|
-
comparisonHeading: e.i18n.panelTitleComparisonResults,
|
|
2474
|
-
recommendedChoiceLabel: e.i18n.recommendedChoiceLabel,
|
|
2475
|
-
highlightsLabel: e.i18n.highlightsLabel,
|
|
2476
|
-
keyDifferencesLabel: e.i18n.keyDifferencesLabel,
|
|
2477
|
-
specialCasesLabel: e.i18n.specialCasesLabel,
|
|
2478
|
-
addToCartButton: e.i18n.addToCartButton
|
|
2479
|
-
});
|
|
2480
|
-
const h = Kt(m);
|
|
2481
|
-
return Be() && h.classList.add("gengage-chat-comparison--mobile"), h;
|
|
2482
|
-
}
|
|
2483
|
-
function Ca(o) {
|
|
2484
|
-
const e = document.createElement("hr");
|
|
2485
|
-
e.className = "gengage-chat-divider";
|
|
2486
|
-
const t = o.props?.label;
|
|
2487
|
-
if (t) {
|
|
2488
|
-
const a = document.createElement("div");
|
|
2489
|
-
a.className = "gengage-chat-divider-wrapper";
|
|
2490
|
-
const n = document.createElement("span");
|
|
2491
|
-
return n.className = "gengage-chat-divider-label", n.textContent = t, a.appendChild(e), a.appendChild(n), a;
|
|
2492
|
-
}
|
|
2493
|
-
return e;
|
|
2494
|
-
}
|
|
2495
|
-
const Ea = /* @__PURE__ */ new Set([
|
|
2496
|
-
"P",
|
|
2497
|
-
"DIV",
|
|
2498
|
-
"H1",
|
|
2499
|
-
"H2",
|
|
2500
|
-
"H3",
|
|
2501
|
-
"H4",
|
|
2502
|
-
"H5",
|
|
2503
|
-
"H6",
|
|
2504
|
-
"LI",
|
|
2505
|
-
"UL",
|
|
2506
|
-
"OL",
|
|
2507
|
-
"BLOCKQUOTE",
|
|
2508
|
-
"PRE",
|
|
2509
|
-
"TABLE",
|
|
2510
|
-
"SECTION",
|
|
2511
|
-
"HR",
|
|
2512
|
-
"FIGURE",
|
|
2513
|
-
"FIGCAPTION",
|
|
2514
|
-
"DL",
|
|
2515
|
-
"DT",
|
|
2516
|
-
"DD"
|
|
2517
|
-
]);
|
|
2518
|
-
function Sa(o) {
|
|
2519
|
-
const e = [];
|
|
2520
|
-
let t = [];
|
|
2521
|
-
for (const a of o)
|
|
2522
|
-
a.nodeType === Node.ELEMENT_NODE && Ea.has(a.tagName) ? (t.length > 0 && (e.push(t), t = []), e.push([a])) : t.push(a);
|
|
2523
|
-
return t.length > 0 && e.push(t), e;
|
|
2524
|
-
}
|
|
2525
|
-
function Ta(o) {
|
|
2526
|
-
for (const e of o)
|
|
2527
|
-
for (const t of e)
|
|
2528
|
-
if (t.nodeType === Node.ELEMENT_NODE && (t.tagName === "TABLE" || t.querySelector?.("table")))
|
|
2529
|
-
return !0;
|
|
2530
|
-
return !1;
|
|
2531
|
-
}
|
|
2532
|
-
function La() {
|
|
2533
|
-
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2534
|
-
}
|
|
2535
|
-
function Ia(o) {
|
|
2536
|
-
const { container: e, html: t, delayMs: a = 30, onTick: n, onComplete: i } = o, s = document.createElement("template");
|
|
2537
|
-
s.innerHTML = t;
|
|
2538
|
-
const l = Sa(s.content.childNodes);
|
|
2539
|
-
if (La() || l.length <= 1 || Ta(l))
|
|
2540
|
-
return e.innerHTML = t, i?.(), { complete() {
|
|
2541
|
-
}, cancel() {
|
|
2542
|
-
}, isRunning: !1 };
|
|
2543
|
-
e.innerHTML = "";
|
|
2544
|
-
let d = 0, c = null, g = !0;
|
|
2545
|
-
function r() {
|
|
2546
|
-
if (!g || d >= l.length) {
|
|
2547
|
-
g = !1, i?.();
|
|
2548
|
-
return;
|
|
2549
|
-
}
|
|
2550
|
-
const m = l[d], h = document.createElement("span");
|
|
2551
|
-
h.className = "gengage-chat-typewriter-block";
|
|
2552
|
-
for (const y of m)
|
|
2553
|
-
h.appendChild(y.cloneNode(!0));
|
|
2554
|
-
e.appendChild(h), d++, n?.(), d < l.length ? c = setTimeout(r, a) : (g = !1, i?.());
|
|
2555
|
-
}
|
|
2556
|
-
return r(), {
|
|
2557
|
-
complete() {
|
|
2558
|
-
g && (c !== null && clearTimeout(c), g = !1, e.innerHTML = t, i?.());
|
|
2559
|
-
},
|
|
2560
|
-
cancel() {
|
|
2561
|
-
c !== null && clearTimeout(c), g = !1;
|
|
2562
|
-
},
|
|
2563
|
-
get isRunning() {
|
|
2564
|
-
return g;
|
|
2565
|
-
}
|
|
2566
|
-
};
|
|
2567
|
-
}
|
|
2568
|
-
function we(o) {
|
|
2569
|
-
return o !== void 0 && /[\p{L}\p{N}_]/u.test(o);
|
|
2570
|
-
}
|
|
2571
|
-
function Aa(o) {
|
|
2572
|
-
const { container: e, mentions: t, onProductClick: a } = o;
|
|
2573
|
-
if (t.length === 0) return;
|
|
2574
|
-
const n = /* @__PURE__ */ new Map();
|
|
2575
|
-
for (const i of t)
|
|
2576
|
-
i.short_name.length !== 0 && n.set(i.short_name.toLowerCase(), i);
|
|
2577
|
-
if (n.size !== 0)
|
|
2578
|
-
for (const [i, s] of n) {
|
|
2579
|
-
const l = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
2580
|
-
let d = l.nextNode(), c = !1;
|
|
2581
|
-
for (; d && !c; ) {
|
|
2582
|
-
const g = d.textContent ?? "", r = g.toLowerCase().indexOf(i);
|
|
2583
|
-
if (r === -1) {
|
|
2584
|
-
d = l.nextNode();
|
|
2585
|
-
continue;
|
|
2586
|
-
}
|
|
2587
|
-
const m = r > 0 ? g[r - 1] : void 0, h = g[r + s.short_name.length];
|
|
2588
|
-
if (we(m) || we(h)) {
|
|
2589
|
-
d = l.nextNode();
|
|
2590
|
-
continue;
|
|
2591
|
-
}
|
|
2592
|
-
const y = g.slice(0, r), _ = g.slice(r, r + s.short_name.length), v = g.slice(r + s.short_name.length), C = d.parentNode;
|
|
2593
|
-
if (!C) {
|
|
2594
|
-
d = l.nextNode();
|
|
2595
|
-
continue;
|
|
2596
|
-
}
|
|
2597
|
-
const E = document.createElement("a");
|
|
2598
|
-
E.className = "gengage-product-mention", E.textContent = _, E.href = "#", E.addEventListener("click", (S) => {
|
|
2599
|
-
S.preventDefault(), a(s.sku);
|
|
2600
|
-
}), y && C.insertBefore(document.createTextNode(y), d), C.insertBefore(E, d), v && C.insertBefore(document.createTextNode(v), d), C.removeChild(d), c = !0;
|
|
2601
|
-
}
|
|
2602
|
-
}
|
|
2603
|
-
}
|
|
2604
|
-
const Pa = /* @__PURE__ */ new Set(["search", "info", "review", "similar"]), Na = /* @__PURE__ */ new Set([
|
|
2605
|
-
"quickAnswer",
|
|
2606
|
-
"reviewSummary",
|
|
2607
|
-
"searchDiscovery",
|
|
2608
|
-
"launchDiscovery",
|
|
2609
|
-
"exploreTogetherV2"
|
|
2610
|
-
]);
|
|
2611
|
-
function Ma(o) {
|
|
2612
|
-
return !!(o.icon && Pa.has(o.icon) || o.action?.type && Na.has(o.action.type));
|
|
2613
|
-
}
|
|
2614
|
-
const Ue = "gengage_choice_prompter_dismissed";
|
|
2615
|
-
function Ba(o) {
|
|
2616
|
-
const e = document.createElement("div");
|
|
2617
|
-
e.className = "gengage-chat-choice-prompter";
|
|
2618
|
-
const t = document.createElement("div");
|
|
2619
|
-
t.className = "gengage-chat-choice-prompter-heading", t.textContent = o.heading, e.appendChild(t);
|
|
2620
|
-
const a = document.createElement("div");
|
|
2621
|
-
a.className = "gengage-chat-choice-prompter-suggestion", a.textContent = o.suggestion, e.appendChild(a);
|
|
2622
|
-
const n = document.createElement("button");
|
|
2623
|
-
n.type = "button", n.className = "gengage-chat-choice-prompter-cta", n.textContent = o.ctaLabel, n.addEventListener("click", () => {
|
|
2624
|
-
ye(), e.remove(), o.onCtaClick();
|
|
2625
|
-
}), e.appendChild(n);
|
|
2626
|
-
const i = document.createElement("button");
|
|
2627
|
-
return i.type = "button", i.className = "gengage-chat-choice-prompter-dismiss", i.textContent = "×", i.setAttribute("aria-label", o.dismissAriaLabel ?? "Dismiss"), i.addEventListener("click", () => {
|
|
2628
|
-
ye(), e.remove(), o.onDismiss?.();
|
|
2629
|
-
}), e.appendChild(i), e;
|
|
2630
|
-
}
|
|
2631
|
-
function za() {
|
|
2632
|
-
try {
|
|
2633
|
-
return sessionStorage.getItem(Ue) === "1";
|
|
2634
|
-
} catch {
|
|
2635
|
-
return !1;
|
|
2636
|
-
}
|
|
2637
|
-
}
|
|
2638
|
-
function ye() {
|
|
2639
|
-
try {
|
|
2640
|
-
sessionStorage.setItem(Ue, "1");
|
|
2641
|
-
} catch {
|
|
2642
|
-
}
|
|
2643
|
-
}
|
|
2644
|
-
const Ra = "gengage_assistant", Da = 3, X = "sessions", j = "context", $ = "payload", V = "favorites";
|
|
2645
|
-
function oe(o) {
|
|
2646
|
-
return new Promise((e, t) => {
|
|
2647
|
-
o.onsuccess = () => e(o.result), o.onerror = () => t(o.error);
|
|
2648
|
-
});
|
|
2649
|
-
}
|
|
2650
|
-
function ae(o) {
|
|
2651
|
-
return new Promise((e, t) => {
|
|
2652
|
-
o.oncomplete = () => e(), o.onerror = () => t(o.error), o.onabort = () => t(o.error ?? new DOMException("Transaction aborted"));
|
|
2653
|
-
});
|
|
2654
|
-
}
|
|
2655
|
-
class Ua {
|
|
2656
|
-
constructor(e = Ra, t = Da) {
|
|
2657
|
-
this._db = null, this._dbName = e, this._version = t;
|
|
2658
|
-
}
|
|
2659
|
-
// -------------------------------------------------------------------------
|
|
2660
|
-
// Lifecycle
|
|
2661
|
-
// -------------------------------------------------------------------------
|
|
2662
|
-
async open() {
|
|
2663
|
-
return this._db ? this._db : new Promise((e, t) => {
|
|
2664
|
-
const a = indexedDB.open(this._dbName, this._version);
|
|
2665
|
-
a.onupgradeneeded = (n) => {
|
|
2666
|
-
const i = a.result, s = n.oldVersion;
|
|
2667
|
-
s < 1 && (i.createObjectStore(X, { keyPath: ["userId", "appId", "sessionId"] }), i.createObjectStore(j, { keyPath: ["sessionId", "threadId"] }), i.createObjectStore($, {
|
|
2668
|
-
keyPath: ["threadId", "messageId"]
|
|
2669
|
-
}).createIndex("threadId", "threadId", { unique: !1 }), i.createObjectStore(V, { keyPath: ["userId", "appId", "sku"] })), s >= 1 && s < 2 && (i.objectStoreNames.contains(X) && i.deleteObjectStore(X), i.objectStoreNames.contains($) && i.deleteObjectStore($), i.createObjectStore(X, { keyPath: ["userId", "appId", "sessionId"] }), i.createObjectStore($, {
|
|
2670
|
-
keyPath: ["threadId", "messageId"]
|
|
2671
|
-
}).createIndex("threadId", "threadId", { unique: !1 }), i.objectStoreNames.contains(j) || i.createObjectStore(j, { keyPath: ["sessionId", "threadId"] })), s < 3 && (i.objectStoreNames.contains(V) || i.createObjectStore(V, { keyPath: ["userId", "appId", "sku"] }));
|
|
2672
|
-
}, a.onsuccess = () => {
|
|
2673
|
-
this._db = a.result, e(this._db);
|
|
2674
|
-
}, a.onerror = () => t(a.error);
|
|
2675
|
-
});
|
|
2676
|
-
}
|
|
2677
|
-
close() {
|
|
2678
|
-
this._db?.close(), this._db = null;
|
|
2679
|
-
}
|
|
2680
|
-
// -------------------------------------------------------------------------
|
|
2681
|
-
// Sessions
|
|
2682
|
-
// -------------------------------------------------------------------------
|
|
2683
|
-
async saveSession(e) {
|
|
2684
|
-
const a = this._requireDb().transaction(X, "readwrite");
|
|
2685
|
-
a.objectStore(X).put(e), await ae(a);
|
|
2686
|
-
}
|
|
2687
|
-
async loadSession(e, t, a) {
|
|
2688
|
-
const i = this._requireDb().transaction(X, "readonly");
|
|
2689
|
-
return await oe(i.objectStore(X).get([e, t, a])) ?? null;
|
|
2690
|
-
}
|
|
2691
|
-
// -------------------------------------------------------------------------
|
|
2692
|
-
// Context (compound key: [sessionId, threadId])
|
|
2693
|
-
// -------------------------------------------------------------------------
|
|
2694
|
-
async saveContext(e) {
|
|
2695
|
-
const a = this._requireDb().transaction(j, "readwrite");
|
|
2696
|
-
a.objectStore(j).put(e), await ae(a);
|
|
2697
|
-
}
|
|
2698
|
-
async loadContext(e, t) {
|
|
2699
|
-
const n = this._requireDb().transaction(j, "readonly");
|
|
2700
|
-
return await oe(n.objectStore(j).get([e, t])) ?? null;
|
|
2701
|
-
}
|
|
2702
|
-
/**
|
|
2703
|
-
* Delete all context entries for a session whose threadId is lexicographically
|
|
2704
|
-
* greater than the given threadId. Used during rollback to prune future branches.
|
|
2705
|
-
*
|
|
2706
|
-
* Thread IDs are UUIDv7 (lexicographically sortable by time), so string
|
|
2707
|
-
* comparison is sufficient.
|
|
2708
|
-
*/
|
|
2709
|
-
async deleteContextsAfterThread(e, t) {
|
|
2710
|
-
const n = this._requireDb().transaction(j, "readwrite"), s = n.objectStore(j).openCursor();
|
|
2711
|
-
await new Promise((l, d) => {
|
|
2712
|
-
s.onsuccess = () => {
|
|
2713
|
-
const c = s.result;
|
|
2714
|
-
if (!c) {
|
|
2715
|
-
l();
|
|
2716
|
-
return;
|
|
2717
|
-
}
|
|
2718
|
-
const g = c.value;
|
|
2719
|
-
if (g.sessionId === e && g.threadId > t)
|
|
2720
|
-
try {
|
|
2721
|
-
c.delete();
|
|
2722
|
-
} catch {
|
|
2723
|
-
}
|
|
2724
|
-
c.continue();
|
|
2725
|
-
}, s.onerror = () => d(s.error);
|
|
2726
|
-
}), await ae(n);
|
|
2727
|
-
}
|
|
2728
|
-
/**
|
|
2729
|
-
* Load the most recent context for a session (latest threadId).
|
|
2730
|
-
* Uses lexicographic ordering of UUIDv7 threadIds for chronological sort.
|
|
2731
|
-
*/
|
|
2732
|
-
async loadLatestContext(e) {
|
|
2733
|
-
const n = this._requireDb().transaction(j, "readonly").objectStore(j), i = IDBKeyRange.bound([e, ""], [e, ""]);
|
|
2734
|
-
return new Promise((s, l) => {
|
|
2735
|
-
const d = n.openCursor(i, "prev");
|
|
2736
|
-
d.onsuccess = () => {
|
|
2737
|
-
const c = d.result;
|
|
2738
|
-
s(c ? c.value : null);
|
|
2739
|
-
}, d.onerror = () => l(d.error);
|
|
2740
|
-
});
|
|
2741
|
-
}
|
|
2742
|
-
// -------------------------------------------------------------------------
|
|
2743
|
-
// Payload
|
|
2744
|
-
// -------------------------------------------------------------------------
|
|
2745
|
-
async savePayload(e) {
|
|
2746
|
-
const a = this._requireDb().transaction($, "readwrite");
|
|
2747
|
-
a.objectStore($).put(e), await ae(a);
|
|
2748
|
-
}
|
|
2749
|
-
async loadPayload(e, t) {
|
|
2750
|
-
const n = this._requireDb().transaction($, "readonly");
|
|
2751
|
-
return await oe(n.objectStore($).get([e, t])) ?? null;
|
|
2752
|
-
}
|
|
2753
|
-
async loadPayloadsByThread(e) {
|
|
2754
|
-
const n = this._requireDb().transaction($, "readonly").objectStore($).index("threadId"), i = [];
|
|
2755
|
-
return new Promise((s, l) => {
|
|
2756
|
-
const d = n.openCursor(IDBKeyRange.only(e));
|
|
2757
|
-
d.onsuccess = () => {
|
|
2758
|
-
const c = d.result;
|
|
2759
|
-
if (!c) {
|
|
2760
|
-
s(i);
|
|
2761
|
-
return;
|
|
2762
|
-
}
|
|
2763
|
-
i.push(c.value), c.continue();
|
|
2764
|
-
}, d.onerror = () => l(d.error);
|
|
2765
|
-
});
|
|
2766
|
-
}
|
|
2767
|
-
// -------------------------------------------------------------------------
|
|
2768
|
-
// Favorites
|
|
2769
|
-
// -------------------------------------------------------------------------
|
|
2770
|
-
async saveFavorite(e) {
|
|
2771
|
-
const a = this._requireDb().transaction(V, "readwrite");
|
|
2772
|
-
a.objectStore(V).put(e), await ae(a);
|
|
2773
|
-
}
|
|
2774
|
-
async removeFavorite(e, t, a) {
|
|
2775
|
-
const i = this._requireDb().transaction(V, "readwrite");
|
|
2776
|
-
i.objectStore(V).delete([e, t, a]), await ae(i);
|
|
2777
|
-
}
|
|
2778
|
-
async loadFavorites(e, t) {
|
|
2779
|
-
const n = this._requireDb().transaction(V, "readonly");
|
|
2780
|
-
return (await oe(n.objectStore(V).getAll())).filter((s) => s.userId === e && s.appId === t);
|
|
2781
|
-
}
|
|
2782
|
-
async isFavorite(e, t, a) {
|
|
2783
|
-
const i = this._requireDb().transaction(V, "readonly");
|
|
2784
|
-
return await oe(i.objectStore(V).get([e, t, a])) !== void 0;
|
|
2785
|
-
}
|
|
2786
|
-
// -------------------------------------------------------------------------
|
|
2787
|
-
// Internal
|
|
2788
|
-
// -------------------------------------------------------------------------
|
|
2789
|
-
_requireDb() {
|
|
2790
|
-
if (!this._db)
|
|
2791
|
-
throw new Error("GengageIndexedDB: database not open. Call open() first.");
|
|
2792
|
-
return this._db;
|
|
2793
|
-
}
|
|
2794
|
-
}
|
|
2795
|
-
const Fa = [
|
|
2796
|
-
"comparisonTable",
|
|
2797
|
-
"groupList",
|
|
2798
|
-
"productDetailsSimilars",
|
|
2799
|
-
"productList"
|
|
2800
|
-
];
|
|
2801
|
-
class qa {
|
|
2802
|
-
constructor(e) {
|
|
2803
|
-
this._lockCount = 1, this._hiddenByUser = !1, this._lastPanelContentType = null, this._chatShown = !1, this._isFavoritesMode = !1, this._lastExtended = !1, this._onChange = e.onChange;
|
|
2804
|
-
const t = new Set(Fa);
|
|
2805
|
-
e.productDetailsInPanel && t.add("productDetails"), this._panelContentTypes = t;
|
|
2806
|
-
}
|
|
2807
|
-
get isExtended() {
|
|
2808
|
-
return this._lockCount === 0 && !this._hiddenByUser && !this._isFavoritesMode && this._lastPanelContentType !== null && this._panelContentTypes.has(this._lastPanelContentType) && this._chatShown;
|
|
2809
|
-
}
|
|
2810
|
-
unlock() {
|
|
2811
|
-
this._lockCount > 0 && this._lockCount--, this._checkStateChange();
|
|
2812
|
-
}
|
|
2813
|
-
lock() {
|
|
2814
|
-
this._lockCount++, this._checkStateChange();
|
|
2815
|
-
}
|
|
2816
|
-
setHiddenByUser(e) {
|
|
2817
|
-
this._hiddenByUser = e, this._checkStateChange();
|
|
2818
|
-
}
|
|
2819
|
-
setChatShown(e) {
|
|
2820
|
-
this._chatShown = e, this._checkStateChange();
|
|
2821
|
-
}
|
|
2822
|
-
setFavoritesMode(e) {
|
|
2823
|
-
this._isFavoritesMode = e, this._checkStateChange();
|
|
2824
|
-
}
|
|
2825
|
-
setPanelContentType(e) {
|
|
2826
|
-
this._lastPanelContentType = e, this._checkStateChange();
|
|
2827
|
-
}
|
|
2828
|
-
_checkStateChange() {
|
|
2829
|
-
const e = this.isExtended;
|
|
2830
|
-
e !== this._lastExtended && (this._lastExtended = e, this._onChange(e));
|
|
2831
|
-
}
|
|
2832
|
-
}
|
|
2833
|
-
class Ha {
|
|
2834
|
-
constructor(e) {
|
|
2835
|
-
this.deps = e, this.snapshots = /* @__PURE__ */ new Map(), this.snapshotTypes = /* @__PURE__ */ new Map(), this.activePanelMessageId = null, this.currentType = null, this.threads = [], this.lastActionType = null;
|
|
2836
|
-
}
|
|
2837
|
-
/**
|
|
2838
|
-
* Deep-clone the current panel content (excluding topbar/thumbnails) and store
|
|
2839
|
-
* it keyed by message ID. Called when a stream completes so panel content can
|
|
2840
|
-
* be restored later without duplicating the topbar.
|
|
2841
|
-
*/
|
|
2842
|
-
snapshotForMessage(e) {
|
|
2843
|
-
const t = this.deps.drawer();
|
|
2844
|
-
if (!t?.hasPanelContent() || t.isPanelLoading()) return;
|
|
2845
|
-
const a = t.getPanelContentElement();
|
|
2846
|
-
if (!a) return;
|
|
2847
|
-
const n = a.cloneNode(!0);
|
|
2848
|
-
this.snapshots.set(e, n), this.currentType && this.snapshotTypes.set(e, this.currentType);
|
|
2849
|
-
}
|
|
2850
|
-
/**
|
|
2851
|
-
* Attach a click handler to a bot message bubble so clicking it restores
|
|
2852
|
-
* the panel content that was active when that message was received.
|
|
2853
|
-
*/
|
|
2854
|
-
attachClickHandler(e) {
|
|
2855
|
-
const a = this.deps.shadow()?.querySelector(`[data-message-id="${CSS.escape(e)}"]`);
|
|
2856
|
-
a && (a.style.cursor = "pointer", a.addEventListener("click", () => this.restoreForMessage(e)));
|
|
2857
|
-
}
|
|
2858
|
-
/**
|
|
2859
|
-
* Restore the panel content snapshot associated with a given message ID.
|
|
2860
|
-
* Highlights the active message and de-highlights the previous one.
|
|
2861
|
-
* Also restores the panel topbar title for the snapshot's component type.
|
|
2862
|
-
* Returns true if the snapshot was found and restored.
|
|
2863
|
-
*/
|
|
2864
|
-
restoreForMessage(e) {
|
|
2865
|
-
const t = this.snapshots.get(e);
|
|
2866
|
-
if (!t) return !1;
|
|
2867
|
-
const a = this.deps.shadow(), n = this.deps.drawer();
|
|
2868
|
-
this.activePanelMessageId && a?.querySelector(`[data-message-id="${CSS.escape(this.activePanelMessageId)}"]`)?.classList.remove("gengage-chat-bubble--active"), a?.querySelector(`[data-message-id="${CSS.escape(e)}"]`)?.classList.add("gengage-chat-bubble--active"), this.activePanelMessageId = e, n?.setPanelContent(t.cloneNode(!0));
|
|
2869
|
-
const s = this.snapshotTypes.get(e);
|
|
2870
|
-
return s && (this.currentType = s, this.updateTopBar(s)), !0;
|
|
2871
|
-
}
|
|
2872
|
-
/**
|
|
2873
|
-
* Send maximize-pdp / minify-pdp bridge messages with production-matching delays.
|
|
2874
|
-
* Called by the extended mode manager when panel extension state changes.
|
|
2875
|
-
*/
|
|
2876
|
-
notifyExtension(e) {
|
|
2877
|
-
const t = this.deps.bridge();
|
|
2878
|
-
e ? setTimeout(() => t?.send("maximize-pdp", {}), 350) : setTimeout(() => t?.send("minify-pdp", {}), 200);
|
|
2879
|
-
}
|
|
2880
|
-
/**
|
|
2881
|
-
* Derive panel title from UISpec root element type using i18n strings.
|
|
2882
|
-
* When the backend provides a `panelTitle` prop, it takes precedence.
|
|
2883
|
-
*/
|
|
2884
|
-
titleForComponent(e, t) {
|
|
2885
|
-
if (t) return t;
|
|
2886
|
-
const a = this.deps.i18n();
|
|
2887
|
-
switch (e) {
|
|
2888
|
-
case "ProductDetailsPanel":
|
|
2889
|
-
return a.panelTitleProductDetails;
|
|
2890
|
-
case "ProductGrid":
|
|
2891
|
-
return _e(this.lastActionType) ? a.panelTitleSearchResults : a.panelTitleSimilarProducts;
|
|
2892
|
-
case "ComparisonTable":
|
|
2893
|
-
return a.panelTitleComparisonResults;
|
|
2894
|
-
case "AIGroupingCards":
|
|
2895
|
-
return a.panelTitleCategories;
|
|
2896
|
-
default:
|
|
2897
|
-
return "";
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
/**
|
|
2901
|
-
* Update the panel top bar navigation state and title.
|
|
2902
|
-
* When the backend provides a `panelTitle`, it takes precedence over i18n defaults.
|
|
2903
|
-
*/
|
|
2904
|
-
updateTopBar(e, t) {
|
|
2905
|
-
const a = this.deps.currentThreadId();
|
|
2906
|
-
if (!a) return;
|
|
2907
|
-
const n = this.threads.indexOf(a), i = n > 0, s = n >= 0 && n < this.threads.length - 1, l = this.titleForComponent(e, t);
|
|
2908
|
-
this.deps.drawer()?.updatePanelTopBar(i, s, l);
|
|
2909
|
-
}
|
|
2910
|
-
/**
|
|
2911
|
-
* Set panel topbar title during loading (before actual panel content arrives).
|
|
2912
|
-
* Maps backend pending types to the same i18n titles used for final content.
|
|
2913
|
-
*/
|
|
2914
|
-
updateTopBarForLoading(e) {
|
|
2915
|
-
const t = this.deps.i18n(), n = {
|
|
2916
|
-
productDetails: t.panelTitleProductDetails,
|
|
2917
|
-
productList: _e(this.lastActionType) ? t.panelTitleSearchResults : t.panelTitleSimilarProducts,
|
|
2918
|
-
comparisonTable: t.panelTitleComparisonResults,
|
|
2919
|
-
groupList: t.panelTitleCategories
|
|
2920
|
-
}[e] ?? "";
|
|
2921
|
-
if (n) {
|
|
2922
|
-
const i = this.deps.currentThreadId(), s = i ? this.threads.indexOf(i) : -1, l = s > 0, d = s >= 0 && s < this.threads.length - 1;
|
|
2923
|
-
this.deps.drawer()?.updatePanelTopBar(l, d, n);
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
|
-
/**
|
|
2927
|
-
* Map UISpec component types to PanelContentType for the extended mode manager.
|
|
2928
|
-
*/
|
|
2929
|
-
updateExtendedMode(e) {
|
|
2930
|
-
const a = {
|
|
2931
|
-
ComparisonTable: "comparisonTable",
|
|
2932
|
-
AIGroupingCards: "groupList",
|
|
2933
|
-
ProductDetailsPanel: "productDetails",
|
|
2934
|
-
ProductGrid: "productList"
|
|
2935
|
-
}[e] ?? null;
|
|
2936
|
-
this.deps.extendedModeManager()?.setPanelContentType(a);
|
|
2937
|
-
}
|
|
2938
|
-
/** Navigate to the previous panel thread. */
|
|
2939
|
-
navigateBack() {
|
|
2940
|
-
const e = this.deps.currentThreadId();
|
|
2941
|
-
if (!e) return;
|
|
2942
|
-
const t = this.threads.indexOf(e);
|
|
2943
|
-
if (t > 0) {
|
|
2944
|
-
const a = this.threads[t - 1];
|
|
2945
|
-
a && this.deps.rollbackToThread(a);
|
|
2946
|
-
}
|
|
2947
|
-
}
|
|
2948
|
-
/** Navigate to the next panel thread. */
|
|
2949
|
-
navigateForward() {
|
|
2950
|
-
const e = this.deps.currentThreadId();
|
|
2951
|
-
if (!e) return;
|
|
2952
|
-
const t = this.threads.indexOf(e);
|
|
2953
|
-
if (t >= 0 && t < this.threads.length - 1) {
|
|
2954
|
-
const a = this.threads[t + 1];
|
|
2955
|
-
a && this.deps.rollbackToThread(a);
|
|
2956
|
-
}
|
|
2957
|
-
}
|
|
2958
|
-
/**
|
|
2959
|
-
* Panel route shaping:
|
|
2960
|
-
* - product details => expanded LHS panel (`ProductDetailsPanel`)
|
|
2961
|
-
* - all other panel-routed specs keep their original component types
|
|
2962
|
-
*/
|
|
2963
|
-
toPanelSpec(e) {
|
|
2964
|
-
const t = e.elements[e.root];
|
|
2965
|
-
if (!t || t.type !== "ProductCard") return e;
|
|
2966
|
-
const a = {
|
|
2967
|
-
...t,
|
|
2968
|
-
type: "ProductDetailsPanel"
|
|
2969
|
-
};
|
|
2970
|
-
return {
|
|
2971
|
-
root: e.root,
|
|
2972
|
-
elements: {
|
|
2973
|
-
...e.elements,
|
|
2974
|
-
[e.root]: a
|
|
2975
|
-
}
|
|
2976
|
-
};
|
|
2977
|
-
}
|
|
2978
|
-
destroy() {
|
|
2979
|
-
this.snapshots.clear(), this.snapshotTypes.clear(), this.activePanelMessageId = null, this.currentType = null, this.threads = [];
|
|
2980
|
-
}
|
|
2981
|
-
}
|
|
2982
|
-
function _e(o) {
|
|
2983
|
-
return o === "user_message" || o === "inputText";
|
|
2984
|
-
}
|
|
2985
|
-
function Oa(o) {
|
|
2986
|
-
return o.similarsAppend && o.currentPanelType === "ProductDetailsPanel" && o.hasPanelContent && !o.isPanelLoading ? "appendSimilars" : o.componentType === "ProductGrid" && !o.isFirstPanelContentInStream && o.hasPanelContent && !o.isPanelLoading ? "append" : "replace";
|
|
2987
|
-
}
|
|
2988
|
-
class ke {
|
|
2989
|
-
constructor(e) {
|
|
2990
|
-
this.favoritedSkus = /* @__PURE__ */ new Set(), this._persistLock = Promise.resolve(), this._db = e;
|
|
2991
|
-
}
|
|
2992
|
-
get db() {
|
|
2993
|
-
return this._db;
|
|
2994
|
-
}
|
|
2995
|
-
set db(e) {
|
|
2996
|
-
this._db = e;
|
|
2997
|
-
}
|
|
2998
|
-
/**
|
|
2999
|
-
* Persist current session state to IndexedDB.
|
|
3000
|
-
* Called after each stream completion (onDone). Non-fatal on failure.
|
|
3001
|
-
*/
|
|
3002
|
-
async persist(e) {
|
|
3003
|
-
if (!this._db) return;
|
|
3004
|
-
const t = this._persistLock;
|
|
3005
|
-
let a;
|
|
3006
|
-
this._persistLock = new Promise((n) => {
|
|
3007
|
-
a = n;
|
|
3008
|
-
}), await t;
|
|
3009
|
-
try {
|
|
3010
|
-
await this._persistImpl(e);
|
|
3011
|
-
} finally {
|
|
3012
|
-
a();
|
|
3013
|
-
}
|
|
3014
|
-
}
|
|
3015
|
-
async _persistImpl(e) {
|
|
3016
|
-
if (!this._db) return;
|
|
3017
|
-
const t = e.messages.map((n) => {
|
|
3018
|
-
const i = {
|
|
3019
|
-
id: n.id,
|
|
3020
|
-
role: n.role,
|
|
3021
|
-
timestamp: n.timestamp,
|
|
3022
|
-
status: n.status === "streaming" ? "done" : n.status
|
|
3023
|
-
};
|
|
3024
|
-
return n.threadId !== void 0 && (i.threadId = n.threadId), n.content !== void 0 && (i.content = n.content), n.silent && (i.silent = !0), i;
|
|
3025
|
-
}), a = {};
|
|
3026
|
-
for (const [n, i] of e.panelSnapshots)
|
|
3027
|
-
i.querySelector(".gengage-chat-panel-skeleton") || (a[n] = i.innerHTML);
|
|
3028
|
-
await this._db.saveSession({
|
|
3029
|
-
userId: e.userId,
|
|
3030
|
-
appId: e.appId,
|
|
3031
|
-
sessionId: e.sessionId,
|
|
3032
|
-
messages: t,
|
|
3033
|
-
currentThreadId: e.currentThreadId,
|
|
3034
|
-
lastThreadId: e.lastThreadId,
|
|
3035
|
-
createdAt: e.chatCreatedAt,
|
|
3036
|
-
panelThreads: e.panelThreads.length > 0 ? e.panelThreads : void 0,
|
|
3037
|
-
thumbnailEntries: e.thumbnailEntries.length > 0 ? e.thumbnailEntries : void 0,
|
|
3038
|
-
panelSnapshotHtml: Object.keys(a).length > 0 ? a : void 0,
|
|
3039
|
-
sku: e.sku
|
|
3040
|
-
}), e.lastBackendContext && e.currentThreadId && await this._db.saveContext({
|
|
3041
|
-
sessionId: e.sessionId,
|
|
3042
|
-
threadId: e.currentThreadId,
|
|
3043
|
-
context: e.lastBackendContext
|
|
3044
|
-
});
|
|
3045
|
-
for (const n of e.messages)
|
|
3046
|
-
n.uiSpec && n.threadId && await this._db.savePayload({
|
|
3047
|
-
threadId: n.threadId,
|
|
3048
|
-
messageId: n.id,
|
|
3049
|
-
uiSpec: n.uiSpec
|
|
3050
|
-
});
|
|
3051
|
-
}
|
|
3052
|
-
/**
|
|
3053
|
-
* Persist session to IndexedDB, then navigate to the URL.
|
|
3054
|
-
* Sends an 'openURLInNewTab' bridge message so the host page can intercept
|
|
3055
|
-
* (e.g. for SPA routing), then navigates directly as fallback.
|
|
3056
|
-
*
|
|
3057
|
-
* Legacy compatibility: the prior engine navigated via window.location.href
|
|
3058
|
-
* after posting saveSessionAndOpenURL to the iframe. The clean-room runs in
|
|
3059
|
-
* the same window (Shadow DOM, not iframe), so it navigates directly.
|
|
3060
|
-
*/
|
|
3061
|
-
async saveAndOpenURL(e, t, a) {
|
|
3062
|
-
try {
|
|
3063
|
-
await t();
|
|
3064
|
-
} catch {
|
|
3065
|
-
}
|
|
3066
|
-
a?.send("openURLInNewTab", { url: e }), O(e) && (window.location.href = e);
|
|
3067
|
-
}
|
|
3068
|
-
/**
|
|
3069
|
-
* Load a UISpec payload from IndexedDB with retry logic.
|
|
3070
|
-
* Returns null if not found or all retries fail.
|
|
3071
|
-
*/
|
|
3072
|
-
async loadPayload(e, t) {
|
|
3073
|
-
if (!this._db) return null;
|
|
3074
|
-
for (let a = 0; a < 3; a++) {
|
|
3075
|
-
try {
|
|
3076
|
-
const n = await this._db.loadPayload(e, t);
|
|
3077
|
-
if (n) return n.uiSpec;
|
|
3078
|
-
} catch {
|
|
3079
|
-
}
|
|
3080
|
-
a < 2 && await new Promise((n) => setTimeout(n, 100));
|
|
3081
|
-
}
|
|
3082
|
-
return null;
|
|
3083
|
-
}
|
|
3084
|
-
/**
|
|
3085
|
-
* Load favorited SKUs from IDB into the in-memory set.
|
|
3086
|
-
*/
|
|
3087
|
-
async loadFavorites(e, t) {
|
|
3088
|
-
if (this._db)
|
|
3089
|
-
try {
|
|
3090
|
-
const a = await this._db.loadFavorites(e, t);
|
|
3091
|
-
for (const n of a) this.favoritedSkus.add(n.sku);
|
|
3092
|
-
} catch {
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
/**
|
|
3096
|
-
* Toggle a product's favorited state in IDB and in-memory set.
|
|
3097
|
-
*/
|
|
3098
|
-
async toggleFavorite(e, t, a, n) {
|
|
3099
|
-
this._db && (this.favoritedSkus.has(a) ? (this.favoritedSkus.delete(a), await this._db.removeFavorite(e, t, a)) : (this.favoritedSkus.add(a), await this._db.saveFavorite({
|
|
3100
|
-
userId: e,
|
|
3101
|
-
appId: t,
|
|
3102
|
-
sku: a,
|
|
3103
|
-
name: n.name,
|
|
3104
|
-
imageUrl: n.imageUrl,
|
|
3105
|
-
price: n.price,
|
|
3106
|
-
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3107
|
-
})));
|
|
3108
|
-
}
|
|
3109
|
-
close() {
|
|
3110
|
-
this._db?.close(), this._db = null;
|
|
3111
|
-
}
|
|
3112
|
-
}
|
|
3113
|
-
const Fe = "gengage_kvkk_shown", ja = ["kvkk", "kişisel veri", "kisisel veri"], Va = /\b6698\b/;
|
|
3114
|
-
function ue(o) {
|
|
3115
|
-
const e = o.toLowerCase();
|
|
3116
|
-
return ja.some((t) => e.includes(t)) || Va.test(e);
|
|
3117
|
-
}
|
|
3118
|
-
function Ce(o) {
|
|
3119
|
-
try {
|
|
3120
|
-
return localStorage.getItem(`${Fe}_${o}`) === "1";
|
|
3121
|
-
} catch {
|
|
3122
|
-
return !1;
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
function Wa(o) {
|
|
3126
|
-
try {
|
|
3127
|
-
localStorage.setItem(`${Fe}_${o}`, "1");
|
|
3128
|
-
} catch {
|
|
3129
|
-
}
|
|
3130
|
-
}
|
|
3131
|
-
function $a(o) {
|
|
3132
|
-
const t = new DOMParser().parseFromString(o, "text/html").body, a = Array.from(t.children);
|
|
3133
|
-
for (const n of a)
|
|
3134
|
-
if (ue(n.textContent ?? "")) {
|
|
3135
|
-
n.remove();
|
|
3136
|
-
break;
|
|
3137
|
-
}
|
|
3138
|
-
return t.innerHTML.trim();
|
|
3139
|
-
}
|
|
3140
|
-
function Ga(o) {
|
|
3141
|
-
const e = new DOMParser().parseFromString(o, "text/html");
|
|
3142
|
-
for (const t of Array.from(e.body.children))
|
|
3143
|
-
if (ue(t.textContent ?? ""))
|
|
3144
|
-
return t.outerHTML;
|
|
3145
|
-
return null;
|
|
3146
|
-
}
|
|
3147
|
-
const Ya = {
|
|
3148
|
-
tr: "TURKISH",
|
|
3149
|
-
en: "ENGLISH",
|
|
3150
|
-
de: "GERMAN",
|
|
3151
|
-
fr: "FRENCH"
|
|
3152
|
-
};
|
|
3153
|
-
function Ka(o) {
|
|
3154
|
-
return o ? Ya[o.toLowerCase().slice(0, 2)] ?? "TURKISH" : "TURKISH";
|
|
3155
|
-
}
|
|
3156
|
-
const Qa = ':host{all:initial;font-family:var(--gengage-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:var(--gengage-font-size, 14px)}.gengage-chat-root button,.gengage-chat-root [role=button],.gengage-chat-root a{cursor:pointer}.gengage-chat-root{position:fixed;z-index:var(--gengage-z-index, 2147483647);--_gengage-chat-offset: var(--gengage-chat-offset, 20px);--_gengage-chat-launcher-bottom: var(--gengage-chat-launcher-bottom, 20px);--_gengage-chat-launcher-right: var(--gengage-chat-launcher-right, 20px);--_gengage-chat-launcher-size: var(--gengage-chat-launcher-size, 56px);--_gengage-chat-drawer-width: var(--gengage-chat-width, 400px);--_gengage-chat-radius: var(--gengage-chat-shell-radius, 12px);--_gengage-chat-header-height: var(--gengage-chat-header-height, 60px);--_gengage-chat-conversation-width: var(--gengage-chat-conversation-width, 396px);--_gengage-chat-panel-min-width: var(--gengage-chat-panel-min-width, 320px);--_gengage-chat-panel-max-width: var(--gengage-chat-panel-max-width, 860px);--_gengage-chat-input-height: var(--gengage-chat-input-height, 48px);--_gengage-chat-shadow: var(--gengage-chat-shadow, 0 12px 40px rgba(15, 23, 42, .18));--_gengage-border-color: var(--gengage-border-color, #e5e7eb);--_gengage-discount-color: var(--gengage-discount-color, #ef4444);--_gengage-success-color: var(--gengage-success-color, #16a34a);--_gengage-text-primary: var(--gengage-text-primary, #1f2937);--_gengage-text-secondary: var(--gengage-text-secondary, #64748b);--_gengage-surface-secondary: var(--gengage-surface-secondary, #f3f4f6);--_gengage-surface-muted: var(--gengage-surface-muted, #f8fafc);--_gengage-surface-dark: var(--gengage-surface-dark, #1e293b);--_gengage-rating-color: var(--gengage-rating-color, #d97706);--_gengage-qty-btn-size: var(--gengage-qty-btn-size, 28px);--_gengage-qty-btn-size-compact: var(--gengage-qty-btn-size-compact, 24px)}.gengage-chat-launcher-container{position:fixed;bottom:var(--_gengage-chat-launcher-bottom);right:var(--_gengage-chat-launcher-right);display:flex;flex-direction:column;align-items:flex-end;gap:10px;z-index:var(--gengage-z-index, 2147483647)}.gengage-chat-launcher-content-area,.gengage-chat-launcher-content-area-bottom{display:flex;flex-direction:column;align-items:flex-end;gap:8px}.gengage-chat-launcher-content-area:empty,.gengage-chat-launcher-content-area-bottom:empty{display:none}.gengage-chat-root--open .gengage-chat-launcher-content-area,.gengage-chat-root--open .gengage-chat-launcher-content-area-bottom{display:none}.gengage-chat-root--open .gengage-chat-launcher-container{pointer-events:none;opacity:0;transition:opacity .2s ease}.gengage-chat-launcher{width:var(--_gengage-chat-launcher-size);height:var(--_gengage-chat-launcher-size);border-radius:50%;border:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 22px #0f172a47;transition:transform .18s cubic-bezier(.2,.8,.2,1),box-shadow .18s ease;position:relative;flex-shrink:0}.gengage-chat-launcher:hover{transform:scale(1.05);box-shadow:0 14px 28px #0f172a47}.gengage-chat-launcher svg{width:24px;height:24px}.gengage-chat-launcher--image-mode{background:none;border-radius:0;box-shadow:none;padding:0;overflow:hidden}.gengage-chat-launcher--image-mode:hover{box-shadow:none}.gengage-chat-launcher--image-mode img{width:100%;height:100%;object-fit:contain}.gengage-chat-launcher--hidden-mobile{display:none!important}.gengage-chat-launcher-tooltip{position:absolute;right:calc(100% + 12px);top:50%;transform:translateY(-50%);padding:6px 12px;border-radius:8px;background:var(--_gengage-surface-dark);color:#fff;font-size:13px;font-weight:500;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .2s ease;box-shadow:0 2px 8px #00000026}.gengage-chat-launcher-tooltip:after{content:"";position:absolute;left:100%;top:50%;transform:translateY(-50%);border:5px solid transparent;border-left-color:var(--_gengage-surface-dark)}.gengage-chat-launcher:hover .gengage-chat-launcher-tooltip{opacity:1}.gengage-chat-root--open .gengage-chat-launcher-tooltip{display:none}.gengage-chat-drawer{position:fixed;top:0;bottom:0;right:0;width:var(--_gengage-chat-drawer-width);max-height:-webkit-fill-available;max-height:100dvh;border-radius:0;background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:var(--gengage-z-index, 2147483647);transform:translate(0);transition:transform .25s cubic-bezier(.4,0,.2,1),opacity .2s ease;opacity:1}.gengage-chat-root--mobile .gengage-chat-launcher-container{right:var(--gengage-chat-launcher-mobile-right, 16px);bottom:calc(var(--gengage-chat-launcher-mobile-bottom, 16px) + env(safe-area-inset-bottom,0px))}.gengage-chat-root--mobile .gengage-chat-drawer{left:0;right:0;bottom:0;width:100%;max-width:none;max-height:-webkit-fill-available;max-height:100dvh;border-radius:16px 16px 0 0;border-top:1px solid rgba(0,0,0,.06);box-shadow:0 -4px 16px #0000001a,0 12px 40px #0f172a2e;padding-bottom:env(safe-area-inset-bottom,0px)}.gengage-chat-root--mobile.gengage-chat-root--open:before{content:"";position:fixed;inset:0;background:#0000001f;z-index:-1;pointer-events:none}.gengage-chat-root--mobile.gengage-chat-root--mobile-half .gengage-chat-drawer{top:auto;height:min(72dvh,620px);max-height:min(72dvh,620px)}.gengage-chat-root--mobile.gengage-chat-root--mobile-full .gengage-chat-drawer{top:0;height:100dvh;max-height:100dvh;border-radius:0;border-top:none}.gengage-chat-root--mobile .gengage-chat-input-area{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--_gengage-border-color, #e5e7eb);transform:translateY(calc(-1 * var(--gengage-keyboard-offset, 0px)))}.gengage-chat-header{display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;min-height:var(--_gengage-chat-header-height);padding:4px 12px;background:var(--gengage-chat-header-bg, #1d2939);color:var(--gengage-chat-header-foreground, #fff);box-shadow:0 4px 20px #00000014,0 0 2px #0000001f;border:none;position:relative;z-index:2}.gengage-chat-header-left{display:flex;align-items:center;gap:10px;min-width:0}.gengage-chat-header-avatar{width:40px;height:40px;border-radius:0;object-fit:contain;flex-shrink:0}.gengage-chat-header-info{display:flex;flex-direction:column;gap:2px;min-width:0}.gengage-chat-header-title-row{display:flex;align-items:center;gap:6px}.gengage-chat-header-title{font-weight:700;font-size:15px;line-height:1.25;letter-spacing:.01em;color:inherit}.gengage-chat-header-badge{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;line-height:1.5}.gengage-chat-header-powered{display:flex;align-items:center;gap:4px;font-size:11px;color:#ffffffbf;text-decoration:none;transition:color .15s}.gengage-chat-header-powered:hover{color:#fffc}.gengage-chat-header-powered svg{width:12px;height:12px;opacity:.6}.gengage-chat-header-right{display:flex;align-items:center;gap:4px;flex-shrink:0}.gengage-chat-header-btn{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-header-btn:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-close{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;font-size:18px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-close:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-body{display:flex;flex:1;overflow:hidden;min-height:0}.gengage-chat-panel{display:none;width:0;overflow:hidden;transition:width .22s cubic-bezier(.2,.72,.2,1)}.gengage-chat-panel--visible{display:flex;flex-direction:column;position:relative;box-sizing:border-box;width:440px;min-width:440px;background:var(--gengage-chat-panel-bg, #fff);border-right:1px solid var(--_gengage-border-color);overflow-y:auto;padding:16px;background:var(--_gengage-surface-muted)}.gengage-chat-panel-divider{display:flex;align-items:center;width:4px;cursor:pointer;background:var(--_gengage-border-color);position:relative;flex-shrink:0;transition:background .15s;z-index:2}.gengage-chat-panel-divider:hover{background:#cbd5e1}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-panel-divider-toggle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:24px;height:48px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:var(--_gengage-text-secondary);box-shadow:0 1px 3px #00000014;transition:background .15s,color .15s;padding:0;line-height:1}.gengage-chat-panel-divider-toggle:hover{background:var(--_gengage-surface-muted);color:#334155}.gengage-chat-panel--collapsed{flex:0 0 0px!important;width:0!important;min-width:0!important;max-width:0!important;padding:0!important;border-right:none!important;overflow:hidden}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:0;transform:translateY(-50%)}.gengage-chat-conversation{display:flex;flex-direction:column;flex:1;min-width:0;overflow:hidden;background:var(--gengage-background-color, #fff);position:relative;z-index:1}.gengage-chat-drawer--with-panel{width:auto;background:transparent;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-header{border-radius:0;flex-shrink:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex:1 1 0;min-height:0;gap:0;padding:0;align-items:stretch}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{flex:0 0 auto;width:clamp(var(--_gengage-chat-panel-min-width),50vw,var(--_gengage-chat-panel-max-width));min-width:var(--_gengage-chat-panel-min-width);max-width:var(--_gengage-chat-panel-max-width);border-right:none;background:#fff;padding:0 16px 16px;overflow-y:auto;margin:0;border-radius:0;box-shadow:0 8px 32px #0f172a1f,0 2px 8px #0f172a0f;max-height:100dvh}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{width:20px;height:48px;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;border:2px solid #fff;box-shadow:0 2px 8px #0f172a2e;font-size:12px;z-index:10}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover{background:var(--gengage-primary-hover, #2563eb);color:#fff}.gengage-chat-drawer--with-panel .gengage-chat-conversation{flex:0 0 var(--_gengage-chat-conversation-width);width:var(--_gengage-chat-conversation-width);border-left:none;background:var(--gengage-background-color, #fff);box-shadow:-4px 0 24px #0f172a1f,-1px 0 4px #0f172a0f}.gengage-chat-drawer--with-panel .gengage-chat-messages{padding-right:6px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.12) transparent}.gengage-chat-drawer--with-panel .gengage-chat-messages::-webkit-scrollbar{width:0}.gengage-chat-drawer--with-panel:has(.gengage-chat-panel--collapsed){width:var(--_gengage-chat-conversation-width);background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow)}.gengage-chat-drawer--with-panel .gengage-chat-footer{display:none}.gengage-chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px;min-height:0;scroll-behavior:smooth;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}.gengage-chat-messages::-webkit-scrollbar{width:6px}.gengage-chat-messages::-webkit-scrollbar-track{background:transparent}.gengage-chat-messages::-webkit-scrollbar-thumb{background:#0000001f;border-radius:3px}.gengage-chat-messages::-webkit-scrollbar-thumb:hover{background:#0003}.gengage-chat-bubble{max-width:85%;padding:12px 16px;border-radius:12px;line-height:1.5;font-size:14px;font-weight:500;word-wrap:break-word;overflow-wrap:break-word;animation:gengage-chat-msg-in .3s cubic-bezier(.2,.7,.2,1)}@keyframes gengage-chat-msg-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-bubble--user{align-self:flex-end;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);border-bottom-right-radius:4px}.gengage-chat-bubble--assistant{align-self:flex-start;background:var(--_gengage-surface-secondary);color:var(--_gengage-text-primary);border-bottom-left-radius:4px;min-width:120px}.gengage-chat-bubble--active{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:-2px}.gengage-chat-bubble--assistant:empty{display:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a{color:var(--gengage-primary-color, #2563eb);text-decoration:underline}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a:hover{text-decoration:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p{margin:0 0 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p:last-child{margin-bottom:0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text ul,.gengage-chat-bubble--assistant .gengage-chat-bubble-text ol{margin:6px 0;padding-left:20px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text li{margin-bottom:6px;line-height:1.5}.gengage-chat-bubble--assistant .gengage-chat-bubble-text code{background:#0000000f;padding:1px 4px;border-radius:3px;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text pre{background:#0000000a;padding:8px;border-radius:6px;overflow-x:auto;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text table{border-collapse:collapse;margin:4px 0;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text th,.gengage-chat-bubble--assistant .gengage-chat-bubble-text td{border:1px solid var(--_gengage-border-color);padding:4px 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text img{max-width:100%;height:auto;border-radius:4px;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text h1,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h2,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h3,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h4,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h5,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h6{margin:8px 0 4px;line-height:1.3;color:#0f172a}.gengage-chat-bubble--assistant .gengage-chat-bubble-text blockquote{border-left:3px solid var(--_gengage-border-color);padding-left:12px;margin:4px 0;color:var(--_gengage-text-secondary)}.gengage-chat-bubble--first{border-left:3px solid var(--gengage-accent-primary, #3b82f6);padding-left:12px}.gengage-chat-bubble--first .gengage-chat-bubble-text{font-size:15px}.gengage-chat-typing{display:flex;align-items:center;gap:5px;padding:8px 4px;align-self:flex-start;max-width:85%}.gengage-chat-typing:has(.gengage-chat-typing-text),.gengage-chat-typing:has(.gengage-chat-thinking-steps){background:var(--_gengage-surface-secondary);padding:10px 14px;border-radius:12px 12px 12px 4px;gap:8px}.gengage-chat-typing-dots{display:flex;align-items:center;gap:5px}.gengage-chat-typing-dots span{width:6px;height:6px;border-radius:50%;background:#94a3b8;display:inline-block;animation:gengage-chat-typing-fade 1.4s ease-in-out infinite}.gengage-chat-typing-dots span:nth-child(2){animation-delay:.2s}.gengage-chat-typing-dots span:nth-child(3){animation-delay:.4s}@keyframes gengage-chat-typing-fade{0%,to{opacity:.25}50%{opacity:1}}.gengage-chat-typing-sparkle{animation:gengage-sparkle-pulse 1.2s infinite}@keyframes gengage-sparkle-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-typing-text{font-size:13px;color:var(--_gengage-text-secondary);font-style:italic;flex:1;min-width:0;word-wrap:break-word;overflow-wrap:break-word}.gengage-chat-stop-btn{display:flex;align-items:center;gap:6px;margin:4px 0 8px;padding:6px 14px;border:1px solid #d1d5db;border-radius:16px;background:#fff;color:var(--_gengage-text-secondary);font-size:13px;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-stop-btn:hover{background:var(--_gengage-surface-secondary);border-color:#9ca3af}.gengage-chat-stop-btn:focus-visible{outline:2px solid var(--gengage-chat-primary, #f27a1a);outline-offset:2px}.gengage-chat-stop-icon{display:inline-block;width:10px;height:10px;background:currentColor;border-radius:2px;flex-shrink:0}.gengage-chat-offline-bar{display:none;align-items:center;gap:6px;padding:6px 12px;font-size:12px;line-height:1.4;color:#92400e;background:#fef3c7;border-bottom:1px solid #fde68a}.gengage-chat-offline-bar--visible{display:flex}.gengage-chat-offline-bar:before{content:"";display:inline-block;width:8px;height:8px;background:var(--_gengage-rating-color);border-radius:50%;flex-shrink:0}.gengage-chat-still-working{font-size:12px;color:var(--gengage-chat-text-secondary, #666);margin-top:6px;animation:gengage-fade-in .3s ease}@keyframes gengage-fade-in{0%{opacity:0}to{opacity:1}}.gengage-chat-thinking-steps{display:flex;flex-direction:column;gap:4px;padding:4px 0}.gengage-chat-thinking-step{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--gengage-chat-text-secondary, #666)}.gengage-chat-thinking-step-marker{font-size:12px;width:16px;text-align:center;flex-shrink:0}.gengage-chat-thinking-step-marker--done{color:var(--gengage-chat-success, #4caf50)}.gengage-chat-thinking-step-marker--active{color:var(--gengage-chat-primary, #1976d2);animation:gengage-thinking-pulse 1.5s ease-in-out infinite}@keyframes gengage-thinking-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-thinking-step-text{line-height:1.4}.gengage-chat-error{display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 14px;border-radius:10px;background:#fef2f2;color:#991b1b;font-size:13px;text-align:center;border:1px solid #fecaca}.gengage-chat-error-retry{flex-shrink:0;padding:4px 12px;border:1px solid #fca5a5;border-radius:6px;background:#fff;color:#991b1b;font-size:12px;font-weight:500;cursor:pointer;transition:background .15s}.gengage-chat-error-retry:hover{background:#fee2e2}.gengage-chat-input-area{display:flex;flex-wrap:wrap;align-items:center;flex-shrink:0;gap:0;padding:8px 12px;border-top:1px solid var(--_gengage-border-color);background:var(--gengage-background-color, #fff)}.gengage-chat-input-pill{display:flex;align-items:center;gap:4px;flex:1;min-width:0;height:44px;background:var(--_gengage-surface-secondary);border:1px solid var(--_gengage-border-color);border-radius:30px;padding:2px 8px;overflow:hidden;transition:border-color .2s ease,box-shadow .2s ease}.gengage-chat-input-pill:focus-within{border-color:var(--gengage-primary-color, #3b82f6);box-shadow:0 0 0 2px #3b82f626}.gengage-chat-input{flex:1;min-width:0;min-height:40px;max-height:120px;padding:0 6px 0 14px;border:none;border-radius:0;font-size:14px;font-family:inherit;line-height:1.4;align-content:center;outline:none;background:transparent;color:var(--_gengage-text-primary);resize:none;overflow-y:hidden}@media(max-width:767px){.gengage-chat-input-pill{height:52px;padding:3px 8px}.gengage-chat-input{min-height:44px;max-height:44px;font-size:16px;white-space:nowrap;overflow:hidden}.gengage-chat-input::placeholder{font-size:15px}}.gengage-chat-input::placeholder{font-size:14px;color:#6b7280}.gengage-chat-send{width:36px;height:36px;min-width:36px;padding:0;border:none;border-radius:50%;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-weight:700;font-size:0;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s ease,transform .15s ease;box-shadow:0 2px 4px #0000001f}.gengage-chat-send:hover{filter:brightness(.92);transform:translateY(-1px);box-shadow:0 4px 8px #0000002e}.gengage-chat-send:active{transform:translateY(0);box-shadow:0 1px 2px #0000001f}.gengage-chat-send svg{width:18px;height:18px}.gengage-chat-send:disabled{background:#d1d5db;box-shadow:none;cursor:not-allowed}.gengage-chat-footer{padding:4px 10px;text-align:center;font-size:10px;color:#6b7280;border-top:1px solid var(--_gengage-surface-muted);background:var(--gengage-background-color, #fff)}.gengage-chat-uispec{width:100%}.gengage-chat-uispec:empty{display:none}.gengage-chat-uispec>*{animation:gengage-chat-widget-enter .16s cubic-bezier(.2,.7,.2,1) both}@keyframes gengage-chat-widget-enter{0%{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-chat-action-buttons{display:flex;flex-wrap:wrap;gap:8px;padding:6px 0 4px}.gengage-chat-action-btn{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;line-height:1.25;font-family:inherit;cursor:pointer;white-space:nowrap;transition:filter .15s ease,transform .1s ease}.gengage-chat-action-btn:hover{filter:brightness(.92)}.gengage-chat-action-btn:active{transform:scale(.97)}.gengage-chat-product-card{position:relative;display:flex;flex-direction:column;border:1px solid #eee;border-radius:16px;overflow:hidden;background:#fff;width:160px;min-width:160px;max-width:160px;box-shadow:0 2px 8px #0000000f;transition:transform .1s ease,box-shadow .2s ease}.gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 16px #0000001f}.gengage-chat-product-card-img{width:100%;height:120px;object-fit:contain;display:block;background:#fff;padding:8px;box-sizing:border-box}.gengage-chat-product-card-body{display:flex;flex-direction:column;flex:1;gap:4px;padding:8px 10px 10px;text-align:center}.gengage-chat-product-card-name{font-size:13px;font-weight:600;color:var(--_gengage-text-primary);line-height:1.35;margin-bottom:0;min-height:2.7em;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-card-brand{font-size:10px;color:#666}.gengage-chat-product-card-rating{font-size:11px;color:var(--_gengage-rating-color);line-height:1}.gengage-star-half{display:inline-block;position:relative}.gengage-star-half>span{position:absolute;left:0;top:0;overflow:hidden;width:.5em}.gengage-chat-product-card-review-count{color:#475569;font-size:10px}.gengage-chat-product-card-price{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:center;gap:2px 4px;font-size:16px;font-weight:800;color:#0f172a}.gengage-chat-product-card-original-price{text-decoration:line-through;color:#64748b;font-weight:400;font-size:12px}.gengage-chat-price-skeleton{display:inline-block;width:80px;height:16px;background:linear-gradient(90deg,#e2e8f0 25%,#f1f5f9,#e2e8f0 75%);background-size:200% 100%;animation:gengage-skeleton-price-pulse 1.5s ease-in-out infinite;border-radius:4px;vertical-align:middle}@keyframes gengage-skeleton-price-pulse{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-product-card-cta{display:block;margin-top:auto;padding:8px 10px;text-align:center;background:transparent;color:var(--gengage-primary-color, #3b82f6);text-decoration:none;font-size:12px;font-weight:700;letter-spacing:.01em;border-top:1px solid var(--_gengage-surface-muted);cursor:pointer;transition:color .15s ease,background .15s ease}.gengage-chat-product-card-cta:hover{color:var(--gengage-primary-color, #0b24d6);background:var(--_gengage-surface-muted)}.gengage-chat-product-card-cta:active{background:var(--_gengage-surface-muted)}.gengage-chat-product-summary{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid var(--_gengage-border-color);border-radius:12px;background:#fff;cursor:pointer;transition:background .15s,box-shadow .15s;margin:4px 0}.gengage-chat-product-summary:hover{background:#f9fafb;box-shadow:0 1px 4px #0000000f}.gengage-chat-product-summary__image{flex-shrink:0;width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid var(--_gengage-surface-secondary);background:#f9fafb}.gengage-chat-product-summary__image img{width:100%;height:100%;object-fit:cover;display:block}.gengage-chat-product-summary__content{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.gengage-chat-product-summary__name{font-size:13px;font-weight:500;line-height:1.3;color:#111827;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-product-summary__rating{font-size:11px;color:var(--_gengage-rating-color);line-height:1}.gengage-chat-product-summary__review-count{color:#475569;font-size:11px}.gengage-chat-product-summary__price{font-size:13px;font-weight:600;color:#111827;line-height:1;margin-top:2px}.gengage-chat-product-summary__price-original{text-decoration:line-through;color:#6b7280;font-weight:400;font-size:11px}.gengage-chat-product-summary__price-current{color:var(--gengage-primary-color, #111827)}.gengage-chat-product-summary__cta{flex-shrink:0;font-size:12px;font-weight:500;color:var(--gengage-primary-color, #2563eb);text-decoration:none;padding:4px 10px;border-radius:8px;transition:background .15s;white-space:nowrap}.gengage-chat-product-summary__cta:hover{background:#0000000a}.gengage-chat-product-summary__cta:focus-visible{outline:2px solid var(--gengage-primary-color, #2563eb);outline-offset:2px}.gengage-chat-product-grid{display:flex;gap:12px;overflow-x:auto;padding:8px 0;-webkit-overflow-scrolling:touch;scrollbar-width:none;scroll-snap-type:x proximity;min-height:180px}.gengage-chat-product-grid>*{scroll-snap-align:start;flex:0 0 auto}.gengage-chat-product-grid::-webkit-scrollbar{display:none}.gengage-chat-review-highlights{padding:2px 0 6px}.gengage-chat-review-item{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:10px 12px;background:#fff}.gengage-chat-review-item[data-tone=positive]{border-color:#bbf7d0;background:#f0fdf4}.gengage-chat-review-item[data-tone=negative]{border-color:#fecaca;background:#fef2f2}.gengage-chat-review-tag{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:var(--_gengage-text-secondary);margin-bottom:4px}.gengage-chat-review-text{font-size:13px;line-height:1.45;color:var(--_gengage-text-primary);display:-webkit-box;-webkit-line-clamp:4;line-clamp:4;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-review-rating{margin-top:6px;font-size:12px;font-weight:700;color:#0f172a}.gengage-chat-review-empty{font-size:12px;color:var(--_gengage-text-secondary)}.gengage-chat-review-tabs{display:flex;gap:6px;margin-bottom:10px}.gengage-chat-review-tab{padding:6px 14px;border:1px solid var(--_gengage-border-color);border-radius:999px;background:#fff;color:var(--_gengage-text-secondary);font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-tab:hover{background:var(--_gengage-surface-muted)}.gengage-chat-review-tab--active{background:var(--_gengage-surface-muted);border-color:#94a3b8;color:#0f172a}.gengage-chat-review-pills{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.gengage-chat-review-pill{display:flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:#fff;font-size:12px;color:#334155;box-shadow:0 1px 2px #0000000a}.gengage-chat-review-pill[data-tone=positive]{border-color:#bbf7d0}.gengage-chat-review-pill[data-tone=negative]{border-color:#fecaca}.gengage-chat-review-pill-icon{font-size:11px;font-weight:700}.gengage-chat-review-pill[data-tone=positive] .gengage-chat-review-pill-icon{color:var(--_gengage-success-color)}.gengage-chat-review-pill[data-tone=negative] .gengage-chat-review-pill-icon{color:#dc2626}.gengage-chat-review-pill-count{font-size:10px;font-weight:700;background:var(--_gengage-surface-muted);color:var(--_gengage-text-secondary);border-radius:4px;padding:1px 5px}.gengage-chat-review-items{display:grid;gap:10px}.gengage-chat-divider{border:none;border-top:1px solid var(--_gengage-border-color);margin:8px 0}.gengage-chat-divider-wrapper{display:flex;align-items:center;gap:8px;margin:8px 0}.gengage-chat-divider-wrapper hr{flex:1;border:none;border-top:1px solid var(--_gengage-border-color);margin:0}.gengage-chat-divider-label{font-size:11px;color:#6b7280;white-space:nowrap}.gengage-chat--overlay .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-width:480px;max-height:100%;margin:0 auto;border-radius:0;animation:gengage-chat-overlay-in .24s cubic-bezier(.2,.72,.2,1)}.gengage-chat--overlay:before{content:"";position:fixed;inset:0;background:#00000073;z-index:-1}@keyframes gengage-chat-overlay-in{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-panel-skeleton{display:flex;flex-direction:column;gap:14px;padding:6px 0}.gengage-chat-panel-skeleton-block{height:110px;border-radius:10px;background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6,#e5e7eb 75%);background-size:200% 100%;animation:gengage-panel-shimmer 1.4s infinite}@keyframes gengage-panel-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-panel-skeleton-block--image{height:200px;border-radius:8px;margin-bottom:12px}.gengage-chat-panel-skeleton-block--text{height:16px;border-radius:4px;margin-bottom:8px}.gengage-chat-panel-skeleton-block--text:nth-child(3){width:80%}.gengage-chat-panel-skeleton-block--text:nth-child(4){width:60%}.gengage-chat-panel-skeleton-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.gengage-chat-panel-skeleton-block--card{height:120px;border-radius:8px}.gengage-chat-panel-skeleton-block--row{height:32px;border-radius:4px;margin-bottom:4px}.gengage-chat-panel .gengage-chat-product-card{width:100%;max-width:100%;min-width:0;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--_gengage-border-color);box-shadow:0 1px 4px #0000000f;overflow:hidden;padding:0}.gengage-chat-panel .gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a;border-color:#d1d5db}.gengage-chat-panel .gengage-chat-product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));overflow-x:visible;gap:12px;min-height:auto;padding:4px 0}.gengage-chat-panel .gengage-chat-product-card-img{width:100%;height:160px;border-radius:0;object-fit:contain;background:#fafafa;padding:12px;box-sizing:border-box}.gengage-chat-panel .gengage-chat-product-card-body{padding:10px 12px 12px;text-align:left;gap:4px}.gengage-chat-panel .gengage-chat-product-card-name{min-height:0;margin-bottom:2px;font-size:13px;-webkit-line-clamp:2;line-clamp:2}.gengage-chat-panel .gengage-chat-product-card-price{justify-content:flex-start;font-size:15px}.gengage-chat-panel .gengage-chat-product-card-cta{display:block;padding:10px 12px;text-align:center;border-top:1px solid var(--_gengage-surface-muted);border-radius:0;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-weight:700;font-size:13px}.gengage-chat-product-details-panel{display:flex;flex-direction:column;gap:12px;width:100%;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:16px;padding:14px;box-sizing:border-box}.gengage-chat-product-details-media{border:1px solid var(--_gengage-surface-muted);border-radius:12px;background:#fafafa;padding:12px;display:flex;flex-direction:column;align-items:center}.gengage-chat-product-details-img{width:100%;height:auto;max-height:300px;object-fit:contain;border-radius:8px}.gengage-chat-product-details-content{display:flex;flex-direction:column;gap:8px;min-width:0}.gengage-chat-product-details-title{margin:0;font-size:17px;font-weight:700;line-height:1.3;color:#0f172a}.gengage-chat-product-details-rating{display:inline-flex;align-items:center;gap:4px;width:fit-content;padding:3px 8px;border-radius:999px;background:#fff7ed;color:#9a3412;font-size:13px;font-weight:700}.gengage-chat-product-details-review-count{color:#7c2d12;font-weight:600}.gengage-chat-product-details-price{display:flex;align-items:baseline;gap:6px}.gengage-chat-product-details-original-price{font-size:14px;color:#64748b;text-decoration:line-through}.gengage-chat-product-details-current-price{font-size:22px;font-weight:800;line-height:1.1;color:#0f172a}.gengage-chat-product-details-stock{width:fit-content;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700}.gengage-chat-product-details-stock.is-in-stock{background:#dcfce7;color:#166534}.gengage-chat-product-details-stock.is-out-of-stock{background:#fee2e2;color:#991b1b}.gengage-chat-product-details-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:4px}.gengage-chat-product-details-cta{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 20px;border-radius:999px;border:none;text-decoration:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:14px;font-weight:700;cursor:pointer;transition:filter .14s ease,transform .12s ease}.gengage-chat-product-details-cta:hover{filter:brightness(1.05);transform:translateY(-1px)}.gengage-chat-product-details-cta:active{transform:translateY(1px)}.gengage-chat-product-details-atc{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 20px;border:none;border-radius:10px;background:var(--_gengage-success-color);color:#fff;font-size:14px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .12s ease,transform .12s ease}.gengage-chat-product-details-atc:hover{filter:brightness(1.08);transform:translateY(-1px)}.gengage-chat-product-details-atc:active{transform:translateY(1px)}.gengage-chat-product-detail-tabs{margin-top:4px;border-top:1px solid var(--_gengage-border-color);padding-top:12px}.gengage-chat-product-detail-tab-bar{display:flex;gap:0;border-bottom:2px solid var(--_gengage-border-color);margin-bottom:12px}.gengage-chat-product-detail-tab{flex:1;padding:8px 12px;border:none;background:transparent;color:var(--_gengage-text-secondary);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:color .15s,border-color .15s}.gengage-chat-product-detail-tab:hover{color:#334155}.gengage-chat-product-detail-tab--active{color:var(--gengage-primary-color, #3b82f6);border-bottom-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-detail-tab-panel{font-size:13px;line-height:1.6;color:#374151}.gengage-chat-product-specs-table{width:100%;border-collapse:collapse;font-size:13px}.gengage-chat-product-specs-table tr:nth-child(2n){background:var(--_gengage-surface-muted)}.gengage-chat-product-specs-key{padding:6px 10px;font-weight:600;color:#475569;white-space:nowrap;border-bottom:1px solid var(--_gengage-surface-muted);width:40%}.gengage-chat-product-specs-value{padding:6px 10px;color:var(--_gengage-text-primary);border-bottom:1px solid var(--_gengage-surface-muted)}.gengage-chat-product-card-atc{position:absolute;bottom:42px;right:6px;opacity:0;transition:opacity .15s ease;z-index:1}.gengage-chat-product-card:hover .gengage-chat-product-card-atc{opacity:1}@media(hover:none),(pointer:coarse){.gengage-chat-product-card-atc{opacity:1;position:relative;bottom:auto;right:auto;margin-top:4px}}.gengage-chat-drawer.gengage-chat-drawer--hidden{transform:translate(100%);opacity:0;pointer-events:none;box-shadow:none;visibility:hidden}.gengage-chat-root--mobile .gengage-chat-drawer.gengage-chat-drawer--hidden{transform:translateY(100%);opacity:0;pointer-events:none;box-shadow:none;visibility:hidden}@media(max-width:900px){.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:clamp(280px,calc(100vw - var(--_gengage-chat-conversation-width)),560px);max-width:560px}}.gengage-chat-attachment-preview{display:flex;align-items:center;gap:8px;padding:6px 10px;background:var(--_gengage-surface-secondary);border:1px solid var(--_gengage-border-color);border-radius:8px;width:100%;box-sizing:border-box}.gengage-chat-attachment-preview--hidden{display:none}.gengage-chat-attachment-preview-thumb{width:40px;height:40px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-attachment-name{flex:1;font-size:12px;color:#4b5563;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.gengage-chat-attachment-remove{background:none;border:none;cursor:pointer;font-size:18px;color:#6b7280;padding:0 4px;line-height:1;flex-shrink:0}.gengage-chat-attachment-remove:hover{color:#ef4444}.gengage-chat-attach-btn{background:none;border:none;cursor:pointer;width:32px;height:32px;padding:0;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-attach-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-attach-btn svg{width:20px;height:20px}.gengage-chat-mic-btn{background:none;border:none;cursor:pointer;width:32px;height:32px;padding:0;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-mic-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-mic-btn svg{width:20px;height:20px}.gengage-chat-mic-btn--active{color:#ef4444;animation:gengage-mic-pulse 1.2s ease-in-out infinite}.gengage-chat-mic-btn--active:hover{color:#dc2626}@keyframes gengage-mic-pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.15);opacity:.8}}.gengage-chat-input-area--dragover{outline:2px dashed var(--gengage-primary-color, #3b82f6);outline-offset:-2px;background:#eff6ff}.gengage-chat-attachment-thumb{width:120px;max-width:100%;height:auto;border-radius:8px;margin-bottom:6px;display:block}@media(max-width:768px){.gengage-chat-root{--_gengage-qty-btn-size: 44px;--_gengage-qty-btn-size-compact: 44px}.gengage-chat-header-btn,.gengage-chat-close{width:44px;height:44px;border-radius:12px}.gengage-chat-attach-btn,.gengage-chat-mic-btn,.gengage-chat-send{width:44px;height:44px;min-width:44px}.gengage-chat-attach-btn svg,.gengage-chat-mic-btn svg{width:22px;height:22px}.gengage-chat-panel-divider{display:flex;width:100%;height:20px;align-items:center;justify-content:center;cursor:ns-resize;background:transparent;touch-action:pan-y;position:relative;overflow:visible}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-drawer--with-panel{left:0;right:0;width:100%;border-radius:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex-direction:column}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:100%;min-width:0;max-width:none;max-height:25dvh;border-right:none;border-bottom:1px solid var(--_gengage-border-color);padding:0 12px 12px;margin:0;border-radius:0;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:100%;height:20px;background:transparent;border-bottom:1px solid rgba(148,163,184,.22)}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{left:50%;top:50%;transform:translate(-50%,-50%);width:100%;height:44px;border:none;border-radius:0;background:transparent;box-shadow:none;color:transparent;font-size:0;line-height:0;padding:0}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:before{content:"";display:block;width:52px;height:5px;margin:0 auto;border-radius:999px;background:#94a3b8;box-shadow:0 1px #64748b59;transition:background .15s ease}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover,.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:active{background:transparent;color:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover:before,.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:active:before{background:#64748b}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:100%;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:50%;transform:translate(-50%,-50%)}.gengage-chat-drawer--with-panel .gengage-chat-conversation{width:100%;flex:1;border-left:none}.gengage-qty-stepper--compact .gengage-qty-value{min-width:24px;font-size:13px}.gengage-qty-stepper--compact .gengage-qty-submit{min-height:44px;padding:0 12px;font-size:13px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{min-height:44px;padding:0 16px}.gengage-chat-product-details-share{width:44px;height:44px}.gengage-chat-panel .gengage-chat-product-card{grid-template-columns:84px 1fr}.gengage-chat-panel .gengage-chat-product-card-cta{grid-column:1 / -1;width:100%}.gengage-chat-product-details-panel{padding:12px;gap:12px}.gengage-chat-product-details-media{min-height:140px}.gengage-chat-product-details-title{font-size:15px}.gengage-chat-product-details-current-price{font-size:20px}.gengage-chat-product-grid{scroll-snap-type:x mandatory}.gengage-chat-product-card{width:280px;min-width:280px;scroll-snap-align:center}.gengage-chat-product-card-img{height:180px}}@media(max-width:480px){.gengage-chat-drawer{position:fixed;inset:0;width:100%;max-height:100%;border-radius:0}.gengage-chat-bubble{max-width:100%}}.gengage-chat-kvkk-banner{display:flex;align-items:flex-start;gap:8px;padding:10px 14px;background:#fffbeb;border-bottom:1px solid #fde68a;font-size:12px;line-height:1.5;color:#92400e}.gengage-chat-kvkk-content{flex:1;min-width:0}.gengage-chat-kvkk-content a{color:#b45309;text-decoration:underline}.gengage-chat-kvkk-dismiss{flex-shrink:0;width:20px;height:20px;border:none;background:transparent;color:#92400e;font-size:16px;cursor:pointer;padding:0;line-height:1}.gengage-chat-comparison{padding:16px}.gengage-chat-comparison-heading{font-size:14px;font-weight:700;letter-spacing:.05em;color:#0f172a;margin:0 0 16px}.gengage-chat-comparison-recommended{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:16px;background:#fff;box-shadow:0 1px 3px #0000000f;margin-bottom:12px}.gengage-chat-comparison-recommended-label{font-size:12px;font-weight:700;color:var(--_gengage-success-color);text-transform:uppercase;letter-spacing:.04em;margin-bottom:12px}.gengage-chat-comparison-recommended-body{display:flex;gap:12px;align-items:flex-start}.gengage-chat-comparison-recommended-body img{width:80px;height:80px;object-fit:contain;border-radius:8px;background:var(--_gengage-surface-muted)}.gengage-chat-comparison-recommended-info{flex:1;min-width:0}.gengage-chat-comparison-recommended-title{font-size:14px;font-weight:600;color:#0f172a;margin-bottom:4px}.gengage-chat-comparison-recommended-price{font-size:16px;font-weight:700;color:#0f172a}.gengage-chat-comparison-highlights{margin-top:12px;padding-top:12px;border-top:1px solid var(--_gengage-surface-muted)}.gengage-chat-comparison-highlights-label{font-size:12px;font-weight:600;color:var(--_gengage-text-secondary);margin-bottom:6px}.gengage-chat-comparison-highlights ul{margin:0;padding-left:18px;font-size:13px;color:#334155;line-height:1.6}.gengage-chat-comparison-special{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:12px 16px;margin-bottom:12px;font-size:13px;color:#92400e}.gengage-chat-comparison-special summary{cursor:pointer;font-weight:600}.gengage-chat-comparison-special ul{margin:8px 0 0;padding-left:18px;line-height:1.6}.gengage-chat-comparison-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:12px}.gengage-chat-comparison-table th,.gengage-chat-comparison-table td{padding:10px 12px;text-align:center;border-bottom:1px solid var(--_gengage-surface-muted);vertical-align:top}.gengage-chat-comparison-table th{font-weight:600;font-size:12px;color:#334155}.gengage-chat-comparison-table th img{width:60px;height:60px;object-fit:contain;border-radius:6px;background:var(--_gengage-surface-muted);margin-bottom:6px}.gengage-chat-comparison-table-price{font-weight:700;color:#0f172a}.gengage-chat-comparison-label{text-align:left;font-weight:600;color:var(--_gengage-text-secondary);white-space:nowrap}.gengage-chat-comparison-selected{background:#f0fdf4}.gengage-chat-comparison-recommended-text{padding:8px 12px;font-size:12px;color:var(--gengage-text-secondary, #475569);font-style:italic;border-top:1px solid var(--gengage-border-color, #e2e8f0);margin-top:8px}.gengage-chat-comparison-product-actions{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}.gengage-chat-comparison-view-btn{flex:1;min-width:0;padding:8px 12px;border:1px solid var(--gengage-primary-color, #3b82f6);border-radius:6px;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s ease,color .15s ease;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.gengage-chat-comparison-view-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-pills{position:relative;padding:8px 12px;border-top:1px solid var(--_gengage-surface-muted);background:var(--gengage-background-color, #fff)}.gengage-chat-pills-scroll{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding-right:28px}.gengage-chat-pills-scroll::-webkit-scrollbar{display:none}.gengage-chat-pill{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;transition:filter .15s,transform .1s}.gengage-chat-pill:hover{filter:brightness(.92)}.gengage-chat-pill:active{transform:scale(.97)}.gengage-chat-pill--rich{display:flex;align-items:center;gap:8px;padding:6px 14px 6px 6px;border-radius:20px}.gengage-chat-pill-img{width:32px;height:32px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#ffffff26}.gengage-chat-pill-text{font-size:13px;font-weight:600;line-height:1.2}.gengage-chat-pill-desc{display:none}.gengage-chat-pill--rich .gengage-chat-pill-desc{display:block;font-size:10px;font-weight:400;opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}.gengage-chat-pills-arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:50%;border:1px solid var(--_gengage-border-color);background:#fff;color:var(--_gengage-text-secondary);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:-4px 0 8px #ffffffe6;z-index:1}.gengage-chat-pills-arrow:hover{background:var(--_gengage-surface-muted);color:#334155}@media(prefers-reduced-motion:reduce){.gengage-chat-uispec>*,.gengage-chat-action-btn,.gengage-chat-product-card,.gengage-chat-product-card-cta,.gengage-chat-send,.gengage-chat-launcher,.gengage-chat-pill,.gengage-chat-drawer,.gengage-chat-typing-dots span,.gengage-chat-typing-sparkle,.gengage-chat-thinking-step-marker--active,.gengage-chat-bubble,.gengage-chat-panel-skeleton-block,.gengage-chat-ai-toppick-card,.gengage-chat-mic-btn--active,.gengage-chat-ai-toppick-spinner:after,.gengage-chat-panel-shimmer,.gengage-chat-overlay,.gengage-chat-product-details-skeleton-price,.gengage-chat-still-working{animation:none!important;transition:none!important;transform:none!important}}.gengage-chat-bubble--user{position:relative}.gengage-chat-rollback-btn{position:absolute;left:-28px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;border-radius:50%;background:var(--gengage-surface-color, #f1f5f9);color:var(--gengage-text-secondary, #64748b);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s ease;padding:0}.gengage-chat-bubble--user:hover .gengage-chat-rollback-btn{opacity:1}.gengage-chat-rollback-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-bubble--hidden{display:none}.gengage-chat-ai-top-picks{display:flex;flex-direction:column;gap:12px;padding:8px 0}.gengage-chat-ai-top-picks-title{font-size:15px;font-weight:600;color:var(--gengage-text-primary, #1e293b);margin:0 0 4px}.gengage-chat-ai-top-picks-cards{display:flex;flex-direction:column;gap:10px}.gengage-chat-ai-toppick-discount-badge{position:absolute;top:8px;right:8px;background:var(--gengage-discount-bg, #ef4444);color:#fff;font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;z-index:1}.gengage-chat-ai-toppick-card--winner{position:relative;display:flex;flex-direction:column;border:2px solid var(--gengage-primary-color, #3b82f6);border-radius:12px;background:#fff;overflow:hidden;transition:box-shadow .2s ease}.gengage-chat-ai-toppick-card--winner:hover{box-shadow:0 4px 16px #3b82f626}.gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{width:100%;height:140px;object-fit:contain;background:var(--_gengage-surface-muted)}.gengage-chat-ai-toppick-card--compact{position:relative;display:flex;flex-direction:row;align-items:center;gap:12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;background:#fff;padding:10px;transition:box-shadow .2s ease,transform .15s ease}.gengage-chat-ai-toppick-card--compact:hover{box-shadow:0 2px 8px #00000014;transform:translateY(-1px)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:64px;height:64px;object-fit:contain;border-radius:8px;background:var(--_gengage-surface-muted);flex-shrink:0}.gengage-chat-ai-toppick-badge{position:absolute;top:8px;left:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;text-transform:uppercase;padding:2px 8px;border-radius:4px;z-index:1;letter-spacing:.5px}.gengage-chat-ai-toppick-body{display:flex;flex-direction:column;gap:4px;padding:10px;flex:1;min-width:0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-body{padding:0}.gengage-chat-ai-toppick-name{font-size:13px;font-weight:600;color:var(--gengage-text-primary, #1e293b);overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical}.gengage-chat-ai-toppick-role{font-size:11px;font-weight:600;color:var(--gengage-primary-color, #3b82f6);text-transform:uppercase;letter-spacing:.3px}.gengage-chat-ai-toppick-labels{display:flex;flex-wrap:wrap;gap:4px}.gengage-chat-ai-toppick-label{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500}.gengage-chat-ai-toppick-label[data-sentiment=positive]{background:#dcfce7;color:#166534}.gengage-chat-ai-toppick-label[data-sentiment=negative]{background:#fee2e2;color:#991b1b}.gengage-chat-ai-toppick-label[data-sentiment=neutral]{background:var(--_gengage-surface-muted);color:#475569}.gengage-chat-ai-toppick-score{font-size:12px;font-weight:700;color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-ai-toppick-reason{font-size:12px;color:var(--gengage-chat-text-secondary, #666);line-height:1.4;margin-top:4px}.gengage-chat-ai-toppick-review{font-size:12px;font-style:italic;color:var(--gengage-text-secondary, #64748b);margin:2px 0;padding-left:8px;border-left:2px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-ai-toppick-price{font-size:14px;font-weight:700;color:var(--gengage-text-primary, #1e293b)}.gengage-chat-ai-toppick-original-price{text-decoration:line-through;color:var(--gengage-text-secondary, #64748b);font-weight:400;font-size:12px}.gengage-chat-ai-toppick-cta{display:block;width:calc(100% - 20px);margin:6px 10px 10px;padding:8px 0;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .15s ease}.gengage-chat-ai-toppick-cta:hover{filter:brightness(.92)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:auto;margin:0;padding:6px 14px;flex-shrink:0;align-self:center}.gengage-chat-ai-toppick-spinner{position:absolute;inset:0;background:#ffffffb3;display:flex;align-items:center;justify-content:center;border-radius:12px;z-index:3}.gengage-chat-ai-toppick-spinner:after{content:"";width:24px;height:24px;border:3px solid var(--gengage-border, #e2e8f0);border-top-color:var(--gengage-accent-primary, #3b82f6);border-radius:50%;animation:gengage-spin .7s linear infinite}@keyframes gengage-spin{to{transform:rotate(360deg)}}@media(max-width:768px){.gengage-chat-ai-top-picks-cards{flex-direction:row;overflow-x:auto;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;gap:10px;padding-bottom:4px}.gengage-chat-ai-toppick-card--winner,.gengage-chat-ai-toppick-card--compact{min-width:280px;max-width:280px;flex-shrink:0;scroll-snap-align:start}.gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:100%;height:100px;border-radius:8px 8px 0 0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:calc(100% - 20px);margin:6px 10px 10px;align-self:stretch}.gengage-chat-rollback-btn{left:-24px}}.gengage-chat-grounding-review{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grounding-review:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grounding-review-icon{font-size:20px;flex-shrink:0}.gengage-chat-grounding-review-body{flex:1;min-width:0}.gengage-chat-grounding-review-title{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grounding-review-subtitle{font-size:12px;color:var(--gengage-text-muted, #64748b);margin-top:2px}.gengage-chat-grounding-review-cta{font-size:13px;font-weight:500;color:var(--gengage-primary-color, #3b82f6);white-space:nowrap;flex-shrink:0}.gengage-chat-grouping-cards{display:flex;flex-direction:column;gap:6px}.gengage-chat-grouping-card{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:8px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grouping-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grouping-card-arrow{display:none;font-size:14px;color:var(--gengage-primary-color, #3b82f6);flex-shrink:0}.gengage-chat-grouping-card-img{width:20px;height:20px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-grouping-card-body{flex:1;min-width:0;display:flex;align-items:baseline;gap:6px;flex-wrap:wrap}.gengage-chat-grouping-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grouping-card-desc{font-size:12px;color:var(--gengage-text-muted, #64748b)}.gengage-chat-grouping-card-labels{display:block;font-size:11px;color:var(--gengage-chat-text-secondary, #888);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-root--mobile .gengage-chat-grouping-card-img{display:none}.gengage-chat-root--mobile .gengage-chat-grouping-card-arrow{display:inline}.gengage-chat-suggested-search-cards{display:flex;flex-direction:column;gap:8px}.gengage-chat-suggested-search-card{display:flex;align-items:flex-start;gap:12px;padding:10px 14px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-suggested-search-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-suggested-search-card-img{width:40px;height:40px;border-radius:6px;object-fit:cover;flex-shrink:0}.gengage-chat-suggested-search-card-body{flex:1;min-width:0}.gengage-chat-suggested-search-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-suggested-search-card-desc{font-size:12px;color:var(--gengage-text-secondary, #475569);margin-top:2px}.gengage-chat-suggested-search-card-diff{font-size:11px;color:var(--gengage-text-muted, #64748b);margin-top:2px;font-style:italic}.gengage-chat-product-details-gallery{position:relative}.gengage-chat-product-details-gallery .gengage-chat-product-details-img{touch-action:pan-y}.gengage-chat-product-gallery-thumbs{display:flex;gap:8px;padding:10px 0 4px;overflow-x:auto;scrollbar-width:thin;justify-content:center;width:100%}.gengage-chat-product-gallery-thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;border:2px solid transparent;cursor:pointer;flex-shrink:0;transition:border-color .15s ease;background:#fff}.gengage-chat-product-gallery-thumb:hover{border-color:var(--gengage-border-color, #cbd5e1)}.gengage-chat-product-gallery-thumb--active{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-variants{margin-top:12px}.gengage-chat-product-variants-label{font-size:12px;font-weight:600;color:var(--gengage-text-muted, #64748b);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.gengage-chat-product-variants-list{display:flex;flex-wrap:wrap;gap:6px}.gengage-chat-product-variant-btn{padding:6px 12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:6px;background:var(--gengage-surface-color, #f8fafc);color:var(--gengage-text-color, #1e293b);font-size:12px;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-product-variant-btn:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-grid-wrapper{display:flex;flex-direction:column;gap:8px}.gengage-chat-product-sort-toolbar{display:flex;gap:4px;padding:4px;background:var(--gengage-surface-color, #f8fafc);border-radius:8px;border:1px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-product-sort-btn{flex:1;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.gengage-chat-product-sort-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-product-sort-btn--active,.gengage-chat-product-sort-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-product-sort-separator{width:1px;background:var(--gengage-border-color, #e2e8f0);margin:2px}.gengage-chat-comparison-toggle-btn{flex:none;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease;white-space:nowrap}.gengage-chat-comparison-toggle-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-comparison-toggle-btn--active,.gengage-chat-comparison-toggle-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-comparison-select-wrapper{position:relative}.gengage-chat-comparison-checkbox{position:absolute;top:8px;right:8px;z-index:4;width:20px;height:20px;cursor:pointer;accent-color:var(--gengage-primary-color, #3b82f6);background:#fff;border-radius:4px;box-shadow:0 1px 3px #00000026}.gengage-chat-comparison-floating-btn{display:block;width:100%;padding:10px 16px;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s ease;text-align:center;position:sticky;bottom:0;z-index:5;box-shadow:0 -2px 8px #0000001a}.gengage-chat-comparison-floating-btn:hover:not(:disabled){background:var(--gengage-primary-hover, #2563eb)}.gengage-chat-comparison-floating-btn--disabled{background:#94a3b8;cursor:default;opacity:.8}.gengage-chat-panel-topbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--_gengage-border-color);background:var(--_gengage-surface-muted);min-height:44px;flex-shrink:0;position:sticky;top:0;z-index:3}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward{width:28px;height:28px;min-width:28px;padding:0;border:1px solid #d1d5db;border-radius:6px;background:transparent;color:#374151;font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s ease,border-color .15s ease,opacity .15s ease}.gengage-chat-panel-topbar-back:hover:not(:disabled),.gengage-chat-panel-topbar-forward:hover:not(:disabled){background:var(--_gengage-surface-secondary);border-color:#9ca3af}.gengage-chat-panel-topbar-back:disabled,.gengage-chat-panel-topbar-forward:disabled{opacity:.3;cursor:default}.gengage-chat-panel-topbar-title{flex:1;font-size:14px;font-weight:600;color:var(--_gengage-text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}@keyframes gengage-typewriter-fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-typewriter-block{display:block;animation:gengage-typewriter-fade-in .15s ease both}@media(prefers-reduced-motion:reduce){.gengage-chat-typewriter-block{animation:none}}.gengage-product-mention{color:var(--gengage-primary-color, #3b82f6);text-decoration:none;cursor:pointer;font-weight:500;border-bottom:1px dashed var(--gengage-primary-color, #3b82f6);transition:border-color .15s}.gengage-product-mention:hover{border-bottom-style:solid}@keyframes gengage-skeleton-pulse{0%,to{opacity:.4}50%{opacity:.8}}.gengage-chat-panel-skeleton-block{animation:gengage-skeleton-pulse 1.5s ease-in-out infinite}@media(prefers-reduced-motion:reduce){.gengage-chat-panel-skeleton-block{animation:none}}.gengage-chat-input-chips{display:flex;gap:6px;padding:4px 12px 2px;flex-wrap:wrap}.gengage-chat-input-chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:12px;border:1px solid var(--_gengage-border-color);background:#f9fafb;color:#374151;font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .12s,border-color .12s;white-space:nowrap}.gengage-chat-input-chip:hover{background:var(--_gengage-surface-secondary);border-color:#d1d5db}.gengage-chat-icon{width:14px;height:14px;flex-shrink:0}.gengage-chat-input-chip-icon,.gengage-chat-pill-icon{display:inline-flex;align-items:center;margin-right:4px}.gengage-chat-product-card-img-wrapper,.gengage-chat-product-details-img-wrap{position:relative;overflow:hidden}.gengage-chat-product-card-discount-badge{position:absolute;top:6px;left:6px;padding:3px 8px;border-radius:4px;background:var(--_gengage-discount-color);color:#fff;font-size:11px;font-weight:700;line-height:1.3;z-index:1}.gengage-chat-product-card-stock{font-size:11px;font-weight:600;margin-top:2px}.gengage-chat-product-card-stock.is-in-stock{color:var(--_gengage-success-color)}.gengage-chat-product-card-stock.is-out-of-stock{color:#dc2626}.gengage-chat-find-similar-pill{position:absolute;top:40px;right:8px;opacity:0;pointer-events:none;transition:opacity .2s ease;padding:4px 10px;font-size:11px;font-weight:500;font-family:inherit;border:none;border-radius:12px;background:var(--gengage-chat-pill-bg, rgba(0, 0, 0, .7));color:var(--gengage-chat-pill-text, #fff);cursor:pointer;white-space:nowrap;z-index:2}.gengage-chat-product-card-img-wrapper:hover .gengage-chat-find-similar-pill,.gengage-chat-product-details-img-wrap:hover .gengage-chat-find-similar-pill{opacity:1;pointer-events:auto}.gengage-chat-favorite-btn{position:absolute;top:8px;right:8px;background:#ffffffe6;border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--gengage-text-secondary, #64748b);z-index:3;transition:color .2s;padding:0}.gengage-chat-favorite-btn:hover,.gengage-chat-favorite-btn--active{color:var(--gengage-accent-primary, #ef4444)}.gengage-chat-product-card-promos,.gengage-chat-product-details-promos{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{display:inline-block;padding:2px 6px;font-size:10px;font-weight:500;border-radius:4px;background:var(--gengage-chat-promo-bg, #e8f5e9);color:var(--gengage-chat-promo-text, #2e7d32);white-space:nowrap}.gengage-chat-thumbnails-column{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;gap:4px;z-index:2;pointer-events:auto}.gengage-chat-thumbnail-btn{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:2px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;overflow:hidden;transition:border-color .15s ease}.gengage-chat-thumbnail-btn:hover{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-thumbnail-img{width:100%;height:100%;object-fit:cover}.gengage-chat-choice-prompter{position:absolute;bottom:12px;right:12px;width:200px;padding:12px 14px;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:10px;box-shadow:0 4px 12px #0000001a;z-index:10;animation:gengage-choice-prompter-in .2s ease}@keyframes gengage-choice-prompter-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-choice-prompter-heading{font-size:13px;font-weight:600;color:var(--_gengage-text-primary);margin-bottom:4px}.gengage-chat-choice-prompter-suggestion{font-size:12px;color:#6b7280;margin-bottom:10px;line-height:1.4}.gengage-chat-choice-prompter-cta{display:block;width:100%;padding:6px 12px;border:none;border-radius:6px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;text-align:center;transition:opacity .15s ease}.gengage-chat-choice-prompter-cta:hover{opacity:.9}.gengage-chat-choice-prompter-dismiss{position:absolute;top:4px;right:6px;padding:2px 6px;border:none;background:none;color:#6b7280;font-size:16px;cursor:pointer;line-height:1}.gengage-chat-choice-prompter-dismiss:hover{color:#6b7280}@media(prefers-reduced-motion:reduce){.gengage-chat-choice-prompter{animation:none}}.gengage-chat-pros-cons{padding:12px 14px;background:var(--_gengage-surface-muted);border-radius:8px;margin:8px 0}.gengage-chat-pros-cons-heading{margin:0 0 10px;font-size:14px;font-weight:600;color:#0f172a}.gengage-chat-pros-cons-list{list-style:none;margin:0 0 8px;padding:0}.gengage-chat-pros-cons-list:last-child{margin-bottom:0}.gengage-chat-pros-cons-item{display:flex;align-items:flex-start;gap:8px;padding:4px 0;font-size:13px;line-height:1.5;color:#334155}.gengage-chat-pros-cons-icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;border-radius:50%}.gengage-chat-pros-cons-icon--pro{color:var(--_gengage-success-color);background:color-mix(in srgb,var(--_gengage-success-color) 15%,#fff)}.gengage-chat-pros-cons-icon--con{color:#dc2626;background:#fee2e2}.gengage-chat-categories{display:flex;flex-direction:column;gap:8px}.gengage-chat-categories-tabs{display:flex;gap:4px;overflow-x:auto;padding:4px 0;-webkit-overflow-scrolling:touch}.gengage-chat-categories-tab{padding:6px 14px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:20px;background:var(--gengage-bg, #fff);color:var(--gengage-text, #374151);cursor:pointer;white-space:nowrap;font-size:13px;transition:background .15s,color .15s}.gengage-chat-categories-tab:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-categories-tab--active{background:var(--gengage-primary, #2563eb);color:#fff;border-color:var(--gengage-primary, #2563eb)}.gengage-chat-categories-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.gengage-chat-categories-filter-tags{display:flex;gap:6px;flex-wrap:wrap;margin-top:4px}.gengage-chat-categories-filter-tag{padding:4px 10px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:14px;background:var(--gengage-bg, #fff);color:var(--gengage-text-secondary, #6b7280);font-size:12px;cursor:pointer;transition:background .15s}.gengage-chat-categories-filter-tag:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid-view-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:8px;background:var(--gengage-bg, #fff);color:var(--gengage-primary, #2563eb);font-size:14px;font-weight:500;cursor:pointer;text-align:center;transition:background .15s;grid-column:1 / -1}.gengage-chat-product-grid-view-more:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid--mobile{display:flex;overflow-x:auto;gap:8px;padding:8px 0;-webkit-overflow-scrolling:touch}.gengage-chat-product-grid--mobile .gengage-chat-product-card{min-width:160px;max-width:180px;flex-shrink:0}.gengage-chat-comparison--mobile{overflow-x:auto;-webkit-overflow-scrolling:touch;position:relative}.gengage-chat-comparison--mobile{-webkit-mask-image:linear-gradient(to right,#000 85%,transparent);mask-image:linear-gradient(to right,#000 85%,transparent)}.gengage-chat-comparison--mobile .gengage-chat-comparison-table{min-width:480px}.gengage-chat-comparison-key-differences{margin-top:12px;padding:12px;background:var(--gengage-bg-secondary, #f9fafb);border-radius:8px}.gengage-chat-comparison-key-differences h4{margin:0 0 8px;font-size:14px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-comparison-key-differences-content{font-size:13px;color:var(--gengage-text-secondary, #6b7280);line-height:1.5}.gengage-chat-comparison-key-differences-content ul{margin:0;padding-left:18px}.gengage-chat-comparison-key-differences-content li{margin-bottom:4px}.gengage-chat-product-details-similars-heading{margin:16px 0 8px;font-size:15px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-product-details-similars{margin-top:8px}.gengage-chat-handoff-notice{display:flex;flex-direction:column;align-items:center;gap:6px;padding:16px;margin:8px 0;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;text-align:center}.gengage-chat-handoff-notice-icon{font-size:24px}.gengage-chat-handoff-notice-heading{margin:0;font-size:14px;font-weight:600;color:#92400e}.gengage-chat-handoff-notice-summary{margin:0;font-size:13px;line-height:1.5;color:#78350f}.gengage-qty-stepper{display:inline-flex;align-items:center;gap:0;border:1px solid #d1d5db;border-radius:8px;overflow:hidden;background:#fff}.gengage-qty-btn{width:var(--_gengage-qty-btn-size);height:var(--_gengage-qty-btn-size);border:none;background:transparent;color:#374151;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .12s}.gengage-qty-btn:hover:not(:disabled){background:var(--_gengage-surface-secondary)}.gengage-qty-btn:disabled{opacity:.35;cursor:default}.gengage-qty-value{min-width:24px;text-align:center;font-size:13px;font-weight:600;color:var(--_gengage-text-primary);-webkit-user-select:none;user-select:none}.gengage-qty-submit{border:none;border-left:1px solid #d1d5db;background:var(--_gengage-success-color);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;padding:6px 12px;transition:filter .12s ease,transform .12s ease}.gengage-qty-submit:hover{filter:brightness(1.08)}.gengage-qty-submit:active{transform:translateY(1px)}.gengage-qty-submit--success{background:var(--_gengage-success-color);transition:background .2s ease}.gengage-qty-stepper--compact{border-radius:14px;box-shadow:0 2px 6px #0000001f}.gengage-qty-stepper--compact .gengage-qty-btn{width:var(--_gengage-qty-btn-size-compact);height:var(--_gengage-qty-btn-size-compact);font-size:12px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:18px;font-size:12px}.gengage-qty-stepper--compact .gengage-qty-submit{padding:4px 8px;font-size:13px;border-radius:0 14px 14px 0}.gengage-chat-product-details-atc-stepper{border-radius:10px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:32px;height:32px}.gengage-chat-product-details-atc-stepper .gengage-qty-value{min-width:28px;font-size:14px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{padding:8px 18px;font-size:14px;border-radius:0 10px 10px 0}.gengage-chat-product-details-share{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #d1d5db;border-radius:10px;background:transparent;color:#6b7280;cursor:pointer;transition:color .12s,border-color .12s,background-color .12s;position:relative;flex-shrink:0}.gengage-chat-product-details-share:hover{color:var(--gengage-primary-color, #3b82f6);border-color:var(--gengage-primary-color, #3b82f6);background:#f0f7ff}.gengage-chat-product-details-share:before{content:attr(aria-label);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:var(--_gengage-surface-dark);color:#fff;font-size:11px;font-weight:500;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:2}.gengage-chat-product-details-share:hover:before{opacity:1}.gengage-chat-product-details-share--copied:after{content:"✓";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--_gengage-success-color);color:#fff;border-radius:10px;font-size:16px;font-weight:700}.gengage-chat-launcher:focus-visible,.gengage-chat-close:focus-visible,.gengage-chat-header-btn:focus-visible,.gengage-chat-header-powered:focus-visible,.gengage-chat-send:focus-visible,.gengage-chat-action-btn:focus-visible,.gengage-chat-pill:focus-visible,.gengage-chat-input-chip:focus-visible,.gengage-chat-pills-arrow:focus-visible,.gengage-chat-error-retry:focus-visible,.gengage-chat-product-card-cta:focus-visible,.gengage-chat-product-details-cta:focus-visible,.gengage-chat-product-details-atc:focus-visible,.gengage-chat-product-detail-tab:focus-visible,.gengage-chat-panel-divider-toggle:focus-visible,.gengage-chat-panel-topbar-back:focus-visible,.gengage-chat-panel-topbar-forward:focus-visible,.gengage-chat-rollback-btn:focus-visible,.gengage-chat-ai-toppick-cta:focus-visible,.gengage-chat-comparison-view-btn:focus-visible,.gengage-chat-comparison-toggle-btn:focus-visible,.gengage-chat-comparison-floating-btn:focus-visible,.gengage-chat-comparison-checkbox:focus-visible,.gengage-chat-product-sort-btn:focus-visible,.gengage-chat-product-variant-btn:focus-visible,.gengage-chat-product-gallery-thumb:focus-visible,.gengage-chat-thumbnail-btn:focus-visible,.gengage-chat-find-similar-pill:focus-visible,.gengage-chat-favorite-btn:focus-visible,.gengage-chat-attach-btn:focus-visible,.gengage-chat-mic-btn:focus-visible,.gengage-chat-attachment-remove:focus-visible,.gengage-chat-kvkk-dismiss:focus-visible,.gengage-chat-choice-prompter-cta:focus-visible,.gengage-chat-choice-prompter-dismiss:focus-visible,.gengage-chat-categories-tab:focus-visible,.gengage-chat-categories-filter-tag:focus-visible,.gengage-chat-product-grid-view-more:focus-visible,.gengage-chat-product-details-share:focus-visible,.gengage-qty-btn:focus-visible,.gengage-qty-submit:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}@media(max-width:768px){.gengage-chat-choice-prompter{position:sticky;left:12px;right:12px;width:auto;max-width:none;bottom:calc(var(--_gengage-chat-launcher-bottom) + var(--_gengage-chat-launcher-size) + 12px + env(safe-area-inset-bottom,0px));max-height:40vh;overflow-y:auto}.gengage-chat-product-sort-btn,.gengage-chat-comparison-toggle-btn{min-height:40px}.gengage-chat-input-chip{min-height:40px;padding:8px 12px}.gengage-chat-choice-prompter-dismiss{width:32px;height:32px}.gengage-chat-panel-divider-toggle{min-height:44px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:44px;height:44px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit,.gengage-qty-stepper--compact .gengage-qty-submit{min-height:44px}.gengage-qty-stepper--compact .gengage-qty-submit{min-width:44px;padding:0 10px}.gengage-qty-stepper--compact .gengage-qty-btn{width:44px;height:44px;font-size:14px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:24px;font-size:13px}.gengage-chat-product-card-cta,.gengage-chat-choice-prompter-cta,.gengage-chat-product-grid-view-more{min-height:44px;display:flex;align-items:center;justify-content:center}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward,.gengage-chat-favorite-btn,.gengage-chat-product-details-share{width:44px;height:44px}}', Xa = B({
|
|
3157
|
-
role: Se(["user", "assistant"]),
|
|
3158
|
-
content: x(),
|
|
3159
|
-
timestamp: Z().optional()
|
|
3160
|
-
}), Ja = B({
|
|
3161
|
-
sku: x(),
|
|
3162
|
-
name: x(),
|
|
3163
|
-
imageUrl: x().url().optional(),
|
|
3164
|
-
price: x().optional(),
|
|
3165
|
-
originalPrice: x().optional(),
|
|
3166
|
-
url: x().url(),
|
|
3167
|
-
/** Override CTA label (default: "View product") */
|
|
3168
|
-
ctaLabel: x().optional()
|
|
3169
|
-
}), Za = B({
|
|
3170
|
-
buttons: U(
|
|
3171
|
-
B({
|
|
3172
|
-
label: x(),
|
|
3173
|
-
/** Opaque action payload forwarded to the backend when clicked. */
|
|
3174
|
-
action: B({
|
|
3175
|
-
title: x(),
|
|
3176
|
-
type: x(),
|
|
3177
|
-
payload: Q().optional()
|
|
3178
|
-
})
|
|
3179
|
-
})
|
|
3180
|
-
)
|
|
3181
|
-
}), en = B({}), tn = B({
|
|
3182
|
-
label: x().optional()
|
|
3183
|
-
}), Ee = B({
|
|
3184
|
-
sku: x(),
|
|
3185
|
-
name: x(),
|
|
3186
|
-
price: x(),
|
|
3187
|
-
imageUrl: x().optional(),
|
|
3188
|
-
rating: Z().optional(),
|
|
3189
|
-
reviewCount: Z().optional()
|
|
3190
|
-
}), an = B({
|
|
3191
|
-
recommended: Ee,
|
|
3192
|
-
products: U(Ee),
|
|
3193
|
-
attributes: U(
|
|
3194
|
-
B({
|
|
3195
|
-
label: x(),
|
|
3196
|
-
values: U(x())
|
|
3197
|
-
})
|
|
3198
|
-
),
|
|
3199
|
-
highlights: U(x()),
|
|
3200
|
-
specialCases: U(x()).optional(),
|
|
3201
|
-
recommendedText: x().optional(),
|
|
3202
|
-
winnerHits: re(
|
|
3203
|
-
x(),
|
|
3204
|
-
B({
|
|
3205
|
-
positive: U(x()).optional(),
|
|
3206
|
-
negative: U(x()).optional()
|
|
3207
|
-
})
|
|
3208
|
-
).optional(),
|
|
3209
|
-
productActions: re(
|
|
3210
|
-
x(),
|
|
3211
|
-
B({
|
|
3212
|
-
title: x(),
|
|
3213
|
-
type: x(),
|
|
3214
|
-
payload: Q().optional()
|
|
3215
|
-
})
|
|
3216
|
-
).optional()
|
|
3217
|
-
}), nn = B({
|
|
3218
|
-
label: x(),
|
|
3219
|
-
sentiment: Se(["positive", "negative", "neutral"]).optional()
|
|
3220
|
-
}), on = B({
|
|
3221
|
-
product: re(x(), Q()),
|
|
3222
|
-
role: x().optional(),
|
|
3223
|
-
reason: x().optional(),
|
|
3224
|
-
labels: U(nn).optional(),
|
|
3225
|
-
expertQualityScore: Z().optional(),
|
|
3226
|
-
reviewHighlight: x().optional(),
|
|
3227
|
-
action: B({
|
|
3228
|
-
title: x(),
|
|
3229
|
-
type: x(),
|
|
3230
|
-
payload: Q().optional()
|
|
3231
|
-
}).optional()
|
|
3232
|
-
}), rn = B({
|
|
3233
|
-
suggestions: U(on)
|
|
3234
|
-
}), sn = B({
|
|
3235
|
-
title: x().optional(),
|
|
3236
|
-
text: x().optional(),
|
|
3237
|
-
reviewCount: x().optional(),
|
|
3238
|
-
action: B({ title: x(), type: x(), payload: Q().optional() })
|
|
3239
|
-
}), cn = B({
|
|
3240
|
-
entries: U(
|
|
3241
|
-
B({
|
|
3242
|
-
name: x(),
|
|
3243
|
-
image: x().optional(),
|
|
3244
|
-
description: x().optional(),
|
|
3245
|
-
action: B({ title: x(), type: x(), payload: Q().optional() })
|
|
3246
|
-
})
|
|
3247
|
-
)
|
|
3248
|
-
}), ln = B({
|
|
3249
|
-
entries: U(
|
|
3250
|
-
B({
|
|
3251
|
-
shortName: x(),
|
|
3252
|
-
detailedMessage: x().optional(),
|
|
3253
|
-
whyDifferent: x().optional(),
|
|
3254
|
-
image: x().optional(),
|
|
3255
|
-
action: B({ title: x(), type: x(), payload: Q().optional() })
|
|
3256
|
-
})
|
|
3257
|
-
)
|
|
3258
|
-
}), qe = B({
|
|
3259
|
-
title: x(),
|
|
3260
|
-
type: x(),
|
|
3261
|
-
payload: Q().optional()
|
|
3262
|
-
}), gn = B({
|
|
3263
|
-
name: x().optional(),
|
|
3264
|
-
variant_name: x().optional(),
|
|
3265
|
-
sku: x().optional(),
|
|
3266
|
-
price: de([Z(), x()]).optional()
|
|
3267
|
-
}), dn = B({
|
|
3268
|
-
product: B({
|
|
3269
|
-
sku: x().optional(),
|
|
3270
|
-
name: x().optional(),
|
|
3271
|
-
images: U(x()).optional(),
|
|
3272
|
-
imageUrl: x().optional(),
|
|
3273
|
-
rating: Z().optional(),
|
|
3274
|
-
reviewCount: Z().optional(),
|
|
3275
|
-
price: x().optional(),
|
|
3276
|
-
originalPrice: x().optional(),
|
|
3277
|
-
price_async: ge().optional(),
|
|
3278
|
-
inStock: ge().optional(),
|
|
3279
|
-
promotions: U(x()).optional(),
|
|
3280
|
-
variants: U(gn).optional(),
|
|
3281
|
-
url: x().optional(),
|
|
3282
|
-
cartCode: x().optional(),
|
|
3283
|
-
description: x().optional(),
|
|
3284
|
-
specifications: de([re(x(), x()), U(B({ key: x(), value: x() }))]).optional()
|
|
3285
|
-
}).optional(),
|
|
3286
|
-
action: qe.optional()
|
|
3287
|
-
}), pn = B({
|
|
3288
|
-
endOfList: ge().optional()
|
|
3289
|
-
}), hn = B({
|
|
3290
|
-
review_class: x().optional(),
|
|
3291
|
-
review_text: x().optional(),
|
|
3292
|
-
review_rating: de([x(), Z()]).optional(),
|
|
3293
|
-
review_tag: x().optional()
|
|
3294
|
-
}), un = B({
|
|
3295
|
-
reviews: U(hn).optional()
|
|
3296
|
-
}), mn = B({
|
|
3297
|
-
productName: x().optional(),
|
|
3298
|
-
pros: U(x()).optional(),
|
|
3299
|
-
cons: U(x()).optional()
|
|
3300
|
-
}), fn = B({
|
|
3301
|
-
groups: U(
|
|
3302
|
-
B({
|
|
3303
|
-
groupName: x(),
|
|
3304
|
-
products: U(re(x(), Q())).optional()
|
|
3305
|
-
})
|
|
3306
|
-
).optional(),
|
|
3307
|
-
filterTags: U(
|
|
3308
|
-
B({
|
|
3309
|
-
title: x(),
|
|
3310
|
-
action: qe.optional()
|
|
3311
|
-
})
|
|
3312
|
-
).optional()
|
|
3313
|
-
}), bn = B({
|
|
3314
|
-
summary: x().optional(),
|
|
3315
|
-
products_discussed: U(x()).optional(),
|
|
3316
|
-
user_sentiment: x().optional()
|
|
3317
|
-
}), _n = {
|
|
3318
|
-
components: {
|
|
3319
|
-
MessageBubble: {
|
|
3320
|
-
schema: Xa,
|
|
3321
|
-
description: "A single chat message bubble for user or assistant turns."
|
|
3322
|
-
},
|
|
3323
|
-
ProductCard: {
|
|
3324
|
-
schema: Ja,
|
|
3325
|
-
description: "A product card rendered inline in the chat stream."
|
|
3326
|
-
},
|
|
3327
|
-
ActionButtons: {
|
|
3328
|
-
schema: Za,
|
|
3329
|
-
description: "A horizontal row of quick-reply action buttons."
|
|
3330
|
-
},
|
|
3331
|
-
TypingIndicator: {
|
|
3332
|
-
schema: en,
|
|
3333
|
-
description: "An animated indicator shown while the assistant is typing."
|
|
3334
|
-
},
|
|
3335
|
-
Divider: {
|
|
3336
|
-
schema: tn,
|
|
3337
|
-
description: "A horizontal rule with an optional label."
|
|
3338
|
-
},
|
|
3339
|
-
ComparisonTable: {
|
|
3340
|
-
schema: an,
|
|
3341
|
-
description: "A product comparison table with recommended pick, attribute rows, and highlights."
|
|
3342
|
-
},
|
|
3343
|
-
AITopPicks: {
|
|
3344
|
-
schema: rn,
|
|
3345
|
-
description: "Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."
|
|
3346
|
-
},
|
|
3347
|
-
GroundingReviewCard: {
|
|
3348
|
-
schema: sn,
|
|
3349
|
-
description: "A card showing review grounding data with review count and CTA."
|
|
3350
|
-
},
|
|
3351
|
-
AIGroupingCards: {
|
|
3352
|
-
schema: cn,
|
|
3353
|
-
description: "Category grouping cards with images and labels for product discovery."
|
|
3354
|
-
},
|
|
3355
|
-
AISuggestedSearchCards: {
|
|
3356
|
-
schema: ln,
|
|
3357
|
-
description: "Suggested search cards with images, descriptions, and differentiation."
|
|
3358
|
-
},
|
|
3359
|
-
ProductDetailsPanel: {
|
|
3360
|
-
schema: dn,
|
|
3361
|
-
description: "Full product detail view with images, specs, variants, and purchase actions."
|
|
3362
|
-
},
|
|
3363
|
-
ProductGrid: {
|
|
3364
|
-
schema: pn,
|
|
3365
|
-
description: 'A scrollable grid of ProductCard children with optional "more" pagination.'
|
|
3366
|
-
},
|
|
3367
|
-
ReviewHighlights: {
|
|
3368
|
-
schema: un,
|
|
3369
|
-
description: "A list of highlighted customer reviews with sentiment and ratings."
|
|
3370
|
-
},
|
|
3371
|
-
ProsAndCons: {
|
|
3372
|
-
schema: mn,
|
|
3373
|
-
description: "A pros and cons list for a product."
|
|
3374
|
-
},
|
|
3375
|
-
CategoriesContainer: {
|
|
3376
|
-
schema: fn,
|
|
3377
|
-
description: "Tabbed product groups with optional filter tag buttons."
|
|
3378
|
-
},
|
|
3379
|
-
HandoffNotice: {
|
|
3380
|
-
schema: bn,
|
|
3381
|
-
description: "A notice shown when the conversation is escalated to a human agent."
|
|
3382
|
-
}
|
|
3383
|
-
}
|
|
3384
|
-
};
|
|
3385
|
-
function xn(o) {
|
|
3386
|
-
return o.length > 120 ? !1 : /^[a-zA-Z0-9#(),.\s%/\-]+$/.test(o);
|
|
3387
|
-
}
|
|
3388
|
-
function le(o) {
|
|
3389
|
-
return typeof o == "object" && o !== null && typeof o.type == "string";
|
|
3390
|
-
}
|
|
3391
|
-
class vn extends $e {
|
|
3392
|
-
constructor() {
|
|
3393
|
-
super(...arguments), this._shadow = null, this._rootEl = null, this._launcher = null, this._drawer = null, this._bridge = null, this._drawerVisible = !1, this._messages = [], this._currentMessageId = 0, this._abortControllers = /* @__PURE__ */ new Set(), this._currentThreadId = null, this._lastThreadId = null, this._chatCreatedAt = "", this._lastBackendContext = null, this._productSort = { type: "related" }, this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._thumbnailEntries = [], this._choicePrompterEl = null, this._openState = "full", this._mobileBreakpoint = 768, this._isMobileViewport = !1, this._pdpLaunched = !1, this._pdpPrimingInFlight = !1, this._queuedUserMessages = [], this._productContextUnavailableSku = null, this._i18n = he, this._extendedModeManager = null, this._activeTypewriter = null, this._activeTtsHandle = null, this._activeRequestThreadId = null, this._skuToProductItem = {}, this._conversationMode = null, this._initComplete = !1, this._pendingActions = [], this._bridgeContext = null, this._cartQuantity = null, this._threadsWithFirstBot = /* @__PURE__ */ new Set(), this._panel = null, this._session = null, this._eventCallbacks = /* @__PURE__ */ new Map(), this._lastSentAction = null;
|
|
3394
|
-
}
|
|
3395
|
-
async onInit(e) {
|
|
3396
|
-
this._i18n = this._resolveI18n(e), this._chatCreatedAt = (/* @__PURE__ */ new Date()).toISOString(), this._shadow = this.root.attachShadow({ mode: "open" });
|
|
3397
|
-
const t = document.createElement("style");
|
|
3398
|
-
t.textContent = Qa, this._shadow.appendChild(t);
|
|
3399
|
-
const a = document.createElement("div");
|
|
3400
|
-
a.className = "gengage-chat-root", this._rootEl = a, this._shadow.appendChild(a);
|
|
3401
|
-
const n = e.variant ?? "floating";
|
|
3402
|
-
if (n === "floating") {
|
|
3403
|
-
const r = {
|
|
3404
|
-
onClick: () => this.open(),
|
|
3405
|
-
ariaLabel: this._i18n.openButton
|
|
3406
|
-
};
|
|
3407
|
-
e.launcherImageUrl !== void 0 ? r.imageUrl = e.launcherImageUrl : e.launcherSvg !== void 0 && (r.svgMarkup = e.launcherSvg), e.hideMobileLauncher !== void 0 && (r.hideMobile = e.hideMobileLauncher), e.mobileBreakpoint !== void 0 && (r.mobileBreakpoint = e.mobileBreakpoint), e.launcherTooltip !== void 0 && (r.tooltip = e.launcherTooltip), this._launcher = Vt(r), a.appendChild(this._launcher.container);
|
|
3408
|
-
}
|
|
3409
|
-
n === "overlay" && a.classList.add("gengage-chat--overlay");
|
|
3410
|
-
const i = document.createElement("div");
|
|
3411
|
-
a.appendChild(i), this._drawer = new Ot(i, {
|
|
3412
|
-
i18n: this._i18n,
|
|
3413
|
-
onSend: (r, m) => this._sendMessage(r, m),
|
|
3414
|
-
onClose: () => this.close(),
|
|
3415
|
-
onAttachment: (r) => this._handleAttachment(r),
|
|
3416
|
-
onPanelToggle: () => {
|
|
3417
|
-
this._drawer?.persistPanelState(e.accountId);
|
|
3418
|
-
},
|
|
3419
|
-
onRollback: (r) => this._handleRollback(r),
|
|
3420
|
-
onPanelBack: () => this._panel?.navigateBack(),
|
|
3421
|
-
onPanelForward: () => this._panel?.navigateForward(),
|
|
3422
|
-
headerTitle: e.headerTitle,
|
|
3423
|
-
headerAvatarUrl: e.headerAvatarUrl,
|
|
3424
|
-
headerBadge: e.headerBadge,
|
|
3425
|
-
headerCartUrl: e.headerCartUrl,
|
|
3426
|
-
headerFavoritesToggle: e.headerFavoritesToggle,
|
|
3427
|
-
onFavoritesClick: () => {
|
|
3428
|
-
Ge(), e.onFavoritesClick?.();
|
|
3429
|
-
},
|
|
3430
|
-
onThumbnailClick: (r) => this._rollbackToThread(r),
|
|
3431
|
-
onLinkClick: (r) => {
|
|
3432
|
-
this._saveSessionAndOpenURL(r);
|
|
3433
|
-
},
|
|
3434
|
-
voiceEnabled: e.voiceEnabled,
|
|
3435
|
-
voiceLang: e.locale ? `${e.locale.split("-")[0] ?? "tr"}-${(e.locale.split("-")[1] ?? e.locale.split("-")[0] ?? "TR").toUpperCase()}` : void 0
|
|
3436
|
-
}), this._extendedModeManager = new qa({
|
|
3437
|
-
onChange: (r) => this._panel?.notifyExtension(r),
|
|
3438
|
-
productDetailsInPanel: e.isDemoWebsite ?? !1
|
|
3439
|
-
}), this._panel = new Ha({
|
|
3440
|
-
drawer: () => this._drawer,
|
|
3441
|
-
shadow: () => this._shadow,
|
|
3442
|
-
currentThreadId: () => this._currentThreadId,
|
|
3443
|
-
bridge: () => this._bridge,
|
|
3444
|
-
extendedModeManager: () => this._extendedModeManager,
|
|
3445
|
-
i18n: () => this._i18n,
|
|
3446
|
-
rollbackToThread: (r) => this._rollbackToThread(r)
|
|
3447
|
-
}), n !== "inline" && this._drawer.getElement().classList.add("gengage-chat-drawer--hidden"), this._drawer.restorePanelState(e.accountId);
|
|
3448
|
-
const s = e.panelMode ?? "auto";
|
|
3449
|
-
s === "collapsed" ? this._drawer.setPanelCollapsed(!0) : s === "expanded" && this._drawer.setForceExpanded();
|
|
3450
|
-
const l = sessionStorage.getItem("gengage_restore_session_id"), d = sessionStorage.getItem("gengage_restore_sku"), c = !!(l && d);
|
|
3451
|
-
c && (sessionStorage.removeItem("gengage_restore_session_id"), sessionStorage.removeItem("gengage_restore_sku"));
|
|
3452
|
-
try {
|
|
3453
|
-
const r = new Ua();
|
|
3454
|
-
await r.open(), this._session = new ke(r), await this._restoreFromIndexedDB(c);
|
|
3455
|
-
} catch {
|
|
3456
|
-
this._session = new ke(null);
|
|
3457
|
-
}
|
|
3458
|
-
this._registerPublicAPI(), e.mobileInitialState !== void 0 && (this._openState = e.mobileInitialState), this._mobileBreakpoint = e.mobileBreakpoint ?? 768, this._syncViewportState();
|
|
3459
|
-
const g = () => this._syncViewportState();
|
|
3460
|
-
if (window.addEventListener("resize", g, { passive: !0 }), this.addCleanup(() => window.removeEventListener("resize", g)), window.visualViewport) {
|
|
3461
|
-
const r = () => {
|
|
3462
|
-
if (!this._drawerVisible || !this._isMobileViewport) return;
|
|
3463
|
-
const m = this._drawer?.getElement();
|
|
3464
|
-
if (!m) return;
|
|
3465
|
-
const h = window.innerHeight - (window.visualViewport?.height ?? window.innerHeight);
|
|
3466
|
-
m.style.setProperty("--gengage-keyboard-offset", `${Math.max(0, h)}px`);
|
|
3467
|
-
};
|
|
3468
|
-
window.visualViewport.addEventListener("resize", r), this.addCleanup(() => window.visualViewport?.removeEventListener("resize", r));
|
|
3469
|
-
}
|
|
3470
|
-
n === "inline" && (this._drawerVisible = !0, this.isVisible = !0, this._applyOpenStateClasses()), this._bridge = new vt({
|
|
3471
|
-
namespace: "chat",
|
|
3472
|
-
onMessage: (r) => this._handleBridgeMessage(r)
|
|
3473
|
-
}), this._lastSku = this.config.pageContext?.sku, this._initComplete = !0;
|
|
3474
|
-
for (const r of this._pendingActions)
|
|
3475
|
-
this._sendAction(r.action, r.options);
|
|
3476
|
-
this._pendingActions = [], W("gengage:chat:ready", {}), Ye("chat"), e.onReady?.();
|
|
3477
|
-
}
|
|
3478
|
-
onUpdate(e) {
|
|
3479
|
-
e.sku !== void 0 && e.sku !== this._lastSku && (this._lastSku = e.sku, this._resetForNewPage());
|
|
3480
|
-
}
|
|
3481
|
-
onShow() {
|
|
3482
|
-
this._showDrawer(), this.emit("open"), W("gengage:chat:open", { state: this._openState }), Ke("chat"), this.config.onOpen?.(), !this._pdpLaunched && this.config.pageContext?.sku && (this._pdpLaunched = !0, this._pdpPrimingInFlight = !0, this._sendAction(
|
|
3483
|
-
{
|
|
3484
|
-
title: "",
|
|
3485
|
-
type: "launchSingleProduct",
|
|
3486
|
-
payload: { sku: this.config.pageContext.sku }
|
|
3487
|
-
},
|
|
3488
|
-
{ silent: !0, isPdpPrime: !0 }
|
|
3489
|
-
));
|
|
3490
|
-
}
|
|
3491
|
-
onHide() {
|
|
3492
|
-
(this.config.variant ?? "floating") === "floating" && (this.root.style.display = ""), this._hideDrawer(), this.emit("close"), W("gengage:chat:close", {}), this.config.onClose?.();
|
|
3493
|
-
}
|
|
3494
|
-
onDestroy() {
|
|
3495
|
-
this._abortControllers.forEach((e) => e.abort()), this._abortControllers.clear(), this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._drawer?.destroy(), this._drawer = null, this._bridge?.destroy(), this._bridge = null, this._extendedModeManager = null, this._panel?.destroy(), this._panel = null, this._session?.close(), this._session = null, window.gengage && delete window.gengage.chat, this._shadow && (this._shadow.innerHTML = "", this._shadow = null), this._rootEl = null;
|
|
3496
|
-
}
|
|
3497
|
-
// ---------------------------------------------------------------------------
|
|
3498
|
-
// Public API
|
|
3499
|
-
// ---------------------------------------------------------------------------
|
|
3500
|
-
open(e) {
|
|
3501
|
-
e?.state !== void 0 && (this._openState = e.state, this._drawerVisible && this._applyOpenStateClasses()), this.show(), e?.initialMessage !== void 0 && this._sendMessage(e.initialMessage);
|
|
3502
|
-
}
|
|
3503
|
-
openWithAction(e, t) {
|
|
3504
|
-
t?.sku !== void 0 && this.update({ sku: t.sku }), this._pdpLaunched = !0, t?.state !== void 0 ? this._openState = t.state : this._isMobileViewport && (this._openState = "half"), this.show(), this._drawerVisible && this._applyOpenStateClasses(), this._sendAction(e);
|
|
3505
|
-
}
|
|
3506
|
-
/** Send a user message programmatically (same flow as typing + submit). */
|
|
3507
|
-
sendMessage(e) {
|
|
3508
|
-
this._sendMessage(e);
|
|
3509
|
-
}
|
|
3510
|
-
/** Send a backend action programmatically. */
|
|
3511
|
-
sendAction(e, t) {
|
|
3512
|
-
this._sendAction(e, t);
|
|
3513
|
-
}
|
|
3514
|
-
close() {
|
|
3515
|
-
this.hide();
|
|
3516
|
-
}
|
|
3517
|
-
saveSession(e, t) {
|
|
3518
|
-
sessionStorage.setItem("gengage_restore_session_id", e), sessionStorage.setItem("gengage_restore_sku", t);
|
|
3519
|
-
}
|
|
3520
|
-
get isOpen() {
|
|
3521
|
-
return this._drawerVisible;
|
|
3522
|
-
}
|
|
3523
|
-
/**
|
|
3524
|
-
* Register a callback for a GA4 event name (e.g. 'gengage-cart-add').
|
|
3525
|
-
* The callback receives the event detail and should return true (success) or false (failure).
|
|
3526
|
-
* For add-to-cart, failure triggers an error message in the chat.
|
|
3527
|
-
* @returns unsubscribe function
|
|
3528
|
-
*/
|
|
3529
|
-
addCallback(e, t) {
|
|
3530
|
-
let a = this._eventCallbacks.get(e);
|
|
3531
|
-
return a || (a = /* @__PURE__ */ new Set(), this._eventCallbacks.set(e, a)), a.add(t), () => {
|
|
3532
|
-
a.delete(t), a.size === 0 && this._eventCallbacks.delete(e);
|
|
3533
|
-
};
|
|
3534
|
-
}
|
|
3535
|
-
// ---------------------------------------------------------------------------
|
|
3536
|
-
// Private
|
|
3537
|
-
// ---------------------------------------------------------------------------
|
|
3538
|
-
/** Reset all chat state when navigating to a different SKU/page. */
|
|
3539
|
-
_resetForNewPage() {
|
|
3540
|
-
this._activeRequestThreadId = null, this._abortControllers.forEach((e) => e.abort()), this._abortControllers.clear(), this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._messages.length = 0, this._drawer?.clearMessages(), this._drawer?.clearPanel(), this._panel.snapshots.clear(), this._panel.threads = [], this._thumbnailEntries = [], this._drawer?.setThumbnails([]), this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._currentThreadId = null, this._lastThreadId = null, this._lastBackendContext = null, this._chatCreatedAt = (/* @__PURE__ */ new Date()).toISOString(), this._pdpLaunched = !1, this._pdpPrimingInFlight = !1, this._queuedUserMessages = [], this._productContextUnavailableSku = null;
|
|
3541
|
-
}
|
|
3542
|
-
_handleBridgeMessage(e) {
|
|
3543
|
-
switch (e.type) {
|
|
3544
|
-
case "openChat":
|
|
3545
|
-
this.open();
|
|
3546
|
-
break;
|
|
3547
|
-
case "closeChat":
|
|
3548
|
-
this.close();
|
|
3549
|
-
break;
|
|
3550
|
-
case "startNewChatWithLauncherAction": {
|
|
3551
|
-
const t = e.payload, a = t?.action, n = le(a) ? a : le(t) ? t : null;
|
|
3552
|
-
n && this._sendAction(n, { silent: !0 }), this.open();
|
|
3553
|
-
break;
|
|
3554
|
-
}
|
|
3555
|
-
case "startNewChatWithDetailContext": {
|
|
3556
|
-
const t = e.payload;
|
|
3557
|
-
if (t && typeof t == "object") {
|
|
3558
|
-
this._bridgeContext = t;
|
|
3559
|
-
const a = t.sku;
|
|
3560
|
-
if (a && this.update({ sku: a }), le(t.action)) {
|
|
3561
|
-
this._pdpLaunched = !0, this.open(), this._sendAction(t.action);
|
|
3562
|
-
break;
|
|
3563
|
-
}
|
|
3564
|
-
}
|
|
3565
|
-
this.open();
|
|
3566
|
-
break;
|
|
3567
|
-
}
|
|
3568
|
-
case "launcherAction": {
|
|
3569
|
-
const a = e.payload?.action;
|
|
3570
|
-
a && typeof a == "object" && "type" in a && this._sendAction(a);
|
|
3571
|
-
break;
|
|
3572
|
-
}
|
|
3573
|
-
case "scrollToBottom":
|
|
3574
|
-
this._drawer?.scrollToBottomIfNeeded();
|
|
3575
|
-
break;
|
|
3576
|
-
case "addToCardHandler": {
|
|
3577
|
-
this._bridge?.send("addToCardResult", e.payload);
|
|
3578
|
-
break;
|
|
3579
|
-
}
|
|
3580
|
-
case "cartQuantityHandler": {
|
|
3581
|
-
const t = e.payload;
|
|
3582
|
-
t && "quantity" in t && typeof t.quantity == "number" && (this._cartQuantity = t.quantity);
|
|
3583
|
-
break;
|
|
3584
|
-
}
|
|
3585
|
-
case "minimizeRequestedByUser":
|
|
3586
|
-
this._extendedModeManager?.setHiddenByUser(!0);
|
|
3587
|
-
break;
|
|
3588
|
-
case "bgColorChange": {
|
|
3589
|
-
const a = e.payload?.color;
|
|
3590
|
-
typeof a == "string" && xn(a) && this._shadow && this._shadow.host.style.setProperty("--gengage-chat-bg", a);
|
|
3591
|
-
break;
|
|
3592
|
-
}
|
|
3593
|
-
}
|
|
3594
|
-
}
|
|
3595
|
-
_registerPublicAPI() {
|
|
3596
|
-
window.gengage || (window.gengage = {}), window.gengage.chat = {
|
|
3597
|
-
open: (e) => this.open(e),
|
|
3598
|
-
openWithAction: (e, t) => this.openWithAction(e, t),
|
|
3599
|
-
sendMessage: (e) => this.sendMessage(e),
|
|
3600
|
-
sendAction: (e, t) => this.sendAction(e, t),
|
|
3601
|
-
close: () => this.close(),
|
|
3602
|
-
saveSession: (e, t) => this.saveSession(e, t),
|
|
3603
|
-
get isOpen() {
|
|
3604
|
-
return !1;
|
|
3605
|
-
},
|
|
3606
|
-
// Placeholder, overridden below
|
|
3607
|
-
on: (e, t) => this.on(e, t),
|
|
3608
|
-
trackCheckout: (e, t) => this.trackCheckout(e, t),
|
|
3609
|
-
flushMeteringSummary: (e) => this.flushMeteringSummary(e),
|
|
3610
|
-
addCallback: (e, t) => this.addCallback(e, t)
|
|
3611
|
-
}, Object.defineProperty(window.gengage.chat, "isOpen", {
|
|
3612
|
-
get: () => this._drawerVisible
|
|
3613
|
-
});
|
|
3614
|
-
}
|
|
3615
|
-
_showDrawer() {
|
|
3616
|
-
if (this._drawerVisible) return;
|
|
3617
|
-
this._drawerVisible = !0;
|
|
3618
|
-
const e = this._drawer?.getElement();
|
|
3619
|
-
e && e.classList.remove("gengage-chat-drawer--hidden"), this._applyOpenStateClasses(), this._drawer?.trapFocus(), this._isMobileViewport && this._openState === "half" || this._drawer?.focusInput(), this._extendedModeManager?.setChatShown(!0);
|
|
3620
|
-
}
|
|
3621
|
-
_hideDrawer() {
|
|
3622
|
-
if (!this._drawerVisible) return;
|
|
3623
|
-
this._drawer?.releaseFocus(), this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._drawerVisible = !1, this._openState = "full";
|
|
3624
|
-
const e = this._drawer?.getElement();
|
|
3625
|
-
e && e.classList.add("gengage-chat-drawer--hidden"), this._applyOpenStateClasses(), this._extendedModeManager?.setChatShown(!1);
|
|
3626
|
-
}
|
|
3627
|
-
_syncViewportState() {
|
|
3628
|
-
if (this._rootEl) {
|
|
3629
|
-
if (this._isMobileViewport = window.innerWidth <= this._mobileBreakpoint, this._rootEl.classList.toggle("gengage-chat-root--mobile", this._isMobileViewport), this._launcher) {
|
|
3630
|
-
const e = this._isMobileViewport && this.config.hideMobileLauncher === !0;
|
|
3631
|
-
this._launcher.container.classList.toggle("gengage-chat-launcher--hidden-mobile", e);
|
|
3632
|
-
}
|
|
3633
|
-
this._applyOpenStateClasses();
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
_applyOpenStateClasses() {
|
|
3637
|
-
if (!this._rootEl) return;
|
|
3638
|
-
const e = this._drawerVisible && this._isMobileViewport && this._openState === "half", t = this._drawerVisible && this._isMobileViewport && this._openState === "full";
|
|
3639
|
-
this._rootEl.classList.toggle("gengage-chat-root--open", this._drawerVisible), this._rootEl.classList.toggle("gengage-chat-root--mobile-half", e), this._rootEl.classList.toggle("gengage-chat-root--mobile-full", t);
|
|
3640
|
-
}
|
|
3641
|
-
_handleAttachment(e) {
|
|
3642
|
-
const t = Tt(e);
|
|
3643
|
-
if (!t.ok) {
|
|
3644
|
-
const a = t.reason === "invalid_type" ? this._i18n.invalidFileType : this._i18n.fileTooLarge;
|
|
3645
|
-
W("gengage:global:error", {
|
|
3646
|
-
message: a,
|
|
3647
|
-
source: "chat"
|
|
3648
|
-
});
|
|
3649
|
-
return;
|
|
3650
|
-
}
|
|
3651
|
-
this._drawer?.stageAttachment(e);
|
|
3652
|
-
}
|
|
3653
|
-
_sendMessage(e, t) {
|
|
3654
|
-
if (this._pdpPrimingInFlight) {
|
|
3655
|
-
this._queuedUserMessages.push(t !== void 0 ? { text: e, attachment: t } : { text: e });
|
|
3656
|
-
return;
|
|
3657
|
-
}
|
|
3658
|
-
Qe(), this._messages.some((i) => i.role === "user") || Xe();
|
|
3659
|
-
const n = {
|
|
3660
|
-
title: e,
|
|
3661
|
-
type: "user_message",
|
|
3662
|
-
payload: e
|
|
3663
|
-
};
|
|
3664
|
-
t !== void 0 ? this._sendAction(n, { attachment: t }) : this._sendAction(n);
|
|
3665
|
-
}
|
|
3666
|
-
_flushQueuedUserMessages() {
|
|
3667
|
-
if (this._pdpPrimingInFlight || this._queuedUserMessages.length === 0) return;
|
|
3668
|
-
const e = [...this._queuedUserMessages];
|
|
3669
|
-
this._queuedUserMessages = [];
|
|
3670
|
-
for (const t of e)
|
|
3671
|
-
this._sendMessage(t.text, t.attachment);
|
|
3672
|
-
}
|
|
3673
|
-
_sendAction(e, t) {
|
|
3674
|
-
if (this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._lastSentAction = { action: e, options: t }, !this._initComplete) {
|
|
3675
|
-
this._pendingActions.length < 10 && this._pendingActions.push({ action: e, options: t });
|
|
3676
|
-
return;
|
|
3677
|
-
}
|
|
3678
|
-
if (this._choicePrompterEl?.remove(), this._choicePrompterEl = null, !t?.preservePanel && this._comparisonSelectMode && (this._comparisonSelectMode = !1, this._comparisonSelectedSkus = []), this._currentThreadId && this._lastThreadId && this._lastThreadId > this._currentThreadId) {
|
|
3679
|
-
const p = this._currentThreadId, b = this._messages.filter((k) => k.threadId !== void 0 && k.threadId > p);
|
|
3680
|
-
this._messages = this._messages.filter((k) => !k.threadId || k.threadId <= p);
|
|
3681
|
-
for (const k of b)
|
|
3682
|
-
this._shadow?.querySelector(`[data-message-id="${CSS.escape(k.id)}"]`)?.remove(), this._panel.snapshots.delete(k.id), this._panel.snapshotTypes.delete(k.id);
|
|
3683
|
-
this._shadow?.querySelectorAll("[data-thread-id]")?.forEach((k) => {
|
|
3684
|
-
k instanceof HTMLElement && k.dataset.threadId && k.dataset.threadId > p && k.remove();
|
|
3685
|
-
});
|
|
3686
|
-
}
|
|
3687
|
-
this._drawer?.setPills([]), this._drawer?.clearInputAreaChips(), this._bridge?.send("isResponding", !0);
|
|
3688
|
-
const a = xt();
|
|
3689
|
-
this._currentThreadId = a, this._lastThreadId = a, this._panel && e.type !== "launchSingleProduct" && (this._panel.lastActionType = e.type);
|
|
3690
|
-
const n = t?.preservePanel === !0, i = e.type === "launchSingleProduct" && t?.silent === !0 && t?.isPdpPrime === !0;
|
|
3691
|
-
if (n || (this._activeRequestThreadId = a), !t?.silent) {
|
|
3692
|
-
const p = this._createMessage("user", typeof e.payload == "string" ? e.payload : e.title);
|
|
3693
|
-
p.threadId = a, t?.attachment !== void 0 && (p.attachment = t.attachment), this._drawer?.addMessage(p), this._messages.push(p);
|
|
3694
|
-
}
|
|
3695
|
-
if (!t?.silent && this._hasUnavailableProductContext() && (e.type === "user_message" || e.type === "inputText")) {
|
|
3696
|
-
const p = this._i18n.productNotFoundMessage, b = this._createMessage("assistant", p);
|
|
3697
|
-
b.threadId = a, b.status = "done", this._messages.push(b), this._ensureAssistantMessageRendered(b), this._drawer?.updateBotMessage(b.id, p), this._bridge?.send("isResponding", !1), this.emit("message", b), this._persistToIndexedDB().catch(() => {
|
|
3698
|
-
});
|
|
3699
|
-
return;
|
|
3700
|
-
}
|
|
3701
|
-
let l = null;
|
|
3702
|
-
const d = () => {
|
|
3703
|
-
if (l || t?.preservePanel) return;
|
|
3704
|
-
const p = this._drawer?.getPanelContentElement();
|
|
3705
|
-
p && (l = p.cloneNode(!0));
|
|
3706
|
-
}, c = () => {
|
|
3707
|
-
this._drawer?.isPanelLoading() && (l ? this._drawer.setPanelContent(l) : this._drawer.clearPanel(), l = null);
|
|
3708
|
-
};
|
|
3709
|
-
this._drawer?.showTypingIndicator();
|
|
3710
|
-
let g = "";
|
|
3711
|
-
const r = this._createMessage("assistant", "");
|
|
3712
|
-
r.threadId = a, r.status = "streaming", t?.silent && (r.silent = !0), this._messages.push(r), t?.preservePanel || (this._abortControllers.forEach((p) => p.abort()), this._abortControllers.clear());
|
|
3713
|
-
const m = {
|
|
3714
|
-
middlewareUrl: this.config.middlewareUrl,
|
|
3715
|
-
...this.config.accountId ? { accountId: this.config.accountId } : {}
|
|
3716
|
-
};
|
|
3717
|
-
t?.attachment !== void 0 && (m.attachment = t.attachment);
|
|
3718
|
-
const y = this._getVisibleMessages().filter((p) => p !== r && (p.content || p.role === "assistant")).slice(-50).map((p) => ({
|
|
3719
|
-
role: p.role === "user" ? "user" : "model",
|
|
3720
|
-
content: p.content ?? ""
|
|
3721
|
-
})), _ = {
|
|
3722
|
-
outputLanguage: Ka(this.config.locale),
|
|
3723
|
-
parentUrl: window.location.href,
|
|
3724
|
-
windowWidth: String(window.innerWidth),
|
|
3725
|
-
windowHeight: String(window.innerHeight),
|
|
3726
|
-
selfUrl: "",
|
|
3727
|
-
id: this.config.session?.sessionId ?? "",
|
|
3728
|
-
userId: this.config.session?.userId ?? "",
|
|
3729
|
-
appId: this.config.accountId,
|
|
3730
|
-
threads: [],
|
|
3731
|
-
createdAt: this._chatCreatedAt,
|
|
3732
|
-
kvkkApproved: Ce(this.config.accountId),
|
|
3733
|
-
voiceEnabled: this.config.voiceEnabled ?? !1,
|
|
3734
|
-
threadId: a,
|
|
3735
|
-
isControlGroup: this.config.session?.abTestVariant === "control",
|
|
3736
|
-
isMobile: this._isMobileViewport
|
|
3737
|
-
};
|
|
3738
|
-
this.config.session?.viewId !== void 0 && (_.viewId = this.config.session.viewId);
|
|
3739
|
-
const v = Lt(e, {
|
|
3740
|
-
pageContext: this.config.pageContext,
|
|
3741
|
-
backendContext: this._lastBackendContext,
|
|
3742
|
-
isMobile: this._isMobileViewport
|
|
3743
|
-
}), C = {
|
|
3744
|
-
account_id: this.config.accountId,
|
|
3745
|
-
session_id: this.config.session?.sessionId ?? "",
|
|
3746
|
-
correlation_id: this.config.session?.sessionId ?? "",
|
|
3747
|
-
type: v.type,
|
|
3748
|
-
locale: this.config.locale ?? "tr",
|
|
3749
|
-
meta: _,
|
|
3750
|
-
context: {
|
|
3751
|
-
// Spread backend context (panel, message_id, etc.) but preserve FE's
|
|
3752
|
-
// authoritative chatHistory — the backend's stale `messages` must not
|
|
3753
|
-
// overwrite the up-to-date conversation history built by the widget.
|
|
3754
|
-
...this._lastBackendContext ?? {},
|
|
3755
|
-
messages: y,
|
|
3756
|
-
// Backend reads session_id from context.
|
|
3757
|
-
session_id: this.config.session?.sessionId ?? ""
|
|
3758
|
-
}
|
|
3759
|
-
};
|
|
3760
|
-
this.config.session?.userId !== void 0 && (C.user_id = this.config.session.userId), this.config.session?.viewId !== void 0 && (C.view_id = this.config.session.viewId), v.payload !== void 0 && (C.payload = v.payload), this.config.pageContext?.sku !== void 0 && (C.sku = this.config.pageContext.sku), this.config.pageContext?.pageType !== void 0 && (C.page_type = this.config.pageContext.pageType);
|
|
3761
|
-
const E = crypto.randomUUID(), S = Date.now();
|
|
3762
|
-
let w = 0, L = !1, R = !1;
|
|
3763
|
-
this.track(
|
|
3764
|
-
Je(this.analyticsContext(), {
|
|
3765
|
-
endpoint: "process_action",
|
|
3766
|
-
request_id: E,
|
|
3767
|
-
widget: "chat"
|
|
3768
|
-
})
|
|
3769
|
-
);
|
|
3770
|
-
let q = null;
|
|
3771
|
-
if (q = Pt(
|
|
3772
|
-
C,
|
|
3773
|
-
{
|
|
3774
|
-
onTextChunk: (p, b, f) => {
|
|
3775
|
-
if (!n && a !== this._activeRequestThreadId || (g += p, this._drawer?.removeTypingIndicator(), f?.skuToProductItem && (this._skuToProductItem = { ...this._skuToProductItem, ...f.skuToProductItem }), f?.conversationMode && (this._conversationMode = f.conversationMode), this.track(
|
|
3776
|
-
ft(this.analyticsContext(), {
|
|
3777
|
-
request_id: E,
|
|
3778
|
-
chunk_index: w++,
|
|
3779
|
-
widget: "chat"
|
|
3780
|
-
})
|
|
3781
|
-
), !this._drawer)) return;
|
|
3782
|
-
let k = g;
|
|
3783
|
-
if (b && ue(k)) {
|
|
3784
|
-
const I = this.config.accountId;
|
|
3785
|
-
if (!Ce(I)) {
|
|
3786
|
-
const z = Ga(k);
|
|
3787
|
-
z && this._drawer?.showKvkkBanner(z, () => {
|
|
3788
|
-
this._drawer?.hideKvkkBanner();
|
|
3789
|
-
}), Wa(I);
|
|
3790
|
-
}
|
|
3791
|
-
k = $a(k);
|
|
3792
|
-
}
|
|
3793
|
-
const T = this._shadow?.querySelector(
|
|
3794
|
-
`[data-message-id="${r.id}"] .gengage-chat-bubble-text`
|
|
3795
|
-
);
|
|
3796
|
-
if (T ? T.innerHTML = G(k) : (r.content = k, r.role === "assistant" && r.threadId && !this._threadsWithFirstBot.has(r.threadId) && (this._threadsWithFirstBot.add(r.threadId), this._drawer.markFirstBotMessage(r.id)), this._drawer.addMessage(r)), b) {
|
|
3797
|
-
r.content = k, r.status = "done", xe();
|
|
3798
|
-
const I = this._shadow?.querySelector(
|
|
3799
|
-
`[data-message-id="${r.id}"] .gengage-chat-bubble-text`
|
|
3800
|
-
);
|
|
3801
|
-
if (I) {
|
|
3802
|
-
this._activeTypewriter?.cancel();
|
|
3803
|
-
const z = f?.productMentions;
|
|
3804
|
-
this._activeTypewriter = Ia({
|
|
3805
|
-
container: I,
|
|
3806
|
-
html: G(k),
|
|
3807
|
-
onTick: () => this._drawer?.scrollToBottomIfNeeded(),
|
|
3808
|
-
onComplete: () => {
|
|
3809
|
-
this._activeTypewriter = null, z && z.length > 0 && I && Aa({
|
|
3810
|
-
container: I,
|
|
3811
|
-
mentions: z,
|
|
3812
|
-
onProductClick: (D) => {
|
|
3813
|
-
this._sendAction({
|
|
3814
|
-
title: z.find((N) => N.sku === D)?.short_name ?? D,
|
|
3815
|
-
type: "launchSingleProduct",
|
|
3816
|
-
payload: { sku: D }
|
|
3817
|
-
});
|
|
3818
|
-
}
|
|
3819
|
-
});
|
|
3820
|
-
}
|
|
3821
|
-
});
|
|
3822
|
-
}
|
|
3823
|
-
}
|
|
3824
|
-
},
|
|
3825
|
-
onUISpec: (p, b, f) => {
|
|
3826
|
-
if (!n && a !== this._activeRequestThreadId || b !== "chat") return;
|
|
3827
|
-
const k = p.elements[p.root], T = k?.type ?? "unknown";
|
|
3828
|
-
this.track(
|
|
3829
|
-
ht(this.analyticsContext(), {
|
|
3830
|
-
request_id: E,
|
|
3831
|
-
chunk_index: w,
|
|
3832
|
-
component_type: T,
|
|
3833
|
-
widget: "chat"
|
|
3834
|
-
})
|
|
3835
|
-
);
|
|
3836
|
-
const I = this._buildRenderContext();
|
|
3837
|
-
if (T === "ComparisonTable") {
|
|
3838
|
-
const N = k?.props?.products;
|
|
3839
|
-
ut(Array.isArray(N) ? N.length : 0);
|
|
3840
|
-
}
|
|
3841
|
-
if (T === "ProductGrid") {
|
|
3842
|
-
const N = k?.children?.length ?? 0;
|
|
3843
|
-
mt(void 0, N);
|
|
3844
|
-
}
|
|
3845
|
-
const z = f === "panel" && this._panel ? this._panel.toPanelSpec(p) : p, D = !r.silent && (f !== "panel" || T === "ProductCard") && T !== "ActionButtons";
|
|
3846
|
-
if (f === "panel" && this._panel) {
|
|
3847
|
-
const N = !R;
|
|
3848
|
-
R = !0;
|
|
3849
|
-
const A = Oa({
|
|
3850
|
-
componentType: T,
|
|
3851
|
-
similarsAppend: k?.props?.similarsAppend === !0,
|
|
3852
|
-
currentPanelType: this._panel.currentType,
|
|
3853
|
-
hasPanelContent: this._drawer?.hasPanelContent() ?? !1,
|
|
3854
|
-
isPanelLoading: this._drawer?.isPanelLoading() ?? !1,
|
|
3855
|
-
isFirstPanelContentInStream: N
|
|
3856
|
-
});
|
|
3857
|
-
A === "appendSimilars" ? this._appendSimilarsToPanel(z, I) : A === "append" ? this._drawer?.appendPanelContent(this._renderUISpec(z, I)) : (this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._drawer?.setPanelContent(this._renderUISpec(z, I)), this._panel.currentType = T), T === "ProductDetailsPanel" && e.type === "launchSingleProduct" && this._clearUnavailableProductContext(), r.threadId && !this._panel.threads.includes(r.threadId) && this._panel.threads.push(r.threadId);
|
|
3858
|
-
const M = this._panel.currentType ?? T, u = k?.props?.panelTitle;
|
|
3859
|
-
this._panel.updateTopBar(M, u), this._panel.updateExtendedMode(T);
|
|
3860
|
-
}
|
|
3861
|
-
if (T === "ProductDetailsPanel" && !r.silent && f === "panel") {
|
|
3862
|
-
const N = k?.props?.product;
|
|
3863
|
-
if (N) {
|
|
3864
|
-
const A = {
|
|
3865
|
-
root: "root",
|
|
3866
|
-
elements: {
|
|
3867
|
-
root: {
|
|
3868
|
-
type: "ProductSummaryCard",
|
|
3869
|
-
props: { product: N }
|
|
3870
|
-
}
|
|
3871
|
-
}
|
|
3872
|
-
}, M = this._shadow?.querySelector(".gengage-chat-messages");
|
|
3873
|
-
if (M) {
|
|
3874
|
-
const u = this._renderUISpec(A, I);
|
|
3875
|
-
r.threadId && (u.dataset.threadId = r.threadId), M.appendChild(u), u.scrollIntoView({ behavior: "auto", block: "end" });
|
|
3876
|
-
}
|
|
3877
|
-
}
|
|
3878
|
-
}
|
|
3879
|
-
if (D) {
|
|
3880
|
-
const N = this._shadow?.querySelector(".gengage-chat-messages");
|
|
3881
|
-
if (N) {
|
|
3882
|
-
const A = this._renderUISpec(p, I);
|
|
3883
|
-
r.threadId && (A.dataset.threadId = r.threadId), N.appendChild(A), A.scrollIntoView({ behavior: "auto", block: "end" });
|
|
3884
|
-
}
|
|
3885
|
-
}
|
|
3886
|
-
if ((T === "ProductGrid" || T === "ProductCard") && r.threadId) {
|
|
3887
|
-
const N = k?.children ?? [], A = T === "ProductGrid" ? N.map((M) => p.elements[M]?.props?.product).filter(Boolean) : [k?.props?.product].filter(Boolean);
|
|
3888
|
-
for (const M of A) {
|
|
3889
|
-
const u = M.sku, P = M.imageUrl;
|
|
3890
|
-
u && P && this._thumbnailEntries.push({ sku: u, imageUrl: P, threadId: r.threadId });
|
|
3891
|
-
}
|
|
3892
|
-
this._drawer?.setThumbnails(this._thumbnailEntries);
|
|
3893
|
-
}
|
|
3894
|
-
if (T === "ProductGrid" || T === "ProductDetailsPanel") {
|
|
3895
|
-
const A = (T === "ProductGrid" ? (k?.children ?? []).map((M) => p.elements[M]?.props?.product).filter(Boolean) : [
|
|
3896
|
-
k?.props?.product ?? k?.props
|
|
3897
|
-
].filter(Boolean)).map((M) => M.imageUrl).filter((M) => typeof M == "string").slice(0, 5);
|
|
3898
|
-
A.length > 0 && this._bridge?.send("previewImages", { images: A });
|
|
3899
|
-
}
|
|
3900
|
-
if (T === "ProductGrid" && f === "panel" && !this._comparisonSelectMode && !za()) {
|
|
3901
|
-
this._choicePrompterEl?.remove(), this._shadow?.querySelectorAll(".gengage-chat-choice-prompter").forEach((u) => u.remove()), this._choicePrompterEl = Ba({
|
|
3902
|
-
heading: this._i18n.choicePrompterHeading,
|
|
3903
|
-
suggestion: this._i18n.choicePrompterSuggestion,
|
|
3904
|
-
ctaLabel: this._i18n.choicePrompterCta,
|
|
3905
|
-
dismissAriaLabel: this._i18n.dismissAriaLabel,
|
|
3906
|
-
onCtaClick: () => {
|
|
3907
|
-
this._comparisonSelectMode = !0, this._choicePrompterEl = null, this._refreshComparisonUI();
|
|
3908
|
-
},
|
|
3909
|
-
onDismiss: () => {
|
|
3910
|
-
this._choicePrompterEl = null;
|
|
3911
|
-
}
|
|
3912
|
-
});
|
|
3913
|
-
const A = this._isMobileViewport || this._drawer?.isPanelCollapsed() ? ".gengage-chat-conversation" : ".gengage-chat-panel", M = this._shadow?.querySelector(A);
|
|
3914
|
-
M ? M.appendChild(this._choicePrompterEl) : this._choicePrompterEl = null;
|
|
3915
|
-
}
|
|
3916
|
-
if (T === "ActionButtons") {
|
|
3917
|
-
const N = k?.props?.buttons;
|
|
3918
|
-
if (N && N.length > 0) {
|
|
3919
|
-
const A = [], M = [];
|
|
3920
|
-
for (const u of N)
|
|
3921
|
-
if (Ma(u)) {
|
|
3922
|
-
const P = {
|
|
3923
|
-
label: u.label,
|
|
3924
|
-
action: u.action
|
|
3925
|
-
};
|
|
3926
|
-
u.icon && (P.icon = u.icon), A.push(P);
|
|
3927
|
-
} else
|
|
3928
|
-
M.push(u);
|
|
3929
|
-
A.length > 0 && this._drawer?.setInputAreaChips(
|
|
3930
|
-
A.map((u) => ({
|
|
3931
|
-
label: u.label,
|
|
3932
|
-
onAction: () => this._sendAction(u.action),
|
|
3933
|
-
...u.icon ? { icon: u.icon } : {}
|
|
3934
|
-
}))
|
|
3935
|
-
), M.length > 0 && this._drawer?.setPills(
|
|
3936
|
-
M.map((u) => {
|
|
3937
|
-
const P = {
|
|
3938
|
-
label: u.label,
|
|
3939
|
-
onAction: () => this._sendAction(u.action)
|
|
3940
|
-
};
|
|
3941
|
-
return u.icon && (P.icon = u.icon), u.image && (P.image = u.image), u.description && (P.description = u.description), P;
|
|
3942
|
-
})
|
|
3943
|
-
);
|
|
3944
|
-
}
|
|
3945
|
-
}
|
|
3946
|
-
r.uiSpec = p;
|
|
3947
|
-
},
|
|
3948
|
-
onAction: (p) => {
|
|
3949
|
-
if (!(!n && a !== this._activeRequestThreadId) && p.type === "action") {
|
|
3950
|
-
const b = {};
|
|
3951
|
-
this.config.actionHandling?.unknownActionPolicy !== void 0 && (b.unknownActionPolicy = this.config.actionHandling.unknownActionPolicy), this.config.actionHandling?.allowScriptCall !== void 0 && (b.allowScriptCall = this.config.actionHandling.allowScriptCall), _t(
|
|
3952
|
-
p,
|
|
3953
|
-
{
|
|
3954
|
-
openChat: () => this.open(),
|
|
3955
|
-
navigate: (f) => {
|
|
3956
|
-
O(f.url) && (this._bridge?.send("navigate", f), f.newTab ? window.open(f.url, "_blank", "noopener,noreferrer") : window.location.href = f.url);
|
|
3957
|
-
},
|
|
3958
|
-
saveSession: (f) => this.saveSession(f.sessionId, f.sku),
|
|
3959
|
-
addToCart: (f) => {
|
|
3960
|
-
W("gengage:similar:add-to-cart", f);
|
|
3961
|
-
},
|
|
3962
|
-
scriptCall: (f) => {
|
|
3963
|
-
W("gengage:chat:script-call", f), this.config.onScriptCall?.(f);
|
|
3964
|
-
}
|
|
3965
|
-
},
|
|
3966
|
-
b
|
|
3967
|
-
);
|
|
3968
|
-
}
|
|
3969
|
-
},
|
|
3970
|
-
onMetadata: (p) => {
|
|
3971
|
-
if (!(!n && a !== this._activeRequestThreadId) && p.type === "metadata" && p.meta) {
|
|
3972
|
-
if ((p.meta.panel !== void 0 || p.meta.messages !== void 0 || p.meta.message_id !== void 0) && (this._lastBackendContext = p.meta), p.meta.panelLoading) {
|
|
3973
|
-
L = !0, R = !1, d();
|
|
3974
|
-
const f = typeof p.meta.panelPendingType == "string" ? p.meta.panelPendingType : void 0;
|
|
3975
|
-
this._panel && (this._panel.currentType = null), this._drawer?.showPanelLoading(f), f && this._panel?.updateTopBarForLoading(f);
|
|
3976
|
-
}
|
|
3977
|
-
if (p.meta.voice) {
|
|
3978
|
-
const f = new CustomEvent("gengage:chat:voice", {
|
|
3979
|
-
detail: { payload: p.meta.voice },
|
|
3980
|
-
bubbles: !1,
|
|
3981
|
-
cancelable: !0
|
|
3982
|
-
}), k = window.dispatchEvent(f);
|
|
3983
|
-
if (dt(), k) {
|
|
3984
|
-
const T = p.meta.voice;
|
|
3985
|
-
T.audio_base64 && (this._activeTtsHandle?.stop(), this._activeTtsHandle = $t(
|
|
3986
|
-
T.audio_base64,
|
|
3987
|
-
T.content_type ?? "audio/ogg"
|
|
3988
|
-
));
|
|
3989
|
-
}
|
|
3990
|
-
}
|
|
3991
|
-
(p.meta.redirectTarget || p.meta.redirect) && W("gengage:chat:redirect", {
|
|
3992
|
-
target: p.meta.redirectTarget ?? null,
|
|
3993
|
-
payload: p.meta.redirect ?? null
|
|
3994
|
-
}), p.meta.analyzeAnimation && (L = !0, R = !1, d(), this._panel && (this._panel.currentType = null), this._drawer?.showPanelLoading(), this._panel?.updateTopBarForLoading("productDetails")), p.meta.loading && typeof p.meta.loadingText == "string" && (this._drawer?.addThinkingStep(p.meta.loadingText), this._bridge?.send("loadingMessage", { text: p.meta.loadingText })), p.meta.visitorDataResponse && this._bridge?.send("engagingMessage", p.meta.visitorDataResponse), p.meta.formType && this._bridge?.send("glovOtokoc", {
|
|
3995
|
-
type: p.meta.formType,
|
|
3996
|
-
data: p.meta.formPayload
|
|
3997
|
-
}), p.meta.launcherContent && this._bridge?.send("launcherContent", p.meta.launcherContent), W("gengage:chat:metadata", { payload: p.meta });
|
|
3998
|
-
const b = p.meta;
|
|
3999
|
-
typeof b.prompt_tokens == "number" && typeof b.completion_tokens == "number" && this.track(
|
|
4000
|
-
pt(this.analyticsContext(), {
|
|
4001
|
-
model: p.model ?? "unknown",
|
|
4002
|
-
prompt_tokens: b.prompt_tokens,
|
|
4003
|
-
completion_tokens: b.completion_tokens,
|
|
4004
|
-
total_tokens: b.total_tokens ?? b.prompt_tokens + b.completion_tokens
|
|
4005
|
-
})
|
|
4006
|
-
);
|
|
4007
|
-
}
|
|
4008
|
-
},
|
|
4009
|
-
onError: (p) => {
|
|
4010
|
-
if (q && this._abortControllers.delete(q), !n && a !== this._activeRequestThreadId) return;
|
|
4011
|
-
this._bridge?.send("isResponding", !1), this._bridge?.send("loadingMessage", { text: null }), this._drawer?.removeTypingIndicator();
|
|
4012
|
-
const b = R;
|
|
4013
|
-
if (L && !R && c(), L = !1, R = !1, !(r.silent || r.content != null && r.content.length > 0 || g.length > 0 || b))
|
|
4014
|
-
if (i || this._hasUnavailableProductContext()) {
|
|
4015
|
-
const k = this._i18n.productNotFoundMessage;
|
|
4016
|
-
r.content = k, r.status = "done", this._ensureAssistantMessageRendered(r), this._drawer?.updateBotMessage(r.id, k), this._markUnavailableProductContext();
|
|
4017
|
-
} else
|
|
4018
|
-
this.emit("error", p), this._drawer?.showError(this._i18n.errorMessage, () => {
|
|
4019
|
-
this._lastSentAction && this._sendAction(this._lastSentAction.action, this._lastSentAction.options);
|
|
4020
|
-
});
|
|
4021
|
-
i && (this._pdpPrimingInFlight = !1, this._flushQueuedUserMessages()), r.status === "streaming" && (r.status = "error"), this.track(
|
|
4022
|
-
gt(this.analyticsContext(), {
|
|
4023
|
-
request_id: E,
|
|
4024
|
-
error_code: "STREAM_ERROR",
|
|
4025
|
-
error_message: p.message,
|
|
4026
|
-
widget: "chat"
|
|
4027
|
-
})
|
|
4028
|
-
);
|
|
4029
|
-
},
|
|
4030
|
-
onDone: () => {
|
|
4031
|
-
if (q && this._abortControllers.delete(q), !(!n && a !== this._activeRequestThreadId)) {
|
|
4032
|
-
if (this._activeRequestThreadId = null, this._bridge?.send("isResponding", !1), this._bridge?.send("loadingMessage", { text: null }), this._drawer?.removeTypingIndicator(), L && !R && c(), L = !1, R = !1, i && !g && !R) {
|
|
4033
|
-
const p = this._i18n.productNotFoundMessage;
|
|
4034
|
-
r.content = p, this._ensureAssistantMessageRendered(r), this._drawer?.updateBotMessage(r.id, p), this._markUnavailableProductContext();
|
|
4035
|
-
}
|
|
4036
|
-
i && (this._pdpPrimingInFlight = !1, this._flushQueuedUserMessages()), r.status === "streaming" && (r.status = "done", xe()), this.emit("message", r), this._panel?.snapshotForMessage(r.id), this._panel?.attachClickHandler(r.id), this.track(
|
|
4037
|
-
st(this.analyticsContext(), {
|
|
4038
|
-
request_id: E,
|
|
4039
|
-
latency_ms: Date.now() - S,
|
|
4040
|
-
chunk_count: w,
|
|
4041
|
-
widget: "chat"
|
|
4042
|
-
})
|
|
4043
|
-
), this.track(
|
|
4044
|
-
ct(this.analyticsContext(), {
|
|
4045
|
-
meter_key: "chat_request",
|
|
4046
|
-
quantity: 1,
|
|
4047
|
-
unit: "request"
|
|
4048
|
-
})
|
|
4049
|
-
), this.track(
|
|
4050
|
-
lt(this.analyticsContext(), {
|
|
4051
|
-
message_count: this._messages.length,
|
|
4052
|
-
history_ref: this.config.session?.sessionId ?? "",
|
|
4053
|
-
redaction_level: "none"
|
|
4054
|
-
})
|
|
4055
|
-
), this._persistToIndexedDB().catch(() => {
|
|
4056
|
-
});
|
|
4057
|
-
}
|
|
4058
|
-
}
|
|
4059
|
-
},
|
|
4060
|
-
m
|
|
4061
|
-
), this._abortControllers.add(q), !t?.silent && !n) {
|
|
4062
|
-
const p = q;
|
|
4063
|
-
this._drawer?.showStopButton(() => {
|
|
4064
|
-
p.abort(), this._abortControllers.delete(p), this._drawer?.removeTypingIndicator(), this._bridge?.send("isResponding", !1), this._bridge?.send("loadingMessage", { text: null }), r.status === "streaming" && (r.status = "done");
|
|
4065
|
-
});
|
|
4066
|
-
}
|
|
4067
|
-
}
|
|
4068
|
-
/** Return messages visible at the current thread cursor. */
|
|
4069
|
-
_getVisibleMessages() {
|
|
4070
|
-
const e = this._messages.filter((a) => !a.silent);
|
|
4071
|
-
if (!this._currentThreadId) return e;
|
|
4072
|
-
const t = this._currentThreadId;
|
|
4073
|
-
return e.filter((a) => !a.threadId || a.threadId <= t);
|
|
4074
|
-
}
|
|
4075
|
-
/** Handle rollback-on-click from a user message bubble. */
|
|
4076
|
-
_appendSimilarsToPanel(e, t) {
|
|
4077
|
-
if (!this._drawer) return;
|
|
4078
|
-
const a = this._drawer.getPanelContentElement();
|
|
4079
|
-
if (!a) return;
|
|
4080
|
-
const n = document.createElement("h3");
|
|
4081
|
-
n.className = "gengage-chat-product-details-similars-heading", n.textContent = this._i18n.similarProductsLabel ?? "Similar Products", a.appendChild(n);
|
|
4082
|
-
const i = this._renderUISpec(e, t);
|
|
4083
|
-
i.classList.add("gengage-chat-product-details-similars"), a.appendChild(i);
|
|
4084
|
-
}
|
|
4085
|
-
_handleRollback(e) {
|
|
4086
|
-
const t = this._messages.find((a) => a.id === e);
|
|
4087
|
-
t?.threadId && this._rollbackToThread(t.threadId);
|
|
4088
|
-
}
|
|
4089
|
-
/** Rewind the conversation to the given thread. */
|
|
4090
|
-
_rollbackToThread(e) {
|
|
4091
|
-
this._currentThreadId = e, this._extendedModeManager?.setHiddenByUser(!1);
|
|
4092
|
-
for (const i of this._messages) {
|
|
4093
|
-
const s = this._shadow?.querySelector(`[data-message-id="${CSS.escape(i.id)}"]`);
|
|
4094
|
-
s && (i.threadId && i.threadId > e ? s.classList.add("gengage-chat-bubble--hidden") : s.classList.remove("gengage-chat-bubble--hidden"));
|
|
4095
|
-
}
|
|
4096
|
-
this._shadow?.querySelectorAll("[data-thread-id]").forEach((i) => {
|
|
4097
|
-
i instanceof HTMLElement && i.dataset.threadId && i.dataset.threadId > e ? i.classList.add("gengage-chat-bubble--hidden") : i instanceof HTMLElement && i.classList.remove("gengage-chat-bubble--hidden");
|
|
4098
|
-
});
|
|
4099
|
-
const t = this._messages.find((i) => i.role === "assistant" && i.threadId === e);
|
|
4100
|
-
t && this._panel?.restoreForMessage(t.id) || this._drawer?.clearPanel();
|
|
4101
|
-
const n = this._panel.currentType ?? "";
|
|
4102
|
-
this._panel?.updateTopBar(n), this._drawer?.setPills([]), this._session?.db && this.config.session?.sessionId && this._session?.db.loadContext(this.config.session.sessionId, e).then((i) => {
|
|
4103
|
-
i && (this._lastBackendContext = i.context);
|
|
4104
|
-
}).catch(() => {
|
|
4105
|
-
}), this._session?.db && this.config.session?.sessionId && this._session?.db.deleteContextsAfterThread(this.config.session.sessionId, e).catch(() => {
|
|
4106
|
-
});
|
|
4107
|
-
}
|
|
4108
|
-
// ---------------------------------------------------------------------------
|
|
4109
|
-
// IndexedDB persistence (delegates to SessionPersistence)
|
|
4110
|
-
// ---------------------------------------------------------------------------
|
|
4111
|
-
async _persistToIndexedDB() {
|
|
4112
|
-
!this._session || !this.config.session?.sessionId || await this._session.persist({
|
|
4113
|
-
userId: this.config.session.userId ?? "",
|
|
4114
|
-
appId: this.config.accountId,
|
|
4115
|
-
sessionId: this.config.session.sessionId,
|
|
4116
|
-
messages: this._messages,
|
|
4117
|
-
currentThreadId: this._currentThreadId,
|
|
4118
|
-
lastThreadId: this._lastThreadId,
|
|
4119
|
-
chatCreatedAt: this._chatCreatedAt,
|
|
4120
|
-
panelSnapshots: this._panel?.snapshots ?? /* @__PURE__ */ new Map(),
|
|
4121
|
-
panelThreads: this._panel?.threads ?? [],
|
|
4122
|
-
thumbnailEntries: this._thumbnailEntries,
|
|
4123
|
-
lastBackendContext: this._lastBackendContext,
|
|
4124
|
-
sku: this.config.pageContext?.sku
|
|
4125
|
-
});
|
|
4126
|
-
}
|
|
4127
|
-
_isSameOriginUrl(e) {
|
|
4128
|
-
try {
|
|
4129
|
-
return e.trim() ? new URL(e, window.location.href).origin === window.location.origin : !1;
|
|
4130
|
-
} catch {
|
|
4131
|
-
return !1;
|
|
4132
|
-
}
|
|
4133
|
-
}
|
|
4134
|
-
_markUnavailableProductContext() {
|
|
4135
|
-
this._productContextUnavailableSku = this.config.pageContext?.sku ?? null;
|
|
4136
|
-
}
|
|
4137
|
-
_clearUnavailableProductContext() {
|
|
4138
|
-
this._productContextUnavailableSku = null;
|
|
4139
|
-
}
|
|
4140
|
-
_hasUnavailableProductContext() {
|
|
4141
|
-
const e = this.config.pageContext?.sku;
|
|
4142
|
-
return e !== void 0 && e.length > 0 && this._productContextUnavailableSku === e;
|
|
4143
|
-
}
|
|
4144
|
-
_ensureAssistantMessageRendered(e) {
|
|
4145
|
-
if (!(this._shadow?.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`) || !this._drawer)) {
|
|
4146
|
-
if (e.role === "assistant" && e.threadId && !this._threadsWithFirstBot.has(e.threadId)) {
|
|
4147
|
-
this._threadsWithFirstBot.add(e.threadId), this._drawer.addMessage(e), this._drawer.markFirstBotMessage(e.id);
|
|
4148
|
-
return;
|
|
4149
|
-
}
|
|
4150
|
-
this._drawer.addMessage(e);
|
|
4151
|
-
}
|
|
4152
|
-
}
|
|
4153
|
-
async _saveSessionAndOpenURL(e) {
|
|
4154
|
-
this._session && await this._session.saveAndOpenURL(e, () => this._persistToIndexedDB(), this._bridge);
|
|
4155
|
-
}
|
|
4156
|
-
async _loadPayload(e, t) {
|
|
4157
|
-
return this._session ? this._session.loadPayload(e, t) : null;
|
|
4158
|
-
}
|
|
4159
|
-
/**
|
|
4160
|
-
* Attempt to restore chat session from IndexedDB.
|
|
4161
|
-
* Always restores when IDB has session data for the current sessionId.
|
|
4162
|
-
* Best-effort — failures are silently ignored.
|
|
4163
|
-
*/
|
|
4164
|
-
async _restoreFromIndexedDB(e) {
|
|
4165
|
-
if (!this._session?.db) return;
|
|
4166
|
-
const t = this.config.session?.sessionId;
|
|
4167
|
-
if (!t) return;
|
|
4168
|
-
const a = this.config.session?.userId ?? "", n = this.config.accountId;
|
|
4169
|
-
if (await this._session.loadFavorites(a, n), !e) return;
|
|
4170
|
-
const i = await this._session.db?.loadSession(a, n, t);
|
|
4171
|
-
if (!i || i.messages.length === 0) return;
|
|
4172
|
-
const s = this.config.pageContext?.sku;
|
|
4173
|
-
if (s && i.sku && i.sku !== s) return;
|
|
4174
|
-
if (this._pdpLaunched = !0, this._drawer?.lockScrollForRestore(), this._currentThreadId = i.currentThreadId, this._lastThreadId = i.lastThreadId, this._chatCreatedAt = i.createdAt, i.panelThreads && (this._panel.threads = i.panelThreads), i.thumbnailEntries && (this._thumbnailEntries = i.thumbnailEntries, this._drawer?.setThumbnails(this._thumbnailEntries)), i.panelSnapshotHtml)
|
|
4175
|
-
for (const [d, c] of Object.entries(i.panelSnapshotHtml)) {
|
|
4176
|
-
const g = document.createElement("div");
|
|
4177
|
-
g.innerHTML = G(c), this._panel.snapshots.set(d, g);
|
|
4178
|
-
}
|
|
4179
|
-
let l = 0;
|
|
4180
|
-
for (const d of i.messages) {
|
|
4181
|
-
const c = {
|
|
4182
|
-
id: d.id,
|
|
4183
|
-
role: d.role,
|
|
4184
|
-
timestamp: d.timestamp,
|
|
4185
|
-
status: d.status
|
|
4186
|
-
};
|
|
4187
|
-
if (d.threadId !== void 0 && (c.threadId = d.threadId), d.content !== void 0 && (c.content = d.content), d.silent && (c.silent = !0), this._messages.push(c), c.silent) continue;
|
|
4188
|
-
c.role === "assistant" && c.threadId && !this._threadsWithFirstBot.has(c.threadId) && (this._threadsWithFirstBot.add(c.threadId), this._drawer?.markFirstBotMessage(c.id)), this._drawer?.addMessage(c);
|
|
4189
|
-
const g = parseInt(d.id.replace("msg-", ""), 10);
|
|
4190
|
-
if (!isNaN(g) && g > l && (l = g), c.role === "assistant" && c.threadId) {
|
|
4191
|
-
const r = await this._loadPayload(c.threadId, c.id);
|
|
4192
|
-
r && (c.uiSpec = r, this._restoreInlineUISpec(c), this._panel?.attachClickHandler(c.id), delete c.uiSpec);
|
|
4193
|
-
}
|
|
4194
|
-
}
|
|
4195
|
-
if (l > this._currentMessageId && (this._currentMessageId = l), this._currentThreadId) {
|
|
4196
|
-
let d = await this._session.db?.loadContext(t, this._currentThreadId);
|
|
4197
|
-
d || (d = await this._session.db?.loadLatestContext(t)), d && (this._lastBackendContext = d.context);
|
|
4198
|
-
}
|
|
4199
|
-
if (this._currentThreadId) {
|
|
4200
|
-
const d = [...this._messages].reverse().find((c) => c.role === "assistant" && c.threadId === this._currentThreadId && !c.silent);
|
|
4201
|
-
d && this._panel.snapshots.has(d.id) && this._panel?.restoreForMessage(d.id);
|
|
4202
|
-
}
|
|
4203
|
-
if (this._currentThreadId) {
|
|
4204
|
-
const d = this._currentThreadId;
|
|
4205
|
-
for (const c of this._messages)
|
|
4206
|
-
c.threadId && c.threadId > d && this._shadow?.querySelector(`[data-message-id="${CSS.escape(c.id)}"]`)?.classList.add("gengage-chat-bubble--hidden");
|
|
4207
|
-
this._shadow?.querySelectorAll("[data-thread-id]").forEach((c) => {
|
|
4208
|
-
c instanceof HTMLElement && c.dataset.threadId && c.dataset.threadId > d && c.classList.add("gengage-chat-bubble--hidden");
|
|
4209
|
-
});
|
|
4210
|
-
}
|
|
4211
|
-
if (this._panel.threads.length > 0 && this._currentThreadId) {
|
|
4212
|
-
const d = this._panel.threads[this._panel.threads.length - 1];
|
|
4213
|
-
if (d) {
|
|
4214
|
-
const c = [...this._messages].reverse().find((g) => g.role === "assistant" && g.threadId === d);
|
|
4215
|
-
if (c?.threadId) {
|
|
4216
|
-
const g = await this._loadPayload(c.threadId, c.id);
|
|
4217
|
-
if (g) {
|
|
4218
|
-
const r = g.elements[g.root];
|
|
4219
|
-
r && this._panel?.updateTopBar(r.type);
|
|
4220
|
-
}
|
|
4221
|
-
}
|
|
4222
|
-
}
|
|
4223
|
-
}
|
|
4224
|
-
setTimeout(() => {
|
|
4225
|
-
this._drawer?.scrollToLastThread();
|
|
4226
|
-
}, 550);
|
|
4227
|
-
}
|
|
4228
|
-
/**
|
|
4229
|
-
* Toggle comparison mode or individual SKU selection, then refresh the DOM.
|
|
4230
|
-
* Extracted so both the render-context callback and DOM-created checkboxes
|
|
4231
|
-
* share the same state-mutation + refresh path.
|
|
4232
|
-
*/
|
|
4233
|
-
_toggleComparisonSku(e) {
|
|
4234
|
-
e === "" ? (this._comparisonSelectMode = !this._comparisonSelectMode, this._comparisonSelectMode || (this._comparisonSelectedSkus = [], Ze())) : this._comparisonSelectedSkus.indexOf(e) >= 0 ? this._comparisonSelectedSkus = this._comparisonSelectedSkus.filter((a) => a !== e) : (this._comparisonSelectedSkus = [...this._comparisonSelectedSkus, e], et(e)), this._refreshComparisonUI();
|
|
4235
|
-
}
|
|
4236
|
-
/**
|
|
4237
|
-
* Refresh the panel DOM to reflect the current comparison state without
|
|
4238
|
-
* full re-render. Updates: toggle button active class, checkbox overlays
|
|
4239
|
-
* on product cards, and the floating comparison button.
|
|
4240
|
-
*/
|
|
4241
|
-
_refreshComparisonUI() {
|
|
4242
|
-
const e = this._shadow?.querySelector(".gengage-chat-panel");
|
|
4243
|
-
if (!e) return;
|
|
4244
|
-
const t = e.querySelector(".gengage-chat-product-grid-wrapper");
|
|
4245
|
-
if (!t) return;
|
|
4246
|
-
const a = t.querySelector(".gengage-chat-product-grid");
|
|
4247
|
-
if (!a) return;
|
|
4248
|
-
const n = t.querySelector(".gengage-chat-comparison-toggle-btn");
|
|
4249
|
-
if (n && n.classList.toggle("gengage-chat-comparison-toggle-btn--active", this._comparisonSelectMode), this._comparisonSelectMode) {
|
|
4250
|
-
const s = a.querySelectorAll(".gengage-chat-product-card[data-sku]");
|
|
4251
|
-
for (const l of s) {
|
|
4252
|
-
if (l.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")) {
|
|
4253
|
-
const r = l.parentElement.querySelector(".gengage-chat-comparison-checkbox");
|
|
4254
|
-
r && (r.checked = this._comparisonSelectedSkus.includes(l.dataset.sku));
|
|
4255
|
-
continue;
|
|
4256
|
-
}
|
|
4257
|
-
const d = l.dataset.sku, c = document.createElement("div");
|
|
4258
|
-
c.className = "gengage-chat-comparison-select-wrapper";
|
|
4259
|
-
const g = document.createElement("input");
|
|
4260
|
-
g.type = "checkbox", g.className = "gengage-chat-comparison-checkbox", g.checked = this._comparisonSelectedSkus.includes(d), g.addEventListener("change", () => {
|
|
4261
|
-
this._toggleComparisonSku(d);
|
|
4262
|
-
}), l.parentNode.insertBefore(c, l), c.appendChild(g), c.appendChild(l), c.style.cursor = "pointer", c.addEventListener("click", (r) => {
|
|
4263
|
-
r.target !== g && (g.checked = !g.checked, this._toggleComparisonSku(d));
|
|
4264
|
-
});
|
|
4265
|
-
}
|
|
4266
|
-
} else {
|
|
4267
|
-
const s = a.querySelectorAll(".gengage-chat-comparison-select-wrapper");
|
|
4268
|
-
for (const l of s) {
|
|
4269
|
-
const d = l.querySelector(".gengage-chat-product-card");
|
|
4270
|
-
d && l.parentNode && (l.parentNode.insertBefore(d, l), l.remove());
|
|
4271
|
-
}
|
|
4272
|
-
}
|
|
4273
|
-
const i = t.querySelector(".gengage-chat-comparison-floating-btn");
|
|
4274
|
-
if (this._comparisonSelectMode) {
|
|
4275
|
-
const s = this._comparisonSelectedSkus.length, l = s >= 2, d = this._i18n.compareSelected ?? "Compare", c = l ? `${d} (${s})` : this._i18n.compareMinHint ?? "Select at least 2 products";
|
|
4276
|
-
if (i)
|
|
4277
|
-
i.textContent = c, i.disabled = !l, i.classList.toggle("gengage-chat-comparison-floating-btn--disabled", !l);
|
|
4278
|
-
else {
|
|
4279
|
-
const g = document.createElement("button");
|
|
4280
|
-
g.className = "gengage-chat-comparison-floating-btn", g.type = "button", g.textContent = c, g.disabled = !l, l || g.classList.add("gengage-chat-comparison-floating-btn--disabled"), g.addEventListener("click", () => {
|
|
4281
|
-
this._comparisonSelectedSkus.length < 2 || (be(this._comparisonSelectedSkus), this._sendAction({
|
|
4282
|
-
title: d,
|
|
4283
|
-
type: "getComparisonTable",
|
|
4284
|
-
payload: { sku_list: [...this._comparisonSelectedSkus] }
|
|
4285
|
-
}));
|
|
4286
|
-
}), t.appendChild(g);
|
|
4287
|
-
}
|
|
4288
|
-
} else
|
|
4289
|
-
i?.remove();
|
|
4290
|
-
}
|
|
4291
|
-
/**
|
|
4292
|
-
* Build a ChatUISpecRenderContext with all callbacks wired up.
|
|
4293
|
-
* Used both during streaming and during session restore.
|
|
4294
|
-
*/
|
|
4295
|
-
_buildRenderContext() {
|
|
4296
|
-
const e = {
|
|
4297
|
-
onAction: (t) => {
|
|
4298
|
-
if (ot(t.title, t.type), t.type === "findSimilar") {
|
|
4299
|
-
const n = typeof t.payload == "object" && t.payload !== null && "sku" in t.payload ? String(t.payload.sku) : "";
|
|
4300
|
-
rt(n);
|
|
4301
|
-
}
|
|
4302
|
-
t.type === "getComparisonTable" && be(this._comparisonSelectedSkus);
|
|
4303
|
-
const a = t.type === "addToCart" || t.type === "like";
|
|
4304
|
-
this._sendAction(t, a ? { preservePanel: !0 } : void 0);
|
|
4305
|
-
},
|
|
4306
|
-
onProductClick: (t) => {
|
|
4307
|
-
it(t.sku), this.config.isDemoWebsite !== !0 && this._isSameOriginUrl(t.url) ? (W("gengage:similar:product-click", {
|
|
4308
|
-
sku: t.sku,
|
|
4309
|
-
url: t.url,
|
|
4310
|
-
sessionId: this.config.session?.sessionId ?? null
|
|
4311
|
-
}), this._saveSessionAndOpenURL(t.url)) : this._sendAction({
|
|
4312
|
-
title: t.sku,
|
|
4313
|
-
type: "launchSingleProduct",
|
|
4314
|
-
payload: { sku: t.sku }
|
|
4315
|
-
});
|
|
4316
|
-
},
|
|
4317
|
-
onAddToCart: (t) => {
|
|
4318
|
-
nt(t.sku, t.quantity);
|
|
4319
|
-
const a = {
|
|
4320
|
-
...t,
|
|
4321
|
-
sessionId: this.config.session?.sessionId ?? null
|
|
4322
|
-
};
|
|
4323
|
-
W("gengage:chat:add-to-cart", a), this._bridge?.send("addToCart", t), this._runEventCallbacks("gengage-cart-add", a), this._sendAction(
|
|
4324
|
-
{
|
|
4325
|
-
title: this._i18n.addToCartButton ?? "Add to Cart",
|
|
4326
|
-
type: "addToCart",
|
|
4327
|
-
payload: { sku: t.sku, cart_code: t.cartCode, quantity: t.quantity }
|
|
4328
|
-
},
|
|
4329
|
-
{ preservePanel: !0 }
|
|
4330
|
-
);
|
|
4331
|
-
},
|
|
4332
|
-
onProductSelect: (t) => {
|
|
4333
|
-
const a = {
|
|
4334
|
-
root: "root",
|
|
4335
|
-
elements: {
|
|
4336
|
-
root: {
|
|
4337
|
-
type: "ProductDetailsPanel",
|
|
4338
|
-
props: { product: t }
|
|
4339
|
-
}
|
|
4340
|
-
}
|
|
4341
|
-
};
|
|
4342
|
-
this._drawer?.setPanelContent(this._renderUISpec(a, e));
|
|
4343
|
-
},
|
|
4344
|
-
i18n: this._i18n,
|
|
4345
|
-
pricing: this.config.pricing,
|
|
4346
|
-
productSort: this._productSort,
|
|
4347
|
-
onSortChange: (t) => {
|
|
4348
|
-
this._productSort = t;
|
|
4349
|
-
},
|
|
4350
|
-
comparisonSelectMode: this._comparisonSelectMode,
|
|
4351
|
-
comparisonSelectedSkus: this._comparisonSelectedSkus,
|
|
4352
|
-
onToggleComparisonSku: (t) => {
|
|
4353
|
-
this._toggleComparisonSku(t);
|
|
4354
|
-
},
|
|
4355
|
-
favoritedSkus: this._session?.favoritedSkus ?? /* @__PURE__ */ new Set(),
|
|
4356
|
-
onFavoriteToggle: (t, a) => {
|
|
4357
|
-
at(t), this._toggleFavorite(t, a);
|
|
4358
|
-
const n = a.name ?? t;
|
|
4359
|
-
this._sendAction(
|
|
4360
|
-
{
|
|
4361
|
-
title: n,
|
|
4362
|
-
type: "like",
|
|
4363
|
-
payload: { sku: t }
|
|
4364
|
-
},
|
|
4365
|
-
{ preservePanel: !0 }
|
|
4366
|
-
);
|
|
4367
|
-
}
|
|
4368
|
-
};
|
|
4369
|
-
return e;
|
|
4370
|
-
}
|
|
4371
|
-
async _toggleFavorite(e, t) {
|
|
4372
|
-
if (!this._session) return;
|
|
4373
|
-
const a = this.config.session?.userId ?? "", n = this.config.accountId;
|
|
4374
|
-
await this._session.toggleFavorite(a, n, e, t);
|
|
4375
|
-
}
|
|
4376
|
-
/**
|
|
4377
|
-
* Run registered callbacks for a GA4 event.
|
|
4378
|
-
* If any callback returns false or throws, handle the failure (e.g. show error for cart-add).
|
|
4379
|
-
*/
|
|
4380
|
-
async _runEventCallbacks(e, t) {
|
|
4381
|
-
const a = this._eventCallbacks.get(e);
|
|
4382
|
-
if (!(!a || a.size === 0))
|
|
4383
|
-
for (const n of a)
|
|
4384
|
-
try {
|
|
4385
|
-
const i = n(t);
|
|
4386
|
-
if ((i instanceof Promise ? await i : i) === !1) {
|
|
4387
|
-
this._handleCallbackFailure(e, t);
|
|
4388
|
-
return;
|
|
4389
|
-
}
|
|
4390
|
-
} catch {
|
|
4391
|
-
this._handleCallbackFailure(e, t);
|
|
4392
|
-
return;
|
|
4393
|
-
}
|
|
4394
|
-
}
|
|
4395
|
-
/**
|
|
4396
|
-
* Handle a callback failure — for add-to-cart, show an error message in chat.
|
|
4397
|
-
*/
|
|
4398
|
-
_handleCallbackFailure(e, t) {
|
|
4399
|
-
if (e === "gengage-cart-add") {
|
|
4400
|
-
const a = this._i18n.cartAddErrorMessage, n = this._createMessage("assistant", a);
|
|
4401
|
-
this._currentThreadId && (n.threadId = this._currentThreadId), this._messages.push(n), this._drawer?.addMessage(n);
|
|
4402
|
-
}
|
|
4403
|
-
}
|
|
4404
|
-
/**
|
|
4405
|
-
* Re-render inline UISpec elements for a restored bot message.
|
|
4406
|
-
* Inserts them into the messages container after the message bubble.
|
|
4407
|
-
*/
|
|
4408
|
-
_restoreInlineUISpec(e) {
|
|
4409
|
-
if (!e.uiSpec || !this._drawer) return;
|
|
4410
|
-
const t = e.uiSpec, a = t.elements[t.root];
|
|
4411
|
-
if (!a) return;
|
|
4412
|
-
const n = a.type;
|
|
4413
|
-
if (n === "ActionButtons" || n === "ComparisonTable" || n === "ProductGrid" && a.props?.similarsAppend === !0) return;
|
|
4414
|
-
const i = this._buildRenderContext(), s = this._shadow?.querySelector(".gengage-chat-messages");
|
|
4415
|
-
if (!s) return;
|
|
4416
|
-
if (n === "ProductDetailsPanel") {
|
|
4417
|
-
const d = a.props?.product;
|
|
4418
|
-
if (!d) return;
|
|
4419
|
-
const c = {
|
|
4420
|
-
root: "root",
|
|
4421
|
-
elements: { root: { type: "ProductSummaryCard", props: { product: d } } }
|
|
4422
|
-
}, g = this._renderUISpec(c, i);
|
|
4423
|
-
e.threadId && (g.dataset.threadId = e.threadId), s.appendChild(g);
|
|
4424
|
-
return;
|
|
4425
|
-
}
|
|
4426
|
-
const l = this._renderUISpec(t, i);
|
|
4427
|
-
e.threadId && (l.dataset.threadId = e.threadId), s.appendChild(l);
|
|
4428
|
-
}
|
|
4429
|
-
_createMessage(e, t) {
|
|
4430
|
-
return this._currentMessageId++, {
|
|
4431
|
-
id: `msg-${this._currentMessageId}`,
|
|
4432
|
-
role: e,
|
|
4433
|
-
content: t,
|
|
4434
|
-
timestamp: Date.now(),
|
|
4435
|
-
status: "done"
|
|
4436
|
-
};
|
|
4437
|
-
}
|
|
4438
|
-
_resolveI18n(e) {
|
|
4439
|
-
return { ...Bt(e.locale), ...e.i18n };
|
|
4440
|
-
}
|
|
4441
|
-
_resolveUISpecRegistry() {
|
|
4442
|
-
const e = ua();
|
|
4443
|
-
return tt(e, this.config.renderer?.registry);
|
|
4444
|
-
}
|
|
4445
|
-
_renderUISpec(e, t) {
|
|
4446
|
-
const a = this._resolveUISpecRegistry(), n = this.config.renderer?.unknownRenderer ?? Re, i = (d, c) => ma(d, c, a, n), s = this.config.renderer?.renderUISpec;
|
|
4447
|
-
return s ? s(e, t, {
|
|
4448
|
-
registry: a,
|
|
4449
|
-
unknownRenderer: n,
|
|
4450
|
-
defaultRender: i
|
|
4451
|
-
}) : i(e, t);
|
|
4452
|
-
}
|
|
4453
|
-
}
|
|
4454
|
-
function kn() {
|
|
4455
|
-
return new vn();
|
|
4456
|
-
}
|
|
4457
|
-
export {
|
|
4458
|
-
vn as G,
|
|
4459
|
-
Rt as V,
|
|
4460
|
-
ua as a,
|
|
4461
|
-
ma as b,
|
|
4462
|
-
kn as c,
|
|
4463
|
-
Re as d,
|
|
4464
|
-
_n as e,
|
|
4465
|
-
zt as i,
|
|
4466
|
-
_t as r
|
|
4467
|
-
};
|
|
4468
|
-
//# sourceMappingURL=index-BHaQLt-o.js.map
|