@gengage/assistant-fe 0.6.12 → 0.6.14

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 (50) hide show
  1. package/dist/agentic/adaptor/mount.d.ts +1 -0
  2. package/dist/agentic/context/context-store.d.ts +2 -1
  3. package/dist/agentic/context/persistence.d.ts +2 -1
  4. package/dist/agentic/index.d.ts +3 -2
  5. package/dist/agentic/index.js +244 -240
  6. package/dist/agentic/types.d.ts +28 -20
  7. package/dist/agentic/util/browser-memory.d.ts +2 -2
  8. package/dist/agentic/util/cache-key.d.ts +15 -0
  9. package/dist/agentic/worker/be-client.d.ts +3 -1
  10. package/dist/agentic/worker.d.ts +3 -2
  11. package/dist/agentic/worker.js +92 -86
  12. package/dist/agentic.iife.js +5 -5
  13. package/dist/{api-paths-Cth1szY1.js → api-paths-kwROurUu.js} +1 -1
  14. package/dist/{chat-CrEa2W-e.js → chat-BP-yXukW.js} +1 -1
  15. package/dist/chat-runtime.js +1 -1
  16. package/dist/chat.iife.js +17 -17
  17. package/dist/chat.js +2 -2
  18. package/dist/common/request-response-cache.d.ts +9 -0
  19. package/dist/{common-CmPjQ9RK.js → common-DZuPNgWh.js} +3 -3
  20. package/dist/common.js +7 -7
  21. package/dist/{connection-warning-Bx1TJaU9.js → connection-warning-Bg4gn-cq.js} +1 -1
  22. package/dist/{fastIntent-nZXiT9DG.js → fastIntent-BSgLJDlW.js} +1 -1
  23. package/dist/index.js +12 -12
  24. package/dist/{native-webview-BlHM7cLs.js → native-webview-DbKq9lN8.js} +1 -1
  25. package/dist/native.iife.js +14 -14
  26. package/dist/native.js +1 -1
  27. package/dist/overlay.js +1 -1
  28. package/dist/{qna-BNvttR6s.js → qna-B3lMzHvS.js} +1 -1
  29. package/dist/qna-runtime.js +1 -1
  30. package/dist/qna.iife.js +13 -13
  31. package/dist/qna.js +2 -2
  32. package/dist/request-response-cache-zsgz3Awp.js +154 -0
  33. package/dist/request-text-su3Vlhrs.js +1318 -0
  34. package/dist/{runtime-B0v76aJ5.js → runtime-CAJp9Ehc.js} +366 -365
  35. package/dist/{runtime-xlTFF9HS.js → runtime-DwQSV54I.js} +38 -37
  36. package/dist/{runtime-Dt6FUotQ.js → runtime-KV5wCTc-.js} +69 -68
  37. package/dist/{simbut-pTonQlCT.js → simbut-Bm96zEAo.js} +1 -1
  38. package/dist/simbut.iife.js +1 -1
  39. package/dist/simbut.js +1 -1
  40. package/dist/{simrel-C3ZJHVIW.js → simrel-C9sM9CCV.js} +3 -3
  41. package/dist/simrel-runtime.js +1 -1
  42. package/dist/simrel.iife.js +12 -12
  43. package/dist/simrel.js +2 -2
  44. package/dist/{widget-base-C6H3cDSW.js → widget-base-TZjXRr3u.js} +1 -1
  45. package/package.json +1 -1
  46. package/dist/agentic/flow/beauty-consulting-turn.d.ts +0 -1
  47. package/dist/similarity-qMH5-do-.js +0 -1262
  48. /package/dist/{overlay-fgrzmFTR.js → overlay-CyoB1K0w.js} +0 -0
  49. /package/dist/{price-formatter-xI3g9Cd4.js → price-formatter-CFsWT0lP.js} +0 -0
  50. /package/dist/{schemas-CLo8wCjs.js → schemas-Cq2blsO_.js} +0 -0
@@ -1,9 +1,10 @@
1
- import { d as x, h as Q, p as R, r as N, t as H } from "./api-paths-Cth1szY1.js";
1
+ import { d as x, h as Q, p as R, r as N, t as H } from "./api-paths-kwROurUu.js";
2
2
  import { A as O, D as U, E as j, a as q, v as M } from "./context-BBuSsXZ9.js";
3
- import { o as F, t as W } from "./widget-base-C6H3cDSW.js";
3
+ import { o as F, t as W } from "./widget-base-TZjXRr3u.js";
4
4
  import { t as A } from "./locale-CfqNifrU.js";
5
- import { n as D } from "./connection-warning-Bx1TJaU9.js";
6
- async function z(e, t, n) {
5
+ import { t as D } from "./request-response-cache-zsgz3Awp.js";
6
+ import { n as z } from "./connection-warning-Bg4gn-cq.js";
7
+ async function $(e, t, n) {
7
8
  const o = H("launcher_action", t), i = {
8
9
  uiSpecs: [],
9
10
  actions: []
@@ -13,7 +14,7 @@ async function z(e, t, n) {
13
14
  body: JSON.stringify(e)
14
15
  };
15
16
  n !== void 0 && (a.signal = n);
16
- const l = await fetch(o, a);
17
+ const l = await D(o, a);
17
18
  if (!l.ok) throw new Error(`HTTP ${l.status}: ${l.statusText}`);
18
19
  const s = { onEvent: (c) => {
19
20
  const r = N(c);
@@ -47,7 +48,7 @@ function T(e) {
47
48
  }
48
49
  return t;
49
50
  }
50
- function $(e) {
51
+ function G(e) {
51
52
  const t = document.createElement("div");
52
53
  t.className = "gengage-qna-input-wrapper", t.dataset.gengagePart = "qna-input-wrapper";
53
54
  const n = document.createElement("div");
@@ -176,7 +177,7 @@ var L = {
176
177
  sendButtonText: t.i18n.sendButton,
177
178
  sendQuestionAriaLabel: t.i18n.sendQuestionAriaLabel
178
179
  };
179
- return o !== void 0 && (a.placeholders = o), i !== void 0 && (a.ctaLabel = i), $(a);
180
+ return o !== void 0 && (a.placeholders = o), i !== void 0 && (a.ctaLabel = i), G(a);
180
181
  },
181
182
  QuestionHeading: ({ element: e, context: t }) => {
182
183
  const n = document.createElement("h3");
@@ -194,10 +195,10 @@ var L = {
194
195
  }
195
196
  return n;
196
197
  };
197
- function G() {
198
+ function J() {
198
199
  return { ...L };
199
200
  }
200
- function J(e, t, n = L, o = S) {
201
+ function V(e, t, n = L, o = S) {
201
202
  return Q({
202
203
  spec: e,
203
204
  context: t,
@@ -206,7 +207,7 @@ function J(e, t, n = L, o = S) {
206
207
  unknownRenderer: o
207
208
  });
208
209
  }
209
- function V(e) {
210
+ function Y(e) {
210
211
  if (!e) return;
211
212
  const t = e.extra;
212
213
  if (t && typeof t == "object" && !Array.isArray(t)) {
@@ -233,7 +234,7 @@ function P(e, t) {
233
234
  };
234
235
  return s !== void 0 && (c.payload = s), c;
235
236
  }
236
- function Y(e, t) {
237
+ function Z(e, t) {
237
238
  const n = e.elements[e.root];
238
239
  if (!n) return !1;
239
240
  const o = (i) => {
@@ -258,7 +259,7 @@ var I = 0;
258
259
  function w() {
259
260
  return I += 1, `gengage-merge-${I}`;
260
261
  }
261
- function Z(e, t) {
262
+ function K(e, t) {
262
263
  const n = e.elements[e.root];
263
264
  if (!n || n.type !== "ButtonRow") return;
264
265
  const o = w();
@@ -274,7 +275,7 @@ function Z(e, t) {
274
275
  }
275
276
  }, n.children = n.children ? [o, ...n.children] : [o];
276
277
  }
277
- function K(e, t) {
278
+ function X(e, t) {
278
279
  const n = e.elements[e.root];
279
280
  if (!n || n.type !== "ActionButtons") return;
280
281
  const o = w();
@@ -302,7 +303,7 @@ function K(e, t) {
302
303
  buttons: [a, ...i]
303
304
  };
304
305
  }
305
- function X(e) {
306
+ function tt(e) {
306
307
  const t = {}, n = [];
307
308
  for (let o = 0; o < e.length; o++) {
308
309
  const i = e[o], a = `action-${o}`;
@@ -326,7 +327,7 @@ function X(e) {
326
327
  elements: t
327
328
  };
328
329
  }
329
- function tt(e) {
330
+ function et(e) {
330
331
  return e.find((t) => {
331
332
  const n = t.elements[t.root];
332
333
  return n?.type === "ActionButtons" || n?.type === "ButtonRow";
@@ -340,7 +341,7 @@ function k(e, t) {
340
341
  payload: o
341
342
  };
342
343
  }
343
- function et(e, t, n) {
344
+ function nt(e, t, n) {
344
345
  const o = n?.skuList, i = [], a = [];
345
346
  for (const c of e) {
346
347
  const r = c.elements[c.root];
@@ -354,11 +355,11 @@ function et(e, t, n) {
354
355
  a.push(c);
355
356
  }
356
357
  if (i.length === 0) return e;
357
- const l = k(t, o), s = tt(a);
358
- if (!s) return [...a, X([l])];
359
- if (!Y(s, l.title)) {
358
+ const l = k(t, o), s = et(a);
359
+ if (!s) return [...a, tt([l])];
360
+ if (!Z(s, l.title)) {
360
361
  const c = s.elements[s.root];
361
- c?.type === "ActionButtons" ? K(s, l) : c?.type === "ButtonRow" && Z(s, l);
362
+ c?.type === "ActionButtons" ? X(s, l) : c?.type === "ButtonRow" && K(s, l);
362
363
  }
363
364
  return a;
364
365
  }
@@ -371,7 +372,7 @@ var B = {
371
372
  defaultCtaText: "Başka bir şey sor",
372
373
  redirectingToChat: "Sohbete yönlendiriliyor...",
373
374
  productContextQuickPillLabel: "Bu ürün hakkında ne bilmeliyim?"
374
- }, nt = {
375
+ }, ot = {
375
376
  quickQuestionsAriaLabel: "Quick questions",
376
377
  askQuestionAriaLabel: "Ask a question",
377
378
  defaultInputPlaceholder: "Ask a question...",
@@ -381,13 +382,13 @@ var B = {
381
382
  redirectingToChat: "Redirecting to chat...",
382
383
  productContextQuickPillLabel: "What should I know about this product?"
383
384
  };
384
- function ot(e) {
385
+ function it(e) {
385
386
  return e ? e.toLowerCase().split("-")[0] ?? "tr" : "tr";
386
387
  }
387
- function it(e) {
388
- return ot(e) === "en" ? nt : B;
388
+ function at(e) {
389
+ return it(e) === "en" ? ot : B;
389
390
  }
390
- var at = class extends W {
391
+ var st = class extends W {
391
392
  constructor(...e) {
392
393
  super(...e), this._abortController = null, this._debounceTimer = null, this._contentEl = null, this._i18n = B, this._actionHandler = this._handleAction.bind(this), this._openChatHandler = this._handleOpenChat.bind(this);
393
394
  }
@@ -436,7 +437,7 @@ var at = class extends W {
436
437
  this._cleanupTextInputTimers(), this._contentEl.innerHTML = "";
437
438
  const t = this._createLoadingIndicator();
438
439
  this._contentEl.appendChild(t);
439
- const n = { middlewareUrl: this.config.middlewareUrl }, o = D({
440
+ const n = { middlewareUrl: this.config.middlewareUrl }, o = z({
440
441
  source: "qna",
441
442
  locale: this.config.locale
442
443
  });
@@ -451,7 +452,7 @@ var at = class extends W {
451
452
  this.config.session?.userId !== void 0 && (a.user_id = this.config.session.userId), this.config.session?.viewId !== void 0 && (a.view_id = this.config.session.viewId);
452
453
  const l = this.config.pageContext?.pageType;
453
454
  l !== void 0 && (a.page_type = l);
454
- const s = await z(a, n, this._abortController.signal);
455
+ const s = await $(a, n, this._abortController.signal);
455
456
  if (!this._contentEl) return;
456
457
  this._contentEl.innerHTML = "";
457
458
  const c = document.createElement("div");
@@ -473,7 +474,7 @@ var at = class extends W {
473
474
  i18n: this._i18n
474
475
  }, f = this._resolvedQnaHeaderTitle();
475
476
  f !== void 0 && (h.headingTitleOverride = f), this.config.hideButtonRowCta || (h.onOpenChat = this._openChatHandler, this.config.ctaText !== void 0 && (h.ctaText = this.config.ctaText)), g !== void 0 && (h.inputPlaceholder = g);
476
- const p = this._buildFallbackActionsSpec(s.actions), y = V(this.config.pageContext), b = (s.uiSpecs.length > 0 ? et(s.uiSpecs, this._i18n, { skuList: y }) : [p]).filter((d) => Object.keys(d.elements).length > 0);
477
+ const p = this._buildFallbackActionsSpec(s.actions), y = Y(this.config.pageContext), b = (s.uiSpecs.length > 0 ? nt(s.uiSpecs, this._i18n, { skuList: y }) : [p]).filter((d) => Object.keys(d.elements).length > 0);
477
478
  for (const d of b) {
478
479
  const _ = this._renderUISpec(d, h);
479
480
  c.appendChild(_);
@@ -511,7 +512,7 @@ var at = class extends W {
511
512
  }
512
513
  _resolveI18n(e) {
513
514
  return {
514
- ...it(e.locale),
515
+ ...at(e.locale),
515
516
  ...e.i18n
516
517
  };
517
518
  }
@@ -542,10 +543,10 @@ var at = class extends W {
542
543
  return s.children.length === 0 ? null : s;
543
544
  }
544
545
  _resolveUISpecRegistry() {
545
- return R(G(), this.config.renderer?.registry);
546
+ return R(J(), this.config.renderer?.registry);
546
547
  }
547
548
  _renderUISpec(e, t) {
548
- const n = this._resolveUISpecRegistry(), o = this.config.renderer?.unknownRenderer ?? S, i = (l, s) => J(l, s, n, o), a = this.config.renderer?.renderUISpec;
549
+ const n = this._resolveUISpecRegistry(), o = this.config.renderer?.unknownRenderer ?? S, i = (l, s) => V(l, s, n, o), a = this.config.renderer?.renderUISpec;
549
550
  return a ? a(e, t, {
550
551
  registry: n,
551
552
  unknownRenderer: o,
@@ -630,13 +631,13 @@ var at = class extends W {
630
631
  }, 600);
631
632
  }
632
633
  };
633
- function ut() {
634
- return new at();
634
+ function gt() {
635
+ return new st();
635
636
  }
636
637
  export {
637
- J as a,
638
+ V as a,
638
639
  S as i,
639
- ut as n,
640
- G as r,
641
- at as t
640
+ gt as n,
641
+ J as r,
642
+ st as t
642
643
  };
@@ -1,10 +1,11 @@
1
- import { a as x, d as L, h as j, i as q, p as F, r as I, t as N } from "./api-paths-Cth1szY1.js";
2
- import { A as z, E as S, N as D, a as k, l as H, v as $ } from "./context-BBuSsXZ9.js";
3
- import { o as W, t as J } from "./widget-base-C6H3cDSW.js";
4
- import { t as K } from "./locale-CfqNifrU.js";
5
- import { a as Q, n as V, r as Y, t as A } from "./price-formatter-xI3g9Cd4.js";
6
- import { n as X } from "./connection-warning-Bx1TJaU9.js";
7
- function R(e) {
1
+ import { a as j, d as L, h as F, i as q, p as z, r as I, t as N } from "./api-paths-kwROurUu.js";
2
+ import { A as D, E as S, N as H, a as k, l as $, v as W } from "./context-BBuSsXZ9.js";
3
+ import { o as J, t as K } from "./widget-base-TZjXRr3u.js";
4
+ import { t as Q } from "./locale-CfqNifrU.js";
5
+ import { t as R } from "./request-response-cache-zsgz3Awp.js";
6
+ import { a as V, n as Y, r as X, t as A } from "./price-formatter-CFsWT0lP.js";
7
+ import { n as Z } from "./connection-warning-Bg4gn-cq.js";
8
+ function M(e) {
8
9
  const t = [];
9
10
  for (const n of Object.values(e)) if (n.type === "ProductCard" && n.props) {
10
11
  const r = n.props.product ?? n.props;
@@ -12,36 +13,36 @@ function R(e) {
12
13
  }
13
14
  return t;
14
15
  }
15
- function M(e) {
16
+ function U(e) {
16
17
  const t = e.headers.get("Content-Type") ?? "";
17
18
  return t.includes("application/x-ndjson") || t.includes("text/event-stream");
18
19
  }
19
- async function Z(e, t) {
20
+ async function ee(e, t) {
20
21
  const n = [], r = { onEvent: (s) => {
21
22
  const i = I(s);
22
- !i || i.type !== "ui_spec" || n.push(...R(i.spec.elements));
23
+ !i || i.type !== "ui_spec" || n.push(...M(i.spec.elements));
23
24
  } };
24
25
  return t !== void 0 && (r.signal = t), await L(e, r), n;
25
26
  }
26
- async function ee(e, t, n) {
27
+ async function te(e, t, n) {
27
28
  const r = N("similar_products", t), s = {
28
29
  method: "POST",
29
30
  headers: { "Content-Type": "application/json" },
30
31
  body: JSON.stringify(e)
31
32
  };
32
33
  n !== void 0 && (s.signal = n);
33
- const i = await fetch(r, s);
34
+ const i = await R(r, s);
34
35
  if (!i.ok) throw new Error(`HTTP ${i.status}: ${i.statusText}`);
35
- if (M(i)) return Z(i, n);
36
+ if (U(i)) return ee(i, n);
36
37
  const a = await i.text();
37
38
  if (!a) throw new Error("Empty response body from similar_products endpoint");
38
39
  try {
39
- return x(JSON.parse(a));
40
+ return j(JSON.parse(a));
40
41
  } catch {
41
42
  throw new Error("Invalid JSON from similar_products endpoint");
42
43
  }
43
44
  }
44
- async function te(e, t) {
45
+ async function ne(e, t) {
45
46
  const n = [];
46
47
  let r = null;
47
48
  const s = { onEvent: (i) => {
@@ -58,21 +59,21 @@ async function te(e, t) {
58
59
  typeof m == "string" && (r.highlight = m), n.push(r);
59
60
  }
60
61
  }
61
- a.type === "ui_spec" && r && r.products.push(...R(a.spec.elements));
62
+ a.type === "ui_spec" && r && r.products.push(...M(a.spec.elements));
62
63
  }
63
64
  } };
64
65
  return t !== void 0 && (s.signal = t), await L(e, s), n;
65
66
  }
66
- async function ne(e, t, n) {
67
+ async function re(e, t, n) {
67
68
  const r = N("product_groupings", t), s = {
68
69
  method: "POST",
69
70
  headers: { "Content-Type": "application/json" },
70
71
  body: JSON.stringify(e)
71
72
  };
72
73
  n !== void 0 && (s.signal = n);
73
- const i = await fetch(r, s);
74
+ const i = await R(r, s);
74
75
  if (!i.ok) throw new Error(`HTTP ${i.status}: ${i.statusText}`);
75
- if (M(i)) return te(i, n);
76
+ if (U(i)) return ne(i, n);
76
77
  const a = await i.text();
77
78
  if (!a) return [];
78
79
  try {
@@ -81,7 +82,7 @@ async function ne(e, t, n) {
81
82
  throw new Error("Invalid JSON from product_groupings endpoint");
82
83
  }
83
84
  }
84
- function U(e) {
85
+ function G(e) {
85
86
  const { product: t, index: n, discountType: r, onClick: s, onAddToCart: i, renderCard: a } = e, d = e.i18n, m = e.pricing;
86
87
  if (e.renderCardElement) {
87
88
  const o = e.renderCardElement(t, n);
@@ -89,20 +90,20 @@ function U(e) {
89
90
  }
90
91
  if (a) {
91
92
  const o = document.createElement("div");
92
- return o.className = "gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive", o.dataset.gengagePart = "simrel-product-card", o.innerHTML = D(a(t, n)), o.addEventListener("click", (c) => {
93
+ return o.className = "gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive", o.dataset.gengagePart = "simrel-product-card", o.innerHTML = H(a(t, n)), o.addEventListener("click", (c) => {
93
94
  c.target.closest(".gengage-simrel-atc") || c.target.closest(".gengage-chat-product-card-atc") || s(t);
94
95
  }), o;
95
96
  }
96
97
  const l = document.createElement("article");
97
98
  l.className = "gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive", l.dataset.gengagePart = "simrel-product-card", t.inStock === !1 && l.classList.add("gengage-simrel-card--out-of-stock"), l.setAttribute("role", "listitem"), l.dataset.sku = t.sku;
98
99
  const g = document.createElement("div");
99
- if (g.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", g.dataset.gengagePart = "simrel-product-card-image", t.imageUrl && z(t.imageUrl)) {
100
+ if (g.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", g.dataset.gengagePart = "simrel-product-card-image", t.imageUrl && D(t.imageUrl)) {
100
101
  const o = document.createElement("img");
101
- o.className = "gengage-chat-product-card-img", o.src = t.imageUrl, o.alt = t.name, o.loading = "lazy", V(o), g.appendChild(o);
102
+ o.className = "gengage-chat-product-card-img", o.src = t.imageUrl, o.alt = t.name, o.loading = "lazy", Y(o), g.appendChild(o);
102
103
  }
103
104
  if (r === "badge" && t.discountPercent && t.discountPercent > 0) {
104
105
  const o = document.createElement("span");
105
- o.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", o.textContent = `%${Y(t.discountPercent)}`, g.appendChild(o);
106
+ o.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", o.textContent = `%${X(t.discountPercent)}`, g.appendChild(o);
106
107
  }
107
108
  l.appendChild(g);
108
109
  const u = document.createElement("div");
@@ -113,7 +114,7 @@ function U(e) {
113
114
  const h = document.createElement("div");
114
115
  if (h.className = "gengage-simrel-card-name gengage-chat-product-card-name", h.textContent = t.name, h.title = t.name, u.appendChild(h), t.rating != null && t.rating > 0) {
115
116
  const o = document.createElement("div");
116
- if (o.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", o.appendChild(Q(t.rating)), t.reviewCount != null) {
117
+ if (o.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", o.appendChild(V(t.rating)), t.reviewCount != null) {
117
118
  const c = document.createElement("span");
118
119
  c.className = "gengage-simrel-card-review-count gengage-chat-product-card-review-count", c.textContent = ` (${t.reviewCount})`, o.appendChild(c);
119
120
  }
@@ -160,14 +161,14 @@ function w(e) {
160
161
  onAddToCart: e.onAddToCart
161
162
  };
162
163
  e.i18n !== void 0 && (r.i18n = e.i18n), e.discountType !== void 0 && (r.discountType = e.discountType), e.renderCard !== void 0 && (r.renderCard = e.renderCard), e.renderCardElement !== void 0 && (r.renderCardElement = e.renderCardElement);
163
- const s = U(r);
164
+ const s = G(r);
164
165
  t.appendChild(s);
165
166
  }
166
167
  return e.products.length === 0 && (t.style.display = "none", t.dataset.empty = "true"), t;
167
168
  }
168
- var re = 0;
169
- function ie(e) {
170
- const t = re++, n = document.createElement("div");
169
+ var ie = 0;
170
+ function se(e) {
171
+ const t = ie++, n = document.createElement("div");
171
172
  if (n.className = "gengage-simrel-groups", n.dataset.gengagePart = "simrel-groups", e.groups.length === 0)
172
173
  return n.style.display = "none", n.dataset.empty = "true", n;
173
174
  const r = document.createElement("div");
@@ -269,7 +270,7 @@ function P(e) {
269
270
  const h = t.extras;
270
271
  return h != null && typeof h == "object" && (n.extras = h), n;
271
272
  }
272
- function se(e) {
273
+ function oe(e) {
273
274
  if (!e || typeof e != "object") return null;
274
275
  const t = e, n = t.title, r = t.type;
275
276
  if (typeof n != "string" || typeof r != "string") return null;
@@ -279,7 +280,7 @@ function se(e) {
279
280
  };
280
281
  return t.payload !== void 0 && (s.payload = t.payload), s;
281
282
  }
282
- var G = {
283
+ var O = {
283
284
  ProductGrid: ({ element: e, renderElement: t, context: n }) => {
284
285
  const r = document.createElement("div");
285
286
  r.className = "gengage-simrel-grid", r.setAttribute("role", "list");
@@ -306,7 +307,7 @@ var G = {
306
307
  onAddToCart: t.onAddToCart,
307
308
  i18n: t.i18n
308
309
  };
309
- return a !== void 0 && (d.discountType = a), t.renderCard !== void 0 && (d.renderCard = t.renderCard), t.renderCardElement !== void 0 && (d.renderCardElement = t.renderCardElement), t.pricing !== void 0 && (d.pricing = t.pricing), U(d);
310
+ return a !== void 0 && (d.discountType = a), t.renderCard !== void 0 && (d.renderCard = t.renderCard), t.renderCardElement !== void 0 && (d.renderCardElement = t.renderCardElement), t.pricing !== void 0 && (d.pricing = t.pricing), G(d);
310
311
  },
311
312
  GroupTabs: ({ element: e, context: t }) => {
312
313
  const n = e.props?.groups;
@@ -333,7 +334,7 @@ var G = {
333
334
  onAddToCart: t.onAddToCart,
334
335
  i18n: t.i18n
335
336
  }, i = e.props?.columns;
336
- return typeof i == "number" && Number.isFinite(i) && i > 0 ? s.columns = Math.floor(i) : typeof t.gridColumns == "number" && Number.isFinite(t.gridColumns) && t.gridColumns > 0 && (s.columns = Math.floor(t.gridColumns)), t.discountType !== void 0 && (s.discountType = t.discountType), t.renderCard !== void 0 && (s.renderCard = t.renderCard), t.renderCardElement !== void 0 && (s.renderCardElement = t.renderCardElement), t.onGroupingActivate !== void 0 && (s.onGroupingActivate = t.onGroupingActivate), ie(s);
337
+ return typeof i == "number" && Number.isFinite(i) && i > 0 ? s.columns = Math.floor(i) : typeof t.gridColumns == "number" && Number.isFinite(t.gridColumns) && t.gridColumns > 0 && (s.columns = Math.floor(t.gridColumns)), t.discountType !== void 0 && (s.discountType = t.discountType), t.renderCard !== void 0 && (s.renderCard = t.renderCard), t.renderCardElement !== void 0 && (s.renderCardElement = t.renderCardElement), t.onGroupingActivate !== void 0 && (s.onGroupingActivate = t.onGroupingActivate), se(s);
337
338
  },
338
339
  EmptyState: ({ element: e, context: t }) => {
339
340
  const n = document.createElement("div");
@@ -362,7 +363,7 @@ var G = {
362
363
  if (!Array.isArray(r) || !t.onAction) return n;
363
364
  for (const s of r) {
364
365
  if (!s || typeof s != "object") continue;
365
- const i = s, a = i.label, d = se(i.action);
366
+ const i = s, a = i.label, d = oe(i.action);
366
367
  if (typeof a != "string" || !d) continue;
367
368
  const m = document.createElement("button");
368
369
  m.className = "gengage-simrel-quick-action", m.type = "button", m.textContent = a, m.addEventListener("click", (l) => {
@@ -371,7 +372,7 @@ var G = {
371
372
  }
372
373
  return n;
373
374
  }
374
- }, O = ({ element: e, renderElement: t }) => {
375
+ }, B = ({ element: e, renderElement: t }) => {
375
376
  if (!e.children || e.children.length === 0) return null;
376
377
  const n = document.createElement("div");
377
378
  for (const r of e.children) {
@@ -380,11 +381,11 @@ var G = {
380
381
  }
381
382
  return n;
382
383
  };
383
- function oe() {
384
- return { ...G };
384
+ function ae() {
385
+ return { ...O };
385
386
  }
386
- function ae(e, t, n = G, r = O) {
387
- return j({
387
+ function ce(e, t, n = O, r = B) {
388
+ return F({
388
389
  spec: e,
389
390
  context: t,
390
391
  registry: n,
@@ -392,7 +393,7 @@ function ae(e, t, n = G, r = O) {
392
393
  unknownRenderer: r
393
394
  });
394
395
  }
395
- var B = {
396
+ var x = {
396
397
  similarProductsAriaLabel: "Benzer ürünler",
397
398
  emptyStateMessage: "Benzer ürün bulunamadı.",
398
399
  addToCartButton: "Sepete Ekle",
@@ -405,7 +406,7 @@ var B = {
405
406
  priceSuffix: " TL",
406
407
  scrollTabsLeft: "Sola kaydır",
407
408
  scrollTabsRight: "Sağa kaydır"
408
- }, ce = {
409
+ }, de = {
409
410
  similarProductsAriaLabel: "Similar products",
410
411
  emptyStateMessage: "No similar products found.",
411
412
  addToCartButton: "Add to cart",
@@ -419,28 +420,28 @@ var B = {
419
420
  scrollTabsLeft: "Scroll tabs left",
420
421
  scrollTabsRight: "Scroll tabs right"
421
422
  };
422
- function de(e) {
423
+ function le(e) {
423
424
  return e ? e.toLowerCase().split("-")[0] ?? "tr" : "tr";
424
425
  }
425
- function le(e) {
426
- return de(e) === "en" ? ce : B;
426
+ function ge(e) {
427
+ return le(e) === "en" ? de : x;
427
428
  }
428
- var ge = 12e4;
429
- function ue(e) {
429
+ var ue = 12e4;
430
+ function pe(e) {
430
431
  return e instanceof DOMException && e.name === "AbortError";
431
432
  }
432
- var pe = class extends J {
433
+ var me = class extends K {
433
434
  constructor(...e) {
434
- super(...e), this._abortController = null, this._contentEl = null, this._lastResultCount = -1, this._i18n = B, this._pendingAddToCartKeys = /* @__PURE__ */ new Set();
435
+ super(...e), this._abortController = null, this._contentEl = null, this._lastResultCount = -1, this._i18n = x, this._pendingAddToCartKeys = /* @__PURE__ */ new Set();
435
436
  }
436
437
  async init(e) {
437
438
  if (!this.isInitialised && (e.mountTarget === void 0 || e.mountTarget === null)) throw new Error("[gengage] SimRel mountTarget is required. Provide a merchant-owned mount before initializing.");
438
439
  await super.init(e);
439
440
  }
440
441
  async onInit(e) {
441
- this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this._contentEl.dataset.gengagePart = "simrel-container", this._contentEl.lang = K(e.locale);
442
+ this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this._contentEl.dataset.gengagePart = "simrel-container", this._contentEl.lang = Q(e.locale);
442
443
  const t = this._clampGridColumns(e.gridColumns);
443
- t !== void 0 && this._contentEl.style.setProperty("--gengage-simrel-columns", String(t)), this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), $("simrel");
444
+ t !== void 0 && this._contentEl.style.setProperty("--gengage-simrel-columns", String(t)), this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), W("simrel");
444
445
  }
445
446
  onUpdate(e) {
446
447
  const t = e.sku;
@@ -483,7 +484,7 @@ var pe = class extends J {
483
484
  console.error("[gengage] simrel onAddToCart", n);
484
485
  return;
485
486
  }
486
- H(e.sku, e.quantity), k("gengage:similar:add-to-cart", e);
487
+ $(e.sku, e.quantity), k("gengage:similar:add-to-cart", e);
487
488
  } finally {
488
489
  this._pendingAddToCartKeys.delete(t);
489
490
  }
@@ -506,7 +507,7 @@ var pe = class extends J {
506
507
  }
507
508
  _resolveRequestTimeoutMs() {
508
509
  const e = this.config.requestTimeoutMs;
509
- return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? ge : Math.floor(e);
510
+ return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? ue : Math.floor(e);
510
511
  }
511
512
  async _fetchAndRender(e) {
512
513
  this._abort();
@@ -523,7 +524,7 @@ var pe = class extends J {
523
524
  i.className = "gengage-simrel-loading", i.dataset.gengagePart = "simrel-loading";
524
525
  const a = document.createElement("div");
525
526
  a.className = "gengage-simrel-spinner", a.dataset.gengagePart = "simrel-loading-spinner", i.appendChild(a), this._contentEl.appendChild(i);
526
- const d = { middlewareUrl: this.config.middlewareUrl }, m = X({
527
+ const d = { middlewareUrl: this.config.middlewareUrl }, m = Z({
527
528
  source: "simrel",
528
529
  locale: this.config.locale
529
530
  });
@@ -535,10 +536,10 @@ var pe = class extends J {
535
536
  sku: e
536
537
  };
537
538
  this.config.domain !== void 0 && (l.domain = this.config.domain);
538
- const g = await ee(l, d, n);
539
+ const g = await te(l, d, n);
539
540
  if (this._lastResultCount = g.length, !this._contentEl) return;
540
541
  if (this._contentEl.innerHTML = "", g.length > 0 && this.config.enableProductGroupings !== !1) try {
541
- const u = g.map((f) => f.sku), h = new Map(g.map((f) => [f.sku, f])), y = (await ne({
542
+ const u = g.map((f) => f.sku), h = new Map(g.map((f) => [f.sku, f])), y = (await re({
542
543
  account_id: this.config.accountId,
543
544
  session_id: this.config.session?.sessionId ?? "",
544
545
  correlation_id: this.config.session?.sessionId ?? "",
@@ -564,12 +565,12 @@ var pe = class extends J {
564
565
  }
565
566
  g.length > 0 && S("simrel"), this._emitSimilarProductsImpression(g.length, !1);
566
567
  } catch (l) {
567
- const g = ue(l);
568
+ const g = pe(l);
568
569
  if (g && this._isSuperseded(n)) return;
569
570
  if (k("gengage:global:error", {
570
571
  source: "simrel",
571
572
  code: g && r ? "REQUEST_TIMEOUT" : "FETCH_ERROR",
572
- message: W(this.config.locale, l)
573
+ message: J(this.config.locale, l)
573
574
  }), this._contentEl) {
574
575
  this._contentEl.innerHTML = "";
575
576
  const u = document.createElement("div");
@@ -591,12 +592,12 @@ var pe = class extends J {
591
592
  }
592
593
  _resolveI18n(e) {
593
594
  return {
594
- ...le(e.locale),
595
+ ...ge(e.locale),
595
596
  ...e.i18n
596
597
  };
597
598
  }
598
599
  _resolveUISpecRegistry() {
599
- return F(oe(), this.config.renderer?.registry);
600
+ return z(ae(), this.config.renderer?.registry);
600
601
  }
601
602
  _buildRenderContext() {
602
603
  const e = this.config.renderCard, t = {
@@ -618,7 +619,7 @@ var pe = class extends J {
618
619
  return n !== void 0 && (t.gridColumns = n), t;
619
620
  }
620
621
  _renderUISpec(e) {
621
- const t = this._resolveUISpecRegistry(), n = this._buildRenderContext(), r = this.config.renderer?.unknownRenderer ?? O, s = (a, d) => ae(a, d, t, r), i = this.config.renderer?.renderUISpec;
622
+ const t = this._resolveUISpecRegistry(), n = this._buildRenderContext(), r = this.config.renderer?.unknownRenderer ?? B, s = (a, d) => ce(a, d, t, r), i = this.config.renderer?.renderUISpec;
622
623
  return i ? i(e, n, {
623
624
  registry: t,
624
625
  unknownRenderer: r,
@@ -658,14 +659,14 @@ var pe = class extends J {
658
659
  };
659
660
  }
660
661
  };
661
- function ve() {
662
- return new pe();
662
+ function _e() {
663
+ return new me();
663
664
  }
664
665
  export {
665
- ae as a,
666
- O as i,
667
- ve as n,
668
- ie as o,
669
- oe as r,
670
- pe as t
666
+ ce as a,
667
+ B as i,
668
+ _e as n,
669
+ se as o,
670
+ ae as r,
671
+ me as t
671
672
  };
@@ -1,5 +1,5 @@
1
1
  import { A as m, D as h, _ as u, j as f, v as p } from "./context-BBuSsXZ9.js";
2
- import { t as b } from "./widget-base-C6H3cDSW.js";
2
+ import { t as b } from "./widget-base-TZjXRr3u.js";
3
3
  import { t as y } from "./locale-CfqNifrU.js";
4
4
  var g = { findSimilarLabel: "Benzerlerini Bul" }, _ = { findSimilarLabel: "Find Similar" };
5
5
  function S(t, n) {
@@ -44,4 +44,4 @@
44
44
  transform: translateY(0);
45
45
  }
46
46
  }
47
- `,document.head.appendChild(e)}var f=null;function Y(){if(f!==null)return f;try{f=localStorage.getItem("gengage:debug")==="1"}catch{f=!1}return f}function S(e,t,i){if(!Y())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var j=("0.6.12".trim(),"0.6.12".trim()),J=("iife-build".trim(),"iife-build".trim());function K(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${j} (${J})`))}var Q=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=U(e.theme);K(),this.config={...e,theme:t,session:N(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),O();const i=x("gengage:context:update",n=>this.update(n));this._cleanups.push(i),S("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,S("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}emit(e,...t){this._handlers.get(e)?.forEach(i=>i(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const i=document.querySelector(e);if(!i)throw new Error(`[gengage] Mount target not found: "${e}"`);return i}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,i]of Object.entries(e))if(i!==void 0){const n=t.startsWith("--")?t:`--gengage-${X(t)}`;this.root.style.setProperty(n,i)}}}};function X(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Z(e){const t=e?.trim();return t||"tr"}var C={findSimilarLabel:"Benzerlerini Bul"},ee={findSimilarLabel:"Find Similar"};function te(e,t){return t?.findSimilarLabel?t.findSimilarLabel:(e??"tr").toLowerCase().startsWith("en")?ee.findSimilarLabel:C.findSimilarLabel}function h(e){const t=typeof e.sku=="string"&&e.sku.length>0?e.sku:void 0,i=typeof e.pageContext?.sku=="string"&&e.pageContext.sku.length>0?e.pageContext.sku:void 0;return t??i}var E=class extends Q{constructor(...e){super(...e),this._button=null,this._inlineFrame=null,this._label=C.findSimilarLabel}async onInit(e){this._label=te(e.locale,e.i18n);const t=e.layout??"overlay";this.root.classList.add("gengage-simbut-root"),this.root.classList.toggle("gengage-simbut-root--overlay",t==="overlay"),this.root.classList.toggle("gengage-simbut-root--inline-card",t==="inline-card"),t==="overlay"&&window.getComputedStyle(this.root).position==="static"&&(this.root.style.position="relative");const i=document.createElement("button");i.type="button",i.className="gengage-chat-find-similar-pill",i.lang=Z(e.locale),i.textContent=this._label,this._button=i;const n=()=>{i.disabled=!(h(this.config)&&(this.config.onFindSimilar||this.config.chat))};if(i.addEventListener("click",r=>{r.stopPropagation();const s=h(this.config);if(!s)return;const o=this.config.imageUrl,g=typeof o=="string"&&L(o)?o:void 0;if(F(this._label,"findSimilar"),R(s),this.config.onFindSimilar){this.config.onFindSimilar(g?{sku:s,imageUrl:g}:{sku:s});return}const u=this.config.chat;if(!u)return;const a={title:this._label,type:"findSimilar",payload:{sku:s}};u.openWithAction(a,{sku:s})}),t==="inline-card"){const r=this._createInlineCard(e,i);this._inlineFrame=r,this.root.appendChild(r)}else this.root.appendChild(i);n(),k("simbut")}_createInlineCard(e,t){const i=e.inlineCard,n=typeof i?.title=="string"?i.title.trim():"",r=typeof i?.description=="string"?i.description.trim():"",s=typeof i?.imageUrl=="string"?i.imageUrl.trim():"",o=document.createElement("section");o.className="gengage-simbut-inline-card",o.dataset.gengagePart="simbut-inline-card";const g=document.createElement("div");if(g.className="gengage-simbut-inline-copy",g.dataset.gengagePart="simbut-inline-copy",n){const a=document.createElement("h4");a.className="gengage-simbut-inline-title",a.dataset.gengagePart="simbut-inline-title",a.textContent=n,g.appendChild(a)}if(r){const a=document.createElement("p");a.className="gengage-simbut-inline-description",a.dataset.gengagePart="simbut-inline-description",a.textContent=r,g.appendChild(a)}g.children.length>0&&o.appendChild(g);const u=document.createElement("div");if(u.className="gengage-simbut-inline-action",u.dataset.gengagePart="simbut-inline-action",u.appendChild(t),o.appendChild(u),s&&I(s)){const a=document.createElement("img");a.className="gengage-simbut-inline-image",a.dataset.gengagePart="simbut-inline-image",a.src=s,a.alt=typeof i?.imageAlt=="string"?i.imageAlt:"",a.loading="lazy",a.addEventListener("error",()=>{a.style.display="none"},{once:!0}),o.appendChild(a)}return o}onUpdate(e){if(!this._button)return;const t=!!h(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}hide(){this.isVisible&&(this.isVisible=!1,this._inlineFrame&&(this._inlineFrame.style.display="none"),this._button&&(this._button.style.display="none"),this.onHide(),this.emit("hide"))}show(){this.isVisible||(this.isVisible=!0,this._inlineFrame&&(this._inlineFrame.style.display=""),this._button&&(this._button.style.display=""),this.onShow(),this.emit("show"))}_cleanupRoot(){}onShow(){}onHide(){}onDestroy(){this._inlineFrame?.remove(),this._inlineFrame=null,this._button?.remove(),this._button=null}setChat(e){if(this.config.chat=e,this._button){const t=!!h(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}}};function ie(){return new E}m.GengageSimBut=E,m.createSimButWidget=ie})(this.Gengage=this.Gengage||{});
47
+ `,document.head.appendChild(e)}var f=null;function Y(){if(f!==null)return f;try{f=localStorage.getItem("gengage:debug")==="1"}catch{f=!1}return f}function S(e,t,i){if(!Y())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var j=("0.6.14".trim(),"0.6.14".trim()),J=("iife-build".trim(),"iife-build".trim());function K(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${j} (${J})`))}var Q=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=U(e.theme);K(),this.config={...e,theme:t,session:N(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),O();const i=x("gengage:context:update",n=>this.update(n));this._cleanups.push(i),S("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,S("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}emit(e,...t){this._handlers.get(e)?.forEach(i=>i(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const i=document.querySelector(e);if(!i)throw new Error(`[gengage] Mount target not found: "${e}"`);return i}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,i]of Object.entries(e))if(i!==void 0){const n=t.startsWith("--")?t:`--gengage-${X(t)}`;this.root.style.setProperty(n,i)}}}};function X(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Z(e){const t=e?.trim();return t||"tr"}var C={findSimilarLabel:"Benzerlerini Bul"},ee={findSimilarLabel:"Find Similar"};function te(e,t){return t?.findSimilarLabel?t.findSimilarLabel:(e??"tr").toLowerCase().startsWith("en")?ee.findSimilarLabel:C.findSimilarLabel}function h(e){const t=typeof e.sku=="string"&&e.sku.length>0?e.sku:void 0,i=typeof e.pageContext?.sku=="string"&&e.pageContext.sku.length>0?e.pageContext.sku:void 0;return t??i}var E=class extends Q{constructor(...e){super(...e),this._button=null,this._inlineFrame=null,this._label=C.findSimilarLabel}async onInit(e){this._label=te(e.locale,e.i18n);const t=e.layout??"overlay";this.root.classList.add("gengage-simbut-root"),this.root.classList.toggle("gengage-simbut-root--overlay",t==="overlay"),this.root.classList.toggle("gengage-simbut-root--inline-card",t==="inline-card"),t==="overlay"&&window.getComputedStyle(this.root).position==="static"&&(this.root.style.position="relative");const i=document.createElement("button");i.type="button",i.className="gengage-chat-find-similar-pill",i.lang=Z(e.locale),i.textContent=this._label,this._button=i;const n=()=>{i.disabled=!(h(this.config)&&(this.config.onFindSimilar||this.config.chat))};if(i.addEventListener("click",r=>{r.stopPropagation();const s=h(this.config);if(!s)return;const o=this.config.imageUrl,g=typeof o=="string"&&L(o)?o:void 0;if(F(this._label,"findSimilar"),R(s),this.config.onFindSimilar){this.config.onFindSimilar(g?{sku:s,imageUrl:g}:{sku:s});return}const u=this.config.chat;if(!u)return;const a={title:this._label,type:"findSimilar",payload:{sku:s}};u.openWithAction(a,{sku:s})}),t==="inline-card"){const r=this._createInlineCard(e,i);this._inlineFrame=r,this.root.appendChild(r)}else this.root.appendChild(i);n(),k("simbut")}_createInlineCard(e,t){const i=e.inlineCard,n=typeof i?.title=="string"?i.title.trim():"",r=typeof i?.description=="string"?i.description.trim():"",s=typeof i?.imageUrl=="string"?i.imageUrl.trim():"",o=document.createElement("section");o.className="gengage-simbut-inline-card",o.dataset.gengagePart="simbut-inline-card";const g=document.createElement("div");if(g.className="gengage-simbut-inline-copy",g.dataset.gengagePart="simbut-inline-copy",n){const a=document.createElement("h4");a.className="gengage-simbut-inline-title",a.dataset.gengagePart="simbut-inline-title",a.textContent=n,g.appendChild(a)}if(r){const a=document.createElement("p");a.className="gengage-simbut-inline-description",a.dataset.gengagePart="simbut-inline-description",a.textContent=r,g.appendChild(a)}g.children.length>0&&o.appendChild(g);const u=document.createElement("div");if(u.className="gengage-simbut-inline-action",u.dataset.gengagePart="simbut-inline-action",u.appendChild(t),o.appendChild(u),s&&I(s)){const a=document.createElement("img");a.className="gengage-simbut-inline-image",a.dataset.gengagePart="simbut-inline-image",a.src=s,a.alt=typeof i?.imageAlt=="string"?i.imageAlt:"",a.loading="lazy",a.addEventListener("error",()=>{a.style.display="none"},{once:!0}),o.appendChild(a)}return o}onUpdate(e){if(!this._button)return;const t=!!h(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}hide(){this.isVisible&&(this.isVisible=!1,this._inlineFrame&&(this._inlineFrame.style.display="none"),this._button&&(this._button.style.display="none"),this.onHide(),this.emit("hide"))}show(){this.isVisible||(this.isVisible=!0,this._inlineFrame&&(this._inlineFrame.style.display=""),this._button&&(this._button.style.display=""),this.onShow(),this.emit("show"))}_cleanupRoot(){}onShow(){}onHide(){}onDestroy(){this._inlineFrame?.remove(),this._inlineFrame=null,this._button?.remove(),this._button=null}setChat(e){if(this.config.chat=e,this._button){const t=!!h(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}}};function ie(){return new E}m.GengageSimBut=E,m.createSimButWidget=ie})(this.Gengage=this.Gengage||{});
package/dist/simbut.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as e, t as a } from "./simbut-pTonQlCT.js";
1
+ import { n as e, t as a } from "./simbut-Bm96zEAo.js";
2
2
  export {
3
3
  a as GengageSimBut,
4
4
  e as createSimButWidget