@gengage/assistant-fe 0.6.40 → 0.6.42

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 (33) hide show
  1. package/dist/chat/catalog.d.ts +1 -1
  2. package/dist/chat/components/ChatDrawer.d.ts +9 -2
  3. package/dist/chat/history-storage.d.ts +3 -0
  4. package/dist/chat/panel-manager.d.ts +7 -0
  5. package/dist/chat/runtime.d.ts +3 -0
  6. package/dist/chat/session-persistence.d.ts +2 -0
  7. package/dist/chat/types.d.ts +1 -0
  8. package/dist/chat-runtime.js +1 -1
  9. package/dist/chat.iife.js +37 -37
  10. package/dist/chat.js +1 -1
  11. package/dist/common/indexed-db.d.ts +3 -0
  12. package/dist/{common-DfAGSY36.js → common-B9n_o9ki.js} +1 -1
  13. package/dist/common.js +5 -5
  14. package/dist/{connection-warning-CXGTkX7f.js → connection-warning-ByY3TKaG.js} +1 -1
  15. package/dist/{fastIntent-Cj9pb-XJ.js → fastIntent-BaNC2CJz.js} +1 -1
  16. package/dist/index.js +10 -10
  17. package/dist/native.iife.js +13 -13
  18. package/dist/qna-runtime.js +1 -1
  19. package/dist/qna.iife.js +1 -1
  20. package/dist/qna.js +1 -1
  21. package/dist/{request-response-cache-Bc0acP64.js → request-response-cache-DkilqELR.js} +1 -1
  22. package/dist/{runtime-BuEjhF-4.js → runtime-BkqUiRUi.js} +3 -3
  23. package/dist/{runtime-8xoIKpil.js → runtime-CmpEARET.js} +3 -3
  24. package/dist/{runtime-BIMNnYje.js → runtime-_ly8XVXC.js} +2252 -2184
  25. package/dist/{simbut-DMd--dzI.js → simbut-CltMk2OF.js} +1 -1
  26. package/dist/simbut.iife.js +1 -1
  27. package/dist/simbut.js +1 -1
  28. package/dist/{simrel-C4X5Yp32.js → simrel-BuCc53Pw.js} +1 -1
  29. package/dist/simrel-runtime.js +1 -1
  30. package/dist/simrel.iife.js +1 -1
  31. package/dist/simrel.js +2 -2
  32. package/dist/{widget-base-C5udoWCy.js → widget-base-vDXD27_n.js} +1 -1
  33. package/package.json +1 -1
@@ -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-C5udoWCy.js";
2
+ import { t as b } from "./widget-base-vDXD27_n.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) {
@@ -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.40".trim(),"0.6.40".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.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||{});
package/dist/simbut.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as e, t as a } from "./simbut-DMd--dzI.js";
1
+ import { n as e, t as a } from "./simbut-CltMk2OF.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-8xoIKpil.js";
4
+ import { o as j } from "./runtime-CmpEARET.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-8xoIKpil.js";
1
+ import { a, i as r, n as i, r as t, t as S } from "./runtime-CmpEARET.js";
2
2
  export {
3
3
  S as GengageSimRel,
4
4
  t as createDefaultSimRelUISpecRegistry,
@@ -44,7 +44,7 @@
44
44
  transform: translateY(0);
45
45
  }
46
46
  }
47
- `,document.head.appendChild(e)}var se=null;function Un(){if(se!==null)return se;try{se=localStorage.getItem("gengage:debug")==="1"}catch{se=!1}return se}function Ge(e,t,r){if(!Un())return;const n=[`[gengage:${e}]`,t];r!==void 0&&n.push(r),console.debug(...n)}var jn=("0.6.40".trim(),"0.6.40".trim()),Mn=("iife-build".trim(),"iife-build".trim());function Fn(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${jn} (${Mn})`))}var Bn=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=Cn(e.theme);Fn(),this.config={...e,theme:t,session:En(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),Nn();const r=vt("gengage:context:update",n=>this.update(n));this._cleanups.push(r),Ge("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,Ge("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(r=>r(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const r=document.querySelector(e);if(!r)throw new Error(`[gengage] Mount target not found: "${e}"`);return r}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,r]of Object.entries(e))if(r!==void 0){const n=t.startsWith("--")?t:`--gengage-${Gn(t)}`;this.root.style.setProperty(n,r)}}}};function Gn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function qn(e){const t=e?.trim();return t||"tr"}var Jn=8e3,Vn=5e3,Wn="https://www.google.com/favicon.ico",F=new Map,Ct=!1,re=null,ce=null,X=!1;function Hn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function Tt(e){return Hn(e)?"İnternet bağlantısında sorun var gibi görünüyor. İstek sürerken yeniden deneyeceğiz.":"Your internet connection looks unstable. We'll keep retrying while this request is active."}function xt(){let e;for(const t of F.values())e=t;return e}function qe(){re&&(clearTimeout(re),re=null)}function Kn(){ce&&(clearInterval(ce),ce=null)}async function zt(){try{if(typeof navigator<"u"&&navigator.onLine===!1)return!1;if(typeof window<"u"){const r=window.location.hostname;if(r==="localhost"||r==="127.0.0.1")return navigator.onLine}const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);try{return await fetch(Wn,{method:"HEAD",mode:"no-cors",cache:"no-cache",signal:e.signal}),!0}catch{return navigator.onLine}finally{clearTimeout(t)}}catch{return typeof navigator>"u"?!0:navigator.onLine}}function ke(){X=!1,Kn(),Et()}function Se(){re||X||F.size===0||(re=setTimeout(async()=>{re=null,!(X||F.size===0)&&!await zt()&&F.size>0&&(X=!0,Be({source:"sdk",message:Tt(xt()),sticky:!0}),ce||(ce=setInterval(async()=>{if(F.size===0){ke();return}await zt()&&(ke(),Se())},Vn)))},Jn))}function Yn(){Ct||typeof window>"u"||(Ct=!0,window.addEventListener("online",()=>{ke(),Se()}),window.addEventListener("offline",()=>{F.size===0||X||(X=!0,qe(),Be({source:"sdk",message:Tt(xt()),sticky:!0}))}))}function Xn(e){Yn();const t=Symbol(e.source);F.set(t,e.locale),Se();let r=!1;return()=>{if(!r){if(r=!0,F.delete(t),F.size===0){qe(),ke();return}X||(qe(),Se())}}}var Qn={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function eo(e){if(e===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const t=e.trim();return t===""?"":t.replace(/\/+$/,"")}function At(e,t){return`${eo(t?.middlewareUrl)}/chat${Qn[e]}`}function Pt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function to(e){const t=[];let r=0,n=!1,o=!1,i=0;for(let a=0;a<e.length;a++){const s=e[a];if(o){o=!1;continue}if(s==="\\"&&n){o=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&r++,s==="}"&&(r--,r===0&&(t.push(e.slice(i,a+1)),i=a+1)))}return t.length>0?t:[e]}function It(e,t){const r=e.trim();if(!r||r.startsWith(":"))return!1;const n=r.startsWith("data: ")?r.slice(6):r;if(n==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(n);return Pt(o)?(Ge("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=to(n);if(o.length>1){for(const i of o)try{const a=JSON.parse(i);if(!Pt(a))continue;if(t.onEvent(a),a.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function $t(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const r=e.body.getReader(),n=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,a=Symbol("idle-timeout");let s=!1;try{for(;;){const c=r.read();let u;const l=await(i>0?Promise.race([c.then(h=>(clearTimeout(u),h)),new Promise(h=>{u=setTimeout(()=>h(a),i)})]):c);if(l===a){s=!0,await r.cancel();break}const{done:d,value:f}=l;if(d)break;o+=n.decode(f,{stream:!0});const m=o.split(`
47
+ `,document.head.appendChild(e)}var se=null;function Un(){if(se!==null)return se;try{se=localStorage.getItem("gengage:debug")==="1"}catch{se=!1}return se}function Ge(e,t,r){if(!Un())return;const n=[`[gengage:${e}]`,t];r!==void 0&&n.push(r),console.debug(...n)}var jn=("0.6.42".trim(),"0.6.42".trim()),Mn=("iife-build".trim(),"iife-build".trim());function Fn(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${jn} (${Mn})`))}var Bn=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=Cn(e.theme);Fn(),this.config={...e,theme:t,session:En(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),Nn();const r=vt("gengage:context:update",n=>this.update(n));this._cleanups.push(r),Ge("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,Ge("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(r=>r(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const r=document.querySelector(e);if(!r)throw new Error(`[gengage] Mount target not found: "${e}"`);return r}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,r]of Object.entries(e))if(r!==void 0){const n=t.startsWith("--")?t:`--gengage-${Gn(t)}`;this.root.style.setProperty(n,r)}}}};function Gn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function qn(e){const t=e?.trim();return t||"tr"}var Jn=8e3,Vn=5e3,Wn="https://www.google.com/favicon.ico",F=new Map,Ct=!1,re=null,ce=null,X=!1;function Hn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function Tt(e){return Hn(e)?"İnternet bağlantısında sorun var gibi görünüyor. İstek sürerken yeniden deneyeceğiz.":"Your internet connection looks unstable. We'll keep retrying while this request is active."}function xt(){let e;for(const t of F.values())e=t;return e}function qe(){re&&(clearTimeout(re),re=null)}function Kn(){ce&&(clearInterval(ce),ce=null)}async function zt(){try{if(typeof navigator<"u"&&navigator.onLine===!1)return!1;if(typeof window<"u"){const r=window.location.hostname;if(r==="localhost"||r==="127.0.0.1")return navigator.onLine}const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);try{return await fetch(Wn,{method:"HEAD",mode:"no-cors",cache:"no-cache",signal:e.signal}),!0}catch{return navigator.onLine}finally{clearTimeout(t)}}catch{return typeof navigator>"u"?!0:navigator.onLine}}function ke(){X=!1,Kn(),Et()}function Se(){re||X||F.size===0||(re=setTimeout(async()=>{re=null,!(X||F.size===0)&&!await zt()&&F.size>0&&(X=!0,Be({source:"sdk",message:Tt(xt()),sticky:!0}),ce||(ce=setInterval(async()=>{if(F.size===0){ke();return}await zt()&&(ke(),Se())},Vn)))},Jn))}function Yn(){Ct||typeof window>"u"||(Ct=!0,window.addEventListener("online",()=>{ke(),Se()}),window.addEventListener("offline",()=>{F.size===0||X||(X=!0,qe(),Be({source:"sdk",message:Tt(xt()),sticky:!0}))}))}function Xn(e){Yn();const t=Symbol(e.source);F.set(t,e.locale),Se();let r=!1;return()=>{if(!r){if(r=!0,F.delete(t),F.size===0){qe(),ke();return}X||(qe(),Se())}}}var Qn={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function eo(e){if(e===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const t=e.trim();return t===""?"":t.replace(/\/+$/,"")}function At(e,t){return`${eo(t?.middlewareUrl)}/chat${Qn[e]}`}function Pt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function to(e){const t=[];let r=0,n=!1,o=!1,i=0;for(let a=0;a<e.length;a++){const s=e[a];if(o){o=!1;continue}if(s==="\\"&&n){o=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&r++,s==="}"&&(r--,r===0&&(t.push(e.slice(i,a+1)),i=a+1)))}return t.length>0?t:[e]}function It(e,t){const r=e.trim();if(!r||r.startsWith(":"))return!1;const n=r.startsWith("data: ")?r.slice(6):r;if(n==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(n);return Pt(o)?(Ge("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=to(n);if(o.length>1){for(const i of o)try{const a=JSON.parse(i);if(!Pt(a))continue;if(t.onEvent(a),a.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function $t(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const r=e.body.getReader(),n=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,a=Symbol("idle-timeout");let s=!1;try{for(;;){const c=r.read();let u;const l=await(i>0?Promise.race([c.then(h=>(clearTimeout(u),h)),new Promise(h=>{u=setTimeout(()=>h(a),i)})]):c);if(l===a){s=!0,await r.cancel();break}const{done:d,value:f}=l;if(d)break;o+=n.decode(f,{stream:!0});const m=o.split(`
48
48
  `);o=m.pop()??"";for(const h of m)if(It(h,t))return}if(o.trim()&&It(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||r.releaseLock()}t.onDone?.()}var ro=7200*1e3,Nt=200,no=5*1024*1024,oo="gengage_request_response_cache",io=1,U="responses",ao=new Set(["addToCart","like"]),j=new Map,Ot=null;async function Lt(e,t={},r={}){const n=so(e,t);if(!n)return fetch(e,t);const o=Date.now(),i=await fo(n,o);if(i)return mo(i);const a=await fetch(e,t);return a.ok&&po(n,a.clone(),o,{ttlMs:r.ttlMs??ro,maxEntries:r.maxEntries??Nt,maxBodyBytes:r.maxBodyBytes??no}),a}function so(e,t={}){if(typeof Request<"u"&&e instanceof Request)return null;const r=String(t.method||"GET").toUpperCase();if(r!=="POST"||typeof t.body!="string")return null;const n=co(t.body);if(uo(n))return null;const o=lo(n);if(o){const i=ue(n?.action);return`rr:${Ut(Dt({url:String(e),method:r,headers:Rt(t.headers),type:n?.type??i?.type??"",account_id:n?.account_id??n?.accountId??"",locale:n?.locale??"",outputLanguage:ue(n?.meta)?.outputLanguage??"",cache_key:o}))}`}return`rr:${Ut(Dt({url:String(e),method:r,headers:Rt(t.headers),body:t.body}))}`}function co(e){try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function uo(e){const t=e?.type;return typeof t=="string"&&ao.has(t)}function lo(e){const t=(ue(e?.payload)??ue(ue(e?.action)?.payload))?.cache_key;return typeof t=="string"&&t.trim().length>0?t.trim():null}async function fo(e,t){const r=j.get(e);if(r)if(r.expiresAt<=t)j.delete(e);else return r.lastAccessedAt=t,j.delete(e),j.set(e,r),Je(r),r;const n=await yo(e);return n?n.expiresAt<=t?(j.delete(e),_o(e),null):(n.lastAccessedAt=t,j.set(e,n),Je(n),Zt(Nt),n):null}async function po(e,t,r,n){try{const o=await t.text();if(bo(o)>n.maxBodyBytes||go(o))return;const i={key:e,status:t.status,statusText:t.statusText,headers:ho(t.headers),body:o,createdAt:r,expiresAt:r+n.ttlMs,lastAccessedAt:r};j.set(e,i),Zt(n.maxEntries),await Je(i),await vo(n.maxEntries,r)}catch{}}function go(e){return/"_error"\s*:/u.test(e)||/"type"\s*:\s*"error"/u.test(e)}function mo(e){return new Response(e.body,{status:e.status,statusText:e.statusText,headers:new Headers(e.headers)})}function Rt(e){const t=new Headers(e),r=[];return t.forEach((n,o)=>{const i=o.toLowerCase();i!=="authorization"&&i!=="cookie"&&r.push([i,n])}),r.sort(([n],[o])=>n.localeCompare(o))}function ho(e){const t=[];return e.forEach((r,n)=>{const o=n.toLowerCase();o!=="set-cookie"&&t.push([o,r])}),t.sort(([r],[n])=>r.localeCompare(n))}function Zt(e){for(;j.size>e;){const t=[...j.values()].sort((r,n)=>r.lastAccessedAt-n.lastAccessedAt)[0];if(!t)break;j.delete(t.key)}}async function Ee(){return typeof indexedDB>"u"?null:(Ot??=new Promise(e=>{const t=indexedDB.open(oo,io);t.onupgradeneeded=()=>{const r=t.result;r.objectStoreNames.contains(U)||r.createObjectStore(U,{keyPath:"key"}).createIndex("lastAccessedAt","lastAccessedAt",{unique:!1})},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}),Ot)}async function yo(e){const t=await Ee();return t?new Promise(r=>{const n=t.transaction(U,"readonly"),o=n.objectStore(U).get(e);o.onsuccess=()=>r(o.result??null),o.onerror=()=>r(null),n.onerror=()=>r(null)}):null}async function Je(e){const t=await Ee();t&&await new Promise(r=>{const n=t.transaction(U,"readwrite");n.objectStore(U).put(e),n.oncomplete=()=>r(),n.onerror=()=>r(),n.onabort=()=>r()})}async function _o(e){const t=await Ee();t&&await new Promise(r=>{const n=t.transaction(U,"readwrite");n.objectStore(U).delete(e),n.oncomplete=()=>r(),n.onerror=()=>r(),n.onabort=()=>r()})}async function vo(e,t){const r=await Ee();r&&await new Promise(n=>{const o=r.transaction(U,"readwrite"),i=o.objectStore(U),a=[],s=i.openCursor();s.onsuccess=()=>{const c=s.result;if(!c){const u=a.filter(d=>d.expiresAt<=t),l=a.filter(d=>d.expiresAt>t).sort((d,f)=>d.lastAccessedAt-f.lastAccessedAt).slice(0,Math.max(0,a.length-u.length-e));for(const d of[...u,...l])i.delete(d.key);return}a.push(c.value),c.continue()},s.onerror=()=>n(),o.oncomplete=()=>n(),o.onerror=()=>n(),o.onabort=()=>n()})}function Dt(e){return JSON.stringify(Ve(e))}function ue(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Ve(e){return Array.isArray(e)?e.map(Ve):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,Ve(r)]))}function Ut(e){let t=14695981039346656037n;const r=1099511628211n;for(let n=0;n<e.length;n+=1)t^=BigInt(e.charCodeAt(n)),t=BigInt.asUintN(64,t*r);return t.toString(16).padStart(16,"0")}function bo(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).byteLength:e.length}var jt=3,wo=(e,t)=>{const r=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!r)return"";const n=t?.stripLeadingStopWords?r.replace(/^(?:daha|için)\s+/i,"").trim():r;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},We=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(r=>wo(r,t)).filter(Boolean):[];function ko(e){const t=(e.display_keywords??[]).flatMap(o=>We(o,{stripLeadingStopWords:!0})),r=t.filter((o,i)=>t.indexOf(o)===i);if(r.length>0)return r.slice(0,jt);const n=[...We(e.chosen_attribute,{stripLeadingStopWords:!0}),...We(e.short_name)];return n.filter((o,i)=>n.indexOf(o)===i).slice(0,jt)}function So(e){return ko(e).join(" • ")}function Eo(e){return e==="beauty_consulting"||e==="account_expert"}function le(...e){for(const t of e){if(typeof t!="string")continue;const r=t.trim();if(r.length>0)return r}}function de(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim()):[]}function Ce(e){const t={...e},r=le(t.sku),n=de(t.group_skus);if(r?t.sku=r:delete t.sku,n.length>0?t.group_skus=n:delete t.group_skus,r||n.length>0)delete t.image_url;else{const o=le(t.image_url);o?t.image_url=o:delete t.image_url}return t}function Mt(e){if(typeof e.type!="string")return null;if(Co(e))return e;const t=e;switch(t.type){case"outputText":return To(t);case"suggestedActions":return xo(t);case"productList":return zo(t);case"productDetails":return Ao(t);case"productDetailsSimilars":return Po(t);case"comparisonTable":return Io(t);case"context":return Lo(t);case"chatStreamEnd":return Ro();case"loading":return Zo(t);case"panelLoading":return Do(t);case"similarLoading":return Uo(t);case"redirect":return jo(t);case"error":return Mo(t);case"dummy":return Fo(t);case"launcherAction":return Bo(t);case"text":return He(t);case"productItem":return Go(t);case"text_image":return Ft(t);case"quick_qna":return Bt(t);case"reviewHighlights":return qo(t);case"aiProductSuggestions":return Wo(t);case"aiProductGroupings":return Ho(t);case"aiSuggestedSearches":return Xo(t);case"prosAndCons":return Jo(t);case"getGroundingReview":return Qo(t);case"voice":return ti(t);case"visitorDataResponse":return Vo(t);case"productListPreview":return ei();case"groupList":return ri(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return ni(t);case"launcherContent":return ii(t);case"handoff":return oi(t);case"uiSpec":return mi(t);default:return null}}function Co(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const r=e.widget;if(r!=="chat"&&r!=="qna"&&r!=="simrel")return!1;const n=$(e.spec);return n?typeof n.root=="string"&&$(n.elements)!==null:!1}case"action":{const r=$(e.action);return r!==null&&typeof r.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function To(e){const t=w(e.payload.text,e.payload.plain_text)??"",r=w(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:r||"Backend returned an error"};const n={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(n.productMentions=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const a=e.payload.conversation_mode;typeof a=="string"&&a&&(n.conversationMode=a);const s=e.payload.render_hint;return typeof s=="string"&&s&&(n.renderHint=s),e.payload.kvkk===!0&&(n.kvkk=!0),n}function xo(e){return Gt((e.payload.actions??[]).map(t=>{const r=w(t.title)??"",n=R(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(pe),"chat")}function zo(e){const t=Array.isArray(e.payload.grouped_assignment)?e.payload.grouped_assignment:[],r=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(s=>{const c=w(s.style_label);if(!c)return null;const u=w(s.style_mood),l=w(s.image_url??void 0),d=(Array.isArray(s.product_list)?s.product_list:[]).map(m=>{const h=$(m);return h?Xe($(h.product_detail)??$(h.product)??h):null}).filter(pe),f=Array.isArray(s.recommendation_groups)?s.recommendation_groups.map(m=>({label:w(m.label)??"",reason:w(m.reason)??"",skus:Array.isArray(m.skus)?m.skus.filter(h=>typeof h=="string"&&h.trim().length>0):[]})):[];return{style_label:c,style_mood:u??"",...l?{image_url:l}:{},...typeof s.status=="string"?{status:s.status}:{},product_list:d,recommendation_groups:f}}).filter(pe),n=e.payload.product_list??[],o=Eo(e.payload.source)&&r.length>0?r[0].product_list:null,i=o?si(o,"chat"):t.length>0?ai(t,n,"chat")??Ye(n,"chat"):Ye(n,"chat");i.panelHint="panel";const a=i.spec.elements[i.spec.root];if(a){const s={};typeof e.payload.offset=="number"&&(s.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(s.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(s.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(s.source=e.payload.source),r.length>0&&(s.styleVariations=r),e.payload.replace_panel===!0&&(s.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(s.rankingState=e.payload.ranking_state);const c=e.payload.sequence_id??e.payload.search_id;typeof c=="string"&&c.length>0&&(s.sequenceId=c),Object.keys(s).length>0&&(a.props={...a.props,...s})}return i}function Ao(e){const t=e.payload.productDetails;if(!t)return ui("chat");const r=B(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...r}}}}},panelHint:"panel"}}function Po(e){const t=Ye(e.payload.similarProducts??[],"chat"),r=t.spec.elements[t.spec.root];return r&&(r.props={...r.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Io(e){const t=e.payload.multiple_product_details??[],r=e.payload,n={key_differences:r.key_differences,recommended_choice:r.recommended_choice,recommended_choice_sku:r.recommended_choice_sku,special_considerations:r.special_considerations,criteria_view:r.criteria_view,criteria_view_short:r.criteria_view_short,compared_field_names:r.compared_field_names,winner_product:r.winner_product,winner_hits:r.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,a=[];for(const y of t){const k=B(y);a.push(k)}const s=$o(o,a,n,i);let c;n?.recommended_choice_sku?c=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(c=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const u=c?a.find(y=>y.sku===c)??a[0]:a[0],l=[];if(Array.isArray(n?.key_differences))for(const y of n.key_differences)typeof y=="string"&&l.push(y);const d=qt(n?.special_considerations),f=n?.recommended_choice,m=n?.winner_hits,h={};for(const y of a){const k=y.sku;k&&(h[k]={title:y.name??k,type:"launchSingleProduct",payload:{sku:k}})}const p={products:a,attributes:s,highlights:l,productActions:h};return u&&(p.recommended=u),d.length>0&&(p.specialCases=d),f&&(p.recommendedText=f),m&&(p.winnerHits=m),typeof n?.key_differences=="string"&&(p.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(p.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:p}}},panelHint:"panel"}}function $o(e,t,r,n){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const d=r.criteria_view??r.criteria_view_short??{},f=r.compared_field_names??Object.keys(e),m=[];for(const h of f){const p=e[h];if(!p||!Array.isArray(p))continue;const y=d[h]??h;m.push({label:y,values:p.map(k=>typeof k=="string"?k:String(k??""))})}return m}const a=e,s=t.map(d=>String(d.sku??"")).filter(d=>d.length>0),c=r.criteria_view??r.criteria_view_short??{},u=(n&&n.length>0?n:r.compared_field_names&&r.compared_field_names.length>0?r.compared_field_names:No(a)).filter(d=>d!=="name"&&d!=="name_short"&&!d.endsWith("_short")),l=[];for(const d of u){const f=s.map(h=>{const p=a[h];if(!p||typeof p!="object")return"";const y=p[`${d}_short`],k=p[d];return Oo(y??k)});if(f.every(h=>h.length===0))continue;const m=c[d]??d;l.push({label:m,values:f})}return l}function No(e){const t=[],r=new Set;for(const n of Object.values(e))if(!(!n||typeof n!="object"))for(const o of Object.keys(n))r.has(o)||(r.add(o),t.push(o));return t}function Oo(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Lo(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Ro(){return{type:"done"}}function Zo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:e.payload.text,thinkingMessages:e.payload.thinking_messages,dynamicLoading:e.payload.is_dynamic===!0}}}function Do(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Uo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function jo(e){const t=w(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:w(e.payload.to)}}}function Mo(e){return{type:"error",code:"BACKEND_ERROR",message:w(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Fo(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Bo(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.theme=a),Bt({type:"quick_qna",payload:o})}const r=$(t.action);if(r){const o={action:r},i=typeof t.text=="string"?t.text:void 0,a=typeof t.image_url=="string"?t.image_url:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),a!==void 0&&(o.image_url=a),s!==void 0&&(o.theme=s),Ft({type:"text_image",payload:o})}const n=typeof t.text=="string"?t.text:"";if(n){const o={text:n},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0,s=$(t.payload)??void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.payload=s),a!==void 0&&(o.theme=a),He({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function He(e){const t={text:w(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function Go(e){return ci(e.payload,"qna")}function Ft(e){const t=w(e.payload.text)??"",r=R(e.payload.action,t);if(r){const o={label:t||r.title,action:r};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const n={text:t};return typeof e.payload.theme=="string"&&(n.theme=e.payload.theme),He({type:"text",payload:n})}function Bt(e){return Gt((e.payload.action_list??[]).map(t=>{const r=w(t.title)??"",n=R(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(pe),"qna")}function qo(e){const t={reviews:(e.payload.reviews??[]).map(r=>{const n={};return typeof r.review_class=="string"&&(n.review_class=r.review_class),typeof r.review_text=="string"&&(n.review_text=r.review_text),(typeof r.review_rating=="string"||typeof r.review_rating=="number")&&(n.review_rating=r.review_rating),typeof r.review_tag=="string"&&(n.review_tag=r.review_tag),n})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function Jo(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function Vo(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Wo(e){const t=e.payload.product_suggestions??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=li(o);if(!i)continue;const a={product:i},s=R(o.requestDetails,i.name);s&&(a.action=s),typeof o.role=="string"&&(a.role=o.role),typeof o.reason=="string"&&(a.reason=o.reason),typeof o.review_highlight=="string"&&(a.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(a.labels=o.labels),typeof o.expert_quality_score=="number"&&(a.expertQualityScore=o.expert_quality_score),r.push(a)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:r}}}}}}function Ho(e){const t=e.payload.product_groupings??[],r=[],n=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const a=w(i.name)??"",s=w(i.description),c=w(i.highlight),u=Array.isArray(i.labels)?qt(i.labels):[],l=w(i.sku,i.repr_sku),d=w(i.image,i.repr_image),f=Ko(i,a,l),m=(Array.isArray(i.group_products)?i.group_products:[]).map(y=>{const k=$(y);return k?Xe(k):null}).filter(pe),h=d??w(...m.map(y=>y.imageUrl));if(a&&m.length>0){const y={groupName:a,products:m};h&&(y.image=h),s&&(y.description=s),c&&(y.highlight=c),u.length>0&&(y.labels=u),r.push(y)}if(!f)continue;const p={name:a,action:f};u.length>0&&(p.labels=u),d!==void 0&&(p.image=d),n.push(p)}return r.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r}}}},panelHint:"panel"}:n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function Ko(e,t,r){const n=$(e.requestDetails);if(n){if(n.type!=="findSimilar")return R(n,t);const a={...$(n.payload)??{}};r&&!le(a.sku)&&(a.sku=r);const s=de(e.group_skus);return s.length>0&&(a.group_skus=s),R({...n,payload:Ce(a)},t)}const o={};r&&(o.sku=r);const i=de(e.group_skus);return i.length>0&&(o.group_skus=i),Object.keys(o).length===0?null:R({type:"findSimilar",payload:Ce(o)},t)}function Yo(e,t){const r=$(e.requestDetails),n=$(r?.payload),o=w(e.detailed_user_message),i=e.group_skus&&Array.isArray(e.group_skus)?de(e.group_skus):de(n?.group_skus),a=w(e.sku,e.representative_product_sku,n?.sku);if(r?.type==="findSimilar"){const c={...n??{}};return a&&(c.sku=a),i.length>0&&(c.group_skus=i),o&&(c.input=o,le(c.text)||(c.text=o)),c.is_search_suggestion=1,R({...r,payload:Ce(c)},t)}if(a){const c={sku:a,is_search_suggestion:1};return i.length>0&&(c.group_skus=i),o&&(c.input=o,c.text=o),R({type:"findSimilar",payload:Ce(c)},t)}const s={...n??{},is_suggested_text:1,is_search_suggestion:1};return o&&!le(s.text)&&(s.text=o),i.length>0&&(s.group_skus=i),R(r?.type==="inputText"?{...r,payload:s}:{type:"inputText",payload:s},t)}function Xo(e){const t=e.payload.suggested_searches??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=w(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${n+1}`,a=Yo(o,i);if(!a)continue;const s={shortName:i,action:a},c=w(o.detailed_user_message);c&&c!==i&&(s.detailedMessage=c);const u=So(o);u&&u!==i&&u!==(c??"")&&(s.whyDifferent=u),typeof o.image=="string"&&(s.image=o.image),r.push(s)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:r}}}}}}function Qo(e){const t=e.payload,r=R(t.requestDetails??t.request_details,w(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!r)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const n={action:r};return t.title&&(n.title=t.title),t.text&&(n.text=t.text),t.review_count?n.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(n.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function ei(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function ti(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function ri(e){const t=e.payload.group_list??[],r=[];for(const o of t){const i=o.group_name??"",a=(o.product_list??[]).map(B);r.push({groupName:i,products:a})}const n=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const a=R(o.requestDetails,i),s={title:i};a&&(s.action=a),n.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r,filterTags:n}}}},panelHint:"panel"}}function ni(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function oi(e){const t={};return typeof e.payload?.summary=="string"&&(t.summary=e.payload.summary),Array.isArray(e.payload?.products_discussed)&&(t.products_discussed=e.payload.products_discussed),typeof e.payload?.user_sentiment=="string"&&(t.user_sentiment=e.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:t}}}}}function ii(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Ke(e,t){const r={product:e,index:t},n=e,o=typeof n.sku=="string"?n.sku:void 0;return o&&(r.action={title:typeof n.name=="string"?n.name:"",type:"launchSingleProduct",payload:{sku:o}}),{type:"ProductCard",props:r}}function Gt(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`action-${o}`;n.push(a);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),r[a]={type:"ActionButton",props:s}}return r.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function Ye(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=B(i),s=`product-${o}`;n.push(s),r[s]=Ke(a,o)}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function ai(e,t,r){const n=new Map;for(const u of t)u?.sku&&n.set(u.sku,u);if(n.size===0)return null;const o=new Set,i={},a=[],s=[];let c=0;for(let u=0;u<e.length;u++){const l=e[u],d=w(l?.title)??"",f=Array.isArray(l?.skus)?l.skus:[],m=[];for(let h=0;h<f.length;h++){const p=typeof f[h]=="string"?f[h].trim():"";if(!p||o.has(p))continue;const y=n.get(p);if(!y)continue;o.add(p);const k=`product-${u}-${h}`,P=B(y);a.push(k),m.push(k),i[k]=Ke(P,c),c+=1}m.length>0&&s.push({title:d,children:m})}return s.length===0||o.size<n.size?null:(i.root={type:"ProductGrid",props:{layout:"grouped",productSections:s},children:a},{type:"ui_spec",widget:r,spec:{root:"root",elements:i}})}function si(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`product-${o}`;n.push(a),r[a]=Ke(i,o)}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function ci(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:B(e),index:0}}}}}}function ui(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function li(e){const t=w(e.sku),r=w(e.short_name),n={...$(e.product_item)??e},o=w(e.discount_reason,e.discountReason);return o&&!w(n.discount_reason,n.discountReason)&&(n.discount_reason=o),Xe(n,t,r)}function Xe(e,t,r){const n=w(e.sku,t),o=w(e.name,r);if(!n||!o)return null;const i={sku:n,name:o},a=w(e.brand);a&&(i.brand=a);const s=w(e.url);s&&(i.url=s);const c=di(e.images);if(c.length>0)i.images=c;else{const p=w(e.image,e.image_url,e.imageUrl);p&&(i.images=[p])}const u=fe(e.price_discounted);u!==void 0&&(i.price_discounted=u);const l=fe(e.price);l!==void 0&&(i.price=l);const d=fe(e.rating);d!==void 0&&(i.rating=d);const f=fe(e.review_count)??fe(e.reviewCount);f!==void 0&&(i.review_count=f);const m=w(e.cart_code,e.cartCode);m&&(i.cart_code=m),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const h=w(e.discount_reason,e.discountReason);return h&&(i.discount_reason=h),B(i)}function R(e,t){const r=$(e);if(!r)return null;const n=r.type;if(typeof n!="string"||n.length===0)return null;const o={title:t||n,type:n};return r.payload!==void 0&&(o.payload=r.payload),o}function $(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function w(...e){for(const t of e)if(typeof t=="string"){const r=t.trim();if(r.length>0)return r}}function di(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function qt(e){if(typeof e=="string"){const t=e.trim();return t?[t]:[]}return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0):[]}function fe(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const r=Number(t);if(Number.isFinite(r))return r}}function pe(e){return e!=null}var fi=new Set(["sku","name","brand","images","price","price_discounted","price_discount_rate","price_currency","discount_reason","url","rating","review_count","cart_code","in_stock","description","description_html","features","specifications","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function B(e){const t=e.price_discounted!=null&&e.price_discounted>0,r=t?e.price_discounted:e.price,n=t&&e.price!=null?e.price:void 0;let o;n!=null&&r!=null&&n>0?o=Math.round((n-r)/n*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=w(e.brand),a=w(e.name)??e.sku,s=i&&!a.toLowerCase().startsWith(i.toLowerCase())?`${i} ${a}`:a,c={sku:e.sku,name:s,url:w(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),r!=null&&r>0&&(c.price=String(r)),n!=null&&n>0&&(c.originalPrice=String(n)),o!==void 0&&(c.discountPercent=o),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.category_names&&e.category_names.length>0&&(c.categoryNames=e.category_names),e.short_name!==void 0&&(c.shortName=e.short_name);const l=e,d={};let f=!1;for(const m of Object.keys(l))fi.has(m)||(d[m]=l[m],f=!0);return f&&(c.extras=d),c}function pi(e){return e.results.map(B)}function gi(e){return e.product_groupings.map(t=>{const r={name:t.name,products:(t.group_products??[]).map(B)};return t.highlight!==void 0&&(r.highlight=t.highlight),r})}function mi(e){const t=e.payload.type,{type:r,...n}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:n}}}}}function Jt(e){const t=[];for(const r of Object.values(e))if(r.type==="ProductCard"&&r.props){const n=r.props.product??r.props;typeof n.sku=="string"&&typeof n.name=="string"&&t.push(n)}return t}function Vt(e){const t=e.headers.get("Content-Type")??"";return t.includes("application/x-ndjson")||t.includes("text/event-stream")}async function hi(e,t){const r=[],n={onEvent:o=>{const i=Mt(o);!i||i.type!=="ui_spec"||r.push(...Jt(i.spec.elements))}};return t!==void 0&&(n.signal=t),await $t(e,n),r}async function yi(e,t,r){const n=At("similar_products",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await Lt(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(Vt(i))return hi(i,r);const a=await i.text();if(!a)throw new Error("Empty response body from similar_products endpoint");try{return pi(JSON.parse(a))}catch{throw new Error("Invalid JSON from similar_products endpoint")}}async function _i(e,t){const r=[];let n=null;const o={onEvent:i=>{const a=Mt(i);if(a){if(a.type==="metadata"&&a.meta){const s=a.meta.group_name;if(typeof s=="string"){n={name:s,products:[]};const c=a.meta.highlight;typeof c=="string"&&(n.highlight=c),r.push(n)}}a.type==="ui_spec"&&n&&n.products.push(...Jt(a.spec.elements))}}};return t!==void 0&&(o.signal=t),await $t(e,o),r}async function vi(e,t,r){const n=At("product_groupings",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await Lt(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(Vt(i))return _i(i,r);const a=await i.text();if(!a)return[];try{return gi(JSON.parse(a))}catch{throw new Error("Invalid JSON from product_groupings endpoint")}}var bi={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function ge(e,t){const r=Number(e);if(!Number.isFinite(r)||r<0)return e;const n={...bi,...t},o=Math.abs(r%1)<Number.EPSILON,i=n.alwaysShowDecimals||!o?r.toFixed(2):r.toFixed(0),a=i.indexOf("."),s=a===-1?i:i.slice(0,a),c=a===-1?void 0:i.slice(a+1),u=s.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousandsSeparator);let l;return c!==void 0?l=`${u}${n.decimalSeparator}${c}`:l=u,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${l}`:`${l} ${n.currencySymbol}`:l}function wi(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function ki(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Si(e){const t=wi(e),r=Math.floor(t),n=t-r>=.5,o=5-r-(n?1:0),i=document.createElement("span");if(i.className="gengage-star-rating",i.setAttribute("role","img"),i.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),r>0&&i.appendChild(document.createTextNode("★".repeat(r))),n){const a=document.createElement("span");a.className="gengage-star-half",a.textContent="☆";const s=document.createElement("span");s.textContent="★",a.appendChild(s),i.appendChild(a)}return o>0&&i.appendChild(document.createTextNode("☆".repeat(o))),i}function Wt(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function Ht(e){const{product:t,index:r,discountType:n,onClick:o,onAddToCart:i,renderCard:a}=e,s=e.i18n,c=e.pricing;if(e.renderCardElement){const p=e.renderCardElement(t,r);if(p)return p}if(a){const p=document.createElement("div");return p.className="gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive",p.dataset.gengagePart="simrel-product-card",p.innerHTML=vn(a(t,r)),p.addEventListener("click",y=>{y.target.closest(".gengage-simrel-atc")||y.target.closest(".gengage-chat-product-card-atc")||o(t)}),p}const u=document.createElement("article");u.className="gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive",u.dataset.gengagePart="simrel-product-card",t.inStock===!1&&u.classList.add("gengage-simrel-card--out-of-stock"),u.setAttribute("role","listitem"),u.dataset.sku=t.sku;const l=document.createElement("div");if(l.className="gengage-simrel-card-image gengage-chat-product-card-img-wrapper",l.dataset.gengagePart="simrel-product-card-image",t.imageUrl&&we(t.imageUrl)){const p=document.createElement("img");p.className="gengage-chat-product-card-img",p.src=t.imageUrl,p.alt=t.name,p.loading="lazy",Wt(p),l.appendChild(p)}if(n==="badge"&&t.discountPercent&&t.discountPercent>0){const p=document.createElement("span");p.className="gengage-simrel-badge gengage-chat-product-card-discount-badge",p.textContent=`%${ki(t.discountPercent)}`,l.appendChild(p)}u.appendChild(l);const d=document.createElement("div");if(d.className="gengage-simrel-card-info gengage-chat-product-card-body",d.dataset.gengagePart="simrel-product-card-body",t.brand){const p=document.createElement("div");p.className="gengage-simrel-card-brand gengage-chat-product-card-brand",p.textContent=t.brand,d.appendChild(p)}const f=document.createElement("div");if(f.className="gengage-simrel-card-name gengage-chat-product-card-name",f.textContent=t.name,f.title=t.name,d.appendChild(f),t.rating!=null&&t.rating>0){const p=document.createElement("div");if(p.className="gengage-simrel-card-rating gengage-chat-product-card-rating",p.appendChild(Si(t.rating)),t.reviewCount!=null){const y=document.createElement("span");y.className="gengage-simrel-card-review-count gengage-chat-product-card-review-count",y.textContent=` (${t.reviewCount})`,p.appendChild(y)}d.appendChild(p)}const m=document.createElement("div");if(m.className="gengage-simrel-card-price gengage-chat-product-card-price",t.originalPrice&&t.originalPrice!==t.price&&(n==="strike-through"||n==="inline"||!n)){const p=document.createElement("span");p.className=["gengage-simrel-card-price-original","gengage-chat-product-card-original-price"].join(" "),n==="inline"&&p.classList.add("gengage-simrel-card-price-original--inline"),p.textContent=ge(t.originalPrice,c),m.appendChild(p)}if(t.price&&parseFloat(t.price)>0){const p=document.createElement("span");p.className="gengage-simrel-card-price-current gengage-chat-product-card-price-current",p.textContent=ge(t.price,c),m.appendChild(p)}d.appendChild(m),u.appendChild(d);const h=document.createElement("button");if(h.className="gengage-simrel-card-cta gengage-chat-product-card-cta gds-btn gds-btn-secondary",h.type="button",h.dataset.gengagePart="simrel-product-card-cta",h.textContent=s?.ctaLabel??"View",h.addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),o(t)}),u.appendChild(h),t.inStock===!1){const p=document.createElement("div");p.className="gengage-simrel-card-oos",p.textContent=s?.outOfStockLabel??"Out of Stock",u.appendChild(p)}else if(t.cartCode){const p=document.createElement("button");p.className="gengage-simrel-atc gengage-simrel-atc-button gds-btn gds-btn-secondary",p.type="button",p.textContent=s?.addToCartButton??"Add to Cart",p.addEventListener("click",y=>{y.preventDefault(),y.stopPropagation(),i({sku:t.sku,quantity:1,cartCode:t.cartCode})}),u.appendChild(p)}return u.addEventListener("click",p=>{p.target.closest(".gengage-simrel-atc")||p.target.closest(".gengage-chat-product-card-atc")||p.target.closest(".gengage-chat-product-card-cta")||o(t)}),u}function Kt(e){const t=document.createElement("div");t.className="gengage-simrel-grid",t.setAttribute("role","list"),t.setAttribute("aria-label",e.i18n?.similarProductsAriaLabel??"Similar products"),e.columns&&t.style.setProperty("--gengage-simrel-columns",String(e.columns));for(let r=0;r<e.products.length;r++){const n={product:e.products[r],index:r,onClick:e.onClick,onAddToCart:e.onAddToCart};e.i18n!==void 0&&(n.i18n=e.i18n),e.discountType!==void 0&&(n.discountType=e.discountType),e.renderCard!==void 0&&(n.renderCard=e.renderCard),e.renderCardElement!==void 0&&(n.renderCardElement=e.renderCardElement);const o=Ht(n);t.appendChild(o)}return e.products.length===0&&(t.style.display="none",t.dataset.empty="true"),t}var Ei=0;function Yt(e){const t=Ei++,r=document.createElement("div");if(r.className="gengage-simrel-groups",r.dataset.gengagePart="simrel-groups",e.groups.length===0)return r.style.display="none",r.dataset.empty="true",r;const n=document.createElement("div");n.className="gengage-simrel-tabs gds-toolbar",n.dataset.gengagePart="simrel-tab-bar",n.setAttribute("role","tablist");const o=[],i=[];let a=0;const s=y=>{const k={products:y.products,onClick:e.onClick,onAddToCart:e.onAddToCart};return e.i18n!==void 0&&(k.i18n=e.i18n),e.discountType!==void 0&&(k.discountType=e.discountType),e.renderCard!==void 0&&(k.renderCard=e.renderCard),e.renderCardElement!==void 0&&(k.renderCardElement=e.renderCardElement),e.columns!==void 0&&(k.columns=e.columns),k},c=(y,k=!1)=>{if(k&&y!==a&&e.onGroupingActivate){const b=e.groups[y];e.onGroupingActivate({grouping_label:b.name,grouping_index:y})}a=y;for(let b=0;b<o.length;b++){const I=b===y;o[b].classList.toggle("gengage-simrel-tab--active",I),o[b].setAttribute("aria-selected",String(I)),o[b].tabIndex=I?0:-1}const P=e.groups[y],S=i[y];S.innerHTML="";const v=Kt(s(P));S.appendChild(v);for(let b=0;b<i.length;b++){const I=b===y;i[b].style.display=I?"":"none",i[b].tabIndex=I?0:-1}};for(let y=0;y<e.groups.length;y++){const k=e.groups[y],P=`gengage-simrel-tab-${t}-${y}`,S=`gengage-simrel-panel-${t}-${y}`,v=document.createElement("button");v.className="gengage-simrel-tab gds-tab",v.type="button",v.dataset.gengagePart="simrel-tab",v.id=P,v.textContent=k.name,v.setAttribute("role","tab"),v.setAttribute("aria-controls",S),v.setAttribute("aria-selected",String(y===0)),v.tabIndex=y===0?0:-1,y===0&&v.classList.add("gengage-simrel-tab--active"),v.addEventListener("click",()=>c(y,!0)),v.addEventListener("keydown",I=>{let M=-1;I.key==="ArrowRight"||I.key==="ArrowDown"?M=(y+1)%e.groups.length:I.key==="ArrowLeft"||I.key==="ArrowUp"?M=(y-1+e.groups.length)%e.groups.length:I.key==="Home"?M=0:I.key==="End"&&(M=e.groups.length-1),M>=0&&(I.preventDefault(),c(M,!0),o[M].focus())}),o.push(v),n.appendChild(v);const b=document.createElement("div");b.className="gengage-simrel-tab-panel",b.dataset.gengagePart="simrel-tab-panel",b.id=S,b.setAttribute("role","tabpanel"),b.setAttribute("aria-labelledby",P),b.tabIndex=y===0?0:-1,y!==0&&(b.style.display="none"),i.push(b)}const u=document.createElement("button");u.type="button",u.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--left",u.setAttribute("aria-label",e.i18n?.scrollTabsLeft??"Scroll tabs left"),u.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>';const l=document.createElement("button");l.type="button",l.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--right",l.setAttribute("aria-label",e.i18n?.scrollTabsRight??"Scroll tabs right"),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="9 18 15 12 9 6"/></svg>';const d=200;u.addEventListener("click",()=>{n.scrollBy({left:-200,behavior:"smooth"})}),l.addEventListener("click",()=>{n.scrollBy({left:d,behavior:"smooth"})});const f=()=>{const y=n.scrollLeft<=4,k=n.scrollLeft+n.clientWidth>=n.scrollWidth-4;u.style.display=y?"none":"",l.style.display=k?"none":"",n.classList.toggle("gengage-simrel-tabs--peek-right",!k),n.classList.toggle("gengage-simrel-tabs--peek-left",!y)};n.addEventListener("scroll",f,{passive:!0}),typeof ResizeObserver<"u"&&new ResizeObserver(f).observe(n),u.style.display="none",l.style.display="none",requestAnimationFrame(f);const m=document.createElement("div");m.className="gengage-simrel-tabs-wrapper",m.appendChild(u),m.appendChild(n),m.appendChild(l),r.appendChild(m);const h=i[0],p=Kt(s(e.groups[0]));h.appendChild(p);for(const y of i)r.appendChild(y);return r}function Xt(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.sku!="string"||typeof t.name!="string"||typeof t.url!="string")return null;const r={sku:t.sku,name:t.name,url:t.url},n=t.imageUrl;typeof n=="string"&&(r.imageUrl=n);const o=t.price;typeof o=="string"&&(r.price=o);const i=t.originalPrice;typeof i=="string"&&(r.originalPrice=i);const a=t.discountPercent;typeof a=="number"&&(r.discountPercent=a);const s=t.brand;typeof s=="string"&&(r.brand=s);const c=t.rating;typeof c=="number"&&(r.rating=c);const u=t.reviewCount;typeof u=="number"&&(r.reviewCount=u);const l=t.cartCode;typeof l=="string"&&(r.cartCode=l);const d=t.inStock;typeof d=="boolean"&&(r.inStock=d);const f=t.extras;return f!=null&&typeof f=="object"&&(r.extras=f),r}function Ci(e){if(!e||typeof e!="object")return null;const t=e,r=t.title,n=t.type;if(typeof r!="string"||typeof n!="string")return null;const o={title:r,type:n};return t.payload!==void 0&&(o.payload=t.payload),o}var Qt={ProductGrid:({element:e,renderElement:t,context:r})=>{const n=document.createElement("div");n.className="gengage-simrel-grid",n.setAttribute("role","list");const o=e.props?.columns;let i;typeof o=="number"&&Number.isFinite(o)&&o>0?i=Math.floor(o):typeof r.gridColumns=="number"&&Number.isFinite(r.gridColumns)&&r.gridColumns>0&&(i=Math.floor(r.gridColumns)),i!==void 0&&n.style.setProperty("--gengage-simrel-columns",String(i));for(const a of e.children??[]){const s=t(a);s&&n.appendChild(s)}if(n.children.length===0){const a=document.createElement("div");a.className="gengage-simrel-empty",a.textContent=r.i18n.emptyStateMessage,n.appendChild(a)}return n},ProductCard:({element:e,context:t})=>{const r=Xt(e.props?.product??e.props);if(!r)return null;const n=e.props?.index,o=typeof n=="number"&&Number.isFinite(n)?n:0,i=e.props?.discountType,a=i==="strike-through"||i==="badge"||i==="inline"?i:t.discountType,s={product:r,index:o,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return a!==void 0&&(s.discountType=a),t.renderCard!==void 0&&(s.renderCard=t.renderCard),t.renderCardElement!==void 0&&(s.renderCardElement=t.renderCardElement),t.pricing!==void 0&&(s.pricing=t.pricing),Ht(s)},GroupTabs:({element:e,context:t})=>{const r=e.props?.groups;if(!Array.isArray(r))return null;const n=[];for(const a of r){if(!a||typeof a!="object")continue;const s=a;if(typeof s.name!="string")continue;const c=[];if(Array.isArray(s.products))for(const l of s.products){const d=Xt(l);d&&c.push(d)}const u={name:s.name,products:c};typeof s.highlight=="string"&&(u.highlight=s.highlight),n.push(u)}const o={groups:n,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n},i=e.props?.columns;return typeof i=="number"&&Number.isFinite(i)&&i>0?o.columns=Math.floor(i):typeof t.gridColumns=="number"&&Number.isFinite(t.gridColumns)&&t.gridColumns>0&&(o.columns=Math.floor(t.gridColumns)),t.discountType!==void 0&&(o.discountType=t.discountType),t.renderCard!==void 0&&(o.renderCard=t.renderCard),t.renderCardElement!==void 0&&(o.renderCardElement=t.renderCardElement),t.onGroupingActivate!==void 0&&(o.onGroupingActivate=t.onGroupingActivate),Yt(o)},EmptyState:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-empty";const n=e.props?.message;return r.textContent=typeof n=="string"?n:t.i18n.emptyStateMessage,r},AddToCartButton:({element:e,context:t})=>{const r=e.props?.sku,n=e.props?.cartCode;if(typeof r!="string"||typeof n!="string")return null;const o=document.createElement("button");o.className="gengage-simrel-atc gengage-chat-product-card-cta",o.type="button";const i=e.props?.label;return o.textContent=typeof i=="string"?i:t.i18n.addToCartButton,o.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),t.onAddToCart({sku:r,quantity:1,cartCode:n})}),o},QuickActions:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-quick-actions";const n=e.props?.actions;if(!Array.isArray(n)||!t.onAction)return r;for(const o of n){if(!o||typeof o!="object")continue;const i=o,a=i.label,s=Ci(i.action);if(typeof a!="string"||!s)continue;const c=document.createElement("button");c.className="gengage-simrel-quick-action",c.type="button",c.textContent=a,c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),t.onAction?.(s)}),r.appendChild(c)}return r}},Qe=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const r=document.createElement("div");for(const n of e.children){const o=t(n);o&&r.appendChild(o)}return r};function er(){return{...Qt}}function tr(e,t,r=Qt,n=Qe){return dn({spec:e,context:t,registry:r,containerClassName:"gengage-simrel-uispec",unknownRenderer:n})}var rr={similarProductsAriaLabel:"Benzer ürünler",emptyStateMessage:"Benzer ürün bulunamadı.",addToCartButton:"Sepete Ekle",ctaLabel:"İncele",outOfStockLabel:"Stokta Yok",decreaseLabel:"Azalt",increaseLabel:"Artır",errorLoadingMessage:"Benzer ürünler yüklenemedi.",retryButtonText:"Tekrar dene",priceSuffix:" TL",scrollTabsLeft:"Sola kaydır",scrollTabsRight:"Sağa kaydır"},Ti={similarProductsAriaLabel:"Similar products",emptyStateMessage:"No similar products found.",addToCartButton:"Add to cart",ctaLabel:"View",outOfStockLabel:"Out of Stock",decreaseLabel:"Decrease",increaseLabel:"Increase",errorLoadingMessage:"Could not load similar products.",retryButtonText:"Try again",priceSuffix:"",scrollTabsLeft:"Scroll tabs left",scrollTabsRight:"Scroll tabs right"};function xi(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function zi(e){return xi(e)==="en"?Ti:rr}var Ai=12e4;function Pi(e){return e instanceof DOMException&&e.name==="AbortError"}var nr=class extends Bn{constructor(...e){super(...e),this._abortController=null,this._contentEl=null,this._lastResultCount=-1,this._i18n=rr,this._pendingAddToCartKeys=new Set}async init(e){if(!this.isInitialised&&(e.mountTarget===void 0||e.mountTarget===null))throw new Error("[gengage] SimRel mountTarget is required. Provide a merchant-owned mount before initializing.");await super.init(e)}async onInit(e){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=qn(e.locale);const t=this._clampGridColumns(e.gridColumns);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),wn("simrel")}onUpdate(e){const t=e.sku;!t||t===this._lastSku&&this._lastResultCount!==0||(this._lastSku=t,this._fetchAndRender(t))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.3s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._contentEl&&(this._contentEl.remove(),this._contentEl=null)}_handleProductClick(e){const t={sku:e.sku,name:e.name,url:e.url};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;const r=this.config.session?.sessionId??null;ae("gengage:similar:product-click",{sku:e.sku,url:e.url,sessionId:r,productName:e.name}),this.config.onProductNavigate?.(e.url,e.sku,r)}async _handleAddToCart(e){const t=`${e.sku}\0${e.cartCode}\0${e.quantity}`;if(!this._pendingAddToCartKeys.has(t)){this._pendingAddToCartKeys.add(t);try{if(this.config.onAddToCart===void 0)return;try{await Promise.resolve(this.config.onAddToCart(e))}catch(r){console.error("[gengage] simrel onAddToCart",r);return}kn(e.sku,e.quantity),ae("gengage:similar:add-to-cart",e)}finally{this._pendingAddToCartKeys.delete(t)}}}_abort(){this._abortController?.abort(),this._abortController=null}_isSuperseded(e){return this._abortController?.signal!==e}_emitSimilarProductsImpression(e,t){const r=this.config.session?.sessionId??null;ae("gengage:similar:products-impression",{source_sku:this.config.sku,product_count:e,grouped:t,sessionId:r})}_resolveRequestTimeoutMs(){const e=this.config.requestTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Ai:Math.floor(e)}async _fetchAndRender(e){this._abort();const t=new AbortController;this._abortController=t;const r=t.signal;let n=!1;const o=setTimeout(()=>{n=!0,t.abort()},this._resolveRequestTimeoutMs());if(r.addEventListener("abort",()=>clearTimeout(o),{once:!0}),!this._contentEl)return;this._contentEl.innerHTML="",this._contentEl.style.display="";const i=document.createElement("div");i.className="gengage-simrel-loading",i.dataset.gengagePart="simrel-loading";const a=document.createElement("div");a.className="gengage-simrel-spinner",a.dataset.gengagePart="simrel-loading-spinner",i.appendChild(a),this._contentEl.appendChild(i);const s={middlewareUrl:this.config.middlewareUrl},c=Xn({source:"simrel",locale:this.config.locale});try{const u={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e};this.config.domain!==void 0&&(u.domain=this.config.domain);const l=await yi(u,s,r);if(this._lastResultCount=l.length,!this._contentEl)return;if(this._contentEl.innerHTML="",l.length>0&&this.config.enableProductGroupings!==!1)try{const d=l.map(h=>h.sku),f=new Map(l.map(h=>[h.sku,h])),m=(await vi({account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",skus:d},s,r)).map(h=>({...h,products:h.products.map(p=>({...f.get(p.sku),...p})).filter(p=>typeof p.sku=="string"&&typeof p.name=="string"&&typeof p.url=="string")})).filter(h=>h.products.length>0);if(m.length>0&&this._contentEl){const h=this._buildGroupsSpec(m),p=this._renderUISpec(h);this._contentEl.appendChild(p),_t("simrel"),this._emitSimilarProductsImpression(m.reduce((y,k)=>y+k.products.length,0),!0);return}}catch{}if(this._isSuperseded(r))return;if(this._contentEl){const d=this._buildProductsSpec(l),f=this._renderUISpec(d);this._contentEl.appendChild(f)}l.length>0&&_t("simrel"),this._emitSimilarProductsImpression(l.length,!1)}catch(u){const l=Pi(u);if(l&&this._isSuperseded(r))return;if(ae("gengage:global:error",{source:"simrel",code:l&&n?"REQUEST_TIMEOUT":"FETCH_ERROR",message:$n(this.config.locale,u)}),this._contentEl){this._contentEl.innerHTML="";const d=document.createElement("div");d.className="gengage-simrel-error";const f=document.createElement("span");f.textContent=this._i18n.errorLoadingMessage,d.appendChild(f);const m=document.createElement("button");m.className="gengage-simrel-retry",m.textContent=this._i18n.retryButtonText,m.addEventListener("click",()=>{this._fetchAndRender(this.config.sku)}),d.appendChild(m),this._contentEl.appendChild(d)}}finally{clearTimeout(o),c()}}_clampGridColumns(e){if(!(e===void 0||typeof e!="number"||!Number.isFinite(e)))return Math.max(1,Math.min(12,Math.floor(e)))}_resolveI18n(e){return{...zi(e.locale),...e.i18n}}_resolveUISpecRegistry(){return fn(er(),this.config.renderer?.registry)}_buildRenderContext(){const e=this.config.renderCard,t={onClick:n=>this._handleProductClick(n),onAddToCart:n=>{this._handleAddToCart(n)},onGroupingActivate:n=>{ae("gengage:similar:grouping-click",{grouping_label:n.grouping_label,grouping_index:n.grouping_index,sessionId:this.config.session?.sessionId??null})},i18n:this._i18n};this.config.discountType!==void 0&&(t.discountType=this.config.discountType),e!==void 0&&(t.renderCard=e),this.config.renderCardElement!==void 0&&(t.renderCardElement=this.config.renderCardElement),this.config.pricing!==void 0&&(t.pricing=this.config.pricing);const r=this._clampGridColumns(this.config.gridColumns);return r!==void 0&&(t.gridColumns=r),t}_renderUISpec(e){const t=this._resolveUISpecRegistry(),r=this._buildRenderContext(),n=this.config.renderer?.unknownRenderer??Qe,o=(a,s)=>tr(a,s,t,n),i=this.config.renderer?.renderUISpec;return i?i(e,r,{registry:t,unknownRenderer:n,defaultRender:o}):o(e,r)}_buildProductsSpec(e){const t={},r=[];for(let i=0;i<e.length;i++){const a=e[i],s=`product-${i}`;r.push(s),t[s]={type:"ProductCard",props:{product:a,index:i,discountType:this.config.discountType}}}const n={layout:"grid"},o=this._clampGridColumns(this.config.gridColumns);return o!==void 0&&(n.columns=o),t.root={type:"ProductGrid",props:n,children:r},{root:"root",elements:t}}_buildGroupsSpec(e){return{root:"root",elements:{root:{type:"GroupTabs",props:{groups:e}}}}}};function Ii(){return new nr}var $i={images:["images","extras.images","imageUrl"],subtitle:["categoryNames","category_names","extras.categoryNames","extras.category_names","description"],promotions:["promotions","extras.promotions"],warranties:["warranties","extras.warranties"],productInfoUrl:["productInfoFormUrl","extras.productInfoFormUrl","documents.0.url","extras.documents.0.url"],discountReason:["discountReason","discount_reason","extras.discountReason","extras.discount_reason"],specialPrice:["isSpecialPrice","extras.isSpecialPrice"],customBadgeFacets:["customBadgeFacets","custom_badge_facets","extras.customBadgeFacets","extras.custom_badge_facets","facetHits","facet_hits","extras.facetHits","extras.facet_hits"],customBadgeText:["customBadgeText","custom_badge_text","customBadge","custom_badge","customLabel","custom_label","bottomLabel","bottom_label","cornerBadge","corner_badge","extras.customBadgeText","extras.custom_badge_text","extras.customBadge","extras.custom_badge","extras.customLabel","extras.custom_label","extras.bottomLabel","extras.bottom_label","extras.cornerBadge","extras.corner_badge"],customBadgeImageUrl:["customBadgeImageUrl","custom_badge_image_url","customLabelImageUrl","custom_label_image_url","bottomLabelImageUrl","bottom_label_image_url","cornerBadgeImageUrl","corner_badge_image_url","extras.customBadgeImageUrl","extras.custom_badge_image_url","extras.customLabelImageUrl","extras.custom_label_image_url","extras.bottomLabelImageUrl","extras.bottom_label_image_url","extras.cornerBadgeImageUrl","extras.corner_badge_image_url"]};function Te(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function G(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}function or(e){if(Array.isArray(e))return e.map(r=>G(r)).filter(r=>!!r);const t=G(e);return t?[t]:[]}function ir(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const t=Number.parseFloat(e);if(Number.isFinite(t))return t}}function Ni(e){if(typeof e=="boolean")return e;if(typeof e=="number"&&Number.isFinite(e)){if(e===1)return!0;if(e===0)return!1}if(typeof e=="string"){const t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1;if(t==="1")return!0;if(t==="0")return!1}}function ar(...e){for(const t of e){const r=G(t);if(r)return r}}function sr(e){const t=Te(e);if(!t)return null;const r=G(t.sku),n=G(t.name),o=G(t.url);if(!r||!n||!o)return null;const i={sku:r,name:n,url:o};for(const[a,s]of Object.entries(t))s!==void 0&&(i[a]=s);return i}function Oi(e){const t=Te(e);if(!t)return null;const r=G(t.name);if(!r)return null;const n=[];if(Array.isArray(t.products))for(const a of t.products){const s=sr(a);s&&n.push(s)}const o={name:r,products:n},i=G(t.highlight);return i&&(o.highlight=i),o}function xe(e,t){const r=typeof t=="string"?t.split("."):[...t];let n=e;for(const o of r){if(n==null)return;if(Array.isArray(n)){const a=Number.parseInt(o,10);if(!Number.isInteger(a))return;n=n[a];continue}const i=Te(n);if(!i)return;n=i[o]}return n}function Li(e,t){for(const r of t){const n=xe(e,r);if(n!=null)return n}}function et(e,t){for(const r of t){const n=or(xe(e,r));if(n.length>0)return n}return[]}function me(e,t){for(const r of t){const n=xe(e,r),o=G(n);if(o)return o;const i=or(n);if(i.length>0)return i[0]}}function Ri(e,t){for(const r of t){const n=Te(xe(e,r));if(n)return n}return null}function cr(e,t){return{labels:{customBadgeAlt:e.labels?.customBadgeAlt??"Product badge",imageDot:e.labels?.imageDot??(r=>`Show product image ${r+1}`),previousPromotion:e.labels?.previousPromotion??"Previous promotion",nextPromotion:e.labels?.nextPromotion??"Next promotion"},ctaLabel:e.labels?.cta??t.i18n.ctaLabel,productInfoLabel:e.labels?.productInfo,reviewLabel:e.labels?.review??(r=>`${r} reviews`),specialPriceBadgeAlt:e.labels?.specialPriceBadgeAlt??"",fields:{...$i,...e.fields},media:e.media??{},warrantyPromotionPattern:e.warrantyPromotionPattern??/warranty/i,specialPricePattern:e.specialPricePattern??/special/i,pricing:e.pricing??t.pricing}}function Zi(e,t,r){return r.media.imageUrlTransform?.(e,t)??e}function Di(e,t){const r=e.trim(),n=t.trim();if(!r||!n)return r;const o=r.toLocaleLowerCase().indexOf(n.toLocaleLowerCase());return o===-1?r:`${r.slice(0,o).trim()} ${r.slice(o+n.length).trim()}`.replace(/\s{2,}/g," ").replace(/(\s[-|/,:]){2,}/g,"$1").replace(/^\s*[-|/,:]\s*/,"").replace(/\s*[-|/,:]\s*$/,"").trim()||r}function Ui(e,t){const r=me(e,t.fields.customBadgeImageUrl);if(r)return{imageUrl:r,labelText:null};const n=me(e,t.fields.customBadgeText);if(n)return{imageUrl:t.media.customBadgeImageUrl?.(e,n)??null,labelText:n};const o=Ri(e,t.fields.customBadgeFacets);if(!o)return{imageUrl:null,labelText:null};const i=ar(o["Custom Badge Image"],o["Custom Label Image"],o["Bottom Label Image"],o["Corner Badge Image"],o.custom_badge_image,o.custom_label_image,o.bottom_label_image,o.corner_badge_image,o.customBadgeImage,o.customLabelImage,o.bottomLabelImage,o.cornerBadgeImage);if(i)return{imageUrl:i,labelText:null};const a=ar(o["Custom Badge"],o["Custom Label"],o["Bottom Label"],o["Corner Badge"],o.custom_badge,o.custom_label,o.bottom_label,o.corner_badge,o.customBadge,o.customLabel,o.bottomLabel,o.cornerBadge);return a?{imageUrl:t.media.customBadgeImageUrl?.(e,a)??null,labelText:a}:{imageUrl:null,labelText:null}}function V(e,t,r){const n=document.createElement(e);return n.className=t,n.textContent=r,n}function ji(e,t,r){const n=document.createElement("div");n.className="gengage-simrel-default-card-image";let o=null;return r.length>0&&(o=document.createElement("img"),o.src=r[0],o.alt=t,o.loading="lazy",Wt(o),n.appendChild(o)),r.length>1&&o&&(n.addEventListener("mousemove",i=>{const a=n.getBoundingClientRect(),s=Math.min(Math.floor((i.clientX-a.left)/a.width*r.length),r.length-1);o?.dataset.hoverIdx!==String(s)&&(o.dataset.hoverIdx=String(s),o.src=r[s],e.querySelectorAll(".gengage-simrel-default-card-image-dot").forEach((c,u)=>c.classList.toggle("is-active",u===s)))}),n.addEventListener("mouseleave",()=>{o&&(delete o.dataset.hoverIdx,o.src=r[0],e.querySelectorAll(".gengage-simrel-default-card-image-dot").forEach((i,a)=>i.classList.toggle("is-active",a===0)))})),n}function Mi(e,t){if(!e.imageUrl&&!e.labelText)return null;const r=document.createElement("div");if(r.className="gengage-simrel-default-card-custom-badge",e.imageUrl&&we(e.imageUrl)){const n=document.createElement("img");return n.src=e.imageUrl,n.className="gengage-simrel-default-card-custom-badge-icon",n.alt=t,e.labelText&&n.addEventListener("error",()=>{r.innerHTML="",r.appendChild(V("span","gengage-simrel-default-card-custom-badge-text",e.labelText))},{once:!0}),r.appendChild(n),r}return e.labelText&&r.appendChild(V("span","gengage-simrel-default-card-custom-badge-text",e.labelText)),r}function Fi(e,t,r){if(e.length<=1||!t)return null;const n=document.createElement("div");return n.className="gengage-simrel-default-card-image-dots",e.forEach((o,i)=>{const a=document.createElement("button");a.className=`gengage-simrel-default-card-image-dot${i===0?" is-active":""}`,a.type="button",a.setAttribute("aria-label",r.labels.imageDot(i)),a.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),t.dataset.hoverIdx=String(i),t.style.opacity="0",window.setTimeout(()=>{t.src=o,t.style.opacity="1"},50),n.querySelectorAll(".gengage-simrel-default-card-image-dot").forEach((c,u)=>c.classList.toggle("is-active",u===i))}),n.appendChild(a)}),n}function Bi(e,t,r,n){const o=e.reviewCount??0,i=e.rating??0,a=document.createElement("div");a.className="gengage-simrel-default-card-rating",o<=0&&!r.productInfoLabel&&a.classList.add("is-placeholder");const s=document.createElement("div");s.className="gengage-simrel-default-card-rating-left";const c=document.createElement("div");c.className="gengage-simrel-default-card-stars";const u=Math.max(0,Math.min(5,Math.round(i)));for(let d=1;d<=5;d+=1){const f=document.createElement("span");f.className=`gengage-simrel-default-card-star${d<=u?" is-filled":""}`,f.textContent="★",c.appendChild(f)}s.appendChild(c);const l=document.createElement("button");if(l.className="gengage-simrel-default-card-review-link",l.type="button",l.textContent=r.reviewLabel(o),l.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),n(e)}),s.appendChild(l),a.appendChild(s),r.productInfoLabel){const d=document.createElement(t&&yt(t)?"a":"span");d.className="gengage-simrel-default-card-product-info-link",d.textContent=r.productInfoLabel,d instanceof HTMLAnchorElement&&(d.href=t,d.target="_blank",d.rel="noopener noreferrer",d.addEventListener("click",f=>f.stopPropagation())),a.appendChild(d)}return a}function Gi(e){const t=document.createElement("div");t.className="gengage-simrel-default-card-warranty-row";const r=e.length>0?e:[""];for(const n of r){const o=document.createElement("div");o.className=`gengage-simrel-default-card-warranty-badge${n?"":" is-placeholder"}`,n||o.setAttribute("aria-hidden","true"),o.textContent=n,t.appendChild(o)}return t}function qi(e,t){const r=document.createElement("div");r.className="gengage-simrel-default-card-feature-slot";const n=document.createElement("div");if(n.className="gengage-simrel-default-card-feature-swiper",e.length===0&&n.classList.add("is-placeholder"),n.dataset.current="0",e.length>0){if(t.media.promotionIconUrl&&yt(t.media.promotionIconUrl)){const a=document.createElement("img");a.src=t.media.promotionIconUrl,a.className="gengage-simrel-default-card-feature-icon",a.alt="",n.appendChild(a)}const o=document.createElement("div");o.className="gengage-simrel-default-card-feature-content";const i=V("span","gengage-simrel-default-card-feature-text",e[0]);if(o.appendChild(i),n.appendChild(o),e.length>1){const a=document.createElement("div");a.className="gengage-simrel-default-card-feature-arrows";const s=(l,d)=>{const f=d==="next"?"slide-out-left":"slide-out-right",m=d==="next"?"prepare-from-right":"prepare-from-left";i.classList.add(f),window.setTimeout(()=>{i.classList.remove(f),i.classList.add(m),i.textContent=e[l]??"",n.dataset.current=String(l),requestAnimationFrame(()=>requestAnimationFrame(()=>i.classList.remove(m)))},250)},c=document.createElement("button");c.className="gengage-simrel-default-card-feature-prev",c.type="button",c.textContent="‹",c.setAttribute("aria-label",t.labels.previousPromotion),c.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),s((Number.parseInt(n.dataset.current??"0",10)-1+e.length)%e.length,"prev")});const u=document.createElement("button");u.className="gengage-simrel-default-card-feature-next",u.type="button",u.textContent="›",u.setAttribute("aria-label",t.labels.nextPromotion),u.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),s((Number.parseInt(n.dataset.current??"0",10)+1)%e.length,"next")}),a.appendChild(c),a.appendChild(u),n.appendChild(a)}}return r.appendChild(n),r}function Ji(e,t,r,n,o){const i=ir(e.originalPrice),a=ir(e.price),s=a!==void 0&&i!==void 0&&a>0&&i>0&&a<i,c=document.createElement("div");c.className="gengage-simrel-default-card-price-action";const u=document.createElement("div");if(u.className="gengage-simrel-default-card-price",s){const l=o==="inline"?"gengage-simrel-default-card-price-old gengage-simrel-default-card-price-old--inline":"gengage-simrel-default-card-price-old";u.appendChild(V("span",l,ge(String(i),r.pricing)));const d=document.createElement("div");if(d.className="gengage-simrel-default-card-price-current-row",d.appendChild(V("span","gengage-simrel-default-card-price-current",ge(String(a),r.pricing))),t&&r.media.specialPriceBadgeUrl&&we(r.media.specialPriceBadgeUrl)){const f=document.createElement("img");f.src=r.media.specialPriceBadgeUrl,f.className="gengage-simrel-default-card-special-price-badge",f.alt=r.specialPriceBadgeAlt,d.appendChild(f)}u.appendChild(d)}else{const l=i??a;u.appendChild(V("span","gengage-simrel-default-card-price-current",l!==void 0?ge(String(l),r.pricing):""))}if(c.appendChild(u),r.ctaLabel){const l=document.createElement("button");l.className="gengage-simrel-default-card-cta",l.dataset.gengagePart="simrel-product-card-cta",l.type="button",l.dataset.sku=e.sku,l.textContent=r.ctaLabel,l.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),n(e)}),c.appendChild(l)}return c}function Vi(e,t){return e==="strike-through"||e==="badge"||e==="inline"?e:t.discountType}function ur(e){const{product:t,config:r}=e,n=et(t,r.fields.images).map(S=>Zi(S,t,r)).filter(we),o=et(t,r.fields.promotions),i=o.filter(S=>r.warrantyPromotionPattern.test(S)),a=o.filter(S=>!r.warrantyPromotionPattern.test(S)),s=me(t,r.fields.subtitle)??"",c=me(t,r.fields.discountReason)??"",u=Ni(Li(t,r.fields.specialPrice))===!0||r.specialPricePattern.test(c),l=t.brand??"",d=Di(l&&t.name.startsWith(`${l} `)?t.name.slice(l.length+1):t.name,s),f=document.createElement("article");f.className="gengage-simrel-default-card gengage-simrel-default-scope gengage-simrel-card gds-card gds-product-card gds-card-interactive",f.dataset.gengagePart="simrel-product-card",f.setAttribute("role","listitem"),f.setAttribute("tabindex","0"),f.setAttribute("aria-label",d),f.dataset.sku=t.sku,f.dataset.index=String(e.index);const m=ji(f,d,n);f.appendChild(m);const h=m.querySelector("img"),p=document.createElement("div");p.className="gengage-simrel-default-card-meta-row";const y=Mi(Ui(t,r),r.labels.customBadgeAlt);y&&p.appendChild(y);const k=Fi(n,h,r);k&&p.appendChild(k),f.appendChild(p);const P=document.createElement("div");return P.className="gengage-simrel-default-card-info",P.dataset.gengagePart="simrel-product-card-body",P.appendChild(V("h3","gengage-simrel-default-card-title",d)),s&&P.appendChild(V("p","gengage-simrel-default-card-subtitle",s)),P.appendChild(Bi(t,me(t,r.fields.productInfoUrl),r,e.context.onClick)),P.appendChild(Gi([...et(t,r.fields.warranties),...i])),P.appendChild(qi(a,r)),f.appendChild(P),f.appendChild(Ji(t,u,r,e.context.onClick,e.context.discountType)),f.addEventListener("click",S=>{(S.target instanceof HTMLElement?S.target:null)?.closest("button, a")||e.context.onClick(t)}),f.addEventListener("keydown",S=>{if(S.key!=="Enter"&&S.key!==" ")return;const v=S.target instanceof HTMLElement?S.target:null;v&&v!==f||(S.preventDefault(),e.context.onClick(t))}),f}function Wi(e,t){const r=sr(e.element.props?.product??e.element.props);if(!r)return null;const n=e.element.props?.index,o=typeof n=="number"&&Number.isFinite(n)?n:0,i=Vi(e.element.props?.discountType,e.context);return ur({product:r,index:o,context:i===e.context.discountType?e.context:{...e.context,...i!==void 0?{discountType:i}:{}},config:cr(t,e.context)})}function Hi(e){const t=document.createElement("div");t.className="gengage-simrel-grid gengage-simrel-default-grid gengage-simrel-default-scope",t.setAttribute("role","list");const r=e.element.props?.columns;let n;typeof r=="number"&&Number.isFinite(r)&&r>0?n=Math.floor(r):typeof e.context.gridColumns=="number"&&Number.isFinite(e.context.gridColumns)&&e.context.gridColumns>0&&(n=Math.floor(e.context.gridColumns)),n!==void 0&&t.style.setProperty("--gengage-simrel-columns",String(n));for(const o of e.element.children??[]){const i=e.renderElement(o);i&&t.appendChild(i)}if(t.children.length===0){const o=document.createElement("div");o.className="gengage-simrel-empty",o.textContent=e.context.i18n.emptyStateMessage,t.appendChild(o)}return t}function Ki(e,t){const r=e.element.props?.groups;if(!Array.isArray(r))return null;const n=r.map(Oi).filter(c=>!!c),o=e.element.props?.columns,i=cr(t,e.context),a=(c,u)=>ur({product:c,index:u,context:e.context,config:i}),s=Yt({groups:n,onClick:e.context.onClick,onAddToCart:e.context.onAddToCart,renderCardElement:a,i18n:e.context.i18n,...e.context.discountType!==void 0?{discountType:e.context.discountType}:{},...e.context.onGroupingActivate!==void 0?{onGroupingActivate:e.context.onGroupingActivate}:{},...typeof o=="number"&&Number.isFinite(o)&&o>0?{columns:Math.floor(o)}:e.context.gridColumns!==void 0?{columns:e.context.gridColumns}:{}});return s.classList.add("gengage-simrel-default-groups","gengage-simrel-default-scope"),s}function Yi(e={}){return{registry:{ProductGrid:t=>Hi(t),ProductCard:t=>Wi(t,e),GroupTabs:t=>Ki(t,e)}}}var lr;function g(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const u=a.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){const f=l[d];f in s||(s[f]=u[f].bind(s))}}const o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(s){var c;const u=r?.Parent?new i:this;n(u,s),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var ne=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},dr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(lr=globalThis).__zod_globalConfig??(lr.__zod_globalConfig={});var ze=globalThis.__zod_globalConfig;function Q(e){return e&&Object.assign(ze,e),ze}function fr(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function tt(e,t){return typeof t=="bigint"?t.toString():t}function rt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function nt(e){return e==null}function ot(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Xi(e,t){const r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var pr=Symbol("evaluating");function E(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==pr)return n===void 0&&(n=pr,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ee(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function W(...e){const t={};for(const r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function gr(e){return JSON.stringify(e)}function Qi(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var mr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ea=rt(()=>{if(ze.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function he(e){if(Ae(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Ae(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function hr(e){return he(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ta=new Set(["string","number","symbol"]);function Pe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function H(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function _(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ra(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var na={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function oa(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return H(e,W(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=r.shape[i])}return ee(this,"shape",o),o},checks:[]}))}function ia(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return H(e,W(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return ee(this,"shape",o),o},checks:[]}))}function aa(e,t){if(!he(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const n=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(n,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return H(e,W(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return ee(this,"shape",n),n}}))}function sa(e,t){if(!he(t))throw new Error("Invalid input to safeExtend: expected a plain object");return H(e,W(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return ee(this,"shape",r),r}}))}function ca(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return H(e,W(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return ee(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ua(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return H(t,W(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(r)for(const a in r){if(!(a in o))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=e?new e({type:"optional",innerType:o[a]}):o[a])}else for(const a in o)i[a]=e?new e({type:"optional",innerType:o[a]}):o[a];return ee(this,"shape",i),i},checks:[]}))}function la(e,t,r){return H(t,W(t._zod.def,{get shape(){const n=t._zod.def.shape,o={...n};if(r)for(const i in r){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(o[i]=new e({type:"nonoptional",innerType:n[i]}))}else for(const i in n)o[i]=new e({type:"nonoptional",innerType:n[i]});return ee(this,"shape",o),o}}))}function oe(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function da(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function yr(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ie(e){return typeof e=="string"?e:e?.message}function te(e,t,r){const n=e.message?e.message:Ie(e.inst?._zod.def?.error?.(e))??Ie(t?.error?.(e))??Ie(r.customError?.(e))??Ie(r.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:a,...s}=e;return s.path??(s.path=[]),s.message=n,t?.reportInput&&(s.input=a),s}function it(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ye(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var _r=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,tt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vr=g("$ZodError",_r),br=g("$ZodError",_r,{Parent:Error});function fa(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function pa(e,t=r=>r.message){const r={_errors:[]},n=(o,i=[])=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>n({issues:s},[...i,...a.path]));else if(a.code==="invalid_key")n({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")n({issues:a.issues},[...i,...a.path]);else{const s=[...i,...a.path];if(s.length===0)r._errors.push(t(a));else{let c=r,u=0;for(;u<s.length;){const l=s[u];u!==s.length-1?c[l]=c[l]||{_errors:[]}:(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(a))),c=c[l],u++}}}};return n(e),r}var at=e=>(t,r,n,o)=>{const i=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new ne;if(a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>te(c,i,Q())));throw mr(s,o?.callee),s}return a.value},st=e=>async(t,r,n,o)=>{const i=n?{...n,async:!0}:{async:!0};let a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>te(c,i,Q())));throw mr(s,o?.callee),s}return a.value},$e=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new ne;return i.issues.length?{success:!1,error:new(e??vr)(i.issues.map(a=>te(a,o,Q())))}:{success:!0,data:i.value}},ga=$e(br),Ne=e=>async(t,r,n)=>{const o=n?{...n,async:!0}:{async:!0};let i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>te(a,o,Q())))}:{success:!0,data:i.value}},ma=Ne(br),ha=e=>(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return at(e)(t,r,o)},ya=e=>(t,r,n)=>at(e)(t,r,n),_a=e=>async(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return st(e)(t,r,o)},va=e=>async(t,r,n)=>st(e)(t,r,n),ba=e=>(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return $e(e)(t,r,o)},wa=e=>(t,r,n)=>$e(e)(t,r,n),ka=e=>async(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return Ne(e)(t,r,o)},Sa=e=>async(t,r,n)=>Ne(e)(t,r,n),Ea=/^[cC][0-9a-z]{6,}$/,Ca=/^[0-9a-z]+$/,Ta=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xa=/^[0-9a-vA-V]{20}$/,za=/^[A-Za-z0-9]{27}$/,Aa=/^[a-zA-Z0-9_-]{21}$/,Pa=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ia=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,wr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,$a=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Na="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Oa(){return new RegExp(Na,"u")}var La=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ra=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Za=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Da=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ua=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kr=/^[A-Za-z0-9_-]*$/,ja=/^https?$/,Ma=/^\+[1-9]\d{6,14}$/,Sr="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Fa=new RegExp(`^${Sr}$`);function Er(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ba(e){return new RegExp(`^${Er(e)}$`)}function Ga(e){const t=Er({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Sr}T(?:${n})$`)}var qa=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ja=/^-?\d+$/,Va=/^-?\d+(?:\.\d+)?$/,Wa=/^[^A-Z]*$/,Ha=/^[^a-z]*$/,O=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Cr={number:"number",bigint:"bigint",object:"date"},Tr=g("$ZodCheckLessThan",(e,t)=>{O.init(e,t);const r=Cr[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xr=g("$ZodCheckGreaterThan",(e,t)=>{O.init(e,t);const r=Cr[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ka=g("$ZodCheckMultipleOf",(e,t)=>{O.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Xi(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Ya=g("$ZodCheckNumberFormat",(e,t)=>{O.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,i]=na[t.format];e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,s.minimum=o,s.maximum=i,r&&(s.pattern=Ja)}),e._zod.check=a=>{const s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<o&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Xa=g("$ZodCheckMaxLength",(e,t)=>{var r;O.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!nt(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=it(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Qa=g("$ZodCheckMinLength",(e,t)=>{var r;O.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!nt(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=it(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),es=g("$ZodCheckLengthEquals",(e,t)=>{var r;O.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!nt(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const a=it(o),s=i>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Oe=g("$ZodCheckStringFormat",(e,t)=>{var r,n;O.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),ts=g("$ZodCheckRegex",(e,t)=>{Oe.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),rs=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Wa),Oe.init(e,t)}),ns=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ha),Oe.init(e,t)}),os=g("$ZodCheckIncludes",(e,t)=>{O.init(e,t);const r=Pe(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),is=g("$ZodCheckStartsWith",(e,t)=>{O.init(e,t);const r=new RegExp(`^${Pe(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),as=g("$ZodCheckEndsWith",(e,t)=>{O.init(e,t);const r=new RegExp(`.*${Pe(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),ss=g("$ZodCheckOverwrite",(e,t)=>{O.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),cs=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const t=e.split(`
49
49
  `).filter(o=>o),r=Math.min(...t.map(o=>o.length-o.trimStart().length)),n=t.map(o=>o.slice(r)).map(o=>" ".repeat(this.indent*2)+o);for(const o of n)this.content.push(o)}compile(){const e=Function,t=this?.args,r=[...(this?.content??[""]).map(n=>` ${n}`)];return new e(...t,r.join(`
50
50
  `))}},us={major:4,minor:4,patch:3},x=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=us;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,s,c)=>{let u=oe(a),l;for(const d of s){if(d._zod.def.when){if(da(a)||!d._zod.def.when(a))continue}else if(u)continue;const f=a.issues.length,m=d._zod.check(a);if(m instanceof Promise&&c?.async===!1)throw new ne;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await m,a.issues.length!==f&&(u||(u=oe(a,f)))});else{if(a.issues.length===f)continue;u||(u=oe(a,f))}}return l?l.then(()=>a):a},i=(a,s,c)=>{if(oe(a))return a.aborted=!0,a;const u=o(s,n,c);if(u instanceof Promise){if(c.async===!1)throw new ne;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(l=>i(l,a,s)):i(u,a,s)}const c=e._zod.parse(a,s);if(c instanceof Promise){if(s.async===!1)throw new ne;return c.then(u=>o(u,n,s))}return o(c,n,s)}}E(e,"~standard",()=>({validate:o=>{try{const i=ga(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return ma(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),ct=g("$ZodString",(e,t)=>{x.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??qa(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),C=g("$ZodStringFormat",(e,t)=>{Oe.init(e,t),ct.init(e,t)}),ls=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ia),C.init(e,t)}),ds=g("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=wr(r))}else t.pattern??(t.pattern=wr());C.init(e,t)}),fs=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=$a),C.init(e,t)}),ps=g("$ZodURL",(e,t)=>{C.init(e,t),e._zod.check=r=>{try{const n=r.value.trim();if(!t.normalize&&t.protocol?.source===ja.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}const o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),gs=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Oa()),C.init(e,t)}),ms=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Aa),C.init(e,t)}),hs=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ea),C.init(e,t)}),ys=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ca),C.init(e,t)}),_s=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ta),C.init(e,t)}),vs=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xa),C.init(e,t)}),bs=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=za),C.init(e,t)}),ws=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ga(t)),C.init(e,t)}),ks=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Fa),C.init(e,t)}),Ss=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ba(t)),C.init(e,t)}),Es=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Pa),C.init(e,t)}),Cs=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=La),C.init(e,t),e._zod.bag.format="ipv4"}),Ts=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ra),C.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),xs=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Za),C.init(e,t)}),zs=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Da),C.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[o,i]=n;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function zr(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var As=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ua),C.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{zr(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Ps(e){if(!kr.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/");return zr(t.padEnd(Math.ceil(t.length/4)*4,"="))}var Is=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=kr),C.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Ps(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),$s=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ma),C.init(e,t)});function Ns(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var Os=g("$ZodJWT",(e,t)=>{C.init(e,t),e._zod.check=r=>{Ns(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Ar=g("$ZodNumber",(e,t)=>{x.init(e,t),e._zod.pattern=e._zod.bag.pattern??Va,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),Ls=g("$ZodNumberFormat",(e,t)=>{Ya.init(e,t),Ar.init(e,t)}),Rs=g("$ZodUnknown",(e,t)=>{x.init(e,t),e._zod.parse=r=>r}),Zs=g("$ZodNever",(e,t)=>{x.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Pr(e,t,r){e.issues.length&&t.issues.push(...yr(r,e.issues)),t.value[r]=e.value}var Ds=g("$ZodArray",(e,t)=>{x.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const s=o[a],c=t.element._zod.run({value:s,issues:[]},n);c instanceof Promise?i.push(c.then(u=>Pr(u,r,a))):Pr(c,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function Le(e,t,r,n,o,i){const a=r in n;if(e.issues.length){if(o&&i&&!a)return;t.issues.push(...yr(r,e.issues))}if(!a&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?a&&(t.value[r]=void 0):t.value[r]=e.value}function Ir(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=ra(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function $r(e,t,r,n,o,i){const a=[],s=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(const f in t){if(f==="__proto__"||s.has(f))continue;if(u==="never"){a.push(f);continue}const m=c.run({value:t[f],issues:[]},n);m instanceof Promise?e.push(m.then(h=>Le(h,r,f,t,l,d))):Le(m,r,f,t,l,d)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var Us=g("$ZodObject",(e,t)=>{if(x.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const s={...a};return Object.defineProperty(t,"shape",{value:s}),s}})}const r=rt(()=>Ir(t));E(e._zod,"propValues",()=>{const a=t.shape,s={};for(const c in a){const u=a[c]._zod;if(u.values){s[c]??(s[c]=new Set);for(const l of u.values)s[c].add(l)}}return s});const n=Ae,o=t.catchall;let i;e._zod.parse=(a,s)=>{i??(i=r.value);const c=a.value;if(!n(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),a;a.value={};const u=[],l=i.shape;for(const d of i.keys){const f=l[d],m=f._zod.optin==="optional",h=f._zod.optout==="optional",p=f._zod.run({value:c[d],issues:[]},s);p instanceof Promise?u.push(p.then(y=>Le(y,a,d,c,m,h))):Le(p,a,d,c,m,h)}return o?$r(u,c,a,s,r.value,e):u.length?Promise.all(u).then(()=>a):a}}),js=g("$ZodObjectJIT",(e,t)=>{Us.init(e,t);const r=e._zod.parse,n=rt(()=>Ir(t)),o=f=>{const m=new cs(["shape","payload","ctx"]),h=n.value,p=S=>{const v=gr(S);return`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`};m.write("const input = payload.value;");const y=Object.create(null);let k=0;for(const S of h.keys)y[S]=`key_${k++}`;m.write("const newResult = {};");for(const S of h.keys){const v=y[S],b=gr(S),I=f[S],M=I?._zod?.optin==="optional",Nl=I?._zod?.optout==="optional";m.write(`const ${v} = ${p(S)};`),M&&Nl?m.write(`
package/dist/simrel.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a, i as r, n as t, r as i, t as m } from "./runtime-8xoIKpil.js";
2
- import { n as R, t as n } from "./simrel-C4X5Yp32.js";
1
+ import { a, i as r, n as t, r as i, t as m } from "./runtime-CmpEARET.js";
2
+ import { n as R, t as n } from "./simrel-BuCc53Pw.js";
3
3
  export {
4
4
  m as GengageSimRel,
5
5
  i as createDefaultSimRelUISpecRegistry,
@@ -257,7 +257,7 @@ function p(e, t, r) {
257
257
  const a = [`[gengage:${e}]`, t];
258
258
  r !== void 0 && a.push(r), console.debug(...a);
259
259
  }
260
- var D = ("0.6.40".trim(), "0.6.40".trim()), B = ("package-build".trim(), "package-build".trim());
260
+ var D = ("0.6.42".trim(), "0.6.42".trim()), B = ("package-build".trim(), "package-build".trim());
261
261
  function G() {
262
262
  if (typeof window > "u") return;
263
263
  const e = window;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gengage/assistant-fe",
3
- "version": "0.6.40",
3
+ "version": "0.6.42",
4
4
  "description": "Source-available frontend widgets for Gengage AI Assistant — chat, Q&A, and similar-products. Backend is SaaS (gengage.ai).",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",