@gengage/assistant-fe 0.6.49 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/chat/api.d.ts +1 -1
  2. package/dist/chat/components/ChatDrawer.d.ts +3 -1
  3. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +1 -1
  4. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +7 -1
  5. package/dist/chat/history-storage.d.ts +36 -4
  6. package/dist/chat/runtime.d.ts +73 -3
  7. package/dist/chat/utils/chat-presentation-debug.d.ts +0 -14
  8. package/dist/chat-runtime.js +1 -1
  9. package/dist/chat.iife.js +72 -72
  10. package/dist/chat.js +1 -1
  11. package/dist/common/connection-warning.d.ts +10 -0
  12. package/dist/common/indexed-db.d.ts +35 -2
  13. package/dist/common/native-webview.d.ts +1 -1
  14. package/dist/common/streaming.d.ts +6 -1
  15. package/dist/common/transport.d.ts +2 -1
  16. package/dist/common/types.d.ts +16 -0
  17. package/dist/{common-nAeMxZrn.js → common-CeuGSwJL.js} +61 -65
  18. package/dist/common.js +30 -30
  19. package/dist/{connection-warning-CDtUX-ol.js → connection-warning-C0e2byq5.js} +31 -25
  20. package/dist/{fastIntent-D45C2rEO.js → fastIntent-BI7l1oDv.js} +2 -2
  21. package/dist/global-error-toast-DvaKvPNA.js +798 -0
  22. package/dist/index.js +29 -29
  23. package/dist/native-webview-CHKpwixw.js +303 -0
  24. package/dist/native.iife.js +30 -30
  25. package/dist/native.js +1 -1
  26. package/dist/{overlay-BPZEIyo_.js → overlay-C3XzoSKd.js} +51 -32
  27. package/dist/overlay.js +6 -6
  28. package/dist/{price-formatter-CHUmYq8I.js → price-formatter-Q3wUKrl1.js} +2 -1
  29. package/dist/qna/runtime.d.ts +1 -0
  30. package/dist/qna-runtime.js +1 -1
  31. package/dist/qna.iife.js +32 -32
  32. package/dist/qna.js +1 -1
  33. package/dist/{request-response-cache-CGxwN0CV.js → request-response-cache-BLQy7llq.js} +478 -454
  34. package/dist/{runtime-CNlICVeC.js → runtime-BC8-a6Ql.js} +231 -219
  35. package/dist/runtime-BSIrZhF2.js +8889 -0
  36. package/dist/{runtime-Cg-6aUps.js → runtime-DiONTdBz.js} +230 -212
  37. package/dist/{simbut-BtaGMLLn.js → simbut-BDbb3nMH.js} +5 -5
  38. package/dist/simbut.iife.js +2 -2
  39. package/dist/simbut.js +1 -1
  40. package/dist/simrel/components/GroupTabs.d.ts +6 -0
  41. package/dist/simrel/runtime.d.ts +8 -0
  42. package/dist/{simrel-iGl2aXiY.js → simrel-CdxDIKu3.js} +15 -15
  43. package/dist/simrel-runtime.js +1 -1
  44. package/dist/simrel.iife.js +22 -22
  45. package/dist/simrel.js +2 -2
  46. package/dist/widget-base-Cvxdrqqt.js +141 -0
  47. package/package.json +1 -1
  48. package/dist/context-UTzCGyR9.js +0 -543
  49. package/dist/native-webview-CYX30O3Q.js +0 -273
  50. package/dist/runtime-COLQGOkl.js +0 -8708
  51. package/dist/widget-base-AuwRxs2X.js +0 -365
package/dist/qna.iife.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(M){Object.defineProperty(M,Symbol.toStringTag,{value:"Module"});var Cn=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function On(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const n=e.unknownRenderer??Cn,r=i=>{const s=e.spec.elements[i];if(!s)return null;const a=e.registry[s.type];return a?a({elementId:i,element:s,spec:e.spec,context:e.context,renderElement:r}):n({elementId:i,element:s,spec:e.spec,context:e.context,renderElement:r})},o=r(e.spec.root);return o&&t.appendChild(o),t}function Zn(e,t){if(!t)return e;const n={...e};for(const[r,o]of Object.entries(t))o&&(n[r]=o);return n}var Rn=["http:","https:"];function Ln(e){const t=e.trim();if(!t)return!1;if(t.startsWith("/")&&!t.startsWith("//"))return!0;try{return Rn.includes(new URL(t).protocol)}catch{return!1}}function Nn(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function Pe(e,t){const n={event:e,...t};Nn()&&window.dataLayer.push(n)}function jn(e){Pe("gengage-on-init",{gengage_widget:e})}function qn(e){Pe("gengage-show",{gengage_widget:e})}function Dn(e,t){Pe("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function xe(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function nt(e,t){const n=r=>{t(r.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function Un(){const e=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=e,sessionStorage.setItem("gengage_session_id",e),window.gengage||(window.gengage={}),window.gengage.sessionId=e,e}function Bn(e){return{sessionId:e?.sessionId??Un(),...e}}var rt={"--gengage-chat-offset":"20px","--gengage-chat-launcher-width":"56px","--gengage-chat-launcher-height":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"12px","--gengage-simrel-card-radius":"0.75rem","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--surface-card-muted":"#f8fafc","--text-secondary":"#4b5563","--text-muted":"#6b7280","--border-default":"rgba(17, 24, 39, 0.10)"};function Mn(e){if(!e)return{...rt};const t={...rt,...e},n=e["--gengage-chat-launcher-size"];return n!==void 0&&(e["--gengage-chat-launcher-width"]===void 0&&(t["--gengage-chat-launcher-width"]=n),e["--gengage-chat-launcher-height"]===void 0&&(t["--gengage-chat-launcher-height"]=n)),t}var R={primaryColor:"#b7102a",primaryForeground:"#ffffff",backgroundColor:"#ffffff",foregroundColor:"#111827",borderRadius:"0.75rem",fontFamily:'"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px",zIndex:"1000","--glov-chatbot-width":"420px","--glov-left-spacing":"260px","--chatbot-padding":"16px","--root-wrapper-background-color":"#f8f9fa","--root-wrapper-border-color":"#edeeef","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem","--client-primary":"#b7102a","--client-primary-hover":"color-mix(in srgb, #b7102a 88%, black 12%)","--client-primary-active":"color-mix(in srgb, #b7102a 78%, black 22%)","--client-primary-subtle":"color-mix(in srgb, #b7102a 12%, white)","--client-primary-soft":"color-mix(in srgb, #b7102a 20%, white)","--client-on-primary":"#ffffff","--client-focus-ring":"color-mix(in srgb, #b7102a 32%, transparent)","--surface-page":"#f6f7fb","--surface-shell":"#10131a","--surface-card":"#ffffff","--surface-card-muted":"#f8fafc","--surface-card-soft":"#f8fafc","--surface-elevated":"#ffffff","--surface-input":"#ffffff","--surface-overlay":"rgba(16, 19, 26, 0.52)","--text-primary":"#111827","--text-secondary":"#4b5563","--text-muted":"#6b7280","--text-inverse":"#f9fafb","--border-subtle":"rgba(17, 24, 39, 0.06)","--border-default":"rgba(17, 24, 39, 0.10)","--border-strong":"rgba(17, 24, 39, 0.18)","--shadow-1":"0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)","--shadow-2":"0 4px 12px rgba(16, 24, 40, 0.08)","--shadow-3":"0 10px 24px rgba(16, 24, 40, 0.12)","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--success":"#16a34a","--warning":"#d97706","--error":"#dc2626","--info":"#2563eb","--rating":"#f5b301","--gengage-brand-accent-start":"#0b24d6","--gengage-brand-accent-mid":"#f768f2","--gengage-brand-accent-end":"#ffed74","--ai-accent-start":"#0b24d6","--ai-accent-end":"#f768f2","--ai-accent-soft":"linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"},D="gengage-global-toast-root",ot="gengage-global-toast-style",Ce="gengage-global-toast-root--visible",Fn=4200,Hn=1500,Jn=15e3,Qn=["--gengage-font-family","--surface-card","--text-primary","--text-muted","--border-default","--radius-card","--shadow-3","--error","--ds-toast-error-bg","--ds-toast-error-border","--ds-toast-error-accent","--ds-toast-error-fg","--ds-toast-error-shadow"],it=!1,F=null,Wn=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i];function st(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function Vn(e){if(typeof navigator<"u"&&navigator.onLine===!1)return!0;const t=e instanceof Error?e.message.trim():"";return t?Wn.some(n=>n.test(t)):!1}function Gn(e,t){return Vn(t)?st(e)?"Bağlantı sorunu oluştu. Lütfen tekrar deneyin.":"Connection issue. Please try again.":st(e)?"Bir hata oluştu. Lütfen tekrar deneyin.":"Something went wrong. Please try again."}function Kn(){it||typeof window>"u"||typeof document>"u"||(it=!0,nt("gengage:global:error",e=>{Oe(e)}))}function Oe(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;nr();const n=Xn();er(n),n.innerHTML="";const r=document.createElement("section");r.className="gengage-global-toast gengage-global-toast--error",r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="gengage-global-toast-title",o.textContent=Yn(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,r.appendChild(o),r.appendChild(i),n.appendChild(r),n.classList.add(Ce),F&&(clearTimeout(F),F=null),e.sticky!==!0&&(F=setTimeout(()=>{at()},tr(e.durationMs)))}function at(){if(typeof document>"u")return;const e=document.getElementById(D);e&&(e.classList.remove(Ce),e.innerHTML="",F&&(clearTimeout(F),F=null))}function Yn(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function Xn(){const e=document.getElementById(D);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=D,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function er(e){if(typeof document>"u"||typeof window>"u")return;const t=document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");if(!t)return;const n=window.getComputedStyle(t);for(const r of Qn){const o=n.getPropertyValue(r).trim();o?e.style.setProperty(r,o):e.style.removeProperty(r)}}function tr(e){return typeof e!="number"||!Number.isFinite(e)?Fn:Math.min(Jn,Math.max(Hn,Math.round(e)))}function nr(){if(document.getElementById(ot))return;const e=document.createElement("style");e.id=ot;const t=R["--surface-card"]??R.backgroundColor??"#ffffff",n=R["--text-primary"]??R.foregroundColor??"#111827",r=R["--border-default"]??"rgba(17, 24, 39, 0.10)",o=R["--error"]??"#dc2626",i=R["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",s=R["--radius-card"]??"16px",a=R["--text-muted"]??"#6b7280";e.textContent=`
1
+ (function(M){Object.defineProperty(M,Symbol.toStringTag,{value:"Module"});var xn=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function Cn(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const n=e.unknownRenderer??xn,r=i=>{const s=e.spec.elements[i];if(!s)return null;const a=e.registry[s.type];return a?a({elementId:i,element:s,spec:e.spec,context:e.context,renderElement:r}):n({elementId:i,element:s,spec:e.spec,context:e.context,renderElement:r})},o=r(e.spec.root);return o&&t.appendChild(o),t}function On(e,t){if(!t)return e;const n={...e};for(const[r,o]of Object.entries(t))o&&(n[r]=o);return n}var Zn=["http:","https:"];function Rn(e){const t=e.trim();if(!t)return!1;if(t.startsWith("/")&&!t.startsWith("//"))return!0;try{return Zn.includes(new URL(t).protocol)}catch{return!1}}function Ln(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function Pe(e,t){const n={event:e,...t};Ln()&&window.dataLayer.push(n)}function Nn(e){Pe("gengage-on-init",{gengage_widget:e})}function jn(e){Pe("gengage-show",{gengage_widget:e})}function qn(e,t){Pe("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function xe(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function nt(e,t){const n=r=>{t(r.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function Dn(){const e=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=e,sessionStorage.setItem("gengage_session_id",e),window.gengage||(window.gengage={}),window.gengage.sessionId=e,e}function Un(e){return{sessionId:e?.sessionId??Dn(),...e}}var rt={"--gengage-chat-offset":"20px","--gengage-chat-launcher-width":"56px","--gengage-chat-launcher-height":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"12px","--gengage-simrel-card-radius":"0.75rem","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--surface-card-muted":"#f8fafc","--text-secondary":"#4b5563","--text-muted":"#6b7280","--border-default":"rgba(17, 24, 39, 0.10)"};function Bn(e){if(!e)return{...rt};const t={...rt,...e},n=e["--gengage-chat-launcher-size"];return n!==void 0&&(e["--gengage-chat-launcher-width"]===void 0&&(t["--gengage-chat-launcher-width"]=n),e["--gengage-chat-launcher-height"]===void 0&&(t["--gengage-chat-launcher-height"]=n)),t}var R={primaryColor:"#b7102a",primaryForeground:"#ffffff",backgroundColor:"#ffffff",foregroundColor:"#111827",borderRadius:"0.75rem",fontFamily:'"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px",zIndex:"1000","--glov-chatbot-width":"420px","--glov-left-spacing":"260px","--chatbot-padding":"16px","--root-wrapper-background-color":"#f8f9fa","--root-wrapper-border-color":"#edeeef","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem","--client-primary":"#b7102a","--client-primary-hover":"color-mix(in srgb, #b7102a 88%, black 12%)","--client-primary-active":"color-mix(in srgb, #b7102a 78%, black 22%)","--client-primary-subtle":"color-mix(in srgb, #b7102a 12%, white)","--client-primary-soft":"color-mix(in srgb, #b7102a 20%, white)","--client-on-primary":"#ffffff","--client-focus-ring":"color-mix(in srgb, #b7102a 32%, transparent)","--surface-page":"#f6f7fb","--surface-shell":"#10131a","--surface-card":"#ffffff","--surface-card-muted":"#f8fafc","--surface-card-soft":"#f8fafc","--surface-elevated":"#ffffff","--surface-input":"#ffffff","--surface-overlay":"rgba(16, 19, 26, 0.52)","--text-primary":"#111827","--text-secondary":"#4b5563","--text-muted":"#6b7280","--text-inverse":"#f9fafb","--border-subtle":"rgba(17, 24, 39, 0.06)","--border-default":"rgba(17, 24, 39, 0.10)","--border-strong":"rgba(17, 24, 39, 0.18)","--shadow-1":"0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)","--shadow-2":"0 4px 12px rgba(16, 24, 40, 0.08)","--shadow-3":"0 10px 24px rgba(16, 24, 40, 0.12)","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--success":"#16a34a","--warning":"#d97706","--error":"#dc2626","--info":"#2563eb","--rating":"#f5b301","--gengage-brand-accent-start":"#0b24d6","--gengage-brand-accent-mid":"#f768f2","--gengage-brand-accent-end":"#ffed74","--ai-accent-start":"#0b24d6","--ai-accent-end":"#f768f2","--ai-accent-soft":"linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"},D="gengage-global-toast-root",ot="gengage-global-toast-style",Ce="gengage-global-toast-root--visible",Mn=4200,Fn=1500,Hn=15e3,Jn=["--gengage-font-family","--surface-card","--text-primary","--text-muted","--border-default","--radius-card","--shadow-3","--error","--ds-toast-error-bg","--ds-toast-error-border","--ds-toast-error-accent","--ds-toast-error-fg","--ds-toast-error-shadow"],it=!1,F=null,Qn=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i];function st(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function Wn(e){if(typeof navigator<"u"&&navigator.onLine===!1)return!0;const t=(e instanceof Error?e.message:typeof e=="string"?e:"").trim();return t?Qn.some(n=>n.test(t)):!1}function Vn(e,t){return Wn(t)?st(e)?"Bağlantı sorunu oluştu. Lütfen tekrar deneyin.":"Connection issue. Please try again.":st(e)?"Bir hata oluştu. Lütfen tekrar deneyin.":"Something went wrong. Please try again."}function Gn(){it||typeof window>"u"||typeof document>"u"||(it=!0,nt("gengage:global:error",e=>{Oe(e)}))}function Oe(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;tr();const n=Yn();Xn(n),n.innerHTML="";const r=document.createElement("section");r.className="gengage-global-toast gengage-global-toast--error",r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="gengage-global-toast-title",o.textContent=Kn(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,r.appendChild(o),r.appendChild(i),n.appendChild(r),n.classList.add(Ce),F&&(clearTimeout(F),F=null),e.sticky!==!0&&(F=setTimeout(()=>{at()},er(e.durationMs)))}function at(){if(typeof document>"u")return;const e=document.getElementById(D);e&&(e.classList.remove(Ce),e.innerHTML="",F&&(clearTimeout(F),F=null))}function Kn(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function Yn(){const e=document.getElementById(D);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=D,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function Xn(e){if(typeof document>"u"||typeof window>"u")return;const t=document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");if(!t)return;const n=window.getComputedStyle(t);for(const r of Jn){const o=n.getPropertyValue(r).trim();o?e.style.setProperty(r,o):e.style.removeProperty(r)}}function er(e){return typeof e!="number"||!Number.isFinite(e)?Mn:Math.min(Hn,Math.max(Fn,Math.round(e)))}function tr(){if(document.getElementById(ot))return;const e=document.createElement("style");e.id=ot;const t=R["--surface-card"]??R.backgroundColor??"#ffffff",n=R["--text-primary"]??R.foregroundColor??"#111827",r=R["--border-default"]??"rgba(17, 24, 39, 0.10)",o=R["--error"]??"#dc2626",i=R["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",s=R["--radius-card"]??"16px",a=R["--text-muted"]??"#6b7280";e.textContent=`
2
2
  #${D} {
3
3
  position: fixed;
4
4
  top: 16px;
@@ -44,68 +44,68 @@
44
44
  transform: translateY(0);
45
45
  }
46
46
  }
47
- `,document.head.appendChild(e)}var te=null;function rr(){if(te!==null)return te;try{te=localStorage.getItem("gengage:debug")==="1"}catch{te=!1}return te}function Ze(e,t,n){if(!rr())return;const r=[`[gengage:${e}]`,t];n!==void 0&&r.push(n),console.debug(...r)}var or=("0.6.49".trim(),"0.6.49".trim()),ir=("iife-build".trim(),"iife-build".trim());function sr(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${or} (${ir})`))}var ar=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=Mn(e.theme);sr(),this.config={...e,theme:t,session:Bn(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),Kn();const n=nt("gengage:context:update",r=>this.update(r));this._cleanups.push(n),Ze("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(r){throw this.destroy(),r}this._destroying||(this.isInitialised=!0,Ze("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(n=>n(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const n=document.querySelector(e);if(!n)throw new Error(`[gengage] Mount target not found: "${e}"`);return n}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,n]of Object.entries(e))if(n!==void 0){const r=t.startsWith("--")?t:`--gengage-${cr(t)}`;this.root.style.setProperty(r,n)}}}};function cr(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function ct(e){const t=e?.trim();return t||"tr"}var ur=8e3,lr=5e3,dr="https://www.google.com/favicon.ico",q=new Map,ut=!1,G=null,ne=null,H=!1;function fr(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function lt(e){return fr(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 dt(){let e;for(const t of q.values())e=t;return e}function Re(){G&&(clearTimeout(G),G=null)}function pr(){ne&&(clearInterval(ne),ne=null)}async function ft(){try{if(typeof navigator<"u"&&navigator.onLine===!1)return!1;if(typeof window<"u"){const n=window.location.hostname;if(n==="localhost"||n==="127.0.0.1")return navigator.onLine}const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);try{return await fetch(dr,{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 fe(){H=!1,pr(),at()}function pe(){G||H||q.size===0||(G=setTimeout(async()=>{G=null,!(H||q.size===0)&&!await ft()&&q.size>0&&(H=!0,Oe({source:"sdk",message:lt(dt()),sticky:!0}),ne||(ne=setInterval(async()=>{if(q.size===0){fe();return}await ft()&&(fe(),pe())},lr)))},ur))}function gr(){ut||typeof window>"u"||(ut=!0,window.addEventListener("online",()=>{fe(),pe()}),window.addEventListener("offline",()=>{q.size===0||H||(H=!0,Re(),Oe({source:"sdk",message:lt(dt()),sticky:!0}))}))}function hr(e){gr();const t=Symbol(e.source);q.set(t,e.locale),pe();let n=!1;return()=>{if(!n){if(n=!0,q.delete(t),q.size===0){Re(),fe();return}H||(Re(),pe())}}}function pt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function mr(e){const t=[];let n=0,r=!1,o=!1,i=0;for(let s=0;s<e.length;s++){const a=e[s];if(o){o=!1;continue}if(a==="\\"&&r){o=!0;continue}if(a==='"'){r=!r;continue}r||(a==="{"&&n++,a==="}"&&(n--,n===0&&(t.push(e.slice(i,s+1)),i=s+1)))}return t.length>0?t:[e]}function gt(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const r=n.startsWith("data: ")?n.slice(6):n;if(r==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(r);return pt(o)?(Ze("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=mr(r);if(o.length>1){for(const i of o)try{const s=JSON.parse(i);if(!pt(s))continue;if(t.onEvent(s),s.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function yr(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 n=e.body.getReader(),r=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,s=Symbol("idle-timeout");let a=!1;try{for(;;){const c=n.read();let u;const d=await(i>0?Promise.race([c.then(h=>(clearTimeout(u),h)),new Promise(h=>{u=setTimeout(()=>h(s),i)})]):c);if(d===s){a=!0,await n.cancel();break}const{done:f,value:g}=d;if(f)break;o+=r.decode(g,{stream:!0});const p=o.split(`
48
- `);o=p.pop()??"";for(const h of p)if(gt(h,t))return}if(o.trim()&&gt(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{a||n.releaseLock()}t.onDone?.()}var _r={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function vr(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 br(e,t){return`${vr(t?.middlewareUrl)}/chat${_r[e]}`}var ht=3,wr=(e,t)=>{const n=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!n)return"";const r=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,"").trim():n;return r?r.split(/\s+/).slice(0,3).join(" ").trim():""},Le=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(n=>wr(n,t)).filter(Boolean):[];function kr(e){const t=(e.display_keywords??[]).flatMap(o=>Le(o,{stripLeadingStopWords:!0})),n=t.filter((o,i)=>t.indexOf(o)===i);if(n.length>0)return n.slice(0,ht);const r=[...Le(e.chosen_attribute,{stripLeadingStopWords:!0}),...Le(e.short_name)];return r.filter((o,i)=>r.indexOf(o)===i).slice(0,ht)}function Sr(e){return kr(e).join(" • ")}function zr(e){return e==="beauty_consulting"||e==="account_expert"}function re(...e){for(const t of e){if(typeof t!="string")continue;const n=t.trim();if(n.length>0)return n}}function oe(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim()):[]}function ge(e){const t={...e},n=re(t.sku),r=oe(t.group_skus);if(n?t.sku=n:delete t.sku,r.length>0?t.group_skus=r:delete t.group_skus,n||r.length>0)delete t.image_url;else{const o=re(t.image_url);o?t.image_url=o:delete t.image_url}return t}function Er(e){if(typeof e.type!="string")return null;if(Ar(e))return e;const t=e;switch(t.type){case"outputText":return Tr(t);case"suggestedActions":return $r(t);case"productList":return Ir(t);case"productDetails":return Pr(t);case"productDetailsSimilars":return xr(t);case"comparisonTable":return Cr(t);case"context":return Lr(t);case"chatStreamEnd":return Nr();case"loading":return jr(t);case"panelLoading":return qr(t);case"similarLoading":return Dr(t);case"redirect":return Ur(t);case"error":return Br(t);case"dummy":return Mr(t);case"launcherAction":return Fr(t);case"text":return Ne(t);case"productItem":return Hr(t);case"text_image":return mt(t);case"quick_qna":return yt(t);case"reviewHighlights":return Jr(t);case"aiProductSuggestions":return Qr(t);case"aiProductGroupings":return Wr(t);case"aiSuggestedSearches":return Kr(t);case"getGroundingReview":return Yr(t);case"voice":return Xr(t);case"uiSpec":return ao(t);default:return null}}function Ar(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 n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const r=x(e.spec);return r?typeof r.root=="string"&&x(r.elements)!==null:!1}case"action":{const n=x(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Tr(e){const t=_(e.payload.text,e.payload.plain_text)??"",n=_(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const r={type:"text_chunk",content:t,final:!0},o=e.payload.sku_to_product_item;o&&typeof o=="object"&&!Array.isArray(o)&&(r.skuToProductItem=o);const i=e.payload.product_mentions;Array.isArray(i)&&i.length>0&&(r.productMentions=i.map(c=>{if(typeof c!="object"||c===null||typeof c.sku!="string")return null;const u=typeof c.short_name=="string"?c.short_name:"";if(!u)return null;const d=(typeof c.url=="string"&&c.url.trim()?c.url.trim():void 0)??(()=>{const f=r.skuToProductItem?.[c.sku];return typeof f?.url=="string"&&f.url.trim()?f.url.trim():void 0})();return d?{sku:c.sku,short_name:u,url:d}:{sku:c.sku,short_name:u}}).filter(c=>c!==null));const s=e.payload.conversation_mode;typeof s=="string"&&s&&(r.conversationMode=s);const a=e.payload.render_hint;return typeof a=="string"&&a&&(r.renderHint=a),e.payload.kvkk===!0&&(r.kvkk=!0),r}function $r(e){return _t((e.payload.actions??[]).map(t=>{const n=_(t.title)??"",r=Z(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(se),"chat")}function Ir(e){const t=Array.isArray(e.payload.grouped_assignment)?e.payload.grouped_assignment:[],n=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(a=>{const c=_(a.style_label);if(!c)return null;const u=_(a.style_mood),d=_(a.image_url??void 0),f=(Array.isArray(a.product_list)?a.product_list:[]).map(p=>{const h=x(p);return h?De(x(h.product_detail)??x(h.product)??h):null}).filter(se),g=Array.isArray(a.recommendation_groups)?a.recommendation_groups.map(p=>({label:_(p.label)??"",reason:_(p.reason)??"",skus:Array.isArray(p.skus)?p.skus.filter(h=>typeof h=="string"&&h.trim().length>0):[]})):[];return{style_label:c,style_mood:u??"",...d?{image_url:d}:{},...typeof a.status=="string"?{status:a.status}:{},product_list:f,recommendation_groups:g}}).filter(se),r=e.payload.product_list??[],o=zr(e.payload.source)&&n.length>0?n[0].product_list:null,i=o?to(o,"chat"):t.length>0?eo(t,r,"chat")??qe(r,"chat"):qe(r,"chat");i.panelHint="panel";const s=i.spec.elements[i.spec.root];if(s){const a={};typeof e.payload.offset=="number"&&(a.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(a.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(a.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(a.source=e.payload.source),n.length>0&&(a.styleVariations=n),e.payload.replace_panel===!0&&(a.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(a.rankingState=e.payload.ranking_state);const c=e.payload.sequence_id??e.payload.search_id;typeof c=="string"&&c.length>0&&(a.sequenceId=c),Object.keys(a).length>0&&(s.props={...s.props,...a})}return i}function Pr(e){const t=e.payload.productDetails;if(!t)return ro("chat");const n=K(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...n}}}}},panelHint:"panel"}}function xr(e){const t=qe(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Cr(e){const t=e.payload.multiple_product_details??[],n=e.payload,r={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,s=[];for(const v of t){const w=K(v);s.push(w)}const a=Or(o,s,r,i);let c;r?.recommended_choice_sku?c=r.recommended_choice_sku:r?.winner_product&&r.winner_product.length>0&&(c=r.winner_product[0]?.product_detail?.sku??r.winner_product[0]?.sku);const u=c?s.find(v=>v.sku===c)??s[0]:s[0],d=[];if(Array.isArray(r?.key_differences))for(const v of r.key_differences)typeof v=="string"&&d.push(v);const f=vt(r?.special_considerations),g=r?.recommended_choice,p=r?.winner_hits,h={};for(const v of s){const w=v.sku;w&&(h[w]={title:v.name??w,type:"launchSingleProduct",payload:{sku:w}})}const m={products:s,attributes:a,highlights:d,productActions:h};return u&&(m.recommended=u),f.length>0&&(m.specialCases=f),g&&(m.recommendedText=g),p&&(m.winnerHits=p),typeof r?.key_differences=="string"&&(m.keyDifferencesHtml=r.key_differences),r?.special_considerations&&(m.specialConsiderations=r.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function Or(e,t,n,r){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const f=n.criteria_view??n.criteria_view_short??{},g=n.compared_field_names??Object.keys(e),p=[];for(const h of g){const m=e[h];if(!m||!Array.isArray(m))continue;const v=f[h]??h;p.push({label:v,values:m.map(w=>typeof w=="string"?w:String(w??""))})}return p}const s=e,a=t.map(f=>String(f.sku??"")).filter(f=>f.length>0),c=n.criteria_view??n.criteria_view_short??{},u=(r&&r.length>0?r:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:Zr(s)).filter(f=>f!=="name"&&f!=="name_short"&&!f.endsWith("_short")),d=[];for(const f of u){const g=a.map(h=>{const m=s[h];if(!m||typeof m!="object")return"";const v=m[`${f}_short`],w=m[f];return Rr(v??w)});if(g.every(h=>h.length===0))continue;const p=c[f]??f;d.push({label:p,values:g})}return d}function Zr(e){const t=[],n=new Set;for(const r of Object.values(e))if(!(!r||typeof r!="object"))for(const o of Object.keys(r))n.has(o)||(n.add(o),t.push(o));return t}function Rr(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Lr(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Nr(){return{type:"done"}}function jr(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 qr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Dr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Ur(e){const t=_(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:_(e.payload.to)}}}function Br(e){return{type:"error",code:"BACKEND_ERROR",message:_(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Mr(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Fr(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,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.theme=s),yt({type:"quick_qna",payload:o})}const n=x(t.action);if(n){const o={action:n},i=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),s!==void 0&&(o.image_url=s),a!==void 0&&(o.theme=a),mt({type:"text_image",payload:o})}const r=typeof t.text=="string"?t.text:"";if(r){const o={text:r},i=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,a=x(t.payload)??void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.payload=a),s!==void 0&&(o.theme=s),Ne({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Ne(e){const t={text:_(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 Hr(e){return no(e.payload,"qna")}function mt(e){const t=_(e.payload.text)??"",n=Z(e.payload.action,t);if(n){const o={label:t||n.title,action:n};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 r={text:t};return typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),Ne({type:"text",payload:r})}function yt(e){return _t((e.payload.action_list??[]).map(t=>{const n=_(t.title)??"",r=Z(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(se),"qna")}function Jr(e){const t={reviews:(e.payload.reviews??[]).map(n=>{const r={};return typeof n.review_class=="string"&&(r.review_class=n.review_class),typeof n.review_text=="string"&&(r.review_text=n.review_text),(typeof n.review_rating=="string"||typeof n.review_rating=="number")&&(r.review_rating=n.review_rating),typeof n.review_tag=="string"&&(r.review_tag=n.review_tag),r})};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 Qr(e){const t=e.payload.product_suggestions??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=oo(o);if(!i)continue;const s={product:i},a=Z(o.requestDetails,i.name);a&&(s.action=a),typeof o.role=="string"&&(s.role=o.role),typeof o.reason=="string"&&(s.reason=o.reason),typeof o.review_highlight=="string"&&(s.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(s.labels=o.labels),typeof o.expert_quality_score=="number"&&(s.expertQualityScore=o.expert_quality_score),n.push(s)}return n.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:n}}}}}}function Wr(e){const t=e.payload.product_groupings??[],n=[],r=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const s=_(i.name)??"",a=_(i.description),c=_(i.highlight),u=Array.isArray(i.labels)?vt(i.labels):[],d=_(i.sku,i.repr_sku),f=_(i.image,i.repr_image),g=Vr(i,s,d),p=(Array.isArray(i.group_products)?i.group_products:[]).map(v=>{const w=x(v);return w?De(w):null}).filter(se),h=f??_(...p.map(v=>v.imageUrl));if(s&&p.length>0){const v={groupName:s,products:p};h&&(v.image=h),a&&(v.description=a),c&&(v.highlight=c),u.length>0&&(v.labels=u),n.push(v)}if(!g)continue;const m={name:s,action:g};u.length>0&&(m.labels=u),f!==void 0&&(m.image=f),r.push(m)}return n.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n}}}},panelHint:"panel"}:r.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:r}}}}}}function Vr(e,t,n){const r=x(e.requestDetails);if(r){if(r.type!=="findSimilar")return Z(r,t);const s={...x(r.payload)??{}};n&&!re(s.sku)&&(s.sku=n);const a=oe(e.group_skus);return a.length>0&&(s.group_skus=a),Z({...r,payload:ge(s)},t)}const o={};n&&(o.sku=n);const i=oe(e.group_skus);return i.length>0&&(o.group_skus=i),Object.keys(o).length===0?null:Z({type:"findSimilar",payload:ge(o)},t)}function Gr(e,t){const n=x(e.requestDetails),r=x(n?.payload),o=_(e.detailed_user_message),i=e.group_skus&&Array.isArray(e.group_skus)?oe(e.group_skus):oe(r?.group_skus),s=_(e.sku,e.representative_product_sku,r?.sku);if(n?.type==="findSimilar"){const c={...r??{}};return s&&(c.sku=s),i.length>0&&(c.group_skus=i),o&&(c.input=o,re(c.text)||(c.text=o)),c.is_search_suggestion=1,Z({...n,payload:ge(c)},t)}if(s){const c={sku:s,is_search_suggestion:1};return i.length>0&&(c.group_skus=i),o&&(c.input=o,c.text=o),Z({type:"findSimilar",payload:ge(c)},t)}const a={...r??{},is_suggested_text:1,is_search_suggestion:1};return o&&!re(a.text)&&(a.text=o),i.length>0&&(a.group_skus=i),Z(n?.type==="inputText"?{...n,payload:a}:{type:"inputText",payload:a},t)}function Kr(e){const t=e.payload.suggested_searches??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=_(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${r+1}`,s=Gr(o,i);if(!s)continue;const a={shortName:i,action:s},c=_(o.detailed_user_message);c&&c!==i&&(a.detailedMessage=c);const u=Sr(o);u&&u!==i&&u!==(c??"")&&(a.whyDifferent=u),typeof o.image=="string"&&(a.image=o.image),n.push(a)}return n.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:n}}}}}}function Yr(e){const t=e.payload,n=Z(t.requestDetails??t.request_details,_(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!n)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const r={action:n};return t.title&&(r.title=t.title),t.text&&(r.text=t.text),t.review_count?r.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(r.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:r}}}}}function Xr(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function je(e,t){const n={product:e,index:t},r=e,o=typeof r.sku=="string"?r.sku:void 0;return o&&(n.action={title:typeof r.name=="string"?r.name:"",type:"launchSingleProduct",payload:{sku:o}}),{type:"ProductCard",props:n}}function _t(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`action-${o}`;r.push(s);const a={label:i.label,action:i.action};i.icon!==void 0&&(a.icon=i.icon),i.image!==void 0&&(a.image=i.image),i.description!==void 0&&(a.description=i.description),n[s]={type:"ActionButton",props:a}}return n.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:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function qe(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=K(i),a=`product-${o}`;r.push(a),n[a]=je(s,o)}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function eo(e,t,n){const r=new Map;for(const u of t)u?.sku&&r.set(u.sku,u);if(r.size===0)return null;const o=new Set,i={},s=[],a=[];let c=0;for(let u=0;u<e.length;u++){const d=e[u],f=_(d?.title)??"",g=Array.isArray(d?.skus)?d.skus:[],p=[];for(let h=0;h<g.length;h++){const m=typeof g[h]=="string"?g[h].trim():"";if(!m||o.has(m))continue;const v=r.get(m);if(!v)continue;o.add(m);const w=`product-${u}-${h}`,k=K(v);s.push(w),p.push(w),i[w]=je(k,c),c+=1}p.length>0&&a.push({title:f,children:p})}return a.length===0||o.size<r.size?null:(i.root={type:"ProductGrid",props:{layout:"grouped",productSections:a},children:s},{type:"ui_spec",widget:n,spec:{root:"root",elements:i}})}function to(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`product-${o}`;r.push(s),n[s]=je(i,o)}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function no(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:K(e),index:0}}}}}}function ro(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function oo(e){const t=_(e.sku),n=_(e.short_name),r={...x(e.product_item)??e},o=_(e.discount_reason,e.discountReason);return o&&!_(r.discount_reason,r.discountReason)&&(r.discount_reason=o),De(r,t,n)}function De(e,t,n){const r=_(e.sku,t),o=_(e.name,n);if(!r||!o)return null;const i={sku:r,name:o},s=_(e.brand);s&&(i.brand=s);const a=_(e.url);a&&(i.url=a);const c=io(e.images);if(c.length>0)i.images=c;else{const m=_(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const u=ie(e.price_discounted);u!==void 0&&(i.price_discounted=u);const d=ie(e.price);d!==void 0&&(i.price=d);const f=ie(e.rating);f!==void 0&&(i.rating=f);const g=ie(e.review_count)??ie(e.reviewCount);g!==void 0&&(i.review_count=g);const p=_(e.cart_code,e.cartCode);p&&(i.cart_code=p),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const h=_(e.discount_reason,e.discountReason);return h&&(i.discount_reason=h),K(i)}function Z(e,t){const n=x(e);if(!n)return null;const r=n.type;if(typeof r!="string"||r.length===0)return null;const o={title:t||r,type:r};return n.payload!==void 0&&(o.payload=n.payload),o}function x(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function _(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function io(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function vt(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 ie(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 n=Number(t);if(Number.isFinite(n))return n}}function se(e){return e!=null}var so=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 K(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,r=t&&e.price!=null?e.price:void 0;let o;r!=null&&n!=null&&r>0?o=Math.round((r-n)/r*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=_(e.brand),s=_(e.name)??e.sku,a=i&&!s.toLowerCase().startsWith(i.toLowerCase())?`${i} ${s}`:s,c={sku:e.sku,name:a,url:_(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&n>0&&(c.price=String(n)),r!=null&&r>0&&(c.originalPrice=String(r)),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 d=e,f={};let g=!1;for(const p of Object.keys(d))so.has(p)||(f[p]=d[p],g=!0);return g&&(c.extras=f),c}function ao(e){const t=e.payload.type,{type:n,...r}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:r}}}}}var co=7200*1e3,bt=200,uo=5*1024*1024,lo="gengage_request_response_cache",fo=1,L="responses",po=new Set(["addToCart","like"]),N=new Map,wt=null;async function go(e,t={},n={}){const r=ho(e,t);if(!r)return fetch(e,t);const o=Date.now(),i=await vo(r,o);if(i)return ko(i);const s=await fetch(e,t);return s.ok&&bo(r,s.clone(),o,{ttlMs:n.ttlMs??co,maxEntries:n.maxEntries??bt,maxBodyBytes:n.maxBodyBytes??uo}),s}function ho(e,t={}){if(typeof Request<"u"&&e instanceof Request)return null;const n=String(t.method||"GET").toUpperCase();if(n!=="POST"||typeof t.body!="string")return null;const r=mo(t.body);if(yo(r))return null;const o=_o(r);if(o){const i=ae(r?.action);return`rr:${Et(zt({url:String(e),method:n,headers:kt(t.headers),type:r?.type??i?.type??"",account_id:r?.account_id??r?.accountId??"",locale:r?.locale??"",outputLanguage:ae(r?.meta)?.outputLanguage??"",cache_key:o}))}`}return`rr:${Et(zt({url:String(e),method:n,headers:kt(t.headers),body:t.body}))}`}function mo(e){try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function yo(e){const t=e?.type;return typeof t=="string"&&po.has(t)}function _o(e){const t=(ae(e?.payload)??ae(ae(e?.action)?.payload))?.cache_key;return typeof t=="string"&&t.trim().length>0?t.trim():null}async function vo(e,t){const n=N.get(e);if(n)if(n.expiresAt<=t)N.delete(e);else return n.lastAccessedAt=t,N.delete(e),N.set(e,n),Ue(n),n;const r=await zo(e);return r?r.expiresAt<=t?(N.delete(e),Eo(e),null):(r.lastAccessedAt=t,N.set(e,r),Ue(r),St(bt),r):null}async function bo(e,t,n,r){try{const o=await t.text();if(To(o)>r.maxBodyBytes||wo(o))return;const i={key:e,status:t.status,statusText:t.statusText,headers:So(t.headers),body:o,createdAt:n,expiresAt:n+r.ttlMs,lastAccessedAt:n};N.set(e,i),St(r.maxEntries),await Ue(i),await Ao(r.maxEntries,n)}catch{}}function wo(e){return/"_error"\s*:/u.test(e)||/"type"\s*:\s*"error"/u.test(e)}function ko(e){return new Response(e.body,{status:e.status,statusText:e.statusText,headers:new Headers(e.headers)})}function kt(e){const t=new Headers(e),n=[];return t.forEach((r,o)=>{const i=o.toLowerCase();i!=="authorization"&&i!=="cookie"&&n.push([i,r])}),n.sort(([r],[o])=>r.localeCompare(o))}function So(e){const t=[];return e.forEach((n,r)=>{const o=r.toLowerCase();o!=="set-cookie"&&t.push([o,n])}),t.sort(([n],[r])=>n.localeCompare(r))}function St(e){for(;N.size>e;){const t=[...N.values()].sort((n,r)=>n.lastAccessedAt-r.lastAccessedAt)[0];if(!t)break;N.delete(t.key)}}async function he(){return typeof indexedDB>"u"?null:(wt??=new Promise(e=>{const t=indexedDB.open(lo,fo);t.onupgradeneeded=()=>{const n=t.result;n.objectStoreNames.contains(L)||n.createObjectStore(L,{keyPath:"key"}).createIndex("lastAccessedAt","lastAccessedAt",{unique:!1})},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}),wt)}async function zo(e){const t=await he();return t?new Promise(n=>{const r=t.transaction(L,"readonly"),o=r.objectStore(L).get(e);o.onsuccess=()=>n(o.result??null),o.onerror=()=>n(null),r.onerror=()=>n(null)}):null}async function Ue(e){const t=await he();t&&await new Promise(n=>{const r=t.transaction(L,"readwrite");r.objectStore(L).put(e),r.oncomplete=()=>n(),r.onerror=()=>n(),r.onabort=()=>n()})}async function Eo(e){const t=await he();t&&await new Promise(n=>{const r=t.transaction(L,"readwrite");r.objectStore(L).delete(e),r.oncomplete=()=>n(),r.onerror=()=>n(),r.onabort=()=>n()})}async function Ao(e,t){const n=await he();n&&await new Promise(r=>{const o=n.transaction(L,"readwrite"),i=o.objectStore(L),s=[],a=i.openCursor();a.onsuccess=()=>{const c=a.result;if(!c){const u=s.filter(f=>f.expiresAt<=t),d=s.filter(f=>f.expiresAt>t).sort((f,g)=>f.lastAccessedAt-g.lastAccessedAt).slice(0,Math.max(0,s.length-u.length-e));for(const f of[...u,...d])i.delete(f.key);return}s.push(c.value),c.continue()},a.onerror=()=>r(),o.oncomplete=()=>r(),o.onerror=()=>r(),o.onabort=()=>r()})}function zt(e){return JSON.stringify(Be(e))}function ae(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Be(e){return Array.isArray(e)?e.map(Be):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,Be(n)]))}function Et(e){let t=14695981039346656037n;const n=1099511628211n;for(let r=0;r<e.length;r+=1)t^=BigInt(e.charCodeAt(r)),t=BigInt.asUintN(64,t*n);return t.toString(16).padStart(16,"0")}function To(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).byteLength:e.length}async function $o(e,t,n){const r=br("launcher_action",t),o={uiSpecs:[],actions:[]},i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);const s=await go(r,i);if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);const a={onEvent:c=>{const u=Er(c);if(u&&(u.type==="ui_spec"&&o.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const d of Object.values(u.spec.elements))if(d.type==="ActionButton"&&d.props?.action){const f=d.props.action;o.actions.push(f)}}}};return n!==void 0&&(a.signal=n),await yr(s,a),o}function At(e){const t=document.createElement("div");t.className="gengage-qna-buttons gds-toolbar",t.dataset.gengagePart="qna-button-row",t.setAttribute("role","group"),t.setAttribute("aria-label",e.quickQuestionsAriaLabel??"Quick questions"),e.orientation==="vertical"&&(t.style.flexDirection="column");for(const n of e.actions){const r=document.createElement("button");r.className="gengage-qna-button gds-chip",r.dataset.gengagePart="qna-quick-question",r.textContent=n.title,r.type="button",r.addEventListener("click",()=>{const o={title:n.title,type:n.type};n.payload!==void 0&&(o.payload=n.payload),e.onAction(o)}),t.appendChild(r)}if(e.ctaText||e.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta gds-btn gds-btn-secondary",n.dataset.gengagePart="qna-cta",n.textContent=e.ctaText??e.defaultCtaText??"Ask something else",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function Io(e){const t=document.createElement("div");t.className="gengage-qna-input-wrapper",t.dataset.gengagePart="qna-input-wrapper";const n=document.createElement("div");n.className="gengage-qna-input-combo",n.dataset.gengagePart="qna-input-combo";const r=document.createElement("input");r.type="text",r.className="gengage-qna-input",r.dataset.gengagePart="qna-input",r.setAttribute("aria-label",e.askQuestionAriaLabel??"Ask a question");const o=Array.isArray(e.placeholders)?e.placeholders:e.placeholders?[e.placeholders]:[e.defaultInputPlaceholder??"Ask a question..."];let i=0,s=o[0]??"";r.placeholder=s;let a=null,c=null,u=!1;const d=()=>{a&&clearInterval(a),a=null,c&&clearTimeout(c),c=null,r.classList.remove("gengage-qna-input--fade")},f=()=>o.length>1&&!u&&r.value.trim().length===0,g=()=>{d(),f()&&(a=setInterval(()=>{f()&&(r.classList.add("gengage-qna-input--fade"),c=setTimeout(()=>{i=(i+1)%o.length,s=o[i]??"",r.placeholder=s,r.classList.remove("gengage-qna-input--fade")},180))},3e3))},p=document.createElement("div");p.className="gengage-qna-input-actions",p.dataset.gengagePart="qna-input-actions";const h=document.createElement("button");h.className="gengage-qna-icon-btn gengage-qna-clear gengage-qna-icon-btn--hidden",h.type="button",h.dataset.gengagePart="qna-clear",h.setAttribute("aria-label","Clear question"),h.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18" /><path d="M6 6L18 18" /></svg>';const m=document.createElement("button");m.className="gengage-qna-icon-btn gengage-qna-send gengage-qna-icon-btn--hidden",m.type="button",m.dataset.gengagePart="qna-send",m.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question"),m.disabled=!0,m.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M22 2L11 13" /><path d="M22 2L15 22L11 13L2 9L22 2Z" /></svg><span class="gengage-qna-sr-only">${e.ctaLabel??e.sendButtonText??"Ask"}</span>`;const v=()=>{const k=r.value.trim().length>0;h.classList.toggle("gengage-qna-icon-btn--hidden",!k),m.classList.toggle("gengage-qna-icon-btn--hidden",!k),m.classList.toggle("gengage-qna-send--active",k),m.disabled=!k},w=()=>{const k=r.value.trim();k&&(e.onSubmit({title:k,type:"user_message",payload:k}),r.value="",v(),g())};return h.addEventListener("click",()=>{r.value="",v(),r.focus({preventScroll:!0})}),m.addEventListener("click",w),r.addEventListener("focus",()=>{u=!0,d(),r.placeholder=""}),r.addEventListener("blur",()=>{u=!1,r.value.trim().length===0&&(r.placeholder=s),g()}),r.addEventListener("input",()=>{if(v(),r.value.trim().length>0){d();return}r.placeholder=u?"":s,g()}),r.addEventListener("keydown",k=>{k.key==="Enter"&&(k.preventDefault(),w()),k.key==="Escape"&&r.value.length>0&&(r.value="",v(),g())}),p.appendChild(h),p.appendChild(m),n.appendChild(r),n.appendChild(p),t.appendChild(n),v(),g(),t._cleanup=()=>{d()},t}function me(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.type;if(typeof r!="string"||r.length===0)return null;const o=n.title,i=n.payload,s=typeof o=="string"&&o.length>0?o:t;if(!s)return null;const a={title:s,type:r};return i!==void 0&&(a.payload=i),a}function Tt(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function $t(e,t){const n=[],r=e.props?.actions;if(Array.isArray(r))for(const s of r){const a=me(s);a&&n.push(a)}const o=e.props?.buttons;if(Array.isArray(o))for(const s of o){if(!s||typeof s!="object")continue;const a=s,c=typeof a.label=="string"?a.label:void 0,u=me(a.action,c);u&&n.push(u)}if(e.children)for(const s of e.children){const a=t.elements[s];if(!a||a.type!=="ActionButton")continue;const c=typeof a.props?.label=="string"?a.props.label:void 0,u=me(a.props?.action,c);u&&n.push(u)}const i=new Set;return n.filter(s=>i.has(s.title)?!1:(i.add(s.title),!0))}var It={ButtonRow:({element:e,spec:t,context:n})=>{const r=$t(e,t).map(Tt),o=e.props?.orientation,i={actions:r,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(i.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(i.ctaText=n.ctaText),(o==="horizontal"||o==="vertical")&&(i.orientation=o),At(i)},ActionButtons:({element:e,spec:t,context:n})=>{const r={actions:$t(e,t).map(Tt),onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(r.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(r.ctaText=n.ctaText),At(r)},ActionButton:({element:e,context:t})=>{const n=document.createElement("button");n.className="gengage-qna-button gds-chip",n.type="button",n.dataset.gengagePart="qna-action-button";const r=e.props?.label;typeof r=="string"?n.textContent=r:n.textContent=t.i18n.defaultCtaText;const o=me(e.props?.action,typeof r=="string"?r:void 0);return o&&n.addEventListener("click",()=>t.onAction(o)),n},TextInput:({element:e,context:t})=>{const n=e.props?.placeholder,r=typeof n=="string"||Array.isArray(n)?n:t.inputPlaceholder,o=typeof e.props?.ctaLabel=="string"?e.props.ctaLabel:void 0,i={onSubmit:t.onAction,askQuestionAriaLabel:t.i18n.askQuestionAriaLabel,defaultInputPlaceholder:t.i18n.defaultInputPlaceholder,sendButtonText:t.i18n.sendButton,sendQuestionAriaLabel:t.i18n.sendQuestionAriaLabel};return r!==void 0&&(i.placeholders=r),o!==void 0&&(i.ctaLabel=o),Io(i)},QuestionHeading:({element:e,context:t})=>{const n=document.createElement("h3");n.className="gengage-qna-heading",n.dataset.gengagePart="qna-heading";const r=e.props?.text,o=t.headingTitleOverride;return n.textContent=typeof o=="string"&&o.trim().length>0?o:typeof r=="string"?r:"",n},ProductCard:()=>null},Me=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function Pt(){return{...It}}function xt(e,t,n=It,r=Me){return On({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:r})}function Po(e){if(!e)return;const t=e.extra;if(t&&typeof t=="object"&&!Array.isArray(t)){const r=t.visible_skus??t.visibleSkus;if(Array.isArray(r)){const o=r.filter(i=>typeof i=="string"&&i.trim().length>0).map(i=>i.trim()).slice(0,200);if(o.length>0)return o}}const n=typeof e.sku=="string"&&e.sku.trim()?e.sku.trim():void 0;return n?[n]:void 0}function Ct(e,t){if(!e)return null;const n=e.action;if(!n||typeof n!="object")return null;const r=n,o=r.type;if(typeof o!="string"||o.length===0)return null;const i=r.title,s=typeof i=="string"&&i.length>0?i:typeof t=="string"&&t.length>0?t:"";if(!s)return null;const a=r.payload,c={title:s,type:o};return a!==void 0&&(c.payload=a),c}function xo(e,t){const n=e.elements[e.root];if(!n)return!1;const r=o=>{if(o.type!=="ActionButton")return!1;const i=o.props;if(!i||typeof i!="object")return!1;const s=typeof i.label=="string"?i.label:void 0;return s===t?!0:Ct(i,s)?.title===t};if(n.type==="ActionButton")return r(n);if(n.children)for(const o of n.children){const i=e.elements[o];if(i&&r(i))return!0}if(n.type==="ActionButtons"&&Array.isArray(n.props?.buttons)){for(const o of n.props.buttons)if(o?.label===t||o?.action?.title===t)return!0}return!1}var Ot=0;function Zt(){return Ot+=1,`gengage-merge-${Ot}`}function Co(e,t){const n=e.elements[e.root];if(!n||n.type!=="ButtonRow")return;const r=Zt();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r]}function Oo(e,t){const n=e.elements[e.root];if(!n||n.type!=="ActionButtons")return;const r=Zt();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r];const o=n.props?.buttons??[],i={label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}};n.props={...n.props,buttons:[i,...o]}}function Zo(e){const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,...o.payload!==void 0?{payload:o.payload}:{}}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}function Ro(e){return e.find(t=>{const n=t.elements[t.root];return n?.type==="ActionButtons"||n?.type==="ButtonRow"})}function Rt(e,t){const n=e.productContextQuickPillLabel,r={text:n};return t&&t.length>0&&(r.sku_list=t),{title:n,type:"user_message",payload:r}}function Lo(e,t,n){const r=n?.skuList,o=[],i=[];for(const c of e){const u=c.elements[c.root];if(u?.type==="ActionButton"){const d=u.props;if(Ct(d,typeof d?.label=="string"?d.label:void 0)?.type==="findSimilar"){o.push(Rt(t,r));continue}}i.push(c)}if(o.length===0)return e;const s=Rt(t,r),a=Ro(i);if(!a)return[...i,Zo([s])];if(!xo(a,s.title)){const c=a.elements[a.root];c?.type==="ActionButtons"?Oo(a,s):c?.type==="ButtonRow"&&Co(a,s)}return i}var Lt={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor",redirectingToChat:"Sohbete yönlendiriliyor...",productContextQuickPillLabel:"Bu ürün hakkında ne bilmeliyim?"},No={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else",redirectingToChat:"Redirecting to chat...",productContextQuickPillLabel:"What should I know about this product?"};function jo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function qo(e){return jo(e)==="en"?No:Lt}var Nt=class extends ar{constructor(...e){super(...e),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=Lt,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this._contentEl.dataset.gengagePart="qna-container",this._contentEl.lang=ct(e.locale);const t=this._createChrome(e);if(t){const r=document.createElement("div");r.className="gengage-qna-chrome-widget",r.dataset.gengagePart="qna-chrome-widget",r.appendChild(this._contentEl),t.appendChild(r),this.root.appendChild(t)}else this.root.appendChild(this._contentEl);const n=e.pageContext?.sku;n&&(this._lastSku=n,await this._fetchAndRender(n)),jn("qna")}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_resolvedQnaHeaderTitle(){const e=this.config.headerTitle??this.config.headingTitle;if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}_cleanupTextInputTimers(){if(!this._contentEl)return;const e=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const t of e)t._cleanup?.()}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const t=this._createLoadingIndicator();this._contentEl.appendChild(t);const n={middlewareUrl:this.config.middlewareUrl},r=hr({source:"qna",locale:this.config.locale});try{const o=this.config.session?.sessionId??"",i={account_id:this.config.accountId,session_id:o,correlation_id:o,sku:e,locale:ct(this.config.locale)};this.config.session?.userId!==void 0&&(i.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(i.view_id=this.config.session.viewId);const s=this.config.pageContext?.pageType;s!==void 0&&(i.page_type=s);const a=await $o(i,n,this._abortController.signal);if(!this._contentEl)return;this._contentEl.innerHTML="";const c=document.createElement("div");c.className="gengage-qna-panel gds-panel",c.dataset.gengagePart="qna-panel",this._contentEl.appendChild(c);const u=this._specIncludesType(a.uiSpecs,"QuestionHeading"),d=this._resolvedQnaHeaderTitle()??(this.config.showStaticQuestion&&this.config.staticQuestionText?this.config.staticQuestionText:void 0);if(!u&&d){const k=document.createElement("h3");k.className="gengage-qna-heading",k.textContent=d,c.appendChild(k)}const f=this.config.inputPlaceholder;let g;if(f!==!0)g=f??this._i18n.defaultInputPlaceholder;else if(a.actions.length>0){const k=a.actions.filter(I=>I.type==="user_message"||I.title.includes("?")).map(I=>I.title);g=k.length>0?k:this._i18n.defaultInputPlaceholder}else g=this._i18n.defaultInputPlaceholder;const p={onAction:this._actionHandler,i18n:this._i18n},h=this._resolvedQnaHeaderTitle();h!==void 0&&(p.headingTitleOverride=h),this.config.hideButtonRowCta||(p.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(p.ctaText=this.config.ctaText)),g!==void 0&&(p.inputPlaceholder=g);const m=this._buildFallbackActionsSpec(a.actions),v=Po(this.config.pageContext),w=(a.uiSpecs.length>0?Lo(a.uiSpecs,this._i18n,{skuList:v}):[m]).filter(k=>Object.keys(k.elements).length>0);for(const k of w){const I=this._renderUISpec(k,p);c.appendChild(I)}w.length>0&&qn("qna"),this._specIncludesType(w,"TextInput")||this._insertStandaloneInputBeforePills(c,p,g)}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;if(xe("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:Gn(this.config.locale,o)}),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const i=document.createElement("div");i.className="gengage-qna-panel",this._contentEl.appendChild(i);const s=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,a={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler},c=this._resolvedQnaHeaderTitle();c!==void 0&&(a.headingTitleOverride=c),this.config.ctaText!==void 0&&(a.ctaText=this.config.ctaText),this._appendStandaloneInput(a,s,i)}}finally{r()}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let t=0;t<3;t++){const n=document.createElement("div");n.className="gengage-qna-loading-dot",e.appendChild(n)}return e}_resolveI18n(e){return{...qo(e.locale),...e.i18n}}_createChrome(e){const t=e.chrome;if(!t)return null;const n=typeof t.title=="string"?t.title.trim():"",r=typeof t.subtitle=="string"?t.subtitle.trim():"",o=typeof t.startButtonLabel=="string"?t.startButtonLabel.trim():"",i=typeof t.imageUrl=="string"?t.imageUrl.trim():"",s=typeof t.imagePadding=="string"?t.imagePadding.trim():"",a=document.createElement("section");a.className="gengage-qna-chrome",a.dataset.gengagePart="qna-chrome",t.layout==="side-image"&&(a.classList.add("gengage-qna-chrome--side-image"),a.dataset.gengageChromeLayout="side-image"),s&&a.style.setProperty("--gengage-qna-chrome-image-padding",s);const c=document.createElement("div");if(c.className="gengage-qna-chrome-copy",c.dataset.gengagePart="qna-chrome-copy",n){const u=document.createElement("h2");u.className="gengage-qna-chrome-title",u.dataset.gengagePart="qna-chrome-title",u.textContent=n,c.appendChild(u)}if(r){const u=document.createElement("p");u.className="gengage-qna-chrome-subtitle",u.dataset.gengagePart="qna-chrome-subtitle",u.textContent=r,c.appendChild(u)}if(c.children.length>0&&a.appendChild(c),i&&Ln(i)){const u=document.createElement("img");u.className="gengage-qna-chrome-image",u.dataset.gengagePart="qna-chrome-image",u.src=i,u.alt=typeof t.imageAlt=="string"?t.imageAlt:"",u.loading="lazy",u.addEventListener("error",()=>{u.style.display="none"},{once:!0}),a.appendChild(u)}if(o){const u=document.createElement("button");u.className="gengage-qna-chrome-start",u.dataset.gengagePart="qna-chrome-start",u.type="button",u.textContent=o,u.addEventListener("click",()=>this._handleOpenChat()),a.appendChild(u)}return a.children.length===0?null:a}_resolveUISpecRegistry(){return Zn(Pt(),this.config.renderer?.registry)}_renderUISpec(e,t){const n=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??Me,o=(s,a)=>xt(s,a,n,r),i=this.config.renderer?.renderUISpec;return i?i(e,t,{registry:n,unknownRenderer:r,defaultRender:o}):o(e,t)}_specIncludesType(e,t){for(const n of e)for(const r of Object.values(n.elements))if(r.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,payload:o.payload}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}_insertStandaloneInputBeforePills(e,t,n){const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:n}}}},o=this._renderUISpec(r,t),i=o.querySelector(".gengage-qna-input-wrapper");if(!i)return;const s=e.querySelector(".gengage-qna-uispec"),a=e.querySelector(".gengage-qna-uispec > .gengage-qna-buttons"),c=this.config.inputAfterPills===!0;if(a)c?a.insertAdjacentElement("afterend",i):a.insertAdjacentElement("beforebegin",i);else if(s){const u=s.querySelector(":scope > .gengage-qna-heading");!c&&u?u.insertAdjacentElement("afterend",i):s.appendChild(i)}else{e.appendChild(o);return}o.remove()}_appendStandaloneInput(e,t,n){if(!this._contentEl)return;const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:t}}}},o=this._renderUISpec(r,e);(n??this._contentEl).appendChild(o)}_handleAction(e){this._showTransitionIndicator(),Dn(e.title,e.type),this.config.onActionSelected?.(e),setTimeout(()=>xe("gengage:qna:action",e),350)}_handleOpenChat(){this._showTransitionIndicator(),this.config.onOpenChat?.(),setTimeout(()=>xe("gengage:qna:open-chat",{}),350)}_showTransitionIndicator(){if(!this._contentEl)return;this._contentEl.querySelector(".gengage-qna-transition-indicator")?.remove(),this._contentEl.classList.add("gengage-qna--transitioning");const e=this._i18n.redirectingToChat??"Redirecting to chat...",t=document.createElement("div");t.className="gengage-qna-transition-indicator",t.textContent=e,(this._contentEl.querySelector(".gengage-qna-panel")??this._contentEl).appendChild(t),setTimeout(()=>{this._contentEl?.classList.remove("gengage-qna--transitioning"),t.remove()},600)}};function Do(){return new Nt}var jt;function l(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=s.prototype,d=Object.keys(u);for(let f=0;f<d.length;f++){const g=d[f];g in a||(a[g]=u[g].bind(a))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=n?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var Y=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},qt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(jt=globalThis).__zod_globalConfig??(jt.__zod_globalConfig={});var ye=globalThis.__zod_globalConfig;function J(e){return e&&Object.assign(ye,e),ye}function Dt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}function Fe(e,t){return typeof t=="bigint"?t.toString():t}function He(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function Je(e){return e==null}function Qe(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var Ut=Symbol("evaluating");function b(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ut)return r===void 0&&(r=Ut,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Q(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function U(...e){const t={};for(const n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Bt(e){return JSON.stringify(e)}function Uo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Mt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Bo=He(()=>{if(ye.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function ce(e){if(_e(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(_e(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ft(e){return ce(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Mo=new Set(["string","number","symbol"]);function ve(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function B(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function y(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 Fo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var mu={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 Ho(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return B(e,U(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=n.shape[i])}return Q(this,"shape",o),o},checks:[]}))}function Jo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return B(e,U(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return Q(this,"shape",o),o},checks:[]}))}function Qo(e,t){if(!ce(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const r=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return B(e,U(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Q(this,"shape",r),r}}))}function Wo(e,t){if(!ce(t))throw new Error("Invalid input to safeExtend: expected a plain object");return B(e,U(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Q(this,"shape",n),n}}))}function Vo(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return B(e,U(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Q(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Go(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return B(t,U(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:o[s]}):o[s])}else for(const s in o)i[s]=e?new e({type:"optional",innerType:o[s]}):o[s];return Q(this,"shape",i),i},checks:[]}))}function Ko(e,t,n){return B(t,U(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)o[i]=new e({type:"nonoptional",innerType:r[i]});return Q(this,"shape",o),o}}))}function X(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Yo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ht(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function be(e){return typeof e=="string"?e:e?.message}function W(e,t,n){const r=e.message?e.message:be(e.inst?._zod.def?.error?.(e))??be(t?.error?.(e))??be(n.customError?.(e))??be(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function We(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ue(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}var Jt=(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,Fe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Qt=l("$ZodError",Jt),Wt=l("$ZodError",Jt,{Parent:Error});function Xo(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function ei(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,u=0;for(;u<a.length;){const d=a[u];u!==a.length-1?c[d]=c[d]||{_errors:[]}:(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(s))),c=c[d],u++}}}};return r(e),n}var Ve=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Y;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>W(c,i,J())));throw Mt(a,o?.callee),a}return s.value},Ge=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>W(c,i,J())));throw Mt(a,o?.callee),a}return s.value},we=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Y;return i.issues.length?{success:!1,error:new(e??Qt)(i.issues.map(s=>W(s,o,J())))}:{success:!0,data:i.value}},ti=we(Wt),ke=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>W(s,o,J())))}:{success:!0,data:i.value}},ni=ke(Wt),ri=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ve(e)(t,n,o)},oi=e=>(t,n,r)=>Ve(e)(t,n,r),ii=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ge(e)(t,n,o)},si=e=>async(t,n,r)=>Ge(e)(t,n,r),ai=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return we(e)(t,n,o)},ci=e=>(t,n,r)=>we(e)(t,n,r),ui=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ke(e)(t,n,o)},li=e=>async(t,n,r)=>ke(e)(t,n,r),di=/^[cC][0-9a-z]{6,}$/,fi=/^[0-9a-z]+$/,pi=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,gi=/^[0-9a-vA-V]{20}$/,hi=/^[A-Za-z0-9]{27}$/,mi=/^[a-zA-Z0-9_-]{21}$/,yi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_i=/^([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})$/,Vt=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)$/,vi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,bi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function wi(){return new RegExp(bi,"u")}var ki=/^(?:(?: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])$/,Si=/^(([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}|:))$/,zi=/^((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])$/,Ei=/^(([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])$/,Ai=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gt=/^[A-Za-z0-9_-]*$/,Ti=/^https?$/,$i=/^\+[1-9]\d{6,14}$/,Kt="(?:(?:\\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])))",Ii=new RegExp(`^${Kt}$`);function Yt(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 Pi(e){return new RegExp(`^${Yt(e)}$`)}function xi(e){const t=Yt({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Kt}T(?:${r})$`)}var Ci=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Oi=/^(?:true|false)$/i,Zi=/^[^A-Z]*$/,Ri=/^[^a-z]*$/,j=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Li=l("$ZodCheckMaxLength",(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Je(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=We(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ni=l("$ZodCheckMinLength",(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Je(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=We(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ji=l("$ZodCheckLengthEquals",(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Je(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const s=We(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Se=l("$ZodCheckStringFormat",(e,t)=>{var n,r;j.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?(n=e._zod).check??(n.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})}):(r=e._zod).check??(r.check=()=>{})}),qi=l("$ZodCheckRegex",(e,t)=>{Se.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Di=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Zi),Se.init(e,t)}),Ui=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ri),Se.init(e,t)}),Bi=l("$ZodCheckIncludes",(e,t)=>{j.init(e,t);const n=ve(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),Mi=l("$ZodCheckStartsWith",(e,t)=>{j.init(e,t);const n=new RegExp(`^${ve(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Fi=l("$ZodCheckEndsWith",(e,t)=>{j.init(e,t);const n=new RegExp(`.*${ve(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Hi=l("$ZodCheckOverwrite",(e,t)=>{j.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),Ji=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(`
47
+ `,document.head.appendChild(e)}var ne=null;function nr(){if(ne!==null)return ne;try{ne=localStorage.getItem("gengage:debug")==="1"}catch{ne=!1}return ne}function Ze(e,t,n){if(!nr())return;const r=[`[gengage:${e}]`,t];n!==void 0&&r.push(n),console.debug(...r)}var rr=("0.7.0".trim(),"0.7.0".trim()),or=("iife-build".trim(),"iife-build".trim());function ir(){typeof window>"u"||(window.gengage||(window.gengage={}),window.gengage.__internal||(window.gengage.__internal={}),!window.gengage.__internal.sdkRuntimeInfoLogged&&(window.gengage.__internal.sdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${rr} (${or})`)))}var sr=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=Bn(e.theme);ir(),this.config={...e,theme:t,session:Un(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),Gn();const n=nt("gengage:context:update",r=>this.update(r));this._cleanups.push(n),Ze("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(r){throw this.destroy(),r}this._destroying||(this.isInitialised=!0,Ze("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(n=>n(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const n=document.querySelector(e);if(!n)throw new Error(`[gengage] Mount target not found: "${e}"`);return n}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,n]of Object.entries(e))if(n!==void 0){const r=t.startsWith("--")?t:`--gengage-${ar(t)}`;this.root.style.setProperty(r,n)}}}};function ar(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function ct(e){const t=e?.trim();return t||"tr"}var cr=8e3,ur=5e3,lr="https://www.google.com/favicon.ico",q=new Map,ut=!1,K=null,re=null,H=!1;function dr(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function lt(e){return dr(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 dt(){let e;for(const t of q.values())e=t;return e}function Re(){K&&(clearTimeout(K),K=null)}function fr(){re&&(clearInterval(re),re=null)}async function ft(){try{if(typeof navigator<"u"&&navigator.onLine===!1)return!1;if(typeof window<"u"){const n=window.location.hostname;if(n==="localhost"||n==="127.0.0.1")return typeof navigator<"u"?navigator.onLine:!0}const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);try{return await fetch(lr,{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 fe(){H=!1,fr(),at()}function pe(){K||H||q.size===0||(K=setTimeout(async()=>{K=null,!(H||q.size===0)&&!await ft()&&q.size>0&&(H=!0,Oe({source:"sdk",message:lt(dt()),sticky:!0}),re||(re=setInterval(async()=>{if(q.size===0){fe();return}await ft()&&(fe(),pe())},ur)))},cr))}function pr(){fe(),pe()}function gr(){q.size===0||H||(H=!0,Re(),Oe({source:"sdk",message:lt(dt()),sticky:!0}))}function hr(){ut||typeof window>"u"||(ut=!0,window.addEventListener("online",pr),window.addEventListener("offline",gr))}function mr(e){hr();const t=Symbol(e.source);q.set(t,e.locale),pe();let n=!1;return()=>{if(!n){if(n=!0,q.delete(t),q.size===0){Re(),fe();return}H||(Re(),pe())}}}function pt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function yr(e){const t=[];let n=0,r=!1,o=!1,i=0;for(let s=0;s<e.length;s++){const a=e[s];if(o){o=!1;continue}if(a==="\\"&&r){o=!0;continue}if(a==='"'){r=!r;continue}r||(a==="{"&&n++,a==="}"&&(n--,n===0&&(t.push(e.slice(i,s+1)),i=s+1)))}return t.length>0?t:[e]}function gt(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const r=n.startsWith("data: ")?n.slice(6):n;if(r==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(r);return pt(o)?(Ze("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=yr(r);if(o.length>=1){let i=!1;for(const s of o)try{const a=JSON.parse(s);if(!pt(a))continue;if(i=!0,t.onEvent(a),a.type==="done")return t.onDone?.(),!0}catch{o.length>1}if(i)return!1}return!1}}async function _r(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 n=e.body.getReader(),r=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??12e4,s=Symbol("idle-timeout");let a=!1;try{for(;;){const c=n.read();let u;const f=await(i>0?Promise.race([c.finally(()=>clearTimeout(u)),new Promise(h=>{u=setTimeout(()=>h(s),i)})]):c);if(f===s){a=!0,await n.cancel();break}const{done:g,value:d}=f;if(g)break;o+=r.decode(d,{stream:!0});const p=o.split(`
48
+ `);o=p.pop()??"";for(const h of p)if(gt(h,t))return}if(o+=r.decode(),o.trim()&&gt(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{a||n.releaseLock()}t.onDone?.()}var vr={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function br(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 wr(e,t){return`${br(t?.middlewareUrl)}/chat${vr[e]}`}var ht=3,kr=(e,t)=>{const n=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!n)return"";const r=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,"").trim():n;return r?r.split(/\s+/).slice(0,3).join(" ").trim():""},Le=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(n=>kr(n,t)).filter(Boolean):[];function Sr(e){const t=(e.display_keywords??[]).flatMap(o=>Le(o,{stripLeadingStopWords:!0})),n=t.filter((o,i)=>t.indexOf(o)===i);if(n.length>0)return n.slice(0,ht);const r=[...Le(e.chosen_attribute,{stripLeadingStopWords:!0}),...Le(e.short_name)];return r.filter((o,i)=>r.indexOf(o)===i).slice(0,ht)}function zr(e){return Sr(e).join(" • ")}function Er(e){return e==="beauty_consulting"||e==="account_expert"}function oe(...e){for(const t of e){if(typeof t!="string")continue;const n=t.trim();if(n.length>0)return n}}function ie(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim()):[]}function ge(e){const t={...e},n=oe(t.sku),r=ie(t.group_skus);if(n?t.sku=n:delete t.sku,r.length>0?t.group_skus=r:delete t.group_skus,n||r.length>0)delete t.image_url;else{const o=oe(t.image_url);o?t.image_url=o:delete t.image_url}return t}function Ar(e){if(typeof e.type!="string")return null;if(e.payload==null&&(e.payload={}),Tr(e))return e;const t=e;switch(t.type){case"outputText":return $r(t);case"suggestedActions":return Ir(t);case"productList":return Pr(t);case"productDetails":return xr(t);case"productDetailsSimilars":return Cr(t);case"comparisonTable":return Or(t);case"context":return Nr(t);case"chatStreamEnd":return jr();case"loading":return qr(t);case"panelLoading":return Dr(t);case"similarLoading":return Ur(t);case"redirect":return Br(t);case"error":return Mr(t);case"dummy":return Fr(t);case"launcherAction":return Hr(t);case"text":return Ne(t);case"productItem":return Jr(t);case"text_image":return mt(t);case"quick_qna":return yt(t);case"reviewHighlights":return Qr(t);case"aiProductSuggestions":return Wr(t);case"aiProductGroupings":return Vr(t);case"aiSuggestedSearches":return Yr(t);case"getGroundingReview":return Xr(t);case"voice":return eo(t);case"uiSpec":return co(t);default:return null}}function Tr(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 n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const r=z(e.spec);return r?typeof r.root=="string"&&z(r.elements)!==null:!1}case"action":{const n=z(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function $r(e){const t=v(e.payload.text,e.payload.plain_text)??"",n=v(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const r={type:"text_chunk",content:t,final:!0},o=e.payload.sku_to_product_item;o&&typeof o=="object"&&!Array.isArray(o)&&(r.skuToProductItem=o);const i=e.payload.product_mentions;Array.isArray(i)&&i.length>0&&(r.productMentions=i.map(c=>{if(typeof c!="object"||c===null||typeof c.sku!="string")return null;const u=typeof c.short_name=="string"?c.short_name:"";if(!u)return null;const f=(typeof c.url=="string"&&c.url.trim()?c.url.trim():void 0)??(()=>{const g=r.skuToProductItem?.[c.sku];return typeof g?.url=="string"&&g.url.trim()?g.url.trim():void 0})();return f?{sku:c.sku,short_name:u,url:f}:{sku:c.sku,short_name:u}}).filter(c=>c!==null));const s=e.payload.conversation_mode;typeof s=="string"&&s&&(r.conversationMode=s);const a=e.payload.render_hint;return typeof a=="string"&&a&&(r.renderHint=a),e.payload.kvkk===!0&&(r.kvkk=!0),r}function Ir(e){return _t((e.payload.actions??[]).map(t=>{if(!z(t))return null;const n=v(t.title)??"",r=Z(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(J),"chat")}function Pr(e){const t=Array.isArray(e.payload.grouped_assignment)?e.payload.grouped_assignment:[],n=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(a=>{if(!z(a))return null;const c=v(a.style_label);if(!c)return null;const u=v(a.style_mood),f=v(a.image_url??void 0),g=(Array.isArray(a.product_list)?a.product_list:[]).map(p=>{const h=z(p);return h?De(z(h.product_detail)??z(h.product)??h):null}).filter(J),d=Array.isArray(a.recommendation_groups)?a.recommendation_groups.map(p=>z(p)?{label:v(p.label)??"",reason:v(p.reason)??"",skus:Array.isArray(p.skus)?p.skus.filter(h=>typeof h=="string"&&h.trim().length>0):[]}:null).filter(J):[];return{style_label:c,style_mood:u??"",...f?{image_url:f}:{},...typeof a.status=="string"?{status:a.status}:{},product_list:g,recommendation_groups:d}}).filter(J),r=e.payload.product_list??[],o=Er(e.payload.source)&&n.length>0?n[0].product_list:null,i=o?no(o,"chat"):t.length>0?to(t,r,"chat")??qe(r,"chat"):qe(r,"chat");i.panelHint="panel";const s=i.spec.elements[i.spec.root];if(s){const a={};typeof e.payload.offset=="number"&&(a.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(a.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(a.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(a.source=e.payload.source),n.length>0&&(a.styleVariations=n),e.payload.replace_panel===!0&&(a.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(a.rankingState=e.payload.ranking_state);const c=e.payload.sequence_id??e.payload.search_id;typeof c=="string"&&c.length>0&&(a.sequenceId=c),Object.keys(a).length>0&&(s.props={...s.props,...a})}return i}function xr(e){const t=e.payload.productDetails;if(!t)return oo("chat");const n=Y(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...n}}}}},panelHint:"panel"}}function Cr(e){const t=qe(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Or(e){const t=e.payload.multiple_product_details??[],n=e.payload,r={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,s=[];for(const _ of t){const w=Y(_);s.push(w)}const a=Zr(o,s,r,i);let c;r?.recommended_choice_sku?c=r.recommended_choice_sku:r?.winner_product&&r.winner_product.length>0&&(c=r.winner_product[0]?.product_detail?.sku??r.winner_product[0]?.sku);const u=c?s.find(_=>_.sku===c)??s[0]:s[0],f=[];if(Array.isArray(r?.key_differences))for(const _ of r.key_differences)typeof _=="string"&&f.push(_);const g=vt(r?.special_considerations),d=r?.recommended_choice,p=r?.winner_hits,h={};for(const _ of s){const w=_.sku;w&&(h[w]={title:_.name??w,type:"launchSingleProduct",payload:{sku:w}})}const m={products:s,attributes:a,highlights:f,productActions:h};return u&&(m.recommended=u),g.length>0&&(m.specialCases=g),d&&(m.recommendedText=d),p&&(m.winnerHits=p),typeof r?.key_differences=="string"&&(m.keyDifferencesHtml=r.key_differences),r?.special_considerations&&(m.specialConsiderations=r.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function Zr(e,t,n,r){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const d=z(n.criteria_view)??z(n.criteria_view_short)??{},p=(Array.isArray(n.compared_field_names)?n.compared_field_names:[]).filter(_=>typeof _=="string"),h=p.length>0?p:Object.keys(e),m=[];for(const _ of h){const w=e[_];if(!w||!Array.isArray(w))continue;const b=d[_],T=typeof b=="string"&&b?b:_;m.push({label:T,values:w.map(S=>typeof S=="string"?S:String(S??""))})}return m}const s=e,a=t.map(d=>String(d.sku??"")).filter(d=>d.length>0),c=z(n.criteria_view)??z(n.criteria_view_short)??{},u=(Array.isArray(n.compared_field_names)?n.compared_field_names:[]).filter(d=>typeof d=="string"),f=(r&&r.length>0?r:u.length>0?u:Rr(s)).filter(d=>d!=="name"&&d!=="name_short"&&!d.endsWith("_short")),g=[];for(const d of f){const p=a.map(_=>{const w=s[_];if(!w||typeof w!="object")return"";const b=w[`${d}_short`],T=w[d];return Lr(b??T)});if(p.every(_=>_.length===0))continue;const h=c[d],m=typeof h=="string"&&h?h:d;g.push({label:m,values:p})}return g}function Rr(e){const t=[],n=new Set;for(const r of Object.values(e))if(!(!r||typeof r!="object"))for(const o of Object.keys(r))n.has(o)||(n.add(o),t.push(o));return t}function Lr(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Nr(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function jr(){return{type:"done"}}function qr(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 Dr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Ur(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Br(e){const t=v(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:v(e.payload.to)}}}function Mr(e){return{type:"error",code:"BACKEND_ERROR",message:v(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Fr(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Hr(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,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.theme=s),yt({type:"quick_qna",payload:o})}const n=z(t.action);if(n){const o={action:n},i=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),s!==void 0&&(o.image_url=s),a!==void 0&&(o.theme=a),mt({type:"text_image",payload:o})}const r=typeof t.text=="string"?t.text:"";if(r){const o={text:r},i=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,a=z(t.payload)??void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.payload=a),s!==void 0&&(o.theme=s),Ne({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Ne(e){const t={text:v(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 Jr(e){return ro(e.payload,"qna")}function mt(e){const t=v(e.payload.text)??"",n=Z(e.payload.action,t);if(n){const o={label:t||n.title,action:n};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 r={text:t};return typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),Ne({type:"text",payload:r})}function yt(e){return _t((e.payload.action_list??[]).map(t=>{if(!z(t))return null;const n=v(t.title)??"",r=Z(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(J),"qna")}function Qr(e){const t={reviews:(e.payload.reviews??[]).map(n=>{if(!z(n))return null;const r={};return typeof n.review_class=="string"&&(r.review_class=n.review_class),typeof n.review_text=="string"&&(r.review_text=n.review_text),(typeof n.review_rating=="string"||typeof n.review_rating=="number")&&(r.review_rating=n.review_rating),typeof n.review_tag=="string"&&(r.review_tag=n.review_tag),r}).filter(J)};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 Wr(e){const t=e.payload.product_suggestions??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=io(o);if(!i)continue;const s={product:i},a=Z(o.requestDetails,i.name);a&&(s.action=a),typeof o.role=="string"&&(s.role=o.role),typeof o.reason=="string"&&(s.reason=o.reason),typeof o.review_highlight=="string"&&(s.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(s.labels=o.labels),typeof o.expert_quality_score=="number"&&(s.expertQualityScore=o.expert_quality_score),n.push(s)}return n.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:n}}}}}}function Vr(e){const t=e.payload.product_groupings??[],n=[],r=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const s=v(i.name)??"",a=v(i.description),c=v(i.highlight),u=Array.isArray(i.labels)?vt(i.labels):[],f=v(i.sku,i.repr_sku),g=v(i.image,i.repr_image),d=Gr(i,s,f),p=(Array.isArray(i.group_products)?i.group_products:[]).map(_=>{const w=z(_);return w?De(w):null}).filter(J),h=g??v(...p.map(_=>_.imageUrl));if(s&&p.length>0){const _={groupName:s,products:p};h&&(_.image=h),a&&(_.description=a),c&&(_.highlight=c),u.length>0&&(_.labels=u),n.push(_)}if(!d)continue;const m={name:s,action:d};u.length>0&&(m.labels=u),g!==void 0&&(m.image=g),r.push(m)}return n.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n}}}},panelHint:"panel"}:r.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:r}}}}}}function Gr(e,t,n){const r=z(e.requestDetails);if(r){if(r.type!=="findSimilar")return Z(r,t);const s={...z(r.payload)??{}};n&&!oe(s.sku)&&(s.sku=n);const a=ie(e.group_skus);return a.length>0&&(s.group_skus=a),Z({...r,payload:ge(s)},t)}const o={};n&&(o.sku=n);const i=ie(e.group_skus);return i.length>0&&(o.group_skus=i),Object.keys(o).length===0?null:Z({type:"findSimilar",payload:ge(o)},t)}function Kr(e,t){const n=z(e.requestDetails),r=z(n?.payload),o=v(e.detailed_user_message),i=e.group_skus&&Array.isArray(e.group_skus)?ie(e.group_skus):ie(r?.group_skus),s=v(e.sku,e.representative_product_sku,r?.sku);if(n?.type==="findSimilar"){const c={...r??{}};return s&&(c.sku=s),i.length>0&&(c.group_skus=i),o&&(c.input=o,oe(c.text)||(c.text=o)),c.is_search_suggestion=1,Z({...n,payload:ge(c)},t)}if(s){const c={sku:s,is_search_suggestion:1};return i.length>0&&(c.group_skus=i),o&&(c.input=o,c.text=o),Z({type:"findSimilar",payload:ge(c)},t)}const a={...r??{},is_suggested_text:1,is_search_suggestion:1};return o&&!oe(a.text)&&(a.text=o),i.length>0&&(a.group_skus=i),Z(n?.type==="inputText"?{...n,payload:a}:{type:"inputText",payload:a},t)}function Yr(e){const t=e.payload.suggested_searches??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=v(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${r+1}`,s=Kr(o,i);if(!s)continue;const a={shortName:i,action:s},c=v(o.detailed_user_message);c&&c!==i&&(a.detailedMessage=c);const u=zr(o);u&&u!==i&&u!==(c??"")&&(a.whyDifferent=u),typeof o.image=="string"&&(a.image=o.image),n.push(a)}return n.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:n}}}}}}function Xr(e){const t=e.payload,n=Z(t.requestDetails??t.request_details,v(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!n)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const r={action:n};return t.title&&(r.title=t.title),t.text&&(r.text=t.text),t.review_count?r.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(r.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:r}}}}}function eo(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function je(e,t){const n={product:e,index:t},r=e,o=typeof r.sku=="string"?r.sku:void 0;return o&&(n.action={title:typeof r.name=="string"?r.name:"",type:"launchSingleProduct",payload:{sku:o}}),{type:"ProductCard",props:n}}function _t(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`action-${o}`;r.push(s);const a={label:i.label,action:i.action};i.icon!==void 0&&(a.icon=i.icon),i.image!==void 0&&(a.image=i.image),i.description!==void 0&&(a.description=i.description),n[s]={type:"ActionButton",props:a}}return n.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:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function qe(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=Y(i),a=`product-${o}`;r.push(a),n[a]=je(s,o)}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function to(e,t,n){const r=new Map;for(const u of t)u?.sku&&r.set(u.sku,u);if(r.size===0)return null;const o=new Set,i={},s=[],a=[];let c=0;for(let u=0;u<e.length;u++){const f=e[u],g=v(f?.title)??"",d=Array.isArray(f?.skus)?f.skus:[],p=[];for(let h=0;h<d.length;h++){const m=typeof d[h]=="string"?d[h].trim():"";if(!m||o.has(m))continue;const _=r.get(m);if(!_)continue;o.add(m);const w=`product-${u}-${h}`,b=Y(_);s.push(w),p.push(w),i[w]=je(b,c),c+=1}p.length>0&&a.push({title:g,children:p})}return a.length===0||o.size<r.size?null:(i.root={type:"ProductGrid",props:{layout:"grouped",productSections:a},children:s},{type:"ui_spec",widget:n,spec:{root:"root",elements:i}})}function no(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`product-${o}`;r.push(s),n[s]=je(i,o)}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function ro(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:Y(e),index:0}}}}}}function oo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function io(e){const t=v(e.sku),n=v(e.short_name),r={...z(e.product_item)??e},o=v(e.discount_reason,e.discountReason);return o&&!v(r.discount_reason,r.discountReason)&&(r.discount_reason=o),De(r,t,n)}function De(e,t,n){const r=v(e.sku,t),o=v(e.name,n);if(!r||!o)return null;const i={sku:r,name:o},s=v(e.brand);s&&(i.brand=s);const a=v(e.url);a&&(i.url=a);const c=so(e.images);if(c.length>0)i.images=c;else{const m=v(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const u=se(e.price_discounted);u!==void 0&&(i.price_discounted=u);const f=se(e.price);f!==void 0&&(i.price=f);const g=se(e.rating);g!==void 0&&(i.rating=g);const d=se(e.review_count)??se(e.reviewCount);d!==void 0&&(i.review_count=d);const p=v(e.cart_code,e.cartCode);p&&(i.cart_code=p),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const h=v(e.discount_reason,e.discountReason);return h&&(i.discount_reason=h),Y(i)}function Z(e,t){const n=z(e);if(!n)return null;const r=n.type;if(typeof r!="string"||r.length===0)return null;const o={title:t||r,type:r};return n.payload!==void 0&&(o.payload=n.payload),o}function z(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function v(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function so(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function vt(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 se(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){if(!e.trim())return;let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const n=Number(t);if(Number.isFinite(n))return n}}function J(e){return e!=null}var ao=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 Y(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,r=t&&e.price!=null?e.price:void 0;let o;r!=null&&n!=null&&r>0?o=Math.round((r-n)/r*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=v(e.brand),s=v(e.name)??e.sku,a=i&&!s.toLowerCase().startsWith(i.toLowerCase())?`${i} ${s}`:s,c={sku:e.sku,name:a,url:v(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&n>0&&(c.price=String(n)),o!==void 0&&o>0&&(c.discountPercent=o,r!=null&&r>0&&(c.originalPrice=String(r))),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 f=e,g={};let d=!1;for(const p of Object.keys(f))ao.has(p)||(g[p]=f[p],d=!0);return d&&(c.extras=g),c}function co(e){const t=z(e.payload)??{},n=typeof t.type=="string"?t.type:"",{type:r,...o}=t;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:n,props:o}}}}}var uo=7200*1e3,bt=200,lo=5*1024*1024,fo="gengage_request_response_cache",po=1,L="responses",go=new Set(["addToCart","like"]),N=new Map,wt=null;async function ho(e,t={},n={}){const r=mo(e,t);if(!r)return fetch(e,t);const o=Date.now(),i=await bo(r,o);if(i)return So(i);const s=await fetch(e,t);return s.ok&&wo(r,s.clone(),o,{ttlMs:n.ttlMs??uo,maxEntries:n.maxEntries??bt,maxBodyBytes:n.maxBodyBytes??lo}),s}function mo(e,t={}){if(typeof Request<"u"&&e instanceof Request)return null;const n=String(t.method||"GET").toUpperCase();if(n!=="POST"||typeof t.body!="string")return null;const r=yo(t.body);if(_o(r))return null;const o=vo(r);if(o){const i=ae(r?.action);return`rr:${Et(zt({url:String(e),method:n,headers:kt(t.headers),type:r?.type??i?.type??"",account_id:r?.account_id??r?.accountId??"",locale:r?.locale??"",outputLanguage:ae(r?.meta)?.outputLanguage??"",cache_key:o}))}`}return`rr:${Et(zt({url:String(e),method:n,headers:kt(t.headers),body:t.body}))}`}function yo(e){try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function _o(e){const t=e?.type;return typeof t=="string"&&go.has(t)}function vo(e){const t=(ae(e?.payload)??ae(ae(e?.action)?.payload))?.cache_key;return typeof t=="string"&&t.trim().length>0?t.trim():null}async function bo(e,t){const n=N.get(e);if(n)if(n.expiresAt<=t)N.delete(e);else return n.lastAccessedAt=t,N.delete(e),N.set(e,n),Ue(n),n;const r=await Eo(e);return r?r.expiresAt<=t?(N.delete(e),Ao(e),null):(r.lastAccessedAt=t,N.set(e,r),Ue(r),St(bt),r):null}async function wo(e,t,n,r){try{const o=await t.text();if($o(o)>r.maxBodyBytes||ko(o))return;const i={key:e,status:t.status,statusText:t.statusText,headers:zo(t.headers),body:o,createdAt:n,expiresAt:n+r.ttlMs,lastAccessedAt:n};N.set(e,i),St(r.maxEntries),await Ue(i),await To(r.maxEntries,n)}catch{}}function ko(e){return/"_error"\s*:/u.test(e)||/"type"\s*:\s*"error"/u.test(e)}function So(e){return new Response(e.body,{status:e.status,statusText:e.statusText,headers:new Headers(e.headers)})}function kt(e){const t=new Headers(e),n=[];return t.forEach((r,o)=>{const i=o.toLowerCase();i!=="authorization"&&i!=="cookie"&&n.push([i,r])}),n.sort(([r],[o])=>r.localeCompare(o))}function zo(e){const t=[];return e.forEach((n,r)=>{const o=r.toLowerCase();o!=="set-cookie"&&t.push([o,n])}),t.sort(([n],[r])=>n.localeCompare(r))}function St(e){for(;N.size>e;){const t=[...N.values()].sort((n,r)=>n.lastAccessedAt-r.lastAccessedAt)[0];if(!t)break;N.delete(t.key)}}async function he(){return typeof indexedDB>"u"?null:(wt??=new Promise(e=>{const t=indexedDB.open(fo,po);t.onupgradeneeded=()=>{const n=t.result;n.objectStoreNames.contains(L)||n.createObjectStore(L,{keyPath:"key"}).createIndex("lastAccessedAt","lastAccessedAt",{unique:!1})},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}),wt)}async function Eo(e){const t=await he();return t?new Promise(n=>{const r=t.transaction(L,"readonly"),o=r.objectStore(L).get(e);o.onsuccess=()=>n(o.result??null),o.onerror=()=>n(null),r.onerror=()=>n(null)}):null}async function Ue(e){const t=await he();t&&await new Promise(n=>{const r=t.transaction(L,"readwrite");r.objectStore(L).put(e),r.oncomplete=()=>n(),r.onerror=()=>n(),r.onabort=()=>n()})}async function Ao(e){const t=await he();t&&await new Promise(n=>{const r=t.transaction(L,"readwrite");r.objectStore(L).delete(e),r.oncomplete=()=>n(),r.onerror=()=>n(),r.onabort=()=>n()})}async function To(e,t){const n=await he();n&&await new Promise(r=>{const o=n.transaction(L,"readwrite"),i=o.objectStore(L),s=[],a=i.openCursor();a.onsuccess=()=>{const c=a.result;if(!c){const u=s.filter(g=>g.expiresAt<=t),f=s.filter(g=>g.expiresAt>t).sort((g,d)=>g.lastAccessedAt-d.lastAccessedAt).slice(0,Math.max(0,s.length-u.length-e));for(const g of[...u,...f])i.delete(g.key);return}s.push(c.value),c.continue()},a.onerror=()=>r(),o.oncomplete=()=>r(),o.onerror=()=>r(),o.onabort=()=>r()})}function zt(e){return JSON.stringify(Be(e))}function ae(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Be(e){return Array.isArray(e)?e.map(Be):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,Be(n)]))}function Et(e){let t=14695981039346656037n;const n=1099511628211n;for(let r=0;r<e.length;r+=1)t^=BigInt(e.charCodeAt(r)),t=BigInt.asUintN(64,t*n);return t.toString(16).padStart(16,"0")}function $o(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).byteLength:e.length}async function Io(e,t,n){const r=wr("launcher_action",t),o={uiSpecs:[],actions:[]},i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);const s=await ho(r,i);if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);const a={onEvent:c=>{const u=Ar(c);if(u&&(u.type==="ui_spec"&&o.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const f of Object.values(u.spec.elements))if(f.type==="ActionButton"&&f.props?.action){const g=f.props.action;if(typeof g.title=="string"&&typeof g.type=="string"){const d={title:g.title,type:g.type};g.payload!==void 0&&(d.payload=g.payload),o.actions.push(d)}}}}};return n!==void 0&&(a.signal=n),await _r(s,a),o}function At(e){const t=document.createElement("div");t.className="gengage-qna-buttons gds-toolbar",t.dataset.gengagePart="qna-button-row",t.setAttribute("role","group"),t.setAttribute("aria-label",e.quickQuestionsAriaLabel??"Quick questions"),e.orientation==="vertical"&&(t.style.flexDirection="column");for(const n of e.actions){const r=document.createElement("button");r.className="gengage-qna-button gds-chip",r.dataset.gengagePart="qna-quick-question",r.textContent=n.title,r.type="button",r.addEventListener("click",()=>{const o={title:n.title,type:n.type};n.payload!==void 0&&(o.payload=n.payload),e.onAction(o)}),t.appendChild(r)}if(e.ctaText||e.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta gds-btn gds-btn-secondary",n.dataset.gengagePart="qna-cta",n.textContent=e.ctaText??e.defaultCtaText??"Ask something else",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function Po(e){const t=document.createElement("div");t.className="gengage-qna-input-wrapper",t.dataset.gengagePart="qna-input-wrapper";const n=document.createElement("div");n.className="gengage-qna-input-combo",n.dataset.gengagePart="qna-input-combo";const r=document.createElement("input");r.type="text",r.className="gengage-qna-input",r.dataset.gengagePart="qna-input",r.setAttribute("aria-label",e.askQuestionAriaLabel??"Ask a question");const o=Array.isArray(e.placeholders)?e.placeholders:e.placeholders?[e.placeholders]:[e.defaultInputPlaceholder??"Ask a question..."];let i=0,s=o[0]??"";r.placeholder=s;let a=null,c=null,u=!1;const f=()=>{a&&clearInterval(a),a=null,c&&clearTimeout(c),c=null,r.classList.remove("gengage-qna-input--fade")},g=()=>o.length>1&&!u&&r.value.trim().length===0,d=()=>{f(),g()&&(a=setInterval(()=>{g()&&(r.classList.add("gengage-qna-input--fade"),c=setTimeout(()=>{i=(i+1)%o.length,s=o[i]??"",r.placeholder=s,r.classList.remove("gengage-qna-input--fade")},180))},3e3))},p=document.createElement("div");p.className="gengage-qna-input-actions",p.dataset.gengagePart="qna-input-actions";const h=document.createElement("button");h.className="gengage-qna-icon-btn gengage-qna-clear gengage-qna-icon-btn--hidden",h.type="button",h.dataset.gengagePart="qna-clear",h.setAttribute("aria-label","Clear question"),h.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18" /><path d="M6 6L18 18" /></svg>';const m=document.createElement("button");m.className="gengage-qna-icon-btn gengage-qna-send gengage-qna-icon-btn--hidden",m.type="button",m.dataset.gengagePart="qna-send",m.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question"),m.disabled=!0,m.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M22 2L11 13" /><path d="M22 2L15 22L11 13L2 9L22 2Z" /></svg><span class="gengage-qna-sr-only">${e.ctaLabel??e.sendButtonText??"Ask"}</span>`;const _=()=>{const b=r.value.trim().length>0;h.classList.toggle("gengage-qna-icon-btn--hidden",!b),m.classList.toggle("gengage-qna-icon-btn--hidden",!b),m.classList.toggle("gengage-qna-send--active",b),m.disabled=!b},w=()=>{const b=r.value.trim();b&&(e.onSubmit({title:b,type:"user_message",payload:b}),r.value="",_(),d())};return h.addEventListener("click",()=>{r.value="",_(),r.focus({preventScroll:!0})}),m.addEventListener("click",w),r.addEventListener("focus",()=>{u=!0,f(),r.placeholder=""}),r.addEventListener("blur",()=>{u=!1,r.value.trim().length===0&&(r.placeholder=s),d()}),r.addEventListener("input",()=>{if(_(),r.value.trim().length>0){f();return}r.placeholder=u?"":s,d()}),r.addEventListener("keydown",b=>{b.key==="Enter"&&(b.preventDefault(),w()),b.key==="Escape"&&r.value.length>0&&(r.value="",_(),d())}),p.appendChild(h),p.appendChild(m),n.appendChild(r),n.appendChild(p),t.appendChild(n),_(),d(),t._cleanup=()=>{f()},t}function me(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.type;if(typeof r!="string"||r.length===0)return null;const o=n.title,i=n.payload,s=typeof o=="string"&&o.length>0?o:t;if(!s)return null;const a={title:s,type:r};return i!==void 0&&(a.payload=i),a}function Tt(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function $t(e,t){const n=[],r=e.props?.actions;if(Array.isArray(r))for(const s of r){const a=me(s);a&&n.push(a)}const o=e.props?.buttons;if(Array.isArray(o))for(const s of o){if(!s||typeof s!="object")continue;const a=s,c=typeof a.label=="string"?a.label:void 0,u=me(a.action,c);u&&n.push(u)}if(e.children)for(const s of e.children){const a=t.elements[s];if(!a||a.type!=="ActionButton")continue;const c=typeof a.props?.label=="string"?a.props.label:void 0,u=me(a.props?.action,c);u&&n.push(u)}const i=new Set;return n.filter(s=>i.has(s.title)?!1:(i.add(s.title),!0))}var It={ButtonRow:({element:e,spec:t,context:n})=>{const r=$t(e,t).map(Tt),o=e.props?.orientation,i={actions:r,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(i.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(i.ctaText=n.ctaText),(o==="horizontal"||o==="vertical")&&(i.orientation=o),At(i)},ActionButtons:({element:e,spec:t,context:n})=>{const r={actions:$t(e,t).map(Tt),onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(r.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(r.ctaText=n.ctaText),At(r)},ActionButton:({element:e,context:t})=>{const n=document.createElement("button");n.className="gengage-qna-button gds-chip",n.type="button",n.dataset.gengagePart="qna-action-button";const r=e.props?.label;typeof r=="string"?n.textContent=r:n.textContent=t.i18n.defaultCtaText;const o=me(e.props?.action,typeof r=="string"?r:void 0);return o&&n.addEventListener("click",()=>t.onAction(o)),n},TextInput:({element:e,context:t})=>{const n=e.props?.placeholder,r=typeof n=="string"||Array.isArray(n)?n:t.inputPlaceholder,o=typeof e.props?.ctaLabel=="string"?e.props.ctaLabel:void 0,i={onSubmit:t.onAction,askQuestionAriaLabel:t.i18n.askQuestionAriaLabel,defaultInputPlaceholder:t.i18n.defaultInputPlaceholder,sendButtonText:t.i18n.sendButton,sendQuestionAriaLabel:t.i18n.sendQuestionAriaLabel};return r!==void 0&&(i.placeholders=r),o!==void 0&&(i.ctaLabel=o),Po(i)},QuestionHeading:({element:e,context:t})=>{const n=document.createElement("h3");n.className="gengage-qna-heading",n.dataset.gengagePart="qna-heading";const r=e.props?.text,o=t.headingTitleOverride;return n.textContent=typeof o=="string"&&o.trim().length>0?o:typeof r=="string"?r:"",n},ProductCard:()=>null},Me=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function Pt(){return{...It}}function xt(e,t,n=It,r=Me){return Cn({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:r})}function xo(e){if(!e)return;const t=e.extra;if(t&&typeof t=="object"&&!Array.isArray(t)){const r=t.visible_skus??t.visibleSkus;if(Array.isArray(r)){const o=r.filter(i=>typeof i=="string"&&i.trim().length>0).map(i=>i.trim()).slice(0,200);if(o.length>0)return o}}const n=typeof e.sku=="string"&&e.sku.trim()?e.sku.trim():void 0;return n?[n]:void 0}function Ct(e,t){if(!e)return null;const n=e.action;if(!n||typeof n!="object")return null;const r=n,o=r.type;if(typeof o!="string"||o.length===0)return null;const i=r.title,s=typeof i=="string"&&i.length>0?i:typeof t=="string"&&t.length>0?t:"";if(!s)return null;const a=r.payload,c={title:s,type:o};return a!==void 0&&(c.payload=a),c}function Co(e,t){const n=e.elements[e.root];if(!n)return!1;const r=o=>{if(o.type!=="ActionButton")return!1;const i=o.props;if(!i||typeof i!="object")return!1;const s=typeof i.label=="string"?i.label:void 0;return s===t?!0:Ct(i,s)?.title===t};if(n.type==="ActionButton")return r(n);if(n.children)for(const o of n.children){const i=e.elements[o];if(i&&r(i))return!0}if(n.type==="ActionButtons"&&Array.isArray(n.props?.buttons)){for(const o of n.props.buttons)if(o?.label===t||o?.action?.title===t)return!0}return!1}var Ot=0;function Zt(){return Ot+=1,`gengage-merge-${Ot}`}function Oo(e,t){const n=e.elements[e.root];if(!n||n.type!=="ButtonRow")return;const r=Zt();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r]}function Zo(e,t){const n=e.elements[e.root];if(!n||n.type!=="ActionButtons")return;const r=Zt();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r];const o=n.props?.buttons??[],i={label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}};n.props={...n.props,buttons:[i,...o]}}function Ro(e){const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,...o.payload!==void 0?{payload:o.payload}:{}}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}function Lo(e){return e.find(t=>{const n=t.elements[t.root];return n?.type==="ActionButtons"||n?.type==="ButtonRow"})}function No(e,t){const n=e.productContextQuickPillLabel,r={text:n};return t&&t.length>0&&(r.sku_list=t),{title:n,type:"user_message",payload:r}}function jo(e,t,n){const r=n?.skuList;let o=!1;const i=[];for(const c of e){const u=c.elements[c.root];if(u?.type==="ActionButton"){const f=u.props;if(Ct(f,typeof f?.label=="string"?f.label:void 0)?.type==="findSimilar"){o=!0;continue}}i.push(c)}if(!o)return e;const s=No(t,r),a=Lo(i);if(!a)return[...i,Ro([s])];if(!Co(a,s.title)){const c=a.elements[a.root];c?.type==="ActionButtons"?Zo(a,s):c?.type==="ButtonRow"&&Oo(a,s)}return i}var Rt={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor",redirectingToChat:"Sohbete yönlendiriliyor...",productContextQuickPillLabel:"Bu ürün hakkında ne bilmeliyim?"},qo={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else",redirectingToChat:"Redirecting to chat...",productContextQuickPillLabel:"What should I know about this product?"};function Do(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Uo(e){return Do(e)==="en"?qo:Rt}var Lt=class extends sr{constructor(...e){super(...e),this._abortController=null,this._debounceTimer=null,this._dispatchTimers=new Set,this._contentEl=null,this._i18n=Rt,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this._contentEl.dataset.gengagePart="qna-container",this._contentEl.lang=ct(e.locale);const t=this._createChrome(e);if(t){const r=document.createElement("div");r.className="gengage-qna-chrome-widget",r.dataset.gengagePart="qna-chrome-widget",r.appendChild(this._contentEl),t.appendChild(r),this.root.appendChild(t)}else this.root.appendChild(this._contentEl);const n=e.pageContext?.sku;n&&(this._lastSku=n,await this._fetchAndRender(n)),Nn("qna")}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null);for(const e of this._dispatchTimers)clearTimeout(e);this._dispatchTimers.clear(),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_resolvedQnaHeaderTitle(){const e=this.config.headerTitle??this.config.headingTitle;if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}_cleanupTextInputTimers(){if(!this._contentEl)return;const e=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const t of e)t._cleanup?.()}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const t=this._createLoadingIndicator();this._contentEl.appendChild(t);const n={middlewareUrl:this.config.middlewareUrl},r=mr({source:"qna",locale:this.config.locale});try{const o=this.config.session?.sessionId??"",i={account_id:this.config.accountId,session_id:o,correlation_id:o,sku:e,locale:ct(this.config.locale)};this.config.session?.userId!==void 0&&(i.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(i.view_id=this.config.session.viewId);const s=this.config.pageContext?.pageType;s!==void 0&&(i.page_type=s);const a=await Io(i,n,this._abortController.signal);if(!this._contentEl)return;this._contentEl.innerHTML="";const c=document.createElement("div");c.className="gengage-qna-panel gds-panel",c.dataset.gengagePart="qna-panel",this._contentEl.appendChild(c);const u=this._specIncludesType(a.uiSpecs,"QuestionHeading"),f=this._resolvedQnaHeaderTitle()??(this.config.showStaticQuestion&&this.config.staticQuestionText?this.config.staticQuestionText:void 0);if(!u&&f){const b=document.createElement("h3");b.className="gengage-qna-heading",b.textContent=f,c.appendChild(b)}const g=this.config.inputPlaceholder;let d;if(g!==!0)d=g??this._i18n.defaultInputPlaceholder;else if(a.actions.length>0){const b=a.actions.filter(T=>T.type==="user_message"||typeof T.title=="string"&&T.title.includes("?")).map(T=>T.title);d=b.length>0?b:this._i18n.defaultInputPlaceholder}else d=this._i18n.defaultInputPlaceholder;const p={onAction:this._actionHandler,i18n:this._i18n},h=this._resolvedQnaHeaderTitle();h!==void 0&&(p.headingTitleOverride=h),this.config.hideButtonRowCta||(p.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(p.ctaText=this.config.ctaText)),d!==void 0&&(p.inputPlaceholder=d);const m=this._buildFallbackActionsSpec(a.actions),_=xo(this.config.pageContext),w=(a.uiSpecs.length>0?jo(a.uiSpecs,this._i18n,{skuList:_}):[m]).filter(b=>Object.keys(b.elements).length>0);for(const b of w){const T=this._renderUISpec(b,p);c.appendChild(T)}w.length>0&&jn("qna"),this._specIncludesType(w,"TextInput")||this._insertStandaloneInputBeforePills(c,p,d)}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;if(this._lastSku=void 0,xe("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:Vn(this.config.locale,o)}),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const i=document.createElement("div");i.className="gengage-qna-panel",this._contentEl.appendChild(i);const s=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,a={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler},c=this._resolvedQnaHeaderTitle();c!==void 0&&(a.headingTitleOverride=c),this.config.ctaText!==void 0&&(a.ctaText=this.config.ctaText),this._appendStandaloneInput(a,s,i)}}finally{r()}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let t=0;t<3;t++){const n=document.createElement("div");n.className="gengage-qna-loading-dot",e.appendChild(n)}return e}_resolveI18n(e){return{...Uo(e.locale),...e.i18n}}_createChrome(e){const t=e.chrome;if(!t)return null;const n=typeof t.title=="string"?t.title.trim():"",r=typeof t.subtitle=="string"?t.subtitle.trim():"",o=typeof t.startButtonLabel=="string"?t.startButtonLabel.trim():"",i=typeof t.imageUrl=="string"?t.imageUrl.trim():"",s=typeof t.imagePadding=="string"?t.imagePadding.trim():"",a=document.createElement("section");a.className="gengage-qna-chrome",a.dataset.gengagePart="qna-chrome",t.layout==="side-image"&&(a.classList.add("gengage-qna-chrome--side-image"),a.dataset.gengageChromeLayout="side-image"),s&&a.style.setProperty("--gengage-qna-chrome-image-padding",s);const c=document.createElement("div");if(c.className="gengage-qna-chrome-copy",c.dataset.gengagePart="qna-chrome-copy",n){const u=document.createElement("h2");u.className="gengage-qna-chrome-title",u.dataset.gengagePart="qna-chrome-title",u.textContent=n,c.appendChild(u)}if(r){const u=document.createElement("p");u.className="gengage-qna-chrome-subtitle",u.dataset.gengagePart="qna-chrome-subtitle",u.textContent=r,c.appendChild(u)}if(c.children.length>0&&a.appendChild(c),i&&Rn(i)){const u=document.createElement("img");u.className="gengage-qna-chrome-image",u.dataset.gengagePart="qna-chrome-image",u.src=i,u.alt=typeof t.imageAlt=="string"?t.imageAlt:"",u.loading="lazy",u.addEventListener("error",()=>{u.style.display="none"},{once:!0}),a.appendChild(u)}if(o){const u=document.createElement("button");u.className="gengage-qna-chrome-start",u.dataset.gengagePart="qna-chrome-start",u.type="button",u.textContent=o,u.addEventListener("click",()=>this._handleOpenChat()),a.appendChild(u)}return a.children.length===0?null:a}_resolveUISpecRegistry(){return On(Pt(),this.config.renderer?.registry)}_renderUISpec(e,t){const n=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??Me,o=(s,a)=>xt(s,a,n,r),i=this.config.renderer?.renderUISpec;return i?i(e,t,{registry:n,unknownRenderer:r,defaultRender:o}):o(e,t)}_specIncludesType(e,t){for(const n of e)for(const r of Object.values(n.elements))if(r.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,payload:o.payload}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}_insertStandaloneInputBeforePills(e,t,n){const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:n}}}},o=this._renderUISpec(r,t),i=o.querySelector(".gengage-qna-input-wrapper");if(!i)return;const s=e.querySelector(".gengage-qna-uispec"),a=e.querySelector(".gengage-qna-uispec > .gengage-qna-buttons"),c=this.config.inputAfterPills===!0;if(a)c?a.insertAdjacentElement("afterend",i):a.insertAdjacentElement("beforebegin",i);else if(s){const u=s.querySelector(":scope > .gengage-qna-heading");!c&&u?u.insertAdjacentElement("afterend",i):s.appendChild(i)}else{e.appendChild(o);return}o.remove()}_appendStandaloneInput(e,t,n){if(!this._contentEl)return;const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:t}}}},o=this._renderUISpec(r,e);(n??this._contentEl).appendChild(o)}_handleAction(e){this._showTransitionIndicator(),qn(e.title,e.type),this.config.onActionSelected?.(e);const t=setTimeout(()=>{this._dispatchTimers.delete(t),this._contentEl&&xe("gengage:qna:action",e)},350);this._dispatchTimers.add(t)}_handleOpenChat(){this._showTransitionIndicator(),this.config.onOpenChat?.();const e=setTimeout(()=>{this._dispatchTimers.delete(e),this._contentEl&&xe("gengage:qna:open-chat",{})},350);this._dispatchTimers.add(e)}_showTransitionIndicator(){if(!this._contentEl)return;this._contentEl.querySelector(".gengage-qna-transition-indicator")?.remove(),this._contentEl.classList.add("gengage-qna--transitioning");const e=this._i18n.redirectingToChat??"Redirecting to chat...",t=document.createElement("div");t.className="gengage-qna-transition-indicator",t.textContent=e,(this._contentEl.querySelector(".gengage-qna-panel")??this._contentEl).appendChild(t),setTimeout(()=>{this._contentEl?.classList.remove("gengage-qna--transitioning"),t.remove()},600)}};function Bo(){return new Lt}var Nt;function l(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=s.prototype,f=Object.keys(u);for(let g=0;g<f.length;g++){const d=f[g];d in a||(a[d]=u[d].bind(a))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=n?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const f of u._zod.deferred)f();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var X=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},jt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Nt=globalThis).__zod_globalConfig??(Nt.__zod_globalConfig={});var ye=globalThis.__zod_globalConfig;function Q(e){return e&&Object.assign(ye,e),ye}function qt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}function Fe(e,t){return typeof t=="bigint"?t.toString():t}function He(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function Je(e){return e==null}function Qe(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var Dt=Symbol("evaluating");function k(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Dt)return r===void 0&&(r=Dt,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function W(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function U(...e){const t={};for(const n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Ut(e){return JSON.stringify(e)}function Mo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Bt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Fo=He(()=>{if(ye.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function ce(e){if(_e(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(_e(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Mt(e){return ce(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ho=new Set(["string","number","symbol"]);function ve(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function B(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function y(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 Jo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var _u={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 Qo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return B(e,U(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=n.shape[i])}return W(this,"shape",o),o},checks:[]}))}function Wo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return B(e,U(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return W(this,"shape",o),o},checks:[]}))}function Vo(e,t){if(!ce(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const r=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return B(e,U(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return W(this,"shape",r),r}}))}function Go(e,t){if(!ce(t))throw new Error("Invalid input to safeExtend: expected a plain object");return B(e,U(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return W(this,"shape",n),n}}))}function Ko(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return B(e,U(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return W(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Yo(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return B(t,U(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:o[s]}):o[s])}else for(const s in o)i[s]=e?new e({type:"optional",innerType:o[s]}):o[s];return W(this,"shape",i),i},checks:[]}))}function Xo(e,t,n){return B(t,U(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)o[i]=new e({type:"nonoptional",innerType:r[i]});return W(this,"shape",o),o}}))}function ee(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ei(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ft(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function be(e){return typeof e=="string"?e:e?.message}function V(e,t,n){const r=e.message?e.message:be(e.inst?._zod.def?.error?.(e))??be(t?.error?.(e))??be(n.customError?.(e))??be(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function We(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ue(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}var Ht=(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,Fe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Jt=l("$ZodError",Ht),Qt=l("$ZodError",Ht,{Parent:Error});function ti(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function ni(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,u=0;for(;u<a.length;){const f=a[u];u!==a.length-1?c[f]=c[f]||{_errors:[]}:(c[f]=c[f]||{_errors:[]},c[f]._errors.push(t(s))),c=c[f],u++}}}};return r(e),n}var Ve=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new X;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>V(c,i,Q())));throw Bt(a,o?.callee),a}return s.value},Ge=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>V(c,i,Q())));throw Bt(a,o?.callee),a}return s.value},we=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new X;return i.issues.length?{success:!1,error:new(e??Jt)(i.issues.map(s=>V(s,o,Q())))}:{success:!0,data:i.value}},ri=we(Qt),ke=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>V(s,o,Q())))}:{success:!0,data:i.value}},oi=ke(Qt),ii=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ve(e)(t,n,o)},si=e=>(t,n,r)=>Ve(e)(t,n,r),ai=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ge(e)(t,n,o)},ci=e=>async(t,n,r)=>Ge(e)(t,n,r),ui=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return we(e)(t,n,o)},li=e=>(t,n,r)=>we(e)(t,n,r),di=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ke(e)(t,n,o)},fi=e=>async(t,n,r)=>ke(e)(t,n,r),pi=/^[cC][0-9a-z]{6,}$/,gi=/^[0-9a-z]+$/,hi=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mi=/^[0-9a-vA-V]{20}$/,yi=/^[A-Za-z0-9]{27}$/,_i=/^[a-zA-Z0-9_-]{21}$/,vi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,bi=/^([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})$/,Wt=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)$/,wi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ki="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Si(){return new RegExp(ki,"u")}var zi=/^(?:(?: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])$/,Ei=/^(([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}|:))$/,Ai=/^((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])$/,Ti=/^(([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])$/,$i=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vt=/^[A-Za-z0-9_-]*$/,Ii=/^https?$/,Pi=/^\+[1-9]\d{6,14}$/,Gt="(?:(?:\\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])))",xi=new RegExp(`^${Gt}$`);function Kt(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 Ci(e){return new RegExp(`^${Kt(e)}$`)}function Oi(e){const t=Kt({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Gt}T(?:${r})$`)}var Zi=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ri=/^(?:true|false)$/i,Li=/^[^A-Z]*$/,Ni=/^[^a-z]*$/,j=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ji=l("$ZodCheckMaxLength",(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Je(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=We(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),qi=l("$ZodCheckMinLength",(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Je(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=We(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Di=l("$ZodCheckLengthEquals",(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Je(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const s=We(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Se=l("$ZodCheckStringFormat",(e,t)=>{var n,r;j.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?(n=e._zod).check??(n.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})}):(r=e._zod).check??(r.check=()=>{})}),Ui=l("$ZodCheckRegex",(e,t)=>{Se.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Bi=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Li),Se.init(e,t)}),Mi=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ni),Se.init(e,t)}),Fi=l("$ZodCheckIncludes",(e,t)=>{j.init(e,t);const n=ve(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),Hi=l("$ZodCheckStartsWith",(e,t)=>{j.init(e,t);const n=new RegExp(`^${ve(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ji=l("$ZodCheckEndsWith",(e,t)=>{j.init(e,t);const n=new RegExp(`.*${ve(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Qi=l("$ZodCheckOverwrite",(e,t)=>{j.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),Wi=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),n=Math.min(...t.map(o=>o.length-o.trimStart().length)),r=t.map(o=>o.slice(n)).map(o=>" ".repeat(this.indent*2)+o);for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args,n=[...(this?.content??[""]).map(r=>` ${r}`)];return new e(...t,n.join(`
50
- `))}},Qi={major:4,minor:4,patch:3},A=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Qi;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,a,c)=>{let u=X(s),d;for(const f of a){if(f._zod.def.when){if(Yo(s)||!f._zod.def.when(s))continue}else if(u)continue;const g=s.issues.length,p=f._zod.check(s);if(p instanceof Promise&&c?.async===!1)throw new Y;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,s.issues.length!==g&&(u||(u=X(s,g)))});else{if(s.issues.length===g)continue;u||(u=X(s,g))}}return d?d.then(()=>s):s},i=(s,a,c)=>{if(X(s))return s.aborted=!0,s;const u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new Y;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){const u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>i(d,s,a)):i(u,s,a)}const c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Y;return c.then(u=>o(u,r,a))}return o(c,r,a)}}b(e,"~standard",()=>({validate:o=>{try{const i=ti(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return ni(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Ke=l("$ZodString",(e,t)=>{A.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ci(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),S=l("$ZodStringFormat",(e,t)=>{Se.init(e,t),Ke.init(e,t)}),Wi=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=_i),S.init(e,t)}),Vi=l("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Vt(n))}else t.pattern??(t.pattern=Vt());S.init(e,t)}),Gi=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=vi),S.init(e,t)}),Ki=l("$ZodURL",(e,t)=>{S.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Ti.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.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)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Yi=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=wi()),S.init(e,t)}),Xi=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=mi),S.init(e,t)}),es=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=di),S.init(e,t)}),ts=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=fi),S.init(e,t)}),ns=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=pi),S.init(e,t)}),rs=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=gi),S.init(e,t)}),os=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=hi),S.init(e,t)}),is=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=xi(t)),S.init(e,t)}),ss=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ii),S.init(e,t)}),as=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Pi(t)),S.init(e,t)}),cs=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=yi),S.init(e,t)}),us=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ki),S.init(e,t),e._zod.bag.format="ipv4"}),ls=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Si),S.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),ds=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=zi),S.init(e,t)}),fs=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ei),S.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Xt(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ps=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ai),S.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Xt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function gs(e){if(!Gt.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/");return Xt(t.padEnd(Math.ceil(t.length/4)*4,"="))}var hs=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Gt),S.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{gs(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ms=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$i),S.init(e,t)});function ys(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var _s=l("$ZodJWT",(e,t)=>{S.init(e,t),e._zod.check=n=>{ys(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),vs=l("$ZodBoolean",(e,t)=>{A.init(e,t),e._zod.pattern=Oi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),bs=l("$ZodUnknown",(e,t)=>{A.init(e,t),e._zod.parse=n=>n}),ws=l("$ZodNever",(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function en(e,t,n){e.issues.length&&t.issues.push(...Ht(n,e.issues)),t.value[n]=e.value}var ks=l("$ZodArray",(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let s=0;s<o.length;s++){const a=o[s],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?i.push(c.then(u=>en(u,n,s))):en(c,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function ze(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...Ht(n,e.issues))}if(!s&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?s&&(t.value[n]=void 0):t.value[n]=e.value}function tn(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Fo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function nn(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optin==="optional",f=c.optout==="optional";for(const g in t){if(g==="__proto__"||a.has(g))continue;if(u==="never"){s.push(g);continue}const p=c.run({value:t[g],issues:[]},r);p instanceof Promise?e.push(p.then(h=>ze(h,n,g,t,d,f))):ze(p,n,g,t,d,f)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var Ss=l("$ZodObject",(e,t)=>{if(A.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const a={...s};return Object.defineProperty(t,"shape",{value:a}),a}})}const n=He(()=>tn(t));b(e._zod,"propValues",()=>{const s=t.shape,a={};for(const c in s){const u=s[c]._zod;if(u.values){a[c]??(a[c]=new Set);for(const d of u.values)a[c].add(d)}}return a});const r=_e,o=t.catchall;let i;e._zod.parse=(s,a)=>{i??(i=n.value);const c=s.value;if(!r(c))return s.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),s;s.value={};const u=[],d=i.shape;for(const f of i.keys){const g=d[f],p=g._zod.optin==="optional",h=g._zod.optout==="optional",m=g._zod.run({value:c[f],issues:[]},a);m instanceof Promise?u.push(m.then(v=>ze(v,s,f,c,p,h))):ze(m,s,f,c,p,h)}return o?nn(u,c,s,a,n.value,e):u.length?Promise.all(u).then(()=>s):s}}),zs=l("$ZodObjectJIT",(e,t)=>{Ss.init(e,t);const n=e._zod.parse,r=He(()=>tn(t)),o=g=>{const p=new Ji(["shape","payload","ctx"]),h=r.value,m=I=>{const E=Bt(I);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};p.write("const input = payload.value;");const v=Object.create(null);let w=0;for(const I of h.keys)v[I]=`key_${w++}`;p.write("const newResult = {};");for(const I of h.keys){const E=v[I],P=Bt(I),Pn=g[I],xn=Pn?._zod?.optin==="optional",hu=Pn?._zod?.optout==="optional";p.write(`const ${E} = ${m(I)};`),xn&&hu?p.write(`
51
- if (${E}.issues.length) {
52
- if (${P} in input) {
53
- payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
50
+ `))}},Vi={major:4,minor:4,patch:3},$=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vi;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,a,c)=>{let u=ee(s),f;for(const g of a){if(g._zod.def.when){if(ei(s)||!g._zod.def.when(s))continue}else if(u)continue;const d=s.issues.length,p=g._zod.check(s);if(p instanceof Promise&&c?.async===!1)throw new X;if(f||p instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await p,s.issues.length!==d&&(u||(u=ee(s,d)))});else{if(s.issues.length===d)continue;u||(u=ee(s,d))}}return f?f.then(()=>s):s},i=(s,a,c)=>{if(ee(s))return s.aborted=!0,s;const u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new X;return u.then(f=>e._zod.parse(f,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){const u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(f=>i(f,s,a)):i(u,s,a)}const c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new X;return c.then(u=>o(u,r,a))}return o(c,r,a)}}k(e,"~standard",()=>({validate:o=>{try{const i=ri(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return oi(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Ke=l("$ZodString",(e,t)=>{$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Zi(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),E=l("$ZodStringFormat",(e,t)=>{Se.init(e,t),Ke.init(e,t)}),Gi=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=bi),E.init(e,t)}),Ki=l("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Wt(n))}else t.pattern??(t.pattern=Wt());E.init(e,t)}),Yi=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=wi),E.init(e,t)}),Xi=l("$ZodURL",(e,t)=>{E.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Ii.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.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)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),es=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Si()),E.init(e,t)}),ts=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=_i),E.init(e,t)}),ns=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pi),E.init(e,t)}),rs=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=gi),E.init(e,t)}),os=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=hi),E.init(e,t)}),is=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=mi),E.init(e,t)}),ss=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=yi),E.init(e,t)}),as=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Oi(t)),E.init(e,t)}),cs=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=xi),E.init(e,t)}),us=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ci(t)),E.init(e,t)}),ls=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=vi),E.init(e,t)}),ds=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=zi),E.init(e,t),e._zod.bag.format="ipv4"}),fs=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ei),E.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),ps=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ai),E.init(e,t)}),gs=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ti),E.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Yt(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var hs=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$i),E.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Yt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function ms(e){if(!Vt.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/");return Yt(t.padEnd(Math.ceil(t.length/4)*4,"="))}var ys=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Vt),E.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{ms(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),_s=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Pi),E.init(e,t)});function vs(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var bs=l("$ZodJWT",(e,t)=>{E.init(e,t),e._zod.check=n=>{vs(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ws=l("$ZodBoolean",(e,t)=>{$.init(e,t),e._zod.pattern=Ri,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),ks=l("$ZodUnknown",(e,t)=>{$.init(e,t),e._zod.parse=n=>n}),Ss=l("$ZodNever",(e,t)=>{$.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Xt(e,t,n){e.issues.length&&t.issues.push(...Ft(n,e.issues)),t.value[n]=e.value}var zs=l("$ZodArray",(e,t)=>{$.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let s=0;s<o.length;s++){const a=o[s],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?i.push(c.then(u=>Xt(u,n,s))):Xt(c,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function ze(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...Ft(n,e.issues))}if(!s&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?s&&(t.value[n]=void 0):t.value[n]=e.value}function en(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Jo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function tn(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,f=c.optin==="optional",g=c.optout==="optional";for(const d in t){if(d==="__proto__"||a.has(d))continue;if(u==="never"){s.push(d);continue}const p=c.run({value:t[d],issues:[]},r);p instanceof Promise?e.push(p.then(h=>ze(h,n,d,t,f,g))):ze(p,n,d,t,f,g)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var Es=l("$ZodObject",(e,t)=>{if($.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const a={...s};return Object.defineProperty(t,"shape",{value:a}),a}})}const n=He(()=>en(t));k(e._zod,"propValues",()=>{const s=t.shape,a={};for(const c in s){const u=s[c]._zod;if(u.values){a[c]??(a[c]=new Set);for(const f of u.values)a[c].add(f)}}return a});const r=_e,o=t.catchall;let i;e._zod.parse=(s,a)=>{i??(i=n.value);const c=s.value;if(!r(c))return s.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),s;s.value={};const u=[],f=i.shape;for(const g of i.keys){const d=f[g],p=d._zod.optin==="optional",h=d._zod.optout==="optional",m=d._zod.run({value:c[g],issues:[]},a);m instanceof Promise?u.push(m.then(_=>ze(_,s,g,c,p,h))):ze(m,s,g,c,p,h)}return o?tn(u,c,s,a,n.value,e):u.length?Promise.all(u).then(()=>s):s}}),As=l("$ZodObjectJIT",(e,t)=>{Es.init(e,t);const n=e._zod.parse,r=He(()=>en(t)),o=d=>{const p=new Wi(["shape","payload","ctx"]),h=r.value,m=T=>{const S=Ut(T);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};p.write("const input = payload.value;");const _=Object.create(null);let w=0;for(const T of h.keys)_[T]=`key_${w++}`;p.write("const newResult = {};");for(const T of h.keys){const S=_[T],x=Ut(T),In=d[T],Pn=In?._zod?.optin==="optional",yu=In?._zod?.optout==="optional";p.write(`const ${S} = ${m(T)};`),Pn&&yu?p.write(`
51
+ if (${S}.issues.length) {
52
+ if (${x} in input) {
53
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
54
54
  ...iss,
55
- path: iss.path ? [${P}, ...iss.path] : [${P}]
55
+ path: iss.path ? [${x}, ...iss.path] : [${x}]
56
56
  })));
57
57
  }
58
58
  }
59
59
 
60
- if (${E}.value === undefined) {
61
- if (${P} in input) {
62
- newResult[${P}] = undefined;
60
+ if (${S}.value === undefined) {
61
+ if (${x} in input) {
62
+ newResult[${x}] = undefined;
63
63
  }
64
64
  } else {
65
- newResult[${P}] = ${E}.value;
65
+ newResult[${x}] = ${S}.value;
66
66
  }
67
67
 
68
- `):xn?p.write(`
69
- if (${E}.issues.length) {
70
- payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
68
+ `):Pn?p.write(`
69
+ if (${S}.issues.length) {
70
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
71
71
  ...iss,
72
- path: iss.path ? [${P}, ...iss.path] : [${P}]
72
+ path: iss.path ? [${x}, ...iss.path] : [${x}]
73
73
  })));
74
74
  }
75
75
 
76
- if (${E}.value === undefined) {
77
- if (${P} in input) {
78
- newResult[${P}] = undefined;
76
+ if (${S}.value === undefined) {
77
+ if (${x} in input) {
78
+ newResult[${x}] = undefined;
79
79
  }
80
80
  } else {
81
- newResult[${P}] = ${E}.value;
81
+ newResult[${x}] = ${S}.value;
82
82
  }
83
83
 
84
84
  `):p.write(`
85
- const ${E}_present = ${P} in input;
86
- if (${E}.issues.length) {
87
- payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
85
+ const ${S}_present = ${x} in input;
86
+ if (${S}.issues.length) {
87
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
88
88
  ...iss,
89
- path: iss.path ? [${P}, ...iss.path] : [${P}]
89
+ path: iss.path ? [${x}, ...iss.path] : [${x}]
90
90
  })));
91
91
  }
92
- if (!${E}_present && !${E}.issues.length) {
92
+ if (!${S}_present && !${S}.issues.length) {
93
93
  payload.issues.push({
94
94
  code: "invalid_type",
95
95
  expected: "nonoptional",
96
96
  input: undefined,
97
- path: [${P}]
97
+ path: [${x}]
98
98
  });
99
99
  }
100
100
 
101
- if (${E}_present) {
102
- if (${E}.value === undefined) {
103
- newResult[${P}] = undefined;
101
+ if (${S}_present) {
102
+ if (${S}.value === undefined) {
103
+ newResult[${x}] = undefined;
104
104
  } else {
105
- newResult[${P}] = ${E}.value;
105
+ newResult[${x}] = ${S}.value;
106
106
  }
107
107
  }
108
108
 
109
- `)}p.write("payload.value = newResult;"),p.write("return payload;");const k=p.compile();return(I,E)=>k(g,I,E)};let i;const s=_e,a=!ye.jitless,u=a&&Bo.value,d=t.catchall;let f;e._zod.parse=(g,p)=>{f??(f=r.value);const h=g.value;return s(h)?a&&u&&p?.async===!1&&p.jitless!==!0?(i||(i=o(t.shape)),g=i(g,p),d?nn([],h,g,p,f,e):g):n(g,p):(g.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),g)}});function rn(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!X(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>W(s,r,J())))}),t)}var Es=l("$ZodUnion",(e,t)=>{A.init(e,t),b(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),b(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),b(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),b(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Qe(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>rn(a,r,e,o)):rn(s,r,e,o)}}),As=l("$ZodIntersection",(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,c])=>on(n,a,c)):on(n,i,s)}});function Ye(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ce(e)&&ce(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=Ye(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Ye(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function on(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),X(e))return e;const s=Ye(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Ts=l("$ZodEnum",(e,t)=>{A.init(e,t);const n=Dt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Mo.has(typeof o)).map(o=>typeof o=="string"?ve(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),$s=l("$ZodTransform",(e,t)=>{A.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new qt(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new Y;return n.value=o,n.fallback=!0,n}});function sn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var an=l("$ZodOptional",(e,t)=>{A.init(e,t),e._zod.optin="optional",e._zod.optout="optional",b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Qe(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>sn(s,o)):sn(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Is=l("$ZodExactOptional",(e,t)=>{an.init(e,t),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Ps=l("$ZodNullable",(e,t)=>{A.init(e,t),b(e._zod,"optin",()=>t.innerType._zod.optin),b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Qe(n.source)}|null)$`):void 0}),b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),xs=l("$ZodDefault",(e,t)=>{A.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>cn(i,t)):cn(o,t)}});function cn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Cs=l("$ZodPrefault",(e,t)=>{A.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Os=l("$ZodNonOptional",(e,t)=>{A.init(e,t),b(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>un(i,e)):un(o,e)}});function un(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Zs=l("$ZodCatch",(e,t)=>{A.init(e,t),e._zod.optin="optional",b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>W(s,r,J()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>W(i,r,J()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Rs=l("$ZodPipe",(e,t)=>{A.init(e,t),b(e._zod,"values",()=>t.in._zod.values),b(e._zod,"optin",()=>t.in._zod.optin),b(e._zod,"optout",()=>t.out._zod.optout),b(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>Ee(s,t.in,r)):Ee(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Ee(i,t.out,r)):Ee(o,t.out,r)}});function Ee(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Ls=l("$ZodReadonly",(e,t)=>{A.init(e,t),b(e._zod,"propValues",()=>t.innerType._zod.propValues),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"optin",()=>t.innerType?._zod?.optin),b(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(ln):ln(o)}});function ln(e){return e.value=Object.freeze(e.value),e}var Ns=l("$ZodCustom",(e,t)=>{j.init(e,t),A.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>dn(i,n,r,e));dn(o,n,r,e)}});function dn(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(ue(o))}}var fn,js=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function qs(){return new js}(fn=globalThis).__zod_globalRegistry??(fn.__zod_globalRegistry=qs());var le=globalThis.__zod_globalRegistry;function Ds(e,t){return new e({type:"string",...y(t)})}function Us(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function pn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Bs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Ms(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Fs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Hs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function Js(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Qs(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Ws(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Vs(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Gs(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function Ks(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function Ys(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function Xs(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function ea(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function ta(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function na(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function ra(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function oa(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function ia(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function sa(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function aa(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function ca(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function ua(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function la(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function da(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function fa(e,t){return new e({type:"boolean",...y(t)})}function pa(e){return new e({type:"unknown"})}function ga(e,t){return new e({type:"never",...y(t)})}function gn(e,t){return new Li({check:"max_length",...y(t),maximum:e})}function Ae(e,t){return new Ni({check:"min_length",...y(t),minimum:e})}function hn(e,t){return new ji({check:"length_equals",...y(t),length:e})}function ha(e,t){return new qi({check:"string_format",format:"regex",...y(t),pattern:e})}function ma(e){return new Di({check:"string_format",format:"lowercase",...y(e)})}function ya(e){return new Ui({check:"string_format",format:"uppercase",...y(e)})}function _a(e,t){return new Bi({check:"string_format",format:"includes",...y(t),includes:e})}function va(e,t){return new Mi({check:"string_format",format:"starts_with",...y(t),prefix:e})}function ba(e,t){return new Fi({check:"string_format",format:"ends_with",...y(t),suffix:e})}function ee(e){return new Hi({check:"overwrite",tx:e})}function wa(e){return ee(t=>t.normalize(e))}function ka(){return ee(e=>e.trim())}function Sa(){return ee(e=>e.toLowerCase())}function za(){return ee(e=>e.toUpperCase())}function Ea(){return ee(e=>Uo(e))}function Aa(e,t,n){return new e({type:"array",element:t,...y(n)})}function Ta(e,t,n){return new e({type:"custom",check:"custom",fn:t,...y(n)})}function $a(e,t){const n=Ia(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(ue(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(ue(i))}},e(r.value,r)),t);return n}function Ia(e,t){const n=new j({check:"custom",...y(t)});return n._zod.check=e,n}function mn(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??le,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function $(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const f=s.schema,g=t.processors[o.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);g(e,t,f,u)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),$(d,t,u),t.seen.get(d).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&C(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function yn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,f=e.external.uri??(p=>p);if(d)return{ref:f(d)};const g=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=g,{defId:g,ref:`${f("__shared")}#/${a}/${g}`}}if(s[1]===n)return{ref:"#"};const c=`#/${a}/`,u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=o(s);a.def={...a.schema},u&&(a.defId=u);const d=a.schema;for(const f in d)delete d[f];d.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
109
+ `)}p.write("payload.value = newResult;"),p.write("return payload;");const b=p.compile();return(T,S)=>b(d,T,S)};let i;const s=_e,a=!ye.jitless,u=a&&Fo.value,f=t.catchall;let g;e._zod.parse=(d,p)=>{g??(g=r.value);const h=d.value;return s(h)?a&&u&&p?.async===!1&&p.jitless!==!0?(i||(i=o(t.shape)),d=i(d,p),f?tn([],h,d,p,g,e):d):n(d,p):(d.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),d)}});function nn(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!ee(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>V(s,r,Q())))}),t)}var Ts=l("$ZodUnion",(e,t)=>{$.init(e,t),k(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),k(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),k(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),k(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Qe(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>nn(a,r,e,o)):nn(s,r,e,o)}}),$s=l("$ZodIntersection",(e,t)=>{$.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,c])=>rn(n,a,c)):rn(n,i,s)}});function Ye(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ce(e)&&ce(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=Ye(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Ye(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function rn(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),ee(e))return e;const s=Ye(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Is=l("$ZodEnum",(e,t)=>{$.init(e,t);const n=qt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Ho.has(typeof o)).map(o=>typeof o=="string"?ve(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),Ps=l("$ZodTransform",(e,t)=>{$.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new jt(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new X;return n.value=o,n.fallback=!0,n}});function on(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var sn=l("$ZodOptional",(e,t)=>{$.init(e,t),e._zod.optin="optional",e._zod.optout="optional",k(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),k(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Qe(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>on(s,o)):on(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),xs=l("$ZodExactOptional",(e,t)=>{sn.init(e,t),k(e._zod,"values",()=>t.innerType._zod.values),k(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Cs=l("$ZodNullable",(e,t)=>{$.init(e,t),k(e._zod,"optin",()=>t.innerType._zod.optin),k(e._zod,"optout",()=>t.innerType._zod.optout),k(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Qe(n.source)}|null)$`):void 0}),k(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Os=l("$ZodDefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",k(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>an(i,t)):an(o,t)}});function an(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Zs=l("$ZodPrefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",k(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Rs=l("$ZodNonOptional",(e,t)=>{$.init(e,t),k(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>cn(i,e)):cn(o,e)}});function cn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Ls=l("$ZodCatch",(e,t)=>{$.init(e,t),e._zod.optin="optional",k(e._zod,"optout",()=>t.innerType._zod.optout),k(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>V(s,r,Q()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>V(i,r,Q()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Ns=l("$ZodPipe",(e,t)=>{$.init(e,t),k(e._zod,"values",()=>t.in._zod.values),k(e._zod,"optin",()=>t.in._zod.optin),k(e._zod,"optout",()=>t.out._zod.optout),k(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>Ee(s,t.in,r)):Ee(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Ee(i,t.out,r)):Ee(o,t.out,r)}});function Ee(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var js=l("$ZodReadonly",(e,t)=>{$.init(e,t),k(e._zod,"propValues",()=>t.innerType._zod.propValues),k(e._zod,"values",()=>t.innerType._zod.values),k(e._zod,"optin",()=>t.innerType?._zod?.optin),k(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(un):un(o)}});function un(e){return e.value=Object.freeze(e.value),e}var qs=l("$ZodCustom",(e,t)=>{j.init(e,t),$.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>ln(i,n,r,e));ln(o,n,r,e)}});function ln(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(ue(o))}}var dn,Ds=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Us(){return new Ds}(dn=globalThis).__zod_globalRegistry??(dn.__zod_globalRegistry=Us());var le=globalThis.__zod_globalRegistry;function Bs(e,t){return new e({type:"string",...y(t)})}function Ms(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function fn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Fs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Hs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Js(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Qs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function Ws(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Vs(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Gs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Ks(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Ys(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function Xs(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function ea(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function ta(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function na(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function ra(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function oa(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function ia(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function sa(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function aa(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function ca(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function ua(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function la(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function da(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function fa(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function pa(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function ga(e,t){return new e({type:"boolean",...y(t)})}function ha(e){return new e({type:"unknown"})}function ma(e,t){return new e({type:"never",...y(t)})}function pn(e,t){return new ji({check:"max_length",...y(t),maximum:e})}function Ae(e,t){return new qi({check:"min_length",...y(t),minimum:e})}function gn(e,t){return new Di({check:"length_equals",...y(t),length:e})}function ya(e,t){return new Ui({check:"string_format",format:"regex",...y(t),pattern:e})}function _a(e){return new Bi({check:"string_format",format:"lowercase",...y(e)})}function va(e){return new Mi({check:"string_format",format:"uppercase",...y(e)})}function ba(e,t){return new Fi({check:"string_format",format:"includes",...y(t),includes:e})}function wa(e,t){return new Hi({check:"string_format",format:"starts_with",...y(t),prefix:e})}function ka(e,t){return new Ji({check:"string_format",format:"ends_with",...y(t),suffix:e})}function te(e){return new Qi({check:"overwrite",tx:e})}function Sa(e){return te(t=>t.normalize(e))}function za(){return te(e=>e.trim())}function Ea(){return te(e=>e.toLowerCase())}function Aa(){return te(e=>e.toUpperCase())}function Ta(){return te(e=>Mo(e))}function $a(e,t,n){return new e({type:"array",element:t,...y(n)})}function Ia(e,t,n){return new e({type:"custom",check:"custom",fn:t,...y(n)})}function Pa(e,t){const n=xa(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(ue(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(ue(i))}},e(r.value,r)),t);return n}function xa(e,t){const n=new j({check:"custom",...y(t)});return n._zod.check=e,n}function hn(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??le,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function P(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const g=s.schema,d=t.processors[o.type];if(!d)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);d(e,t,g,u)}const f=e._zod.parent;f&&(s.ref||(s.ref=f),P(f,t,u),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&C(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function mn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(s[0])?.id,g=e.external.uri??(p=>p);if(f)return{ref:g(f)};const d=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=d,{defId:d,ref:`${g("__shared")}#/${a}/${d}`}}if(s[1]===n)return{ref:"#"};const c=`#/${a}/`,u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=o(s);a.def={...a.schema},u&&(a.defId=u);const f=a.schema;for(const g in f)delete f[g];f.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
110
110
 
111
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1&&e.reused==="ref"){i(s);continue}}}function _n(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,d={...u},f=c.ref;if(c.ref=null,f){r(f);const p=e.seen.get(f),h=p.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Object.assign(u,h),Object.assign(u,d),a._zod.parent===f)for(const m in u)m==="$ref"||m==="allOf"||m in d||delete u[m];if(h.$ref&&p.def)for(const m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}const g=a._zod.parent;if(g&&g!==f){r(g);const p=e.seen.get(g);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(const h in u)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(u[h])===JSON.stringify(p.def[h])&&delete u[h]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())r(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const s=e.external?.defs??{};for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Te(t,"input",e.processors),output:Te(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function C(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return C(r.element,n);if(r.type==="set")return C(r.valueType,n);if(r.type==="lazy")return C(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return C(r.innerType,n);if(r.type==="intersection")return C(r.left,n)||C(r.right,n);if(r.type==="record"||r.type==="map")return C(r.keyType,n)||C(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:C(r.in,n)||C(r.out,n);if(r.type==="object"){for(const o in r.shape)if(C(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(C(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(C(o,n))return!0;return!!(r.rest&&C(r.rest,n))}return!1}var Pa=(e,t={})=>n=>{const r=mn({...n,processors:t});return $(e,r),yn(r,e),_n(r,e)},Te=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=mn({...o??{},target:i,io:t,processors:n});return $(e,s),yn(s,e),_n(s,e)},xa={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ca=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=xa[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Oa=(e,t,n,r)=>{n.type="boolean"},Za=(e,t,n,r)=>{n.not={}},Ra=(e,t,n,r)=>{},La=(e,t,n,r)=>{const o=e._zod.def,i=Dt(o.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},Na=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ja=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},qa=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=$(i.element,t,{...r,path:[...r.path,"items"]})},Da=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=$(s[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{const d=i.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=$(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Ua=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>$(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},Ba=(e,t,n,r)=>{const o=e._zod.def,i=$(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=$(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1;n.allOf=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]]},Ma=(e,t,n,r)=>{const o=e._zod.def,i=$(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Fa=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Ha=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Ja=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Qa=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},Wa=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;$(s,t,r);const a=t.seen.get(e);a.ref=s},Va=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},vn=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Ga=l("ZodISODateTime",(e,t)=>{is.init(e,t),z.init(e,t)});function Ka(e){return ca(Ga,e)}var Ya=l("ZodISODate",(e,t)=>{ss.init(e,t),z.init(e,t)});function Xa(e){return ua(Ya,e)}var ec=l("ZodISOTime",(e,t)=>{as.init(e,t),z.init(e,t)});function tc(e){return la(ec,e)}var nc=l("ZodISODuration",(e,t)=>{cs.init(e,t),z.init(e,t)});function rc(e){return da(nc,e)}var oc=(e,t)=>{Qt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>ei(e,n)},flatten:{value:n=>Xo(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Fe,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Fe,2)}},isEmpty:{get(){return e.issues.length===0}}})},O=l("ZodError",oc,{Parent:Error}),ic=Ve(O),sc=Ge(O),ac=we(O),cc=ke(O),uc=ri(O),lc=oi(O),dc=ii(O),fc=si(O),pc=ai(O),gc=ci(O),hc=ui(O),mc=li(O),bn=new WeakMap;function $e(e,t,n){const r=Object.getPrototypeOf(e);let o=bn.get(r);if(o||(o=new Set,bn.set(r,o)),!o.has(t)){o.add(t);for(const i in n){const s=n[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){const a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var T=l("ZodType",(e,t)=>(A.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Te(e,"input"),output:Te(e,"output")}}),e.toJSONSchema=Pa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>ic(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>ac(e,n,r),e.parseAsync=async(n,r)=>sc(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>cc(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>uc(e,n,r),e.decode=(n,r)=>lc(e,n,r),e.encodeAsync=async(n,r)=>dc(e,n,r),e.decodeAsync=async(n,r)=>fc(e,n,r),e.safeEncode=(n,r)=>pc(e,n,r),e.safeDecode=(n,r)=>gc(e,n,r),e.safeEncodeAsync=async(n,r)=>hc(e,n,r),e.safeDecodeAsync=async(n,r)=>mc(e,n,r),$e(e,"ZodType",{check(...n){const r=this.def;return this.clone(U(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return B(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(au(n,r))},superRefine(n,r){return this.check(cu(n,r))},overwrite(n){return this.check(ee(n))},optional(){return An(this)},exactOptional(){return Wc(this)},nullable(){return Tn(this)},nullish(){return An(Tn(this))},nonoptional(n){return eu(this,n)},array(){return Sn(this)},or(n){return zn([this,n])},and(n){return Fc(this,n)},transform(n){return In(this,Jc(n))},default(n){return Kc(this,n)},prefault(n){return Xc(this,n)},catch(n){return nu(this,n)},pipe(n){return In(this,n)},readonly(){return iu(this)},describe(n){const r=this.clone();return le.add(r,{description:n}),r},meta(...n){if(n.length===0)return le.get(this);const r=this.clone();return le.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return le.get(e)?.description},configurable:!0}),e)),wn=l("_ZodString",(e,t)=>{Ke.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Ca(e,r,o,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,$e(e,"_ZodString",{regex(...r){return this.check(ha(...r))},includes(...r){return this.check(_a(...r))},startsWith(...r){return this.check(va(...r))},endsWith(...r){return this.check(ba(...r))},min(...r){return this.check(Ae(...r))},max(...r){return this.check(gn(...r))},length(...r){return this.check(hn(...r))},nonempty(...r){return this.check(Ae(1,...r))},lowercase(r){return this.check(ma(r))},uppercase(r){return this.check(ya(r))},trim(){return this.check(ka())},normalize(...r){return this.check(wa(...r))},toLowerCase(){return this.check(Sa())},toUpperCase(){return this.check(za())},slugify(){return this.check(Ea())}})}),yc=l("ZodString",(e,t)=>{Ke.init(e,t),wn.init(e,t),e.email=n=>e.check(Us(_c,n)),e.url=n=>e.check(Js(vc,n)),e.jwt=n=>e.check(aa(Zc,n)),e.emoji=n=>e.check(Qs(bc,n)),e.guid=n=>e.check(pn(kn,n)),e.uuid=n=>e.check(Bs(Ie,n)),e.uuidv4=n=>e.check(Ms(Ie,n)),e.uuidv6=n=>e.check(Fs(Ie,n)),e.uuidv7=n=>e.check(Hs(Ie,n)),e.nanoid=n=>e.check(Ws(wc,n)),e.guid=n=>e.check(pn(kn,n)),e.cuid=n=>e.check(Vs(kc,n)),e.cuid2=n=>e.check(Gs(Sc,n)),e.ulid=n=>e.check(Ks(zc,n)),e.base64=n=>e.check(oa(xc,n)),e.base64url=n=>e.check(ia(Cc,n)),e.xid=n=>e.check(Ys(Ec,n)),e.ksuid=n=>e.check(Xs(Ac,n)),e.ipv4=n=>e.check(ea(Tc,n)),e.ipv6=n=>e.check(ta($c,n)),e.cidrv4=n=>e.check(na(Ic,n)),e.cidrv6=n=>e.check(ra(Pc,n)),e.e164=n=>e.check(sa(Oc,n)),e.datetime=n=>e.check(Ka(n)),e.date=n=>e.check(Xa(n)),e.time=n=>e.check(tc(n)),e.duration=n=>e.check(rc(n))});function V(e){return Ds(yc,e)}var z=l("ZodStringFormat",(e,t)=>{S.init(e,t),wn.init(e,t)}),_c=l("ZodEmail",(e,t)=>{Gi.init(e,t),z.init(e,t)}),kn=l("ZodGUID",(e,t)=>{Wi.init(e,t),z.init(e,t)}),Ie=l("ZodUUID",(e,t)=>{Vi.init(e,t),z.init(e,t)}),vc=l("ZodURL",(e,t)=>{Ki.init(e,t),z.init(e,t)}),bc=l("ZodEmoji",(e,t)=>{Yi.init(e,t),z.init(e,t)}),wc=l("ZodNanoID",(e,t)=>{Xi.init(e,t),z.init(e,t)}),kc=l("ZodCUID",(e,t)=>{es.init(e,t),z.init(e,t)}),Sc=l("ZodCUID2",(e,t)=>{ts.init(e,t),z.init(e,t)}),zc=l("ZodULID",(e,t)=>{ns.init(e,t),z.init(e,t)}),Ec=l("ZodXID",(e,t)=>{rs.init(e,t),z.init(e,t)}),Ac=l("ZodKSUID",(e,t)=>{os.init(e,t),z.init(e,t)}),Tc=l("ZodIPv4",(e,t)=>{us.init(e,t),z.init(e,t)}),$c=l("ZodIPv6",(e,t)=>{ls.init(e,t),z.init(e,t)}),Ic=l("ZodCIDRv4",(e,t)=>{ds.init(e,t),z.init(e,t)}),Pc=l("ZodCIDRv6",(e,t)=>{fs.init(e,t),z.init(e,t)}),xc=l("ZodBase64",(e,t)=>{ps.init(e,t),z.init(e,t)}),Cc=l("ZodBase64URL",(e,t)=>{hs.init(e,t),z.init(e,t)}),Oc=l("ZodE164",(e,t)=>{ms.init(e,t),z.init(e,t)}),Zc=l("ZodJWT",(e,t)=>{_s.init(e,t),z.init(e,t)}),Rc=l("ZodBoolean",(e,t)=>{vs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Oa(e,n,r,o)});function Lc(e){return fa(Rc,e)}var Nc=l("ZodUnknown",(e,t)=>{bs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ra(e,n,r,o)});function Xe(){return pa(Nc)}var jc=l("ZodNever",(e,t)=>{ws.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Za(e,n,r,o)});function qc(e){return ga(jc,e)}var Dc=l("ZodArray",(e,t)=>{ks.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qa(e,n,r,o),e.element=t.element,$e(e,"ZodArray",{min(n,r){return this.check(Ae(n,r))},nonempty(n){return this.check(Ae(1,n))},max(n,r){return this.check(gn(n,r))},length(n,r){return this.check(hn(n,r))},unwrap(){return this.element}})});function Sn(e,t){return Aa(Dc,e,t)}var Uc=l("ZodObject",(e,t)=>{zs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Da(e,n,r,o),b(e,"shape",()=>t.shape),$e(e,"ZodObject",{keyof(){return tt(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Xe()})},loose(){return this.clone({...this._zod.def,catchall:Xe()})},strict(){return this.clone({...this._zod.def,catchall:qc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Qo(this,n)},safeExtend(n){return Wo(this,n)},merge(n){return Vo(this,n)},pick(n){return Ho(this,n)},omit(n){return Jo(this,n)},partial(...n){return Go(En,this,n[0])},required(...n){return Ko($n,this,n[0])}})});function de(e,t){return new Uc({type:"object",shape:e??{},...y(t)})}var Bc=l("ZodUnion",(e,t)=>{Es.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ua(e,n,r,o),e.options=t.options});function zn(e,t){return new Bc({type:"union",options:e,...y(t)})}var Mc=l("ZodIntersection",(e,t)=>{As.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ba(e,n,r,o)});function Fc(e,t){return new Mc({type:"intersection",left:e,right:t})}var et=l("ZodEnum",(e,t)=>{Ts.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,i)=>La(e,r,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new et({...t,checks:[],...y(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new et({...t,checks:[],...y(o),entries:i})}});function tt(e,t){return new et({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e,...y(t)})}var Hc=l("ZodTransform",(e,t)=>{$s.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ja(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new qt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(ue(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(ue(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function Jc(e){return new Hc({type:"transform",transform:e})}var En=l("ZodOptional",(e,t)=>{an.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function An(e){return new En({type:"optional",innerType:e})}var Qc=l("ZodExactOptional",(e,t)=>{Is.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Wc(e){return new Qc({type:"optional",innerType:e})}var Vc=l("ZodNullable",(e,t)=>{Ps.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ma(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Tn(e){return new Vc({type:"nullable",innerType:e})}var Gc=l("ZodDefault",(e,t)=>{xs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ha(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kc(e,t){return new Gc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ft(t)}})}var Yc=l("ZodPrefault",(e,t)=>{Cs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ja(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Xc(e,t){return new Yc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ft(t)}})}var $n=l("ZodNonOptional",(e,t)=>{Os.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function eu(e,t){return new $n({type:"nonoptional",innerType:e,...y(t)})}var tu=l("ZodCatch",(e,t)=>{Zs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nu(e,t){return new tu({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var ru=l("ZodPipe",(e,t)=>{Rs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wa(e,n,r,o),e.in=t.in,e.out=t.out});function In(e,t){return new ru({type:"pipe",in:e,out:t})}var ou=l("ZodReadonly",(e,t)=>{Ls.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Va(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function iu(e){return new ou({type:"readonly",innerType:e})}var su=l("ZodCustom",(e,t)=>{Ns.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Na(e,n,r,o)});function au(e,t={}){return Ta(su,e,t)}function cu(e,t){return $a(e,t)}var uu=de({title:V(),type:V(),payload:Xe().optional()}),lu=de({label:V(),action:uu,variant:tt(["primary","outline","ghost"]).optional()}),du=de({orientation:tt(["horizontal","vertical"]).optional(),wrap:Lc().optional()}),fu=de({placeholder:zn([V(),Sn(V())]).optional(),ctaLabel:V().optional()}),pu=de({text:V()}),gu={components:{ActionButton:{schema:lu,description:"A single clickable QNA action button."},ButtonRow:{schema:du,description:"Container for a group of QNA action buttons."},TextInput:{schema:fu,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:pu,description:"A heading displayed above the QNA button group."}}};M.GengageQNA=Nt,M.createDefaultQnaUISpecRegistry=Pt,M.createQNAWidget=Do,M.defaultQnaUnknownUISpecRenderer=Me,M.qnaCatalog=gu,M.renderQnaUISpec=xt})(this.Gengage=this.Gengage||{});
111
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1&&e.reused==="ref"){i(s);continue}}}function yn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,f={...u},g=c.ref;if(c.ref=null,g){r(g);const p=e.seen.get(g),h=p.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Object.assign(u,h),Object.assign(u,f),a._zod.parent===g)for(const m in u)m==="$ref"||m==="allOf"||m in f||delete u[m];if(h.$ref&&p.def)for(const m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}const d=a._zod.parent;if(d&&d!==g){r(d);const p=e.seen.get(d);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(const h in u)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(u[h])===JSON.stringify(p.def[h])&&delete u[h]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())r(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const s=e.external?.defs??{};for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Te(t,"input",e.processors),output:Te(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function C(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return C(r.element,n);if(r.type==="set")return C(r.valueType,n);if(r.type==="lazy")return C(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return C(r.innerType,n);if(r.type==="intersection")return C(r.left,n)||C(r.right,n);if(r.type==="record"||r.type==="map")return C(r.keyType,n)||C(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:C(r.in,n)||C(r.out,n);if(r.type==="object"){for(const o in r.shape)if(C(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(C(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(C(o,n))return!0;return!!(r.rest&&C(r.rest,n))}return!1}var Ca=(e,t={})=>n=>{const r=hn({...n,processors:t});return P(e,r),mn(r,e),yn(r,e)},Te=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=hn({...o??{},target:i,io:t,processors:n});return P(e,s),mn(s,e),yn(s,e)},Oa={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Za=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=Oa[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const f=[...c];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},Ra=(e,t,n,r)=>{n.type="boolean"},La=(e,t,n,r)=>{n.not={}},Na=(e,t,n,r)=>{},ja=(e,t,n,r)=>{const o=e._zod.def,i=qt(o.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},qa=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Da=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ua=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=P(i.element,t,{...r,path:[...r.path,"items"]})},Ba=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=P(s[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{const f=i.shape[u]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=P(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Ma=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>P(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},Fa=(e,t,n,r)=>{const o=e._zod.def,i=P(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=P(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1;n.allOf=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]]},Ha=(e,t,n,r)=>{const o=e._zod.def,i=P(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Ja=(e,t,n,r)=>{const o=e._zod.def;P(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Qa=(e,t,n,r)=>{const o=e._zod.def;P(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Wa=(e,t,n,r)=>{const o=e._zod.def;P(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Va=(e,t,n,r)=>{const o=e._zod.def;P(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},Ga=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;P(s,t,r);const a=t.seen.get(e);a.ref=s},Ka=(e,t,n,r)=>{const o=e._zod.def;P(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},_n=(e,t,n,r)=>{const o=e._zod.def;P(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Ya=l("ZodISODateTime",(e,t)=>{as.init(e,t),A.init(e,t)});function Xa(e){return la(Ya,e)}var ec=l("ZodISODate",(e,t)=>{cs.init(e,t),A.init(e,t)});function tc(e){return da(ec,e)}var nc=l("ZodISOTime",(e,t)=>{us.init(e,t),A.init(e,t)});function rc(e){return fa(nc,e)}var oc=l("ZodISODuration",(e,t)=>{ls.init(e,t),A.init(e,t)});function ic(e){return pa(oc,e)}var sc=(e,t)=>{Jt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>ni(e,n)},flatten:{value:n=>ti(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Fe,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Fe,2)}},isEmpty:{get(){return e.issues.length===0}}})},O=l("ZodError",sc,{Parent:Error}),ac=Ve(O),cc=Ge(O),uc=we(O),lc=ke(O),dc=ii(O),fc=si(O),pc=ai(O),gc=ci(O),hc=ui(O),mc=li(O),yc=di(O),_c=fi(O),vn=new WeakMap;function $e(e,t,n){const r=Object.getPrototypeOf(e);let o=vn.get(r);if(o||(o=new Set,vn.set(r,o)),!o.has(t)){o.add(t);for(const i in n){const s=n[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){const a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var I=l("ZodType",(e,t)=>($.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Te(e,"input"),output:Te(e,"output")}}),e.toJSONSchema=Ca(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>ac(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>uc(e,n,r),e.parseAsync=async(n,r)=>cc(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>lc(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>dc(e,n,r),e.decode=(n,r)=>fc(e,n,r),e.encodeAsync=async(n,r)=>pc(e,n,r),e.decodeAsync=async(n,r)=>gc(e,n,r),e.safeEncode=(n,r)=>hc(e,n,r),e.safeDecode=(n,r)=>mc(e,n,r),e.safeEncodeAsync=async(n,r)=>yc(e,n,r),e.safeDecodeAsync=async(n,r)=>_c(e,n,r),$e(e,"ZodType",{check(...n){const r=this.def;return this.clone(U(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return B(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(uu(n,r))},superRefine(n,r){return this.check(lu(n,r))},overwrite(n){return this.check(te(n))},optional(){return En(this)},exactOptional(){return Gc(this)},nullable(){return An(this)},nullish(){return En(An(this))},nonoptional(n){return nu(this,n)},array(){return kn(this)},or(n){return Sn([this,n])},and(n){return Jc(this,n)},transform(n){return $n(this,Wc(n))},default(n){return Xc(this,n)},prefault(n){return tu(this,n)},catch(n){return ou(this,n)},pipe(n){return $n(this,n)},readonly(){return au(this)},describe(n){const r=this.clone();return le.add(r,{description:n}),r},meta(...n){if(n.length===0)return le.get(this);const r=this.clone();return le.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return le.get(e)?.description},configurable:!0}),e)),bn=l("_ZodString",(e,t)=>{Ke.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Za(e,r,o,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,$e(e,"_ZodString",{regex(...r){return this.check(ya(...r))},includes(...r){return this.check(ba(...r))},startsWith(...r){return this.check(wa(...r))},endsWith(...r){return this.check(ka(...r))},min(...r){return this.check(Ae(...r))},max(...r){return this.check(pn(...r))},length(...r){return this.check(gn(...r))},nonempty(...r){return this.check(Ae(1,...r))},lowercase(r){return this.check(_a(r))},uppercase(r){return this.check(va(r))},trim(){return this.check(za())},normalize(...r){return this.check(Sa(...r))},toLowerCase(){return this.check(Ea())},toUpperCase(){return this.check(Aa())},slugify(){return this.check(Ta())}})}),vc=l("ZodString",(e,t)=>{Ke.init(e,t),bn.init(e,t),e.email=n=>e.check(Ms(bc,n)),e.url=n=>e.check(Ws(wc,n)),e.jwt=n=>e.check(ua(Lc,n)),e.emoji=n=>e.check(Vs(kc,n)),e.guid=n=>e.check(fn(wn,n)),e.uuid=n=>e.check(Fs(Ie,n)),e.uuidv4=n=>e.check(Hs(Ie,n)),e.uuidv6=n=>e.check(Js(Ie,n)),e.uuidv7=n=>e.check(Qs(Ie,n)),e.nanoid=n=>e.check(Gs(Sc,n)),e.guid=n=>e.check(fn(wn,n)),e.cuid=n=>e.check(Ks(zc,n)),e.cuid2=n=>e.check(Ys(Ec,n)),e.ulid=n=>e.check(Xs(Ac,n)),e.base64=n=>e.check(sa(Oc,n)),e.base64url=n=>e.check(aa(Zc,n)),e.xid=n=>e.check(ea(Tc,n)),e.ksuid=n=>e.check(ta($c,n)),e.ipv4=n=>e.check(na(Ic,n)),e.ipv6=n=>e.check(ra(Pc,n)),e.cidrv4=n=>e.check(oa(xc,n)),e.cidrv6=n=>e.check(ia(Cc,n)),e.e164=n=>e.check(ca(Rc,n)),e.datetime=n=>e.check(Xa(n)),e.date=n=>e.check(tc(n)),e.time=n=>e.check(rc(n)),e.duration=n=>e.check(ic(n))});function G(e){return Bs(vc,e)}var A=l("ZodStringFormat",(e,t)=>{E.init(e,t),bn.init(e,t)}),bc=l("ZodEmail",(e,t)=>{Yi.init(e,t),A.init(e,t)}),wn=l("ZodGUID",(e,t)=>{Gi.init(e,t),A.init(e,t)}),Ie=l("ZodUUID",(e,t)=>{Ki.init(e,t),A.init(e,t)}),wc=l("ZodURL",(e,t)=>{Xi.init(e,t),A.init(e,t)}),kc=l("ZodEmoji",(e,t)=>{es.init(e,t),A.init(e,t)}),Sc=l("ZodNanoID",(e,t)=>{ts.init(e,t),A.init(e,t)}),zc=l("ZodCUID",(e,t)=>{ns.init(e,t),A.init(e,t)}),Ec=l("ZodCUID2",(e,t)=>{rs.init(e,t),A.init(e,t)}),Ac=l("ZodULID",(e,t)=>{os.init(e,t),A.init(e,t)}),Tc=l("ZodXID",(e,t)=>{is.init(e,t),A.init(e,t)}),$c=l("ZodKSUID",(e,t)=>{ss.init(e,t),A.init(e,t)}),Ic=l("ZodIPv4",(e,t)=>{ds.init(e,t),A.init(e,t)}),Pc=l("ZodIPv6",(e,t)=>{fs.init(e,t),A.init(e,t)}),xc=l("ZodCIDRv4",(e,t)=>{ps.init(e,t),A.init(e,t)}),Cc=l("ZodCIDRv6",(e,t)=>{gs.init(e,t),A.init(e,t)}),Oc=l("ZodBase64",(e,t)=>{hs.init(e,t),A.init(e,t)}),Zc=l("ZodBase64URL",(e,t)=>{ys.init(e,t),A.init(e,t)}),Rc=l("ZodE164",(e,t)=>{_s.init(e,t),A.init(e,t)}),Lc=l("ZodJWT",(e,t)=>{bs.init(e,t),A.init(e,t)}),Nc=l("ZodBoolean",(e,t)=>{ws.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ra(e,n,r,o)});function jc(e){return ga(Nc,e)}var qc=l("ZodUnknown",(e,t)=>{ks.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Na(e,n,r,o)});function Xe(){return ha(qc)}var Dc=l("ZodNever",(e,t)=>{Ss.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>La(e,n,r,o)});function Uc(e){return ma(Dc,e)}var Bc=l("ZodArray",(e,t)=>{zs.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ua(e,n,r,o),e.element=t.element,$e(e,"ZodArray",{min(n,r){return this.check(Ae(n,r))},nonempty(n){return this.check(Ae(1,n))},max(n,r){return this.check(pn(n,r))},length(n,r){return this.check(gn(n,r))},unwrap(){return this.element}})});function kn(e,t){return $a(Bc,e,t)}var Mc=l("ZodObject",(e,t)=>{As.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ba(e,n,r,o),k(e,"shape",()=>t.shape),$e(e,"ZodObject",{keyof(){return tt(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Xe()})},loose(){return this.clone({...this._zod.def,catchall:Xe()})},strict(){return this.clone({...this._zod.def,catchall:Uc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Vo(this,n)},safeExtend(n){return Go(this,n)},merge(n){return Ko(this,n)},pick(n){return Qo(this,n)},omit(n){return Wo(this,n)},partial(...n){return Yo(zn,this,n[0])},required(...n){return Xo(Tn,this,n[0])}})});function de(e,t){return new Mc({type:"object",shape:e??{},...y(t)})}var Fc=l("ZodUnion",(e,t)=>{Ts.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ma(e,n,r,o),e.options=t.options});function Sn(e,t){return new Fc({type:"union",options:e,...y(t)})}var Hc=l("ZodIntersection",(e,t)=>{$s.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fa(e,n,r,o)});function Jc(e,t){return new Hc({type:"intersection",left:e,right:t})}var et=l("ZodEnum",(e,t)=>{Is.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ja(e,r,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new et({...t,checks:[],...y(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new et({...t,checks:[],...y(o),entries:i})}});function tt(e,t){return new et({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e,...y(t)})}var Qc=l("ZodTransform",(e,t)=>{Ps.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Da(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new jt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(ue(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(ue(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function Wc(e){return new Qc({type:"transform",transform:e})}var zn=l("ZodOptional",(e,t)=>{sn.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_n(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function En(e){return new zn({type:"optional",innerType:e})}var Vc=l("ZodExactOptional",(e,t)=>{xs.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_n(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Gc(e){return new Vc({type:"optional",innerType:e})}var Kc=l("ZodNullable",(e,t)=>{Cs.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ha(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function An(e){return new Kc({type:"nullable",innerType:e})}var Yc=l("ZodDefault",(e,t)=>{Os.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xc(e,t){return new Yc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Mt(t)}})}var eu=l("ZodPrefault",(e,t)=>{Zs.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function tu(e,t){return new eu({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Mt(t)}})}var Tn=l("ZodNonOptional",(e,t)=>{Rs.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ja(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function nu(e,t){return new Tn({type:"nonoptional",innerType:e,...y(t)})}var ru=l("ZodCatch",(e,t)=>{Ls.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Va(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ou(e,t){return new ru({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var iu=l("ZodPipe",(e,t)=>{Ns.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ga(e,n,r,o),e.in=t.in,e.out=t.out});function $n(e,t){return new iu({type:"pipe",in:e,out:t})}var su=l("ZodReadonly",(e,t)=>{js.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ka(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function au(e){return new su({type:"readonly",innerType:e})}var cu=l("ZodCustom",(e,t)=>{qs.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qa(e,n,r,o)});function uu(e,t={}){return Ia(cu,e,t)}function lu(e,t){return Pa(e,t)}var du=de({title:G(),type:G(),payload:Xe().optional()}),fu=de({label:G(),action:du,variant:tt(["primary","outline","ghost"]).optional()}),pu=de({orientation:tt(["horizontal","vertical"]).optional(),wrap:jc().optional()}),gu=de({placeholder:Sn([G(),kn(G())]).optional(),ctaLabel:G().optional()}),hu=de({text:G()}),mu={components:{ActionButton:{schema:fu,description:"A single clickable QNA action button."},ButtonRow:{schema:pu,description:"Container for a group of QNA action buttons."},TextInput:{schema:gu,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:hu,description:"A heading displayed above the QNA button group."}}};M.GengageQNA=Lt,M.createDefaultQnaUISpecRegistry=Pt,M.createQNAWidget=Bo,M.defaultQnaUnknownUISpecRenderer=Me,M.qnaCatalog=mu,M.renderQnaUISpec=xt})(this.Gengage=this.Gengage||{});