@gengage/assistant-fe 0.1.0

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