@gengage/assistant-fe 0.1.8 → 0.2.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 (138) hide show
  1. package/README.md +79 -286
  2. package/dist/assistant-fe.css +1 -1
  3. package/dist/chat/api.d.ts +1 -12
  4. package/dist/chat/api.d.ts.map +1 -1
  5. package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
  6. package/dist/chat/components/ChatDrawer.d.ts +15 -1
  7. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  8. package/dist/chat/components/ChoicePrompter.d.ts +1 -0
  9. package/dist/chat/components/ChoicePrompter.d.ts.map +1 -1
  10. package/dist/chat/components/ComparisonTable.d.ts +5 -3
  11. package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
  12. package/dist/chat/components/PanelTopBar.d.ts +2 -0
  13. package/dist/chat/components/PanelTopBar.d.ts.map +1 -1
  14. package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -1
  15. package/dist/chat/components/ReviewHighlights.d.ts +3 -0
  16. package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
  17. package/dist/chat/components/renderUISpec.d.ts +0 -5
  18. package/dist/chat/components/renderUISpec.d.ts.map +1 -1
  19. package/dist/chat/index.d.ts +18 -9
  20. package/dist/chat/index.d.ts.map +1 -1
  21. package/dist/chat/locales/en.d.ts.map +1 -1
  22. package/dist/chat/locales/tr.d.ts.map +1 -1
  23. package/dist/chat/session-persistence.d.ts +3 -0
  24. package/dist/chat/session-persistence.d.ts.map +1 -1
  25. package/dist/chat/types.d.ts +23 -25
  26. package/dist/chat/types.d.ts.map +1 -1
  27. package/dist/chat.cjs +1 -1
  28. package/dist/chat.iife.js +22 -22
  29. package/dist/chat.iife.js.map +1 -1
  30. package/dist/chat.js +8 -9
  31. package/dist/chat.js.map +1 -1
  32. package/dist/common/action-router.d.ts.map +1 -1
  33. package/dist/common/activity-tracker.d.ts +1 -1
  34. package/dist/common/analytics.d.ts +12 -8
  35. package/dist/common/analytics.d.ts.map +1 -1
  36. package/dist/common/api-paths.d.ts +2 -5
  37. package/dist/common/api-paths.d.ts.map +1 -1
  38. package/dist/common/config-schema.d.ts.map +1 -1
  39. package/dist/common/debug.d.ts +14 -0
  40. package/dist/common/debug.d.ts.map +1 -0
  41. package/dist/common/events.d.ts.map +1 -1
  42. package/dist/common/index.d.ts +2 -2
  43. package/dist/common/index.d.ts.map +1 -1
  44. package/dist/common/native-webview.d.ts.map +1 -1
  45. package/dist/common/overlay.d.ts +19 -0
  46. package/dist/common/overlay.d.ts.map +1 -1
  47. package/dist/common/product-utils.d.ts +10 -0
  48. package/dist/common/product-utils.d.ts.map +1 -1
  49. package/dist/common/{v1-protocol-adapter.d.ts → protocol-adapter.d.ts} +2 -2
  50. package/dist/common/protocol-adapter.d.ts.map +1 -0
  51. package/dist/common/quantity-stepper.d.ts +10 -10
  52. package/dist/common/quantity-stepper.d.ts.map +1 -1
  53. package/dist/common/safe-html.d.ts.map +1 -1
  54. package/dist/common/streaming.d.ts.map +1 -1
  55. package/dist/common/tts-player.d.ts +2 -0
  56. package/dist/common/tts-player.d.ts.map +1 -1
  57. package/dist/common/types.d.ts +1 -1
  58. package/dist/common/voice-input.d.ts +1 -0
  59. package/dist/common/voice-input.d.ts.map +1 -1
  60. package/dist/common/widget-base.d.ts.map +1 -1
  61. package/dist/common.cjs +1 -1
  62. package/dist/common.cjs.map +1 -1
  63. package/dist/common.js +173 -172
  64. package/dist/common.js.map +1 -1
  65. package/dist/index-BA7N_XOO.cjs +2 -0
  66. package/dist/index-BA7N_XOO.cjs.map +1 -0
  67. package/dist/{index-CcOJTzYu.js → index-C6KDzSjm.js} +155 -159
  68. package/dist/index-C6KDzSjm.js.map +1 -0
  69. package/dist/index-RmQRBt6w.js +4449 -0
  70. package/dist/index-RmQRBt6w.js.map +1 -0
  71. package/dist/index-VgLdYuZV.cjs +13 -0
  72. package/dist/index-VgLdYuZV.cjs.map +1 -0
  73. package/dist/index.cjs +1 -1
  74. package/dist/index.js +16 -16
  75. package/dist/native.cjs +1 -1
  76. package/dist/native.iife.js +23 -23
  77. package/dist/native.iife.js.map +1 -1
  78. package/dist/native.js +1 -1
  79. package/dist/qna/index.d.ts +19 -0
  80. package/dist/qna/index.d.ts.map +1 -1
  81. package/dist/qna/types.d.ts +2 -2
  82. package/dist/qna/types.d.ts.map +1 -1
  83. package/dist/qna.cjs +1 -1
  84. package/dist/qna.cjs.map +1 -1
  85. package/dist/qna.css +1 -1
  86. package/dist/qna.iife.js +7 -7
  87. package/dist/qna.iife.js.map +1 -1
  88. package/dist/qna.js +14 -14
  89. package/dist/qna.js.map +1 -1
  90. package/dist/quantity-stepper-BKtPQUR1.js +78 -0
  91. package/dist/quantity-stepper-BKtPQUR1.js.map +1 -0
  92. package/dist/quantity-stepper-DU6va4sS.cjs +2 -0
  93. package/dist/quantity-stepper-DU6va4sS.cjs.map +1 -0
  94. package/dist/{schemas-yF4IOEUi.js → schemas-BAEbjFPE.js} +1181 -957
  95. package/dist/schemas-BAEbjFPE.js.map +1 -0
  96. package/dist/schemas-DIyHm5pa.cjs +86 -0
  97. package/dist/schemas-DIyHm5pa.cjs.map +1 -0
  98. package/dist/simrel/api.d.ts +1 -1
  99. package/dist/simrel/api.d.ts.map +1 -1
  100. package/dist/simrel/components/GroupTabs.d.ts +1 -1
  101. package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
  102. package/dist/simrel/components/ProductCard.d.ts +1 -1
  103. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  104. package/dist/simrel/components/ProductGrid.d.ts +1 -1
  105. package/dist/simrel/components/ProductGrid.d.ts.map +1 -1
  106. package/dist/simrel/index.d.ts +20 -1
  107. package/dist/simrel/index.d.ts.map +1 -1
  108. package/dist/simrel/locales/en.d.ts.map +1 -1
  109. package/dist/simrel/locales/tr.d.ts.map +1 -1
  110. package/dist/simrel/types.d.ts +2 -0
  111. package/dist/simrel/types.d.ts.map +1 -1
  112. package/dist/simrel.cjs +1 -1
  113. package/dist/simrel.cjs.map +1 -1
  114. package/dist/simrel.css +1 -1
  115. package/dist/simrel.iife.js +11 -11
  116. package/dist/simrel.iife.js.map +1 -1
  117. package/dist/simrel.js +281 -267
  118. package/dist/simrel.js.map +1 -1
  119. package/package.json +1 -1
  120. package/dist/chat/components/ProactivePopup.d.ts +0 -20
  121. package/dist/chat/components/ProactivePopup.d.ts.map +0 -1
  122. package/dist/chat/heartbeat.d.ts +0 -71
  123. package/dist/chat/heartbeat.d.ts.map +0 -1
  124. package/dist/common/v1-protocol-adapter.d.ts.map +0 -1
  125. package/dist/index-BqIzV4ni.cjs +0 -2
  126. package/dist/index-BqIzV4ni.cjs.map +0 -1
  127. package/dist/index-CcOJTzYu.js.map +0 -1
  128. package/dist/index-DZ3Mi5xF.cjs +0 -13
  129. package/dist/index-DZ3Mi5xF.cjs.map +0 -1
  130. package/dist/index-FnP8WtfG.js +0 -4571
  131. package/dist/index-FnP8WtfG.js.map +0 -1
  132. package/dist/quantity-stepper-B8kX8GbN.js +0 -209
  133. package/dist/quantity-stepper-B8kX8GbN.js.map +0 -1
  134. package/dist/quantity-stepper-UbAp53Ow.cjs +0 -2
  135. package/dist/quantity-stepper-UbAp53Ow.cjs.map +0 -1
  136. package/dist/schemas-DHzfUzwA.cjs +0 -86
  137. package/dist/schemas-DHzfUzwA.cjs.map +0 -1
  138. package/dist/schemas-yF4IOEUi.js.map +0 -1
package/dist/simrel.js CHANGED
@@ -1,151 +1,151 @@
1
- import { b as A, p as D, q as j, c as I, a as R, r as M, o as b, s as h, f as q, e as B, _ as N, v, B as H, t as z, x as $, j as _, y as F, z as J, g as Q, i as E, h as k, w as S, k as W, l as V, m as Y } from "./schemas-yF4IOEUi.js";
2
- import { s as K, i as X, a as Z, c as ee, r as te, f as T, b as ne } from "./quantity-stepper-B8kX8GbN.js";
3
- function x(n) {
1
+ import { b as P, p as j, q as M, c as N, a as x, v as B, x as q, r as z, o as b, s as f, f as H, e as $, _ as I, y as v, B as F, t as J, z as W, j as E, A as Q, C as V, g as Y, i as k, h as _, w as S, k as K, l as X, m as Z } from "./schemas-BAEbjFPE.js";
2
+ import { a as ee, c as te, b as ne, f as T, d as re } from "./quantity-stepper-BKtPQUR1.js";
3
+ function R(n) {
4
+ const e = [];
5
+ for (const t of Object.values(n))
6
+ if (t.type === "ProductCard" && t.props) {
7
+ const r = t.props.product ?? t.props;
8
+ typeof r.sku == "string" && typeof r.name == "string" && e.push(r);
9
+ }
10
+ return e;
11
+ }
12
+ function L(n) {
4
13
  const e = n.headers.get("Content-Type") ?? "";
5
14
  return e.includes("application/x-ndjson") || e.includes("text/event-stream");
6
15
  }
7
- async function re(n, e) {
16
+ async function ie(n, e) {
8
17
  const t = [], r = {
9
18
  onEvent: (i) => {
10
- const o = R(i);
11
- if (!(!o || o.type !== "ui_spec")) {
12
- for (const s of Object.values(o.spec.elements))
13
- if (s.type === "ProductCard" && s.props) {
14
- const u = s.props.product ?? s.props;
15
- typeof u.sku == "string" && typeof u.name == "string" && t.push(u);
16
- }
17
- }
19
+ const s = x(i);
20
+ !s || s.type !== "ui_spec" || t.push(...R(s.spec.elements));
18
21
  }
19
22
  };
20
- return e !== void 0 && (r.signal = e), await I(n, r), t;
23
+ return e !== void 0 && (r.signal = e), await N(n, r), t;
21
24
  }
22
- async function ie(n, e, t) {
23
- const r = A("similar_products", e), i = {
25
+ async function oe(n, e, t) {
26
+ const r = P("similar_products", e), i = {
24
27
  method: "POST",
25
28
  headers: { "Content-Type": "application/json" },
26
29
  body: JSON.stringify(n)
27
30
  };
28
31
  t !== void 0 && (i.signal = t);
29
- const o = await fetch(r, i);
30
- if (!o.ok)
31
- throw new Error(`HTTP ${o.status}: ${o.statusText}`);
32
- if (x(o))
33
- return re(o, t);
34
- const s = await o.text();
35
- if (!s) return [];
32
+ const s = await fetch(r, i);
33
+ if (!s.ok)
34
+ throw new Error(`HTTP ${s.status}: ${s.statusText}`);
35
+ if (L(s))
36
+ return ie(s, t);
37
+ const a = await s.text();
38
+ if (!a) return [];
36
39
  try {
37
- return D(JSON.parse(s));
40
+ return j(JSON.parse(a));
38
41
  } catch {
39
42
  throw new Error("Invalid JSON from similar_products endpoint");
40
43
  }
41
44
  }
42
- async function oe(n, e) {
45
+ async function se(n, e) {
43
46
  const t = [];
44
47
  let r = null;
45
48
  const i = {
46
- onEvent: (o) => {
47
- const s = R(o);
48
- if (s) {
49
- if (s.type === "metadata" && s.meta) {
50
- const u = s.meta.group_name;
51
- if (typeof u == "string") {
52
- r = { name: u, products: [] };
53
- const d = s.meta.highlight;
54
- typeof d == "string" && (r.highlight = d), t.push(r);
49
+ onEvent: (s) => {
50
+ const a = x(s);
51
+ if (a) {
52
+ if (a.type === "metadata" && a.meta) {
53
+ const p = a.meta.group_name;
54
+ if (typeof p == "string") {
55
+ r = { name: p, products: [] };
56
+ const l = a.meta.highlight;
57
+ typeof l == "string" && (r.highlight = l), t.push(r);
55
58
  }
56
59
  }
57
- if (s.type === "ui_spec" && r) {
58
- for (const u of Object.values(s.spec.elements))
59
- if (u.type === "ProductCard" && u.props) {
60
- const d = u.props.product ?? u.props;
61
- typeof d.sku == "string" && typeof d.name == "string" && r.products.push(d);
62
- }
63
- }
60
+ a.type === "ui_spec" && r && r.products.push(...R(a.spec.elements));
64
61
  }
65
62
  }
66
63
  };
67
- return e !== void 0 && (i.signal = e), await I(n, i), t;
64
+ return e !== void 0 && (i.signal = e), await N(n, i), t;
68
65
  }
69
- async function se(n, e, t) {
70
- const r = A("product_groupings", e), i = {
66
+ async function ae(n, e, t) {
67
+ const r = P("product_groupings", e), i = {
71
68
  method: "POST",
72
69
  headers: { "Content-Type": "application/json" },
73
70
  body: JSON.stringify(n)
74
71
  };
75
72
  t !== void 0 && (i.signal = t);
76
- const o = await fetch(r, i);
77
- if (!o.ok)
78
- throw new Error(`HTTP ${o.status}: ${o.statusText}`);
79
- if (x(o))
80
- return oe(o, t);
81
- const s = await o.text();
82
- if (!s) return [];
73
+ const s = await fetch(r, i);
74
+ if (!s.ok)
75
+ throw new Error(`HTTP ${s.status}: ${s.statusText}`);
76
+ if (L(s))
77
+ return se(s, t);
78
+ const a = await s.text();
79
+ if (!a) return [];
83
80
  try {
84
- return j(JSON.parse(s));
81
+ return M(JSON.parse(a));
85
82
  } catch {
86
83
  throw new Error("Invalid JSON from product_groupings endpoint");
87
84
  }
88
85
  }
89
86
  function U(n) {
90
- const { product: e, index: t, discountType: r, onClick: i, onAddToCart: o, renderCard: s } = n, u = n.i18n, d = n.pricing;
91
- if (s) {
92
- const a = document.createElement("div");
93
- return a.className = "gengage-simrel-card gengage-simrel-card--custom", a.innerHTML = K(s(e, t)), a.addEventListener("click", (m) => {
87
+ const { product: e, index: t, discountType: r, onClick: i, onAddToCart: s, renderCard: a } = n, p = n.i18n, l = n.pricing;
88
+ if (a) {
89
+ const o = document.createElement("div");
90
+ return o.className = "gengage-simrel-card gengage-simrel-card--custom", o.innerHTML = B(a(e, t)), o.addEventListener("click", (m) => {
94
91
  m.target.closest(".gengage-simrel-atc") || m.target.closest(".gengage-chat-product-card-atc") || i(e);
95
- }), a;
92
+ }), o;
96
93
  }
97
- const g = document.createElement("article");
98
- g.className = "gengage-simrel-card gengage-chat-product-card", g.setAttribute("role", "listitem"), g.dataset.sku = e.sku;
94
+ const u = document.createElement("article");
95
+ u.className = "gengage-simrel-card gengage-chat-product-card", u.setAttribute("role", "listitem"), u.dataset.sku = e.sku;
99
96
  const c = document.createElement("div");
100
- if (c.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", e.imageUrl && X(e.imageUrl)) {
101
- const a = document.createElement("img");
102
- a.className = "gengage-chat-product-card-img", a.src = e.imageUrl, a.alt = e.name, a.loading = "lazy", Z(a), c.appendChild(a);
97
+ if (c.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", e.imageUrl && q(e.imageUrl)) {
98
+ const o = document.createElement("img");
99
+ o.className = "gengage-chat-product-card-img", o.src = e.imageUrl, o.alt = e.name, o.loading = "lazy", ee(o), c.appendChild(o);
103
100
  }
104
101
  if (r === "badge" && e.discountPercent && e.discountPercent > 0) {
105
- const a = document.createElement("span");
106
- a.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", a.textContent = `%${ee(e.discountPercent)}`, c.appendChild(a);
107
- }
108
- g.appendChild(c);
109
- const p = document.createElement("div");
110
- if (p.className = "gengage-simrel-card-info gengage-chat-product-card-body", e.brand) {
111
- const a = document.createElement("div");
112
- a.className = "gengage-simrel-card-brand gengage-chat-product-card-brand", a.textContent = e.brand, p.appendChild(a);
113
- }
114
- const f = document.createElement("div");
115
- if (f.className = "gengage-simrel-card-name gengage-chat-product-card-name", f.textContent = e.name, p.appendChild(f), e.rating != null && e.rating > 0) {
116
- const a = document.createElement("div");
117
- if (a.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", a.textContent = te(e.rating), e.reviewCount != null) {
102
+ const o = document.createElement("span");
103
+ o.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", o.textContent = `%${te(e.discountPercent)}`, c.appendChild(o);
104
+ }
105
+ u.appendChild(c);
106
+ const g = document.createElement("div");
107
+ if (g.className = "gengage-simrel-card-info gengage-chat-product-card-body", e.brand) {
108
+ const o = document.createElement("div");
109
+ o.className = "gengage-simrel-card-brand gengage-chat-product-card-brand", o.textContent = e.brand, g.appendChild(o);
110
+ }
111
+ const h = document.createElement("div");
112
+ if (h.className = "gengage-simrel-card-name gengage-chat-product-card-name", h.textContent = e.name, g.appendChild(h), e.rating != null && e.rating > 0) {
113
+ const o = document.createElement("div");
114
+ if (o.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", o.appendChild(ne(e.rating)), e.reviewCount != null) {
118
115
  const m = document.createElement("span");
119
- m.className = "gengage-simrel-card-review-count gengage-chat-product-card-review-count", m.textContent = ` (${e.reviewCount})`, a.appendChild(m);
116
+ m.className = "gengage-simrel-card-review-count gengage-chat-product-card-review-count", m.textContent = ` (${e.reviewCount})`, o.appendChild(m);
120
117
  }
121
- p.appendChild(a);
118
+ g.appendChild(o);
122
119
  }
123
120
  const y = document.createElement("div");
124
121
  if (y.className = "gengage-simrel-card-price gengage-chat-product-card-price", e.originalPrice && e.originalPrice !== e.price && (r === "strike-through" || !r)) {
125
- const a = document.createElement("span");
126
- a.className = "gengage-simrel-card-price-original gengage-chat-product-card-original-price", a.textContent = T(e.originalPrice, d), y.appendChild(a);
122
+ const o = document.createElement("span");
123
+ o.className = "gengage-simrel-card-price-original gengage-chat-product-card-original-price", o.textContent = T(e.originalPrice, l), y.appendChild(o);
127
124
  }
128
125
  if (e.price) {
129
- const a = document.createElement("span");
130
- a.className = "gengage-simrel-card-price-current gengage-chat-product-card-price-current", a.textContent = T(e.price, d), y.appendChild(a);
131
- }
132
- p.appendChild(y), g.appendChild(p);
133
- const l = document.createElement("button");
134
- if (l.className = "gengage-simrel-card-cta gengage-chat-product-card-cta", l.type = "button", l.textContent = "İncele", l.addEventListener("click", (a) => {
135
- a.preventDefault(), a.stopPropagation(), i(e);
136
- }), g.appendChild(l), e.cartCode && e.inStock !== !1) {
137
- const a = e.cartCode, m = ne({
126
+ const o = document.createElement("span");
127
+ o.className = "gengage-simrel-card-price-current gengage-chat-product-card-price-current", o.textContent = T(e.price, l), y.appendChild(o);
128
+ }
129
+ g.appendChild(y), u.appendChild(g);
130
+ const d = document.createElement("button");
131
+ if (d.className = "gengage-simrel-card-cta gengage-chat-product-card-cta", d.type = "button", d.textContent = p?.ctaLabel ?? "View", d.addEventListener("click", (o) => {
132
+ o.preventDefault(), o.stopPropagation(), i(e);
133
+ }), u.appendChild(d), e.inStock === !1) {
134
+ const o = document.createElement("div");
135
+ o.className = "gengage-simrel-card-oos", o.textContent = p?.outOfStockLabel ?? "Out of Stock", u.appendChild(o);
136
+ } else if (e.cartCode) {
137
+ const o = e.cartCode, m = re({
138
138
  compact: !0,
139
- label: u?.addToCartButton ?? "Sepete Ekle",
139
+ label: p?.addToCartButton ?? "Add to Cart",
140
140
  onSubmit: (C) => {
141
- o({ sku: e.sku, quantity: C, cartCode: a });
141
+ s({ sku: e.sku, quantity: C, cartCode: o });
142
142
  }
143
143
  });
144
- m.classList.add("gengage-simrel-atc", "gengage-chat-product-card-atc"), g.appendChild(m);
144
+ m.classList.add("gengage-simrel-atc"), u.appendChild(m);
145
145
  }
146
- return g.addEventListener("click", (a) => {
147
- a.target.closest(".gengage-simrel-atc") || a.target.closest(".gengage-chat-product-card-atc") || a.target.closest(".gengage-chat-product-card-cta") || i(e);
148
- }), g;
146
+ return u.addEventListener("click", (o) => {
147
+ o.target.closest(".gengage-simrel-atc") || o.target.closest(".gengage-chat-product-card-atc") || o.target.closest(".gengage-chat-product-card-cta") || i(e);
148
+ }), u;
149
149
  }
150
150
  function w(n) {
151
151
  const e = document.createElement("div");
@@ -158,61 +158,61 @@ function w(n) {
158
158
  onAddToCart: n.onAddToCart
159
159
  };
160
160
  n.i18n !== void 0 && (i.i18n = n.i18n), n.discountType !== void 0 && (i.discountType = n.discountType), n.renderCard !== void 0 && (i.renderCard = n.renderCard);
161
- const o = U(i);
162
- e.appendChild(o);
161
+ const s = U(i);
162
+ e.appendChild(s);
163
163
  }
164
164
  if (n.products.length === 0) {
165
165
  const t = document.createElement("div");
166
- t.className = "gengage-simrel-empty", t.textContent = n.i18n?.emptyStateMessage ?? "Benzer ürün bulunamadı.", e.appendChild(t);
166
+ t.className = "gengage-simrel-empty", t.textContent = n.i18n?.emptyStateMessage ?? "No similar products found.", e.appendChild(t);
167
167
  }
168
168
  return e;
169
169
  }
170
- let ae = 0;
171
- function ce(n) {
172
- const e = ae++, t = document.createElement("div");
170
+ let ce = 0;
171
+ function de(n) {
172
+ const e = ce++, t = document.createElement("div");
173
173
  if (t.className = "gengage-simrel-groups", n.groups.length === 0) {
174
174
  const c = document.createElement("div");
175
- return c.className = "gengage-simrel-empty", c.textContent = n.i18n?.emptyStateMessage ?? "Benzer ürün bulunamadı.", t.appendChild(c), t;
175
+ return c.className = "gengage-simrel-empty", c.textContent = n.i18n?.emptyStateMessage ?? "No similar products found.", t.appendChild(c), t;
176
176
  }
177
177
  const r = document.createElement("div");
178
178
  r.className = "gengage-simrel-tabs", r.setAttribute("role", "tablist");
179
- const i = [], o = [], s = (c) => {
180
- const p = {
179
+ const i = [], s = [], a = (c) => {
180
+ const g = {
181
181
  products: c.products,
182
182
  onClick: n.onClick,
183
183
  onAddToCart: n.onAddToCart
184
184
  };
185
- return n.i18n !== void 0 && (p.i18n = n.i18n), n.discountType !== void 0 && (p.discountType = n.discountType), n.renderCard !== void 0 && (p.renderCard = n.renderCard), p;
186
- }, u = (c) => {
187
- for (let l = 0; l < i.length; l++) {
188
- const a = l === c;
189
- i[l].classList.toggle("gengage-simrel-tab--active", a), i[l].setAttribute("aria-selected", String(a)), i[l].tabIndex = a ? 0 : -1;
185
+ return n.i18n !== void 0 && (g.i18n = n.i18n), n.discountType !== void 0 && (g.discountType = n.discountType), n.renderCard !== void 0 && (g.renderCard = n.renderCard), g;
186
+ }, p = (c) => {
187
+ for (let d = 0; d < i.length; d++) {
188
+ const o = d === c;
189
+ i[d].classList.toggle("gengage-simrel-tab--active", o), i[d].setAttribute("aria-selected", String(o)), i[d].tabIndex = o ? 0 : -1;
190
190
  }
191
- const p = n.groups[c], f = o[c];
192
- f.innerHTML = "";
193
- const y = w(s(p));
194
- f.appendChild(y);
195
- for (let l = 0; l < o.length; l++) {
196
- const a = l === c;
197
- o[l].style.display = a ? "" : "none", o[l].tabIndex = a ? 0 : -1;
191
+ const g = n.groups[c], h = s[c];
192
+ h.innerHTML = "";
193
+ const y = w(a(g));
194
+ h.appendChild(y);
195
+ for (let d = 0; d < s.length; d++) {
196
+ const o = d === c;
197
+ s[d].style.display = o ? "" : "none", s[d].tabIndex = o ? 0 : -1;
198
198
  }
199
199
  };
200
200
  for (let c = 0; c < n.groups.length; c++) {
201
- const p = n.groups[c], f = `gengage-simrel-tab-${e}-${c}`, y = `gengage-simrel-panel-${e}-${c}`, l = document.createElement("button");
202
- l.className = "gengage-simrel-tab", l.type = "button", l.id = f, l.textContent = p.name, l.setAttribute("role", "tab"), l.setAttribute("aria-controls", y), l.setAttribute("aria-selected", String(c === 0)), l.tabIndex = c === 0 ? 0 : -1, c === 0 && l.classList.add("gengage-simrel-tab--active"), l.addEventListener("click", () => u(c)), l.addEventListener("keydown", (m) => {
201
+ const g = n.groups[c], h = `gengage-simrel-tab-${e}-${c}`, y = `gengage-simrel-panel-${e}-${c}`, d = document.createElement("button");
202
+ d.className = "gengage-simrel-tab", d.type = "button", d.id = h, d.textContent = g.name, d.setAttribute("role", "tab"), d.setAttribute("aria-controls", y), d.setAttribute("aria-selected", String(c === 0)), d.tabIndex = c === 0 ? 0 : -1, c === 0 && d.classList.add("gengage-simrel-tab--active"), d.addEventListener("click", () => p(c)), d.addEventListener("keydown", (m) => {
203
203
  let C = -1;
204
- m.key === "ArrowRight" || m.key === "ArrowDown" ? C = (c + 1) % n.groups.length : m.key === "ArrowLeft" || m.key === "ArrowUp" ? C = (c - 1 + n.groups.length) % n.groups.length : m.key === "Home" ? C = 0 : m.key === "End" && (C = n.groups.length - 1), C >= 0 && (m.preventDefault(), u(C), i[C].focus());
205
- }), i.push(l), r.appendChild(l);
206
- const a = document.createElement("div");
207
- a.className = "gengage-simrel-tab-panel", a.id = y, a.setAttribute("role", "tabpanel"), a.setAttribute("aria-labelledby", f), a.tabIndex = c === 0 ? 0 : -1, c !== 0 && (a.style.display = "none"), o.push(a);
204
+ m.key === "ArrowRight" || m.key === "ArrowDown" ? C = (c + 1) % n.groups.length : m.key === "ArrowLeft" || m.key === "ArrowUp" ? C = (c - 1 + n.groups.length) % n.groups.length : m.key === "Home" ? C = 0 : m.key === "End" && (C = n.groups.length - 1), C >= 0 && (m.preventDefault(), p(C), i[C].focus());
205
+ }), i.push(d), r.appendChild(d);
206
+ const o = document.createElement("div");
207
+ o.className = "gengage-simrel-tab-panel", o.id = y, o.setAttribute("role", "tabpanel"), o.setAttribute("aria-labelledby", h), o.tabIndex = c === 0 ? 0 : -1, c !== 0 && (o.style.display = "none"), s.push(o);
208
208
  }
209
209
  t.appendChild(r);
210
- const d = o[0], g = w(s(n.groups[0]));
211
- d.appendChild(g);
212
- for (const c of o) t.appendChild(c);
210
+ const l = s[0], u = w(a(n.groups[0]));
211
+ l.appendChild(u);
212
+ for (const c of s) t.appendChild(c);
213
213
  return t;
214
214
  }
215
- function P(n) {
215
+ function A(n) {
216
216
  if (!n || typeof n != "object") return null;
217
217
  const e = n;
218
218
  if (typeof e.sku != "string" || typeof e.name != "string" || typeof e.url != "string")
@@ -225,75 +225,75 @@ function P(n) {
225
225
  typeof r == "string" && (t.imageUrl = r);
226
226
  const i = e.price;
227
227
  typeof i == "string" && (t.price = i);
228
- const o = e.originalPrice;
229
- typeof o == "string" && (t.originalPrice = o);
230
- const s = e.discountPercent;
231
- typeof s == "number" && (t.discountPercent = s);
232
- const u = e.brand;
233
- typeof u == "string" && (t.brand = u);
234
- const d = e.rating;
235
- typeof d == "number" && (t.rating = d);
236
- const g = e.reviewCount;
237
- typeof g == "number" && (t.reviewCount = g);
228
+ const s = e.originalPrice;
229
+ typeof s == "string" && (t.originalPrice = s);
230
+ const a = e.discountPercent;
231
+ typeof a == "number" && (t.discountPercent = a);
232
+ const p = e.brand;
233
+ typeof p == "string" && (t.brand = p);
234
+ const l = e.rating;
235
+ typeof l == "number" && (t.rating = l);
236
+ const u = e.reviewCount;
237
+ typeof u == "number" && (t.reviewCount = u);
238
238
  const c = e.cartCode;
239
239
  typeof c == "string" && (t.cartCode = c);
240
- const p = e.inStock;
241
- return typeof p == "boolean" && (t.inStock = p), t;
240
+ const g = e.inStock;
241
+ return typeof g == "boolean" && (t.inStock = g), t;
242
242
  }
243
- function de(n) {
243
+ function le(n) {
244
244
  if (!n || typeof n != "object") return null;
245
245
  const e = n, t = e.title, r = e.type;
246
246
  if (typeof t != "string" || typeof r != "string") return null;
247
247
  const i = { title: t, type: r };
248
248
  return e.payload !== void 0 && (i.payload = e.payload), i;
249
249
  }
250
- const L = {
250
+ const O = {
251
251
  ProductGrid: ({ element: n, renderElement: e, context: t }) => {
252
252
  const r = document.createElement("div");
253
253
  r.className = "gengage-simrel-grid", r.setAttribute("role", "list");
254
254
  const i = n.props?.columns;
255
255
  typeof i == "number" && Number.isFinite(i) && i > 0 && r.style.setProperty("--gengage-simrel-columns", String(i));
256
- for (const o of n.children ?? []) {
257
- const s = e(o);
258
- s && r.appendChild(s);
256
+ for (const s of n.children ?? []) {
257
+ const a = e(s);
258
+ a && r.appendChild(a);
259
259
  }
260
260
  if (r.children.length === 0) {
261
- const o = document.createElement("div");
262
- o.className = "gengage-simrel-empty", o.textContent = t.i18n.emptyStateMessage, r.appendChild(o);
261
+ const s = document.createElement("div");
262
+ s.className = "gengage-simrel-empty", s.textContent = t.i18n.emptyStateMessage, r.appendChild(s);
263
263
  }
264
264
  return r;
265
265
  },
266
266
  ProductCard: ({ element: n, context: e }) => {
267
- const t = n.props?.product ?? n.props, r = P(t);
267
+ const t = n.props?.product ?? n.props, r = A(t);
268
268
  if (!r) return null;
269
- const i = n.props?.index, o = typeof i == "number" && Number.isFinite(i) ? i : 0, s = n.props?.discountType, u = s === "strike-through" || s === "badge" ? s : e.discountType, d = {
269
+ const i = n.props?.index, s = typeof i == "number" && Number.isFinite(i) ? i : 0, a = n.props?.discountType, p = a === "strike-through" || a === "badge" ? a : e.discountType, l = {
270
270
  product: r,
271
- index: o,
271
+ index: s,
272
272
  onClick: e.onClick,
273
273
  onAddToCart: e.onAddToCart,
274
274
  i18n: e.i18n
275
275
  };
276
- return u !== void 0 && (d.discountType = u), e.renderCard !== void 0 && (d.renderCard = e.renderCard), e.pricing !== void 0 && (d.pricing = e.pricing), U(d);
276
+ return p !== void 0 && (l.discountType = p), e.renderCard !== void 0 && (l.renderCard = e.renderCard), e.pricing !== void 0 && (l.pricing = e.pricing), U(l);
277
277
  },
278
278
  GroupTabs: ({ element: n, context: e }) => {
279
279
  const t = n.props?.groups;
280
280
  if (!Array.isArray(t)) return null;
281
281
  const r = [];
282
- for (const o of t) {
283
- if (!o || typeof o != "object") continue;
284
- const s = o;
285
- if (typeof s.name != "string") continue;
286
- const u = [];
287
- if (Array.isArray(s.products))
288
- for (const g of s.products) {
289
- const c = P(g);
290
- c && u.push(c);
282
+ for (const s of t) {
283
+ if (!s || typeof s != "object") continue;
284
+ const a = s;
285
+ if (typeof a.name != "string") continue;
286
+ const p = [];
287
+ if (Array.isArray(a.products))
288
+ for (const u of a.products) {
289
+ const c = A(u);
290
+ c && p.push(c);
291
291
  }
292
- const d = {
293
- name: s.name,
294
- products: u
292
+ const l = {
293
+ name: a.name,
294
+ products: p
295
295
  };
296
- typeof s.highlight == "string" && (d.highlight = s.highlight), r.push(d);
296
+ typeof a.highlight == "string" && (l.highlight = a.highlight), r.push(l);
297
297
  }
298
298
  const i = {
299
299
  groups: r,
@@ -301,7 +301,7 @@ const L = {
301
301
  onAddToCart: e.onAddToCart,
302
302
  i18n: e.i18n
303
303
  };
304
- return e.discountType !== void 0 && (i.discountType = e.discountType), e.renderCard !== void 0 && (i.renderCard = e.renderCard), ce(i);
304
+ return e.discountType !== void 0 && (i.discountType = e.discountType), e.renderCard !== void 0 && (i.renderCard = e.renderCard), de(i);
305
305
  },
306
306
  EmptyState: ({ element: n, context: e }) => {
307
307
  const t = document.createElement("div");
@@ -314,9 +314,9 @@ const L = {
314
314
  if (typeof t != "string" || typeof r != "string") return null;
315
315
  const i = document.createElement("button");
316
316
  i.className = "gengage-simrel-atc gengage-chat-product-card-cta", i.type = "button";
317
- const o = n.props?.label;
318
- return i.textContent = typeof o == "string" ? o : e.i18n.addToCartButton, i.addEventListener("click", (s) => {
319
- s.preventDefault(), s.stopPropagation(), e.onAddToCart({ sku: t, quantity: 1, cartCode: r });
317
+ const s = n.props?.label;
318
+ return i.textContent = typeof s == "string" ? s : e.i18n.addToCartButton, i.addEventListener("click", (a) => {
319
+ a.preventDefault(), a.stopPropagation(), e.onAddToCart({ sku: t, quantity: 1, cartCode: r });
320
320
  }), i;
321
321
  },
322
322
  QuickActions: ({ element: n, context: e }) => {
@@ -326,12 +326,12 @@ const L = {
326
326
  if (!Array.isArray(r) || !e.onAction) return t;
327
327
  for (const i of r) {
328
328
  if (!i || typeof i != "object") continue;
329
- const o = i, s = o.label, u = de(o.action);
330
- if (typeof s != "string" || !u) continue;
331
- const d = document.createElement("button");
332
- d.className = "gengage-simrel-quick-action", d.type = "button", d.textContent = s, d.addEventListener("click", (g) => {
333
- g.preventDefault(), g.stopPropagation(), e.onAction?.(u);
334
- }), t.appendChild(d);
329
+ const s = i, a = s.label, p = le(s.action);
330
+ if (typeof a != "string" || !p) continue;
331
+ const l = document.createElement("button");
332
+ l.className = "gengage-simrel-quick-action", l.type = "button", l.textContent = a, l.addEventListener("click", (u) => {
333
+ u.preventDefault(), u.stopPropagation(), e.onAction?.(p);
334
+ }), t.appendChild(l);
335
335
  }
336
336
  return t;
337
337
  }
@@ -348,11 +348,11 @@ const L = {
348
348
  }
349
349
  return t;
350
350
  };
351
- function le() {
352
- return { ...L };
351
+ function ue() {
352
+ return { ...O };
353
353
  }
354
- function ue(n, e, t = L, r = G) {
355
- return M({
354
+ function ge(n, e, t = O, r = G) {
355
+ return z({
356
356
  spec: n,
357
357
  context: e,
358
358
  registry: t,
@@ -360,88 +360,92 @@ function ue(n, e, t = L, r = G) {
360
360
  unknownRenderer: r
361
361
  });
362
362
  }
363
- const O = {
363
+ const D = {
364
364
  similarProductsAriaLabel: "Benzer ürünler",
365
365
  emptyStateMessage: "Benzer ürün bulunamadı.",
366
366
  addToCartButton: "Sepete Ekle",
367
+ ctaLabel: "İncele",
368
+ outOfStockLabel: "Stokta Yok",
367
369
  priceSuffix: " TL"
368
- }, ge = {
370
+ }, pe = {
369
371
  similarProductsAriaLabel: "Similar products",
370
372
  emptyStateMessage: "No similar products found.",
371
373
  addToCartButton: "Add to cart",
374
+ ctaLabel: "View",
375
+ outOfStockLabel: "Out of Stock",
372
376
  priceSuffix: ""
373
377
  };
374
- function pe(n) {
378
+ function me(n) {
375
379
  return n ? n.toLowerCase().split("-")[0] ?? "tr" : "tr";
376
380
  }
377
- function me(n) {
378
- return pe(n) === "en" ? ge : O;
381
+ function fe(n) {
382
+ return me(n) === "en" ? pe : D;
379
383
  }
380
384
  const he = b({
381
- sku: h(),
382
- name: h(),
383
- imageUrl: h().url().optional(),
384
- price: h().optional(),
385
- originalPrice: h().optional(),
385
+ sku: f(),
386
+ name: f(),
387
+ imageUrl: f().url().optional(),
388
+ price: f().optional(),
389
+ originalPrice: f().optional(),
386
390
  discountPercent: v().optional(),
387
- url: h().url(),
388
- brand: h().optional(),
391
+ url: f().url(),
392
+ brand: f().optional(),
389
393
  rating: v().min(0).max(5).optional(),
390
394
  reviewCount: v().int().nonnegative().optional()
391
- }), fe = b({
392
- layout: N(["grid", "carousel"]).optional(),
393
- columns: v().int().positive().optional()
394
395
  }), ye = b({
396
+ layout: I(["grid", "carousel"]).optional(),
397
+ columns: v().int().positive().optional()
398
+ }), Ce = b({
395
399
  product: he,
396
400
  index: v().int().nonnegative(),
397
- discountType: N(["strike-through", "badge"]).optional()
398
- }), Ce = b({
399
- sku: h(),
400
- label: h().optional(),
401
- cartCode: h()
401
+ discountType: I(["strike-through", "badge"]).optional()
402
402
  }), be = b({
403
- actions: q(
403
+ sku: f(),
404
+ label: f().optional(),
405
+ cartCode: f()
406
+ }), ve = b({
407
+ actions: H(
404
408
  b({
405
- label: h(),
409
+ label: f(),
406
410
  action: b({
407
- title: h(),
408
- type: h(),
409
- payload: B().optional()
411
+ title: f(),
412
+ type: f(),
413
+ payload: $().optional()
410
414
  })
411
415
  })
412
416
  )
413
- }), ve = b({
414
- message: h().optional()
415
- }), Se = {
417
+ }), Ee = b({
418
+ message: f().optional()
419
+ }), Te = {
416
420
  components: {
417
421
  ProductGrid: {
418
- schema: fe,
422
+ schema: ye,
419
423
  description: "Outer grid or carousel container for similar products."
420
424
  },
421
425
  ProductCard: {
422
- schema: ye,
426
+ schema: Ce,
423
427
  description: "A single product card with image, title, price, and actions."
424
428
  },
425
429
  AddToCartButton: {
426
- schema: Ce,
430
+ schema: be,
427
431
  description: "Add-to-cart CTA rendered inside or below a product card."
428
432
  },
429
433
  QuickActions: {
430
- schema: be,
434
+ schema: ve,
431
435
  description: "A row of quick-action buttons below product info."
432
436
  },
433
437
  EmptyState: {
434
- schema: ve,
438
+ schema: Ee,
435
439
  description: "Empty state shown when no similar products are available."
436
440
  }
437
441
  }
438
442
  };
439
- class _e extends H {
443
+ class ke extends F {
440
444
  constructor() {
441
- super(...arguments), this._abortController = null, this._contentEl = null, this._i18n = O;
445
+ super(...arguments), this._abortController = null, this._contentEl = null, this._i18n = D;
442
446
  }
443
447
  async onInit(e) {
444
- this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), this.isVisible = !0, z("simrel");
448
+ this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), this.isVisible = !0, J("simrel");
445
449
  }
446
450
  onUpdate(e) {
447
451
  const t = e.sku;
@@ -467,17 +471,17 @@ class _e extends H {
467
471
  url: e.url
468
472
  };
469
473
  if (e.imageUrl !== void 0 && (t.imageUrl = e.imageUrl), e.price !== void 0 && (t.price = e.price), e.originalPrice !== void 0 && (t.originalPrice = e.originalPrice), e.discountPercent !== void 0 && (t.discountPercent = e.discountPercent), e.brand !== void 0 && (t.brand = e.brand), e.rating !== void 0 && (t.rating = e.rating), e.reviewCount !== void 0 && (t.reviewCount = e.reviewCount), e.cartCode !== void 0 && (t.cartCode = e.cartCode), e.inStock !== void 0 && (t.inStock = e.inStock), this.config.onProductClick?.(t) === !1) return;
470
- $(e.sku, e.name);
474
+ W(e.sku, e.name);
471
475
  const r = this.config.session?.sessionId ?? null;
472
- _("gengage:similar:product-click", {
476
+ E("gengage:similar:product-click", {
473
477
  sku: e.sku,
474
478
  url: e.url,
475
479
  sessionId: r
476
480
  }), this.config.onProductNavigate?.(e.url, e.sku, r);
477
481
  }
478
482
  _handleAddToCart(e) {
479
- F(e.sku, e.quantity), this.config.onAddToCart?.(e), _("gengage:similar:add-to-cart", e), this.track(
480
- J(this.analyticsContext(), {
483
+ Q(e.sku, e.quantity), this.config.onAddToCart?.(e), E("gengage:similar:add-to-cart", e), this.track(
484
+ V(this.analyticsContext(), {
481
485
  attribution_source: "simrel",
482
486
  attribution_action_id: crypto.randomUUID(),
483
487
  cart_value: 0,
@@ -503,51 +507,51 @@ class _e extends H {
503
507
  r.className = "gengage-simrel-loading";
504
508
  const i = document.createElement("div");
505
509
  i.className = "gengage-simrel-spinner", r.appendChild(i), this._contentEl.appendChild(r);
506
- const o = {
510
+ const s = {
507
511
  middlewareUrl: this.config.middlewareUrl
508
- }, s = crypto.randomUUID(), u = Date.now();
512
+ }, a = crypto.randomUUID(), p = Date.now();
509
513
  this.track(
510
- Q(this.analyticsContext(), {
514
+ Y(this.analyticsContext(), {
511
515
  endpoint: "similar_products",
512
- request_id: s,
516
+ request_id: a,
513
517
  widget: "simrel"
514
518
  })
515
519
  );
516
520
  try {
517
- const d = {
521
+ const l = {
518
522
  account_id: this.config.accountId,
519
523
  session_id: this.config.session?.sessionId ?? "",
520
524
  correlation_id: this.config.session?.sessionId ?? "",
521
525
  sku: e
522
526
  };
523
- this.config.domain !== void 0 && (d.domain = this.config.domain);
524
- const g = await ie(d, o, t);
527
+ this.config.domain !== void 0 && (l.domain = this.config.domain);
528
+ const u = await oe(l, s, t);
525
529
  if (!this._contentEl) return;
526
- if (this._contentEl.innerHTML = "", g.length > 0)
530
+ if (this._contentEl.innerHTML = "", u.length > 0)
527
531
  try {
528
- const c = g.map((f) => f.sku), p = await se(
532
+ const c = u.map((h) => h.sku), g = await ae(
529
533
  {
530
534
  account_id: this.config.accountId,
531
535
  session_id: this.config.session?.sessionId ?? "",
532
536
  correlation_id: this.config.session?.sessionId ?? "",
533
537
  skus: c
534
538
  },
535
- o,
539
+ s,
536
540
  t
537
541
  );
538
- if (p.length > 0 && this._contentEl) {
539
- const f = this._buildGroupsSpec(p), y = this._renderUISpec(f);
540
- this._contentEl.appendChild(y), E("simrel"), this.track(
541
- k(this.analyticsContext(), {
542
- request_id: s,
543
- latency_ms: Date.now() - u,
544
- chunk_count: p.reduce((l, a) => l + a.products.length, 0),
542
+ if (g.length > 0 && this._contentEl) {
543
+ const h = this._buildGroupsSpec(g), y = this._renderUISpec(h);
544
+ this._contentEl.appendChild(y), k("simrel"), this.track(
545
+ _(this.analyticsContext(), {
546
+ request_id: a,
547
+ latency_ms: Date.now() - p,
548
+ chunk_count: g.reduce((d, o) => d + o.products.length, 0),
545
549
  widget: "simrel"
546
550
  })
547
551
  ), this.track(
548
552
  S(this.analyticsContext(), {
549
- message_count: p.reduce((l, a) => l + a.products.length, 0),
550
- history_ref: s,
553
+ message_count: g.reduce((d, o) => d + o.products.length, 0),
554
+ history_ref: a,
551
555
  redaction_level: "none",
552
556
  widget: "simrel"
553
557
  })
@@ -557,46 +561,56 @@ class _e extends H {
557
561
  } catch {
558
562
  }
559
563
  if (this._contentEl) {
560
- const c = this._buildProductsSpec(g), p = this._renderUISpec(c);
561
- this._contentEl.appendChild(p);
564
+ const c = this._buildProductsSpec(u), g = this._renderUISpec(c);
565
+ this._contentEl.appendChild(g);
562
566
  }
563
- g.length > 0 && E("simrel"), this.track(
564
- k(this.analyticsContext(), {
565
- request_id: s,
566
- latency_ms: Date.now() - u,
567
- chunk_count: g.length,
567
+ u.length > 0 && k("simrel"), this.track(
568
+ _(this.analyticsContext(), {
569
+ request_id: a,
570
+ latency_ms: Date.now() - p,
571
+ chunk_count: u.length,
568
572
  widget: "simrel"
569
573
  })
570
574
  ), this.track(
571
575
  S(this.analyticsContext(), {
572
- message_count: g.length,
573
- history_ref: s,
576
+ message_count: u.length,
577
+ history_ref: a,
574
578
  redaction_level: "none",
575
579
  widget: "simrel"
576
580
  })
577
581
  );
578
- } catch (d) {
579
- if (d instanceof DOMException && d.name === "AbortError") return;
580
- _("gengage:global:error", {
582
+ } catch (l) {
583
+ if (l instanceof DOMException && l.name === "AbortError") return;
584
+ if (E("gengage:global:error", {
581
585
  source: "simrel",
582
586
  code: "FETCH_ERROR",
583
- message: W(this.config.locale)
587
+ message: K(this.config.locale)
584
588
  }), this.track(
585
- V(this.analyticsContext(), {
586
- request_id: s,
589
+ X(this.analyticsContext(), {
590
+ request_id: a,
587
591
  error_code: "FETCH_ERROR",
588
- error_message: d instanceof Error ? d.message : String(d),
592
+ error_message: l instanceof Error ? l.message : String(l),
589
593
  widget: "simrel"
590
594
  })
591
- ), this._contentEl && (this._contentEl.innerHTML = "", this._contentEl.style.display = "none");
595
+ ), this._contentEl) {
596
+ this._contentEl.innerHTML = "";
597
+ const u = document.createElement("div");
598
+ u.className = "gengage-simrel-error", u.style.cssText = "text-align:center;padding:16px;color:#6b7280;font-size:13px;";
599
+ const c = document.createElement("span");
600
+ c.textContent = this.config.locale?.startsWith("tr") ? "Benzer ürünler yüklenemedi." : "Could not load similar products.", u.appendChild(c);
601
+ const g = document.createElement("button");
602
+ g.textContent = this.config.locale?.startsWith("tr") ? "Tekrar dene" : "Try again", g.style.cssText = "margin-left:8px;border:1px solid #d1d5db;background:#fff;border-radius:6px;padding:4px 12px;cursor:pointer;font-size:13px;color:#374151;", g.addEventListener("click", () => {
603
+ this._fetchAndRender(this.config.sku);
604
+ }), u.appendChild(g), this._contentEl.appendChild(u);
605
+ }
592
606
  }
593
607
  }
594
608
  _resolveI18n(e) {
595
- return { ...me(e.locale), ...e.i18n };
609
+ return { ...fe(e.locale), ...e.i18n };
596
610
  }
597
611
  _resolveUISpecRegistry() {
598
- const e = le();
599
- return Y(e, this.config.renderer?.registry);
612
+ const e = ue();
613
+ return Z(e, this.config.renderer?.registry);
600
614
  }
601
615
  _buildRenderContext() {
602
616
  const e = this.config.renderCard, t = {
@@ -607,21 +621,21 @@ class _e extends H {
607
621
  return this.config.discountType !== void 0 && (t.discountType = this.config.discountType), e !== void 0 && (t.renderCard = e), this.config.pricing !== void 0 && (t.pricing = this.config.pricing), t;
608
622
  }
609
623
  _renderUISpec(e) {
610
- const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), i = this.config.renderer?.unknownRenderer ?? G, o = (d, g) => ue(d, g, t, i), s = this.config.renderer?.renderUISpec;
611
- return s ? s(e, r, {
624
+ const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), i = this.config.renderer?.unknownRenderer ?? G, s = (l, u) => ge(l, u, t, i), a = this.config.renderer?.renderUISpec;
625
+ return a ? a(e, r, {
612
626
  registry: t,
613
627
  unknownRenderer: i,
614
- defaultRender: o
615
- }) : o(e, r);
628
+ defaultRender: s
629
+ }) : s(e, r);
616
630
  }
617
631
  _buildProductsSpec(e) {
618
632
  const t = {}, r = [];
619
633
  for (let i = 0; i < e.length; i++) {
620
- const o = e[i], s = `product-${i}`;
621
- r.push(s), t[s] = {
634
+ const s = e[i], a = `product-${i}`;
635
+ r.push(a), t[a] = {
622
636
  type: "ProductCard",
623
637
  props: {
624
- product: o,
638
+ product: s,
625
639
  index: i,
626
640
  discountType: this.config.discountType
627
641
  }
@@ -650,15 +664,15 @@ class _e extends H {
650
664
  };
651
665
  }
652
666
  }
653
- function Te() {
654
- return new _e();
667
+ function we() {
668
+ return new ke();
655
669
  }
656
670
  export {
657
- _e as GengageSimRel,
658
- le as createDefaultSimRelUISpecRegistry,
659
- Te as createSimRelWidget,
671
+ ke as GengageSimRel,
672
+ ue as createDefaultSimRelUISpecRegistry,
673
+ we as createSimRelWidget,
660
674
  G as defaultSimRelUnknownUISpecRenderer,
661
- ue as renderSimRelUISpec,
662
- Se as simRelCatalog
675
+ ge as renderSimRelUISpec,
676
+ Te as simRelCatalog
663
677
  };
664
678
  //# sourceMappingURL=simrel.js.map