@gengage/assistant-fe 0.4.19 → 0.4.20
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/api-paths-CReMDZWg.js +1250 -0
- package/dist/chat/components/ChoicePrompter.d.ts +2 -2
- package/dist/chat/runtime.d.ts +2 -1
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +17 -17
- package/dist/chat.js +1 -1
- package/dist/common/find-similar-payload.d.ts +3 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/overlay.d.ts +2 -2
- package/dist/common/sdk-version.d.ts +3 -0
- package/dist/{common-Bpp43wr0.js → common-BM2ZsSLI.js} +2 -2
- package/dist/common.js +79 -77
- package/dist/{connection-warning-C7ehvQxx.js → connection-warning-C_4e7ahZ.js} +1 -1
- package/dist/{fastIntent-CINRmM8r.js → fastIntent-DMNzXOSI.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +75 -73
- package/dist/native.iife.js +18 -18
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +22 -22
- package/dist/qna.js +1 -1
- package/dist/{runtime-B0hDHRlN.js → runtime-C51WykbJ.js} +13 -13
- package/dist/{runtime-DhdfOJEN.js → runtime-DBh8899B.js} +854 -847
- package/dist/{runtime-CLcYqzoA.js → runtime-bbMljGVG.js} +17 -17
- package/dist/simbut/index.d.ts +1 -1
- package/dist/simbut/types.d.ts +7 -7
- package/dist/{simbut-3kqLW3SM.js → simbut-CO1rLVM9.js} +19 -22
- package/dist/simbut.iife.js +9 -9
- package/dist/simbut.js +1 -1
- package/dist/simrel/components/GroupTabs.d.ts +1 -1
- package/dist/simrel/types.d.ts +3 -3
- package/dist/simrel-runtime.js +1 -1
- package/dist/{simrel-fQg2EIB8.js → simrel-zCDlCrqG.js} +1 -1
- package/dist/simrel.iife.js +7 -7
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-bdJaGJYi.js → widget-base-Cf9ofZhh.js} +91 -83
- package/package.json +2 -1
- package/dist/api-paths-BX3Lea3A.js +0 -1213
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as D,
|
|
2
|
-
import {
|
|
1
|
+
import { a as D, d as N, h as j, i as F, p as H, r as R, t as U } from "./api-paths-CReMDZWg.js";
|
|
2
|
+
import { C as z, E as T, S as w, m as $, o as W, t as J, w as Q } from "./widget-base-Cf9ofZhh.js";
|
|
3
3
|
import { A as Y, E as A, N as V, a as S, l as K, v as X } from "./context-DGz5F81j.js";
|
|
4
4
|
import { t as Z } from "./locale-CfqNifrU.js";
|
|
5
5
|
import { a as ee, n as te, r as re, t as P } from "./price-formatter-xI3g9Cd4.js";
|
|
6
|
-
import { n as ne } from "./connection-warning-
|
|
6
|
+
import { n as ne } from "./connection-warning-C_4e7ahZ.js";
|
|
7
7
|
function M(e) {
|
|
8
8
|
const t = [];
|
|
9
9
|
for (const r of Object.values(e)) if (r.type === "ProductCard" && r.props) {
|
|
@@ -18,13 +18,13 @@ function G(e) {
|
|
|
18
18
|
}
|
|
19
19
|
async function ie(e, t) {
|
|
20
20
|
const r = [], n = { onEvent: (i) => {
|
|
21
|
-
const s =
|
|
21
|
+
const s = R(i);
|
|
22
22
|
!s || s.type !== "ui_spec" || r.push(...M(s.spec.elements));
|
|
23
23
|
} };
|
|
24
|
-
return t !== void 0 && (n.signal = t), await
|
|
24
|
+
return t !== void 0 && (n.signal = t), await N(e, n), r;
|
|
25
25
|
}
|
|
26
26
|
async function se(e, t, r) {
|
|
27
|
-
const n =
|
|
27
|
+
const n = U("similar_products", t), i = {
|
|
28
28
|
method: "POST",
|
|
29
29
|
headers: { "Content-Type": "application/json" },
|
|
30
30
|
body: JSON.stringify(e)
|
|
@@ -45,7 +45,7 @@ async function oe(e, t) {
|
|
|
45
45
|
const r = [];
|
|
46
46
|
let n = null;
|
|
47
47
|
const i = { onEvent: (s) => {
|
|
48
|
-
const c =
|
|
48
|
+
const c = R(s);
|
|
49
49
|
if (c) {
|
|
50
50
|
if (c.type === "metadata" && c.meta) {
|
|
51
51
|
const d = c.meta.group_name;
|
|
@@ -61,10 +61,10 @@ async function oe(e, t) {
|
|
|
61
61
|
c.type === "ui_spec" && n && n.products.push(...M(c.spec.elements));
|
|
62
62
|
}
|
|
63
63
|
} };
|
|
64
|
-
return t !== void 0 && (i.signal = t), await
|
|
64
|
+
return t !== void 0 && (i.signal = t), await N(e, i), r;
|
|
65
65
|
}
|
|
66
66
|
async function ae(e, t, r) {
|
|
67
|
-
const n =
|
|
67
|
+
const n = U("product_groupings", t), i = {
|
|
68
68
|
method: "POST",
|
|
69
69
|
headers: { "Content-Type": "application/json" },
|
|
70
70
|
body: JSON.stringify(e)
|
|
@@ -384,7 +384,7 @@ function ge() {
|
|
|
384
384
|
return { ...O };
|
|
385
385
|
}
|
|
386
386
|
function ue(e, t, r = O, n = B) {
|
|
387
|
-
return
|
|
387
|
+
return j({
|
|
388
388
|
spec: e,
|
|
389
389
|
context: t,
|
|
390
390
|
registry: r,
|
|
@@ -515,7 +515,7 @@ var Ce = class extends J {
|
|
|
515
515
|
source: "simrel",
|
|
516
516
|
locale: this.config.locale
|
|
517
517
|
});
|
|
518
|
-
this.track(
|
|
518
|
+
this.track(Q(this.analyticsContext(), {
|
|
519
519
|
endpoint: "similar_products",
|
|
520
520
|
request_id: g,
|
|
521
521
|
widget: "simrel"
|
|
@@ -545,12 +545,12 @@ var Ce = class extends J {
|
|
|
545
545
|
})).filter((a) => a.products.length > 0);
|
|
546
546
|
if (o.length > 0 && this._contentEl) {
|
|
547
547
|
const a = this._buildGroupsSpec(o), u = this._renderUISpec(a);
|
|
548
|
-
this._contentEl.appendChild(u), A("simrel"), this.track(
|
|
548
|
+
this._contentEl.appendChild(u), A("simrel"), this.track(w(this.analyticsContext(), {
|
|
549
549
|
request_id: g,
|
|
550
550
|
latency_ms: Date.now() - l,
|
|
551
551
|
chunk_count: o.reduce((_, E) => _ + E.products.length, 0),
|
|
552
552
|
widget: "simrel"
|
|
553
|
-
})), this.track(
|
|
553
|
+
})), this.track(T(this.analyticsContext(), {
|
|
554
554
|
message_count: o.reduce((_, E) => _ + E.products.length, 0),
|
|
555
555
|
history_ref: g,
|
|
556
556
|
redaction_level: "none",
|
|
@@ -565,12 +565,12 @@ var Ce = class extends J {
|
|
|
565
565
|
const y = this._buildProductsSpec(p), b = this._renderUISpec(y);
|
|
566
566
|
this._contentEl.appendChild(b);
|
|
567
567
|
}
|
|
568
|
-
p.length > 0 && A("simrel"), this.track(
|
|
568
|
+
p.length > 0 && A("simrel"), this.track(w(this.analyticsContext(), {
|
|
569
569
|
request_id: g,
|
|
570
570
|
latency_ms: Date.now() - l,
|
|
571
571
|
chunk_count: p.length,
|
|
572
572
|
widget: "simrel"
|
|
573
|
-
})), this.track(
|
|
573
|
+
})), this.track(T(this.analyticsContext(), {
|
|
574
574
|
message_count: p.length,
|
|
575
575
|
history_ref: g,
|
|
576
576
|
redaction_level: "none",
|
|
@@ -584,7 +584,7 @@ var Ce = class extends J {
|
|
|
584
584
|
source: "simrel",
|
|
585
585
|
code: y,
|
|
586
586
|
message: W(this.config.locale, m)
|
|
587
|
-
}), this.track(
|
|
587
|
+
}), this.track(z(this.analyticsContext(), {
|
|
588
588
|
request_id: g,
|
|
589
589
|
error_code: y,
|
|
590
590
|
error_message: b,
|
|
@@ -615,7 +615,7 @@ var Ce = class extends J {
|
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
617
|
_resolveUISpecRegistry() {
|
|
618
|
-
return
|
|
618
|
+
return H(ge(), this.config.renderer?.registry);
|
|
619
619
|
}
|
|
620
620
|
_buildRenderContext() {
|
|
621
621
|
const e = this.config.renderCard, t = {
|
package/dist/simbut/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare class GengageSimBut extends BaseWidget<SimButWidgetConfig> {
|
|
|
15
15
|
protected onShow(): void;
|
|
16
16
|
protected onHide(): void;
|
|
17
17
|
protected onDestroy(): void;
|
|
18
|
-
/**
|
|
18
|
+
/** Optional hook for wiring overlay chat after initialization. */
|
|
19
19
|
setChat(chat: GengageChat | null): void;
|
|
20
20
|
}
|
|
21
21
|
export declare function createSimButWidget(): GengageSimBut;
|
package/dist/simbut/types.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export interface SimButInlineCardConfig {
|
|
|
12
12
|
}
|
|
13
13
|
export interface SimButWidgetConfig extends BaseWidgetConfig {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Product image element, or its `position: relative` wrapper.
|
|
16
|
+
* The button is absolutely positioned inside this element and does not take layout space.
|
|
17
17
|
*/
|
|
18
18
|
mountTarget: HTMLElement | string;
|
|
19
19
|
/** Visual layout. Defaults to the existing product-image overlay pill. */
|
|
@@ -21,18 +21,18 @@ export interface SimButWidgetConfig extends BaseWidgetConfig {
|
|
|
21
21
|
/** Content used by `layout: 'inline-card'`. Ignored for overlay layout. */
|
|
22
22
|
inlineCard?: SimButInlineCardConfig;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Product SKU. Falls back to `pageContext.sku`, including overlay context updates.
|
|
25
25
|
*/
|
|
26
26
|
sku?: string;
|
|
27
|
-
/** `
|
|
27
|
+
/** Optional product image URL passed to custom `onFindSimilar`; chat actions use SKU when available. */
|
|
28
28
|
imageUrl?: string;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Chat instance used to open chat and send `findSimilar`. `initOverlayWidgets` wires this automatically.
|
|
31
31
|
*/
|
|
32
32
|
chat?: GengageChat | null;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* Overrides the default click behavior, for example for a custom integration.
|
|
35
|
+
* When defined, `chat` is not used.
|
|
36
36
|
*/
|
|
37
37
|
onFindSimilar?: (detail: {
|
|
38
38
|
sku: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as m } from "./widget-base-
|
|
1
|
+
import { t as m } from "./widget-base-Cf9ofZhh.js";
|
|
2
2
|
import { A as h, D as u, _ as f, j as p, v as b } from "./context-DGz5F81j.js";
|
|
3
|
-
import { t as
|
|
4
|
-
var g = { findSimilarLabel: "Benzerlerini Bul" },
|
|
3
|
+
import { t as y } from "./locale-CfqNifrU.js";
|
|
4
|
+
var g = { findSimilarLabel: "Benzerlerini Bul" }, _ = { findSimilarLabel: "Find Similar" };
|
|
5
5
|
function S(t, n) {
|
|
6
|
-
return n?.findSimilarLabel ? n.findSimilarLabel : (t ?? "tr").toLowerCase().startsWith("en") ?
|
|
6
|
+
return n?.findSimilarLabel ? n.findSimilarLabel : (t ?? "tr").toLowerCase().startsWith("en") ? _.findSimilarLabel : g.findSimilarLabel;
|
|
7
7
|
}
|
|
8
8
|
function d(t) {
|
|
9
9
|
const n = typeof t.sku == "string" && t.sku.length > 0 ? t.sku : void 0, i = typeof t.pageContext?.sku == "string" && t.pageContext.sku.length > 0 ? t.pageContext.sku : void 0;
|
|
@@ -18,7 +18,7 @@ var C = class extends m {
|
|
|
18
18
|
const n = t.layout ?? "overlay";
|
|
19
19
|
this.root.classList.add("gengage-simbut-root"), this.root.classList.toggle("gengage-simbut-root--overlay", n === "overlay"), this.root.classList.toggle("gengage-simbut-root--inline-card", n === "inline-card"), n === "overlay" && window.getComputedStyle(this.root).position === "static" && (this.root.style.position = "relative");
|
|
20
20
|
const i = document.createElement("button");
|
|
21
|
-
i.type = "button", i.className = "gengage-chat-find-similar-pill", i.lang =
|
|
21
|
+
i.type = "button", i.className = "gengage-chat-find-similar-pill", i.lang = y(t.locale), i.textContent = this._label, this._button = i;
|
|
22
22
|
const c = () => {
|
|
23
23
|
i.disabled = !(d(this.config) && (this.config.onFindSimilar || this.config.chat));
|
|
24
24
|
};
|
|
@@ -26,11 +26,11 @@ var C = class extends m {
|
|
|
26
26
|
l.stopPropagation();
|
|
27
27
|
const s = d(this.config);
|
|
28
28
|
if (!s) return;
|
|
29
|
-
const
|
|
29
|
+
const a = this.config.imageUrl, o = typeof a == "string" && p(a) ? a : void 0;
|
|
30
30
|
if (u(this._label, "findSimilar"), f(s), this.config.onFindSimilar) {
|
|
31
|
-
this.config.onFindSimilar(
|
|
31
|
+
this.config.onFindSimilar(o ? {
|
|
32
32
|
sku: s,
|
|
33
|
-
imageUrl:
|
|
33
|
+
imageUrl: o
|
|
34
34
|
} : { sku: s });
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -39,10 +39,7 @@ var C = class extends m {
|
|
|
39
39
|
const e = {
|
|
40
40
|
title: this._label,
|
|
41
41
|
type: "findSimilar",
|
|
42
|
-
payload:
|
|
43
|
-
sku: s,
|
|
44
|
-
image_url: a
|
|
45
|
-
} : { sku: s }
|
|
42
|
+
payload: { sku: s }
|
|
46
43
|
};
|
|
47
44
|
r.openWithAction(e, { sku: s });
|
|
48
45
|
}), n === "inline-card") {
|
|
@@ -52,26 +49,26 @@ var C = class extends m {
|
|
|
52
49
|
c(), b("simbut");
|
|
53
50
|
}
|
|
54
51
|
_createInlineCard(t, n) {
|
|
55
|
-
const i = t.inlineCard, c = typeof i?.title == "string" ? i.title.trim() : "", l = typeof i?.description == "string" ? i.description.trim() : "", s = typeof i?.imageUrl == "string" ? i.imageUrl.trim() : "",
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
52
|
+
const i = t.inlineCard, c = typeof i?.title == "string" ? i.title.trim() : "", l = typeof i?.description == "string" ? i.description.trim() : "", s = typeof i?.imageUrl == "string" ? i.imageUrl.trim() : "", a = document.createElement("section");
|
|
53
|
+
a.className = "gengage-simbut-inline-card", a.dataset.gengagePart = "simbut-inline-card";
|
|
54
|
+
const o = document.createElement("div");
|
|
55
|
+
if (o.className = "gengage-simbut-inline-copy", o.dataset.gengagePart = "simbut-inline-copy", c) {
|
|
59
56
|
const e = document.createElement("h4");
|
|
60
|
-
e.className = "gengage-simbut-inline-title", e.dataset.gengagePart = "simbut-inline-title", e.textContent = c,
|
|
57
|
+
e.className = "gengage-simbut-inline-title", e.dataset.gengagePart = "simbut-inline-title", e.textContent = c, o.appendChild(e);
|
|
61
58
|
}
|
|
62
59
|
if (l) {
|
|
63
60
|
const e = document.createElement("p");
|
|
64
|
-
e.className = "gengage-simbut-inline-description", e.dataset.gengagePart = "simbut-inline-description", e.textContent = l,
|
|
61
|
+
e.className = "gengage-simbut-inline-description", e.dataset.gengagePart = "simbut-inline-description", e.textContent = l, o.appendChild(e);
|
|
65
62
|
}
|
|
66
|
-
|
|
63
|
+
o.children.length > 0 && a.appendChild(o);
|
|
67
64
|
const r = document.createElement("div");
|
|
68
|
-
if (r.className = "gengage-simbut-inline-action", r.dataset.gengagePart = "simbut-inline-action", r.appendChild(n),
|
|
65
|
+
if (r.className = "gengage-simbut-inline-action", r.dataset.gengagePart = "simbut-inline-action", r.appendChild(n), a.appendChild(r), s && h(s)) {
|
|
69
66
|
const e = document.createElement("img");
|
|
70
67
|
e.className = "gengage-simbut-inline-image", e.dataset.gengagePart = "simbut-inline-image", e.src = s, e.alt = typeof i?.imageAlt == "string" ? i.imageAlt : "", e.loading = "lazy", e.addEventListener("error", () => {
|
|
71
68
|
e.style.display = "none";
|
|
72
|
-
}, { once: !0 }),
|
|
69
|
+
}, { once: !0 }), a.appendChild(e);
|
|
73
70
|
}
|
|
74
|
-
return
|
|
71
|
+
return a;
|
|
75
72
|
}
|
|
76
73
|
onUpdate(t) {
|
|
77
74
|
if (!this._button) return;
|
package/dist/simbut.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(m){Object.defineProperty(m,Symbol.toStringTag,{value:"Module"});function I(e,t){const i={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(i.view_id=e.view_id),e.user_id!==void 0&&(i.user_id=e.user_id),e.page_type!==void 0&&(i.page_type=e.page_type),e.sku!==void 0&&(i.sku=e.sku),i}function k(e,t){const i={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(i.view_id=e.view_id),e.user_id!==void 0&&(i.user_id=e.user_id),e.page_type!==void 0&&(i.page_type=e.page_type),e.sku!==void 0&&(i.sku=e.sku),i}function T(e,t){const i={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(i.view_id=e.view_id),e.user_id!==void 0&&(i.user_id=e.user_id),e.page_type!==void 0&&(i.page_type=e.page_type),e.sku!==void 0&&(i.sku=e.sku),i}var _=["http:","https:"];function L(e){const t=e.trim();if(!t)return!1;if(t.startsWith("/")&&!t.startsWith("//"))return!0;try{return _.includes(new URL(t).protocol)}catch{return!1}}function F(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return _.includes(t.protocol)}catch{return!1}}function
|
|
1
|
+
(function(m){Object.defineProperty(m,Symbol.toStringTag,{value:"Module"});function I(e,t){const i={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(i.view_id=e.view_id),e.user_id!==void 0&&(i.user_id=e.user_id),e.page_type!==void 0&&(i.page_type=e.page_type),e.sku!==void 0&&(i.sku=e.sku),i}function k(e,t){const i={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(i.view_id=e.view_id),e.user_id!==void 0&&(i.user_id=e.user_id),e.page_type!==void 0&&(i.page_type=e.page_type),e.sku!==void 0&&(i.sku=e.sku),i}function T(e,t){const i={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(i.view_id=e.view_id),e.user_id!==void 0&&(i.user_id=e.user_id),e.page_type!==void 0&&(i.page_type=e.page_type),e.sku!==void 0&&(i.sku=e.sku),i}var _=["http:","https:"];function L(e){const t=e.trim();if(!t)return!1;if(t.startsWith("/")&&!t.startsWith("//"))return!0;try{return _.includes(new URL(t).protocol)}catch{return!1}}function F(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return _.includes(t.protocol)}catch{return!1}}function R(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function p(e,t){const i={event:e,...t};R()&&window.dataLayer.push(i)}function M(e){p("gengage-on-init",{gengage_widget:e})}function N(e,t){p("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function U(e){p("gengage-find-similars",{gengage_sku:e})}function y(e,t){const i=n=>{t(n.detail)};return window.addEventListener(e,i),()=>window.removeEventListener(e,i)}function $(){const e=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=e,sessionStorage.setItem("gengage_session_id",e),window.gengage||(window.gengage={}),window.gengage.sessionId=e,e}function A(e){return{sessionId:e?.sessionId??$(),...e}}var v={"--gengage-chat-offset":"20px","--gengage-chat-launcher-width":"56px","--gengage-chat-launcher-height":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"12px","--gengage-simrel-card-radius":"0.75rem","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--surface-card-muted":"#f8fafc","--text-secondary":"#4b5563","--text-muted":"#6b7280","--border-default":"rgba(17, 24, 39, 0.10)"};function B(e){if(!e)return{...v};const t={...v,...e},i=e["--gengage-chat-launcher-size"];return i!==void 0&&(e["--gengage-chat-launcher-width"]===void 0&&(t["--gengage-chat-launcher-width"]=i),e["--gengage-chat-launcher-height"]===void 0&&(t["--gengage-chat-launcher-height"]=i)),t}var d={primaryColor:"#b7102a",primaryForeground:"#ffffff",backgroundColor:"#ffffff",foregroundColor:"#111827",borderRadius:"0.75rem",fontFamily:'"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px",zIndex:"1000","--glov-chatbot-width":"420px","--glov-left-spacing":"260px","--chatbot-padding":"16px","--root-wrapper-background-color":"#f8f9fa","--root-wrapper-border-color":"#edeeef","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem","--client-primary":"#b7102a","--client-primary-hover":"color-mix(in srgb, #b7102a 88%, black 12%)","--client-primary-active":"color-mix(in srgb, #b7102a 78%, black 22%)","--client-primary-subtle":"color-mix(in srgb, #b7102a 12%, white)","--client-primary-soft":"color-mix(in srgb, #b7102a 20%, white)","--client-on-primary":"#ffffff","--client-focus-ring":"color-mix(in srgb, #b7102a 32%, transparent)","--surface-page":"#f6f7fb","--surface-shell":"#10131a","--surface-card":"#ffffff","--surface-card-muted":"#f8fafc","--surface-card-soft":"#f8fafc","--surface-elevated":"#ffffff","--surface-input":"#ffffff","--surface-overlay":"rgba(16, 19, 26, 0.52)","--text-primary":"#111827","--text-secondary":"#4b5563","--text-muted":"#6b7280","--text-inverse":"#f9fafb","--border-subtle":"rgba(17, 24, 39, 0.06)","--border-default":"rgba(17, 24, 39, 0.10)","--border-strong":"rgba(17, 24, 39, 0.18)","--shadow-1":"0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)","--shadow-2":"0 4px 12px rgba(16, 24, 40, 0.08)","--shadow-3":"0 10px 24px rgba(16, 24, 40, 0.12)","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--success":"#16a34a","--warning":"#d97706","--error":"#dc2626","--info":"#2563eb","--rating":"#f5b301","--ai-accent-start":"#0b24d6","--ai-accent-end":"#f768f2","--ai-accent-soft":"linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"},c="gengage-global-toast-root",w="gengage-global-toast-style",b="gengage-global-toast-root--visible",D=4200,O=1500,V=15e3,G=["--gengage-font-family","--surface-card","--text-primary","--text-muted","--border-default","--radius-card","--shadow-3","--error","--ds-toast-error-bg","--ds-toast-error-border","--ds-toast-error-accent","--ds-toast-error-fg","--ds-toast-error-shadow"],x=!1,l=null;function W(){x||typeof window>"u"||typeof document>"u"||(x=!0,y("gengage:global:error",e=>{P(e)}))}function P(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;J();const i=z();Y(i),i.innerHTML="";const n=document.createElement("section");n.className="gengage-global-toast gengage-global-toast--error",n.setAttribute("role","status"),n.setAttribute("aria-live","polite");const a=document.createElement("div");a.className="gengage-global-toast-title",a.textContent=H(e.source);const s=document.createElement("div");s.className="gengage-global-toast-message",s.textContent=t,n.appendChild(a),n.appendChild(s),i.appendChild(n),i.classList.add(b),l&&(clearTimeout(l),l=null),e.sticky!==!0&&(l=setTimeout(()=>{q()},j(e.durationMs)))}function q(){if(typeof document>"u")return;const e=document.getElementById(c);e&&(e.classList.remove(b),e.innerHTML="",l&&(clearTimeout(l),l=null))}function H(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function z(){const e=document.getElementById(c);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=c,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function Y(e){if(typeof document>"u"||typeof window>"u")return;const t=document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");if(!t)return;const i=window.getComputedStyle(t);for(const n of G){const a=i.getPropertyValue(n).trim();a?e.style.setProperty(n,a):e.style.removeProperty(n)}}function j(e){return typeof e!="number"||!Number.isFinite(e)?D:Math.min(V,Math.max(O,Math.round(e)))}function J(){if(document.getElementById(w))return;const e=document.createElement("style");e.id=w;const t=d["--surface-card"]??d.backgroundColor??"#ffffff",i=d["--text-primary"]??d.foregroundColor??"#111827",n=d["--border-default"]??"rgba(17, 24, 39, 0.10)",a=d["--error"]??"#dc2626",s=d["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",o=d["--radius-card"]??"16px",g=d["--text-muted"]??"#6b7280";e.textContent=`
|
|
2
2
|
#${c} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
top: 16px;
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
#${c} .gengage-global-toast {
|
|
13
13
|
min-width: 260px;
|
|
14
14
|
max-width: min(92vw, 420px);
|
|
15
|
-
border-radius: var(--radius-card, ${
|
|
16
|
-
border: 1px solid var(--ds-toast-error-border, color-mix(in srgb, var(--error, ${
|
|
17
|
-
border-left: 4px solid var(--ds-toast-error-accent, var(--error, ${
|
|
18
|
-
background: var(--ds-toast-error-bg, color-mix(in srgb, var(--error, ${
|
|
19
|
-
color: var(--ds-toast-error-fg, color-mix(in srgb, var(--error, ${
|
|
20
|
-
box-shadow: var(--ds-toast-error-shadow, var(--shadow-3, ${
|
|
15
|
+
border-radius: var(--radius-card, ${o});
|
|
16
|
+
border: 1px solid var(--ds-toast-error-border, color-mix(in srgb, var(--error, ${a}) 18%, var(--border-default, ${n})));
|
|
17
|
+
border-left: 4px solid var(--ds-toast-error-accent, var(--error, ${a}));
|
|
18
|
+
background: var(--ds-toast-error-bg, color-mix(in srgb, var(--error, ${a}) 5%, var(--surface-card, ${t})));
|
|
19
|
+
color: var(--ds-toast-error-fg, color-mix(in srgb, var(--error, ${a}) 22%, var(--text-primary, ${i})));
|
|
20
|
+
box-shadow: var(--ds-toast-error-shadow, var(--shadow-3, ${s}));
|
|
21
21
|
padding: 10px 12px;
|
|
22
22
|
font-family: var(--gengage-font-family, ${JSON.stringify(d.fontFamily??'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif')});
|
|
23
23
|
font-size: 13px;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
margin: 0 0 4px;
|
|
29
29
|
font-size: 12px;
|
|
30
30
|
font-weight: 700;
|
|
31
|
-
color: var(--text-muted, ${
|
|
31
|
+
color: var(--text-muted, ${g});
|
|
32
32
|
}
|
|
33
33
|
#${c} .gengage-global-toast-message {
|
|
34
34
|
margin: 0;
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
transform: translateY(0);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,document.head.appendChild(e)}var f=null;function K(){if(f!==null)return f;try{f=localStorage.getItem("gengage:debug")==="1"}catch{f=!1}return f}function S(e,t,i){if(!K())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var Q=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=B(e.theme);this.config={...e,theme:t,session:A(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),
|
|
47
|
+
`,document.head.appendChild(e)}var f=null;function K(){if(f!==null)return f;try{f=localStorage.getItem("gengage:debug")==="1"}catch{f=!1}return f}function S(e,t,i){if(!K())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var Q=("0.4.20".trim(),"0.4.20".trim()),X=("iife-build".trim(),"iife-build".trim());function Z(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${Q} (${X})`))}var ee=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=B(e.theme);Z(),this.config={...e,theme:t,session:A(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),W();const i=y("gengage:context:update",n=>this.update(n));this._cleanups.push(i),S("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,S("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}trackCheckout(e,t){const i=e==="start"?k:T;this.track(i(this.analyticsContext(),t))}flushMeteringSummary(e){this.track(I(this.analyticsContext(),e))}emit(e,...t){this._handlers.get(e)?.forEach(i=>i(...t))}addCleanup(e){this._cleanups.push(e)}track(e){this.config.analyticsClient?.track(e)}analyticsContext(){const e={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(e.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(e.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(e.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(e.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(e.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(e.ab_test_experiment_id=this.config.session.abTestExperimentId),e}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const i=document.querySelector(e);if(!i)throw new Error(`[gengage] Mount target not found: "${e}"`);return i}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,i]of Object.entries(e))if(i!==void 0){const n=t.startsWith("--")?t:`--gengage-${te(t)}`;this.root.style.setProperty(n,i)}}}};function te(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function ie(e){const t=e?.trim();return t||"tr"}var C={findSimilarLabel:"Benzerlerini Bul"},ne={findSimilarLabel:"Find Similar"};function re(e,t){return t?.findSimilarLabel?t.findSimilarLabel:(e??"tr").toLowerCase().startsWith("en")?ne.findSimilarLabel:C.findSimilarLabel}function h(e){const t=typeof e.sku=="string"&&e.sku.length>0?e.sku:void 0,i=typeof e.pageContext?.sku=="string"&&e.pageContext.sku.length>0?e.pageContext.sku:void 0;return t??i}var E=class extends ee{constructor(...e){super(...e),this._button=null,this._inlineFrame=null,this._label=C.findSimilarLabel}async onInit(e){this._label=re(e.locale,e.i18n);const t=e.layout??"overlay";this.root.classList.add("gengage-simbut-root"),this.root.classList.toggle("gengage-simbut-root--overlay",t==="overlay"),this.root.classList.toggle("gengage-simbut-root--inline-card",t==="inline-card"),t==="overlay"&&window.getComputedStyle(this.root).position==="static"&&(this.root.style.position="relative");const i=document.createElement("button");i.type="button",i.className="gengage-chat-find-similar-pill",i.lang=ie(e.locale),i.textContent=this._label,this._button=i;const n=()=>{i.disabled=!(h(this.config)&&(this.config.onFindSimilar||this.config.chat))};if(i.addEventListener("click",a=>{a.stopPropagation();const s=h(this.config);if(!s)return;const o=this.config.imageUrl,g=typeof o=="string"&&F(o)?o:void 0;if(N(this._label,"findSimilar"),U(s),this.config.onFindSimilar){this.config.onFindSimilar(g?{sku:s,imageUrl:g}:{sku:s});return}const u=this.config.chat;if(!u)return;const r={title:this._label,type:"findSimilar",payload:{sku:s}};u.openWithAction(r,{sku:s})}),t==="inline-card"){const a=this._createInlineCard(e,i);this._inlineFrame=a,this.root.appendChild(a)}else this.root.appendChild(i);n(),M("simbut")}_createInlineCard(e,t){const i=e.inlineCard,n=typeof i?.title=="string"?i.title.trim():"",a=typeof i?.description=="string"?i.description.trim():"",s=typeof i?.imageUrl=="string"?i.imageUrl.trim():"",o=document.createElement("section");o.className="gengage-simbut-inline-card",o.dataset.gengagePart="simbut-inline-card";const g=document.createElement("div");if(g.className="gengage-simbut-inline-copy",g.dataset.gengagePart="simbut-inline-copy",n){const r=document.createElement("h4");r.className="gengage-simbut-inline-title",r.dataset.gengagePart="simbut-inline-title",r.textContent=n,g.appendChild(r)}if(a){const r=document.createElement("p");r.className="gengage-simbut-inline-description",r.dataset.gengagePart="simbut-inline-description",r.textContent=a,g.appendChild(r)}g.children.length>0&&o.appendChild(g);const u=document.createElement("div");if(u.className="gengage-simbut-inline-action",u.dataset.gengagePart="simbut-inline-action",u.appendChild(t),o.appendChild(u),s&&L(s)){const r=document.createElement("img");r.className="gengage-simbut-inline-image",r.dataset.gengagePart="simbut-inline-image",r.src=s,r.alt=typeof i?.imageAlt=="string"?i.imageAlt:"",r.loading="lazy",r.addEventListener("error",()=>{r.style.display="none"},{once:!0}),o.appendChild(r)}return o}onUpdate(e){if(!this._button)return;const t=!!h(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}hide(){this.isVisible&&(this.isVisible=!1,this._inlineFrame&&(this._inlineFrame.style.display="none"),this._button&&(this._button.style.display="none"),this.onHide(),this.emit("hide"))}show(){this.isVisible||(this.isVisible=!0,this._inlineFrame&&(this._inlineFrame.style.display=""),this._button&&(this._button.style.display=""),this.onShow(),this.emit("show"))}_cleanupRoot(){}onShow(){}onHide(){}onDestroy(){this._inlineFrame?.remove(),this._inlineFrame=null,this._button?.remove(),this._button=null}setChat(e){if(this.config.chat=e,this._button){const t=!!h(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}}};function ae(){return new E}m.GengageSimBut=E,m.createSimButWidget=ae})(this.Gengage=this.Gengage||{});
|
package/dist/simbut.js
CHANGED
|
@@ -13,7 +13,7 @@ export interface GroupTabsOptions {
|
|
|
13
13
|
renderCard?: (product: NormalizedProduct, index: number) => string;
|
|
14
14
|
renderCardElement?: (product: NormalizedProduct, index: number) => HTMLElement | null;
|
|
15
15
|
i18n?: SimRelI18n;
|
|
16
|
-
/** ProductGrid `columns
|
|
16
|
+
/** ProductGrid `columns`: number of cards per desktop row. */
|
|
17
17
|
columns?: number;
|
|
18
18
|
/** User changed grouping tab (click or keyboard). */
|
|
19
19
|
onGroupingActivate?: (detail: {
|
package/dist/simrel/types.d.ts
CHANGED
|
@@ -42,8 +42,8 @@ export interface SimRelWidgetConfig extends BaseWidgetConfig {
|
|
|
42
42
|
renderSpecialCard?: (product: SimilarProduct) => string | null;
|
|
43
43
|
discountType?: 'strike-through' | 'badge';
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
45
|
+
* Number of product cards per desktop row (1-12). Default: 4.
|
|
46
|
+
* Narrow screens (<=768px) keep the horizontally scrollable carousel behavior.
|
|
47
47
|
*/
|
|
48
48
|
gridColumns?: number;
|
|
49
49
|
/** Client-side abort cap for similar-products and grouping requests. Defaults to 120 seconds. */
|
|
@@ -104,7 +104,7 @@ export interface SimRelUISpecRenderContext {
|
|
|
104
104
|
renderCardElement?: (product: SimilarProduct, index: number) => HTMLElement | null;
|
|
105
105
|
i18n: SimRelI18n;
|
|
106
106
|
pricing?: import('../common/price-formatter.js').PriceFormatConfig;
|
|
107
|
-
/** ui_spec `ProductGrid`
|
|
107
|
+
/** Used when the ui_spec `ProductGrid` omits `columns` (widget `gridColumns`). */
|
|
108
108
|
gridColumns?: number;
|
|
109
109
|
}
|
|
110
110
|
export type SimRelRendererConfig = UISpecRendererOverrides<SimRelUISpecRenderContext>;
|
package/dist/simrel-runtime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A, j as S } from "./context-DGz5F81j.js";
|
|
2
2
|
import { n as $, t as _ } from "./price-formatter-xI3g9Cd4.js";
|
|
3
3
|
import { a as C, c as f, n as q, o as h, t as k, u as H } from "./schemas-CLo8wCjs.js";
|
|
4
|
-
import { o as j } from "./runtime-
|
|
4
|
+
import { o as j } from "./runtime-bbMljGVG.js";
|
|
5
5
|
var V = {
|
|
6
6
|
images: [
|
|
7
7
|
"images",
|