@gengage/assistant-fe 0.1.0 → 0.1.1

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