@gengage/assistant-fe 0.1.9 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/assistant-fe.css +1 -1
  2. package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
  3. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  4. package/dist/chat/components/renderUISpec.d.ts.map +1 -1
  5. package/dist/chat/index.d.ts.map +1 -1
  6. package/dist/chat/panel-manager.d.ts +16 -0
  7. package/dist/chat/panel-manager.d.ts.map +1 -1
  8. package/dist/chat.cjs +1 -1
  9. package/dist/chat.iife.js +28 -28
  10. package/dist/chat.iife.js.map +1 -1
  11. package/dist/chat.js +2 -2
  12. package/dist/common/action-router.d.ts.map +1 -1
  13. package/dist/common/debug.d.ts.map +1 -1
  14. package/dist/common/events.d.ts.map +1 -1
  15. package/dist/common/native-webview.d.ts.map +1 -1
  16. package/dist/common/product-utils.d.ts +10 -0
  17. package/dist/common/product-utils.d.ts.map +1 -1
  18. package/dist/common/protocol-adapter.d.ts.map +1 -1
  19. package/dist/common.cjs +1 -1
  20. package/dist/common.js +5 -5
  21. package/dist/index-BUtw0Jlm.cjs +2 -0
  22. package/dist/index-BUtw0Jlm.cjs.map +1 -0
  23. package/dist/index-D-tVifN8.cjs +13 -0
  24. package/dist/index-D-tVifN8.cjs.map +1 -0
  25. package/dist/{index-DR2uepzb.js → index-DjPldwe7.js} +181 -187
  26. package/dist/index-DjPldwe7.js.map +1 -0
  27. package/dist/{index-CEt87kCd.js → index-TY0qKDI-.js} +1291 -1292
  28. package/dist/index-TY0qKDI-.js.map +1 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +3 -3
  31. package/dist/native.cjs +1 -1
  32. package/dist/native.iife.js +30 -30
  33. package/dist/native.iife.js.map +1 -1
  34. package/dist/native.js +1 -1
  35. package/dist/qna.cjs +1 -1
  36. package/dist/qna.iife.js +2 -2
  37. package/dist/qna.iife.js.map +1 -1
  38. package/dist/qna.js +1 -1
  39. package/dist/quantity-stepper-BKtPQUR1.js +78 -0
  40. package/dist/quantity-stepper-BKtPQUR1.js.map +1 -0
  41. package/dist/quantity-stepper-DU6va4sS.cjs +2 -0
  42. package/dist/quantity-stepper-DU6va4sS.cjs.map +1 -0
  43. package/dist/{schemas-DIhL3DkL.js → schemas-BAEbjFPE.js} +17 -12
  44. package/dist/schemas-BAEbjFPE.js.map +1 -0
  45. package/dist/{schemas-Dsr0bbO_.cjs → schemas-DIyHm5pa.cjs} +4 -4
  46. package/dist/{schemas-DIhL3DkL.js.map → schemas-DIyHm5pa.cjs.map} +1 -1
  47. package/dist/simrel/api.d.ts.map +1 -1
  48. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  49. package/dist/simrel/locales/en.d.ts.map +1 -1
  50. package/dist/simrel/locales/tr.d.ts.map +1 -1
  51. package/dist/simrel/types.d.ts +1 -0
  52. package/dist/simrel/types.d.ts.map +1 -1
  53. package/dist/simrel.cjs +1 -1
  54. package/dist/simrel.cjs.map +1 -1
  55. package/dist/simrel.css +1 -1
  56. package/dist/simrel.iife.js +6 -6
  57. package/dist/simrel.iife.js.map +1 -1
  58. package/dist/simrel.js +236 -234
  59. package/dist/simrel.js.map +1 -1
  60. package/package.json +1 -1
  61. package/dist/index-BWPx4pM7.cjs +0 -13
  62. package/dist/index-BWPx4pM7.cjs.map +0 -1
  63. package/dist/index-CEt87kCd.js.map +0 -1
  64. package/dist/index-DL4CAkyL.cjs +0 -2
  65. package/dist/index-DL4CAkyL.cjs.map +0 -1
  66. package/dist/index-DR2uepzb.js.map +0 -1
  67. package/dist/quantity-stepper-C-nV4lwi.js +0 -77
  68. package/dist/quantity-stepper-C-nV4lwi.js.map +0 -1
  69. package/dist/quantity-stepper-CURMkwRF.cjs +0 -2
  70. package/dist/quantity-stepper-CURMkwRF.cjs.map +0 -1
  71. package/dist/schemas-Dsr0bbO_.cjs.map +0 -1
package/dist/simrel.js CHANGED
@@ -1,150 +1,150 @@
1
- import { b as P, p as D, q as j, c as I, a as N, v as M, x as B, r as q, o as b, s as f, f as z, e as H, _ as x, y as v, B as $, t as F, z as J, j as E, A as W, C as Q, g as V, i as _, h as k, w as S, k as Y, l as K, m as X } from "./schemas-DIhL3DkL.js";
2
- import { a as Z, c as ee, r as te, f as T, b as ne } from "./quantity-stepper-C-nV4lwi.js";
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
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 = N(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 g = s.props.product ?? s.props;
15
- typeof g.sku == "string" && typeof g.name == "string" && t.push(g);
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) {
25
+ async function oe(n, e, t) {
23
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 (R(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 = N(o);
48
- if (s) {
49
- if (s.type === "metadata" && s.meta) {
50
- const g = s.meta.group_name;
51
- if (typeof g == "string") {
52
- r = { name: g, 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 g of Object.values(s.spec.elements))
59
- if (g.type === "ProductCard" && g.props) {
60
- const d = g.props.product ?? g.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) {
66
+ async function ae(n, e, t) {
70
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 (R(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, g = 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 = M(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
94
  const u = document.createElement("article");
98
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 && B(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);
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);
107
104
  }
108
105
  u.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);
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);
113
110
  }
114
111
  const h = document.createElement("div");
115
- if (h.className = "gengage-simrel-card-name gengage-chat-product-card-name", h.textContent = e.name, p.appendChild(h), 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) {
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), u.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 = g?.ctaLabel ?? "View", l.addEventListener("click", (a) => {
135
- a.preventDefault(), a.stopPropagation(), i(e);
136
- }), u.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: g?.addToCartButton ?? "Add to Cart",
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"), u.appendChild(m);
144
+ m.classList.add("gengage-simrel-atc"), u.appendChild(m);
145
145
  }
146
- return u.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);
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
148
  }), u;
149
149
  }
150
150
  function w(n) {
@@ -158,8 +158,8 @@ 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");
@@ -167,49 +167,49 @@ function w(n) {
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
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
- }, g = (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], h = o[c];
191
+ const g = n.groups[c], h = s[c];
192
192
  h.innerHTML = "";
193
- const y = w(s(p));
193
+ const y = w(a(g));
194
194
  h.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;
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], h = `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 = h, 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", () => g(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(), g(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", h), 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], u = w(s(n.groups[0]));
211
- d.appendChild(u);
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
215
  function A(n) {
@@ -225,75 +225,75 @@ function A(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 g = e.brand;
233
- typeof g == "string" && (t.brand = g);
234
- const d = e.rating;
235
- typeof d == "number" && (t.rating = d);
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
236
  const u = e.reviewCount;
237
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
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, g = 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 g !== void 0 && (d.discountType = g), 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 g = [];
287
- if (Array.isArray(s.products))
288
- for (const u of s.products) {
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
289
  const c = A(u);
290
- c && g.push(c);
290
+ c && p.push(c);
291
291
  }
292
- const d = {
293
- name: s.name,
294
- products: g
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, g = de(o.action);
330
- if (typeof s != "string" || !g) continue;
331
- const d = document.createElement("button");
332
- d.className = "gengage-simrel-quick-action", d.type = "button", d.textContent = s, d.addEventListener("click", (u) => {
333
- u.preventDefault(), u.stopPropagation(), e.onAction?.(g);
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 q({
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,26 +360,28 @@ 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
367
  ctaLabel: "İncele",
368
+ outOfStockLabel: "Stokta Yok",
368
369
  priceSuffix: " TL"
369
- }, ge = {
370
+ }, pe = {
370
371
  similarProductsAriaLabel: "Similar products",
371
372
  emptyStateMessage: "No similar products found.",
372
373
  addToCartButton: "Add to cart",
373
374
  ctaLabel: "View",
375
+ outOfStockLabel: "Out of Stock",
374
376
  priceSuffix: ""
375
377
  };
376
- function pe(n) {
378
+ function me(n) {
377
379
  return n ? n.toLowerCase().split("-")[0] ?? "tr" : "tr";
378
380
  }
379
- function me(n) {
380
- return pe(n) === "en" ? ge : O;
381
+ function fe(n) {
382
+ return me(n) === "en" ? pe : D;
381
383
  }
382
- const fe = b({
384
+ const he = b({
383
385
  sku: f(),
384
386
  name: f(),
385
387
  imageUrl: f().url().optional(),
@@ -390,60 +392,60 @@ const fe = b({
390
392
  brand: f().optional(),
391
393
  rating: v().min(0).max(5).optional(),
392
394
  reviewCount: v().int().nonnegative().optional()
393
- }), he = b({
394
- layout: x(["grid", "carousel"]).optional(),
395
- columns: v().int().positive().optional()
396
395
  }), ye = b({
397
- product: fe,
398
- index: v().int().nonnegative(),
399
- discountType: x(["strike-through", "badge"]).optional()
396
+ layout: I(["grid", "carousel"]).optional(),
397
+ columns: v().int().positive().optional()
400
398
  }), Ce = b({
399
+ product: he,
400
+ index: v().int().nonnegative(),
401
+ discountType: I(["strike-through", "badge"]).optional()
402
+ }), be = b({
401
403
  sku: f(),
402
404
  label: f().optional(),
403
405
  cartCode: f()
404
- }), be = b({
405
- actions: z(
406
+ }), ve = b({
407
+ actions: H(
406
408
  b({
407
409
  label: f(),
408
410
  action: b({
409
411
  title: f(),
410
412
  type: f(),
411
- payload: H().optional()
413
+ payload: $().optional()
412
414
  })
413
415
  })
414
416
  )
415
- }), ve = b({
417
+ }), Ee = b({
416
418
  message: f().optional()
417
- }), Se = {
419
+ }), Te = {
418
420
  components: {
419
421
  ProductGrid: {
420
- schema: he,
422
+ schema: ye,
421
423
  description: "Outer grid or carousel container for similar products."
422
424
  },
423
425
  ProductCard: {
424
- schema: ye,
426
+ schema: Ce,
425
427
  description: "A single product card with image, title, price, and actions."
426
428
  },
427
429
  AddToCartButton: {
428
- schema: Ce,
430
+ schema: be,
429
431
  description: "Add-to-cart CTA rendered inside or below a product card."
430
432
  },
431
433
  QuickActions: {
432
- schema: be,
434
+ schema: ve,
433
435
  description: "A row of quick-action buttons below product info."
434
436
  },
435
437
  EmptyState: {
436
- schema: ve,
438
+ schema: Ee,
437
439
  description: "Empty state shown when no similar products are available."
438
440
  }
439
441
  }
440
442
  };
441
- class Ee extends $ {
443
+ class ke extends F {
442
444
  constructor() {
443
- super(...arguments), this._abortController = null, this._contentEl = null, this._i18n = O;
445
+ super(...arguments), this._abortController = null, this._contentEl = null, this._i18n = D;
444
446
  }
445
447
  async onInit(e) {
446
- 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, F("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");
447
449
  }
448
450
  onUpdate(e) {
449
451
  const t = e.sku;
@@ -469,7 +471,7 @@ class Ee extends $ {
469
471
  url: e.url
470
472
  };
471
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;
472
- J(e.sku, e.name);
474
+ W(e.sku, e.name);
473
475
  const r = this.config.session?.sessionId ?? null;
474
476
  E("gengage:similar:product-click", {
475
477
  sku: e.sku,
@@ -478,8 +480,8 @@ class Ee extends $ {
478
480
  }), this.config.onProductNavigate?.(e.url, e.sku, r);
479
481
  }
480
482
  _handleAddToCart(e) {
481
- W(e.sku, e.quantity), this.config.onAddToCart?.(e), E("gengage:similar:add-to-cart", e), this.track(
482
- Q(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(), {
483
485
  attribution_source: "simrel",
484
486
  attribution_action_id: crypto.randomUUID(),
485
487
  cart_value: 0,
@@ -505,51 +507,51 @@ class Ee extends $ {
505
507
  r.className = "gengage-simrel-loading";
506
508
  const i = document.createElement("div");
507
509
  i.className = "gengage-simrel-spinner", r.appendChild(i), this._contentEl.appendChild(r);
508
- const o = {
510
+ const s = {
509
511
  middlewareUrl: this.config.middlewareUrl
510
- }, s = crypto.randomUUID(), g = Date.now();
512
+ }, a = crypto.randomUUID(), p = Date.now();
511
513
  this.track(
512
- V(this.analyticsContext(), {
514
+ Y(this.analyticsContext(), {
513
515
  endpoint: "similar_products",
514
- request_id: s,
516
+ request_id: a,
515
517
  widget: "simrel"
516
518
  })
517
519
  );
518
520
  try {
519
- const d = {
521
+ const l = {
520
522
  account_id: this.config.accountId,
521
523
  session_id: this.config.session?.sessionId ?? "",
522
524
  correlation_id: this.config.session?.sessionId ?? "",
523
525
  sku: e
524
526
  };
525
- this.config.domain !== void 0 && (d.domain = this.config.domain);
526
- const u = await ie(d, o, t);
527
+ this.config.domain !== void 0 && (l.domain = this.config.domain);
528
+ const u = await oe(l, s, t);
527
529
  if (!this._contentEl) return;
528
530
  if (this._contentEl.innerHTML = "", u.length > 0)
529
531
  try {
530
- const c = u.map((h) => h.sku), p = await se(
532
+ const c = u.map((h) => h.sku), g = await ae(
531
533
  {
532
534
  account_id: this.config.accountId,
533
535
  session_id: this.config.session?.sessionId ?? "",
534
536
  correlation_id: this.config.session?.sessionId ?? "",
535
537
  skus: c
536
538
  },
537
- o,
539
+ s,
538
540
  t
539
541
  );
540
- if (p.length > 0 && this._contentEl) {
541
- const h = this._buildGroupsSpec(p), y = this._renderUISpec(h);
542
- this._contentEl.appendChild(y), _("simrel"), this.track(
543
- k(this.analyticsContext(), {
544
- request_id: s,
545
- latency_ms: Date.now() - g,
546
- 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),
547
549
  widget: "simrel"
548
550
  })
549
551
  ), this.track(
550
552
  S(this.analyticsContext(), {
551
- message_count: p.reduce((l, a) => l + a.products.length, 0),
552
- history_ref: s,
553
+ message_count: g.reduce((d, o) => d + o.products.length, 0),
554
+ history_ref: a,
553
555
  redaction_level: "none",
554
556
  widget: "simrel"
555
557
  })
@@ -559,35 +561,35 @@ class Ee extends $ {
559
561
  } catch {
560
562
  }
561
563
  if (this._contentEl) {
562
- const c = this._buildProductsSpec(u), p = this._renderUISpec(c);
563
- this._contentEl.appendChild(p);
564
+ const c = this._buildProductsSpec(u), g = this._renderUISpec(c);
565
+ this._contentEl.appendChild(g);
564
566
  }
565
- u.length > 0 && _("simrel"), this.track(
566
- k(this.analyticsContext(), {
567
- request_id: s,
568
- latency_ms: Date.now() - g,
567
+ u.length > 0 && k("simrel"), this.track(
568
+ _(this.analyticsContext(), {
569
+ request_id: a,
570
+ latency_ms: Date.now() - p,
569
571
  chunk_count: u.length,
570
572
  widget: "simrel"
571
573
  })
572
574
  ), this.track(
573
575
  S(this.analyticsContext(), {
574
576
  message_count: u.length,
575
- history_ref: s,
577
+ history_ref: a,
576
578
  redaction_level: "none",
577
579
  widget: "simrel"
578
580
  })
579
581
  );
580
- } catch (d) {
581
- if (d instanceof DOMException && d.name === "AbortError") return;
582
+ } catch (l) {
583
+ if (l instanceof DOMException && l.name === "AbortError") return;
582
584
  if (E("gengage:global:error", {
583
585
  source: "simrel",
584
586
  code: "FETCH_ERROR",
585
- message: Y(this.config.locale)
587
+ message: K(this.config.locale)
586
588
  }), this.track(
587
- K(this.analyticsContext(), {
588
- request_id: s,
589
+ X(this.analyticsContext(), {
590
+ request_id: a,
589
591
  error_code: "FETCH_ERROR",
590
- error_message: d instanceof Error ? d.message : String(d),
592
+ error_message: l instanceof Error ? l.message : String(l),
591
593
  widget: "simrel"
592
594
  })
593
595
  ), this._contentEl) {
@@ -596,19 +598,19 @@ class Ee extends $ {
596
598
  u.className = "gengage-simrel-error", u.style.cssText = "text-align:center;padding:16px;color:#6b7280;font-size:13px;";
597
599
  const c = document.createElement("span");
598
600
  c.textContent = this.config.locale?.startsWith("tr") ? "Benzer ürünler yüklenemedi." : "Could not load similar products.", u.appendChild(c);
599
- const p = document.createElement("button");
600
- p.textContent = this.config.locale?.startsWith("tr") ? "Tekrar dene" : "Try again", p.style.cssText = "margin-left:8px;border:1px solid #d1d5db;background:#fff;border-radius:6px;padding:4px 12px;cursor:pointer;font-size:13px;color:#374151;", p.addEventListener("click", () => {
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", () => {
601
603
  this._fetchAndRender(this.config.sku);
602
- }), u.appendChild(p), this._contentEl.appendChild(u);
604
+ }), u.appendChild(g), this._contentEl.appendChild(u);
603
605
  }
604
606
  }
605
607
  }
606
608
  _resolveI18n(e) {
607
- return { ...me(e.locale), ...e.i18n };
609
+ return { ...fe(e.locale), ...e.i18n };
608
610
  }
609
611
  _resolveUISpecRegistry() {
610
- const e = le();
611
- return X(e, this.config.renderer?.registry);
612
+ const e = ue();
613
+ return Z(e, this.config.renderer?.registry);
612
614
  }
613
615
  _buildRenderContext() {
614
616
  const e = this.config.renderCard, t = {
@@ -619,21 +621,21 @@ class Ee extends $ {
619
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;
620
622
  }
621
623
  _renderUISpec(e) {
622
- const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), i = this.config.renderer?.unknownRenderer ?? G, o = (d, u) => ue(d, u, t, i), s = this.config.renderer?.renderUISpec;
623
- 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, {
624
626
  registry: t,
625
627
  unknownRenderer: i,
626
- defaultRender: o
627
- }) : o(e, r);
628
+ defaultRender: s
629
+ }) : s(e, r);
628
630
  }
629
631
  _buildProductsSpec(e) {
630
632
  const t = {}, r = [];
631
633
  for (let i = 0; i < e.length; i++) {
632
- const o = e[i], s = `product-${i}`;
633
- r.push(s), t[s] = {
634
+ const s = e[i], a = `product-${i}`;
635
+ r.push(a), t[a] = {
634
636
  type: "ProductCard",
635
637
  props: {
636
- product: o,
638
+ product: s,
637
639
  index: i,
638
640
  discountType: this.config.discountType
639
641
  }
@@ -662,15 +664,15 @@ class Ee extends $ {
662
664
  };
663
665
  }
664
666
  }
665
- function Te() {
666
- return new Ee();
667
+ function we() {
668
+ return new ke();
667
669
  }
668
670
  export {
669
- Ee as GengageSimRel,
670
- le as createDefaultSimRelUISpecRegistry,
671
- Te as createSimRelWidget,
671
+ ke as GengageSimRel,
672
+ ue as createDefaultSimRelUISpecRegistry,
673
+ we as createSimRelWidget,
672
674
  G as defaultSimRelUnknownUISpecRenderer,
673
- ue as renderSimRelUISpec,
674
- Se as simRelCatalog
675
+ ge as renderSimRelUISpec,
676
+ Te as simRelCatalog
675
677
  };
676
678
  //# sourceMappingURL=simrel.js.map