@gengage/assistant-fe 0.3.41 → 0.4.1
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.
- package/dist/chat/catalog.d.ts +10 -0
- package/dist/chat/types.d.ts +6 -0
- package/dist/{chat-CmGV3i0P.js → chat-C9l4oBJA.js} +363 -358
- package/dist/chat.iife.js +9 -9
- package/dist/chat.js +1 -1
- package/dist/common/client.d.ts +6 -1
- package/dist/common/config-schema.d.ts +1 -1
- package/dist/common/overlay.d.ts +2 -0
- package/dist/{common-ouVC4QMB.js → common-CiTC1BDg.js} +113 -102
- package/dist/common.js +4 -4
- package/dist/index.js +6 -6
- package/dist/{native-webview-Blw4xXPu.js → native-webview-FnIiDil0.js} +48 -49
- package/dist/native.iife.js +8 -8
- package/dist/native.js +1 -1
- package/dist/{qna-DrlYm1d8.js → qna-CQugVOHy.js} +1 -1
- package/dist/qna.iife.js +7 -7
- package/dist/qna.js +1 -1
- package/dist/{schemas-DnAo0x7A.js → schemas-JFGRVTVz.js} +3 -1
- package/dist/{simrel-BjNqBbmw.js → simrel-DjzpRZmZ.js} +1 -1
- package/dist/simrel.iife.js +6 -6
- package/dist/simrel.js +1 -1
- package/package.json +2 -2
package/dist/simrel.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(J){Object.defineProperty(J,Symbol.toStringTag,{value:"Module"});var Ir=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const r=document.createElement("div");for(const n of e.children){const o=t(n);o&&r.appendChild(o)}return r};function $r(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const r=e.unknownRenderer??Ir,n=i=>{const a=e.spec.elements[i];if(!a)return null;const s=e.registry[a.type];return s?s({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:n}):r({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:n})},o=n(e.spec.root);return o&&t.appendChild(o),t}function Ar(e,t){if(!t)return e;const r={...e};for(const[n,o]of Object.entries(t))o&&(r[n]=o);return r}function Pr(e,t){const r={event_name:"stream.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{endpoint:t.endpoint,request_id:t.request_id}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),t.widget!==void 0&&(r.widget=t.widget),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function He(e,t){const r={event_name:"stream.done",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,latency_ms:t.latency_ms,chunk_count:t.chunk_count}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),t.widget!==void 0&&(r.widget=t.widget),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Nr(e,t){const r={event_name:"stream.error",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,error_code:t.error_code,error_message:t.error_message}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),t.widget!==void 0&&(r.widget=t.widget),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Or(e,t){const r={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Ke(e,t){const r={event_name:"widget.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.widget,payload:{message_count:t.message_count,history_ref:t.history_ref,redaction_level:t.redaction_level}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Zr(e,t){const r={event_name:"basket.add",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items,sku:t.sku}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Rr(e,t){const r={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function xr(e,t){const r={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}var Lr=new Set(["p","br","a","strong","b","em","i","u","ul","ol","li","h1","h2","h3","h4","h5","h6","span","div","table","thead","tbody","tr","th","td","hr","code","pre","blockquote","img","sup","sub"]),Dr=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta","template","noscript"]),Ye={"*":new Set(["class"]),a:new Set(["href","target","rel"]),img:new Set(["src","alt","width","height"]),div:new Set(["style"]),span:new Set(["style"]),p:new Set(["style"])};function jr(e){return/^\s*javascript\s*:/i.test(e)}var Ur=new Set(["color","background-color","font-size","font-weight","font-style","font-family","text-align","text-decoration","line-height","letter-spacing","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","border","border-top","border-right","border-bottom","border-left","border-radius","border-color","border-width","border-style","width","max-width","min-width","height","max-height","min-height","display","vertical-align","white-space","word-break","overflow","opacity","visibility","list-style","list-style-type","text-transform","text-indent","text-overflow","box-sizing","flex","flex-direction","flex-wrap","justify-content","align-items","gap"]),Mr=/url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;function Fr(e){const t=[];for(const r of e.split(";")){const n=r.trim();if(!n)continue;const o=n.indexOf(":");if(o===-1)continue;const i=n.slice(0,o).trim().toLowerCase(),a=n.slice(o+1).trim();Ur.has(i)&&(Mr.test(a)||t.push(n))}return t.join("; ")}function Ee(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const r=e,n=r.tagName.toLowerCase();if(Dr.has(n)){r.parentNode?.removeChild(r);return}if(!Lr.has(n)){const c=Array.from(r.childNodes);for(const u of c)t.insertBefore(u,r);t.removeChild(r);for(const u of c)Ee(u,t);return}const o=Ye["*"]??new Set,i=Ye[n]??new Set,a=Array.from(r.attributes);for(const c of a){const u=c.name.toLowerCase();if(!o.has(u)&&!i.has(u)){r.removeAttribute(c.name);continue}if(jr(c.value)){r.removeAttribute(c.name);continue}if(u==="style"){const l=Fr(c.value);l?r.setAttribute("style",l):r.removeAttribute("style");continue}}if(n==="a"){const c=r.getAttribute("href");if(c!==null){const u=c.trim().toLowerCase();!u.startsWith("http://")&&!u.startsWith("https://")&&!u.startsWith("mailto:")&&r.removeAttribute("href")}r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer")}if(n==="img"){const c=r.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||r.removeAttribute("src"))}const s=Array.from(r.childNodes);for(const c of s)Ee(c,r)}var Gr=["http:","https:"];function qr(e){try{return Gr.includes(new URL(e).protocol)}catch{return!1}}function Jr(e){if(!e)return"";const t=new DOMParser().parseFromString(e,"text/html").body,r=Array.from(t.childNodes);for(const n of r)Ee(n,t);return t.innerHTML}function Br(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function Ce(e,t){const r={event:e,...t};Br()&&window.dataLayer.push(r)}function Vr(e){Ce("gengage-on-init",{gengage_widget:e})}function Qe(e){Ce("gengage-show",{gengage_widget:e})}function Wr(e,t){Ce("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function re(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Xe(e,t){const r=n=>{t(n.detail)};return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}function Hr(){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 Kr(e){return{sessionId:e?.sessionId??Hr(),...e}}var et={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"12px","--gengage-simrel-card-radius":"0.75rem","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--surface-card-muted":"#f8fafc","--text-secondary":"#4b5563","--text-muted":"#6b7280","--border-default":"rgba(17, 24, 39, 0.10)"};function Yr(e){return e?{...et,...e}:{...et}}var L={primaryColor:"#b7102a",primaryForeground:"#ffffff",backgroundColor:"#ffffff",foregroundColor:"#111827",borderRadius:"0.75rem",fontFamily:'"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px",zIndex:"1000","--glov-chatbot-width":"420px","--glov-left-spacing":"260px","--chatbot-padding":"16px","--root-wrapper-background-color":"#f8f9fa","--root-wrapper-border-color":"#edeeef","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem","--client-primary":"#b7102a","--client-primary-hover":"color-mix(in srgb, #b7102a 88%, black 12%)","--client-primary-active":"color-mix(in srgb, #b7102a 78%, black 22%)","--client-primary-subtle":"color-mix(in srgb, #b7102a 12%, white)","--client-primary-soft":"color-mix(in srgb, #b7102a 20%, white)","--client-on-primary":"#ffffff","--client-focus-ring":"color-mix(in srgb, #b7102a 32%, transparent)","--surface-page":"#f6f7fb","--surface-shell":"#10131a","--surface-card":"#ffffff","--surface-card-muted":"#f8fafc","--surface-card-soft":"#f8fafc","--surface-elevated":"#ffffff","--surface-input":"#ffffff","--surface-overlay":"rgba(16, 19, 26, 0.52)","--text-primary":"#111827","--text-secondary":"#4b5563","--text-muted":"#6b7280","--text-inverse":"#f9fafb","--border-subtle":"rgba(17, 24, 39, 0.06)","--border-default":"rgba(17, 24, 39, 0.10)","--border-strong":"rgba(17, 24, 39, 0.18)","--shadow-1":"0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)","--shadow-2":"0 4px 12px rgba(16, 24, 40, 0.08)","--shadow-3":"0 10px 24px rgba(16, 24, 40, 0.12)","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--success":"#16a34a","--warning":"#d97706","--error":"#dc2626","--info":"#2563eb","--rating":"#f5b301","--ai-accent-start":"#0b24d6","--ai-accent-end":"#f768f2","--ai-accent-soft":"linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"},U="gengage-global-toast-root",tt="gengage-global-toast-style",ze="gengage-global-toast-root--visible",Qr=4200,Xr=1500,en=15e3,tn=["--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"],rt=!1,B=null,rn=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i];function nt(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function nn(e){if(typeof navigator<"u"&&navigator.onLine===!1)return!0;const t=e instanceof Error?e.message.trim():"";return t?rn.some(r=>r.test(t)):!1}function on(e,t){return nn(t)?nt(e)?"Bağlantı sorunu oluştu. Lütfen tekrar deneyin.":"Connection issue. Please try again.":nt(e)?"Bir hata oluştu. Lütfen tekrar deneyin.":"Something went wrong. Please try again."}function an(){rt||typeof window>"u"||typeof document>"u"||(rt=!0,Xe("gengage:global:error",e=>{Te(e)}))}function Te(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;ln();const r=cn();un(r),r.innerHTML="";const n=document.createElement("section");n.className="gengage-global-toast gengage-global-toast--error",n.setAttribute("role","status"),n.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="gengage-global-toast-title",o.textContent=sn(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,n.appendChild(o),n.appendChild(i),r.appendChild(n),r.classList.add(ze),B&&(clearTimeout(B),B=null),e.sticky!==!0&&(B=setTimeout(()=>{ot()},dn(e.durationMs)))}function ot(){if(typeof document>"u")return;const e=document.getElementById(U);e&&(e.classList.remove(ze),e.innerHTML="",B&&(clearTimeout(B),B=null))}function sn(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function cn(){const e=document.getElementById(U);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=U,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function un(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 r=window.getComputedStyle(t);for(const n of tn){const o=r.getPropertyValue(n).trim();o?e.style.setProperty(n,o):e.style.removeProperty(n)}}function dn(e){return typeof e!="number"||!Number.isFinite(e)?Qr:Math.min(en,Math.max(Xr,Math.round(e)))}function ln(){if(document.getElementById(tt))return;const e=document.createElement("style");e.id=tt;const t=L["--surface-card"]??L.backgroundColor??"#ffffff",r=L["--text-primary"]??L.foregroundColor??"#111827",n=L["--border-default"]??"rgba(17, 24, 39, 0.10)",o=L["--error"]??"#dc2626",i=L["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",a=L["--radius-card"]??"16px",s=L["--text-muted"]??"#6b7280";e.textContent=`
|
|
1
|
+
(function(J){Object.defineProperty(J,Symbol.toStringTag,{value:"Module"});var Ir=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const r=document.createElement("div");for(const n of e.children){const o=t(n);o&&r.appendChild(o)}return r};function $r(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const r=e.unknownRenderer??Ir,n=i=>{const a=e.spec.elements[i];if(!a)return null;const s=e.registry[a.type];return s?s({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:n}):r({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:n})},o=n(e.spec.root);return o&&t.appendChild(o),t}function Ar(e,t){if(!t)return e;const r={...e};for(const[n,o]of Object.entries(t))o&&(r[n]=o);return r}function Pr(e,t){const r={event_name:"stream.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{endpoint:t.endpoint,request_id:t.request_id}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),t.widget!==void 0&&(r.widget=t.widget),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function He(e,t){const r={event_name:"stream.done",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,latency_ms:t.latency_ms,chunk_count:t.chunk_count}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),t.widget!==void 0&&(r.widget=t.widget),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Nr(e,t){const r={event_name:"stream.error",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,error_code:t.error_code,error_message:t.error_message}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),t.widget!==void 0&&(r.widget=t.widget),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Or(e,t){const r={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Ke(e,t){const r={event_name:"widget.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.widget,payload:{message_count:t.message_count,history_ref:t.history_ref,redaction_level:t.redaction_level}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Zr(e,t){const r={event_name:"basket.add",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items,sku:t.sku}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function Rr(e,t){const r={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}function xr(e,t){const r={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(r.view_id=e.view_id),e.user_id!==void 0&&(r.user_id=e.user_id),e.page_type!==void 0&&(r.page_type=e.page_type),e.sku!==void 0&&(r.sku=e.sku),r}var Lr=new Set(["p","br","a","strong","b","em","i","u","ul","ol","li","h1","h2","h3","h4","h5","h6","span","div","table","thead","tbody","tr","th","td","hr","code","pre","blockquote","img","sup","sub"]),Dr=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta","template","noscript"]),Ye={"*":new Set(["class"]),a:new Set(["href","target","rel"]),img:new Set(["src","alt","width","height"]),div:new Set(["style"]),span:new Set(["style"]),p:new Set(["style"])};function jr(e){return/^\s*javascript\s*:/i.test(e)}var Ur=new Set(["color","background-color","font-size","font-weight","font-style","font-family","text-align","text-decoration","line-height","letter-spacing","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","border","border-top","border-right","border-bottom","border-left","border-radius","border-color","border-width","border-style","width","max-width","min-width","height","max-height","min-height","display","vertical-align","white-space","word-break","overflow","opacity","visibility","list-style","list-style-type","text-transform","text-indent","text-overflow","box-sizing","flex","flex-direction","flex-wrap","justify-content","align-items","gap"]),Mr=/url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;function Fr(e){const t=[];for(const r of e.split(";")){const n=r.trim();if(!n)continue;const o=n.indexOf(":");if(o===-1)continue;const i=n.slice(0,o).trim().toLowerCase(),a=n.slice(o+1).trim();Ur.has(i)&&(Mr.test(a)||t.push(n))}return t.join("; ")}function Ee(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const r=e,n=r.tagName.toLowerCase();if(Dr.has(n)){r.parentNode?.removeChild(r);return}if(!Lr.has(n)){const c=Array.from(r.childNodes);for(const u of c)t.insertBefore(u,r);t.removeChild(r);for(const u of c)Ee(u,t);return}const o=Ye["*"]??new Set,i=Ye[n]??new Set,a=Array.from(r.attributes);for(const c of a){const u=c.name.toLowerCase();if(!o.has(u)&&!i.has(u)){r.removeAttribute(c.name);continue}if(jr(c.value)){r.removeAttribute(c.name);continue}if(u==="style"){const l=Fr(c.value);l?r.setAttribute("style",l):r.removeAttribute("style");continue}}if(n==="a"){const c=r.getAttribute("href");if(c!==null){const u=c.trim().toLowerCase();!u.startsWith("http://")&&!u.startsWith("https://")&&!u.startsWith("mailto:")&&r.removeAttribute("href")}r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer")}if(n==="img"){const c=r.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||r.removeAttribute("src"))}const s=Array.from(r.childNodes);for(const c of s)Ee(c,r)}var qr=["http:","https:"];function Gr(e){try{return qr.includes(new URL(e).protocol)}catch{return!1}}function Jr(e){if(!e)return"";const t=new DOMParser().parseFromString(e,"text/html").body,r=Array.from(t.childNodes);for(const n of r)Ee(n,t);return t.innerHTML}function Br(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function Ce(e,t){const r={event:e,...t};Br()&&window.dataLayer.push(r)}function Vr(e){Ce("gengage-on-init",{gengage_widget:e})}function Qe(e){Ce("gengage-show",{gengage_widget:e})}function Wr(e,t){Ce("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function re(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Xe(e,t){const r=n=>{t(n.detail)};return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}function Hr(){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 Kr(e){return{sessionId:e?.sessionId??Hr(),...e}}var et={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"12px","--gengage-simrel-card-radius":"0.75rem","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--surface-card-muted":"#f8fafc","--text-secondary":"#4b5563","--text-muted":"#6b7280","--border-default":"rgba(17, 24, 39, 0.10)"};function Yr(e){return e?{...et,...e}:{...et}}var L={primaryColor:"#b7102a",primaryForeground:"#ffffff",backgroundColor:"#ffffff",foregroundColor:"#111827",borderRadius:"0.75rem",fontFamily:'"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px",zIndex:"1000","--glov-chatbot-width":"420px","--glov-left-spacing":"260px","--chatbot-padding":"16px","--root-wrapper-background-color":"#f8f9fa","--root-wrapper-border-color":"#edeeef","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem","--client-primary":"#b7102a","--client-primary-hover":"color-mix(in srgb, #b7102a 88%, black 12%)","--client-primary-active":"color-mix(in srgb, #b7102a 78%, black 22%)","--client-primary-subtle":"color-mix(in srgb, #b7102a 12%, white)","--client-primary-soft":"color-mix(in srgb, #b7102a 20%, white)","--client-on-primary":"#ffffff","--client-focus-ring":"color-mix(in srgb, #b7102a 32%, transparent)","--surface-page":"#f6f7fb","--surface-shell":"#10131a","--surface-card":"#ffffff","--surface-card-muted":"#f8fafc","--surface-card-soft":"#f8fafc","--surface-elevated":"#ffffff","--surface-input":"#ffffff","--surface-overlay":"rgba(16, 19, 26, 0.52)","--text-primary":"#111827","--text-secondary":"#4b5563","--text-muted":"#6b7280","--text-inverse":"#f9fafb","--border-subtle":"rgba(17, 24, 39, 0.06)","--border-default":"rgba(17, 24, 39, 0.10)","--border-strong":"rgba(17, 24, 39, 0.18)","--shadow-1":"0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)","--shadow-2":"0 4px 12px rgba(16, 24, 40, 0.08)","--shadow-3":"0 10px 24px rgba(16, 24, 40, 0.12)","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--success":"#16a34a","--warning":"#d97706","--error":"#dc2626","--info":"#2563eb","--rating":"#f5b301","--ai-accent-start":"#0b24d6","--ai-accent-end":"#f768f2","--ai-accent-soft":"linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"},U="gengage-global-toast-root",tt="gengage-global-toast-style",ze="gengage-global-toast-root--visible",Qr=4200,Xr=1500,en=15e3,tn=["--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"],rt=!1,B=null,rn=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i];function nt(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function nn(e){if(typeof navigator<"u"&&navigator.onLine===!1)return!0;const t=e instanceof Error?e.message.trim():"";return t?rn.some(r=>r.test(t)):!1}function on(e,t){return nn(t)?nt(e)?"Bağlantı sorunu oluştu. Lütfen tekrar deneyin.":"Connection issue. Please try again.":nt(e)?"Bir hata oluştu. Lütfen tekrar deneyin.":"Something went wrong. Please try again."}function an(){rt||typeof window>"u"||typeof document>"u"||(rt=!0,Xe("gengage:global:error",e=>{Te(e)}))}function Te(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;ln();const r=cn();un(r),r.innerHTML="";const n=document.createElement("section");n.className="gengage-global-toast gengage-global-toast--error",n.setAttribute("role","status"),n.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="gengage-global-toast-title",o.textContent=sn(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,n.appendChild(o),n.appendChild(i),r.appendChild(n),r.classList.add(ze),B&&(clearTimeout(B),B=null),e.sticky!==!0&&(B=setTimeout(()=>{ot()},dn(e.durationMs)))}function ot(){if(typeof document>"u")return;const e=document.getElementById(U);e&&(e.classList.remove(ze),e.innerHTML="",B&&(clearTimeout(B),B=null))}function sn(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function cn(){const e=document.getElementById(U);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=U,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function un(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 r=window.getComputedStyle(t);for(const n of tn){const o=r.getPropertyValue(n).trim();o?e.style.setProperty(n,o):e.style.removeProperty(n)}}function dn(e){return typeof e!="number"||!Number.isFinite(e)?Qr:Math.min(en,Math.max(Xr,Math.round(e)))}function ln(){if(document.getElementById(tt))return;const e=document.createElement("style");e.id=tt;const t=L["--surface-card"]??L.backgroundColor??"#ffffff",r=L["--text-primary"]??L.foregroundColor??"#111827",n=L["--border-default"]??"rgba(17, 24, 39, 0.10)",o=L["--error"]??"#dc2626",i=L["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",a=L["--radius-card"]??"16px",s=L["--text-muted"]??"#6b7280";e.textContent=`
|
|
2
2
|
#${U} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
top: 16px;
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
transform: translateY(0);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,document.head.appendChild(e)}var ne=null;function
|
|
48
|
-
`);o=m.pop()??"";for(const _ of m)if(lt(_,t))return}if(o.trim()&<(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||r.releaseLock()}t.onDone?.()}var pt=3,zn=(e,t)=>{const r=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!r)return"";const n=t?.stripLeadingStopWords?r.replace(/^(?:daha|için)\s+/i,"").trim():r;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},Ae=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(r=>zn(r,t)).filter(Boolean):[];function Tn(e){const t=(e.display_keywords??[]).flatMap(o=>Ae(o,{stripLeadingStopWords:!0})),r=t.filter((o,i)=>t.indexOf(o)===i);if(r.length>0)return r.slice(0,pt);const n=[...Ae(e.chosen_attribute,{stripLeadingStopWords:!0}),...Ae(e.short_name)];return n.filter((o,i)=>n.indexOf(o)===i).slice(0,pt)}function In(e){return Tn(e).join(" • ")}var $n=["beauty_consulting","watch_expert"];function An(e){return typeof e=="string"&&$n.includes(e)}function gt(e){if(typeof e.type!="string")return null;if(Pn(e))return e;const t=e;switch(t.type){case"outputText":return Nn(t);case"suggestedActions":return On(t);case"productList":return Zn(t);case"productDetails":return Rn(t);case"productDetailsSimilars":return xn(t);case"comparisonTable":return Ln(t);case"context":return Mn(t);case"chatStreamEnd":return Fn();case"loading":return Gn(t);case"panelLoading":return qn(t);case"similarLoading":return Jn(t);case"redirect":return Bn(t);case"error":return Vn(t);case"dummy":return Wn(t);case"launcherAction":return Hn(t);case"text":return Pe(t);case"productItem":return Kn(t);case"text_image":return mt(t);case"quick_qna":return ht(t);case"reviewHighlights":return Yn(t);case"aiProductSuggestions":return eo(t);case"aiProductGroupings":return to(t);case"aiSuggestedSearches":return ro(t);case"prosAndCons":return Qn(t);case"getGroundingReview":return no(t);case"voice":return io(t);case"visitorDataResponse":return Xn(t);case"productListPreview":return oo();case"groupList":return ao(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return so(t);case"launcherContent":return uo(t);case"handoff":return co(t);case"uiSpec":return bo(t);default:return null}}function Pn(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const r=e.widget;if(r!=="chat"&&r!=="qna"&&r!=="simrel")return!1;const n=Z(e.spec);return n?typeof n.root=="string"&&Z(n.elements)!==null:!1}case"action":{const r=Z(e.action);return r!==null&&typeof r.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Nn(e){const t=b(e.payload.text,e.payload.plain_text)??"",r=b(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:r||"Backend returned an error"};const n={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(n.productMentions=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const a=e.payload.conversation_mode;typeof a=="string"&&a&&(n.conversationMode=a);const s=e.payload.render_hint;return typeof s=="string"&&s&&(n.renderHint=s),e.payload.kvkk===!0&&(n.kvkk=!0),n}function On(e){return _t((e.payload.actions??[]).map(t=>{const r=b(t.title)??"",n=D(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(ae),"chat")}function Zn(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(a=>{const s=b(a.style_label);if(!s)return null;const c=b(a.style_mood),u=b(a.image_url??void 0),l=(Array.isArray(a.product_list)?a.product_list:[]).map(f=>{const m=Z(f);return m?Ne(Z(m.product_detail)??Z(m.product)??m):null}).filter(ae),g=Array.isArray(a.recommendation_groups)?a.recommendation_groups.map(f=>({label:b(f.label)??"",reason:b(f.reason)??"",skus:Array.isArray(f.skus)?f.skus.filter(m=>typeof m=="string"&&m.trim().length>0):[]})):[];return{style_label:s,style_mood:c??"",...u?{image_url:u}:{},...typeof a.status=="string"?{status:a.status}:{},product_list:l,recommendation_groups:g}}).filter(ae),r=e.payload.product_list??[],n=An(e.payload.source)&&t.length>0?t[0].product_list:null,o=n?lo(n,"chat"):yt(r,"chat");o.panelHint="panel";const i=o.spec.elements[o.spec.root];if(i){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),t.length>0&&(a.styleVariations=t),e.payload.replace_panel===!0&&(a.replacePanel=!0),Object.keys(a).length>0&&(i.props={...i.props,...a})}return o}function Rn(e){const t=e.payload.productDetails;if(!t)return po("chat");const r=M(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...r}}}}},panelHint:"panel"}}function xn(e){const t=yt(e.payload.similarProducts??[],"chat"),r=t.spec.elements[t.spec.root];return r&&(r.props={...r.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Ln(e){const t=e.payload.multiple_product_details??[],r=e.payload,n={key_differences:r.key_differences,recommended_choice:r.recommended_choice,recommended_choice_sku:r.recommended_choice_sku,special_considerations:r.special_considerations,criteria_view:r.criteria_view,criteria_view_short:r.criteria_view_short,compared_field_names:r.compared_field_names,winner_product:r.winner_product,winner_hits:r.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,a=[];for(const h of t){const v=M(h);a.push(v)}const s=Dn(o,a,n,i);let c;n?.recommended_choice_sku?c=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(c=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const u=c?a.find(h=>h.sku===c)??a[0]:a[0],l=[];if(Array.isArray(n?.key_differences))for(const h of n.key_differences)typeof h=="string"&&l.push(h);const g=ho(n?.special_considerations),f=n?.recommended_choice,m=n?.winner_hits,_={};for(const h of a){const v=h.sku;v&&(_[v]={title:h.name??v,type:"launchSingleProduct",payload:{sku:v}})}const p={products:a,attributes:s,highlights:l,productActions:_};return u&&(p.recommended=u),g.length>0&&(p.specialCases=g),f&&(p.recommendedText=f),m&&(p.winnerHits=m),typeof n?.key_differences=="string"&&(p.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(p.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:p}}},panelHint:"panel"}}function Dn(e,t,r,n){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const g=r.criteria_view??r.criteria_view_short??{},f=r.compared_field_names??Object.keys(e),m=[];for(const _ of f){const p=e[_];if(!p||!Array.isArray(p))continue;const h=g[_]??_;m.push({label:h,values:p.map(v=>typeof v=="string"?v:String(v??""))})}return m}const a=e,s=t.map(g=>String(g.sku??"")).filter(g=>g.length>0),c=r.criteria_view??r.criteria_view_short??{},u=(n&&n.length>0?n:r.compared_field_names&&r.compared_field_names.length>0?r.compared_field_names:jn(a)).filter(g=>g!=="name"&&g!=="name_short"&&!g.endsWith("_short")),l=[];for(const g of u){const f=s.map(_=>{const p=a[_];if(!p||typeof p!="object")return"";const h=p[`${g}_short`],v=p[g];return Un(h??v)});if(f.every(_=>_.length===0))continue;const m=c[g]??g;l.push({label:m,values:f})}return l}function jn(e){const t=[],r=new Set;for(const n of Object.values(e))if(!(!n||typeof n!="object"))for(const o of Object.keys(n))r.has(o)||(r.add(o),t.push(o));return t}function Un(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Mn(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Fn(){return{type:"done"}}function Gn(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 qn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Jn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Bn(e){const t=b(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:b(e.payload.to)}}}function Vn(e){return{type:"error",code:"BACKEND_ERROR",message:b(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Wn(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Hn(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.theme=a),ht({type:"quick_qna",payload:o})}const r=Z(t.action);if(r){const o={action:r},i=typeof t.text=="string"?t.text:void 0,a=typeof t.image_url=="string"?t.image_url:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),a!==void 0&&(o.image_url=a),s!==void 0&&(o.theme=s),mt({type:"text_image",payload:o})}const n=typeof t.text=="string"?t.text:"";if(n){const o={text:n},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0,s=Z(t.payload)??void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.payload=s),a!==void 0&&(o.theme=a),Pe({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Pe(e){const t={text:b(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 Kn(e){return fo(e.payload,"qna")}function mt(e){const t=b(e.payload.text)??"",r=D(e.payload.action,t);if(r){const o={label:t||r.title,action:r};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const n={text:t};return typeof e.payload.theme=="string"&&(n.theme=e.payload.theme),Pe({type:"text",payload:n})}function ht(e){return _t((e.payload.action_list??[]).map(t=>{const r=b(t.title)??"",n=D(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(ae),"qna")}function Yn(e){const t={reviews:(e.payload.reviews??[]).map(r=>{const n={};return typeof r.review_class=="string"&&(n.review_class=r.review_class),typeof r.review_text=="string"&&(n.review_text=r.review_text),(typeof r.review_rating=="string"||typeof r.review_rating=="number")&&(n.review_rating=r.review_rating),typeof r.review_tag=="string"&&(n.review_tag=r.review_tag),n})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function Qn(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function Xn(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function eo(e){const t=e.payload.product_suggestions??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=go(o);if(!i)continue;const a={product:i},s=D(o.requestDetails,i.name);s&&(a.action=s),typeof o.role=="string"&&(a.role=o.role),typeof o.reason=="string"&&(a.reason=o.reason),typeof o.review_highlight=="string"&&(a.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(a.labels=o.labels),typeof o.expert_quality_score=="number"&&(a.expertQualityScore=o.expert_quality_score),r.push(a)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:r}}}}}}function to(e){const t=e.payload.product_groupings??[],r=[],n=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const a=b(i.name)??"",s=b(i.sku,i.repr_sku),c=b(i.image,i.repr_image),u=s!==void 0?{type:"findSimilar",payload:{sku:s}}:void 0,l=D(i.requestDetails??u,a),g=(Array.isArray(i.group_products)?i.group_products:[]).map(_=>{const p=Z(_);return p?Ne(p):null}).filter(ae),f=c??b(...g.map(_=>_.imageUrl));if(a&&g.length>0){const _={groupName:a,products:g};f&&(_.image=f),r.push(_)}if(!l)continue;const m={name:a,action:l};if(Array.isArray(i.labels)){const _=i.labels.filter(p=>typeof p=="string");_.length>0&&(m.labels=_)}c!==void 0&&(m.image=c),n.push(m)}return r.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r}}}},panelHint:"panel"}:n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function ro(e){const t=e.payload.suggested_searches??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=b(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${n+1}`,a={},s=b(o.detailed_user_message);s&&(a.text=s);const c=Z(Z(o.requestDetails)?.payload),u=c?.group_skus;o.group_skus&&Array.isArray(o.group_skus)?a.group_skus=o.group_skus:Array.isArray(u)&&(a.group_skus=u.filter(v=>typeof v=="string"));const l=b(o.sku,o.representative_product_sku,c?.sku);l&&(a.sku=l),a.is_suggested_text=1;const g={type:"inputText",payload:a},f=D(o.requestDetails,i),m=f?.type==="findSimilar"&&typeof a.text=="string"?D(g,i):f??D(g,i);if(!m)continue;const _={shortName:i,action:m},p=b(o.detailed_user_message);p&&p!==i&&(_.detailedMessage=p);const h=In(o);h&&h!==i&&h!==(p??"")&&(_.whyDifferent=h),typeof o.image=="string"&&(_.image=o.image),r.push(_)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:r}}}}}}function no(e){const t=e.payload,r=D(t.requestDetails??t.request_details,b(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!r)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const n={action:r};return t.title&&(n.title=t.title),t.text&&(n.text=t.text),t.review_count?n.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(n.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function oo(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function io(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function ao(e){const t=e.payload.group_list??[],r=[];for(const o of t){const i=o.group_name??"",a=(o.product_list??[]).map(M);r.push({groupName:i,products:a})}const n=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const a=D(o.requestDetails,i),s={title:i};a&&(s.action=a),n.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r,filterTags:n}}}},panelHint:"panel"}}function so(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function co(e){const t={};return typeof e.payload?.summary=="string"&&(t.summary=e.payload.summary),Array.isArray(e.payload?.products_discussed)&&(t.products_discussed=e.payload.products_discussed),typeof e.payload?.user_sentiment=="string"&&(t.user_sentiment=e.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:t}}}}}function uo(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function _t(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`action-${o}`;n.push(a);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),r[a]={type:"ActionButton",props:s}}return r.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function yt(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=M(i),s=`product-${o}`;n.push(s);const c={product:a,index:o};a.sku&&(c.action={title:a.name,type:"launchSingleProduct",payload:{sku:a.sku}}),r[s]={type:"ProductCard",props:c}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function lo(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`product-${o}`;n.push(a);const s={product:i,index:o},c=i.sku;c&&(s.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),r[a]={type:"ProductCard",props:s}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function fo(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:M(e),index:0}}}}}}function po(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function go(e){const t=b(e.sku),r=b(e.short_name),n={...Z(e.product_item)??e},o=b(e.discount_reason,e.discountReason);return o&&!b(n.discount_reason,n.discountReason)&&(n.discount_reason=o),Ne(n,t,r)}function Ne(e,t,r){const n=b(e.sku,t),o=b(e.name,r);if(!n||!o)return null;const i={sku:n,name:o},a=b(e.brand);a&&(i.brand=a);const s=b(e.url);s&&(i.url=s);const c=mo(e.images);if(c.length>0)i.images=c;else{const p=b(e.image,e.image_url,e.imageUrl);p&&(i.images=[p])}const u=ie(e.price_discounted);u!==void 0&&(i.price_discounted=u);const l=ie(e.price);l!==void 0&&(i.price=l);const g=ie(e.rating);g!==void 0&&(i.rating=g);const f=ie(e.review_count)??ie(e.reviewCount);f!==void 0&&(i.review_count=f);const m=b(e.cart_code,e.cartCode);m&&(i.cart_code=m),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const _=b(e.discount_reason,e.discountReason);return _&&(i.discount_reason=_),M(i)}function D(e,t){const r=Z(e);if(!r)return null;const n=r.type;if(typeof n!="string"||n.length===0)return null;const o={title:t||n,type:n};return r.payload!==void 0&&(o.payload=r.payload),o}function Z(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function b(...e){for(const t of e)if(typeof t=="string"){const r=t.trim();if(r.length>0)return r}}function mo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ho(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 r=Number(t);if(Number.isFinite(r))return r}}function ae(e){return e!=null}var _o=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","facet_tags","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function M(e){const t=e.price_discounted!=null&&e.price_discounted>0,r=t?e.price_discounted:e.price,n=t&&e.price!=null?e.price:void 0;let o;n!=null&&r!=null&&n>0?o=Math.round((n-r)/n*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=b(e.brand),a=b(e.name)??e.sku,s=i&&!a.toLowerCase().startsWith(i.toLowerCase())?`${i} ${a}`:a,c={sku:e.sku,name:s,url:b(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),r!=null&&r>0&&(c.price=String(r)),n!=null&&n>0&&(c.originalPrice=String(n)),o!==void 0&&(c.discountPercent=o),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.short_name!==void 0&&(c.shortName=e.short_name);const l=e,g={};let f=!1;for(const m of Object.keys(l))_o.has(m)||(g[m]=l[m],f=!0);return f&&(c.extras=g),c}function yo(e){return e.results.map(M)}function vo(e){return e.product_groupings.map(t=>{const r={name:t.name,products:(t.group_products??[]).map(M)};return t.highlight!==void 0&&(r.highlight=t.highlight),r})}function bo(e){const t=e.payload.type,{type:r,...n}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:n}}}}}function vt(e){const t=[];for(const r of Object.values(e))if(r.type==="ProductCard"&&r.props){const n=r.props.product??r.props;typeof n.sku=="string"&&typeof n.name=="string"&&t.push(n)}return t}function bt(e){const t=e.headers.get("Content-Type")??"";return t.includes("application/x-ndjson")||t.includes("text/event-stream")}async function wo(e,t){const r=[],n={onEvent:o=>{const i=gt(o);!i||i.type!=="ui_spec"||r.push(...vt(i.spec.elements))}};return t!==void 0&&(n.signal=t),await ft(e,n),r}async function ko(e,t,r){const n=ut("similar_products",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await fetch(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(bt(i))return wo(i,r);const a=await i.text();if(!a)throw new Error("Empty response body from similar_products endpoint");try{return yo(JSON.parse(a))}catch{throw new Error("Invalid JSON from similar_products endpoint")}}async function So(e,t){const r=[];let n=null;const o={onEvent:i=>{const a=gt(i);if(a){if(a.type==="metadata"&&a.meta){const s=a.meta.group_name;if(typeof s=="string"){n={name:s,products:[]};const c=a.meta.highlight;typeof c=="string"&&(n.highlight=c),r.push(n)}}a.type==="ui_spec"&&n&&n.products.push(...vt(a.spec.elements))}}};return t!==void 0&&(o.signal=t),await ft(e,o),r}async function Eo(e,t,r){const n=ut("product_groupings",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await fetch(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(bt(i))return So(i,r);const a=await i.text();if(!a)return[];try{return vo(JSON.parse(a))}catch{throw new Error("Invalid JSON from product_groupings endpoint")}}var Co={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function wt(e,t){const r=Number(e);if(!Number.isFinite(r)||r<0)return e;const n={...Co,...t},o=Math.abs(r%1)<Number.EPSILON,i=n.alwaysShowDecimals||!o?r.toFixed(2):r.toFixed(0),a=i.indexOf("."),s=a===-1?i:i.slice(0,a),c=a===-1?void 0:i.slice(a+1),u=s.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousandsSeparator);let l;return c!==void 0?l=`${u}${n.decimalSeparator}${c}`:l=u,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${l}`:`${l} ${n.currencySymbol}`:l}function zo(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function To(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Io(e){const t=zo(e),r=Math.floor(t),n=t-r>=.5,o=5-r-(n?1:0),i=document.createElement("span");if(i.className="gengage-star-rating",i.setAttribute("role","img"),i.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),r>0&&i.appendChild(document.createTextNode("★".repeat(r))),n){const a=document.createElement("span");a.className="gengage-star-half",a.textContent="☆";const s=document.createElement("span");s.textContent="★",a.appendChild(s),i.appendChild(a)}return o>0&&i.appendChild(document.createTextNode("☆".repeat(o))),i}function $o(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function kt(e){const{product:t,index:r,discountType:n,onClick:o,onAddToCart:i,renderCard:a}=e,s=e.i18n,c=e.pricing;if(e.renderCardElement){const p=e.renderCardElement(t,r);if(p)return p}if(a){const p=document.createElement("div");return p.className="gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive",p.dataset.gengagePart="simrel-product-card",p.innerHTML=Jr(a(t,r)),p.addEventListener("click",h=>{h.target.closest(".gengage-simrel-atc")||h.target.closest(".gengage-chat-product-card-atc")||o(t)}),p}const u=document.createElement("article");u.className="gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive",u.dataset.gengagePart="simrel-product-card",t.inStock===!1&&u.classList.add("gengage-simrel-card--out-of-stock"),u.setAttribute("role","listitem"),u.dataset.sku=t.sku;const l=document.createElement("div");if(l.className="gengage-simrel-card-image gengage-chat-product-card-img-wrapper",l.dataset.gengagePart="simrel-product-card-image",t.imageUrl&&qr(t.imageUrl)){const p=document.createElement("img");p.className="gengage-chat-product-card-img",p.src=t.imageUrl,p.alt=t.name,p.loading="lazy",$o(p),l.appendChild(p)}if(n==="badge"&&t.discountPercent&&t.discountPercent>0){const p=document.createElement("span");p.className="gengage-simrel-badge gengage-chat-product-card-discount-badge",p.textContent=`%${To(t.discountPercent)}`,l.appendChild(p)}u.appendChild(l);const g=document.createElement("div");if(g.className="gengage-simrel-card-info gengage-chat-product-card-body",g.dataset.gengagePart="simrel-product-card-body",t.brand){const p=document.createElement("div");p.className="gengage-simrel-card-brand gengage-chat-product-card-brand",p.textContent=t.brand,g.appendChild(p)}const f=document.createElement("div");if(f.className="gengage-simrel-card-name gengage-chat-product-card-name",f.textContent=t.name,f.title=t.name,g.appendChild(f),t.rating!=null&&t.rating>0){const p=document.createElement("div");if(p.className="gengage-simrel-card-rating gengage-chat-product-card-rating",p.appendChild(Io(t.rating)),t.reviewCount!=null){const h=document.createElement("span");h.className="gengage-simrel-card-review-count gengage-chat-product-card-review-count",h.textContent=` (${t.reviewCount})`,p.appendChild(h)}g.appendChild(p)}const m=document.createElement("div");if(m.className="gengage-simrel-card-price gengage-chat-product-card-price",t.originalPrice&&t.originalPrice!==t.price&&(n==="strike-through"||!n)){const p=document.createElement("span");p.className="gengage-simrel-card-price-original gengage-chat-product-card-original-price",p.textContent=wt(t.originalPrice,c),m.appendChild(p)}if(t.price&&parseFloat(t.price)>0){const p=document.createElement("span");p.className="gengage-simrel-card-price-current gengage-chat-product-card-price-current",p.textContent=wt(t.price,c),m.appendChild(p)}g.appendChild(m),u.appendChild(g);const _=document.createElement("button");if(_.className="gengage-simrel-card-cta gengage-chat-product-card-cta gds-btn gds-btn-secondary",_.type="button",_.dataset.gengagePart="simrel-product-card-cta",_.textContent=s?.ctaLabel??"View",_.addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),o(t)}),u.appendChild(_),t.inStock===!1){const p=document.createElement("div");p.className="gengage-simrel-card-oos",p.textContent=s?.outOfStockLabel??"Out of Stock",u.appendChild(p)}else if(t.cartCode){const p=document.createElement("button");p.className="gengage-simrel-atc gengage-simrel-atc-button gds-btn gds-btn-secondary",p.type="button",p.textContent=s?.addToCartButton??"Add to Cart",p.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),i({sku:t.sku,quantity:1,cartCode:t.cartCode})}),u.appendChild(p)}return u.addEventListener("click",p=>{p.target.closest(".gengage-simrel-atc")||p.target.closest(".gengage-chat-product-card-atc")||p.target.closest(".gengage-chat-product-card-cta")||o(t)}),u}function St(e){const t=document.createElement("div");t.className="gengage-simrel-grid",t.setAttribute("role","list"),t.setAttribute("aria-label",e.i18n?.similarProductsAriaLabel??"Similar products"),e.columns&&t.style.setProperty("--gengage-simrel-columns",String(e.columns));for(let r=0;r<e.products.length;r++){const n={product:e.products[r],index:r,onClick:e.onClick,onAddToCart:e.onAddToCart};e.i18n!==void 0&&(n.i18n=e.i18n),e.discountType!==void 0&&(n.discountType=e.discountType),e.renderCard!==void 0&&(n.renderCard=e.renderCard),e.renderCardElement!==void 0&&(n.renderCardElement=e.renderCardElement);const o=kt(n);t.appendChild(o)}return e.products.length===0&&(t.style.display="none",t.dataset.empty="true"),t}var Ao=0;function Po(e){const t=Ao++,r=document.createElement("div");if(r.className="gengage-simrel-groups",r.dataset.gengagePart="simrel-groups",e.groups.length===0)return r.style.display="none",r.dataset.empty="true",r;const n=document.createElement("div");n.className="gengage-simrel-tabs gds-toolbar",n.dataset.gengagePart="simrel-tab-bar",n.setAttribute("role","tablist");const o=[],i=[];let a=0;const s=h=>{const v={products:h.products,onClick:e.onClick,onAddToCart:e.onAddToCart};return e.i18n!==void 0&&(v.i18n=e.i18n),e.discountType!==void 0&&(v.discountType=e.discountType),e.renderCard!==void 0&&(v.renderCard=e.renderCard),e.renderCardElement!==void 0&&(v.renderCardElement=e.renderCardElement),e.columns!==void 0&&(v.columns=e.columns),v},c=(h,v=!1)=>{if(v&&h!==a&&e.onGroupingActivate){const w=e.groups[h];e.onGroupingActivate({grouping_label:w.name,grouping_index:h})}a=h;for(let w=0;w<o.length;w++){const A=w===h;o[w].classList.toggle("gengage-simrel-tab--active",A),o[w].setAttribute("aria-selected",String(A)),o[w].tabIndex=A?0:-1}const x=e.groups[h],z=i[h];z.innerHTML="";const k=St(s(x));z.appendChild(k);for(let w=0;w<i.length;w++){const A=w===h;i[w].style.display=A?"":"none",i[w].tabIndex=A?0:-1}};for(let h=0;h<e.groups.length;h++){const v=e.groups[h],x=`gengage-simrel-tab-${t}-${h}`,z=`gengage-simrel-panel-${t}-${h}`,k=document.createElement("button");k.className="gengage-simrel-tab gds-tab",k.type="button",k.dataset.gengagePart="simrel-tab",k.id=x,k.textContent=v.name,k.setAttribute("role","tab"),k.setAttribute("aria-controls",z),k.setAttribute("aria-selected",String(h===0)),k.tabIndex=h===0?0:-1,h===0&&k.classList.add("gengage-simrel-tab--active"),k.addEventListener("click",()=>c(h,!0)),k.addEventListener("keydown",A=>{let Y=-1;A.key==="ArrowRight"||A.key==="ArrowDown"?Y=(h+1)%e.groups.length:A.key==="ArrowLeft"||A.key==="ArrowUp"?Y=(h-1+e.groups.length)%e.groups.length:A.key==="Home"?Y=0:A.key==="End"&&(Y=e.groups.length-1),Y>=0&&(A.preventDefault(),c(Y,!0),o[Y].focus())}),o.push(k),n.appendChild(k);const w=document.createElement("div");w.className="gengage-simrel-tab-panel",w.dataset.gengagePart="simrel-tab-panel",w.id=z,w.setAttribute("role","tabpanel"),w.setAttribute("aria-labelledby",x),w.tabIndex=h===0?0:-1,h!==0&&(w.style.display="none"),i.push(w)}const u=document.createElement("button");u.type="button",u.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--left",u.setAttribute("aria-label",e.i18n?.scrollTabsLeft??"Scroll tabs left"),u.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>';const l=document.createElement("button");l.type="button",l.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--right",l.setAttribute("aria-label",e.i18n?.scrollTabsRight??"Scroll tabs right"),l.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>';const g=200;u.addEventListener("click",()=>{n.scrollBy({left:-g,behavior:"smooth"})}),l.addEventListener("click",()=>{n.scrollBy({left:g,behavior:"smooth"})});const f=()=>{const h=n.scrollLeft<=4,v=n.scrollLeft+n.clientWidth>=n.scrollWidth-4;u.style.display=h?"none":"",l.style.display=v?"none":"",n.classList.toggle("gengage-simrel-tabs--peek-right",!v),n.classList.toggle("gengage-simrel-tabs--peek-left",!h)};n.addEventListener("scroll",f,{passive:!0}),typeof ResizeObserver<"u"&&new ResizeObserver(f).observe(n),u.style.display="none",l.style.display="none",requestAnimationFrame(f);const m=document.createElement("div");m.className="gengage-simrel-tabs-wrapper",m.appendChild(u),m.appendChild(n),m.appendChild(l),r.appendChild(m);const _=i[0],p=St(s(e.groups[0]));_.appendChild(p);for(const h of i)r.appendChild(h);return r}function Et(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.sku!="string"||typeof t.name!="string"||typeof t.url!="string")return null;const r={sku:t.sku,name:t.name,url:t.url},n=t.imageUrl;typeof n=="string"&&(r.imageUrl=n);const o=t.price;typeof o=="string"&&(r.price=o);const i=t.originalPrice;typeof i=="string"&&(r.originalPrice=i);const a=t.discountPercent;typeof a=="number"&&(r.discountPercent=a);const s=t.brand;typeof s=="string"&&(r.brand=s);const c=t.rating;typeof c=="number"&&(r.rating=c);const u=t.reviewCount;typeof u=="number"&&(r.reviewCount=u);const l=t.cartCode;typeof l=="string"&&(r.cartCode=l);const g=t.inStock;typeof g=="boolean"&&(r.inStock=g);const f=t.extras;return f!=null&&typeof f=="object"&&(r.extras=f),r}function No(e){if(!e||typeof e!="object")return null;const t=e,r=t.title,n=t.type;if(typeof r!="string"||typeof n!="string")return null;const o={title:r,type:n};return t.payload!==void 0&&(o.payload=t.payload),o}var Ct={ProductGrid:({element:e,renderElement:t,context:r})=>{const n=document.createElement("div");n.className="gengage-simrel-grid",n.setAttribute("role","list");const o=e.props?.columns;let i;typeof o=="number"&&Number.isFinite(o)&&o>0?i=Math.floor(o):typeof r.gridColumns=="number"&&Number.isFinite(r.gridColumns)&&r.gridColumns>0&&(i=Math.floor(r.gridColumns)),i!==void 0&&n.style.setProperty("--gengage-simrel-columns",String(i));for(const a of e.children??[]){const s=t(a);s&&n.appendChild(s)}if(n.children.length===0){const a=document.createElement("div");a.className="gengage-simrel-empty",a.textContent=r.i18n.emptyStateMessage,n.appendChild(a)}return n},ProductCard:({element:e,context:t})=>{const r=Et(e.props?.product??e.props);if(!r)return null;const n=e.props?.index,o=typeof n=="number"&&Number.isFinite(n)?n:0,i=e.props?.discountType,a=i==="strike-through"||i==="badge"?i:t.discountType,s={product:r,index:o,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return a!==void 0&&(s.discountType=a),t.renderCard!==void 0&&(s.renderCard=t.renderCard),t.renderCardElement!==void 0&&(s.renderCardElement=t.renderCardElement),t.pricing!==void 0&&(s.pricing=t.pricing),kt(s)},GroupTabs:({element:e,context:t})=>{const r=e.props?.groups;if(!Array.isArray(r))return null;const n=[];for(const a of r){if(!a||typeof a!="object")continue;const s=a;if(typeof s.name!="string")continue;const c=[];if(Array.isArray(s.products))for(const l of s.products){const g=Et(l);g&&c.push(g)}const u={name:s.name,products:c};typeof s.highlight=="string"&&(u.highlight=s.highlight),n.push(u)}const o={groups:n,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n},i=e.props?.columns;return typeof i=="number"&&Number.isFinite(i)&&i>0?o.columns=Math.floor(i):typeof t.gridColumns=="number"&&Number.isFinite(t.gridColumns)&&t.gridColumns>0&&(o.columns=Math.floor(t.gridColumns)),t.discountType!==void 0&&(o.discountType=t.discountType),t.renderCard!==void 0&&(o.renderCard=t.renderCard),t.renderCardElement!==void 0&&(o.renderCardElement=t.renderCardElement),t.onGroupingActivate!==void 0&&(o.onGroupingActivate=t.onGroupingActivate),Po(o)},EmptyState:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-empty";const n=e.props?.message;return r.textContent=typeof n=="string"?n:t.i18n.emptyStateMessage,r},AddToCartButton:({element:e,context:t})=>{const r=e.props?.sku,n=e.props?.cartCode;if(typeof r!="string"||typeof n!="string")return null;const o=document.createElement("button");o.className="gengage-simrel-atc gengage-chat-product-card-cta",o.type="button";const i=e.props?.label;return o.textContent=typeof i=="string"?i:t.i18n.addToCartButton,o.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),t.onAddToCart({sku:r,quantity:1,cartCode:n})}),o},QuickActions:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-quick-actions";const n=e.props?.actions;if(!Array.isArray(n)||!t.onAction)return r;for(const o of n){if(!o||typeof o!="object")continue;const i=o,a=i.label,s=No(i.action);if(typeof a!="string"||!s)continue;const c=document.createElement("button");c.className="gengage-simrel-quick-action",c.type="button",c.textContent=a,c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),t.onAction?.(s)}),r.appendChild(c)}return r}},Oe=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const r=document.createElement("div");for(const n of e.children){const o=t(n);o&&r.appendChild(o)}return r};function zt(){return{...Ct}}function Tt(e,t,r=Ct,n=Oe){return $r({spec:e,context:t,registry:r,containerClassName:"gengage-simrel-uispec",unknownRenderer:n})}var It={similarProductsAriaLabel:"Benzer ürünler",emptyStateMessage:"Benzer ürün bulunamadı.",addToCartButton:"Sepete Ekle",ctaLabel:"İncele",outOfStockLabel:"Stokta Yok",decreaseLabel:"Azalt",increaseLabel:"Artır",errorLoadingMessage:"Benzer ürünler yüklenemedi.",retryButtonText:"Tekrar dene",priceSuffix:" TL",scrollTabsLeft:"Sola kaydır",scrollTabsRight:"Sağa kaydır"},Oo={similarProductsAriaLabel:"Similar products",emptyStateMessage:"No similar products found.",addToCartButton:"Add to cart",ctaLabel:"View",outOfStockLabel:"Out of Stock",decreaseLabel:"Decrease",increaseLabel:"Increase",errorLoadingMessage:"Could not load similar products.",retryButtonText:"Try again",priceSuffix:"",scrollTabsLeft:"Scroll tabs left",scrollTabsRight:"Scroll tabs right"};function Zo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Ro(e){return Zo(e)==="en"?Oo:It}var _u=Object.freeze({status:"aborted"});function d(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const u=a.prototype,l=Object.keys(u);for(let g=0;g<l.length;g++){const f=l[g];f in s||(s[f]=u[f].bind(s))}}const o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(s){var c;const u=r?.Parent?new i:this;n(u,s),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var X=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},$t=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}},Ze={};function W(e){return e&&Object.assign(Ze,e),Ze}function At(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function Re(e,t){return typeof t=="bigint"?t.toString():t}function xe(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function Le(e){return e==null}function De(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function xo(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){const a=n.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}const i=r>o?r:o;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}var Pt=Symbol("evaluating");function S(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Pt)return n===void 0&&(n=Pt,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function H(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function F(...e){const t={};for(const r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function Nt(e){return JSON.stringify(e)}function Lo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Ot="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Do=xe(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function se(e){if(pe(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(pe(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Zt(e){return se(e)?{...e}:Array.isArray(e)?[...e]:e}var jo=new Set(["string","number","symbol"]);function ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function G(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}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 Uo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Mo={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 Fo(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return G(e,F(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=r.shape[i])}return H(this,"shape",o),o},checks:[]}))}function Go(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return G(e,F(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return H(this,"shape",o),o},checks:[]}))}function qo(e,t){if(!se(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const n=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(n,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return G(e,F(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return H(this,"shape",n),n}}))}function Jo(e,t){if(!se(t))throw new Error("Invalid input to safeExtend: expected a plain object");return G(e,F(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return H(this,"shape",r),r}}))}function Bo(e,t){return G(e,F(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return H(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]}))}function Vo(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return G(t,F(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(r)for(const a in r){if(!(a in o))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=e?new e({type:"optional",innerType:o[a]}):o[a])}else for(const a in o)i[a]=e?new e({type:"optional",innerType:o[a]}):o[a];return H(this,"shape",i),i},checks:[]}))}function Wo(e,t,r){return G(t,F(t._zod.def,{get shape(){const n=t._zod.def.shape,o={...n};if(r)for(const i in r){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(o[i]=new e({type:"nonoptional",innerType:n[i]}))}else for(const i in n)o[i]=new e({type:"nonoptional",innerType:n[i]});return H(this,"shape",o),o}}))}function ee(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Rt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function me(e){return typeof e=="string"?e:e?.message}function K(e,t,r){const n={...e,path:e.path??[]};return e.message||(n.message=me(e.inst?._zod.def?.error?.(e))??me(t?.error?.(e))??me(r.customError?.(e))??me(r.localeError?.(e))??"Invalid input"),delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function je(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ce(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var xt=(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,Re,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Lt=d("$ZodError",xt),Dt=d("$ZodError",xt,{Parent:Error});function Ho(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Ko(e,t=r=>r.message){const r={_errors:[]},n=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let a=r,s=0;for(;s<i.path.length;){const c=i.path[s];s!==i.path.length-1?a[c]=a[c]||{_errors:[]}:(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(i))),a=a[c],s++}}};return n(e),r}var Ue=e=>(t,r,n,o)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new X;if(a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>K(c,i,W())));throw Ot(s,o?.callee),s}return a.value},Me=e=>async(t,r,n,o)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>K(c,i,W())));throw Ot(s,o?.callee),s}return a.value},he=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new X;return i.issues.length?{success:!1,error:new(e??Lt)(i.issues.map(a=>K(a,o,W())))}:{success:!0,data:i.value}},Yo=he(Dt),_e=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>K(a,o,W())))}:{success:!0,data:i.value}},Qo=_e(Dt),Xo=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ue(e)(t,r,o)},ei=e=>(t,r,n)=>Ue(e)(t,r,n),ti=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Me(e)(t,r,o)},ri=e=>async(t,r,n)=>Me(e)(t,r,n),ni=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return he(e)(t,r,o)},oi=e=>(t,r,n)=>he(e)(t,r,n),ii=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _e(e)(t,r,o)},ai=e=>async(t,r,n)=>_e(e)(t,r,n),si=/^[cC][^\s-]{8,}$/,ci=/^[0-9a-z]+$/,ui=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,di=/^[0-9a-vA-V]{20}$/,li=/^[A-Za-z0-9]{27}$/,fi=/^[a-zA-Z0-9_-]{21}$/,pi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gi=/^([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})$/,jt=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)$/,mi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,hi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function _i(){return new RegExp(hi,"u")}var yi=/^(?:(?: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])$/,vi=/^(([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}|:))$/,bi=/^((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])$/,wi=/^(([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])$/,ki=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ut=/^[A-Za-z0-9_-]*$/,Si=/^\+[1-9]\d{6,14}$/,Mt="(?:(?:\\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])))",Ei=new RegExp(`^${Mt}$`);function Ft(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(`^${Ft(e)}$`)}function zi(e){const t=Ft({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Mt}T(?:${n})$`)}var Ti=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ii=/^-?\d+$/,$i=/^-?\d+(?:\.\d+)?$/,Ai=/^[^A-Z]*$/,Pi=/^[^a-z]*$/,N=d("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Gt={number:"number",bigint:"bigint",object:"date"},qt=d("$ZodCheckLessThan",(e,t)=>{N.init(e,t);const r=Gt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jt=d("$ZodCheckGreaterThan",(e,t)=>{N.init(e,t);const r=Gt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ni=d("$ZodCheckMultipleOf",(e,t)=>{N.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):xo(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Oi=d("$ZodCheckNumberFormat",(e,t)=>{N.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,i]=Mo[t.format];e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,s.minimum=o,s.maximum=i,r&&(s.pattern=Ii)}),e._zod.check=a=>{const s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<o&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Zi=d("$ZodCheckMaxLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=je(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ri=d("$ZodCheckMinLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=je(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),xi=d("$ZodCheckLengthEquals",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const a=je(o),s=i>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ye=d("$ZodCheckStringFormat",(e,t)=>{var r,n;N.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Li=d("$ZodCheckRegex",(e,t)=>{ye.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Di=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ai),ye.init(e,t)}),ji=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Pi),ye.init(e,t)}),Ui=d("$ZodCheckIncludes",(e,t)=>{N.init(e,t);const r=ge(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Mi=d("$ZodCheckStartsWith",(e,t)=>{N.init(e,t);const r=new RegExp(`^${ge(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Fi=d("$ZodCheckEndsWith",(e,t)=>{N.init(e,t);const r=new RegExp(`.*${ge(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Gi=d("$ZodCheckOverwrite",(e,t)=>{N.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),qi=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 pn(){if(ne!==null)return ne;try{ne=localStorage.getItem("gengage:debug")==="1"}catch{ne=!1}return ne}function Ie(e,t,r){if(!pn())return;const n=[`[gengage:${e}]`,t];r!==void 0&&n.push(r),console.debug(...n)}var fn=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=Yr(e.theme);this.config={...e,theme:t,session:Kr(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),an();const r=Xe("gengage:context:update",n=>this.update(n));this._cleanups.push(r),Ie("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,Ie("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}trackCheckout(e,t){const r=e==="start"?Rr:xr;this.track(r(this.analyticsContext(),t))}flushMeteringSummary(e){this.track(Or(this.analyticsContext(),e))}emit(e,...t){this._handlers.get(e)?.forEach(r=>r(...t))}addCleanup(e){this._cleanups.push(e)}track(e){this.config.analyticsClient?.track(e)}analyticsContext(){const e={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(e.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(e.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(e.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(e.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(e.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(e.ab_test_experiment_id=this.config.session.abTestExperimentId),e}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const r=document.querySelector(e);if(!r)throw new Error(`[gengage] Mount target not found: "${e}"`);return r}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,r]of Object.entries(e))if(r!==void 0){const n=t.startsWith("--")?t:`--gengage-${gn(t)}`;this.root.style.setProperty(n,r)}}}};function gn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function mn(e){const t=e?.trim();return t||"tr"}var hn=8e3,_n=5e3,yn="https://www.google.com/favicon.ico",j=new Map,it=!1,Q=null,oe=null,V=!1;function vn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function at(e){return vn(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 st(){let e;for(const t of j.values())e=t;return e}function $e(){Q&&(clearTimeout(Q),Q=null)}function bn(){oe&&(clearInterval(oe),oe=null)}async function ct(){try{if(typeof navigator<"u"&&navigator.onLine===!1)return!1;if(typeof window<"u"){const r=window.location.hostname;if(r==="localhost"||r==="127.0.0.1")return navigator.onLine}const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);try{return await fetch(yn,{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 le(){V=!1,bn(),ot()}function pe(){Q||V||j.size===0||(Q=setTimeout(async()=>{Q=null,!(V||j.size===0)&&!await ct()&&j.size>0&&(V=!0,Te({source:"sdk",message:at(st()),sticky:!0}),oe||(oe=setInterval(async()=>{if(j.size===0){le();return}await ct()&&(le(),pe())},_n)))},hn))}function wn(){it||typeof window>"u"||(it=!0,window.addEventListener("online",()=>{le(),pe()}),window.addEventListener("offline",()=>{j.size===0||V||(V=!0,$e(),Te({source:"sdk",message:at(st()),sticky:!0}))}))}function kn(e){wn();const t=Symbol(e.source);j.set(t,e.locale),pe();let r=!1;return()=>{if(!r){if(r=!0,j.delete(t),j.size===0){$e(),le();return}V||($e(),pe())}}}var Sn={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function En(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 ut(e,t){return`${En(t?.middlewareUrl)}/chat${Sn[e]}`}function dt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Cn(e){const t=[];let r=0,n=!1,o=!1,i=0;for(let a=0;a<e.length;a++){const s=e[a];if(o){o=!1;continue}if(s==="\\"&&n){o=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&r++,s==="}"&&(r--,r===0&&(t.push(e.slice(i,a+1)),i=a+1)))}return t.length>0?t:[e]}function lt(e,t){const r=e.trim();if(!r||r.startsWith(":"))return!1;const n=r.startsWith("data: ")?r.slice(6):r;if(n==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(n);return dt(o)?(Ie("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=Cn(n);if(o.length>1){for(const i of o)try{const a=JSON.parse(i);if(!dt(a))continue;if(t.onEvent(a),a.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function pt(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const r=e.body.getReader(),n=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,a=Symbol("idle-timeout");let s=!1;try{for(;;){const c=r.read();let u;const l=await(i>0?Promise.race([c.then(_=>(clearTimeout(u),_)),new Promise(_=>{u=setTimeout(()=>_(a),i)})]):c);if(l===a){s=!0,await r.cancel();break}const{done:g,value:p}=l;if(g)break;o+=n.decode(p,{stream:!0});const m=o.split(`
|
|
48
|
+
`);o=m.pop()??"";for(const _ of m)if(lt(_,t))return}if(o.trim()&<(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||r.releaseLock()}t.onDone?.()}var ft=3,zn=(e,t)=>{const r=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!r)return"";const n=t?.stripLeadingStopWords?r.replace(/^(?:daha|için)\s+/i,"").trim():r;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},Ae=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(r=>zn(r,t)).filter(Boolean):[];function Tn(e){const t=(e.display_keywords??[]).flatMap(o=>Ae(o,{stripLeadingStopWords:!0})),r=t.filter((o,i)=>t.indexOf(o)===i);if(r.length>0)return r.slice(0,ft);const n=[...Ae(e.chosen_attribute,{stripLeadingStopWords:!0}),...Ae(e.short_name)];return n.filter((o,i)=>n.indexOf(o)===i).slice(0,ft)}function In(e){return Tn(e).join(" • ")}var $n=["beauty_consulting","watch_expert"];function An(e){return typeof e=="string"&&$n.includes(e)}function gt(e){if(typeof e.type!="string")return null;if(Pn(e))return e;const t=e;switch(t.type){case"outputText":return Nn(t);case"suggestedActions":return On(t);case"productList":return Zn(t);case"productDetails":return Rn(t);case"productDetailsSimilars":return xn(t);case"comparisonTable":return Ln(t);case"context":return Mn(t);case"chatStreamEnd":return Fn();case"loading":return qn(t);case"panelLoading":return Gn(t);case"similarLoading":return Jn(t);case"redirect":return Bn(t);case"error":return Vn(t);case"dummy":return Wn(t);case"launcherAction":return Hn(t);case"text":return Pe(t);case"productItem":return Kn(t);case"text_image":return mt(t);case"quick_qna":return ht(t);case"reviewHighlights":return Yn(t);case"aiProductSuggestions":return eo(t);case"aiProductGroupings":return to(t);case"aiSuggestedSearches":return ro(t);case"prosAndCons":return Qn(t);case"getGroundingReview":return no(t);case"voice":return io(t);case"visitorDataResponse":return Xn(t);case"productListPreview":return oo();case"groupList":return ao(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return so(t);case"launcherContent":return uo(t);case"handoff":return co(t);case"uiSpec":return bo(t);default:return null}}function Pn(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const r=e.widget;if(r!=="chat"&&r!=="qna"&&r!=="simrel")return!1;const n=Z(e.spec);return n?typeof n.root=="string"&&Z(n.elements)!==null:!1}case"action":{const r=Z(e.action);return r!==null&&typeof r.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Nn(e){const t=b(e.payload.text,e.payload.plain_text)??"",r=b(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:r||"Backend returned an error"};const n={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(n.productMentions=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const a=e.payload.conversation_mode;typeof a=="string"&&a&&(n.conversationMode=a);const s=e.payload.render_hint;return typeof s=="string"&&s&&(n.renderHint=s),e.payload.kvkk===!0&&(n.kvkk=!0),n}function On(e){return _t((e.payload.actions??[]).map(t=>{const r=b(t.title)??"",n=D(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(ae),"chat")}function Zn(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(a=>{const s=b(a.style_label);if(!s)return null;const c=b(a.style_mood),u=b(a.image_url??void 0),l=(Array.isArray(a.product_list)?a.product_list:[]).map(p=>{const m=Z(p);return m?Ne(Z(m.product_detail)??Z(m.product)??m):null}).filter(ae),g=Array.isArray(a.recommendation_groups)?a.recommendation_groups.map(p=>({label:b(p.label)??"",reason:b(p.reason)??"",skus:Array.isArray(p.skus)?p.skus.filter(m=>typeof m=="string"&&m.trim().length>0):[]})):[];return{style_label:s,style_mood:c??"",...u?{image_url:u}:{},...typeof a.status=="string"?{status:a.status}:{},product_list:l,recommendation_groups:g}}).filter(ae),r=e.payload.product_list??[],n=An(e.payload.source)&&t.length>0?t[0].product_list:null,o=n?lo(n,"chat"):yt(r,"chat");o.panelHint="panel";const i=o.spec.elements[o.spec.root];if(i){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),t.length>0&&(a.styleVariations=t),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 s=e.payload.sequence_id??e.payload.search_id;typeof s=="string"&&s.length>0&&(a.sequenceId=s),Object.keys(a).length>0&&(i.props={...i.props,...a})}return o}function Rn(e){const t=e.payload.productDetails;if(!t)return fo("chat");const r=M(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...r}}}}},panelHint:"panel"}}function xn(e){const t=yt(e.payload.similarProducts??[],"chat"),r=t.spec.elements[t.spec.root];return r&&(r.props={...r.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Ln(e){const t=e.payload.multiple_product_details??[],r=e.payload,n={key_differences:r.key_differences,recommended_choice:r.recommended_choice,recommended_choice_sku:r.recommended_choice_sku,special_considerations:r.special_considerations,criteria_view:r.criteria_view,criteria_view_short:r.criteria_view_short,compared_field_names:r.compared_field_names,winner_product:r.winner_product,winner_hits:r.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,a=[];for(const h of t){const v=M(h);a.push(v)}const s=Dn(o,a,n,i);let c;n?.recommended_choice_sku?c=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(c=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const u=c?a.find(h=>h.sku===c)??a[0]:a[0],l=[];if(Array.isArray(n?.key_differences))for(const h of n.key_differences)typeof h=="string"&&l.push(h);const g=ho(n?.special_considerations),p=n?.recommended_choice,m=n?.winner_hits,_={};for(const h of a){const v=h.sku;v&&(_[v]={title:h.name??v,type:"launchSingleProduct",payload:{sku:v}})}const f={products:a,attributes:s,highlights:l,productActions:_};return u&&(f.recommended=u),g.length>0&&(f.specialCases=g),p&&(f.recommendedText=p),m&&(f.winnerHits=m),typeof n?.key_differences=="string"&&(f.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(f.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:f}}},panelHint:"panel"}}function Dn(e,t,r,n){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const g=r.criteria_view??r.criteria_view_short??{},p=r.compared_field_names??Object.keys(e),m=[];for(const _ of p){const f=e[_];if(!f||!Array.isArray(f))continue;const h=g[_]??_;m.push({label:h,values:f.map(v=>typeof v=="string"?v:String(v??""))})}return m}const a=e,s=t.map(g=>String(g.sku??"")).filter(g=>g.length>0),c=r.criteria_view??r.criteria_view_short??{},u=(n&&n.length>0?n:r.compared_field_names&&r.compared_field_names.length>0?r.compared_field_names:jn(a)).filter(g=>g!=="name"&&g!=="name_short"&&!g.endsWith("_short")),l=[];for(const g of u){const p=s.map(_=>{const f=a[_];if(!f||typeof f!="object")return"";const h=f[`${g}_short`],v=f[g];return Un(h??v)});if(p.every(_=>_.length===0))continue;const m=c[g]??g;l.push({label:m,values:p})}return l}function jn(e){const t=[],r=new Set;for(const n of Object.values(e))if(!(!n||typeof n!="object"))for(const o of Object.keys(n))r.has(o)||(r.add(o),t.push(o));return t}function Un(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Mn(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Fn(){return{type:"done"}}function qn(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 Gn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Jn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Bn(e){const t=b(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:b(e.payload.to)}}}function Vn(e){return{type:"error",code:"BACKEND_ERROR",message:b(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Wn(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Hn(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.theme=a),ht({type:"quick_qna",payload:o})}const r=Z(t.action);if(r){const o={action:r},i=typeof t.text=="string"?t.text:void 0,a=typeof t.image_url=="string"?t.image_url:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),a!==void 0&&(o.image_url=a),s!==void 0&&(o.theme=s),mt({type:"text_image",payload:o})}const n=typeof t.text=="string"?t.text:"";if(n){const o={text:n},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0,s=Z(t.payload)??void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.payload=s),a!==void 0&&(o.theme=a),Pe({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Pe(e){const t={text:b(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 Kn(e){return po(e.payload,"qna")}function mt(e){const t=b(e.payload.text)??"",r=D(e.payload.action,t);if(r){const o={label:t||r.title,action:r};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const n={text:t};return typeof e.payload.theme=="string"&&(n.theme=e.payload.theme),Pe({type:"text",payload:n})}function ht(e){return _t((e.payload.action_list??[]).map(t=>{const r=b(t.title)??"",n=D(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(ae),"qna")}function Yn(e){const t={reviews:(e.payload.reviews??[]).map(r=>{const n={};return typeof r.review_class=="string"&&(n.review_class=r.review_class),typeof r.review_text=="string"&&(n.review_text=r.review_text),(typeof r.review_rating=="string"||typeof r.review_rating=="number")&&(n.review_rating=r.review_rating),typeof r.review_tag=="string"&&(n.review_tag=r.review_tag),n})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function Qn(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function Xn(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function eo(e){const t=e.payload.product_suggestions??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=go(o);if(!i)continue;const a={product:i},s=D(o.requestDetails,i.name);s&&(a.action=s),typeof o.role=="string"&&(a.role=o.role),typeof o.reason=="string"&&(a.reason=o.reason),typeof o.review_highlight=="string"&&(a.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(a.labels=o.labels),typeof o.expert_quality_score=="number"&&(a.expertQualityScore=o.expert_quality_score),r.push(a)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:r}}}}}}function to(e){const t=e.payload.product_groupings??[],r=[],n=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const a=b(i.name)??"",s=b(i.sku,i.repr_sku),c=b(i.image,i.repr_image),u=s!==void 0?{type:"findSimilar",payload:{sku:s}}:void 0,l=D(i.requestDetails??u,a),g=(Array.isArray(i.group_products)?i.group_products:[]).map(_=>{const f=Z(_);return f?Ne(f):null}).filter(ae),p=c??b(...g.map(_=>_.imageUrl));if(a&&g.length>0){const _={groupName:a,products:g};p&&(_.image=p),r.push(_)}if(!l)continue;const m={name:a,action:l};if(Array.isArray(i.labels)){const _=i.labels.filter(f=>typeof f=="string");_.length>0&&(m.labels=_)}c!==void 0&&(m.image=c),n.push(m)}return r.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r}}}},panelHint:"panel"}:n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function ro(e){const t=e.payload.suggested_searches??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=b(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${n+1}`,a={},s=b(o.detailed_user_message);s&&(a.text=s);const c=Z(Z(o.requestDetails)?.payload),u=c?.group_skus;o.group_skus&&Array.isArray(o.group_skus)?a.group_skus=o.group_skus:Array.isArray(u)&&(a.group_skus=u.filter(v=>typeof v=="string"));const l=b(o.sku,o.representative_product_sku,c?.sku);l&&(a.sku=l),a.is_suggested_text=1;const g={type:"inputText",payload:a},p=D(o.requestDetails,i),m=p?.type==="findSimilar"&&typeof a.text=="string"?D(g,i):p??D(g,i);if(!m)continue;const _={shortName:i,action:m},f=b(o.detailed_user_message);f&&f!==i&&(_.detailedMessage=f);const h=In(o);h&&h!==i&&h!==(f??"")&&(_.whyDifferent=h),typeof o.image=="string"&&(_.image=o.image),r.push(_)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:r}}}}}}function no(e){const t=e.payload,r=D(t.requestDetails??t.request_details,b(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!r)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const n={action:r};return t.title&&(n.title=t.title),t.text&&(n.text=t.text),t.review_count?n.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(n.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function oo(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function io(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function ao(e){const t=e.payload.group_list??[],r=[];for(const o of t){const i=o.group_name??"",a=(o.product_list??[]).map(M);r.push({groupName:i,products:a})}const n=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const a=D(o.requestDetails,i),s={title:i};a&&(s.action=a),n.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r,filterTags:n}}}},panelHint:"panel"}}function so(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function co(e){const t={};return typeof e.payload?.summary=="string"&&(t.summary=e.payload.summary),Array.isArray(e.payload?.products_discussed)&&(t.products_discussed=e.payload.products_discussed),typeof e.payload?.user_sentiment=="string"&&(t.user_sentiment=e.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:t}}}}}function uo(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function _t(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`action-${o}`;n.push(a);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),r[a]={type:"ActionButton",props:s}}return r.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function yt(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=M(i),s=`product-${o}`;n.push(s);const c={product:a,index:o};a.sku&&(c.action={title:a.name,type:"launchSingleProduct",payload:{sku:a.sku}}),r[s]={type:"ProductCard",props:c}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function lo(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`product-${o}`;n.push(a);const s={product:i,index:o},c=i.sku;c&&(s.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),r[a]={type:"ProductCard",props:s}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function po(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:M(e),index:0}}}}}}function fo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function go(e){const t=b(e.sku),r=b(e.short_name),n={...Z(e.product_item)??e},o=b(e.discount_reason,e.discountReason);return o&&!b(n.discount_reason,n.discountReason)&&(n.discount_reason=o),Ne(n,t,r)}function Ne(e,t,r){const n=b(e.sku,t),o=b(e.name,r);if(!n||!o)return null;const i={sku:n,name:o},a=b(e.brand);a&&(i.brand=a);const s=b(e.url);s&&(i.url=s);const c=mo(e.images);if(c.length>0)i.images=c;else{const f=b(e.image,e.image_url,e.imageUrl);f&&(i.images=[f])}const u=ie(e.price_discounted);u!==void 0&&(i.price_discounted=u);const l=ie(e.price);l!==void 0&&(i.price=l);const g=ie(e.rating);g!==void 0&&(i.rating=g);const p=ie(e.review_count)??ie(e.reviewCount);p!==void 0&&(i.review_count=p);const m=b(e.cart_code,e.cartCode);m&&(i.cart_code=m),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const _=b(e.discount_reason,e.discountReason);return _&&(i.discount_reason=_),M(i)}function D(e,t){const r=Z(e);if(!r)return null;const n=r.type;if(typeof n!="string"||n.length===0)return null;const o={title:t||n,type:n};return r.payload!==void 0&&(o.payload=r.payload),o}function Z(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function b(...e){for(const t of e)if(typeof t=="string"){const r=t.trim();if(r.length>0)return r}}function mo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ho(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 r=Number(t);if(Number.isFinite(r))return r}}function ae(e){return e!=null}var _o=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","facet_tags","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function M(e){const t=e.price_discounted!=null&&e.price_discounted>0,r=t?e.price_discounted:e.price,n=t&&e.price!=null?e.price:void 0;let o;n!=null&&r!=null&&n>0?o=Math.round((n-r)/n*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=b(e.brand),a=b(e.name)??e.sku,s=i&&!a.toLowerCase().startsWith(i.toLowerCase())?`${i} ${a}`:a,c={sku:e.sku,name:s,url:b(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),r!=null&&r>0&&(c.price=String(r)),n!=null&&n>0&&(c.originalPrice=String(n)),o!==void 0&&(c.discountPercent=o),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.short_name!==void 0&&(c.shortName=e.short_name);const l=e,g={};let p=!1;for(const m of Object.keys(l))_o.has(m)||(g[m]=l[m],p=!0);return p&&(c.extras=g),c}function yo(e){return e.results.map(M)}function vo(e){return e.product_groupings.map(t=>{const r={name:t.name,products:(t.group_products??[]).map(M)};return t.highlight!==void 0&&(r.highlight=t.highlight),r})}function bo(e){const t=e.payload.type,{type:r,...n}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:n}}}}}function vt(e){const t=[];for(const r of Object.values(e))if(r.type==="ProductCard"&&r.props){const n=r.props.product??r.props;typeof n.sku=="string"&&typeof n.name=="string"&&t.push(n)}return t}function bt(e){const t=e.headers.get("Content-Type")??"";return t.includes("application/x-ndjson")||t.includes("text/event-stream")}async function wo(e,t){const r=[],n={onEvent:o=>{const i=gt(o);!i||i.type!=="ui_spec"||r.push(...vt(i.spec.elements))}};return t!==void 0&&(n.signal=t),await pt(e,n),r}async function ko(e,t,r){const n=ut("similar_products",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await fetch(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(bt(i))return wo(i,r);const a=await i.text();if(!a)throw new Error("Empty response body from similar_products endpoint");try{return yo(JSON.parse(a))}catch{throw new Error("Invalid JSON from similar_products endpoint")}}async function So(e,t){const r=[];let n=null;const o={onEvent:i=>{const a=gt(i);if(a){if(a.type==="metadata"&&a.meta){const s=a.meta.group_name;if(typeof s=="string"){n={name:s,products:[]};const c=a.meta.highlight;typeof c=="string"&&(n.highlight=c),r.push(n)}}a.type==="ui_spec"&&n&&n.products.push(...vt(a.spec.elements))}}};return t!==void 0&&(o.signal=t),await pt(e,o),r}async function Eo(e,t,r){const n=ut("product_groupings",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await fetch(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(bt(i))return So(i,r);const a=await i.text();if(!a)return[];try{return vo(JSON.parse(a))}catch{throw new Error("Invalid JSON from product_groupings endpoint")}}var Co={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function wt(e,t){const r=Number(e);if(!Number.isFinite(r)||r<0)return e;const n={...Co,...t},o=Math.abs(r%1)<Number.EPSILON,i=n.alwaysShowDecimals||!o?r.toFixed(2):r.toFixed(0),a=i.indexOf("."),s=a===-1?i:i.slice(0,a),c=a===-1?void 0:i.slice(a+1),u=s.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousandsSeparator);let l;return c!==void 0?l=`${u}${n.decimalSeparator}${c}`:l=u,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${l}`:`${l} ${n.currencySymbol}`:l}function zo(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function To(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Io(e){const t=zo(e),r=Math.floor(t),n=t-r>=.5,o=5-r-(n?1:0),i=document.createElement("span");if(i.className="gengage-star-rating",i.setAttribute("role","img"),i.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),r>0&&i.appendChild(document.createTextNode("★".repeat(r))),n){const a=document.createElement("span");a.className="gengage-star-half",a.textContent="☆";const s=document.createElement("span");s.textContent="★",a.appendChild(s),i.appendChild(a)}return o>0&&i.appendChild(document.createTextNode("☆".repeat(o))),i}function $o(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function kt(e){const{product:t,index:r,discountType:n,onClick:o,onAddToCart:i,renderCard:a}=e,s=e.i18n,c=e.pricing;if(e.renderCardElement){const f=e.renderCardElement(t,r);if(f)return f}if(a){const f=document.createElement("div");return f.className="gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive",f.dataset.gengagePart="simrel-product-card",f.innerHTML=Jr(a(t,r)),f.addEventListener("click",h=>{h.target.closest(".gengage-simrel-atc")||h.target.closest(".gengage-chat-product-card-atc")||o(t)}),f}const u=document.createElement("article");u.className="gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive",u.dataset.gengagePart="simrel-product-card",t.inStock===!1&&u.classList.add("gengage-simrel-card--out-of-stock"),u.setAttribute("role","listitem"),u.dataset.sku=t.sku;const l=document.createElement("div");if(l.className="gengage-simrel-card-image gengage-chat-product-card-img-wrapper",l.dataset.gengagePart="simrel-product-card-image",t.imageUrl&&Gr(t.imageUrl)){const f=document.createElement("img");f.className="gengage-chat-product-card-img",f.src=t.imageUrl,f.alt=t.name,f.loading="lazy",$o(f),l.appendChild(f)}if(n==="badge"&&t.discountPercent&&t.discountPercent>0){const f=document.createElement("span");f.className="gengage-simrel-badge gengage-chat-product-card-discount-badge",f.textContent=`%${To(t.discountPercent)}`,l.appendChild(f)}u.appendChild(l);const g=document.createElement("div");if(g.className="gengage-simrel-card-info gengage-chat-product-card-body",g.dataset.gengagePart="simrel-product-card-body",t.brand){const f=document.createElement("div");f.className="gengage-simrel-card-brand gengage-chat-product-card-brand",f.textContent=t.brand,g.appendChild(f)}const p=document.createElement("div");if(p.className="gengage-simrel-card-name gengage-chat-product-card-name",p.textContent=t.name,p.title=t.name,g.appendChild(p),t.rating!=null&&t.rating>0){const f=document.createElement("div");if(f.className="gengage-simrel-card-rating gengage-chat-product-card-rating",f.appendChild(Io(t.rating)),t.reviewCount!=null){const h=document.createElement("span");h.className="gengage-simrel-card-review-count gengage-chat-product-card-review-count",h.textContent=` (${t.reviewCount})`,f.appendChild(h)}g.appendChild(f)}const m=document.createElement("div");if(m.className="gengage-simrel-card-price gengage-chat-product-card-price",t.originalPrice&&t.originalPrice!==t.price&&(n==="strike-through"||!n)){const f=document.createElement("span");f.className="gengage-simrel-card-price-original gengage-chat-product-card-original-price",f.textContent=wt(t.originalPrice,c),m.appendChild(f)}if(t.price&&parseFloat(t.price)>0){const f=document.createElement("span");f.className="gengage-simrel-card-price-current gengage-chat-product-card-price-current",f.textContent=wt(t.price,c),m.appendChild(f)}g.appendChild(m),u.appendChild(g);const _=document.createElement("button");if(_.className="gengage-simrel-card-cta gengage-chat-product-card-cta gds-btn gds-btn-secondary",_.type="button",_.dataset.gengagePart="simrel-product-card-cta",_.textContent=s?.ctaLabel??"View",_.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),o(t)}),u.appendChild(_),t.inStock===!1){const f=document.createElement("div");f.className="gengage-simrel-card-oos",f.textContent=s?.outOfStockLabel??"Out of Stock",u.appendChild(f)}else if(t.cartCode){const f=document.createElement("button");f.className="gengage-simrel-atc gengage-simrel-atc-button gds-btn gds-btn-secondary",f.type="button",f.textContent=s?.addToCartButton??"Add to Cart",f.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),i({sku:t.sku,quantity:1,cartCode:t.cartCode})}),u.appendChild(f)}return u.addEventListener("click",f=>{f.target.closest(".gengage-simrel-atc")||f.target.closest(".gengage-chat-product-card-atc")||f.target.closest(".gengage-chat-product-card-cta")||o(t)}),u}function St(e){const t=document.createElement("div");t.className="gengage-simrel-grid",t.setAttribute("role","list"),t.setAttribute("aria-label",e.i18n?.similarProductsAriaLabel??"Similar products"),e.columns&&t.style.setProperty("--gengage-simrel-columns",String(e.columns));for(let r=0;r<e.products.length;r++){const n={product:e.products[r],index:r,onClick:e.onClick,onAddToCart:e.onAddToCart};e.i18n!==void 0&&(n.i18n=e.i18n),e.discountType!==void 0&&(n.discountType=e.discountType),e.renderCard!==void 0&&(n.renderCard=e.renderCard),e.renderCardElement!==void 0&&(n.renderCardElement=e.renderCardElement);const o=kt(n);t.appendChild(o)}return e.products.length===0&&(t.style.display="none",t.dataset.empty="true"),t}var Ao=0;function Po(e){const t=Ao++,r=document.createElement("div");if(r.className="gengage-simrel-groups",r.dataset.gengagePart="simrel-groups",e.groups.length===0)return r.style.display="none",r.dataset.empty="true",r;const n=document.createElement("div");n.className="gengage-simrel-tabs gds-toolbar",n.dataset.gengagePart="simrel-tab-bar",n.setAttribute("role","tablist");const o=[],i=[];let a=0;const s=h=>{const v={products:h.products,onClick:e.onClick,onAddToCart:e.onAddToCart};return e.i18n!==void 0&&(v.i18n=e.i18n),e.discountType!==void 0&&(v.discountType=e.discountType),e.renderCard!==void 0&&(v.renderCard=e.renderCard),e.renderCardElement!==void 0&&(v.renderCardElement=e.renderCardElement),e.columns!==void 0&&(v.columns=e.columns),v},c=(h,v=!1)=>{if(v&&h!==a&&e.onGroupingActivate){const w=e.groups[h];e.onGroupingActivate({grouping_label:w.name,grouping_index:h})}a=h;for(let w=0;w<o.length;w++){const A=w===h;o[w].classList.toggle("gengage-simrel-tab--active",A),o[w].setAttribute("aria-selected",String(A)),o[w].tabIndex=A?0:-1}const x=e.groups[h],z=i[h];z.innerHTML="";const k=St(s(x));z.appendChild(k);for(let w=0;w<i.length;w++){const A=w===h;i[w].style.display=A?"":"none",i[w].tabIndex=A?0:-1}};for(let h=0;h<e.groups.length;h++){const v=e.groups[h],x=`gengage-simrel-tab-${t}-${h}`,z=`gengage-simrel-panel-${t}-${h}`,k=document.createElement("button");k.className="gengage-simrel-tab gds-tab",k.type="button",k.dataset.gengagePart="simrel-tab",k.id=x,k.textContent=v.name,k.setAttribute("role","tab"),k.setAttribute("aria-controls",z),k.setAttribute("aria-selected",String(h===0)),k.tabIndex=h===0?0:-1,h===0&&k.classList.add("gengage-simrel-tab--active"),k.addEventListener("click",()=>c(h,!0)),k.addEventListener("keydown",A=>{let Y=-1;A.key==="ArrowRight"||A.key==="ArrowDown"?Y=(h+1)%e.groups.length:A.key==="ArrowLeft"||A.key==="ArrowUp"?Y=(h-1+e.groups.length)%e.groups.length:A.key==="Home"?Y=0:A.key==="End"&&(Y=e.groups.length-1),Y>=0&&(A.preventDefault(),c(Y,!0),o[Y].focus())}),o.push(k),n.appendChild(k);const w=document.createElement("div");w.className="gengage-simrel-tab-panel",w.dataset.gengagePart="simrel-tab-panel",w.id=z,w.setAttribute("role","tabpanel"),w.setAttribute("aria-labelledby",x),w.tabIndex=h===0?0:-1,h!==0&&(w.style.display="none"),i.push(w)}const u=document.createElement("button");u.type="button",u.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--left",u.setAttribute("aria-label",e.i18n?.scrollTabsLeft??"Scroll tabs left"),u.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>';const l=document.createElement("button");l.type="button",l.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--right",l.setAttribute("aria-label",e.i18n?.scrollTabsRight??"Scroll tabs right"),l.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>';const g=200;u.addEventListener("click",()=>{n.scrollBy({left:-g,behavior:"smooth"})}),l.addEventListener("click",()=>{n.scrollBy({left:g,behavior:"smooth"})});const p=()=>{const h=n.scrollLeft<=4,v=n.scrollLeft+n.clientWidth>=n.scrollWidth-4;u.style.display=h?"none":"",l.style.display=v?"none":"",n.classList.toggle("gengage-simrel-tabs--peek-right",!v),n.classList.toggle("gengage-simrel-tabs--peek-left",!h)};n.addEventListener("scroll",p,{passive:!0}),typeof ResizeObserver<"u"&&new ResizeObserver(p).observe(n),u.style.display="none",l.style.display="none",requestAnimationFrame(p);const m=document.createElement("div");m.className="gengage-simrel-tabs-wrapper",m.appendChild(u),m.appendChild(n),m.appendChild(l),r.appendChild(m);const _=i[0],f=St(s(e.groups[0]));_.appendChild(f);for(const h of i)r.appendChild(h);return r}function Et(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.sku!="string"||typeof t.name!="string"||typeof t.url!="string")return null;const r={sku:t.sku,name:t.name,url:t.url},n=t.imageUrl;typeof n=="string"&&(r.imageUrl=n);const o=t.price;typeof o=="string"&&(r.price=o);const i=t.originalPrice;typeof i=="string"&&(r.originalPrice=i);const a=t.discountPercent;typeof a=="number"&&(r.discountPercent=a);const s=t.brand;typeof s=="string"&&(r.brand=s);const c=t.rating;typeof c=="number"&&(r.rating=c);const u=t.reviewCount;typeof u=="number"&&(r.reviewCount=u);const l=t.cartCode;typeof l=="string"&&(r.cartCode=l);const g=t.inStock;typeof g=="boolean"&&(r.inStock=g);const p=t.extras;return p!=null&&typeof p=="object"&&(r.extras=p),r}function No(e){if(!e||typeof e!="object")return null;const t=e,r=t.title,n=t.type;if(typeof r!="string"||typeof n!="string")return null;const o={title:r,type:n};return t.payload!==void 0&&(o.payload=t.payload),o}var Ct={ProductGrid:({element:e,renderElement:t,context:r})=>{const n=document.createElement("div");n.className="gengage-simrel-grid",n.setAttribute("role","list");const o=e.props?.columns;let i;typeof o=="number"&&Number.isFinite(o)&&o>0?i=Math.floor(o):typeof r.gridColumns=="number"&&Number.isFinite(r.gridColumns)&&r.gridColumns>0&&(i=Math.floor(r.gridColumns)),i!==void 0&&n.style.setProperty("--gengage-simrel-columns",String(i));for(const a of e.children??[]){const s=t(a);s&&n.appendChild(s)}if(n.children.length===0){const a=document.createElement("div");a.className="gengage-simrel-empty",a.textContent=r.i18n.emptyStateMessage,n.appendChild(a)}return n},ProductCard:({element:e,context:t})=>{const r=Et(e.props?.product??e.props);if(!r)return null;const n=e.props?.index,o=typeof n=="number"&&Number.isFinite(n)?n:0,i=e.props?.discountType,a=i==="strike-through"||i==="badge"?i:t.discountType,s={product:r,index:o,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return a!==void 0&&(s.discountType=a),t.renderCard!==void 0&&(s.renderCard=t.renderCard),t.renderCardElement!==void 0&&(s.renderCardElement=t.renderCardElement),t.pricing!==void 0&&(s.pricing=t.pricing),kt(s)},GroupTabs:({element:e,context:t})=>{const r=e.props?.groups;if(!Array.isArray(r))return null;const n=[];for(const a of r){if(!a||typeof a!="object")continue;const s=a;if(typeof s.name!="string")continue;const c=[];if(Array.isArray(s.products))for(const l of s.products){const g=Et(l);g&&c.push(g)}const u={name:s.name,products:c};typeof s.highlight=="string"&&(u.highlight=s.highlight),n.push(u)}const o={groups:n,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n},i=e.props?.columns;return typeof i=="number"&&Number.isFinite(i)&&i>0?o.columns=Math.floor(i):typeof t.gridColumns=="number"&&Number.isFinite(t.gridColumns)&&t.gridColumns>0&&(o.columns=Math.floor(t.gridColumns)),t.discountType!==void 0&&(o.discountType=t.discountType),t.renderCard!==void 0&&(o.renderCard=t.renderCard),t.renderCardElement!==void 0&&(o.renderCardElement=t.renderCardElement),t.onGroupingActivate!==void 0&&(o.onGroupingActivate=t.onGroupingActivate),Po(o)},EmptyState:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-empty";const n=e.props?.message;return r.textContent=typeof n=="string"?n:t.i18n.emptyStateMessage,r},AddToCartButton:({element:e,context:t})=>{const r=e.props?.sku,n=e.props?.cartCode;if(typeof r!="string"||typeof n!="string")return null;const o=document.createElement("button");o.className="gengage-simrel-atc gengage-chat-product-card-cta",o.type="button";const i=e.props?.label;return o.textContent=typeof i=="string"?i:t.i18n.addToCartButton,o.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),t.onAddToCart({sku:r,quantity:1,cartCode:n})}),o},QuickActions:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-quick-actions";const n=e.props?.actions;if(!Array.isArray(n)||!t.onAction)return r;for(const o of n){if(!o||typeof o!="object")continue;const i=o,a=i.label,s=No(i.action);if(typeof a!="string"||!s)continue;const c=document.createElement("button");c.className="gengage-simrel-quick-action",c.type="button",c.textContent=a,c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),t.onAction?.(s)}),r.appendChild(c)}return r}},Oe=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const r=document.createElement("div");for(const n of e.children){const o=t(n);o&&r.appendChild(o)}return r};function zt(){return{...Ct}}function Tt(e,t,r=Ct,n=Oe){return $r({spec:e,context:t,registry:r,containerClassName:"gengage-simrel-uispec",unknownRenderer:n})}var It={similarProductsAriaLabel:"Benzer ürünler",emptyStateMessage:"Benzer ürün bulunamadı.",addToCartButton:"Sepete Ekle",ctaLabel:"İncele",outOfStockLabel:"Stokta Yok",decreaseLabel:"Azalt",increaseLabel:"Artır",errorLoadingMessage:"Benzer ürünler yüklenemedi.",retryButtonText:"Tekrar dene",priceSuffix:" TL",scrollTabsLeft:"Sola kaydır",scrollTabsRight:"Sağa kaydır"},Oo={similarProductsAriaLabel:"Similar products",emptyStateMessage:"No similar products found.",addToCartButton:"Add to cart",ctaLabel:"View",outOfStockLabel:"Out of Stock",decreaseLabel:"Decrease",increaseLabel:"Increase",errorLoadingMessage:"Could not load similar products.",retryButtonText:"Try again",priceSuffix:"",scrollTabsLeft:"Scroll tabs left",scrollTabsRight:"Scroll tabs right"};function Zo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Ro(e){return Zo(e)==="en"?Oo:It}var _u=Object.freeze({status:"aborted"});function d(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const u=a.prototype,l=Object.keys(u);for(let g=0;g<l.length;g++){const p=l[g];p in s||(s[p]=u[p].bind(s))}}const o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(s){var c;const u=r?.Parent?new i:this;n(u,s),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var X=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},$t=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}},Ze={};function W(e){return e&&Object.assign(Ze,e),Ze}function At(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function Re(e,t){return typeof t=="bigint"?t.toString():t}function xe(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function Le(e){return e==null}function De(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function xo(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){const a=n.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}const i=r>o?r:o;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}var Pt=Symbol("evaluating");function S(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Pt)return n===void 0&&(n=Pt,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function H(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function F(...e){const t={};for(const r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function Nt(e){return JSON.stringify(e)}function Lo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Ot="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function fe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Do=xe(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function se(e){if(fe(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(fe(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Zt(e){return se(e)?{...e}:Array.isArray(e)?[...e]:e}var jo=new Set(["string","number","symbol"]);function ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}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 Uo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Mo={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 Fo(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return q(e,F(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=r.shape[i])}return H(this,"shape",o),o},checks:[]}))}function qo(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return q(e,F(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return H(this,"shape",o),o},checks:[]}))}function Go(e,t){if(!se(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const n=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(n,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return q(e,F(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return H(this,"shape",n),n}}))}function Jo(e,t){if(!se(t))throw new Error("Invalid input to safeExtend: expected a plain object");return q(e,F(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return H(this,"shape",r),r}}))}function Bo(e,t){return q(e,F(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return H(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]}))}function Vo(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return q(t,F(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(r)for(const a in r){if(!(a in o))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=e?new e({type:"optional",innerType:o[a]}):o[a])}else for(const a in o)i[a]=e?new e({type:"optional",innerType:o[a]}):o[a];return H(this,"shape",i),i},checks:[]}))}function Wo(e,t,r){return q(t,F(t._zod.def,{get shape(){const n=t._zod.def.shape,o={...n};if(r)for(const i in r){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(o[i]=new e({type:"nonoptional",innerType:n[i]}))}else for(const i in n)o[i]=new e({type:"nonoptional",innerType:n[i]});return H(this,"shape",o),o}}))}function ee(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Rt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function me(e){return typeof e=="string"?e:e?.message}function K(e,t,r){const n={...e,path:e.path??[]};return e.message||(n.message=me(e.inst?._zod.def?.error?.(e))??me(t?.error?.(e))??me(r.customError?.(e))??me(r.localeError?.(e))??"Invalid input"),delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function je(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ce(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var xt=(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,Re,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Lt=d("$ZodError",xt),Dt=d("$ZodError",xt,{Parent:Error});function Ho(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Ko(e,t=r=>r.message){const r={_errors:[]},n=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let a=r,s=0;for(;s<i.path.length;){const c=i.path[s];s!==i.path.length-1?a[c]=a[c]||{_errors:[]}:(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(i))),a=a[c],s++}}};return n(e),r}var Ue=e=>(t,r,n,o)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new X;if(a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>K(c,i,W())));throw Ot(s,o?.callee),s}return a.value},Me=e=>async(t,r,n,o)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>K(c,i,W())));throw Ot(s,o?.callee),s}return a.value},he=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new X;return i.issues.length?{success:!1,error:new(e??Lt)(i.issues.map(a=>K(a,o,W())))}:{success:!0,data:i.value}},Yo=he(Dt),_e=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>K(a,o,W())))}:{success:!0,data:i.value}},Qo=_e(Dt),Xo=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ue(e)(t,r,o)},ei=e=>(t,r,n)=>Ue(e)(t,r,n),ti=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Me(e)(t,r,o)},ri=e=>async(t,r,n)=>Me(e)(t,r,n),ni=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return he(e)(t,r,o)},oi=e=>(t,r,n)=>he(e)(t,r,n),ii=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _e(e)(t,r,o)},ai=e=>async(t,r,n)=>_e(e)(t,r,n),si=/^[cC][^\s-]{8,}$/,ci=/^[0-9a-z]+$/,ui=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,di=/^[0-9a-vA-V]{20}$/,li=/^[A-Za-z0-9]{27}$/,pi=/^[a-zA-Z0-9_-]{21}$/,fi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gi=/^([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})$/,jt=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)$/,mi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,hi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function _i(){return new RegExp(hi,"u")}var yi=/^(?:(?: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])$/,vi=/^(([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}|:))$/,bi=/^((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])$/,wi=/^(([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])$/,ki=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ut=/^[A-Za-z0-9_-]*$/,Si=/^\+[1-9]\d{6,14}$/,Mt="(?:(?:\\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])))",Ei=new RegExp(`^${Mt}$`);function Ft(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(`^${Ft(e)}$`)}function zi(e){const t=Ft({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Mt}T(?:${n})$`)}var Ti=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ii=/^-?\d+$/,$i=/^-?\d+(?:\.\d+)?$/,Ai=/^[^A-Z]*$/,Pi=/^[^a-z]*$/,N=d("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),qt={number:"number",bigint:"bigint",object:"date"},Gt=d("$ZodCheckLessThan",(e,t)=>{N.init(e,t);const r=qt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jt=d("$ZodCheckGreaterThan",(e,t)=>{N.init(e,t);const r=qt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ni=d("$ZodCheckMultipleOf",(e,t)=>{N.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):xo(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Oi=d("$ZodCheckNumberFormat",(e,t)=>{N.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,i]=Mo[t.format];e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,s.minimum=o,s.maximum=i,r&&(s.pattern=Ii)}),e._zod.check=a=>{const s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<o&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Zi=d("$ZodCheckMaxLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=je(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ri=d("$ZodCheckMinLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=je(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),xi=d("$ZodCheckLengthEquals",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const a=je(o),s=i>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ye=d("$ZodCheckStringFormat",(e,t)=>{var r,n;N.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Li=d("$ZodCheckRegex",(e,t)=>{ye.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Di=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ai),ye.init(e,t)}),ji=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Pi),ye.init(e,t)}),Ui=d("$ZodCheckIncludes",(e,t)=>{N.init(e,t);const r=ge(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Mi=d("$ZodCheckStartsWith",(e,t)=>{N.init(e,t);const r=new RegExp(`^${ge(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Fi=d("$ZodCheckEndsWith",(e,t)=>{N.init(e,t);const r=new RegExp(`.*${ge(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),qi=d("$ZodCheckOverwrite",(e,t)=>{N.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),Gi=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const t=e.split(`
|
|
49
49
|
`).filter(o=>o),r=Math.min(...t.map(o=>o.length-o.trimStart().length)),n=t.map(o=>o.slice(r)).map(o=>" ".repeat(this.indent*2)+o);for(const o of n)this.content.push(o)}compile(){const e=Function,t=this?.args,r=[...(this?.content??[""]).map(n=>` ${n}`)];return new e(...t,r.join(`
|
|
50
|
-
`))}},Ji={major:4,minor:3,patch:6},T=d("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ji;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,s,c)=>{let u=ee(a),l;for(const g of s){if(g._zod.def.when){if(!g._zod.def.when(a))continue}else if(u)continue;const
|
|
50
|
+
`))}},Ji={major:4,minor:3,patch:6},T=d("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ji;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,s,c)=>{let u=ee(a),l;for(const g of s){if(g._zod.def.when){if(!g._zod.def.when(a))continue}else if(u)continue;const p=a.issues.length,m=g._zod.check(a);if(m instanceof Promise&&c?.async===!1)throw new X;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(u||(u=ee(a,p)))});else{if(a.issues.length===p)continue;u||(u=ee(a,p))}}return l?l.then(()=>a):a},i=(a,s,c)=>{if(ee(a))return a.aborted=!0,a;const u=o(s,n,c);if(u instanceof Promise){if(c.async===!1)throw new X;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(l=>i(l,a,s)):i(u,a,s)}const c=e._zod.parse(a,s);if(c instanceof Promise){if(s.async===!1)throw new X;return c.then(u=>o(u,n,s))}return o(c,n,s)}}S(e,"~standard",()=>({validate:o=>{try{const i=Yo(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Qo(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Fe=d("$ZodString",(e,t)=>{T.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ti(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),E=d("$ZodStringFormat",(e,t)=>{ye.init(e,t),Fe.init(e,t)}),Bi=d("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=gi),E.init(e,t)}),Vi=d("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=jt(r))}else t.pattern??(t.pattern=jt());E.init(e,t)}),Wi=d("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=mi),E.init(e,t)}),Hi=d("$ZodURL",(e,t)=>{E.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Ki=d("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=_i()),E.init(e,t)}),Yi=d("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=pi),E.init(e,t)}),Qi=d("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=si),E.init(e,t)}),Xi=d("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ci),E.init(e,t)}),ea=d("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ui),E.init(e,t)}),ta=d("$ZodXID",(e,t)=>{t.pattern??(t.pattern=di),E.init(e,t)}),ra=d("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=li),E.init(e,t)}),na=d("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zi(t)),E.init(e,t)}),oa=d("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ei),E.init(e,t)}),ia=d("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ci(t)),E.init(e,t)}),aa=d("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=fi),E.init(e,t)}),sa=d("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=yi),E.init(e,t),e._zod.bag.format="ipv4"}),ca=d("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=vi),E.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),ua=d("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=bi),E.init(e,t)}),da=d("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=wi),E.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[o,i]=n;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Bt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var la=d("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ki),E.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Bt(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function pa(e){if(!Ut.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/");return Bt(t.padEnd(Math.ceil(t.length/4)*4,"="))}var fa=d("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ut),E.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{pa(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ga=d("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Si),E.init(e,t)});function ma(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var ha=d("$ZodJWT",(e,t)=>{E.init(e,t),e._zod.check=r=>{ma(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Vt=d("$ZodNumber",(e,t)=>{T.init(e,t),e._zod.pattern=e._zod.bag.pattern??$i,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),_a=d("$ZodNumberFormat",(e,t)=>{Oi.init(e,t),Vt.init(e,t)}),ya=d("$ZodUnknown",(e,t)=>{T.init(e,t),e._zod.parse=r=>r}),va=d("$ZodNever",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Wt(e,t,r){e.issues.length&&t.issues.push(...Rt(r,e.issues)),t.value[r]=e.value}var ba=d("$ZodArray",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const s=o[a],c=t.element._zod.run({value:s,issues:[]},n);c instanceof Promise?i.push(c.then(u=>Wt(u,r,a))):Wt(c,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function ve(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...Rt(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Ht(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=Uo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Kt(e,t,r,n,o,i){const a=[],s=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optout==="optional";for(const g in t){if(s.has(g))continue;if(u==="never"){a.push(g);continue}const p=c.run({value:t[g],issues:[]},n);p instanceof Promise?e.push(p.then(m=>ve(m,r,g,t,l))):ve(p,r,g,t,l)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var wa=d("$ZodObject",(e,t)=>{if(T.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const s={...a};return Object.defineProperty(t,"shape",{value:s}),s}})}const r=xe(()=>Ht(t));S(e._zod,"propValues",()=>{const a=t.shape,s={};for(const c in a){const u=a[c]._zod;if(u.values){s[c]??(s[c]=new Set);for(const l of u.values)s[c].add(l)}}return s});const n=fe,o=t.catchall;let i;e._zod.parse=(a,s)=>{i??(i=r.value);const c=a.value;if(!n(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),a;a.value={};const u=[],l=i.shape;for(const g of i.keys){const p=l[g],m=p._zod.optout==="optional",_=p._zod.run({value:c[g],issues:[]},s);_ instanceof Promise?u.push(_.then(f=>ve(f,a,g,c,m))):ve(_,a,g,c,m)}return o?Kt(u,c,a,s,r.value,e):u.length?Promise.all(u).then(()=>a):a}}),ka=d("$ZodObjectJIT",(e,t)=>{wa.init(e,t);const r=e._zod.parse,n=xe(()=>Ht(t)),o=p=>{const m=new Gi(["shape","payload","ctx"]),_=n.value,f=z=>{const k=Nt(z);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};m.write("const input = payload.value;");const h=Object.create(null);let v=0;for(const z of _.keys)h[z]=`key_${v++}`;m.write("const newResult = {};");for(const z of _.keys){const k=h[z],w=Nt(z),A=p[z]?._zod?.optout==="optional";m.write(`const ${k} = ${f(z)};`),A?m.write(`
|
|
51
51
|
if (${k}.issues.length) {
|
|
52
52
|
if (${w} in input) {
|
|
53
53
|
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
@@ -81,6 +81,6 @@
|
|
|
81
81
|
newResult[${w}] = ${k}.value;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const x=m.compile();return(z,k)=>x(f,z,k)};let i;const a=pe,s=!Ze.jitless,u=s&&Do.value,l=t.catchall;let g;e._zod.parse=(f,m)=>{g??(g=n.value);const _=f.value;return a(_)?s&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),f=i(f,m),l?Kt([],_,f,m,g,e):f):r(f,m):(f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f)}});function Yt(e,t,r,n){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:r,errors:e.map(i=>i.issues.map(a=>K(a,n,W())))}),t)}var Sa=d("$ZodUnion",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),S(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>De(i.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let a=!1;const s=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(c=>Yt(c,o,e,i)):Yt(s,o,e,i)}}),Ea=d("$ZodIntersection",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,i=t.left._zod.run({value:o,issues:[]},n),a=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([s,c])=>Qt(r,s,c)):Qt(r,i,a)}});function Ge(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(se(e)&&se(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(const i of n){const a=Ge(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=e[n],i=t[n],a=Ge(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Qt(e,t,r){const n=new Map;let o;for(const s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(const c of s.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(s);for(const s of r.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(s);const i=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),ee(e))return e;const a=Ge(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var Ca=d("$ZodEnum",(e,t)=>{T.init(e,t);const r=At(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>jo.has(typeof o)).map(o=>typeof o=="string"?ge(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:r,input:a,inst:e}),o}}),za=d("$ZodTransform",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new $t(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new X;return r.value=o,r}});function Xt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var er=d("$ZodOptional",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${De(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Xt(i,r.value)):Xt(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Ta=d("$ZodExactOptional",(e,t)=>{er.init(e,t),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Ia=d("$ZodNullable",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${De(r.source)}|null)$`):void 0}),S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),$a=d("$ZodDefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>tr(i,t)):tr(o,t)}});function tr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Aa=d("$ZodPrefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Pa=d("$ZodNonOptional",(e,t)=>{T.init(e,t),S(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>rr(i,e)):rr(o,e)}});function rr(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 Na=d("$ZodCatch",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>K(a,n,W()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>K(i,n,W()))},input:r.value}),r.issues=[]),r)}}),Oa=d("$ZodPipe",(e,t)=>{T.init(e,t),S(e._zod,"values",()=>t.in._zod.values),S(e._zod,"optin",()=>t.in._zod.optin),S(e._zod,"optout",()=>t.out._zod.optout),S(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(a=>be(a,t.in,n)):be(i,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>be(i,t.out,n)):be(o,t.out,n)}});function be(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Za=d("$ZodReadonly",(e,t)=>{T.init(e,t),S(e._zod,"propValues",()=>t.innerType._zod.propValues),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"optin",()=>t.innerType?._zod?.optin),S(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(nr):nr(o)}});function nr(e){return e.value=Object.freeze(e.value),e}var Ra=d("$ZodCustom",(e,t)=>{N.init(e,t),T.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>or(i,r,n,e));or(o,r,n,e)}});function or(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(ce(o))}}var ir,xa=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.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 r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function La(){return new xa}(ir=globalThis).__zod_globalRegistry??(ir.__zod_globalRegistry=La());var ue=globalThis.__zod_globalRegistry;function Da(e,t){return new e({type:"string",...y(t)})}function ja(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function ar(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Ua(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Ma(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Fa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Ga(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function qa(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Ja(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Ba(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Va(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Wa(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function Ha(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function Ka(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function Ya(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function Qa(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function Xa(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function es(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function ts(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function rs(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function ns(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function os(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function is(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function as(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function ss(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function cs(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function us(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function ds(e,t){return new e({type:"number",checks:[],...y(t)})}function ls(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...y(t)})}function fs(e){return new e({type:"unknown"})}function ps(e,t){return new e({type:"never",...y(t)})}function sr(e,t){return new qt({check:"less_than",...y(t),value:e,inclusive:!1})}function qe(e,t){return new qt({check:"less_than",...y(t),value:e,inclusive:!0})}function cr(e,t){return new Jt({check:"greater_than",...y(t),value:e,inclusive:!1})}function Je(e,t){return new Jt({check:"greater_than",...y(t),value:e,inclusive:!0})}function ur(e,t){return new Ni({check:"multiple_of",...y(t),value:e})}function dr(e,t){return new Zi({check:"max_length",...y(t),maximum:e})}function we(e,t){return new Ri({check:"min_length",...y(t),minimum:e})}function lr(e,t){return new xi({check:"length_equals",...y(t),length:e})}function gs(e,t){return new Li({check:"string_format",format:"regex",...y(t),pattern:e})}function ms(e){return new Di({check:"string_format",format:"lowercase",...y(e)})}function hs(e){return new ji({check:"string_format",format:"uppercase",...y(e)})}function _s(e,t){return new Ui({check:"string_format",format:"includes",...y(t),includes:e})}function ys(e,t){return new Mi({check:"string_format",format:"starts_with",...y(t),prefix:e})}function vs(e,t){return new Fi({check:"string_format",format:"ends_with",...y(t),suffix:e})}function te(e){return new Gi({check:"overwrite",tx:e})}function bs(e){return te(t=>t.normalize(e))}function ws(){return te(e=>e.trim())}function ks(){return te(e=>e.toLowerCase())}function Ss(){return te(e=>e.toUpperCase())}function Es(){return te(e=>Lo(e))}function Cs(e,t,r){return new e({type:"array",element:t,...y(r)})}function zs(e,t,r){return new e({type:"custom",check:"custom",fn:t,...y(r)})}function Ts(e){const t=Is(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ce(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(ce(o))}},e(r.value,r)));return t}function Is(e,t){const r=new N({check:"custom",...y(t)});return r._zod.check=e,r}function fr(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??ue,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,r={path:[],schemaPath:[]}){var n;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{const g=a.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,g,u)}const l=e._zod.parent;l&&(a.ref||(a.ref=l),$(l,t,u),t.seen.get(l).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&P(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function pr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const a of e.seen.entries()){const s=e.metadataRegistry.get(a[0])?.id;if(s){const c=n.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,a[0])}}const o=a=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const l=e.external.registry.get(a[0])?.id,g=e.external.uri??(m=>m);if(l)return{ref:g(l)};const f=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=f,{defId:f,ref:`${g("__shared")}#/${s}/${f}`}}if(a[1]===r)return{ref:"#"};const c=`#/${s}/`,u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},i=a=>{if(a[1].schema.$ref)return;const s=a[1],{ref:c,defId:u}=o(a);s.def={...s.schema},u&&(s.defId=u);const l=s.schema;for(const g in l)delete l[g];l.$ref=c};if(e.cycles==="throw")for(const a of e.seen.entries()){const s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
84
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const x=m.compile();return(z,k)=>x(p,z,k)};let i;const a=fe,s=!Ze.jitless,u=s&&Do.value,l=t.catchall;let g;e._zod.parse=(p,m)=>{g??(g=n.value);const _=p.value;return a(_)?s&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),p=i(p,m),l?Kt([],_,p,m,g,e):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),p)}});function Yt(e,t,r,n){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:r,errors:e.map(i=>i.issues.map(a=>K(a,n,W())))}),t)}var Sa=d("$ZodUnion",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),S(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>De(i.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let a=!1;const s=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(c=>Yt(c,o,e,i)):Yt(s,o,e,i)}}),Ea=d("$ZodIntersection",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,i=t.left._zod.run({value:o,issues:[]},n),a=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([s,c])=>Qt(r,s,c)):Qt(r,i,a)}});function qe(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(se(e)&&se(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(const i of n){const a=qe(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=e[n],i=t[n],a=qe(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Qt(e,t,r){const n=new Map;let o;for(const s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(const c of s.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(s);for(const s of r.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(s);const i=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),ee(e))return e;const a=qe(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var Ca=d("$ZodEnum",(e,t)=>{T.init(e,t);const r=At(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>jo.has(typeof o)).map(o=>typeof o=="string"?ge(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:r,input:a,inst:e}),o}}),za=d("$ZodTransform",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new $t(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new X;return r.value=o,r}});function Xt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var er=d("$ZodOptional",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${De(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Xt(i,r.value)):Xt(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Ta=d("$ZodExactOptional",(e,t)=>{er.init(e,t),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Ia=d("$ZodNullable",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${De(r.source)}|null)$`):void 0}),S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),$a=d("$ZodDefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>tr(i,t)):tr(o,t)}});function tr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Aa=d("$ZodPrefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Pa=d("$ZodNonOptional",(e,t)=>{T.init(e,t),S(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>rr(i,e)):rr(o,e)}});function rr(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 Na=d("$ZodCatch",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>K(a,n,W()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>K(i,n,W()))},input:r.value}),r.issues=[]),r)}}),Oa=d("$ZodPipe",(e,t)=>{T.init(e,t),S(e._zod,"values",()=>t.in._zod.values),S(e._zod,"optin",()=>t.in._zod.optin),S(e._zod,"optout",()=>t.out._zod.optout),S(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(a=>be(a,t.in,n)):be(i,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>be(i,t.out,n)):be(o,t.out,n)}});function be(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Za=d("$ZodReadonly",(e,t)=>{T.init(e,t),S(e._zod,"propValues",()=>t.innerType._zod.propValues),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"optin",()=>t.innerType?._zod?.optin),S(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(nr):nr(o)}});function nr(e){return e.value=Object.freeze(e.value),e}var Ra=d("$ZodCustom",(e,t)=>{N.init(e,t),T.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>or(i,r,n,e));or(o,r,n,e)}});function or(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(ce(o))}}var ir,xa=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.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 r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function La(){return new xa}(ir=globalThis).__zod_globalRegistry??(ir.__zod_globalRegistry=La());var ue=globalThis.__zod_globalRegistry;function Da(e,t){return new e({type:"string",...y(t)})}function ja(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function ar(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Ua(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Ma(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Fa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function qa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function Ga(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Ja(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Ba(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Va(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Wa(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function Ha(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function Ka(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function Ya(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function Qa(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function Xa(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function es(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function ts(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function rs(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function ns(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function os(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function is(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function as(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function ss(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function cs(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function us(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function ds(e,t){return new e({type:"number",checks:[],...y(t)})}function ls(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...y(t)})}function ps(e){return new e({type:"unknown"})}function fs(e,t){return new e({type:"never",...y(t)})}function sr(e,t){return new Gt({check:"less_than",...y(t),value:e,inclusive:!1})}function Ge(e,t){return new Gt({check:"less_than",...y(t),value:e,inclusive:!0})}function cr(e,t){return new Jt({check:"greater_than",...y(t),value:e,inclusive:!1})}function Je(e,t){return new Jt({check:"greater_than",...y(t),value:e,inclusive:!0})}function ur(e,t){return new Ni({check:"multiple_of",...y(t),value:e})}function dr(e,t){return new Zi({check:"max_length",...y(t),maximum:e})}function we(e,t){return new Ri({check:"min_length",...y(t),minimum:e})}function lr(e,t){return new xi({check:"length_equals",...y(t),length:e})}function gs(e,t){return new Li({check:"string_format",format:"regex",...y(t),pattern:e})}function ms(e){return new Di({check:"string_format",format:"lowercase",...y(e)})}function hs(e){return new ji({check:"string_format",format:"uppercase",...y(e)})}function _s(e,t){return new Ui({check:"string_format",format:"includes",...y(t),includes:e})}function ys(e,t){return new Mi({check:"string_format",format:"starts_with",...y(t),prefix:e})}function vs(e,t){return new Fi({check:"string_format",format:"ends_with",...y(t),suffix:e})}function te(e){return new qi({check:"overwrite",tx:e})}function bs(e){return te(t=>t.normalize(e))}function ws(){return te(e=>e.trim())}function ks(){return te(e=>e.toLowerCase())}function Ss(){return te(e=>e.toUpperCase())}function Es(){return te(e=>Lo(e))}function Cs(e,t,r){return new e({type:"array",element:t,...y(r)})}function zs(e,t,r){return new e({type:"custom",check:"custom",fn:t,...y(r)})}function Ts(e){const t=Is(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ce(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(ce(o))}},e(r.value,r)));return t}function Is(e,t){const r=new N({check:"custom",...y(t)});return r._zod.check=e,r}function pr(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??ue,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,r={path:[],schemaPath:[]}){var n;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{const g=a.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,g,u)}const l=e._zod.parent;l&&(a.ref||(a.ref=l),$(l,t,u),t.seen.get(l).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&P(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function fr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const a of e.seen.entries()){const s=e.metadataRegistry.get(a[0])?.id;if(s){const c=n.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,a[0])}}const o=a=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const l=e.external.registry.get(a[0])?.id,g=e.external.uri??(m=>m);if(l)return{ref:g(l)};const p=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=p,{defId:p,ref:`${g("__shared")}#/${s}/${p}`}}if(a[1]===r)return{ref:"#"};const c=`#/${s}/`,u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},i=a=>{if(a[1].schema.$ref)return;const s=a[1],{ref:c,defId:u}=o(a);s.def={...s.schema},u&&(s.defId=u);const l=s.schema;for(const g in l)delete l[g];l.$ref=c};if(e.cycles==="throw")for(const a of e.seen.entries()){const s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
85
85
|
|
|
86
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const s=a[1];if(t===a[0]){i(a);continue}if(e.external){const c=e.external.registry.get(a[0])?.id;if(t!==a[0]&&c){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}if(s.count>1&&e.reused==="ref"){i(a);continue}}}function gr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a=>{const s=e.seen.get(a);if(s.ref===null)return;const c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){n(l);const f=e.seen.get(l),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(m)):Object.assign(c,m),Object.assign(c,u),a._zod.parent===l)for(const _ in c)_==="$ref"||_==="allOf"||_ in u||delete c[_];if(m.$ref&&f.def)for(const _ in c)_==="$ref"||_==="allOf"||_ in f.def&&JSON.stringify(c[_])===JSON.stringify(f.def[_])&&delete c[_]}const g=a._zod.parent;if(g&&g!==l){n(g);const f=e.seen.get(g);if(f?.schema.$ref&&(c.$ref=f.schema.$ref,f.def))for(const m in c)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(c[m])===JSON.stringify(f.def[m])&&delete c[m]}e.override({zodSchema:a,jsonSchema:c,path:s.path??[]})};for(const a of[...e.seen.entries()].reverse())n(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,r.def??r.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:ke(t,"input",e.processors),output:ke(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function P(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return P(n.element,r);if(n.type==="set")return P(n.valueType,r);if(n.type==="lazy")return P(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return P(n.innerType,r);if(n.type==="intersection")return P(n.left,r)||P(n.right,r);if(n.type==="record"||n.type==="map")return P(n.keyType,r)||P(n.valueType,r);if(n.type==="pipe")return P(n.in,r)||P(n.out,r);if(n.type==="object"){for(const o in n.shape)if(P(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(P(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(P(o,r))return!0;return!!(n.rest&&P(n.rest,r))}return!1}var $s=(e,t={})=>r=>{const n=fr({...r,processors:t});return $(e,n),pr(n,e),gr(n,e)},ke=(e,t,r={})=>n=>{const{libraryOptions:o,target:i}=n??{},a=fr({...o??{},target:i,io:t,processors:r});return $(e,a),pr(a,e),gr(a,e)},As={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ps=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:i,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),s&&(o.format=As[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},Ns=(e,t,r,n)=>{const o=r,{minimum:i,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?o.type="integer":o.type="number",typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l),typeof i=="number"&&(o.minimum=i,typeof l=="number"&&t.target!=="draft-04"&&(l>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof a=="number"&&(o.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},Os=(e,t,r,n)=>{r.not={}},Zs=(e,t,r,n)=>{},Rs=(e,t,r,n)=>{const o=e._zod.def,i=At(o.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},xs=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ls=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ds=(e,t,r,n)=>{const o=r,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=$(i.element,t,{...n,path:[...n.path,"items"]})},js=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const u in a)o.properties[u]=$(a[u],t,{...n,path:[...n.path,"properties",u]});const s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{const l=i.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.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,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Us=(e,t,r,n)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((s,c)=>$(s,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=a:r.anyOf=a},Ms=(e,t,r,n)=>{const o=e._zod.def,i=$(o.left,t,{...n,path:[...n.path,"allOf",0]}),a=$(o.right,t,{...n,path:[...n.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1;r.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]},Fs=(e,t,r,n)=>{const o=e._zod.def,i=$(o.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Gs=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},qs=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Js=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Bs=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},Vs=(e,t,r,n)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;$(i,t,n);const a=t.seen.get(e);a.ref=i},Ws=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},mr=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Hs=d("ZodISODateTime",(e,t)=>{na.init(e,t),C.init(e,t)});function Ks(e){return as(Hs,e)}var Ys=d("ZodISODate",(e,t)=>{oa.init(e,t),C.init(e,t)});function Qs(e){return ss(Ys,e)}var Xs=d("ZodISOTime",(e,t)=>{ia.init(e,t),C.init(e,t)});function ec(e){return cs(Xs,e)}var tc=d("ZodISODuration",(e,t)=>{aa.init(e,t),C.init(e,t)});function rc(e){return us(tc,e)}var hr=(e,t)=>{Lt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Ko(e,r)},flatten:{value:r=>Ho(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Re,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Re,2)}},isEmpty:{get(){return e.issues.length===0}}})},yu=d("ZodError",hr),R=d("ZodError",hr,{Parent:Error}),nc=Ue(R),oc=Me(R),ic=he(R),ac=_e(R),sc=Xo(R),cc=ei(R),uc=ti(R),dc=ri(R),lc=ni(R),fc=oi(R),pc=ii(R),gc=ai(R),I=d("ZodType",(e,t)=>(T.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ke(e,"input"),output:ke(e,"output")}}),e.toJSONSchema=$s(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(F(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>G(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>nc(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>ic(e,r,n),e.parseAsync=async(r,n)=>oc(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>ac(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>sc(e,r,n),e.decode=(r,n)=>cc(e,r,n),e.encodeAsync=async(r,n)=>uc(e,r,n),e.decodeAsync=async(r,n)=>dc(e,r,n),e.safeEncode=(r,n)=>lc(e,r,n),e.safeDecode=(r,n)=>fc(e,r,n),e.safeEncodeAsync=async(r,n)=>pc(e,r,n),e.safeDecodeAsync=async(r,n)=>gc(e,r,n),e.refine=(r,n)=>e.check(iu(r,n)),e.superRefine=r=>e.check(au(r)),e.overwrite=r=>e.check(te(r)),e.optional=()=>Sr(e),e.exactOptional=()=>Bc(e),e.nullable=()=>Er(e),e.nullish=()=>Sr(Er(e)),e.nonoptional=r=>Qc(e,r),e.array=()=>wr(e),e.or=r=>Uc([e,r]),e.and=r=>Fc(e,r),e.transform=r=>zr(e,qc(r)),e.default=r=>Hc(e,r),e.prefault=r=>Yc(e,r),e.catch=r=>eu(e,r),e.pipe=r=>zr(e,r),e.readonly=()=>nu(e),e.describe=r=>{const n=e.clone();return ue.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return ue.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return ue.get(e);const n=e.clone();return ue.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),_r=d("_ZodString",(e,t)=>{Fe.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ps(e,n,o,i);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(gs(...n)),e.includes=(...n)=>e.check(_s(...n)),e.startsWith=(...n)=>e.check(ys(...n)),e.endsWith=(...n)=>e.check(vs(...n)),e.min=(...n)=>e.check(we(...n)),e.max=(...n)=>e.check(dr(...n)),e.length=(...n)=>e.check(lr(...n)),e.nonempty=(...n)=>e.check(we(1,...n)),e.lowercase=n=>e.check(ms(n)),e.uppercase=n=>e.check(hs(n)),e.trim=()=>e.check(ws()),e.normalize=(...n)=>e.check(bs(...n)),e.toLowerCase=()=>e.check(ks()),e.toUpperCase=()=>e.check(Ss()),e.slugify=()=>e.check(Es())}),mc=d("ZodString",(e,t)=>{Fe.init(e,t),_r.init(e,t),e.email=r=>e.check(ja(hc,r)),e.url=r=>e.check(qa(_c,r)),e.jwt=r=>e.check(is(Nc,r)),e.emoji=r=>e.check(Ja(yc,r)),e.guid=r=>e.check(ar(yr,r)),e.uuid=r=>e.check(Ua(Se,r)),e.uuidv4=r=>e.check(Ma(Se,r)),e.uuidv6=r=>e.check(Fa(Se,r)),e.uuidv7=r=>e.check(Ga(Se,r)),e.nanoid=r=>e.check(Ba(vc,r)),e.guid=r=>e.check(ar(yr,r)),e.cuid=r=>e.check(Va(bc,r)),e.cuid2=r=>e.check(Wa(wc,r)),e.ulid=r=>e.check(Ha(kc,r)),e.base64=r=>e.check(rs($c,r)),e.base64url=r=>e.check(ns(Ac,r)),e.xid=r=>e.check(Ka(Sc,r)),e.ksuid=r=>e.check(Ya(Ec,r)),e.ipv4=r=>e.check(Qa(Cc,r)),e.ipv6=r=>e.check(Xa(zc,r)),e.cidrv4=r=>e.check(es(Tc,r)),e.cidrv6=r=>e.check(ts(Ic,r)),e.e164=r=>e.check(os(Pc,r)),e.datetime=r=>e.check(Ks(r)),e.date=r=>e.check(Qs(r)),e.time=r=>e.check(ec(r)),e.duration=r=>e.check(rc(r))});function O(e){return Da(mc,e)}var C=d("ZodStringFormat",(e,t)=>{E.init(e,t),_r.init(e,t)}),hc=d("ZodEmail",(e,t)=>{Wi.init(e,t),C.init(e,t)}),yr=d("ZodGUID",(e,t)=>{Bi.init(e,t),C.init(e,t)}),Se=d("ZodUUID",(e,t)=>{Vi.init(e,t),C.init(e,t)}),_c=d("ZodURL",(e,t)=>{Hi.init(e,t),C.init(e,t)}),yc=d("ZodEmoji",(e,t)=>{Ki.init(e,t),C.init(e,t)}),vc=d("ZodNanoID",(e,t)=>{Yi.init(e,t),C.init(e,t)}),bc=d("ZodCUID",(e,t)=>{Qi.init(e,t),C.init(e,t)}),wc=d("ZodCUID2",(e,t)=>{Xi.init(e,t),C.init(e,t)}),kc=d("ZodULID",(e,t)=>{ea.init(e,t),C.init(e,t)}),Sc=d("ZodXID",(e,t)=>{ta.init(e,t),C.init(e,t)}),Ec=d("ZodKSUID",(e,t)=>{ra.init(e,t),C.init(e,t)}),Cc=d("ZodIPv4",(e,t)=>{sa.init(e,t),C.init(e,t)}),zc=d("ZodIPv6",(e,t)=>{ca.init(e,t),C.init(e,t)}),Tc=d("ZodCIDRv4",(e,t)=>{ua.init(e,t),C.init(e,t)}),Ic=d("ZodCIDRv6",(e,t)=>{da.init(e,t),C.init(e,t)}),$c=d("ZodBase64",(e,t)=>{la.init(e,t),C.init(e,t)}),Ac=d("ZodBase64URL",(e,t)=>{pa.init(e,t),C.init(e,t)}),Pc=d("ZodE164",(e,t)=>{ga.init(e,t),C.init(e,t)}),Nc=d("ZodJWT",(e,t)=>{ha.init(e,t),C.init(e,t)}),vr=d("ZodNumber",(e,t)=>{Vt.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ns(e,n,o,i),e.gt=(n,o)=>e.check(cr(n,o)),e.gte=(n,o)=>e.check(Je(n,o)),e.min=(n,o)=>e.check(Je(n,o)),e.lt=(n,o)=>e.check(sr(n,o)),e.lte=(n,o)=>e.check(qe(n,o)),e.max=(n,o)=>e.check(qe(n,o)),e.int=n=>e.check(br(n)),e.safe=n=>e.check(br(n)),e.positive=n=>e.check(cr(0,n)),e.nonnegative=n=>e.check(Je(0,n)),e.negative=n=>e.check(sr(0,n)),e.nonpositive=n=>e.check(qe(0,n)),e.multipleOf=(n,o)=>e.check(ur(n,o)),e.step=(n,o)=>e.check(ur(n,o)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function de(e){return ds(vr,e)}var Oc=d("ZodNumberFormat",(e,t)=>{_a.init(e,t),vr.init(e,t)});function br(e){return ls(Oc,e)}var Zc=d("ZodUnknown",(e,t)=>{ya.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zs(e,r,n,o)});function Be(){return fs(Zc)}var Rc=d("ZodNever",(e,t)=>{va.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Os(e,r,n,o)});function xc(e){return ps(Rc,e)}var Lc=d("ZodArray",(e,t)=>{ba.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ds(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(we(r,n)),e.nonempty=r=>e.check(we(1,r)),e.max=(r,n)=>e.check(dr(r,n)),e.length=(r,n)=>e.check(lr(r,n)),e.unwrap=()=>e.element});function wr(e,t){return Cs(Lc,e,t)}var Dc=d("ZodObject",(e,t)=>{ka.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>js(e,r,n,o),S(e,"shape",()=>t.shape),e.keyof=()=>We(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Be()}),e.loose=()=>e.clone({...e._zod.def,catchall:Be()}),e.strict=()=>e.clone({...e._zod.def,catchall:xc()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>qo(e,r),e.safeExtend=r=>Jo(e,r),e.merge=r=>Bo(e,r),e.pick=r=>Fo(e,r),e.omit=r=>Go(e,r),e.partial=(...r)=>Vo(kr,e,r[0]),e.required=(...r)=>Wo(Cr,e,r[0])});function q(e,t){return new Dc({type:"object",shape:e??{},...y(t)})}var jc=d("ZodUnion",(e,t)=>{Sa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Us(e,r,n,o),e.options=t.options});function Uc(e,t){return new jc({type:"union",options:e,...y(t)})}var Mc=d("ZodIntersection",(e,t)=>{Ea.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ms(e,r,n,o)});function Fc(e,t){return new Mc({type:"intersection",left:e,right:t})}var Ve=d("ZodEnum",(e,t)=>{Ca.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Rs(e,n,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const i={};for(const a of n)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Ve({...t,checks:[],...y(o),entries:i})},e.exclude=(n,o)=>{const i={...t.entries};for(const a of n)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Ve({...t,checks:[],...y(o),entries:i})}});function We(e,t){return new Ve({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e,...y(t)})}var Gc=d("ZodTransform",(e,t)=>{za.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ls(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new $t(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(ce(i,r.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(ce(a))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r)):(r.value=o,r)}});function qc(e){return new Gc({type:"transform",transform:e})}var kr=d("ZodOptional",(e,t)=>{er.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Sr(e){return new kr({type:"optional",innerType:e})}var Jc=d("ZodExactOptional",(e,t)=>{Ta.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Bc(e){return new Jc({type:"optional",innerType:e})}var Vc=d("ZodNullable",(e,t)=>{Ia.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Er(e){return new Vc({type:"nullable",innerType:e})}var Wc=d("ZodDefault",(e,t)=>{$a.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Hc(e,t){return new Wc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Zt(t)}})}var Kc=d("ZodPrefault",(e,t)=>{Aa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Js(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Yc(e,t){return new Kc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Zt(t)}})}var Cr=d("ZodNonOptional",(e,t)=>{Pa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Qc(e,t){return new Cr({type:"nonoptional",innerType:e,...y(t)})}var Xc=d("ZodCatch",(e,t)=>{Na.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function eu(e,t){return new Xc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var tu=d("ZodPipe",(e,t)=>{Oa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vs(e,r,n,o),e.in=t.in,e.out=t.out});function zr(e,t){return new tu({type:"pipe",in:e,out:t})}var ru=d("ZodReadonly",(e,t)=>{Za.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ws(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function nu(e){return new ru({type:"readonly",innerType:e})}var ou=d("ZodCustom",(e,t)=>{Ra.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xs(e,r,n,o)});function iu(e,t={}){return zs(ou,e,t)}function au(e){return Ts(e)}var su=q({sku:O(),name:O(),imageUrl:O().url().optional(),price:O().optional(),originalPrice:O().optional(),discountPercent:de().optional(),url:O().url(),brand:O().optional(),rating:de().min(0).max(5).optional(),reviewCount:de().int().nonnegative().optional()}),cu=q({layout:We(["grid","carousel"]).optional(),columns:de().int().positive().optional()}),uu=q({product:su,index:de().int().nonnegative(),discountType:We(["strike-through","badge"]).optional()}),du=q({sku:O(),label:O().optional(),cartCode:O()}),lu=q({actions:wr(q({label:O(),action:q({title:O(),type:O(),payload:Be().optional()})}))}),fu=q({message:O().optional()}),pu={components:{ProductGrid:{schema:cu,description:"Outer grid or carousel container for similar products."},ProductCard:{schema:uu,description:"A single product card with image, title, price, and actions."},AddToCartButton:{schema:du,description:"Add-to-cart CTA rendered inside or below a product card."},QuickActions:{schema:lu,description:"A row of quick-action buttons below product info."},EmptyState:{schema:fu,description:"Empty state shown when no similar products are available."}}},gu=12e4;function mu(e){return e instanceof DOMException&&e.name==="AbortError"}var Tr=class extends pn{constructor(...e){super(...e),this._abortController=null,this._contentEl=null,this._lastResultCount=-1,this._i18n=It}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-simrel-container",this._contentEl.dataset.gengagePart="simrel-container",this._contentEl.lang=mn(e.locale);const t=this._clampGridColumns(e.gridColumns);t!==void 0&&this._contentEl.style.setProperty("--gengage-simrel-columns",String(t)),this.root.appendChild(this._contentEl),this._lastSku=e.sku,await this._fetchAndRender(e.sku),Vr("simrel")}onUpdate(e){const t=e.sku;!t||t===this._lastSku&&this._lastResultCount!==0||(this._lastSku=t,this._fetchAndRender(t))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.3s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._contentEl&&(this._contentEl.remove(),this._contentEl=null)}_handleProductClick(e){const t={sku:e.sku,name:e.name,url:e.url};if(e.imageUrl!==void 0&&(t.imageUrl=e.imageUrl),e.price!==void 0&&(t.price=e.price),e.originalPrice!==void 0&&(t.originalPrice=e.originalPrice),e.discountPercent!==void 0&&(t.discountPercent=e.discountPercent),e.brand!==void 0&&(t.brand=e.brand),e.rating!==void 0&&(t.rating=e.rating),e.reviewCount!==void 0&&(t.reviewCount=e.reviewCount),e.cartCode!==void 0&&(t.cartCode=e.cartCode),e.inStock!==void 0&&(t.inStock=e.inStock),this.config.onProductClick?.(t)===!1)return;const r=this.config.session?.sessionId??null;re("gengage:similar:product-click",{sku:e.sku,url:e.url,sessionId:r,productName:e.name}),this.config.onProductNavigate?.(e.url,e.sku,r)}_handleAddToCart(e){Wr(e.sku,e.quantity),this.config.onAddToCart?.(e),re("gengage:similar:add-to-cart",e),this.track(Zr(this.analyticsContext(),{attribution_source:"simrel",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:this.config.pricing?.currencyCode??"TRY",line_items:e.quantity,sku:e.sku}))}_abort(){this._abortController?.abort(),this._abortController=null}_isSuperseded(e){return this._abortController?.signal!==e}_emitSimilarProductsImpression(e,t){const r=this.config.session?.sessionId??null;re("gengage:similar:products-impression",{source_sku:this.config.sku,product_count:e,grouped:t,sessionId:r})}_resolveRequestTimeoutMs(){const e=this.config.requestTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?gu:Math.floor(e)}async _fetchAndRender(e){this._abort();const t=new AbortController;this._abortController=t;const r=t.signal;let n=!1;const o=setTimeout(()=>{n=!0,t.abort()},this._resolveRequestTimeoutMs());if(r.addEventListener("abort",()=>clearTimeout(o),{once:!0}),!this._contentEl)return;this._contentEl.innerHTML="",this._contentEl.style.display="";const i=document.createElement("div");i.className="gengage-simrel-loading",i.dataset.gengagePart="simrel-loading";const a=document.createElement("div");a.className="gengage-simrel-spinner",a.dataset.gengagePart="simrel-loading-spinner",i.appendChild(a),this._contentEl.appendChild(i);const s={middlewareUrl:this.config.middlewareUrl},c=crypto.randomUUID(),u=Date.now(),l=kn({source:"simrel",locale:this.config.locale});this.track(Pr(this.analyticsContext(),{endpoint:"similar_products",request_id:c,widget:"simrel"}));try{const g={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e};this.config.domain!==void 0&&(g.domain=this.config.domain);const f=await ko(g,s,r);if(this._lastResultCount=f.length,!this._contentEl)return;if(this._contentEl.innerHTML="",f.length>0)try{const m=f.map(h=>h.sku),_=new Map(f.map(h=>[h.sku,h])),p=(await Eo({account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",skus:m},s,r)).map(h=>({...h,products:h.products.map(v=>({..._.get(v.sku),...v})).filter(v=>typeof v.sku=="string"&&typeof v.name=="string"&&typeof v.url=="string")})).filter(h=>h.products.length>0);if(p.length>0&&this._contentEl){const h=this._buildGroupsSpec(p),v=this._renderUISpec(h);this._contentEl.appendChild(v),Qe("simrel"),this.track(He(this.analyticsContext(),{request_id:c,latency_ms:Date.now()-u,chunk_count:p.reduce((x,z)=>x+z.products.length,0),widget:"simrel"})),this.track(Ke(this.analyticsContext(),{message_count:p.reduce((x,z)=>x+z.products.length,0),history_ref:c,redaction_level:"none",widget:"simrel"})),this._emitSimilarProductsImpression(p.reduce((x,z)=>x+z.products.length,0),!0);return}}catch{}if(this._isSuperseded(r))return;if(this._contentEl){const m=this._buildProductsSpec(f),_=this._renderUISpec(m);this._contentEl.appendChild(_)}f.length>0&&Qe("simrel"),this.track(He(this.analyticsContext(),{request_id:c,latency_ms:Date.now()-u,chunk_count:f.length,widget:"simrel"})),this.track(Ke(this.analyticsContext(),{message_count:f.length,history_ref:c,redaction_level:"none",widget:"simrel"})),this._emitSimilarProductsImpression(f.length,!1)}catch(g){const f=mu(g);if(f&&this._isSuperseded(r))return;const m=f&&n?"REQUEST_TIMEOUT":"FETCH_ERROR",_=f&&n?"request_timeout":g instanceof Error?g.message:String(g);if(re("gengage:global:error",{source:"simrel",code:m,message:on(this.config.locale,g)}),this.track(Nr(this.analyticsContext(),{request_id:c,error_code:m,error_message:_,widget:"simrel"})),this._contentEl){this._contentEl.innerHTML="";const p=document.createElement("div");p.className="gengage-simrel-error";const h=document.createElement("span");h.textContent=this._i18n.errorLoadingMessage,p.appendChild(h);const v=document.createElement("button");v.className="gengage-simrel-retry",v.textContent=this._i18n.retryButtonText,v.addEventListener("click",()=>{this._fetchAndRender(this.config.sku)}),p.appendChild(v),this._contentEl.appendChild(p)}}finally{clearTimeout(o),l()}}_clampGridColumns(e){if(!(e===void 0||typeof e!="number"||!Number.isFinite(e)))return Math.max(1,Math.min(12,Math.floor(e)))}_resolveI18n(e){return{...Ro(e.locale),...e.i18n}}_resolveUISpecRegistry(){return Ar(zt(),this.config.renderer?.registry)}_buildRenderContext(){const e=this.config.renderCard,t={onClick:n=>this._handleProductClick(n),onAddToCart:n=>this._handleAddToCart(n),onGroupingActivate:n=>{re("gengage:similar:grouping-click",{grouping_label:n.grouping_label,grouping_index:n.grouping_index,sessionId:this.config.session?.sessionId??null})},i18n:this._i18n};this.config.discountType!==void 0&&(t.discountType=this.config.discountType),e!==void 0&&(t.renderCard=e),this.config.renderCardElement!==void 0&&(t.renderCardElement=this.config.renderCardElement),this.config.pricing!==void 0&&(t.pricing=this.config.pricing);const r=this._clampGridColumns(this.config.gridColumns);return r!==void 0&&(t.gridColumns=r),t}_renderUISpec(e){const t=this._resolveUISpecRegistry(),r=this._buildRenderContext(),n=this.config.renderer?.unknownRenderer??Oe,o=(a,s)=>Tt(a,s,t,n),i=this.config.renderer?.renderUISpec;return i?i(e,r,{registry:t,unknownRenderer:n,defaultRender:o}):o(e,r)}_buildProductsSpec(e){const t={},r=[];for(let i=0;i<e.length;i++){const a=e[i],s=`product-${i}`;r.push(s),t[s]={type:"ProductCard",props:{product:a,index:i,discountType:this.config.discountType}}}const n={layout:"grid"},o=this._clampGridColumns(this.config.gridColumns);return o!==void 0&&(n.columns=o),t.root={type:"ProductGrid",props:n,children:r},{root:"root",elements:t}}_buildGroupsSpec(e){return{root:"root",elements:{root:{type:"GroupTabs",props:{groups:e}}}}}};function hu(){return new Tr}J.GengageSimRel=Tr,J.createDefaultSimRelUISpecRegistry=zt,J.createSimRelWidget=hu,J.defaultSimRelUnknownUISpecRenderer=Oe,J.renderSimRelUISpec=Tt,J.simRelCatalog=pu})(this.Gengage=this.Gengage||{});
|
|
86
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const s=a[1];if(t===a[0]){i(a);continue}if(e.external){const c=e.external.registry.get(a[0])?.id;if(t!==a[0]&&c){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}if(s.count>1&&e.reused==="ref"){i(a);continue}}}function gr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a=>{const s=e.seen.get(a);if(s.ref===null)return;const c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){n(l);const p=e.seen.get(l),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(m)):Object.assign(c,m),Object.assign(c,u),a._zod.parent===l)for(const _ in c)_==="$ref"||_==="allOf"||_ in u||delete c[_];if(m.$ref&&p.def)for(const _ in c)_==="$ref"||_==="allOf"||_ in p.def&&JSON.stringify(c[_])===JSON.stringify(p.def[_])&&delete c[_]}const g=a._zod.parent;if(g&&g!==l){n(g);const p=e.seen.get(g);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(const m in c)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(c[m])===JSON.stringify(p.def[m])&&delete c[m]}e.override({zodSchema:a,jsonSchema:c,path:s.path??[]})};for(const a of[...e.seen.entries()].reverse())n(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,r.def??r.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:ke(t,"input",e.processors),output:ke(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function P(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return P(n.element,r);if(n.type==="set")return P(n.valueType,r);if(n.type==="lazy")return P(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return P(n.innerType,r);if(n.type==="intersection")return P(n.left,r)||P(n.right,r);if(n.type==="record"||n.type==="map")return P(n.keyType,r)||P(n.valueType,r);if(n.type==="pipe")return P(n.in,r)||P(n.out,r);if(n.type==="object"){for(const o in n.shape)if(P(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(P(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(P(o,r))return!0;return!!(n.rest&&P(n.rest,r))}return!1}var $s=(e,t={})=>r=>{const n=pr({...r,processors:t});return $(e,n),fr(n,e),gr(n,e)},ke=(e,t,r={})=>n=>{const{libraryOptions:o,target:i}=n??{},a=pr({...o??{},target:i,io:t,processors:r});return $(e,a),fr(a,e),gr(a,e)},As={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ps=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:i,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),s&&(o.format=As[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},Ns=(e,t,r,n)=>{const o=r,{minimum:i,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?o.type="integer":o.type="number",typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l),typeof i=="number"&&(o.minimum=i,typeof l=="number"&&t.target!=="draft-04"&&(l>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof a=="number"&&(o.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},Os=(e,t,r,n)=>{r.not={}},Zs=(e,t,r,n)=>{},Rs=(e,t,r,n)=>{const o=e._zod.def,i=At(o.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},xs=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ls=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ds=(e,t,r,n)=>{const o=r,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=$(i.element,t,{...n,path:[...n.path,"items"]})},js=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const u in a)o.properties[u]=$(a[u],t,{...n,path:[...n.path,"properties",u]});const s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{const l=i.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.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,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Us=(e,t,r,n)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((s,c)=>$(s,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=a:r.anyOf=a},Ms=(e,t,r,n)=>{const o=e._zod.def,i=$(o.left,t,{...n,path:[...n.path,"allOf",0]}),a=$(o.right,t,{...n,path:[...n.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1;r.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]},Fs=(e,t,r,n)=>{const o=e._zod.def,i=$(o.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},qs=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Gs=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Js=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Bs=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},Vs=(e,t,r,n)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;$(i,t,n);const a=t.seen.get(e);a.ref=i},Ws=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},mr=(e,t,r,n)=>{const o=e._zod.def;$(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Hs=d("ZodISODateTime",(e,t)=>{na.init(e,t),C.init(e,t)});function Ks(e){return as(Hs,e)}var Ys=d("ZodISODate",(e,t)=>{oa.init(e,t),C.init(e,t)});function Qs(e){return ss(Ys,e)}var Xs=d("ZodISOTime",(e,t)=>{ia.init(e,t),C.init(e,t)});function ec(e){return cs(Xs,e)}var tc=d("ZodISODuration",(e,t)=>{aa.init(e,t),C.init(e,t)});function rc(e){return us(tc,e)}var hr=(e,t)=>{Lt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Ko(e,r)},flatten:{value:r=>Ho(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Re,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Re,2)}},isEmpty:{get(){return e.issues.length===0}}})},yu=d("ZodError",hr),R=d("ZodError",hr,{Parent:Error}),nc=Ue(R),oc=Me(R),ic=he(R),ac=_e(R),sc=Xo(R),cc=ei(R),uc=ti(R),dc=ri(R),lc=ni(R),pc=oi(R),fc=ii(R),gc=ai(R),I=d("ZodType",(e,t)=>(T.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ke(e,"input"),output:ke(e,"output")}}),e.toJSONSchema=$s(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(F(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>q(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>nc(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>ic(e,r,n),e.parseAsync=async(r,n)=>oc(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>ac(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>sc(e,r,n),e.decode=(r,n)=>cc(e,r,n),e.encodeAsync=async(r,n)=>uc(e,r,n),e.decodeAsync=async(r,n)=>dc(e,r,n),e.safeEncode=(r,n)=>lc(e,r,n),e.safeDecode=(r,n)=>pc(e,r,n),e.safeEncodeAsync=async(r,n)=>fc(e,r,n),e.safeDecodeAsync=async(r,n)=>gc(e,r,n),e.refine=(r,n)=>e.check(iu(r,n)),e.superRefine=r=>e.check(au(r)),e.overwrite=r=>e.check(te(r)),e.optional=()=>Sr(e),e.exactOptional=()=>Bc(e),e.nullable=()=>Er(e),e.nullish=()=>Sr(Er(e)),e.nonoptional=r=>Qc(e,r),e.array=()=>wr(e),e.or=r=>Uc([e,r]),e.and=r=>Fc(e,r),e.transform=r=>zr(e,Gc(r)),e.default=r=>Hc(e,r),e.prefault=r=>Yc(e,r),e.catch=r=>eu(e,r),e.pipe=r=>zr(e,r),e.readonly=()=>nu(e),e.describe=r=>{const n=e.clone();return ue.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return ue.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return ue.get(e);const n=e.clone();return ue.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),_r=d("_ZodString",(e,t)=>{Fe.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ps(e,n,o,i);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(gs(...n)),e.includes=(...n)=>e.check(_s(...n)),e.startsWith=(...n)=>e.check(ys(...n)),e.endsWith=(...n)=>e.check(vs(...n)),e.min=(...n)=>e.check(we(...n)),e.max=(...n)=>e.check(dr(...n)),e.length=(...n)=>e.check(lr(...n)),e.nonempty=(...n)=>e.check(we(1,...n)),e.lowercase=n=>e.check(ms(n)),e.uppercase=n=>e.check(hs(n)),e.trim=()=>e.check(ws()),e.normalize=(...n)=>e.check(bs(...n)),e.toLowerCase=()=>e.check(ks()),e.toUpperCase=()=>e.check(Ss()),e.slugify=()=>e.check(Es())}),mc=d("ZodString",(e,t)=>{Fe.init(e,t),_r.init(e,t),e.email=r=>e.check(ja(hc,r)),e.url=r=>e.check(Ga(_c,r)),e.jwt=r=>e.check(is(Nc,r)),e.emoji=r=>e.check(Ja(yc,r)),e.guid=r=>e.check(ar(yr,r)),e.uuid=r=>e.check(Ua(Se,r)),e.uuidv4=r=>e.check(Ma(Se,r)),e.uuidv6=r=>e.check(Fa(Se,r)),e.uuidv7=r=>e.check(qa(Se,r)),e.nanoid=r=>e.check(Ba(vc,r)),e.guid=r=>e.check(ar(yr,r)),e.cuid=r=>e.check(Va(bc,r)),e.cuid2=r=>e.check(Wa(wc,r)),e.ulid=r=>e.check(Ha(kc,r)),e.base64=r=>e.check(rs($c,r)),e.base64url=r=>e.check(ns(Ac,r)),e.xid=r=>e.check(Ka(Sc,r)),e.ksuid=r=>e.check(Ya(Ec,r)),e.ipv4=r=>e.check(Qa(Cc,r)),e.ipv6=r=>e.check(Xa(zc,r)),e.cidrv4=r=>e.check(es(Tc,r)),e.cidrv6=r=>e.check(ts(Ic,r)),e.e164=r=>e.check(os(Pc,r)),e.datetime=r=>e.check(Ks(r)),e.date=r=>e.check(Qs(r)),e.time=r=>e.check(ec(r)),e.duration=r=>e.check(rc(r))});function O(e){return Da(mc,e)}var C=d("ZodStringFormat",(e,t)=>{E.init(e,t),_r.init(e,t)}),hc=d("ZodEmail",(e,t)=>{Wi.init(e,t),C.init(e,t)}),yr=d("ZodGUID",(e,t)=>{Bi.init(e,t),C.init(e,t)}),Se=d("ZodUUID",(e,t)=>{Vi.init(e,t),C.init(e,t)}),_c=d("ZodURL",(e,t)=>{Hi.init(e,t),C.init(e,t)}),yc=d("ZodEmoji",(e,t)=>{Ki.init(e,t),C.init(e,t)}),vc=d("ZodNanoID",(e,t)=>{Yi.init(e,t),C.init(e,t)}),bc=d("ZodCUID",(e,t)=>{Qi.init(e,t),C.init(e,t)}),wc=d("ZodCUID2",(e,t)=>{Xi.init(e,t),C.init(e,t)}),kc=d("ZodULID",(e,t)=>{ea.init(e,t),C.init(e,t)}),Sc=d("ZodXID",(e,t)=>{ta.init(e,t),C.init(e,t)}),Ec=d("ZodKSUID",(e,t)=>{ra.init(e,t),C.init(e,t)}),Cc=d("ZodIPv4",(e,t)=>{sa.init(e,t),C.init(e,t)}),zc=d("ZodIPv6",(e,t)=>{ca.init(e,t),C.init(e,t)}),Tc=d("ZodCIDRv4",(e,t)=>{ua.init(e,t),C.init(e,t)}),Ic=d("ZodCIDRv6",(e,t)=>{da.init(e,t),C.init(e,t)}),$c=d("ZodBase64",(e,t)=>{la.init(e,t),C.init(e,t)}),Ac=d("ZodBase64URL",(e,t)=>{fa.init(e,t),C.init(e,t)}),Pc=d("ZodE164",(e,t)=>{ga.init(e,t),C.init(e,t)}),Nc=d("ZodJWT",(e,t)=>{ha.init(e,t),C.init(e,t)}),vr=d("ZodNumber",(e,t)=>{Vt.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ns(e,n,o,i),e.gt=(n,o)=>e.check(cr(n,o)),e.gte=(n,o)=>e.check(Je(n,o)),e.min=(n,o)=>e.check(Je(n,o)),e.lt=(n,o)=>e.check(sr(n,o)),e.lte=(n,o)=>e.check(Ge(n,o)),e.max=(n,o)=>e.check(Ge(n,o)),e.int=n=>e.check(br(n)),e.safe=n=>e.check(br(n)),e.positive=n=>e.check(cr(0,n)),e.nonnegative=n=>e.check(Je(0,n)),e.negative=n=>e.check(sr(0,n)),e.nonpositive=n=>e.check(Ge(0,n)),e.multipleOf=(n,o)=>e.check(ur(n,o)),e.step=(n,o)=>e.check(ur(n,o)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function de(e){return ds(vr,e)}var Oc=d("ZodNumberFormat",(e,t)=>{_a.init(e,t),vr.init(e,t)});function br(e){return ls(Oc,e)}var Zc=d("ZodUnknown",(e,t)=>{ya.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zs(e,r,n,o)});function Be(){return ps(Zc)}var Rc=d("ZodNever",(e,t)=>{va.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Os(e,r,n,o)});function xc(e){return fs(Rc,e)}var Lc=d("ZodArray",(e,t)=>{ba.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ds(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(we(r,n)),e.nonempty=r=>e.check(we(1,r)),e.max=(r,n)=>e.check(dr(r,n)),e.length=(r,n)=>e.check(lr(r,n)),e.unwrap=()=>e.element});function wr(e,t){return Cs(Lc,e,t)}var Dc=d("ZodObject",(e,t)=>{ka.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>js(e,r,n,o),S(e,"shape",()=>t.shape),e.keyof=()=>We(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Be()}),e.loose=()=>e.clone({...e._zod.def,catchall:Be()}),e.strict=()=>e.clone({...e._zod.def,catchall:xc()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Go(e,r),e.safeExtend=r=>Jo(e,r),e.merge=r=>Bo(e,r),e.pick=r=>Fo(e,r),e.omit=r=>qo(e,r),e.partial=(...r)=>Vo(kr,e,r[0]),e.required=(...r)=>Wo(Cr,e,r[0])});function G(e,t){return new Dc({type:"object",shape:e??{},...y(t)})}var jc=d("ZodUnion",(e,t)=>{Sa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Us(e,r,n,o),e.options=t.options});function Uc(e,t){return new jc({type:"union",options:e,...y(t)})}var Mc=d("ZodIntersection",(e,t)=>{Ea.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ms(e,r,n,o)});function Fc(e,t){return new Mc({type:"intersection",left:e,right:t})}var Ve=d("ZodEnum",(e,t)=>{Ca.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Rs(e,n,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const i={};for(const a of n)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Ve({...t,checks:[],...y(o),entries:i})},e.exclude=(n,o)=>{const i={...t.entries};for(const a of n)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Ve({...t,checks:[],...y(o),entries:i})}});function We(e,t){return new Ve({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e,...y(t)})}var qc=d("ZodTransform",(e,t)=>{za.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ls(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new $t(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(ce(i,r.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(ce(a))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r)):(r.value=o,r)}});function Gc(e){return new qc({type:"transform",transform:e})}var kr=d("ZodOptional",(e,t)=>{er.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Sr(e){return new kr({type:"optional",innerType:e})}var Jc=d("ZodExactOptional",(e,t)=>{Ta.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Bc(e){return new Jc({type:"optional",innerType:e})}var Vc=d("ZodNullable",(e,t)=>{Ia.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Er(e){return new Vc({type:"nullable",innerType:e})}var Wc=d("ZodDefault",(e,t)=>{$a.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Hc(e,t){return new Wc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Zt(t)}})}var Kc=d("ZodPrefault",(e,t)=>{Aa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Js(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Yc(e,t){return new Kc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Zt(t)}})}var Cr=d("ZodNonOptional",(e,t)=>{Pa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Qc(e,t){return new Cr({type:"nonoptional",innerType:e,...y(t)})}var Xc=d("ZodCatch",(e,t)=>{Na.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function eu(e,t){return new Xc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var tu=d("ZodPipe",(e,t)=>{Oa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vs(e,r,n,o),e.in=t.in,e.out=t.out});function zr(e,t){return new tu({type:"pipe",in:e,out:t})}var ru=d("ZodReadonly",(e,t)=>{Za.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ws(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function nu(e){return new ru({type:"readonly",innerType:e})}var ou=d("ZodCustom",(e,t)=>{Ra.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xs(e,r,n,o)});function iu(e,t={}){return zs(ou,e,t)}function au(e){return Ts(e)}var su=G({sku:O(),name:O(),imageUrl:O().url().optional(),price:O().optional(),originalPrice:O().optional(),discountPercent:de().optional(),url:O().url(),brand:O().optional(),rating:de().min(0).max(5).optional(),reviewCount:de().int().nonnegative().optional()}),cu=G({layout:We(["grid","carousel"]).optional(),columns:de().int().positive().optional()}),uu=G({product:su,index:de().int().nonnegative(),discountType:We(["strike-through","badge"]).optional()}),du=G({sku:O(),label:O().optional(),cartCode:O()}),lu=G({actions:wr(G({label:O(),action:G({title:O(),type:O(),payload:Be().optional()})}))}),pu=G({message:O().optional()}),fu={components:{ProductGrid:{schema:cu,description:"Outer grid or carousel container for similar products."},ProductCard:{schema:uu,description:"A single product card with image, title, price, and actions."},AddToCartButton:{schema:du,description:"Add-to-cart CTA rendered inside or below a product card."},QuickActions:{schema:lu,description:"A row of quick-action buttons below product info."},EmptyState:{schema:pu,description:"Empty state shown when no similar products are available."}}},gu=12e4;function mu(e){return e instanceof DOMException&&e.name==="AbortError"}var Tr=class extends fn{constructor(...e){super(...e),this._abortController=null,this._contentEl=null,this._lastResultCount=-1,this._i18n=It}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-simrel-container",this._contentEl.dataset.gengagePart="simrel-container",this._contentEl.lang=mn(e.locale);const t=this._clampGridColumns(e.gridColumns);t!==void 0&&this._contentEl.style.setProperty("--gengage-simrel-columns",String(t)),this.root.appendChild(this._contentEl),this._lastSku=e.sku,await this._fetchAndRender(e.sku),Vr("simrel")}onUpdate(e){const t=e.sku;!t||t===this._lastSku&&this._lastResultCount!==0||(this._lastSku=t,this._fetchAndRender(t))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.3s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._contentEl&&(this._contentEl.remove(),this._contentEl=null)}_handleProductClick(e){const t={sku:e.sku,name:e.name,url:e.url};if(e.imageUrl!==void 0&&(t.imageUrl=e.imageUrl),e.price!==void 0&&(t.price=e.price),e.originalPrice!==void 0&&(t.originalPrice=e.originalPrice),e.discountPercent!==void 0&&(t.discountPercent=e.discountPercent),e.brand!==void 0&&(t.brand=e.brand),e.rating!==void 0&&(t.rating=e.rating),e.reviewCount!==void 0&&(t.reviewCount=e.reviewCount),e.cartCode!==void 0&&(t.cartCode=e.cartCode),e.inStock!==void 0&&(t.inStock=e.inStock),this.config.onProductClick?.(t)===!1)return;const r=this.config.session?.sessionId??null;re("gengage:similar:product-click",{sku:e.sku,url:e.url,sessionId:r,productName:e.name}),this.config.onProductNavigate?.(e.url,e.sku,r)}_handleAddToCart(e){Wr(e.sku,e.quantity),this.config.onAddToCart?.(e),re("gengage:similar:add-to-cart",e),this.track(Zr(this.analyticsContext(),{attribution_source:"simrel",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:this.config.pricing?.currencyCode??"TRY",line_items:e.quantity,sku:e.sku}))}_abort(){this._abortController?.abort(),this._abortController=null}_isSuperseded(e){return this._abortController?.signal!==e}_emitSimilarProductsImpression(e,t){const r=this.config.session?.sessionId??null;re("gengage:similar:products-impression",{source_sku:this.config.sku,product_count:e,grouped:t,sessionId:r})}_resolveRequestTimeoutMs(){const e=this.config.requestTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?gu:Math.floor(e)}async _fetchAndRender(e){this._abort();const t=new AbortController;this._abortController=t;const r=t.signal;let n=!1;const o=setTimeout(()=>{n=!0,t.abort()},this._resolveRequestTimeoutMs());if(r.addEventListener("abort",()=>clearTimeout(o),{once:!0}),!this._contentEl)return;this._contentEl.innerHTML="",this._contentEl.style.display="";const i=document.createElement("div");i.className="gengage-simrel-loading",i.dataset.gengagePart="simrel-loading";const a=document.createElement("div");a.className="gengage-simrel-spinner",a.dataset.gengagePart="simrel-loading-spinner",i.appendChild(a),this._contentEl.appendChild(i);const s={middlewareUrl:this.config.middlewareUrl},c=crypto.randomUUID(),u=Date.now(),l=kn({source:"simrel",locale:this.config.locale});this.track(Pr(this.analyticsContext(),{endpoint:"similar_products",request_id:c,widget:"simrel"}));try{const g={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e};this.config.domain!==void 0&&(g.domain=this.config.domain);const p=await ko(g,s,r);if(this._lastResultCount=p.length,!this._contentEl)return;if(this._contentEl.innerHTML="",p.length>0)try{const m=p.map(h=>h.sku),_=new Map(p.map(h=>[h.sku,h])),f=(await Eo({account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",skus:m},s,r)).map(h=>({...h,products:h.products.map(v=>({..._.get(v.sku),...v})).filter(v=>typeof v.sku=="string"&&typeof v.name=="string"&&typeof v.url=="string")})).filter(h=>h.products.length>0);if(f.length>0&&this._contentEl){const h=this._buildGroupsSpec(f),v=this._renderUISpec(h);this._contentEl.appendChild(v),Qe("simrel"),this.track(He(this.analyticsContext(),{request_id:c,latency_ms:Date.now()-u,chunk_count:f.reduce((x,z)=>x+z.products.length,0),widget:"simrel"})),this.track(Ke(this.analyticsContext(),{message_count:f.reduce((x,z)=>x+z.products.length,0),history_ref:c,redaction_level:"none",widget:"simrel"})),this._emitSimilarProductsImpression(f.reduce((x,z)=>x+z.products.length,0),!0);return}}catch{}if(this._isSuperseded(r))return;if(this._contentEl){const m=this._buildProductsSpec(p),_=this._renderUISpec(m);this._contentEl.appendChild(_)}p.length>0&&Qe("simrel"),this.track(He(this.analyticsContext(),{request_id:c,latency_ms:Date.now()-u,chunk_count:p.length,widget:"simrel"})),this.track(Ke(this.analyticsContext(),{message_count:p.length,history_ref:c,redaction_level:"none",widget:"simrel"})),this._emitSimilarProductsImpression(p.length,!1)}catch(g){const p=mu(g);if(p&&this._isSuperseded(r))return;const m=p&&n?"REQUEST_TIMEOUT":"FETCH_ERROR",_=p&&n?"request_timeout":g instanceof Error?g.message:String(g);if(re("gengage:global:error",{source:"simrel",code:m,message:on(this.config.locale,g)}),this.track(Nr(this.analyticsContext(),{request_id:c,error_code:m,error_message:_,widget:"simrel"})),this._contentEl){this._contentEl.innerHTML="";const f=document.createElement("div");f.className="gengage-simrel-error";const h=document.createElement("span");h.textContent=this._i18n.errorLoadingMessage,f.appendChild(h);const v=document.createElement("button");v.className="gengage-simrel-retry",v.textContent=this._i18n.retryButtonText,v.addEventListener("click",()=>{this._fetchAndRender(this.config.sku)}),f.appendChild(v),this._contentEl.appendChild(f)}}finally{clearTimeout(o),l()}}_clampGridColumns(e){if(!(e===void 0||typeof e!="number"||!Number.isFinite(e)))return Math.max(1,Math.min(12,Math.floor(e)))}_resolveI18n(e){return{...Ro(e.locale),...e.i18n}}_resolveUISpecRegistry(){return Ar(zt(),this.config.renderer?.registry)}_buildRenderContext(){const e=this.config.renderCard,t={onClick:n=>this._handleProductClick(n),onAddToCart:n=>this._handleAddToCart(n),onGroupingActivate:n=>{re("gengage:similar:grouping-click",{grouping_label:n.grouping_label,grouping_index:n.grouping_index,sessionId:this.config.session?.sessionId??null})},i18n:this._i18n};this.config.discountType!==void 0&&(t.discountType=this.config.discountType),e!==void 0&&(t.renderCard=e),this.config.renderCardElement!==void 0&&(t.renderCardElement=this.config.renderCardElement),this.config.pricing!==void 0&&(t.pricing=this.config.pricing);const r=this._clampGridColumns(this.config.gridColumns);return r!==void 0&&(t.gridColumns=r),t}_renderUISpec(e){const t=this._resolveUISpecRegistry(),r=this._buildRenderContext(),n=this.config.renderer?.unknownRenderer??Oe,o=(a,s)=>Tt(a,s,t,n),i=this.config.renderer?.renderUISpec;return i?i(e,r,{registry:t,unknownRenderer:n,defaultRender:o}):o(e,r)}_buildProductsSpec(e){const t={},r=[];for(let i=0;i<e.length;i++){const a=e[i],s=`product-${i}`;r.push(s),t[s]={type:"ProductCard",props:{product:a,index:i,discountType:this.config.discountType}}}const n={layout:"grid"},o=this._clampGridColumns(this.config.gridColumns);return o!==void 0&&(n.columns=o),t.root={type:"ProductGrid",props:n,children:r},{root:"root",elements:t}}_buildGroupsSpec(e){return{root:"root",elements:{root:{type:"GroupTabs",props:{groups:e}}}}}};function hu(){return new Tr}J.GengageSimRel=Tr,J.createDefaultSimRelUISpecRegistry=zt,J.createSimRelWidget=hu,J.defaultSimRelUnknownUISpecRenderer=Oe,J.renderSimRelUISpec=Tt,J.simRelCatalog=fu})(this.Gengage=this.Gengage||{});
|