@gengage/assistant-fe 0.6.42 → 0.6.45

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 (38) hide show
  1. package/dist/chat/components/ChatDrawer.d.ts +5 -1
  2. package/dist/chat/components/productMentionLinker.d.ts +5 -5
  3. package/dist/chat/runtime.d.ts +4 -1
  4. package/dist/chat/types.d.ts +18 -0
  5. package/dist/chat-runtime.js +1 -1
  6. package/dist/chat.iife.js +12 -12
  7. package/dist/chat.js +1 -1
  8. package/dist/common/overlay.d.ts +1 -0
  9. package/dist/common/transport.d.ts +1 -0
  10. package/dist/common/types.d.ts +1 -0
  11. package/dist/{common-B9n_o9ki.js → common-BqApfsJV.js} +2 -2
  12. package/dist/common.js +7 -7
  13. package/dist/{connection-warning-ByY3TKaG.js → connection-warning-B829KlSR.js} +1 -1
  14. package/dist/{fastIntent-BaNC2CJz.js → fastIntent-DtopsdAD.js} +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +12 -12
  17. package/dist/{native-webview-Ch9lsx7E.js → native-webview-CYX30O3Q.js} +1 -1
  18. package/dist/native.iife.js +8 -8
  19. package/dist/native.js +1 -1
  20. package/dist/{overlay-CPLLn1eK.js → overlay-BPZEIyo_.js} +1 -1
  21. package/dist/overlay.js +1 -1
  22. package/dist/qna-runtime.js +1 -1
  23. package/dist/qna.iife.js +8 -8
  24. package/dist/qna.js +1 -1
  25. package/dist/request-response-cache-DIu22gmN.js +1491 -0
  26. package/dist/{runtime-_ly8XVXC.js → runtime-5Iu4s-BA.js} +1206 -1153
  27. package/dist/{runtime-CmpEARET.js → runtime-BmIfwBR6.js} +3 -3
  28. package/dist/{runtime-BkqUiRUi.js → runtime-Dly7YrGI.js} +3 -3
  29. package/dist/{simbut-CltMk2OF.js → simbut-DN8UCH7t.js} +1 -1
  30. package/dist/simbut.iife.js +2 -2
  31. package/dist/simbut.js +1 -1
  32. package/dist/{simrel-BuCc53Pw.js → simrel-DGfunNnJ.js} +1 -1
  33. package/dist/simrel-runtime.js +1 -1
  34. package/dist/simrel.iife.js +3 -3
  35. package/dist/simrel.js +2 -2
  36. package/dist/{widget-base-vDXD27_n.js → widget-base-DH9dsYIO.js} +4 -1
  37. package/package.json +1 -1
  38. package/dist/request-response-cache-DkilqELR.js +0 -1475
@@ -1,9 +1,9 @@
1
- import { a as j, f as L, g as F, i as I, m as q, n as N, o as z, t as R } from "./request-response-cache-DkilqELR.js";
1
+ import { a as j, f as L, g as F, i as I, m as q, n as N, o as z, t as R } from "./request-response-cache-DIu22gmN.js";
2
2
  import { A as D, E as S, N as H, a as k, l as $, v as W } from "./context-UTzCGyR9.js";
3
- import { o as J, t as K } from "./widget-base-vDXD27_n.js";
3
+ import { o as J, t as K } from "./widget-base-DH9dsYIO.js";
4
4
  import { t as Q } from "./locale-uQ5XZ2yS.js";
5
5
  import { a as V, n as Y, r as X, t as A } from "./price-formatter-CHUmYq8I.js";
6
- import { n as Z } from "./connection-warning-ByY3TKaG.js";
6
+ import { n as Z } from "./connection-warning-B829KlSR.js";
7
7
  function M(e) {
8
8
  const t = [];
9
9
  for (const n of Object.values(e)) if (n.type === "ProductCard" && n.props) {
@@ -1,8 +1,8 @@
1
- import { f as x, g as Q, i as R, m as N, n as H, t as O } from "./request-response-cache-DkilqELR.js";
1
+ import { f as x, g as Q, i as R, m as N, n as H, t as O } from "./request-response-cache-DIu22gmN.js";
2
2
  import { A as U, D as j, E as M, a as q, v as F } from "./context-UTzCGyR9.js";
3
- import { o as W, t as D } from "./widget-base-vDXD27_n.js";
3
+ import { o as W, t as D } from "./widget-base-DH9dsYIO.js";
4
4
  import { t as A } from "./locale-uQ5XZ2yS.js";
5
- import { n as z } from "./connection-warning-ByY3TKaG.js";
5
+ import { n as z } from "./connection-warning-B829KlSR.js";
6
6
  async function $(t, e, n) {
7
7
  const o = H("launcher_action", e), i = {
8
8
  uiSpecs: [],
@@ -1,5 +1,5 @@
1
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-vDXD27_n.js";
2
+ import { t as b } from "./widget-base-DH9dsYIO.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) {
@@ -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","--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 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=`
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.42".trim(),"0.6.42".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.6.45".trim(),"0.6.45".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||{});
package/dist/simbut.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as e, t as a } from "./simbut-CltMk2OF.js";
1
+ import { n as e, t as a } from "./simbut-DN8UCH7t.js";
2
2
  export {
3
3
  a as GengageSimBut,
4
4
  e as createSimButWidget
@@ -1,7 +1,7 @@
1
1
  import { A, j as S } from "./context-UTzCGyR9.js";
2
2
  import { n as $, t as L } from "./price-formatter-CHUmYq8I.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-CmpEARET.js";
4
+ import { o as j } from "./runtime-BmIfwBR6.js";
5
5
  var V = {
6
6
  images: [
7
7
  "images",
@@ -1,4 +1,4 @@
1
- import { a, i as r, n as i, r as t, t as S } from "./runtime-CmpEARET.js";
1
+ import { a, i as r, n as i, r as t, t as S } from "./runtime-BmIfwBR6.js";
2
2
  export {
3
3
  S as GengageSimRel,
4
4
  t as createDefaultSimRelUISpecRegistry,