@gengage/assistant-fe 0.1.8 → 0.2.0

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 (138) hide show
  1. package/README.md +79 -286
  2. package/dist/assistant-fe.css +1 -1
  3. package/dist/chat/api.d.ts +1 -12
  4. package/dist/chat/api.d.ts.map +1 -1
  5. package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
  6. package/dist/chat/components/ChatDrawer.d.ts +15 -1
  7. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  8. package/dist/chat/components/ChoicePrompter.d.ts +1 -0
  9. package/dist/chat/components/ChoicePrompter.d.ts.map +1 -1
  10. package/dist/chat/components/ComparisonTable.d.ts +5 -3
  11. package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
  12. package/dist/chat/components/PanelTopBar.d.ts +2 -0
  13. package/dist/chat/components/PanelTopBar.d.ts.map +1 -1
  14. package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -1
  15. package/dist/chat/components/ReviewHighlights.d.ts +3 -0
  16. package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
  17. package/dist/chat/components/renderUISpec.d.ts +0 -5
  18. package/dist/chat/components/renderUISpec.d.ts.map +1 -1
  19. package/dist/chat/index.d.ts +18 -9
  20. package/dist/chat/index.d.ts.map +1 -1
  21. package/dist/chat/locales/en.d.ts.map +1 -1
  22. package/dist/chat/locales/tr.d.ts.map +1 -1
  23. package/dist/chat/session-persistence.d.ts +3 -0
  24. package/dist/chat/session-persistence.d.ts.map +1 -1
  25. package/dist/chat/types.d.ts +23 -25
  26. package/dist/chat/types.d.ts.map +1 -1
  27. package/dist/chat.cjs +1 -1
  28. package/dist/chat.iife.js +22 -22
  29. package/dist/chat.iife.js.map +1 -1
  30. package/dist/chat.js +8 -9
  31. package/dist/chat.js.map +1 -1
  32. package/dist/common/action-router.d.ts.map +1 -1
  33. package/dist/common/activity-tracker.d.ts +1 -1
  34. package/dist/common/analytics.d.ts +12 -8
  35. package/dist/common/analytics.d.ts.map +1 -1
  36. package/dist/common/api-paths.d.ts +2 -5
  37. package/dist/common/api-paths.d.ts.map +1 -1
  38. package/dist/common/config-schema.d.ts.map +1 -1
  39. package/dist/common/debug.d.ts +14 -0
  40. package/dist/common/debug.d.ts.map +1 -0
  41. package/dist/common/events.d.ts.map +1 -1
  42. package/dist/common/index.d.ts +2 -2
  43. package/dist/common/index.d.ts.map +1 -1
  44. package/dist/common/native-webview.d.ts.map +1 -1
  45. package/dist/common/overlay.d.ts +19 -0
  46. package/dist/common/overlay.d.ts.map +1 -1
  47. package/dist/common/product-utils.d.ts +10 -0
  48. package/dist/common/product-utils.d.ts.map +1 -1
  49. package/dist/common/{v1-protocol-adapter.d.ts → protocol-adapter.d.ts} +2 -2
  50. package/dist/common/protocol-adapter.d.ts.map +1 -0
  51. package/dist/common/quantity-stepper.d.ts +10 -10
  52. package/dist/common/quantity-stepper.d.ts.map +1 -1
  53. package/dist/common/safe-html.d.ts.map +1 -1
  54. package/dist/common/streaming.d.ts.map +1 -1
  55. package/dist/common/tts-player.d.ts +2 -0
  56. package/dist/common/tts-player.d.ts.map +1 -1
  57. package/dist/common/types.d.ts +1 -1
  58. package/dist/common/voice-input.d.ts +1 -0
  59. package/dist/common/voice-input.d.ts.map +1 -1
  60. package/dist/common/widget-base.d.ts.map +1 -1
  61. package/dist/common.cjs +1 -1
  62. package/dist/common.cjs.map +1 -1
  63. package/dist/common.js +173 -172
  64. package/dist/common.js.map +1 -1
  65. package/dist/index-BA7N_XOO.cjs +2 -0
  66. package/dist/index-BA7N_XOO.cjs.map +1 -0
  67. package/dist/{index-CcOJTzYu.js → index-C6KDzSjm.js} +155 -159
  68. package/dist/index-C6KDzSjm.js.map +1 -0
  69. package/dist/index-RmQRBt6w.js +4449 -0
  70. package/dist/index-RmQRBt6w.js.map +1 -0
  71. package/dist/index-VgLdYuZV.cjs +13 -0
  72. package/dist/index-VgLdYuZV.cjs.map +1 -0
  73. package/dist/index.cjs +1 -1
  74. package/dist/index.js +16 -16
  75. package/dist/native.cjs +1 -1
  76. package/dist/native.iife.js +23 -23
  77. package/dist/native.iife.js.map +1 -1
  78. package/dist/native.js +1 -1
  79. package/dist/qna/index.d.ts +19 -0
  80. package/dist/qna/index.d.ts.map +1 -1
  81. package/dist/qna/types.d.ts +2 -2
  82. package/dist/qna/types.d.ts.map +1 -1
  83. package/dist/qna.cjs +1 -1
  84. package/dist/qna.cjs.map +1 -1
  85. package/dist/qna.css +1 -1
  86. package/dist/qna.iife.js +7 -7
  87. package/dist/qna.iife.js.map +1 -1
  88. package/dist/qna.js +14 -14
  89. package/dist/qna.js.map +1 -1
  90. package/dist/quantity-stepper-BKtPQUR1.js +78 -0
  91. package/dist/quantity-stepper-BKtPQUR1.js.map +1 -0
  92. package/dist/quantity-stepper-DU6va4sS.cjs +2 -0
  93. package/dist/quantity-stepper-DU6va4sS.cjs.map +1 -0
  94. package/dist/{schemas-yF4IOEUi.js → schemas-BAEbjFPE.js} +1181 -957
  95. package/dist/schemas-BAEbjFPE.js.map +1 -0
  96. package/dist/schemas-DIyHm5pa.cjs +86 -0
  97. package/dist/schemas-DIyHm5pa.cjs.map +1 -0
  98. package/dist/simrel/api.d.ts +1 -1
  99. package/dist/simrel/api.d.ts.map +1 -1
  100. package/dist/simrel/components/GroupTabs.d.ts +1 -1
  101. package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
  102. package/dist/simrel/components/ProductCard.d.ts +1 -1
  103. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  104. package/dist/simrel/components/ProductGrid.d.ts +1 -1
  105. package/dist/simrel/components/ProductGrid.d.ts.map +1 -1
  106. package/dist/simrel/index.d.ts +20 -1
  107. package/dist/simrel/index.d.ts.map +1 -1
  108. package/dist/simrel/locales/en.d.ts.map +1 -1
  109. package/dist/simrel/locales/tr.d.ts.map +1 -1
  110. package/dist/simrel/types.d.ts +2 -0
  111. package/dist/simrel/types.d.ts.map +1 -1
  112. package/dist/simrel.cjs +1 -1
  113. package/dist/simrel.cjs.map +1 -1
  114. package/dist/simrel.css +1 -1
  115. package/dist/simrel.iife.js +11 -11
  116. package/dist/simrel.iife.js.map +1 -1
  117. package/dist/simrel.js +281 -267
  118. package/dist/simrel.js.map +1 -1
  119. package/package.json +1 -1
  120. package/dist/chat/components/ProactivePopup.d.ts +0 -20
  121. package/dist/chat/components/ProactivePopup.d.ts.map +0 -1
  122. package/dist/chat/heartbeat.d.ts +0 -71
  123. package/dist/chat/heartbeat.d.ts.map +0 -1
  124. package/dist/common/v1-protocol-adapter.d.ts.map +0 -1
  125. package/dist/index-BqIzV4ni.cjs +0 -2
  126. package/dist/index-BqIzV4ni.cjs.map +0 -1
  127. package/dist/index-CcOJTzYu.js.map +0 -1
  128. package/dist/index-DZ3Mi5xF.cjs +0 -13
  129. package/dist/index-DZ3Mi5xF.cjs.map +0 -1
  130. package/dist/index-FnP8WtfG.js +0 -4571
  131. package/dist/index-FnP8WtfG.js.map +0 -1
  132. package/dist/quantity-stepper-B8kX8GbN.js +0 -209
  133. package/dist/quantity-stepper-B8kX8GbN.js.map +0 -1
  134. package/dist/quantity-stepper-UbAp53Ow.cjs +0 -2
  135. package/dist/quantity-stepper-UbAp53Ow.cjs.map +0 -1
  136. package/dist/schemas-DHzfUzwA.cjs +0 -86
  137. package/dist/schemas-DHzfUzwA.cjs.map +0 -1
  138. package/dist/schemas-yF4IOEUi.js.map +0 -1
@@ -1,46 +1,46 @@
1
- import { G as Q } from "./index-FnP8WtfG.js";
2
- import { GengageQNA as H } from "./qna.js";
3
- import { GengageSimRel as V } from "./simrel.js";
4
- import { o as p, s as h, U as j, _ as E, d as y, v as q, V as K, W as G } from "./schemas-yF4IOEUi.js";
5
- const b = p({
1
+ import { G as F } from "./index-RmQRBt6w.js";
2
+ import { GengageQNA as Q } from "./qna.js";
3
+ import { GengageSimRel as H } from "./simrel.js";
4
+ import { o as p, s as h, Y as j, _ as U, D as M, d as y, y as S, Z as K, $ as V, E as $ } from "./schemas-BAEbjFPE.js";
5
+ const C = p({
6
6
  enabled: y().default(!0)
7
- }), $ = p({
7
+ }), G = p({
8
8
  chat: h().optional(),
9
9
  qna: h().optional(),
10
10
  simrel: h().optional()
11
- }), Y = p({}), J = E(["none", "x-api-key-header", "bearer-header", "body-api-key"]), X = p({
11
+ }), Y = p({}), J = U(["none", "x-api-key-header", "bearer-header", "body-api-key"]), X = p({
12
12
  mode: J.default("none"),
13
13
  key: h().optional(),
14
14
  headerName: h().optional(),
15
15
  bodyField: h().default("api_key")
16
- }), z = p({
16
+ }), Z = p({
17
17
  enabled: y().default(!0),
18
18
  endpoint: h().default("/analytics"),
19
19
  auth: X.default({ mode: "none", bodyField: "api_key" }),
20
20
  fireAndForget: y().default(!0),
21
21
  useBeacon: y().default(!0),
22
22
  keepaliveFetch: y().default(!0),
23
- timeoutMs: q().int().positive().default(4e3),
24
- maxRetries: q().int().min(0).max(5).default(1)
25
- }), x = "__gengageWidgetsInit", Z = p({
26
- idempotencyKey: h().default(x),
23
+ timeoutMs: S().int().positive().default(4e3),
24
+ maxRetries: S().int().min(0).max(5).default(1)
25
+ }), R = "__gengageWidgetsInit", z = p({
26
+ idempotencyKey: h().default(R),
27
27
  requireDomReady: y().default(!0)
28
- }), ee = E(["log-and-ignore", "throw", "delegate"]), te = p({
28
+ }), ee = U(["log-and-ignore", "throw", "delegate"]), te = p({
29
29
  unknownActionPolicy: ee.default("log-and-ignore"),
30
30
  allowScriptCall: y().default(!1)
31
- }), R = p({
32
- version: j("1"),
33
- accountId: h().min(1),
34
- middlewareUrl: h().url(),
31
+ }), P = p({
32
+ version: j("1", { error: 'version must be "1"' }),
33
+ accountId: h({ error: "accountId must be a non-empty string" }).min(1, { error: "accountId must be a non-empty string" }),
34
+ 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")' }),
35
35
  locale: h().optional(),
36
36
  widgets: p({
37
- chat: b.default({ enabled: !0 }),
38
- qna: b.default({ enabled: !0 }),
39
- simrel: b.default({ enabled: !0 })
37
+ chat: C.default({ enabled: !0 }),
38
+ qna: C.default({ enabled: !0 }),
39
+ simrel: C.default({ enabled: !0 })
40
40
  }),
41
- mounts: $.default({}),
41
+ mounts: G.default({}),
42
42
  transport: Y.default({}),
43
- analytics: z.default({
43
+ analytics: Z.default({
44
44
  enabled: !0,
45
45
  endpoint: "/analytics",
46
46
  auth: { mode: "none", bodyField: "api_key" },
@@ -50,7 +50,7 @@ const b = p({
50
50
  timeoutMs: 4e3,
51
51
  maxRetries: 1
52
52
  }),
53
- gtm: Z.default({
53
+ gtm: z.default({
54
54
  idempotencyKey: "__gengageWidgetsInit",
55
55
  requireDomReady: !0
56
56
  }),
@@ -59,18 +59,20 @@ const b = p({
59
59
  allowScriptCall: !1
60
60
  })
61
61
  });
62
- function ne(t) {
63
- return R.parse(t);
62
+ function ne(n) {
63
+ M("config", "parsing account runtime config", n);
64
+ const e = P.parse(n);
65
+ return M("config", "config resolved", { accountId: e.accountId, middlewareUrl: e.middlewareUrl }), e;
64
66
  }
65
- function Te(t) {
66
- return R.safeParse(t);
67
+ function be(n) {
68
+ return P.safeParse(n);
67
69
  }
68
- function be(t) {
70
+ function Te(n) {
69
71
  return ne({
70
72
  version: "1",
71
- accountId: t.accountId,
72
- middlewareUrl: t.middlewareUrl,
73
- locale: t.locale,
73
+ accountId: n.accountId,
74
+ middlewareUrl: n.middlewareUrl,
75
+ locale: n.locale,
74
76
  widgets: {
75
77
  chat: { enabled: !0 },
76
78
  qna: { enabled: !0 },
@@ -78,37 +80,37 @@ function be(t) {
78
80
  }
79
81
  });
80
82
  }
81
- const U = `${x}_overlay_`, ie = "#gengage-qna", se = "#gengage-simrel";
82
- function C() {
83
- const t = window;
84
- return t.__gengageOverlayRegistry || (t.__gengageOverlayRegistry = {
83
+ const W = `${R}_overlay_`, ie = "#gengage-qna", se = "#gengage-simrel";
84
+ function I() {
85
+ const n = window;
86
+ return n.__gengageOverlayRegistry || (n.__gengageOverlayRegistry = {
85
87
  instances: {},
86
88
  pending: {}
87
- }), t.__gengageOverlayRegistry;
89
+ }), n.__gengageOverlayRegistry;
88
90
  }
89
- function oe(t) {
91
+ function oe(n) {
90
92
  const e = {
91
- pageType: t.pageContext?.pageType ?? (t.sku !== void 0 ? "pdp" : "other")
92
- }, n = t.pageContext;
93
- return n?.sku !== void 0 && (e.sku = n.sku), n?.price !== void 0 && (e.price = n.price), n?.categoryTree !== void 0 && (e.categoryTree = n.categoryTree), n?.url !== void 0 && (e.url = n.url), n?.extra !== void 0 && (e.extra = n.extra), t.sku !== void 0 && (e.sku = t.sku), e;
93
+ pageType: n.pageContext?.pageType ?? (n.sku !== void 0 ? "pdp" : "other")
94
+ }, t = n.pageContext;
95
+ return t?.sku !== void 0 && (e.sku = t.sku), t?.price !== void 0 && (e.price = t.price), t?.categoryTree !== void 0 && (e.categoryTree = t.categoryTree), t?.url !== void 0 && (e.url = t.url), t?.extra !== void 0 && (e.extra = t.extra), n.sku !== void 0 && (e.sku = n.sku), e;
94
96
  }
95
- function ae(t, e) {
96
- const n = {
97
- ...t,
97
+ function ae(n, e) {
98
+ const t = {
99
+ ...n,
98
100
  ...e,
99
- pageType: e.pageType ?? t.pageType
101
+ pageType: e.pageType ?? n.pageType
100
102
  };
101
- return e.sku === void 0 && t.sku !== void 0 && (n.sku = t.sku), n;
103
+ return e.sku === void 0 && n.sku !== void 0 && (t.sku = n.sku), t;
102
104
  }
103
- function M(t) {
104
- return t instanceof HTMLElement || document.querySelector(t) ? t : null;
105
+ function k(n) {
106
+ return n instanceof HTMLElement || document.querySelector(n) ? n : null;
105
107
  }
106
- function P(t) {
107
- return t.idempotencyKey ?? `${U}${t.accountId}`;
108
+ function L(n) {
109
+ return n.idempotencyKey ?? `${W}${n.accountId}`;
108
110
  }
109
111
  class re {
110
- constructor(e, n) {
111
- this.options = e, this.onDestroy = n, this._chat = null, this._qna = null, this._simrel = null, this._analyticsClient = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this.idempotencyKey = P(e), this.session = K(e.session), this._pageContext = oe(e);
112
+ constructor(e, t) {
113
+ this.options = e, this.onDestroy = t, this._chat = null, this._qna = null, this._simrel = null, this._analyticsClient = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this.idempotencyKey = L(e), this.session = K(e.session), this._pageContext = oe(e);
112
114
  }
113
115
  get chat() {
114
116
  return this._chat;
@@ -123,7 +125,7 @@ class re {
123
125
  return this._analyticsClient;
124
126
  }
125
127
  async init() {
126
- window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire = G()), await this._syncPdpWidgets(), window.gengage.overlay = this;
128
+ window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire = V()), await this._syncPdpWidgets(), window.gengage.overlay = this;
127
129
  }
128
130
  openChat(e) {
129
131
  this._chat?.open(e);
@@ -136,22 +138,22 @@ class re {
136
138
  this._pageContext = ae(this._pageContext, e), window.gengage || (window.gengage = {}), window.gengage.pageContext = this._pageContext, this._chat?.update(e), this._qna?.update(e), this._simrel?.update(e), await this._syncPdpWidgets();
137
139
  });
138
140
  }
139
- async updateSku(e, n = "pdp") {
140
- await this.updateContext({ sku: e, pageType: n });
141
+ async updateSku(e, t = "pdp") {
142
+ await this.updateContext({ sku: e, pageType: t });
141
143
  }
142
144
  destroy() {
143
145
  this._destroyed || (this._destroyed = !0, this._offQnaWire?.(), this._offQnaWire = null, this._chat?.destroy(), this._qna?.destroy(), this._simrel?.destroy(), this._chat = null, this._qna = null, this._simrel = null, window.gengage?.overlay === this && delete window.gengage.overlay, this.onDestroy());
144
146
  }
145
147
  async _initChat() {
146
148
  if (this.options.chat?.enabled === !1) return;
147
- const e = this.options.middlewareUrl, n = {
149
+ const e = this.options.middlewareUrl, t = {
148
150
  accountId: this.options.accountId,
149
151
  middlewareUrl: e,
150
152
  session: this.session,
151
153
  pageContext: this._pageContext,
152
154
  variant: this.options.chat?.variant ?? "floating"
153
155
  };
154
- this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.locale !== void 0 && (n.locale = this.options.locale), this.options.pricing !== void 0 && (n.pricing = this.options.pricing), this.options.chat?.mountTarget !== void 0 && (n.mountTarget = this.options.chat.mountTarget), this.options.chat?.launcherSvg !== void 0 && (n.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.headerTitle !== void 0 && (n.headerTitle = this.options.chat.headerTitle), this.options.chat?.headerAvatarUrl !== void 0 && (n.headerAvatarUrl = this.options.chat.headerAvatarUrl), this.options.chat?.headerBadge !== void 0 && (n.headerBadge = this.options.chat.headerBadge), this.options.chat?.headerCartUrl !== void 0 && (n.headerCartUrl = this.options.chat.headerCartUrl), this.options.chat?.headerFavoritesToggle !== void 0 && (n.headerFavoritesToggle = this.options.chat.headerFavoritesToggle), this.options.chat?.hideMobileLauncher !== void 0 && (n.hideMobileLauncher = this.options.chat.hideMobileLauncher), this.options.chat?.mobileBreakpoint !== void 0 && (n.mobileBreakpoint = this.options.chat.mobileBreakpoint), this.options.chat?.mobileInitialState !== void 0 && (n.mobileInitialState = this.options.chat.mobileInitialState), this.options.chat?.i18n !== void 0 && (n.i18n = this.options.chat.i18n), this.options.chat?.actionHandling !== void 0 && (n.actionHandling = this.options.chat.actionHandling), this.options.onScriptCall !== void 0 && (n.onScriptCall = this.options.onScriptCall), this._chat = new Q(), await this._chat.init(n);
156
+ this.options.theme !== void 0 && (t.theme = this.options.theme), this.options.locale !== void 0 && (t.locale = this.options.locale), this.options.pricing !== void 0 && (t.pricing = this.options.pricing), this.options.chat?.mountTarget !== void 0 && (t.mountTarget = this.options.chat.mountTarget), this.options.chat?.launcherSvg !== void 0 && (t.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.headerTitle !== void 0 && (t.headerTitle = this.options.chat.headerTitle), this.options.chat?.headerAvatarUrl !== void 0 && (t.headerAvatarUrl = this.options.chat.headerAvatarUrl), this.options.chat?.headerBadge !== void 0 && (t.headerBadge = this.options.chat.headerBadge), this.options.chat?.headerCartUrl !== void 0 && (t.headerCartUrl = this.options.chat.headerCartUrl), this.options.chat?.headerFavoritesToggle !== void 0 && (t.headerFavoritesToggle = this.options.chat.headerFavoritesToggle), this.options.chat?.hideMobileLauncher !== void 0 && (t.hideMobileLauncher = this.options.chat.hideMobileLauncher), this.options.chat?.mobileBreakpoint !== void 0 && (t.mobileBreakpoint = this.options.chat.mobileBreakpoint), this.options.chat?.mobileInitialState !== void 0 && (t.mobileInitialState = this.options.chat.mobileInitialState), this.options.chat?.i18n !== void 0 && (t.i18n = this.options.chat.i18n), this.options.chat?.actionHandling !== void 0 && (t.actionHandling = this.options.chat.actionHandling), this.options.onScriptCall !== void 0 && (t.onScriptCall = this.options.onScriptCall), this._chat = new F(), await this._chat.init(t);
155
157
  }
156
158
  async _syncPdpWidgets() {
157
159
  if (this._destroyed) return;
@@ -162,12 +164,12 @@ class re {
162
164
  }
163
165
  const a = this.options.middlewareUrl;
164
166
  if (this.options.qna?.enabled !== !1) {
165
- const s = this.options.qna?.mountTarget ?? ie, i = M(s);
167
+ const s = this.options.qna?.mountTarget ?? ie, i = k(s);
166
168
  if (i)
167
169
  if (this._warnedQnaMountMissing = !1, this._qna)
168
170
  this._qna.show(), this._qna.update({ pageType: "pdp", sku: e });
169
171
  else {
170
- const u = new H(), o = {
172
+ const u = new Q(), o = {
171
173
  accountId: this.options.accountId,
172
174
  middlewareUrl: a,
173
175
  session: this.session,
@@ -184,12 +186,12 @@ class re {
184
186
  } else
185
187
  this._qna?.destroy(), this._qna = null;
186
188
  if (this.options.simrel?.enabled !== !1) {
187
- const s = this.options.simrel?.mountTarget ?? se, i = M(s);
189
+ const s = this.options.simrel?.mountTarget ?? se, i = k(s);
188
190
  if (i)
189
191
  if (this._warnedSimRelMountMissing = !1, this._simrel)
190
192
  this._simrel.show(), this._simrel.update({ pageType: "pdp", sku: e });
191
193
  else {
192
- const u = new V(), o = {
194
+ const u = new H(), o = {
193
195
  accountId: this.options.accountId,
194
196
  middlewareUrl: a,
195
197
  session: this.session,
@@ -197,7 +199,7 @@ class re {
197
199
  mountTarget: i
198
200
  };
199
201
  this.options.theme !== void 0 && (o.theme = this.options.theme), this.options.pricing !== void 0 && (o.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (o.discountType = this.options.simrel.discountType), this.options.onAddToCart !== void 0 && (o.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? o.onProductNavigate = this.options.onProductNavigate : o.onProductNavigate = (r, c, m) => {
200
- this._chat?.saveSession(m ?? this.session.sessionId, c), window.location.href = r;
202
+ $(r) && (this._chat?.saveSession(m ?? this.session.sessionId, c), window.location.href = r);
201
203
  }, await u.init(o), this._simrel = u;
202
204
  }
203
205
  else
@@ -209,32 +211,32 @@ class re {
209
211
  this._qna?.destroy(), this._simrel?.destroy(), this._qna = null, this._simrel = null;
210
212
  }
211
213
  _enqueue(e) {
212
- const n = this._queue.then(e);
213
- return this._queue = n.catch((a) => {
214
- }), n;
214
+ const t = this._queue.then(e);
215
+ return this._queue = t.catch((a) => {
216
+ }), t;
215
217
  }
216
218
  }
217
- async function de(t) {
218
- const e = P(t), n = C(), a = n.instances[e];
219
+ async function de(n) {
220
+ const e = L(n), t = I(), a = t.instances[e];
219
221
  if (a) return a;
220
- const s = n.pending[e];
222
+ const s = t.pending[e];
221
223
  if (s) return s;
222
- const i = new re(t, () => {
223
- const o = C();
224
+ const i = new re(n, () => {
225
+ const o = I();
224
226
  delete o.instances[e], delete o.pending[e];
225
- }), u = i.init().then(() => (n.instances[e] = i, delete n.pending[e], i)).catch((o) => {
226
- throw delete n.pending[e], o;
227
+ }), u = i.init().then(() => (t.instances[e] = i, delete t.pending[e], i)).catch((o) => {
228
+ throw delete t.pending[e], o;
227
229
  });
228
- return n.pending[e] = u, u;
230
+ return t.pending[e] = u, u;
229
231
  }
230
- function ce(t) {
231
- return C().instances[t] ?? null;
232
+ function ce(n) {
233
+ return I().instances[n] ?? null;
232
234
  }
233
- function Ce(t) {
234
- ce(t)?.destroy();
235
+ function Ce(n) {
236
+ ce(n)?.destroy();
235
237
  }
236
- function Ne(t) {
237
- return `${U}${t}`;
238
+ function Ie(n) {
239
+ return `${W}${n}`;
238
240
  }
239
241
  const le = [
240
242
  "gengage:chat:open",
@@ -247,11 +249,11 @@ const le = [
247
249
  "gengage:similar:add-to-cart",
248
250
  "gengage:global:error",
249
251
  "gengage:context:update"
250
- ], ge = 32, S = "#gengage-qna", k = "#gengage-simrel";
251
- function ue(t) {
252
- let e = t;
253
- if (typeof t == "string") {
254
- const i = t.trim();
252
+ ], ge = 32, A = "#gengage-qna", E = "#gengage-simrel";
253
+ function ue(n) {
254
+ let e = n;
255
+ if (typeof n == "string") {
256
+ const i = n.trim();
255
257
  if (i.length === 0) return null;
256
258
  if (!i.startsWith("{") && !i.startsWith("["))
257
259
  return { type: i };
@@ -262,98 +264,92 @@ function ue(t) {
262
264
  }
263
265
  }
264
266
  if (!e || typeof e != "object") return null;
265
- const n = e, a = [n.type, n.command, n.action, n.event].find(
267
+ const t = e, a = [t.type, t.command, t.action, t.event].find(
266
268
  (i) => typeof i == "string" && i.length > 0
267
269
  );
268
270
  if (!a) return null;
269
- let s = n.payload;
270
- if (s === void 0 && "data" in n && (s = n.data), a === "setSession" && s === void 0) {
271
+ let s = t.payload;
272
+ if (s === void 0 && "data" in t && (s = t.data), a === "setSession" && s === void 0) {
271
273
  const i = {};
272
- typeof n.sessionId == "string" && (i.sessionId = n.sessionId), typeof n.userId == "string" && (i.userId = n.userId), (i.sessionId !== void 0 || i.userId !== void 0) && (s = i);
274
+ typeof t.sessionId == "string" && (i.sessionId = t.sessionId), typeof t.userId == "string" && (i.userId = t.userId), (i.sessionId !== void 0 || i.userId !== void 0) && (s = i);
273
275
  }
274
276
  return s === void 0 ? { type: a } : { type: a, payload: s };
275
277
  }
276
- function he(t) {
277
- if (typeof t == "string" && t.length > 0)
278
- return { sku: t };
279
- if (t && typeof t == "object" && "sku" in t) {
280
- const e = t.sku;
278
+ function he(n) {
279
+ if (typeof n == "string" && n.length > 0)
280
+ return { sku: n };
281
+ if (n && typeof n == "object" && "sku" in n) {
282
+ const e = n.sku;
281
283
  if (typeof e == "string" && e.length > 0) {
282
- const n = t.pageType;
283
- return n !== void 0 ? { sku: e, pageType: n } : { sku: e };
284
+ const t = n.pageType;
285
+ return t !== void 0 ? { sku: e, pageType: t } : { sku: e };
284
286
  }
285
287
  }
286
288
  return null;
287
289
  }
288
- function N(t, e) {
289
- return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 : t.document.querySelector(e) !== null;
290
+ function N(n, e) {
291
+ return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 : n.document.querySelector(e) !== null;
290
292
  }
291
- function A(t, e, n) {
292
- if (e instanceof HTMLElement || N(t, e) || typeof e != "string") return e;
293
+ function x(n, e, t) {
294
+ if (e instanceof HTMLElement || N(n, e) || typeof e != "string") return e;
293
295
  if (e.startsWith("#")) {
294
296
  const i = e.slice(1);
295
297
  if (i.length > 0) {
296
- const u = t.document.getElementById(i);
298
+ const u = n.document.getElementById(i);
297
299
  if (u) return u;
298
- const o = t.document.createElement("div");
299
- return o.id = i, t.document.body.appendChild(o), o;
300
+ const o = n.document.createElement("div");
301
+ return o.id = i, n.document.body.appendChild(o), o;
300
302
  }
301
303
  }
302
- const a = t.document.getElementById(n);
304
+ const a = n.document.getElementById(t);
303
305
  if (a) return a;
304
- const s = t.document.createElement("div");
305
- return s.id = n, t.document.body.appendChild(s), s;
306
- }
307
- function W(t, e) {
308
- const n = t.webkit?.messageHandlers?.[e];
309
- return n && typeof n.postMessage == "function" ? n.postMessage.bind(n) : null;
310
- }
311
- function O(t, e) {
312
- const n = t[e];
313
- return n && typeof n == "object" && typeof n.postMessage == "function" ? n : null;
306
+ const s = n.document.createElement("div");
307
+ return s.id = t, n.document.body.appendChild(s), s;
314
308
  }
315
- function B(t, e) {
316
- return O(t, e);
309
+ function O(n, e) {
310
+ const t = n.webkit?.messageHandlers?.[e];
311
+ return t && typeof t.postMessage == "function" ? t.postMessage.bind(t) : null;
317
312
  }
318
- function L(t, e) {
319
- return O(t, e);
313
+ function w(n, e) {
314
+ const t = n[e];
315
+ return t && typeof t == "object" && typeof t.postMessage == "function" ? t : null;
320
316
  }
321
- function fe(t = {}) {
322
- const e = t.win ?? window, n = t.iosHandlerName ?? "gengage", a = t.androidInterfaceName ?? "GengageNative", s = t.reactNativeInterfaceName ?? "ReactNativeWebView";
323
- return W(e, n) ? "ios" : B(e, a) ? "android" : L(e, s) ? "react-native" : "browser";
317
+ function fe(n = {}) {
318
+ const e = n.win ?? window, t = n.iosHandlerName ?? "gengage", a = n.androidInterfaceName ?? "GengageNative", s = n.reactNativeInterfaceName ?? "ReactNativeWebView";
319
+ return O(e, t) ? "ios" : w(e, a) ? "android" : w(e, s) ? "react-native" : "browser";
324
320
  }
325
- function pe(t, e = {}) {
326
- const n = e.win ?? window;
327
- if (t.sessionId !== void 0) {
328
- n.__gengageSessionId = t.sessionId, n.gengage || (n.gengage = {}), n.gengage.sessionId = t.sessionId;
321
+ function pe(n, e = {}) {
322
+ const t = e.win ?? window;
323
+ if (n.sessionId !== void 0) {
324
+ t.__gengageSessionId = n.sessionId, t.gengage || (t.gengage = {}), t.gengage.sessionId = n.sessionId;
329
325
  try {
330
- n.sessionStorage.setItem("gengage_session_id", t.sessionId);
326
+ t.sessionStorage.setItem("gengage_session_id", n.sessionId);
331
327
  } catch {
332
328
  }
333
329
  }
334
- if (t.userId !== void 0) {
335
- n.gengage || (n.gengage = {});
336
- const a = n.gengage, s = a.session ?? {};
337
- s.userId = t.userId, a.session = s;
330
+ if (n.userId !== void 0) {
331
+ t.gengage || (t.gengage = {});
332
+ const a = t.gengage, s = a.session ?? {};
333
+ s.userId = n.userId, a.session = s;
338
334
  }
339
335
  }
340
- function me(t = {}) {
341
- const e = t.win ?? window, n = e;
342
- if (n.gengageNative) return n.gengageNative;
343
- const a = t.iosHandlerName ?? "gengage", s = t.androidInterfaceName ?? "GengageNative", i = t.reactNativeInterfaceName ?? "ReactNativeWebView", u = t.trackedEvents ?? [...le], o = fe({ win: e, iosHandlerName: a, androidInterfaceName: s, reactNativeInterfaceName: i });
336
+ function me(n = {}) {
337
+ const e = n.win ?? window, t = e;
338
+ if (t.gengageNative) return t.gengageNative;
339
+ const a = n.iosHandlerName ?? "gengage", s = n.androidInterfaceName ?? "GengageNative", i = n.reactNativeInterfaceName ?? "ReactNativeWebView", u = n.trackedEvents ?? [...le], o = fe({ win: e, iosHandlerName: a, androidInterfaceName: s, reactNativeInterfaceName: i });
344
340
  let r = e.gengage?.overlay ?? null;
345
341
  const c = [], m = (l, d) => {
346
342
  const f = d === void 0 ? { type: l } : { type: l, payload: d };
347
343
  if (o === "ios") {
348
- W(e, a)?.(f);
344
+ O(e, a)?.(f);
349
345
  return;
350
346
  }
351
347
  if (o === "android") {
352
- B(e, s)?.postMessage(JSON.stringify(f));
348
+ w(e, s)?.postMessage(JSON.stringify(f));
353
349
  return;
354
350
  }
355
351
  if (o === "react-native") {
356
- L(e, i)?.postMessage(JSON.stringify(f));
352
+ w(e, i)?.postMessage(JSON.stringify(f));
357
353
  return;
358
354
  }
359
355
  }, v = (l) => {
@@ -365,7 +361,7 @@ function me(t = {}) {
365
361
  });
366
362
  };
367
363
  e.addEventListener("gengage:bridge:message", v);
368
- const F = u.map((l) => {
364
+ const B = u.map((l) => {
369
365
  const d = (f) => {
370
366
  const g = f.detail;
371
367
  m("widget_event", {
@@ -380,8 +376,8 @@ function me(t = {}) {
380
376
  if (!r || c.length === 0) return;
381
377
  const l = c.splice(0, c.length);
382
378
  for (const d of l)
383
- I(d);
384
- }, I = (l) => {
379
+ q(d);
380
+ }, q = (l) => {
385
381
  const d = ue(l);
386
382
  if (!d || typeof d.type != "string") {
387
383
  console.warn("[gengage:native-bridge] Invalid message:", l);
@@ -421,26 +417,26 @@ function me(t = {}) {
421
417
  return;
422
418
  }
423
419
  default:
424
- e.postMessage({ gengage: "native", type: f, payload: g }, e.location.origin), t.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", f);
420
+ e.postMessage({ gengage: "native", type: f, payload: g }, e.location.origin), n.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", f);
425
421
  }
426
- }, w = {
422
+ }, b = {
427
423
  env: o,
428
424
  sendToNative: m,
429
- receive: I,
425
+ receive: q,
430
426
  setController(l) {
431
427
  r = l, D();
432
428
  },
433
429
  destroy() {
434
430
  e.removeEventListener("gengage:bridge:message", v);
435
- for (const l of F)
431
+ for (const l of B)
436
432
  e.removeEventListener(l.event, l.handler);
437
- c.splice(0, c.length), e.gengageNative === w && delete e.gengageNative;
433
+ c.splice(0, c.length), e.gengageNative === b && delete e.gengageNative;
438
434
  }
439
435
  };
440
- return n.gengageNative = w, w;
436
+ return t.gengageNative = b, b;
441
437
  }
442
- async function Ie(t) {
443
- const { nativeBridge: e, emitReadyEvent: n = !0, ...a } = t, s = me(e), i = { ...a };
438
+ async function Ne(n) {
439
+ const { nativeBridge: e, emitReadyEvent: t = !0, ...a } = n, s = me(e), i = { ...a };
444
440
  i.onAddToCart || (i.onAddToCart = (c) => {
445
441
  s.sendToNative("addToCart", {
446
442
  sku: c.sku,
@@ -457,25 +453,25 @@ async function Ie(t) {
457
453
  const u = i.qna?.enabled === !0 || i.qna?.mountTarget !== void 0;
458
454
  if (i.qna?.enabled !== !1)
459
455
  if (u) {
460
- const c = A(
456
+ const c = x(
461
457
  window,
462
- i.qna?.mountTarget ?? S,
458
+ i.qna?.mountTarget ?? A,
463
459
  "gengage-qna"
464
460
  );
465
461
  i.qna = { ...i.qna, enabled: !0, mountTarget: c };
466
- } else N(window, S) || (i.qna = { enabled: !1 });
462
+ } else N(window, A) || (i.qna = { enabled: !1 });
467
463
  const o = i.simrel?.enabled === !0 || i.simrel?.mountTarget !== void 0;
468
464
  if (i.simrel?.enabled !== !1)
469
465
  if (o) {
470
- const c = A(
466
+ const c = x(
471
467
  window,
472
- i.simrel?.mountTarget ?? k,
468
+ i.simrel?.mountTarget ?? E,
473
469
  "gengage-simrel"
474
470
  );
475
471
  i.simrel = { ...i.simrel, enabled: !0, mountTarget: c };
476
- } else N(window, k) || (i.simrel = { enabled: !1 });
472
+ } else N(window, E) || (i.simrel = { enabled: !1 });
477
473
  const r = await de(i);
478
- return s.setController(r), n && s.sendToNative("ready", {
474
+ return s.setController(r), t && s.sendToNative("ready", {
479
475
  sessionId: r.session.sessionId,
480
476
  widgets: {
481
477
  chat: r.chat !== null,
@@ -491,20 +487,20 @@ async function Ie(t) {
491
487
  };
492
488
  }
493
489
  export {
494
- R as A,
490
+ P as A,
495
491
  le as D,
496
492
  ee as U,
497
493
  J as a,
498
494
  pe as b,
499
- Ne as c,
500
- be as d,
495
+ Ie as c,
496
+ Te as d,
501
497
  me as e,
502
498
  Ce as f,
503
499
  fe as g,
504
500
  ce as h,
505
501
  de as i,
506
- Ie as j,
502
+ Ne as j,
507
503
  ne as p,
508
- Te as s
504
+ be as s
509
505
  };
510
- //# sourceMappingURL=index-CcOJTzYu.js.map
506
+ //# sourceMappingURL=index-C6KDzSjm.js.map