@gengage/assistant-fe 0.6.50 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/chat/api.d.ts +1 -1
  2. package/dist/chat/components/ChatDrawer.d.ts +3 -1
  3. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +1 -1
  4. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +7 -1
  5. package/dist/chat/history-storage.d.ts +36 -4
  6. package/dist/chat/runtime.d.ts +2 -2
  7. package/dist/chat/utils/chat-presentation-debug.d.ts +0 -14
  8. package/dist/chat-runtime.js +1 -1
  9. package/dist/chat.iife.js +56 -56
  10. package/dist/chat.js +1 -1
  11. package/dist/common/connection-warning.d.ts +10 -0
  12. package/dist/common/indexed-db.d.ts +35 -2
  13. package/dist/common/native-webview.d.ts +1 -1
  14. package/dist/common/streaming.d.ts +6 -1
  15. package/dist/common/transport.d.ts +2 -1
  16. package/dist/common/types.d.ts +16 -0
  17. package/dist/{common-DJFI5t11.js → common-CeuGSwJL.js} +61 -65
  18. package/dist/common.js +30 -30
  19. package/dist/{connection-warning-TXqyeFaf.js → connection-warning-C0e2byq5.js} +31 -25
  20. package/dist/{fastIntent-539wPavr.js → fastIntent-BI7l1oDv.js} +2 -2
  21. package/dist/global-error-toast-DvaKvPNA.js +798 -0
  22. package/dist/index.js +29 -29
  23. package/dist/native-webview-CHKpwixw.js +303 -0
  24. package/dist/native.iife.js +27 -27
  25. package/dist/native.js +1 -1
  26. package/dist/{overlay-BPZEIyo_.js → overlay-C3XzoSKd.js} +51 -32
  27. package/dist/overlay.js +6 -6
  28. package/dist/{price-formatter-CHUmYq8I.js → price-formatter-Q3wUKrl1.js} +2 -1
  29. package/dist/qna/runtime.d.ts +1 -0
  30. package/dist/qna-runtime.js +1 -1
  31. package/dist/qna.iife.js +32 -32
  32. package/dist/qna.js +1 -1
  33. package/dist/{request-response-cache-DwADBDeB.js → request-response-cache-BLQy7llq.js} +478 -454
  34. package/dist/{runtime-Do3qShrH.js → runtime-BC8-a6Ql.js} +231 -219
  35. package/dist/{runtime-9f9SB4WE.js → runtime-BSIrZhF2.js} +2783 -2692
  36. package/dist/{runtime-rTw1jMhB.js → runtime-DiONTdBz.js} +230 -212
  37. package/dist/{simbut-DlWvDoPI.js → simbut-BDbb3nMH.js} +5 -5
  38. package/dist/simbut.iife.js +2 -2
  39. package/dist/simbut.js +1 -1
  40. package/dist/simrel/components/GroupTabs.d.ts +6 -0
  41. package/dist/simrel/runtime.d.ts +8 -0
  42. package/dist/{simrel-BFPU2n5p.js → simrel-CdxDIKu3.js} +15 -15
  43. package/dist/simrel-runtime.js +1 -1
  44. package/dist/simrel.iife.js +22 -22
  45. package/dist/simrel.js +2 -2
  46. package/dist/widget-base-Cvxdrqqt.js +141 -0
  47. package/package.json +1 -1
  48. package/dist/context-UTzCGyR9.js +0 -543
  49. package/dist/native-webview-CYX30O3Q.js +0 -273
  50. package/dist/widget-base-BwU6SI2o.js +0 -365
@@ -1,5 +1,5 @@
1
- import { A as m, D as h, _ as u, j as f, v as p } from "./context-UTzCGyR9.js";
2
- import { t as b } from "./widget-base-BwU6SI2o.js";
1
+ import { L as m, P as h, R as u, T as f, w as p } from "./global-error-toast-DvaKvPNA.js";
2
+ import { t as b } from "./widget-base-Cvxdrqqt.js";
3
3
  import { t as y } from "./locale-uQ5XZ2yS.js";
4
4
  var g = { findSimilarLabel: "Benzerlerini Bul" }, _ = { findSimilarLabel: "Find Similar" };
5
5
  function S(t, n) {
@@ -26,8 +26,8 @@ var C = class extends b {
26
26
  l.stopPropagation();
27
27
  const s = d(this.config);
28
28
  if (!s) return;
29
- const a = this.config.imageUrl, o = typeof a == "string" && f(a) ? a : void 0;
30
- if (h(this._label, "findSimilar"), u(s), this.config.onFindSimilar) {
29
+ const a = this.config.imageUrl, o = typeof a == "string" && u(a) ? a : void 0;
30
+ if (h(this._label, "findSimilar"), p(s), this.config.onFindSimilar) {
31
31
  this.config.onFindSimilar(o ? {
32
32
  sku: s,
33
33
  imageUrl: o
@@ -46,7 +46,7 @@ var C = class extends b {
46
46
  const l = this._createInlineCard(t, i);
47
47
  this._inlineFrame = l, this.root.appendChild(l);
48
48
  } else this.root.appendChild(i);
49
- c(), p("simbut");
49
+ c(), f("simbut");
50
50
  }
51
51
  _createInlineCard(t, n) {
52
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");
@@ -1,4 +1,4 @@
1
- (function(m){Object.defineProperty(m,Symbol.toStringTag,{value:"Module"});var y=["http:","https:"];function I(e){const t=e.trim();if(!t)return!1;if(t.startsWith("/")&&!t.startsWith("//"))return!0;try{return y.includes(new URL(t).protocol)}catch{return!1}}function L(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return y.includes(t.protocol)}catch{return!1}}function T(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function p(e,t){const i={event:e,...t};T()&&window.dataLayer.push(i)}function k(e){p("gengage-on-init",{gengage_widget:e})}function F(e,t){p("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function R(e){p("gengage-find-similars",{gengage_sku:e})}function x(e,t){const i=n=>{t(n.detail)};return window.addEventListener(e,i),()=>window.removeEventListener(e,i)}function M(){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 N(e){return{sessionId:e?.sessionId??M(),...e}}var _={"--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 U(e){if(!e)return{..._};const t={..._,...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 l={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","--gengage-brand-accent-start":"#0b24d6","--gengage-brand-accent-mid":"#f768f2","--gengage-brand-accent-end":"#ffed74","--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))"},d="gengage-global-toast-root",w="gengage-global-toast-style",b="gengage-global-toast-root--visible",$=4200,A=1500,B=15e3,D=["--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"],v=!1,c=null;function O(){v||typeof window>"u"||typeof document>"u"||(v=!0,x("gengage:global:error",e=>{G(e)}))}function G(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;z();const i=V();H(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=P(e.source);const s=document.createElement("div");s.className="gengage-global-toast-message",s.textContent=t,n.appendChild(r),n.appendChild(s),i.appendChild(n),i.classList.add(b),c&&(clearTimeout(c),c=null),e.sticky!==!0&&(c=setTimeout(()=>{W()},q(e.durationMs)))}function W(){if(typeof document>"u")return;const e=document.getElementById(d);e&&(e.classList.remove(b),e.innerHTML="",c&&(clearTimeout(c),c=null))}function P(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(d);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=d,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function H(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 D){const r=i.getPropertyValue(n).trim();r?e.style.setProperty(n,r):e.style.removeProperty(n)}}function q(e){return typeof e!="number"||!Number.isFinite(e)?$:Math.min(B,Math.max(A,Math.round(e)))}function z(){if(document.getElementById(w))return;const e=document.createElement("style");e.id=w;const t=l["--surface-card"]??l.backgroundColor??"#ffffff",i=l["--text-primary"]??l.foregroundColor??"#111827",n=l["--border-default"]??"rgba(17, 24, 39, 0.10)",r=l["--error"]??"#dc2626",s=l["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",o=l["--radius-card"]??"16px",g=l["--text-muted"]??"#6b7280";e.textContent=`
1
+ (function(m){Object.defineProperty(m,Symbol.toStringTag,{value:"Module"});var y=["http:","https:"];function I(e){const t=e.trim();if(!t)return!1;if(t.startsWith("/")&&!t.startsWith("//"))return!0;try{return y.includes(new URL(t).protocol)}catch{return!1}}function L(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return y.includes(t.protocol)}catch{return!1}}function T(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function p(e,t){const i={event:e,...t};T()&&window.dataLayer.push(i)}function k(e){p("gengage-on-init",{gengage_widget:e})}function F(e,t){p("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function R(e){p("gengage-find-similars",{gengage_sku:e})}function w(e,t){const i=n=>{t(n.detail)};return window.addEventListener(e,i),()=>window.removeEventListener(e,i)}function M(){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 N(e){return{sessionId:e?.sessionId??M(),...e}}var _={"--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 U(e){if(!e)return{..._};const t={..._,...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 l={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","--gengage-brand-accent-start":"#0b24d6","--gengage-brand-accent-mid":"#f768f2","--gengage-brand-accent-end":"#ffed74","--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))"},d="gengage-global-toast-root",x="gengage-global-toast-style",b="gengage-global-toast-root--visible",$=4200,A=1500,B=15e3,D=["--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"],v=!1,c=null;function O(){v||typeof window>"u"||typeof document>"u"||(v=!0,w("gengage:global:error",e=>{G(e)}))}function G(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;z();const i=V();H(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=P(e.source);const s=document.createElement("div");s.className="gengage-global-toast-message",s.textContent=t,n.appendChild(r),n.appendChild(s),i.appendChild(n),i.classList.add(b),c&&(clearTimeout(c),c=null),e.sticky!==!0&&(c=setTimeout(()=>{W()},q(e.durationMs)))}function W(){if(typeof document>"u")return;const e=document.getElementById(d);e&&(e.classList.remove(b),e.innerHTML="",c&&(clearTimeout(c),c=null))}function P(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(d);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=d,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function H(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 D){const r=i.getPropertyValue(n).trim();r?e.style.setProperty(n,r):e.style.removeProperty(n)}}function q(e){return typeof e!="number"||!Number.isFinite(e)?$:Math.min(B,Math.max(A,Math.round(e)))}function z(){if(document.getElementById(x))return;const e=document.createElement("style");e.id=x;const t=l["--surface-card"]??l.backgroundColor??"#ffffff",i=l["--text-primary"]??l.foregroundColor??"#111827",n=l["--border-default"]??"rgba(17, 24, 39, 0.10)",r=l["--error"]??"#dc2626",s=l["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",o=l["--radius-card"]??"16px",g=l["--text-muted"]??"#6b7280";e.textContent=`
2
2
  #${d} {
3
3
  position: fixed;
4
4
  top: 16px;
@@ -44,4 +44,4 @@
44
44
  transform: translateY(0);
45
45
  }
46
46
  }
47
- `,document.head.appendChild(e)}var f=null;function Y(){if(f!==null)return f;try{f=localStorage.getItem("gengage:debug")==="1"}catch{f=!1}return f}function S(e,t,i){if(!Y())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var j=("0.6.50".trim(),"0.6.50".trim()),J=("iife-build".trim(),"iife-build".trim());function K(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${j} (${J})`))}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=U(e.theme);K(),this.config={...e,theme:t,session:N(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),O();const i=x("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._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)}emit(e,...t){this._handlers.get(e)?.forEach(i=>i(...t))}addCleanup(e){this._cleanups.push(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-${X(t)}`;this.root.style.setProperty(n,i)}}}};function X(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Z(e){const t=e?.trim();return t||"tr"}var C={findSimilarLabel:"Benzerlerini Bul"},ee={findSimilarLabel:"Find Similar"};function te(e,t){return t?.findSimilarLabel?t.findSimilarLabel:(e??"tr").toLowerCase().startsWith("en")?ee.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 Q{constructor(...e){super(...e),this._button=null,this._inlineFrame=null,this._label=C.findSimilarLabel}async onInit(e){this._label=te(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=Z(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",r=>{r.stopPropagation();const s=h(this.config);if(!s)return;const o=this.config.imageUrl,g=typeof o=="string"&&L(o)?o:void 0;if(F(this._label,"findSimilar"),R(s),this.config.onFindSimilar){this.config.onFindSimilar(g?{sku:s,imageUrl:g}:{sku:s});return}const u=this.config.chat;if(!u)return;const a={title:this._label,type:"findSimilar",payload:{sku:s}};u.openWithAction(a,{sku:s})}),t==="inline-card"){const r=this._createInlineCard(e,i);this._inlineFrame=r,this.root.appendChild(r)}else this.root.appendChild(i);n(),k("simbut")}_createInlineCard(e,t){const i=e.inlineCard,n=typeof i?.title=="string"?i.title.trim():"",r=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 a=document.createElement("h4");a.className="gengage-simbut-inline-title",a.dataset.gengagePart="simbut-inline-title",a.textContent=n,g.appendChild(a)}if(r){const a=document.createElement("p");a.className="gengage-simbut-inline-description",a.dataset.gengagePart="simbut-inline-description",a.textContent=r,g.appendChild(a)}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&&I(s)){const a=document.createElement("img");a.className="gengage-simbut-inline-image",a.dataset.gengagePart="simbut-inline-image",a.src=s,a.alt=typeof i?.imageAlt=="string"?i.imageAlt:"",a.loading="lazy",a.addEventListener("error",()=>{a.style.display="none"},{once:!0}),o.appendChild(a)}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 ie(){return new E}m.GengageSimBut=E,m.createSimButWidget=ie})(this.Gengage=this.Gengage||{});
47
+ `,document.head.appendChild(e)}var f=null;function Y(){if(f!==null)return f;try{f=localStorage.getItem("gengage:debug")==="1"}catch{f=!1}return f}function S(e,t,i){if(!Y())return;const n=[`[gengage:${e}]`,t];i!==void 0&&n.push(i),console.debug(...n)}var j=("0.7.0".trim(),"0.7.0".trim()),J=("iife-build".trim(),"iife-build".trim());function K(){typeof window>"u"||(window.gengage||(window.gengage={}),window.gengage.__internal||(window.gengage.__internal={}),!window.gengage.__internal.sdkRuntimeInfoLogged&&(window.gengage.__internal.sdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${j} (${J})`)))}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=U(e.theme);K(),this.config={...e,theme:t,session:N(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),O();const i=w("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._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)}emit(e,...t){this._handlers.get(e)?.forEach(i=>i(...t))}addCleanup(e){this._cleanups.push(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-${X(t)}`;this.root.style.setProperty(n,i)}}}};function X(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Z(e){const t=e?.trim();return t||"tr"}var C={findSimilarLabel:"Benzerlerini Bul"},ee={findSimilarLabel:"Find Similar"};function te(e,t){return t?.findSimilarLabel?t.findSimilarLabel:(e??"tr").toLowerCase().startsWith("en")?ee.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 Q{constructor(...e){super(...e),this._button=null,this._inlineFrame=null,this._label=C.findSimilarLabel}async onInit(e){this._label=te(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=Z(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",r=>{r.stopPropagation();const s=h(this.config);if(!s)return;const o=this.config.imageUrl,g=typeof o=="string"&&L(o)?o:void 0;if(F(this._label,"findSimilar"),R(s),this.config.onFindSimilar){this.config.onFindSimilar(g?{sku:s,imageUrl:g}:{sku:s});return}const u=this.config.chat;if(!u)return;const a={title:this._label,type:"findSimilar",payload:{sku:s}};u.openWithAction(a,{sku:s})}),t==="inline-card"){const r=this._createInlineCard(e,i);this._inlineFrame=r,this.root.appendChild(r)}else this.root.appendChild(i);n(),k("simbut")}_createInlineCard(e,t){const i=e.inlineCard,n=typeof i?.title=="string"?i.title.trim():"",r=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 a=document.createElement("h4");a.className="gengage-simbut-inline-title",a.dataset.gengagePart="simbut-inline-title",a.textContent=n,g.appendChild(a)}if(r){const a=document.createElement("p");a.className="gengage-simbut-inline-description",a.dataset.gengagePart="simbut-inline-description",a.textContent=r,g.appendChild(a)}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&&I(s)){const a=document.createElement("img");a.className="gengage-simbut-inline-image",a.dataset.gengagePart="simbut-inline-image",a.src=s,a.alt=typeof i?.imageAlt=="string"?i.imageAlt:"",a.loading="lazy",a.addEventListener("error",()=>{a.style.display="none"},{once:!0}),o.appendChild(a)}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 ie(){return new E}m.GengageSimBut=E,m.createSimButWidget=ie})(this.Gengage=this.Gengage||{});
package/dist/simbut.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as e, t as a } from "./simbut-DlWvDoPI.js";
1
+ import { n as e, t as a } from "./simbut-BDbb3nMH.js";
2
2
  export {
3
3
  a as GengageSimBut,
4
4
  e as createSimButWidget
@@ -21,4 +21,10 @@ export interface GroupTabsOptions {
21
21
  grouping_index: number;
22
22
  }) => void;
23
23
  }
24
+ /**
25
+ * Disconnect the ResizeObserver attached to a previously rendered GroupTabs
26
+ * container (if any). Safe to call multiple times or on elements that never had
27
+ * an observer. Call before discarding a GroupTabs DOM subtree.
28
+ */
29
+ export declare function disposeGroupTabs(container: HTMLElement): void;
24
30
  export declare function renderGroupTabs(options: GroupTabsOptions): HTMLElement;
@@ -50,6 +50,14 @@ export declare class GengageSimRel extends BaseWidget<SimRelWidgetConfig> {
50
50
  cartCode: string;
51
51
  }): Promise<void>;
52
52
  private _abort;
53
+ /**
54
+ * Disconnect ResizeObservers attached to any GroupTabs subtree currently
55
+ * mounted in the content element. Must run before the content is cleared or
56
+ * the widget is destroyed, otherwise each re-render leaks an observer. Covers
57
+ * both the default registry path and the default.ts override path (both keep
58
+ * the `simrel-groups` part marker from renderGroupTabs).
59
+ */
60
+ private _disposeRenderedGroupTabs;
53
61
  private _isSuperseded;
54
62
  private _emitSimilarProductsImpression;
55
63
  private _resolveRequestTimeoutMs;
@@ -1,8 +1,8 @@
1
- import { A, j as S } from "./context-UTzCGyR9.js";
2
- import { n as $, t as L } from "./price-formatter-CHUmYq8I.js";
1
+ import { L as A, R as S } from "./global-error-toast-DvaKvPNA.js";
2
+ import { n as $, t as _ } from "./price-formatter-Q3wUKrl1.js";
3
3
  import { a as C, c as f, n as q, o as h, t as k, u as H } from "./schemas-BnYUhYSy.js";
4
- import { o as j } from "./runtime-Do3qShrH.js";
5
- var V = {
4
+ import { o as V } from "./runtime-BC8-a6Ql.js";
5
+ var j = {
6
6
  images: [
7
7
  "images",
8
8
  "extras.images",
@@ -150,7 +150,7 @@ function z(e) {
150
150
  }, o = p(t.highlight);
151
151
  return o && (n.highlight = o), n;
152
152
  }
153
- function _(e, t) {
153
+ function L(e, t) {
154
154
  const r = typeof t == "string" ? t.split(".") : [...t];
155
155
  let a = e;
156
156
  for (const n of r) {
@@ -169,20 +169,20 @@ function _(e, t) {
169
169
  }
170
170
  function Q(e, t) {
171
171
  for (const r of t) {
172
- const a = _(e, r);
172
+ const a = L(e, r);
173
173
  if (a != null) return a;
174
174
  }
175
175
  }
176
176
  function w(e, t) {
177
177
  for (const r of t) {
178
- const a = F(_(e, r));
178
+ const a = F(L(e, r));
179
179
  if (a.length > 0) return a;
180
180
  }
181
181
  return [];
182
182
  }
183
183
  function y(e, t) {
184
184
  for (const r of t) {
185
- const a = _(e, r), n = p(a);
185
+ const a = L(e, r), n = p(a);
186
186
  if (n) return n;
187
187
  const o = F(a);
188
188
  if (o.length > 0) return o[0];
@@ -190,7 +190,7 @@ function y(e, t) {
190
190
  }
191
191
  function W(e, t) {
192
192
  for (const r of t) {
193
- const a = E(_(e, r));
193
+ const a = E(L(e, r));
194
194
  if (a) return a;
195
195
  }
196
196
  return null;
@@ -208,7 +208,7 @@ function R(e, t) {
208
208
  reviewLabel: e.labels?.review ?? ((r) => `${r} reviews`),
209
209
  specialPriceBadgeAlt: e.labels?.specialPriceBadgeAlt ?? "",
210
210
  fields: {
211
- ...V,
211
+ ...j,
212
212
  ...e.fields
213
213
  },
214
214
  media: e.media ?? {},
@@ -265,7 +265,7 @@ function Y(e, t, r) {
265
265
  a.className = "gengage-simrel-default-card-image";
266
266
  let n = null;
267
267
  return r.length > 0 && (n = document.createElement("img"), n.src = r[0], n.alt = t, n.loading = "lazy", $(n), a.appendChild(n)), r.length > 1 && n && (a.addEventListener("mousemove", (o) => {
268
- const i = a.getBoundingClientRect(), s = Math.min(Math.floor((o.clientX - i.left) / i.width * r.length), r.length - 1);
268
+ const i = a.getBoundingClientRect(), s = Math.max(0, Math.min(Math.floor((o.clientX - i.left) / i.width * r.length), r.length - 1));
269
269
  n?.dataset.hoverIdx !== String(s) && (n.dataset.hoverIdx = String(s), n.src = r[s], e.querySelectorAll(".gengage-simrel-default-card-image-dot").forEach((u, m) => u.classList.toggle("is-active", m === s)));
270
270
  }), a.addEventListener("mouseleave", () => {
271
271
  n && (delete n.dataset.hoverIdx, n.src = r[0], e.querySelectorAll(".gengage-simrel-default-card-image-dot").forEach((o, i) => o.classList.toggle("is-active", i === 0)));
@@ -364,16 +364,16 @@ function ne(e, t, r, a, n) {
364
364
  const m = document.createElement("div");
365
365
  if (m.className = "gengage-simrel-default-card-price", s) {
366
366
  const l = n === "inline" ? "gengage-simrel-default-card-price-old gengage-simrel-default-card-price-old--inline" : "gengage-simrel-default-card-price-old";
367
- m.appendChild(x("span", l, L(String(o), r.pricing)));
367
+ m.appendChild(x("span", l, _(String(o), r.pricing)));
368
368
  const c = document.createElement("div");
369
- if (c.className = "gengage-simrel-default-card-price-current-row", c.appendChild(x("span", "gengage-simrel-default-card-price-current", L(String(i), r.pricing))), t && r.media.specialPriceBadgeUrl && A(r.media.specialPriceBadgeUrl)) {
369
+ if (c.className = "gengage-simrel-default-card-price-current-row", c.appendChild(x("span", "gengage-simrel-default-card-price-current", _(String(i), r.pricing))), t && r.media.specialPriceBadgeUrl && A(r.media.specialPriceBadgeUrl)) {
370
370
  const d = document.createElement("img");
371
371
  d.src = r.media.specialPriceBadgeUrl, d.className = "gengage-simrel-default-card-special-price-badge", d.alt = r.specialPriceBadgeAlt, c.appendChild(d);
372
372
  }
373
373
  m.appendChild(c);
374
374
  } else {
375
375
  const l = o ?? i;
376
- m.appendChild(x("span", "gengage-simrel-default-card-price-current", l !== void 0 ? L(String(l), r.pricing) : ""));
376
+ m.appendChild(x("span", "gengage-simrel-default-card-price-current", l !== void 0 ? _(String(l), r.pricing) : ""));
377
377
  }
378
378
  if (u.appendChild(m), r.ctaLabel) {
379
379
  const l = document.createElement("button");
@@ -444,7 +444,7 @@ function se(e, t) {
444
444
  index: m,
445
445
  context: e.context,
446
446
  config: o
447
- }), s = j({
447
+ }), s = V({
448
448
  groups: a,
449
449
  onClick: e.context.onClick,
450
450
  onAddToCart: e.context.onAddToCart,
@@ -1,4 +1,4 @@
1
- import { a, i as r, n as i, r as t, t as S } from "./runtime-Do3qShrH.js";
1
+ import { a, i as r, n as i, r as t, t as S } from "./runtime-BC8-a6Ql.js";
2
2
  export {
3
3
  S as GengageSimRel,
4
4
  t as createDefaultSimRelUISpecRegistry,