@gengage/assistant-fe 0.4.12 → 0.4.13

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/native.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a, i, n as t, r, t as s } from "./native-webview-BGpkM3T9.js";
1
+ import { a, i, n as t, r, t as s } from "./native-webview-BsRcv49q.js";
2
2
  export {
3
3
  s as DEFAULT_NATIVE_TRACKED_EVENTS,
4
4
  t as applyNativeSession,
@@ -8,16 +8,16 @@ function d() {
8
8
  }), i.__gengageOverlayRegistry;
9
9
  }
10
10
  function T(i) {
11
- const t = { pageType: i.pageContext?.pageType ?? (typeof i.sku == "string" ? "pdp" : "other") }, s = i.pageContext;
12
- return typeof s?.sku == "string" && (t.sku = s.sku), s?.skuList !== void 0 && (t.skuList = s.skuList), s?.price !== void 0 && (t.price = s.price), s?.categoryTree !== void 0 && (t.categoryTree = s.categoryTree), s?.url !== void 0 && (t.url = s.url), s?.extra !== void 0 && (t.extra = s.extra), typeof i.sku == "string" && (t.sku = i.sku), t;
11
+ const e = { pageType: i.pageContext?.pageType ?? (typeof i.sku == "string" ? "pdp" : "other") }, s = i.pageContext;
12
+ return typeof s?.sku == "string" && (e.sku = s.sku), s?.skuList !== void 0 && (e.skuList = s.skuList), s?.price !== void 0 && (e.price = s.price), s?.categoryTree !== void 0 && (e.categoryTree = s.categoryTree), s?.url !== void 0 && (e.url = s.url), s?.extra !== void 0 && (e.extra = s.extra), typeof i.sku == "string" && (e.sku = i.sku), e;
13
13
  }
14
- function b(i, t) {
14
+ function b(i, e) {
15
15
  const s = {
16
16
  ...i,
17
- ...t,
18
- pageType: t.pageType ?? i.pageType
17
+ ...e,
18
+ pageType: e.pageType ?? i.pageType
19
19
  };
20
- return t.sku !== void 0 && typeof t.sku != "string" && delete s.sku, t.pageType !== void 0 && t.pageType !== i.pageType ? (t.pageType !== "pdp" && t.sku === void 0 && delete s.sku, t.pageType !== "plp" && t.skuList === void 0 && delete s.skuList) : (t.sku === void 0 && i.sku !== void 0 && (s.sku = i.sku), t.skuList === void 0 && i.skuList !== void 0 && (s.skuList = i.skuList)), s;
20
+ return e.sku !== void 0 && typeof e.sku != "string" && delete s.sku, e.pageType !== void 0 && e.pageType !== i.pageType ? (e.pageType !== "pdp" && e.sku === void 0 && delete s.sku, e.pageType !== "plp" && e.skuList === void 0 && delete s.skuList) : (e.sku === void 0 && i.sku !== void 0 && (s.sku = i.sku), e.skuList === void 0 && i.skuList !== void 0 && (s.skuList = i.skuList)), s;
21
21
  }
22
22
  function r(i) {
23
23
  return i instanceof HTMLElement || document.querySelector(i) ? i : null;
@@ -25,9 +25,9 @@ function r(i) {
25
25
  function p(i) {
26
26
  return i.idempotencyKey ?? `${l}${i.accountId}`;
27
27
  }
28
- var S = class {
29
- constructor(i, t) {
30
- this.options = i, 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 = p(i), this.session = m(i.session), this._pageContext = T(i);
28
+ var q = class {
29
+ constructor(i, e) {
30
+ this.options = i, this.onDestroy = e, 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 = p(i), this.session = m(i.session), this._pageContext = T(i);
31
31
  }
32
32
  get chat() {
33
33
  return this._chat;
@@ -58,10 +58,10 @@ var S = class {
58
58
  this._pageContext = b(this._pageContext, i), 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();
59
59
  });
60
60
  }
61
- async updateSku(i, t = "pdp") {
61
+ async updateSku(i, e = "pdp") {
62
62
  await this.updateContext({
63
63
  sku: i,
64
- pageType: t
64
+ pageType: e
65
65
  });
66
66
  }
67
67
  async updatePageContext(i) {
@@ -75,16 +75,16 @@ var S = class {
75
75
  }
76
76
  async _initChat() {
77
77
  if (this.options.chat?.enabled === !1) return;
78
- const i = this.options.middlewareUrl, t = this.options.chat?.productDetailsExtended ?? this.options.productDetailsExtended, s = this.options.chat?.isDemoWebsite ?? this.options.isDemoWebsite, e = {
78
+ const i = this.options.middlewareUrl, e = this.options.chat?.productDetailsExtended ?? this.options.productDetailsExtended, s = this.options.chat?.isDemoWebsite ?? this.options.isDemoWebsite, t = {
79
79
  accountId: this.options.accountId,
80
80
  middlewareUrl: i,
81
81
  session: this.session,
82
82
  pageContext: this._pageContext,
83
83
  variant: this.options.chat?.variant ?? "floating"
84
84
  };
85
- this.options.theme !== void 0 && (e.theme = this.options.theme), this.options.locale !== void 0 && (e.locale = this.options.locale), this.options.pricing !== void 0 && (e.pricing = this.options.pricing), this.options.chat?.mountTarget !== void 0 && (e.mountTarget = this.options.chat.mountTarget), this.options.chat?.pillLauncher !== void 0 && (e.pillLauncher = this.options.chat.pillLauncher), this.options.chat?.floatingLauncher !== void 0 && (e.floatingLauncher = this.options.chat.floatingLauncher), this.options.chat?.launcherImageUrl !== void 0 ? e.launcherImageUrl = this.options.chat.launcherImageUrl : this.options.chat?.launcherSvg !== void 0 && (e.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.headerTitle !== void 0 && (e.headerTitle = this.options.chat.headerTitle), this.options.chat?.headerAvatarUrl !== void 0 && (e.headerAvatarUrl = this.options.chat.headerAvatarUrl), this.options.chat?.headerBadge !== void 0 && (e.headerBadge = this.options.chat.headerBadge), this.options.chat?.headerCartUrl !== void 0 && (e.headerCartUrl = this.options.chat.headerCartUrl), this.options.chat?.headerFavoritesToggle !== void 0 && (e.headerFavoritesToggle = this.options.chat.headerFavoritesToggle), this.options.chat?.onFavoritesClick !== void 0 && (e.onFavoritesClick = this.options.chat.onFavoritesClick), this.options.chat?.hideMobileLauncher !== void 0 && (e.hideMobileLauncher = this.options.chat.hideMobileLauncher), this.options.chat?.mobileBreakpoint !== void 0 && (e.mobileBreakpoint = this.options.chat.mobileBreakpoint), this.options.chat?.mobileInitialState !== void 0 && (e.mobileInitialState = this.options.chat.mobileInitialState), this.options.chat?.i18n !== void 0 && (e.i18n = this.options.chat.i18n), this.options.chat?.actionHandling !== void 0 && (e.actionHandling = this.options.chat.actionHandling), this.options.chat?.renderer !== void 0 && (e.renderer = this.options.chat.renderer), t !== void 0 && (e.productDetailsExtended = t), s !== void 0 && (e.isDemoWebsite = s), this.options.chat?.productPriceUi !== void 0 && (e.productPriceUi = this.options.chat.productPriceUi), this.options.chat?.hideProductDiscountBadge !== void 0 && (e.hideProductDiscountBadge = this.options.chat.hideProductDiscountBadge), this.options.chat?.hideUserReviews !== void 0 && (e.hideUserReviews = this.options.chat.hideUserReviews), this.options.chat?.hideStockStatus !== void 0 && (e.hideStockStatus = this.options.chat.hideStockStatus), this.options.onScriptCall !== void 0 && (e.onScriptCall = this.options.onScriptCall), this.options.onAddToCart !== void 0 && (e.onAddToCart = this.options.onAddToCart), this.options.chat?.onOpen !== void 0 && (e.onOpen = this.options.chat.onOpen), this.options.chat?.onClose !== void 0 && (e.onClose = this.options.chat.onClose);
85
+ 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?.pillLauncher !== void 0 && (t.pillLauncher = this.options.chat.pillLauncher), this.options.chat?.floatingLauncher !== void 0 && (t.floatingLauncher = this.options.chat.floatingLauncher), this.options.chat?.launcherImageUrl !== void 0 ? t.launcherImageUrl = this.options.chat.launcherImageUrl : this.options.chat?.launcherSvg !== void 0 && (t.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.mobileLauncherImageUrl !== void 0 && (t.mobileLauncherImageUrl = this.options.chat.mobileLauncherImageUrl), 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?.onFavoritesClick !== void 0 && (t.onFavoritesClick = this.options.chat.onFavoritesClick), 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.chat?.renderer !== void 0 && (t.renderer = this.options.chat.renderer), e !== void 0 && (t.productDetailsExtended = e), s !== void 0 && (t.isDemoWebsite = s), this.options.chat?.productPriceUi !== void 0 && (t.productPriceUi = this.options.chat.productPriceUi), this.options.chat?.hideProductDiscountBadge !== void 0 && (t.hideProductDiscountBadge = this.options.chat.hideProductDiscountBadge), this.options.chat?.hideUserReviews !== void 0 && (t.hideUserReviews = this.options.chat.hideUserReviews), this.options.chat?.hideStockStatus !== void 0 && (t.hideStockStatus = this.options.chat.hideStockStatus), this.options.onScriptCall !== void 0 && (t.onScriptCall = this.options.onScriptCall), this.options.onAddToCart !== void 0 && (t.onAddToCart = this.options.onAddToCart), this.options.chat?.onOpen !== void 0 && (t.onOpen = this.options.chat.onOpen), this.options.chat?.onClose !== void 0 && (t.onClose = this.options.chat.onClose);
86
86
  const { GengageChat: a } = await import("./chat-runtime.js");
87
- this._chat = new a(), await this._chat.init(e);
87
+ this._chat = new a(), await this._chat.init(t);
88
88
  }
89
89
  async _syncPdpWidgets() {
90
90
  if (this._destroyed) return;
@@ -93,10 +93,10 @@ var S = class {
93
93
  this._qna?.hide(), this._simrel?.hide(), this._simbut?.hide();
94
94
  return;
95
95
  }
96
- const t = this.options.middlewareUrl;
96
+ const e = this.options.middlewareUrl;
97
97
  if (this.options.qna?.enabled !== !1) {
98
- const s = this.options.qna?.mountTarget ?? y, e = r(s);
99
- if (e)
98
+ const s = this.options.qna?.mountTarget ?? y, t = r(s);
99
+ if (t)
100
100
  if (this._warnedQnaMountMissing = !1, this._qna)
101
101
  this._qna.show(), this._qna.update({
102
102
  pageType: "pdp",
@@ -105,15 +105,15 @@ var S = class {
105
105
  else {
106
106
  const { GengageQNA: a } = await import("./qna-runtime.js"), h = new a(), o = {
107
107
  accountId: this.options.accountId,
108
- middlewareUrl: t,
108
+ middlewareUrl: e,
109
109
  session: this.session,
110
110
  pageContext: {
111
111
  pageType: "pdp",
112
112
  sku: i
113
113
  },
114
- mountTarget: e
114
+ mountTarget: t
115
115
  };
116
- this.options.theme !== void 0 && (o.theme = this.options.theme), this.options.qna?.chrome !== void 0 && (o.chrome = this.options.qna.chrome), this.options.qna?.ctaText !== void 0 && (o.ctaText = this.options.qna.ctaText), this.options.qna?.hideButtonRowCta !== void 0 && (o.hideButtonRowCta = this.options.qna.hideButtonRowCta), this.options.qna?.inputPlaceholder !== void 0 && (o.inputPlaceholder = this.options.qna.inputPlaceholder), this.options.qna?.i18n !== void 0 && (o.i18n = this.options.qna.i18n), this.options.qna?.renderer !== void 0 && (o.renderer = this.options.qna.renderer);
116
+ this.options.theme !== void 0 && (o.theme = this.options.theme), this.options.qna?.chrome !== void 0 && (o.chrome = this.options.qna.chrome), this.options.qna?.ctaText !== void 0 && (o.ctaText = this.options.qna.ctaText), this.options.qna?.hideButtonRowCta !== void 0 && (o.hideButtonRowCta = this.options.qna.hideButtonRowCta), this.options.qna?.inputPlaceholder !== void 0 && (o.inputPlaceholder = this.options.qna.inputPlaceholder), this.options.qna?.inputAfterPills !== void 0 && (o.inputAfterPills = this.options.qna.inputAfterPills), this.options.qna?.i18n !== void 0 && (o.i18n = this.options.qna.i18n), this.options.qna?.renderer !== void 0 && (o.renderer = this.options.qna.renderer);
117
117
  const n = this.options.qna?.headerTitle ?? this.options.qna?.headingTitle;
118
118
  n !== void 0 && (o.headerTitle = n), await h.init(o), this._qna = h;
119
119
  }
@@ -122,8 +122,8 @@ var S = class {
122
122
  } else
123
123
  this._qna?.destroy(), this._qna = null;
124
124
  if (this.options.simrel !== void 0 && this.options.simrel.enabled !== !1) {
125
- const s = this.options.simrel?.mountTarget ?? w, e = r(s);
126
- if (e)
125
+ const s = this.options.simrel?.mountTarget ?? w, t = r(s);
126
+ if (t)
127
127
  if (this._warnedSimRelMountMissing = !1, this._simrel)
128
128
  this._simrel.show(), this._simrel.update({
129
129
  pageType: "pdp",
@@ -132,10 +132,10 @@ var S = class {
132
132
  else {
133
133
  const { GengageSimRel: a } = await import("./simrel-runtime.js"), h = new a(), o = {
134
134
  accountId: this.options.accountId,
135
- middlewareUrl: t,
135
+ middlewareUrl: e,
136
136
  session: this.session,
137
137
  sku: i,
138
- mountTarget: e
138
+ mountTarget: t
139
139
  };
140
140
  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.simrel?.gridColumns !== void 0 && (o.gridColumns = this.options.simrel.gridColumns), this.options.simrel?.renderCardElement !== void 0 && (o.renderCardElement = this.options.simrel.renderCardElement), this.options.simrel?.renderer !== void 0 && (o.renderer = this.options.simrel.renderer), this.options.onAddToCart !== void 0 && (o.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? o.onProductNavigate = this.options.onProductNavigate : o.onProductNavigate = (n, u, c) => {
141
141
  g(n) && (this._chat?.saveSession(c ?? this.session.sessionId, u), window.location.href = n);
@@ -146,8 +146,8 @@ var S = class {
146
146
  } else
147
147
  this._simrel?.destroy(), this._simrel = null;
148
148
  if (this.options.simbut && this.options.simbut.enabled !== !1) {
149
- const s = this.options.simbut.mountTarget ?? C, e = r(s), a = this._chat ?? this.options.simbut.onFindSimilar;
150
- if (e && a)
149
+ const s = this.options.simbut.mountTarget ?? C, t = r(s), a = this._chat ?? this.options.simbut.onFindSimilar;
150
+ if (t && a)
151
151
  if (this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this._simbut)
152
152
  this._simbut.show(), this._simbut.setChat(this._chat), this._simbut.update({
153
153
  pageType: "pdp",
@@ -156,49 +156,49 @@ var S = class {
156
156
  else {
157
157
  const { GengageSimBut: h } = await import("./simbut.js"), o = new h(), n = {
158
158
  accountId: this.options.accountId,
159
- middlewareUrl: t,
159
+ middlewareUrl: e,
160
160
  session: this.session,
161
161
  pageContext: {
162
162
  pageType: "pdp",
163
163
  sku: i
164
164
  },
165
- mountTarget: e,
165
+ mountTarget: t,
166
166
  chat: this._chat
167
167
  };
168
168
  this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.locale !== void 0 && (n.locale = this.options.locale), this.options.simbut.layout !== void 0 && (n.layout = this.options.simbut.layout), this.options.simbut.inlineCard !== void 0 && (n.inlineCard = this.options.simbut.inlineCard), this.options.simbut.imageUrl !== void 0 && (n.imageUrl = this.options.simbut.imageUrl), this.options.simbut.i18n !== void 0 && (n.i18n = this.options.simbut.i18n), this.options.simbut.onFindSimilar !== void 0 && (n.onFindSimilar = this.options.simbut.onFindSimilar), await o.init(n), this._simbut = o;
169
169
  }
170
170
  else
171
- this._simbut?.destroy(), this._simbut = null, !e && !this._warnedSimButMountMissing ? (console.warn(`[gengage] SimBut mount target not found: ${s}`), this._warnedSimButMountMissing = !0) : !a && !this._warnedSimButNoChat && (console.warn("[gengage] SimBut requires chat to be enabled or simbut.onFindSimilar"), this._warnedSimButNoChat = !0);
171
+ this._simbut?.destroy(), this._simbut = null, !t && !this._warnedSimButMountMissing ? (console.warn(`[gengage] SimBut mount target not found: ${s}`), this._warnedSimButMountMissing = !0) : !a && !this._warnedSimButNoChat && (console.warn("[gengage] SimBut requires chat to be enabled or simbut.onFindSimilar"), this._warnedSimButNoChat = !0);
172
172
  } else
173
173
  this._simbut?.destroy(), this._simbut = null;
174
174
  }
175
175
  _enqueue(i) {
176
- const t = this._queue.then(i);
177
- return this._queue = t.catch((s) => {
178
- }), t;
176
+ const e = this._queue.then(i);
177
+ return this._queue = e.catch((s) => {
178
+ }), e;
179
179
  }
180
180
  };
181
181
  async function k(i) {
182
- const t = p(i), s = d(), e = s.instances[t];
183
- if (e) return e;
184
- const a = s.pending[t];
182
+ const e = p(i), s = d(), t = s.instances[e];
183
+ if (t) return t;
184
+ const a = s.pending[e];
185
185
  if (a) return a;
186
- const h = new S(i, () => {
186
+ const h = new q(i, () => {
187
187
  const n = d();
188
- delete n.instances[t], delete n.pending[t];
189
- }), o = h.init().then(() => (s.instances[t] = h, delete s.pending[t], h)).catch((n) => {
190
- throw delete s.pending[t], _({
188
+ delete n.instances[e], delete n.pending[e];
189
+ }), o = h.init().then(() => (s.instances[e] = h, delete s.pending[e], h)).catch((n) => {
190
+ throw delete s.pending[e], _({
191
191
  reason: "overlay_init_failed",
192
192
  message: n instanceof Error ? n.message : String(n)
193
193
  }), n;
194
194
  });
195
- return s.pending[t] = o, o;
195
+ return s.pending[e] = o, o;
196
196
  }
197
- function q(i) {
197
+ function S(i) {
198
198
  return d().instances[i] ?? null;
199
199
  }
200
200
  function M(i) {
201
- q(i)?.destroy();
201
+ S(i)?.destroy();
202
202
  }
203
203
  function U(i) {
204
204
  return `${l}${i}`;
@@ -207,6 +207,6 @@ export {
207
207
  v as a,
208
208
  k as i,
209
209
  M as n,
210
- q as r,
210
+ S as r,
211
211
  U as t
212
212
  };
package/dist/overlay.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as t, t as a } from "./context-DGz5F81j.js";
2
- import { i as r, n as i, r as o, t as d } from "./overlay-DXdWi-GM.js";
2
+ import { i as r, n as i, r as o, t as d } from "./overlay-CfnBuj7M.js";
3
3
  export {
4
4
  a as bootstrapSession,
5
5
  d as buildOverlayIdempotencyKey,
@@ -45,8 +45,8 @@ export declare class GengageQNA extends BaseWidget<QNAWidgetConfig> {
45
45
  private _specIncludesType;
46
46
  private _buildFallbackActionsSpec;
47
47
  /**
48
- * Free-text field when the launcher stream has no TextInput. Must sit **above** the
49
- * quick-question pills (heading search chips), not below — see `render` order above.
48
+ * Free-text field when the launcher stream has no TextInput. Sits above the pills by
49
+ * default; set `inputAfterPills: true` in config to place it after.
50
50
  */
51
51
  private _insertStandaloneInputBeforePills;
52
52
  private _appendStandaloneInput;
@@ -13,6 +13,8 @@ export interface QNAWidgetConfig extends BaseWidgetConfig {
13
13
  /** Placeholder text cycling inside the free-text input.
14
14
  * Set to `true` to use fetched action titles as rotating placeholders. */
15
15
  inputPlaceholder?: string | string[] | true;
16
+ /** When true, the standalone input is placed after the question pills instead of before them. */
17
+ inputAfterPills?: boolean;
16
18
  /** Locale key for SDK defaults (for example 'tr', 'en'). */
17
19
  locale?: string;
18
20
  i18n?: Partial<QNAI18n>;
@@ -1,4 +1,4 @@
1
- import { a, i as r, n, r as t, t as s } from "./runtime-CN3nY1qp.js";
1
+ import { a, i as r, n, r as t, t as s } from "./runtime-DW9q1zyk.js";
2
2
  export {
3
3
  s as GengageQNA,
4
4
  t as createDefaultQnaUISpecRegistry,