@gengage/assistant-fe 0.4.5 → 0.4.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.
Files changed (63) hide show
  1. package/README.md +22 -2
  2. package/dist/api-paths-DR5bPNhi.js +1213 -0
  3. package/dist/assistant-fe.css +1 -1
  4. package/dist/chat/index.d.ts +1 -374
  5. package/dist/chat/runtime.d.ts +374 -0
  6. package/dist/chat-BRKK63lt.js +303 -0
  7. package/dist/chat-runtime.js +13 -0
  8. package/dist/chat.iife.js +8 -8
  9. package/dist/chat.js +11 -10
  10. package/dist/common/config-constants.d.ts +1 -0
  11. package/dist/common/config-schema.d.ts +0 -1
  12. package/dist/common/overlay.d.ts +8 -4
  13. package/dist/common/protocol-adapter.d.ts +1 -1
  14. package/dist/common/safe-html.d.ts +1 -1
  15. package/dist/common-c-awF96O.js +491 -0
  16. package/dist/common.js +78 -76
  17. package/dist/{connection-warning-n88bjkqL.js → connection-warning-ecZqpczd.js} +1 -1
  18. package/dist/context-DGz5F81j.js +532 -0
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +73 -68
  21. package/dist/locale-CfqNifrU.js +7 -0
  22. package/dist/native-webview-C_PmKnzm.js +273 -0
  23. package/dist/native.iife.js +28 -91
  24. package/dist/native.js +1 -1
  25. package/dist/overlay-DJ1ZRMfI.js +212 -0
  26. package/dist/overlay.d.ts +4 -0
  27. package/dist/overlay.js +10 -0
  28. package/dist/pill-launcher-DSEeJT9h.js +364 -0
  29. package/dist/qna/index.d.ts +1 -61
  30. package/dist/qna/runtime.d.ts +62 -0
  31. package/dist/qna/types.d.ts +14 -0
  32. package/dist/qna-BNvttR6s.js +40 -0
  33. package/dist/qna-runtime.js +8 -0
  34. package/dist/qna.css +1 -1
  35. package/dist/qna.iife.js +21 -21
  36. package/dist/qna.js +6 -5
  37. package/dist/{simrel-K2TGFi1r.js → runtime-BsZZ8zTg.js} +245 -293
  38. package/dist/{chat-B1lLKIxj.js → runtime-DNbjpTCh.js} +1643 -2297
  39. package/dist/runtime-SKDvc0Xc.js +660 -0
  40. package/dist/schemas-CLo8wCjs.js +3207 -0
  41. package/dist/simbut/index.d.ts +3 -1
  42. package/dist/simbut/types.d.ts +11 -0
  43. package/dist/simbut-Bw3vBFtW.js +109 -0
  44. package/dist/simbut.css +1 -1
  45. package/dist/simbut.iife.js +10 -10
  46. package/dist/simbut.js +1 -1
  47. package/dist/simrel/index.d.ts +3 -59
  48. package/dist/simrel/renderers/default.d.ts +40 -0
  49. package/dist/simrel/runtime.d.ts +59 -0
  50. package/dist/simrel-DJZ983BF.js +513 -0
  51. package/dist/simrel-runtime.js +8 -0
  52. package/dist/simrel.css +3 -0
  53. package/dist/simrel.iife.js +38 -38
  54. package/dist/simrel.js +8 -6
  55. package/dist/widget-base-2-B1Ch5I.js +578 -0
  56. package/package.json +22 -1
  57. package/dist/common-C5e2gLuG.js +0 -387
  58. package/dist/locale-MM0U5eeR.js +0 -1109
  59. package/dist/native-webview-niMtkiHX.js +0 -586
  60. package/dist/qna-C5Ok3wd0.js +0 -663
  61. package/dist/schemas-JpRGzRQT.js +0 -4419
  62. package/dist/simbut-Cb5RfaAp.js +0 -79
  63. /package/dist/{price-formatter-CR6VT5z4.js → price-formatter-xI3g9Cd4.js} +0 -0
package/dist/common.js CHANGED
@@ -1,86 +1,88 @@
1
- import { C as a, S as t, b as s, d as r, f as n, g as i, h as o, m as c, p as m, v as l, w as g, x as d, y as u } from "./schemas-JpRGzRQT.js";
2
- import { $ as E, G as S, J as h, K as v, Q as y, V as f, X as C, Y as A, Z as T, _ as w, a as U, b as W, c as I, d as P, et as b, f as D, g as R, h as k, i as G, it as O, l as N, m as _, n as x, nt as L, p as M, q as z, rt as B, s as H, tt as K, u as F, v as V, y as Q } from "./locale-MM0U5eeR.js";
3
- import { a as Z, d as J, h as X, u as Y } from "./chat-B1lLKIxj.js";
4
- import { n as j, t as ee } from "./connection-warning-n88bjkqL.js";
5
- import { a as te, c as se, d as re, f as ne, h as ie, i as oe, l as ce, m as me, n as le, o as ge, p as de, r as ue, s as pe, u as Ee } from "./native-webview-niMtkiHX.js";
6
- import { a as he, c as ve, d as ye, f as fe, i as Ce, l as Ae, n as Te, o as we, p as Ue, r as We, s as Ie, t as Pe, u as be } from "./common-C5e2gLuG.js";
1
+ import { a, c as t, d as s, f as r, i, l as n, m as o, n as c, o as m, p as l, r as g, t as d, u as p } from "./api-paths-DR5bPNhi.js";
2
+ import { C as E, S, _ as h, b as v, c as f, d as y, f as C, g as A, h as T, i as w, l as U, m as W, o as I, p as P, r as k, s as D, t as R, u as b, v as G, w as N, x as O, y as _ } from "./widget-base-2-B1Ch5I.js";
3
+ import { N as L, a as M, c as z, i as B, k as H, n as F, o as K, r as V, s as Q, t as q } from "./context-DGz5F81j.js";
4
+ import { a as j, n as J, r as X, t as Y } from "./pill-launcher-DSEeJT9h.js";
5
+ import { n as ee, t as ae } from "./connection-warning-ecZqpczd.js";
6
+ import { i as se, n as re, r as ie, t as ne } from "./overlay-DJ1ZRMfI.js";
7
+ import { a as ce, i as me, n as le, r as ge } from "./native-webview-C_PmKnzm.js";
8
+ import { _ as pe, a as ue, c as Ee, d as Se, f as he, g as ve, h as fe, i as ye, l as Ce, m as Ae, n as Te, o as we, p as Ue, r as We, s as Ie, t as Pe, u as ke, v as De, y as Re } from "./common-c-awF96O.js";
7
9
  export {
8
- Ee as AccountRuntimeConfigSchema,
9
- re as AnalyticsAuthModeSchema,
10
- fe as AnalyticsClient,
11
- N as BASE_WIDGET_THEME,
12
- x as BaseWidget,
10
+ Ae as AccountRuntimeConfigSchema,
11
+ fe as AnalyticsAuthModeSchema,
12
+ he as AnalyticsClient,
13
+ f as BASE_WIDGET_THEME,
14
+ R as BaseWidget,
13
15
  we as DEFAULT_CUSTOMIZATION_LOCALE,
14
- P as DEFAULT_WIDGET_THEME_TOKENS,
15
- ne as UnknownActionPolicySchema,
16
- Y as VoiceInput,
17
- m as adaptBackendEvent,
16
+ b as DEFAULT_WIDGET_THEME_TOKENS,
17
+ ve as UnknownActionPolicySchema,
18
+ J as VoiceInput,
19
+ g as adaptBackendEvent,
18
20
  le as applyNativeSession,
19
21
  Pe as autoDetectPageContext,
20
- v as basketAddEvent,
21
- M as bootstrapSession,
22
- r as buildChatEndpointUrl,
23
- ge as buildOverlayIdempotencyKey,
24
- z as chatHistorySnapshotEvent,
25
- h as checkoutCompleteEvent,
26
- A as checkoutStartEvent,
27
- ee as configureConnectionWarning,
28
- s as consumeStream,
22
+ C as basketAddEvent,
23
+ q as bootstrapSession,
24
+ d as buildChatEndpointUrl,
25
+ ne as buildOverlayIdempotencyKey,
26
+ P as chatHistorySnapshotEvent,
27
+ W as checkoutCompleteEvent,
28
+ T as checkoutStartEvent,
29
+ ae as configureConnectionWarning,
30
+ p as consumeStream,
29
31
  Ie as createAccountIdentity,
30
32
  Ue as createAnalyticsClient,
31
- de as createDefaultAccountRuntimeConfig,
32
- ve as createDefaultAnalyticsConfig,
33
- Ae as createFloatingChatConfig,
34
- ue as createNativeWebViewBridge,
35
- be as createPdpQnaConfig,
36
- ye as createPdpSimRelConfig,
37
- a as defaultUnknownUISpecRenderer,
38
- pe as destroyOverlayWidgets,
39
- oe as detectNativeEnvironment,
33
+ pe as createDefaultAccountRuntimeConfig,
34
+ Ee as createDefaultAnalyticsConfig,
35
+ Ce as createFloatingChatConfig,
36
+ ge as createNativeWebViewBridge,
37
+ ke as createPdpQnaConfig,
38
+ Se as createPdpSimRelConfig,
39
+ l as defaultUnknownUISpecRenderer,
40
+ re as destroyOverlayWidgets,
41
+ me as detectNativeEnvironment,
40
42
  Te as detectPageType,
41
- G as dismissGlobalErrorToast,
42
- w as dispatch,
43
+ k as dismissGlobalErrorToast,
44
+ M as dispatch,
43
45
  We as extractSkuFromUrl,
44
- U as getGlobalErrorMessage,
45
- se as getOverlayWidgets,
46
- l as getSuggestedSearchKeywords,
47
- u as getSuggestedSearchKeywordsText,
48
- _ as getWindowPageContext,
49
- Ce as initGengageClient,
50
- te as initNativeOverlayWidgets,
51
- ce as initOverlayWidgets,
52
- J as isVoiceInputSupported,
53
- V as listen,
54
- C as llmUsageEvent,
55
- Z as makePillLauncher,
56
- t as mergeUISpecRegistry,
57
- T as meteringIncrementEvent,
58
- y as meteringSummaryEvent,
59
- n as normalizeMiddlewareUrl,
60
- c as normalizeProductGroupingsResponse,
61
- o as normalizeSimilarProductsResponse,
62
- me as parseAccountRuntimeConfig,
63
- he as preflightDiagnostics,
64
- i as productToNormalized,
65
- H as registerGlobalErrorToastListener,
66
- g as renderUISpecWithRegistry,
67
- k as resolveSession,
68
- X as routeStreamAction,
69
- ie as safeParseAccountRuntimeConfig,
70
- S as sanitizeHtml,
71
- I as showGlobalErrorToast,
72
- E as streamChunkEvent,
73
- b as streamDoneEvent,
74
- K as streamErrorEvent,
75
- d as streamPost,
76
- L as streamStartEvent,
77
- B as streamUiSpecEvent,
78
- j as trackConnectionWarningRequest,
79
- R as updatePageContext,
80
- O as widgetHistorySnapshotEvent,
81
- f as wireGADataLayer,
46
+ w as getGlobalErrorMessage,
47
+ ie as getOverlayWidgets,
48
+ t as getSuggestedSearchKeywords,
49
+ n as getSuggestedSearchKeywordsText,
50
+ F as getWindowPageContext,
51
+ ye as initGengageClient,
52
+ ce as initNativeOverlayWidgets,
53
+ se as initOverlayWidgets,
54
+ X as isVoiceInputSupported,
55
+ K as listen,
56
+ A as llmUsageEvent,
57
+ Y as makePillLauncher,
58
+ r as mergeUISpecRegistry,
59
+ h as meteringIncrementEvent,
60
+ G as meteringSummaryEvent,
61
+ c as normalizeMiddlewareUrl,
62
+ i as normalizeProductGroupingsResponse,
63
+ a as normalizeSimilarProductsResponse,
64
+ De as parseAccountRuntimeConfig,
65
+ ue as preflightDiagnostics,
66
+ m as productToNormalized,
67
+ I as registerGlobalErrorToastListener,
68
+ o as renderUISpecWithRegistry,
69
+ V as resolveSession,
70
+ j as routeStreamAction,
71
+ Re as safeParseAccountRuntimeConfig,
72
+ L as sanitizeHtml,
73
+ D as showGlobalErrorToast,
74
+ _ as streamChunkEvent,
75
+ v as streamDoneEvent,
76
+ O as streamErrorEvent,
77
+ s as streamPost,
78
+ S as streamStartEvent,
79
+ E as streamUiSpecEvent,
80
+ ee as trackConnectionWarningRequest,
81
+ B as updatePageContext,
82
+ N as widgetHistorySnapshotEvent,
83
+ H as wireGADataLayer,
82
84
  Q as wireQNAToChat,
83
- W as wireSimilarToChat,
84
- F as withBaseTheme,
85
- D as withDefaultWidgetTheme
85
+ z as wireSimilarToChat,
86
+ U as withBaseTheme,
87
+ y as withDefaultWidgetTheme
86
88
  };
@@ -1,4 +1,4 @@
1
- import { c as d, i as y } from "./locale-MM0U5eeR.js";
1
+ import { r as y, s as d } from "./widget-base-2-B1Ch5I.js";
2
2
  var h = 8e3, m = 5e3, g = "https://www.google.com/favicon.ico";
3
3
  function b(e) {
4
4
  e.probeUrl && (g = e.probeUrl);
@@ -0,0 +1,532 @@
1
+ var T = /* @__PURE__ */ new Set([
2
+ "p",
3
+ "br",
4
+ "a",
5
+ "strong",
6
+ "b",
7
+ "em",
8
+ "i",
9
+ "u",
10
+ "ul",
11
+ "ol",
12
+ "li",
13
+ "h1",
14
+ "h2",
15
+ "h3",
16
+ "h4",
17
+ "h5",
18
+ "h6",
19
+ "span",
20
+ "div",
21
+ "table",
22
+ "thead",
23
+ "tbody",
24
+ "tr",
25
+ "th",
26
+ "td",
27
+ "hr",
28
+ "code",
29
+ "pre",
30
+ "blockquote",
31
+ "img",
32
+ "sup",
33
+ "sub"
34
+ ]), E = /* @__PURE__ */ new Set([
35
+ "script",
36
+ "iframe",
37
+ "object",
38
+ "embed",
39
+ "form",
40
+ "input",
41
+ "textarea",
42
+ "select",
43
+ "button",
44
+ "style",
45
+ "link",
46
+ "meta",
47
+ "template",
48
+ "noscript"
49
+ ]), b = {
50
+ "*": /* @__PURE__ */ new Set(["class"]),
51
+ a: /* @__PURE__ */ new Set([
52
+ "href",
53
+ "target",
54
+ "rel"
55
+ ]),
56
+ img: /* @__PURE__ */ new Set([
57
+ "src",
58
+ "alt",
59
+ "width",
60
+ "height"
61
+ ]),
62
+ div: /* @__PURE__ */ new Set(["style"]),
63
+ span: /* @__PURE__ */ new Set(["style"]),
64
+ p: /* @__PURE__ */ new Set(["style"])
65
+ };
66
+ function I(e) {
67
+ return /^\s*javascript\s*:/i.test(e);
68
+ }
69
+ var O = /* @__PURE__ */ new Set([
70
+ "color",
71
+ "background-color",
72
+ "font-size",
73
+ "font-weight",
74
+ "font-style",
75
+ "font-family",
76
+ "text-align",
77
+ "text-decoration",
78
+ "line-height",
79
+ "letter-spacing",
80
+ "margin",
81
+ "margin-top",
82
+ "margin-right",
83
+ "margin-bottom",
84
+ "margin-left",
85
+ "padding",
86
+ "padding-top",
87
+ "padding-right",
88
+ "padding-bottom",
89
+ "padding-left",
90
+ "border",
91
+ "border-top",
92
+ "border-right",
93
+ "border-bottom",
94
+ "border-left",
95
+ "border-radius",
96
+ "border-color",
97
+ "border-width",
98
+ "border-style",
99
+ "width",
100
+ "max-width",
101
+ "min-width",
102
+ "height",
103
+ "max-height",
104
+ "min-height",
105
+ "display",
106
+ "vertical-align",
107
+ "white-space",
108
+ "word-break",
109
+ "overflow",
110
+ "opacity",
111
+ "visibility",
112
+ "list-style",
113
+ "list-style-type",
114
+ "text-transform",
115
+ "text-indent",
116
+ "text-overflow",
117
+ "box-sizing",
118
+ "flex",
119
+ "flex-direction",
120
+ "flex-wrap",
121
+ "justify-content",
122
+ "align-items",
123
+ "gap"
124
+ ]), P = /url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;
125
+ function N(e) {
126
+ const t = [];
127
+ for (const n of e.split(";")) {
128
+ const i = n.trim();
129
+ if (!i) continue;
130
+ const a = i.indexOf(":");
131
+ if (a === -1) continue;
132
+ const s = i.slice(0, a).trim().toLowerCase(), u = i.slice(a + 1).trim();
133
+ O.has(s) && (P.test(u) || t.push(i));
134
+ }
135
+ return t.join("; ");
136
+ }
137
+ function w(e, t) {
138
+ if (e.nodeType === Node.TEXT_NODE) return;
139
+ if (e.nodeType !== Node.ELEMENT_NODE) {
140
+ e.parentNode?.removeChild(e);
141
+ return;
142
+ }
143
+ const n = e, i = n.tagName.toLowerCase();
144
+ if (E.has(i)) {
145
+ n.parentNode?.removeChild(n);
146
+ return;
147
+ }
148
+ if (!T.has(i)) {
149
+ const o = Array.from(n.childNodes);
150
+ for (const c of o) t.insertBefore(c, n);
151
+ t.removeChild(n);
152
+ for (const c of o) w(c, t);
153
+ return;
154
+ }
155
+ const a = b["*"] ?? /* @__PURE__ */ new Set(), s = b[i] ?? /* @__PURE__ */ new Set(), u = Array.from(n.attributes);
156
+ for (const o of u) {
157
+ const c = o.name.toLowerCase();
158
+ if (!a.has(c) && !s.has(c)) {
159
+ n.removeAttribute(o.name);
160
+ continue;
161
+ }
162
+ if (I(o.value)) {
163
+ n.removeAttribute(o.name);
164
+ continue;
165
+ }
166
+ if (c === "style") {
167
+ const d = N(o.value);
168
+ d ? n.setAttribute("style", d) : n.removeAttribute("style");
169
+ continue;
170
+ }
171
+ }
172
+ if (i === "a") {
173
+ const o = n.getAttribute("href");
174
+ if (o !== null) {
175
+ const c = o.trim().toLowerCase();
176
+ !c.startsWith("http://") && !c.startsWith("https://") && !c.startsWith("mailto:") && n.removeAttribute("href");
177
+ }
178
+ n.setAttribute("target", "_blank"), n.setAttribute("rel", "noopener noreferrer");
179
+ }
180
+ if (i === "img") {
181
+ const o = n.getAttribute("src");
182
+ o !== null && (o.trim().toLowerCase().startsWith("https://") || n.removeAttribute("src"));
183
+ }
184
+ const p = Array.from(n.childNodes);
185
+ for (const o of p) w(o, n);
186
+ }
187
+ var k = ["http:", "https:"];
188
+ function J(e) {
189
+ const t = e.trim();
190
+ if (!t) return !1;
191
+ if (t.startsWith("/") && !t.startsWith("//")) return !0;
192
+ try {
193
+ return k.includes(new URL(t).protocol);
194
+ } catch {
195
+ return !1;
196
+ }
197
+ }
198
+ function S(e) {
199
+ if (e.startsWith("/") && !e.startsWith("//")) return !0;
200
+ try {
201
+ const t = new URL(e);
202
+ return k.includes(t.protocol);
203
+ } catch {
204
+ return !1;
205
+ }
206
+ }
207
+ function X(e, t, n) {
208
+ (t === "href" || t === "src") && !S(n) || e.setAttribute(t, n);
209
+ }
210
+ function K(e) {
211
+ if (!e) return "";
212
+ const t = new DOMParser().parseFromString(e, "text/html").body, n = Array.from(t.childNodes);
213
+ for (const i of n) w(i, t);
214
+ return t.innerHTML;
215
+ }
216
+ function W() {
217
+ return typeof window < "u" && Array.isArray(window.dataLayer);
218
+ }
219
+ function r(e, t) {
220
+ const n = {
221
+ event: e,
222
+ ...t
223
+ };
224
+ W() && window.dataLayer.push(n);
225
+ }
226
+ function D(e) {
227
+ r("gengage-on-init", { gengage_widget: e });
228
+ }
229
+ function v(e) {
230
+ r("gengage-show", { gengage_widget: e });
231
+ }
232
+ function U(e) {
233
+ r("gengage-hide", { gengage_widget: e });
234
+ }
235
+ function z(e, t) {
236
+ r("gengage-suggested-question", {
237
+ gengage_question_title: e,
238
+ gengage_action_type: t
239
+ });
240
+ }
241
+ function Y(e) {
242
+ r("gengage-find-similars", { gengage_sku: e });
243
+ }
244
+ function Z(e) {
245
+ r("gengage-compare-preselection", { gengage_sku: e });
246
+ }
247
+ function $(e) {
248
+ r("gengage-compare-selected", {
249
+ gengage_skus: e,
250
+ gengage_product_count: e.length
251
+ });
252
+ }
253
+ function ee() {
254
+ r("gengage-compare-clear");
255
+ }
256
+ function te(e) {
257
+ r("gengage-compare-received", { gengage_product_count: e });
258
+ }
259
+ function ne(e) {
260
+ r("gengage-like-product", { gengage_sku: e });
261
+ }
262
+ function ie() {
263
+ r("gengage-like-list");
264
+ }
265
+ function re(e, t) {
266
+ r("gengage-search", {
267
+ gengage_search_query: e,
268
+ gengage_result_count: t
269
+ });
270
+ }
271
+ function oe(e, t) {
272
+ r("gengage-product-detail", {
273
+ gengage_sku: e,
274
+ gengage_product_name: t
275
+ });
276
+ }
277
+ function M(e, t) {
278
+ r("gengage-similar-product-click", {
279
+ gengage_sku: e,
280
+ ...t?.url !== void 0 ? { gengage_product_url: t.url } : {},
281
+ ...t?.name !== void 0 ? { gengage_product_name: t.name } : {},
282
+ ...t?.session_id !== void 0 ? { gengage_session_id: t.session_id } : {}
283
+ });
284
+ }
285
+ function R(e, t) {
286
+ r("gengage-similar-grouping-click", {
287
+ gengage_grouping_label: e,
288
+ gengage_grouping_index: t
289
+ });
290
+ }
291
+ function j(e) {
292
+ r("gengage-similar-products-impression", {
293
+ gengage_source_sku: e.source_sku,
294
+ gengage_product_count: e.product_count,
295
+ gengage_grouped: e.grouped,
296
+ ...e.session_id !== void 0 ? { gengage_session_id: e.session_id } : {}
297
+ });
298
+ }
299
+ function ae(e) {
300
+ r("gengage-compare-product", {
301
+ gengage_skus: e,
302
+ gengage_product_count: e.length
303
+ });
304
+ }
305
+ function se() {
306
+ r("gengage-chatbot-maximized");
307
+ }
308
+ function q(e) {
309
+ r("gengage-interface-not-ready", {
310
+ ...e?.reason !== void 0 ? { gengage_reason: e.reason } : {},
311
+ ...e?.attempts !== void 0 ? { gengage_attempts: e.attempts } : {},
312
+ ...e?.message !== void 0 ? { gengage_message: e.message } : {}
313
+ });
314
+ }
315
+ function G(e, t) {
316
+ r("gengage-cart-add", {
317
+ gengage_sku: e,
318
+ gengage_quantity: t
319
+ });
320
+ }
321
+ function ge() {
322
+ r("gengage-message-sent");
323
+ }
324
+ function ce() {
325
+ r("gengage-message-received");
326
+ }
327
+ function le() {
328
+ r("gengage-conversation-start");
329
+ }
330
+ function F() {
331
+ r("gengage-voice-input");
332
+ }
333
+ function Q(e, t) {
334
+ r("gengage-error", {
335
+ gengage_widget: e,
336
+ gengage_error: t
337
+ });
338
+ }
339
+ var f = null;
340
+ function ue() {
341
+ if (typeof window > "u") return () => {
342
+ };
343
+ if (f) return f;
344
+ const e = [];
345
+ function t(n, i) {
346
+ const a = (s) => i(s.detail);
347
+ window.addEventListener(n, a), e.push(() => window.removeEventListener(n, a));
348
+ }
349
+ return t("gengage:chat:open", () => v("chat")), t("gengage:chat:close", () => U("chat")), t("gengage:chat:ready", () => D("chat")), t("gengage:similar:add-to-cart", ({ sku: n, quantity: i }) => {
350
+ G(n, i);
351
+ }), t("gengage:similar:product-click", ({ sku: n, url: i, sessionId: a, productName: s }) => {
352
+ const u = {
353
+ url: i,
354
+ session_id: a
355
+ };
356
+ s !== void 0 && s !== "" && (u.name = s), M(n, u);
357
+ }), t("gengage:similar:grouping-click", ({ grouping_label: n, grouping_index: i }) => {
358
+ R(n, i);
359
+ }), t("gengage:similar:products-impression", ({ source_sku: n, product_count: i, grouped: a, sessionId: s }) => {
360
+ j({
361
+ source_sku: n,
362
+ product_count: i,
363
+ grouped: a,
364
+ session_id: s
365
+ });
366
+ }), t("gengage:qna:action", ({ title: n, type: i }) => {
367
+ z(n, i);
368
+ }), t("gengage:chat:voice", () => F()), t("gengage:qna:open-chat", () => v("chat")), t("gengage:global:error", ({ source: n, message: i }) => {
369
+ Q(n, i);
370
+ }), f = () => {
371
+ for (const n of e) n();
372
+ e.length = 0, f = null;
373
+ }, f;
374
+ }
375
+ function de(e, t) {
376
+ window.dispatchEvent(new CustomEvent(e, {
377
+ detail: t,
378
+ bubbles: !1
379
+ }));
380
+ }
381
+ function _(e, t) {
382
+ const n = (i) => {
383
+ t(i.detail);
384
+ };
385
+ return window.addEventListener(e, n), () => window.removeEventListener(e, n);
386
+ }
387
+ function H(e) {
388
+ if (e.type !== "user_message" && e.type !== "inputText") return null;
389
+ if (typeof e.payload == "string" && e.payload.trim().length > 0) return e.payload.trim();
390
+ if (typeof e.payload == "object" && e.payload !== null) {
391
+ const t = e.payload;
392
+ if (typeof t.text == "string") {
393
+ const n = t.text.trim();
394
+ if (n.length > 0) return n;
395
+ }
396
+ }
397
+ return typeof e.title == "string" && e.title.trim().length > 0 ? e.title.trim() : null;
398
+ }
399
+ function V(e) {
400
+ if (e.type !== "inputText" && e.type !== "user_message") return e;
401
+ const t = typeof e.payload == "string" ? { text: e.payload.trim() } : e.payload != null && typeof e.payload == "object" && !Array.isArray(e.payload) ? { ...e.payload } : {};
402
+ if (typeof t.text != "string" || !t.text.trim()) {
403
+ const n = e.title?.trim();
404
+ n && (t.text = n);
405
+ }
406
+ return "is_launcher" in t || (t.is_launcher = 1), "is_suggested_text" in t || (t.is_suggested_text = 1), {
407
+ ...e,
408
+ payload: t
409
+ };
410
+ }
411
+ function fe(e) {
412
+ let t = !1;
413
+ const n = [];
414
+ let i = 0, a = null, s = 0;
415
+ const u = 500, p = 10;
416
+ function o() {
417
+ return window.gengage?.chat ?? null;
418
+ }
419
+ function c() {
420
+ t || (console.warn("[gengage] QNA tried to open chat, but chat widget is not initialized. Ensure GengageChat is initialized before calling wireQNAToChat()."), t = !0), e?.onChatUnavailable?.();
421
+ }
422
+ function d(g, l) {
423
+ if (g.openWithAction) {
424
+ const L = l.type === "inputText" || l.type === "user_message" ? V(l) : l;
425
+ g.openWithAction(L);
426
+ return;
427
+ }
428
+ const h = H(l);
429
+ if (h && g.sendMessage) {
430
+ g.open?.(), g.sendMessage(h);
431
+ return;
432
+ }
433
+ }
434
+ function m() {
435
+ a !== null && (window.clearInterval(a), a = null);
436
+ }
437
+ function A() {
438
+ const g = o();
439
+ if (!g) return !1;
440
+ if (i > 0 && (g.open?.(), i = 0), n.length > 0) {
441
+ const l = n.splice(0, n.length);
442
+ for (const h of l) d(g, h);
443
+ }
444
+ return m(), !0;
445
+ }
446
+ function y() {
447
+ a === null && (s = 0, a = window.setInterval(() => {
448
+ A() || (s += 1, s >= p && ((n.length > 0 || i > 0) && q({
449
+ reason: "chat_unavailable_after_poll",
450
+ attempts: p
451
+ }), n.length = 0, i = 0, m()));
452
+ }, u));
453
+ }
454
+ const C = _("gengage:qna:action", (g) => {
455
+ const l = o();
456
+ if (l) {
457
+ d(l, g);
458
+ return;
459
+ }
460
+ c(), n.length >= 20 && n.shift(), n.push(g), y();
461
+ }), x = _("gengage:qna:open-chat", () => {
462
+ const g = o();
463
+ if (g) {
464
+ g.open?.();
465
+ return;
466
+ }
467
+ c(), i += 1, y();
468
+ });
469
+ return () => {
470
+ C(), x(), n.length = 0, i = 0, m();
471
+ };
472
+ }
473
+ function pe() {
474
+ return _("gengage:similar:product-click", ({ sku: e, url: t, sessionId: n }) => {
475
+ n && window.gengage?.chat?.saveSession(n, e), S(t) && (window.location.href = t);
476
+ });
477
+ }
478
+ function B() {
479
+ const e = window.__gengageSessionId ?? sessionStorage.getItem("gengage_session_id") ?? null ?? crypto.randomUUID();
480
+ return window.__gengageSessionId = e, sessionStorage.setItem("gengage_session_id", e), window.gengage || (window.gengage = {}), window.gengage.sessionId = e, e;
481
+ }
482
+ function he() {
483
+ return window.gengage?.pageContext ?? null;
484
+ }
485
+ function me(e) {
486
+ window.gengage || (window.gengage = {}), window.gengage.pageContext = {
487
+ pageType: "other",
488
+ ...window.gengage.pageContext,
489
+ ...e
490
+ }, window.dispatchEvent(new CustomEvent("gengage:context:update", { detail: e }));
491
+ }
492
+ function we(e) {
493
+ return {
494
+ sessionId: e?.sessionId ?? B(),
495
+ ...e
496
+ };
497
+ }
498
+ export {
499
+ J as A,
500
+ ge as C,
501
+ z as D,
502
+ v as E,
503
+ X as M,
504
+ K as N,
505
+ F as O,
506
+ ce as S,
507
+ re as T,
508
+ Y as _,
509
+ de as a,
510
+ ie as b,
511
+ pe as c,
512
+ ee as d,
513
+ Z as f,
514
+ le as g,
515
+ $ as h,
516
+ me as i,
517
+ S as j,
518
+ ue as k,
519
+ G as l,
520
+ te as m,
521
+ he as n,
522
+ _ as o,
523
+ ae as p,
524
+ we as r,
525
+ fe as s,
526
+ B as t,
527
+ se as u,
528
+ D as v,
529
+ oe as w,
530
+ ne as x,
531
+ q as y
532
+ };