@gengage/assistant-fe 0.4.5 → 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.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/api-paths-C4GDpeTf.js +1214 -0
  3. package/dist/chat/index.d.ts +1 -374
  4. package/dist/chat/runtime.d.ts +374 -0
  5. package/dist/chat-BRKK63lt.js +303 -0
  6. package/dist/chat-runtime.js +13 -0
  7. package/dist/chat.iife.js +6 -6
  8. package/dist/chat.js +11 -10
  9. package/dist/common/config-constants.d.ts +1 -0
  10. package/dist/common/config-schema.d.ts +0 -1
  11. package/dist/common/overlay.d.ts +4 -4
  12. package/dist/common-CEN5OW7E.js +491 -0
  13. package/dist/common.js +78 -76
  14. package/dist/{connection-warning-n88bjkqL.js → connection-warning-B6oIU-9s.js} +1 -1
  15. package/dist/context-VIG4SVcS.js +529 -0
  16. package/dist/index.js +70 -67
  17. package/dist/locale-CfqNifrU.js +7 -0
  18. package/dist/native-webview-DudQ7nHe.js +273 -0
  19. package/dist/native.iife.js +28 -91
  20. package/dist/native.js +1 -1
  21. package/dist/overlay-1EO41ZC7.js +212 -0
  22. package/dist/overlay.d.ts +4 -0
  23. package/dist/overlay.js +10 -0
  24. package/dist/pill-launcher-57nrdLRr.js +364 -0
  25. package/dist/qna/index.d.ts +1 -61
  26. package/dist/qna/runtime.d.ts +61 -0
  27. package/dist/qna-BNvttR6s.js +40 -0
  28. package/dist/qna-runtime.js +8 -0
  29. package/dist/qna.iife.js +4 -4
  30. package/dist/qna.js +6 -5
  31. package/dist/{simrel-K2TGFi1r.js → runtime-BdwZZIrO.js} +244 -293
  32. package/dist/{chat-B1lLKIxj.js → runtime-C0qZk0y7.js} +1643 -2297
  33. package/dist/{qna-C5Ok3wd0.js → runtime-DDu8Wk0z.js} +87 -121
  34. package/dist/schemas-CLo8wCjs.js +3207 -0
  35. package/dist/{simbut-Cb5RfaAp.js → simbut-BMWC6x_t.js} +24 -22
  36. package/dist/simbut.js +1 -1
  37. package/dist/simrel/index.d.ts +1 -59
  38. package/dist/simrel/runtime.d.ts +59 -0
  39. package/dist/simrel-ohfkluhp.js +55 -0
  40. package/dist/simrel-runtime.js +8 -0
  41. package/dist/simrel.iife.js +4 -4
  42. package/dist/simrel.js +7 -6
  43. package/dist/widget-base-TgwiA8cD.js +578 -0
  44. package/package.json +17 -1
  45. package/dist/common-C5e2gLuG.js +0 -387
  46. package/dist/locale-MM0U5eeR.js +0 -1109
  47. package/dist/native-webview-niMtkiHX.js +0 -586
  48. package/dist/schemas-JpRGzRQT.js +0 -4419
  49. /package/dist/{price-formatter-CR6VT5z4.js → price-formatter-xI3g9Cd4.js} +0 -0
package/dist/index.js CHANGED
@@ -1,76 +1,79 @@
1
- import { C as a, b as t, d as s, f as i, w as n, x as r } from "./schemas-JpRGzRQT.js";
2
- import { V as c, _ as m, b as l, d, f as g, g as p, l as u, p as f, u as S, v as C, y as h } from "./locale-MM0U5eeR.js";
3
- import { a as y, c as A, d as I, h as R, l as T, n as W, s as w, t as D, u as E } from "./chat-B1lLKIxj.js";
4
- import { t as N } from "./connection-warning-n88bjkqL.js";
5
- import { a as P, i as G, n as _, o as k, t as Q } from "./qna-C5Ok3wd0.js";
6
- import { a as L, i as x, n as B, o as M, t as F } from "./simrel-K2TGFi1r.js";
7
- import { n as H, t as K } from "./simbut-Cb5RfaAp.js";
8
- import { a as Z, c as j, d as q, f as J, h as X, i as Y, l as $, m as ee, n as ae, o as te, p as se, r as ie, s as ne, u as re } from "./native-webview-niMtkiHX.js";
9
- import { a as ce, c as me, d as le, i as de, l as ge, n as pe, o as ue, p as fe, r as Se, s as Ce, t as he, u as Ue } from "./common-C5e2gLuG.js";
1
+ import { d as a, m as t, n as i, p as r, t as s, u as n } from "./api-paths-C4GDpeTf.js";
2
+ import { c, d as m, l, u as p } from "./widget-base-TgwiA8cD.js";
3
+ import { a as g, c as u, i as f, k as S, o as C, s as U, t as h } from "./context-VIG4SVcS.js";
4
+ import { a as A, n as I, o as R, s as T, t as W } from "./runtime-C0qZk0y7.js";
5
+ import { a as E, n as w, r as v, t as N } from "./pill-launcher-57nrdLRr.js";
6
+ import { t as P } from "./connection-warning-B6oIU-9s.js";
7
+ import { a as G, i as _, n as Q, r as L, t as B } from "./runtime-DDu8Wk0z.js";
8
+ import { a as b, i as x, n as F, r as V, t as H } from "./runtime-BdwZZIrO.js";
9
+ import { n as z, t as Z } from "./simbut-BMWC6x_t.js";
10
+ import { i as q, n as J, r as X, t as Y } from "./overlay-1EO41ZC7.js";
11
+ import { a as ee, i as ae, n as te, r as ie } from "./native-webview-DudQ7nHe.js";
12
+ import { _ as se, a as ne, c as oe, d as ce, g as me, h as le, i as pe, l as de, m as ge, n as ue, o as fe, p as Se, r as Ce, s as Ue, t as he, u as ye, v as Ae, y as Ie } from "./common-CEN5OW7E.js";
10
13
  export {
11
- re as AccountRuntimeConfigSchema,
12
- q as AnalyticsAuthModeSchema,
13
- u as BASE_WIDGET_THEME,
14
- ue as DEFAULT_CUSTOMIZATION_LOCALE,
15
- d as DEFAULT_WIDGET_THEME_TOKENS,
16
- D as GengageChat,
17
- Q as GengageQNA,
18
- K as GengageSimBut,
19
- F as GengageSimRel,
20
- J as UnknownActionPolicySchema,
21
- E as VoiceInput,
22
- ae as applyNativeSession,
14
+ ge as AccountRuntimeConfigSchema,
15
+ le as AnalyticsAuthModeSchema,
16
+ c as BASE_WIDGET_THEME,
17
+ fe as DEFAULT_CUSTOMIZATION_LOCALE,
18
+ p as DEFAULT_WIDGET_THEME_TOKENS,
19
+ W as GengageChat,
20
+ B as GengageQNA,
21
+ Z as GengageSimBut,
22
+ H as GengageSimRel,
23
+ me as UnknownActionPolicySchema,
24
+ w as VoiceInput,
25
+ te as applyNativeSession,
23
26
  he as autoDetectPageContext,
24
- f as bootstrapSession,
27
+ h as bootstrapSession,
25
28
  s as buildChatEndpointUrl,
26
- te as buildOverlayIdempotencyKey,
27
- N as configureConnectionWarning,
28
- t as consumeStream,
29
- Ce as createAccountIdentity,
30
- fe as createAnalyticsClient,
31
- W as createChatWidget,
29
+ Y as buildOverlayIdempotencyKey,
30
+ P as configureConnectionWarning,
31
+ n as consumeStream,
32
+ Ue as createAccountIdentity,
33
+ Se as createAnalyticsClient,
34
+ I as createChatWidget,
32
35
  se as createDefaultAccountRuntimeConfig,
33
- me as createDefaultAnalyticsConfig,
34
- w as createDefaultChatUISpecRegistry,
35
- G as createDefaultQnaUISpecRegistry,
36
- x as createDefaultSimRelUISpecRegistry,
37
- ge as createFloatingChatConfig,
36
+ oe as createDefaultAnalyticsConfig,
37
+ A as createDefaultChatUISpecRegistry,
38
+ L as createDefaultQnaUISpecRegistry,
39
+ V as createDefaultSimRelUISpecRegistry,
40
+ de as createFloatingChatConfig,
38
41
  ie as createNativeWebViewBridge,
39
- Ue as createPdpQnaConfig,
40
- le as createPdpSimRelConfig,
41
- _ as createQNAWidget,
42
- H as createSimButWidget,
43
- B as createSimRelWidget,
44
- A as defaultChatUnknownUISpecRenderer,
45
- P as defaultQnaUnknownUISpecRenderer,
46
- L as defaultSimRelUnknownUISpecRenderer,
47
- a as defaultUnknownUISpecRenderer,
48
- ne as destroyOverlayWidgets,
49
- Y as detectNativeEnvironment,
50
- pe as detectPageType,
51
- m as dispatch,
52
- Se as extractSkuFromUrl,
53
- j as getOverlayWidgets,
54
- de as initGengageClient,
55
- Z as initNativeOverlayWidgets,
56
- $ as initOverlayWidgets,
57
- I as isVoiceInputSupported,
42
+ ye as createPdpQnaConfig,
43
+ ce as createPdpSimRelConfig,
44
+ Q as createQNAWidget,
45
+ z as createSimButWidget,
46
+ F as createSimRelWidget,
47
+ R as defaultChatUnknownUISpecRenderer,
48
+ _ as defaultQnaUnknownUISpecRenderer,
49
+ x as defaultSimRelUnknownUISpecRenderer,
50
+ r as defaultUnknownUISpecRenderer,
51
+ J as destroyOverlayWidgets,
52
+ ae as detectNativeEnvironment,
53
+ ue as detectPageType,
54
+ g as dispatch,
55
+ Ce as extractSkuFromUrl,
56
+ X as getOverlayWidgets,
57
+ pe as initGengageClient,
58
+ ee as initNativeOverlayWidgets,
59
+ q as initOverlayWidgets,
60
+ v as isVoiceInputSupported,
58
61
  C as listen,
59
- y as makePillLauncher,
62
+ N as makePillLauncher,
60
63
  i as normalizeMiddlewareUrl,
61
- ee as parseAccountRuntimeConfig,
62
- ce as preflightDiagnostics,
64
+ Ae as parseAccountRuntimeConfig,
65
+ ne as preflightDiagnostics,
63
66
  T as renderChatUISpec,
64
- k as renderQnaUISpec,
65
- M as renderSimRelUISpec,
66
- n as renderUISpecWithRegistry,
67
- R as routeStreamAction,
68
- X as safeParseAccountRuntimeConfig,
69
- r as streamPost,
70
- p as updatePageContext,
71
- c as wireGADataLayer,
72
- h as wireQNAToChat,
73
- l as wireSimilarToChat,
74
- S as withBaseTheme,
75
- g as withDefaultWidgetTheme
67
+ G as renderQnaUISpec,
68
+ b as renderSimRelUISpec,
69
+ t as renderUISpecWithRegistry,
70
+ E as routeStreamAction,
71
+ Ie as safeParseAccountRuntimeConfig,
72
+ a as streamPost,
73
+ f as updatePageContext,
74
+ S as wireGADataLayer,
75
+ U as wireQNAToChat,
76
+ u as wireSimilarToChat,
77
+ l as withBaseTheme,
78
+ m as withDefaultWidgetTheme
76
79
  };
@@ -0,0 +1,7 @@
1
+ function e(r) {
2
+ const t = r?.trim();
3
+ return t || "tr";
4
+ }
5
+ export {
6
+ e as t
7
+ };
@@ -0,0 +1,273 @@
1
+ import { i as k } from "./overlay-1EO41ZC7.js";
2
+ var _ = [
3
+ "gengage:chat:open",
4
+ "gengage:chat:close",
5
+ "gengage:chat:ready",
6
+ "gengage:chat:add-to-cart",
7
+ "gengage:qna:action",
8
+ "gengage:qna:open-chat",
9
+ "gengage:similar:product-click",
10
+ "gengage:similar:grouping-click",
11
+ "gengage:similar:products-impression",
12
+ "gengage:similar:add-to-cart",
13
+ "gengage:global:error",
14
+ "gengage:context:update"
15
+ ], S = 32, E = "#gengage-qna", w = "#gengage-simrel";
16
+ function A(n) {
17
+ let e = n;
18
+ if (typeof n == "string") {
19
+ const s = n.trim();
20
+ if (s.length === 0) return null;
21
+ if (!s.startsWith("{") && !s.startsWith("[")) return { type: s };
22
+ try {
23
+ e = JSON.parse(s);
24
+ } catch {
25
+ return null;
26
+ }
27
+ }
28
+ if (!e || typeof e != "object") return null;
29
+ const t = e, d = [
30
+ t.type,
31
+ t.command,
32
+ t.action,
33
+ t.event
34
+ ].find((s) => typeof s == "string" && s.length > 0);
35
+ if (!d) return null;
36
+ let a = t.payload;
37
+ if (a === void 0 && "data" in t && (a = t.data), d === "setSession" && a === void 0) {
38
+ const s = {};
39
+ typeof t.sessionId == "string" && (s.sessionId = t.sessionId), typeof t.userId == "string" && (s.userId = t.userId), (s.sessionId !== void 0 || s.userId !== void 0) && (a = s);
40
+ }
41
+ return a === void 0 ? { type: d } : {
42
+ type: d,
43
+ payload: a
44
+ };
45
+ }
46
+ function L(n) {
47
+ if (typeof n == "string" && n.length > 0) return { sku: n };
48
+ if (n && typeof n == "object" && "sku" in n) {
49
+ const e = n.sku;
50
+ if (typeof e == "string" && e.length > 0) {
51
+ const t = n.pageType;
52
+ return t !== void 0 ? {
53
+ sku: e,
54
+ pageType: t
55
+ } : { sku: e };
56
+ }
57
+ }
58
+ return null;
59
+ }
60
+ function b(n, e) {
61
+ return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 : n.document.querySelector(e) !== null;
62
+ }
63
+ function T(n, e, t) {
64
+ if (e instanceof HTMLElement || b(n, e) || typeof e != "string") return e;
65
+ if (e.startsWith("#")) {
66
+ const s = e.slice(1);
67
+ if (s.length > 0) {
68
+ const f = n.document.getElementById(s);
69
+ if (f) return f;
70
+ const u = n.document.createElement("div");
71
+ return u.id = s, n.document.body.appendChild(u), u;
72
+ }
73
+ }
74
+ const d = n.document.getElementById(t);
75
+ if (d) return d;
76
+ const a = n.document.createElement("div");
77
+ return a.id = t, n.document.body.appendChild(a), a;
78
+ }
79
+ function C(n, e) {
80
+ const t = n.webkit?.messageHandlers?.[e];
81
+ return t && typeof t.postMessage == "function" ? t.postMessage.bind(t) : null;
82
+ }
83
+ function y(n, e) {
84
+ const t = n[e];
85
+ return t && typeof t == "object" && typeof t.postMessage == "function" ? t : null;
86
+ }
87
+ function O(n = {}) {
88
+ const e = n.win ?? window, t = n.iosHandlerName ?? "gengage", d = n.androidInterfaceName ?? "GengageNative", a = n.reactNativeInterfaceName ?? "ReactNativeWebView";
89
+ return C(e, t) ? "ios" : y(e, d) ? "android" : y(e, a) ? "react-native" : "browser";
90
+ }
91
+ function U(n, e = {}) {
92
+ const t = e.win ?? window;
93
+ if (n.sessionId !== void 0) {
94
+ t.__gengageSessionId = n.sessionId, t.gengage || (t.gengage = {}), t.gengage.sessionId = n.sessionId;
95
+ try {
96
+ t.sessionStorage.setItem("gengage_session_id", n.sessionId);
97
+ } catch {
98
+ }
99
+ }
100
+ if (n.userId !== void 0) {
101
+ t.gengage || (t.gengage = {});
102
+ const d = t.gengage, a = d.session ?? {};
103
+ a.userId = n.userId, d.session = a;
104
+ }
105
+ }
106
+ function W(n = {}) {
107
+ const e = n.win ?? window, t = e;
108
+ if (t.gengageNative) return t.gengageNative;
109
+ const d = n.iosHandlerName ?? "gengage", a = n.androidInterfaceName ?? "GengageNative", s = n.reactNativeInterfaceName ?? "ReactNativeWebView", f = n.trackedEvents ?? [..._], u = O({
110
+ win: e,
111
+ iosHandlerName: d,
112
+ androidInterfaceName: a,
113
+ reactNativeInterfaceName: s
114
+ });
115
+ let o = e.gengage?.overlay ?? null;
116
+ const g = [], m = (r, i) => {
117
+ const l = i === void 0 ? { type: r } : {
118
+ type: r,
119
+ payload: i
120
+ };
121
+ if (u === "ios") {
122
+ C(e, d)?.(l);
123
+ return;
124
+ }
125
+ if (u === "android") {
126
+ y(e, a)?.postMessage(JSON.stringify(l));
127
+ return;
128
+ }
129
+ if (u === "react-native") {
130
+ y(e, s)?.postMessage(JSON.stringify(l));
131
+ return;
132
+ }
133
+ }, v = (r) => {
134
+ const i = r.detail;
135
+ !i || typeof i.namespace != "string" || typeof i.type != "string" || m("bridge_message", {
136
+ namespace: i.namespace,
137
+ type: i.type,
138
+ payload: i.payload
139
+ });
140
+ };
141
+ e.addEventListener("gengage:bridge:message", v);
142
+ const q = f.map((r) => {
143
+ const i = (l) => {
144
+ const c = l.detail;
145
+ m("widget_event", {
146
+ event: r,
147
+ detail: c
148
+ });
149
+ };
150
+ return e.addEventListener(r, i), {
151
+ event: r,
152
+ handler: i
153
+ };
154
+ }), p = (r) => {
155
+ g.length >= S && g.shift(), g.push(r);
156
+ }, M = () => {
157
+ if (!o || g.length === 0) return;
158
+ const r = g.splice(0, g.length);
159
+ for (const i of r) I(i);
160
+ }, I = (r) => {
161
+ const i = A(r);
162
+ if (!i || typeof i.type != "string") {
163
+ console.warn("[gengage:native-bridge] Invalid message:", r);
164
+ return;
165
+ }
166
+ const l = i.type, c = i.payload;
167
+ switch (l) {
168
+ case "openChat":
169
+ o ? o.openChat(c && typeof c == "object" ? c : c === "half" || c === "full" ? { state: c } : void 0) : p(i);
170
+ return;
171
+ case "closeChat":
172
+ o ? o.closeChat() : p(i);
173
+ return;
174
+ case "updateContext":
175
+ case "updatePageContext":
176
+ case "setPageContext":
177
+ o && c && typeof c == "object" ? o.updateContext(c) : o ? console.warn(`[gengage:native-bridge] ${l}: missing payload`) : p(i);
178
+ return;
179
+ case "updateSku": {
180
+ const h = L(c);
181
+ if (o && h) {
182
+ o.updateSku(h.sku, h.pageType);
183
+ return;
184
+ }
185
+ o ? console.warn("[gengage:native-bridge] updateSku: missing sku") : p(i);
186
+ return;
187
+ }
188
+ case "setSession":
189
+ c && typeof c == "object" && U(c, { win: e });
190
+ return;
191
+ case "destroy":
192
+ o?.destroy();
193
+ return;
194
+ default:
195
+ e.postMessage({
196
+ gengage: "native",
197
+ type: l,
198
+ payload: c
199
+ }, e.location.origin), n.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", l);
200
+ }
201
+ }, N = {
202
+ env: u,
203
+ sendToNative: m,
204
+ receive: I,
205
+ setController(r) {
206
+ o = r, M();
207
+ },
208
+ destroy() {
209
+ e.removeEventListener("gengage:bridge:message", v);
210
+ for (const r of q) e.removeEventListener(r.event, r.handler);
211
+ g.splice(0, g.length), e.gengageNative === N && delete e.gengageNative;
212
+ }
213
+ };
214
+ return t.gengageNative = N, N;
215
+ }
216
+ async function V(n) {
217
+ const { nativeBridge: e, emitReadyEvent: t = !0, ...d } = n, a = W(e), s = { ...d };
218
+ s.onAddToCart || (s.onAddToCart = (g) => {
219
+ a.sendToNative("addToCart", {
220
+ sku: g.sku,
221
+ quantity: g.quantity,
222
+ cartCode: g.cartCode
223
+ });
224
+ }), s.onProductNavigate || (s.onProductNavigate = (g, m, v) => {
225
+ a.sendToNative("productNavigate", {
226
+ url: g,
227
+ sku: m,
228
+ sessionId: v
229
+ });
230
+ });
231
+ const f = s.qna?.enabled === !0 || s.qna?.mountTarget !== void 0;
232
+ if (s.qna?.enabled !== !1)
233
+ if (f) {
234
+ const g = T(window, s.qna?.mountTarget ?? E, "gengage-qna");
235
+ s.qna = {
236
+ ...s.qna,
237
+ enabled: !0,
238
+ mountTarget: g
239
+ };
240
+ } else b(window, E) || (s.qna = { enabled: !1 });
241
+ const u = s.simrel?.enabled === !0 || s.simrel?.mountTarget !== void 0;
242
+ if (s.simrel?.enabled !== !1)
243
+ if (u) {
244
+ const g = T(window, s.simrel?.mountTarget ?? w, "gengage-simrel");
245
+ s.simrel = {
246
+ ...s.simrel,
247
+ enabled: !0,
248
+ mountTarget: g
249
+ };
250
+ } else b(window, w) || (s.simrel = { enabled: !1 });
251
+ const o = await k(s);
252
+ return a.setController(o), t && a.sendToNative("ready", {
253
+ sessionId: o.session.sessionId,
254
+ widgets: {
255
+ chat: o.chat !== null,
256
+ qna: o.qna !== null,
257
+ simrel: o.simrel !== null
258
+ }
259
+ }), {
260
+ controller: o,
261
+ bridge: a,
262
+ destroy() {
263
+ o.destroy(), a.destroy();
264
+ }
265
+ };
266
+ }
267
+ export {
268
+ V as a,
269
+ O as i,
270
+ U as n,
271
+ W as r,
272
+ _ as t
273
+ };