@gengage/assistant-fe 0.1.8 → 0.1.9
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/README.md +79 -286
- package/dist/assistant-fe.css +1 -1
- package/dist/chat/api.d.ts +1 -12
- package/dist/chat/api.d.ts.map +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +15 -1
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
- package/dist/chat/components/ChoicePrompter.d.ts +1 -0
- package/dist/chat/components/ChoicePrompter.d.ts.map +1 -1
- package/dist/chat/components/ComparisonTable.d.ts +5 -3
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
- package/dist/chat/components/PanelTopBar.d.ts +2 -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 +3 -0
- package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
- package/dist/chat/components/renderUISpec.d.ts +0 -5
- package/dist/chat/components/renderUISpec.d.ts.map +1 -1
- package/dist/chat/index.d.ts +18 -9
- 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/session-persistence.d.ts +3 -0
- package/dist/chat/session-persistence.d.ts.map +1 -1
- package/dist/chat/types.d.ts +23 -25
- package/dist/chat/types.d.ts.map +1 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +24 -24
- package/dist/chat.iife.js.map +1 -1
- package/dist/chat.js +8 -9
- package/dist/chat.js.map +1 -1
- package/dist/common/action-router.d.ts.map +1 -1
- package/dist/common/activity-tracker.d.ts +1 -1
- package/dist/common/analytics.d.ts +12 -8
- package/dist/common/analytics.d.ts.map +1 -1
- package/dist/common/api-paths.d.ts +2 -5
- package/dist/common/api-paths.d.ts.map +1 -1
- package/dist/common/config-schema.d.ts.map +1 -1
- package/dist/common/debug.d.ts +14 -0
- package/dist/common/debug.d.ts.map +1 -0
- package/dist/common/events.d.ts.map +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/overlay.d.ts +19 -0
- package/dist/common/overlay.d.ts.map +1 -1
- package/dist/common/{v1-protocol-adapter.d.ts → protocol-adapter.d.ts} +2 -2
- package/dist/common/protocol-adapter.d.ts.map +1 -0
- package/dist/common/quantity-stepper.d.ts +10 -10
- package/dist/common/quantity-stepper.d.ts.map +1 -1
- package/dist/common/safe-html.d.ts.map +1 -1
- package/dist/common/streaming.d.ts.map +1 -1
- package/dist/common/tts-player.d.ts +2 -0
- package/dist/common/tts-player.d.ts.map +1 -1
- package/dist/common/types.d.ts +1 -1
- package/dist/common/voice-input.d.ts +1 -0
- package/dist/common/voice-input.d.ts.map +1 -1
- package/dist/common/widget-base.d.ts.map +1 -1
- package/dist/common.cjs +1 -1
- package/dist/common.cjs.map +1 -1
- package/dist/common.js +173 -172
- package/dist/common.js.map +1 -1
- package/dist/index-BWPx4pM7.cjs +13 -0
- package/dist/index-BWPx4pM7.cjs.map +1 -0
- package/dist/index-CEt87kCd.js +4463 -0
- package/dist/index-CEt87kCd.js.map +1 -0
- package/dist/index-DL4CAkyL.cjs +2 -0
- package/dist/index-DL4CAkyL.cjs.map +1 -0
- package/dist/{index-CcOJTzYu.js → index-DR2uepzb.js} +108 -106
- package/dist/index-DR2uepzb.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +16 -16
- package/dist/native.cjs +1 -1
- package/dist/native.iife.js +18 -18
- package/dist/native.iife.js.map +1 -1
- package/dist/native.js +1 -1
- package/dist/qna/index.d.ts +19 -0
- package/dist/qna/index.d.ts.map +1 -1
- package/dist/qna/types.d.ts +2 -2
- package/dist/qna/types.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 +7 -7
- package/dist/qna.iife.js.map +1 -1
- package/dist/qna.js +14 -14
- package/dist/qna.js.map +1 -1
- package/dist/quantity-stepper-C-nV4lwi.js +77 -0
- package/dist/quantity-stepper-C-nV4lwi.js.map +1 -0
- package/dist/quantity-stepper-CURMkwRF.cjs +2 -0
- package/dist/quantity-stepper-CURMkwRF.cjs.map +1 -0
- package/dist/{schemas-yF4IOEUi.js → schemas-DIhL3DkL.js} +1166 -947
- package/dist/schemas-DIhL3DkL.js.map +1 -0
- package/dist/schemas-Dsr0bbO_.cjs +86 -0
- package/dist/schemas-Dsr0bbO_.cjs.map +1 -0
- package/dist/simrel/api.d.ts +1 -1
- package/dist/simrel/api.d.ts.map +1 -1
- package/dist/simrel/components/GroupTabs.d.ts +1 -1
- package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
- package/dist/simrel/components/ProductCard.d.ts +1 -1
- package/dist/simrel/components/ProductCard.d.ts.map +1 -1
- package/dist/simrel/components/ProductGrid.d.ts +1 -1
- package/dist/simrel/components/ProductGrid.d.ts.map +1 -1
- package/dist/simrel/index.d.ts +20 -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 +1 -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 +123 -111
- package/dist/simrel.js.map +1 -1
- package/package.json +1 -1
- package/dist/chat/components/ProactivePopup.d.ts +0 -20
- package/dist/chat/components/ProactivePopup.d.ts.map +0 -1
- package/dist/chat/heartbeat.d.ts +0 -71
- package/dist/chat/heartbeat.d.ts.map +0 -1
- package/dist/common/v1-protocol-adapter.d.ts.map +0 -1
- package/dist/index-BqIzV4ni.cjs +0 -2
- package/dist/index-BqIzV4ni.cjs.map +0 -1
- package/dist/index-CcOJTzYu.js.map +0 -1
- package/dist/index-DZ3Mi5xF.cjs +0 -13
- package/dist/index-DZ3Mi5xF.cjs.map +0 -1
- package/dist/index-FnP8WtfG.js +0 -4571
- package/dist/index-FnP8WtfG.js.map +0 -1
- package/dist/quantity-stepper-B8kX8GbN.js +0 -209
- package/dist/quantity-stepper-B8kX8GbN.js.map +0 -1
- package/dist/quantity-stepper-UbAp53Ow.cjs +0 -2
- package/dist/quantity-stepper-UbAp53Ow.cjs.map +0 -1
- package/dist/schemas-DHzfUzwA.cjs +0 -86
- package/dist/schemas-DHzfUzwA.cjs.map +0 -1
- package/dist/schemas-yF4IOEUi.js.map +0 -1
|
@@ -0,0 +1,4463 @@
|
|
|
1
|
+
import { D as Re, E as H, b as De, c as Fe, a as Ue, v as $, x as G, F as U, r as qe, o as B, s as w, f as D, G as te, d as re, u as se, y as Q, e as Y, _ as we, B as He, H as Oe, j as V, t as je, i as Ve, I as We, J as $e, g as Ge, K as Ye, L as Ke, M as de, m as Qe, N as Xe, A as Je, z as Ze, n as et, O as tt, P as pe, h as at, Q as nt, R as it, l as ot, S as rt, T as st, U as ct, V as lt, W as gt, X as dt } from "./schemas-DIhL3DkL.js";
|
|
2
|
+
import { f as q, c as ce, a as X, r as ye, d as _e, b as ke } from "./quantity-stepper-C-nV4lwi.js";
|
|
3
|
+
function pt() {
|
|
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 ht {
|
|
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 (!ut(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 ut(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 mt = console;
|
|
66
|
+
function ft(o, e, t = {}) {
|
|
67
|
+
const a = o.action, n = t.logger ?? mt;
|
|
68
|
+
switch (Re("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
|
+
J(a, e, t, n);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const i = typeof a.newTab == "boolean" ? a.newTab : void 0;
|
|
79
|
+
if (e.navigate) {
|
|
80
|
+
i !== void 0 ? e.navigate({ url: a.url, newTab: i }) : e.navigate({ url: a.url });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
bt(a.url, i);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
case "save_session": {
|
|
87
|
+
if (typeof a.sessionId != "string" || typeof a.sku != "string") {
|
|
88
|
+
J(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
|
+
J(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
|
+
J(a, e, t, n);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (typeof a.name != "string") {
|
|
112
|
+
J(a, e, t, n);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const i = xt(a.payload) ? a.payload : void 0;
|
|
116
|
+
i !== void 0 ? e.scriptCall?.({ name: a.name, payload: i }) : e.scriptCall?.({ name: a.name });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
default:
|
|
120
|
+
J(a, e, t, n);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function J(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 bt(o, e) {
|
|
134
|
+
if (!(typeof window > "u")) {
|
|
135
|
+
if (!H(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 xt(o) {
|
|
147
|
+
return typeof o == "object" && o !== null && !Array.isArray(o);
|
|
148
|
+
}
|
|
149
|
+
const vt = ["image/jpeg", "image/png", "image/webp"], wt = 5 * 1024 * 1024;
|
|
150
|
+
function yt(o) {
|
|
151
|
+
return vt.includes(o.type) ? o.size > wt ? { ok: !1, reason: "too_large" } : { ok: !0 } : { ok: !1, reason: "invalid_type" };
|
|
152
|
+
}
|
|
153
|
+
function _t(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, r] of Object.entries(i))
|
|
157
|
+
l in s || (s[l] = r);
|
|
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 kt = {
|
|
188
|
+
user_message: "inputText"
|
|
189
|
+
};
|
|
190
|
+
function Ct(o) {
|
|
191
|
+
const { action: e, type: t, payload: a, ...n } = o, i = t ?? e?.type ?? "inputText", s = a ?? e?.payload, l = kt[i] ?? i, r = {
|
|
192
|
+
...n,
|
|
193
|
+
type: l
|
|
194
|
+
};
|
|
195
|
+
return s !== void 0 && (r.payload = typeof s == "string" ? { text: s } : s), JSON.stringify(r);
|
|
196
|
+
}
|
|
197
|
+
function Et(o, e, t) {
|
|
198
|
+
const a = De("process_action", t), n = new AbortController();
|
|
199
|
+
return (async () => {
|
|
200
|
+
try {
|
|
201
|
+
const s = Ct(o), l = t.attachment !== void 0;
|
|
202
|
+
let r;
|
|
203
|
+
if (l) {
|
|
204
|
+
const m = new FormData();
|
|
205
|
+
m.append("request", s), t.attachment !== void 0 && m.append("attachment", t.attachment), r = {
|
|
206
|
+
method: "POST",
|
|
207
|
+
body: m,
|
|
208
|
+
signal: n.signal
|
|
209
|
+
};
|
|
210
|
+
} else
|
|
211
|
+
r = {
|
|
212
|
+
method: "POST",
|
|
213
|
+
headers: { "Content-Type": "application/json" },
|
|
214
|
+
body: s,
|
|
215
|
+
signal: n.signal
|
|
216
|
+
};
|
|
217
|
+
const c = await fetch(a, r);
|
|
218
|
+
if (!c.ok) {
|
|
219
|
+
let m = c.statusText;
|
|
220
|
+
try {
|
|
221
|
+
const p = await c.json(), y = p.detail ?? p.message ?? p.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 d = () => {
|
|
230
|
+
g || (g = !0, e.onDone());
|
|
231
|
+
};
|
|
232
|
+
await Fe(c, {
|
|
233
|
+
onEvent: (m) => {
|
|
234
|
+
const p = Ue(m);
|
|
235
|
+
if (p)
|
|
236
|
+
switch (p.type) {
|
|
237
|
+
case "text_chunk":
|
|
238
|
+
e.onTextChunk(p.content, p.final === !0, {
|
|
239
|
+
productMentions: p.productMentions,
|
|
240
|
+
skuToProductItem: p.skuToProductItem,
|
|
241
|
+
conversationMode: p.conversationMode
|
|
242
|
+
});
|
|
243
|
+
break;
|
|
244
|
+
case "ui_spec":
|
|
245
|
+
e.onUISpec(p.spec, p.widget, p.panelHint);
|
|
246
|
+
break;
|
|
247
|
+
case "action":
|
|
248
|
+
e.onAction(p);
|
|
249
|
+
break;
|
|
250
|
+
case "metadata":
|
|
251
|
+
e.onMetadata(p);
|
|
252
|
+
break;
|
|
253
|
+
case "error":
|
|
254
|
+
e.onError(new Error(p.message));
|
|
255
|
+
break;
|
|
256
|
+
case "done":
|
|
257
|
+
d();
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
onError: e.onError,
|
|
262
|
+
signal: n.signal
|
|
263
|
+
}), d();
|
|
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 le = {
|
|
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
|
+
}, St = {
|
|
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 Tt(o) {
|
|
434
|
+
return o ? o.toLowerCase().split("-")[0] ?? "tr" : "tr";
|
|
435
|
+
}
|
|
436
|
+
function Lt(o) {
|
|
437
|
+
return Tt(o) === "en" ? St : le;
|
|
438
|
+
}
|
|
439
|
+
function It() {
|
|
440
|
+
return Ce() !== null;
|
|
441
|
+
}
|
|
442
|
+
function Ce() {
|
|
443
|
+
const o = globalThis;
|
|
444
|
+
return o.SpeechRecognition ?? o.webkitSpeechRecognition ?? null;
|
|
445
|
+
}
|
|
446
|
+
class At {
|
|
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 = Ce();
|
|
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 r = l[0];
|
|
478
|
+
r && (l.isFinal ? i += r.transcript : n += r.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 = Nt(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 Nt(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 Pt(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 = $(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 Mt {
|
|
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 Bt {
|
|
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, G(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 he = {
|
|
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
|
+
}, zt = le;
|
|
621
|
+
class Rt {
|
|
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 = { ...zt, ...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 f = document.createElement("img");
|
|
629
|
+
f.className = "gengage-chat-header-avatar", f.src = t.headerAvatarUrl, f.alt = t.headerTitle ?? "Assistant", n.appendChild(f);
|
|
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 f = document.createElement("span");
|
|
638
|
+
f.className = "gengage-chat-header-badge", f.textContent = t.headerBadge, s.appendChild(f);
|
|
639
|
+
}
|
|
640
|
+
i.appendChild(s);
|
|
641
|
+
const r = document.createElement("a");
|
|
642
|
+
r.className = "gengage-chat-header-powered", r.href = "https://gengage.ai/", r.target = "_blank", r.rel = "noopener noreferrer", r.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(r), n.appendChild(i), a.appendChild(n);
|
|
643
|
+
const c = document.createElement("div");
|
|
644
|
+
if (c.className = "gengage-chat-header-right", t.headerCartUrl) {
|
|
645
|
+
const f = document.createElement("a");
|
|
646
|
+
f.className = "gengage-chat-header-btn", U(f, "href", t.headerCartUrl), f.target = "_blank", f.rel = "noopener noreferrer", f.setAttribute("aria-label", this.i18n.cartAriaLabel), f.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(f);
|
|
647
|
+
}
|
|
648
|
+
if (t.headerFavoritesToggle) {
|
|
649
|
+
const f = document.createElement("button");
|
|
650
|
+
f.className = "gengage-chat-header-btn", f.type = "button", f.setAttribute("aria-label", this.i18n.favoritesAriaLabel), f.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>', f.addEventListener("click", () => t.onFavoritesClick?.()), c.appendChild(f);
|
|
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 f = null, C = 0;
|
|
656
|
+
const M = 80;
|
|
657
|
+
a.addEventListener(
|
|
658
|
+
"touchstart",
|
|
659
|
+
(F) => {
|
|
660
|
+
if (window.innerWidth > 768) return;
|
|
661
|
+
const R = F.changedTouches?.[0];
|
|
662
|
+
R && (f = R.clientY, C = 0, this.root.style.transition = "none");
|
|
663
|
+
},
|
|
664
|
+
{ passive: !0 }
|
|
665
|
+
), a.addEventListener(
|
|
666
|
+
"touchmove",
|
|
667
|
+
(F) => {
|
|
668
|
+
if (f === null) return;
|
|
669
|
+
const R = F.changedTouches?.[0];
|
|
670
|
+
R && (C = Math.max(0, R.clientY - f), this.root.style.transform = `translateY(${C}px)`, this.root.style.opacity = String(1 - C / 300));
|
|
671
|
+
},
|
|
672
|
+
{ passive: !0 }
|
|
673
|
+
), a.addEventListener(
|
|
674
|
+
"touchend",
|
|
675
|
+
() => {
|
|
676
|
+
f !== null && (f = null, this.root.style.transition = "", C >= M && t.onClose(), this.root.style.transform = "", this.root.style.opacity = "", C = 0);
|
|
677
|
+
},
|
|
678
|
+
{ passive: !0 }
|
|
679
|
+
), a.addEventListener(
|
|
680
|
+
"touchcancel",
|
|
681
|
+
() => {
|
|
682
|
+
f !== null && (f = null, this.root.style.transition = "", this.root.style.transform = "", this.root.style.opacity = "", C = 0);
|
|
683
|
+
},
|
|
684
|
+
{ passive: !0 }
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
const d = document.createElement("div");
|
|
688
|
+
d.className = "gengage-chat-body", this._panelEl = document.createElement("div"), this._panelEl.className = "gengage-chat-panel", this._panelTopBar = new Mt({
|
|
689
|
+
onBack: () => t.onPanelBack?.(),
|
|
690
|
+
onForward: () => t.onPanelForward?.(),
|
|
691
|
+
backAriaLabel: this.i18n.backAriaLabel,
|
|
692
|
+
forwardAriaLabel: this.i18n.forwardAriaLabel
|
|
693
|
+
}), this._panelEl.appendChild(this._panelTopBar.getElement()), d.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);
|
|
694
|
+
const m = document.createElement("button");
|
|
695
|
+
m.className = "gengage-chat-panel-divider-toggle", m.type = "button", m.setAttribute("aria-label", this.i18n.togglePanelAriaLabel), m.textContent = "»", m.addEventListener("click", () => {
|
|
696
|
+
if (this._ignoreNextDividerClick) {
|
|
697
|
+
this._ignoreNextDividerClick = !1;
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
this.togglePanel(), this._onPanelToggle?.();
|
|
701
|
+
});
|
|
702
|
+
let p = null, y = null;
|
|
703
|
+
const _ = 24;
|
|
704
|
+
this._dividerEl.addEventListener(
|
|
705
|
+
"touchstart",
|
|
706
|
+
(f) => {
|
|
707
|
+
if (window.innerWidth > 768) return;
|
|
708
|
+
const C = f.changedTouches?.[0];
|
|
709
|
+
C && (p = C.clientX, y = C.clientY);
|
|
710
|
+
},
|
|
711
|
+
{ passive: !0 }
|
|
712
|
+
), this._dividerEl.addEventListener(
|
|
713
|
+
"touchend",
|
|
714
|
+
(f) => {
|
|
715
|
+
if (window.innerWidth > 768 || p === null || y === null) return;
|
|
716
|
+
const C = f.changedTouches?.[0];
|
|
717
|
+
if (!C) return;
|
|
718
|
+
const M = C.clientX - p, F = C.clientY - y;
|
|
719
|
+
if (p = null, y = null, Math.abs(F) < _ || Math.abs(F) < Math.abs(M)) return;
|
|
720
|
+
const R = F < 0;
|
|
721
|
+
R !== this._panelCollapsed && (this._ignoreNextDividerClick = !0, this.setPanelCollapsed(R), this._onPanelToggle?.());
|
|
722
|
+
},
|
|
723
|
+
{ passive: !0 }
|
|
724
|
+
), this._dividerEl.appendChild(m), d.appendChild(this._dividerEl);
|
|
725
|
+
const x = document.createElement("div");
|
|
726
|
+
x.className = "gengage-chat-conversation", x.appendChild(a);
|
|
727
|
+
const E = document.createElement("div");
|
|
728
|
+
E.className = "gengage-chat-offline-bar", E.setAttribute("role", "status"), E.setAttribute("aria-live", "polite"), E.textContent = this.i18n.offlineMessage, typeof navigator < "u" && !navigator.onLine && E.classList.add("gengage-chat-offline-bar--visible"), x.appendChild(E);
|
|
729
|
+
const I = () => E.classList.add("gengage-chat-offline-bar--visible"), S = () => E.classList.remove("gengage-chat-offline-bar--visible");
|
|
730
|
+
window.addEventListener("offline", I), window.addEventListener("online", S), this._cleanups.push(() => {
|
|
731
|
+
window.removeEventListener("offline", I), window.removeEventListener("online", S);
|
|
732
|
+
}), this._kvkkSlot = document.createElement("div"), this._kvkkSlot.className = "gengage-chat-kvkk-slot", x.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);
|
|
733
|
+
let v = !1;
|
|
734
|
+
this.messagesEl.addEventListener(
|
|
735
|
+
"scroll",
|
|
736
|
+
() => {
|
|
737
|
+
v || (v = !0, requestAnimationFrame(() => {
|
|
738
|
+
v = !1;
|
|
739
|
+
const { scrollTop: f, scrollHeight: C, clientHeight: M } = this.messagesEl;
|
|
740
|
+
this._userScrolledUp = C - f - M > 10;
|
|
741
|
+
}));
|
|
742
|
+
},
|
|
743
|
+
{ passive: !0 }
|
|
744
|
+
), x.appendChild(this.messagesEl), this._thumbnailsColumn = new Bt({
|
|
745
|
+
onThumbnailClick: (f) => t.onThumbnailClick?.(f)
|
|
746
|
+
}), 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";
|
|
747
|
+
const h = document.createElement("div");
|
|
748
|
+
h.className = "gengage-chat-pills-scroll", this._pillsEl.appendChild(h);
|
|
749
|
+
const L = document.createElement("button");
|
|
750
|
+
L.className = "gengage-chat-pills-arrow", L.type = "button", L.setAttribute("aria-label", this.i18n.moreSuggestionsAriaLabel), L.textContent = "›", L.addEventListener("click", () => {
|
|
751
|
+
h.scrollBy({ left: 150, behavior: "smooth" });
|
|
752
|
+
}), this._pillsEl.appendChild(L);
|
|
753
|
+
let A = !1;
|
|
754
|
+
h.addEventListener(
|
|
755
|
+
"scroll",
|
|
756
|
+
() => {
|
|
757
|
+
A || (A = !0, requestAnimationFrame(() => {
|
|
758
|
+
A = !1;
|
|
759
|
+
const f = h.scrollLeft + h.clientWidth >= h.scrollWidth - 4;
|
|
760
|
+
L.style.display = f ? "none" : "";
|
|
761
|
+
}));
|
|
762
|
+
},
|
|
763
|
+
{ passive: !0 }
|
|
764
|
+
), x.appendChild(this._pillsEl), this._inputChipsEl = document.createElement("div"), this._inputChipsEl.className = "gengage-chat-input-chips", this._inputChipsEl.style.display = "none", x.appendChild(this._inputChipsEl);
|
|
765
|
+
const u = document.createElement("div");
|
|
766
|
+
u.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", () => {
|
|
767
|
+
requestAnimationFrame(() => {
|
|
768
|
+
this.inputEl.style.height = "auto", this.inputEl.style.height = `${Math.min(this.inputEl.scrollHeight, 120)}px`;
|
|
769
|
+
});
|
|
770
|
+
}), this.inputEl.addEventListener("keydown", (f) => {
|
|
771
|
+
f.key === "Enter" && (window.innerWidth < 768 || !f.shiftKey) && (f.preventDefault(), this._submit());
|
|
772
|
+
}), this.inputEl.addEventListener("paste", (f) => {
|
|
773
|
+
const C = f.clipboardData?.files[0];
|
|
774
|
+
C && C.type.startsWith("image/") && (f.preventDefault(), this._onAttachment ? this._onAttachment(C) : this.stageAttachment(C));
|
|
775
|
+
}), 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", () => {
|
|
776
|
+
const f = this._fileInput.files?.[0];
|
|
777
|
+
f && (this._onAttachment ? this._onAttachment(f) : this.stageAttachment(f)), this._fileInput.value = "";
|
|
778
|
+
});
|
|
779
|
+
const b = document.createElement("button");
|
|
780
|
+
b.className = "gengage-chat-attach-btn", b.type = "button", b.setAttribute("aria-label", this.i18n.attachImageButton), b.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>', b.addEventListener("click", () => this._fileInput.click()), this._previewStrip = document.createElement("div"), this._previewStrip.className = "gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";
|
|
781
|
+
const k = document.createElement("img");
|
|
782
|
+
k.className = "gengage-chat-attachment-preview-thumb", k.alt = "", this._previewName = document.createElement("span"), this._previewName.className = "gengage-chat-attachment-name";
|
|
783
|
+
const P = document.createElement("button");
|
|
784
|
+
P.className = "gengage-chat-attachment-remove", P.type = "button", P.setAttribute("aria-label", this.i18n.removeAttachmentButton), P.textContent = "×", P.addEventListener("click", () => this.clearAttachment()), this._previewStrip.appendChild(k), this._previewStrip.appendChild(this._previewName), this._previewStrip.appendChild(P), 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()), u.addEventListener("dragover", (f) => {
|
|
785
|
+
f.preventDefault(), u.classList.add("gengage-chat-input-area--dragover");
|
|
786
|
+
}), u.addEventListener("dragleave", () => {
|
|
787
|
+
u.classList.remove("gengage-chat-input-area--dragover");
|
|
788
|
+
}), u.addEventListener("drop", (f) => {
|
|
789
|
+
f.preventDefault(), u.classList.remove("gengage-chat-input-area--dragover");
|
|
790
|
+
const C = f.dataTransfer?.files[0];
|
|
791
|
+
C && (this._onAttachment ? this._onAttachment(C) : this.stageAttachment(C));
|
|
792
|
+
});
|
|
793
|
+
const z = document.createElement("div");
|
|
794
|
+
z.className = "gengage-chat-input-pill", z.appendChild(b), z.appendChild(this.inputEl), this._voiceEnabled && It() && (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()), z.appendChild(this._micBtn), this._voiceInput = new At(
|
|
795
|
+
{
|
|
796
|
+
onInterim: (f) => {
|
|
797
|
+
this.inputEl.value = f, this.inputEl.style.height = "auto", this.inputEl.style.height = `${Math.min(this.inputEl.scrollHeight, 120)}px`;
|
|
798
|
+
},
|
|
799
|
+
onFinal: (f) => {
|
|
800
|
+
this.inputEl.value = f;
|
|
801
|
+
},
|
|
802
|
+
onAutoSubmit: (f) => {
|
|
803
|
+
this.inputEl.value = f, this._micBtn?.classList.remove("gengage-chat-mic-btn--active"), this._submit();
|
|
804
|
+
},
|
|
805
|
+
onStateChange: (f) => {
|
|
806
|
+
f === "listening" ? this._micBtn?.classList.add("gengage-chat-mic-btn--active") : this._micBtn?.classList.remove("gengage-chat-mic-btn--active");
|
|
807
|
+
},
|
|
808
|
+
onError: (f, C) => {
|
|
809
|
+
this._micBtn?.classList.remove("gengage-chat-mic-btn--active");
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
{ lang: this._voiceLang }
|
|
813
|
+
)), z.appendChild(this.sendBtn), u.appendChild(this._previewStrip), u.appendChild(this._fileInput), u.appendChild(z), x.appendChild(u), d.appendChild(x), this.root.appendChild(d);
|
|
814
|
+
const T = document.createElement("div");
|
|
815
|
+
T.className = "gengage-chat-footer", T.textContent = this.i18n.poweredBy, this.root.appendChild(T);
|
|
816
|
+
const N = (f) => {
|
|
817
|
+
f.key === "Escape" && t.onClose();
|
|
818
|
+
};
|
|
819
|
+
this.root.addEventListener("keydown", N), this._cleanups.push(() => this.root.removeEventListener("keydown", N)), e.appendChild(this.root);
|
|
820
|
+
}
|
|
821
|
+
addMessage(e) {
|
|
822
|
+
const t = document.createElement("div");
|
|
823
|
+
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) {
|
|
824
|
+
const a = document.createElement("img");
|
|
825
|
+
a.className = "gengage-chat-attachment-thumb";
|
|
826
|
+
const n = URL.createObjectURL(e.attachment);
|
|
827
|
+
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);
|
|
828
|
+
}
|
|
829
|
+
if (e.content) {
|
|
830
|
+
const a = document.createElement("div");
|
|
831
|
+
if (a.className = "gengage-chat-bubble-text", e.role === "assistant") {
|
|
832
|
+
if (a.innerHTML = $(e.content), this._onLinkClick) {
|
|
833
|
+
const n = a.querySelectorAll("a[href]");
|
|
834
|
+
for (const i of n)
|
|
835
|
+
i.addEventListener("click", (s) => {
|
|
836
|
+
s.preventDefault();
|
|
837
|
+
const l = i.getAttribute("href");
|
|
838
|
+
l && this._onLinkClick?.(l);
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
} else
|
|
842
|
+
a.textContent = e.content;
|
|
843
|
+
t.appendChild(a);
|
|
844
|
+
}
|
|
845
|
+
if (e.role === "user" && this._onRollback) {
|
|
846
|
+
const a = document.createElement("button");
|
|
847
|
+
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) => {
|
|
848
|
+
n.stopPropagation(), this._onRollback?.(e.id);
|
|
849
|
+
}), t.appendChild(a);
|
|
850
|
+
}
|
|
851
|
+
this.messagesEl.appendChild(t), this._scrollToBottom(e.role === "user");
|
|
852
|
+
}
|
|
853
|
+
showTypingIndicator(e) {
|
|
854
|
+
this.removeTypingIndicator();
|
|
855
|
+
const t = document.createElement("div");
|
|
856
|
+
if (t.className = "gengage-chat-typing", t.dataset.typing = "true", this._thinkingSteps.length > 0)
|
|
857
|
+
this._renderThinkingStepsInto(t);
|
|
858
|
+
else {
|
|
859
|
+
const a = document.createElement("div");
|
|
860
|
+
a.className = "gengage-chat-typing-dots";
|
|
861
|
+
for (let n = 0; n < 3; n++) a.appendChild(document.createElement("span"));
|
|
862
|
+
if (t.appendChild(a), e) {
|
|
863
|
+
const n = document.createElement("span");
|
|
864
|
+
n.className = "gengage-chat-typing-sparkle", n.textContent = "✨", t.appendChild(n);
|
|
865
|
+
const i = document.createElement("span");
|
|
866
|
+
i.className = "gengage-chat-typing-text", i.textContent = e, t.appendChild(i);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
this.messagesEl.appendChild(t), this._scrollToBottom(!0), this._clearStillWorkingTimer(), this._stillWorkingTimer = setTimeout(() => {
|
|
870
|
+
this._stillWorkingTimer = null;
|
|
871
|
+
const a = this.messagesEl.querySelector(".gengage-chat-typing");
|
|
872
|
+
if (!a || a.querySelector(".gengage-chat-still-working")) return;
|
|
873
|
+
const n = document.createElement("div");
|
|
874
|
+
n.className = "gengage-chat-still-working", n.textContent = this.i18n.stillWorkingMessage, a.appendChild(n), this._scrollToBottom(!0);
|
|
875
|
+
}, 1e4);
|
|
876
|
+
}
|
|
877
|
+
/** Accumulate a new thinking step (shown as a checklist in the typing indicator). */
|
|
878
|
+
addThinkingStep(e) {
|
|
879
|
+
this._thinkingSteps.push(e), this._renderThinkingSteps();
|
|
880
|
+
}
|
|
881
|
+
removeTypingIndicator() {
|
|
882
|
+
this._clearStillWorkingTimer(), this.messagesEl.querySelector(".gengage-chat-typing")?.remove(), this._thinkingSteps = [], this.hideStopButton();
|
|
883
|
+
}
|
|
884
|
+
_clearStillWorkingTimer() {
|
|
885
|
+
this._stillWorkingTimer !== null && (clearTimeout(this._stillWorkingTimer), this._stillWorkingTimer = null);
|
|
886
|
+
}
|
|
887
|
+
/** Show a "Stop generating" button below the typing indicator. */
|
|
888
|
+
showStopButton(e) {
|
|
889
|
+
this.hideStopButton();
|
|
890
|
+
const t = document.createElement("button");
|
|
891
|
+
t.className = "gengage-chat-stop-btn", t.type = "button", t.setAttribute("aria-label", this.i18n.stopGenerating);
|
|
892
|
+
const a = document.createElement("span");
|
|
893
|
+
a.className = "gengage-chat-stop-icon", a.setAttribute("aria-hidden", "true"), t.appendChild(a);
|
|
894
|
+
const n = document.createElement("span");
|
|
895
|
+
n.textContent = this.i18n.stopGenerating, t.appendChild(n), t.addEventListener("click", () => {
|
|
896
|
+
this.hideStopButton(), e();
|
|
897
|
+
}), this.messagesEl.appendChild(t), this._scrollToBottom(!0);
|
|
898
|
+
}
|
|
899
|
+
/** Remove the stop-generating button if present. */
|
|
900
|
+
hideStopButton() {
|
|
901
|
+
this.messagesEl.querySelector(".gengage-chat-stop-btn")?.remove();
|
|
902
|
+
}
|
|
903
|
+
showError(e, t) {
|
|
904
|
+
const a = document.createElement("div");
|
|
905
|
+
a.className = "gengage-chat-error";
|
|
906
|
+
const n = document.createElement("span");
|
|
907
|
+
if (n.textContent = e ?? this.i18n.errorMessage, a.appendChild(n), t) {
|
|
908
|
+
const i = document.createElement("button");
|
|
909
|
+
i.className = "gengage-chat-error-retry", i.textContent = this.i18n.retryButton ?? "Retry", i.addEventListener("click", () => {
|
|
910
|
+
a.remove(), t();
|
|
911
|
+
}), a.appendChild(i);
|
|
912
|
+
}
|
|
913
|
+
this.messagesEl.appendChild(a), this._scrollToBottom(!0);
|
|
914
|
+
}
|
|
915
|
+
clearMessages() {
|
|
916
|
+
this.messagesEl.innerHTML = "";
|
|
917
|
+
}
|
|
918
|
+
/** Replace suggestion pills. Pass empty array to hide. */
|
|
919
|
+
setPills(e) {
|
|
920
|
+
const t = this._pillsEl.querySelector(".gengage-chat-pills-scroll");
|
|
921
|
+
if (!t) return;
|
|
922
|
+
for (; t.firstChild; ) t.removeChild(t.firstChild);
|
|
923
|
+
if (e.length === 0) {
|
|
924
|
+
this._pillsEl.style.display = "none";
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
this._pillsEl.style.display = "";
|
|
928
|
+
for (const n of e) {
|
|
929
|
+
const i = document.createElement("button");
|
|
930
|
+
if (i.className = n.image ? "gengage-chat-pill gengage-chat-pill--rich" : "gengage-chat-pill", i.type = "button", n.icon) {
|
|
931
|
+
const l = he[n.icon];
|
|
932
|
+
if (l) {
|
|
933
|
+
const r = document.createElement("span");
|
|
934
|
+
r.className = "gengage-chat-pill-icon", r.innerHTML = l, i.appendChild(r);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (n.image && G(n.image)) {
|
|
938
|
+
const l = document.createElement("img");
|
|
939
|
+
l.className = "gengage-chat-pill-img", l.src = n.image, l.alt = "", i.appendChild(l);
|
|
940
|
+
}
|
|
941
|
+
const s = document.createElement("span");
|
|
942
|
+
if (s.className = "gengage-chat-pill-text", s.textContent = n.label, i.appendChild(s), n.description) {
|
|
943
|
+
const l = document.createElement("span");
|
|
944
|
+
l.className = "gengage-chat-pill-desc", l.textContent = n.description, i.appendChild(l);
|
|
945
|
+
}
|
|
946
|
+
i.addEventListener("click", () => n.onAction()), t.appendChild(i);
|
|
947
|
+
}
|
|
948
|
+
const a = this._pillsEl.querySelector(".gengage-chat-pills-arrow");
|
|
949
|
+
a && requestAnimationFrame(() => {
|
|
950
|
+
a.style.display = t.scrollWidth > t.clientWidth ? "" : "none";
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
focusInput() {
|
|
954
|
+
this.inputEl.focus();
|
|
955
|
+
}
|
|
956
|
+
showKvkkBanner(e, t) {
|
|
957
|
+
this._kvkkSlot.innerHTML = "";
|
|
958
|
+
const a = Pt({ htmlContent: e, onDismiss: t, closeAriaLabel: this.i18n.closeAriaLabel });
|
|
959
|
+
this._kvkkSlot.appendChild(a);
|
|
960
|
+
}
|
|
961
|
+
hideKvkkBanner() {
|
|
962
|
+
this._kvkkSlot.innerHTML = "";
|
|
963
|
+
}
|
|
964
|
+
getElement() {
|
|
965
|
+
return this.root;
|
|
966
|
+
}
|
|
967
|
+
/** Stage a file attachment for sending. Shows preview. */
|
|
968
|
+
stageAttachment(e) {
|
|
969
|
+
this._pendingAttachment = e, this._previewName.textContent = e.name;
|
|
970
|
+
const t = this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");
|
|
971
|
+
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");
|
|
972
|
+
}
|
|
973
|
+
/** Remove the staged attachment and hide preview. */
|
|
974
|
+
clearAttachment() {
|
|
975
|
+
const e = this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");
|
|
976
|
+
e?.src && (URL.revokeObjectURL(e.src), e.src = ""), this._pendingAttachment = null, this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden");
|
|
977
|
+
}
|
|
978
|
+
/** Get the currently staged attachment file, or null. */
|
|
979
|
+
getPendingAttachment() {
|
|
980
|
+
return this._pendingAttachment;
|
|
981
|
+
}
|
|
982
|
+
/** Replace panel content and show the panel. */
|
|
983
|
+
setPanelContent(e) {
|
|
984
|
+
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");
|
|
985
|
+
}
|
|
986
|
+
/** Append content to the panel without replacing existing content. */
|
|
987
|
+
appendPanelContent(e) {
|
|
988
|
+
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"));
|
|
989
|
+
}
|
|
990
|
+
/** Return the panel element's content child (after topbar), or null. */
|
|
991
|
+
getPanelContentElement() {
|
|
992
|
+
const e = this._panelEl.children;
|
|
993
|
+
for (let t = 0; t < e.length; t++) {
|
|
994
|
+
const a = e[t];
|
|
995
|
+
if (!(a.classList.contains("gengage-chat-panel-topbar") || a.classList.contains("gengage-chat-thumbnails-column")))
|
|
996
|
+
return a;
|
|
997
|
+
}
|
|
998
|
+
return null;
|
|
999
|
+
}
|
|
1000
|
+
/** Whether the panel is currently visible and has rendered content (beyond topbar + thumbnails column). */
|
|
1001
|
+
hasPanelContent() {
|
|
1002
|
+
return this._panelVisible && this.getPanelContentElement() !== null;
|
|
1003
|
+
}
|
|
1004
|
+
/** Whether panel currently shows loading skeleton blocks. */
|
|
1005
|
+
isPanelLoading() {
|
|
1006
|
+
return this._panelEl.querySelector(".gengage-chat-panel-skeleton") !== null;
|
|
1007
|
+
}
|
|
1008
|
+
/** Show loading skeleton in the panel. Variant depends on contentType hint. */
|
|
1009
|
+
showPanelLoading(e) {
|
|
1010
|
+
this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"), this._panelEl.innerHTML = "", this._panelEl.appendChild(this._panelTopBar.getElement());
|
|
1011
|
+
const t = document.createElement("div");
|
|
1012
|
+
switch (t.className = "gengage-chat-panel-skeleton", e) {
|
|
1013
|
+
case "productDetails": {
|
|
1014
|
+
const a = document.createElement("div");
|
|
1015
|
+
a.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image", t.appendChild(a);
|
|
1016
|
+
for (let n = 0; n < 3; n++) {
|
|
1017
|
+
const i = document.createElement("div");
|
|
1018
|
+
i.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text", t.appendChild(i);
|
|
1019
|
+
}
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
case "productList":
|
|
1023
|
+
case "groupList": {
|
|
1024
|
+
const a = document.createElement("div");
|
|
1025
|
+
a.className = "gengage-chat-panel-skeleton-grid";
|
|
1026
|
+
for (let n = 0; n < 6; n++) {
|
|
1027
|
+
const i = document.createElement("div");
|
|
1028
|
+
i.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card", a.appendChild(i);
|
|
1029
|
+
}
|
|
1030
|
+
t.appendChild(a);
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
case "comparisonTable": {
|
|
1034
|
+
for (let a = 0; a < 4; a++) {
|
|
1035
|
+
const n = document.createElement("div");
|
|
1036
|
+
n.className = "gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--row", t.appendChild(n);
|
|
1037
|
+
}
|
|
1038
|
+
break;
|
|
1039
|
+
}
|
|
1040
|
+
default: {
|
|
1041
|
+
for (let a = 0; a < 3; a++) {
|
|
1042
|
+
const n = document.createElement("div");
|
|
1043
|
+
n.className = "gengage-chat-panel-skeleton-block", t.appendChild(n);
|
|
1044
|
+
}
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
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"));
|
|
1049
|
+
}
|
|
1050
|
+
/** Update the panel top bar navigation state. */
|
|
1051
|
+
updatePanelTopBar(e, t, a) {
|
|
1052
|
+
this._panelTopBar.update(e, t, a);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Hide the panel and clear its content. Always hides — even in force-expanded mode.
|
|
1056
|
+
* Callers: _hideDrawer (stale panel cleanup), stream onDone (loading skeleton cleanup),
|
|
1057
|
+
* thread navigation (no snapshot to restore). All require full hide.
|
|
1058
|
+
* Keeps `_panelCollapsed` untouched so user collapse preference survives future panel renders.
|
|
1059
|
+
*/
|
|
1060
|
+
clearPanel() {
|
|
1061
|
+
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");
|
|
1062
|
+
}
|
|
1063
|
+
/** Expand panel without locking — user can still toggle via divider. */
|
|
1064
|
+
expandPanel() {
|
|
1065
|
+
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"));
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Ensure the panel starts expanded (panelMode: 'expanded').
|
|
1069
|
+
* Users can still collapse/expand via the divider chevron.
|
|
1070
|
+
*/
|
|
1071
|
+
setForceExpanded() {
|
|
1072
|
+
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");
|
|
1073
|
+
}
|
|
1074
|
+
/** Toggle panel between collapsed and expanded. */
|
|
1075
|
+
togglePanel() {
|
|
1076
|
+
this.setPanelCollapsed(!this._panelCollapsed);
|
|
1077
|
+
}
|
|
1078
|
+
/** Whether the panel is currently collapsed by the user. */
|
|
1079
|
+
isPanelCollapsed() {
|
|
1080
|
+
return this._panelCollapsed;
|
|
1081
|
+
}
|
|
1082
|
+
/** Programmatically set panel collapsed state. */
|
|
1083
|
+
setPanelCollapsed(e) {
|
|
1084
|
+
this._panelCollapsed = e, e ? this._panelEl.classList.add("gengage-chat-panel--collapsed") : this._panelEl.classList.remove("gengage-chat-panel--collapsed");
|
|
1085
|
+
const t = this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");
|
|
1086
|
+
t && (t.textContent = e ? "«" : "»");
|
|
1087
|
+
}
|
|
1088
|
+
/** Save panel collapsed state to sessionStorage. */
|
|
1089
|
+
persistPanelState(e) {
|
|
1090
|
+
try {
|
|
1091
|
+
const t = `gengage:panel:${e}`;
|
|
1092
|
+
this._panelCollapsed ? sessionStorage.setItem(t, "collapsed") : sessionStorage.removeItem(t);
|
|
1093
|
+
} catch {
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
/** Restore panel collapsed state from sessionStorage. Returns true when restored as collapsed. */
|
|
1097
|
+
restorePanelState(e) {
|
|
1098
|
+
try {
|
|
1099
|
+
const t = `gengage:panel:${e}`;
|
|
1100
|
+
if (sessionStorage.getItem(t) === "collapsed")
|
|
1101
|
+
return this._panelCollapsed = !0, !0;
|
|
1102
|
+
} catch {
|
|
1103
|
+
}
|
|
1104
|
+
return !1;
|
|
1105
|
+
}
|
|
1106
|
+
/** Re-render thinking steps inside the existing typing indicator container. */
|
|
1107
|
+
_renderThinkingSteps() {
|
|
1108
|
+
const e = this.messagesEl.querySelector('[data-typing="true"]');
|
|
1109
|
+
if (!e) {
|
|
1110
|
+
this.showTypingIndicator();
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
e.innerHTML = "", this._renderThinkingStepsInto(e), this._scrollToBottom(!1);
|
|
1114
|
+
}
|
|
1115
|
+
/** Render the accumulated thinking-step checklist into a container element. */
|
|
1116
|
+
_renderThinkingStepsInto(e) {
|
|
1117
|
+
const t = document.createElement("div");
|
|
1118
|
+
t.className = "gengage-chat-thinking-steps";
|
|
1119
|
+
for (let a = 0; a < this._thinkingSteps.length; a++) {
|
|
1120
|
+
const n = document.createElement("div");
|
|
1121
|
+
n.className = "gengage-chat-thinking-step";
|
|
1122
|
+
const i = document.createElement("span");
|
|
1123
|
+
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);
|
|
1124
|
+
const s = document.createElement("span");
|
|
1125
|
+
s.className = "gengage-chat-thinking-step-text", s.textContent = this._thinkingSteps[a], n.appendChild(s), t.appendChild(n);
|
|
1126
|
+
}
|
|
1127
|
+
e.appendChild(t);
|
|
1128
|
+
}
|
|
1129
|
+
_submit() {
|
|
1130
|
+
const e = this.inputEl.value.trim(), t = this._pendingAttachment;
|
|
1131
|
+
!e && !t || (this.onSend(e, t ?? void 0), this.inputEl.value = "", this.inputEl.style.height = "auto", this.clearAttachment());
|
|
1132
|
+
}
|
|
1133
|
+
_toggleVoice() {
|
|
1134
|
+
if (this._voiceInput)
|
|
1135
|
+
if (this._voiceInput.state === "listening") {
|
|
1136
|
+
const e = this._voiceInput.stop();
|
|
1137
|
+
e.trim() && (this.inputEl.value = e, this._submit());
|
|
1138
|
+
} else
|
|
1139
|
+
this.inputEl.value = "", this._voiceInput.start();
|
|
1140
|
+
}
|
|
1141
|
+
/** Lock auto-scroll for 500ms after session history restore to prevent visual jump. */
|
|
1142
|
+
lockScrollForRestore() {
|
|
1143
|
+
this._scrollLockedUntil = Date.now() + 500;
|
|
1144
|
+
}
|
|
1145
|
+
/** Scroll to bottom only if user hasn't scrolled up. Force=true always scrolls. */
|
|
1146
|
+
_scrollToBottom(e = !1) {
|
|
1147
|
+
!e && this._userScrolledUp || !e && Date.now() < this._scrollLockedUntil || requestAnimationFrame(() => {
|
|
1148
|
+
this.messagesEl.scrollTop = this.messagesEl.scrollHeight, this._userScrolledUp = !1;
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
/** Public method for typewriter ticks — scrolls only if user is near bottom. */
|
|
1152
|
+
scrollToBottomIfNeeded() {
|
|
1153
|
+
this._scrollToBottom(!1);
|
|
1154
|
+
}
|
|
1155
|
+
/** Update a bot message's text content in the DOM (e.g. for fallback messages). */
|
|
1156
|
+
updateBotMessage(e, t) {
|
|
1157
|
+
const a = this.messagesEl.querySelector(`[data-message-id="${CSS.escape(e)}"]`);
|
|
1158
|
+
if (!a) return;
|
|
1159
|
+
let n = a.querySelector(".gengage-chat-bubble-text");
|
|
1160
|
+
n || (n = document.createElement("div"), n.className = "gengage-chat-bubble-text", a.appendChild(n)), n.innerHTML = $(t), this._scrollToBottom(!1);
|
|
1161
|
+
}
|
|
1162
|
+
/** Mark a message as the first bot message in its thread (for special styling). */
|
|
1163
|
+
markFirstBotMessage(e) {
|
|
1164
|
+
this._firstBotMessageIds.add(e);
|
|
1165
|
+
const t = this.messagesEl.querySelector(`[data-message-id="${CSS.escape(e)}"]`);
|
|
1166
|
+
t && t.classList.add("gengage-chat-bubble--first");
|
|
1167
|
+
}
|
|
1168
|
+
/** Scroll to the first message of the last thread (for restore targeting). */
|
|
1169
|
+
scrollToLastThread() {
|
|
1170
|
+
const e = this.messagesEl.querySelectorAll("[data-thread-id]");
|
|
1171
|
+
if (e.length === 0) {
|
|
1172
|
+
this._scrollToBottom(!0);
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
const t = e[e.length - 1].getAttribute("data-thread-id");
|
|
1176
|
+
if (!t) {
|
|
1177
|
+
this._scrollToBottom(!0);
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
const a = this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(t)}"]`);
|
|
1181
|
+
a ? requestAnimationFrame(() => {
|
|
1182
|
+
a.scrollIntoView({ block: "start", behavior: "auto" }), this._userScrolledUp = !1;
|
|
1183
|
+
}) : this._scrollToBottom(!0);
|
|
1184
|
+
}
|
|
1185
|
+
/** Set compact input-area chips (search/info/review shortcuts above input). */
|
|
1186
|
+
setInputAreaChips(e) {
|
|
1187
|
+
if (this._inputChipsEl.innerHTML = "", e.length === 0) {
|
|
1188
|
+
this._inputChipsEl.style.display = "none";
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
this._inputChipsEl.style.display = "";
|
|
1192
|
+
for (const t of e) {
|
|
1193
|
+
const a = document.createElement("button");
|
|
1194
|
+
if (a.className = "gengage-chat-input-chip", a.type = "button", t.icon) {
|
|
1195
|
+
const i = he[t.icon];
|
|
1196
|
+
if (i) {
|
|
1197
|
+
const s = document.createElement("span");
|
|
1198
|
+
s.className = "gengage-chat-input-chip-icon", s.innerHTML = i, a.appendChild(s);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
const n = document.createElement("span");
|
|
1202
|
+
n.textContent = t.label, a.appendChild(n), a.addEventListener("click", () => t.onAction()), this._inputChipsEl.appendChild(a);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
/** Clear input-area chips. */
|
|
1206
|
+
clearInputAreaChips() {
|
|
1207
|
+
this._inputChipsEl.innerHTML = "", this._inputChipsEl.style.display = "none";
|
|
1208
|
+
}
|
|
1209
|
+
setThumbnails(e) {
|
|
1210
|
+
this._thumbnailsColumn.setEntries(e), e.length > 0 ? this._thumbnailsColumn.show() : this._thumbnailsColumn.hide();
|
|
1211
|
+
}
|
|
1212
|
+
hideThumbnails() {
|
|
1213
|
+
this._thumbnailsColumn.hide();
|
|
1214
|
+
}
|
|
1215
|
+
/** Activate focus trap — Tab/Shift+Tab cycles within the drawer. */
|
|
1216
|
+
trapFocus() {
|
|
1217
|
+
this._previouslyFocusedElement = document.activeElement, this.releaseFocus();
|
|
1218
|
+
const e = (t) => {
|
|
1219
|
+
if (t.key !== "Tab") return;
|
|
1220
|
+
const a = this.root.querySelectorAll(
|
|
1221
|
+
'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
1222
|
+
);
|
|
1223
|
+
if (a.length === 0) return;
|
|
1224
|
+
const n = a[0], i = a[a.length - 1], s = this.root.getRootNode(), l = s instanceof ShadowRoot ? s.activeElement : document.activeElement;
|
|
1225
|
+
t.shiftKey ? (l === n || !this.root.contains(l)) && (t.preventDefault(), i.focus()) : (l === i || !this.root.contains(l)) && (t.preventDefault(), n.focus());
|
|
1226
|
+
};
|
|
1227
|
+
this._focusTrapHandler = e, this.root.addEventListener("keydown", e);
|
|
1228
|
+
}
|
|
1229
|
+
/** Release the focus trap and restore previously focused element. */
|
|
1230
|
+
releaseFocus() {
|
|
1231
|
+
if (this._focusTrapHandler && (this.root.removeEventListener("keydown", this._focusTrapHandler), this._focusTrapHandler = null), this._previouslyFocusedElement) {
|
|
1232
|
+
try {
|
|
1233
|
+
this._previouslyFocusedElement.focus();
|
|
1234
|
+
} catch {
|
|
1235
|
+
}
|
|
1236
|
+
this._previouslyFocusedElement = null;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
/** Clean up event listeners and child resources (VoiceInput, timers). */
|
|
1240
|
+
destroy() {
|
|
1241
|
+
this.releaseFocus(), this._clearStillWorkingTimer();
|
|
1242
|
+
for (const e of this._cleanups) e();
|
|
1243
|
+
this._cleanups.length = 0, this._voiceInput?.destroy(), this._voiceInput = null;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
const Dt = `<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1247
|
+
<rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>
|
|
1248
|
+
<rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
|
|
1249
|
+
<circle cx="9" cy="13" r="1.5" fill="currentColor"/>
|
|
1250
|
+
<circle cx="15" cy="13" r="1.5" fill="currentColor"/>
|
|
1251
|
+
<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"/>
|
|
1252
|
+
<path d="M12 7V4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1253
|
+
<circle cx="12" cy="3" r="1" fill="currentColor"/>
|
|
1254
|
+
<path d="M1 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1255
|
+
<path d="M23 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1256
|
+
</svg>`;
|
|
1257
|
+
function Ft(o) {
|
|
1258
|
+
const e = document.createElement("div");
|
|
1259
|
+
e.className = "gengage-chat-launcher-container";
|
|
1260
|
+
const t = document.createElement("div");
|
|
1261
|
+
t.className = "gengage-chat-launcher-content-area", e.appendChild(t);
|
|
1262
|
+
const a = document.createElement("button");
|
|
1263
|
+
if (a.className = "gengage-chat-launcher", a.type = "button", a.setAttribute("aria-label", o.ariaLabel ?? "Open chat"), a.innerHTML = o.svgMarkup ?? Dt, o.tooltip !== void 0) {
|
|
1264
|
+
const i = document.createElement("span");
|
|
1265
|
+
i.className = "gengage-chat-launcher-tooltip", i.textContent = o.tooltip, a.appendChild(i);
|
|
1266
|
+
}
|
|
1267
|
+
o.hideMobile && (e.dataset.hideMobile = "1"), o.mobileBreakpoint !== void 0 && (e.dataset.mobileBreakpoint = String(o.mobileBreakpoint)), a.addEventListener("click", o.onClick), e.appendChild(a);
|
|
1268
|
+
const n = document.createElement("div");
|
|
1269
|
+
return n.className = "gengage-chat-launcher-content-area-bottom", e.appendChild(n), { container: e, button: a, contentArea: t, contentAreaBottom: n };
|
|
1270
|
+
}
|
|
1271
|
+
const Ut = /* @__PURE__ */ new Set([
|
|
1272
|
+
"audio/ogg",
|
|
1273
|
+
"audio/mpeg",
|
|
1274
|
+
"audio/mp3",
|
|
1275
|
+
"audio/wav",
|
|
1276
|
+
"audio/webm",
|
|
1277
|
+
"audio/aac",
|
|
1278
|
+
"audio/mp4"
|
|
1279
|
+
]), Ee = /* @__PURE__ */ new Set();
|
|
1280
|
+
function ie(o) {
|
|
1281
|
+
o.pause(), o.removeAttribute("src"), o.load(), Ee.delete(o);
|
|
1282
|
+
}
|
|
1283
|
+
function qt(o, e = "audio/ogg") {
|
|
1284
|
+
const t = e.split(";")[0].trim();
|
|
1285
|
+
if (!Ut.has(t)) return null;
|
|
1286
|
+
try {
|
|
1287
|
+
const a = new Audio(`data:${e};base64,${o}`);
|
|
1288
|
+
return Ee.add(a), a.addEventListener("ended", () => ie(a), { once: !0 }), a.play().catch(() => {
|
|
1289
|
+
ie(a);
|
|
1290
|
+
}), {
|
|
1291
|
+
stop: () => ie(a)
|
|
1292
|
+
};
|
|
1293
|
+
} catch {
|
|
1294
|
+
return null;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
const Ht = {
|
|
1298
|
+
screen_size: "Screen Size",
|
|
1299
|
+
weight: "Weight",
|
|
1300
|
+
battery_capacity: "Battery Capacity",
|
|
1301
|
+
battery_life: "Battery Life",
|
|
1302
|
+
storage: "Storage",
|
|
1303
|
+
memory: "Memory",
|
|
1304
|
+
ram: "RAM",
|
|
1305
|
+
processor: "Processor",
|
|
1306
|
+
camera: "Camera",
|
|
1307
|
+
resolution: "Resolution",
|
|
1308
|
+
display_type: "Display Type",
|
|
1309
|
+
refresh_rate: "Refresh Rate",
|
|
1310
|
+
color: "Color",
|
|
1311
|
+
material: "Material",
|
|
1312
|
+
dimensions: "Dimensions",
|
|
1313
|
+
warranty: "Warranty",
|
|
1314
|
+
connectivity: "Connectivity",
|
|
1315
|
+
water_resistance: "Water Resistance",
|
|
1316
|
+
operating_system: "Operating System",
|
|
1317
|
+
brand: "Brand",
|
|
1318
|
+
model: "Model",
|
|
1319
|
+
price: "Price",
|
|
1320
|
+
energy_class: "Energy Class",
|
|
1321
|
+
noise_level: "Noise Level",
|
|
1322
|
+
capacity: "Capacity",
|
|
1323
|
+
power: "Power",
|
|
1324
|
+
voltage: "Voltage",
|
|
1325
|
+
width: "Width",
|
|
1326
|
+
height: "Height",
|
|
1327
|
+
depth: "Depth"
|
|
1328
|
+
};
|
|
1329
|
+
function Ot(o, e) {
|
|
1330
|
+
return e?.[o] ?? Ht[o] ?? o.replace(/_/g, " ").replace(/^\w/, (t) => t.toUpperCase());
|
|
1331
|
+
}
|
|
1332
|
+
function jt(o) {
|
|
1333
|
+
const { recommended: e, products: t, attributes: a, highlights: n, specialCases: i, onProductClick: s, i18n: l } = o, r = document.createElement("div");
|
|
1334
|
+
r.className = "gengage-chat-comparison";
|
|
1335
|
+
const c = document.createElement("h3");
|
|
1336
|
+
if (c.className = "gengage-chat-comparison-heading", c.textContent = l?.comparisonHeading ?? "COMPARISON RESULTS", r.appendChild(c), e) {
|
|
1337
|
+
const g = document.createElement("div");
|
|
1338
|
+
g.className = "gengage-chat-comparison-recommended";
|
|
1339
|
+
const d = document.createElement("div");
|
|
1340
|
+
d.className = "gengage-chat-comparison-recommended-label", d.textContent = l?.recommendedChoiceLabel ?? "Recommended Choice", g.appendChild(d);
|
|
1341
|
+
const m = document.createElement("div");
|
|
1342
|
+
if (m.className = "gengage-chat-comparison-recommended-body", e.imageUrl && G(e.imageUrl)) {
|
|
1343
|
+
const x = document.createElement("img");
|
|
1344
|
+
x.src = e.imageUrl, x.alt = e.name, x.loading = "lazy", x.addEventListener(
|
|
1345
|
+
"error",
|
|
1346
|
+
() => {
|
|
1347
|
+
x.style.display = "none";
|
|
1348
|
+
},
|
|
1349
|
+
{ once: !0 }
|
|
1350
|
+
), m.appendChild(x);
|
|
1351
|
+
}
|
|
1352
|
+
const p = document.createElement("div");
|
|
1353
|
+
p.className = "gengage-chat-comparison-recommended-info";
|
|
1354
|
+
const y = document.createElement("div");
|
|
1355
|
+
y.className = "gengage-chat-comparison-recommended-title", y.textContent = e.name, p.appendChild(y);
|
|
1356
|
+
const _ = document.createElement("div");
|
|
1357
|
+
if (_.className = "gengage-chat-comparison-recommended-price", _.textContent = q(e.price, o.pricing), p.appendChild(_), m.appendChild(p), m.addEventListener("click", () => {
|
|
1358
|
+
s(e.sku);
|
|
1359
|
+
}), m.style.cursor = "pointer", g.appendChild(m), n.length > 0) {
|
|
1360
|
+
const x = document.createElement("div");
|
|
1361
|
+
x.className = "gengage-chat-comparison-highlights";
|
|
1362
|
+
const E = document.createElement("div");
|
|
1363
|
+
E.className = "gengage-chat-comparison-highlights-label", E.textContent = l?.highlightsLabel ?? "Key Highlights", x.appendChild(E);
|
|
1364
|
+
const I = document.createElement("ul");
|
|
1365
|
+
for (const S of n) {
|
|
1366
|
+
const v = document.createElement("li");
|
|
1367
|
+
v.textContent = S, I.appendChild(v);
|
|
1368
|
+
}
|
|
1369
|
+
x.appendChild(I), g.appendChild(x);
|
|
1370
|
+
}
|
|
1371
|
+
if (o.recommendedText) {
|
|
1372
|
+
const x = document.createElement("div");
|
|
1373
|
+
x.className = "gengage-chat-comparison-recommended-text", x.innerHTML = $(o.recommendedText), g.appendChild(x);
|
|
1374
|
+
}
|
|
1375
|
+
r.appendChild(g);
|
|
1376
|
+
}
|
|
1377
|
+
if (o.keyDifferencesHtml) {
|
|
1378
|
+
const g = document.createElement("div");
|
|
1379
|
+
g.className = "gengage-chat-comparison-key-differences";
|
|
1380
|
+
const d = document.createElement("h4");
|
|
1381
|
+
d.textContent = l?.keyDifferencesLabel ?? "Key Differences", g.appendChild(d);
|
|
1382
|
+
const m = document.createElement("div");
|
|
1383
|
+
m.className = "gengage-chat-comparison-key-differences-content", m.innerHTML = $(Vt(o.keyDifferencesHtml)), g.appendChild(m), r.appendChild(g);
|
|
1384
|
+
}
|
|
1385
|
+
if (i && i.length > 0) {
|
|
1386
|
+
const g = document.createElement("details");
|
|
1387
|
+
g.className = "gengage-chat-comparison-special";
|
|
1388
|
+
const d = document.createElement("summary");
|
|
1389
|
+
d.textContent = l?.specialCasesLabel ?? "For Special Cases", g.appendChild(d);
|
|
1390
|
+
const m = document.createElement("ul");
|
|
1391
|
+
for (const p of i)
|
|
1392
|
+
Wt(m, p);
|
|
1393
|
+
m.childElementCount > 0 && g.appendChild(m), r.appendChild(g);
|
|
1394
|
+
}
|
|
1395
|
+
if (t.length > 0 && a.length > 0) {
|
|
1396
|
+
const g = document.createElement("table");
|
|
1397
|
+
g.className = "gengage-chat-comparison-table";
|
|
1398
|
+
const d = document.createElement("thead"), m = document.createElement("tr"), p = document.createElement("th");
|
|
1399
|
+
m.appendChild(p);
|
|
1400
|
+
for (const _ of t) {
|
|
1401
|
+
const x = document.createElement("th");
|
|
1402
|
+
if (_.sku === e?.sku && (x.className = "gengage-chat-comparison-selected"), _.imageUrl && G(_.imageUrl)) {
|
|
1403
|
+
const S = document.createElement("img");
|
|
1404
|
+
S.src = _.imageUrl, S.alt = _.name, S.loading = "lazy", S.addEventListener(
|
|
1405
|
+
"error",
|
|
1406
|
+
() => {
|
|
1407
|
+
S.style.display = "none";
|
|
1408
|
+
},
|
|
1409
|
+
{ once: !0 }
|
|
1410
|
+
), x.appendChild(S);
|
|
1411
|
+
}
|
|
1412
|
+
const E = document.createElement("div");
|
|
1413
|
+
E.textContent = _.name, x.appendChild(E);
|
|
1414
|
+
const I = document.createElement("div");
|
|
1415
|
+
I.className = "gengage-chat-comparison-table-price", I.textContent = q(_.price, o.pricing), x.appendChild(I), m.appendChild(x);
|
|
1416
|
+
}
|
|
1417
|
+
d.appendChild(m), g.appendChild(d);
|
|
1418
|
+
const y = document.createElement("tbody");
|
|
1419
|
+
for (const _ of a) {
|
|
1420
|
+
const x = document.createElement("tr"), E = document.createElement("td");
|
|
1421
|
+
E.className = "gengage-chat-comparison-label", E.textContent = Ot(_.label, l?.criteriaLabels), x.appendChild(E);
|
|
1422
|
+
for (let I = 0; I < _.values.length; I++) {
|
|
1423
|
+
const S = document.createElement("td");
|
|
1424
|
+
t[I]?.sku === e?.sku && (S.className = "gengage-chat-comparison-selected"), S.textContent = _.values[I] ?? "", x.appendChild(S);
|
|
1425
|
+
}
|
|
1426
|
+
y.appendChild(x);
|
|
1427
|
+
}
|
|
1428
|
+
g.appendChild(y), r.appendChild(g);
|
|
1429
|
+
}
|
|
1430
|
+
if (o.productActions) {
|
|
1431
|
+
const g = document.createElement("div");
|
|
1432
|
+
g.className = "gengage-chat-comparison-product-actions";
|
|
1433
|
+
for (const d of t)
|
|
1434
|
+
if (o.productActions[d.sku]) {
|
|
1435
|
+
const p = document.createElement("button");
|
|
1436
|
+
p.className = "gengage-chat-comparison-view-btn", p.type = "button", p.textContent = d.name, p.addEventListener("click", () => s(d.sku)), g.appendChild(p);
|
|
1437
|
+
}
|
|
1438
|
+
g.childElementCount > 0 && r.appendChild(g);
|
|
1439
|
+
}
|
|
1440
|
+
return r;
|
|
1441
|
+
}
|
|
1442
|
+
function Vt(o) {
|
|
1443
|
+
if (/<[uo]l[\s>]/i.test(o) || /<li[\s>]/i.test(o)) return o;
|
|
1444
|
+
const e = o.split(`
|
|
1445
|
+
`).filter((t) => t.trim());
|
|
1446
|
+
return e.length <= 1 ? o : "<ul>" + e.map((t) => `<li>${t.trim()}</li>`).join("") + "</ul>";
|
|
1447
|
+
}
|
|
1448
|
+
function Wt(o, e) {
|
|
1449
|
+
const t = $(e);
|
|
1450
|
+
if (!t) return;
|
|
1451
|
+
const a = document.createElement("template");
|
|
1452
|
+
a.innerHTML = t;
|
|
1453
|
+
const n = Array.from(a.content.querySelectorAll("li"));
|
|
1454
|
+
if (n.length > 0) {
|
|
1455
|
+
for (const s of n) {
|
|
1456
|
+
const l = document.createElement("li");
|
|
1457
|
+
l.innerHTML = $(s.innerHTML), o.appendChild(l);
|
|
1458
|
+
}
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
const i = document.createElement("li");
|
|
1462
|
+
$t(e) ? i.innerHTML = t : i.textContent = e, o.appendChild(i);
|
|
1463
|
+
}
|
|
1464
|
+
function $t(o) {
|
|
1465
|
+
return /<\/?[a-z][\s\S]*>/i.test(o);
|
|
1466
|
+
}
|
|
1467
|
+
function Gt(o, e) {
|
|
1468
|
+
const t = document.createElement("div");
|
|
1469
|
+
t.className = "gengage-chat-review-highlights";
|
|
1470
|
+
const a = o.props?.reviews;
|
|
1471
|
+
if (!Array.isArray(a) || a.length === 0) {
|
|
1472
|
+
const _ = document.createElement("div");
|
|
1473
|
+
return _.className = "gengage-chat-review-empty", _.textContent = e?.emptyReviewsMessage ?? "No review summary found.", t.appendChild(_), t;
|
|
1474
|
+
}
|
|
1475
|
+
const n = a.filter(
|
|
1476
|
+
(_) => _ !== null && typeof _ == "object"
|
|
1477
|
+
), i = { all: n.length, positive: 0, negative: 0, neutral: 0 };
|
|
1478
|
+
for (const _ of n)
|
|
1479
|
+
_.review_class === "positive" ? i.positive++ : _.review_class === "negative" ? i.negative++ : i.neutral++;
|
|
1480
|
+
const s = document.createElement("div");
|
|
1481
|
+
s.className = "gengage-chat-review-tabs";
|
|
1482
|
+
const l = e?.reviewFilterAll ?? "All", r = e?.reviewFilterPositive ?? "Positive", c = e?.reviewFilterNegative ?? "Negative", g = [{ label: `${l} (${i.all})`, filter: "all" }];
|
|
1483
|
+
i.positive > 0 && g.push({ label: `${r} (${i.positive})`, filter: "positive" }), i.negative > 0 && g.push({ label: `${c} (${i.negative})`, filter: "negative" });
|
|
1484
|
+
let d = "all";
|
|
1485
|
+
const m = document.createElement("div");
|
|
1486
|
+
m.className = "gengage-chat-review-items";
|
|
1487
|
+
function p() {
|
|
1488
|
+
for (; m.firstChild; ) m.removeChild(m.firstChild);
|
|
1489
|
+
const _ = d === "all" ? n : n.filter((x) => x.review_class === d);
|
|
1490
|
+
for (const x of _) {
|
|
1491
|
+
const E = document.createElement("article");
|
|
1492
|
+
E.className = "gengage-chat-review-item";
|
|
1493
|
+
const I = x.review_class;
|
|
1494
|
+
if ((I === "positive" || I === "negative" || I === "neutral") && (E.dataset.tone = I), typeof x.review_tag == "string" && x.review_tag.length > 0) {
|
|
1495
|
+
const S = document.createElement("div");
|
|
1496
|
+
S.className = "gengage-chat-review-tag", S.textContent = x.review_tag, E.appendChild(S);
|
|
1497
|
+
}
|
|
1498
|
+
if (typeof x.review_text == "string" && x.review_text.length > 0) {
|
|
1499
|
+
const S = document.createElement("div");
|
|
1500
|
+
S.className = "gengage-chat-review-text", S.textContent = x.review_text, E.appendChild(S);
|
|
1501
|
+
}
|
|
1502
|
+
if (x.review_rating !== void 0 && String(x.review_rating).length > 0) {
|
|
1503
|
+
const S = document.createElement("div");
|
|
1504
|
+
S.className = "gengage-chat-review-rating", S.textContent = String(x.review_rating), E.appendChild(S);
|
|
1505
|
+
}
|
|
1506
|
+
m.appendChild(E);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
for (const _ of g) {
|
|
1510
|
+
const x = document.createElement("button");
|
|
1511
|
+
x.className = "gengage-chat-review-tab", x.type = "button", x.textContent = _.label, _.filter === d && x.classList.add("gengage-chat-review-tab--active"), x.addEventListener("click", () => {
|
|
1512
|
+
d = _.filter;
|
|
1513
|
+
for (const E of s.querySelectorAll(".gengage-chat-review-tab"))
|
|
1514
|
+
E.classList.toggle("gengage-chat-review-tab--active", E === x);
|
|
1515
|
+
p();
|
|
1516
|
+
}), s.appendChild(x);
|
|
1517
|
+
}
|
|
1518
|
+
t.appendChild(s);
|
|
1519
|
+
const y = /* @__PURE__ */ new Map();
|
|
1520
|
+
for (const _ of n)
|
|
1521
|
+
if (typeof _.review_tag == "string" && _.review_tag.length > 0) {
|
|
1522
|
+
const x = y.get(_.review_tag);
|
|
1523
|
+
x ? x.count++ : y.set(_.review_tag, { count: 1, sentiment: _.review_class ?? "neutral" });
|
|
1524
|
+
}
|
|
1525
|
+
if (y.size > 0) {
|
|
1526
|
+
const _ = document.createElement("div");
|
|
1527
|
+
_.className = "gengage-chat-review-pills";
|
|
1528
|
+
for (const [x, E] of y) {
|
|
1529
|
+
const I = document.createElement("span");
|
|
1530
|
+
I.className = "gengage-chat-review-pill", I.dataset.tone = E.sentiment;
|
|
1531
|
+
const S = document.createElement("span");
|
|
1532
|
+
S.className = "gengage-chat-review-pill-icon", S.textContent = E.sentiment === "positive" ? "✓" : E.sentiment === "negative" ? "✕" : "●", I.appendChild(S);
|
|
1533
|
+
const v = document.createElement("span");
|
|
1534
|
+
if (v.textContent = x, I.appendChild(v), E.count > 1) {
|
|
1535
|
+
const h = document.createElement("span");
|
|
1536
|
+
h.className = "gengage-chat-review-pill-count", h.textContent = String(E.count), I.appendChild(h);
|
|
1537
|
+
}
|
|
1538
|
+
_.appendChild(I);
|
|
1539
|
+
}
|
|
1540
|
+
t.appendChild(_);
|
|
1541
|
+
}
|
|
1542
|
+
return p(), t.appendChild(m), t;
|
|
1543
|
+
}
|
|
1544
|
+
function Se(o) {
|
|
1545
|
+
const e = o.product.sku;
|
|
1546
|
+
if (typeof e == "string" && e.length > 0) return e;
|
|
1547
|
+
const t = o.action?.payload;
|
|
1548
|
+
return t && typeof t == "object" && "sku" in t && typeof t.sku == "string" ? t.sku : null;
|
|
1549
|
+
}
|
|
1550
|
+
const Yt = {
|
|
1551
|
+
winner: "roleWinner",
|
|
1552
|
+
best_value: "roleBestValue",
|
|
1553
|
+
best_alternative: "roleBestAlternative"
|
|
1554
|
+
};
|
|
1555
|
+
function Te(o, e) {
|
|
1556
|
+
if (!o || !e) return null;
|
|
1557
|
+
const t = Yt[o];
|
|
1558
|
+
return t ? e[t] ?? o : o;
|
|
1559
|
+
}
|
|
1560
|
+
function Kt(o, e) {
|
|
1561
|
+
const t = document.createElement("div");
|
|
1562
|
+
t.className = "gengage-chat-ai-top-picks";
|
|
1563
|
+
const a = o.props?.suggestions ?? [];
|
|
1564
|
+
if (a.length === 0) return t;
|
|
1565
|
+
const n = document.createElement("h3");
|
|
1566
|
+
n.className = "gengage-chat-ai-top-picks-title", n.textContent = e.i18n?.aiTopPicksTitle ?? "Top Picks", t.appendChild(n);
|
|
1567
|
+
const i = document.createElement("div");
|
|
1568
|
+
i.className = "gengage-chat-ai-top-picks-cards";
|
|
1569
|
+
for (let s = 0; s < a.length; s++) {
|
|
1570
|
+
const l = a[s], c = l.role === "winner" || s === 0 ? Qt(l, e) : Xt(l, e);
|
|
1571
|
+
i.appendChild(c);
|
|
1572
|
+
}
|
|
1573
|
+
return t.appendChild(i), t;
|
|
1574
|
+
}
|
|
1575
|
+
function Qt(o, e) {
|
|
1576
|
+
const t = document.createElement("div");
|
|
1577
|
+
t.className = "gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner";
|
|
1578
|
+
const a = document.createElement("span");
|
|
1579
|
+
a.className = "gengage-chat-ai-toppick-badge", a.textContent = Te(o.role, e.i18n) ?? e.i18n?.roleWinner ?? "TOP MATCH", t.appendChild(a);
|
|
1580
|
+
const n = o.product, i = n.discountPercent;
|
|
1581
|
+
if (typeof i == "number" && i > 0) {
|
|
1582
|
+
const d = document.createElement("span");
|
|
1583
|
+
d.className = "gengage-chat-ai-toppick-discount-badge", d.textContent = `%${ce(i)}`, t.appendChild(d);
|
|
1584
|
+
}
|
|
1585
|
+
const s = n.imageUrl;
|
|
1586
|
+
if (s && G(s)) {
|
|
1587
|
+
const d = document.createElement("img");
|
|
1588
|
+
d.className = "gengage-chat-ai-toppick-img", U(d, "src", s), d.loading = "lazy", d.alt = n.name || "Product image", X(d), t.appendChild(d);
|
|
1589
|
+
}
|
|
1590
|
+
const l = document.createElement("div");
|
|
1591
|
+
l.className = "gengage-chat-ai-toppick-body";
|
|
1592
|
+
const r = n.name;
|
|
1593
|
+
if (r) {
|
|
1594
|
+
const d = document.createElement("div");
|
|
1595
|
+
d.className = "gengage-chat-ai-toppick-name", d.textContent = r, l.appendChild(d);
|
|
1596
|
+
}
|
|
1597
|
+
if (o.reason) {
|
|
1598
|
+
const d = document.createElement("div");
|
|
1599
|
+
d.className = "gengage-chat-ai-toppick-reason", d.textContent = o.reason, l.appendChild(d);
|
|
1600
|
+
}
|
|
1601
|
+
if (o.labels && o.labels.length > 0 && l.appendChild(Le(o.labels)), typeof o.expertQualityScore == "number") {
|
|
1602
|
+
const d = document.createElement("div");
|
|
1603
|
+
d.className = "gengage-chat-ai-toppick-score";
|
|
1604
|
+
const m = o.expertQualityScore <= 5 ? 5 : 10;
|
|
1605
|
+
d.textContent = `${o.expertQualityScore}/${m}`, l.appendChild(d);
|
|
1606
|
+
}
|
|
1607
|
+
if (o.reviewHighlight) {
|
|
1608
|
+
const d = document.createElement("blockquote");
|
|
1609
|
+
d.className = "gengage-chat-ai-toppick-review", d.textContent = o.reviewHighlight, l.appendChild(d);
|
|
1610
|
+
}
|
|
1611
|
+
const c = n.price, g = n.originalPrice;
|
|
1612
|
+
if (c) {
|
|
1613
|
+
const d = document.createElement("div");
|
|
1614
|
+
if (d.className = "gengage-chat-ai-toppick-price", g && g !== c) {
|
|
1615
|
+
const p = document.createElement("span");
|
|
1616
|
+
p.className = "gengage-chat-ai-toppick-original-price", p.textContent = q(g, e.pricing), d.appendChild(p), d.appendChild(document.createTextNode(" "));
|
|
1617
|
+
}
|
|
1618
|
+
const m = document.createElement("span");
|
|
1619
|
+
m.textContent = q(c, e.pricing), d.appendChild(m), l.appendChild(d);
|
|
1620
|
+
}
|
|
1621
|
+
if (t.appendChild(l), o.action) {
|
|
1622
|
+
const d = Se(o), m = n.url ?? "", p = document.createElement("div");
|
|
1623
|
+
p.className = "gengage-chat-ai-toppick-spinner", p.style.display = d && e.topPicksLoadingSku === d ? "" : "none", t.appendChild(p);
|
|
1624
|
+
const y = document.createElement("button");
|
|
1625
|
+
y.className = "gengage-chat-ai-toppick-cta", y.type = "button", y.textContent = e.i18n?.viewDetails ?? "View Details", y.addEventListener("click", () => {
|
|
1626
|
+
if (o.action?.type === "findSimilar" && d && e.onProductClick) {
|
|
1627
|
+
e.onProductClick({ sku: d, url: m });
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
e.onAction(o.action);
|
|
1631
|
+
}), t.appendChild(y);
|
|
1632
|
+
}
|
|
1633
|
+
return t;
|
|
1634
|
+
}
|
|
1635
|
+
function Xt(o, e) {
|
|
1636
|
+
const t = document.createElement("div");
|
|
1637
|
+
t.className = "gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact";
|
|
1638
|
+
const a = o.product, n = a.discountPercent;
|
|
1639
|
+
if (typeof n == "number" && n > 0) {
|
|
1640
|
+
const g = document.createElement("span");
|
|
1641
|
+
g.className = "gengage-chat-ai-toppick-discount-badge", g.textContent = `%${ce(n)}`, t.appendChild(g);
|
|
1642
|
+
}
|
|
1643
|
+
const i = a.imageUrl;
|
|
1644
|
+
if (i && G(i)) {
|
|
1645
|
+
const g = document.createElement("img");
|
|
1646
|
+
g.className = "gengage-chat-ai-toppick-img", U(g, "src", i), g.loading = "lazy", g.alt = a.name || "Product image", X(g), t.appendChild(g);
|
|
1647
|
+
}
|
|
1648
|
+
const s = document.createElement("div");
|
|
1649
|
+
s.className = "gengage-chat-ai-toppick-body";
|
|
1650
|
+
const l = Te(o.role, e.i18n);
|
|
1651
|
+
if (l) {
|
|
1652
|
+
const g = document.createElement("div");
|
|
1653
|
+
g.className = "gengage-chat-ai-toppick-role", g.textContent = l, s.appendChild(g);
|
|
1654
|
+
}
|
|
1655
|
+
const r = a.name;
|
|
1656
|
+
if (r) {
|
|
1657
|
+
const g = document.createElement("div");
|
|
1658
|
+
g.className = "gengage-chat-ai-toppick-name", g.textContent = r, s.appendChild(g);
|
|
1659
|
+
}
|
|
1660
|
+
if (o.reason) {
|
|
1661
|
+
const g = document.createElement("div");
|
|
1662
|
+
g.className = "gengage-chat-ai-toppick-reason", g.textContent = o.reason, s.appendChild(g);
|
|
1663
|
+
}
|
|
1664
|
+
o.labels && o.labels.length > 0 && s.appendChild(Le(o.labels));
|
|
1665
|
+
const c = a.price;
|
|
1666
|
+
if (c) {
|
|
1667
|
+
const g = document.createElement("div");
|
|
1668
|
+
g.className = "gengage-chat-ai-toppick-price", g.textContent = q(c, e.pricing), s.appendChild(g);
|
|
1669
|
+
}
|
|
1670
|
+
if (t.appendChild(s), o.action) {
|
|
1671
|
+
const g = Se(o), d = a.url ?? "", m = document.createElement("div");
|
|
1672
|
+
m.className = "gengage-chat-ai-toppick-spinner", m.style.display = g && e.topPicksLoadingSku === g ? "" : "none", t.appendChild(m);
|
|
1673
|
+
const p = document.createElement("button");
|
|
1674
|
+
p.className = "gengage-chat-ai-toppick-cta", p.type = "button", p.textContent = e.i18n?.viewDetails ?? "View Details", p.addEventListener("click", () => {
|
|
1675
|
+
if (o.action?.type === "findSimilar" && g && e.onProductClick) {
|
|
1676
|
+
e.onProductClick({ sku: g, url: d });
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
e.onAction(o.action);
|
|
1680
|
+
}), t.appendChild(p);
|
|
1681
|
+
}
|
|
1682
|
+
return t;
|
|
1683
|
+
}
|
|
1684
|
+
function Le(o) {
|
|
1685
|
+
const e = document.createElement("div");
|
|
1686
|
+
e.className = "gengage-chat-ai-toppick-labels";
|
|
1687
|
+
for (const t of o) {
|
|
1688
|
+
const a = document.createElement("span");
|
|
1689
|
+
a.className = "gengage-chat-ai-toppick-label", a.dataset.sentiment = t.sentiment ?? "neutral", a.textContent = t.label, e.appendChild(a);
|
|
1690
|
+
}
|
|
1691
|
+
return e;
|
|
1692
|
+
}
|
|
1693
|
+
function Jt(o, e) {
|
|
1694
|
+
const t = document.createElement("div");
|
|
1695
|
+
t.className = "gengage-chat-grounding-review";
|
|
1696
|
+
const a = o.props ?? {}, n = a.title, i = a.reviewCount, s = a.action, l = e.i18n?.groundingReviewCta ?? "Read Reviews", r = document.createElement("span");
|
|
1697
|
+
r.className = "gengage-chat-grounding-review-icon", r.textContent = "📋", t.appendChild(r);
|
|
1698
|
+
const c = document.createElement("div");
|
|
1699
|
+
c.className = "gengage-chat-grounding-review-body";
|
|
1700
|
+
const g = document.createElement("div");
|
|
1701
|
+
if (g.className = "gengage-chat-grounding-review-title", g.textContent = n ?? e.i18n?.customerReviewsTitle ?? "Customer Reviews", c.appendChild(g), i) {
|
|
1702
|
+
const m = document.createElement("div");
|
|
1703
|
+
m.className = "gengage-chat-grounding-review-subtitle";
|
|
1704
|
+
const p = e.i18n?.groundingReviewSubtitle ?? "{count} yorum mevcut";
|
|
1705
|
+
m.textContent = p.replace("{count}", i), c.appendChild(m);
|
|
1706
|
+
}
|
|
1707
|
+
t.appendChild(c);
|
|
1708
|
+
const d = document.createElement("span");
|
|
1709
|
+
return d.className = "gengage-chat-grounding-review-cta", d.textContent = `${l} →`, t.appendChild(d), s && (t.style.cursor = "pointer", t.addEventListener("click", () => e.onAction(s))), t;
|
|
1710
|
+
}
|
|
1711
|
+
function Zt(o) {
|
|
1712
|
+
if (o.action.type !== "findSimilar") return o.action;
|
|
1713
|
+
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();
|
|
1714
|
+
if (!t) return o.action;
|
|
1715
|
+
const a = {
|
|
1716
|
+
text: t,
|
|
1717
|
+
is_suggested_text: 1
|
|
1718
|
+
};
|
|
1719
|
+
if (typeof e?.sku == "string" && e.sku.trim() && (a.sku = e.sku), Array.isArray(e?.group_skus)) {
|
|
1720
|
+
const n = e.group_skus.filter((i) => typeof i == "string" && i.length > 0);
|
|
1721
|
+
n.length > 0 && (a.group_skus = n);
|
|
1722
|
+
}
|
|
1723
|
+
return {
|
|
1724
|
+
title: o.action.title,
|
|
1725
|
+
type: "inputText",
|
|
1726
|
+
payload: a
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
function ea(o, e) {
|
|
1730
|
+
const t = document.createElement("div");
|
|
1731
|
+
t.className = "gengage-chat-grouping-cards";
|
|
1732
|
+
const a = o.props?.entries ?? [];
|
|
1733
|
+
if (a.length === 0) return t;
|
|
1734
|
+
for (const n of a) {
|
|
1735
|
+
const i = document.createElement("div");
|
|
1736
|
+
if (i.className = "gengage-chat-grouping-card", i.style.cursor = "pointer", i.addEventListener("click", () => e.onAction(Zt(n))), n.image && G(n.image)) {
|
|
1737
|
+
const c = document.createElement("img");
|
|
1738
|
+
c.className = "gengage-chat-grouping-card-img", c.src = n.image, c.alt = n.name, c.width = 20, c.height = 20, i.appendChild(c);
|
|
1739
|
+
}
|
|
1740
|
+
const s = document.createElement("div");
|
|
1741
|
+
s.className = "gengage-chat-grouping-card-body";
|
|
1742
|
+
const l = document.createElement("span");
|
|
1743
|
+
if (l.className = "gengage-chat-grouping-card-name", l.textContent = n.name, s.appendChild(l), n.description) {
|
|
1744
|
+
const c = document.createElement("span");
|
|
1745
|
+
c.className = "gengage-chat-grouping-card-desc", c.textContent = n.description, s.appendChild(c);
|
|
1746
|
+
}
|
|
1747
|
+
if (n.labels && n.labels.length > 0) {
|
|
1748
|
+
const c = document.createElement("span");
|
|
1749
|
+
c.className = "gengage-chat-grouping-card-labels", c.textContent = n.labels.slice(0, 3).join(" · "), s.appendChild(c);
|
|
1750
|
+
}
|
|
1751
|
+
i.appendChild(s);
|
|
1752
|
+
const r = document.createElement("span");
|
|
1753
|
+
r.className = "gengage-chat-grouping-card-arrow", r.textContent = "↳", i.insertBefore(r, i.firstChild), t.appendChild(i);
|
|
1754
|
+
}
|
|
1755
|
+
return t;
|
|
1756
|
+
}
|
|
1757
|
+
function ta(o, e) {
|
|
1758
|
+
const t = document.createElement("div");
|
|
1759
|
+
t.className = "gengage-chat-suggested-search-cards";
|
|
1760
|
+
const a = o.props?.entries ?? [];
|
|
1761
|
+
if (a.length === 0) return t;
|
|
1762
|
+
for (const n of a) {
|
|
1763
|
+
const i = document.createElement("div");
|
|
1764
|
+
if (i.className = "gengage-chat-suggested-search-card", i.style.cursor = "pointer", i.addEventListener("click", () => e.onAction(n.action)), n.image && G(n.image)) {
|
|
1765
|
+
const r = document.createElement("img");
|
|
1766
|
+
r.className = "gengage-chat-suggested-search-card-img", r.src = n.image, r.alt = n.shortName, r.width = 40, r.height = 40, i.appendChild(r);
|
|
1767
|
+
}
|
|
1768
|
+
const s = document.createElement("div");
|
|
1769
|
+
s.className = "gengage-chat-suggested-search-card-body";
|
|
1770
|
+
const l = document.createElement("div");
|
|
1771
|
+
if (l.className = "gengage-chat-suggested-search-card-name", l.textContent = n.shortName, s.appendChild(l), n.detailedMessage) {
|
|
1772
|
+
const r = document.createElement("div");
|
|
1773
|
+
r.className = "gengage-chat-suggested-search-card-desc", r.textContent = n.detailedMessage, s.appendChild(r);
|
|
1774
|
+
}
|
|
1775
|
+
if (n.whyDifferent) {
|
|
1776
|
+
const r = document.createElement("div");
|
|
1777
|
+
r.className = "gengage-chat-suggested-search-card-diff", r.textContent = n.whyDifferent, s.appendChild(r);
|
|
1778
|
+
}
|
|
1779
|
+
i.appendChild(s), t.appendChild(i);
|
|
1780
|
+
}
|
|
1781
|
+
return t;
|
|
1782
|
+
}
|
|
1783
|
+
function aa(o, e) {
|
|
1784
|
+
const t = document.createElement("button");
|
|
1785
|
+
t.className = "gengage-chat-comparison-floating-btn", t.type = "button";
|
|
1786
|
+
const a = e.i18n?.compareSelected ?? "Compare";
|
|
1787
|
+
return t.textContent = `${a} (${o.length})`, t.addEventListener("click", () => {
|
|
1788
|
+
e.onAction({
|
|
1789
|
+
title: a,
|
|
1790
|
+
type: "getComparisonTable",
|
|
1791
|
+
payload: { sku_list: [...o] }
|
|
1792
|
+
});
|
|
1793
|
+
}), t;
|
|
1794
|
+
}
|
|
1795
|
+
function na(o) {
|
|
1796
|
+
const e = document.createElement("div");
|
|
1797
|
+
e.className = "gengage-chat-pros-cons";
|
|
1798
|
+
const t = o.props?.productName;
|
|
1799
|
+
if (t) {
|
|
1800
|
+
const i = document.createElement("h4");
|
|
1801
|
+
i.className = "gengage-chat-pros-cons-heading", i.textContent = t, e.appendChild(i);
|
|
1802
|
+
}
|
|
1803
|
+
const a = o.props?.pros, n = o.props?.cons;
|
|
1804
|
+
if (a && a.length > 0) {
|
|
1805
|
+
const i = document.createElement("ul");
|
|
1806
|
+
i.className = "gengage-chat-pros-cons-list";
|
|
1807
|
+
for (const s of a) {
|
|
1808
|
+
const l = document.createElement("li");
|
|
1809
|
+
l.className = "gengage-chat-pros-cons-item";
|
|
1810
|
+
const r = document.createElement("span");
|
|
1811
|
+
r.className = "gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro", r.textContent = "✓", l.appendChild(r);
|
|
1812
|
+
const c = document.createElement("span");
|
|
1813
|
+
c.textContent = s, l.appendChild(c), i.appendChild(l);
|
|
1814
|
+
}
|
|
1815
|
+
e.appendChild(i);
|
|
1816
|
+
}
|
|
1817
|
+
if (n && n.length > 0) {
|
|
1818
|
+
const i = document.createElement("ul");
|
|
1819
|
+
i.className = "gengage-chat-pros-cons-list";
|
|
1820
|
+
for (const s of n) {
|
|
1821
|
+
const l = document.createElement("li");
|
|
1822
|
+
l.className = "gengage-chat-pros-cons-item";
|
|
1823
|
+
const r = document.createElement("span");
|
|
1824
|
+
r.className = "gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con", r.textContent = "✗", l.appendChild(r);
|
|
1825
|
+
const c = document.createElement("span");
|
|
1826
|
+
c.textContent = s, l.appendChild(c), i.appendChild(l);
|
|
1827
|
+
}
|
|
1828
|
+
e.appendChild(i);
|
|
1829
|
+
}
|
|
1830
|
+
return e;
|
|
1831
|
+
}
|
|
1832
|
+
function ia(o, e) {
|
|
1833
|
+
const t = o.props?.groups ?? [], a = o.props?.filterTags ?? [], n = document.createElement("div");
|
|
1834
|
+
if (n.className = "gengage-chat-categories", t.length === 0) return n;
|
|
1835
|
+
const i = document.createElement("div");
|
|
1836
|
+
i.className = "gengage-chat-categories-tabs", i.setAttribute("role", "tablist");
|
|
1837
|
+
const s = [], l = [], r = (c) => {
|
|
1838
|
+
for (let g = 0; g < s.length; g++) {
|
|
1839
|
+
const d = g === c;
|
|
1840
|
+
s[g].classList.toggle("gengage-chat-categories-tab--active", d), s[g].setAttribute("aria-selected", String(d)), s[g].tabIndex = d ? 0 : -1, l[g].style.display = d ? "" : "none";
|
|
1841
|
+
}
|
|
1842
|
+
};
|
|
1843
|
+
for (let c = 0; c < t.length; c++) {
|
|
1844
|
+
const g = t[c], d = `gengage-cat-tab-${c}`, m = `gengage-cat-panel-${c}`, p = document.createElement("button");
|
|
1845
|
+
p.className = "gengage-chat-categories-tab", p.type = "button", p.id = d, p.setAttribute("role", "tab"), p.setAttribute("aria-controls", m), p.setAttribute("aria-selected", String(c === 0)), p.tabIndex = c === 0 ? 0 : -1, c === 0 && p.classList.add("gengage-chat-categories-tab--active"), p.textContent = g.groupName, p.addEventListener("click", () => r(c)), p.addEventListener("keydown", (_) => {
|
|
1846
|
+
let x = -1;
|
|
1847
|
+
_.key === "ArrowRight" || _.key === "ArrowDown" ? x = (c + 1) % t.length : _.key === "ArrowLeft" || _.key === "ArrowUp" ? x = (c - 1 + t.length) % t.length : _.key === "Home" ? x = 0 : _.key === "End" && (x = t.length - 1), x >= 0 && (_.preventDefault(), r(x), s[x].focus());
|
|
1848
|
+
}), s.push(p), i.appendChild(p);
|
|
1849
|
+
const y = document.createElement("div");
|
|
1850
|
+
y.className = "gengage-chat-categories-grid", y.id = m, y.setAttribute("role", "tabpanel"), y.setAttribute("aria-labelledby", d), c !== 0 && (y.style.display = "none");
|
|
1851
|
+
for (const _ of g.products) {
|
|
1852
|
+
const x = oa(_, e);
|
|
1853
|
+
y.appendChild(x);
|
|
1854
|
+
}
|
|
1855
|
+
l.push(y);
|
|
1856
|
+
}
|
|
1857
|
+
n.appendChild(i);
|
|
1858
|
+
for (const c of l) n.appendChild(c);
|
|
1859
|
+
if (a.length > 0) {
|
|
1860
|
+
const c = document.createElement("div");
|
|
1861
|
+
c.className = "gengage-chat-categories-filter-tags";
|
|
1862
|
+
for (const g of a) {
|
|
1863
|
+
const d = document.createElement("button");
|
|
1864
|
+
d.className = "gengage-chat-categories-filter-tag", d.type = "button", d.textContent = g.title, g.action && d.addEventListener("click", () => {
|
|
1865
|
+
e.onAction(g.action);
|
|
1866
|
+
}), c.appendChild(d);
|
|
1867
|
+
}
|
|
1868
|
+
n.appendChild(c);
|
|
1869
|
+
}
|
|
1870
|
+
return n;
|
|
1871
|
+
}
|
|
1872
|
+
function oa(o, e) {
|
|
1873
|
+
const t = document.createElement("div");
|
|
1874
|
+
if (t.className = "gengage-chat-product-card", o.imageUrl && G(o.imageUrl)) {
|
|
1875
|
+
const i = document.createElement("img");
|
|
1876
|
+
i.className = "gengage-chat-product-card-img", i.src = o.imageUrl, i.alt = o.name, t.appendChild(i);
|
|
1877
|
+
}
|
|
1878
|
+
const a = document.createElement("div");
|
|
1879
|
+
a.className = "gengage-chat-product-card-body";
|
|
1880
|
+
const n = document.createElement("div");
|
|
1881
|
+
if (n.className = "gengage-chat-product-card-name", n.textContent = o.name, a.appendChild(n), o.price) {
|
|
1882
|
+
const i = document.createElement("div");
|
|
1883
|
+
i.className = "gengage-chat-product-card-price", i.textContent = o.price, a.appendChild(i);
|
|
1884
|
+
}
|
|
1885
|
+
return t.appendChild(a), e.onProductSelect && (t.style.cursor = "pointer", t.addEventListener("click", () => {
|
|
1886
|
+
e.onProductSelect?.(o);
|
|
1887
|
+
})), t;
|
|
1888
|
+
}
|
|
1889
|
+
function ra(o, e) {
|
|
1890
|
+
const t = document.createElement("div");
|
|
1891
|
+
t.className = "gengage-chat-handoff-notice", t.setAttribute("role", "alert");
|
|
1892
|
+
const a = document.createElement("span");
|
|
1893
|
+
a.className = "gengage-chat-handoff-notice-icon", a.textContent = "👤", a.setAttribute("aria-hidden", "true"), t.appendChild(a);
|
|
1894
|
+
const n = document.createElement("h4");
|
|
1895
|
+
n.className = "gengage-chat-handoff-notice-heading", n.textContent = e.i18n?.handoffHeading ?? "Transferring to a support agent", t.appendChild(n);
|
|
1896
|
+
const i = o.props?.summary;
|
|
1897
|
+
if (i) {
|
|
1898
|
+
const s = document.createElement("p");
|
|
1899
|
+
s.className = "gengage-chat-handoff-notice-summary", s.textContent = i, t.appendChild(s);
|
|
1900
|
+
}
|
|
1901
|
+
return t;
|
|
1902
|
+
}
|
|
1903
|
+
function sa(o, e) {
|
|
1904
|
+
const t = o.props?.product ?? o.props, a = document.createElement("div");
|
|
1905
|
+
if (a.className = "gengage-chat-product-summary", !t) return a;
|
|
1906
|
+
a.style.cursor = "pointer", a.addEventListener("click", (p) => {
|
|
1907
|
+
p.target.closest("a") || e.onProductSelect?.(t);
|
|
1908
|
+
});
|
|
1909
|
+
const n = t.imageUrl;
|
|
1910
|
+
if (n && H(n)) {
|
|
1911
|
+
const p = document.createElement("div");
|
|
1912
|
+
p.className = "gengage-chat-product-summary__image";
|
|
1913
|
+
const y = document.createElement("img");
|
|
1914
|
+
y.loading = "lazy", U(y, "src", n);
|
|
1915
|
+
const _ = t.name;
|
|
1916
|
+
y.alt = _ || "Product image", X(y), p.appendChild(y), a.appendChild(p);
|
|
1917
|
+
}
|
|
1918
|
+
const i = document.createElement("div");
|
|
1919
|
+
i.className = "gengage-chat-product-summary__content";
|
|
1920
|
+
const s = t.brand, l = t.name;
|
|
1921
|
+
if (l) {
|
|
1922
|
+
const p = document.createElement("div");
|
|
1923
|
+
p.className = "gengage-chat-product-summary__name";
|
|
1924
|
+
const y = s && !l.toLowerCase().startsWith(s.toLowerCase());
|
|
1925
|
+
p.textContent = y ? `${s} ${l}` : l, i.appendChild(p);
|
|
1926
|
+
}
|
|
1927
|
+
const r = t.rating, c = t.reviewCount;
|
|
1928
|
+
if (typeof r == "number" && Number.isFinite(r) && r > 0) {
|
|
1929
|
+
const p = document.createElement("div");
|
|
1930
|
+
if (p.className = "gengage-chat-product-summary__rating", p.textContent = ye(_e(r)), typeof c == "number" && Number.isFinite(c)) {
|
|
1931
|
+
const y = document.createElement("span");
|
|
1932
|
+
y.className = "gengage-chat-product-summary__review-count", y.textContent = ` (${c})`, p.appendChild(y);
|
|
1933
|
+
}
|
|
1934
|
+
i.appendChild(p);
|
|
1935
|
+
}
|
|
1936
|
+
const g = t.price, d = t.originalPrice;
|
|
1937
|
+
if (g) {
|
|
1938
|
+
const p = document.createElement("div");
|
|
1939
|
+
if (p.className = "gengage-chat-product-summary__price", d && d !== g) {
|
|
1940
|
+
const _ = document.createElement("span");
|
|
1941
|
+
_.className = "gengage-chat-product-summary__price-original", _.textContent = q(d, e.pricing), p.appendChild(_), p.appendChild(document.createTextNode(" "));
|
|
1942
|
+
}
|
|
1943
|
+
const y = document.createElement("span");
|
|
1944
|
+
y.className = "gengage-chat-product-summary__price-current", y.textContent = q(g, e.pricing), p.appendChild(y), i.appendChild(p);
|
|
1945
|
+
}
|
|
1946
|
+
a.appendChild(i);
|
|
1947
|
+
const m = t.url;
|
|
1948
|
+
if (m && H(m)) {
|
|
1949
|
+
const p = document.createElement("a");
|
|
1950
|
+
p.className = "gengage-chat-product-summary__cta", U(p, "href", m), U(p, "target", "_blank"), U(p, "rel", "noopener noreferrer"), p.textContent = e.i18n?.productCtaLabel ?? "View", a.appendChild(p);
|
|
1951
|
+
}
|
|
1952
|
+
return a;
|
|
1953
|
+
}
|
|
1954
|
+
function Ie() {
|
|
1955
|
+
return window.innerWidth < 768;
|
|
1956
|
+
}
|
|
1957
|
+
const Ae = {
|
|
1958
|
+
ActionButtons: ({ element: o, context: e }) => ga(o, e),
|
|
1959
|
+
ActionButton: ({ element: o, context: e }) => da(o, e),
|
|
1960
|
+
ProductCard: ({ element: o, context: e }) => pa(o, e),
|
|
1961
|
+
ProductDetailsPanel: ({ element: o, context: e }) => ha(o, e),
|
|
1962
|
+
ProductGrid: ({ element: o, spec: e, renderElement: t, context: a }) => fa(o, e, t, a),
|
|
1963
|
+
ReviewHighlights: ({ element: o, context: e }) => Gt(o, {
|
|
1964
|
+
emptyReviewsMessage: e.i18n?.emptyReviewsMessage,
|
|
1965
|
+
reviewFilterAll: e.i18n?.reviewFilterAll,
|
|
1966
|
+
reviewFilterPositive: e.i18n?.reviewFilterPositive,
|
|
1967
|
+
reviewFilterNegative: e.i18n?.reviewFilterNegative
|
|
1968
|
+
}),
|
|
1969
|
+
ComparisonTable: ({ element: o, context: e }) => ba(o, e),
|
|
1970
|
+
AITopPicks: ({ element: o, context: e }) => Kt(o, e),
|
|
1971
|
+
GroundingReviewCard: ({ element: o, context: e }) => Jt(o, e),
|
|
1972
|
+
AIGroupingCards: ({ element: o, context: e }) => ea(o, e),
|
|
1973
|
+
AISuggestedSearchCards: ({ element: o, context: e }) => ta(o, e),
|
|
1974
|
+
ProsAndCons: ({ element: o }) => na(o),
|
|
1975
|
+
CategoriesContainer: ({ element: o, context: e }) => ia(o, e),
|
|
1976
|
+
HandoffNotice: ({ element: o, context: e }) => ra(o, e),
|
|
1977
|
+
ProductSummaryCard: ({ element: o, context: e }) => sa(o, e),
|
|
1978
|
+
Divider: ({ element: o }) => xa(o)
|
|
1979
|
+
}, Ne = ({
|
|
1980
|
+
element: o,
|
|
1981
|
+
renderElement: e
|
|
1982
|
+
}) => {
|
|
1983
|
+
if (!o.children || o.children.length === 0)
|
|
1984
|
+
return null;
|
|
1985
|
+
const t = document.createElement("div");
|
|
1986
|
+
for (const a of o.children) {
|
|
1987
|
+
const n = e(a);
|
|
1988
|
+
n && t.appendChild(n);
|
|
1989
|
+
}
|
|
1990
|
+
return t;
|
|
1991
|
+
};
|
|
1992
|
+
function ca() {
|
|
1993
|
+
return { ...Ae };
|
|
1994
|
+
}
|
|
1995
|
+
function la(o, e, t = Ae, a = Ne) {
|
|
1996
|
+
return qe({
|
|
1997
|
+
spec: o,
|
|
1998
|
+
context: e,
|
|
1999
|
+
registry: t,
|
|
2000
|
+
containerClassName: "gengage-chat-uispec",
|
|
2001
|
+
unknownRenderer: a
|
|
2002
|
+
});
|
|
2003
|
+
}
|
|
2004
|
+
function ga(o, e) {
|
|
2005
|
+
const t = document.createElement("div");
|
|
2006
|
+
t.className = "gengage-chat-action-buttons";
|
|
2007
|
+
const a = o.props?.buttons;
|
|
2008
|
+
if (a)
|
|
2009
|
+
for (const n of a) {
|
|
2010
|
+
const i = document.createElement("button");
|
|
2011
|
+
i.className = "gengage-chat-action-btn", i.textContent = n.label, i.addEventListener("click", () => e.onAction(n.action)), t.appendChild(i);
|
|
2012
|
+
}
|
|
2013
|
+
return t;
|
|
2014
|
+
}
|
|
2015
|
+
function da(o, e) {
|
|
2016
|
+
const t = document.createElement("button");
|
|
2017
|
+
t.className = "gengage-chat-action-btn";
|
|
2018
|
+
const a = o.props?.label;
|
|
2019
|
+
typeof a == "string" && (t.textContent = a);
|
|
2020
|
+
const n = o.props?.action;
|
|
2021
|
+
return n && t.addEventListener("click", () => e.onAction(n)), t;
|
|
2022
|
+
}
|
|
2023
|
+
function pa(o, e) {
|
|
2024
|
+
const t = document.createElement("div");
|
|
2025
|
+
t.className = "gengage-chat-product-card";
|
|
2026
|
+
const a = o.props?.product ?? o.props;
|
|
2027
|
+
if (!a) return t;
|
|
2028
|
+
const n = a.sku;
|
|
2029
|
+
n && (t.dataset.sku = n), e.onProductSelect && (t.style.cursor = "pointer", t.addEventListener("click", (v) => {
|
|
2030
|
+
v.target.closest(".gengage-chat-product-card-atc") || v.target.closest(".gengage-chat-product-card-cta") || e.onProductSelect?.(a);
|
|
2031
|
+
}));
|
|
2032
|
+
const i = a.imageUrl;
|
|
2033
|
+
if (i && H(i)) {
|
|
2034
|
+
const v = document.createElement("div");
|
|
2035
|
+
v.className = "gengage-chat-product-card-img-wrapper";
|
|
2036
|
+
const h = document.createElement("img");
|
|
2037
|
+
h.className = "gengage-chat-product-card-img", h.loading = "lazy", U(h, "src", i);
|
|
2038
|
+
const L = a.name;
|
|
2039
|
+
L && (h.alt = L), X(h), v.appendChild(h);
|
|
2040
|
+
const A = a.discountPercent;
|
|
2041
|
+
if (typeof A == "number" && A > 0) {
|
|
2042
|
+
const k = document.createElement("span");
|
|
2043
|
+
k.className = "gengage-chat-product-card-discount-badge", k.textContent = `%${ce(A)}`, v.appendChild(k);
|
|
2044
|
+
}
|
|
2045
|
+
const u = a.sku;
|
|
2046
|
+
if (u) {
|
|
2047
|
+
const k = document.createElement("button");
|
|
2048
|
+
k.className = "gengage-chat-find-similar-pill", k.type = "button", k.textContent = e.i18n?.findSimilarLabel ?? "Find Similar", k.addEventListener("click", (P) => {
|
|
2049
|
+
P.stopPropagation(), e.onAction({
|
|
2050
|
+
title: e.i18n?.findSimilarLabel ?? "Find Similar",
|
|
2051
|
+
type: "findSimilar",
|
|
2052
|
+
payload: { sku: u, ...i ? { image_url: i } : {} }
|
|
2053
|
+
});
|
|
2054
|
+
}), v.appendChild(k);
|
|
2055
|
+
}
|
|
2056
|
+
const b = a.sku;
|
|
2057
|
+
if (b && e.onFavoriteToggle) {
|
|
2058
|
+
const k = document.createElement("button");
|
|
2059
|
+
k.className = "gengage-chat-favorite-btn", k.type = "button", k.setAttribute("aria-label", e.i18n?.addToFavoritesLabel ?? "Add to favorites");
|
|
2060
|
+
const P = e.favoritedSkus?.has(b) ?? !1;
|
|
2061
|
+
P && k.classList.add("gengage-chat-favorite-btn--active");
|
|
2062
|
+
const z = P ? "currentColor" : "none";
|
|
2063
|
+
k.innerHTML = `<svg width="16" height="16" viewBox="0 0 24 24" fill="${z}" 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>`, k.addEventListener("click", (T) => {
|
|
2064
|
+
T.stopPropagation(), k.classList.toggle("gengage-chat-favorite-btn--active");
|
|
2065
|
+
const N = k.querySelector("svg");
|
|
2066
|
+
N && N.setAttribute(
|
|
2067
|
+
"fill",
|
|
2068
|
+
k.classList.contains("gengage-chat-favorite-btn--active") ? "currentColor" : "none"
|
|
2069
|
+
), e.onFavoriteToggle(b, a);
|
|
2070
|
+
}), v.appendChild(k);
|
|
2071
|
+
}
|
|
2072
|
+
t.appendChild(v);
|
|
2073
|
+
}
|
|
2074
|
+
const s = document.createElement("div");
|
|
2075
|
+
s.className = "gengage-chat-product-card-body";
|
|
2076
|
+
const l = a.brand;
|
|
2077
|
+
if (l) {
|
|
2078
|
+
const v = document.createElement("div");
|
|
2079
|
+
v.className = "gengage-chat-product-card-brand", v.textContent = l, s.appendChild(v);
|
|
2080
|
+
}
|
|
2081
|
+
const r = a.name;
|
|
2082
|
+
if (r) {
|
|
2083
|
+
const v = document.createElement("div");
|
|
2084
|
+
v.className = "gengage-chat-product-card-name", v.textContent = r, s.appendChild(v);
|
|
2085
|
+
}
|
|
2086
|
+
const c = a.rating, g = a.reviewCount;
|
|
2087
|
+
if (typeof c == "number" && Number.isFinite(c)) {
|
|
2088
|
+
const v = document.createElement("div");
|
|
2089
|
+
if (v.className = "gengage-chat-product-card-rating", v.textContent = ye(c), typeof g == "number" && Number.isFinite(g)) {
|
|
2090
|
+
const h = document.createElement("span");
|
|
2091
|
+
h.className = "gengage-chat-product-card-review-count", h.textContent = ` (${g})`, v.appendChild(h);
|
|
2092
|
+
}
|
|
2093
|
+
s.appendChild(v);
|
|
2094
|
+
}
|
|
2095
|
+
const d = a.price, m = a.originalPrice;
|
|
2096
|
+
if (a.price_async === !0) {
|
|
2097
|
+
const v = document.createElement("div");
|
|
2098
|
+
v.className = "gengage-chat-product-card-price";
|
|
2099
|
+
const h = document.createElement("span");
|
|
2100
|
+
h.className = "gengage-chat-price-skeleton", v.appendChild(h), s.appendChild(v), setTimeout(() => {
|
|
2101
|
+
h.parentElement && (d ? h.replaceWith(document.createTextNode(q(d, e.pricing))) : h.remove());
|
|
2102
|
+
}, 300);
|
|
2103
|
+
} else if (d) {
|
|
2104
|
+
const v = document.createElement("div");
|
|
2105
|
+
if (v.className = "gengage-chat-product-card-price", m && m !== d) {
|
|
2106
|
+
const L = document.createElement("span");
|
|
2107
|
+
L.className = "gengage-chat-product-card-original-price", L.textContent = q(m, e.pricing), v.appendChild(L), v.appendChild(document.createTextNode(" "));
|
|
2108
|
+
}
|
|
2109
|
+
const h = document.createElement("span");
|
|
2110
|
+
h.textContent = q(d, e.pricing), v.appendChild(h), s.appendChild(v);
|
|
2111
|
+
}
|
|
2112
|
+
const y = a.inStock;
|
|
2113
|
+
if (typeof y == "boolean") {
|
|
2114
|
+
const v = document.createElement("div");
|
|
2115
|
+
v.className = `gengage-chat-product-card-stock ${y ? "is-in-stock" : "is-out-of-stock"}`, v.textContent = y ? e.i18n?.inStockLabel ?? "In Stock" : e.i18n?.outOfStockLabel ?? "Out of Stock", s.appendChild(v);
|
|
2116
|
+
}
|
|
2117
|
+
const _ = a.promotions;
|
|
2118
|
+
if (_ && _.length > 0) {
|
|
2119
|
+
const v = document.createElement("div");
|
|
2120
|
+
v.className = "gengage-chat-product-card-promos";
|
|
2121
|
+
for (const h of _) {
|
|
2122
|
+
const L = document.createElement("span");
|
|
2123
|
+
L.className = "gengage-chat-product-card-promo-badge", L.textContent = h, v.appendChild(L);
|
|
2124
|
+
}
|
|
2125
|
+
s.appendChild(v);
|
|
2126
|
+
}
|
|
2127
|
+
t.appendChild(s);
|
|
2128
|
+
const x = a.url, E = a.sku, I = o.props?.action;
|
|
2129
|
+
if (I) {
|
|
2130
|
+
const v = document.createElement("button");
|
|
2131
|
+
v.className = "gengage-chat-product-card-cta", v.type = "button", v.textContent = I.title || e.i18n?.productCtaLabel || "View", v.addEventListener("click", () => e.onAction(I)), t.appendChild(v);
|
|
2132
|
+
} else if (x && H(x)) {
|
|
2133
|
+
const v = document.createElement("a");
|
|
2134
|
+
v.className = "gengage-chat-product-card-cta", U(v, "href", x), U(v, "target", "_blank"), U(v, "rel", "noopener noreferrer"), v.textContent = e.i18n?.productCtaLabel ?? "View", v.addEventListener("click", (h) => {
|
|
2135
|
+
e.onProductClick && E && (h.preventDefault(), e.onProductClick({ sku: E, url: x }));
|
|
2136
|
+
}), t.appendChild(v);
|
|
2137
|
+
}
|
|
2138
|
+
const S = a.cartCode;
|
|
2139
|
+
if (S && E && y !== !1) {
|
|
2140
|
+
const v = ke({
|
|
2141
|
+
compact: !0,
|
|
2142
|
+
label: e.i18n?.addToCartButton ?? "Add to Cart",
|
|
2143
|
+
decreaseLabel: e.i18n?.decreaseLabel,
|
|
2144
|
+
increaseLabel: e.i18n?.increaseLabel,
|
|
2145
|
+
onSubmit: (h) => {
|
|
2146
|
+
e.onAction({
|
|
2147
|
+
title: e.i18n?.addToCartButton ?? "Add to Cart",
|
|
2148
|
+
type: "addToCart",
|
|
2149
|
+
payload: { sku: E, cartCode: S, quantity: h }
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
});
|
|
2153
|
+
v.classList.add("gengage-chat-product-card-atc"), t.appendChild(v);
|
|
2154
|
+
}
|
|
2155
|
+
if (e.comparisonSelectMode && E && e.onToggleComparisonSku) {
|
|
2156
|
+
const v = document.createElement("div");
|
|
2157
|
+
v.className = "gengage-chat-comparison-select-wrapper";
|
|
2158
|
+
const h = document.createElement("input");
|
|
2159
|
+
return h.type = "checkbox", h.className = "gengage-chat-comparison-checkbox", h.checked = e.comparisonSelectedSkus?.includes(E) ?? !1, h.addEventListener("change", () => {
|
|
2160
|
+
e.onToggleComparisonSku?.(E);
|
|
2161
|
+
}), v.appendChild(h), v.appendChild(t), v;
|
|
2162
|
+
}
|
|
2163
|
+
return t;
|
|
2164
|
+
}
|
|
2165
|
+
function ha(o, e) {
|
|
2166
|
+
const t = document.createElement("article");
|
|
2167
|
+
t.className = "gengage-chat-product-details-panel";
|
|
2168
|
+
const a = o.props?.product ?? o.props;
|
|
2169
|
+
if (!a) return t;
|
|
2170
|
+
const n = a.images, i = a.imageUrl, s = a.sku;
|
|
2171
|
+
if (n && n.length > 1) {
|
|
2172
|
+
const u = document.createElement("div");
|
|
2173
|
+
u.className = "gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";
|
|
2174
|
+
const b = document.createElement("img");
|
|
2175
|
+
b.className = "gengage-chat-product-details-img";
|
|
2176
|
+
const k = n.find((M) => H(M));
|
|
2177
|
+
k && U(b, "src", k);
|
|
2178
|
+
const P = a.name;
|
|
2179
|
+
P && (b.alt = P), X(b), u.appendChild(b);
|
|
2180
|
+
const z = document.createElement("div");
|
|
2181
|
+
z.className = "gengage-chat-product-gallery-thumbs";
|
|
2182
|
+
let T = null, N = 0;
|
|
2183
|
+
for (let M = 0; M < n.length; M++) {
|
|
2184
|
+
const F = n[M];
|
|
2185
|
+
if (!F || !H(F)) continue;
|
|
2186
|
+
const R = document.createElement("img");
|
|
2187
|
+
R.className = "gengage-chat-product-gallery-thumb", M === 0 && (R.classList.add("gengage-chat-product-gallery-thumb--active"), T = R), U(R, "src", F), R.alt = `${P ?? "Product"} ${M + 1}`, R.width = 48, R.height = 48, X(R), R.addEventListener("click", () => {
|
|
2188
|
+
U(b, "src", F), T && T.classList.remove("gengage-chat-product-gallery-thumb--active"), R.classList.add("gengage-chat-product-gallery-thumb--active"), T = R, N = M;
|
|
2189
|
+
}), z.appendChild(R);
|
|
2190
|
+
}
|
|
2191
|
+
let f = 0;
|
|
2192
|
+
const C = 50;
|
|
2193
|
+
if (b.addEventListener(
|
|
2194
|
+
"touchstart",
|
|
2195
|
+
(M) => {
|
|
2196
|
+
f = M.changedTouches[0].clientX;
|
|
2197
|
+
},
|
|
2198
|
+
{ passive: !0 }
|
|
2199
|
+
), b.addEventListener("touchend", (M) => {
|
|
2200
|
+
const F = M.changedTouches[0].clientX, R = f - F;
|
|
2201
|
+
if (Math.abs(R) < C) return;
|
|
2202
|
+
const ae = z.querySelectorAll(".gengage-chat-product-gallery-thumb"), ne = R > 0 ? Math.min(N + 1, ae.length - 1) : Math.max(N - 1, 0);
|
|
2203
|
+
ne !== N && ae[ne] && ae[ne].click();
|
|
2204
|
+
}), u.appendChild(z), s) {
|
|
2205
|
+
const M = document.createElement("button");
|
|
2206
|
+
M.className = "gengage-chat-find-similar-pill", M.type = "button", M.textContent = e.i18n?.findSimilarLabel ?? "Find Similar", M.addEventListener("click", () => {
|
|
2207
|
+
e.onAction({
|
|
2208
|
+
title: e.i18n?.findSimilarLabel ?? "Find Similar",
|
|
2209
|
+
type: "findSimilar",
|
|
2210
|
+
payload: { sku: s, ...k ? { image_url: k } : {} }
|
|
2211
|
+
});
|
|
2212
|
+
}), u.appendChild(M);
|
|
2213
|
+
}
|
|
2214
|
+
t.appendChild(u);
|
|
2215
|
+
} else if (i && H(i)) {
|
|
2216
|
+
const u = document.createElement("div");
|
|
2217
|
+
u.className = "gengage-chat-product-details-media gengage-chat-product-details-img-wrap";
|
|
2218
|
+
const b = document.createElement("img");
|
|
2219
|
+
b.className = "gengage-chat-product-details-img", b.loading = "lazy", U(b, "src", i), X(b);
|
|
2220
|
+
const k = a.name;
|
|
2221
|
+
if (k && (b.alt = k), u.appendChild(b), s) {
|
|
2222
|
+
const P = document.createElement("button");
|
|
2223
|
+
P.className = "gengage-chat-find-similar-pill", P.type = "button", P.textContent = e.i18n?.findSimilarLabel ?? "Find Similar", P.addEventListener("click", () => {
|
|
2224
|
+
e.onAction({
|
|
2225
|
+
title: e.i18n?.findSimilarLabel ?? "Find Similar",
|
|
2226
|
+
type: "findSimilar",
|
|
2227
|
+
payload: { sku: s, ...i ? { image_url: i } : {} }
|
|
2228
|
+
});
|
|
2229
|
+
}), u.appendChild(P);
|
|
2230
|
+
}
|
|
2231
|
+
t.appendChild(u);
|
|
2232
|
+
}
|
|
2233
|
+
const l = document.createElement("div");
|
|
2234
|
+
l.className = "gengage-chat-product-details-content";
|
|
2235
|
+
const r = a.name;
|
|
2236
|
+
if (r) {
|
|
2237
|
+
const u = document.createElement("h3");
|
|
2238
|
+
u.className = "gengage-chat-product-details-title", u.textContent = r, l.appendChild(u);
|
|
2239
|
+
}
|
|
2240
|
+
const c = a.rating, g = a.reviewCount;
|
|
2241
|
+
if (typeof c == "number" && Number.isFinite(c)) {
|
|
2242
|
+
const u = document.createElement("div");
|
|
2243
|
+
if (u.className = "gengage-chat-product-details-rating", u.textContent = `★ ${_e(c).toFixed(1)}`, typeof g == "number" && Number.isFinite(g)) {
|
|
2244
|
+
const b = document.createElement("span");
|
|
2245
|
+
b.className = "gengage-chat-product-details-review-count", b.textContent = ` (${g})`, u.appendChild(b);
|
|
2246
|
+
}
|
|
2247
|
+
l.appendChild(u);
|
|
2248
|
+
}
|
|
2249
|
+
const d = a.price, m = a.originalPrice;
|
|
2250
|
+
if (a.price_async === !0) {
|
|
2251
|
+
const u = document.createElement("div");
|
|
2252
|
+
u.className = "gengage-chat-product-details-price";
|
|
2253
|
+
const b = document.createElement("span");
|
|
2254
|
+
b.className = "gengage-chat-price-skeleton", u.appendChild(b), l.appendChild(u), setTimeout(() => {
|
|
2255
|
+
if (b.parentElement)
|
|
2256
|
+
if (d) {
|
|
2257
|
+
const k = document.createElement("span");
|
|
2258
|
+
k.className = "gengage-chat-product-details-current-price", k.textContent = q(d, e.pricing), b.replaceWith(k);
|
|
2259
|
+
} else
|
|
2260
|
+
b.remove();
|
|
2261
|
+
}, 300);
|
|
2262
|
+
} else if (d) {
|
|
2263
|
+
const u = document.createElement("div");
|
|
2264
|
+
if (u.className = "gengage-chat-product-details-price", m && m !== d) {
|
|
2265
|
+
const k = document.createElement("span");
|
|
2266
|
+
k.className = "gengage-chat-product-details-original-price", k.textContent = q(m, e.pricing), u.appendChild(k), u.appendChild(document.createTextNode(" "));
|
|
2267
|
+
}
|
|
2268
|
+
const b = document.createElement("span");
|
|
2269
|
+
b.className = "gengage-chat-product-details-current-price", b.textContent = q(d, e.pricing), u.appendChild(b), l.appendChild(u);
|
|
2270
|
+
}
|
|
2271
|
+
const y = a.inStock;
|
|
2272
|
+
if (typeof y == "boolean") {
|
|
2273
|
+
const u = document.createElement("div");
|
|
2274
|
+
u.className = `gengage-chat-product-details-stock ${y ? "is-in-stock" : "is-out-of-stock"}`, u.textContent = y ? e.i18n?.inStockLabel ?? "In Stock" : e.i18n?.outOfStockLabel ?? "Out of Stock", l.appendChild(u);
|
|
2275
|
+
}
|
|
2276
|
+
const _ = a.promotions;
|
|
2277
|
+
if (_ && _.length > 0) {
|
|
2278
|
+
const u = document.createElement("div");
|
|
2279
|
+
u.className = "gengage-chat-product-details-promos";
|
|
2280
|
+
for (const b of _) {
|
|
2281
|
+
const k = document.createElement("span");
|
|
2282
|
+
k.className = "gengage-chat-product-details-promo-badge", k.textContent = b, u.appendChild(k);
|
|
2283
|
+
}
|
|
2284
|
+
l.appendChild(u);
|
|
2285
|
+
}
|
|
2286
|
+
const x = a.variants;
|
|
2287
|
+
if (x && x.length > 0) {
|
|
2288
|
+
const u = document.createElement("div");
|
|
2289
|
+
u.className = "gengage-chat-product-variants";
|
|
2290
|
+
const b = document.createElement("div");
|
|
2291
|
+
b.className = "gengage-chat-product-variants-label", b.textContent = e.i18n?.variantsLabel ?? "Variants", u.appendChild(b);
|
|
2292
|
+
const k = document.createElement("div");
|
|
2293
|
+
k.className = "gengage-chat-product-variants-list";
|
|
2294
|
+
for (const P of x) {
|
|
2295
|
+
const z = P.name ?? P.variant_name, T = P.sku;
|
|
2296
|
+
if (!z && !T) continue;
|
|
2297
|
+
const N = document.createElement("button");
|
|
2298
|
+
N.className = "gengage-chat-product-variant-btn", N.type = "button";
|
|
2299
|
+
const f = z ?? T ?? "", C = P.price;
|
|
2300
|
+
C && String(C) !== String(d) ? N.textContent = `${f} - ${q(String(C), e.pricing)}` : N.textContent = f, T && N.addEventListener("click", () => {
|
|
2301
|
+
e.onAction({
|
|
2302
|
+
title: f,
|
|
2303
|
+
type: "launchVariant",
|
|
2304
|
+
payload: { sku: T }
|
|
2305
|
+
});
|
|
2306
|
+
}), k.appendChild(N);
|
|
2307
|
+
}
|
|
2308
|
+
u.appendChild(k), l.appendChild(u);
|
|
2309
|
+
}
|
|
2310
|
+
const E = a.sku, I = a.cartCode, S = document.createElement("div");
|
|
2311
|
+
S.className = "gengage-chat-product-details-actions";
|
|
2312
|
+
const v = o.props?.action;
|
|
2313
|
+
if (v) {
|
|
2314
|
+
const u = document.createElement("button");
|
|
2315
|
+
u.className = "gengage-chat-product-details-cta", u.type = "button", u.textContent = v.title || e.i18n?.productCtaLabel || "View", u.addEventListener("click", () => e.onAction(v)), S.appendChild(u);
|
|
2316
|
+
} else {
|
|
2317
|
+
const u = a.url;
|
|
2318
|
+
if (u && H(u)) {
|
|
2319
|
+
const b = document.createElement("a");
|
|
2320
|
+
b.className = "gengage-chat-product-details-cta", U(b, "href", u), U(b, "target", "_blank"), U(b, "rel", "noopener noreferrer"), b.textContent = e.i18n?.productCtaLabel ?? "View", b.addEventListener("click", (k) => {
|
|
2321
|
+
e.onProductClick && E && (k.preventDefault(), e.onProductClick({ sku: E, url: u }));
|
|
2322
|
+
}), S.appendChild(b);
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
if (I && E && y !== !1) {
|
|
2326
|
+
const u = ke({
|
|
2327
|
+
compact: !1,
|
|
2328
|
+
label: e.i18n?.addToCartButton ?? "Add to Cart",
|
|
2329
|
+
decreaseLabel: e.i18n?.decreaseLabel,
|
|
2330
|
+
increaseLabel: e.i18n?.increaseLabel,
|
|
2331
|
+
onSubmit: (b) => {
|
|
2332
|
+
e.onAction({
|
|
2333
|
+
title: e.i18n?.addToCartButton ?? "Add to Cart",
|
|
2334
|
+
type: "addToCart",
|
|
2335
|
+
payload: { sku: E, cartCode: I, quantity: b }
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
});
|
|
2339
|
+
u.classList.add("gengage-chat-product-details-atc-stepper"), S.appendChild(u);
|
|
2340
|
+
}
|
|
2341
|
+
const h = a.url;
|
|
2342
|
+
if (h && H(h)) {
|
|
2343
|
+
let u = function(N, f) {
|
|
2344
|
+
const C = document.createElementNS(z, "circle");
|
|
2345
|
+
C.setAttribute("cx", N), C.setAttribute("cy", f), C.setAttribute("r", "3"), T.appendChild(C);
|
|
2346
|
+
}, b = function(N, f, C, M) {
|
|
2347
|
+
const F = document.createElementNS(z, "line");
|
|
2348
|
+
F.setAttribute("x1", N), F.setAttribute("y1", f), F.setAttribute("x2", C), F.setAttribute("y2", M), T.appendChild(F);
|
|
2349
|
+
};
|
|
2350
|
+
const k = document.createElement("button");
|
|
2351
|
+
k.className = "gengage-chat-product-details-share", k.type = "button";
|
|
2352
|
+
const P = e.i18n?.shareButton ?? "Share";
|
|
2353
|
+
k.title = P, k.setAttribute("aria-label", P);
|
|
2354
|
+
const z = "http://www.w3.org/2000/svg", T = document.createElementNS(z, "svg");
|
|
2355
|
+
T.setAttribute("width", "18"), T.setAttribute("height", "18"), T.setAttribute("viewBox", "0 0 24 24"), T.setAttribute("fill", "none"), T.setAttribute("stroke", "currentColor"), T.setAttribute("stroke-width", "2"), T.setAttribute("stroke-linecap", "round"), T.setAttribute("stroke-linejoin", "round"), u("18", "5"), u("6", "12"), u("18", "19"), b("8.59", "13.51", "15.42", "17.49"), b("15.41", "6.51", "8.59", "10.49"), k.appendChild(T), k.addEventListener("click", async () => {
|
|
2356
|
+
const N = a.name;
|
|
2357
|
+
try {
|
|
2358
|
+
navigator.share ? await navigator.share({ title: N ?? "", url: h }) : navigator.clipboard && (await navigator.clipboard.writeText(h), k.classList.add("gengage-chat-product-details-share--copied"), setTimeout(() => k.classList.remove("gengage-chat-product-details-share--copied"), 1500));
|
|
2359
|
+
} catch {
|
|
2360
|
+
}
|
|
2361
|
+
}), S.appendChild(k);
|
|
2362
|
+
}
|
|
2363
|
+
S.childElementCount > 0 && l.appendChild(S), t.appendChild(l);
|
|
2364
|
+
const L = a.description, A = a.specifications;
|
|
2365
|
+
return (L || A) && t.appendChild(ua(L, A, e)), t;
|
|
2366
|
+
}
|
|
2367
|
+
function ua(o, e, t) {
|
|
2368
|
+
const a = document.createElement("div");
|
|
2369
|
+
a.className = "gengage-chat-product-detail-tabs";
|
|
2370
|
+
const n = document.createElement("div");
|
|
2371
|
+
n.className = "gengage-chat-product-detail-tab-bar";
|
|
2372
|
+
const i = [];
|
|
2373
|
+
if (o) {
|
|
2374
|
+
const l = document.createElement("button");
|
|
2375
|
+
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);
|
|
2376
|
+
const r = document.createElement("div");
|
|
2377
|
+
r.className = "gengage-chat-product-detail-tab-panel", r.textContent = o, i.push(r);
|
|
2378
|
+
}
|
|
2379
|
+
if (e) {
|
|
2380
|
+
const l = document.createElement("button");
|
|
2381
|
+
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);
|
|
2382
|
+
const r = document.createElement("div");
|
|
2383
|
+
r.className = "gengage-chat-product-detail-tab-panel", o && (r.style.display = "none");
|
|
2384
|
+
const c = document.createElement("table");
|
|
2385
|
+
c.className = "gengage-chat-product-specs-table";
|
|
2386
|
+
const g = Array.isArray(e) ? e : Object.entries(e).map(([d, m]) => ({ key: d, value: m }));
|
|
2387
|
+
for (const d of g) {
|
|
2388
|
+
const m = document.createElement("tr"), p = document.createElement("td");
|
|
2389
|
+
p.className = "gengage-chat-product-specs-key", p.textContent = d.key;
|
|
2390
|
+
const y = document.createElement("td");
|
|
2391
|
+
y.className = "gengage-chat-product-specs-value", y.textContent = d.value, m.appendChild(p), m.appendChild(y), c.appendChild(m);
|
|
2392
|
+
}
|
|
2393
|
+
r.appendChild(c), i.push(r);
|
|
2394
|
+
}
|
|
2395
|
+
const s = n.querySelectorAll(".gengage-chat-product-detail-tab");
|
|
2396
|
+
s.forEach((l, r) => {
|
|
2397
|
+
l.addEventListener("click", () => {
|
|
2398
|
+
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) => {
|
|
2399
|
+
c.style.display = g === r ? "" : "none";
|
|
2400
|
+
});
|
|
2401
|
+
});
|
|
2402
|
+
}), a.appendChild(n);
|
|
2403
|
+
for (const l of i) a.appendChild(l);
|
|
2404
|
+
return a;
|
|
2405
|
+
}
|
|
2406
|
+
function Pe(o, e, t) {
|
|
2407
|
+
if (!t || t.type === "related") return o;
|
|
2408
|
+
const a = o.map((n) => {
|
|
2409
|
+
const s = e.elements[n]?.props?.product, l = s ? Number(s.price) : NaN;
|
|
2410
|
+
return { id: n, price: Number.isFinite(l) ? l : 1 / 0 };
|
|
2411
|
+
});
|
|
2412
|
+
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);
|
|
2413
|
+
}
|
|
2414
|
+
function ma(o, e, t, a) {
|
|
2415
|
+
const n = Pe(e, t, a), i = /* @__PURE__ */ new Map();
|
|
2416
|
+
for (const s of Array.from(o.children)) {
|
|
2417
|
+
const l = s.dataset.elementId;
|
|
2418
|
+
l && i.set(l, s);
|
|
2419
|
+
}
|
|
2420
|
+
for (const s of n) {
|
|
2421
|
+
const l = i.get(s);
|
|
2422
|
+
l && o.appendChild(l);
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
function fa(o, e, t, a) {
|
|
2426
|
+
const n = document.createElement("div");
|
|
2427
|
+
n.className = "gengage-chat-product-grid-wrapper";
|
|
2428
|
+
const i = o.children ?? [];
|
|
2429
|
+
if (i.length > 1 && a?.onSortChange) {
|
|
2430
|
+
const c = document.createElement("div");
|
|
2431
|
+
c.className = "gengage-chat-product-sort-toolbar";
|
|
2432
|
+
const g = a.productSort ?? { type: "related" }, d = [
|
|
2433
|
+
{ label: a.i18n?.sortRelated ?? "Related", sortState: { type: "related" } },
|
|
2434
|
+
{ label: a.i18n?.sortPriceAsc ?? "Price ↑", sortState: { type: "price", direction: "asc" } },
|
|
2435
|
+
{ label: a.i18n?.sortPriceDesc ?? "Price ↓", sortState: { type: "price", direction: "desc" } }
|
|
2436
|
+
];
|
|
2437
|
+
for (const m of d) {
|
|
2438
|
+
const p = document.createElement("button");
|
|
2439
|
+
p.className = "gengage-chat-product-sort-btn", p.type = "button", g.type === m.sortState.type && g.direction === m.sortState.direction && p.classList.add("gengage-chat-product-sort-btn--active"), p.textContent = m.label, p.addEventListener("click", () => {
|
|
2440
|
+
a.onSortChange?.(m.sortState), ma(s, i, e, m.sortState), c.querySelectorAll(".gengage-chat-product-sort-btn").forEach((_) => _.classList.remove("gengage-chat-product-sort-btn--active")), p.classList.add("gengage-chat-product-sort-btn--active");
|
|
2441
|
+
}), c.appendChild(p);
|
|
2442
|
+
}
|
|
2443
|
+
if (a.onToggleComparisonSku) {
|
|
2444
|
+
const m = document.createElement("div");
|
|
2445
|
+
m.className = "gengage-chat-product-sort-separator", c.appendChild(m);
|
|
2446
|
+
const p = document.createElement("button");
|
|
2447
|
+
p.className = "gengage-chat-comparison-toggle-btn", p.type = "button", a.comparisonSelectMode && p.classList.add("gengage-chat-comparison-toggle-btn--active"), p.textContent = a.i18n?.compareSelected ?? "Compare", p.addEventListener("click", () => {
|
|
2448
|
+
a.onToggleComparisonSku?.("");
|
|
2449
|
+
}), c.appendChild(p);
|
|
2450
|
+
}
|
|
2451
|
+
n.appendChild(c);
|
|
2452
|
+
}
|
|
2453
|
+
const s = document.createElement("div");
|
|
2454
|
+
s.className = "gengage-chat-product-grid";
|
|
2455
|
+
const l = Pe(i, e, a?.productSort);
|
|
2456
|
+
for (const c of l) {
|
|
2457
|
+
if (!e.elements[c]) continue;
|
|
2458
|
+
const g = t(c);
|
|
2459
|
+
g && (g.dataset.elementId = c, s.appendChild(g));
|
|
2460
|
+
}
|
|
2461
|
+
if (Ie() && s.classList.add("gengage-chat-product-grid--mobile"), n.appendChild(s), o.props?.endOfList !== !0 && i.length > 0) {
|
|
2462
|
+
const c = document.createElement("button");
|
|
2463
|
+
c.className = "gengage-chat-product-grid-view-more", c.type = "button", c.textContent = a?.i18n?.viewMoreLabel ?? "Show More", c.addEventListener("click", () => {
|
|
2464
|
+
a?.onAction({ title: "More", type: "moreProductList", payload: {} });
|
|
2465
|
+
}), n.appendChild(c);
|
|
2466
|
+
}
|
|
2467
|
+
if (a?.comparisonSelectMode && a.comparisonSelectedSkus && a.comparisonSelectedSkus.length >= 2) {
|
|
2468
|
+
const c = aa(a.comparisonSelectedSkus, a);
|
|
2469
|
+
n.appendChild(c);
|
|
2470
|
+
}
|
|
2471
|
+
return n;
|
|
2472
|
+
}
|
|
2473
|
+
function ba(o, e) {
|
|
2474
|
+
const t = o.props ?? {}, a = t.keyDifferencesHtml, n = t.recommended, i = t.products ?? [], s = t.attributes ?? [], l = t.highlights ?? [], r = t.specialCases, c = t.recommendedText, g = t.winnerHits, d = t.productActions;
|
|
2475
|
+
if (!n)
|
|
2476
|
+
return document.createElement("div");
|
|
2477
|
+
const m = {
|
|
2478
|
+
recommended: n,
|
|
2479
|
+
products: i,
|
|
2480
|
+
attributes: s,
|
|
2481
|
+
highlights: l,
|
|
2482
|
+
specialCases: r,
|
|
2483
|
+
onProductClick: (y) => {
|
|
2484
|
+
e.onProductClick?.({ sku: y, url: "" });
|
|
2485
|
+
},
|
|
2486
|
+
pricing: e.pricing
|
|
2487
|
+
};
|
|
2488
|
+
c !== void 0 && (m.recommendedText = c), g !== void 0 && (m.winnerHits = g), d !== void 0 && (m.productActions = d), a !== void 0 && (m.keyDifferencesHtml = a), e.i18n && (m.i18n = {
|
|
2489
|
+
comparisonHeading: e.i18n.panelTitleComparisonResults,
|
|
2490
|
+
recommendedChoiceLabel: e.i18n.recommendedChoiceLabel,
|
|
2491
|
+
highlightsLabel: e.i18n.highlightsLabel,
|
|
2492
|
+
keyDifferencesLabel: e.i18n.keyDifferencesLabel,
|
|
2493
|
+
specialCasesLabel: e.i18n.specialCasesLabel,
|
|
2494
|
+
addToCartButton: e.i18n.addToCartButton
|
|
2495
|
+
});
|
|
2496
|
+
const p = jt(m);
|
|
2497
|
+
return Ie() && p.classList.add("gengage-chat-comparison--mobile"), p;
|
|
2498
|
+
}
|
|
2499
|
+
function xa(o) {
|
|
2500
|
+
const e = document.createElement("hr");
|
|
2501
|
+
e.className = "gengage-chat-divider";
|
|
2502
|
+
const t = o.props?.label;
|
|
2503
|
+
if (t) {
|
|
2504
|
+
const a = document.createElement("div");
|
|
2505
|
+
a.className = "gengage-chat-divider-wrapper";
|
|
2506
|
+
const n = document.createElement("span");
|
|
2507
|
+
return n.className = "gengage-chat-divider-label", n.textContent = t, a.appendChild(e), a.appendChild(n), a;
|
|
2508
|
+
}
|
|
2509
|
+
return e;
|
|
2510
|
+
}
|
|
2511
|
+
const va = /* @__PURE__ */ new Set([
|
|
2512
|
+
"P",
|
|
2513
|
+
"DIV",
|
|
2514
|
+
"H1",
|
|
2515
|
+
"H2",
|
|
2516
|
+
"H3",
|
|
2517
|
+
"H4",
|
|
2518
|
+
"H5",
|
|
2519
|
+
"H6",
|
|
2520
|
+
"LI",
|
|
2521
|
+
"UL",
|
|
2522
|
+
"OL",
|
|
2523
|
+
"BLOCKQUOTE",
|
|
2524
|
+
"PRE",
|
|
2525
|
+
"TABLE",
|
|
2526
|
+
"SECTION",
|
|
2527
|
+
"HR",
|
|
2528
|
+
"FIGURE",
|
|
2529
|
+
"FIGCAPTION",
|
|
2530
|
+
"DL",
|
|
2531
|
+
"DT",
|
|
2532
|
+
"DD"
|
|
2533
|
+
]);
|
|
2534
|
+
function wa(o) {
|
|
2535
|
+
const e = [];
|
|
2536
|
+
let t = [];
|
|
2537
|
+
for (const a of o)
|
|
2538
|
+
a.nodeType === Node.ELEMENT_NODE && va.has(a.tagName) ? (t.length > 0 && (e.push(t), t = []), e.push([a])) : t.push(a);
|
|
2539
|
+
return t.length > 0 && e.push(t), e;
|
|
2540
|
+
}
|
|
2541
|
+
function ya(o) {
|
|
2542
|
+
for (const e of o)
|
|
2543
|
+
for (const t of e)
|
|
2544
|
+
if (t.nodeType === Node.ELEMENT_NODE && (t.tagName === "TABLE" || t.querySelector?.("table")))
|
|
2545
|
+
return !0;
|
|
2546
|
+
return !1;
|
|
2547
|
+
}
|
|
2548
|
+
function _a() {
|
|
2549
|
+
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2550
|
+
}
|
|
2551
|
+
function ka(o) {
|
|
2552
|
+
const { container: e, html: t, delayMs: a = 30, onTick: n, onComplete: i } = o, s = document.createElement("template");
|
|
2553
|
+
s.innerHTML = t;
|
|
2554
|
+
const l = wa(s.content.childNodes);
|
|
2555
|
+
if (_a() || l.length <= 1 || ya(l))
|
|
2556
|
+
return e.innerHTML = t, i?.(), { complete() {
|
|
2557
|
+
}, cancel() {
|
|
2558
|
+
}, isRunning: !1 };
|
|
2559
|
+
e.innerHTML = "";
|
|
2560
|
+
let r = 0, c = null, g = !0;
|
|
2561
|
+
function d() {
|
|
2562
|
+
if (!g || r >= l.length) {
|
|
2563
|
+
g = !1, i?.();
|
|
2564
|
+
return;
|
|
2565
|
+
}
|
|
2566
|
+
const m = l[r], p = document.createElement("span");
|
|
2567
|
+
p.className = "gengage-chat-typewriter-block";
|
|
2568
|
+
for (const y of m)
|
|
2569
|
+
p.appendChild(y.cloneNode(!0));
|
|
2570
|
+
e.appendChild(p), r++, n?.(), r < l.length ? c = setTimeout(d, a) : (g = !1, i?.());
|
|
2571
|
+
}
|
|
2572
|
+
return d(), {
|
|
2573
|
+
complete() {
|
|
2574
|
+
g && (c !== null && clearTimeout(c), g = !1, e.innerHTML = t, i?.());
|
|
2575
|
+
},
|
|
2576
|
+
cancel() {
|
|
2577
|
+
c !== null && clearTimeout(c), g = !1;
|
|
2578
|
+
},
|
|
2579
|
+
get isRunning() {
|
|
2580
|
+
return g;
|
|
2581
|
+
}
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
function ue(o) {
|
|
2585
|
+
return o !== void 0 && /[\p{L}\p{N}_]/u.test(o);
|
|
2586
|
+
}
|
|
2587
|
+
function Ca(o) {
|
|
2588
|
+
const { container: e, mentions: t, onProductClick: a } = o;
|
|
2589
|
+
if (t.length === 0) return;
|
|
2590
|
+
const n = /* @__PURE__ */ new Map();
|
|
2591
|
+
for (const i of t)
|
|
2592
|
+
i.short_name.length !== 0 && n.set(i.short_name.toLowerCase(), i);
|
|
2593
|
+
if (n.size !== 0)
|
|
2594
|
+
for (const [i, s] of n) {
|
|
2595
|
+
const l = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
2596
|
+
let r = l.nextNode(), c = !1;
|
|
2597
|
+
for (; r && !c; ) {
|
|
2598
|
+
const g = r.textContent ?? "", d = g.toLowerCase().indexOf(i);
|
|
2599
|
+
if (d === -1) {
|
|
2600
|
+
r = l.nextNode();
|
|
2601
|
+
continue;
|
|
2602
|
+
}
|
|
2603
|
+
const m = d > 0 ? g[d - 1] : void 0, p = g[d + s.short_name.length];
|
|
2604
|
+
if (ue(m) || ue(p)) {
|
|
2605
|
+
r = l.nextNode();
|
|
2606
|
+
continue;
|
|
2607
|
+
}
|
|
2608
|
+
const y = g.slice(0, d), _ = g.slice(d, d + s.short_name.length), x = g.slice(d + s.short_name.length), E = r.parentNode;
|
|
2609
|
+
if (!E) {
|
|
2610
|
+
r = l.nextNode();
|
|
2611
|
+
continue;
|
|
2612
|
+
}
|
|
2613
|
+
const I = document.createElement("a");
|
|
2614
|
+
I.className = "gengage-product-mention", I.textContent = _, I.href = "#", I.addEventListener("click", (S) => {
|
|
2615
|
+
S.preventDefault(), a(s.sku);
|
|
2616
|
+
}), y && E.insertBefore(document.createTextNode(y), r), E.insertBefore(I, r), x && E.insertBefore(document.createTextNode(x), r), E.removeChild(r), c = !0;
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
const Ea = /* @__PURE__ */ new Set(["search", "info", "review", "similar"]), Sa = /* @__PURE__ */ new Set([
|
|
2621
|
+
"quickAnswer",
|
|
2622
|
+
"reviewSummary",
|
|
2623
|
+
"searchDiscovery",
|
|
2624
|
+
"launchDiscovery",
|
|
2625
|
+
"exploreTogetherV2"
|
|
2626
|
+
]);
|
|
2627
|
+
function Ta(o) {
|
|
2628
|
+
return !!(o.icon && Ea.has(o.icon) || o.action?.type && Sa.has(o.action.type));
|
|
2629
|
+
}
|
|
2630
|
+
const Me = "gengage_choice_prompter_dismissed";
|
|
2631
|
+
function La(o) {
|
|
2632
|
+
const e = document.createElement("div");
|
|
2633
|
+
e.className = "gengage-chat-choice-prompter";
|
|
2634
|
+
const t = document.createElement("div");
|
|
2635
|
+
t.className = "gengage-chat-choice-prompter-heading", t.textContent = o.heading, e.appendChild(t);
|
|
2636
|
+
const a = document.createElement("div");
|
|
2637
|
+
a.className = "gengage-chat-choice-prompter-suggestion", a.textContent = o.suggestion, e.appendChild(a);
|
|
2638
|
+
const n = document.createElement("button");
|
|
2639
|
+
n.type = "button", n.className = "gengage-chat-choice-prompter-cta", n.textContent = o.ctaLabel, n.addEventListener("click", () => {
|
|
2640
|
+
me(), e.remove(), o.onCtaClick();
|
|
2641
|
+
}), e.appendChild(n);
|
|
2642
|
+
const i = document.createElement("button");
|
|
2643
|
+
return i.type = "button", i.className = "gengage-chat-choice-prompter-dismiss", i.textContent = "×", i.setAttribute("aria-label", o.dismissAriaLabel ?? "Dismiss"), i.addEventListener("click", () => {
|
|
2644
|
+
me(), e.remove(), o.onDismiss?.();
|
|
2645
|
+
}), e.appendChild(i), e;
|
|
2646
|
+
}
|
|
2647
|
+
function Ia() {
|
|
2648
|
+
try {
|
|
2649
|
+
return sessionStorage.getItem(Me) === "1";
|
|
2650
|
+
} catch {
|
|
2651
|
+
return !1;
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
function me() {
|
|
2655
|
+
try {
|
|
2656
|
+
sessionStorage.setItem(Me, "1");
|
|
2657
|
+
} catch {
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
const Aa = "gengage_assistant", Na = 3, K = "sessions", O = "context", W = "payload", j = "favorites";
|
|
2661
|
+
function ee(o) {
|
|
2662
|
+
return new Promise((e, t) => {
|
|
2663
|
+
o.onsuccess = () => e(o.result), o.onerror = () => t(o.error);
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
function Z(o) {
|
|
2667
|
+
return new Promise((e, t) => {
|
|
2668
|
+
o.oncomplete = () => e(), o.onerror = () => t(o.error), o.onabort = () => t(o.error ?? new DOMException("Transaction aborted"));
|
|
2669
|
+
});
|
|
2670
|
+
}
|
|
2671
|
+
class Pa {
|
|
2672
|
+
constructor(e = Aa, t = Na) {
|
|
2673
|
+
this._db = null, this._dbName = e, this._version = t;
|
|
2674
|
+
}
|
|
2675
|
+
// -------------------------------------------------------------------------
|
|
2676
|
+
// Lifecycle
|
|
2677
|
+
// -------------------------------------------------------------------------
|
|
2678
|
+
async open() {
|
|
2679
|
+
return this._db ? this._db : new Promise((e, t) => {
|
|
2680
|
+
const a = indexedDB.open(this._dbName, this._version);
|
|
2681
|
+
a.onupgradeneeded = (n) => {
|
|
2682
|
+
const i = a.result, s = n.oldVersion;
|
|
2683
|
+
s < 1 && (i.createObjectStore(K, { keyPath: ["userId", "appId", "sessionId"] }), i.createObjectStore(O, { keyPath: ["sessionId", "threadId"] }), i.createObjectStore(W, {
|
|
2684
|
+
keyPath: ["threadId", "messageId"]
|
|
2685
|
+
}).createIndex("threadId", "threadId", { unique: !1 }), i.createObjectStore(j, { keyPath: ["userId", "appId", "sku"] })), s >= 1 && s < 2 && (i.objectStoreNames.contains(K) && i.deleteObjectStore(K), i.objectStoreNames.contains(W) && i.deleteObjectStore(W), i.createObjectStore(K, { keyPath: ["userId", "appId", "sessionId"] }), i.createObjectStore(W, {
|
|
2686
|
+
keyPath: ["threadId", "messageId"]
|
|
2687
|
+
}).createIndex("threadId", "threadId", { unique: !1 }), i.objectStoreNames.contains(O) || i.createObjectStore(O, { keyPath: ["sessionId", "threadId"] })), s < 3 && (i.objectStoreNames.contains(j) || i.createObjectStore(j, { keyPath: ["userId", "appId", "sku"] }));
|
|
2688
|
+
}, a.onsuccess = () => {
|
|
2689
|
+
this._db = a.result, e(this._db);
|
|
2690
|
+
}, a.onerror = () => t(a.error);
|
|
2691
|
+
});
|
|
2692
|
+
}
|
|
2693
|
+
close() {
|
|
2694
|
+
this._db?.close(), this._db = null;
|
|
2695
|
+
}
|
|
2696
|
+
// -------------------------------------------------------------------------
|
|
2697
|
+
// Sessions
|
|
2698
|
+
// -------------------------------------------------------------------------
|
|
2699
|
+
async saveSession(e) {
|
|
2700
|
+
const a = this._requireDb().transaction(K, "readwrite");
|
|
2701
|
+
a.objectStore(K).put(e), await Z(a);
|
|
2702
|
+
}
|
|
2703
|
+
async loadSession(e, t, a) {
|
|
2704
|
+
const i = this._requireDb().transaction(K, "readonly");
|
|
2705
|
+
return await ee(i.objectStore(K).get([e, t, a])) ?? null;
|
|
2706
|
+
}
|
|
2707
|
+
// -------------------------------------------------------------------------
|
|
2708
|
+
// Context (compound key: [sessionId, threadId])
|
|
2709
|
+
// -------------------------------------------------------------------------
|
|
2710
|
+
async saveContext(e) {
|
|
2711
|
+
const a = this._requireDb().transaction(O, "readwrite");
|
|
2712
|
+
a.objectStore(O).put(e), await Z(a);
|
|
2713
|
+
}
|
|
2714
|
+
async loadContext(e, t) {
|
|
2715
|
+
const n = this._requireDb().transaction(O, "readonly");
|
|
2716
|
+
return await ee(n.objectStore(O).get([e, t])) ?? null;
|
|
2717
|
+
}
|
|
2718
|
+
/**
|
|
2719
|
+
* Delete all context entries for a session whose threadId is lexicographically
|
|
2720
|
+
* greater than the given threadId. Used during rollback to prune future branches.
|
|
2721
|
+
*
|
|
2722
|
+
* Thread IDs are UUIDv7 (lexicographically sortable by time), so string
|
|
2723
|
+
* comparison is sufficient.
|
|
2724
|
+
*/
|
|
2725
|
+
async deleteContextsAfterThread(e, t) {
|
|
2726
|
+
const n = this._requireDb().transaction(O, "readwrite"), s = n.objectStore(O).openCursor();
|
|
2727
|
+
await new Promise((l, r) => {
|
|
2728
|
+
s.onsuccess = () => {
|
|
2729
|
+
const c = s.result;
|
|
2730
|
+
if (!c) {
|
|
2731
|
+
l();
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
const g = c.value;
|
|
2735
|
+
if (g.sessionId === e && g.threadId > t)
|
|
2736
|
+
try {
|
|
2737
|
+
c.delete();
|
|
2738
|
+
} catch {
|
|
2739
|
+
}
|
|
2740
|
+
c.continue();
|
|
2741
|
+
}, s.onerror = () => r(s.error);
|
|
2742
|
+
}), await Z(n);
|
|
2743
|
+
}
|
|
2744
|
+
/**
|
|
2745
|
+
* Load the most recent context for a session (latest threadId).
|
|
2746
|
+
* Uses lexicographic ordering of UUIDv7 threadIds for chronological sort.
|
|
2747
|
+
*/
|
|
2748
|
+
async loadLatestContext(e) {
|
|
2749
|
+
const n = this._requireDb().transaction(O, "readonly").objectStore(O), i = IDBKeyRange.bound([e, ""], [e, ""]);
|
|
2750
|
+
return new Promise((s, l) => {
|
|
2751
|
+
const r = n.openCursor(i, "prev");
|
|
2752
|
+
r.onsuccess = () => {
|
|
2753
|
+
const c = r.result;
|
|
2754
|
+
s(c ? c.value : null);
|
|
2755
|
+
}, r.onerror = () => l(r.error);
|
|
2756
|
+
});
|
|
2757
|
+
}
|
|
2758
|
+
// -------------------------------------------------------------------------
|
|
2759
|
+
// Payload
|
|
2760
|
+
// -------------------------------------------------------------------------
|
|
2761
|
+
async savePayload(e) {
|
|
2762
|
+
const a = this._requireDb().transaction(W, "readwrite");
|
|
2763
|
+
a.objectStore(W).put(e), await Z(a);
|
|
2764
|
+
}
|
|
2765
|
+
async loadPayload(e, t) {
|
|
2766
|
+
const n = this._requireDb().transaction(W, "readonly");
|
|
2767
|
+
return await ee(n.objectStore(W).get([e, t])) ?? null;
|
|
2768
|
+
}
|
|
2769
|
+
async loadPayloadsByThread(e) {
|
|
2770
|
+
const n = this._requireDb().transaction(W, "readonly").objectStore(W).index("threadId"), i = [];
|
|
2771
|
+
return new Promise((s, l) => {
|
|
2772
|
+
const r = n.openCursor(IDBKeyRange.only(e));
|
|
2773
|
+
r.onsuccess = () => {
|
|
2774
|
+
const c = r.result;
|
|
2775
|
+
if (!c) {
|
|
2776
|
+
s(i);
|
|
2777
|
+
return;
|
|
2778
|
+
}
|
|
2779
|
+
i.push(c.value), c.continue();
|
|
2780
|
+
}, r.onerror = () => l(r.error);
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2783
|
+
// -------------------------------------------------------------------------
|
|
2784
|
+
// Favorites
|
|
2785
|
+
// -------------------------------------------------------------------------
|
|
2786
|
+
async saveFavorite(e) {
|
|
2787
|
+
const a = this._requireDb().transaction(j, "readwrite");
|
|
2788
|
+
a.objectStore(j).put(e), await Z(a);
|
|
2789
|
+
}
|
|
2790
|
+
async removeFavorite(e, t, a) {
|
|
2791
|
+
const i = this._requireDb().transaction(j, "readwrite");
|
|
2792
|
+
i.objectStore(j).delete([e, t, a]), await Z(i);
|
|
2793
|
+
}
|
|
2794
|
+
async loadFavorites(e, t) {
|
|
2795
|
+
const n = this._requireDb().transaction(j, "readonly");
|
|
2796
|
+
return (await ee(n.objectStore(j).getAll())).filter((s) => s.userId === e && s.appId === t);
|
|
2797
|
+
}
|
|
2798
|
+
async isFavorite(e, t, a) {
|
|
2799
|
+
const i = this._requireDb().transaction(j, "readonly");
|
|
2800
|
+
return await ee(i.objectStore(j).get([e, t, a])) !== void 0;
|
|
2801
|
+
}
|
|
2802
|
+
// -------------------------------------------------------------------------
|
|
2803
|
+
// Internal
|
|
2804
|
+
// -------------------------------------------------------------------------
|
|
2805
|
+
_requireDb() {
|
|
2806
|
+
if (!this._db)
|
|
2807
|
+
throw new Error("GengageIndexedDB: database not open. Call open() first.");
|
|
2808
|
+
return this._db;
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
const Ma = [
|
|
2812
|
+
"comparisonTable",
|
|
2813
|
+
"groupList",
|
|
2814
|
+
"productDetailsSimilars",
|
|
2815
|
+
"productList"
|
|
2816
|
+
];
|
|
2817
|
+
class Ba {
|
|
2818
|
+
constructor(e) {
|
|
2819
|
+
this._lockCount = 1, this._hiddenByUser = !1, this._lastPanelContentType = null, this._chatShown = !1, this._isFavoritesMode = !1, this._lastExtended = !1, this._onChange = e.onChange;
|
|
2820
|
+
const t = new Set(Ma);
|
|
2821
|
+
e.productDetailsInPanel && t.add("productDetails"), this._panelContentTypes = t;
|
|
2822
|
+
}
|
|
2823
|
+
get isExtended() {
|
|
2824
|
+
return this._lockCount === 0 && !this._hiddenByUser && !this._isFavoritesMode && this._lastPanelContentType !== null && this._panelContentTypes.has(this._lastPanelContentType) && this._chatShown;
|
|
2825
|
+
}
|
|
2826
|
+
unlock() {
|
|
2827
|
+
this._lockCount > 0 && this._lockCount--, this._checkStateChange();
|
|
2828
|
+
}
|
|
2829
|
+
lock() {
|
|
2830
|
+
this._lockCount++, this._checkStateChange();
|
|
2831
|
+
}
|
|
2832
|
+
setHiddenByUser(e) {
|
|
2833
|
+
this._hiddenByUser = e, this._checkStateChange();
|
|
2834
|
+
}
|
|
2835
|
+
setChatShown(e) {
|
|
2836
|
+
this._chatShown = e, this._checkStateChange();
|
|
2837
|
+
}
|
|
2838
|
+
setFavoritesMode(e) {
|
|
2839
|
+
this._isFavoritesMode = e, this._checkStateChange();
|
|
2840
|
+
}
|
|
2841
|
+
setPanelContentType(e) {
|
|
2842
|
+
this._lastPanelContentType = e, this._checkStateChange();
|
|
2843
|
+
}
|
|
2844
|
+
_checkStateChange() {
|
|
2845
|
+
const e = this.isExtended;
|
|
2846
|
+
e !== this._lastExtended && (this._lastExtended = e, this._onChange(e));
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
class za {
|
|
2850
|
+
constructor(e) {
|
|
2851
|
+
this.deps = e, this.snapshots = /* @__PURE__ */ new Map(), this.snapshotTypes = /* @__PURE__ */ new Map(), this.activePanelMessageId = null, this.currentType = null, this.threads = [], this.lastActionType = null;
|
|
2852
|
+
}
|
|
2853
|
+
/**
|
|
2854
|
+
* Deep-clone the current panel content (excluding topbar/thumbnails) and store
|
|
2855
|
+
* it keyed by message ID. Called when a stream completes so panel content can
|
|
2856
|
+
* be restored later without duplicating the topbar.
|
|
2857
|
+
*/
|
|
2858
|
+
snapshotForMessage(e) {
|
|
2859
|
+
const t = this.deps.drawer();
|
|
2860
|
+
if (!t?.hasPanelContent() || t.isPanelLoading()) return;
|
|
2861
|
+
const a = t.getPanelContentElement();
|
|
2862
|
+
if (!a) return;
|
|
2863
|
+
const n = a.cloneNode(!0);
|
|
2864
|
+
this.snapshots.set(e, n), this.currentType && this.snapshotTypes.set(e, this.currentType);
|
|
2865
|
+
}
|
|
2866
|
+
/**
|
|
2867
|
+
* Attach a click handler to a bot message bubble so clicking it restores
|
|
2868
|
+
* the panel content that was active when that message was received.
|
|
2869
|
+
*/
|
|
2870
|
+
attachClickHandler(e) {
|
|
2871
|
+
const a = this.deps.shadow()?.querySelector(`[data-message-id="${CSS.escape(e)}"]`);
|
|
2872
|
+
a && (a.style.cursor = "pointer", a.addEventListener("click", () => this.restoreForMessage(e)));
|
|
2873
|
+
}
|
|
2874
|
+
/**
|
|
2875
|
+
* Restore the panel content snapshot associated with a given message ID.
|
|
2876
|
+
* Highlights the active message and de-highlights the previous one.
|
|
2877
|
+
* Also restores the panel topbar title for the snapshot's component type.
|
|
2878
|
+
* Returns true if the snapshot was found and restored.
|
|
2879
|
+
*/
|
|
2880
|
+
restoreForMessage(e) {
|
|
2881
|
+
const t = this.snapshots.get(e);
|
|
2882
|
+
if (!t) return !1;
|
|
2883
|
+
const a = this.deps.shadow(), n = this.deps.drawer();
|
|
2884
|
+
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));
|
|
2885
|
+
const s = this.snapshotTypes.get(e);
|
|
2886
|
+
return s && (this.currentType = s, this.updateTopBar(s)), !0;
|
|
2887
|
+
}
|
|
2888
|
+
/**
|
|
2889
|
+
* Send maximize-pdp / minify-pdp bridge messages with production-matching delays.
|
|
2890
|
+
* Called by the extended mode manager when panel extension state changes.
|
|
2891
|
+
*/
|
|
2892
|
+
notifyExtension(e) {
|
|
2893
|
+
const t = this.deps.bridge();
|
|
2894
|
+
e ? setTimeout(() => t?.send("maximize-pdp", {}), 350) : setTimeout(() => t?.send("minify-pdp", {}), 200);
|
|
2895
|
+
}
|
|
2896
|
+
/**
|
|
2897
|
+
* Derive panel title from UISpec root element type using i18n strings.
|
|
2898
|
+
* When the backend provides a `panelTitle` prop, it takes precedence.
|
|
2899
|
+
*/
|
|
2900
|
+
titleForComponent(e, t) {
|
|
2901
|
+
if (t) return t;
|
|
2902
|
+
const a = this.deps.i18n();
|
|
2903
|
+
switch (e) {
|
|
2904
|
+
case "ProductDetailsPanel":
|
|
2905
|
+
return a.panelTitleProductDetails;
|
|
2906
|
+
case "ProductGrid":
|
|
2907
|
+
return fe(this.lastActionType) ? a.panelTitleSearchResults : a.panelTitleSimilarProducts;
|
|
2908
|
+
case "ComparisonTable":
|
|
2909
|
+
return a.panelTitleComparisonResults;
|
|
2910
|
+
case "AIGroupingCards":
|
|
2911
|
+
return a.panelTitleCategories;
|
|
2912
|
+
default:
|
|
2913
|
+
return "";
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
/**
|
|
2917
|
+
* Update the panel top bar navigation state and title.
|
|
2918
|
+
* When the backend provides a `panelTitle`, it takes precedence over i18n defaults.
|
|
2919
|
+
*/
|
|
2920
|
+
updateTopBar(e, t) {
|
|
2921
|
+
const a = this.deps.currentThreadId();
|
|
2922
|
+
if (!a) return;
|
|
2923
|
+
const n = this.threads.indexOf(a), i = n > 0, s = n >= 0 && n < this.threads.length - 1, l = this.titleForComponent(e, t);
|
|
2924
|
+
this.deps.drawer()?.updatePanelTopBar(i, s, l);
|
|
2925
|
+
}
|
|
2926
|
+
/**
|
|
2927
|
+
* Set panel topbar title during loading (before actual panel content arrives).
|
|
2928
|
+
* Maps backend pending types to the same i18n titles used for final content.
|
|
2929
|
+
*/
|
|
2930
|
+
updateTopBarForLoading(e) {
|
|
2931
|
+
const t = this.deps.i18n(), n = {
|
|
2932
|
+
productDetails: t.panelTitleProductDetails,
|
|
2933
|
+
productList: fe(this.lastActionType) ? t.panelTitleSearchResults : t.panelTitleSimilarProducts,
|
|
2934
|
+
comparisonTable: t.panelTitleComparisonResults,
|
|
2935
|
+
groupList: t.panelTitleCategories
|
|
2936
|
+
}[e] ?? "";
|
|
2937
|
+
if (n) {
|
|
2938
|
+
const i = this.deps.currentThreadId(), s = i ? this.threads.indexOf(i) : -1, l = s > 0, r = s >= 0 && s < this.threads.length - 1;
|
|
2939
|
+
this.deps.drawer()?.updatePanelTopBar(l, r, n);
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
/**
|
|
2943
|
+
* Map UISpec component types to PanelContentType for the extended mode manager.
|
|
2944
|
+
*/
|
|
2945
|
+
updateExtendedMode(e) {
|
|
2946
|
+
const a = {
|
|
2947
|
+
ComparisonTable: "comparisonTable",
|
|
2948
|
+
AIGroupingCards: "groupList",
|
|
2949
|
+
ProductDetailsPanel: "productDetails",
|
|
2950
|
+
ProductGrid: "productList"
|
|
2951
|
+
}[e] ?? null;
|
|
2952
|
+
this.deps.extendedModeManager()?.setPanelContentType(a);
|
|
2953
|
+
}
|
|
2954
|
+
/** Navigate to the previous panel thread. */
|
|
2955
|
+
navigateBack() {
|
|
2956
|
+
const e = this.deps.currentThreadId();
|
|
2957
|
+
if (!e) return;
|
|
2958
|
+
const t = this.threads.indexOf(e);
|
|
2959
|
+
if (t > 0) {
|
|
2960
|
+
const a = this.threads[t - 1];
|
|
2961
|
+
a && this.deps.rollbackToThread(a);
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
/** Navigate to the next panel thread. */
|
|
2965
|
+
navigateForward() {
|
|
2966
|
+
const e = this.deps.currentThreadId();
|
|
2967
|
+
if (!e) return;
|
|
2968
|
+
const t = this.threads.indexOf(e);
|
|
2969
|
+
if (t >= 0 && t < this.threads.length - 1) {
|
|
2970
|
+
const a = this.threads[t + 1];
|
|
2971
|
+
a && this.deps.rollbackToThread(a);
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* Panel route shaping:
|
|
2976
|
+
* - product details => expanded LHS panel (`ProductDetailsPanel`)
|
|
2977
|
+
* - all other panel-routed specs keep their original component types
|
|
2978
|
+
*/
|
|
2979
|
+
toPanelSpec(e) {
|
|
2980
|
+
const t = e.elements[e.root];
|
|
2981
|
+
if (!t || t.type !== "ProductCard") return e;
|
|
2982
|
+
const a = {
|
|
2983
|
+
...t,
|
|
2984
|
+
type: "ProductDetailsPanel"
|
|
2985
|
+
};
|
|
2986
|
+
return {
|
|
2987
|
+
root: e.root,
|
|
2988
|
+
elements: {
|
|
2989
|
+
...e.elements,
|
|
2990
|
+
[e.root]: a
|
|
2991
|
+
}
|
|
2992
|
+
};
|
|
2993
|
+
}
|
|
2994
|
+
destroy() {
|
|
2995
|
+
this.snapshots.clear(), this.snapshotTypes.clear(), this.activePanelMessageId = null, this.currentType = null, this.threads = [];
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
function fe(o) {
|
|
2999
|
+
return o === "user_message" || o === "inputText";
|
|
3000
|
+
}
|
|
3001
|
+
class be {
|
|
3002
|
+
constructor(e) {
|
|
3003
|
+
this.favoritedSkus = /* @__PURE__ */ new Set(), this._persistLock = Promise.resolve(), this._db = e;
|
|
3004
|
+
}
|
|
3005
|
+
get db() {
|
|
3006
|
+
return this._db;
|
|
3007
|
+
}
|
|
3008
|
+
set db(e) {
|
|
3009
|
+
this._db = e;
|
|
3010
|
+
}
|
|
3011
|
+
/**
|
|
3012
|
+
* Persist current session state to IndexedDB.
|
|
3013
|
+
* Called after each stream completion (onDone). Non-fatal on failure.
|
|
3014
|
+
*/
|
|
3015
|
+
async persist(e) {
|
|
3016
|
+
if (!this._db) return;
|
|
3017
|
+
const t = this._persistLock;
|
|
3018
|
+
let a;
|
|
3019
|
+
this._persistLock = new Promise((n) => {
|
|
3020
|
+
a = n;
|
|
3021
|
+
}), await t;
|
|
3022
|
+
try {
|
|
3023
|
+
await this._persistImpl(e);
|
|
3024
|
+
} finally {
|
|
3025
|
+
a();
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
async _persistImpl(e) {
|
|
3029
|
+
if (!this._db) return;
|
|
3030
|
+
const t = e.messages.map((n) => {
|
|
3031
|
+
const i = {
|
|
3032
|
+
id: n.id,
|
|
3033
|
+
role: n.role,
|
|
3034
|
+
timestamp: n.timestamp,
|
|
3035
|
+
status: n.status === "streaming" ? "done" : n.status
|
|
3036
|
+
};
|
|
3037
|
+
return n.threadId !== void 0 && (i.threadId = n.threadId), n.content !== void 0 && (i.content = n.content), n.silent && (i.silent = !0), i;
|
|
3038
|
+
}), a = {};
|
|
3039
|
+
for (const [n, i] of e.panelSnapshots)
|
|
3040
|
+
i.querySelector(".gengage-chat-panel-skeleton") || (a[n] = i.innerHTML);
|
|
3041
|
+
await this._db.saveSession({
|
|
3042
|
+
userId: e.userId,
|
|
3043
|
+
appId: e.appId,
|
|
3044
|
+
sessionId: e.sessionId,
|
|
3045
|
+
messages: t,
|
|
3046
|
+
currentThreadId: e.currentThreadId,
|
|
3047
|
+
lastThreadId: e.lastThreadId,
|
|
3048
|
+
createdAt: e.chatCreatedAt,
|
|
3049
|
+
panelThreads: e.panelThreads.length > 0 ? e.panelThreads : void 0,
|
|
3050
|
+
thumbnailEntries: e.thumbnailEntries.length > 0 ? e.thumbnailEntries : void 0,
|
|
3051
|
+
panelSnapshotHtml: Object.keys(a).length > 0 ? a : void 0,
|
|
3052
|
+
sku: e.sku
|
|
3053
|
+
}), e.lastBackendContext && e.currentThreadId && await this._db.saveContext({
|
|
3054
|
+
sessionId: e.sessionId,
|
|
3055
|
+
threadId: e.currentThreadId,
|
|
3056
|
+
context: e.lastBackendContext
|
|
3057
|
+
});
|
|
3058
|
+
for (const n of e.messages)
|
|
3059
|
+
n.uiSpec && n.threadId && await this._db.savePayload({
|
|
3060
|
+
threadId: n.threadId,
|
|
3061
|
+
messageId: n.id,
|
|
3062
|
+
uiSpec: n.uiSpec
|
|
3063
|
+
});
|
|
3064
|
+
}
|
|
3065
|
+
/**
|
|
3066
|
+
* Persist session to IndexedDB, then navigate to the URL.
|
|
3067
|
+
* Sends an 'openURLInNewTab' bridge message so the host page can intercept
|
|
3068
|
+
* (e.g. for SPA routing), then navigates directly as fallback.
|
|
3069
|
+
*
|
|
3070
|
+
* Legacy compatibility: the prior engine navigated via window.location.href
|
|
3071
|
+
* after posting saveSessionAndOpenURL to the iframe. The clean-room runs in
|
|
3072
|
+
* the same window (Shadow DOM, not iframe), so it navigates directly.
|
|
3073
|
+
*/
|
|
3074
|
+
async saveAndOpenURL(e, t, a) {
|
|
3075
|
+
try {
|
|
3076
|
+
await t();
|
|
3077
|
+
} catch {
|
|
3078
|
+
}
|
|
3079
|
+
a?.send("openURLInNewTab", { url: e }), H(e) && (window.location.href = e);
|
|
3080
|
+
}
|
|
3081
|
+
/**
|
|
3082
|
+
* Load a UISpec payload from IndexedDB with retry logic.
|
|
3083
|
+
* Returns null if not found or all retries fail.
|
|
3084
|
+
*/
|
|
3085
|
+
async loadPayload(e, t) {
|
|
3086
|
+
if (!this._db) return null;
|
|
3087
|
+
for (let a = 0; a < 3; a++) {
|
|
3088
|
+
try {
|
|
3089
|
+
const n = await this._db.loadPayload(e, t);
|
|
3090
|
+
if (n) return n.uiSpec;
|
|
3091
|
+
} catch {
|
|
3092
|
+
}
|
|
3093
|
+
a < 2 && await new Promise((n) => setTimeout(n, 100));
|
|
3094
|
+
}
|
|
3095
|
+
return null;
|
|
3096
|
+
}
|
|
3097
|
+
/**
|
|
3098
|
+
* Load favorited SKUs from IDB into the in-memory set.
|
|
3099
|
+
*/
|
|
3100
|
+
async loadFavorites(e, t) {
|
|
3101
|
+
if (this._db)
|
|
3102
|
+
try {
|
|
3103
|
+
const a = await this._db.loadFavorites(e, t);
|
|
3104
|
+
for (const n of a) this.favoritedSkus.add(n.sku);
|
|
3105
|
+
} catch {
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
/**
|
|
3109
|
+
* Toggle a product's favorited state in IDB and in-memory set.
|
|
3110
|
+
*/
|
|
3111
|
+
async toggleFavorite(e, t, a, n) {
|
|
3112
|
+
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({
|
|
3113
|
+
userId: e,
|
|
3114
|
+
appId: t,
|
|
3115
|
+
sku: a,
|
|
3116
|
+
name: n.name,
|
|
3117
|
+
imageUrl: n.imageUrl,
|
|
3118
|
+
price: n.price,
|
|
3119
|
+
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3120
|
+
})));
|
|
3121
|
+
}
|
|
3122
|
+
close() {
|
|
3123
|
+
this._db?.close(), this._db = null;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
const Be = "gengage_kvkk_shown", Ra = ["kvkk", "kişisel veri", "kisisel veri"], Da = /\b6698\b/;
|
|
3127
|
+
function ge(o) {
|
|
3128
|
+
const e = o.toLowerCase();
|
|
3129
|
+
return Ra.some((t) => e.includes(t)) || Da.test(e);
|
|
3130
|
+
}
|
|
3131
|
+
function xe(o) {
|
|
3132
|
+
try {
|
|
3133
|
+
return localStorage.getItem(`${Be}_${o}`) === "1";
|
|
3134
|
+
} catch {
|
|
3135
|
+
return !1;
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
function Fa(o) {
|
|
3139
|
+
try {
|
|
3140
|
+
localStorage.setItem(`${Be}_${o}`, "1");
|
|
3141
|
+
} catch {
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
function Ua(o) {
|
|
3145
|
+
const t = new DOMParser().parseFromString(o, "text/html").body, a = Array.from(t.children);
|
|
3146
|
+
for (const n of a)
|
|
3147
|
+
if (ge(n.textContent ?? "")) {
|
|
3148
|
+
n.remove();
|
|
3149
|
+
break;
|
|
3150
|
+
}
|
|
3151
|
+
return t.innerHTML.trim();
|
|
3152
|
+
}
|
|
3153
|
+
function qa(o) {
|
|
3154
|
+
const e = new DOMParser().parseFromString(o, "text/html");
|
|
3155
|
+
for (const t of Array.from(e.body.children))
|
|
3156
|
+
if (ge(t.textContent ?? ""))
|
|
3157
|
+
return t.outerHTML;
|
|
3158
|
+
return null;
|
|
3159
|
+
}
|
|
3160
|
+
const Ha = {
|
|
3161
|
+
tr: "TURKISH",
|
|
3162
|
+
en: "ENGLISH",
|
|
3163
|
+
de: "GERMAN",
|
|
3164
|
+
fr: "FRENCH"
|
|
3165
|
+
};
|
|
3166
|
+
function Oa(o) {
|
|
3167
|
+
return o ? Ha[o.toLowerCase().slice(0, 2)] ?? "TURKISH" : "TURKISH";
|
|
3168
|
+
}
|
|
3169
|
+
const ja = ':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--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:50%;object-fit:cover;flex-shrink:0;border:2px solid rgba(255,255,255,.15)}.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;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;gap:8px;padding:6px 0 4px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}.gengage-chat-action-buttons::-webkit-scrollbar{display:none}.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;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;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:0;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-chat-product-card-review-count{color:#475569;font-size:10px}.gengage-chat-product-card-price{display:flex;align-items:baseline;justify-content:center;gap: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;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;-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;left: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:2px 6px;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}.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}}', Va = B({
|
|
3170
|
+
role: we(["user", "assistant"]),
|
|
3171
|
+
content: w(),
|
|
3172
|
+
timestamp: Q().optional()
|
|
3173
|
+
}), Wa = B({
|
|
3174
|
+
sku: w(),
|
|
3175
|
+
name: w(),
|
|
3176
|
+
imageUrl: w().url().optional(),
|
|
3177
|
+
price: w().optional(),
|
|
3178
|
+
originalPrice: w().optional(),
|
|
3179
|
+
url: w().url(),
|
|
3180
|
+
/** Override CTA label (default: "View product") */
|
|
3181
|
+
ctaLabel: w().optional()
|
|
3182
|
+
}), $a = B({
|
|
3183
|
+
buttons: D(
|
|
3184
|
+
B({
|
|
3185
|
+
label: w(),
|
|
3186
|
+
/** Opaque action payload forwarded to the backend when clicked. */
|
|
3187
|
+
action: B({
|
|
3188
|
+
title: w(),
|
|
3189
|
+
type: w(),
|
|
3190
|
+
payload: Y().optional()
|
|
3191
|
+
})
|
|
3192
|
+
})
|
|
3193
|
+
)
|
|
3194
|
+
}), Ga = B({}), Ya = B({
|
|
3195
|
+
label: w().optional()
|
|
3196
|
+
}), ve = B({
|
|
3197
|
+
sku: w(),
|
|
3198
|
+
name: w(),
|
|
3199
|
+
price: w(),
|
|
3200
|
+
imageUrl: w().optional(),
|
|
3201
|
+
rating: Q().optional(),
|
|
3202
|
+
reviewCount: Q().optional()
|
|
3203
|
+
}), Ka = B({
|
|
3204
|
+
recommended: ve,
|
|
3205
|
+
products: D(ve),
|
|
3206
|
+
attributes: D(
|
|
3207
|
+
B({
|
|
3208
|
+
label: w(),
|
|
3209
|
+
values: D(w())
|
|
3210
|
+
})
|
|
3211
|
+
),
|
|
3212
|
+
highlights: D(w()),
|
|
3213
|
+
specialCases: D(w()).optional(),
|
|
3214
|
+
recommendedText: w().optional(),
|
|
3215
|
+
winnerHits: te(
|
|
3216
|
+
w(),
|
|
3217
|
+
B({
|
|
3218
|
+
positive: D(w()).optional(),
|
|
3219
|
+
negative: D(w()).optional()
|
|
3220
|
+
})
|
|
3221
|
+
).optional(),
|
|
3222
|
+
productActions: te(
|
|
3223
|
+
w(),
|
|
3224
|
+
B({
|
|
3225
|
+
title: w(),
|
|
3226
|
+
type: w(),
|
|
3227
|
+
payload: Y().optional()
|
|
3228
|
+
})
|
|
3229
|
+
).optional()
|
|
3230
|
+
}), Qa = B({
|
|
3231
|
+
label: w(),
|
|
3232
|
+
sentiment: we(["positive", "negative", "neutral"]).optional()
|
|
3233
|
+
}), Xa = B({
|
|
3234
|
+
product: te(w(), Y()),
|
|
3235
|
+
role: w().optional(),
|
|
3236
|
+
reason: w().optional(),
|
|
3237
|
+
labels: D(Qa).optional(),
|
|
3238
|
+
expertQualityScore: Q().optional(),
|
|
3239
|
+
reviewHighlight: w().optional(),
|
|
3240
|
+
action: B({
|
|
3241
|
+
title: w(),
|
|
3242
|
+
type: w(),
|
|
3243
|
+
payload: Y().optional()
|
|
3244
|
+
}).optional()
|
|
3245
|
+
}), Ja = B({
|
|
3246
|
+
suggestions: D(Xa)
|
|
3247
|
+
}), Za = B({
|
|
3248
|
+
title: w().optional(),
|
|
3249
|
+
text: w().optional(),
|
|
3250
|
+
reviewCount: w().optional(),
|
|
3251
|
+
action: B({ title: w(), type: w(), payload: Y().optional() })
|
|
3252
|
+
}), en = B({
|
|
3253
|
+
entries: D(
|
|
3254
|
+
B({
|
|
3255
|
+
name: w(),
|
|
3256
|
+
image: w().optional(),
|
|
3257
|
+
description: w().optional(),
|
|
3258
|
+
action: B({ title: w(), type: w(), payload: Y().optional() })
|
|
3259
|
+
})
|
|
3260
|
+
)
|
|
3261
|
+
}), tn = B({
|
|
3262
|
+
entries: D(
|
|
3263
|
+
B({
|
|
3264
|
+
shortName: w(),
|
|
3265
|
+
detailedMessage: w().optional(),
|
|
3266
|
+
whyDifferent: w().optional(),
|
|
3267
|
+
image: w().optional(),
|
|
3268
|
+
action: B({ title: w(), type: w(), payload: Y().optional() })
|
|
3269
|
+
})
|
|
3270
|
+
)
|
|
3271
|
+
}), ze = B({
|
|
3272
|
+
title: w(),
|
|
3273
|
+
type: w(),
|
|
3274
|
+
payload: Y().optional()
|
|
3275
|
+
}), an = B({
|
|
3276
|
+
name: w().optional(),
|
|
3277
|
+
variant_name: w().optional(),
|
|
3278
|
+
sku: w().optional(),
|
|
3279
|
+
price: se([Q(), w()]).optional()
|
|
3280
|
+
}), nn = B({
|
|
3281
|
+
product: B({
|
|
3282
|
+
sku: w().optional(),
|
|
3283
|
+
name: w().optional(),
|
|
3284
|
+
images: D(w()).optional(),
|
|
3285
|
+
imageUrl: w().optional(),
|
|
3286
|
+
rating: Q().optional(),
|
|
3287
|
+
reviewCount: Q().optional(),
|
|
3288
|
+
price: w().optional(),
|
|
3289
|
+
originalPrice: w().optional(),
|
|
3290
|
+
price_async: re().optional(),
|
|
3291
|
+
inStock: re().optional(),
|
|
3292
|
+
promotions: D(w()).optional(),
|
|
3293
|
+
variants: D(an).optional(),
|
|
3294
|
+
url: w().optional(),
|
|
3295
|
+
cartCode: w().optional(),
|
|
3296
|
+
description: w().optional(),
|
|
3297
|
+
specifications: se([te(w(), w()), D(B({ key: w(), value: w() }))]).optional()
|
|
3298
|
+
}).optional(),
|
|
3299
|
+
action: ze.optional()
|
|
3300
|
+
}), on = B({
|
|
3301
|
+
endOfList: re().optional()
|
|
3302
|
+
}), rn = B({
|
|
3303
|
+
review_class: w().optional(),
|
|
3304
|
+
review_text: w().optional(),
|
|
3305
|
+
review_rating: se([w(), Q()]).optional(),
|
|
3306
|
+
review_tag: w().optional()
|
|
3307
|
+
}), sn = B({
|
|
3308
|
+
reviews: D(rn).optional()
|
|
3309
|
+
}), cn = B({
|
|
3310
|
+
productName: w().optional(),
|
|
3311
|
+
pros: D(w()).optional(),
|
|
3312
|
+
cons: D(w()).optional()
|
|
3313
|
+
}), ln = B({
|
|
3314
|
+
groups: D(
|
|
3315
|
+
B({
|
|
3316
|
+
groupName: w(),
|
|
3317
|
+
products: D(te(w(), Y())).optional()
|
|
3318
|
+
})
|
|
3319
|
+
).optional(),
|
|
3320
|
+
filterTags: D(
|
|
3321
|
+
B({
|
|
3322
|
+
title: w(),
|
|
3323
|
+
action: ze.optional()
|
|
3324
|
+
})
|
|
3325
|
+
).optional()
|
|
3326
|
+
}), gn = B({
|
|
3327
|
+
summary: w().optional(),
|
|
3328
|
+
products_discussed: D(w()).optional(),
|
|
3329
|
+
user_sentiment: w().optional()
|
|
3330
|
+
}), mn = {
|
|
3331
|
+
components: {
|
|
3332
|
+
MessageBubble: {
|
|
3333
|
+
schema: Va,
|
|
3334
|
+
description: "A single chat message bubble for user or assistant turns."
|
|
3335
|
+
},
|
|
3336
|
+
ProductCard: {
|
|
3337
|
+
schema: Wa,
|
|
3338
|
+
description: "A product card rendered inline in the chat stream."
|
|
3339
|
+
},
|
|
3340
|
+
ActionButtons: {
|
|
3341
|
+
schema: $a,
|
|
3342
|
+
description: "A horizontal row of quick-reply action buttons."
|
|
3343
|
+
},
|
|
3344
|
+
TypingIndicator: {
|
|
3345
|
+
schema: Ga,
|
|
3346
|
+
description: "An animated indicator shown while the assistant is typing."
|
|
3347
|
+
},
|
|
3348
|
+
Divider: {
|
|
3349
|
+
schema: Ya,
|
|
3350
|
+
description: "A horizontal rule with an optional label."
|
|
3351
|
+
},
|
|
3352
|
+
ComparisonTable: {
|
|
3353
|
+
schema: Ka,
|
|
3354
|
+
description: "A product comparison table with recommended pick, attribute rows, and highlights."
|
|
3355
|
+
},
|
|
3356
|
+
AITopPicks: {
|
|
3357
|
+
schema: Ja,
|
|
3358
|
+
description: "Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."
|
|
3359
|
+
},
|
|
3360
|
+
GroundingReviewCard: {
|
|
3361
|
+
schema: Za,
|
|
3362
|
+
description: "A card showing review grounding data with review count and CTA."
|
|
3363
|
+
},
|
|
3364
|
+
AIGroupingCards: {
|
|
3365
|
+
schema: en,
|
|
3366
|
+
description: "Category grouping cards with images and labels for product discovery."
|
|
3367
|
+
},
|
|
3368
|
+
AISuggestedSearchCards: {
|
|
3369
|
+
schema: tn,
|
|
3370
|
+
description: "Suggested search cards with images, descriptions, and differentiation."
|
|
3371
|
+
},
|
|
3372
|
+
ProductDetailsPanel: {
|
|
3373
|
+
schema: nn,
|
|
3374
|
+
description: "Full product detail view with images, specs, variants, and purchase actions."
|
|
3375
|
+
},
|
|
3376
|
+
ProductGrid: {
|
|
3377
|
+
schema: on,
|
|
3378
|
+
description: 'A scrollable grid of ProductCard children with optional "more" pagination.'
|
|
3379
|
+
},
|
|
3380
|
+
ReviewHighlights: {
|
|
3381
|
+
schema: sn,
|
|
3382
|
+
description: "A list of highlighted customer reviews with sentiment and ratings."
|
|
3383
|
+
},
|
|
3384
|
+
ProsAndCons: {
|
|
3385
|
+
schema: cn,
|
|
3386
|
+
description: "A pros and cons list for a product."
|
|
3387
|
+
},
|
|
3388
|
+
CategoriesContainer: {
|
|
3389
|
+
schema: ln,
|
|
3390
|
+
description: "Tabbed product groups with optional filter tag buttons."
|
|
3391
|
+
},
|
|
3392
|
+
HandoffNotice: {
|
|
3393
|
+
schema: gn,
|
|
3394
|
+
description: "A notice shown when the conversation is escalated to a human agent."
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
};
|
|
3398
|
+
function dn(o) {
|
|
3399
|
+
return o.length > 120 ? !1 : /^[a-zA-Z0-9#(),.\s%/\-]+$/.test(o);
|
|
3400
|
+
}
|
|
3401
|
+
function oe(o) {
|
|
3402
|
+
return typeof o == "object" && o !== null && typeof o.type == "string";
|
|
3403
|
+
}
|
|
3404
|
+
class pn extends He {
|
|
3405
|
+
constructor() {
|
|
3406
|
+
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 = le, 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;
|
|
3407
|
+
}
|
|
3408
|
+
async onInit(e) {
|
|
3409
|
+
this._i18n = this._resolveI18n(e), this._chatCreatedAt = (/* @__PURE__ */ new Date()).toISOString(), this._shadow = this.root.attachShadow({ mode: "open" });
|
|
3410
|
+
const t = document.createElement("style");
|
|
3411
|
+
t.textContent = ja, this._shadow.appendChild(t);
|
|
3412
|
+
const a = document.createElement("div");
|
|
3413
|
+
a.className = "gengage-chat-root", this._rootEl = a, this._shadow.appendChild(a);
|
|
3414
|
+
const n = e.variant ?? "floating";
|
|
3415
|
+
if (n === "floating") {
|
|
3416
|
+
const d = {
|
|
3417
|
+
onClick: () => this.open(),
|
|
3418
|
+
ariaLabel: this._i18n.openButton
|
|
3419
|
+
};
|
|
3420
|
+
e.launcherSvg !== void 0 && (d.svgMarkup = e.launcherSvg), e.hideMobileLauncher !== void 0 && (d.hideMobile = e.hideMobileLauncher), e.mobileBreakpoint !== void 0 && (d.mobileBreakpoint = e.mobileBreakpoint), e.launcherTooltip !== void 0 && (d.tooltip = e.launcherTooltip), this._launcher = Ft(d), a.appendChild(this._launcher.container);
|
|
3421
|
+
}
|
|
3422
|
+
n === "overlay" && a.classList.add("gengage-chat--overlay");
|
|
3423
|
+
const i = document.createElement("div");
|
|
3424
|
+
a.appendChild(i), this._drawer = new Rt(i, {
|
|
3425
|
+
i18n: this._i18n,
|
|
3426
|
+
onSend: (d, m) => this._sendMessage(d, m),
|
|
3427
|
+
onClose: () => this.close(),
|
|
3428
|
+
onAttachment: (d) => this._handleAttachment(d),
|
|
3429
|
+
onPanelToggle: () => {
|
|
3430
|
+
this._drawer?.persistPanelState(e.accountId);
|
|
3431
|
+
},
|
|
3432
|
+
onRollback: (d) => this._handleRollback(d),
|
|
3433
|
+
onPanelBack: () => this._panel?.navigateBack(),
|
|
3434
|
+
onPanelForward: () => this._panel?.navigateForward(),
|
|
3435
|
+
headerTitle: e.headerTitle,
|
|
3436
|
+
headerAvatarUrl: e.headerAvatarUrl,
|
|
3437
|
+
headerBadge: e.headerBadge,
|
|
3438
|
+
headerCartUrl: e.headerCartUrl,
|
|
3439
|
+
headerFavoritesToggle: e.headerFavoritesToggle,
|
|
3440
|
+
onFavoritesClick: () => {
|
|
3441
|
+
Oe(), e.onFavoritesClick?.();
|
|
3442
|
+
},
|
|
3443
|
+
onThumbnailClick: (d) => this._rollbackToThread(d),
|
|
3444
|
+
onLinkClick: (d) => {
|
|
3445
|
+
this._saveSessionAndOpenURL(d);
|
|
3446
|
+
},
|
|
3447
|
+
voiceEnabled: e.voiceEnabled,
|
|
3448
|
+
voiceLang: e.locale ? `${e.locale.split("-")[0] ?? "tr"}-${(e.locale.split("-")[1] ?? e.locale.split("-")[0] ?? "TR").toUpperCase()}` : void 0
|
|
3449
|
+
}), this._extendedModeManager = new Ba({
|
|
3450
|
+
onChange: (d) => this._panel?.notifyExtension(d),
|
|
3451
|
+
productDetailsInPanel: e.isDemoWebsite ?? !1
|
|
3452
|
+
}), this._panel = new za({
|
|
3453
|
+
drawer: () => this._drawer,
|
|
3454
|
+
shadow: () => this._shadow,
|
|
3455
|
+
currentThreadId: () => this._currentThreadId,
|
|
3456
|
+
bridge: () => this._bridge,
|
|
3457
|
+
extendedModeManager: () => this._extendedModeManager,
|
|
3458
|
+
i18n: () => this._i18n,
|
|
3459
|
+
rollbackToThread: (d) => this._rollbackToThread(d)
|
|
3460
|
+
}), n !== "inline" && this._drawer.getElement().classList.add("gengage-chat-drawer--hidden"), this._drawer.restorePanelState(e.accountId);
|
|
3461
|
+
const s = e.panelMode ?? "auto";
|
|
3462
|
+
s === "collapsed" ? this._drawer.setPanelCollapsed(!0) : s === "expanded" && this._drawer.setForceExpanded();
|
|
3463
|
+
const l = sessionStorage.getItem("gengage_restore_session_id"), r = sessionStorage.getItem("gengage_restore_sku"), c = !!(l && r);
|
|
3464
|
+
c && (sessionStorage.removeItem("gengage_restore_session_id"), sessionStorage.removeItem("gengage_restore_sku"));
|
|
3465
|
+
try {
|
|
3466
|
+
const d = new Pa();
|
|
3467
|
+
await d.open(), this._session = new be(d), await this._restoreFromIndexedDB(c);
|
|
3468
|
+
} catch {
|
|
3469
|
+
this._session = new be(null);
|
|
3470
|
+
}
|
|
3471
|
+
this._registerPublicAPI(), e.mobileInitialState !== void 0 && (this._openState = e.mobileInitialState), this._mobileBreakpoint = e.mobileBreakpoint ?? 768, this._syncViewportState();
|
|
3472
|
+
const g = () => this._syncViewportState();
|
|
3473
|
+
if (window.addEventListener("resize", g, { passive: !0 }), this.addCleanup(() => window.removeEventListener("resize", g)), window.visualViewport) {
|
|
3474
|
+
const d = () => {
|
|
3475
|
+
if (!this._drawerVisible || !this._isMobileViewport) return;
|
|
3476
|
+
const m = this._drawer?.getElement();
|
|
3477
|
+
if (!m) return;
|
|
3478
|
+
const p = window.innerHeight - (window.visualViewport?.height ?? window.innerHeight);
|
|
3479
|
+
m.style.setProperty("--gengage-keyboard-offset", `${Math.max(0, p)}px`);
|
|
3480
|
+
};
|
|
3481
|
+
window.visualViewport.addEventListener("resize", d), this.addCleanup(() => window.visualViewport?.removeEventListener("resize", d));
|
|
3482
|
+
}
|
|
3483
|
+
n === "inline" && (this._drawerVisible = !0, this.isVisible = !0, this._applyOpenStateClasses()), this._bridge = new ht({
|
|
3484
|
+
namespace: "chat",
|
|
3485
|
+
onMessage: (d) => this._handleBridgeMessage(d)
|
|
3486
|
+
}), this._lastSku = this.config.pageContext?.sku, this._initComplete = !0;
|
|
3487
|
+
for (const d of this._pendingActions)
|
|
3488
|
+
this._sendAction(d.action, d.options);
|
|
3489
|
+
this._pendingActions = [], V("gengage:chat:ready", {}), je("chat"), e.onReady?.();
|
|
3490
|
+
}
|
|
3491
|
+
onUpdate(e) {
|
|
3492
|
+
e.sku !== void 0 && e.sku !== this._lastSku && (this._lastSku = e.sku, this._resetForNewPage());
|
|
3493
|
+
}
|
|
3494
|
+
onShow() {
|
|
3495
|
+
this._showDrawer(), this.emit("open"), V("gengage:chat:open", { state: this._openState }), Ve("chat"), this.config.onOpen?.(), !this._pdpLaunched && this.config.pageContext?.sku && (this._pdpLaunched = !0, this._pdpPrimingInFlight = !0, this._sendAction(
|
|
3496
|
+
{
|
|
3497
|
+
title: "",
|
|
3498
|
+
type: "launchSingleProduct",
|
|
3499
|
+
payload: { sku: this.config.pageContext.sku }
|
|
3500
|
+
},
|
|
3501
|
+
{ silent: !0, isPdpPrime: !0 }
|
|
3502
|
+
));
|
|
3503
|
+
}
|
|
3504
|
+
onHide() {
|
|
3505
|
+
(this.config.variant ?? "floating") === "floating" && (this.root.style.display = ""), this._hideDrawer(), this.emit("close"), V("gengage:chat:close", {}), this.config.onClose?.();
|
|
3506
|
+
}
|
|
3507
|
+
onDestroy() {
|
|
3508
|
+
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;
|
|
3509
|
+
}
|
|
3510
|
+
// ---------------------------------------------------------------------------
|
|
3511
|
+
// Public API
|
|
3512
|
+
// ---------------------------------------------------------------------------
|
|
3513
|
+
open(e) {
|
|
3514
|
+
e?.state !== void 0 && (this._openState = e.state, this._drawerVisible && this._applyOpenStateClasses()), this.show(), e?.initialMessage !== void 0 && this._sendMessage(e.initialMessage);
|
|
3515
|
+
}
|
|
3516
|
+
openWithAction(e, t) {
|
|
3517
|
+
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);
|
|
3518
|
+
}
|
|
3519
|
+
/** Send a user message programmatically (same flow as typing + submit). */
|
|
3520
|
+
sendMessage(e) {
|
|
3521
|
+
this._sendMessage(e);
|
|
3522
|
+
}
|
|
3523
|
+
/** Send a backend action programmatically. */
|
|
3524
|
+
sendAction(e, t) {
|
|
3525
|
+
this._sendAction(e, t);
|
|
3526
|
+
}
|
|
3527
|
+
close() {
|
|
3528
|
+
this.hide();
|
|
3529
|
+
}
|
|
3530
|
+
saveSession(e, t) {
|
|
3531
|
+
sessionStorage.setItem("gengage_restore_session_id", e), sessionStorage.setItem("gengage_restore_sku", t);
|
|
3532
|
+
}
|
|
3533
|
+
get isOpen() {
|
|
3534
|
+
return this._drawerVisible;
|
|
3535
|
+
}
|
|
3536
|
+
/**
|
|
3537
|
+
* Register a callback for a GA4 event name (e.g. 'gengage-cart-add').
|
|
3538
|
+
* The callback receives the event detail and should return true (success) or false (failure).
|
|
3539
|
+
* For add-to-cart, failure triggers an error message in the chat.
|
|
3540
|
+
* @returns unsubscribe function
|
|
3541
|
+
*/
|
|
3542
|
+
addCallback(e, t) {
|
|
3543
|
+
let a = this._eventCallbacks.get(e);
|
|
3544
|
+
return a || (a = /* @__PURE__ */ new Set(), this._eventCallbacks.set(e, a)), a.add(t), () => {
|
|
3545
|
+
a.delete(t), a.size === 0 && this._eventCallbacks.delete(e);
|
|
3546
|
+
};
|
|
3547
|
+
}
|
|
3548
|
+
// ---------------------------------------------------------------------------
|
|
3549
|
+
// Private
|
|
3550
|
+
// ---------------------------------------------------------------------------
|
|
3551
|
+
/** Reset all chat state when navigating to a different SKU/page. */
|
|
3552
|
+
_resetForNewPage() {
|
|
3553
|
+
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;
|
|
3554
|
+
}
|
|
3555
|
+
_handleBridgeMessage(e) {
|
|
3556
|
+
switch (e.type) {
|
|
3557
|
+
case "openChat":
|
|
3558
|
+
this.open();
|
|
3559
|
+
break;
|
|
3560
|
+
case "closeChat":
|
|
3561
|
+
this.close();
|
|
3562
|
+
break;
|
|
3563
|
+
case "startNewChatWithLauncherAction": {
|
|
3564
|
+
const t = e.payload, a = t?.action, n = oe(a) ? a : oe(t) ? t : null;
|
|
3565
|
+
n && this._sendAction(n, { silent: !0 }), this.open();
|
|
3566
|
+
break;
|
|
3567
|
+
}
|
|
3568
|
+
case "startNewChatWithDetailContext": {
|
|
3569
|
+
const t = e.payload;
|
|
3570
|
+
if (t && typeof t == "object") {
|
|
3571
|
+
this._bridgeContext = t;
|
|
3572
|
+
const a = t.sku;
|
|
3573
|
+
if (a && this.update({ sku: a }), oe(t.action)) {
|
|
3574
|
+
this._pdpLaunched = !0, this.open(), this._sendAction(t.action);
|
|
3575
|
+
break;
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
this.open();
|
|
3579
|
+
break;
|
|
3580
|
+
}
|
|
3581
|
+
case "launcherAction": {
|
|
3582
|
+
const a = e.payload?.action;
|
|
3583
|
+
a && typeof a == "object" && "type" in a && this._sendAction(a);
|
|
3584
|
+
break;
|
|
3585
|
+
}
|
|
3586
|
+
case "scrollToBottom":
|
|
3587
|
+
this._drawer?.scrollToBottomIfNeeded();
|
|
3588
|
+
break;
|
|
3589
|
+
case "addToCardHandler": {
|
|
3590
|
+
this._bridge?.send("addToCardResult", e.payload);
|
|
3591
|
+
break;
|
|
3592
|
+
}
|
|
3593
|
+
case "cartQuantityHandler": {
|
|
3594
|
+
const t = e.payload;
|
|
3595
|
+
t && "quantity" in t && typeof t.quantity == "number" && (this._cartQuantity = t.quantity);
|
|
3596
|
+
break;
|
|
3597
|
+
}
|
|
3598
|
+
case "minimizeRequestedByUser":
|
|
3599
|
+
this._extendedModeManager?.setHiddenByUser(!0);
|
|
3600
|
+
break;
|
|
3601
|
+
case "bgColorChange": {
|
|
3602
|
+
const a = e.payload?.color;
|
|
3603
|
+
typeof a == "string" && dn(a) && this._shadow && this._shadow.host.style.setProperty("--gengage-chat-bg", a);
|
|
3604
|
+
break;
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
_registerPublicAPI() {
|
|
3609
|
+
window.gengage || (window.gengage = {}), window.gengage.chat = {
|
|
3610
|
+
open: (e) => this.open(e),
|
|
3611
|
+
openWithAction: (e, t) => this.openWithAction(e, t),
|
|
3612
|
+
sendMessage: (e) => this.sendMessage(e),
|
|
3613
|
+
sendAction: (e, t) => this.sendAction(e, t),
|
|
3614
|
+
close: () => this.close(),
|
|
3615
|
+
saveSession: (e, t) => this.saveSession(e, t),
|
|
3616
|
+
get isOpen() {
|
|
3617
|
+
return !1;
|
|
3618
|
+
},
|
|
3619
|
+
// Placeholder, overridden below
|
|
3620
|
+
on: (e, t) => this.on(e, t),
|
|
3621
|
+
trackCheckout: (e, t) => this.trackCheckout(e, t),
|
|
3622
|
+
flushMeteringSummary: (e) => this.flushMeteringSummary(e),
|
|
3623
|
+
addCallback: (e, t) => this.addCallback(e, t)
|
|
3624
|
+
}, Object.defineProperty(window.gengage.chat, "isOpen", {
|
|
3625
|
+
get: () => this._drawerVisible
|
|
3626
|
+
});
|
|
3627
|
+
}
|
|
3628
|
+
_showDrawer() {
|
|
3629
|
+
if (this._drawerVisible) return;
|
|
3630
|
+
this._drawerVisible = !0;
|
|
3631
|
+
const e = this._drawer?.getElement();
|
|
3632
|
+
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);
|
|
3633
|
+
}
|
|
3634
|
+
_hideDrawer() {
|
|
3635
|
+
if (!this._drawerVisible) return;
|
|
3636
|
+
this._drawer?.releaseFocus(), this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._drawerVisible = !1, this._openState = "full";
|
|
3637
|
+
const e = this._drawer?.getElement();
|
|
3638
|
+
e && e.classList.add("gengage-chat-drawer--hidden"), this._applyOpenStateClasses(), this._extendedModeManager?.setChatShown(!1);
|
|
3639
|
+
}
|
|
3640
|
+
_syncViewportState() {
|
|
3641
|
+
if (this._rootEl) {
|
|
3642
|
+
if (this._isMobileViewport = window.innerWidth <= this._mobileBreakpoint, this._rootEl.classList.toggle("gengage-chat-root--mobile", this._isMobileViewport), this._launcher) {
|
|
3643
|
+
const e = this._isMobileViewport && this.config.hideMobileLauncher === !0;
|
|
3644
|
+
this._launcher.container.classList.toggle("gengage-chat-launcher--hidden-mobile", e);
|
|
3645
|
+
}
|
|
3646
|
+
this._applyOpenStateClasses();
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
_applyOpenStateClasses() {
|
|
3650
|
+
if (!this._rootEl) return;
|
|
3651
|
+
const e = this._drawerVisible && this._isMobileViewport && this._openState === "half", t = this._drawerVisible && this._isMobileViewport && this._openState === "full";
|
|
3652
|
+
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);
|
|
3653
|
+
}
|
|
3654
|
+
_handleAttachment(e) {
|
|
3655
|
+
const t = yt(e);
|
|
3656
|
+
if (!t.ok) {
|
|
3657
|
+
const a = t.reason === "invalid_type" ? this._i18n.invalidFileType : this._i18n.fileTooLarge;
|
|
3658
|
+
V("gengage:global:error", {
|
|
3659
|
+
message: a,
|
|
3660
|
+
source: "chat"
|
|
3661
|
+
});
|
|
3662
|
+
return;
|
|
3663
|
+
}
|
|
3664
|
+
this._drawer?.stageAttachment(e);
|
|
3665
|
+
}
|
|
3666
|
+
_sendMessage(e, t) {
|
|
3667
|
+
if (this._pdpPrimingInFlight) {
|
|
3668
|
+
this._queuedUserMessages.push(t !== void 0 ? { text: e, attachment: t } : { text: e });
|
|
3669
|
+
return;
|
|
3670
|
+
}
|
|
3671
|
+
We(), this._messages.some((i) => i.role === "user") || $e();
|
|
3672
|
+
const n = {
|
|
3673
|
+
title: e,
|
|
3674
|
+
type: "user_message",
|
|
3675
|
+
payload: e
|
|
3676
|
+
};
|
|
3677
|
+
t !== void 0 ? this._sendAction(n, { attachment: t }) : this._sendAction(n);
|
|
3678
|
+
}
|
|
3679
|
+
_flushQueuedUserMessages() {
|
|
3680
|
+
if (this._pdpPrimingInFlight || this._queuedUserMessages.length === 0) return;
|
|
3681
|
+
const e = [...this._queuedUserMessages];
|
|
3682
|
+
this._queuedUserMessages = [];
|
|
3683
|
+
for (const t of e)
|
|
3684
|
+
this._sendMessage(t.text, t.attachment);
|
|
3685
|
+
}
|
|
3686
|
+
_sendAction(e, t) {
|
|
3687
|
+
if (this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._lastSentAction = { action: e, options: t }, !this._initComplete) {
|
|
3688
|
+
this._pendingActions.length < 10 && this._pendingActions.push({ action: e, options: t });
|
|
3689
|
+
return;
|
|
3690
|
+
}
|
|
3691
|
+
if (this._choicePrompterEl?.remove(), this._choicePrompterEl = null, !t?.preservePanel && this._comparisonSelectMode && (this._comparisonSelectMode = !1, this._comparisonSelectedSkus = []), this._currentThreadId && this._lastThreadId && this._lastThreadId > this._currentThreadId) {
|
|
3692
|
+
const h = this._currentThreadId, L = this._messages.filter((u) => u.threadId !== void 0 && u.threadId > h);
|
|
3693
|
+
this._messages = this._messages.filter((u) => !u.threadId || u.threadId <= h);
|
|
3694
|
+
for (const u of L)
|
|
3695
|
+
this._shadow?.querySelector(`[data-message-id="${CSS.escape(u.id)}"]`)?.remove(), this._panel.snapshots.delete(u.id), this._panel.snapshotTypes.delete(u.id);
|
|
3696
|
+
this._shadow?.querySelectorAll("[data-thread-id]")?.forEach((u) => {
|
|
3697
|
+
u instanceof HTMLElement && u.dataset.threadId && u.dataset.threadId > h && u.remove();
|
|
3698
|
+
});
|
|
3699
|
+
}
|
|
3700
|
+
this._drawer?.setPills([]), this._drawer?.clearInputAreaChips(), this._bridge?.send("isResponding", !0);
|
|
3701
|
+
const a = pt();
|
|
3702
|
+
this._currentThreadId = a, this._lastThreadId = a, this._panel && e.type !== "launchSingleProduct" && (this._panel.lastActionType = e.type);
|
|
3703
|
+
const n = t?.preservePanel === !0, i = e.type === "launchSingleProduct" && t?.silent === !0 && t?.isPdpPrime === !0;
|
|
3704
|
+
if (n || (this._activeRequestThreadId = a), !t?.silent) {
|
|
3705
|
+
const h = this._createMessage("user", typeof e.payload == "string" ? e.payload : e.title);
|
|
3706
|
+
h.threadId = a, t?.attachment !== void 0 && (h.attachment = t.attachment), this._drawer?.addMessage(h), this._messages.push(h);
|
|
3707
|
+
}
|
|
3708
|
+
if (!t?.silent && this._hasUnavailableProductContext() && (e.type === "user_message" || e.type === "inputText")) {
|
|
3709
|
+
const h = this._i18n.productNotFoundMessage, L = this._createMessage("assistant", h);
|
|
3710
|
+
L.threadId = a, L.status = "done", this._messages.push(L), this._ensureAssistantMessageRendered(L), this._drawer?.updateBotMessage(L.id, h), this._bridge?.send("isResponding", !1), this.emit("message", L), this._persistToIndexedDB().catch(() => {
|
|
3711
|
+
});
|
|
3712
|
+
return;
|
|
3713
|
+
}
|
|
3714
|
+
t?.preservePanel || (this._drawer?.hasPanelContent() ? this._drawer.showPanelLoading() : this._drawer?.clearPanel()), this._drawer?.showTypingIndicator();
|
|
3715
|
+
let l = "";
|
|
3716
|
+
const r = this._createMessage("assistant", "");
|
|
3717
|
+
r.threadId = a, r.status = "streaming", t?.silent && (r.silent = !0), this._messages.push(r), t?.preservePanel || (this._abortControllers.forEach((h) => h.abort()), this._abortControllers.clear());
|
|
3718
|
+
const c = {
|
|
3719
|
+
middlewareUrl: this.config.middlewareUrl,
|
|
3720
|
+
...this.config.accountId ? { accountId: this.config.accountId } : {}
|
|
3721
|
+
};
|
|
3722
|
+
t?.attachment !== void 0 && (c.attachment = t.attachment);
|
|
3723
|
+
const d = this._getVisibleMessages().filter((h) => h.content).slice(-50).map((h) => ({
|
|
3724
|
+
role: h.role === "user" ? "user" : "model",
|
|
3725
|
+
content: h.content ?? ""
|
|
3726
|
+
})), m = {
|
|
3727
|
+
outputLanguage: Oa(this.config.locale),
|
|
3728
|
+
parentUrl: window.location.href,
|
|
3729
|
+
windowWidth: String(window.innerWidth),
|
|
3730
|
+
windowHeight: String(window.innerHeight),
|
|
3731
|
+
selfUrl: "",
|
|
3732
|
+
id: this.config.session?.sessionId ?? "",
|
|
3733
|
+
userId: this.config.session?.userId ?? "",
|
|
3734
|
+
appId: this.config.accountId,
|
|
3735
|
+
threads: [],
|
|
3736
|
+
createdAt: this._chatCreatedAt,
|
|
3737
|
+
kvkkApproved: xe(this.config.accountId),
|
|
3738
|
+
voiceEnabled: this.config.voiceEnabled ?? !1,
|
|
3739
|
+
threadId: a,
|
|
3740
|
+
isControlGroup: this.config.session?.abTestVariant === "control",
|
|
3741
|
+
isMobile: this._isMobileViewport
|
|
3742
|
+
};
|
|
3743
|
+
this.config.session?.viewId !== void 0 && (m.viewId = this.config.session.viewId);
|
|
3744
|
+
const p = _t(e, {
|
|
3745
|
+
pageContext: this.config.pageContext,
|
|
3746
|
+
backendContext: this._lastBackendContext,
|
|
3747
|
+
isMobile: this._isMobileViewport
|
|
3748
|
+
}), y = {
|
|
3749
|
+
account_id: this.config.accountId,
|
|
3750
|
+
session_id: this.config.session?.sessionId ?? "",
|
|
3751
|
+
correlation_id: this.config.session?.sessionId ?? "",
|
|
3752
|
+
type: p.type,
|
|
3753
|
+
locale: this.config.locale ?? "tr",
|
|
3754
|
+
meta: m,
|
|
3755
|
+
context: {
|
|
3756
|
+
// Spread backend context (panel, message_id, etc.) but preserve FE's
|
|
3757
|
+
// authoritative chatHistory — the backend's stale `messages` must not
|
|
3758
|
+
// overwrite the up-to-date conversation history built by the widget.
|
|
3759
|
+
...this._lastBackendContext ?? {},
|
|
3760
|
+
messages: d,
|
|
3761
|
+
// Backend reads session_id from context.
|
|
3762
|
+
session_id: this.config.session?.sessionId ?? ""
|
|
3763
|
+
}
|
|
3764
|
+
};
|
|
3765
|
+
this.config.session?.userId !== void 0 && (y.user_id = this.config.session.userId), this.config.session?.viewId !== void 0 && (y.view_id = this.config.session.viewId), p.payload !== void 0 && (y.payload = p.payload), this.config.pageContext?.sku !== void 0 && (y.sku = this.config.pageContext.sku), this.config.pageContext?.pageType !== void 0 && (y.page_type = this.config.pageContext.pageType);
|
|
3766
|
+
const _ = crypto.randomUUID(), x = Date.now();
|
|
3767
|
+
let E = 0, I = !1, S = !1;
|
|
3768
|
+
this.track(
|
|
3769
|
+
Ge(this.analyticsContext(), {
|
|
3770
|
+
endpoint: "process_action",
|
|
3771
|
+
request_id: _,
|
|
3772
|
+
widget: "chat"
|
|
3773
|
+
})
|
|
3774
|
+
);
|
|
3775
|
+
let v = null;
|
|
3776
|
+
if (v = Et(
|
|
3777
|
+
y,
|
|
3778
|
+
{
|
|
3779
|
+
onTextChunk: (h, L, A) => {
|
|
3780
|
+
if (!n && a !== this._activeRequestThreadId || (l += h, this._drawer?.removeTypingIndicator(), A?.skuToProductItem && (this._skuToProductItem = { ...this._skuToProductItem, ...A.skuToProductItem }), A?.conversationMode && (this._conversationMode = A.conversationMode), this.track(
|
|
3781
|
+
dt(this.analyticsContext(), {
|
|
3782
|
+
request_id: _,
|
|
3783
|
+
chunk_index: E++,
|
|
3784
|
+
widget: "chat"
|
|
3785
|
+
})
|
|
3786
|
+
), !this._drawer)) return;
|
|
3787
|
+
let u = l;
|
|
3788
|
+
if (L && ge(u)) {
|
|
3789
|
+
const k = this.config.accountId;
|
|
3790
|
+
if (!xe(k)) {
|
|
3791
|
+
const P = qa(u);
|
|
3792
|
+
P && this._drawer?.showKvkkBanner(P, () => {
|
|
3793
|
+
this._drawer?.hideKvkkBanner();
|
|
3794
|
+
}), Fa(k);
|
|
3795
|
+
}
|
|
3796
|
+
u = Ua(u);
|
|
3797
|
+
}
|
|
3798
|
+
const b = this._shadow?.querySelector(
|
|
3799
|
+
`[data-message-id="${r.id}"] .gengage-chat-bubble-text`
|
|
3800
|
+
);
|
|
3801
|
+
if (b ? b.innerHTML = $(u) : (r.content = u, r.role === "assistant" && r.threadId && !this._threadsWithFirstBot.has(r.threadId) && (this._threadsWithFirstBot.add(r.threadId), this._drawer.markFirstBotMessage(r.id)), this._drawer.addMessage(r)), L) {
|
|
3802
|
+
r.content = u, r.status = "done", pe();
|
|
3803
|
+
const k = this._shadow?.querySelector(
|
|
3804
|
+
`[data-message-id="${r.id}"] .gengage-chat-bubble-text`
|
|
3805
|
+
);
|
|
3806
|
+
if (k) {
|
|
3807
|
+
this._activeTypewriter?.cancel();
|
|
3808
|
+
const P = A?.productMentions;
|
|
3809
|
+
this._activeTypewriter = ka({
|
|
3810
|
+
container: k,
|
|
3811
|
+
html: $(u),
|
|
3812
|
+
onTick: () => this._drawer?.scrollToBottomIfNeeded(),
|
|
3813
|
+
onComplete: () => {
|
|
3814
|
+
this._activeTypewriter = null, P && P.length > 0 && k && Ca({
|
|
3815
|
+
container: k,
|
|
3816
|
+
mentions: P,
|
|
3817
|
+
onProductClick: (z) => {
|
|
3818
|
+
this._sendAction({
|
|
3819
|
+
title: P.find((T) => T.sku === z)?.short_name ?? z,
|
|
3820
|
+
type: "launchSingleProduct",
|
|
3821
|
+
payload: { sku: z }
|
|
3822
|
+
});
|
|
3823
|
+
}
|
|
3824
|
+
});
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
},
|
|
3830
|
+
onUISpec: (h, L, A) => {
|
|
3831
|
+
if (!n && a !== this._activeRequestThreadId || L !== "chat") return;
|
|
3832
|
+
const u = h.elements[h.root], b = u?.type ?? "unknown";
|
|
3833
|
+
this.track(
|
|
3834
|
+
ct(this.analyticsContext(), {
|
|
3835
|
+
request_id: _,
|
|
3836
|
+
chunk_index: E,
|
|
3837
|
+
component_type: b,
|
|
3838
|
+
widget: "chat"
|
|
3839
|
+
})
|
|
3840
|
+
);
|
|
3841
|
+
const k = this._buildRenderContext();
|
|
3842
|
+
if (b === "ComparisonTable") {
|
|
3843
|
+
const T = u?.props?.products;
|
|
3844
|
+
lt(Array.isArray(T) ? T.length : 0);
|
|
3845
|
+
}
|
|
3846
|
+
if (b === "ProductGrid") {
|
|
3847
|
+
const T = u?.children?.length ?? 0;
|
|
3848
|
+
gt(void 0, T);
|
|
3849
|
+
}
|
|
3850
|
+
const P = A === "panel" && this._panel ? this._panel.toPanelSpec(h) : h, z = !r.silent && (A !== "panel" || b === "ProductCard") && b !== "ActionButtons";
|
|
3851
|
+
if (A === "panel" && this._panel) {
|
|
3852
|
+
S = !0, u?.props?.similarsAppend === !0 && this._panel.currentType === "ProductDetailsPanel" && this._drawer?.hasPanelContent() && !this._drawer.isPanelLoading() ? this._appendSimilarsToPanel(P, k) : b === "ProductGrid" && this._drawer?.hasPanelContent() && !this._drawer.isPanelLoading() ? this._drawer.appendPanelContent(this._renderUISpec(P, k)) : (this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._drawer?.setPanelContent(this._renderUISpec(P, k)), this._panel.currentType = b), b === "ProductDetailsPanel" && e.type === "launchSingleProduct" && this._clearUnavailableProductContext(), r.threadId && !this._panel.threads.includes(r.threadId) && this._panel.threads.push(r.threadId);
|
|
3853
|
+
const T = this._panel.currentType ?? b, N = u?.props?.panelTitle;
|
|
3854
|
+
this._panel.updateTopBar(T, N), this._panel.updateExtendedMode(b);
|
|
3855
|
+
}
|
|
3856
|
+
if (b === "ProductDetailsPanel" && !r.silent && A === "panel") {
|
|
3857
|
+
const T = u?.props?.product;
|
|
3858
|
+
if (T) {
|
|
3859
|
+
const N = {
|
|
3860
|
+
root: "root",
|
|
3861
|
+
elements: {
|
|
3862
|
+
root: {
|
|
3863
|
+
type: "ProductSummaryCard",
|
|
3864
|
+
props: { product: T }
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
}, f = this._shadow?.querySelector(".gengage-chat-messages");
|
|
3868
|
+
if (f) {
|
|
3869
|
+
const C = this._renderUISpec(N, k);
|
|
3870
|
+
r.threadId && (C.dataset.threadId = r.threadId), f.appendChild(C), C.scrollIntoView({ behavior: "auto", block: "end" });
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
if (z) {
|
|
3875
|
+
const T = this._shadow?.querySelector(".gengage-chat-messages");
|
|
3876
|
+
if (T) {
|
|
3877
|
+
const N = this._renderUISpec(h, k);
|
|
3878
|
+
r.threadId && (N.dataset.threadId = r.threadId), T.appendChild(N), N.scrollIntoView({ behavior: "auto", block: "end" });
|
|
3879
|
+
}
|
|
3880
|
+
}
|
|
3881
|
+
if ((b === "ProductGrid" || b === "ProductCard") && r.threadId) {
|
|
3882
|
+
const T = u?.children ?? [], N = b === "ProductGrid" ? T.map((f) => h.elements[f]?.props?.product).filter(Boolean) : [u?.props?.product].filter(Boolean);
|
|
3883
|
+
for (const f of N) {
|
|
3884
|
+
const C = f.sku, M = f.imageUrl;
|
|
3885
|
+
C && M && this._thumbnailEntries.push({ sku: C, imageUrl: M, threadId: r.threadId });
|
|
3886
|
+
}
|
|
3887
|
+
this._drawer?.setThumbnails(this._thumbnailEntries);
|
|
3888
|
+
}
|
|
3889
|
+
if (b === "ProductGrid" || b === "ProductDetailsPanel") {
|
|
3890
|
+
const N = (b === "ProductGrid" ? (u?.children ?? []).map((f) => h.elements[f]?.props?.product).filter(Boolean) : [
|
|
3891
|
+
u?.props?.product ?? u?.props
|
|
3892
|
+
].filter(Boolean)).map((f) => f.imageUrl).filter((f) => typeof f == "string").slice(0, 5);
|
|
3893
|
+
N.length > 0 && this._bridge?.send("previewImages", { images: N });
|
|
3894
|
+
}
|
|
3895
|
+
if (b === "ProductGrid" && A === "panel" && !this._comparisonSelectMode && !Ia()) {
|
|
3896
|
+
this._choicePrompterEl?.remove(), this._shadow?.querySelectorAll(".gengage-chat-choice-prompter").forEach((C) => C.remove()), this._choicePrompterEl = La({
|
|
3897
|
+
heading: this._i18n.choicePrompterHeading,
|
|
3898
|
+
suggestion: this._i18n.choicePrompterSuggestion,
|
|
3899
|
+
ctaLabel: this._i18n.choicePrompterCta,
|
|
3900
|
+
dismissAriaLabel: this._i18n.dismissAriaLabel,
|
|
3901
|
+
onCtaClick: () => {
|
|
3902
|
+
this._comparisonSelectMode = !0, this._choicePrompterEl = null, this._refreshComparisonUI();
|
|
3903
|
+
},
|
|
3904
|
+
onDismiss: () => {
|
|
3905
|
+
this._choicePrompterEl = null;
|
|
3906
|
+
}
|
|
3907
|
+
});
|
|
3908
|
+
const N = this._isMobileViewport || this._drawer?.isPanelCollapsed() ? ".gengage-chat-conversation" : ".gengage-chat-panel", f = this._shadow?.querySelector(N);
|
|
3909
|
+
f ? f.appendChild(this._choicePrompterEl) : this._choicePrompterEl = null;
|
|
3910
|
+
}
|
|
3911
|
+
if (b === "ActionButtons") {
|
|
3912
|
+
const T = u?.props?.buttons;
|
|
3913
|
+
if (T && T.length > 0) {
|
|
3914
|
+
const N = [], f = [];
|
|
3915
|
+
for (const C of T)
|
|
3916
|
+
if (Ta(C)) {
|
|
3917
|
+
const M = {
|
|
3918
|
+
label: C.label,
|
|
3919
|
+
action: C.action
|
|
3920
|
+
};
|
|
3921
|
+
C.icon && (M.icon = C.icon), N.push(M);
|
|
3922
|
+
} else
|
|
3923
|
+
f.push(C);
|
|
3924
|
+
N.length > 0 && this._drawer?.setInputAreaChips(
|
|
3925
|
+
N.map((C) => ({
|
|
3926
|
+
label: C.label,
|
|
3927
|
+
onAction: () => this._sendAction(C.action),
|
|
3928
|
+
...C.icon ? { icon: C.icon } : {}
|
|
3929
|
+
}))
|
|
3930
|
+
), f.length > 0 && this._drawer?.setPills(
|
|
3931
|
+
f.map((C) => {
|
|
3932
|
+
const M = {
|
|
3933
|
+
label: C.label,
|
|
3934
|
+
onAction: () => this._sendAction(C.action)
|
|
3935
|
+
};
|
|
3936
|
+
return C.icon && (M.icon = C.icon), C.image && (M.image = C.image), C.description && (M.description = C.description), M;
|
|
3937
|
+
})
|
|
3938
|
+
);
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
r.uiSpec = h;
|
|
3942
|
+
},
|
|
3943
|
+
onAction: (h) => {
|
|
3944
|
+
if (!(!n && a !== this._activeRequestThreadId) && h.type === "action") {
|
|
3945
|
+
const L = {};
|
|
3946
|
+
this.config.actionHandling?.unknownActionPolicy !== void 0 && (L.unknownActionPolicy = this.config.actionHandling.unknownActionPolicy), this.config.actionHandling?.allowScriptCall !== void 0 && (L.allowScriptCall = this.config.actionHandling.allowScriptCall), ft(
|
|
3947
|
+
h,
|
|
3948
|
+
{
|
|
3949
|
+
openChat: () => this.open(),
|
|
3950
|
+
navigate: (A) => {
|
|
3951
|
+
H(A.url) && (this._bridge?.send("navigate", A), A.newTab ? window.open(A.url, "_blank", "noopener,noreferrer") : window.location.href = A.url);
|
|
3952
|
+
},
|
|
3953
|
+
saveSession: (A) => this.saveSession(A.sessionId, A.sku),
|
|
3954
|
+
addToCart: (A) => {
|
|
3955
|
+
V("gengage:similar:add-to-cart", A);
|
|
3956
|
+
},
|
|
3957
|
+
scriptCall: (A) => {
|
|
3958
|
+
V("gengage:chat:script-call", A), this.config.onScriptCall?.(A);
|
|
3959
|
+
}
|
|
3960
|
+
},
|
|
3961
|
+
L
|
|
3962
|
+
);
|
|
3963
|
+
}
|
|
3964
|
+
},
|
|
3965
|
+
onMetadata: (h) => {
|
|
3966
|
+
if (!(!n && a !== this._activeRequestThreadId) && h.type === "metadata" && h.meta) {
|
|
3967
|
+
if ((h.meta.panel !== void 0 || h.meta.messages !== void 0 || h.meta.message_id !== void 0) && (this._lastBackendContext = h.meta), h.meta.panelLoading) {
|
|
3968
|
+
I = !0, S = !1;
|
|
3969
|
+
const A = typeof h.meta.panelPendingType == "string" ? h.meta.panelPendingType : void 0;
|
|
3970
|
+
this._panel && (this._panel.currentType = null), this._drawer?.showPanelLoading(A), A && this._panel?.updateTopBarForLoading(A);
|
|
3971
|
+
}
|
|
3972
|
+
if (h.meta.voice) {
|
|
3973
|
+
const A = new CustomEvent("gengage:chat:voice", {
|
|
3974
|
+
detail: { payload: h.meta.voice },
|
|
3975
|
+
bubbles: !1,
|
|
3976
|
+
cancelable: !0
|
|
3977
|
+
}), u = window.dispatchEvent(A);
|
|
3978
|
+
if (rt(), u) {
|
|
3979
|
+
const b = h.meta.voice;
|
|
3980
|
+
b.audio_base64 && (this._activeTtsHandle?.stop(), this._activeTtsHandle = qt(
|
|
3981
|
+
b.audio_base64,
|
|
3982
|
+
b.content_type ?? "audio/ogg"
|
|
3983
|
+
));
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
(h.meta.redirectTarget || h.meta.redirect) && V("gengage:chat:redirect", {
|
|
3987
|
+
target: h.meta.redirectTarget ?? null,
|
|
3988
|
+
payload: h.meta.redirect ?? null
|
|
3989
|
+
}), h.meta.analyzeAnimation && (I = !0, S = !1, this._panel && (this._panel.currentType = null), this._drawer?.showPanelLoading(), this._panel?.updateTopBarForLoading("productDetails")), h.meta.loading && typeof h.meta.loadingText == "string" && (this._drawer?.addThinkingStep(h.meta.loadingText), this._bridge?.send("loadingMessage", { text: h.meta.loadingText })), h.meta.visitorDataResponse && this._bridge?.send("engagingMessage", h.meta.visitorDataResponse), h.meta.formType && this._bridge?.send("glovOtokoc", {
|
|
3990
|
+
type: h.meta.formType,
|
|
3991
|
+
data: h.meta.formPayload
|
|
3992
|
+
}), h.meta.launcherContent && this._bridge?.send("launcherContent", h.meta.launcherContent), V("gengage:chat:metadata", { payload: h.meta });
|
|
3993
|
+
const L = h.meta;
|
|
3994
|
+
typeof L.prompt_tokens == "number" && typeof L.completion_tokens == "number" && this.track(
|
|
3995
|
+
st(this.analyticsContext(), {
|
|
3996
|
+
model: h.model ?? "unknown",
|
|
3997
|
+
prompt_tokens: L.prompt_tokens,
|
|
3998
|
+
completion_tokens: L.completion_tokens,
|
|
3999
|
+
total_tokens: L.total_tokens ?? L.prompt_tokens + L.completion_tokens
|
|
4000
|
+
})
|
|
4001
|
+
);
|
|
4002
|
+
}
|
|
4003
|
+
},
|
|
4004
|
+
onError: (h) => {
|
|
4005
|
+
if (v && this._abortControllers.delete(v), !n && a !== this._activeRequestThreadId) return;
|
|
4006
|
+
this._bridge?.send("isResponding", !1), this._bridge?.send("loadingMessage", { text: null }), this._drawer?.removeTypingIndicator();
|
|
4007
|
+
const L = S;
|
|
4008
|
+
if (I && !S && this._drawer?.isPanelLoading() && this._drawer.clearPanel(), I = !1, S = !1, !(r.silent || r.content != null && r.content.length > 0 || l.length > 0 || L))
|
|
4009
|
+
if (i || this._hasUnavailableProductContext()) {
|
|
4010
|
+
const u = this._i18n.productNotFoundMessage;
|
|
4011
|
+
r.content = u, r.status = "done", this._ensureAssistantMessageRendered(r), this._drawer?.updateBotMessage(r.id, u), this._markUnavailableProductContext();
|
|
4012
|
+
} else
|
|
4013
|
+
this.emit("error", h), this._drawer?.showError(this._i18n.errorMessage, () => {
|
|
4014
|
+
this._lastSentAction && this._sendAction(this._lastSentAction.action, this._lastSentAction.options);
|
|
4015
|
+
});
|
|
4016
|
+
i && (this._pdpPrimingInFlight = !1, this._flushQueuedUserMessages()), r.status === "streaming" && (r.status = "error"), this.track(
|
|
4017
|
+
ot(this.analyticsContext(), {
|
|
4018
|
+
request_id: _,
|
|
4019
|
+
error_code: "STREAM_ERROR",
|
|
4020
|
+
error_message: h.message,
|
|
4021
|
+
widget: "chat"
|
|
4022
|
+
})
|
|
4023
|
+
);
|
|
4024
|
+
},
|
|
4025
|
+
onDone: () => {
|
|
4026
|
+
if (v && this._abortControllers.delete(v), !(!n && a !== this._activeRequestThreadId)) {
|
|
4027
|
+
if (this._activeRequestThreadId = null, this._bridge?.send("isResponding", !1), this._bridge?.send("loadingMessage", { text: null }), this._drawer?.removeTypingIndicator(), I && !S && this._drawer?.isPanelLoading() && this._drawer.clearPanel(), I = !1, S = !1, i && !l && !S) {
|
|
4028
|
+
const h = this._i18n.productNotFoundMessage;
|
|
4029
|
+
r.content = h, this._ensureAssistantMessageRendered(r), this._drawer?.updateBotMessage(r.id, h), this._markUnavailableProductContext();
|
|
4030
|
+
}
|
|
4031
|
+
i && (this._pdpPrimingInFlight = !1, this._flushQueuedUserMessages()), r.status === "streaming" && (r.status = "done", pe()), this.emit("message", r), this._panel?.snapshotForMessage(r.id), this._panel?.attachClickHandler(r.id), this.track(
|
|
4032
|
+
at(this.analyticsContext(), {
|
|
4033
|
+
request_id: _,
|
|
4034
|
+
latency_ms: Date.now() - x,
|
|
4035
|
+
chunk_count: E,
|
|
4036
|
+
widget: "chat"
|
|
4037
|
+
})
|
|
4038
|
+
), this.track(
|
|
4039
|
+
nt(this.analyticsContext(), {
|
|
4040
|
+
meter_key: "chat_request",
|
|
4041
|
+
quantity: 1,
|
|
4042
|
+
unit: "request"
|
|
4043
|
+
})
|
|
4044
|
+
), this.track(
|
|
4045
|
+
it(this.analyticsContext(), {
|
|
4046
|
+
message_count: this._messages.length,
|
|
4047
|
+
history_ref: this.config.session?.sessionId ?? "",
|
|
4048
|
+
redaction_level: "none"
|
|
4049
|
+
})
|
|
4050
|
+
), this._persistToIndexedDB().catch(() => {
|
|
4051
|
+
});
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
},
|
|
4055
|
+
c
|
|
4056
|
+
), this._abortControllers.add(v), !t?.silent && !n) {
|
|
4057
|
+
const h = v;
|
|
4058
|
+
this._drawer?.showStopButton(() => {
|
|
4059
|
+
h.abort(), this._abortControllers.delete(h), this._drawer?.removeTypingIndicator(), this._bridge?.send("isResponding", !1), this._bridge?.send("loadingMessage", { text: null }), r.status === "streaming" && (r.status = "done");
|
|
4060
|
+
});
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
/** Return messages visible at the current thread cursor. */
|
|
4064
|
+
_getVisibleMessages() {
|
|
4065
|
+
const e = this._messages.filter((a) => !a.silent);
|
|
4066
|
+
if (!this._currentThreadId) return e;
|
|
4067
|
+
const t = this._currentThreadId;
|
|
4068
|
+
return e.filter((a) => !a.threadId || a.threadId <= t);
|
|
4069
|
+
}
|
|
4070
|
+
/** Handle rollback-on-click from a user message bubble. */
|
|
4071
|
+
_appendSimilarsToPanel(e, t) {
|
|
4072
|
+
if (!this._drawer) return;
|
|
4073
|
+
const a = this._drawer.getPanelContentElement();
|
|
4074
|
+
if (!a) return;
|
|
4075
|
+
const n = document.createElement("h3");
|
|
4076
|
+
n.className = "gengage-chat-product-details-similars-heading", n.textContent = this._i18n.similarProductsLabel ?? "Similar Products", a.appendChild(n);
|
|
4077
|
+
const i = this._renderUISpec(e, t);
|
|
4078
|
+
i.classList.add("gengage-chat-product-details-similars"), a.appendChild(i);
|
|
4079
|
+
}
|
|
4080
|
+
_handleRollback(e) {
|
|
4081
|
+
const t = this._messages.find((a) => a.id === e);
|
|
4082
|
+
t?.threadId && this._rollbackToThread(t.threadId);
|
|
4083
|
+
}
|
|
4084
|
+
/** Rewind the conversation to the given thread. */
|
|
4085
|
+
_rollbackToThread(e) {
|
|
4086
|
+
this._currentThreadId = e, this._extendedModeManager?.setHiddenByUser(!1);
|
|
4087
|
+
for (const i of this._messages) {
|
|
4088
|
+
const s = this._shadow?.querySelector(`[data-message-id="${CSS.escape(i.id)}"]`);
|
|
4089
|
+
s && (i.threadId && i.threadId > e ? s.classList.add("gengage-chat-bubble--hidden") : s.classList.remove("gengage-chat-bubble--hidden"));
|
|
4090
|
+
}
|
|
4091
|
+
this._shadow?.querySelectorAll("[data-thread-id]").forEach((i) => {
|
|
4092
|
+
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");
|
|
4093
|
+
});
|
|
4094
|
+
const t = this._messages.find((i) => i.role === "assistant" && i.threadId === e);
|
|
4095
|
+
t && this._panel?.restoreForMessage(t.id) || this._drawer?.clearPanel();
|
|
4096
|
+
const n = this._panel.currentType ?? "";
|
|
4097
|
+
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) => {
|
|
4098
|
+
i && (this._lastBackendContext = i.context);
|
|
4099
|
+
}).catch(() => {
|
|
4100
|
+
}), this._session?.db && this.config.session?.sessionId && this._session?.db.deleteContextsAfterThread(this.config.session.sessionId, e).catch(() => {
|
|
4101
|
+
});
|
|
4102
|
+
}
|
|
4103
|
+
// ---------------------------------------------------------------------------
|
|
4104
|
+
// IndexedDB persistence (delegates to SessionPersistence)
|
|
4105
|
+
// ---------------------------------------------------------------------------
|
|
4106
|
+
async _persistToIndexedDB() {
|
|
4107
|
+
!this._session || !this.config.session?.sessionId || await this._session.persist({
|
|
4108
|
+
userId: this.config.session.userId ?? "",
|
|
4109
|
+
appId: this.config.accountId,
|
|
4110
|
+
sessionId: this.config.session.sessionId,
|
|
4111
|
+
messages: this._messages,
|
|
4112
|
+
currentThreadId: this._currentThreadId,
|
|
4113
|
+
lastThreadId: this._lastThreadId,
|
|
4114
|
+
chatCreatedAt: this._chatCreatedAt,
|
|
4115
|
+
panelSnapshots: this._panel?.snapshots ?? /* @__PURE__ */ new Map(),
|
|
4116
|
+
panelThreads: this._panel?.threads ?? [],
|
|
4117
|
+
thumbnailEntries: this._thumbnailEntries,
|
|
4118
|
+
lastBackendContext: this._lastBackendContext,
|
|
4119
|
+
sku: this.config.pageContext?.sku
|
|
4120
|
+
});
|
|
4121
|
+
}
|
|
4122
|
+
_isSameOriginUrl(e) {
|
|
4123
|
+
try {
|
|
4124
|
+
return e.trim() ? new URL(e, window.location.href).origin === window.location.origin : !1;
|
|
4125
|
+
} catch {
|
|
4126
|
+
return !1;
|
|
4127
|
+
}
|
|
4128
|
+
}
|
|
4129
|
+
_markUnavailableProductContext() {
|
|
4130
|
+
this._productContextUnavailableSku = this.config.pageContext?.sku ?? null;
|
|
4131
|
+
}
|
|
4132
|
+
_clearUnavailableProductContext() {
|
|
4133
|
+
this._productContextUnavailableSku = null;
|
|
4134
|
+
}
|
|
4135
|
+
_hasUnavailableProductContext() {
|
|
4136
|
+
const e = this.config.pageContext?.sku;
|
|
4137
|
+
return e !== void 0 && e.length > 0 && this._productContextUnavailableSku === e;
|
|
4138
|
+
}
|
|
4139
|
+
_ensureAssistantMessageRendered(e) {
|
|
4140
|
+
if (!(this._shadow?.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`) || !this._drawer)) {
|
|
4141
|
+
if (e.role === "assistant" && e.threadId && !this._threadsWithFirstBot.has(e.threadId)) {
|
|
4142
|
+
this._threadsWithFirstBot.add(e.threadId), this._drawer.addMessage(e), this._drawer.markFirstBotMessage(e.id);
|
|
4143
|
+
return;
|
|
4144
|
+
}
|
|
4145
|
+
this._drawer.addMessage(e);
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
async _saveSessionAndOpenURL(e) {
|
|
4149
|
+
this._session && await this._session.saveAndOpenURL(e, () => this._persistToIndexedDB(), this._bridge);
|
|
4150
|
+
}
|
|
4151
|
+
async _loadPayload(e, t) {
|
|
4152
|
+
return this._session ? this._session.loadPayload(e, t) : null;
|
|
4153
|
+
}
|
|
4154
|
+
/**
|
|
4155
|
+
* Attempt to restore chat session from IndexedDB.
|
|
4156
|
+
* Always restores when IDB has session data for the current sessionId.
|
|
4157
|
+
* Best-effort — failures are silently ignored.
|
|
4158
|
+
*/
|
|
4159
|
+
async _restoreFromIndexedDB(e) {
|
|
4160
|
+
if (!this._session?.db) return;
|
|
4161
|
+
const t = this.config.session?.sessionId;
|
|
4162
|
+
if (!t) return;
|
|
4163
|
+
const a = this.config.session?.userId ?? "", n = this.config.accountId;
|
|
4164
|
+
if (await this._session.loadFavorites(a, n), !e) return;
|
|
4165
|
+
const i = await this._session.db?.loadSession(a, n, t);
|
|
4166
|
+
if (!i || i.messages.length === 0) return;
|
|
4167
|
+
const s = this.config.pageContext?.sku;
|
|
4168
|
+
if (s && i.sku && i.sku !== s) return;
|
|
4169
|
+
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)
|
|
4170
|
+
for (const [r, c] of Object.entries(i.panelSnapshotHtml)) {
|
|
4171
|
+
const g = document.createElement("div");
|
|
4172
|
+
g.innerHTML = $(c), this._panel.snapshots.set(r, g);
|
|
4173
|
+
}
|
|
4174
|
+
let l = 0;
|
|
4175
|
+
for (const r of i.messages) {
|
|
4176
|
+
const c = {
|
|
4177
|
+
id: r.id,
|
|
4178
|
+
role: r.role,
|
|
4179
|
+
timestamp: r.timestamp,
|
|
4180
|
+
status: r.status
|
|
4181
|
+
};
|
|
4182
|
+
if (r.threadId !== void 0 && (c.threadId = r.threadId), r.content !== void 0 && (c.content = r.content), r.silent && (c.silent = !0), this._messages.push(c), c.silent) continue;
|
|
4183
|
+
c.role === "assistant" && c.threadId && !this._threadsWithFirstBot.has(c.threadId) && (this._threadsWithFirstBot.add(c.threadId), this._drawer?.markFirstBotMessage(c.id)), this._drawer?.addMessage(c);
|
|
4184
|
+
const g = parseInt(r.id.replace("msg-", ""), 10);
|
|
4185
|
+
if (!isNaN(g) && g > l && (l = g), c.role === "assistant" && c.threadId) {
|
|
4186
|
+
const d = await this._loadPayload(c.threadId, c.id);
|
|
4187
|
+
d && (c.uiSpec = d, this._restoreInlineUISpec(c), this._panel?.attachClickHandler(c.id), delete c.uiSpec);
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
if (l > this._currentMessageId && (this._currentMessageId = l), this._currentThreadId) {
|
|
4191
|
+
let r = await this._session.db?.loadContext(t, this._currentThreadId);
|
|
4192
|
+
r || (r = await this._session.db?.loadLatestContext(t)), r && (this._lastBackendContext = r.context);
|
|
4193
|
+
}
|
|
4194
|
+
if (this._currentThreadId) {
|
|
4195
|
+
const r = [...this._messages].reverse().find((c) => c.role === "assistant" && c.threadId === this._currentThreadId && !c.silent);
|
|
4196
|
+
r && this._panel.snapshots.has(r.id) && this._panel?.restoreForMessage(r.id);
|
|
4197
|
+
}
|
|
4198
|
+
if (this._currentThreadId) {
|
|
4199
|
+
const r = this._currentThreadId;
|
|
4200
|
+
for (const c of this._messages)
|
|
4201
|
+
c.threadId && c.threadId > r && this._shadow?.querySelector(`[data-message-id="${CSS.escape(c.id)}"]`)?.classList.add("gengage-chat-bubble--hidden");
|
|
4202
|
+
this._shadow?.querySelectorAll("[data-thread-id]").forEach((c) => {
|
|
4203
|
+
c instanceof HTMLElement && c.dataset.threadId && c.dataset.threadId > r && c.classList.add("gengage-chat-bubble--hidden");
|
|
4204
|
+
});
|
|
4205
|
+
}
|
|
4206
|
+
if (this._panel.threads.length > 0 && this._currentThreadId) {
|
|
4207
|
+
const r = this._panel.threads[this._panel.threads.length - 1];
|
|
4208
|
+
if (r) {
|
|
4209
|
+
const c = [...this._messages].reverse().find((g) => g.role === "assistant" && g.threadId === r);
|
|
4210
|
+
if (c?.threadId) {
|
|
4211
|
+
const g = await this._loadPayload(c.threadId, c.id);
|
|
4212
|
+
if (g) {
|
|
4213
|
+
const d = g.elements[g.root];
|
|
4214
|
+
d && this._panel?.updateTopBar(d.type);
|
|
4215
|
+
}
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
}
|
|
4219
|
+
setTimeout(() => {
|
|
4220
|
+
this._drawer?.scrollToLastThread();
|
|
4221
|
+
}, 550);
|
|
4222
|
+
}
|
|
4223
|
+
/**
|
|
4224
|
+
* Toggle comparison mode or individual SKU selection, then refresh the DOM.
|
|
4225
|
+
* Extracted so both the render-context callback and DOM-created checkboxes
|
|
4226
|
+
* share the same state-mutation + refresh path.
|
|
4227
|
+
*/
|
|
4228
|
+
_toggleComparisonSku(e) {
|
|
4229
|
+
e === "" ? (this._comparisonSelectMode = !this._comparisonSelectMode, this._comparisonSelectMode || (this._comparisonSelectedSkus = [], Ye())) : this._comparisonSelectedSkus.indexOf(e) >= 0 ? this._comparisonSelectedSkus = this._comparisonSelectedSkus.filter((a) => a !== e) : (this._comparisonSelectedSkus = [...this._comparisonSelectedSkus, e], Ke(e)), this._refreshComparisonUI();
|
|
4230
|
+
}
|
|
4231
|
+
/**
|
|
4232
|
+
* Refresh the panel DOM to reflect the current comparison state without
|
|
4233
|
+
* full re-render. Updates: toggle button active class, checkbox overlays
|
|
4234
|
+
* on product cards, and the floating comparison button.
|
|
4235
|
+
*/
|
|
4236
|
+
_refreshComparisonUI() {
|
|
4237
|
+
const e = this._shadow?.querySelector(".gengage-chat-panel");
|
|
4238
|
+
if (!e) return;
|
|
4239
|
+
const t = e.querySelector(".gengage-chat-product-grid-wrapper");
|
|
4240
|
+
if (!t) return;
|
|
4241
|
+
const a = t.querySelector(".gengage-chat-product-grid");
|
|
4242
|
+
if (!a) return;
|
|
4243
|
+
const n = t.querySelector(".gengage-chat-comparison-toggle-btn");
|
|
4244
|
+
if (n && n.classList.toggle("gengage-chat-comparison-toggle-btn--active", this._comparisonSelectMode), this._comparisonSelectMode) {
|
|
4245
|
+
const s = a.querySelectorAll(".gengage-chat-product-card[data-sku]");
|
|
4246
|
+
for (const l of s) {
|
|
4247
|
+
if (l.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")) {
|
|
4248
|
+
const d = l.parentElement.querySelector(".gengage-chat-comparison-checkbox");
|
|
4249
|
+
d && (d.checked = this._comparisonSelectedSkus.includes(l.dataset.sku));
|
|
4250
|
+
continue;
|
|
4251
|
+
}
|
|
4252
|
+
const r = l.dataset.sku, c = document.createElement("div");
|
|
4253
|
+
c.className = "gengage-chat-comparison-select-wrapper";
|
|
4254
|
+
const g = document.createElement("input");
|
|
4255
|
+
g.type = "checkbox", g.className = "gengage-chat-comparison-checkbox", g.checked = this._comparisonSelectedSkus.includes(r), g.addEventListener("change", () => {
|
|
4256
|
+
this._toggleComparisonSku(r);
|
|
4257
|
+
}), l.parentNode.insertBefore(c, l), c.appendChild(g), c.appendChild(l), c.style.cursor = "pointer", c.addEventListener("click", (d) => {
|
|
4258
|
+
d.target !== g && (g.checked = !g.checked, this._toggleComparisonSku(r));
|
|
4259
|
+
});
|
|
4260
|
+
}
|
|
4261
|
+
} else {
|
|
4262
|
+
const s = a.querySelectorAll(".gengage-chat-comparison-select-wrapper");
|
|
4263
|
+
for (const l of s) {
|
|
4264
|
+
const r = l.querySelector(".gengage-chat-product-card");
|
|
4265
|
+
r && l.parentNode && (l.parentNode.insertBefore(r, l), l.remove());
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
const i = t.querySelector(".gengage-chat-comparison-floating-btn");
|
|
4269
|
+
if (this._comparisonSelectMode) {
|
|
4270
|
+
const s = this._comparisonSelectedSkus.length, l = s >= 2, r = this._i18n.compareSelected ?? "Compare", c = l ? `${r} (${s})` : this._i18n.compareMinHint ?? "Select at least 2 products";
|
|
4271
|
+
if (i)
|
|
4272
|
+
i.textContent = c, i.disabled = !l, i.classList.toggle("gengage-chat-comparison-floating-btn--disabled", !l);
|
|
4273
|
+
else {
|
|
4274
|
+
const g = document.createElement("button");
|
|
4275
|
+
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", () => {
|
|
4276
|
+
this._comparisonSelectedSkus.length < 2 || (de(this._comparisonSelectedSkus), this._sendAction({
|
|
4277
|
+
title: r,
|
|
4278
|
+
type: "getComparisonTable",
|
|
4279
|
+
payload: { sku_list: [...this._comparisonSelectedSkus] }
|
|
4280
|
+
}));
|
|
4281
|
+
}), t.appendChild(g);
|
|
4282
|
+
}
|
|
4283
|
+
} else
|
|
4284
|
+
i?.remove();
|
|
4285
|
+
}
|
|
4286
|
+
/**
|
|
4287
|
+
* Build a ChatUISpecRenderContext with all callbacks wired up.
|
|
4288
|
+
* Used both during streaming and during session restore.
|
|
4289
|
+
*/
|
|
4290
|
+
_buildRenderContext() {
|
|
4291
|
+
const e = {
|
|
4292
|
+
onAction: (t) => {
|
|
4293
|
+
if (et(t.title, t.type), t.type === "findSimilar") {
|
|
4294
|
+
const n = typeof t.payload == "object" && t.payload !== null && "sku" in t.payload ? String(t.payload.sku) : "";
|
|
4295
|
+
tt(n);
|
|
4296
|
+
}
|
|
4297
|
+
t.type === "getComparisonTable" && de(this._comparisonSelectedSkus);
|
|
4298
|
+
const a = t.type === "addToCart" || t.type === "like";
|
|
4299
|
+
this._sendAction(t, a ? { preservePanel: !0 } : void 0);
|
|
4300
|
+
},
|
|
4301
|
+
onProductClick: (t) => {
|
|
4302
|
+
Ze(t.sku), this.config.isDemoWebsite !== !0 && this._isSameOriginUrl(t.url) ? (V("gengage:similar:product-click", {
|
|
4303
|
+
sku: t.sku,
|
|
4304
|
+
url: t.url,
|
|
4305
|
+
sessionId: this.config.session?.sessionId ?? null
|
|
4306
|
+
}), this._saveSessionAndOpenURL(t.url)) : this._sendAction({
|
|
4307
|
+
title: t.sku,
|
|
4308
|
+
type: "launchSingleProduct",
|
|
4309
|
+
payload: { sku: t.sku }
|
|
4310
|
+
});
|
|
4311
|
+
},
|
|
4312
|
+
onAddToCart: (t) => {
|
|
4313
|
+
Je(t.sku, t.quantity);
|
|
4314
|
+
const a = {
|
|
4315
|
+
...t,
|
|
4316
|
+
sessionId: this.config.session?.sessionId ?? null
|
|
4317
|
+
};
|
|
4318
|
+
V("gengage:chat:add-to-cart", a), this._bridge?.send("addToCart", t), this._runEventCallbacks("gengage-cart-add", a), this._sendAction(
|
|
4319
|
+
{
|
|
4320
|
+
title: this._i18n.addToCartButton ?? "Add to Cart",
|
|
4321
|
+
type: "addToCart",
|
|
4322
|
+
payload: { sku: t.sku, cart_code: t.cartCode, quantity: t.quantity }
|
|
4323
|
+
},
|
|
4324
|
+
{ preservePanel: !0 }
|
|
4325
|
+
);
|
|
4326
|
+
},
|
|
4327
|
+
onProductSelect: (t) => {
|
|
4328
|
+
const a = {
|
|
4329
|
+
root: "root",
|
|
4330
|
+
elements: {
|
|
4331
|
+
root: {
|
|
4332
|
+
type: "ProductDetailsPanel",
|
|
4333
|
+
props: { product: t }
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
};
|
|
4337
|
+
this._drawer?.setPanelContent(this._renderUISpec(a, e));
|
|
4338
|
+
},
|
|
4339
|
+
i18n: this._i18n,
|
|
4340
|
+
pricing: this.config.pricing,
|
|
4341
|
+
productSort: this._productSort,
|
|
4342
|
+
onSortChange: (t) => {
|
|
4343
|
+
this._productSort = t;
|
|
4344
|
+
},
|
|
4345
|
+
comparisonSelectMode: this._comparisonSelectMode,
|
|
4346
|
+
comparisonSelectedSkus: this._comparisonSelectedSkus,
|
|
4347
|
+
onToggleComparisonSku: (t) => {
|
|
4348
|
+
this._toggleComparisonSku(t);
|
|
4349
|
+
},
|
|
4350
|
+
favoritedSkus: this._session?.favoritedSkus ?? /* @__PURE__ */ new Set(),
|
|
4351
|
+
onFavoriteToggle: (t, a) => {
|
|
4352
|
+
Xe(t), this._toggleFavorite(t, a);
|
|
4353
|
+
const n = a.name ?? t;
|
|
4354
|
+
this._sendAction(
|
|
4355
|
+
{
|
|
4356
|
+
title: n,
|
|
4357
|
+
type: "like",
|
|
4358
|
+
payload: { sku: t }
|
|
4359
|
+
},
|
|
4360
|
+
{ preservePanel: !0 }
|
|
4361
|
+
);
|
|
4362
|
+
}
|
|
4363
|
+
};
|
|
4364
|
+
return e;
|
|
4365
|
+
}
|
|
4366
|
+
async _toggleFavorite(e, t) {
|
|
4367
|
+
if (!this._session) return;
|
|
4368
|
+
const a = this.config.session?.userId ?? "", n = this.config.accountId;
|
|
4369
|
+
await this._session.toggleFavorite(a, n, e, t);
|
|
4370
|
+
}
|
|
4371
|
+
/**
|
|
4372
|
+
* Run registered callbacks for a GA4 event.
|
|
4373
|
+
* If any callback returns false or throws, handle the failure (e.g. show error for cart-add).
|
|
4374
|
+
*/
|
|
4375
|
+
async _runEventCallbacks(e, t) {
|
|
4376
|
+
const a = this._eventCallbacks.get(e);
|
|
4377
|
+
if (!(!a || a.size === 0))
|
|
4378
|
+
for (const n of a)
|
|
4379
|
+
try {
|
|
4380
|
+
const i = n(t);
|
|
4381
|
+
if ((i instanceof Promise ? await i : i) === !1) {
|
|
4382
|
+
this._handleCallbackFailure(e, t);
|
|
4383
|
+
return;
|
|
4384
|
+
}
|
|
4385
|
+
} catch {
|
|
4386
|
+
this._handleCallbackFailure(e, t);
|
|
4387
|
+
return;
|
|
4388
|
+
}
|
|
4389
|
+
}
|
|
4390
|
+
/**
|
|
4391
|
+
* Handle a callback failure — for add-to-cart, show an error message in chat.
|
|
4392
|
+
*/
|
|
4393
|
+
_handleCallbackFailure(e, t) {
|
|
4394
|
+
if (e === "gengage-cart-add") {
|
|
4395
|
+
const a = this._i18n.cartAddErrorMessage, n = this._createMessage("assistant", a);
|
|
4396
|
+
this._currentThreadId && (n.threadId = this._currentThreadId), this._messages.push(n), this._drawer?.addMessage(n);
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
/**
|
|
4400
|
+
* Re-render inline UISpec elements for a restored bot message.
|
|
4401
|
+
* Inserts them into the messages container after the message bubble.
|
|
4402
|
+
*/
|
|
4403
|
+
_restoreInlineUISpec(e) {
|
|
4404
|
+
if (!e.uiSpec || !this._drawer) return;
|
|
4405
|
+
const t = e.uiSpec, a = t.elements[t.root];
|
|
4406
|
+
if (!a) return;
|
|
4407
|
+
const n = a.type;
|
|
4408
|
+
if (n === "ActionButtons" || n === "ComparisonTable" || n === "ProductGrid" && a.props?.similarsAppend === !0) return;
|
|
4409
|
+
const i = this._buildRenderContext(), s = this._shadow?.querySelector(".gengage-chat-messages");
|
|
4410
|
+
if (!s) return;
|
|
4411
|
+
if (n === "ProductDetailsPanel") {
|
|
4412
|
+
const r = a.props?.product;
|
|
4413
|
+
if (!r) return;
|
|
4414
|
+
const c = {
|
|
4415
|
+
root: "root",
|
|
4416
|
+
elements: { root: { type: "ProductSummaryCard", props: { product: r } } }
|
|
4417
|
+
}, g = this._renderUISpec(c, i);
|
|
4418
|
+
e.threadId && (g.dataset.threadId = e.threadId), s.appendChild(g);
|
|
4419
|
+
return;
|
|
4420
|
+
}
|
|
4421
|
+
const l = this._renderUISpec(t, i);
|
|
4422
|
+
e.threadId && (l.dataset.threadId = e.threadId), s.appendChild(l);
|
|
4423
|
+
}
|
|
4424
|
+
_createMessage(e, t) {
|
|
4425
|
+
return this._currentMessageId++, {
|
|
4426
|
+
id: `msg-${this._currentMessageId}`,
|
|
4427
|
+
role: e,
|
|
4428
|
+
content: t,
|
|
4429
|
+
timestamp: Date.now(),
|
|
4430
|
+
status: "done"
|
|
4431
|
+
};
|
|
4432
|
+
}
|
|
4433
|
+
_resolveI18n(e) {
|
|
4434
|
+
return { ...Lt(e.locale), ...e.i18n };
|
|
4435
|
+
}
|
|
4436
|
+
_resolveUISpecRegistry() {
|
|
4437
|
+
const e = ca();
|
|
4438
|
+
return Qe(e, this.config.renderer?.registry);
|
|
4439
|
+
}
|
|
4440
|
+
_renderUISpec(e, t) {
|
|
4441
|
+
const a = this._resolveUISpecRegistry(), n = this.config.renderer?.unknownRenderer ?? Ne, i = (r, c) => la(r, c, a, n), s = this.config.renderer?.renderUISpec;
|
|
4442
|
+
return s ? s(e, t, {
|
|
4443
|
+
registry: a,
|
|
4444
|
+
unknownRenderer: n,
|
|
4445
|
+
defaultRender: i
|
|
4446
|
+
}) : i(e, t);
|
|
4447
|
+
}
|
|
4448
|
+
}
|
|
4449
|
+
function fn() {
|
|
4450
|
+
return new pn();
|
|
4451
|
+
}
|
|
4452
|
+
export {
|
|
4453
|
+
pn as G,
|
|
4454
|
+
At as V,
|
|
4455
|
+
ca as a,
|
|
4456
|
+
la as b,
|
|
4457
|
+
fn as c,
|
|
4458
|
+
Ne as d,
|
|
4459
|
+
mn as e,
|
|
4460
|
+
It as i,
|
|
4461
|
+
ft as r
|
|
4462
|
+
};
|
|
4463
|
+
//# sourceMappingURL=index-CEt87kCd.js.map
|