@gengage/assistant-fe 0.1.5 → 0.1.7

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