@gengage/assistant-fe 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/assistant-fe.css +2 -1
  2. package/dist/chat-C1_48HTk.js +4867 -0
  3. package/dist/chat-C1_48HTk.js.map +1 -0
  4. package/dist/chat-DJpVCmRT.cjs +13 -0
  5. package/dist/chat-DJpVCmRT.cjs.map +1 -0
  6. package/dist/chat.cjs +1 -2
  7. package/dist/chat.iife.js +31 -31
  8. package/dist/chat.iife.js.map +1 -1
  9. package/dist/chat.js +2 -15
  10. package/dist/common--5smIEwc.js +390 -0
  11. package/dist/common--5smIEwc.js.map +1 -0
  12. package/dist/common-DTY__1sq.cjs +2 -0
  13. package/dist/common-DTY__1sq.cjs.map +1 -0
  14. package/dist/common.cjs +1 -2
  15. package/dist/common.js +5 -448
  16. package/dist/index.cjs +1 -2
  17. package/dist/index.js +7 -70
  18. package/dist/native-webview-D1v6n8kJ.cjs +2 -0
  19. package/dist/native-webview-D1v6n8kJ.cjs.map +1 -0
  20. package/dist/native-webview-DlY9mxqG.js +521 -0
  21. package/dist/native-webview-DlY9mxqG.js.map +1 -0
  22. package/dist/native.cjs +1 -2
  23. package/dist/native.iife.js +31 -31
  24. package/dist/native.iife.js.map +1 -1
  25. package/dist/native.js +2 -9
  26. package/dist/qna-C-ZboudC.cjs +2 -0
  27. package/dist/qna-C-ZboudC.cjs.map +1 -0
  28. package/dist/qna-CDfFy61x.js +442 -0
  29. package/dist/qna-CDfFy61x.js.map +1 -0
  30. package/dist/qna.cjs +1 -2
  31. package/dist/qna.css +1 -1
  32. package/dist/qna.iife.js +29 -29
  33. package/dist/qna.iife.js.map +1 -1
  34. package/dist/qna.js +2 -463
  35. package/dist/quantity-stepper-BuwCXbPt.cjs +2 -0
  36. package/dist/quantity-stepper-BuwCXbPt.cjs.map +1 -0
  37. package/dist/quantity-stepper-CTEOqVS6.js +74 -0
  38. package/dist/quantity-stepper-CTEOqVS6.js.map +1 -0
  39. package/dist/schemas-BNc2hTff.cjs +86 -0
  40. package/dist/schemas-BNc2hTff.cjs.map +1 -0
  41. package/dist/schemas-ClU0oPbf.js +4625 -0
  42. package/dist/schemas-ClU0oPbf.js.map +1 -0
  43. package/dist/simrel-B2UMdZ9p.cjs +2 -0
  44. package/dist/simrel-B2UMdZ9p.cjs.map +1 -0
  45. package/dist/simrel-BjL12luk.js +657 -0
  46. package/dist/simrel-BjL12luk.js.map +1 -0
  47. package/dist/simrel.cjs +1 -2
  48. package/dist/simrel.css +1 -1
  49. package/dist/simrel.iife.js +29 -29
  50. package/dist/simrel.iife.js.map +1 -1
  51. package/dist/simrel.js +2 -689
  52. package/package.json +13 -13
  53. package/dist/chat.cjs.map +0 -1
  54. package/dist/chat.js.map +0 -1
  55. package/dist/common.cjs.map +0 -1
  56. package/dist/common.js.map +0 -1
  57. package/dist/index-BAQXPosE.cjs +0 -2
  58. package/dist/index-BAQXPosE.cjs.map +0 -1
  59. package/dist/index-CUBMZpGs.js +0 -5111
  60. package/dist/index-CUBMZpGs.js.map +0 -1
  61. package/dist/index-Dco2Aw73.cjs +0 -13
  62. package/dist/index-Dco2Aw73.cjs.map +0 -1
  63. package/dist/index-DvSU2I9u.js +0 -506
  64. package/dist/index-DvSU2I9u.js.map +0 -1
  65. package/dist/index.cjs.map +0 -1
  66. package/dist/index.js.map +0 -1
  67. package/dist/native.cjs.map +0 -1
  68. package/dist/native.js.map +0 -1
  69. package/dist/qna.cjs.map +0 -1
  70. package/dist/qna.js.map +0 -1
  71. package/dist/quantity-stepper-CQWgexMO.cjs +0 -2
  72. package/dist/quantity-stepper-CQWgexMO.cjs.map +0 -1
  73. package/dist/quantity-stepper-CjY_cpgJ.js +0 -80
  74. package/dist/quantity-stepper-CjY_cpgJ.js.map +0 -1
  75. package/dist/schemas-5lXjLjwW.js +0 -4944
  76. package/dist/schemas-5lXjLjwW.js.map +0 -1
  77. package/dist/schemas-DqUVzVDf.cjs +0 -86
  78. package/dist/schemas-DqUVzVDf.cjs.map +0 -1
  79. package/dist/simrel.cjs.map +0 -1
  80. package/dist/simrel.js.map +0 -1
@@ -1,15 +1,15 @@
1
- (function(F){"use strict";const dn=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function ln(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const r=e.unknownRenderer??dn,o=s=>{const a=e.spec.elements[s];if(!a)return null;const c=e.registry[a.type];return c?c({elementId:s,element:a,spec:e.spec,context:e.context,renderElement:o}):r({elementId:s,element:a,spec:e.spec,context:e.context,renderElement:o})},i=o(e.spec.root);return i&&t.appendChild(i),t}function pn(e,t){if(!t)return e;const n={...e};for(const[r,o]of Object.entries(t))o&&(n[r]=o);return n}function fn(e,t){const n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Re(e,t){const n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function gn(e,t){const n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function mn(e,t){const n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function xe(e,t){const n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function hn(e,t){const n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function _n(e,t){const n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function yn(e,t){const n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}const vn=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"]),bn=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta","template","noscript"]),Le={"*":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 wn(e){return/^\s*javascript\s*:/i.test(e)}const kn=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"]),Sn=/url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;function En(e){const t=[];for(const n of e.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o===-1)continue;const i=r.slice(0,o).trim().toLowerCase(),s=r.slice(o+1).trim();kn.has(i)&&(Sn.test(s)||t.push(r))}return t.join("; ")}function ge(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const n=e,r=n.tagName.toLowerCase();if(bn.has(r)){n.parentNode?.removeChild(n);return}if(!vn.has(r)){const c=Array.from(n.childNodes);for(const u of c)t.insertBefore(u,n);t.removeChild(n);for(const u of c)ge(u,t);return}const o=Le["*"]??new Set,i=Le[r]??new Set,s=Array.from(n.attributes);for(const c of s){const u=c.name.toLowerCase();if(!o.has(u)&&!i.has(u)){n.removeAttribute(c.name);continue}if(wn(c.value)){n.removeAttribute(c.name);continue}if(u==="style"){const d=En(c.value);d?n.setAttribute("style",d):n.removeAttribute("style");continue}}if(r==="a"){const c=n.getAttribute("href");if(c!==null){const u=c.trim().toLowerCase();!u.startsWith("http://")&&!u.startsWith("https://")&&!u.startsWith("mailto:")&&n.removeAttribute("href")}n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer")}if(r==="img"){const c=n.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||n.removeAttribute("src"))}const a=Array.from(n.childNodes);for(const c of a)ge(c,n)}const zn=["http:","https:"];function Cn(e){try{return zn.includes(new URL(e).protocol)}catch{return!1}}function Tn(e){if(!e)return"";const n=new DOMParser().parseFromString(e,"text/html").body,r=Array.from(n.childNodes);for(const o of r)ge(o,n);return n.innerHTML}function me(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function De(e,t){const n=r=>{t(r.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function $n(){const t=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=t,sessionStorage.setItem("gengage_session_id",t),window.gengage||(window.gengage={}),window.gengage.sessionId=t,t}function In(e){return{sessionId:e?.sessionId??$n(),...e}}const je={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem"};function An(e){return e?{...je,...e}:{...je}}const L="gengage-global-toast-root",Ue="gengage-global-toast-style",he="gengage-global-toast-root--visible",Pn=4200,On=1500,Nn=15e3;let Me=!1,q=null;function Zn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")?"Bağlantı sorunu oluştu. Lütfen tekrar deneyin.":"Connection issue. Please try again."}function Rn(){Me||typeof window>"u"||typeof document>"u"||(Me=!0,De("gengage:global:error",e=>{xn(e)}))}function xn(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;Mn();const n=jn();n.innerHTML="";const r=document.createElement("section");r.className="gengage-global-toast gengage-global-toast--error",r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="gengage-global-toast-title",o.textContent=Dn(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,r.appendChild(o),r.appendChild(i),n.appendChild(r),n.classList.add(he),q&&(clearTimeout(q),q=null),q=setTimeout(()=>{Ln()},Un(e.durationMs))}function Ln(){if(typeof document>"u")return;const e=document.getElementById(L);e&&(e.classList.remove(he),e.innerHTML="",q&&(clearTimeout(q),q=null))}function Dn(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function jn(){const e=document.getElementById(L);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=L,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function Un(e){return typeof e!="number"||!Number.isFinite(e)?Pn:Math.min(Nn,Math.max(On,Math.round(e)))}function Mn(){if(document.getElementById(Ue))return;const e=document.createElement("style");e.id=Ue,e.textContent=`
2
- #${L} {
1
+ (function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;let n=document.createElement(`div`);for(let r of e.children){let e=t(r);e&&n.appendChild(e)}return n};function n(e){let n=document.createElement(`div`);if(n.className=e.containerClassName,!e.spec.elements[e.spec.root])return n;let r=e.unknownRenderer??t,i=t=>{let n=e.spec.elements[t];if(!n)return null;let a=e.registry[n.type];return a?a({elementId:t,element:n,spec:e.spec,context:e.context,renderElement:i}):r({elementId:t,element:n,spec:e.spec,context:e.context,renderElement:i})},a=i(e.spec.root);return a&&n.appendChild(a),n}function r(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t))r&&(n[e]=r);return n}function i(e,t){let n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function a(e,t){let n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function o(e,t){let n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function s(e,t){let n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function c(e,t){let n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function l(e,t){let n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function u(e,t){let n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function d(e,t){let n={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&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}var f=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`.split(`.`)),p=new Set([`script`,`iframe`,`object`,`embed`,`form`,`input`,`textarea`,`select`,`button`,`style`,`link`,`meta`,`template`,`noscript`]),m={"*":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 h(e){return/^\s*javascript\s*:/i.test(e)}var ee=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`.split(`.`)),te=/url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;function ne(e){let t=[];for(let n of e.split(`;`)){let e=n.trim();if(!e)continue;let r=e.indexOf(`:`);if(r===-1)continue;let i=e.slice(0,r).trim().toLowerCase(),a=e.slice(r+1).trim();ee.has(i)&&(te.test(a)||t.push(e))}return t.join(`; `)}function re(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}let n=e,r=n.tagName.toLowerCase();if(p.has(r)){n.parentNode?.removeChild(n);return}if(!f.has(r)){let e=Array.from(n.childNodes);for(let r of e)t.insertBefore(r,n);t.removeChild(n);for(let n of e)re(n,t);return}let i=m[`*`]??new Set,a=m[r]??new Set,o=Array.from(n.attributes);for(let e of o){let t=e.name.toLowerCase();if(!i.has(t)&&!a.has(t)){n.removeAttribute(e.name);continue}if(h(e.value)){n.removeAttribute(e.name);continue}if(t===`style`){let t=ne(e.value);t?n.setAttribute(`style`,t):n.removeAttribute(`style`);continue}}if(r===`a`){let e=n.getAttribute(`href`);if(e!==null){let t=e.trim().toLowerCase();!t.startsWith(`http://`)&&!t.startsWith(`https://`)&&!t.startsWith(`mailto:`)&&n.removeAttribute(`href`)}n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`)}if(r===`img`){let e=n.getAttribute(`src`);e!==null&&(e.trim().toLowerCase().startsWith(`https://`)||n.removeAttribute(`src`))}let s=Array.from(n.childNodes);for(let e of s)re(e,n)}var ie=[`http:`,`https:`];function ae(e){try{return ie.includes(new URL(e).protocol)}catch{return!1}}function oe(e){if(!e)return``;let t=new DOMParser().parseFromString(e,`text/html`).body,n=Array.from(t.childNodes);for(let e of n)re(e,t);return t.innerHTML}function se(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function ce(e,t){let n=e=>{t(e.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function le(){let 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 ue(e){return{sessionId:e?.sessionId??le(),...e}}var de={"--gengage-chat-offset":`20px`,"--gengage-chat-launcher-size":`56px`,"--gengage-chat-width":`400px`,"--gengage-chat-shell-radius":`1rem`,"--gengage-chat-header-height":`60px`,"--gengage-chat-conversation-width":`396px`,"--gengage-chat-panel-min-width":`320px`,"--gengage-chat-panel-max-width":`860px`,"--gengage-chat-input-height":`48px`,"--gengage-qna-pill-radius":`999px`,"--gengage-qna-input-radius":`0.75rem`,"--gengage-simrel-card-radius":`0.75rem`};function fe(e){return e?{...de,...e}:{...de}}var g=`gengage-global-toast-root`,pe=`gengage-global-toast-style`,me=`gengage-global-toast-root--visible`,he=4200,ge=1500,_e=15e3,ve=!1,_=null;function ye(e){return typeof e==`string`&&e.toLowerCase().startsWith(`tr`)?`Bağlantı sorunu oluştu. Lütfen tekrar deneyin.`:`Connection issue. Please try again.`}function be(){ve||typeof window>`u`||typeof document>`u`||(ve=!0,ce(`gengage:global:error`,e=>{xe(e)}))}function xe(e){if(typeof document>`u`)return;let t=e.message.trim();if(!t)return;Ee();let n=we();n.innerHTML=``;let r=document.createElement(`section`);r.className=`gengage-global-toast gengage-global-toast--error`,r.setAttribute(`role`,`status`),r.setAttribute(`aria-live`,`polite`);let i=document.createElement(`div`);i.className=`gengage-global-toast-title`,i.textContent=Ce(e.source);let a=document.createElement(`div`);a.className=`gengage-global-toast-message`,a.textContent=t,r.appendChild(i),r.appendChild(a),n.appendChild(r),n.classList.add(me),_&&=(clearTimeout(_),null),_=setTimeout(()=>{Se()},Te(e.durationMs))}function Se(){if(typeof document>`u`)return;let e=document.getElementById(g);e&&(e.classList.remove(me),e.innerHTML=``,_&&=(clearTimeout(_),null))}function Ce(e){switch(e){case`chat`:return`Chat warning`;case`qna`:return`QnA warning`;case`simrel`:return`Widget warning`;default:return`Connection warning`}}function we(){let e=document.getElementById(g);if(e instanceof HTMLElement)return e;let t=document.createElement(`div`);return t.id=g,t.className=`gengage-global-toast-root`,document.body.appendChild(t),t}function Te(e){return typeof e!=`number`||!Number.isFinite(e)?he:Math.min(_e,Math.max(ge,Math.round(e)))}function Ee(){if(document.getElementById(pe))return;let e=document.createElement(`style`);e.id=pe,e.textContent=`
2
+ #${g} {
3
3
  position: fixed;
4
4
  top: 16px;
5
5
  right: 16px;
6
6
  z-index: 2147483646;
7
7
  pointer-events: none;
8
8
  }
9
- #${L}.${he} {
9
+ #${g}.${me} {
10
10
  pointer-events: auto;
11
11
  }
12
- #${L} .gengage-global-toast {
12
+ #${g} .gengage-global-toast {
13
13
  min-width: 260px;
14
14
  max-width: min(92vw, 420px);
15
15
  border-radius: 12px;
@@ -24,12 +24,12 @@
24
24
  line-height: 1.4;
25
25
  animation: gengage-global-toast-in 180ms ease-out forwards;
26
26
  }
27
- #${L} .gengage-global-toast-title {
27
+ #${g} .gengage-global-toast-title {
28
28
  margin: 0 0 4px;
29
29
  font-size: 12px;
30
30
  font-weight: 700;
31
31
  }
32
- #${L} .gengage-global-toast-message {
32
+ #${g} .gengage-global-toast-message {
33
33
  margin: 0;
34
34
  font-weight: 500;
35
35
  }
@@ -43,44 +43,44 @@
43
43
  transform: translateY(0);
44
44
  }
45
45
  }
46
- `,document.head.appendChild(e)}let K=null;function Fn(){if(K!==null)return K;try{K=localStorage.getItem("gengage:debug")==="1"}catch{K=!1}return K}function _e(e,t,n){if(!Fn())return;const r=[`[gengage:${e}]`,t];n!==void 0&&r.push(n),console.debug(...r)}class qn{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(t){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const n=An(t.theme);this.config={...t,theme:n,session:In(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),Rn();const r=De("gengage:context:update",o=>this.update(o));this._cleanups.push(r),_e("lifecycle",`${this.constructor.name}.init`,{accountId:t.accountId,sku:t.pageContext?.sku});try{await this.onInit(this.config)}catch(o){throw this.destroy(),o}this._destroying||(this.isInitialised=!0,_e("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(t){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...t}}:t.pageType!==void 0&&(this.config={...this.config,pageContext:t}),this.onUpdate(t),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(t=>t()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._ownsRoot?this.root.remove():this.root.innerHTML="",this.isInitialised=!1)}on(t,n){return this._handlers.has(t)||this._handlers.set(t,new Set),this._handlers.get(t).add(n),()=>this._handlers.get(t)?.delete(n)}trackCheckout(t,n){const r=t==="start"?_n:yn;this.track(r(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(mn(this.analyticsContext(),t))}emit(t,...n){this._handlers.get(t)?.forEach(r=>r(...n))}addCleanup(t){this._cleanups.push(t)}track(t){this.config.analyticsClient?.track(t)}analyticsContext(){const t={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(t.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(t.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(t.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(t.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(t.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(t.ab_test_experiment_id=this.config.session.abTestExperimentId),t}_resolveMount(t){if(t instanceof HTMLElement)return t;if(typeof t=="string"){const r=document.querySelector(t);if(!r)throw new Error(`[gengage] Mount target not found: "${t}"`);return r}const n=document.createElement("div");return n.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.appendChild(n),this._ownsRoot=!0,n}_applyTheme(t){if(t){for(const[n,r]of Object.entries(t))if(r!==void 0){const o=n.startsWith("--")?n:`--gengage-${Jn(n)}`;this.root.style.setProperty(o,r)}}}}function Jn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}const Gn={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function Bn(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 Fe(e,t){return`${Bn(t?.middlewareUrl)}/chat${Gn[e]}`}function qe(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Vn(e){const t=[];let n=0,r=!1,o=!1,i=0;for(let s=0;s<e.length;s++){const a=e[s];if(o){o=!1;continue}if(a==="\\"&&r){o=!0;continue}if(a==='"'){r=!r;continue}r||(a==="{"&&n++,a==="}"&&(n--,n===0&&(t.push(e.slice(i,s+1)),i=s+1)))}return t.length>0?t:[e]}function Je(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const r=n.startsWith("data: ")?n.slice(6):n;if(r==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(r);return qe(o)?(_e("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=Vn(r);if(o.length>1){for(const i of o)try{const s=JSON.parse(i);if(!qe(s))continue;if(t.onEvent(s),s.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Ge(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const n=e.body.getReader(),r=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,s=Symbol("idle-timeout");let a=!1;try{for(;;){const c=n.read();let u;const d=await(i>0?Promise.race([c.then(h=>(clearTimeout(u),h)),new Promise(h=>{u=setTimeout(()=>h(s),i)})]):c);if(d===s){a=!0,await n.cancel();break}const{done:g,value:f}=d;if(g)break;o+=r.decode(f,{stream:!0});const m=o.split(`
47
- `);o=m.pop()??"";for(const h of m)if(Je(h,t))return}if(o.trim()&&Je(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{a||n.releaseLock()}t.onDone?.()}const Be=3,Wn=(e,t)=>{const n=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!n)return"";const r=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,"").trim():n;return r?r.split(/\s+/).slice(0,3).join(" ").trim():""},ye=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(n=>Wn(n,t)).filter(Boolean):[];function Hn(e){const t=(e.display_keywords??[]).flatMap(o=>ye(o,{stripLeadingStopWords:!0})),n=t.filter((o,i)=>t.indexOf(o)===i);if(n.length>0)return n.slice(0,Be);const r=[...ye(e.chosen_attribute,{stripLeadingStopWords:!0}),...ye(e.short_name)];return r.filter((o,i)=>r.indexOf(o)===i).slice(0,Be)}function Kn(e){return Hn(e).join(" • ")}function Ve(e){if(typeof e.type!="string")return null;if(Yn(e))return e;const n=e;switch(n.type){case"outputText":return Xn(n);case"suggestedActions":return Qn(n);case"productList":return er(n);case"productDetails":return tr(n);case"productDetailsSimilars":return nr(n);case"comparisonTable":return rr(n);case"context":return ar(n);case"chatStreamEnd":return cr();case"loading":return ur(n);case"panelLoading":return dr(n);case"similarLoading":return lr(n);case"redirect":return pr(n);case"error":return fr(n);case"dummy":return gr();case"launcherAction":return mr(n);case"text":return ve(n);case"productItem":return hr(n);case"text_image":return We(n);case"quick_qna":return He(n);case"reviewHighlights":return _r(n);case"aiProductSuggestions":return br(n);case"aiProductGroupings":return wr(n);case"aiSuggestedSearches":return kr(n);case"prosAndCons":return yr(n);case"getGroundingReview":return Sr(n);case"voice":return zr(n);case"visitorDataResponse":return vr(n);case"productListPreview":return Er();case"groupList":return Cr(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Tr(n);case"launcherContent":return Ir(n);case"handoff":return $r(n);default:return null}}function Yn(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const r=x(e.spec);return r?typeof r.root=="string"&&x(r.elements)!==null:!1}case"action":{const n=x(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Xn(e){const t=w(e.payload.text,e.payload.plain_text)??"",n=w(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const r={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(r.productMentions=o.filter(a=>typeof a=="object"&&a!==null&&typeof a.sku=="string"&&typeof a.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(r.skuToProductItem=i);const s=e.payload.conversation_mode;return typeof s=="string"&&s&&(r.conversationMode=s),r}function Qn(e){const t=(e.payload.actions??[]).map(n=>{const r=w(n.title)??"",o=N(n.requestDetails,r),i=o?{label:r,action:o}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Ke(t.filter(Xe),"chat")}function er(e){const t=Ye(e.payload.product_list??[],"chat");t.panelHint="panel";const n=t.spec.elements[t.spec.root];return n&&(typeof e.payload.offset=="number"&&(n.props={...n.props,offset:e.payload.offset}),typeof e.payload.end_of_list=="boolean"&&(n.props={...n.props,endOfList:e.payload.end_of_list}),typeof e.payload.title=="string"&&(n.props={...n.props,panelTitle:e.payload.title})),t}function tr(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:D(t)}}}},panelHint:"panel"}:Pr("chat")}function nr(e){const t=Ye(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function rr(e){const t=e.payload.multiple_product_details??[],n=e.payload,r={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,s=[];for(const y of t){const b=D(y);s.push(b)}const a=or(o,s,r,i);let c;r?.recommended_choice_sku?c=r.recommended_choice_sku:r?.winner_product&&r.winner_product.length>0&&(c=r.winner_product[0]?.product_detail?.sku??r.winner_product[0]?.sku);const u=c?s.find(y=>y.sku===c)??s[0]:s[0],d=[];if(Array.isArray(r?.key_differences))for(const y of r.key_differences)typeof y=="string"&&d.push(y);const g=Rr(r?.special_considerations),f=r?.recommended_choice,m=r?.winner_hits,h={};for(const y of s){const b=y.sku;b&&(h[b]={title:y.name??b,type:"launchSingleProduct",payload:{sku:b}})}const p={products:s,attributes:a,highlights:d,productActions:h};return u&&(p.recommended=u),g.length>0&&(p.specialCases=g),f&&(p.recommendedText=f),m&&(p.winnerHits=m),typeof r?.key_differences=="string"&&(p.keyDifferencesHtml=r.key_differences),r?.special_considerations&&(p.specialConsiderations=r.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:p}}},panelHint:"panel"}}function or(e,t,n,r){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const f=n.criteria_view??n.criteria_view_short??{},m=n.compared_field_names??Object.keys(e),h=[];for(const p of m){const y=e[p];if(!y||!Array.isArray(y))continue;const b=f[p]??p;h.push({label:b,values:y.map(Z=>typeof Z=="string"?Z:String(Z??""))})}return h}const s=e,a=t.map(f=>String(f.sku??"")).filter(f=>f.length>0),c=n.criteria_view??n.criteria_view_short??{},d=(r&&r.length>0?r:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:ir(s)).filter(f=>f!=="name"&&f!=="name_short"&&!f.endsWith("_short")),g=[];for(const f of d){const m=a.map(p=>{const y=s[p];if(!y||typeof y!="object")return"";const b=y[`${f}_short`],Z=y[f];return sr(b??Z)});if(m.every(p=>p.length===0))continue;const h=c[f]??f;g.push({label:h,values:m})}return g}function ir(e){const t=[],n=new Set;for(const r of Object.values(e))if(!(!r||typeof r!="object"))for(const o of Object.keys(r))n.has(o)||(n.add(o),t.push(o));return t}function sr(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function ar(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function cr(){return{type:"done"}}function ur(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:e.payload.text,thinkingMessages:e.payload.thinking_messages,dynamicLoading:e.payload.is_dynamic===!0}}}function dr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function lr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function pr(e){const t=w(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:w(e.payload.to)}}}function fr(e){return{type:"error",code:"BACKEND_ERROR",message:w(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function gr(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function mr(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const i={action_list:t.action_list},s=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0;return s!==void 0&&(i.type=s),a!==void 0&&(i.theme=a),He({payload:i})}const r=x(t.action);if(r){const i={action:r},s=typeof t.text=="string"?t.text:void 0,a=typeof t.image_url=="string"?t.image_url:void 0,c=typeof t.theme=="string"?t.theme:void 0;return s!==void 0&&(i.text=s),a!==void 0&&(i.image_url=a),c!==void 0&&(i.theme=c),We({payload:i})}const o=typeof t.text=="string"?t.text:"";if(o){const i={text:o},s=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0,c=x(t.payload)??void 0;return s!==void 0&&(i.type=s),c!==void 0&&(i.payload=c),a!==void 0&&(i.theme=a),ve({payload:i})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function ve(e){const t={text:w(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function hr(e){return Ar(e.payload,"qna")}function We(e){const t=w(e.payload.text)??"",n=N(e.payload.action,t);if(n){const o={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const r={text:t};return typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),ve({payload:r})}function He(e){const t=(e.payload.action_list??[]).map(n=>{const r=w(n.title)??"",o=N(n.requestDetails,r),i=o?{label:r,action:o}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Ke(t.filter(Xe),"qna")}function _r(e){const n={reviews:(e.payload.reviews??[]).map(r=>{const o={};return typeof r.review_class=="string"&&(o.review_class=r.review_class),typeof r.review_text=="string"&&(o.review_text=r.review_text),(typeof r.review_rating=="string"||typeof r.review_rating=="number")&&(o.review_rating=r.review_rating),typeof r.review_tag=="string"&&(o.review_tag=r.review_tag),o})};return typeof e.payload.sku=="string"&&(n.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:n}}}}}function yr(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 vr(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function br(e){const t=e.payload.product_suggestions??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=Or(o);if(!i)continue;const s={product:i},a=N(o.requestDetails,i.name);a&&(s.action=a),typeof o.role=="string"&&(s.role=o.role),typeof o.reason=="string"&&(s.reason=o.reason),typeof o.review_highlight=="string"&&(s.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(s.labels=o.labels),typeof o.expert_quality_score=="number"&&(s.expertQualityScore=o.expert_quality_score),n.push(s)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function wr(e){const t=e.payload.product_groupings??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=w(o.name)??"",s=o.sku&&o.sku.length>0?{type:"findSimilar",payload:{sku:o.sku}}:void 0,a=N(o.requestDetails??s,i);if(!a)continue;const c={name:i,action:a};if(Array.isArray(o.labels)){const u=o.labels.filter(d=>typeof d=="string");u.length>0&&(c.labels=u)}typeof o.image=="string"&&(c.image=o.image),n.push(c)}return 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 kr(e){const t=e.payload.suggested_searches??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=w(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${r+1}`,s={},a=w(o.detailed_user_message);a&&(s.text=a);const c=x(o.requestDetails),u=x(c?.payload),d=u?.group_skus;o.group_skus&&Array.isArray(o.group_skus)?s.group_skus=o.group_skus:Array.isArray(d)&&(s.group_skus=d.filter(Z=>typeof Z=="string"));const g=w(o.sku,o.representative_product_sku,u?.sku);g&&(s.sku=g),s.is_suggested_text=1;const f={type:"inputText",payload:s},m=N(o.requestDetails,i),h=m?.type==="findSimilar"&&typeof s.text=="string"?N(f,i):m??N(f,i);if(!h)continue;const p={shortName:i,action:h},y=w(o.detailed_user_message);y&&y!==i&&(p.detailedMessage=y);const b=Kn(o);b&&b!==i&&b!==(y??"")&&(p.whyDifferent=b),typeof o.image=="string"&&(p.image=o.image),n.push(p)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:n}}}}}}function Sr(e){const t=N(e.payload.requestDetails,w(e.payload.review_count,e.payload.text,e.payload.title)??"Show product reviews");if(!t)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:e.payload}};const n={action:t};return e.payload.title&&(n.title=e.payload.title),e.payload.text&&(n.text=e.payload.text),e.payload.review_count&&(n.reviewCount=e.payload.review_count),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function Er(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function zr(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Cr(e){const t=e.payload.group_list??[],n=[];for(const o of t){const i=o.group_name??"",s=(o.product_list??[]).map(D);n.push({groupName:i,products:s})}const r=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const s=N(o.requestDetails,i),a={title:i};s&&(a.action=s),r.push(a)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:r}}}},panelHint:"panel"}}function Tr(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function $r(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 Ir(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Ke(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`action-${o}`;r.push(s);const a={label:i.label,action:i.action};i.icon!==void 0&&(a.icon=i.icon),i.image!==void 0&&(a.image=i.image),i.description!==void 0&&(a.description=i.description),n[s]={type:"ActionButton",props:a}}return n.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Ye(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`product-${o}`;r.push(s),n[s]={type:"ProductCard",props:{product:D(i),index:o}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Ar(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:D(e),index:0}}}}}}function Pr(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Or(e){const t=w(e.sku),n=w(e.short_name),r=x(e.product_item)??e;return Nr(r,t,n)}function Nr(e,t,n){const r=w(e.sku,t),o=w(e.name,n);if(!r||!o)return null;const i={sku:r,name:o},s=w(e.brand);s&&(i.brand=s);const a=w(e.url);a&&(i.url=a);const c=Zr(e.images);if(c.length>0)i.images=c;else{const h=w(e.image,e.image_url,e.imageUrl);h&&(i.images=[h])}const u=Y(e.price_discounted);u!==void 0&&(i.price_discounted=u);const d=Y(e.price);d!==void 0&&(i.price=d);const g=Y(e.rating);g!==void 0&&(i.rating=g);const f=Y(e.review_count)??Y(e.reviewCount);f!==void 0&&(i.review_count=f);const m=w(e.cart_code,e.cartCode);return 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),D(i)}function N(e,t){const n=x(e);if(!n)return null;const r=n.type;if(typeof r!="string"||r.length===0)return null;const o={title:t||r,type:r};return n.payload!==void 0&&(o.payload=n.payload),o}function x(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function w(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function Zr(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Rr(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 Y(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const n=Number(t);if(Number.isFinite(n))return n}}function Xe(e){return e!=null}const xr=new Set(["sku","name","brand","images","price","price_discounted","price_currency","discount_reason","url","rating","review_count","cart_code","in_stock","category_ids","category_names","variants","facet_hits","promotions"]);function D(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,r=t&&e.price!=null?e.price:void 0;let o;r!=null&&n!=null&&r>0&&(o=Math.round((r-n)/r*100));const i=w(e.brand),s=w(e.name)??e.sku,a=i&&!s.toLowerCase().startsWith(i.toLowerCase())?`${i} ${s}`:s,c={sku:e.sku,name:a,url:w(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&(c.price=String(n)),r!=null&&(c.originalPrice=String(r)),o!==void 0&&(c.discountPercent=o),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions);const d=e,g={};let f=!1;for(const m of Object.keys(d))xr.has(m)||(g[m]=d[m],f=!0);return f&&(c.extras=g),c}function Lr(e){return e.results.map(D)}function Dr(e){return e.product_groupings.map(t=>{const n={name:t.name,products:(t.group_products??[]).map(D)};return t.highlight!==void 0&&(n.highlight=t.highlight),n})}function Qe(e){const t=[];for(const n of Object.values(e))if(n.type==="ProductCard"&&n.props){const r=n.props.product??n.props;typeof r.sku=="string"&&typeof r.name=="string"&&t.push(r)}return t}function et(e){const t=e.headers.get("Content-Type")??"";return t.includes("application/x-ndjson")||t.includes("text/event-stream")}async function jr(e,t){const n=[],r={onEvent:o=>{const i=Ve(o);!i||i.type!=="ui_spec"||n.push(...Qe(i.spec.elements))}};return t!==void 0&&(r.signal=t),await Ge(e,r),n}async function Ur(e,t,n){const r=Fe("similar_products",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(o.signal=n);const i=await fetch(r,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(et(i))return jr(i,n);const s=await i.text();if(!s)return[];try{return Lr(JSON.parse(s))}catch{throw new Error("Invalid JSON from similar_products endpoint")}}async function Mr(e,t){const n=[];let r=null;const o={onEvent:i=>{const s=Ve(i);if(s){if(s.type==="metadata"&&s.meta){const a=s.meta.group_name;if(typeof a=="string"){r={name:a,products:[]};const c=s.meta.highlight;typeof c=="string"&&(r.highlight=c),n.push(r)}}s.type==="ui_spec"&&r&&r.products.push(...Qe(s.spec.elements))}}};return t!==void 0&&(o.signal=t),await Ge(e,o),n}async function Fr(e,t,n){const r=Fe("product_groupings",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(o.signal=n);const i=await fetch(r,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(et(i))return Mr(i,n);const s=await i.text();if(!s)return[];try{return Dr(JSON.parse(s))}catch{throw new Error("Invalid JSON from product_groupings endpoint")}}const qr={currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!0};function tt(e,t){const n=Number(e);if(!Number.isFinite(n)||n<0)return e;const r={...qr,...t},i=n%1!==0||r.alwaysShowDecimals?n.toFixed(2):n.toFixed(0),s=i.indexOf("."),a=s===-1?i:i.slice(0,s),c=s===-1?void 0:i.slice(s+1),u=a.replace(/\B(?=(\d{3})+(?!\d))/g,r.thousandsSeparator);let d;return c!==void 0?d=`${u}${r.decimalSeparator}${c}`:d=u,r.currencySymbol?r.currencyPosition==="prefix"?`${r.currencySymbol}${d}`:`${d} ${r.currencySymbol}`:d}function Jr(e){const t=e.min??1,n=e.max??99,r=Math.min(t,n),o=Math.max(t,n);let s=Math.max(r,Math.min(o,e.initial??r));const a=document.createElement("div");a.className="gengage-qty-stepper gengage-qty-stepper--compact";const c=document.createElement("button");c.className="gengage-qty-btn",c.type="button",c.textContent=e.decreaseSymbol??"−",c.setAttribute("aria-label",e.decreaseLabel??"Decrease");const u=document.createElement("span");u.className="gengage-qty-value",u.textContent=String(s),u.setAttribute("aria-live","polite"),u.setAttribute("aria-atomic","true");const d=document.createElement("button");d.className="gengage-qty-btn",d.type="button",d.textContent=e.increaseSymbol??"+",d.setAttribute("aria-label",e.increaseLabel??"Increase");const g=document.createElement("button");g.className="gengage-qty-submit",g.type="button";const f='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>';g.innerHTML=e.submitIcon??f,g.title=e.label??"Add to Cart";function m(){c.disabled=s<=r,d.disabled=s>=o}return c.addEventListener("click",h=>{h.stopPropagation(),s>r&&(s--,u.textContent=String(s),m())}),d.addEventListener("click",h=>{h.stopPropagation(),s<o&&(s++,u.textContent=String(s),m())}),g.addEventListener("click",h=>{h.stopPropagation(),e.onSubmit(s);const p=g.innerHTML;g.textContent="✓",g.classList.add("gengage-qty-submit--success"),g.disabled=!0,setTimeout(()=>{g.innerHTML=p,g.classList.remove("gengage-qty-submit--success"),g.disabled=!1},1200)}),a.addEventListener("click",h=>{h.stopPropagation()}),m(),a.appendChild(c),a.appendChild(u),a.appendChild(d),a.appendChild(g),a}function Gr(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Br(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Vr(e){const t=Gr(e),n=Math.floor(t),r=t-n>=.5,o=5-n-(r?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`),n>0&&i.appendChild(document.createTextNode("★".repeat(n))),r){const s=document.createElement("span");s.className="gengage-star-half",s.textContent="☆";const a=document.createElement("span");a.textContent="★",s.appendChild(a),i.appendChild(s)}return o>0&&i.appendChild(document.createTextNode("☆".repeat(o))),i}function Wr(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function nt(e){const{product:t,index:n,discountType:r,onClick:o,onAddToCart:i,renderCard:s}=e,a=e.i18n,c=e.pricing;if(e.renderCardElement){const p=e.renderCardElement(t,n);if(p)return p}if(s){const p=document.createElement("div");return p.className="gengage-simrel-card gengage-simrel-card--custom",p.innerHTML=Tn(s(t,n)),p.addEventListener("click",y=>{y.target.closest(".gengage-simrel-atc")||y.target.closest(".gengage-chat-product-card-atc")||o(t)}),p}const u=document.createElement("article");u.className="gengage-simrel-card gengage-chat-product-card",t.inStock===!1&&u.classList.add("gengage-simrel-card--out-of-stock"),u.setAttribute("role","listitem"),u.dataset.sku=t.sku;const d=document.createElement("div");if(d.className="gengage-simrel-card-image gengage-chat-product-card-img-wrapper",t.imageUrl&&Cn(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",Wr(p),d.appendChild(p)}if(r==="badge"&&t.discountPercent&&t.discountPercent>0){const p=document.createElement("span");p.className="gengage-simrel-badge gengage-chat-product-card-discount-badge",p.textContent=`%${Br(t.discountPercent)}`,d.appendChild(p)}u.appendChild(d);const g=document.createElement("div");if(g.className="gengage-simrel-card-info gengage-chat-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(Vr(t.rating)),t.reviewCount!=null){const y=document.createElement("span");y.className="gengage-simrel-card-review-count gengage-chat-product-card-review-count",y.textContent=` (${t.reviewCount})`,p.appendChild(y)}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&&(r==="strike-through"||!r)){const p=document.createElement("span");p.className="gengage-simrel-card-price-original gengage-chat-product-card-original-price",p.textContent=tt(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=tt(t.price,c),m.appendChild(p)}g.appendChild(m),u.appendChild(g);const h=document.createElement("button");if(h.className="gengage-simrel-card-cta gengage-chat-product-card-cta",h.type="button",h.textContent=a?.ctaLabel??"View",h.addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),o(t)}),u.appendChild(h),t.inStock===!1){const p=document.createElement("div");p.className="gengage-simrel-card-oos",p.textContent=a?.outOfStockLabel??"Out of Stock",u.appendChild(p)}else if(t.cartCode){const p=t.cartCode,y=Jr({compact:!0,label:a?.addToCartButton??"Add to Cart",decreaseLabel:a?.decreaseLabel,increaseLabel:a?.increaseLabel,onSubmit:b=>{i({sku:t.sku,quantity:b,cartCode:p})}});y.classList.add("gengage-simrel-atc"),u.appendChild(y)}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 rt(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 n=0;n<e.products.length;n++){const o={product:e.products[n],index:n,onClick:e.onClick,onAddToCart:e.onAddToCart};e.i18n!==void 0&&(o.i18n=e.i18n),e.discountType!==void 0&&(o.discountType=e.discountType),e.renderCard!==void 0&&(o.renderCard=e.renderCard),e.renderCardElement!==void 0&&(o.renderCardElement=e.renderCardElement);const i=nt(o);t.appendChild(i)}return e.products.length===0&&(t.style.display="none",t.dataset.empty="true"),t}let Hr=0;function Kr(e){const t=Hr++,n=document.createElement("div");if(n.className="gengage-simrel-groups",e.groups.length===0)return n.style.display="none",n.dataset.empty="true",n;const r=document.createElement("div");r.className="gengage-simrel-tabs",r.setAttribute("role","tablist");const o=[],i=[],s=d=>{const g={products:d.products,onClick:e.onClick,onAddToCart:e.onAddToCart};return e.i18n!==void 0&&(g.i18n=e.i18n),e.discountType!==void 0&&(g.discountType=e.discountType),e.renderCard!==void 0&&(g.renderCard=e.renderCard),e.renderCardElement!==void 0&&(g.renderCardElement=e.renderCardElement),g},a=d=>{for(let h=0;h<o.length;h++){const p=h===d;o[h].classList.toggle("gengage-simrel-tab--active",p),o[h].setAttribute("aria-selected",String(p)),o[h].tabIndex=p?0:-1}const g=e.groups[d],f=i[d];f.innerHTML="";const m=rt(s(g));f.appendChild(m);for(let h=0;h<i.length;h++){const p=h===d;i[h].style.display=p?"":"none",i[h].tabIndex=p?0:-1}};for(let d=0;d<e.groups.length;d++){const g=e.groups[d],f=`gengage-simrel-tab-${t}-${d}`,m=`gengage-simrel-panel-${t}-${d}`,h=document.createElement("button");h.className="gengage-simrel-tab",h.type="button",h.id=f,h.textContent=g.name,h.setAttribute("role","tab"),h.setAttribute("aria-controls",m),h.setAttribute("aria-selected",String(d===0)),h.tabIndex=d===0?0:-1,d===0&&h.classList.add("gengage-simrel-tab--active"),h.addEventListener("click",()=>a(d)),h.addEventListener("keydown",y=>{let b=-1;y.key==="ArrowRight"||y.key==="ArrowDown"?b=(d+1)%e.groups.length:y.key==="ArrowLeft"||y.key==="ArrowUp"?b=(d-1+e.groups.length)%e.groups.length:y.key==="Home"?b=0:y.key==="End"&&(b=e.groups.length-1),b>=0&&(y.preventDefault(),a(b),o[b].focus())}),o.push(h),r.appendChild(h);const p=document.createElement("div");p.className="gengage-simrel-tab-panel",p.id=m,p.setAttribute("role","tabpanel"),p.setAttribute("aria-labelledby",f),p.tabIndex=d===0?0:-1,d!==0&&(p.style.display="none"),i.push(p)}n.appendChild(r);const c=i[0],u=rt(s(e.groups[0]));c.appendChild(u);for(const d of i)n.appendChild(d);return n}function ot(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 n={sku:t.sku,name:t.name,url:t.url},r=t.imageUrl;typeof r=="string"&&(n.imageUrl=r);const o=t.price;typeof o=="string"&&(n.price=o);const i=t.originalPrice;typeof i=="string"&&(n.originalPrice=i);const s=t.discountPercent;typeof s=="number"&&(n.discountPercent=s);const a=t.brand;typeof a=="string"&&(n.brand=a);const c=t.rating;typeof c=="number"&&(n.rating=c);const u=t.reviewCount;typeof u=="number"&&(n.reviewCount=u);const d=t.cartCode;typeof d=="string"&&(n.cartCode=d);const g=t.inStock;typeof g=="boolean"&&(n.inStock=g);const f=t.extras;return f!=null&&typeof f=="object"&&(n.extras=f),n}function Yr(e){if(!e||typeof e!="object")return null;const t=e,n=t.title,r=t.type;if(typeof n!="string"||typeof r!="string")return null;const o={title:n,type:r};return t.payload!==void 0&&(o.payload=t.payload),o}const it={ProductGrid:({element:e,renderElement:t,context:n})=>{const r=document.createElement("div");r.className="gengage-simrel-grid",r.setAttribute("role","list");const o=e.props?.columns;typeof o=="number"&&Number.isFinite(o)&&o>0&&r.style.setProperty("--gengage-simrel-columns",String(o));for(const i of e.children??[]){const s=t(i);s&&r.appendChild(s)}if(r.children.length===0){const i=document.createElement("div");i.className="gengage-simrel-empty",i.textContent=n.i18n.emptyStateMessage,r.appendChild(i)}return r},ProductCard:({element:e,context:t})=>{const n=e.props?.product??e.props,r=ot(n);if(!r)return null;const o=e.props?.index,i=typeof o=="number"&&Number.isFinite(o)?o:0,s=e.props?.discountType,a=s==="strike-through"||s==="badge"?s:t.discountType,c={product:r,index:i,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return a!==void 0&&(c.discountType=a),t.renderCard!==void 0&&(c.renderCard=t.renderCard),t.renderCardElement!==void 0&&(c.renderCardElement=t.renderCardElement),t.pricing!==void 0&&(c.pricing=t.pricing),nt(c)},GroupTabs:({element:e,context:t})=>{const n=e.props?.groups;if(!Array.isArray(n))return null;const r=[];for(const i of n){if(!i||typeof i!="object")continue;const s=i;if(typeof s.name!="string")continue;const a=[];if(Array.isArray(s.products))for(const u of s.products){const d=ot(u);d&&a.push(d)}const c={name:s.name,products:a};typeof s.highlight=="string"&&(c.highlight=s.highlight),r.push(c)}const o={groups:r,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return t.discountType!==void 0&&(o.discountType=t.discountType),t.renderCard!==void 0&&(o.renderCard=t.renderCard),t.renderCardElement!==void 0&&(o.renderCardElement=t.renderCardElement),Kr(o)},EmptyState:({element:e,context:t})=>{const n=document.createElement("div");n.className="gengage-simrel-empty";const r=e.props?.message;return n.textContent=typeof r=="string"?r:t.i18n.emptyStateMessage,n},AddToCartButton:({element:e,context:t})=>{const n=e.props?.sku,r=e.props?.cartCode;if(typeof n!="string"||typeof r!="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",s=>{s.preventDefault(),s.stopPropagation(),t.onAddToCart({sku:n,quantity:1,cartCode:r})}),o},QuickActions:({element:e,context:t})=>{const n=document.createElement("div");n.className="gengage-simrel-quick-actions";const r=e.props?.actions;if(!Array.isArray(r)||!t.onAction)return n;for(const o of r){if(!o||typeof o!="object")continue;const i=o,s=i.label,a=Yr(i.action);if(typeof s!="string"||!a)continue;const c=document.createElement("button");c.className="gengage-simrel-quick-action",c.type="button",c.textContent=s,c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),t.onAction?.(a)}),n.appendChild(c)}return n}},be=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function st(){return{...it}}function at(e,t,n=it,r=be){return ln({spec:e,context:t,registry:n,containerClassName:"gengage-simrel-uispec",unknownRenderer:r})}const ct={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"},Xr={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:""};function Qr(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function eo(e){return Qr(e)==="en"?Xr:ct}function to(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function ne(e,t){const n={event:e,...t};to()&&window.dataLayer.push(n)}function no(e){ne("gengage-on-init",{gengage_widget:e})}function ut(e){ne("gengage-show",{gengage_widget:e})}function ro(e,t){ne("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function oo(e,t){ne("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function l(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=s.prototype,d=Object.keys(u);for(let g=0;g<d.length;g++){const f=d[g];f in a||(a[f]=u[f].bind(a))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=n?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class V extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class dt extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const lt={};function J(e){return lt}function pt(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function we(e,t){return typeof t=="bigint"?t.toString():t}function ke(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Se(e){return e==null}function Ee(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function io(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}const ft=Symbol("evaluating");function v(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ft)return r===void 0&&(r=ft,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function G(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function j(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function gt(e){return JSON.stringify(e)}function so(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const mt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ao=ke(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function X(e){if(re(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(re(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ht(e){return X(e)?{...e}:Array.isArray(e)?[...e]:e}const co=new Set(["string","number","symbol"]);function oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function _(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function uo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const lo={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 po(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=j(e._zod.def,{get shape(){const s={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=n.shape[a])}return G(this,"shape",s),s},checks:[]});return U(e,i)}function fo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=j(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return G(this,"shape",s),s},checks:[]});return U(e,i)}function go(e,t){if(!X(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=j(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return G(this,"shape",i),i}});return U(e,o)}function mo(e,t){if(!X(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=j(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return G(this,"shape",r),r}});return U(e,n)}function ho(e,t){const n=j(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return G(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return U(e,n)}function _o(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=j(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return G(this,"shape",c),c},checks:[]});return U(t,s)}function yo(e,t,n){const r=j(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(const s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return G(this,"shape",i),i}});return U(t,r)}function W(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function _t(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ie(e){return typeof e=="string"?e:e?.message}function B(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=ie(e.inst?._zod.def?.error?.(e))??ie(t?.error?.(e))??ie(n.customError?.(e))??ie(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ze(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Q(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const yt=(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,we,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vt=l("$ZodError",yt),bt=l("$ZodError",yt,{Parent:Error});function vo(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function bo(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;for(;a<i.path.length;){const c=i.path[a];a===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return r(e),n}const Ce=e=>(t,n,r,o)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new V;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>B(c,i,J())));throw mt(a,o?.callee),a}return s.value},Te=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>B(c,i,J())));throw mt(a,o?.callee),a}return s.value},se=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new V;return i.issues.length?{success:!1,error:new(e??vt)(i.issues.map(s=>B(s,o,J())))}:{success:!0,data:i.value}},wo=se(bt),ae=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>B(s,o,J())))}:{success:!0,data:i.value}},ko=ae(bt),So=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ce(e)(t,n,o)},Eo=e=>(t,n,r)=>Ce(e)(t,n,r),zo=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Te(e)(t,n,o)},Co=e=>async(t,n,r)=>Te(e)(t,n,r),To=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return se(e)(t,n,o)},$o=e=>(t,n,r)=>se(e)(t,n,r),Io=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ae(e)(t,n,o)},Ao=e=>async(t,n,r)=>ae(e)(t,n,r),Po=/^[cC][^\s-]{8,}$/,Oo=/^[0-9a-z]+$/,No=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Zo=/^[0-9a-vA-V]{20}$/,Ro=/^[A-Za-z0-9]{27}$/,xo=/^[a-zA-Z0-9_-]{21}$/,Lo=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Do=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,wt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,jo=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Uo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Mo(){return new RegExp(Uo,"u")}const Fo=/^(?:(?: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])$/,qo=/^(([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}|:))$/,Jo=/^((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])$/,Go=/^(([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])$/,Bo=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kt=/^[A-Za-z0-9_-]*$/,Vo=/^\+[1-9]\d{6,14}$/,St="(?:(?:\\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])))",Wo=new RegExp(`^${St}$`);function Et(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 Ho(e){return new RegExp(`^${Et(e)}$`)}function Ko(e){const t=Et({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${St}T(?:${r})$`)}const Yo=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Xo=/^-?\d+$/,Qo=/^-?\d+(?:\.\d+)?$/,ei=/^[^A-Z]*$/,ti=/^[^a-z]*$/,$=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),zt={number:"number",bigint:"bigint",object:"date"},Ct=l("$ZodCheckLessThan",(e,t)=>{$.init(e,t);const n=zt[typeof t.value];e._zod.onattach.push(r=>{const o=r._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=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Tt=l("$ZodCheckGreaterThan",(e,t)=>{$.init(e,t);const n=zt[typeof t.value];e._zod.onattach.push(r=>{const o=r._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=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ni=l("$ZodCheckMultipleOf",(e,t)=>{$.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):io(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ri=l("$ZodCheckNumberFormat",(e,t)=>{$.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=lo[t.format];e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=Xo)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),oi=l("$ZodCheckMaxLength",(e,t)=>{var n;$.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Se(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const s=ze(o);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ii=l("$ZodCheckMinLength",(e,t)=>{var n;$.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Se(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const s=ze(o);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),si=l("$ZodCheckLengthEquals",(e,t)=>{var n;$.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Se(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const s=ze(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ce=l("$ZodCheckStringFormat",(e,t)=>{var n,r;$.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ai=l("$ZodCheckRegex",(e,t)=>{ce.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ci=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ei),ce.init(e,t)}),ui=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ti),ce.init(e,t)}),di=l("$ZodCheckIncludes",(e,t)=>{$.init(e,t);const n=oe(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),li=l("$ZodCheckStartsWith",(e,t)=>{$.init(e,t);const n=new RegExp(`^${oe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),pi=l("$ZodCheckEndsWith",(e,t)=>{$.init(e,t);const n=new RegExp(`.*${oe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),fi=l("$ZodCheckOverwrite",(e,t)=>{$.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class gi{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
48
- `).filter(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
49
- `))}}const mi={major:4,minor:3,patch:6},E=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=mi;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,a,c)=>{let u=W(s),d;for(const g of a){if(g._zod.def.when){if(!g._zod.def.when(s))continue}else if(u)continue;const f=s.issues.length,m=g._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new V;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,s.issues.length!==f&&(u||(u=W(s,f)))});else{if(s.issues.length===f)continue;u||(u=W(s,f))}}return d?d.then(()=>s):s},i=(s,a,c)=>{if(W(s))return s.aborted=!0,s;const u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new V;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){const u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>i(d,s,a)):i(u,s,a)}const c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new V;return c.then(u=>o(u,r,a))}return o(c,r,a)}}v(e,"~standard",()=>({validate:o=>{try{const i=wo(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return ko(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),$e=l("$ZodString",(e,t)=>{E.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Yo(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),k=l("$ZodStringFormat",(e,t)=>{ce.init(e,t),$e.init(e,t)}),hi=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Do),k.init(e,t)}),_i=l("$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=wt(r))}else t.pattern??(t.pattern=wt());k.init(e,t)}),yi=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=jo),k.init(e,t)}),vi=l("$ZodURL",(e,t)=>{k.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),bi=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Mo()),k.init(e,t)}),wi=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=xo),k.init(e,t)}),ki=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Po),k.init(e,t)}),Si=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Oo),k.init(e,t)}),Ei=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=No),k.init(e,t)}),zi=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Zo),k.init(e,t)}),Ci=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ro),k.init(e,t)}),Ti=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ko(t)),k.init(e,t)}),$i=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Wo),k.init(e,t)}),Ii=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ho(t)),k.init(e,t)}),Ai=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Lo),k.init(e,t)}),Pi=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Fo),k.init(e,t),e._zod.bag.format="ipv4"}),Oi=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=qo),k.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Ni=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Jo),k.init(e,t)}),Zi=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Go),k.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function $t(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ri=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Bo),k.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{$t(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function xi(e){if(!kt.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return $t(n)}const Li=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=kt),k.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{xi(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Di=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Vo),k.init(e,t)});function ji(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Ui=l("$ZodJWT",(e,t)=>{k.init(e,t),e._zod.check=n=>{ji(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),It=l("$ZodNumber",(e,t)=>{E.init(e,t),e._zod.pattern=e._zod.bag.pattern??Qo,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Mi=l("$ZodNumberFormat",(e,t)=>{ri.init(e,t),It.init(e,t)}),Fi=l("$ZodUnknown",(e,t)=>{E.init(e,t),e._zod.parse=n=>n}),qi=l("$ZodNever",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function At(e,t,n){e.issues.length&&t.issues.push(..._t(n,e.issues)),t.value[n]=e.value}const Ji=l("$ZodArray",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let s=0;s<o.length;s++){const a=o[s],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?i.push(c.then(u=>At(u,n,s))):At(c,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function ue(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(..._t(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Pt(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=uo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ot(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const g in t){if(a.has(g))continue;if(u==="never"){s.push(g);continue}const f=c.run({value:t[g],issues:[]},r);f instanceof Promise?e.push(f.then(m=>ue(m,n,g,t,d))):ue(f,n,g,t,d)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Gi=l("$ZodObject",(e,t)=>{if(E.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=ke(()=>Pt(t));v(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const g of d.values)c[u].add(g)}}return c});const o=re,i=t.catchall;let s;e._zod.parse=(a,c)=>{s??(s=r.value);const u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const d=[],g=s.shape;for(const f of s.keys){const m=g[f],h=m._zod.optout==="optional",p=m._zod.run({value:u[f],issues:[]},c);p instanceof Promise?d.push(p.then(y=>ue(y,a,f,u,h))):ue(p,a,f,u,h)}return i?Ot(d,u,a,c,r.value,e):d.length?Promise.all(d).then(()=>a):a}}),Bi=l("$ZodObjectJIT",(e,t)=>{Gi.init(e,t);const n=e._zod.parse,r=ke(()=>Pt(t)),o=f=>{const m=new gi(["shape","payload","ctx"]),h=r.value,p=R=>{const A=gt(R);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};m.write("const input = payload.value;");const y=Object.create(null);let b=0;for(const R of h.keys)y[R]=`key_${b++}`;m.write("const newResult = {};");for(const R of h.keys){const A=y[R],O=gt(R),jc=f[R]?._zod?.optout==="optional";m.write(`const ${A} = ${p(R)};`),jc?m.write(`
50
- if (${A}.issues.length) {
51
- if (${O} in input) {
52
- payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
46
+ `,document.head.appendChild(e)}var v=null;function De(){if(v!==null)return v;try{v=localStorage.getItem(`gengage:debug`)===`1`}catch{v=!1}return v}function Oe(e,t,n){if(!De())return;let r=[`[gengage:${e}]`,t];n!==void 0&&r.push(n),console.debug(...r)}var ke=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}let t=fe(e.theme);this.config={...e,theme:t,session:ue(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),be();let n=ce(`gengage:context:update`,e=>this.update(e));this._cleanups.push(n),Oe(`lifecycle`,`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(e){throw this.destroy(),e}this._destroying||(this.isInitialised=!0,Oe(`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._ownsRoot?this.root.remove():this.root.innerHTML=``,this.isInitialised=!1)}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){let n=e===`start`?u:d;this.track(n(this.analyticsContext(),t))}flushMeteringSummary(e){this.track(s(this.analyticsContext(),e))}emit(e,...t){this._handlers.get(e)?.forEach(e=>e(...t))}addCleanup(e){this._cleanups.push(e)}track(e){this.config.analyticsClient?.track(e)}analyticsContext(){let 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`){let t=document.querySelector(e);if(!t)throw Error(`[gengage] Mount target not found: "${e}"`);return t}let t=document.createElement(`div`);return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.appendChild(t),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(let[t,n]of Object.entries(e))if(n!==void 0){let e=t.startsWith(`--`)?t:`--gengage-${Ae(t)}`;this.root.style.setProperty(e,n)}}}};function Ae(e){return e.replace(/([A-Z])/g,`-$1`).toLowerCase()}var je={process_action:`/process_action`,launcher_action:`/launcher_action`,similar_products:`/similar_products`,product_groupings:`/product_groupings`};function Me(e){if(e===void 0)throw Error(`[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.`);let t=e.trim();return t===``?``:t.replace(/\/+$/,``)}function Ne(e,t){return`${Me(t?.middlewareUrl)}/chat${je[e]}`}function Pe(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function Fe(e){let t=[],n=0,r=!1,i=!1,a=0;for(let o=0;o<e.length;o++){let s=e[o];if(i){i=!1;continue}if(s===`\\`&&r){i=!0;continue}if(s===`"`){r=!r;continue}r||(s===`{`&&n++,s===`}`&&(n--,n===0&&(t.push(e.slice(a,o+1)),a=o+1)))}return t.length>0?t:[e]}function Ie(e,t){let n=e.trim();if(!n||n.startsWith(`:`))return!1;let r=n.startsWith(`data: `)?n.slice(6):n;if(r===`[DONE]`)return t.onDone?.(),!0;try{let e=JSON.parse(r);return Pe(e)?(Oe(`stream`,`event: ${e.type}`,e),t.onEvent(e),e.type===`done`?(t.onDone?.(),!0):!1):!1}catch{let e=Fe(r);if(e.length>1){for(let n of e)try{let e=JSON.parse(n);if(!Pe(e))continue;if(t.onEvent(e),e.type===`done`)return t.onDone?.(),!0}catch{}return!1}return!1}}async function Le(e,t){if(!e.ok){t.onError?.(Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(Error(`Response body is null — streaming not supported`));return}let n=e.body.getReader(),r=new TextDecoder(`utf-8`),i=``,a=t.idleTimeoutMs??6e4,o=Symbol(`idle-timeout`),s=!1;try{for(;;){let e=n.read(),c,l=await(a>0?Promise.race([e.then(e=>(clearTimeout(c),e)),new Promise(e=>{c=setTimeout(()=>e(o),a)})]):e);if(l===o){s=!0,await n.cancel();break}let{done:u,value:d}=l;if(u)break;i+=r.decode(d,{stream:!0});let f=i.split(`
47
+ `);i=f.pop()??``;for(let e of f)if(Ie(e,t))return}if(i.trim()&&Ie(i,t))return}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;t.onError?.(e instanceof Error?e:Error(String(e)))}finally{s||n.releaseLock()}t.onDone?.()}var Re=3,ze=(e,t)=>{let n=e.replace(/\s+/g,` `).trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,``);if(!n)return``;let r=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,``).trim():n;return r?r.split(/\s+/).slice(0,3).join(` `).trim():``},Be=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(e=>ze(e,t)).filter(Boolean):[];function Ve(e){let t=(e.display_keywords??[]).flatMap(e=>Be(e,{stripLeadingStopWords:!0})),n=t.filter((e,n)=>t.indexOf(e)===n);if(n.length>0)return n.slice(0,Re);let r=[...Be(e.chosen_attribute,{stripLeadingStopWords:!0}),...Be(e.short_name)];return r.filter((e,t)=>r.indexOf(e)===t).slice(0,Re)}function He(e){return Ve(e).join(` • `)}function Ue(e){if(typeof e.type!=`string`)return null;if(We(e))return e;let t=e;switch(t.type){case`outputText`:return Ge(t);case`suggestedActions`:return Ke(t);case`productList`:return qe(t);case`productDetails`:return Je(t);case`productDetailsSimilars`:return Ye(t);case`comparisonTable`:return Xe(t);case`context`:return et(t);case`chatStreamEnd`:return tt();case`loading`:return nt(t);case`panelLoading`:return rt(t);case`similarLoading`:return it(t);case`redirect`:return at(t);case`error`:return ot(t);case`dummy`:return st(t);case`launcherAction`:return ct(t);case`text`:return lt(t);case`productItem`:return ut(t);case`text_image`:return dt(t);case`quick_qna`:return ft(t);case`reviewHighlights`:return pt(t);case`aiProductSuggestions`:return gt(t);case`aiProductGroupings`:return _t(t);case`aiSuggestedSearches`:return vt(t);case`prosAndCons`:return mt(t);case`getGroundingReview`:return yt(t);case`voice`:return xt(t);case`visitorDataResponse`:return ht(t);case`productListPreview`:return bt();case`groupList`:return St(t);case`formGetInfo`:case`formTestDrive`:case`formServiceRequest`:case`launchFormPage`:return Ct(t);case`launcherContent`:return Tt(t);case`handoff`:return wt(t);default:return null}}function We(e){let 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`:{let t=e.widget;if(t!==`chat`&&t!==`qna`&&t!==`simrel`)return!1;let n=b(e.spec);return n?typeof n.root==`string`&&b(n.elements)!==null:!1}case`action`:{let t=b(e.action);return t!==null&&typeof t.kind==`string`}case`error`:return typeof e.code==`string`&&typeof e.message==`string`;case`done`:return!0;default:return!1}}function Ge(e){let t=x(e.payload.text,e.payload.plain_text)??``,n=x(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:`error`,code:`BACKEND_ERROR`,message:n||`Backend returned an error`};let r={type:`text_chunk`,content:t,final:!0},i=e.payload.product_mentions;Array.isArray(i)&&i.length>0&&(r.productMentions=i.filter(e=>typeof e==`object`&&!!e&&typeof e.sku==`string`&&typeof e.short_name==`string`));let a=e.payload.sku_to_product_item;a&&typeof a==`object`&&!Array.isArray(a)&&(r.skuToProductItem=a);let o=e.payload.conversation_mode;return typeof o==`string`&&o&&(r.conversationMode=o),r}function Ke(e){return Et((e.payload.actions??[]).map(e=>{let t=x(e.title)??``,n=y(e.requestDetails,t),r=n?{label:t,action:n}:null;return r?(typeof e.icon==`string`&&(r.icon=e.icon),typeof e.image==`string`&&(r.image=e.image),r):null}).filter(Pt),`chat`)}function qe(e){let t=Dt(e.payload.product_list??[],`chat`);t.panelHint=`panel`;let n=t.spec.elements[t.spec.root];return n&&(typeof e.payload.offset==`number`&&(n.props={...n.props,offset:e.payload.offset}),typeof e.payload.end_of_list==`boolean`&&(n.props={...n.props,endOfList:e.payload.end_of_list}),typeof e.payload.title==`string`&&(n.props={...n.props,panelTitle:e.payload.title})),t}function Je(e){let t=e.payload.productDetails;return t?{type:`ui_spec`,widget:`chat`,spec:{root:`root`,elements:{root:{type:`ProductDetailsPanel`,props:{product:C(t)}}}},panelHint:`panel`}:kt(`chat`)}function Ye(e){let t=Dt(e.payload.similarProducts??[],`chat`),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:`panel`}}function Xe(e){let t=e.payload.multiple_product_details??[],n=e.payload,r={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},i=e.payload.table,a=e.payload.features_list,o=[];for(let e of t){let t=C(e);o.push(t)}let s=Ze(i,o,r,a),c;r?.recommended_choice_sku?c=r.recommended_choice_sku:r?.winner_product&&r.winner_product.length>0&&(c=r.winner_product[0]?.product_detail?.sku??r.winner_product[0]?.sku);let l=c?o.find(e=>e.sku===c)??o[0]:o[0],u=[];if(Array.isArray(r?.key_differences))for(let e of r.key_differences)typeof e==`string`&&u.push(e);let d=Nt(r?.special_considerations),f=r?.recommended_choice,p=r?.winner_hits,m={};for(let e of o){let t=e.sku;t&&(m[t]={title:e.name??t,type:`launchSingleProduct`,payload:{sku:t}})}let h={products:o,attributes:s,highlights:u,productActions:m};return l&&(h.recommended=l),d.length>0&&(h.specialCases=d),f&&(h.recommendedText=f),p&&(h.winnerHits=p),typeof r?.key_differences==`string`&&(h.keyDifferencesHtml=r.key_differences),r?.special_considerations&&(h.specialConsiderations=r.special_considerations),{type:`ui_spec`,widget:`chat`,spec:{root:`root`,elements:{root:{type:`ComparisonTable`,props:h}}},panelHint:`panel`}}function Ze(e,t,n,r){if(!e)return[];let i=Object.entries(e);if(i.length===0)return[];let a=i[0]?.[1];if(Array.isArray(a)){let t=n.criteria_view??n.criteria_view_short??{},r=n.compared_field_names??Object.keys(e),i=[];for(let n of r){let r=e[n];if(!r||!Array.isArray(r))continue;let a=t[n]??n;i.push({label:a,values:r.map(e=>typeof e==`string`?e:String(e??``))})}return i}let o=e,s=t.map(e=>String(e.sku??``)).filter(e=>e.length>0),c=n.criteria_view??n.criteria_view_short??{},l=(r&&r.length>0?r:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:Qe(o)).filter(e=>e!==`name`&&e!==`name_short`&&!e.endsWith(`_short`)),u=[];for(let e of l){let t=s.map(t=>{let n=o[t];if(!n||typeof n!=`object`)return``;let r=n[`${e}_short`],i=n[e];return $e(r??i)});if(t.every(e=>e.length===0))continue;let n=c[e]??e;u.push({label:n,values:t})}return u}function Qe(e){let t=[],n=new Set;for(let r of Object.values(e))if(!(!r||typeof r!=`object`))for(let e of Object.keys(r))n.has(e)||(n.add(e),t.push(e));return t}function $e(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function et(e){return{type:`metadata`,sessionId:``,model:``,meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function tt(){return{type:`done`}}function nt(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 rt(e){return{type:`metadata`,sessionId:``,model:``,meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function it(e){return{type:`metadata`,sessionId:``,model:``,meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function at(e){let t=x(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:x(e.payload.to)}}}function ot(e){return{type:`error`,code:`BACKEND_ERROR`,message:x(e.payload?.text,e.payload?.message,e.payload?.error)??`Backend returned an error`}}function st(e){return{type:`metadata`,sessionId:``,model:``,meta:{noop:!0}}}function ct(e){let t=e.payload??{};if(Array.isArray(t.action_list)){let e={action_list:t.action_list},n=typeof t.type==`string`?t.type:void 0,r=typeof t.theme==`string`?t.theme:void 0;return n!==void 0&&(e.type=n),r!==void 0&&(e.theme=r),ft({type:`quick_qna`,payload:e})}let n=b(t.action);if(n){let e={action:n},r=typeof t.text==`string`?t.text:void 0,i=typeof t.image_url==`string`?t.image_url:void 0,a=typeof t.theme==`string`?t.theme:void 0;return r!==void 0&&(e.text=r),i!==void 0&&(e.image_url=i),a!==void 0&&(e.theme=a),dt({type:`text_image`,payload:e})}let r=typeof t.text==`string`?t.text:``;if(r){let e={text:r},n=typeof t.type==`string`?t.type:void 0,i=typeof t.theme==`string`?t.theme:void 0,a=b(t.payload)??void 0;return n!==void 0&&(e.type=n),a!==void 0&&(e.payload=a),i!==void 0&&(e.theme=i),lt({type:`text`,payload:e})}return{type:`metadata`,sessionId:``,model:``,meta:{launcherAction:t}}}function lt(e){let t={text:x(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 ut(e){return Ot(e.payload,`qna`)}function dt(e){let t=x(e.payload.text)??``,n=y(e.payload.action,t);if(n){let r={label:t||n.title,action:n};return typeof e.payload.image_url==`string`&&(r.image=e.payload.image_url),typeof e.payload.theme==`string`&&(r.theme=e.payload.theme),{type:`ui_spec`,widget:`qna`,spec:{root:`root`,elements:{root:{type:`ActionButton`,props:r}}}}}let r={text:t};return typeof e.payload.theme==`string`&&(r.theme=e.payload.theme),lt({type:`text`,payload:r})}function ft(e){return Et((e.payload.action_list??[]).map(e=>{let t=x(e.title)??``,n=y(e.requestDetails,t),r=n?{label:t,action:n}:null;return r?(typeof e.icon==`string`&&(r.icon=e.icon),typeof e.image==`string`&&(r.image=e.image),r):null}).filter(Pt),`qna`)}function pt(e){let t={reviews:(e.payload.reviews??[]).map(e=>{let t={};return typeof e.review_class==`string`&&(t.review_class=e.review_class),typeof e.review_text==`string`&&(t.review_text=e.review_text),(typeof e.review_rating==`string`||typeof e.review_rating==`number`)&&(t.review_rating=e.review_rating),typeof e.review_tag==`string`&&(t.review_tag=e.review_tag),t})};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 mt(e){let 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 ht(e){return{type:`metadata`,sessionId:``,model:``,meta:{visitorDataResponse:e.payload}}}function gt(e){let t=e.payload.product_suggestions??[],n=[];for(let e=0;e<t.length;e++){let r=t[e];if(!r)continue;let i=At(r);if(!i)continue;let a={product:i},o=y(r.requestDetails,i.name);o&&(a.action=o),typeof r.role==`string`&&(a.role=r.role),typeof r.reason==`string`&&(a.reason=r.reason),typeof r.review_highlight==`string`&&(a.reviewHighlight=r.review_highlight),Array.isArray(r.labels)&&(a.labels=r.labels),typeof r.expert_quality_score==`number`&&(a.expertQualityScore=r.expert_quality_score),n.push(a)}return n.length===0?{type:`metadata`,sessionId:``,model:``,meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:`ui_spec`,widget:`chat`,spec:{root:`root`,elements:{root:{type:`AITopPicks`,props:{suggestions:n}}}}}}function _t(e){let t=e.payload.product_groupings??[],n=[];for(let e=0;e<t.length;e++){let r=t[e];if(!r)continue;let i=x(r.name)??``,a=r.sku&&r.sku.length>0?{type:`findSimilar`,payload:{sku:r.sku}}:void 0,o=y(r.requestDetails??a,i);if(!o)continue;let s={name:i,action:o};if(Array.isArray(r.labels)){let e=r.labels.filter(e=>typeof e==`string`);e.length>0&&(s.labels=e)}typeof r.image==`string`&&(s.image=r.image),n.push(s)}return 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 vt(e){let t=e.payload.suggested_searches??[],n=[];for(let e=0;e<t.length;e++){let r=t[e];if(!r)continue;let i=x(r.short_name,r.chosen_attribute,r.detailed_user_message)??`Search ${e+1}`,a={},o=x(r.detailed_user_message);o&&(a.text=o);let s=b(b(r.requestDetails)?.payload),c=s?.group_skus;r.group_skus&&Array.isArray(r.group_skus)?a.group_skus=r.group_skus:Array.isArray(c)&&(a.group_skus=c.filter(e=>typeof e==`string`));let l=x(r.sku,r.representative_product_sku,s?.sku);l&&(a.sku=l),a.is_suggested_text=1;let u={type:`inputText`,payload:a},d=y(r.requestDetails,i),f=d?.type===`findSimilar`&&typeof a.text==`string`?y(u,i):d??y(u,i);if(!f)continue;let p={shortName:i,action:f},m=x(r.detailed_user_message);m&&m!==i&&(p.detailedMessage=m);let h=He(r);h&&h!==i&&h!==(m??``)&&(p.whyDifferent=h),typeof r.image==`string`&&(p.image=r.image),n.push(p)}return n.length===0?{type:`metadata`,sessionId:``,model:``,meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:`ui_spec`,widget:`chat`,spec:{root:`root`,elements:{root:{type:`AISuggestedSearchCards`,props:{entries:n}}}}}}function yt(e){let t=y(e.payload.requestDetails,x(e.payload.review_count,e.payload.text,e.payload.title)??`Show product reviews`);if(!t)return{type:`metadata`,sessionId:``,model:``,meta:{groundingReview:e.payload}};let n={action:t};return e.payload.title&&(n.title=e.payload.title),e.payload.text&&(n.text=e.payload.text),e.payload.review_count&&(n.reviewCount=e.payload.review_count),{type:`ui_spec`,widget:`chat`,spec:{root:`root`,elements:{root:{type:`GroundingReviewCard`,props:n}}}}}function bt(){return{type:`metadata`,sessionId:``,model:``,meta:{analyzeAnimation:!0}}}function xt(e){return{type:`metadata`,sessionId:``,model:``,meta:{voice:e.payload}}}function St(e){let t=e.payload.group_list??[],n=[];for(let e of t){let t=e.group_name??``,r=(e.product_list??[]).map(C);n.push({groupName:t,products:r})}let r=[];for(let t of e.payload.filter_tags??[]){let e=t.title??``;if(!e)continue;let n=y(t.requestDetails,e),i={title:e};n&&(i.action=n),r.push(i)}return{type:`ui_spec`,widget:`chat`,spec:{root:`root`,elements:{root:{type:`CategoriesContainer`,props:{groups:n,filterTags:r}}}},panelHint:`panel`}}function Ct(e){return{type:`metadata`,sessionId:``,model:``,meta:{formType:e.type,formPayload:e.payload??{}}}}function wt(e){let 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 Tt(e){return{type:`metadata`,sessionId:``,model:``,meta:{launcherContent:e.payload??{}}}}function Et(e,t){let n={},r=[];for(let t=0;t<e.length;t++){let i=e[t];if(!i)continue;let a=`action-${t}`;r.push(a);let o={label:i.label,action:i.action};i.icon!==void 0&&(o.icon=i.icon),i.image!==void 0&&(o.image=i.image),i.description!==void 0&&(o.description=i.description),n[a]={type:`ActionButton`,props:o}}return n.root={type:`ActionButtons`,props:{buttons:e.map(e=>{let t={label:e.label,action:e.action};return e.image!==void 0&&(t.image=e.image),e.description!==void 0&&(t.description=e.description),e.icon!==void 0&&(t.icon=e.icon),t})},children:r},{type:`ui_spec`,widget:t,spec:{root:`root`,elements:n}}}function Dt(e,t){let n={},r=[];for(let t=0;t<e.length;t++){let i=e[t];if(!i)continue;let a=`product-${t}`;r.push(a),n[a]={type:`ProductCard`,props:{product:C(i),index:t}}}return n.root={type:`ProductGrid`,props:{layout:`grid`},children:r},{type:`ui_spec`,widget:t,spec:{root:`root`,elements:n}}}function Ot(e,t){return{type:`ui_spec`,widget:t,spec:{root:`root`,elements:{root:{type:`ProductCard`,props:{product:C(e),index:0}}}}}}function kt(e){return{type:`ui_spec`,widget:e,spec:{root:`root`,elements:{root:{type:`ActionButtons`,props:{buttons:[]},children:[]}}}}}function At(e){let t=x(e.sku),n=x(e.short_name);return jt(b(e.product_item)??e,t,n)}function jt(e,t,n){let r=x(e.sku,t),i=x(e.name,n);if(!r||!i)return null;let a={sku:r,name:i},o=x(e.brand);o&&(a.brand=o);let s=x(e.url);s&&(a.url=s);let c=Mt(e.images);if(c.length>0)a.images=c;else{let t=x(e.image,e.image_url,e.imageUrl);t&&(a.images=[t])}let l=S(e.price_discounted);l!==void 0&&(a.price_discounted=l);let u=S(e.price);u!==void 0&&(a.price=u);let d=S(e.rating);d!==void 0&&(a.rating=d);let f=S(e.review_count)??S(e.reviewCount);f!==void 0&&(a.review_count=f);let p=x(e.cart_code,e.cartCode);return p&&(a.cart_code=p),typeof e.in_stock==`boolean`&&(a.in_stock=e.in_stock),typeof e.inStock==`boolean`&&(a.in_stock=e.inStock),C(a)}function y(e,t){let n=b(e);if(!n)return null;let r=n.type;if(typeof r!=`string`||r.length===0)return null;let i={title:t||r,type:r};return n.payload!==void 0&&(i.payload=n.payload),i}function b(e){return!e||typeof e!=`object`||Array.isArray(e)?null:e}function x(...e){for(let t of e)if(typeof t==`string`){let e=t.trim();if(e.length>0)return e}}function Mt(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.length>0):[]}function Nt(e){if(typeof e==`string`){let t=e.trim();return t?[t]:[]}return Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0):[]}function S(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`){let t;t=e.includes(`.`)&&e.includes(`,`)?e.replace(/\./g,``).replace(`,`,`.`):e.replace(`,`,`.`);let n=Number(t);if(Number.isFinite(n))return n}}function Pt(e){return e!=null}var Ft=new Set([`sku`,`name`,`brand`,`images`,`price`,`price_discounted`,`price_currency`,`discount_reason`,`url`,`rating`,`review_count`,`cart_code`,`in_stock`,`category_ids`,`category_names`,`variants`,`facet_hits`,`promotions`]);function C(e){let t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,r=t&&e.price!=null?e.price:void 0,i;r!=null&&n!=null&&r>0&&(i=Math.round((r-n)/r*100));let a=x(e.brand),o=x(e.name)??e.sku,s=a&&!o.toLowerCase().startsWith(a.toLowerCase())?`${a} ${o}`:o,c={sku:e.sku,name:s,url:x(e.url)??``},l=e.images?.[0];l&&(c.imageUrl=l),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&(c.price=String(n)),r!=null&&(c.originalPrice=String(r)),i!==void 0&&(c.discountPercent=i),a!==void 0&&(c.brand=a),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);let u=e,d={},f=!1;for(let e of Object.keys(u))Ft.has(e)||(d[e]=u[e],f=!0);return f&&(c.extras=d),c}function It(e){return e.results.map(C)}function Lt(e){return e.product_groupings.map(e=>{let t={name:e.name,products:(e.group_products??[]).map(C)};return e.highlight!==void 0&&(t.highlight=e.highlight),t})}function Rt(e){let t=[];for(let n of Object.values(e))if(n.type===`ProductCard`&&n.props){let e=n.props.product??n.props;typeof e.sku==`string`&&typeof e.name==`string`&&t.push(e)}return t}function zt(e){let t=e.headers.get(`Content-Type`)??``;return t.includes(`application/x-ndjson`)||t.includes(`text/event-stream`)}async function Bt(e,t){let n=[],r={onEvent:e=>{let t=Ue(e);!t||t.type!==`ui_spec`||n.push(...Rt(t.spec.elements))}};return t!==void 0&&(r.signal=t),await Le(e,r),n}async function Vt(e,t,n){let r=Ne(`similar_products`,t),i={method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);let a=await fetch(r,i);if(!a.ok)throw Error(`HTTP ${a.status}: ${a.statusText}`);if(zt(a))return Bt(a,n);let o=await a.text();if(!o)return[];try{return It(JSON.parse(o))}catch{throw Error(`Invalid JSON from similar_products endpoint`)}}async function Ht(e,t){let n=[],r=null,i={onEvent:e=>{let t=Ue(e);if(t){if(t.type===`metadata`&&t.meta){let e=t.meta.group_name;if(typeof e==`string`){r={name:e,products:[]};let i=t.meta.highlight;typeof i==`string`&&(r.highlight=i),n.push(r)}}t.type===`ui_spec`&&r&&r.products.push(...Rt(t.spec.elements))}}};return t!==void 0&&(i.signal=t),await Le(e,i),n}async function Ut(e,t,n){let r=Ne(`product_groupings`,t),i={method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);let a=await fetch(r,i);if(!a.ok)throw Error(`HTTP ${a.status}: ${a.statusText}`);if(zt(a))return Ht(a,n);let o=await a.text();if(!o)return[];try{return Lt(JSON.parse(o))}catch{throw Error(`Invalid JSON from product_groupings endpoint`)}}var Wt={currencySymbol:`TL`,currencyPosition:`suffix`,thousandsSeparator:`.`,decimalSeparator:`,`,alwaysShowDecimals:!0};function Gt(e,t){let n=Number(e);if(!Number.isFinite(n)||n<0)return e;let r={...Wt,...t},i=n%1!=0||r.alwaysShowDecimals?n.toFixed(2):n.toFixed(0),a=i.indexOf(`.`),o=a===-1?i:i.slice(0,a),s=a===-1?void 0:i.slice(a+1),c=o.replace(/\B(?=(\d{3})+(?!\d))/g,r.thousandsSeparator),l;return l=s===void 0?c:`${c}${r.decimalSeparator}${s}`,r.currencySymbol?r.currencyPosition===`prefix`?`${r.currencySymbol}${l}`:`${l} ${r.currencySymbol}`:l}function Kt(e){let t=e.min??1,n=e.max??99,r=Math.min(t,n),i=Math.max(t,n),a=Math.max(r,Math.min(i,e.initial??r)),o=e.compact??!1,s=a,c=document.createElement(`div`);c.className=`gengage-qty-stepper${o?` gengage-qty-stepper--compact`:``}`;let l=document.createElement(`button`);l.className=`gengage-qty-btn`,l.type=`button`,l.textContent=e.decreaseSymbol??`−`,l.setAttribute(`aria-label`,e.decreaseLabel??`Decrease`);let u=document.createElement(`span`);u.className=`gengage-qty-value`,u.textContent=String(s),u.setAttribute(`aria-live`,`polite`),u.setAttribute(`aria-atomic`,`true`);let d=document.createElement(`button`);d.className=`gengage-qty-btn`,d.type=`button`,d.textContent=e.increaseSymbol??`+`,d.setAttribute(`aria-label`,e.increaseLabel??`Increase`);let f=document.createElement(`button`);f.className=`gengage-qty-submit`,f.type=`button`,o?(f.innerHTML=e.submitIcon??`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>`,f.title=e.label??`Add to Cart`):f.textContent=e.label??`Add to Cart`;function p(){l.disabled=s<=r,d.disabled=s>=i}return l.addEventListener(`click`,e=>{e.stopPropagation(),s>r&&(s--,u.textContent=String(s),p())}),d.addEventListener(`click`,e=>{e.stopPropagation(),s<i&&(s++,u.textContent=String(s),p())}),f.addEventListener(`click`,t=>{t.stopPropagation(),e.onSubmit(s);let n=f.innerHTML;f.textContent=`✓`,f.classList.add(`gengage-qty-submit--success`),f.disabled=!0,setTimeout(()=>{f.innerHTML=n,f.classList.remove(`gengage-qty-submit--success`),f.disabled=!1},1200)}),c.addEventListener(`click`,e=>{e.stopPropagation()}),p(),c.appendChild(l),c.appendChild(u),c.appendChild(d),c.appendChild(f),c}function qt(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Jt(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Yt(e){let t=qt(e),n=Math.floor(t),r=t-n>=.5,i=5-n-(r?1:0),a=document.createElement(`span`);if(a.className=`gengage-star-rating`,a.setAttribute(`role`,`img`),a.setAttribute(`aria-label`,`${t.toFixed(1)} out of 5 stars`),n>0&&a.appendChild(document.createTextNode(`★`.repeat(n))),r){let e=document.createElement(`span`);e.className=`gengage-star-half`,e.textContent=`☆`;let t=document.createElement(`span`);t.textContent=`★`,e.appendChild(t),a.appendChild(e)}return i>0&&a.appendChild(document.createTextNode(`☆`.repeat(i))),a}function Xt(e){e.addEventListener(`error`,()=>{e.style.display=`none`},{once:!0})}function Zt(e){let{product:t,index:n,discountType:r,onClick:i,onAddToCart:a,renderCard:o}=e,s=e.i18n,c=e.pricing;if(e.renderCardElement){let r=e.renderCardElement(t,n);if(r)return r}if(o){let e=document.createElement(`div`);return e.className=`gengage-simrel-card gengage-simrel-card--custom`,e.innerHTML=oe(o(t,n)),e.addEventListener(`click`,e=>{e.target.closest(`.gengage-simrel-atc`)||e.target.closest(`.gengage-chat-product-card-atc`)||i(t)}),e}let l=document.createElement(`article`);l.className=`gengage-simrel-card gengage-chat-product-card`,t.inStock===!1&&l.classList.add(`gengage-simrel-card--out-of-stock`),l.setAttribute(`role`,`listitem`),l.dataset.sku=t.sku;let u=document.createElement(`div`);if(u.className=`gengage-simrel-card-image gengage-chat-product-card-img-wrapper`,t.imageUrl&&ae(t.imageUrl)){let e=document.createElement(`img`);e.className=`gengage-chat-product-card-img`,e.src=t.imageUrl,e.alt=t.name,e.loading=`lazy`,Xt(e),u.appendChild(e)}if(r===`badge`&&t.discountPercent&&t.discountPercent>0){let e=document.createElement(`span`);e.className=`gengage-simrel-badge gengage-chat-product-card-discount-badge`,e.textContent=`%${Jt(t.discountPercent)}`,u.appendChild(e)}l.appendChild(u);let d=document.createElement(`div`);if(d.className=`gengage-simrel-card-info gengage-chat-product-card-body`,t.brand){let e=document.createElement(`div`);e.className=`gengage-simrel-card-brand gengage-chat-product-card-brand`,e.textContent=t.brand,d.appendChild(e)}let f=document.createElement(`div`);if(f.className=`gengage-simrel-card-name gengage-chat-product-card-name`,f.textContent=t.name,f.title=t.name,d.appendChild(f),t.rating!=null&&t.rating>0){let e=document.createElement(`div`);if(e.className=`gengage-simrel-card-rating gengage-chat-product-card-rating`,e.appendChild(Yt(t.rating)),t.reviewCount!=null){let n=document.createElement(`span`);n.className=`gengage-simrel-card-review-count gengage-chat-product-card-review-count`,n.textContent=` (${t.reviewCount})`,e.appendChild(n)}d.appendChild(e)}let p=document.createElement(`div`);if(p.className=`gengage-simrel-card-price gengage-chat-product-card-price`,t.originalPrice&&t.originalPrice!==t.price&&(r===`strike-through`||!r)){let e=document.createElement(`span`);e.className=`gengage-simrel-card-price-original gengage-chat-product-card-original-price`,e.textContent=Gt(t.originalPrice,c),p.appendChild(e)}if(t.price&&parseFloat(t.price)>0){let e=document.createElement(`span`);e.className=`gengage-simrel-card-price-current gengage-chat-product-card-price-current`,e.textContent=Gt(t.price,c),p.appendChild(e)}d.appendChild(p),l.appendChild(d);let m=document.createElement(`button`);if(m.className=`gengage-simrel-card-cta gengage-chat-product-card-cta`,m.type=`button`,m.textContent=s?.ctaLabel??`View`,m.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),i(t)}),l.appendChild(m),t.inStock===!1){let e=document.createElement(`div`);e.className=`gengage-simrel-card-oos`,e.textContent=s?.outOfStockLabel??`Out of Stock`,l.appendChild(e)}else if(t.cartCode){let e=t.cartCode,n=Kt({compact:!0,label:s?.addToCartButton??`Add to Cart`,decreaseLabel:s?.decreaseLabel,increaseLabel:s?.increaseLabel,onSubmit:n=>{a({sku:t.sku,quantity:n,cartCode:e})}});n.classList.add(`gengage-simrel-atc`),l.appendChild(n)}return l.addEventListener(`click`,e=>{e.target.closest(`.gengage-simrel-atc`)||e.target.closest(`.gengage-chat-product-card-atc`)||e.target.closest(`.gengage-chat-product-card-cta`)||i(t)}),l}function Qt(e){let 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 n=0;n<e.products.length;n++){let r={product:e.products[n],index:n,onClick:e.onClick,onAddToCart:e.onAddToCart};e.i18n!==void 0&&(r.i18n=e.i18n),e.discountType!==void 0&&(r.discountType=e.discountType),e.renderCard!==void 0&&(r.renderCard=e.renderCard),e.renderCardElement!==void 0&&(r.renderCardElement=e.renderCardElement);let i=Zt(r);t.appendChild(i)}return e.products.length===0&&(t.style.display=`none`,t.dataset.empty=`true`),t}var $t=0;function en(e){let t=$t++,n=document.createElement(`div`);if(n.className=`gengage-simrel-groups`,e.groups.length===0)return n.style.display=`none`,n.dataset.empty=`true`,n;let r=document.createElement(`div`);r.className=`gengage-simrel-tabs`,r.setAttribute(`role`,`tablist`);let i=[],a=[],o=t=>{let n={products:t.products,onClick:e.onClick,onAddToCart:e.onAddToCart};return 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),n},s=t=>{for(let e=0;e<i.length;e++){let n=e===t;i[e].classList.toggle(`gengage-simrel-tab--active`,n),i[e].setAttribute(`aria-selected`,String(n)),i[e].tabIndex=n?0:-1}let n=e.groups[t],r=a[t];r.innerHTML=``;let s=Qt(o(n));r.appendChild(s);for(let e=0;e<a.length;e++){let n=e===t;a[e].style.display=n?``:`none`,a[e].tabIndex=n?0:-1}};for(let n=0;n<e.groups.length;n++){let o=e.groups[n],c=`gengage-simrel-tab-${t}-${n}`,l=`gengage-simrel-panel-${t}-${n}`,u=document.createElement(`button`);u.className=`gengage-simrel-tab`,u.type=`button`,u.id=c,u.textContent=o.name,u.setAttribute(`role`,`tab`),u.setAttribute(`aria-controls`,l),u.setAttribute(`aria-selected`,String(n===0)),u.tabIndex=n===0?0:-1,n===0&&u.classList.add(`gengage-simrel-tab--active`),u.addEventListener(`click`,()=>s(n)),u.addEventListener(`keydown`,t=>{let r=-1;t.key===`ArrowRight`||t.key===`ArrowDown`?r=(n+1)%e.groups.length:t.key===`ArrowLeft`||t.key===`ArrowUp`?r=(n-1+e.groups.length)%e.groups.length:t.key===`Home`?r=0:t.key===`End`&&(r=e.groups.length-1),r>=0&&(t.preventDefault(),s(r),i[r].focus())}),i.push(u),r.appendChild(u);let d=document.createElement(`div`);d.className=`gengage-simrel-tab-panel`,d.id=l,d.setAttribute(`role`,`tabpanel`),d.setAttribute(`aria-labelledby`,c),d.tabIndex=n===0?0:-1,n!==0&&(d.style.display=`none`),a.push(d)}n.appendChild(r);let c=a[0],l=Qt(o(e.groups[0]));c.appendChild(l);for(let e of a)n.appendChild(e);return n}function tn(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.sku!=`string`||typeof t.name!=`string`||typeof t.url!=`string`)return null;let n={sku:t.sku,name:t.name,url:t.url},r=t.imageUrl;typeof r==`string`&&(n.imageUrl=r);let i=t.price;typeof i==`string`&&(n.price=i);let a=t.originalPrice;typeof a==`string`&&(n.originalPrice=a);let o=t.discountPercent;typeof o==`number`&&(n.discountPercent=o);let s=t.brand;typeof s==`string`&&(n.brand=s);let c=t.rating;typeof c==`number`&&(n.rating=c);let l=t.reviewCount;typeof l==`number`&&(n.reviewCount=l);let u=t.cartCode;typeof u==`string`&&(n.cartCode=u);let d=t.inStock;typeof d==`boolean`&&(n.inStock=d);let f=t.extras;return typeof f==`object`&&f&&(n.extras=f),n}function nn(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.title,r=t.type;if(typeof n!=`string`||typeof r!=`string`)return null;let i={title:n,type:r};return t.payload!==void 0&&(i.payload=t.payload),i}var rn={ProductGrid:({element:e,renderElement:t,context:n})=>{let r=document.createElement(`div`);r.className=`gengage-simrel-grid`,r.setAttribute(`role`,`list`);let i=e.props?.columns;typeof i==`number`&&Number.isFinite(i)&&i>0&&r.style.setProperty(`--gengage-simrel-columns`,String(i));for(let n of e.children??[]){let e=t(n);e&&r.appendChild(e)}if(r.children.length===0){let e=document.createElement(`div`);e.className=`gengage-simrel-empty`,e.textContent=n.i18n.emptyStateMessage,r.appendChild(e)}return r},ProductCard:({element:e,context:t})=>{let n=tn(e.props?.product??e.props);if(!n)return null;let r=e.props?.index,i=typeof r==`number`&&Number.isFinite(r)?r:0,a=e.props?.discountType,o=a===`strike-through`||a===`badge`?a:t.discountType,s={product:n,index:i,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return o!==void 0&&(s.discountType=o),t.renderCard!==void 0&&(s.renderCard=t.renderCard),t.renderCardElement!==void 0&&(s.renderCardElement=t.renderCardElement),t.pricing!==void 0&&(s.pricing=t.pricing),Zt(s)},GroupTabs:({element:e,context:t})=>{let n=e.props?.groups;if(!Array.isArray(n))return null;let r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.name!=`string`)continue;let n=[];if(Array.isArray(t.products))for(let e of t.products){let t=tn(e);t&&n.push(t)}let i={name:t.name,products:n};typeof t.highlight==`string`&&(i.highlight=t.highlight),r.push(i)}let i={groups:r,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return t.discountType!==void 0&&(i.discountType=t.discountType),t.renderCard!==void 0&&(i.renderCard=t.renderCard),t.renderCardElement!==void 0&&(i.renderCardElement=t.renderCardElement),en(i)},EmptyState:({element:e,context:t})=>{let n=document.createElement(`div`);n.className=`gengage-simrel-empty`;let r=e.props?.message;return n.textContent=typeof r==`string`?r:t.i18n.emptyStateMessage,n},AddToCartButton:({element:e,context:t})=>{let n=e.props?.sku,r=e.props?.cartCode;if(typeof n!=`string`||typeof r!=`string`)return null;let i=document.createElement(`button`);i.className=`gengage-simrel-atc gengage-chat-product-card-cta`,i.type=`button`;let a=e.props?.label;return i.textContent=typeof a==`string`?a:t.i18n.addToCartButton,i.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),t.onAddToCart({sku:n,quantity:1,cartCode:r})}),i},QuickActions:({element:e,context:t})=>{let n=document.createElement(`div`);n.className=`gengage-simrel-quick-actions`;let r=e.props?.actions;if(!Array.isArray(r)||!t.onAction)return n;for(let e of r){if(!e||typeof e!=`object`)continue;let r=e,i=r.label,a=nn(r.action);if(typeof i!=`string`||!a)continue;let o=document.createElement(`button`);o.className=`gengage-simrel-quick-action`,o.type=`button`,o.textContent=i,o.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),t.onAction?.(a)}),n.appendChild(o)}return n}},an=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;let n=document.createElement(`div`);for(let r of e.children){let e=t(r);e&&n.appendChild(e)}return n};function on(){return{...rn}}function sn(e,t,r=rn,i=an){return n({spec:e,context:t,registry:r,containerClassName:`gengage-simrel-uispec`,unknownRenderer:i})}var cn={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`},ln={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:``};function un(e){return e?e.toLowerCase().split(`-`)[0]??`tr`:`tr`}function dn(e){switch(un(e)){case`en`:return ln;default:return cn}}function fn(){return typeof window<`u`&&Array.isArray(window.dataLayer)}function w(e,t){let n={event:e,...t};fn()&&window.dataLayer.push(n)}function pn(e){w(`gengage-on-init`,{gengage_widget:e})}function mn(e){w(`gengage-show`,{gengage_widget:e})}function hn(e,t){w(`gengage-product-detail`,{gengage_sku:e,gengage_product_name:t})}function gn(e,t){w(`gengage-cart-add`,{gengage_sku:e,gengage_quantity:t})}Object.freeze({status:`aborted`});function T(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var E=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},_n=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},vn={};function D(e){return e&&Object.assign(vn,e),vn}function yn(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function bn(e,t){return typeof t==`bigint`?t.toString():t}function xn(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function Sn(e){return e==null}function Cn(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function wn(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var Tn=Symbol(`evaluating`);function O(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Tn)return r===void 0&&(r=Tn,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function k(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function A(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function En(e){return JSON.stringify(e)}function Dn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var On=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function kn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var An=xn(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function j(e){if(kn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(kn(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function jn(e){return j(e)?{...e}:Array.isArray(e)?[...e]:e}var Mn=new Set([`string`,`number`,`symbol`]);function Nn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function M(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function N(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw 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 Pn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Fn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function In(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return M(e,A(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return k(this,`shape`,e),e},checks:[]}))}function Ln(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return M(e,A(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return k(this,`shape`,r),r},checks:[]}))}function Rn(e,t){if(!j(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return M(e,A(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return k(this,`shape`,n),n}}))}function zn(e,t){if(!j(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return M(e,A(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return k(this,`shape`,n),n}}))}function Bn(e,t){return M(e,A(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return k(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Vn(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return M(t,A(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return k(this,`shape`,i),i},checks:[]}))}function Hn(e,t,n){return M(t,A(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return k(this,`shape`,i),i}}))}function P(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Un(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Wn(e){return typeof e==`string`?e:e?.message}function F(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Wn(e.inst?._zod.def?.error?.(e))??Wn(t?.error?.(e))??Wn(n.customError?.(e))??Wn(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Gn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function I(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Kn=(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,bn,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},qn=T(`$ZodError`,Kn),Jn=T(`$ZodError`,Kn,{Parent:Error});function Yn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Xn(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var Zn=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new E;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>F(e,a,D())));throw On(t,i?.callee),t}return o.value},Qn=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>F(e,a,D())));throw On(t,i?.callee),t}return o.value},$n=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new E;return a.issues.length?{success:!1,error:new(e??qn)(a.issues.map(e=>F(e,i,D())))}:{success:!0,data:a.value}},er=$n(Jn),tr=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>F(e,i,D())))}:{success:!0,data:a.value}},nr=tr(Jn),rr=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Zn(e)(t,n,i)},ir=e=>(t,n,r)=>Zn(e)(t,n,r),ar=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Qn(e)(t,n,i)},or=e=>async(t,n,r)=>Qn(e)(t,n,r),sr=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return $n(e)(t,n,i)},cr=e=>(t,n,r)=>$n(e)(t,n,r),lr=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return tr(e)(t,n,i)},ur=e=>async(t,n,r)=>tr(e)(t,n,r),dr=/^[cC][^\s-]{8,}$/,fr=/^[0-9a-z]+$/,pr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mr=/^[0-9a-vA-V]{20}$/,hr=/^[A-Za-z0-9]{27}$/,gr=/^[a-zA-Z0-9_-]{21}$/,_r=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vr=/^([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})$/,yr=e=>e?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)$/,br=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,xr=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Sr(){return new RegExp(xr,`u`)}var Cr=/^(?:(?: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])$/,wr=/^(([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}|:))$/,Tr=/^((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])$/,Er=/^(([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])$/,Dr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Or=/^[A-Za-z0-9_-]*$/,kr=/^\+[1-9]\d{6,14}$/,Ar=`(?:(?:\\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])))`,jr=RegExp(`^${Ar}$`);function Mr(e){let 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 Nr(e){return RegExp(`^${Mr(e)}$`)}function Pr(e){let t=Mr({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Ar}T(?:${r})$`)}var Fr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ir=/^-?\d+$/,Lr=/^-?\d+(?:\.\d+)?$/,Rr=/^[^A-Z]*$/,zr=/^[^a-z]*$/,L=T(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Br={number:`number`,bigint:`bigint`,object:`date`},Vr=T(`$ZodCheckLessThan`,(e,t)=>{L.init(e,t);let n=Br[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hr=T(`$ZodCheckGreaterThan`,(e,t)=>{L.init(e,t);let n=Br[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ur=T(`$ZodCheckMultipleOf`,(e,t)=>{L.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):wn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Wr=T(`$ZodCheckNumberFormat`,(e,t)=>{L.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Fn[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Ir)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Gr=T(`$ZodCheckMaxLength`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Gn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Kr=T(`$ZodCheckMinLength`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Gn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qr=T(`$ZodCheckLengthEquals`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Gn(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),R=T(`$ZodCheckStringFormat`,(e,t)=>{var n,r;L.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Jr=T(`$ZodCheckRegex`,(e,t)=>{R.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Yr=T(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Rr,R.init(e,t)}),Xr=T(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=zr,R.init(e,t)}),Zr=T(`$ZodCheckIncludes`,(e,t)=>{L.init(e,t);let n=Nn(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Qr=T(`$ZodCheckStartsWith`,(e,t)=>{L.init(e,t);let n=RegExp(`^${Nn(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),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})}}),$r=T(`$ZodCheckEndsWith`,(e,t)=>{L.init(e,t);let n=RegExp(`.*${Nn(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),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})}}),ei=T(`$ZodCheckOverwrite`,(e,t)=>{L.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),ti=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
48
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
49
+ `))}},ni={major:4,minor:3,patch:6},z=T(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ni;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=P(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new E;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=P(e,t))});else{if(e.issues.length===t)continue;r||=P(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(P(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new E;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new E;return o.then(e=>t(e,r,a))}return t(o,r,a)}}O(e,`~standard`,()=>({validate:t=>{try{let n=er(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return nr(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),ri=T(`$ZodString`,(e,t)=>{z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Fr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),B=T(`$ZodStringFormat`,(e,t)=>{R.init(e,t),ri.init(e,t)}),ii=T(`$ZodGUID`,(e,t)=>{t.pattern??=vr,B.init(e,t)}),ai=T(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=yr(e)}else t.pattern??=yr();B.init(e,t)}),oi=T(`$ZodEmail`,(e,t)=>{t.pattern??=br,B.init(e,t)}),si=T(`$ZodURL`,(e,t)=>{B.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ci=T(`$ZodEmoji`,(e,t)=>{t.pattern??=Sr(),B.init(e,t)}),li=T(`$ZodNanoID`,(e,t)=>{t.pattern??=gr,B.init(e,t)}),ui=T(`$ZodCUID`,(e,t)=>{t.pattern??=dr,B.init(e,t)}),di=T(`$ZodCUID2`,(e,t)=>{t.pattern??=fr,B.init(e,t)}),fi=T(`$ZodULID`,(e,t)=>{t.pattern??=pr,B.init(e,t)}),pi=T(`$ZodXID`,(e,t)=>{t.pattern??=mr,B.init(e,t)}),mi=T(`$ZodKSUID`,(e,t)=>{t.pattern??=hr,B.init(e,t)}),hi=T(`$ZodISODateTime`,(e,t)=>{t.pattern??=Pr(t),B.init(e,t)}),gi=T(`$ZodISODate`,(e,t)=>{t.pattern??=jr,B.init(e,t)}),_i=T(`$ZodISOTime`,(e,t)=>{t.pattern??=Nr(t),B.init(e,t)}),vi=T(`$ZodISODuration`,(e,t)=>{t.pattern??=_r,B.init(e,t)}),yi=T(`$ZodIPv4`,(e,t)=>{t.pattern??=Cr,B.init(e,t),e._zod.bag.format=`ipv4`}),bi=T(`$ZodIPv6`,(e,t)=>{t.pattern??=wr,B.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),xi=T(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Tr,B.init(e,t)}),Si=T(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Er,B.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Ci(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var wi=T(`$ZodBase64`,(e,t)=>{t.pattern??=Dr,B.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Ci(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Ti(e){if(!Or.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Ci(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Ei=T(`$ZodBase64URL`,(e,t)=>{t.pattern??=Or,B.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Ti(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Di=T(`$ZodE164`,(e,t)=>{t.pattern??=kr,B.init(e,t)});function Oi(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var ki=T(`$ZodJWT`,(e,t)=>{B.init(e,t),e._zod.check=n=>{Oi(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ai=T(`$ZodNumber`,(e,t)=>{z.init(e,t),e._zod.pattern=e._zod.bag.pattern??Lr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ji=T(`$ZodNumberFormat`,(e,t)=>{Wr.init(e,t),Ai.init(e,t)}),Mi=T(`$ZodUnknown`,(e,t)=>{z.init(e,t),e._zod.parse=e=>e}),Ni=T(`$ZodNever`,(e,t)=>{z.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Pi(e,t,n){e.issues.length&&t.issues.push(...Un(n,e.issues)),t.value[n]=e.value}var Fi=T(`$ZodArray`,(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Pi(t,n,e))):Pi(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function V(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...Un(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Ii(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Pn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Li(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>V(e,n,i,t,u))):V(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Ri=T(`$ZodObject`,(e,t)=>{if(z.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=xn(()=>Ii(t));O(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=kn,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>V(n,t,e,s,r))):V(i,t,e,s,r)}return i?Li(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),zi=T(`$ZodObjectJIT`,(e,t)=>{Ri.init(e,t);let n=e._zod.parse,r=xn(()=>Ii(t)),i=e=>{let t=new ti([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=En(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=En(r),s=e[r]?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),s?t.write(`
50
+ if (${n}.issues.length) {
51
+ if (${o} in input) {
52
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
53
53
  ...iss,
54
- path: iss.path ? [${O}, ...iss.path] : [${O}]
54
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
55
55
  })));
56
56
  }
57
57
  }
58
58
 
59
- if (${A}.value === undefined) {
60
- if (${O} in input) {
61
- newResult[${O}] = undefined;
59
+ if (${n}.value === undefined) {
60
+ if (${o} in input) {
61
+ newResult[${o}] = undefined;
62
62
  }
63
63
  } else {
64
- newResult[${O}] = ${A}.value;
64
+ newResult[${o}] = ${n}.value;
65
65
  }
66
66
 
67
- `):m.write(`
68
- if (${A}.issues.length) {
69
- payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
67
+ `):t.write(`
68
+ if (${n}.issues.length) {
69
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
70
70
  ...iss,
71
- path: iss.path ? [${O}, ...iss.path] : [${O}]
71
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
72
72
  })));
73
73
  }
74
74
 
75
- if (${A}.value === undefined) {
76
- if (${O} in input) {
77
- newResult[${O}] = undefined;
75
+ if (${n}.value === undefined) {
76
+ if (${o} in input) {
77
+ newResult[${o}] = undefined;
78
78
  }
79
79
  } else {
80
- newResult[${O}] = ${A}.value;
80
+ newResult[${o}] = ${n}.value;
81
81
  }
82
82
 
83
- `)}m.write("payload.value = newResult;"),m.write("return payload;");const Z=m.compile();return(R,A)=>Z(f,R,A)};let i;const s=re,a=!lt.jitless,u=a&&ao.value,d=t.catchall;let g;e._zod.parse=(f,m)=>{g??(g=r.value);const h=f.value;return s(h)?a&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),f=i(f,m),d?Ot([],h,f,m,g,e):f):n(f,m):(f.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),f)}});function Nt(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!W(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>B(s,r,J())))}),t)}const Vi=l("$ZodUnion",(e,t)=>{E.init(e,t),v(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),v(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),v(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),v(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=>Ee(i.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)a.push(u),s=!0;else{if(u.issues.length===0)return u;a.push(u)}}return s?Promise.all(a).then(c=>Nt(c,o,e,i)):Nt(a,o,e,i)}}),Wi=l("$ZodIntersection",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>Zt(n,c,u)):Zt(n,i,s)}});function Ie(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(X(e)&&X(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=Ie(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Ie(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Zt(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),W(e))return e;const s=Ie(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const Hi=l("$ZodEnum",(e,t)=>{E.init(e,t);const n=pt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>co.has(typeof o)).map(o=>typeof o=="string"?oe(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),Ki=l("$ZodTransform",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new dt(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new V;return n.value=o,n}});function Rt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const xt=l("$ZodOptional",(e,t)=>{E.init(e,t),e._zod.optin="optional",e._zod.optout="optional",v(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),v(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ee(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Rt(i,n.value)):Rt(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Yi=l("$ZodExactOptional",(e,t)=>{xt.init(e,t),v(e._zod,"values",()=>t.innerType._zod.values),v(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Xi=l("$ZodNullable",(e,t)=>{E.init(e,t),v(e._zod,"optin",()=>t.innerType._zod.optin),v(e._zod,"optout",()=>t.innerType._zod.optout),v(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ee(n.source)}|null)$`):void 0}),v(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Qi=l("$ZodDefault",(e,t)=>{E.init(e,t),e._zod.optin="optional",v(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Lt(i,t)):Lt(o,t)}});function Lt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const es=l("$ZodPrefault",(e,t)=>{E.init(e,t),e._zod.optin="optional",v(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),ts=l("$ZodNonOptional",(e,t)=>{E.init(e,t),v(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Dt(i,e)):Dt(o,e)}});function Dt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const ns=l("$ZodCatch",(e,t)=>{E.init(e,t),v(e._zod,"optin",()=>t.innerType._zod.optin),v(e._zod,"optout",()=>t.innerType._zod.optout),v(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>B(s,r,J()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>B(i,r,J()))},input:n.value}),n.issues=[]),n)}}),rs=l("$ZodPipe",(e,t)=>{E.init(e,t),v(e._zod,"values",()=>t.in._zod.values),v(e._zod,"optin",()=>t.in._zod.optin),v(e._zod,"optout",()=>t.out._zod.optout),v(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>de(s,t.in,r)):de(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>de(i,t.out,r)):de(o,t.out,r)}});function de(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const os=l("$ZodReadonly",(e,t)=>{E.init(e,t),v(e._zod,"propValues",()=>t.innerType._zod.propValues),v(e._zod,"values",()=>t.innerType._zod.values),v(e._zod,"optin",()=>t.innerType?._zod?.optin),v(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(jt):jt(o)}});function jt(e){return e.value=Object.freeze(e.value),e}const is=l("$ZodCustom",(e,t)=>{$.init(e,t),E.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Ut(i,n,r,e));Ut(o,n,r,e)}});function Ut(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Q(o))}}var Mt;class ss{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function as(){return new ss}(Mt=globalThis).__zod_globalRegistry??(Mt.__zod_globalRegistry=as());const ee=globalThis.__zod_globalRegistry;function cs(e,t){return new e({type:"string",..._(t)})}function us(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(t)})}function Ft(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(t)})}function ds(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(t)})}function ls(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(t)})}function ps(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(t)})}function fs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(t)})}function gs(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(t)})}function ms(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(t)})}function hs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(t)})}function _s(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(t)})}function ys(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(t)})}function vs(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(t)})}function bs(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(t)})}function ws(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(t)})}function ks(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(t)})}function Ss(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(t)})}function Es(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(t)})}function zs(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(t)})}function Cs(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(t)})}function Ts(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(t)})}function $s(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(t)})}function Is(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(t)})}function As(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(t)})}function Ps(e,t){return new e({type:"string",format:"date",check:"string_format",..._(t)})}function Os(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(t)})}function Ns(e,t){return new e({type:"string",format:"duration",check:"string_format",..._(t)})}function Zs(e,t){return new e({type:"number",checks:[],..._(t)})}function Rs(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(t)})}function xs(e){return new e({type:"unknown"})}function Ls(e,t){return new e({type:"never",..._(t)})}function qt(e,t){return new Ct({check:"less_than",..._(t),value:e,inclusive:!1})}function Ae(e,t){return new Ct({check:"less_than",..._(t),value:e,inclusive:!0})}function Jt(e,t){return new Tt({check:"greater_than",..._(t),value:e,inclusive:!1})}function Pe(e,t){return new Tt({check:"greater_than",..._(t),value:e,inclusive:!0})}function Gt(e,t){return new ni({check:"multiple_of",..._(t),value:e})}function Bt(e,t){return new oi({check:"max_length",..._(t),maximum:e})}function le(e,t){return new ii({check:"min_length",..._(t),minimum:e})}function Vt(e,t){return new si({check:"length_equals",..._(t),length:e})}function Ds(e,t){return new ai({check:"string_format",format:"regex",..._(t),pattern:e})}function js(e){return new ci({check:"string_format",format:"lowercase",..._(e)})}function Us(e){return new ui({check:"string_format",format:"uppercase",..._(e)})}function Ms(e,t){return new di({check:"string_format",format:"includes",..._(t),includes:e})}function Fs(e,t){return new li({check:"string_format",format:"starts_with",..._(t),prefix:e})}function qs(e,t){return new pi({check:"string_format",format:"ends_with",..._(t),suffix:e})}function H(e){return new fi({check:"overwrite",tx:e})}function Js(e){return H(t=>t.normalize(e))}function Gs(){return H(e=>e.trim())}function Bs(){return H(e=>e.toLowerCase())}function Vs(){return H(e=>e.toUpperCase())}function Ws(){return H(e=>so(e))}function Hs(e,t,n){return new e({type:"array",element:t,..._(n)})}function Ks(e,t,n){return new e({type:"custom",check:"custom",fn:t,..._(n)})}function Ys(e){const t=Xs(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Q(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Q(o))}},e(n.value,n)));return t}function Xs(e,t){const n=new $({check:"custom",..._(t)});return n._zod.check=e,n}function Wt(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??ee,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 C(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,d);else{const f=s.schema,m=t.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,f,d)}const g=e._zod.parent;g&&(s.ref||(s.ref=g),C(g,t,d),t.seen.get(g).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&T(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Ht(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const g=e.external.registry.get(s[0])?.id,f=e.external.uri??(h=>h);if(g)return{ref:f(g)};const m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${f("__shared")}#/${a}/${m}`}}if(s[1]===n)return{ref:"#"};const u=`#/${a}/`,d=s[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=o(s);a.def={...a.schema},u&&(a.defId=u);const d=a.schema;for(const g in d)delete d[g];d.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
83
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=kn,s=!vn.jitless,c=s&&An.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Li([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Bi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!P(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>F(e,r,D())))}),t)}var Vi=T(`$ZodUnion`,(e,t)=>{z.init(e,t),O(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),O(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),O(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),O(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Cn(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Bi(t,i,e,a)):Bi(s,i,e,a)}}),Hi=T(`$ZodIntersection`,(e,t)=>{z.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Wi(e,t,n)):Wi(e,i,a)}});function Ui(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(j(e)&&j(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ui(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ui(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wi(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),P(e))return e;let o=Ui(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Gi=T(`$ZodEnum`,(e,t)=>{z.init(e,t);let n=yn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Mn.has(typeof e)).map(e=>typeof e==`string`?Nn(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ki=T(`$ZodTransform`,(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new _n(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new E;return n.value=i,n}});function qi(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Ji=T(`$ZodOptional`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,O(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),O(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Cn(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>qi(t,e.value)):qi(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Yi=T(`$ZodExactOptional`,(e,t)=>{Ji.init(e,t),O(e._zod,`values`,()=>t.innerType._zod.values),O(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Xi=T(`$ZodNullable`,(e,t)=>{z.init(e,t),O(e._zod,`optin`,()=>t.innerType._zod.optin),O(e._zod,`optout`,()=>t.innerType._zod.optout),O(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Cn(e.source)}|null)$`):void 0}),O(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Zi=T(`$ZodDefault`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,O(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Qi(e,t)):Qi(r,t)}});function Qi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var $i=T(`$ZodPrefault`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,O(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ea=T(`$ZodNonOptional`,(e,t)=>{z.init(e,t),O(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ta(t,e)):ta(i,e)}});function ta(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=T(`$ZodCatch`,(e,t)=>{z.init(e,t),O(e._zod,`optin`,()=>t.innerType._zod.optin),O(e._zod,`optout`,()=>t.innerType._zod.optout),O(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>F(e,n,D()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>F(e,n,D()))},input:e.value}),e.issues=[]),e)}}),ra=T(`$ZodPipe`,(e,t)=>{z.init(e,t),O(e._zod,`values`,()=>t.in._zod.values),O(e._zod,`optin`,()=>t.in._zod.optin),O(e._zod,`optout`,()=>t.out._zod.optout),O(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>H(e,t.in,n)):H(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>H(e,t.out,n)):H(r,t.out,n)}});function H(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var ia=T(`$ZodReadonly`,(e,t)=>{z.init(e,t),O(e._zod,`propValues`,()=>t.innerType._zod.propValues),O(e._zod,`values`,()=>t.innerType._zod.values),O(e._zod,`optin`,()=>t.innerType?._zod?.optin),O(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(aa):aa(r)}});function aa(e){return e.value=Object.freeze(e.value),e}var oa=T(`$ZodCustom`,(e,t)=>{L.init(e,t),z.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>sa(t,n,r,e));sa(i,n,r,e)}});function sa(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(I(e))}}var ca,la=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let 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){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ua(){return new la}(ca=globalThis).__zod_globalRegistry??(ca.__zod_globalRegistry=ua());var U=globalThis.__zod_globalRegistry;function da(e,t){return new e({type:`string`,...N(t)})}function fa(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function pa(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function ma(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function ha(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function ga(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function _a(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function va(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function ya(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function ba(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function xa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function Sa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function Ca(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function wa(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function Ta(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function Ea(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function Da(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...N(t)})}function Oa(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...N(t)})}function ka(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function Aa(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function ja(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function Ma(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function Na(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function Pa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function Fa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function Ia(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function La(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function Ra(e,t){return new e({type:`number`,checks:[],...N(t)})}function za(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function Ba(e){return new e({type:`unknown`})}function Va(e,t){return new e({type:`never`,...N(t)})}function Ha(e,t){return new Vr({check:`less_than`,...N(t),value:e,inclusive:!1})}function Ua(e,t){return new Vr({check:`less_than`,...N(t),value:e,inclusive:!0})}function Wa(e,t){return new Hr({check:`greater_than`,...N(t),value:e,inclusive:!1})}function Ga(e,t){return new Hr({check:`greater_than`,...N(t),value:e,inclusive:!0})}function Ka(e,t){return new Ur({check:`multiple_of`,...N(t),value:e})}function qa(e,t){return new Gr({check:`max_length`,...N(t),maximum:e})}function W(e,t){return new Kr({check:`min_length`,...N(t),minimum:e})}function Ja(e,t){return new qr({check:`length_equals`,...N(t),length:e})}function Ya(e,t){return new Jr({check:`string_format`,format:`regex`,...N(t),pattern:e})}function Xa(e){return new Yr({check:`string_format`,format:`lowercase`,...N(e)})}function Za(e){return new Xr({check:`string_format`,format:`uppercase`,...N(e)})}function Qa(e,t){return new Zr({check:`string_format`,format:`includes`,...N(t),includes:e})}function $a(e,t){return new Qr({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function eo(e,t){return new $r({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function G(e){return new ei({check:`overwrite`,tx:e})}function to(e){return G(t=>t.normalize(e))}function no(){return G(e=>e.trim())}function ro(){return G(e=>e.toLowerCase())}function io(){return G(e=>e.toUpperCase())}function ao(){return G(e=>Dn(e))}function oo(e,t,n){return new e({type:`array`,element:t,...N(n)})}function so(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...N(n)})}function co(e){let t=lo(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(I(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(I(r))}},e(n.value,n)));return t}function lo(e,t){let n=new L({check:`custom`,...N(t)});return n._zod.check=e,n}function uo(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??U,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 K(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,K(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&q(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function fo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
84
84
 
85
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1&&e.reused==="ref"){i(s);continue}}}function Kt(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=s=>{const a=e.seen.get(s);if(a.ref===null)return;const c=a.def??a.schema,u={...c},d=a.ref;if(a.ref=null,d){r(d);const f=e.seen.get(d),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),s._zod.parent===d)for(const p in c)p==="$ref"||p==="allOf"||p in u||delete c[p];if(m.$ref&&f.def)for(const p in c)p==="$ref"||p==="allOf"||p in f.def&&JSON.stringify(c[p])===JSON.stringify(f.def[p])&&delete c[p]}const g=s._zod.parent;if(g&&g!==d){r(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:s,jsonSchema:c,path:a.path??[]})};for(const s of[...e.seen.entries()].reverse())r(s[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 s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const s of e.seen.entries()){const a=s[1];a.def&&a.defId&&(i[a.defId]=a.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:pe(t,"input",e.processors),output:pe(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function T(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return T(r.element,n);if(r.type==="set")return T(r.valueType,n);if(r.type==="lazy")return T(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return T(r.innerType,n);if(r.type==="intersection")return T(r.left,n)||T(r.right,n);if(r.type==="record"||r.type==="map")return T(r.keyType,n)||T(r.valueType,n);if(r.type==="pipe")return T(r.in,n)||T(r.out,n);if(r.type==="object"){for(const o in r.shape)if(T(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(T(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(T(o,n))return!0;return!!(r.rest&&T(r.rest,n))}return!1}const Qs=(e,t={})=>n=>{const r=Wt({...n,processors:t});return C(e,r),Ht(r,e),Kt(r,e)},pe=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Wt({...o??{},target:i,io:t,processors:n});return C(e,s),Ht(s,e),Kt(s,e)},ea={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ta=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=ea[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},na=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d),typeof i=="number"&&(o.minimum=i,typeof d=="number"&&t.target!=="draft-04"&&(d>=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 s=="number"&&(o.maximum=s,typeof u=="number"&&t.target!=="draft-04"&&(u<=s?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},ra=(e,t,n,r)=>{n.not={}},oa=(e,t,n,r)=>{},ia=(e,t,n,r)=>{const o=e._zod.def,i=pt(o.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},sa=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},aa=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ca=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=C(i.element,t,{...r,path:[...r.path,"items"]})},ua=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=C(s[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{const d=i.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=C(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},da=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>C(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},la=(e,t,n,r)=>{const o=e._zod.def,i=C(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=C(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c},pa=(e,t,n,r)=>{const o=e._zod.def,i=C(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},fa=(e,t,n,r)=>{const o=e._zod.def;C(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},ga=(e,t,n,r)=>{const o=e._zod.def;C(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},ma=(e,t,n,r)=>{const o=e._zod.def;C(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},ha=(e,t,n,r)=>{const o=e._zod.def;C(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},_a=(e,t,n,r)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;C(i,t,r);const s=t.seen.get(e);s.ref=i},ya=(e,t,n,r)=>{const o=e._zod.def;C(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Yt=(e,t,n,r)=>{const o=e._zod.def;C(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},va=l("ZodISODateTime",(e,t)=>{Ti.init(e,t),S.init(e,t)});function ba(e){return As(va,e)}const wa=l("ZodISODate",(e,t)=>{$i.init(e,t),S.init(e,t)});function ka(e){return Ps(wa,e)}const Sa=l("ZodISOTime",(e,t)=>{Ii.init(e,t),S.init(e,t)});function Ea(e){return Os(Sa,e)}const za=l("ZodISODuration",(e,t)=>{Ai.init(e,t),S.init(e,t)});function Ca(e){return Ns(za,e)}const P=l("ZodError",(e,t)=>{vt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>bo(e,n)},flatten:{value:n=>vo(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,we,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,we,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ta=Ce(P),$a=Te(P),Ia=se(P),Aa=ae(P),Pa=So(P),Oa=Eo(P),Na=zo(P),Za=Co(P),Ra=To(P),xa=$o(P),La=Io(P),Da=Ao(P),z=l("ZodType",(e,t)=>(E.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:pe(e,"input"),output:pe(e,"output")}}),e.toJSONSchema=Qs(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(j(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>U(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Ta(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Ia(e,n,r),e.parseAsync=async(n,r)=>$a(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Aa(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Pa(e,n,r),e.decode=(n,r)=>Oa(e,n,r),e.encodeAsync=async(n,r)=>Na(e,n,r),e.decodeAsync=async(n,r)=>Za(e,n,r),e.safeEncode=(n,r)=>Ra(e,n,r),e.safeDecode=(n,r)=>xa(e,n,r),e.safeEncodeAsync=async(n,r)=>La(e,n,r),e.safeDecodeAsync=async(n,r)=>Da(e,n,r),e.refine=(n,r)=>e.check(Ic(n,r)),e.superRefine=n=>e.check(Ac(n)),e.overwrite=n=>e.check(H(n)),e.optional=()=>on(e),e.exactOptional=()=>hc(e),e.nullable=()=>sn(e),e.nullish=()=>on(sn(e)),e.nonoptional=n=>kc(e,n),e.array=()=>nn(e),e.or=n=>dc([e,n]),e.and=n=>pc(e,n),e.transform=n=>cn(e,gc(n)),e.default=n=>vc(e,n),e.prefault=n=>wc(e,n),e.catch=n=>Ec(e,n),e.pipe=n=>cn(e,n),e.readonly=()=>Tc(e),e.describe=n=>{const r=e.clone();return ee.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return ee.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return ee.get(e);const r=e.clone();return ee.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Xt=l("_ZodString",(e,t)=>{$e.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ta(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(Ds(...r)),e.includes=(...r)=>e.check(Ms(...r)),e.startsWith=(...r)=>e.check(Fs(...r)),e.endsWith=(...r)=>e.check(qs(...r)),e.min=(...r)=>e.check(le(...r)),e.max=(...r)=>e.check(Bt(...r)),e.length=(...r)=>e.check(Vt(...r)),e.nonempty=(...r)=>e.check(le(1,...r)),e.lowercase=r=>e.check(js(r)),e.uppercase=r=>e.check(Us(r)),e.trim=()=>e.check(Gs()),e.normalize=(...r)=>e.check(Js(...r)),e.toLowerCase=()=>e.check(Bs()),e.toUpperCase=()=>e.check(Vs()),e.slugify=()=>e.check(Ws())}),ja=l("ZodString",(e,t)=>{$e.init(e,t),Xt.init(e,t),e.email=n=>e.check(us(Ua,n)),e.url=n=>e.check(gs(Ma,n)),e.jwt=n=>e.check(Is(nc,n)),e.emoji=n=>e.check(ms(Fa,n)),e.guid=n=>e.check(Ft(Qt,n)),e.uuid=n=>e.check(ds(fe,n)),e.uuidv4=n=>e.check(ls(fe,n)),e.uuidv6=n=>e.check(ps(fe,n)),e.uuidv7=n=>e.check(fs(fe,n)),e.nanoid=n=>e.check(hs(qa,n)),e.guid=n=>e.check(Ft(Qt,n)),e.cuid=n=>e.check(_s(Ja,n)),e.cuid2=n=>e.check(ys(Ga,n)),e.ulid=n=>e.check(vs(Ba,n)),e.base64=n=>e.check(Cs(Qa,n)),e.base64url=n=>e.check(Ts(ec,n)),e.xid=n=>e.check(bs(Va,n)),e.ksuid=n=>e.check(ws(Wa,n)),e.ipv4=n=>e.check(ks(Ha,n)),e.ipv6=n=>e.check(Ss(Ka,n)),e.cidrv4=n=>e.check(Es(Ya,n)),e.cidrv6=n=>e.check(zs(Xa,n)),e.e164=n=>e.check($s(tc,n)),e.datetime=n=>e.check(ba(n)),e.date=n=>e.check(ka(n)),e.time=n=>e.check(Ea(n)),e.duration=n=>e.check(Ca(n))});function I(e){return cs(ja,e)}const S=l("ZodStringFormat",(e,t)=>{k.init(e,t),Xt.init(e,t)}),Ua=l("ZodEmail",(e,t)=>{yi.init(e,t),S.init(e,t)}),Qt=l("ZodGUID",(e,t)=>{hi.init(e,t),S.init(e,t)}),fe=l("ZodUUID",(e,t)=>{_i.init(e,t),S.init(e,t)}),Ma=l("ZodURL",(e,t)=>{vi.init(e,t),S.init(e,t)}),Fa=l("ZodEmoji",(e,t)=>{bi.init(e,t),S.init(e,t)}),qa=l("ZodNanoID",(e,t)=>{wi.init(e,t),S.init(e,t)}),Ja=l("ZodCUID",(e,t)=>{ki.init(e,t),S.init(e,t)}),Ga=l("ZodCUID2",(e,t)=>{Si.init(e,t),S.init(e,t)}),Ba=l("ZodULID",(e,t)=>{Ei.init(e,t),S.init(e,t)}),Va=l("ZodXID",(e,t)=>{zi.init(e,t),S.init(e,t)}),Wa=l("ZodKSUID",(e,t)=>{Ci.init(e,t),S.init(e,t)}),Ha=l("ZodIPv4",(e,t)=>{Pi.init(e,t),S.init(e,t)}),Ka=l("ZodIPv6",(e,t)=>{Oi.init(e,t),S.init(e,t)}),Ya=l("ZodCIDRv4",(e,t)=>{Ni.init(e,t),S.init(e,t)}),Xa=l("ZodCIDRv6",(e,t)=>{Zi.init(e,t),S.init(e,t)}),Qa=l("ZodBase64",(e,t)=>{Ri.init(e,t),S.init(e,t)}),ec=l("ZodBase64URL",(e,t)=>{Li.init(e,t),S.init(e,t)}),tc=l("ZodE164",(e,t)=>{Di.init(e,t),S.init(e,t)}),nc=l("ZodJWT",(e,t)=>{Ui.init(e,t),S.init(e,t)}),en=l("ZodNumber",(e,t)=>{It.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,o,i)=>na(e,r,o),e.gt=(r,o)=>e.check(Jt(r,o)),e.gte=(r,o)=>e.check(Pe(r,o)),e.min=(r,o)=>e.check(Pe(r,o)),e.lt=(r,o)=>e.check(qt(r,o)),e.lte=(r,o)=>e.check(Ae(r,o)),e.max=(r,o)=>e.check(Ae(r,o)),e.int=r=>e.check(tn(r)),e.safe=r=>e.check(tn(r)),e.positive=r=>e.check(Jt(0,r)),e.nonnegative=r=>e.check(Pe(0,r)),e.negative=r=>e.check(qt(0,r)),e.nonpositive=r=>e.check(Ae(0,r)),e.multipleOf=(r,o)=>e.check(Gt(r,o)),e.step=(r,o)=>e.check(Gt(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function te(e){return Zs(en,e)}const rc=l("ZodNumberFormat",(e,t)=>{Mi.init(e,t),en.init(e,t)});function tn(e){return Rs(rc,e)}const oc=l("ZodUnknown",(e,t)=>{Fi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>oa()});function Oe(){return xs(oc)}const ic=l("ZodNever",(e,t)=>{qi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ra(e,n,r)});function sc(e){return Ls(ic,e)}const ac=l("ZodArray",(e,t)=>{Ji.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ca(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(le(n,r)),e.nonempty=n=>e.check(le(1,n)),e.max=(n,r)=>e.check(Bt(n,r)),e.length=(n,r)=>e.check(Vt(n,r)),e.unwrap=()=>e.element});function nn(e,t){return Hs(ac,e,t)}const cc=l("ZodObject",(e,t)=>{Bi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ua(e,n,r,o),v(e,"shape",()=>t.shape),e.keyof=()=>Ze(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Oe()}),e.loose=()=>e.clone({...e._zod.def,catchall:Oe()}),e.strict=()=>e.clone({...e._zod.def,catchall:sc()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>go(e,n),e.safeExtend=n=>mo(e,n),e.merge=n=>ho(e,n),e.pick=n=>po(e,n),e.omit=n=>fo(e,n),e.partial=(...n)=>_o(rn,e,n[0]),e.required=(...n)=>yo(an,e,n[0])});function M(e,t){const n={type:"object",shape:e??{},..._(t)};return new cc(n)}const uc=l("ZodUnion",(e,t)=>{Vi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>da(e,n,r,o),e.options=t.options});function dc(e,t){return new uc({type:"union",options:e,..._(t)})}const lc=l("ZodIntersection",(e,t)=>{Wi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>la(e,n,r,o)});function pc(e,t){return new lc({type:"intersection",left:e,right:t})}const Ne=l("ZodEnum",(e,t)=>{Hi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ia(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Ne({...t,checks:[],..._(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Ne({...t,checks:[],..._(o),entries:i})}});function Ze(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ne({type:"enum",entries:n,..._(t)})}const fc=l("ZodTransform",(e,t)=>{Ki.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>aa(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new dt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Q(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(Q(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function gc(e){return new fc({type:"transform",transform:e})}const rn=l("ZodOptional",(e,t)=>{xt.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yt(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function on(e){return new rn({type:"optional",innerType:e})}const mc=l("ZodExactOptional",(e,t)=>{Yi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yt(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function hc(e){return new mc({type:"optional",innerType:e})}const _c=l("ZodNullable",(e,t)=>{Xi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function sn(e){return new _c({type:"nullable",innerType:e})}const yc=l("ZodDefault",(e,t)=>{Qi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ga(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function vc(e,t){return new yc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ht(t)}})}const bc=l("ZodPrefault",(e,t)=>{es.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ma(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function wc(e,t){return new bc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ht(t)}})}const an=l("ZodNonOptional",(e,t)=>{ts.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function kc(e,t){return new an({type:"nonoptional",innerType:e,..._(t)})}const Sc=l("ZodCatch",(e,t)=>{ns.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ha(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ec(e,t){return new Sc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const zc=l("ZodPipe",(e,t)=>{rs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_a(e,n,r,o),e.in=t.in,e.out=t.out});function cn(e,t){return new zc({type:"pipe",in:e,out:t})}const Cc=l("ZodReadonly",(e,t)=>{os.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ya(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Tc(e){return new Cc({type:"readonly",innerType:e})}const $c=l("ZodCustom",(e,t)=>{is.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sa(e,n)});function Ic(e,t={}){return Ks($c,e,t)}function Ac(e){return Ys(e)}const Pc=M({sku:I(),name:I(),imageUrl:I().url().optional(),price:I().optional(),originalPrice:I().optional(),discountPercent:te().optional(),url:I().url(),brand:I().optional(),rating:te().min(0).max(5).optional(),reviewCount:te().int().nonnegative().optional()}),Oc=M({layout:Ze(["grid","carousel"]).optional(),columns:te().int().positive().optional()}),Nc=M({product:Pc,index:te().int().nonnegative(),discountType:Ze(["strike-through","badge"]).optional()}),Zc=M({sku:I(),label:I().optional(),cartCode:I()}),Rc=M({actions:nn(M({label:I(),action:M({title:I(),type:I(),payload:Oe().optional()})}))}),xc=M({message:I().optional()}),Lc={components:{ProductGrid:{schema:Oc,description:"Outer grid or carousel container for similar products."},ProductCard:{schema:Nc,description:"A single product card with image, title, price, and actions."},AddToCartButton:{schema:Zc,description:"Add-to-cart CTA rendered inside or below a product card."},QuickActions:{schema:Rc,description:"A row of quick-action buttons below product info."},EmptyState:{schema:xc,description:"Empty state shown when no similar products are available."}}};class un extends qn{constructor(){super(...arguments),this._abortController=null,this._contentEl=null,this._i18n=ct}async onInit(t){this._i18n=this._resolveI18n(t),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-simrel-container",this.root.appendChild(this._contentEl),this._lastSku=t.sku,await this._fetchAndRender(t.sku),no("simrel")}onUpdate(t){const n=t.sku;!n||n===this._lastSku||(this._lastSku=n,this._fetchAndRender(n))}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(t){const n={sku:t.sku,name:t.name,url:t.url};if(t.imageUrl!==void 0&&(n.imageUrl=t.imageUrl),t.price!==void 0&&(n.price=t.price),t.originalPrice!==void 0&&(n.originalPrice=t.originalPrice),t.discountPercent!==void 0&&(n.discountPercent=t.discountPercent),t.brand!==void 0&&(n.brand=t.brand),t.rating!==void 0&&(n.rating=t.rating),t.reviewCount!==void 0&&(n.reviewCount=t.reviewCount),t.cartCode!==void 0&&(n.cartCode=t.cartCode),t.inStock!==void 0&&(n.inStock=t.inStock),this.config.onProductClick?.(n)===!1)return;ro(t.sku,t.name);const r=this.config.session?.sessionId??null;me("gengage:similar:product-click",{sku:t.sku,url:t.url,sessionId:r}),this.config.onProductNavigate?.(t.url,t.sku,r)}_handleAddToCart(t){oo(t.sku,t.quantity),this.config.onAddToCart?.(t),me("gengage:similar:add-to-cart",t),this.track(hn(this.analyticsContext(),{attribution_source:"simrel",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:"TRY",line_items:t.quantity,sku:t.sku}))}_abort(){this._abortController?.abort(),this._abortController=null}async _fetchAndRender(t){this._abort(),this._abortController=new AbortController;const n=this._abortController.signal,r=setTimeout(()=>this._abortController?.abort(),1e4);if(n.addEventListener("abort",()=>clearTimeout(r)),!this._contentEl)return;this._contentEl.innerHTML="",this._contentEl.style.display="";const o=document.createElement("div");o.className="gengage-simrel-loading";const i=document.createElement("div");i.className="gengage-simrel-spinner",o.appendChild(i),this._contentEl.appendChild(o);const s={middlewareUrl:this.config.middlewareUrl},a=crypto.randomUUID(),c=Date.now();this.track(fn(this.analyticsContext(),{endpoint:"similar_products",request_id:a,widget:"simrel"}));try{const u={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:t};this.config.domain!==void 0&&(u.domain=this.config.domain);const d=await Ur(u,s,n);if(!this._contentEl)return;if(this._contentEl.innerHTML="",d.length>0)try{const g=d.map(m=>m.sku),f=await Fr({account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",skus:g},s,n);if(f.length>0&&this._contentEl){const m=this._buildGroupsSpec(f),h=this._renderUISpec(m);this._contentEl.appendChild(h),ut("simrel"),this.track(Re(this.analyticsContext(),{request_id:a,latency_ms:Date.now()-c,chunk_count:f.reduce((p,y)=>p+y.products.length,0),widget:"simrel"})),this.track(xe(this.analyticsContext(),{message_count:f.reduce((p,y)=>p+y.products.length,0),history_ref:a,redaction_level:"none",widget:"simrel"}));return}}catch{}if(n.aborted)return;if(this._contentEl){const g=this._buildProductsSpec(d),f=this._renderUISpec(g);this._contentEl.appendChild(f)}d.length>0&&ut("simrel"),this.track(Re(this.analyticsContext(),{request_id:a,latency_ms:Date.now()-c,chunk_count:d.length,widget:"simrel"})),this.track(xe(this.analyticsContext(),{message_count:d.length,history_ref:a,redaction_level:"none",widget:"simrel"}))}catch(u){if(u instanceof DOMException&&u.name==="AbortError")return;if(me("gengage:global:error",{source:"simrel",code:"FETCH_ERROR",message:Zn(this.config.locale)}),this.track(gn(this.analyticsContext(),{request_id:a,error_code:"FETCH_ERROR",error_message:u instanceof Error?u.message:String(u),widget:"simrel"})),this._contentEl){this._contentEl.innerHTML="";const d=document.createElement("div");d.className="gengage-simrel-error";const g=document.createElement("span");g.textContent=this._i18n.errorLoadingMessage,d.appendChild(g);const f=document.createElement("button");f.className="gengage-simrel-retry",f.textContent=this._i18n.retryButtonText,f.addEventListener("click",()=>{this._fetchAndRender(this.config.sku)}),d.appendChild(f),this._contentEl.appendChild(d)}}}_resolveI18n(t){return{...eo(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=st();return pn(t,this.config.renderer?.registry)}_buildRenderContext(){const t=this.config.renderCard,n={onClick:r=>this._handleProductClick(r),onAddToCart:r=>this._handleAddToCart(r),i18n:this._i18n};return this.config.discountType!==void 0&&(n.discountType=this.config.discountType),t!==void 0&&(n.renderCard=t),this.config.renderCardElement!==void 0&&(n.renderCardElement=this.config.renderCardElement),this.config.pricing!==void 0&&(n.pricing=this.config.pricing),n}_renderUISpec(t){const n=this._resolveUISpecRegistry(),r=this._buildRenderContext(),o=this.config.renderer?.unknownRenderer??be,i=(c,u)=>at(c,u,n,o),s=this.config.renderer?.renderUISpec;return s?s(t,r,{registry:n,unknownRenderer:o,defaultRender:i}):i(t,r)}_buildProductsSpec(t){const n={},r=[];for(let o=0;o<t.length;o++){const i=t[o],s=`product-${o}`;r.push(s),n[s]={type:"ProductCard",props:{product:i,index:o,discountType:this.config.discountType}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{root:"root",elements:n}}_buildGroupsSpec(t){return{root:"root",elements:{root:{type:"GroupTabs",props:{groups:t}}}}}}function Dc(){return new un}F.GengageSimRel=un,F.createDefaultSimRelUISpecRegistry=st,F.createSimRelWidget=Dc,F.defaultSimRelUnknownUISpecRenderer=be,F.renderSimRelUISpec=at,F.simRelCatalog=Lc,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
86
- //# sourceMappingURL=simrel.iife.js.map
85
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function po(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:ho(t,`input`,e.processors),output:ho(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function q(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return q(r.element,n);if(r.type===`set`)return q(r.valueType,n);if(r.type===`lazy`)return q(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return q(r.innerType,n);if(r.type===`intersection`)return q(r.left,n)||q(r.right,n);if(r.type===`record`||r.type===`map`)return q(r.keyType,n)||q(r.valueType,n);if(r.type===`pipe`)return q(r.in,n)||q(r.out,n);if(r.type===`object`){for(let e in r.shape)if(q(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(q(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(q(e,n))return!0;return!!(r.rest&&q(r.rest,n))}return!1}var mo=(e,t={})=>n=>{let r=uo({...n,processors:t});return K(e,r),fo(r,e),po(r,e)},ho=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=uo({...i??{},target:a,io:t,processors:n});return K(e,o),fo(o,e),po(o,e)},go={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},_o=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=go[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},vo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},yo=(e,t,n,r)=>{n.not={}},bo=(e,t,n,r)=>{let i=e._zod.def,a=yn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},xo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},So=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Co=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=K(a.element,t,{...r,path:[...r.path,`items`]})},wo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=K(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=K(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},To=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>K(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Eo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=K(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Do=(e,t,n,r)=>{let i=e._zod.def,a=K(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Oo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ko=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ao=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},jo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Mo=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;K(a,t,r);let o=t.seen.get(e);o.ref=a},No=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Po=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Fo=T(`ZodISODateTime`,(e,t)=>{hi.init(e,t),Z.init(e,t)});function Io(e){return Pa(Fo,e)}var Lo=T(`ZodISODate`,(e,t)=>{gi.init(e,t),Z.init(e,t)});function Ro(e){return Fa(Lo,e)}var zo=T(`ZodISOTime`,(e,t)=>{_i.init(e,t),Z.init(e,t)});function Bo(e){return Ia(zo,e)}var Vo=T(`ZodISODuration`,(e,t)=>{vi.init(e,t),Z.init(e,t)});function Ho(e){return La(Vo,e)}var Uo=(e,t)=>{qn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Xn(e,t)},flatten:{value:t=>Yn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,bn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,bn,2)}},isEmpty:{get(){return e.issues.length===0}}})};T(`ZodError`,Uo);var J=T(`ZodError`,Uo,{Parent:Error}),Wo=Zn(J),Go=Qn(J),Ko=$n(J),qo=tr(J),Jo=rr(J),Yo=ir(J),Xo=ar(J),Zo=or(J),Qo=sr(J),$o=cr(J),es=lr(J),ts=ur(J),Y=T(`ZodType`,(e,t)=>(z.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ho(e,`input`),output:ho(e,`output`)}}),e.toJSONSchema=mo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(A(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>M(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Wo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ko(e,t,n),e.parseAsync=async(t,n)=>Go(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>qo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Jo(e,t,n),e.decode=(t,n)=>Yo(e,t,n),e.encodeAsync=async(t,n)=>Xo(e,t,n),e.decodeAsync=async(t,n)=>Zo(e,t,n),e.safeEncode=(t,n)=>Qo(e,t,n),e.safeDecode=(t,n)=>$o(e,t,n),e.safeEncodeAsync=async(t,n)=>es(e,t,n),e.safeDecodeAsync=async(t,n)=>ts(e,t,n),e.refine=(t,n)=>e.check(oc(t,n)),e.superRefine=t=>e.check(sc(t)),e.overwrite=t=>e.check(G(t)),e.optional=()=>Hs(e),e.exactOptional=()=>Ws(e),e.nullable=()=>Ks(e),e.nullish=()=>Hs(Ks(e)),e.nonoptional=t=>Qs(e,t),e.array=()=>js(e),e.or=t=>Ps([e,t]),e.and=t=>Is(e,t),e.transform=t=>nc(e,Bs(t)),e.default=t=>Js(e,t),e.prefault=t=>Xs(e,t),e.catch=t=>ec(e,t),e.pipe=t=>nc(e,t),e.readonly=()=>ic(e),e.describe=t=>{let n=e.clone();return U.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return U.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return U.get(e);let n=e.clone();return U.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),ns=T(`_ZodString`,(e,t)=>{ri.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Ya(...t)),e.includes=(...t)=>e.check(Qa(...t)),e.startsWith=(...t)=>e.check($a(...t)),e.endsWith=(...t)=>e.check(eo(...t)),e.min=(...t)=>e.check(W(...t)),e.max=(...t)=>e.check(qa(...t)),e.length=(...t)=>e.check(Ja(...t)),e.nonempty=(...t)=>e.check(W(1,...t)),e.lowercase=t=>e.check(Xa(t)),e.uppercase=t=>e.check(Za(t)),e.trim=()=>e.check(no()),e.normalize=(...t)=>e.check(to(...t)),e.toLowerCase=()=>e.check(ro()),e.toUpperCase=()=>e.check(io()),e.slugify=()=>e.check(ao())}),rs=T(`ZodString`,(e,t)=>{ri.init(e,t),ns.init(e,t),e.email=t=>e.check(fa(is,t)),e.url=t=>e.check(va(ss,t)),e.jwt=t=>e.check(Na(Ss,t)),e.emoji=t=>e.check(ya(cs,t)),e.guid=t=>e.check(pa(as,t)),e.uuid=t=>e.check(ma(os,t)),e.uuidv4=t=>e.check(ha(os,t)),e.uuidv6=t=>e.check(ga(os,t)),e.uuidv7=t=>e.check(_a(os,t)),e.nanoid=t=>e.check(ba(ls,t)),e.guid=t=>e.check(pa(as,t)),e.cuid=t=>e.check(xa(us,t)),e.cuid2=t=>e.check(Sa(ds,t)),e.ulid=t=>e.check(Ca(fs,t)),e.base64=t=>e.check(Aa(ys,t)),e.base64url=t=>e.check(ja(bs,t)),e.xid=t=>e.check(wa(ps,t)),e.ksuid=t=>e.check(Ta(ms,t)),e.ipv4=t=>e.check(Ea(hs,t)),e.ipv6=t=>e.check(Da(gs,t)),e.cidrv4=t=>e.check(Oa(_s,t)),e.cidrv6=t=>e.check(ka(vs,t)),e.e164=t=>e.check(Ma(xs,t)),e.datetime=t=>e.check(Io(t)),e.date=t=>e.check(Ro(t)),e.time=t=>e.check(Bo(t)),e.duration=t=>e.check(Ho(t))});function X(e){return da(rs,e)}var Z=T(`ZodStringFormat`,(e,t)=>{B.init(e,t),ns.init(e,t)}),is=T(`ZodEmail`,(e,t)=>{oi.init(e,t),Z.init(e,t)}),as=T(`ZodGUID`,(e,t)=>{ii.init(e,t),Z.init(e,t)}),os=T(`ZodUUID`,(e,t)=>{ai.init(e,t),Z.init(e,t)}),ss=T(`ZodURL`,(e,t)=>{si.init(e,t),Z.init(e,t)}),cs=T(`ZodEmoji`,(e,t)=>{ci.init(e,t),Z.init(e,t)}),ls=T(`ZodNanoID`,(e,t)=>{li.init(e,t),Z.init(e,t)}),us=T(`ZodCUID`,(e,t)=>{ui.init(e,t),Z.init(e,t)}),ds=T(`ZodCUID2`,(e,t)=>{di.init(e,t),Z.init(e,t)}),fs=T(`ZodULID`,(e,t)=>{fi.init(e,t),Z.init(e,t)}),ps=T(`ZodXID`,(e,t)=>{pi.init(e,t),Z.init(e,t)}),ms=T(`ZodKSUID`,(e,t)=>{mi.init(e,t),Z.init(e,t)}),hs=T(`ZodIPv4`,(e,t)=>{yi.init(e,t),Z.init(e,t)}),gs=T(`ZodIPv6`,(e,t)=>{bi.init(e,t),Z.init(e,t)}),_s=T(`ZodCIDRv4`,(e,t)=>{xi.init(e,t),Z.init(e,t)}),vs=T(`ZodCIDRv6`,(e,t)=>{Si.init(e,t),Z.init(e,t)}),ys=T(`ZodBase64`,(e,t)=>{wi.init(e,t),Z.init(e,t)}),bs=T(`ZodBase64URL`,(e,t)=>{Ei.init(e,t),Z.init(e,t)}),xs=T(`ZodE164`,(e,t)=>{Di.init(e,t),Z.init(e,t)}),Ss=T(`ZodJWT`,(e,t)=>{ki.init(e,t),Z.init(e,t)}),Cs=T(`ZodNumber`,(e,t)=>{Ai.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),e.gt=(t,n)=>e.check(Wa(t,n)),e.gte=(t,n)=>e.check(Ga(t,n)),e.min=(t,n)=>e.check(Ga(t,n)),e.lt=(t,n)=>e.check(Ha(t,n)),e.lte=(t,n)=>e.check(Ua(t,n)),e.max=(t,n)=>e.check(Ua(t,n)),e.int=t=>e.check(Ts(t)),e.safe=t=>e.check(Ts(t)),e.positive=t=>e.check(Wa(0,t)),e.nonnegative=t=>e.check(Ga(0,t)),e.negative=t=>e.check(Ha(0,t)),e.nonpositive=t=>e.check(Ua(0,t)),e.multipleOf=(t,n)=>e.check(Ka(t,n)),e.step=(t,n)=>e.check(Ka(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Q(e){return Ra(Cs,e)}var ws=T(`ZodNumberFormat`,(e,t)=>{ji.init(e,t),Cs.init(e,t)});function Ts(e){return za(ws,e)}var Es=T(`ZodUnknown`,(e,t)=>{Mi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ds(){return Ba(Es)}var Os=T(`ZodNever`,(e,t)=>{Ni.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r)});function ks(e){return Va(Os,e)}var As=T(`ZodArray`,(e,t)=>{Fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(W(t,n)),e.nonempty=t=>e.check(W(1,t)),e.max=(t,n)=>e.check(qa(t,n)),e.length=(t,n)=>e.check(Ja(t,n)),e.unwrap=()=>e.element});function js(e,t){return oo(As,e,t)}var Ms=T(`ZodObject`,(e,t)=>{zi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),O(e,`shape`,()=>t.shape),e.keyof=()=>Rs(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ds()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ds()}),e.strict=()=>e.clone({...e._zod.def,catchall:ks()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Rn(e,t),e.safeExtend=t=>zn(e,t),e.merge=t=>Bn(e,t),e.pick=t=>In(e,t),e.omit=t=>Ln(e,t),e.partial=(...t)=>Vn(Vs,e,t[0]),e.required=(...t)=>Hn(Zs,e,t[0])});function $(e,t){return new Ms({type:`object`,shape:e??{},...N(t)})}var Ns=T(`ZodUnion`,(e,t)=>{Vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.options=t.options});function Ps(e,t){return new Ns({type:`union`,options:e,...N(t)})}var Fs=T(`ZodIntersection`,(e,t)=>{Hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r)});function Is(e,t){return new Fs({type:`intersection`,left:e,right:t})}var Ls=T(`ZodEnum`,(e,t)=>{Gi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ls({...t,checks:[],...N(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ls({...t,checks:[],...N(r),entries:i})}});function Rs(e,t){return new Ls({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...N(t)})}var zs=T(`ZodTransform`,(e,t)=>{Ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new _n(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(I(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(I(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Bs(e){return new zs({type:`transform`,transform:e})}var Vs=T(`ZodOptional`,(e,t)=>{Ji.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hs(e){return new Vs({type:`optional`,innerType:e})}var Us=T(`ZodExactOptional`,(e,t)=>{Yi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ws(e){return new Us({type:`optional`,innerType:e})}var Gs=T(`ZodNullable`,(e,t)=>{Xi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ks(e){return new Gs({type:`nullable`,innerType:e})}var qs=T(`ZodDefault`,(e,t)=>{Zi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Js(e,t){return new qs({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():jn(t)}})}var Ys=T(`ZodPrefault`,(e,t)=>{$i.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xs(e,t){return new Ys({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():jn(t)}})}var Zs=T(`ZodNonOptional`,(e,t)=>{ea.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qs(e,t){return new Zs({type:`nonoptional`,innerType:e,...N(t)})}var $s=T(`ZodCatch`,(e,t)=>{na.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ec(e,t){return new $s({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var tc=T(`ZodPipe`,(e,t)=>{ra.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.in=t.in,e.out=t.out});function nc(e,t){return new tc({type:`pipe`,in:e,out:t})}var rc=T(`ZodReadonly`,(e,t)=>{ia.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ic(e){return new rc({type:`readonly`,innerType:e})}var ac=T(`ZodCustom`,(e,t)=>{oa.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r)});function oc(e,t={}){return so(ac,e,t)}function sc(e){return co(e)}var cc=$({sku:X(),name:X(),imageUrl:X().url().optional(),price:X().optional(),originalPrice:X().optional(),discountPercent:Q().optional(),url:X().url(),brand:X().optional(),rating:Q().min(0).max(5).optional(),reviewCount:Q().int().nonnegative().optional()}),lc=$({layout:Rs([`grid`,`carousel`]).optional(),columns:Q().int().positive().optional()}),uc=$({product:cc,index:Q().int().nonnegative(),discountType:Rs([`strike-through`,`badge`]).optional()}),dc=$({sku:X(),label:X().optional(),cartCode:X()}),fc=$({actions:js($({label:X(),action:$({title:X(),type:X(),payload:Ds().optional()})}))}),pc=$({message:X().optional()}),mc={components:{ProductGrid:{schema:lc,description:`Outer grid or carousel container for similar products.`},ProductCard:{schema:uc,description:`A single product card with image, title, price, and actions.`},AddToCartButton:{schema:dc,description:`Add-to-cart CTA rendered inside or below a product card.`},QuickActions:{schema:fc,description:`A row of quick-action buttons below product info.`},EmptyState:{schema:pc,description:`Empty state shown when no similar products are available.`}}},hc=class extends ke{constructor(...e){super(...e),this._abortController=null,this._contentEl=null,this._i18n=cn}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement(`div`),this._contentEl.className=`gengage-simrel-container`,this.root.appendChild(this._contentEl),this._lastSku=e.sku,await this._fetchAndRender(e.sku),pn(`simrel`)}onUpdate(e){let t=e.sku;!t||t===this._lastSku||(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(),null)}_handleProductClick(e){let 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;hn(e.sku,e.name);let n=this.config.session?.sessionId??null;se(`gengage:similar:product-click`,{sku:e.sku,url:e.url,sessionId:n}),this.config.onProductNavigate?.(e.url,e.sku,n)}_handleAddToCart(e){gn(e.sku,e.quantity),this.config.onAddToCart?.(e),se(`gengage:similar:add-to-cart`,e),this.track(l(this.analyticsContext(),{attribution_source:`simrel`,attribution_action_id:crypto.randomUUID(),cart_value:0,currency:`TRY`,line_items:e.quantity,sku:e.sku}))}_abort(){this._abortController?.abort(),this._abortController=null}async _fetchAndRender(e){this._abort(),this._abortController=new AbortController;let t=this._abortController.signal,n=setTimeout(()=>this._abortController?.abort(),1e4);if(t.addEventListener(`abort`,()=>clearTimeout(n)),!this._contentEl)return;this._contentEl.innerHTML=``,this._contentEl.style.display=``;let r=document.createElement(`div`);r.className=`gengage-simrel-loading`;let s=document.createElement(`div`);s.className=`gengage-simrel-spinner`,r.appendChild(s),this._contentEl.appendChild(r);let l={middlewareUrl:this.config.middlewareUrl},u=crypto.randomUUID(),d=Date.now();this.track(i(this.analyticsContext(),{endpoint:`similar_products`,request_id:u,widget:`simrel`}));try{let n={account_id:this.config.accountId,session_id:this.config.session?.sessionId??``,correlation_id:this.config.session?.sessionId??``,sku:e};this.config.domain!==void 0&&(n.domain=this.config.domain);let r=await Vt(n,l,t);if(!this._contentEl)return;if(this._contentEl.innerHTML=``,r.length>0)try{let e=r.map(e=>e.sku),n=await Ut({account_id:this.config.accountId,session_id:this.config.session?.sessionId??``,correlation_id:this.config.session?.sessionId??``,skus:e},l,t);if(n.length>0&&this._contentEl){let e=this._buildGroupsSpec(n),t=this._renderUISpec(e);this._contentEl.appendChild(t),mn(`simrel`),this.track(a(this.analyticsContext(),{request_id:u,latency_ms:Date.now()-d,chunk_count:n.reduce((e,t)=>e+t.products.length,0),widget:`simrel`})),this.track(c(this.analyticsContext(),{message_count:n.reduce((e,t)=>e+t.products.length,0),history_ref:u,redaction_level:`none`,widget:`simrel`}));return}}catch{}if(t.aborted)return;if(this._contentEl){let e=this._buildProductsSpec(r),t=this._renderUISpec(e);this._contentEl.appendChild(t)}r.length>0&&mn(`simrel`),this.track(a(this.analyticsContext(),{request_id:u,latency_ms:Date.now()-d,chunk_count:r.length,widget:`simrel`})),this.track(c(this.analyticsContext(),{message_count:r.length,history_ref:u,redaction_level:`none`,widget:`simrel`}))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;if(se(`gengage:global:error`,{source:`simrel`,code:`FETCH_ERROR`,message:ye(this.config.locale)}),this.track(o(this.analyticsContext(),{request_id:u,error_code:`FETCH_ERROR`,error_message:e instanceof Error?e.message:String(e),widget:`simrel`})),this._contentEl){this._contentEl.innerHTML=``;let e=document.createElement(`div`);e.className=`gengage-simrel-error`;let t=document.createElement(`span`);t.textContent=this._i18n.errorLoadingMessage,e.appendChild(t);let n=document.createElement(`button`);n.className=`gengage-simrel-retry`,n.textContent=this._i18n.retryButtonText,n.addEventListener(`click`,()=>{this._fetchAndRender(this.config.sku)}),e.appendChild(n),this._contentEl.appendChild(e)}}}_resolveI18n(e){return{...dn(e.locale),...e.i18n}}_resolveUISpecRegistry(){return r(on(),this.config.renderer?.registry)}_buildRenderContext(){let e=this.config.renderCard,t={onClick:e=>this._handleProductClick(e),onAddToCart:e=>this._handleAddToCart(e),i18n:this._i18n};return 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),t}_renderUISpec(e){let t=this._resolveUISpecRegistry(),n=this._buildRenderContext(),r=this.config.renderer?.unknownRenderer??an,i=(e,n)=>sn(e,n,t,r),a=this.config.renderer?.renderUISpec;return a?a(e,n,{registry:t,unknownRenderer:r,defaultRender:i}):i(e,n)}_buildProductsSpec(e){let t={},n=[];for(let r=0;r<e.length;r++){let i=e[r],a=`product-${r}`;n.push(a),t[a]={type:`ProductCard`,props:{product:i,index:r,discountType:this.config.discountType}}}return t.root={type:`ProductGrid`,props:{layout:`grid`},children:n},{root:`root`,elements:t}}_buildGroupsSpec(e){return{root:`root`,elements:{root:{type:`GroupTabs`,props:{groups:e}}}}}};function gc(){return new hc}e.GengageSimRel=hc,e.createDefaultSimRelUISpecRegistry=on,e.createSimRelWidget=gc,e.defaultSimRelUnknownUISpecRenderer=an,e.renderSimRelUISpec=sn,e.simRelCatalog=mc})(this.Gengage=this.Gengage||{});
86
+ //# sourceMappingURL=simrel.iife.js.map