@gengage/assistant-fe 0.3.35 → 0.3.36

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 (32) hide show
  1. package/dist/chat/components/ChatDrawer.d.ts +17 -10
  2. package/dist/chat/components/ComparisonTable.d.ts +2 -1
  3. package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +10 -0
  4. package/dist/chat/index.d.ts +4 -1
  5. package/dist/chat/session-persistence.d.ts +2 -1
  6. package/dist/chat/types.d.ts +1 -0
  7. package/dist/{chat-BVxo08xS.js → chat-BJu5cvMq.js} +2042 -1981
  8. package/dist/chat.iife.js +39 -39
  9. package/dist/chat.js +11 -10
  10. package/dist/common/action-router.d.ts +1 -0
  11. package/dist/common/locale.d.ts +1 -0
  12. package/dist/common/navigation.d.ts +5 -0
  13. package/dist/{common-dxI9x9_U.js → common-C50zU8bu.js} +2 -2
  14. package/dist/common.js +41 -41
  15. package/dist/{connection-warning-CHHi3BAf.js → connection-warning-nm_yulO-.js} +9 -9
  16. package/dist/{ga-datalayer-BwxWX-cr.js → ga-datalayer-BUM5z5Pq.js} +65 -60
  17. package/dist/index.js +31 -31
  18. package/dist/{native-webview-CMsUMLah.js → native-webview-CrnoI_JS.js} +31 -31
  19. package/dist/native.iife.js +36 -36
  20. package/dist/native.js +1 -1
  21. package/dist/{product-utils-Bm3aiAlJ.js → price-formatter-CR6VT5z4.js} +27 -27
  22. package/dist/{qna-BuBvAr2H.js → qna-6_XrdLG_.js} +85 -85
  23. package/dist/qna.iife.js +6 -6
  24. package/dist/qna.js +1 -1
  25. package/dist/{schemas-DBRIy5NT.js → schemas-ZYhTx11k.js} +1 -1
  26. package/dist/{simbut-BBXTlzOg.js → simbut--wBhTxId.js} +29 -29
  27. package/dist/simbut.iife.js +7 -7
  28. package/dist/simbut.js +1 -1
  29. package/dist/{simrel-BRh5eB2K.js → simrel-5I3yDyyo.js} +65 -65
  30. package/dist/simrel.iife.js +5 -5
  31. package/dist/simrel.js +1 -1
  32. package/package.json +2 -2
package/dist/qna.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a, i as n, n as r, o as t, r as s, t as o } from "./qna-BuBvAr2H.js";
1
+ import { a, i as n, n as r, o as t, r as s, t as o } from "./qna-6_XrdLG_.js";
2
2
  export {
3
3
  o as GengageQNA,
4
4
  n as createDefaultQnaUISpecRegistry,
@@ -1,4 +1,4 @@
1
- import { b as Tt } from "./ga-datalayer-BwxWX-cr.js";
1
+ import { x as Tt } from "./ga-datalayer-BUM5z5Pq.js";
2
2
  var It = ({ element: e, renderElement: t }) => {
3
3
  if (!e.children || e.children.length === 0) return null;
4
4
  const r = document.createElement("div");
@@ -1,33 +1,33 @@
1
- import { c as u, g as d, s as f, y as b, z as g } from "./ga-datalayer-BwxWX-cr.js";
2
- var l = { findSimilarLabel: "Benzerlerini Bul" }, m = { findSimilarLabel: "Find Similar" };
3
- function S(t, i) {
4
- return i?.findSimilarLabel ? i.findSimilarLabel : (t ?? "tr").toLowerCase().startsWith("en") ? m.findSimilarLabel : l.findSimilarLabel;
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 e(t) {
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 p = class extends b {
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 = S(t.locale, t.i18n), this.root.classList.add("gengage-simbut-root"), window.getComputedStyle(this.root).position === "static" && (this.root.style.position = "relative");
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 = !(e(this.config) && (this.config.onFindSimilar || this.config.chat));
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 n = e(this.config);
24
- if (!n) return;
25
- const a = this.config.imageUrl, s = typeof a == "string" && g(a) ? a : void 0;
26
- if (d(this._label, "findSimilar"), f(n), this.config.onFindSimilar) {
27
- this.config.onFindSimilar(s ? {
28
- sku: n,
29
- imageUrl: s
30
- } : { sku: n });
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: s ? {
39
- sku: n,
40
- image_url: s
41
- } : { sku: n }
38
+ payload: n ? {
39
+ sku: e,
40
+ image_url: n
41
+ } : { sku: e }
42
42
  };
43
- r.openWithAction(c, { sku: n });
44
- }), this.root.appendChild(i), o(), u("simbut");
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 = !!e(this.config) && (!!this.config.onFindSimilar || !!this.config.chat);
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 = !!e(this.config) && (!!this.config.onFindSimilar || !!this.config.chat);
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 y() {
74
- return new p();
73
+ function k() {
74
+ return new _();
75
75
  }
76
76
  export {
77
- y as n,
78
- p as t
77
+ k as n,
78
+ _ as t
79
79
  };
@@ -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 r={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 s=document.createElement("div");s.className="gengage-global-toast-title",s.textContent=N(e.source);const o=document.createElement("div");o.className="gengage-global-toast-message",o.textContent=t,n.appendChild(s),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 s=i.getPropertyValue(n).trim();s?e.style.setProperty(n,s):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=r["--surface-card"]??r.backgroundColor??"#ffffff",i=r["--text-primary"]??r.foregroundColor??"#111827",n=r["--border-default"]??"rgba(17, 24, 39, 0.10)",s=r["--error"]??"#dc2626",o=r["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",g=r["--radius-card"]??"16px",l=r["--text-muted"]??"#6b7280";e.textContent=`
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, ${s}) 18%, var(--border-default, ${n})));
17
- border-left: 4px solid var(--ds-toast-error-accent, var(--error, ${s}));
18
- background: var(--ds-toast-error-bg, color-mix(in srgb, var(--error, ${s}) 5%, var(--surface-card, ${t})));
19
- color: var(--ds-toast-error-fg, color-mix(in srgb, var(--error, ${s}) 22%, var(--text-primary, ${i})));
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(r.fontFamily??'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif')});
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};z()&&window.dataLayer.push(i)}function Y(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 J(e){p("gengage-find-similars",{gengage_sku:e})}var w={findSimilarLabel:"Benzerlerini Bul"},K={findSimilarLabel:"Find Similar"};function Q(e,t){return t?.findSimilarLabel?t.findSimilarLabel:(e??"tr").toLowerCase().startsWith("en")?K.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=Q(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.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 s=u(this.config);if(!s)return;const o=this.config.imageUrl,g=typeof o=="string"&&T(o)?o:void 0;if(j(this._label,"findSimilar"),J(s),this.config.onFindSimilar){this.config.onFindSimilar(g?{sku:s,imageUrl:g}:{sku:s});return}const l=this.config.chat;if(!l)return;const Z={title:this._label,type:"findSimilar",payload:g?{sku:s,image_url:g}:{sku:s}};l.openWithAction(Z,{sku:s})}),this.root.appendChild(t),i(),Y("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 X(){return new x}f.GengageSimBut=x,f.createSimButWidget=X})(this.Gengage=this.Gengage||{});
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
@@ -1,4 +1,4 @@
1
- import { n as e, t as a } from "./simbut-BBXTlzOg.js";
1
+ import { n as e, t as a } from "./simbut--wBhTxId.js";
2
2
  export {
3
3
  a as GengageSimBut,
4
4
  e as createSimButWidget
@@ -1,7 +1,7 @@
1
- import { S as F, a as S, b as U, c as C, d as x, h as z, m as $, n as W, o as E, p as M, t as G, u as J, w as Q } from "./schemas-DBRIy5NT.js";
2
- import { H as V, P as T, Q as Y, R as X, S as Z, V as K, X as P, Z as ee, c as te, et as A, h as L, p as ne, t as re, y as ie } from "./ga-datalayer-BwxWX-cr.js";
3
- import { a as R, i as ae, n as se, t as oe } from "./product-utils-Bm3aiAlJ.js";
4
- import { n as ce } from "./connection-warning-CHHi3BAf.js";
1
+ import { S as F, a as S, b as U, c as C, d as x, h as z, m as $, n as W, o as E, p as M, t as G, u as J, w as Q } from "./schemas-ZYhTx11k.js";
2
+ import { $ as Y, C as V, F as w, H as Z, Q as K, U as X, Z as P, b as ee, c as te, h as A, p as ne, t as re, tt as L, y as ie, z as ae } from "./ga-datalayer-BUM5z5Pq.js";
3
+ import { a as se, n as oe, r as ce, t as R } from "./price-formatter-CR6VT5z4.js";
4
+ import { n as de } from "./connection-warning-nm_yulO-.js";
5
5
  function O(e) {
6
6
  const t = [];
7
7
  for (const n of Object.values(e)) if (n.type === "ProductCard" && n.props) {
@@ -14,14 +14,14 @@ function B(e) {
14
14
  const t = e.headers.get("Content-Type") ?? "";
15
15
  return t.includes("application/x-ndjson") || t.includes("text/event-stream");
16
16
  }
17
- async function de(e, t) {
17
+ async function le(e, t) {
18
18
  const n = [], r = { onEvent: (a) => {
19
19
  const s = M(a);
20
20
  !s || s.type !== "ui_spec" || n.push(...O(s.spec.elements));
21
21
  } };
22
22
  return t !== void 0 && (r.signal = t), await U(e, r), n;
23
23
  }
24
- async function le(e, t, n) {
24
+ async function ge(e, t, n) {
25
25
  const r = x("similar_products", t), a = {
26
26
  method: "POST",
27
27
  headers: { "Content-Type": "application/json" },
@@ -30,7 +30,7 @@ async function le(e, t, n) {
30
30
  n !== void 0 && (a.signal = n);
31
31
  const s = await fetch(r, a);
32
32
  if (!s.ok) throw new Error(`HTTP ${s.status}: ${s.statusText}`);
33
- if (B(s)) return de(s, n);
33
+ if (B(s)) return le(s, n);
34
34
  const o = await s.text();
35
35
  if (!o) throw new Error("Empty response body from similar_products endpoint");
36
36
  try {
@@ -39,7 +39,7 @@ async function le(e, t, n) {
39
39
  throw new Error("Invalid JSON from similar_products endpoint");
40
40
  }
41
41
  }
42
- async function ge(e, t) {
42
+ async function ue(e, t) {
43
43
  const n = [];
44
44
  let r = null;
45
45
  const a = { onEvent: (s) => {
@@ -61,7 +61,7 @@ async function ge(e, t) {
61
61
  } };
62
62
  return t !== void 0 && (a.signal = t), await U(e, a), n;
63
63
  }
64
- async function ue(e, t, n) {
64
+ async function pe(e, t, n) {
65
65
  const r = x("product_groupings", t), a = {
66
66
  method: "POST",
67
67
  headers: { "Content-Type": "application/json" },
@@ -70,7 +70,7 @@ async function ue(e, t, n) {
70
70
  n !== void 0 && (a.signal = n);
71
71
  const s = await fetch(r, a);
72
72
  if (!s.ok) throw new Error(`HTTP ${s.status}: ${s.statusText}`);
73
- if (B(s)) return ge(s, n);
73
+ if (B(s)) return ue(s, n);
74
74
  const o = await s.text();
75
75
  if (!o) return [];
76
76
  try {
@@ -87,20 +87,20 @@ function D(e) {
87
87
  }
88
88
  if (o) {
89
89
  const i = document.createElement("div");
90
- return i.className = "gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive", i.dataset.gengagePart = "simrel-product-card", i.innerHTML = K(o(t, n)), i.addEventListener("click", (u) => {
90
+ return i.className = "gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive", i.dataset.gengagePart = "simrel-product-card", i.innerHTML = Z(o(t, n)), i.addEventListener("click", (u) => {
91
91
  u.target.closest(".gengage-simrel-atc") || u.target.closest(".gengage-chat-product-card-atc") || a(t);
92
92
  }), i;
93
93
  }
94
94
  const c = document.createElement("article");
95
95
  c.className = "gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive", c.dataset.gengagePart = "simrel-product-card", t.inStock === !1 && c.classList.add("gengage-simrel-card--out-of-stock"), c.setAttribute("role", "listitem"), c.dataset.sku = t.sku;
96
96
  const g = document.createElement("div");
97
- if (g.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", g.dataset.gengagePart = "simrel-product-card-image", t.imageUrl && X(t.imageUrl)) {
97
+ if (g.className = "gengage-simrel-card-image gengage-chat-product-card-img-wrapper", g.dataset.gengagePart = "simrel-product-card-image", t.imageUrl && ae(t.imageUrl)) {
98
98
  const i = document.createElement("img");
99
99
  i.className = "gengage-chat-product-card-img", i.src = t.imageUrl, i.alt = t.name, i.loading = "lazy", oe(i), g.appendChild(i);
100
100
  }
101
101
  if (r === "badge" && t.discountPercent && t.discountPercent > 0) {
102
102
  const i = document.createElement("span");
103
- i.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", i.textContent = `%${se(t.discountPercent)}`, g.appendChild(i);
103
+ i.className = "gengage-simrel-badge gengage-chat-product-card-discount-badge", i.textContent = `%${ce(t.discountPercent)}`, g.appendChild(i);
104
104
  }
105
105
  c.appendChild(g);
106
106
  const m = document.createElement("div");
@@ -111,7 +111,7 @@ function D(e) {
111
111
  const f = document.createElement("div");
112
112
  if (f.className = "gengage-simrel-card-name gengage-chat-product-card-name", f.textContent = t.name, f.title = t.name, m.appendChild(f), t.rating != null && t.rating > 0) {
113
113
  const i = document.createElement("div");
114
- if (i.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", i.appendChild(ae(t.rating)), t.reviewCount != null) {
114
+ if (i.className = "gengage-simrel-card-rating gengage-chat-product-card-rating", i.appendChild(se(t.rating)), t.reviewCount != null) {
115
115
  const u = document.createElement("span");
116
116
  u.className = "gengage-simrel-card-review-count gengage-chat-product-card-review-count", u.textContent = ` (${t.reviewCount})`, i.appendChild(u);
117
117
  }
@@ -163,9 +163,9 @@ function N(e) {
163
163
  }
164
164
  return e.products.length === 0 && (t.style.display = "none", t.dataset.empty = "true"), t;
165
165
  }
166
- var pe = 0;
167
- function me(e) {
168
- const t = pe++, n = document.createElement("div");
166
+ var me = 0;
167
+ function fe(e) {
168
+ const t = me++, n = document.createElement("div");
169
169
  if (n.className = "gengage-simrel-groups", n.dataset.gengagePart = "simrel-groups", e.groups.length === 0)
170
170
  return n.style.display = "none", n.dataset.empty = "true", n;
171
171
  const r = document.createElement("div");
@@ -184,21 +184,21 @@ function me(e) {
184
184
  }
185
185
  const u = e.groups[i], v = s[i];
186
186
  v.innerHTML = "";
187
- const w = N(o(u));
188
- v.appendChild(w);
187
+ const T = N(o(u));
188
+ v.appendChild(T);
189
189
  for (let p = 0; p < s.length; p++) {
190
190
  const y = p === i;
191
191
  s[p].style.display = y ? "" : "none", s[p].tabIndex = y ? 0 : -1;
192
192
  }
193
193
  };
194
194
  for (let i = 0; i < e.groups.length; i++) {
195
- const u = e.groups[i], v = `gengage-simrel-tab-${t}-${i}`, w = `gengage-simrel-panel-${t}-${i}`, p = document.createElement("button");
196
- p.className = "gengage-simrel-tab gds-tab", p.type = "button", p.dataset.gengagePart = "simrel-tab", p.id = v, p.textContent = u.name, p.setAttribute("role", "tab"), p.setAttribute("aria-controls", w), p.setAttribute("aria-selected", String(i === 0)), p.tabIndex = i === 0 ? 0 : -1, i === 0 && p.classList.add("gengage-simrel-tab--active"), p.addEventListener("click", () => d(i)), p.addEventListener("keydown", (k) => {
195
+ const u = e.groups[i], v = `gengage-simrel-tab-${t}-${i}`, T = `gengage-simrel-panel-${t}-${i}`, p = document.createElement("button");
196
+ p.className = "gengage-simrel-tab gds-tab", p.type = "button", p.dataset.gengagePart = "simrel-tab", p.id = v, p.textContent = u.name, p.setAttribute("role", "tab"), p.setAttribute("aria-controls", T), p.setAttribute("aria-selected", String(i === 0)), p.tabIndex = i === 0 ? 0 : -1, i === 0 && p.classList.add("gengage-simrel-tab--active"), p.addEventListener("click", () => d(i)), p.addEventListener("keydown", (k) => {
197
197
  let _ = -1;
198
198
  k.key === "ArrowRight" || k.key === "ArrowDown" ? _ = (i + 1) % e.groups.length : k.key === "ArrowLeft" || k.key === "ArrowUp" ? _ = (i - 1 + e.groups.length) % e.groups.length : k.key === "Home" ? _ = 0 : k.key === "End" && (_ = e.groups.length - 1), _ >= 0 && (k.preventDefault(), d(_), a[_].focus());
199
199
  }), a.push(p), r.appendChild(p);
200
200
  const y = document.createElement("div");
201
- y.className = "gengage-simrel-tab-panel", y.dataset.gengagePart = "simrel-tab-panel", y.id = w, y.setAttribute("role", "tabpanel"), y.setAttribute("aria-labelledby", v), y.tabIndex = i === 0 ? 0 : -1, i !== 0 && (y.style.display = "none"), s.push(y);
201
+ y.className = "gengage-simrel-tab-panel", y.dataset.gengagePart = "simrel-tab-panel", y.id = T, y.setAttribute("role", "tabpanel"), y.setAttribute("aria-labelledby", v), y.tabIndex = i === 0 ? 0 : -1, i !== 0 && (y.style.display = "none"), s.push(y);
202
202
  }
203
203
  const l = document.createElement("button");
204
204
  l.type = "button", l.className = "gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--left", l.setAttribute("aria-label", e.i18n?.scrollTabsLeft ?? "Scroll tabs left"), l.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>';
@@ -257,7 +257,7 @@ function I(e) {
257
257
  const f = t.extras;
258
258
  return f != null && typeof f == "object" && (n.extras = f), n;
259
259
  }
260
- function fe(e) {
260
+ function he(e) {
261
261
  if (!e || typeof e != "object") return null;
262
262
  const t = e, n = t.title, r = t.type;
263
263
  if (typeof n != "string" || typeof r != "string") return null;
@@ -321,7 +321,7 @@ var j = {
321
321
  onAddToCart: t.onAddToCart,
322
322
  i18n: t.i18n
323
323
  }, s = e.props?.columns;
324
- return typeof s == "number" && Number.isFinite(s) && s > 0 ? a.columns = Math.floor(s) : typeof t.gridColumns == "number" && Number.isFinite(t.gridColumns) && t.gridColumns > 0 && (a.columns = Math.floor(t.gridColumns)), t.discountType !== void 0 && (a.discountType = t.discountType), t.renderCard !== void 0 && (a.renderCard = t.renderCard), t.renderCardElement !== void 0 && (a.renderCardElement = t.renderCardElement), me(a);
324
+ return typeof s == "number" && Number.isFinite(s) && s > 0 ? a.columns = Math.floor(s) : typeof t.gridColumns == "number" && Number.isFinite(t.gridColumns) && t.gridColumns > 0 && (a.columns = Math.floor(t.gridColumns)), t.discountType !== void 0 && (a.discountType = t.discountType), t.renderCard !== void 0 && (a.renderCard = t.renderCard), t.renderCardElement !== void 0 && (a.renderCardElement = t.renderCardElement), fe(a);
325
325
  },
326
326
  EmptyState: ({ element: e, context: t }) => {
327
327
  const n = document.createElement("div");
@@ -350,7 +350,7 @@ var j = {
350
350
  if (!Array.isArray(r) || !t.onAction) return n;
351
351
  for (const a of r) {
352
352
  if (!a || typeof a != "object") continue;
353
- const s = a, o = s.label, d = fe(s.action);
353
+ const s = a, o = s.label, d = he(s.action);
354
354
  if (typeof o != "string" || !d) continue;
355
355
  const l = document.createElement("button");
356
356
  l.className = "gengage-simrel-quick-action", l.type = "button", l.textContent = o, l.addEventListener("click", (c) => {
@@ -368,10 +368,10 @@ var j = {
368
368
  }
369
369
  return n;
370
370
  };
371
- function he() {
371
+ function ye() {
372
372
  return { ...j };
373
373
  }
374
- function ye(e, t, n = j, r = H) {
374
+ function Ce(e, t, n = j, r = H) {
375
375
  return Q({
376
376
  spec: e,
377
377
  context: t,
@@ -393,7 +393,7 @@ var q = {
393
393
  priceSuffix: " TL",
394
394
  scrollTabsLeft: "Sola kaydır",
395
395
  scrollTabsRight: "Sağa kaydır"
396
- }, Ce = {
396
+ }, be = {
397
397
  similarProductsAriaLabel: "Similar products",
398
398
  emptyStateMessage: "No similar products found.",
399
399
  addToCartButton: "Add to cart",
@@ -407,13 +407,13 @@ var q = {
407
407
  scrollTabsLeft: "Scroll tabs left",
408
408
  scrollTabsRight: "Scroll tabs right"
409
409
  };
410
- function be(e) {
410
+ function ve(e) {
411
411
  return e ? e.toLowerCase().split("-")[0] ?? "tr" : "tr";
412
412
  }
413
- function ve(e) {
414
- return be(e) === "en" ? Ce : q;
413
+ function Ee(e) {
414
+ return ve(e) === "en" ? be : q;
415
415
  }
416
- var Ee = E({
416
+ var ke = E({
417
417
  sku: C(),
418
418
  name: C(),
419
419
  imageUrl: C().url().optional(),
@@ -424,14 +424,14 @@ var Ee = E({
424
424
  brand: C().optional(),
425
425
  rating: S().min(0).max(5).optional(),
426
426
  reviewCount: S().int().nonnegative().optional()
427
- }), ke = E({
427
+ }), _e = E({
428
428
  layout: G(["grid", "carousel"]).optional(),
429
429
  columns: S().int().positive().optional()
430
- }), _e = E({
431
- product: Ee,
430
+ }), Se = E({
431
+ product: ke,
432
432
  index: S().int().nonnegative(),
433
433
  discountType: G(["strike-through", "badge"]).optional()
434
- }), Se = E({
434
+ }), Te = E({
435
435
  sku: C(),
436
436
  label: C().optional(),
437
437
  cartCode: C()
@@ -442,17 +442,17 @@ var Ee = E({
442
442
  type: C(),
443
443
  payload: J().optional()
444
444
  })
445
- })) }), Te = E({ message: C().optional() }), Ie = { components: {
445
+ })) }), Pe = E({ message: C().optional() }), Ue = { components: {
446
446
  ProductGrid: {
447
- schema: ke,
447
+ schema: _e,
448
448
  description: "Outer grid or carousel container for similar products."
449
449
  },
450
450
  ProductCard: {
451
- schema: _e,
451
+ schema: Se,
452
452
  description: "A single product card with image, title, price, and actions."
453
453
  },
454
454
  AddToCartButton: {
455
- schema: Se,
455
+ schema: Te,
456
456
  description: "Add-to-cart CTA rendered inside or below a product card."
457
457
  },
458
458
  QuickActions: {
@@ -460,15 +460,15 @@ var Ee = E({
460
460
  description: "A row of quick-action buttons below product info."
461
461
  },
462
462
  EmptyState: {
463
- schema: Te,
463
+ schema: Pe,
464
464
  description: "Empty state shown when no similar products are available."
465
465
  }
466
- } }, Pe = class extends ie {
466
+ } }, Ae = class extends ee {
467
467
  constructor(...e) {
468
468
  super(...e), this._abortController = null, this._contentEl = null, this._lastResultCount = -1, this._i18n = q;
469
469
  }
470
470
  async onInit(e) {
471
- this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this._contentEl.dataset.gengagePart = "simrel-container";
471
+ this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-simrel-container", this._contentEl.dataset.gengagePart = "simrel-container", this._contentEl.lang = ie(e.locale);
472
472
  const t = this._clampGridColumns(e.gridColumns);
473
473
  t !== void 0 && this._contentEl.style.setProperty("--gengage-simrel-columns", String(t)), this.root.appendChild(this._contentEl), this._lastSku = e.sku, await this._fetchAndRender(e.sku), te("simrel");
474
474
  }
@@ -495,14 +495,14 @@ var Ee = E({
495
495
  if (e.imageUrl !== void 0 && (t.imageUrl = e.imageUrl), e.price !== void 0 && (t.price = e.price), e.originalPrice !== void 0 && (t.originalPrice = e.originalPrice), e.discountPercent !== void 0 && (t.discountPercent = e.discountPercent), e.brand !== void 0 && (t.brand = e.brand), e.rating !== void 0 && (t.rating = e.rating), e.reviewCount !== void 0 && (t.reviewCount = e.reviewCount), e.cartCode !== void 0 && (t.cartCode = e.cartCode), e.inStock !== void 0 && (t.inStock = e.inStock), this.config.onProductClick?.(t) === !1) return;
496
496
  ne(e.sku, e.name);
497
497
  const n = this.config.session?.sessionId ?? null;
498
- T("gengage:similar:product-click", {
498
+ w("gengage:similar:product-click", {
499
499
  sku: e.sku,
500
500
  url: e.url,
501
501
  sessionId: n
502
502
  }), this.config.onProductNavigate?.(e.url, e.sku, n);
503
503
  }
504
504
  _handleAddToCart(e) {
505
- re(e.sku, e.quantity), this.config.onAddToCart?.(e), T("gengage:similar:add-to-cart", e), this.track(V(this.analyticsContext(), {
505
+ re(e.sku, e.quantity), this.config.onAddToCart?.(e), w("gengage:similar:add-to-cart", e), this.track(X(this.analyticsContext(), {
506
506
  attribution_source: "simrel",
507
507
  attribution_action_id: crypto.randomUUID(),
508
508
  cart_value: 0,
@@ -526,7 +526,7 @@ var Ee = E({
526
526
  r.className = "gengage-simrel-loading", r.dataset.gengagePart = "simrel-loading";
527
527
  const a = document.createElement("div");
528
528
  a.className = "gengage-simrel-spinner", a.dataset.gengagePart = "simrel-loading-spinner", r.appendChild(a), this._contentEl.appendChild(r);
529
- const s = { middlewareUrl: this.config.middlewareUrl }, o = crypto.randomUUID(), d = Date.now(), l = ce({
529
+ const s = { middlewareUrl: this.config.middlewareUrl }, o = crypto.randomUUID(), d = Date.now(), l = de({
530
530
  source: "simrel",
531
531
  locale: this.config.locale
532
532
  });
@@ -543,10 +543,10 @@ var Ee = E({
543
543
  sku: e
544
544
  };
545
545
  this.config.domain !== void 0 && (c.domain = this.config.domain);
546
- const g = await le(c, s, t);
546
+ const g = await ge(c, s, t);
547
547
  if (this._lastResultCount = g.length, !this._contentEl) return;
548
548
  if (this._contentEl.innerHTML = "", g.length > 0) try {
549
- const m = g.map((h) => h.sku), f = new Map(g.map((h) => [h.sku, h])), b = (await ue({
549
+ const m = g.map((h) => h.sku), f = new Map(g.map((h) => [h.sku, h])), b = (await pe({
550
550
  account_id: this.config.accountId,
551
551
  session_id: this.config.session?.sessionId ?? "",
552
552
  correlation_id: this.config.session?.sessionId ?? "",
@@ -560,12 +560,12 @@ var Ee = E({
560
560
  })).filter((h) => h.products.length > 0);
561
561
  if (b.length > 0 && this._contentEl) {
562
562
  const h = this._buildGroupsSpec(b), i = this._renderUISpec(h);
563
- this._contentEl.appendChild(i), L("simrel"), this.track(P(this.analyticsContext(), {
563
+ this._contentEl.appendChild(i), A("simrel"), this.track(P(this.analyticsContext(), {
564
564
  request_id: o,
565
565
  latency_ms: Date.now() - d,
566
566
  chunk_count: b.reduce((u, v) => u + v.products.length, 0),
567
567
  widget: "simrel"
568
- })), this.track(A(this.analyticsContext(), {
568
+ })), this.track(L(this.analyticsContext(), {
569
569
  message_count: b.reduce((u, v) => u + v.products.length, 0),
570
570
  history_ref: o,
571
571
  redaction_level: "none",
@@ -580,12 +580,12 @@ var Ee = E({
580
580
  const m = this._buildProductsSpec(g), f = this._renderUISpec(m);
581
581
  this._contentEl.appendChild(f);
582
582
  }
583
- g.length > 0 && L("simrel"), this.track(P(this.analyticsContext(), {
583
+ g.length > 0 && A("simrel"), this.track(P(this.analyticsContext(), {
584
584
  request_id: o,
585
585
  latency_ms: Date.now() - d,
586
586
  chunk_count: g.length,
587
587
  widget: "simrel"
588
- })), this.track(A(this.analyticsContext(), {
588
+ })), this.track(L(this.analyticsContext(), {
589
589
  message_count: g.length,
590
590
  history_ref: o,
591
591
  redaction_level: "none",
@@ -593,11 +593,11 @@ var Ee = E({
593
593
  }));
594
594
  } catch (c) {
595
595
  if (c instanceof DOMException && c.name === "AbortError" && this._isSuperseded(t)) return;
596
- if (T("gengage:global:error", {
596
+ if (w("gengage:global:error", {
597
597
  source: "simrel",
598
598
  code: "FETCH_ERROR",
599
- message: Z(this.config.locale, c)
600
- }), this.track(ee(this.analyticsContext(), {
599
+ message: V(this.config.locale, c)
600
+ }), this.track(K(this.analyticsContext(), {
601
601
  request_id: o,
602
602
  error_code: "FETCH_ERROR",
603
603
  error_message: c instanceof Error ? c.message : String(c),
@@ -623,12 +623,12 @@ var Ee = E({
623
623
  }
624
624
  _resolveI18n(e) {
625
625
  return {
626
- ...ve(e.locale),
626
+ ...Ee(e.locale),
627
627
  ...e.i18n
628
628
  };
629
629
  }
630
630
  _resolveUISpecRegistry() {
631
- return F(he(), this.config.renderer?.registry);
631
+ return F(ye(), this.config.renderer?.registry);
632
632
  }
633
633
  _buildRenderContext() {
634
634
  const e = this.config.renderCard, t = {
@@ -641,7 +641,7 @@ var Ee = E({
641
641
  return n !== void 0 && (t.gridColumns = n), t;
642
642
  }
643
643
  _renderUISpec(e) {
644
- const t = this._resolveUISpecRegistry(), n = this._buildRenderContext(), r = this.config.renderer?.unknownRenderer ?? H, a = (o, d) => ye(o, d, t, r), s = this.config.renderer?.renderUISpec;
644
+ const t = this._resolveUISpecRegistry(), n = this._buildRenderContext(), r = this.config.renderer?.unknownRenderer ?? H, a = (o, d) => Ce(o, d, t, r), s = this.config.renderer?.renderUISpec;
645
645
  return s ? s(e, n, {
646
646
  registry: t,
647
647
  unknownRenderer: r,
@@ -681,14 +681,14 @@ var Ee = E({
681
681
  };
682
682
  }
683
683
  };
684
- function Ue() {
685
- return new Pe();
684
+ function xe() {
685
+ return new Ae();
686
686
  }
687
687
  export {
688
688
  H as a,
689
- he as i,
690
- Ue as n,
691
- ye as o,
692
- Ie as r,
693
- Pe as t
689
+ ye as i,
690
+ xe as n,
691
+ Ce as o,
692
+ Ue as r,
693
+ Ae as t
694
694
  };