@gengage/assistant-fe 0.1.5 → 0.1.7
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 +100 -0
- package/dist/assistant-fe.css +1 -1
- package/dist/chat/components/AIGroupingCards.d.ts.map +1 -1
- package/dist/chat/components/AITopPicks.d.ts.map +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +12 -4
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
- package/dist/chat/components/ComparisonTable.d.ts +2 -7
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
- package/dist/chat/components/productMentionLinker.d.ts.map +1 -1
- package/dist/chat/index.d.ts +14 -1
- 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/panel-manager.d.ts +6 -2
- package/dist/chat/panel-manager.d.ts.map +1 -1
- package/dist/chat/session-persistence.d.ts +1 -0
- package/dist/chat/session-persistence.d.ts.map +1 -1
- package/dist/chat/types.d.ts +4 -2
- package/dist/chat/types.d.ts.map +1 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +29 -29
- package/dist/chat.iife.js.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/common/events.d.ts.map +1 -1
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/indexed-db.d.ts +2 -0
- package/dist/common/indexed-db.d.ts.map +1 -1
- package/dist/common/native-webview.d.ts +61 -0
- package/dist/common/native-webview.d.ts.map +1 -0
- package/dist/common/overlay.d.ts +5 -0
- package/dist/common/overlay.d.ts.map +1 -1
- package/dist/common/v1-protocol-adapter.d.ts.map +1 -1
- package/dist/common.cjs +1 -1
- package/dist/common.cjs.map +1 -1
- package/dist/common.js +197 -426
- package/dist/common.js.map +1 -1
- package/dist/index-1yPxOqAw.cjs +13 -0
- package/dist/index-1yPxOqAw.cjs.map +1 -0
- package/dist/index-BH-V2lWn.js +510 -0
- package/dist/index-BH-V2lWn.js.map +1 -0
- package/dist/index-BelS6Vnv.cjs +2 -0
- package/dist/index-BelS6Vnv.cjs.map +1 -0
- package/dist/index-CERWfDdF.js +4571 -0
- package/dist/index-CERWfDdF.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -50
- package/dist/index.js.map +1 -1
- package/dist/native/index.d.ts +3 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native.cjs +2 -0
- package/dist/native.cjs.map +1 -0
- package/dist/native.iife.js +97 -0
- package/dist/native.iife.js.map +1 -0
- package/dist/native.js +9 -0
- package/dist/native.js.map +1 -0
- package/dist/qna/components/TextInput.d.ts.map +1 -1
- package/dist/qna/components/renderUISpec.d.ts.map +1 -1
- package/dist/qna/index.d.ts +1 -0
- package/dist/qna/index.d.ts.map +1 -1
- package/dist/qna/types.d.ts +1 -1
- 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 +20 -20
- package/dist/qna.iife.js.map +1 -1
- package/dist/qna.js +92 -80
- package/dist/qna.js.map +1 -1
- package/dist/schemas-DHzfUzwA.cjs +86 -0
- package/dist/schemas-DHzfUzwA.cjs.map +1 -0
- package/dist/{schemas-B9GN-J3e.js → schemas-yF4IOEUi.js} +1088 -987
- package/dist/schemas-yF4IOEUi.js.map +1 -0
- package/dist/simrel/components/ProductCard.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 +20 -20
- package/dist/simrel.iife.js.map +1 -1
- package/dist/simrel.js +218 -214
- package/dist/simrel.js.map +1 -1
- package/package.json +9 -2
- package/dist/index-eefqsSOT.cjs +0 -13
- package/dist/index-eefqsSOT.cjs.map +0 -1
- package/dist/index-kp84NL1R.js +0 -4399
- package/dist/index-kp84NL1R.js.map +0 -1
- package/dist/schemas-B9GN-J3e.js.map +0 -1
- package/dist/schemas-tCxs1sED.cjs +0 -86
- package/dist/schemas-tCxs1sED.cjs.map +0 -1
package/dist/simrel.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as
|
|
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
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
3
|
function x(n) {
|
|
4
4
|
const e = n.headers.get("Content-Type") ?? "";
|
|
@@ -7,12 +7,12 @@ function x(n) {
|
|
|
7
7
|
async function re(n, e) {
|
|
8
8
|
const t = [], r = {
|
|
9
9
|
onEvent: (i) => {
|
|
10
|
-
const
|
|
11
|
-
if (!(!
|
|
12
|
-
for (const
|
|
13
|
-
if (
|
|
14
|
-
const
|
|
15
|
-
typeof
|
|
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
16
|
}
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -20,21 +20,21 @@ async function re(n, e) {
|
|
|
20
20
|
return e !== void 0 && (r.signal = e), await I(n, r), t;
|
|
21
21
|
}
|
|
22
22
|
async function ie(n, e, t) {
|
|
23
|
-
const r =
|
|
23
|
+
const r = A("similar_products", e), i = {
|
|
24
24
|
method: "POST",
|
|
25
25
|
headers: { "Content-Type": "application/json" },
|
|
26
26
|
body: JSON.stringify(n)
|
|
27
27
|
};
|
|
28
28
|
t !== void 0 && (i.signal = t);
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
31
|
-
throw new Error(`HTTP ${
|
|
32
|
-
if (x(
|
|
33
|
-
return re(
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
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 [];
|
|
36
36
|
try {
|
|
37
|
-
return
|
|
37
|
+
return D(JSON.parse(s));
|
|
38
38
|
} catch {
|
|
39
39
|
throw new Error("Invalid JSON from similar_products endpoint");
|
|
40
40
|
}
|
|
@@ -43,21 +43,21 @@ async function oe(n, e) {
|
|
|
43
43
|
const t = [];
|
|
44
44
|
let r = null;
|
|
45
45
|
const i = {
|
|
46
|
-
onEvent: (
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
if (typeof
|
|
52
|
-
r = { name:
|
|
53
|
-
const d =
|
|
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
54
|
typeof d == "string" && (r.highlight = d), t.push(r);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
if (
|
|
58
|
-
for (const
|
|
59
|
-
if (
|
|
60
|
-
const d =
|
|
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
61
|
typeof d.sku == "string" && typeof d.name == "string" && r.products.push(d);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -67,81 +67,85 @@ async function oe(n, e) {
|
|
|
67
67
|
return e !== void 0 && (i.signal = e), await I(n, i), t;
|
|
68
68
|
}
|
|
69
69
|
async function se(n, e, t) {
|
|
70
|
-
const r =
|
|
70
|
+
const r = A("product_groupings", e), i = {
|
|
71
71
|
method: "POST",
|
|
72
72
|
headers: { "Content-Type": "application/json" },
|
|
73
73
|
body: JSON.stringify(n)
|
|
74
74
|
};
|
|
75
75
|
t !== void 0 && (i.signal = t);
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
78
|
-
throw new Error(`HTTP ${
|
|
79
|
-
if (x(
|
|
80
|
-
return oe(
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
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 [];
|
|
83
83
|
try {
|
|
84
|
-
return
|
|
84
|
+
return j(JSON.parse(s));
|
|
85
85
|
} catch {
|
|
86
86
|
throw new Error("Invalid JSON from product_groupings endpoint");
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
function U(n) {
|
|
90
|
-
const { product: e, index: t, discountType: r, onClick: i, onAddToCart:
|
|
91
|
-
if (
|
|
92
|
-
const
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
}),
|
|
96
|
-
}
|
|
97
|
-
const
|
|
98
|
-
|
|
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) => {
|
|
94
|
+
m.target.closest(".gengage-simrel-atc") || m.target.closest(".gengage-chat-product-card-atc") || i(e);
|
|
95
|
+
}), a;
|
|
96
|
+
}
|
|
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;
|
|
99
99
|
const c = document.createElement("div");
|
|
100
|
-
if (c.className = "gengage-simrel-card-image", e.imageUrl && X(e.imageUrl)) {
|
|
101
|
-
const
|
|
102
|
-
|
|
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);
|
|
103
103
|
}
|
|
104
104
|
if (r === "badge" && e.discountPercent && e.discountPercent > 0) {
|
|
105
|
-
const
|
|
106
|
-
|
|
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
107
|
}
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
112
|
-
|
|
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
113
|
}
|
|
114
114
|
const f = document.createElement("div");
|
|
115
|
-
if (f.className = "gengage-simrel-card-name", f.textContent = e.name,
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
|
|
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) {
|
|
118
|
+
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);
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
p.appendChild(a);
|
|
122
122
|
}
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
126
|
-
|
|
123
|
+
const y = document.createElement("div");
|
|
124
|
+
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);
|
|
127
127
|
}
|
|
128
128
|
if (e.price) {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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({
|
|
138
|
+
compact: !0,
|
|
139
|
+
label: u?.addToCartButton ?? "Sepete Ekle",
|
|
140
|
+
onSubmit: (C) => {
|
|
141
|
+
o({ sku: e.sku, quantity: C, cartCode: a });
|
|
138
142
|
}
|
|
139
143
|
});
|
|
140
|
-
|
|
144
|
+
m.classList.add("gengage-simrel-atc", "gengage-chat-product-card-atc"), g.appendChild(m);
|
|
141
145
|
}
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
}),
|
|
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;
|
|
145
149
|
}
|
|
146
150
|
function w(n) {
|
|
147
151
|
const e = document.createElement("div");
|
|
@@ -154,8 +158,8 @@ function w(n) {
|
|
|
154
158
|
onAddToCart: n.onAddToCart
|
|
155
159
|
};
|
|
156
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);
|
|
157
|
-
const
|
|
158
|
-
e.appendChild(
|
|
161
|
+
const o = U(i);
|
|
162
|
+
e.appendChild(o);
|
|
159
163
|
}
|
|
160
164
|
if (n.products.length === 0) {
|
|
161
165
|
const t = document.createElement("div");
|
|
@@ -172,43 +176,43 @@ function ce(n) {
|
|
|
172
176
|
}
|
|
173
177
|
const r = document.createElement("div");
|
|
174
178
|
r.className = "gengage-simrel-tabs", r.setAttribute("role", "tablist");
|
|
175
|
-
const i = [],
|
|
176
|
-
const
|
|
179
|
+
const i = [], o = [], s = (c) => {
|
|
180
|
+
const p = {
|
|
177
181
|
products: c.products,
|
|
178
182
|
onClick: n.onClick,
|
|
179
183
|
onAddToCart: n.onAddToCart
|
|
180
184
|
};
|
|
181
|
-
return n.i18n !== void 0 && (
|
|
182
|
-
},
|
|
183
|
-
for (let
|
|
184
|
-
const
|
|
185
|
-
i[
|
|
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;
|
|
186
190
|
}
|
|
187
|
-
const
|
|
191
|
+
const p = n.groups[c], f = o[c];
|
|
188
192
|
f.innerHTML = "";
|
|
189
|
-
const
|
|
190
|
-
f.appendChild(
|
|
191
|
-
for (let
|
|
192
|
-
const
|
|
193
|
-
|
|
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;
|
|
194
198
|
}
|
|
195
199
|
};
|
|
196
200
|
for (let c = 0; c < n.groups.length; c++) {
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
let
|
|
200
|
-
|
|
201
|
-
}), i.push(
|
|
202
|
-
const
|
|
203
|
-
|
|
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) => {
|
|
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
208
|
}
|
|
205
209
|
t.appendChild(r);
|
|
206
|
-
const d =
|
|
207
|
-
d.appendChild(
|
|
208
|
-
for (const c of
|
|
210
|
+
const d = o[0], g = w(s(n.groups[0]));
|
|
211
|
+
d.appendChild(g);
|
|
212
|
+
for (const c of o) t.appendChild(c);
|
|
209
213
|
return t;
|
|
210
214
|
}
|
|
211
|
-
function
|
|
215
|
+
function P(n) {
|
|
212
216
|
if (!n || typeof n != "object") return null;
|
|
213
217
|
const e = n;
|
|
214
218
|
if (typeof e.sku != "string" || typeof e.name != "string" || typeof e.url != "string")
|
|
@@ -221,20 +225,20 @@ function A(n) {
|
|
|
221
225
|
typeof r == "string" && (t.imageUrl = r);
|
|
222
226
|
const i = e.price;
|
|
223
227
|
typeof i == "string" && (t.price = i);
|
|
224
|
-
const
|
|
225
|
-
typeof
|
|
226
|
-
const
|
|
227
|
-
typeof
|
|
228
|
-
const
|
|
229
|
-
typeof
|
|
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);
|
|
230
234
|
const d = e.rating;
|
|
231
235
|
typeof d == "number" && (t.rating = d);
|
|
232
|
-
const
|
|
233
|
-
typeof
|
|
236
|
+
const g = e.reviewCount;
|
|
237
|
+
typeof g == "number" && (t.reviewCount = g);
|
|
234
238
|
const c = e.cartCode;
|
|
235
239
|
typeof c == "string" && (t.cartCode = c);
|
|
236
|
-
const
|
|
237
|
-
return typeof
|
|
240
|
+
const p = e.inStock;
|
|
241
|
+
return typeof p == "boolean" && (t.inStock = p), t;
|
|
238
242
|
}
|
|
239
243
|
function de(n) {
|
|
240
244
|
if (!n || typeof n != "object") return null;
|
|
@@ -249,47 +253,47 @@ const L = {
|
|
|
249
253
|
r.className = "gengage-simrel-grid", r.setAttribute("role", "list");
|
|
250
254
|
const i = n.props?.columns;
|
|
251
255
|
typeof i == "number" && Number.isFinite(i) && i > 0 && r.style.setProperty("--gengage-simrel-columns", String(i));
|
|
252
|
-
for (const
|
|
253
|
-
const
|
|
254
|
-
|
|
256
|
+
for (const o of n.children ?? []) {
|
|
257
|
+
const s = e(o);
|
|
258
|
+
s && r.appendChild(s);
|
|
255
259
|
}
|
|
256
260
|
if (r.children.length === 0) {
|
|
257
|
-
const
|
|
258
|
-
|
|
261
|
+
const o = document.createElement("div");
|
|
262
|
+
o.className = "gengage-simrel-empty", o.textContent = t.i18n.emptyStateMessage, r.appendChild(o);
|
|
259
263
|
}
|
|
260
264
|
return r;
|
|
261
265
|
},
|
|
262
266
|
ProductCard: ({ element: n, context: e }) => {
|
|
263
|
-
const t = n.props?.product ?? n.props, r =
|
|
267
|
+
const t = n.props?.product ?? n.props, r = P(t);
|
|
264
268
|
if (!r) return null;
|
|
265
|
-
const i = n.props?.index,
|
|
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 = {
|
|
266
270
|
product: r,
|
|
267
|
-
index:
|
|
271
|
+
index: o,
|
|
268
272
|
onClick: e.onClick,
|
|
269
273
|
onAddToCart: e.onAddToCart,
|
|
270
274
|
i18n: e.i18n
|
|
271
275
|
};
|
|
272
|
-
return
|
|
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);
|
|
273
277
|
},
|
|
274
278
|
GroupTabs: ({ element: n, context: e }) => {
|
|
275
279
|
const t = n.props?.groups;
|
|
276
280
|
if (!Array.isArray(t)) return null;
|
|
277
281
|
const r = [];
|
|
278
|
-
for (const
|
|
279
|
-
if (!
|
|
280
|
-
const
|
|
281
|
-
if (typeof
|
|
282
|
-
const
|
|
283
|
-
if (Array.isArray(
|
|
284
|
-
for (const
|
|
285
|
-
const c =
|
|
286
|
-
c &&
|
|
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);
|
|
287
291
|
}
|
|
288
292
|
const d = {
|
|
289
|
-
name:
|
|
290
|
-
products:
|
|
293
|
+
name: s.name,
|
|
294
|
+
products: u
|
|
291
295
|
};
|
|
292
|
-
typeof
|
|
296
|
+
typeof s.highlight == "string" && (d.highlight = s.highlight), r.push(d);
|
|
293
297
|
}
|
|
294
298
|
const i = {
|
|
295
299
|
groups: r,
|
|
@@ -309,10 +313,10 @@ const L = {
|
|
|
309
313
|
const t = n.props?.sku, r = n.props?.cartCode;
|
|
310
314
|
if (typeof t != "string" || typeof r != "string") return null;
|
|
311
315
|
const i = document.createElement("button");
|
|
312
|
-
i.className = "gengage-simrel-atc", i.type = "button";
|
|
313
|
-
const
|
|
314
|
-
return i.textContent = typeof
|
|
315
|
-
|
|
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 });
|
|
316
320
|
}), i;
|
|
317
321
|
},
|
|
318
322
|
QuickActions: ({ element: n, context: e }) => {
|
|
@@ -322,11 +326,11 @@ const L = {
|
|
|
322
326
|
if (!Array.isArray(r) || !e.onAction) return t;
|
|
323
327
|
for (const i of r) {
|
|
324
328
|
if (!i || typeof i != "object") continue;
|
|
325
|
-
const
|
|
326
|
-
if (typeof
|
|
329
|
+
const o = i, s = o.label, u = de(o.action);
|
|
330
|
+
if (typeof s != "string" || !u) continue;
|
|
327
331
|
const d = document.createElement("button");
|
|
328
|
-
d.className = "gengage-simrel-quick-action", d.type = "button", d.textContent =
|
|
329
|
-
|
|
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);
|
|
330
334
|
}), t.appendChild(d);
|
|
331
335
|
}
|
|
332
336
|
return t;
|
|
@@ -361,57 +365,57 @@ const O = {
|
|
|
361
365
|
emptyStateMessage: "Benzer ürün bulunamadı.",
|
|
362
366
|
addToCartButton: "Sepete Ekle",
|
|
363
367
|
priceSuffix: " TL"
|
|
364
|
-
},
|
|
368
|
+
}, ge = {
|
|
365
369
|
similarProductsAriaLabel: "Similar products",
|
|
366
370
|
emptyStateMessage: "No similar products found.",
|
|
367
371
|
addToCartButton: "Add to cart",
|
|
368
372
|
priceSuffix: ""
|
|
369
373
|
};
|
|
370
|
-
function
|
|
374
|
+
function pe(n) {
|
|
371
375
|
return n ? n.toLowerCase().split("-")[0] ?? "tr" : "tr";
|
|
372
376
|
}
|
|
373
377
|
function me(n) {
|
|
374
|
-
return
|
|
378
|
+
return pe(n) === "en" ? ge : O;
|
|
375
379
|
}
|
|
376
|
-
const
|
|
377
|
-
sku:
|
|
378
|
-
name:
|
|
379
|
-
imageUrl:
|
|
380
|
-
price:
|
|
381
|
-
originalPrice:
|
|
382
|
-
discountPercent:
|
|
383
|
-
url:
|
|
384
|
-
brand:
|
|
385
|
-
rating:
|
|
386
|
-
reviewCount:
|
|
387
|
-
}),
|
|
380
|
+
const he = b({
|
|
381
|
+
sku: h(),
|
|
382
|
+
name: h(),
|
|
383
|
+
imageUrl: h().url().optional(),
|
|
384
|
+
price: h().optional(),
|
|
385
|
+
originalPrice: h().optional(),
|
|
386
|
+
discountPercent: v().optional(),
|
|
387
|
+
url: h().url(),
|
|
388
|
+
brand: h().optional(),
|
|
389
|
+
rating: v().min(0).max(5).optional(),
|
|
390
|
+
reviewCount: v().int().nonnegative().optional()
|
|
391
|
+
}), fe = b({
|
|
388
392
|
layout: N(["grid", "carousel"]).optional(),
|
|
389
|
-
columns:
|
|
390
|
-
}), ye =
|
|
391
|
-
product:
|
|
392
|
-
index:
|
|
393
|
+
columns: v().int().positive().optional()
|
|
394
|
+
}), ye = b({
|
|
395
|
+
product: he,
|
|
396
|
+
index: v().int().nonnegative(),
|
|
393
397
|
discountType: N(["strike-through", "badge"]).optional()
|
|
394
|
-
}), Ce =
|
|
395
|
-
sku:
|
|
396
|
-
label:
|
|
397
|
-
cartCode:
|
|
398
|
-
}), be =
|
|
398
|
+
}), Ce = b({
|
|
399
|
+
sku: h(),
|
|
400
|
+
label: h().optional(),
|
|
401
|
+
cartCode: h()
|
|
402
|
+
}), be = b({
|
|
399
403
|
actions: q(
|
|
400
|
-
|
|
401
|
-
label:
|
|
402
|
-
action:
|
|
403
|
-
title:
|
|
404
|
-
type:
|
|
404
|
+
b({
|
|
405
|
+
label: h(),
|
|
406
|
+
action: b({
|
|
407
|
+
title: h(),
|
|
408
|
+
type: h(),
|
|
405
409
|
payload: B().optional()
|
|
406
410
|
})
|
|
407
411
|
})
|
|
408
412
|
)
|
|
409
|
-
}),
|
|
410
|
-
message:
|
|
413
|
+
}), ve = b({
|
|
414
|
+
message: h().optional()
|
|
411
415
|
}), Se = {
|
|
412
416
|
components: {
|
|
413
417
|
ProductGrid: {
|
|
414
|
-
schema:
|
|
418
|
+
schema: fe,
|
|
415
419
|
description: "Outer grid or carousel container for similar products."
|
|
416
420
|
},
|
|
417
421
|
ProductCard: {
|
|
@@ -427,12 +431,12 @@ const fe = C({
|
|
|
427
431
|
description: "A row of quick-action buttons below product info."
|
|
428
432
|
},
|
|
429
433
|
EmptyState: {
|
|
430
|
-
schema:
|
|
434
|
+
schema: ve,
|
|
431
435
|
description: "Empty state shown when no similar products are available."
|
|
432
436
|
}
|
|
433
437
|
}
|
|
434
438
|
};
|
|
435
|
-
class
|
|
439
|
+
class _e extends H {
|
|
436
440
|
constructor() {
|
|
437
441
|
super(...arguments), this._abortController = null, this._contentEl = null, this._i18n = O;
|
|
438
442
|
}
|
|
@@ -465,14 +469,14 @@ class ve extends H {
|
|
|
465
469
|
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;
|
|
466
470
|
$(e.sku, e.name);
|
|
467
471
|
const r = this.config.session?.sessionId ?? null;
|
|
468
|
-
|
|
472
|
+
_("gengage:similar:product-click", {
|
|
469
473
|
sku: e.sku,
|
|
470
474
|
url: e.url,
|
|
471
475
|
sessionId: r
|
|
472
476
|
}), this.config.onProductNavigate?.(e.url, e.sku, r);
|
|
473
477
|
}
|
|
474
478
|
_handleAddToCart(e) {
|
|
475
|
-
F(e.sku, e.quantity), this.config.onAddToCart?.(e),
|
|
479
|
+
F(e.sku, e.quantity), this.config.onAddToCart?.(e), _("gengage:similar:add-to-cart", e), this.track(
|
|
476
480
|
J(this.analyticsContext(), {
|
|
477
481
|
attribution_source: "simrel",
|
|
478
482
|
attribution_action_id: crypto.randomUUID(),
|
|
@@ -499,13 +503,13 @@ class ve extends H {
|
|
|
499
503
|
r.className = "gengage-simrel-loading";
|
|
500
504
|
const i = document.createElement("div");
|
|
501
505
|
i.className = "gengage-simrel-spinner", r.appendChild(i), this._contentEl.appendChild(r);
|
|
502
|
-
const
|
|
506
|
+
const o = {
|
|
503
507
|
middlewareUrl: this.config.middlewareUrl
|
|
504
|
-
},
|
|
508
|
+
}, s = crypto.randomUUID(), u = Date.now();
|
|
505
509
|
this.track(
|
|
506
510
|
Q(this.analyticsContext(), {
|
|
507
511
|
endpoint: "similar_products",
|
|
508
|
-
request_id:
|
|
512
|
+
request_id: s,
|
|
509
513
|
widget: "simrel"
|
|
510
514
|
})
|
|
511
515
|
);
|
|
@@ -517,33 +521,33 @@ class ve extends H {
|
|
|
517
521
|
sku: e
|
|
518
522
|
};
|
|
519
523
|
this.config.domain !== void 0 && (d.domain = this.config.domain);
|
|
520
|
-
const
|
|
524
|
+
const g = await ie(d, o, t);
|
|
521
525
|
if (!this._contentEl) return;
|
|
522
|
-
if (this._contentEl.innerHTML = "",
|
|
526
|
+
if (this._contentEl.innerHTML = "", g.length > 0)
|
|
523
527
|
try {
|
|
524
|
-
const c =
|
|
528
|
+
const c = g.map((f) => f.sku), p = await se(
|
|
525
529
|
{
|
|
526
530
|
account_id: this.config.accountId,
|
|
527
531
|
session_id: this.config.session?.sessionId ?? "",
|
|
528
532
|
correlation_id: this.config.session?.sessionId ?? "",
|
|
529
533
|
skus: c
|
|
530
534
|
},
|
|
531
|
-
|
|
535
|
+
o,
|
|
532
536
|
t
|
|
533
537
|
);
|
|
534
|
-
if (
|
|
535
|
-
const f = this._buildGroupsSpec(
|
|
536
|
-
this._contentEl.appendChild(
|
|
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(
|
|
537
541
|
k(this.analyticsContext(), {
|
|
538
|
-
request_id:
|
|
539
|
-
latency_ms: Date.now() -
|
|
540
|
-
chunk_count:
|
|
542
|
+
request_id: s,
|
|
543
|
+
latency_ms: Date.now() - u,
|
|
544
|
+
chunk_count: p.reduce((l, a) => l + a.products.length, 0),
|
|
541
545
|
widget: "simrel"
|
|
542
546
|
})
|
|
543
547
|
), this.track(
|
|
544
548
|
S(this.analyticsContext(), {
|
|
545
|
-
message_count:
|
|
546
|
-
history_ref:
|
|
549
|
+
message_count: p.reduce((l, a) => l + a.products.length, 0),
|
|
550
|
+
history_ref: s,
|
|
547
551
|
redaction_level: "none",
|
|
548
552
|
widget: "simrel"
|
|
549
553
|
})
|
|
@@ -553,33 +557,33 @@ class ve extends H {
|
|
|
553
557
|
} catch {
|
|
554
558
|
}
|
|
555
559
|
if (this._contentEl) {
|
|
556
|
-
const c = this._buildProductsSpec(
|
|
557
|
-
this._contentEl.appendChild(
|
|
560
|
+
const c = this._buildProductsSpec(g), p = this._renderUISpec(c);
|
|
561
|
+
this._contentEl.appendChild(p);
|
|
558
562
|
}
|
|
559
|
-
|
|
563
|
+
g.length > 0 && E("simrel"), this.track(
|
|
560
564
|
k(this.analyticsContext(), {
|
|
561
|
-
request_id:
|
|
562
|
-
latency_ms: Date.now() -
|
|
563
|
-
chunk_count:
|
|
565
|
+
request_id: s,
|
|
566
|
+
latency_ms: Date.now() - u,
|
|
567
|
+
chunk_count: g.length,
|
|
564
568
|
widget: "simrel"
|
|
565
569
|
})
|
|
566
570
|
), this.track(
|
|
567
571
|
S(this.analyticsContext(), {
|
|
568
|
-
message_count:
|
|
569
|
-
history_ref:
|
|
572
|
+
message_count: g.length,
|
|
573
|
+
history_ref: s,
|
|
570
574
|
redaction_level: "none",
|
|
571
575
|
widget: "simrel"
|
|
572
576
|
})
|
|
573
577
|
);
|
|
574
578
|
} catch (d) {
|
|
575
579
|
if (d instanceof DOMException && d.name === "AbortError") return;
|
|
576
|
-
|
|
580
|
+
_("gengage:global:error", {
|
|
577
581
|
source: "simrel",
|
|
578
582
|
code: "FETCH_ERROR",
|
|
579
583
|
message: W(this.config.locale)
|
|
580
584
|
}), this.track(
|
|
581
585
|
V(this.analyticsContext(), {
|
|
582
|
-
request_id:
|
|
586
|
+
request_id: s,
|
|
583
587
|
error_code: "FETCH_ERROR",
|
|
584
588
|
error_message: d instanceof Error ? d.message : String(d),
|
|
585
589
|
widget: "simrel"
|
|
@@ -603,21 +607,21 @@ class ve extends H {
|
|
|
603
607
|
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;
|
|
604
608
|
}
|
|
605
609
|
_renderUISpec(e) {
|
|
606
|
-
const t = this._resolveUISpecRegistry(), r = this._buildRenderContext(), i = this.config.renderer?.unknownRenderer ?? G,
|
|
607
|
-
return
|
|
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, {
|
|
608
612
|
registry: t,
|
|
609
613
|
unknownRenderer: i,
|
|
610
|
-
defaultRender:
|
|
611
|
-
}) :
|
|
614
|
+
defaultRender: o
|
|
615
|
+
}) : o(e, r);
|
|
612
616
|
}
|
|
613
617
|
_buildProductsSpec(e) {
|
|
614
618
|
const t = {}, r = [];
|
|
615
619
|
for (let i = 0; i < e.length; i++) {
|
|
616
|
-
const
|
|
617
|
-
r.push(
|
|
620
|
+
const o = e[i], s = `product-${i}`;
|
|
621
|
+
r.push(s), t[s] = {
|
|
618
622
|
type: "ProductCard",
|
|
619
623
|
props: {
|
|
620
|
-
product:
|
|
624
|
+
product: o,
|
|
621
625
|
index: i,
|
|
622
626
|
discountType: this.config.discountType
|
|
623
627
|
}
|
|
@@ -647,10 +651,10 @@ class ve extends H {
|
|
|
647
651
|
}
|
|
648
652
|
}
|
|
649
653
|
function Te() {
|
|
650
|
-
return new
|
|
654
|
+
return new _e();
|
|
651
655
|
}
|
|
652
656
|
export {
|
|
653
|
-
|
|
657
|
+
_e as GengageSimRel,
|
|
654
658
|
le as createDefaultSimRelUISpecRegistry,
|
|
655
659
|
Te as createSimRelWidget,
|
|
656
660
|
G as defaultSimRelUnknownUISpecRenderer,
|