@gengage/assistant-fe 0.3.35 → 0.3.37
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/chat/components/ChatDrawer.d.ts +17 -10
- package/dist/chat/components/ComparisonTable.d.ts +2 -1
- package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +10 -0
- package/dist/chat/index.d.ts +4 -1
- package/dist/chat/session-persistence.d.ts +2 -1
- package/dist/chat/types.d.ts +1 -0
- package/dist/{chat-BVxo08xS.js → chat-BJu5cvMq.js} +2042 -1981
- package/dist/chat.iife.js +39 -39
- package/dist/chat.js +11 -10
- package/dist/common/action-router.d.ts +1 -0
- package/dist/common/locale.d.ts +1 -0
- package/dist/common/navigation.d.ts +5 -0
- package/dist/{common-dxI9x9_U.js → common-DxR7wUEx.js} +2 -2
- package/dist/common.js +41 -41
- package/dist/{connection-warning-CHHi3BAf.js → connection-warning-nm_yulO-.js} +9 -9
- package/dist/{ga-datalayer-BwxWX-cr.js → ga-datalayer-BUM5z5Pq.js} +65 -60
- package/dist/index.js +31 -31
- package/dist/{native-webview-CMsUMLah.js → native-webview-BFWh8f-u.js} +31 -31
- package/dist/native.iife.js +36 -36
- package/dist/native.js +1 -1
- package/dist/{product-utils-Bm3aiAlJ.js → price-formatter-CR6VT5z4.js} +27 -27
- package/dist/{qna-BuBvAr2H.js → qna-6_XrdLG_.js} +85 -85
- package/dist/qna.iife.js +6 -6
- package/dist/qna.js +1 -1
- package/dist/{schemas-DBRIy5NT.js → schemas-ZYhTx11k.js} +1 -1
- package/dist/{simbut-BBXTlzOg.js → simbut--wBhTxId.js} +29 -29
- package/dist/simbut.iife.js +7 -7
- package/dist/simbut.js +1 -1
- package/dist/simrel/index.d.ts +1 -0
- package/dist/simrel/types.d.ts +2 -0
- package/dist/simrel-jN_YPfC7.js +710 -0
- package/dist/simrel.iife.js +19 -19
- package/dist/simrel.js +1 -1
- package/package.json +2 -2
- package/dist/simrel-BRh5eB2K.js +0 -694
package/dist/qna.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
var l = { findSimilarLabel: "Benzerlerini Bul" },
|
|
3
|
-
function
|
|
4
|
-
return i?.findSimilarLabel ? i.findSimilarLabel : (t ?? "tr").toLowerCase().startsWith("en") ?
|
|
1
|
+
import { B as u, b as d, c as f, g as b, s as g, y as m } from "./ga-datalayer-BUM5z5Pq.js";
|
|
2
|
+
var l = { findSimilarLabel: "Benzerlerini Bul" }, S = { findSimilarLabel: "Find Similar" };
|
|
3
|
+
function p(t, i) {
|
|
4
|
+
return i?.findSimilarLabel ? i.findSimilarLabel : (t ?? "tr").toLowerCase().startsWith("en") ? S.findSimilarLabel : l.findSimilarLabel;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function s(t) {
|
|
7
7
|
const i = typeof t.sku == "string" && t.sku.length > 0 ? t.sku : void 0, o = typeof t.pageContext?.sku == "string" && t.pageContext.sku.length > 0 ? t.pageContext.sku : void 0;
|
|
8
8
|
return i ?? o;
|
|
9
9
|
}
|
|
10
|
-
var
|
|
10
|
+
var _ = class extends d {
|
|
11
11
|
constructor(...t) {
|
|
12
12
|
super(...t), this._button = null, this._label = l.findSimilarLabel;
|
|
13
13
|
}
|
|
14
14
|
async onInit(t) {
|
|
15
|
-
this._label =
|
|
15
|
+
this._label = p(t.locale, t.i18n), this.root.classList.add("gengage-simbut-root"), window.getComputedStyle(this.root).position === "static" && (this.root.style.position = "relative");
|
|
16
16
|
const i = document.createElement("button");
|
|
17
|
-
i.type = "button", i.className = "gengage-chat-find-similar-pill", i.textContent = this._label, this._button = i;
|
|
17
|
+
i.type = "button", i.className = "gengage-chat-find-similar-pill", i.lang = m(t.locale), i.textContent = this._label, this._button = i;
|
|
18
18
|
const o = () => {
|
|
19
|
-
i.disabled = !(
|
|
19
|
+
i.disabled = !(s(this.config) && (this.config.onFindSimilar || this.config.chat));
|
|
20
20
|
};
|
|
21
21
|
i.addEventListener("click", (h) => {
|
|
22
22
|
h.stopPropagation();
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
25
|
-
const a = this.config.imageUrl,
|
|
26
|
-
if (
|
|
27
|
-
this.config.onFindSimilar(
|
|
28
|
-
sku:
|
|
29
|
-
imageUrl:
|
|
30
|
-
} : { sku:
|
|
23
|
+
const e = s(this.config);
|
|
24
|
+
if (!e) return;
|
|
25
|
+
const a = this.config.imageUrl, n = typeof a == "string" && u(a) ? a : void 0;
|
|
26
|
+
if (b(this._label, "findSimilar"), g(e), this.config.onFindSimilar) {
|
|
27
|
+
this.config.onFindSimilar(n ? {
|
|
28
|
+
sku: e,
|
|
29
|
+
imageUrl: n
|
|
30
|
+
} : { sku: e });
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
const r = this.config.chat;
|
|
@@ -35,17 +35,17 @@ var p = class extends b {
|
|
|
35
35
|
const c = {
|
|
36
36
|
title: this._label,
|
|
37
37
|
type: "findSimilar",
|
|
38
|
-
payload:
|
|
39
|
-
sku:
|
|
40
|
-
image_url:
|
|
41
|
-
} : { sku:
|
|
38
|
+
payload: n ? {
|
|
39
|
+
sku: e,
|
|
40
|
+
image_url: n
|
|
41
|
+
} : { sku: e }
|
|
42
42
|
};
|
|
43
|
-
r.openWithAction(c, { sku:
|
|
44
|
-
}), this.root.appendChild(i), o(),
|
|
43
|
+
r.openWithAction(c, { sku: e });
|
|
44
|
+
}), this.root.appendChild(i), o(), f("simbut");
|
|
45
45
|
}
|
|
46
46
|
onUpdate(t) {
|
|
47
47
|
if (!this._button) return;
|
|
48
|
-
const i = !!
|
|
48
|
+
const i = !!s(this.config) && (!!this.config.onFindSimilar || !!this.config.chat);
|
|
49
49
|
this._button.disabled = !i;
|
|
50
50
|
}
|
|
51
51
|
hide() {
|
|
@@ -65,15 +65,15 @@ var p = class extends b {
|
|
|
65
65
|
}
|
|
66
66
|
setChat(t) {
|
|
67
67
|
if (this.config.chat = t, this._button) {
|
|
68
|
-
const i = !!
|
|
68
|
+
const i = !!s(this.config) && (!!this.config.onFindSimilar || !!this.config.chat);
|
|
69
69
|
this._button.disabled = !i;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
-
function
|
|
74
|
-
return new
|
|
73
|
+
function k() {
|
|
74
|
+
return new _();
|
|
75
75
|
}
|
|
76
76
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
k as n,
|
|
78
|
+
_ as t
|
|
79
79
|
};
|
package/dist/simbut.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(f){Object.defineProperty(f,Symbol.toStringTag,{value:"Module"});function S(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 C(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 k(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 I=["http:","https:"];function T(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return I.includes(t.protocol)}catch{return!1}}function m(e,t){const i=n=>{t(n.detail)};return window.addEventListener(e,i),()=>window.removeEventListener(e,i)}function E(){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 L(e){return{sessionId:e?.sessionId??E(),...e}}var b={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"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 M(e){return e?{...b,...e}:{...b}}var
|
|
1
|
+
(function(f){Object.defineProperty(f,Symbol.toStringTag,{value:"Module"});function S(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 C(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 k(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 I=["http:","https:"];function T(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return I.includes(t.protocol)}catch{return!1}}function m(e,t){const i=n=>{t(n.detail)};return window.addEventListener(e,i),()=>window.removeEventListener(e,i)}function E(){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 L(e){return{sessionId:e?.sessionId??E(),...e}}var b={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"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 M(e){return e?{...b,...e}:{...b}}var s={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))"},a="gengage-global-toast-root",_="gengage-global-toast-style",h="gengage-global-toast-root--visible",$=4200,R=1500,A=15e3,U=["--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"],y=!1,d=null;function F(){y||typeof window>"u"||typeof document>"u"||(y=!0,m("gengage:global:error",e=>{B(e)}))}function B(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;q();const i=V();O(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 r=document.createElement("div");r.className="gengage-global-toast-title",r.textContent=N(e.source);const o=document.createElement("div");o.className="gengage-global-toast-message",o.textContent=t,n.appendChild(r),n.appendChild(o),i.appendChild(n),i.classList.add(h),d&&(clearTimeout(d),d=null),e.sticky!==!0&&(d=setTimeout(()=>{D()},W(e.durationMs)))}function D(){if(typeof document>"u")return;const e=document.getElementById(a);e&&(e.classList.remove(h),e.innerHTML="",d&&(clearTimeout(d),d=null))}function N(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function V(){const e=document.getElementById(a);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=a,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function O(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 U){const r=i.getPropertyValue(n).trim();r?e.style.setProperty(n,r):e.style.removeProperty(n)}}function W(e){return typeof e!="number"||!Number.isFinite(e)?$:Math.min(A,Math.max(R,Math.round(e)))}function q(){if(document.getElementById(_))return;const e=document.createElement("style");e.id=_;const t=s["--surface-card"]??s.backgroundColor??"#ffffff",i=s["--text-primary"]??s.foregroundColor??"#111827",n=s["--border-default"]??"rgba(17, 24, 39, 0.10)",r=s["--error"]??"#dc2626",o=s["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",g=s["--radius-card"]??"16px",l=s["--text-muted"]??"#6b7280";e.textContent=`
|
|
2
2
|
#${a} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
top: 16px;
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
min-width: 260px;
|
|
14
14
|
max-width: min(92vw, 420px);
|
|
15
15
|
border-radius: var(--radius-card, ${g});
|
|
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, ${
|
|
16
|
+
border: 1px solid var(--ds-toast-error-border, color-mix(in srgb, var(--error, ${r}) 18%, var(--border-default, ${n})));
|
|
17
|
+
border-left: 4px solid var(--ds-toast-error-accent, var(--error, ${r}));
|
|
18
|
+
background: var(--ds-toast-error-bg, color-mix(in srgb, var(--error, ${r}) 5%, var(--surface-card, ${t})));
|
|
19
|
+
color: var(--ds-toast-error-fg, color-mix(in srgb, var(--error, ${r}) 22%, var(--text-primary, ${i})));
|
|
20
20
|
box-shadow: var(--ds-toast-error-shadow, var(--shadow-3, ${o}));
|
|
21
21
|
padding: 10px 12px;
|
|
22
|
-
font-family: var(--gengage-font-family, ${JSON.stringify(
|
|
22
|
+
font-family: var(--gengage-font-family, ${JSON.stringify(s.fontFamily??'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif')});
|
|
23
23
|
font-size: 13px;
|
|
24
24
|
line-height: 1.4;
|
|
25
25
|
animation: gengage-global-toast-in 180ms ease-out forwards;
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
transform: translateY(0);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,document.head.appendChild(e)}var c=null;function H(){if(c!==null)return c;try{c=localStorage.getItem("gengage:debug")==="1"}catch{c=!1}return c}function v(e,t,i){if(!H())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var G=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=M(e.theme);this.config={...e,theme:t,session:L(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),F();const i=m("gengage:context:update",n=>this.update(n));this._cleanups.push(i),v("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,v("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"?C:k;this.track(i(this.analyticsContext(),t))}flushMeteringSummary(e){this.track(S(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-${P(t)}`;this.root.style.setProperty(n,i)}}}};function P(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function z(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function p(e,t){const i={event:e,...t};
|
|
47
|
+
`,document.head.appendChild(e)}var c=null;function H(){if(c!==null)return c;try{c=localStorage.getItem("gengage:debug")==="1"}catch{c=!1}return c}function v(e,t,i){if(!H())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var G=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=M(e.theme);this.config={...e,theme:t,session:L(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),F();const i=m("gengage:context:update",n=>this.update(n));this._cleanups.push(i),v("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,v("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"?C:k;this.track(i(this.analyticsContext(),t))}flushMeteringSummary(e){this.track(S(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-${P(t)}`;this.root.style.setProperty(n,i)}}}};function P(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function z(e){const t=e?.trim();return t||"tr"}function Y(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function p(e,t){const i={event:e,...t};Y()&&window.dataLayer.push(i)}function j(e){p("gengage-on-init",{gengage_widget:e})}function J(e,t){p("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function K(e){p("gengage-find-similars",{gengage_sku:e})}var w={findSimilarLabel:"Benzerlerini Bul"},Q={findSimilarLabel:"Find Similar"};function X(e,t){return t?.findSimilarLabel?t.findSimilarLabel:(e??"tr").toLowerCase().startsWith("en")?Q.findSimilarLabel:w.findSimilarLabel}function u(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 x=class extends G{constructor(...e){super(...e),this._button=null,this._label=w.findSimilarLabel}async onInit(e){this._label=X(e.locale,e.i18n),this.root.classList.add("gengage-simbut-root"),window.getComputedStyle(this.root).position==="static"&&(this.root.style.position="relative");const t=document.createElement("button");t.type="button",t.className="gengage-chat-find-similar-pill",t.lang=z(e.locale),t.textContent=this._label,this._button=t;const i=()=>{t.disabled=!(u(this.config)&&(this.config.onFindSimilar||this.config.chat))};t.addEventListener("click",n=>{n.stopPropagation();const r=u(this.config);if(!r)return;const o=this.config.imageUrl,g=typeof o=="string"&&T(o)?o:void 0;if(J(this._label,"findSimilar"),K(r),this.config.onFindSimilar){this.config.onFindSimilar(g?{sku:r,imageUrl:g}:{sku:r});return}const l=this.config.chat;if(!l)return;const ee={title:this._label,type:"findSimilar",payload:g?{sku:r,image_url:g}:{sku:r}};l.openWithAction(ee,{sku:r})}),this.root.appendChild(t),i(),j("simbut")}onUpdate(e){if(!this._button)return;const t=!!u(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}hide(){this.isVisible&&(this.isVisible=!1,this._button&&(this._button.style.display="none"),this.onHide(),this.emit("hide"))}show(){this.isVisible||(this.isVisible=!0,this._button&&(this._button.style.display=""),this.onShow(),this.emit("show"))}_cleanupRoot(){}onShow(){}onHide(){}onDestroy(){this._button?.remove(),this._button=null}setChat(e){if(this.config.chat=e,this._button){const t=!!u(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!t}}};function Z(){return new x}f.GengageSimBut=x,f.createSimButWidget=Z})(this.Gengage=this.Gengage||{});
|
package/dist/simbut.js
CHANGED
package/dist/simrel/index.d.ts
CHANGED
package/dist/simrel/types.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface SimRelWidgetConfig extends BaseWidgetConfig {
|
|
|
46
46
|
* Dar ekranlarda (≤768px) yatay kaydırmalı carousel davranışı korunur.
|
|
47
47
|
*/
|
|
48
48
|
gridColumns?: number;
|
|
49
|
+
/** Client-side abort cap for similar-products and grouping requests. Defaults to 120 seconds. */
|
|
50
|
+
requestTimeoutMs?: number;
|
|
49
51
|
domain?: string;
|
|
50
52
|
/** Locale key for SDK defaults (for example 'tr', 'en'). */
|
|
51
53
|
locale?: string;
|