@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.
- package/README.md +79 -286
- package/dist/assistant-fe.css +1 -1
- package/dist/chat/api.d.ts +1 -12
- package/dist/chat/api.d.ts.map +1 -1
- package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +15 -1
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
- package/dist/chat/components/ChoicePrompter.d.ts +1 -0
- package/dist/chat/components/ChoicePrompter.d.ts.map +1 -1
- package/dist/chat/components/ComparisonTable.d.ts +5 -3
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
- package/dist/chat/components/PanelTopBar.d.ts +2 -0
- package/dist/chat/components/PanelTopBar.d.ts.map +1 -1
- package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -1
- package/dist/chat/components/ReviewHighlights.d.ts +3 -0
- package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
- package/dist/chat/components/renderUISpec.d.ts +0 -5
- package/dist/chat/components/renderUISpec.d.ts.map +1 -1
- package/dist/chat/index.d.ts +18 -9
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/locales/en.d.ts.map +1 -1
- package/dist/chat/locales/tr.d.ts.map +1 -1
- package/dist/chat/session-persistence.d.ts +3 -0
- package/dist/chat/session-persistence.d.ts.map +1 -1
- package/dist/chat/types.d.ts +23 -25
- package/dist/chat/types.d.ts.map +1 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +22 -22
- package/dist/chat.iife.js.map +1 -1
- package/dist/chat.js +8 -9
- package/dist/chat.js.map +1 -1
- package/dist/common/action-router.d.ts.map +1 -1
- package/dist/common/activity-tracker.d.ts +1 -1
- package/dist/common/analytics.d.ts +12 -8
- package/dist/common/analytics.d.ts.map +1 -1
- package/dist/common/api-paths.d.ts +2 -5
- package/dist/common/api-paths.d.ts.map +1 -1
- package/dist/common/config-schema.d.ts.map +1 -1
- package/dist/common/debug.d.ts +14 -0
- package/dist/common/debug.d.ts.map +1 -0
- package/dist/common/events.d.ts.map +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/native-webview.d.ts.map +1 -1
- package/dist/common/overlay.d.ts +19 -0
- package/dist/common/overlay.d.ts.map +1 -1
- package/dist/common/product-utils.d.ts +10 -0
- package/dist/common/product-utils.d.ts.map +1 -1
- package/dist/common/{v1-protocol-adapter.d.ts → protocol-adapter.d.ts} +2 -2
- package/dist/common/protocol-adapter.d.ts.map +1 -0
- package/dist/common/quantity-stepper.d.ts +10 -10
- package/dist/common/quantity-stepper.d.ts.map +1 -1
- package/dist/common/safe-html.d.ts.map +1 -1
- package/dist/common/streaming.d.ts.map +1 -1
- package/dist/common/tts-player.d.ts +2 -0
- package/dist/common/tts-player.d.ts.map +1 -1
- package/dist/common/types.d.ts +1 -1
- package/dist/common/voice-input.d.ts +1 -0
- package/dist/common/voice-input.d.ts.map +1 -1
- package/dist/common/widget-base.d.ts.map +1 -1
- package/dist/common.cjs +1 -1
- package/dist/common.cjs.map +1 -1
- package/dist/common.js +173 -172
- package/dist/common.js.map +1 -1
- package/dist/index-BA7N_XOO.cjs +2 -0
- package/dist/index-BA7N_XOO.cjs.map +1 -0
- package/dist/{index-CcOJTzYu.js → index-C6KDzSjm.js} +155 -159
- package/dist/index-C6KDzSjm.js.map +1 -0
- package/dist/index-RmQRBt6w.js +4449 -0
- package/dist/index-RmQRBt6w.js.map +1 -0
- package/dist/index-VgLdYuZV.cjs +13 -0
- package/dist/index-VgLdYuZV.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +16 -16
- package/dist/native.cjs +1 -1
- package/dist/native.iife.js +23 -23
- package/dist/native.iife.js.map +1 -1
- package/dist/native.js +1 -1
- package/dist/qna/index.d.ts +19 -0
- package/dist/qna/index.d.ts.map +1 -1
- package/dist/qna/types.d.ts +2 -2
- package/dist/qna/types.d.ts.map +1 -1
- package/dist/qna.cjs +1 -1
- package/dist/qna.cjs.map +1 -1
- package/dist/qna.css +1 -1
- package/dist/qna.iife.js +7 -7
- package/dist/qna.iife.js.map +1 -1
- package/dist/qna.js +14 -14
- package/dist/qna.js.map +1 -1
- package/dist/quantity-stepper-BKtPQUR1.js +78 -0
- package/dist/quantity-stepper-BKtPQUR1.js.map +1 -0
- package/dist/quantity-stepper-DU6va4sS.cjs +2 -0
- package/dist/quantity-stepper-DU6va4sS.cjs.map +1 -0
- package/dist/{schemas-yF4IOEUi.js → schemas-BAEbjFPE.js} +1181 -957
- package/dist/schemas-BAEbjFPE.js.map +1 -0
- package/dist/schemas-DIyHm5pa.cjs +86 -0
- package/dist/schemas-DIyHm5pa.cjs.map +1 -0
- package/dist/simrel/api.d.ts +1 -1
- package/dist/simrel/api.d.ts.map +1 -1
- package/dist/simrel/components/GroupTabs.d.ts +1 -1
- package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
- package/dist/simrel/components/ProductCard.d.ts +1 -1
- package/dist/simrel/components/ProductCard.d.ts.map +1 -1
- package/dist/simrel/components/ProductGrid.d.ts +1 -1
- package/dist/simrel/components/ProductGrid.d.ts.map +1 -1
- package/dist/simrel/index.d.ts +20 -1
- package/dist/simrel/index.d.ts.map +1 -1
- package/dist/simrel/locales/en.d.ts.map +1 -1
- package/dist/simrel/locales/tr.d.ts.map +1 -1
- package/dist/simrel/types.d.ts +2 -0
- package/dist/simrel/types.d.ts.map +1 -1
- package/dist/simrel.cjs +1 -1
- package/dist/simrel.cjs.map +1 -1
- package/dist/simrel.css +1 -1
- package/dist/simrel.iife.js +11 -11
- package/dist/simrel.iife.js.map +1 -1
- package/dist/simrel.js +281 -267
- package/dist/simrel.js.map +1 -1
- package/package.json +1 -1
- package/dist/chat/components/ProactivePopup.d.ts +0 -20
- package/dist/chat/components/ProactivePopup.d.ts.map +0 -1
- package/dist/chat/heartbeat.d.ts +0 -71
- package/dist/chat/heartbeat.d.ts.map +0 -1
- package/dist/common/v1-protocol-adapter.d.ts.map +0 -1
- package/dist/index-BqIzV4ni.cjs +0 -2
- package/dist/index-BqIzV4ni.cjs.map +0 -1
- package/dist/index-CcOJTzYu.js.map +0 -1
- package/dist/index-DZ3Mi5xF.cjs +0 -13
- package/dist/index-DZ3Mi5xF.cjs.map +0 -1
- package/dist/index-FnP8WtfG.js +0 -4571
- package/dist/index-FnP8WtfG.js.map +0 -1
- package/dist/quantity-stepper-B8kX8GbN.js +0 -209
- package/dist/quantity-stepper-B8kX8GbN.js.map +0 -1
- package/dist/quantity-stepper-UbAp53Ow.cjs +0 -2
- package/dist/quantity-stepper-UbAp53Ow.cjs.map +0 -1
- package/dist/schemas-DHzfUzwA.cjs +0 -86
- package/dist/schemas-DHzfUzwA.cjs.map +0 -1
- package/dist/schemas-yF4IOEUi.js.map +0 -1
package/dist/simrel.js
CHANGED
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
import { b as
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
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
|
|
16
|
+
async function ie(n, e) {
|
|
8
17
|
const t = [], r = {
|
|
9
18
|
onEvent: (i) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
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
|
|
23
|
+
return e !== void 0 && (r.signal = e), await N(n, r), t;
|
|
21
24
|
}
|
|
22
|
-
async function
|
|
23
|
-
const r =
|
|
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
|
|
30
|
-
if (!
|
|
31
|
-
throw new Error(`HTTP ${
|
|
32
|
-
if (
|
|
33
|
-
return
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
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
|
|
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
|
|
45
|
+
async function se(n, e) {
|
|
43
46
|
const t = [];
|
|
44
47
|
let r = null;
|
|
45
48
|
const i = {
|
|
46
|
-
onEvent: (
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
if (typeof
|
|
52
|
-
r = { name:
|
|
53
|
-
const
|
|
54
|
-
typeof
|
|
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
|
-
|
|
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
|
|
64
|
+
return e !== void 0 && (i.signal = e), await N(n, i), t;
|
|
68
65
|
}
|
|
69
|
-
async function
|
|
70
|
-
const r =
|
|
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
|
|
77
|
-
if (!
|
|
78
|
-
throw new Error(`HTTP ${
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
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
|
|
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:
|
|
91
|
-
if (
|
|
92
|
-
const
|
|
93
|
-
return
|
|
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
|
-
}),
|
|
92
|
+
}), o;
|
|
96
93
|
}
|
|
97
|
-
const
|
|
98
|
-
|
|
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 &&
|
|
101
|
-
const
|
|
102
|
-
|
|
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
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
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})`,
|
|
116
|
+
m.className = "gengage-simrel-card-review-count gengage-chat-product-card-review-count", m.textContent = ` (${e.reviewCount})`, o.appendChild(m);
|
|
120
117
|
}
|
|
121
|
-
|
|
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
|
|
126
|
-
|
|
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
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
}),
|
|
137
|
-
const
|
|
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:
|
|
139
|
+
label: p?.addToCartButton ?? "Add to Cart",
|
|
140
140
|
onSubmit: (C) => {
|
|
141
|
-
|
|
141
|
+
s({ sku: e.sku, quantity: C, cartCode: o });
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
|
-
m.classList.add("gengage-simrel-atc"
|
|
144
|
+
m.classList.add("gengage-simrel-atc"), u.appendChild(m);
|
|
145
145
|
}
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
}),
|
|
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
|
|
162
|
-
e.appendChild(
|
|
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 ?? "
|
|
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
|
|
171
|
-
function
|
|
172
|
-
const e =
|
|
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 ?? "
|
|
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 = [],
|
|
180
|
-
const
|
|
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 && (
|
|
186
|
-
},
|
|
187
|
-
for (let
|
|
188
|
-
const
|
|
189
|
-
i[
|
|
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
|
|
192
|
-
|
|
193
|
-
const y = w(
|
|
194
|
-
|
|
195
|
-
for (let
|
|
196
|
-
const
|
|
197
|
-
|
|
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
|
|
202
|
-
|
|
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(),
|
|
205
|
-
}), i.push(
|
|
206
|
-
const
|
|
207
|
-
|
|
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
|
|
211
|
-
|
|
212
|
-
for (const c of
|
|
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
|
|
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
|
|
229
|
-
typeof
|
|
230
|
-
const
|
|
231
|
-
typeof
|
|
232
|
-
const
|
|
233
|
-
typeof
|
|
234
|
-
const
|
|
235
|
-
typeof
|
|
236
|
-
const
|
|
237
|
-
typeof
|
|
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
|
|
241
|
-
return typeof
|
|
240
|
+
const g = e.inStock;
|
|
241
|
+
return typeof g == "boolean" && (t.inStock = g), t;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
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
|
|
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
|
|
257
|
-
const
|
|
258
|
-
|
|
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
|
|
262
|
-
|
|
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 =
|
|
267
|
+
const t = n.props?.product ?? n.props, r = A(t);
|
|
268
268
|
if (!r) return null;
|
|
269
|
-
const i = n.props?.index,
|
|
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:
|
|
271
|
+
index: s,
|
|
272
272
|
onClick: e.onClick,
|
|
273
273
|
onAddToCart: e.onAddToCart,
|
|
274
274
|
i18n: e.i18n
|
|
275
275
|
};
|
|
276
|
-
return
|
|
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
|
|
283
|
-
if (!
|
|
284
|
-
const
|
|
285
|
-
if (typeof
|
|
286
|
-
const
|
|
287
|
-
if (Array.isArray(
|
|
288
|
-
for (const
|
|
289
|
-
const c =
|
|
290
|
-
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
|
|
293
|
-
name:
|
|
294
|
-
products:
|
|
292
|
+
const l = {
|
|
293
|
+
name: a.name,
|
|
294
|
+
products: p
|
|
295
295
|
};
|
|
296
|
-
typeof
|
|
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),
|
|
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
|
|
318
|
-
return i.textContent = typeof
|
|
319
|
-
|
|
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
|
|
330
|
-
if (typeof
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}), t.appendChild(
|
|
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
|
|
352
|
-
return { ...
|
|
351
|
+
function ue() {
|
|
352
|
+
return { ...O };
|
|
353
353
|
}
|
|
354
|
-
function
|
|
355
|
-
return
|
|
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
|
|
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
|
-
},
|
|
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
|
|
378
|
+
function me(n) {
|
|
375
379
|
return n ? n.toLowerCase().split("-")[0] ?? "tr" : "tr";
|
|
376
380
|
}
|
|
377
|
-
function
|
|
378
|
-
return
|
|
381
|
+
function fe(n) {
|
|
382
|
+
return me(n) === "en" ? pe : D;
|
|
379
383
|
}
|
|
380
384
|
const he = b({
|
|
381
|
-
sku:
|
|
382
|
-
name:
|
|
383
|
-
imageUrl:
|
|
384
|
-
price:
|
|
385
|
-
originalPrice:
|
|
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:
|
|
388
|
-
brand:
|
|
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:
|
|
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
|
-
|
|
403
|
+
sku: f(),
|
|
404
|
+
label: f().optional(),
|
|
405
|
+
cartCode: f()
|
|
406
|
+
}), ve = b({
|
|
407
|
+
actions: H(
|
|
404
408
|
b({
|
|
405
|
-
label:
|
|
409
|
+
label: f(),
|
|
406
410
|
action: b({
|
|
407
|
-
title:
|
|
408
|
-
type:
|
|
409
|
-
payload:
|
|
411
|
+
title: f(),
|
|
412
|
+
type: f(),
|
|
413
|
+
payload: $().optional()
|
|
410
414
|
})
|
|
411
415
|
})
|
|
412
416
|
)
|
|
413
|
-
}),
|
|
414
|
-
message:
|
|
415
|
-
}),
|
|
417
|
+
}), Ee = b({
|
|
418
|
+
message: f().optional()
|
|
419
|
+
}), Te = {
|
|
416
420
|
components: {
|
|
417
421
|
ProductGrid: {
|
|
418
|
-
schema:
|
|
422
|
+
schema: ye,
|
|
419
423
|
description: "Outer grid or carousel container for similar products."
|
|
420
424
|
},
|
|
421
425
|
ProductCard: {
|
|
422
|
-
schema:
|
|
426
|
+
schema: Ce,
|
|
423
427
|
description: "A single product card with image, title, price, and actions."
|
|
424
428
|
},
|
|
425
429
|
AddToCartButton: {
|
|
426
|
-
schema:
|
|
430
|
+
schema: be,
|
|
427
431
|
description: "Add-to-cart CTA rendered inside or below a product card."
|
|
428
432
|
},
|
|
429
433
|
QuickActions: {
|
|
430
|
-
schema:
|
|
434
|
+
schema: ve,
|
|
431
435
|
description: "A row of quick-action buttons below product info."
|
|
432
436
|
},
|
|
433
437
|
EmptyState: {
|
|
434
|
-
schema:
|
|
438
|
+
schema: Ee,
|
|
435
439
|
description: "Empty state shown when no similar products are available."
|
|
436
440
|
}
|
|
437
441
|
}
|
|
438
442
|
};
|
|
439
|
-
class
|
|
443
|
+
class ke extends F {
|
|
440
444
|
constructor() {
|
|
441
|
-
super(...arguments), this._abortController = null, this._contentEl = null, this._i18n =
|
|
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,
|
|
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
|
-
|
|
474
|
+
W(e.sku, e.name);
|
|
471
475
|
const r = this.config.session?.sessionId ?? null;
|
|
472
|
-
|
|
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
|
-
|
|
480
|
-
|
|
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
|
|
510
|
+
const s = {
|
|
507
511
|
middlewareUrl: this.config.middlewareUrl
|
|
508
|
-
},
|
|
512
|
+
}, a = crypto.randomUUID(), p = Date.now();
|
|
509
513
|
this.track(
|
|
510
|
-
|
|
514
|
+
Y(this.analyticsContext(), {
|
|
511
515
|
endpoint: "similar_products",
|
|
512
|
-
request_id:
|
|
516
|
+
request_id: a,
|
|
513
517
|
widget: "simrel"
|
|
514
518
|
})
|
|
515
519
|
);
|
|
516
520
|
try {
|
|
517
|
-
const
|
|
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 && (
|
|
524
|
-
const
|
|
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 = "",
|
|
530
|
+
if (this._contentEl.innerHTML = "", u.length > 0)
|
|
527
531
|
try {
|
|
528
|
-
const c =
|
|
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
|
-
|
|
539
|
+
s,
|
|
536
540
|
t
|
|
537
541
|
);
|
|
538
|
-
if (
|
|
539
|
-
const
|
|
540
|
-
this._contentEl.appendChild(y),
|
|
541
|
-
|
|
542
|
-
request_id:
|
|
543
|
-
latency_ms: Date.now() -
|
|
544
|
-
chunk_count:
|
|
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:
|
|
550
|
-
history_ref:
|
|
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(
|
|
561
|
-
this._contentEl.appendChild(
|
|
564
|
+
const c = this._buildProductsSpec(u), g = this._renderUISpec(c);
|
|
565
|
+
this._contentEl.appendChild(g);
|
|
562
566
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
request_id:
|
|
566
|
-
latency_ms: Date.now() -
|
|
567
|
-
chunk_count:
|
|
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:
|
|
573
|
-
history_ref:
|
|
576
|
+
message_count: u.length,
|
|
577
|
+
history_ref: a,
|
|
574
578
|
redaction_level: "none",
|
|
575
579
|
widget: "simrel"
|
|
576
580
|
})
|
|
577
581
|
);
|
|
578
|
-
} catch (
|
|
579
|
-
if (
|
|
580
|
-
|
|
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:
|
|
587
|
+
message: K(this.config.locale)
|
|
584
588
|
}), this.track(
|
|
585
|
-
|
|
586
|
-
request_id:
|
|
589
|
+
X(this.analyticsContext(), {
|
|
590
|
+
request_id: a,
|
|
587
591
|
error_code: "FETCH_ERROR",
|
|
588
|
-
error_message:
|
|
592
|
+
error_message: l instanceof Error ? l.message : String(l),
|
|
589
593
|
widget: "simrel"
|
|
590
594
|
})
|
|
591
|
-
), this._contentEl
|
|
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 { ...
|
|
609
|
+
return { ...fe(e.locale), ...e.i18n };
|
|
596
610
|
}
|
|
597
611
|
_resolveUISpecRegistry() {
|
|
598
|
-
const e =
|
|
599
|
-
return
|
|
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,
|
|
611
|
-
return
|
|
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:
|
|
615
|
-
}) :
|
|
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
|
|
621
|
-
r.push(
|
|
634
|
+
const s = e[i], a = `product-${i}`;
|
|
635
|
+
r.push(a), t[a] = {
|
|
622
636
|
type: "ProductCard",
|
|
623
637
|
props: {
|
|
624
|
-
product:
|
|
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
|
|
654
|
-
return new
|
|
667
|
+
function we() {
|
|
668
|
+
return new ke();
|
|
655
669
|
}
|
|
656
670
|
export {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
671
|
+
ke as GengageSimRel,
|
|
672
|
+
ue as createDefaultSimRelUISpecRegistry,
|
|
673
|
+
we as createSimRelWidget,
|
|
660
674
|
G as defaultSimRelUnknownUISpecRenderer,
|
|
661
|
-
|
|
662
|
-
|
|
675
|
+
ge as renderSimRelUISpec,
|
|
676
|
+
Te as simRelCatalog
|
|
663
677
|
};
|
|
664
678
|
//# sourceMappingURL=simrel.js.map
|