@gengage/assistant-fe 0.4.4 → 0.4.6
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 +1 -1
- package/dist/api-paths-C4GDpeTf.js +1214 -0
- package/dist/chat/index.d.ts +1 -374
- package/dist/chat/runtime.d.ts +374 -0
- package/dist/chat/types.d.ts +1 -1
- package/dist/chat-BRKK63lt.js +303 -0
- package/dist/chat-runtime.js +13 -0
- package/dist/chat.iife.js +7 -7
- package/dist/chat.js +11 -10
- package/dist/common/config-constants.d.ts +1 -0
- package/dist/common/config-schema.d.ts +0 -1
- package/dist/common/overlay.d.ts +4 -4
- package/dist/common-CEN5OW7E.js +491 -0
- package/dist/common.js +78 -76
- package/dist/{connection-warning-n88bjkqL.js → connection-warning-B6oIU-9s.js} +1 -1
- package/dist/context-VIG4SVcS.js +529 -0
- package/dist/index.js +70 -67
- package/dist/locale-CfqNifrU.js +7 -0
- package/dist/native-webview-DudQ7nHe.js +273 -0
- package/dist/native.iife.js +28 -91
- package/dist/native.js +1 -1
- package/dist/overlay-1EO41ZC7.js +212 -0
- package/dist/overlay.d.ts +4 -0
- package/dist/overlay.js +10 -0
- package/dist/pill-launcher-57nrdLRr.js +364 -0
- package/dist/qna/index.d.ts +1 -61
- package/dist/qna/runtime.d.ts +61 -0
- package/dist/qna-BNvttR6s.js +40 -0
- package/dist/qna-runtime.js +8 -0
- package/dist/qna.iife.js +4 -4
- package/dist/qna.js +6 -5
- package/dist/{simrel-K2TGFi1r.js → runtime-BdwZZIrO.js} +244 -293
- package/dist/{chat-DI7Vm0gh.js → runtime-C0qZk0y7.js} +1644 -2298
- package/dist/{qna-C5Ok3wd0.js → runtime-DDu8Wk0z.js} +87 -121
- package/dist/schemas-CLo8wCjs.js +3207 -0
- package/dist/{simbut-Cb5RfaAp.js → simbut-BMWC6x_t.js} +24 -22
- package/dist/simbut.js +1 -1
- package/dist/simrel/index.d.ts +1 -59
- package/dist/simrel/runtime.d.ts +59 -0
- package/dist/simrel-ohfkluhp.js +55 -0
- package/dist/simrel-runtime.js +8 -0
- package/dist/simrel.iife.js +4 -4
- package/dist/simrel.js +7 -6
- package/dist/widget-base-TgwiA8cD.js +578 -0
- package/package.json +17 -1
- package/dist/common-BxSi3UWt.js +0 -387
- package/dist/locale-MM0U5eeR.js +0 -1109
- package/dist/native-webview-DFqnyus6.js +0 -586
- package/dist/schemas-JpRGzRQT.js +0 -4419
- /package/dist/{price-formatter-CR6VT5z4.js → price-formatter-xI3g9Cd4.js} +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { f as R, m as Q, r as H, t as N, u as O } from "./api-paths-C4GDpeTf.js";
|
|
2
|
+
import { S as U, b as j, i as M, t as D, w as F, x as W } from "./widget-base-TgwiA8cD.js";
|
|
3
|
+
import { D as $, E as z, a as T, v as G } from "./context-VIG4SVcS.js";
|
|
4
|
+
import { t as q } from "./locale-CfqNifrU.js";
|
|
5
|
+
import { n as J } from "./connection-warning-B6oIU-9s.js";
|
|
6
|
+
async function V(t, n, e) {
|
|
7
|
+
const o = N("launcher_action", n), i = {
|
|
6
8
|
uiSpecs: [],
|
|
7
9
|
actions: []
|
|
8
10
|
}, a = {
|
|
@@ -14,7 +16,7 @@ async function nt(t, n, e) {
|
|
|
14
16
|
const s = await fetch(o, a);
|
|
15
17
|
if (!s.ok) throw new Error(`HTTP ${s.status}: ${s.statusText}`);
|
|
16
18
|
const r = { onEvent: (l) => {
|
|
17
|
-
const c =
|
|
19
|
+
const c = H(l);
|
|
18
20
|
if (c && (c.type === "ui_spec" && i.uiSpecs.push(c.spec), c.type === "ui_spec" && c.spec.elements)) {
|
|
19
21
|
for (const d of Object.values(c.spec.elements)) if (d.type === "ActionButton" && d.props?.action) {
|
|
20
22
|
const m = d.props.action;
|
|
@@ -24,7 +26,7 @@ async function nt(t, n, e) {
|
|
|
24
26
|
} };
|
|
25
27
|
return e !== void 0 && (r.signal = e), await O(s, r), i;
|
|
26
28
|
}
|
|
27
|
-
function
|
|
29
|
+
function E(t) {
|
|
28
30
|
const n = document.createElement("div");
|
|
29
31
|
n.className = "gengage-qna-buttons gds-toolbar", n.dataset.gengagePart = "qna-button-row", n.setAttribute("role", "group"), n.setAttribute("aria-label", t.quickQuestionsAriaLabel ?? "Quick questions"), t.orientation === "vertical" && (n.style.flexDirection = "column");
|
|
30
32
|
for (const e of t.actions) {
|
|
@@ -45,7 +47,7 @@ function k(t) {
|
|
|
45
47
|
}
|
|
46
48
|
return n;
|
|
47
49
|
}
|
|
48
|
-
function
|
|
50
|
+
function Y(t) {
|
|
49
51
|
const n = document.createElement("div");
|
|
50
52
|
n.className = "gengage-qna-input-wrapper", n.dataset.gengagePart = "qna-input-wrapper";
|
|
51
53
|
const e = document.createElement("div");
|
|
@@ -73,7 +75,7 @@ function ot(t) {
|
|
|
73
75
|
const b = () => {
|
|
74
76
|
const u = o.value.trim().length > 0;
|
|
75
77
|
p.classList.toggle("gengage-qna-icon-btn--hidden", !u), h.classList.toggle("gengage-qna-icon-btn--hidden", !u), h.classList.toggle("gengage-qna-send--active", u), h.disabled = !u;
|
|
76
|
-
},
|
|
78
|
+
}, v = () => {
|
|
77
79
|
const u = o.value.trim();
|
|
78
80
|
u && (t.onSubmit({
|
|
79
81
|
title: u,
|
|
@@ -83,7 +85,7 @@ function ot(t) {
|
|
|
83
85
|
};
|
|
84
86
|
return p.addEventListener("click", () => {
|
|
85
87
|
o.value = "", b(), o.focus({ preventScroll: !0 });
|
|
86
|
-
}), h.addEventListener("click",
|
|
88
|
+
}), h.addEventListener("click", v), o.addEventListener("focus", () => {
|
|
87
89
|
c = !0, d(), o.placeholder = "";
|
|
88
90
|
}), o.addEventListener("blur", () => {
|
|
89
91
|
c = !1, o.value.trim().length === 0 && (o.placeholder = s), y();
|
|
@@ -94,12 +96,12 @@ function ot(t) {
|
|
|
94
96
|
}
|
|
95
97
|
o.placeholder = c ? "" : s, y();
|
|
96
98
|
}), o.addEventListener("keydown", (u) => {
|
|
97
|
-
u.key === "Enter" && (u.preventDefault(),
|
|
99
|
+
u.key === "Enter" && (u.preventDefault(), v()), u.key === "Escape" && o.value.length > 0 && (o.value = "", b(), y());
|
|
98
100
|
}), g.appendChild(p), g.appendChild(h), e.appendChild(o), e.appendChild(g), n.appendChild(e), b(), y(), n._cleanup = () => {
|
|
99
101
|
d();
|
|
100
102
|
}, n;
|
|
101
103
|
}
|
|
102
|
-
function
|
|
104
|
+
function A(t, n) {
|
|
103
105
|
if (!t || typeof t != "object") return null;
|
|
104
106
|
const e = t, o = e.type;
|
|
105
107
|
if (typeof o != "string" || o.length === 0) return null;
|
|
@@ -111,59 +113,59 @@ function q(t, n) {
|
|
|
111
113
|
};
|
|
112
114
|
return a !== void 0 && (r.payload = a), r;
|
|
113
115
|
}
|
|
114
|
-
function
|
|
116
|
+
function C(t) {
|
|
115
117
|
const n = {
|
|
116
118
|
title: t.title,
|
|
117
119
|
type: t.type
|
|
118
120
|
};
|
|
119
121
|
return t.payload !== void 0 && (n.payload = t.payload), n;
|
|
120
122
|
}
|
|
121
|
-
function
|
|
123
|
+
function k(t, n) {
|
|
122
124
|
const e = [], o = t.props?.actions;
|
|
123
125
|
if (Array.isArray(o)) for (const s of o) {
|
|
124
|
-
const r =
|
|
126
|
+
const r = A(s);
|
|
125
127
|
r && e.push(r);
|
|
126
128
|
}
|
|
127
129
|
const i = t.props?.buttons;
|
|
128
130
|
if (Array.isArray(i)) for (const s of i) {
|
|
129
131
|
if (!s || typeof s != "object") continue;
|
|
130
|
-
const r = s, l = typeof r.label == "string" ? r.label : void 0, c =
|
|
132
|
+
const r = s, l = typeof r.label == "string" ? r.label : void 0, c = A(r.action, l);
|
|
131
133
|
c && e.push(c);
|
|
132
134
|
}
|
|
133
135
|
if (t.children) for (const s of t.children) {
|
|
134
136
|
const r = n.elements[s];
|
|
135
137
|
if (!r || r.type !== "ActionButton") continue;
|
|
136
|
-
const l = typeof r.props?.label == "string" ? r.props.label : void 0, c =
|
|
138
|
+
const l = typeof r.props?.label == "string" ? r.props.label : void 0, c = A(r.props?.action, l);
|
|
137
139
|
c && e.push(c);
|
|
138
140
|
}
|
|
139
141
|
const a = /* @__PURE__ */ new Set();
|
|
140
142
|
return e.filter((s) => a.has(s.title) ? !1 : (a.add(s.title), !0));
|
|
141
143
|
}
|
|
142
|
-
var
|
|
144
|
+
var L = {
|
|
143
145
|
ButtonRow: ({ element: t, spec: n, context: e }) => {
|
|
144
|
-
const o =
|
|
146
|
+
const o = k(t, n).map(C), i = t.props?.orientation, a = {
|
|
145
147
|
actions: o,
|
|
146
148
|
onAction: e.onAction,
|
|
147
149
|
defaultCtaText: e.i18n.defaultCtaText,
|
|
148
150
|
quickQuestionsAriaLabel: e.i18n.quickQuestionsAriaLabel
|
|
149
151
|
};
|
|
150
|
-
return e.onOpenChat !== void 0 && (a.onOpenChat = e.onOpenChat), e.ctaText !== void 0 && (a.ctaText = e.ctaText), (i === "horizontal" || i === "vertical") && (a.orientation = i),
|
|
152
|
+
return e.onOpenChat !== void 0 && (a.onOpenChat = e.onOpenChat), e.ctaText !== void 0 && (a.ctaText = e.ctaText), (i === "horizontal" || i === "vertical") && (a.orientation = i), E(a);
|
|
151
153
|
},
|
|
152
154
|
ActionButtons: ({ element: t, spec: n, context: e }) => {
|
|
153
155
|
const o = {
|
|
154
|
-
actions:
|
|
156
|
+
actions: k(t, n).map(C),
|
|
155
157
|
onAction: e.onAction,
|
|
156
158
|
defaultCtaText: e.i18n.defaultCtaText,
|
|
157
159
|
quickQuestionsAriaLabel: e.i18n.quickQuestionsAriaLabel
|
|
158
160
|
};
|
|
159
|
-
return e.onOpenChat !== void 0 && (o.onOpenChat = e.onOpenChat), e.ctaText !== void 0 && (o.ctaText = e.ctaText),
|
|
161
|
+
return e.onOpenChat !== void 0 && (o.onOpenChat = e.onOpenChat), e.ctaText !== void 0 && (o.ctaText = e.ctaText), E(o);
|
|
160
162
|
},
|
|
161
163
|
ActionButton: ({ element: t, context: n }) => {
|
|
162
164
|
const e = document.createElement("button");
|
|
163
165
|
e.className = "gengage-qna-button gds-chip", e.type = "button", e.dataset.gengagePart = "qna-action-button";
|
|
164
166
|
const o = t.props?.label;
|
|
165
167
|
typeof o == "string" ? e.textContent = o : e.textContent = n.i18n.defaultCtaText;
|
|
166
|
-
const i =
|
|
168
|
+
const i = A(t.props?.action, typeof o == "string" ? o : void 0);
|
|
167
169
|
return i && e.addEventListener("click", () => n.onAction(i)), e;
|
|
168
170
|
},
|
|
169
171
|
TextInput: ({ element: t, context: n }) => {
|
|
@@ -174,7 +176,7 @@ var x = {
|
|
|
174
176
|
sendButtonText: n.i18n.sendButton,
|
|
175
177
|
sendQuestionAriaLabel: n.i18n.sendQuestionAriaLabel
|
|
176
178
|
};
|
|
177
|
-
return o !== void 0 && (a.placeholders = o), i !== void 0 && (a.ctaLabel = i),
|
|
179
|
+
return o !== void 0 && (a.placeholders = o), i !== void 0 && (a.ctaLabel = i), Y(a);
|
|
178
180
|
},
|
|
179
181
|
QuestionHeading: ({ element: t, context: n }) => {
|
|
180
182
|
const e = document.createElement("h3");
|
|
@@ -183,7 +185,7 @@ var x = {
|
|
|
183
185
|
return e.textContent = typeof i == "string" && i.trim().length > 0 ? i : typeof o == "string" ? o : "", e;
|
|
184
186
|
},
|
|
185
187
|
ProductCard: () => null
|
|
186
|
-
},
|
|
188
|
+
}, w = ({ element: t, renderElement: n }) => {
|
|
187
189
|
if (!t.children || t.children.length === 0) return null;
|
|
188
190
|
const e = document.createElement("div");
|
|
189
191
|
for (const o of t.children) {
|
|
@@ -192,11 +194,11 @@ var x = {
|
|
|
192
194
|
}
|
|
193
195
|
return e;
|
|
194
196
|
};
|
|
195
|
-
function
|
|
196
|
-
return { ...
|
|
197
|
+
function Z() {
|
|
198
|
+
return { ...L };
|
|
197
199
|
}
|
|
198
|
-
function
|
|
199
|
-
return
|
|
200
|
+
function K(t, n, e = L, o = w) {
|
|
201
|
+
return Q({
|
|
200
202
|
spec: t,
|
|
201
203
|
context: n,
|
|
202
204
|
registry: e,
|
|
@@ -204,7 +206,7 @@ function at(t, n, e = x, o = B) {
|
|
|
204
206
|
unknownRenderer: o
|
|
205
207
|
});
|
|
206
208
|
}
|
|
207
|
-
function
|
|
209
|
+
function X(t) {
|
|
208
210
|
if (!t) return;
|
|
209
211
|
const n = t.extra;
|
|
210
212
|
if (n && typeof n == "object" && !Array.isArray(n)) {
|
|
@@ -217,7 +219,7 @@ function st(t) {
|
|
|
217
219
|
const e = typeof t.sku == "string" && t.sku.trim() ? t.sku.trim() : void 0;
|
|
218
220
|
return e ? [e] : void 0;
|
|
219
221
|
}
|
|
220
|
-
function
|
|
222
|
+
function P(t, n) {
|
|
221
223
|
if (!t) return null;
|
|
222
224
|
const e = t.action;
|
|
223
225
|
if (!e || typeof e != "object") return null;
|
|
@@ -231,7 +233,7 @@ function Q(t, n) {
|
|
|
231
233
|
};
|
|
232
234
|
return r !== void 0 && (l.payload = r), l;
|
|
233
235
|
}
|
|
234
|
-
function
|
|
236
|
+
function tt(t, n) {
|
|
235
237
|
const e = t.elements[t.root];
|
|
236
238
|
if (!e) return !1;
|
|
237
239
|
const o = (i) => {
|
|
@@ -239,7 +241,7 @@ function rt(t, n) {
|
|
|
239
241
|
const a = i.props;
|
|
240
242
|
if (!a || typeof a != "object") return !1;
|
|
241
243
|
const s = typeof a.label == "string" ? a.label : void 0;
|
|
242
|
-
return s === n ? !0 :
|
|
244
|
+
return s === n ? !0 : P(a, s)?.title === n;
|
|
243
245
|
};
|
|
244
246
|
if (e.type === "ActionButton") return o(e);
|
|
245
247
|
if (e.children) for (const i of e.children) {
|
|
@@ -252,14 +254,14 @@ function rt(t, n) {
|
|
|
252
254
|
}
|
|
253
255
|
return !1;
|
|
254
256
|
}
|
|
255
|
-
var
|
|
256
|
-
function
|
|
257
|
-
return
|
|
257
|
+
var S = 0;
|
|
258
|
+
function x() {
|
|
259
|
+
return S += 1, `gengage-merge-${S}`;
|
|
258
260
|
}
|
|
259
|
-
function
|
|
261
|
+
function et(t, n) {
|
|
260
262
|
const e = t.elements[t.root];
|
|
261
263
|
if (!e || e.type !== "ButtonRow") return;
|
|
262
|
-
const o =
|
|
264
|
+
const o = x();
|
|
263
265
|
t.elements[o] = {
|
|
264
266
|
type: "ActionButton",
|
|
265
267
|
props: {
|
|
@@ -272,10 +274,10 @@ function lt(t, n) {
|
|
|
272
274
|
}
|
|
273
275
|
}, e.children = e.children ? [o, ...e.children] : [o];
|
|
274
276
|
}
|
|
275
|
-
function
|
|
277
|
+
function nt(t, n) {
|
|
276
278
|
const e = t.elements[t.root];
|
|
277
279
|
if (!e || e.type !== "ActionButtons") return;
|
|
278
|
-
const o =
|
|
280
|
+
const o = x();
|
|
279
281
|
t.elements[o] = {
|
|
280
282
|
type: "ActionButton",
|
|
281
283
|
props: {
|
|
@@ -300,7 +302,7 @@ function ct(t, n) {
|
|
|
300
302
|
buttons: [a, ...i]
|
|
301
303
|
};
|
|
302
304
|
}
|
|
303
|
-
function
|
|
305
|
+
function ot(t) {
|
|
304
306
|
const n = {}, e = [];
|
|
305
307
|
for (let o = 0; o < t.length; o++) {
|
|
306
308
|
const i = t[o], a = `action-${o}`;
|
|
@@ -324,13 +326,13 @@ function dt(t) {
|
|
|
324
326
|
elements: n
|
|
325
327
|
};
|
|
326
328
|
}
|
|
327
|
-
function
|
|
329
|
+
function it(t) {
|
|
328
330
|
return t.find((n) => {
|
|
329
331
|
const e = n.elements[n.root];
|
|
330
332
|
return e?.type === "ActionButtons" || e?.type === "ButtonRow";
|
|
331
333
|
});
|
|
332
334
|
}
|
|
333
|
-
function
|
|
335
|
+
function I(t, n) {
|
|
334
336
|
const e = t.productContextQuickPillLabel, o = { text: e };
|
|
335
337
|
return n && n.length > 0 && (o.sku_list = n), {
|
|
336
338
|
title: e,
|
|
@@ -338,29 +340,29 @@ function L(t, n) {
|
|
|
338
340
|
payload: o
|
|
339
341
|
};
|
|
340
342
|
}
|
|
341
|
-
function
|
|
343
|
+
function at(t, n, e) {
|
|
342
344
|
const o = e?.skuList, i = [], a = [];
|
|
343
345
|
for (const l of t) {
|
|
344
346
|
const c = l.elements[l.root];
|
|
345
347
|
if (c?.type === "ActionButton") {
|
|
346
348
|
const d = c.props;
|
|
347
|
-
if (
|
|
348
|
-
i.push(
|
|
349
|
+
if (P(d, typeof d?.label == "string" ? d.label : void 0)?.type === "findSimilar") {
|
|
350
|
+
i.push(I(n, o));
|
|
349
351
|
continue;
|
|
350
352
|
}
|
|
351
353
|
}
|
|
352
354
|
a.push(l);
|
|
353
355
|
}
|
|
354
356
|
if (i.length === 0) return t;
|
|
355
|
-
const s =
|
|
356
|
-
if (!r) return [...a,
|
|
357
|
-
if (!
|
|
357
|
+
const s = I(n, o), r = it(a);
|
|
358
|
+
if (!r) return [...a, ot([s])];
|
|
359
|
+
if (!tt(r, s.title)) {
|
|
358
360
|
const l = r.elements[r.root];
|
|
359
|
-
l?.type === "ActionButtons" ?
|
|
361
|
+
l?.type === "ActionButtons" ? nt(r, s) : l?.type === "ButtonRow" && et(r, s);
|
|
360
362
|
}
|
|
361
363
|
return a;
|
|
362
364
|
}
|
|
363
|
-
var
|
|
365
|
+
var B = {
|
|
364
366
|
quickQuestionsAriaLabel: "Hızlı sorular",
|
|
365
367
|
askQuestionAriaLabel: "Soru sorun",
|
|
366
368
|
defaultInputPlaceholder: "Bir soru sorun...",
|
|
@@ -369,7 +371,7 @@ var N = {
|
|
|
369
371
|
defaultCtaText: "Başka bir şey sor",
|
|
370
372
|
redirectingToChat: "Sohbete yönlendiriliyor...",
|
|
371
373
|
productContextQuickPillLabel: "Bu ürün hakkında ne bilmeliyim?"
|
|
372
|
-
},
|
|
374
|
+
}, st = {
|
|
373
375
|
quickQuestionsAriaLabel: "Quick questions",
|
|
374
376
|
askQuestionAriaLabel: "Ask a question",
|
|
375
377
|
defaultInputPlaceholder: "Ask a question...",
|
|
@@ -379,55 +381,20 @@ var N = {
|
|
|
379
381
|
redirectingToChat: "Redirecting to chat...",
|
|
380
382
|
productContextQuickPillLabel: "What should I know about this product?"
|
|
381
383
|
};
|
|
382
|
-
function
|
|
384
|
+
function rt(t) {
|
|
383
385
|
return t ? t.toLowerCase().split("-")[0] ?? "tr" : "tr";
|
|
384
386
|
}
|
|
385
|
-
function
|
|
386
|
-
return
|
|
387
|
+
function lt(t) {
|
|
388
|
+
return rt(t) === "en" ? st : B;
|
|
387
389
|
}
|
|
388
|
-
var
|
|
389
|
-
title: _(),
|
|
390
|
-
type: _(),
|
|
391
|
-
payload: W().optional()
|
|
392
|
-
}), mt = A({
|
|
393
|
-
label: _(),
|
|
394
|
-
action: yt,
|
|
395
|
-
variant: P([
|
|
396
|
-
"primary",
|
|
397
|
-
"outline",
|
|
398
|
-
"ghost"
|
|
399
|
-
]).optional()
|
|
400
|
-
}), bt = A({
|
|
401
|
-
orientation: P(["horizontal", "vertical"]).optional(),
|
|
402
|
-
wrap: F().optional()
|
|
403
|
-
}), _t = A({
|
|
404
|
-
placeholder: j([_(), M(_())]).optional(),
|
|
405
|
-
ctaLabel: _().optional()
|
|
406
|
-
}), vt = A({ text: _() }), Ct = { components: {
|
|
407
|
-
ActionButton: {
|
|
408
|
-
schema: mt,
|
|
409
|
-
description: "A single clickable QNA action button."
|
|
410
|
-
},
|
|
411
|
-
ButtonRow: {
|
|
412
|
-
schema: bt,
|
|
413
|
-
description: "Container for a group of QNA action buttons."
|
|
414
|
-
},
|
|
415
|
-
TextInput: {
|
|
416
|
-
schema: _t,
|
|
417
|
-
description: "Free-text input with rotating placeholder and CTA button."
|
|
418
|
-
},
|
|
419
|
-
QuestionHeading: {
|
|
420
|
-
schema: vt,
|
|
421
|
-
description: "A heading displayed above the QNA button group."
|
|
422
|
-
}
|
|
423
|
-
} }, At = class extends Z {
|
|
390
|
+
var ct = class extends D {
|
|
424
391
|
constructor(...t) {
|
|
425
|
-
super(...t), this._abortController = null, this._debounceTimer = null, this._contentEl = null, this._i18n =
|
|
392
|
+
super(...t), this._abortController = null, this._debounceTimer = null, this._contentEl = null, this._i18n = B, this._actionHandler = this._handleAction.bind(this), this._openChatHandler = this._handleOpenChat.bind(this);
|
|
426
393
|
}
|
|
427
394
|
async onInit(t) {
|
|
428
|
-
this._i18n = this._resolveI18n(t), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-qna-container", this._contentEl.dataset.gengagePart = "qna-container", this._contentEl.lang =
|
|
395
|
+
this._i18n = this._resolveI18n(t), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-qna-container", this._contentEl.dataset.gengagePart = "qna-container", this._contentEl.lang = q(t.locale), this.root.appendChild(this._contentEl);
|
|
429
396
|
const n = t.pageContext?.sku;
|
|
430
|
-
n && (this._lastSku = n, await this._fetchAndRender(n)),
|
|
397
|
+
n && (this._lastSku = n, await this._fetchAndRender(n)), G("qna");
|
|
431
398
|
}
|
|
432
399
|
onUpdate(t) {
|
|
433
400
|
const n = t.sku;
|
|
@@ -464,11 +431,11 @@ var yt = A({
|
|
|
464
431
|
this._cleanupTextInputTimers(), this._contentEl.innerHTML = "";
|
|
465
432
|
const n = this._createLoadingIndicator();
|
|
466
433
|
this._contentEl.appendChild(n);
|
|
467
|
-
const e = { middlewareUrl: this.config.middlewareUrl }, o = crypto.randomUUID(), i = Date.now(), a =
|
|
434
|
+
const e = { middlewareUrl: this.config.middlewareUrl }, o = crypto.randomUUID(), i = Date.now(), a = J({
|
|
468
435
|
source: "qna",
|
|
469
436
|
locale: this.config.locale
|
|
470
437
|
});
|
|
471
|
-
this.track(
|
|
438
|
+
this.track(U(this.analyticsContext(), {
|
|
472
439
|
endpoint: "launcher_action",
|
|
473
440
|
request_id: o,
|
|
474
441
|
widget: "qna"
|
|
@@ -479,16 +446,16 @@ var yt = A({
|
|
|
479
446
|
session_id: this.config.session?.sessionId ?? "",
|
|
480
447
|
correlation_id: this.config.session?.sessionId ?? "",
|
|
481
448
|
sku: t,
|
|
482
|
-
locale:
|
|
449
|
+
locale: q(this.config.locale)
|
|
483
450
|
}, r = this.config.pageContext?.pageType;
|
|
484
451
|
r !== void 0 && (s.page_type = r);
|
|
485
|
-
const l = await
|
|
486
|
-
if (this.track(
|
|
452
|
+
const l = await V(s, e, this._abortController.signal);
|
|
453
|
+
if (this.track(j(this.analyticsContext(), {
|
|
487
454
|
request_id: o,
|
|
488
455
|
latency_ms: Date.now() - i,
|
|
489
456
|
chunk_count: l.actions.length,
|
|
490
457
|
widget: "qna"
|
|
491
|
-
})), this.track(
|
|
458
|
+
})), this.track(F(this.analyticsContext(), {
|
|
492
459
|
message_count: l.actions.length,
|
|
493
460
|
history_ref: o,
|
|
494
461
|
redaction_level: "none",
|
|
@@ -506,7 +473,7 @@ var yt = A({
|
|
|
506
473
|
let g;
|
|
507
474
|
if (y !== !0) g = y ?? this._i18n.defaultInputPlaceholder;
|
|
508
475
|
else if (l.actions.length > 0) {
|
|
509
|
-
const f = l.actions.filter((
|
|
476
|
+
const f = l.actions.filter((_) => _.type === "user_message" || _.title.includes("?")).map((_) => _.title);
|
|
510
477
|
g = f.length > 0 ? f : this._i18n.defaultInputPlaceholder;
|
|
511
478
|
} else g = this._i18n.defaultInputPlaceholder;
|
|
512
479
|
const p = {
|
|
@@ -514,19 +481,19 @@ var yt = A({
|
|
|
514
481
|
i18n: this._i18n
|
|
515
482
|
}, h = this._resolvedQnaHeaderTitle();
|
|
516
483
|
h !== void 0 && (p.headingTitleOverride = h), this.config.hideButtonRowCta || (p.onOpenChat = this._openChatHandler, this.config.ctaText !== void 0 && (p.ctaText = this.config.ctaText)), g !== void 0 && (p.inputPlaceholder = g);
|
|
517
|
-
const b = this._buildFallbackActionsSpec(l.actions),
|
|
484
|
+
const b = this._buildFallbackActionsSpec(l.actions), v = X(this.config.pageContext), u = (l.uiSpecs.length > 0 ? at(l.uiSpecs, this._i18n, { skuList: v }) : [b]).filter((f) => Object.keys(f.elements).length > 0);
|
|
518
485
|
for (const f of u) {
|
|
519
|
-
const
|
|
520
|
-
c.appendChild(
|
|
486
|
+
const _ = this._renderUISpec(f, p);
|
|
487
|
+
c.appendChild(_);
|
|
521
488
|
}
|
|
522
|
-
u.length > 0 &&
|
|
489
|
+
u.length > 0 && z("qna"), this._specIncludesType(u, "TextInput") || this._insertStandaloneInputBeforePills(c, p, g);
|
|
523
490
|
} catch (s) {
|
|
524
491
|
if (s instanceof DOMException && s.name === "AbortError") return;
|
|
525
|
-
if (
|
|
492
|
+
if (T("gengage:global:error", {
|
|
526
493
|
source: "qna",
|
|
527
494
|
code: "FETCH_ERROR",
|
|
528
|
-
message:
|
|
529
|
-
}), this.track(
|
|
495
|
+
message: M(this.config.locale, s)
|
|
496
|
+
}), this.track(W(this.analyticsContext(), {
|
|
530
497
|
request_id: o,
|
|
531
498
|
error_code: "FETCH_ERROR",
|
|
532
499
|
error_message: s instanceof Error ? s.message : String(s),
|
|
@@ -557,15 +524,15 @@ var yt = A({
|
|
|
557
524
|
}
|
|
558
525
|
_resolveI18n(t) {
|
|
559
526
|
return {
|
|
560
|
-
...
|
|
527
|
+
...lt(t.locale),
|
|
561
528
|
...t.i18n
|
|
562
529
|
};
|
|
563
530
|
}
|
|
564
531
|
_resolveUISpecRegistry() {
|
|
565
|
-
return
|
|
532
|
+
return R(Z(), this.config.renderer?.registry);
|
|
566
533
|
}
|
|
567
534
|
_renderUISpec(t, n) {
|
|
568
|
-
const e = this._resolveUISpecRegistry(), o = this.config.renderer?.unknownRenderer ??
|
|
535
|
+
const e = this._resolveUISpecRegistry(), o = this.config.renderer?.unknownRenderer ?? w, i = (s, r) => K(s, r, e, o), a = this.config.renderer?.renderUISpec;
|
|
569
536
|
return a ? a(t, n, {
|
|
570
537
|
registry: e,
|
|
571
538
|
unknownRenderer: o,
|
|
@@ -636,10 +603,10 @@ var yt = A({
|
|
|
636
603
|
(e ?? this._contentEl).appendChild(i);
|
|
637
604
|
}
|
|
638
605
|
_handleAction(t) {
|
|
639
|
-
this._showTransitionIndicator(),
|
|
606
|
+
this._showTransitionIndicator(), $(t.title, t.type), this.config.onActionSelected?.(t), setTimeout(() => T("gengage:qna:action", t), 350);
|
|
640
607
|
}
|
|
641
608
|
_handleOpenChat() {
|
|
642
|
-
this._showTransitionIndicator(), this.config.onOpenChat?.(), setTimeout(() =>
|
|
609
|
+
this._showTransitionIndicator(), this.config.onOpenChat?.(), setTimeout(() => T("gengage:qna:open-chat", {}), 350);
|
|
643
610
|
}
|
|
644
611
|
_showTransitionIndicator() {
|
|
645
612
|
if (!this._contentEl) return;
|
|
@@ -650,14 +617,13 @@ var yt = A({
|
|
|
650
617
|
}, 600);
|
|
651
618
|
}
|
|
652
619
|
};
|
|
653
|
-
function
|
|
654
|
-
return new
|
|
620
|
+
function ft() {
|
|
621
|
+
return new ct();
|
|
655
622
|
}
|
|
656
623
|
export {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
At as t
|
|
624
|
+
K as a,
|
|
625
|
+
w as i,
|
|
626
|
+
ft as n,
|
|
627
|
+
Z as r,
|
|
628
|
+
ct as t
|
|
663
629
|
};
|