@gengage/assistant-fe 0.3.38 → 0.3.39
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/dist/assistant-fe.css +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +7 -2
- package/dist/chat/components/ConsultingStylePicker.d.ts +8 -0
- package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +10 -7
- package/dist/chat/index.d.ts +33 -3
- package/dist/{chat-DWbfqurG.js → chat-BdYYhBg0.js} +2315 -2137
- package/dist/chat.iife.js +20 -20
- package/dist/chat.js +1 -1
- package/dist/common/ga-datalayer.d.ts +29 -1
- package/dist/common/native-webview.d.ts +1 -1
- package/dist/common/types.d.ts +13 -1
- package/dist/{common-BnVSPZsM.js → common-DmixzWHZ.js} +2 -2
- package/dist/common.js +44 -44
- package/dist/{connection-warning-nm_yulO-.js → connection-warning-n88bjkqL.js} +5 -5
- package/dist/index.js +38 -38
- package/dist/{ga-datalayer-BUM5z5Pq.js → locale-MM0U5eeR.js} +361 -304
- package/dist/{native-webview-etMxQ2jb.js → native-webview-DkvOte_j.js} +132 -127
- package/dist/native.iife.js +23 -23
- package/dist/native.js +1 -1
- package/dist/{qna-CMjb645J.js → qna-DrlYm1d8.js} +15 -15
- package/dist/qna.iife.js +5 -5
- package/dist/qna.js +1 -1
- package/dist/{schemas-BnHn9LX7.js → schemas-DnAo0x7A.js} +1 -1
- package/dist/{simbut--wBhTxId.js → simbut-Cb5RfaAp.js} +17 -17
- package/dist/simbut.css +1 -1
- package/dist/simbut.iife.js +3 -3
- package/dist/simbut.js +1 -1
- package/dist/simrel/components/GroupTabs.d.ts +5 -0
- package/dist/simrel/index.d.ts +1 -0
- package/dist/simrel/types.d.ts +5 -0
- package/dist/simrel-BjNqBbmw.js +736 -0
- package/dist/simrel.iife.js +17 -17
- package/dist/simrel.js +1 -1
- package/package.json +1 -1
- package/dist/simrel-CSJ_9zSn.js +0 -710
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { a as k, c as h, i as D, o as f, r as m, t as A } from "./schemas-
|
|
2
|
-
import {
|
|
3
|
-
import { t as V } from "./chat-
|
|
4
|
-
import { t as $ } from "./qna-
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as
|
|
7
|
-
var b = f({ enabled: m().default(!0) }),
|
|
1
|
+
import { a as k, c as h, i as D, o as f, r as m, t as A } from "./schemas-DnAo0x7A.js";
|
|
2
|
+
import { U as H, h as Q, j, r as M, y as K } from "./locale-MM0U5eeR.js";
|
|
3
|
+
import { t as V } from "./chat-BdYYhBg0.js";
|
|
4
|
+
import { t as $ } from "./qna-DrlYm1d8.js";
|
|
5
|
+
import { t as G } from "./simrel-BjNqBbmw.js";
|
|
6
|
+
import { t as Y } from "./simbut-Cb5RfaAp.js";
|
|
7
|
+
var b = f({ enabled: m().default(!0) }), J = f({
|
|
8
8
|
chat: h().optional(),
|
|
9
9
|
qna: h().optional(),
|
|
10
10
|
simrel: h().optional(),
|
|
11
11
|
simbut: h().optional()
|
|
12
|
-
}),
|
|
12
|
+
}), X = f({}), z = A([
|
|
13
13
|
"none",
|
|
14
14
|
"x-api-key-header",
|
|
15
15
|
"bearer-header",
|
|
16
16
|
"body-api-key"
|
|
17
|
-
]),
|
|
18
|
-
mode:
|
|
17
|
+
]), Z = f({
|
|
18
|
+
mode: z.default("none"),
|
|
19
19
|
key: h().optional(),
|
|
20
20
|
headerName: h().optional(),
|
|
21
21
|
bodyField: h().default("api_key")
|
|
22
|
-
}),
|
|
22
|
+
}), ee = f({
|
|
23
23
|
enabled: m().default(!0),
|
|
24
24
|
endpoint: h().default("/analytics"),
|
|
25
|
-
auth:
|
|
25
|
+
auth: Z.default({
|
|
26
26
|
mode: "none",
|
|
27
27
|
bodyField: "api_key"
|
|
28
28
|
}),
|
|
@@ -31,17 +31,17 @@ var b = f({ enabled: m().default(!0) }), Y = f({
|
|
|
31
31
|
keepaliveFetch: m().default(!0),
|
|
32
32
|
timeoutMs: k().int().positive().default(4e3),
|
|
33
33
|
maxRetries: k().int().min(0).max(5).default(1)
|
|
34
|
-
}),
|
|
35
|
-
idempotencyKey: h().default(
|
|
34
|
+
}), R = "__gengageWidgetsInit", te = f({
|
|
35
|
+
idempotencyKey: h().default(R),
|
|
36
36
|
requireDomReady: m().default(!0)
|
|
37
|
-
}),
|
|
37
|
+
}), ie = A([
|
|
38
38
|
"log-and-ignore",
|
|
39
39
|
"throw",
|
|
40
40
|
"delegate"
|
|
41
|
-
]),
|
|
42
|
-
unknownActionPolicy:
|
|
41
|
+
]), ne = f({
|
|
42
|
+
unknownActionPolicy: ie.default("log-and-ignore"),
|
|
43
43
|
allowScriptCall: m().default(!1)
|
|
44
|
-
}),
|
|
44
|
+
}), L = f({
|
|
45
45
|
version: D("1", { error: 'version must be "1"' }),
|
|
46
46
|
accountId: h({ error: "accountId must be a non-empty string" }).min(1, { error: "accountId must be a non-empty string" }),
|
|
47
47
|
middlewareUrl: h({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }).url({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }),
|
|
@@ -52,9 +52,9 @@ var b = f({ enabled: m().default(!0) }), Y = f({
|
|
|
52
52
|
simrel: b.default({ enabled: !0 }),
|
|
53
53
|
simbut: b.default({ enabled: !1 })
|
|
54
54
|
}),
|
|
55
|
-
mounts:
|
|
56
|
-
transport:
|
|
57
|
-
analytics:
|
|
55
|
+
mounts: J.default({}),
|
|
56
|
+
transport: X.default({}),
|
|
57
|
+
analytics: ee.default({
|
|
58
58
|
enabled: !0,
|
|
59
59
|
endpoint: "/analytics",
|
|
60
60
|
auth: {
|
|
@@ -67,28 +67,28 @@ var b = f({ enabled: m().default(!0) }), Y = f({
|
|
|
67
67
|
timeoutMs: 4e3,
|
|
68
68
|
maxRetries: 1
|
|
69
69
|
}),
|
|
70
|
-
gtm:
|
|
70
|
+
gtm: te.default({
|
|
71
71
|
idempotencyKey: "__gengageWidgetsInit",
|
|
72
72
|
requireDomReady: !0
|
|
73
73
|
}),
|
|
74
|
-
actionHandling:
|
|
74
|
+
actionHandling: ne.default({
|
|
75
75
|
unknownActionPolicy: "log-and-ignore",
|
|
76
76
|
allowScriptCall: !1
|
|
77
77
|
})
|
|
78
78
|
});
|
|
79
|
-
function
|
|
79
|
+
function se(e) {
|
|
80
80
|
M("config", "parsing account runtime config", e);
|
|
81
|
-
const t =
|
|
81
|
+
const t = L.parse(e);
|
|
82
82
|
return M("config", "config resolved", {
|
|
83
83
|
accountId: t.accountId,
|
|
84
84
|
middlewareUrl: t.middlewareUrl
|
|
85
85
|
}), t;
|
|
86
86
|
}
|
|
87
87
|
function qe(e) {
|
|
88
|
-
return
|
|
88
|
+
return L.safeParse(e);
|
|
89
89
|
}
|
|
90
90
|
function Ne(e) {
|
|
91
|
-
return
|
|
91
|
+
return se({
|
|
92
92
|
version: "1",
|
|
93
93
|
accountId: e.accountId,
|
|
94
94
|
middlewareUrl: e.middlewareUrl,
|
|
@@ -101,19 +101,19 @@ function Ne(e) {
|
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
var
|
|
105
|
-
function
|
|
104
|
+
var P = `${R}_overlay_`, oe = "#gengage-qna", ae = "#gengage-simrel", re = "#gengage-simbut";
|
|
105
|
+
function S() {
|
|
106
106
|
const e = window;
|
|
107
107
|
return e.__gengageOverlayRegistry || (e.__gengageOverlayRegistry = {
|
|
108
108
|
instances: {},
|
|
109
109
|
pending: {}
|
|
110
110
|
}), e.__gengageOverlayRegistry;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function de(e) {
|
|
113
113
|
const t = { pageType: e.pageContext?.pageType ?? (e.sku !== void 0 ? "pdp" : "other") }, i = e.pageContext;
|
|
114
114
|
return i?.sku !== void 0 && (t.sku = i.sku), i?.skuList !== void 0 && (t.skuList = i.skuList), i?.price !== void 0 && (t.price = i.price), i?.categoryTree !== void 0 && (t.categoryTree = i.categoryTree), i?.url !== void 0 && (t.url = i.url), i?.extra !== void 0 && (t.extra = i.extra), e.sku !== void 0 && (t.sku = e.sku), t;
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function le(e, t) {
|
|
117
117
|
const i = {
|
|
118
118
|
...e,
|
|
119
119
|
...t,
|
|
@@ -124,12 +124,12 @@ function de(e, t) {
|
|
|
124
124
|
function I(e) {
|
|
125
125
|
return e instanceof HTMLElement || document.querySelector(e) ? e : null;
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
return e.idempotencyKey ?? `${
|
|
127
|
+
function B(e) {
|
|
128
|
+
return e.idempotencyKey ?? `${P}${e.accountId}`;
|
|
129
129
|
}
|
|
130
|
-
var
|
|
130
|
+
var ue = class {
|
|
131
131
|
constructor(e, t) {
|
|
132
|
-
this.options = e, this.onDestroy = t, this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, this._analyticsClient = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this.idempotencyKey =
|
|
132
|
+
this.options = e, this.onDestroy = t, this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, this._analyticsClient = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this.idempotencyKey = B(e), this.session = Q(e.session), this._pageContext = de(e);
|
|
133
133
|
}
|
|
134
134
|
get chat() {
|
|
135
135
|
return this._chat;
|
|
@@ -147,7 +147,7 @@ var le = class {
|
|
|
147
147
|
return this._analyticsClient;
|
|
148
148
|
}
|
|
149
149
|
async init() {
|
|
150
|
-
window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire =
|
|
150
|
+
window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire = K()), await this._syncPdpWidgets(), window.gengage.overlay = this;
|
|
151
151
|
}
|
|
152
152
|
openChat(e) {
|
|
153
153
|
this._chat?.open(e);
|
|
@@ -157,7 +157,7 @@ var le = class {
|
|
|
157
157
|
}
|
|
158
158
|
async updateContext(e) {
|
|
159
159
|
this._destroyed || await this._enqueue(async () => {
|
|
160
|
-
this._pageContext =
|
|
160
|
+
this._pageContext = le(this._pageContext, e), window.gengage || (window.gengage = {}), window.gengage.pageContext = this._pageContext, this._chat?.update(this._pageContext), this._qna?.update(this._pageContext), this._simrel?.update(this._pageContext), this._simbut?.update(this._pageContext), await this._syncPdpWidgets();
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
async updateSku(e, t = "pdp") {
|
|
@@ -195,7 +195,7 @@ var le = class {
|
|
|
195
195
|
}
|
|
196
196
|
const t = this.options.middlewareUrl;
|
|
197
197
|
if (this.options.qna?.enabled !== !1) {
|
|
198
|
-
const i = this.options.qna?.mountTarget ??
|
|
198
|
+
const i = this.options.qna?.mountTarget ?? oe, s = I(i);
|
|
199
199
|
if (s)
|
|
200
200
|
if (this._warnedQnaMountMissing = !1, this._qna)
|
|
201
201
|
this._qna.show(), this._qna.update({
|
|
@@ -222,7 +222,7 @@ var le = class {
|
|
|
222
222
|
} else
|
|
223
223
|
this._qna?.destroy(), this._qna = null;
|
|
224
224
|
if (this.options.simrel?.enabled !== !1) {
|
|
225
|
-
const i = this.options.simrel?.mountTarget ??
|
|
225
|
+
const i = this.options.simrel?.mountTarget ?? ae, s = I(i);
|
|
226
226
|
if (s)
|
|
227
227
|
if (this._warnedSimRelMountMissing = !1, this._simrel)
|
|
228
228
|
this._simrel.show(), this._simrel.update({
|
|
@@ -230,15 +230,15 @@ var le = class {
|
|
|
230
230
|
sku: e
|
|
231
231
|
});
|
|
232
232
|
else {
|
|
233
|
-
const o = new
|
|
233
|
+
const o = new G(), n = {
|
|
234
234
|
accountId: this.options.accountId,
|
|
235
235
|
middlewareUrl: t,
|
|
236
236
|
session: this.session,
|
|
237
237
|
sku: e,
|
|
238
238
|
mountTarget: s
|
|
239
239
|
};
|
|
240
|
-
this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.pricing !== void 0 && (n.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (n.discountType = this.options.simrel.discountType), this.options.simrel?.renderCardElement !== void 0 && (n.renderCardElement = this.options.simrel.renderCardElement), this.options.simrel?.renderer !== void 0 && (n.renderer = this.options.simrel.renderer), this.options.onAddToCart !== void 0 && (n.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? n.onProductNavigate = this.options.onProductNavigate : n.onProductNavigate = (d,
|
|
241
|
-
H(d) && (this._chat?.saveSession(a ?? this.session.sessionId,
|
|
240
|
+
this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.pricing !== void 0 && (n.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (n.discountType = this.options.simrel.discountType), this.options.simrel?.renderCardElement !== void 0 && (n.renderCardElement = this.options.simrel.renderCardElement), this.options.simrel?.renderer !== void 0 && (n.renderer = this.options.simrel.renderer), this.options.onAddToCart !== void 0 && (n.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? n.onProductNavigate = this.options.onProductNavigate : n.onProductNavigate = (d, l, a) => {
|
|
241
|
+
H(d) && (this._chat?.saveSession(a ?? this.session.sessionId, l), window.location.href = d);
|
|
242
242
|
}, await o.init(n), this._simrel = o;
|
|
243
243
|
}
|
|
244
244
|
else
|
|
@@ -246,7 +246,7 @@ var le = class {
|
|
|
246
246
|
} else
|
|
247
247
|
this._simrel?.destroy(), this._simrel = null;
|
|
248
248
|
if (this.options.simbut && this.options.simbut.enabled !== !1) {
|
|
249
|
-
const i = this.options.simbut.mountTarget ??
|
|
249
|
+
const i = this.options.simbut.mountTarget ?? re, s = I(i), o = this._chat ?? this.options.simbut.onFindSimilar;
|
|
250
250
|
if (s && o)
|
|
251
251
|
if (this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this._simbut)
|
|
252
252
|
this._simbut.show(), this._simbut.setChat(this._chat), this._simbut.update({
|
|
@@ -254,7 +254,7 @@ var le = class {
|
|
|
254
254
|
sku: e
|
|
255
255
|
});
|
|
256
256
|
else {
|
|
257
|
-
const n = new
|
|
257
|
+
const n = new Y(), d = {
|
|
258
258
|
accountId: this.options.accountId,
|
|
259
259
|
middlewareUrl: t,
|
|
260
260
|
session: this.session,
|
|
@@ -278,29 +278,32 @@ var le = class {
|
|
|
278
278
|
}), t;
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
|
-
async function
|
|
282
|
-
const t =
|
|
281
|
+
async function ce(e) {
|
|
282
|
+
const t = B(e), i = S(), s = i.instances[t];
|
|
283
283
|
if (s) return s;
|
|
284
284
|
const o = i.pending[t];
|
|
285
285
|
if (o) return o;
|
|
286
|
-
const n = new
|
|
287
|
-
const
|
|
288
|
-
delete
|
|
289
|
-
}), d = n.init().then(() => (i.instances[t] = n, delete i.pending[t], n)).catch((
|
|
290
|
-
throw delete i.pending[t],
|
|
286
|
+
const n = new ue(e, () => {
|
|
287
|
+
const l = S();
|
|
288
|
+
delete l.instances[t], delete l.pending[t];
|
|
289
|
+
}), d = n.init().then(() => (i.instances[t] = n, delete i.pending[t], n)).catch((l) => {
|
|
290
|
+
throw delete i.pending[t], j({
|
|
291
|
+
reason: "overlay_init_failed",
|
|
292
|
+
message: l instanceof Error ? l.message : String(l)
|
|
293
|
+
}), l;
|
|
291
294
|
});
|
|
292
295
|
return i.pending[t] = d, d;
|
|
293
296
|
}
|
|
294
|
-
function
|
|
295
|
-
return
|
|
296
|
-
}
|
|
297
|
-
function Se(e) {
|
|
298
|
-
ce(e)?.destroy();
|
|
297
|
+
function ge(e) {
|
|
298
|
+
return S().instances[e] ?? null;
|
|
299
299
|
}
|
|
300
300
|
function ke(e) {
|
|
301
|
-
|
|
301
|
+
ge(e)?.destroy();
|
|
302
|
+
}
|
|
303
|
+
function Me(e) {
|
|
304
|
+
return `${P}${e}`;
|
|
302
305
|
}
|
|
303
|
-
var
|
|
306
|
+
var he = [
|
|
304
307
|
"gengage:chat:open",
|
|
305
308
|
"gengage:chat:close",
|
|
306
309
|
"gengage:chat:ready",
|
|
@@ -308,11 +311,13 @@ var ge = [
|
|
|
308
311
|
"gengage:qna:action",
|
|
309
312
|
"gengage:qna:open-chat",
|
|
310
313
|
"gengage:similar:product-click",
|
|
314
|
+
"gengage:similar:grouping-click",
|
|
315
|
+
"gengage:similar:products-impression",
|
|
311
316
|
"gengage:similar:add-to-cart",
|
|
312
317
|
"gengage:global:error",
|
|
313
318
|
"gengage:context:update"
|
|
314
|
-
],
|
|
315
|
-
function
|
|
319
|
+
], pe = 32, x = "#gengage-qna", U = "#gengage-simrel";
|
|
320
|
+
function fe(e) {
|
|
316
321
|
let t = e;
|
|
317
322
|
if (typeof e == "string") {
|
|
318
323
|
const n = e.trim();
|
|
@@ -342,7 +347,7 @@ function pe(e) {
|
|
|
342
347
|
payload: o
|
|
343
348
|
};
|
|
344
349
|
}
|
|
345
|
-
function
|
|
350
|
+
function me(e) {
|
|
346
351
|
if (typeof e == "string" && e.length > 0) return { sku: e };
|
|
347
352
|
if (e && typeof e == "object" && "sku" in e) {
|
|
348
353
|
const t = e.sku;
|
|
@@ -356,18 +361,18 @@ function fe(e) {
|
|
|
356
361
|
}
|
|
357
362
|
return null;
|
|
358
363
|
}
|
|
359
|
-
function
|
|
364
|
+
function q(e, t) {
|
|
360
365
|
return t instanceof HTMLElement ? !0 : typeof t != "string" ? !1 : e.document.querySelector(t) !== null;
|
|
361
366
|
}
|
|
362
367
|
function E(e, t, i) {
|
|
363
|
-
if (t instanceof HTMLElement ||
|
|
368
|
+
if (t instanceof HTMLElement || q(e, t) || typeof t != "string") return t;
|
|
364
369
|
if (t.startsWith("#")) {
|
|
365
370
|
const n = t.slice(1);
|
|
366
371
|
if (n.length > 0) {
|
|
367
372
|
const d = e.document.getElementById(n);
|
|
368
373
|
if (d) return d;
|
|
369
|
-
const
|
|
370
|
-
return
|
|
374
|
+
const l = e.document.createElement("div");
|
|
375
|
+
return l.id = n, e.document.body.appendChild(l), l;
|
|
371
376
|
}
|
|
372
377
|
}
|
|
373
378
|
const s = e.document.getElementById(i);
|
|
@@ -383,11 +388,11 @@ function w(e, t) {
|
|
|
383
388
|
const i = e[t];
|
|
384
389
|
return i && typeof i == "object" && typeof i.postMessage == "function" ? i : null;
|
|
385
390
|
}
|
|
386
|
-
function
|
|
391
|
+
function ve(e = {}) {
|
|
387
392
|
const t = e.win ?? window, i = e.iosHandlerName ?? "gengage", s = e.androidInterfaceName ?? "GengageNative", o = e.reactNativeInterfaceName ?? "ReactNativeWebView";
|
|
388
393
|
return O(t, i) ? "ios" : w(t, s) ? "android" : w(t, o) ? "react-native" : "browser";
|
|
389
394
|
}
|
|
390
|
-
function
|
|
395
|
+
function ye(e, t = {}) {
|
|
391
396
|
const i = t.win ?? window;
|
|
392
397
|
if (e.sessionId !== void 0) {
|
|
393
398
|
i.__gengageSessionId = e.sessionId, i.gengage || (i.gengage = {}), i.gengage.sessionId = e.sessionId;
|
|
@@ -402,35 +407,35 @@ function ve(e, t = {}) {
|
|
|
402
407
|
o.userId = e.userId, s.session = o;
|
|
403
408
|
}
|
|
404
409
|
}
|
|
405
|
-
function
|
|
410
|
+
function _e(e = {}) {
|
|
406
411
|
const t = e.win ?? window, i = t;
|
|
407
412
|
if (i.gengageNative) return i.gengageNative;
|
|
408
|
-
const s = e.iosHandlerName ?? "gengage", o = e.androidInterfaceName ?? "GengageNative", n = e.reactNativeInterfaceName ?? "ReactNativeWebView", d = e.trackedEvents ?? [...
|
|
413
|
+
const s = e.iosHandlerName ?? "gengage", o = e.androidInterfaceName ?? "GengageNative", n = e.reactNativeInterfaceName ?? "ReactNativeWebView", d = e.trackedEvents ?? [...he], l = ve({
|
|
409
414
|
win: t,
|
|
410
415
|
iosHandlerName: s,
|
|
411
416
|
androidInterfaceName: o,
|
|
412
417
|
reactNativeInterfaceName: n
|
|
413
418
|
});
|
|
414
419
|
let a = t.gengage?.overlay ?? null;
|
|
415
|
-
const
|
|
416
|
-
const p = r === void 0 ? { type:
|
|
417
|
-
type:
|
|
420
|
+
const c = [], v = (u, r) => {
|
|
421
|
+
const p = r === void 0 ? { type: u } : {
|
|
422
|
+
type: u,
|
|
418
423
|
payload: r
|
|
419
424
|
};
|
|
420
|
-
if (
|
|
425
|
+
if (l === "ios") {
|
|
421
426
|
O(t, s)?.(p);
|
|
422
427
|
return;
|
|
423
428
|
}
|
|
424
|
-
if (
|
|
429
|
+
if (l === "android") {
|
|
425
430
|
w(t, o)?.postMessage(JSON.stringify(p));
|
|
426
431
|
return;
|
|
427
432
|
}
|
|
428
|
-
if (
|
|
433
|
+
if (l === "react-native") {
|
|
429
434
|
w(t, n)?.postMessage(JSON.stringify(p));
|
|
430
435
|
return;
|
|
431
436
|
}
|
|
432
|
-
}, y = (
|
|
433
|
-
const r =
|
|
437
|
+
}, y = (u) => {
|
|
438
|
+
const r = u.detail;
|
|
434
439
|
!r || typeof r.namespace != "string" || typeof r.type != "string" || v("bridge_message", {
|
|
435
440
|
namespace: r.namespace,
|
|
436
441
|
type: r.type,
|
|
@@ -438,28 +443,28 @@ function ye(e = {}) {
|
|
|
438
443
|
});
|
|
439
444
|
};
|
|
440
445
|
t.addEventListener("gengage:bridge:message", y);
|
|
441
|
-
const F = d.map((
|
|
446
|
+
const F = d.map((u) => {
|
|
442
447
|
const r = (p) => {
|
|
443
448
|
const g = p.detail;
|
|
444
449
|
v("widget_event", {
|
|
445
|
-
event:
|
|
450
|
+
event: u,
|
|
446
451
|
detail: g
|
|
447
452
|
});
|
|
448
453
|
};
|
|
449
|
-
return t.addEventListener(
|
|
450
|
-
event:
|
|
454
|
+
return t.addEventListener(u, r), {
|
|
455
|
+
event: u,
|
|
451
456
|
handler: r
|
|
452
457
|
};
|
|
453
|
-
}), _ = (
|
|
454
|
-
|
|
458
|
+
}), _ = (u) => {
|
|
459
|
+
c.length >= pe && c.shift(), c.push(u);
|
|
455
460
|
}, W = () => {
|
|
456
|
-
if (!a ||
|
|
457
|
-
const
|
|
458
|
-
for (const r of
|
|
459
|
-
},
|
|
460
|
-
const r =
|
|
461
|
+
if (!a || c.length === 0) return;
|
|
462
|
+
const u = c.splice(0, c.length);
|
|
463
|
+
for (const r of u) N(r);
|
|
464
|
+
}, N = (u) => {
|
|
465
|
+
const r = fe(u);
|
|
461
466
|
if (!r || typeof r.type != "string") {
|
|
462
|
-
console.warn("[gengage:native-bridge] Invalid message:",
|
|
467
|
+
console.warn("[gengage:native-bridge] Invalid message:", u);
|
|
463
468
|
return;
|
|
464
469
|
}
|
|
465
470
|
const p = r.type, g = r.payload;
|
|
@@ -476,7 +481,7 @@ function ye(e = {}) {
|
|
|
476
481
|
a && g && typeof g == "object" ? a.updateContext(g) : a ? console.warn(`[gengage:native-bridge] ${p}: missing payload`) : _(r);
|
|
477
482
|
return;
|
|
478
483
|
case "updateSku": {
|
|
479
|
-
const T =
|
|
484
|
+
const T = me(g);
|
|
480
485
|
if (a && T) {
|
|
481
486
|
a.updateSku(T.sku, T.pageType);
|
|
482
487
|
return;
|
|
@@ -485,7 +490,7 @@ function ye(e = {}) {
|
|
|
485
490
|
return;
|
|
486
491
|
}
|
|
487
492
|
case "setSession":
|
|
488
|
-
g && typeof g == "object" &&
|
|
493
|
+
g && typeof g == "object" && ye(g, { win: t });
|
|
489
494
|
return;
|
|
490
495
|
case "destroy":
|
|
491
496
|
a?.destroy();
|
|
@@ -498,31 +503,31 @@ function ye(e = {}) {
|
|
|
498
503
|
}, t.location.origin), e.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", p);
|
|
499
504
|
}
|
|
500
505
|
}, C = {
|
|
501
|
-
env:
|
|
506
|
+
env: l,
|
|
502
507
|
sendToNative: v,
|
|
503
|
-
receive:
|
|
504
|
-
setController(
|
|
505
|
-
a =
|
|
508
|
+
receive: N,
|
|
509
|
+
setController(u) {
|
|
510
|
+
a = u, W();
|
|
506
511
|
},
|
|
507
512
|
destroy() {
|
|
508
513
|
t.removeEventListener("gengage:bridge:message", y);
|
|
509
|
-
for (const
|
|
510
|
-
|
|
514
|
+
for (const u of F) t.removeEventListener(u.event, u.handler);
|
|
515
|
+
c.splice(0, c.length), t.gengageNative === C && delete t.gengageNative;
|
|
511
516
|
}
|
|
512
517
|
};
|
|
513
518
|
return i.gengageNative = C, C;
|
|
514
519
|
}
|
|
515
|
-
async function
|
|
516
|
-
const { nativeBridge: t, emitReadyEvent: i = !0, ...s } = e, o =
|
|
517
|
-
n.onAddToCart || (n.onAddToCart = (
|
|
520
|
+
async function xe(e) {
|
|
521
|
+
const { nativeBridge: t, emitReadyEvent: i = !0, ...s } = e, o = _e(t), n = { ...s };
|
|
522
|
+
n.onAddToCart || (n.onAddToCart = (c) => {
|
|
518
523
|
o.sendToNative("addToCart", {
|
|
519
|
-
sku:
|
|
520
|
-
quantity:
|
|
521
|
-
cartCode:
|
|
524
|
+
sku: c.sku,
|
|
525
|
+
quantity: c.quantity,
|
|
526
|
+
cartCode: c.cartCode
|
|
522
527
|
});
|
|
523
|
-
}), n.onProductNavigate || (n.onProductNavigate = (
|
|
528
|
+
}), n.onProductNavigate || (n.onProductNavigate = (c, v, y) => {
|
|
524
529
|
o.sendToNative("productNavigate", {
|
|
525
|
-
url:
|
|
530
|
+
url: c,
|
|
526
531
|
sku: v,
|
|
527
532
|
sessionId: y
|
|
528
533
|
});
|
|
@@ -530,24 +535,24 @@ async function Me(e) {
|
|
|
530
535
|
const d = n.qna?.enabled === !0 || n.qna?.mountTarget !== void 0;
|
|
531
536
|
if (n.qna?.enabled !== !1)
|
|
532
537
|
if (d) {
|
|
533
|
-
const
|
|
538
|
+
const c = E(window, n.qna?.mountTarget ?? x, "gengage-qna");
|
|
534
539
|
n.qna = {
|
|
535
540
|
...n.qna,
|
|
536
541
|
enabled: !0,
|
|
537
|
-
mountTarget:
|
|
542
|
+
mountTarget: c
|
|
538
543
|
};
|
|
539
|
-
} else
|
|
540
|
-
const
|
|
544
|
+
} else q(window, x) || (n.qna = { enabled: !1 });
|
|
545
|
+
const l = n.simrel?.enabled === !0 || n.simrel?.mountTarget !== void 0;
|
|
541
546
|
if (n.simrel?.enabled !== !1)
|
|
542
|
-
if (
|
|
543
|
-
const
|
|
547
|
+
if (l) {
|
|
548
|
+
const c = E(window, n.simrel?.mountTarget ?? U, "gengage-simrel");
|
|
544
549
|
n.simrel = {
|
|
545
550
|
...n.simrel,
|
|
546
551
|
enabled: !0,
|
|
547
|
-
mountTarget:
|
|
552
|
+
mountTarget: c
|
|
548
553
|
};
|
|
549
|
-
} else
|
|
550
|
-
const a = await
|
|
554
|
+
} else q(window, U) || (n.simrel = { enabled: !1 });
|
|
555
|
+
const a = await ce(n);
|
|
551
556
|
return o.setController(a), i && o.sendToNative("ready", {
|
|
552
557
|
sessionId: a.session.sessionId,
|
|
553
558
|
widgets: {
|
|
@@ -564,19 +569,19 @@ async function Me(e) {
|
|
|
564
569
|
};
|
|
565
570
|
}
|
|
566
571
|
export {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
572
|
+
xe as a,
|
|
573
|
+
ge as c,
|
|
574
|
+
z as d,
|
|
575
|
+
ie as f,
|
|
571
576
|
qe as h,
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
+
ve as i,
|
|
578
|
+
ce as l,
|
|
579
|
+
se as m,
|
|
580
|
+
ye as n,
|
|
581
|
+
Me as o,
|
|
577
582
|
Ne as p,
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
583
|
+
_e as r,
|
|
584
|
+
ke as s,
|
|
585
|
+
he as t,
|
|
586
|
+
L as u
|
|
582
587
|
};
|