@gengage/assistant-fe 0.2.3 → 0.2.5

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 (98) hide show
  1. package/dist/assistant-fe.css +1 -1
  2. package/dist/chat/api.d.ts.map +1 -1
  3. package/dist/chat/catalog.d.ts +2 -0
  4. package/dist/chat/catalog.d.ts.map +1 -1
  5. package/dist/chat/components/ChatDrawer.d.ts +47 -2
  6. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  7. package/dist/chat/components/ChoicePrompter.d.ts +3 -1
  8. package/dist/chat/components/ChoicePrompter.d.ts.map +1 -1
  9. package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
  10. package/dist/chat/components/GroundingReviewCard.d.ts.map +1 -1
  11. package/dist/chat/components/PanelTopBar.d.ts +1 -0
  12. package/dist/chat/components/PanelTopBar.d.ts.map +1 -1
  13. package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -1
  14. package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
  15. package/dist/chat/components/renderUISpec.d.ts.map +1 -1
  16. package/dist/chat/index.d.ts +22 -0
  17. package/dist/chat/index.d.ts.map +1 -1
  18. package/dist/chat/locales/en.d.ts.map +1 -1
  19. package/dist/chat/locales/tr.d.ts.map +1 -1
  20. package/dist/chat/panel-manager.d.ts +6 -4
  21. package/dist/chat/panel-manager.d.ts.map +1 -1
  22. package/dist/chat/session-persistence.d.ts +6 -1
  23. package/dist/chat/session-persistence.d.ts.map +1 -1
  24. package/dist/chat/types.d.ts +23 -1
  25. package/dist/chat/types.d.ts.map +1 -1
  26. package/dist/chat.cjs +1 -1
  27. package/dist/chat.iife.js +29 -29
  28. package/dist/chat.iife.js.map +1 -1
  29. package/dist/chat.js +2 -2
  30. package/dist/common/action-router.d.ts.map +1 -1
  31. package/dist/common/communication-bridge.d.ts.map +1 -1
  32. package/dist/common/ga-datalayer.d.ts.map +1 -1
  33. package/dist/common/price-formatter.d.ts +1 -1
  34. package/dist/common/price-formatter.d.ts.map +1 -1
  35. package/dist/common/product-utils.d.ts.map +1 -1
  36. package/dist/common/quantity-stepper.d.ts +1 -1
  37. package/dist/common/quantity-stepper.d.ts.map +1 -1
  38. package/dist/common/skeleton.d.ts +9 -0
  39. package/dist/common/skeleton.d.ts.map +1 -0
  40. package/dist/common/widget-base.d.ts.map +1 -1
  41. package/dist/common.cjs +1 -1
  42. package/dist/common.js +5 -5
  43. package/dist/{index-Bctbyou5.cjs → index-B6xRdkMq.cjs} +2 -2
  44. package/dist/{index-Bctbyou5.cjs.map → index-B6xRdkMq.cjs.map} +1 -1
  45. package/dist/{index-BaG-fiAK.js → index-BsvmfVa1.js} +3 -3
  46. package/dist/{index-BaG-fiAK.js.map → index-BsvmfVa1.js.map} +1 -1
  47. package/dist/index-BzCc2DCm.cjs +13 -0
  48. package/dist/index-BzCc2DCm.cjs.map +1 -0
  49. package/dist/index-D5UPIXIA.js +4831 -0
  50. package/dist/index-D5UPIXIA.js.map +1 -0
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.js +3 -3
  53. package/dist/native.cjs +1 -1
  54. package/dist/native.iife.js +29 -29
  55. package/dist/native.iife.js.map +1 -1
  56. package/dist/native.js +1 -1
  57. package/dist/qna/index.d.ts.map +1 -1
  58. package/dist/qna.cjs +1 -1
  59. package/dist/qna.cjs.map +1 -1
  60. package/dist/qna.css +1 -1
  61. package/dist/qna.iife.js +14 -14
  62. package/dist/qna.iife.js.map +1 -1
  63. package/dist/qna.js +57 -48
  64. package/dist/qna.js.map +1 -1
  65. package/dist/quantity-stepper-CQWgexMO.cjs +2 -0
  66. package/dist/quantity-stepper-CQWgexMO.cjs.map +1 -0
  67. package/dist/quantity-stepper-CjY_cpgJ.js +80 -0
  68. package/dist/quantity-stepper-CjY_cpgJ.js.map +1 -0
  69. package/dist/{schemas-DOxyUYVA.cjs → schemas-CNzyBhf7.cjs} +8 -8
  70. package/dist/schemas-CNzyBhf7.cjs.map +1 -0
  71. package/dist/{schemas-D1Kd4wn8.js → schemas-Fiaobs4L.js} +306 -308
  72. package/dist/schemas-Fiaobs4L.js.map +1 -0
  73. package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
  74. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  75. package/dist/simrel/components/ProductGrid.d.ts.map +1 -1
  76. package/dist/simrel/index.d.ts.map +1 -1
  77. package/dist/simrel/locales/en.d.ts.map +1 -1
  78. package/dist/simrel/locales/tr.d.ts.map +1 -1
  79. package/dist/simrel/types.d.ts +6 -0
  80. package/dist/simrel/types.d.ts.map +1 -1
  81. package/dist/simrel.cjs +1 -1
  82. package/dist/simrel.cjs.map +1 -1
  83. package/dist/simrel.css +1 -1
  84. package/dist/simrel.iife.js +11 -11
  85. package/dist/simrel.iife.js.map +1 -1
  86. package/dist/simrel.js +163 -158
  87. package/dist/simrel.js.map +1 -1
  88. package/package.json +1 -1
  89. package/dist/index-BHaQLt-o.js +0 -4468
  90. package/dist/index-BHaQLt-o.js.map +0 -1
  91. package/dist/index-CO5VnxEn.cjs +0 -13
  92. package/dist/index-CO5VnxEn.cjs.map +0 -1
  93. package/dist/quantity-stepper-BKtPQUR1.js +0 -78
  94. package/dist/quantity-stepper-BKtPQUR1.js.map +0 -1
  95. package/dist/quantity-stepper-DU6va4sS.cjs +0 -2
  96. package/dist/quantity-stepper-DU6va4sS.cjs.map +0 -1
  97. package/dist/schemas-D1Kd4wn8.js.map +0 -1
  98. package/dist/schemas-DOxyUYVA.cjs.map +0 -1
package/dist/qna.iife.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(x){"use strict";const Ut=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const o of e.children){const r=t(o);r&&n.appendChild(r)}return n};function qt(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const o=e.unknownRenderer??Ut,r=i=>{const a=e.spec.elements[i];if(!a)return null;const c=e.registry[a.type];return c?c({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r}):o({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r})},s=r(e.spec.root);return s&&t.appendChild(s),t}function Ft(e,t){if(!t)return e;const n={...e};for(const[o,r]of Object.entries(t))r&&(n[o]=r);return n}function Mt(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 Jt(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 Bt(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 Qt(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 Ht(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 Vt(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 Wt(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}function fe(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Ze(e,t){const n=o=>{t(o.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function Gt(){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 Kt(e){return{sessionId:e?.sessionId??Gt(),...e}}const Ce={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"12px","--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":"14px","--gengage-simrel-card-radius":"14px"};function Yt(e){return e?{...Ce,...e}:{...Ce}}const j="gengage-global-toast-root",Pe="gengage-global-toast-style",he="gengage-global-toast-root--visible",Xt=4200,en=1500,tn=15e3;let Re=!1,U=null;function nn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")?"Baglanti sorunu olustu. Lutfen tekrar deneyin.":"Connection issue. Please try again."}function on(){Re||typeof window>"u"||typeof document>"u"||(Re=!0,Ze("gengage:global:error",e=>{rn(e)}))}function rn(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;dn();const n=cn();n.innerHTML="";const o=document.createElement("section");o.className="gengage-global-toast gengage-global-toast--error",o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const r=document.createElement("div");r.className="gengage-global-toast-title",r.textContent=an(e.source);const s=document.createElement("div");s.className="gengage-global-toast-message",s.textContent=t,o.appendChild(r),o.appendChild(s),n.appendChild(o),n.classList.add(he),U&&(clearTimeout(U),U=null),U=setTimeout(()=>{sn()},un(e.durationMs))}function sn(){if(typeof document>"u")return;const e=document.getElementById(j);e&&(e.classList.remove(he),e.innerHTML="",U&&(clearTimeout(U),U=null))}function an(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function cn(){const e=document.getElementById(j);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=j,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function un(e){return typeof e!="number"||!Number.isFinite(e)?Xt:Math.min(tn,Math.max(en,Math.round(e)))}function dn(){if(document.getElementById(Pe))return;const e=document.createElement("style");e.id=Pe,e.textContent=`
1
+ (function(x){"use strict";const Ut=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const o of e.children){const r=t(o);r&&n.appendChild(r)}return n};function qt(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const o=e.unknownRenderer??Ut,r=i=>{const a=e.spec.elements[i];if(!a)return null;const c=e.registry[a.type];return c?c({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r}):o({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r})},s=r(e.spec.root);return s&&t.appendChild(s),t}function Ft(e,t){if(!t)return e;const n={...e};for(const[o,r]of Object.entries(t))r&&(n[o]=r);return n}function Mt(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 Jt(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 Bt(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 Qt(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 Ht(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 Vt(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 Wt(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}function fe(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Ze(e,t){const n=o=>{t(o.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function Gt(){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 Kt(e){return{sessionId:e?.sessionId??Gt(),...e}}const Ce={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"12px","--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":"14px","--gengage-simrel-card-radius":"14px"};function Yt(e){return e?{...Ce,...e}:{...Ce}}const j="gengage-global-toast-root",Pe="gengage-global-toast-style",he="gengage-global-toast-root--visible",Xt=4200,en=1500,tn=15e3;let Re=!1,U=null;function nn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")?"Bağlantı sorunu oluştu. Lütfen tekrar deneyin.":"Connection issue. Please try again."}function on(){Re||typeof window>"u"||typeof document>"u"||(Re=!0,Ze("gengage:global:error",e=>{rn(e)}))}function rn(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;dn();const n=cn();n.innerHTML="";const o=document.createElement("section");o.className="gengage-global-toast gengage-global-toast--error",o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const r=document.createElement("div");r.className="gengage-global-toast-title",r.textContent=an(e.source);const s=document.createElement("div");s.className="gengage-global-toast-message",s.textContent=t,o.appendChild(r),o.appendChild(s),n.appendChild(o),n.classList.add(he),U&&(clearTimeout(U),U=null),U=setTimeout(()=>{sn()},un(e.durationMs))}function sn(){if(typeof document>"u")return;const e=document.getElementById(j);e&&(e.classList.remove(he),e.innerHTML="",U&&(clearTimeout(U),U=null))}function an(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function cn(){const e=document.getElementById(j);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=j,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function un(e){return typeof e!="number"||!Number.isFinite(e)?Xt:Math.min(tn,Math.max(en,Math.round(e)))}function dn(){if(document.getElementById(Pe))return;const e=document.createElement("style");e.id=Pe,e.textContent=`
2
2
  #${j} {
3
3
  position: fixed;
4
4
  top: 16px;
@@ -43,44 +43,44 @@
43
43
  transform: translateY(0);
44
44
  }
45
45
  }
46
- `,document.head.appendChild(e)}let W=null;function ln(){if(W!==null)return W;try{W=localStorage.getItem("gengage:debug")==="1"}catch{W=!1}return W}function ge(e,t,n){if(!ln())return;const o=[`[gengage:${e}]`,t];n!==void 0&&o.push(n),console.debug(...o)}class pn{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=Yt(t.theme);this.config={...t,theme:n,session:Kt(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),on();const o=Ze("gengage:context:update",r=>this.update(r));this._cleanups.push(o),ge("lifecycle",`${this.constructor.name}.init`,{accountId:t.accountId,sku:t.pageContext?.sku});try{await this.onInit(this.config)}catch(r){throw this.destroy(),r}this.isInitialised=!0,ge("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 o=t==="start"?Vt:Wt;this.track(o(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(Qt(this.analyticsContext(),t))}emit(t,...n){this._handlers.get(t)?.forEach(o=>o(...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 o=document.querySelector(t);if(!o)throw new Error(`[gengage] Mount target not found: "${t}"`);return o}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,o]of Object.entries(t))if(o!==void 0){const r=n.startsWith("--")?n:`--gengage-${fn(n)}`;this.root.style.setProperty(r,o)}}}}function fn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Ne(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function hn(e){const t=[];let n=0,o=!1,r=!1,s=0;for(let i=0;i<e.length;i++){const a=e[i];if(r){r=!1;continue}if(a==="\\"&&o){r=!0;continue}if(a==='"'){o=!o;continue}o||(a==="{"&&n++,a==="}"&&(n--,n===0&&(t.push(e.slice(s,i+1)),s=i+1)))}return t.length>0?t:[e]}function je(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const o=n.startsWith("data: ")?n.slice(6):n;if(o==="[DONE]")return t.onDone?.(),!0;try{const r=JSON.parse(o);return Ne(r)?(ge("stream",`event: ${r.type}`,r),t.onEvent(r),r.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const r=hn(o);if(r.length>1){for(const s of r)try{const i=JSON.parse(s);if(!Ne(i))continue;if(t.onEvent(i),i.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function gn(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(),o=new TextDecoder("utf-8");let r="";const s=t.idleTimeoutMs??6e4,i=Symbol("idle-timeout");let a=!1;try{for(;;){const c=n.read();let u;const l=await(s>0?Promise.race([c.then(_=>(clearTimeout(u),_)),new Promise(_=>{u=setTimeout(()=>_(i),s)})]):c);if(l===i){a=!0,await n.cancel();break}const{done:h,value:p}=l;if(h)break;r+=o.decode(p,{stream:!0});const f=r.split(`
47
- `);r=f.pop()??"";for(const _ of f)if(je(_,t))return}if(r.trim()&&je(r,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 mn={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function _n(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 yn(e,t){return`${_n(t?.middlewareUrl)}/chat${mn[e]}`}function vn(e){if(typeof e.type!="string")return null;if(wn(e))return e;const n=e;switch(n.type){case"outputText":return bn(n);case"suggestedActions":return kn(n);case"productList":return zn(n);case"productDetails":return Sn(n);case"productDetailsSimilars":return $n(n);case"comparisonTable":return Tn(n);case"context":return On(n);case"chatStreamEnd":return Zn();case"loading":return Cn(n);case"panelLoading":return Pn(n);case"similarLoading":return Rn(n);case"redirect":return Nn(n);case"error":return jn(n);case"dummy":return Dn();case"launcherAction":return Ln(n);case"text":return me(n);case"productItem":return xn(n);case"text_image":return De(n);case"quick_qna":return Le(n);case"reviewHighlights":return Un(n);case"aiProductSuggestions":return Mn(n);case"aiProductGroupings":return Jn(n);case"aiSuggestedSearches":return Bn(n);case"prosAndCons":return qn(n);case"getGroundingReview":return Qn(n);case"voice":return Vn(n);case"visitorDataResponse":return Fn(n);case"productListPreview":return Hn();case"groupList":return Wn(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Gn(n);case"launcherContent":return Yn(n);case"handoff":return Kn(n);default:return null}}function wn(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 o=N(e.spec);return o?typeof o.root=="string"&&N(o.elements)!==null:!1}case"action":{const n=N(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 bn(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 o={type:"text_chunk",content:t,final:!0},r=e.payload.product_mentions;Array.isArray(r)&&r.length>0&&(o.productMentions=r.filter(a=>typeof a=="object"&&a!==null&&typeof a.sku=="string"&&typeof a.short_name=="string"));const s=e.payload.sku_to_product_item;s&&typeof s=="object"&&!Array.isArray(s)&&(o.skuToProductItem=s);const i=e.payload.conversation_mode;return typeof i=="string"&&i&&(o.conversationMode=i),o}function kn(e){const t=(e.payload.actions??[]).map(n=>{const o=w(n.title)??"",r=C(n.requestDetails,o),s=r?{label:o,action:r}:null;return s?(typeof n.icon=="string"&&(s.icon=n.icon),typeof n.image=="string"&&(s.image=n.image),s):null});return xe(t.filter(qe),"chat")}function zn(e){const t=Ue(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 Sn(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:B(t)}}}},panelHint:"panel"}:eo("chat")}function $n(e){const t=Ue(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Tn(e){const t=e.payload.multiple_product_details??[],n=e.payload,o={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??{}},r=e.payload.table,s=e.payload.features_list,i=[];for(const v of t){const b=B(v);i.push(b)}const a=En(r,i,o,s);let c;o?.recommended_choice_sku?c=o.recommended_choice_sku:o?.winner_product&&o.winner_product.length>0&&(c=o.winner_product[0]?.product_detail?.sku??o.winner_product[0]?.sku);const u=c?i.find(v=>v.sku===c)??i[0]:i[0],l=[];if(Array.isArray(o?.key_differences))for(const v of o.key_differences)typeof v=="string"&&l.push(v);const h=ro(o?.special_considerations),p=o?.recommended_choice,f=o?.winner_hits,_={};for(const v of i){const b=v.sku;b&&(_[b]={title:v.name??b,type:"launchSingleProduct",payload:{sku:b}})}const m={products:i,attributes:a,highlights:l,productActions:_};return u&&(m.recommended=u),h.length>0&&(m.specialCases=h),p&&(m.recommendedText=p),f&&(m.winnerHits=f),typeof o?.key_differences=="string"&&(m.keyDifferencesHtml=o.key_differences),o?.special_considerations&&(m.specialConsiderations=o.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function En(e,t,n,o){if(!e)return[];const r=Object.entries(e);if(r.length===0)return[];const s=r[0]?.[1];if(Array.isArray(s)){const p=n.criteria_view??n.criteria_view_short??{},f=n.compared_field_names??Object.keys(e),_=[];for(const m of f){const v=e[m];if(!v||!Array.isArray(v))continue;const b=p[m]??m;_.push({label:b,values:v.map(O=>typeof O=="string"?O:String(O??""))})}return _}const i=e,a=t.map(p=>String(p.sku??"")).filter(p=>p.length>0),c=n.criteria_view??n.criteria_view_short??{},l=(o&&o.length>0?o:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:An(i)).filter(p=>p!=="name"&&p!=="name_short"&&!p.endsWith("_short")),h=[];for(const p of l){const f=a.map(m=>{const v=i[m];if(!v||typeof v!="object")return"";const b=v[`${p}_short`],O=v[p];return In(b??O)});if(f.every(m=>m.length===0))continue;const _=c[p]??p;h.push({label:_,values:f})}return h}function An(e){const t=[],n=new Set;for(const o of Object.values(e))if(!(!o||typeof o!="object"))for(const r of Object.keys(o))n.has(r)||(n.add(r),t.push(r));return t}function In(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function On(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Zn(){return{type:"done"}}function Cn(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 Pn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Rn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Nn(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 jn(e){return{type:"error",code:"BACKEND_ERROR",message:w(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Dn(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Ln(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const s={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(s.type=i),a!==void 0&&(s.theme=a),Le({payload:s})}const o=N(t.action);if(o){const s={action:o},i=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 i!==void 0&&(s.text=i),a!==void 0&&(s.image_url=a),c!==void 0&&(s.theme=c),De({payload:s})}const r=typeof t.text=="string"?t.text:"";if(r){const s={text:r},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0,c=N(t.payload)??void 0;return i!==void 0&&(s.type=i),c!==void 0&&(s.payload=c),a!==void 0&&(s.theme=a),me({payload:s})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function me(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 xn(e){return Xn(e.payload,"qna")}function De(e){const t=w(e.payload.text)??"",n=C(e.payload.action,t);if(n){const 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}}}}}const o={text:t};return typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),me({payload:o})}function Le(e){const t=(e.payload.action_list??[]).map(n=>{const o=w(n.title)??"",r=C(n.requestDetails,o),s=r?{label:o,action:r}:null;return s?(typeof n.icon=="string"&&(s.icon=n.icon),typeof n.image=="string"&&(s.image=n.image),s):null});return xe(t.filter(qe),"qna")}function Un(e){const n={reviews:(e.payload.reviews??[]).map(o=>{const r={};return typeof o.review_class=="string"&&(r.review_class=o.review_class),typeof o.review_text=="string"&&(r.review_text=o.review_text),(typeof o.review_rating=="string"||typeof o.review_rating=="number")&&(r.review_rating=o.review_rating),typeof o.review_tag=="string"&&(r.review_tag=o.review_tag),r})};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 qn(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function Fn(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Mn(e){const t=e.payload.product_suggestions??[],n=[];for(let o=0;o<t.length;o++){const r=t[o];if(!r)continue;const s=to(r);if(!s)continue;const i={product:s},a=C(r.requestDetails,s.name);a&&(i.action=a),typeof r.role=="string"&&(i.role=r.role),typeof r.reason=="string"&&(i.reason=r.reason),typeof r.review_highlight=="string"&&(i.reviewHighlight=r.review_highlight),Array.isArray(r.labels)&&(i.labels=r.labels),typeof r.expert_quality_score=="number"&&(i.expertQualityScore=r.expert_quality_score),n.push(i)}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 Jn(e){const t=e.payload.product_groupings??[],n=[];for(let o=0;o<t.length;o++){const r=t[o];if(!r)continue;const s=w(r.name)??"",i=r.sku&&r.sku.length>0?{type:"findSimilar",payload:{sku:r.sku}}:void 0,a=C(r.requestDetails??i,s);if(!a)continue;const c={name:s,action:a};if(Array.isArray(r.labels)){const u=r.labels.filter(l=>typeof l=="string");u.length>0&&(c.labels=u)}typeof r.image=="string"&&(c.image=r.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 Bn(e){const t=e.payload.suggested_searches??[],n=[];for(let o=0;o<t.length;o++){const r=t[o];if(!r)continue;const s=w(r.short_name,r.chosen_attribute,r.detailed_user_message)??`Search ${o+1}`,i={},a=w(r.detailed_user_message);a&&(i.text=a);const c=N(r.requestDetails),u=N(c?.payload),l=u?.group_skus;r.group_skus&&Array.isArray(r.group_skus)?i.group_skus=r.group_skus:Array.isArray(l)&&(i.group_skus=l.filter(O=>typeof O=="string"));const h=w(r.sku,r.representative_product_sku,u?.sku);h&&(i.sku=h),i.is_suggested_text=1;const p={type:"inputText",payload:i},f=C(r.requestDetails,s),_=f?.type==="findSimilar"&&typeof i.text=="string"?C(p,s):f??C(p,s);if(!_)continue;const m={shortName:s,action:_},v=w(r.detailed_user_message);v&&v!==s&&(m.detailedMessage=v);const b=w(r.why_different);b&&(m.whyDifferent=b),typeof r.image=="string"&&(m.image=r.image),n.push(m)}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 Qn(e){const t=C(e.payload.requestDetails,w(e.payload.review_count,e.payload.text,e.payload.title)??"Urun yorumlarini goster");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 Hn(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Vn(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Wn(e){const t=e.payload.group_list??[],n=[];for(const r of t){const s=r.group_name??"",i=(r.product_list??[]).map(B);n.push({groupName:s,products:i})}const o=[];for(const r of e.payload.filter_tags??[]){const s=r.title??"";if(!s)continue;const i=C(r.requestDetails,s),a={title:s};i&&(a.action=i),o.push(a)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:o}}}},panelHint:"panel"}}function Gn(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Kn(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 Yn(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function xe(e,t){const n={},o=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=`action-${r}`;o.push(i);const a={label:s.label,action:s.action};s.icon!==void 0&&(a.icon=s.icon),s.image!==void 0&&(a.image=s.image),s.description!==void 0&&(a.description=s.description),n[i]={type:"ActionButton",props:a}}return n.root={type:"ActionButtons",props:{buttons:e.map(r=>{const s={label:r.label,action:r.action};return r.image!==void 0&&(s.image=r.image),r.description!==void 0&&(s.description=r.description),r.icon!==void 0&&(s.icon=r.icon),s})},children:o},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Ue(e,t){const n={},o=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=`product-${r}`;o.push(i),n[i]={type:"ProductCard",props:{product:B(s),index:r}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:o},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Xn(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:B(e),index:0}}}}}}function eo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function to(e){const t=w(e.sku),n=w(e.short_name),o=N(e.product_item)??e;return no(o,t,n)}function no(e,t,n){const o=w(e.sku,t),r=w(e.name,n);if(!o||!r)return null;const s={sku:o,name:r},i=w(e.brand);i&&(s.brand=i);const a=w(e.url);a&&(s.url=a);const c=oo(e.images);if(c.length>0)s.images=c;else{const _=w(e.image,e.image_url,e.imageUrl);_&&(s.images=[_])}const u=G(e.price_discounted);u!==void 0&&(s.price_discounted=u);const l=G(e.price);l!==void 0&&(s.price=l);const h=G(e.rating);h!==void 0&&(s.rating=h);const p=G(e.review_count)??G(e.reviewCount);p!==void 0&&(s.review_count=p);const f=w(e.cart_code,e.cartCode);return f&&(s.cart_code=f),typeof e.in_stock=="boolean"&&(s.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(s.in_stock=e.inStock),B(s)}function C(e,t){const n=N(e);if(!n)return null;const o=n.type;if(typeof o!="string"||o.length===0)return null;const r={title:t||o,type:o};return n.payload!==void 0&&(r.payload=n.payload),r}function N(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 oo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ro(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 G(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 qe(e){return e!=null}const io=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 B(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,o=t&&e.price!=null?e.price:void 0;let r;o!=null&&n!=null&&o>0&&(r=Math.round((o-n)/o*100));const s=w(e.brand),i=w(e.name)??e.sku,a=s&&!i.toLowerCase().startsWith(s.toLowerCase())?`${s} ${i}`:i,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)),o!=null&&(c.originalPrice=String(o)),r!==void 0&&(c.discountPercent=r),s!==void 0&&(c.brand=s),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 l=e,h={};let p=!1;for(const f of Object.keys(l))io.has(f)||(h[f]=l[f],p=!0);return p&&(c.extras=h),c}async function so(e,t,n){const o=yn("launcher_action",t),r={uiSpecs:[],actions:[]},s={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(s.signal=n);const i=await fetch(o,s);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const a={onEvent:c=>{const u=vn(c);if(u&&(u.type==="ui_spec"&&r.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const l of Object.values(u.spec.elements))if(l.type==="ActionButton"&&l.props?.action){const h=l.props.action;r.actions.push(h)}}}};return n!==void 0&&(a.signal=n),await gn(i,a),r}function ao(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function _e(e,t){const n={event:e,...t};ao()&&window.dataLayer.push(n)}function co(e){_e("gengage-on-init",{gengage_widget:e})}function uo(e){_e("gengage-show",{gengage_widget:e})}function lo(e,t){_e("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function Fe(e){const t=document.createElement("div");t.className="gengage-qna-buttons",t.setAttribute("role","group"),t.setAttribute("aria-label",e.quickQuestionsAriaLabel??"Quick questions"),e.orientation==="vertical"&&(t.style.flexDirection="column");for(const n of e.actions){const o=document.createElement("button");o.className="gengage-qna-button",o.textContent=n.title,o.type="button",o.addEventListener("click",()=>{const r={title:n.title,type:n.type};n.payload!==void 0&&(r.payload=n.payload),e.onAction(r)}),t.appendChild(o)}if(e.ctaText||e.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta",n.textContent=e.ctaText??e.defaultCtaText??"Ask something else",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function po(e){const t=document.createElement("div");t.className="gengage-qna-input-wrapper";const n=document.createElement("input");n.type="text",n.className="gengage-qna-input",n.setAttribute("aria-label",e.askQuestionAriaLabel??"Ask a question");const o=Array.isArray(e.placeholders)?e.placeholders:e.placeholders?[e.placeholders]:[e.defaultInputPlaceholder??"Ask a question..."];let r=0;n.placeholder=o[0]??"";let s=null,i=null;o.length>1&&(s=setInterval(()=>{n.classList.add("gengage-qna-input--fade"),i=setTimeout(()=>{r=(r+1)%o.length,n.placeholder=o[r]??"",n.classList.remove("gengage-qna-input--fade")},180)},3e3));const a=document.createElement("button");a.className="gengage-qna-send",a.type="button",a.textContent=e.ctaLabel??e.sendButtonText??"Ask",a.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question");const c=()=>{const u=n.value.trim();u&&(e.onSubmit({title:u,type:"user_message",payload:u}),n.value="")};return a.addEventListener("click",c),n.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),c())}),t.appendChild(n),t.appendChild(a),t._cleanup=()=>{s&&clearInterval(s),i&&clearTimeout(i)},t}function te(e,t){if(!e||typeof e!="object")return null;const n=e,o=n.type;if(typeof o!="string"||o.length===0)return null;const r=n.title,s=n.payload,i=typeof r=="string"&&r.length>0?r:t;if(!i)return null;const a={title:i,type:o};return s!==void 0&&(a.payload=s),a}function Me(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function Je(e,t){const n=[],o=e.props?.actions;if(Array.isArray(o))for(const i of o){const a=te(i);a&&n.push(a)}const r=e.props?.buttons;if(Array.isArray(r))for(const i of r){if(!i||typeof i!="object")continue;const a=i,c=typeof a.label=="string"?a.label:void 0,u=te(a.action,c);u&&n.push(u)}if(e.children)for(const i of e.children){const a=t.elements[i];if(!a||a.type!=="ActionButton")continue;const c=typeof a.props?.label=="string"?a.props.label:void 0,u=te(a.props?.action,c);u&&n.push(u)}const s=new Set;return n.filter(i=>s.has(i.title)?!1:(s.add(i.title),!0))}const Be={ButtonRow:({element:e,spec:t,context:n})=>{const o=Je(e,t).map(Me),r=e.props?.orientation,s={actions:o,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(s.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(s.ctaText=n.ctaText),(r==="horizontal"||r==="vertical")&&(s.orientation=r),Fe(s)},ActionButtons:({element:e,spec:t,context:n})=>{const r={actions:Je(e,t).map(Me),onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(r.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(r.ctaText=n.ctaText),Fe(r)},ActionButton:({element:e,context:t})=>{const n=document.createElement("button");n.className="gengage-qna-button",n.type="button";const o=e.props?.label;typeof o=="string"?n.textContent=o:n.textContent=t.i18n.defaultCtaText;const r=te(e.props?.action,typeof o=="string"?o:void 0);return r&&n.addEventListener("click",()=>t.onAction(r)),n},TextInput:({element:e,context:t})=>{const n=e.props?.placeholder,o=typeof n=="string"||Array.isArray(n)?n:t.inputPlaceholder,r=typeof e.props?.ctaLabel=="string"?e.props.ctaLabel:void 0,s={onSubmit:t.onAction,askQuestionAriaLabel:t.i18n.askQuestionAriaLabel,defaultInputPlaceholder:t.i18n.defaultInputPlaceholder,sendButtonText:t.i18n.sendButton,sendQuestionAriaLabel:t.i18n.sendQuestionAriaLabel};return o!==void 0&&(s.placeholders=o),r!==void 0&&(s.ctaLabel=r),po(s)},QuestionHeading:({element:e})=>{const t=document.createElement("h3");t.className="gengage-qna-heading";const n=e.props?.text;return t.textContent=typeof n=="string"?n:"",t},ProductCard:()=>null},ye=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const o of e.children){const r=t(o);r&&n.appendChild(r)}return n};function Qe(){return{...Be}}function He(e,t,n=Be,o=ye){return qt({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:o})}const Ve={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},fo={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function ho(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function go(e){return ho(e)==="en"?fo:Ve}function d(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,l=Object.keys(u);for(let h=0;h<l.length;h++){const p=l[h];p in a||(a[p]=u[p].bind(a))}}const r=n?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Q extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class We extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ge={};function q(e){return Ge}function Ke(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function ve(e,t){return typeof t=="bigint"?t.toString():t}function we(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function be(e){return e==null}function ke(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Ye=Symbol("evaluating");function y(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Ye)return o===void 0&&(o=Ye,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function F(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function D(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function Xe(e){return JSON.stringify(e)}function mo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ne(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const _o=we(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function K(e){if(ne(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ne(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function tt(e){return K(e)?{...e}:Array.isArray(e)?[...e]:e}const yo=new Set(["string","number","symbol"]);function oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function g(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 vo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function wo(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=D(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return F(this,"shape",i),i},checks:[]});return L(e,s)}function bo(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=D(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return F(this,"shape",i),i},checks:[]});return L(e,s)}function ko(e,t){if(!K(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=D(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return F(this,"shape",s),s}});return L(e,r)}function zo(e,t){if(!K(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=D(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return F(this,"shape",o),o}});return L(e,n)}function So(e,t){const n=D(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return F(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return L(e,n)}function $o(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=D(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 F(this,"shape",c),c},checks:[]});return L(t,i)}function To(e,t,n){const o=D(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return F(this,"shape",s),s}});return L(t,o)}function H(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 nt(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function re(e){return typeof e=="string"?e:e?.message}function M(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const r=re(e.inst?._zod.def?.error?.(e))??re(t?.error?.(e))??re(n.customError?.(e))??re(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function ze(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Y(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const ot=(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,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},rt=d("$ZodError",ot),it=d("$ZodError",ot,{Parent:Error});function Eo(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Ao(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>o({issues:i}));else if(s.code==="invalid_key")o({issues:s.issues});else if(s.code==="invalid_element")o({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return o(e),n}const Se=e=>(t,n,o,r)=>{const s=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Q;if(i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>M(c,s,q())));throw et(a,r?.callee),a}return i.value},$e=e=>async(t,n,o,r)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>M(c,s,q())));throw et(a,r?.callee),a}return i.value},ie=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Q;return s.issues.length?{success:!1,error:new(e??rt)(s.issues.map(i=>M(i,r,q())))}:{success:!0,data:s.value}},Io=ie(it),se=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>M(i,r,q())))}:{success:!0,data:s.value}},Oo=se(it),Zo=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Se(e)(t,n,r)},Co=e=>(t,n,o)=>Se(e)(t,n,o),Po=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return $e(e)(t,n,r)},Ro=e=>async(t,n,o)=>$e(e)(t,n,o),No=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ie(e)(t,n,r)},jo=e=>(t,n,o)=>ie(e)(t,n,o),Do=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return se(e)(t,n,r)},Lo=e=>async(t,n,o)=>se(e)(t,n,o),xo=/^[cC][^\s-]{8,}$/,Uo=/^[0-9a-z]+$/,qo=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Fo=/^[0-9a-vA-V]{20}$/,Mo=/^[A-Za-z0-9]{27}$/,Jo=/^[a-zA-Z0-9_-]{21}$/,Bo=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qo=/^([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})$/,st=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)$/,Ho=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Vo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Wo(){return new RegExp(Vo,"u")}const Go=/^(?:(?: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])$/,Ko=/^(([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}|:))$/,Yo=/^((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])$/,Xo=/^(([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])$/,er=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,at=/^[A-Za-z0-9_-]*$/,tr=/^\+[1-9]\d{6,14}$/,ct="(?:(?:\\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])))",nr=new RegExp(`^${ct}$`);function ut(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 or(e){return new RegExp(`^${ut(e)}$`)}function rr(e){const t=ut({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${ct}T(?:${o})$`)}const ir=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},sr=/^(?:true|false)$/i,ar=/^[^A-Z]*$/,cr=/^[^a-z]*$/,P=d("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ur=d("$ZodCheckMaxLength",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!be(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const i=ze(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),dr=d("$ZodCheckMinLength",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!be(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const i=ze(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lr=d("$ZodCheckLengthEquals",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!be(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,s=r.length;if(s===t.length)return;const i=ze(r),a=s>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),ae=d("$ZodCheckStringFormat",(e,t)=>{var n,o;P.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),pr=d("$ZodCheckRegex",(e,t)=>{ae.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})}}),fr=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ar),ae.init(e,t)}),hr=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cr),ae.init(e,t)}),gr=d("$ZodCheckIncludes",(e,t)=>{P.init(e,t);const n=oe(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),mr=d("$ZodCheckStartsWith",(e,t)=>{P.init(e,t);const n=new RegExp(`^${oe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),_r=d("$ZodCheckEndsWith",(e,t)=>{P.init(e,t);const n=new RegExp(`.*${oe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),yr=d("$ZodCheckOverwrite",(e,t)=>{P.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class vr{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 o=t.split(`
46
+ `,document.head.appendChild(e)}let W=null;function ln(){if(W!==null)return W;try{W=localStorage.getItem("gengage:debug")==="1"}catch{W=!1}return W}function ge(e,t,n){if(!ln())return;const o=[`[gengage:${e}]`,t];n!==void 0&&o.push(n),console.debug(...o)}class pn{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=Yt(t.theme);this.config={...t,theme:n,session:Kt(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),on();const o=Ze("gengage:context:update",r=>this.update(r));this._cleanups.push(o),ge("lifecycle",`${this.constructor.name}.init`,{accountId:t.accountId,sku:t.pageContext?.sku});try{await this.onInit(this.config)}catch(r){throw this.destroy(),r}this._destroying||(this.isInitialised=!0,ge("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 o=t==="start"?Vt:Wt;this.track(o(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(Qt(this.analyticsContext(),t))}emit(t,...n){this._handlers.get(t)?.forEach(o=>o(...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 o=document.querySelector(t);if(!o)throw new Error(`[gengage] Mount target not found: "${t}"`);return o}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,o]of Object.entries(t))if(o!==void 0){const r=n.startsWith("--")?n:`--gengage-${fn(n)}`;this.root.style.setProperty(r,o)}}}}function fn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Ne(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function hn(e){const t=[];let n=0,o=!1,r=!1,s=0;for(let i=0;i<e.length;i++){const a=e[i];if(r){r=!1;continue}if(a==="\\"&&o){r=!0;continue}if(a==='"'){o=!o;continue}o||(a==="{"&&n++,a==="}"&&(n--,n===0&&(t.push(e.slice(s,i+1)),s=i+1)))}return t.length>0?t:[e]}function je(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const o=n.startsWith("data: ")?n.slice(6):n;if(o==="[DONE]")return t.onDone?.(),!0;try{const r=JSON.parse(o);return Ne(r)?(ge("stream",`event: ${r.type}`,r),t.onEvent(r),r.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const r=hn(o);if(r.length>1){for(const s of r)try{const i=JSON.parse(s);if(!Ne(i))continue;if(t.onEvent(i),i.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function gn(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(),o=new TextDecoder("utf-8");let r="";const s=t.idleTimeoutMs??6e4,i=Symbol("idle-timeout");let a=!1;try{for(;;){const c=n.read();let u;const p=await(s>0?Promise.race([c.then(m=>(clearTimeout(u),m)),new Promise(m=>{u=setTimeout(()=>m(i),s)})]):c);if(p===i){a=!0,await n.cancel();break}const{done:h,value:l}=p;if(h)break;r+=o.decode(l,{stream:!0});const f=r.split(`
47
+ `);r=f.pop()??"";for(const m of f)if(je(m,t))return}if(r.trim()&&je(r,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 _n={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function mn(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 yn(e,t){return`${mn(t?.middlewareUrl)}/chat${_n[e]}`}function vn(e){if(typeof e.type!="string")return null;if(wn(e))return e;const n=e;switch(n.type){case"outputText":return bn(n);case"suggestedActions":return kn(n);case"productList":return zn(n);case"productDetails":return Sn(n);case"productDetailsSimilars":return $n(n);case"comparisonTable":return Tn(n);case"context":return On(n);case"chatStreamEnd":return Zn();case"loading":return Cn(n);case"panelLoading":return Pn(n);case"similarLoading":return Rn(n);case"redirect":return Nn(n);case"error":return jn(n);case"dummy":return Dn();case"launcherAction":return Ln(n);case"text":return _e(n);case"productItem":return xn(n);case"text_image":return De(n);case"quick_qna":return Le(n);case"reviewHighlights":return Un(n);case"aiProductSuggestions":return Mn(n);case"aiProductGroupings":return Jn(n);case"aiSuggestedSearches":return Bn(n);case"prosAndCons":return qn(n);case"getGroundingReview":return Qn(n);case"voice":return Vn(n);case"visitorDataResponse":return Fn(n);case"productListPreview":return Hn();case"groupList":return Wn(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Gn(n);case"launcherContent":return Yn(n);case"handoff":return Kn(n);default:return null}}function wn(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 o=N(e.spec);return o?typeof o.root=="string"&&N(o.elements)!==null:!1}case"action":{const n=N(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 bn(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 o={type:"text_chunk",content:t,final:!0},r=e.payload.product_mentions;Array.isArray(r)&&r.length>0&&(o.productMentions=r.filter(a=>typeof a=="object"&&a!==null&&typeof a.sku=="string"&&typeof a.short_name=="string"));const s=e.payload.sku_to_product_item;s&&typeof s=="object"&&!Array.isArray(s)&&(o.skuToProductItem=s);const i=e.payload.conversation_mode;return typeof i=="string"&&i&&(o.conversationMode=i),o}function kn(e){const t=(e.payload.actions??[]).map(n=>{const o=w(n.title)??"",r=C(n.requestDetails,o),s=r?{label:o,action:r}:null;return s?(typeof n.icon=="string"&&(s.icon=n.icon),typeof n.image=="string"&&(s.image=n.image),s):null});return xe(t.filter(qe),"chat")}function zn(e){const t=Ue(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 Sn(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:B(t)}}}},panelHint:"panel"}:eo("chat")}function $n(e){const t=Ue(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Tn(e){const t=e.payload.multiple_product_details??[],n=e.payload,o={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??{}},r=e.payload.table,s=e.payload.features_list,i=[];for(const v of t){const b=B(v);i.push(b)}const a=En(r,i,o,s);let c;o?.recommended_choice_sku?c=o.recommended_choice_sku:o?.winner_product&&o.winner_product.length>0&&(c=o.winner_product[0]?.product_detail?.sku??o.winner_product[0]?.sku);const u=c?i.find(v=>v.sku===c)??i[0]:i[0],p=[];if(Array.isArray(o?.key_differences))for(const v of o.key_differences)typeof v=="string"&&p.push(v);const h=ro(o?.special_considerations),l=o?.recommended_choice,f=o?.winner_hits,m={};for(const v of i){const b=v.sku;b&&(m[b]={title:v.name??b,type:"launchSingleProduct",payload:{sku:b}})}const _={products:i,attributes:a,highlights:p,productActions:m};return u&&(_.recommended=u),h.length>0&&(_.specialCases=h),l&&(_.recommendedText=l),f&&(_.winnerHits=f),typeof o?.key_differences=="string"&&(_.keyDifferencesHtml=o.key_differences),o?.special_considerations&&(_.specialConsiderations=o.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:_}}},panelHint:"panel"}}function En(e,t,n,o){if(!e)return[];const r=Object.entries(e);if(r.length===0)return[];const s=r[0]?.[1];if(Array.isArray(s)){const l=n.criteria_view??n.criteria_view_short??{},f=n.compared_field_names??Object.keys(e),m=[];for(const _ of f){const v=e[_];if(!v||!Array.isArray(v))continue;const b=l[_]??_;m.push({label:b,values:v.map(E=>typeof E=="string"?E:String(E??""))})}return m}const i=e,a=t.map(l=>String(l.sku??"")).filter(l=>l.length>0),c=n.criteria_view??n.criteria_view_short??{},p=(o&&o.length>0?o:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:An(i)).filter(l=>l!=="name"&&l!=="name_short"&&!l.endsWith("_short")),h=[];for(const l of p){const f=a.map(_=>{const v=i[_];if(!v||typeof v!="object")return"";const b=v[`${l}_short`],E=v[l];return In(b??E)});if(f.every(_=>_.length===0))continue;const m=c[l]??l;h.push({label:m,values:f})}return h}function An(e){const t=[],n=new Set;for(const o of Object.values(e))if(!(!o||typeof o!="object"))for(const r of Object.keys(o))n.has(r)||(n.add(r),t.push(r));return t}function In(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function On(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Zn(){return{type:"done"}}function Cn(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 Pn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Rn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Nn(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 jn(e){return{type:"error",code:"BACKEND_ERROR",message:w(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Dn(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Ln(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const s={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(s.type=i),a!==void 0&&(s.theme=a),Le({payload:s})}const o=N(t.action);if(o){const s={action:o},i=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 i!==void 0&&(s.text=i),a!==void 0&&(s.image_url=a),c!==void 0&&(s.theme=c),De({payload:s})}const r=typeof t.text=="string"?t.text:"";if(r){const s={text:r},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0,c=N(t.payload)??void 0;return i!==void 0&&(s.type=i),c!==void 0&&(s.payload=c),a!==void 0&&(s.theme=a),_e({payload:s})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function _e(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 xn(e){return Xn(e.payload,"qna")}function De(e){const t=w(e.payload.text)??"",n=C(e.payload.action,t);if(n){const 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}}}}}const o={text:t};return typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),_e({payload:o})}function Le(e){const t=(e.payload.action_list??[]).map(n=>{const o=w(n.title)??"",r=C(n.requestDetails,o),s=r?{label:o,action:r}:null;return s?(typeof n.icon=="string"&&(s.icon=n.icon),typeof n.image=="string"&&(s.image=n.image),s):null});return xe(t.filter(qe),"qna")}function Un(e){const n={reviews:(e.payload.reviews??[]).map(o=>{const r={};return typeof o.review_class=="string"&&(r.review_class=o.review_class),typeof o.review_text=="string"&&(r.review_text=o.review_text),(typeof o.review_rating=="string"||typeof o.review_rating=="number")&&(r.review_rating=o.review_rating),typeof o.review_tag=="string"&&(r.review_tag=o.review_tag),r})};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 qn(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function Fn(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Mn(e){const t=e.payload.product_suggestions??[],n=[];for(let o=0;o<t.length;o++){const r=t[o];if(!r)continue;const s=to(r);if(!s)continue;const i={product:s},a=C(r.requestDetails,s.name);a&&(i.action=a),typeof r.role=="string"&&(i.role=r.role),typeof r.reason=="string"&&(i.reason=r.reason),typeof r.review_highlight=="string"&&(i.reviewHighlight=r.review_highlight),Array.isArray(r.labels)&&(i.labels=r.labels),typeof r.expert_quality_score=="number"&&(i.expertQualityScore=r.expert_quality_score),n.push(i)}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 Jn(e){const t=e.payload.product_groupings??[],n=[];for(let o=0;o<t.length;o++){const r=t[o];if(!r)continue;const s=w(r.name)??"",i=r.sku&&r.sku.length>0?{type:"findSimilar",payload:{sku:r.sku}}:void 0,a=C(r.requestDetails??i,s);if(!a)continue;const c={name:s,action:a};if(Array.isArray(r.labels)){const u=r.labels.filter(p=>typeof p=="string");u.length>0&&(c.labels=u)}typeof r.image=="string"&&(c.image=r.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 Bn(e){const t=e.payload.suggested_searches??[],n=[];for(let o=0;o<t.length;o++){const r=t[o];if(!r)continue;const s=w(r.short_name,r.chosen_attribute,r.detailed_user_message)??`Search ${o+1}`,i={},a=w(r.detailed_user_message);a&&(i.text=a);const c=N(r.requestDetails),u=N(c?.payload),p=u?.group_skus;r.group_skus&&Array.isArray(r.group_skus)?i.group_skus=r.group_skus:Array.isArray(p)&&(i.group_skus=p.filter(E=>typeof E=="string"));const h=w(r.sku,r.representative_product_sku,u?.sku);h&&(i.sku=h),i.is_suggested_text=1;const l={type:"inputText",payload:i},f=C(r.requestDetails,s),m=f?.type==="findSimilar"&&typeof i.text=="string"?C(l,s):f??C(l,s);if(!m)continue;const _={shortName:s,action:m},v=w(r.detailed_user_message);v&&v!==s&&(_.detailedMessage=v);const b=w(r.why_different);b&&(_.whyDifferent=b),typeof r.image=="string"&&(_.image=r.image),n.push(_)}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 Qn(e){const t=C(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 Hn(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Vn(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Wn(e){const t=e.payload.group_list??[],n=[];for(const r of t){const s=r.group_name??"",i=(r.product_list??[]).map(B);n.push({groupName:s,products:i})}const o=[];for(const r of e.payload.filter_tags??[]){const s=r.title??"";if(!s)continue;const i=C(r.requestDetails,s),a={title:s};i&&(a.action=i),o.push(a)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:o}}}},panelHint:"panel"}}function Gn(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Kn(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 Yn(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function xe(e,t){const n={},o=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=`action-${r}`;o.push(i);const a={label:s.label,action:s.action};s.icon!==void 0&&(a.icon=s.icon),s.image!==void 0&&(a.image=s.image),s.description!==void 0&&(a.description=s.description),n[i]={type:"ActionButton",props:a}}return n.root={type:"ActionButtons",props:{buttons:e.map(r=>{const s={label:r.label,action:r.action};return r.image!==void 0&&(s.image=r.image),r.description!==void 0&&(s.description=r.description),r.icon!==void 0&&(s.icon=r.icon),s})},children:o},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Ue(e,t){const n={},o=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=`product-${r}`;o.push(i),n[i]={type:"ProductCard",props:{product:B(s),index:r}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:o},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Xn(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:B(e),index:0}}}}}}function eo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function to(e){const t=w(e.sku),n=w(e.short_name),o=N(e.product_item)??e;return no(o,t,n)}function no(e,t,n){const o=w(e.sku,t),r=w(e.name,n);if(!o||!r)return null;const s={sku:o,name:r},i=w(e.brand);i&&(s.brand=i);const a=w(e.url);a&&(s.url=a);const c=oo(e.images);if(c.length>0)s.images=c;else{const m=w(e.image,e.image_url,e.imageUrl);m&&(s.images=[m])}const u=G(e.price_discounted);u!==void 0&&(s.price_discounted=u);const p=G(e.price);p!==void 0&&(s.price=p);const h=G(e.rating);h!==void 0&&(s.rating=h);const l=G(e.review_count)??G(e.reviewCount);l!==void 0&&(s.review_count=l);const f=w(e.cart_code,e.cartCode);return f&&(s.cart_code=f),typeof e.in_stock=="boolean"&&(s.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(s.in_stock=e.inStock),B(s)}function C(e,t){const n=N(e);if(!n)return null;const o=n.type;if(typeof o!="string"||o.length===0)return null;const r={title:t||o,type:o};return n.payload!==void 0&&(r.payload=n.payload),r}function N(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 oo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ro(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 G(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 qe(e){return e!=null}const io=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 B(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,o=t&&e.price!=null?e.price:void 0;let r;o!=null&&n!=null&&o>0&&(r=Math.round((o-n)/o*100));const s=w(e.brand),i=w(e.name)??e.sku,a=s&&!i.toLowerCase().startsWith(s.toLowerCase())?`${s} ${i}`:i,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)),o!=null&&(c.originalPrice=String(o)),r!==void 0&&(c.discountPercent=r),s!==void 0&&(c.brand=s),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 p=e,h={};let l=!1;for(const f of Object.keys(p))io.has(f)||(h[f]=p[f],l=!0);return l&&(c.extras=h),c}async function so(e,t,n){const o=yn("launcher_action",t),r={uiSpecs:[],actions:[]},s={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(s.signal=n);const i=await fetch(o,s);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const a={onEvent:c=>{const u=vn(c);if(u&&(u.type==="ui_spec"&&r.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const p of Object.values(u.spec.elements))if(p.type==="ActionButton"&&p.props?.action){const h=p.props.action;r.actions.push(h)}}}};return n!==void 0&&(a.signal=n),await gn(i,a),r}function ao(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function me(e,t){const n={event:e,...t};ao()&&window.dataLayer.push(n)}function co(e){me("gengage-on-init",{gengage_widget:e})}function uo(e){me("gengage-show",{gengage_widget:e})}function lo(e,t){me("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function Fe(e){const t=document.createElement("div");t.className="gengage-qna-buttons",t.setAttribute("role","group"),t.setAttribute("aria-label",e.quickQuestionsAriaLabel??"Quick questions"),e.orientation==="vertical"&&(t.style.flexDirection="column");for(const n of e.actions){const o=document.createElement("button");o.className="gengage-qna-button",o.textContent=n.title,o.type="button",o.addEventListener("click",()=>{const r={title:n.title,type:n.type};n.payload!==void 0&&(r.payload=n.payload),e.onAction(r)}),t.appendChild(o)}if(e.ctaText||e.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta",n.textContent=e.ctaText??e.defaultCtaText??"Ask something else",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function po(e){const t=document.createElement("div");t.className="gengage-qna-input-wrapper";const n=document.createElement("input");n.type="text",n.className="gengage-qna-input",n.setAttribute("aria-label",e.askQuestionAriaLabel??"Ask a question");const o=Array.isArray(e.placeholders)?e.placeholders:e.placeholders?[e.placeholders]:[e.defaultInputPlaceholder??"Ask a question..."];let r=0;n.placeholder=o[0]??"";let s=null,i=null;o.length>1&&(s=setInterval(()=>{n.classList.add("gengage-qna-input--fade"),i=setTimeout(()=>{r=(r+1)%o.length,n.placeholder=o[r]??"",n.classList.remove("gengage-qna-input--fade")},180)},3e3));const a=document.createElement("button");a.className="gengage-qna-send",a.type="button",a.textContent=e.ctaLabel??e.sendButtonText??"Ask",a.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question");const c=()=>{const u=n.value.trim();u&&(e.onSubmit({title:u,type:"user_message",payload:u}),n.value="")};return a.addEventListener("click",c),n.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),c())}),t.appendChild(n),t.appendChild(a),t._cleanup=()=>{s&&clearInterval(s),i&&clearTimeout(i)},t}function te(e,t){if(!e||typeof e!="object")return null;const n=e,o=n.type;if(typeof o!="string"||o.length===0)return null;const r=n.title,s=n.payload,i=typeof r=="string"&&r.length>0?r:t;if(!i)return null;const a={title:i,type:o};return s!==void 0&&(a.payload=s),a}function Me(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function Je(e,t){const n=[],o=e.props?.actions;if(Array.isArray(o))for(const i of o){const a=te(i);a&&n.push(a)}const r=e.props?.buttons;if(Array.isArray(r))for(const i of r){if(!i||typeof i!="object")continue;const a=i,c=typeof a.label=="string"?a.label:void 0,u=te(a.action,c);u&&n.push(u)}if(e.children)for(const i of e.children){const a=t.elements[i];if(!a||a.type!=="ActionButton")continue;const c=typeof a.props?.label=="string"?a.props.label:void 0,u=te(a.props?.action,c);u&&n.push(u)}const s=new Set;return n.filter(i=>s.has(i.title)?!1:(s.add(i.title),!0))}const Be={ButtonRow:({element:e,spec:t,context:n})=>{const o=Je(e,t).map(Me),r=e.props?.orientation,s={actions:o,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(s.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(s.ctaText=n.ctaText),(r==="horizontal"||r==="vertical")&&(s.orientation=r),Fe(s)},ActionButtons:({element:e,spec:t,context:n})=>{const r={actions:Je(e,t).map(Me),onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(r.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(r.ctaText=n.ctaText),Fe(r)},ActionButton:({element:e,context:t})=>{const n=document.createElement("button");n.className="gengage-qna-button",n.type="button";const o=e.props?.label;typeof o=="string"?n.textContent=o:n.textContent=t.i18n.defaultCtaText;const r=te(e.props?.action,typeof o=="string"?o:void 0);return r&&n.addEventListener("click",()=>t.onAction(r)),n},TextInput:({element:e,context:t})=>{const n=e.props?.placeholder,o=typeof n=="string"||Array.isArray(n)?n:t.inputPlaceholder,r=typeof e.props?.ctaLabel=="string"?e.props.ctaLabel:void 0,s={onSubmit:t.onAction,askQuestionAriaLabel:t.i18n.askQuestionAriaLabel,defaultInputPlaceholder:t.i18n.defaultInputPlaceholder,sendButtonText:t.i18n.sendButton,sendQuestionAriaLabel:t.i18n.sendQuestionAriaLabel};return o!==void 0&&(s.placeholders=o),r!==void 0&&(s.ctaLabel=r),po(s)},QuestionHeading:({element:e})=>{const t=document.createElement("h3");t.className="gengage-qna-heading";const n=e.props?.text;return t.textContent=typeof n=="string"?n:"",t},ProductCard:()=>null},ye=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const o of e.children){const r=t(o);r&&n.appendChild(r)}return n};function Qe(){return{...Be}}function He(e,t,n=Be,o=ye){return qt({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:o})}const Ve={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},fo={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function ho(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function go(e){return ho(e)==="en"?fo:Ve}function d(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,p=Object.keys(u);for(let h=0;h<p.length;h++){const l=p[h];l in a||(a[l]=u[l].bind(a))}}const r=n?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const p of u._zod.deferred)p();return u}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Q extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class We extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ge={};function q(e){return Ge}function Ke(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function ve(e,t){return typeof t=="bigint"?t.toString():t}function we(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function be(e){return e==null}function ke(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Ye=Symbol("evaluating");function y(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Ye)return o===void 0&&(o=Ye,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function F(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function D(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function Xe(e){return JSON.stringify(e)}function _o(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ne(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const mo=we(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function K(e){if(ne(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ne(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function tt(e){return K(e)?{...e}:Array.isArray(e)?[...e]:e}const yo=new Set(["string","number","symbol"]);function oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function g(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 vo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function wo(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=D(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return F(this,"shape",i),i},checks:[]});return L(e,s)}function bo(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=D(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return F(this,"shape",i),i},checks:[]});return L(e,s)}function ko(e,t){if(!K(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=D(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return F(this,"shape",s),s}});return L(e,r)}function zo(e,t){if(!K(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=D(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return F(this,"shape",o),o}});return L(e,n)}function So(e,t){const n=D(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return F(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return L(e,n)}function $o(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=D(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 F(this,"shape",c),c},checks:[]});return L(t,i)}function To(e,t,n){const o=D(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return F(this,"shape",s),s}});return L(t,o)}function H(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 nt(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function re(e){return typeof e=="string"?e:e?.message}function M(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const r=re(e.inst?._zod.def?.error?.(e))??re(t?.error?.(e))??re(n.customError?.(e))??re(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function ze(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Y(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const ot=(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,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},rt=d("$ZodError",ot),it=d("$ZodError",ot,{Parent:Error});function Eo(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Ao(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>o({issues:i}));else if(s.code==="invalid_key")o({issues:s.issues});else if(s.code==="invalid_element")o({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return o(e),n}const Se=e=>(t,n,o,r)=>{const s=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Q;if(i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>M(c,s,q())));throw et(a,r?.callee),a}return i.value},$e=e=>async(t,n,o,r)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>M(c,s,q())));throw et(a,r?.callee),a}return i.value},ie=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Q;return s.issues.length?{success:!1,error:new(e??rt)(s.issues.map(i=>M(i,r,q())))}:{success:!0,data:s.value}},Io=ie(it),se=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>M(i,r,q())))}:{success:!0,data:s.value}},Oo=se(it),Zo=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Se(e)(t,n,r)},Co=e=>(t,n,o)=>Se(e)(t,n,o),Po=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return $e(e)(t,n,r)},Ro=e=>async(t,n,o)=>$e(e)(t,n,o),No=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ie(e)(t,n,r)},jo=e=>(t,n,o)=>ie(e)(t,n,o),Do=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return se(e)(t,n,r)},Lo=e=>async(t,n,o)=>se(e)(t,n,o),xo=/^[cC][^\s-]{8,}$/,Uo=/^[0-9a-z]+$/,qo=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Fo=/^[0-9a-vA-V]{20}$/,Mo=/^[A-Za-z0-9]{27}$/,Jo=/^[a-zA-Z0-9_-]{21}$/,Bo=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qo=/^([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})$/,st=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)$/,Ho=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Vo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Wo(){return new RegExp(Vo,"u")}const Go=/^(?:(?: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])$/,Ko=/^(([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}|:))$/,Yo=/^((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])$/,Xo=/^(([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])$/,er=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,at=/^[A-Za-z0-9_-]*$/,tr=/^\+[1-9]\d{6,14}$/,ct="(?:(?:\\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])))",nr=new RegExp(`^${ct}$`);function ut(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 or(e){return new RegExp(`^${ut(e)}$`)}function rr(e){const t=ut({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${ct}T(?:${o})$`)}const ir=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},sr=/^(?:true|false)$/i,ar=/^[^A-Z]*$/,cr=/^[^a-z]*$/,P=d("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ur=d("$ZodCheckMaxLength",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!be(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const i=ze(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),dr=d("$ZodCheckMinLength",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!be(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const i=ze(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lr=d("$ZodCheckLengthEquals",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!be(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,s=r.length;if(s===t.length)return;const i=ze(r),a=s>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),ae=d("$ZodCheckStringFormat",(e,t)=>{var n,o;P.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),pr=d("$ZodCheckRegex",(e,t)=>{ae.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})}}),fr=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ar),ae.init(e,t)}),hr=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cr),ae.init(e,t)}),gr=d("$ZodCheckIncludes",(e,t)=>{P.init(e,t);const n=oe(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),_r=d("$ZodCheckStartsWith",(e,t)=>{P.init(e,t);const n=new RegExp(`^${oe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),mr=d("$ZodCheckEndsWith",(e,t)=>{P.init(e,t);const n=new RegExp(`.*${oe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),yr=d("$ZodCheckOverwrite",(e,t)=>{P.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class vr{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 o=t.split(`
48
48
  `).filter(i=>i),r=Math.min(...o.map(i=>i.length-i.trimStart().length)),s=o.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,r.join(`
49
- `))}}const wr={major:4,minor:3,patch:6},S=d("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=wr;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const r of o)for(const s of r._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(i,a,c)=>{let u=H(i),l;for(const h of a){if(h._zod.def.when){if(!h._zod.def.when(i))continue}else if(u)continue;const p=i.issues.length,f=h._zod.check(i);if(f instanceof Promise&&c?.async===!1)throw new Q;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,i.issues.length!==p&&(u||(u=H(i,p)))});else{if(i.issues.length===p)continue;u||(u=H(i,p))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(H(i))return i.aborted=!0,i;const u=r(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new Q;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,i,a)):s(u,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new Q;return c.then(u=>r(u,o,a))}return r(c,o,a)}}y(e,"~standard",()=>({validate:r=>{try{const s=Io(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Oo(e,r).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Te=d("$ZodString",(e,t)=>{S.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ir(e._zod.bag),e._zod.parse=(n,o)=>{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=d("$ZodStringFormat",(e,t)=>{ae.init(e,t),Te.init(e,t)}),br=d("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Qo),k.init(e,t)}),kr=d("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=st(o))}else t.pattern??(t.pattern=st());k.init(e,t)}),zr=d("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ho),k.init(e,t)}),Sr=d("$ZodURL",(e,t)=>{k.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.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(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.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=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),$r=d("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Wo()),k.init(e,t)}),Tr=d("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Jo),k.init(e,t)}),Er=d("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xo),k.init(e,t)}),Ar=d("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Uo),k.init(e,t)}),Ir=d("$ZodULID",(e,t)=>{t.pattern??(t.pattern=qo),k.init(e,t)}),Or=d("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Fo),k.init(e,t)}),Zr=d("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Mo),k.init(e,t)}),Cr=d("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=rr(t)),k.init(e,t)}),Pr=d("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nr),k.init(e,t)}),Rr=d("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=or(t)),k.init(e,t)}),Nr=d("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Bo),k.init(e,t)}),jr=d("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Go),k.init(e,t),e._zod.bag.format="ipv4"}),Dr=d("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ko),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})}}}),Lr=d("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Yo),k.init(e,t)}),xr=d("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Xo),k.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,s]=o;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function dt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ur=d("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=er),k.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{dt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function qr(e){if(!at.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dt(n)}const Fr=d("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=at),k.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{qr(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Mr=d("$ZodE164",(e,t)=>{t.pattern??(t.pattern=tr),k.init(e,t)});function Jr(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const Br=d("$ZodJWT",(e,t)=>{k.init(e,t),e._zod.check=n=>{Jr(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Qr=d("$ZodBoolean",(e,t)=>{S.init(e,t),e._zod.pattern=sr,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Hr=d("$ZodUnknown",(e,t)=>{S.init(e,t),e._zod.parse=n=>n}),Vr=d("$ZodNever",(e,t)=>{S.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function lt(e,t,n){e.issues.length&&t.issues.push(...nt(n,e.issues)),t.value[n]=e.value}const Wr=d("$ZodArray",(e,t)=>{S.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const s=[];for(let i=0;i<r.length;i++){const a=r[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?s.push(c.then(u=>lt(u,n,i))):lt(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function ce(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...nt(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function pt(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=vo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ft(e,t,n,o,r,s){const i=[],a=r.keySet,c=r.catchall._zod,u=c.def.type,l=c.optout==="optional";for(const h in t){if(a.has(h))continue;if(u==="never"){i.push(h);continue}const p=c.run({value:t[h],issues:[]},o);p instanceof Promise?e.push(p.then(f=>ce(f,n,h,t,l))):ce(p,n,h,t,l)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Gr=d("$ZodObject",(e,t)=>{if(S.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 o=we(()=>pt(t));y(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(const h of l.values)c[u].add(h)}}return c});const r=ne,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=o.value);const u=a.value;if(!r(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const l=[],h=i.shape;for(const p of i.keys){const f=h[p],_=f._zod.optout==="optional",m=f._zod.run({value:u[p],issues:[]},c);m instanceof Promise?l.push(m.then(v=>ce(v,a,p,u,_))):ce(m,a,p,u,_)}return s?ft(l,u,a,c,o.value,e):l.length?Promise.all(l).then(()=>a):a}}),Kr=d("$ZodObjectJIT",(e,t)=>{Gr.init(e,t);const n=e._zod.parse,o=we(()=>pt(t)),r=p=>{const f=new vr(["shape","payload","ctx"]),_=o.value,m=R=>{const A=Xe(R);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};f.write("const input = payload.value;");const v=Object.create(null);let b=0;for(const R of _.keys)v[R]=`key_${b++}`;f.write("const newResult = {};");for(const R of _.keys){const A=v[R],Z=Xe(R),Fa=p[R]?._zod?.optout==="optional";f.write(`const ${A} = ${m(R)};`),Fa?f.write(`
50
- if (${A}.issues.length) {
49
+ `))}}const wr={major:4,minor:3,patch:6},S=d("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=wr;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const r of o)for(const s of r._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(i,a,c)=>{let u=H(i),p;for(const h of a){if(h._zod.def.when){if(!h._zod.def.when(i))continue}else if(u)continue;const l=i.issues.length,f=h._zod.check(i);if(f instanceof Promise&&c?.async===!1)throw new Q;if(p||f instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await f,i.issues.length!==l&&(u||(u=H(i,l)))});else{if(i.issues.length===l)continue;u||(u=H(i,l))}}return p?p.then(()=>i):i},s=(i,a,c)=>{if(H(i))return i.aborted=!0,i;const u=r(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new Q;return u.then(p=>e._zod.parse(p,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(p=>s(p,i,a)):s(u,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new Q;return c.then(u=>r(u,o,a))}return r(c,o,a)}}y(e,"~standard",()=>({validate:r=>{try{const s=Io(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Oo(e,r).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Te=d("$ZodString",(e,t)=>{S.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ir(e._zod.bag),e._zod.parse=(n,o)=>{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=d("$ZodStringFormat",(e,t)=>{ae.init(e,t),Te.init(e,t)}),br=d("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Qo),k.init(e,t)}),kr=d("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=st(o))}else t.pattern??(t.pattern=st());k.init(e,t)}),zr=d("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ho),k.init(e,t)}),Sr=d("$ZodURL",(e,t)=>{k.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.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(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.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=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),$r=d("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Wo()),k.init(e,t)}),Tr=d("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Jo),k.init(e,t)}),Er=d("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xo),k.init(e,t)}),Ar=d("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Uo),k.init(e,t)}),Ir=d("$ZodULID",(e,t)=>{t.pattern??(t.pattern=qo),k.init(e,t)}),Or=d("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Fo),k.init(e,t)}),Zr=d("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Mo),k.init(e,t)}),Cr=d("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=rr(t)),k.init(e,t)}),Pr=d("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nr),k.init(e,t)}),Rr=d("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=or(t)),k.init(e,t)}),Nr=d("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Bo),k.init(e,t)}),jr=d("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Go),k.init(e,t),e._zod.bag.format="ipv4"}),Dr=d("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ko),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})}}}),Lr=d("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Yo),k.init(e,t)}),xr=d("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Xo),k.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,s]=o;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function dt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ur=d("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=er),k.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{dt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function qr(e){if(!at.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dt(n)}const Fr=d("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=at),k.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{qr(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Mr=d("$ZodE164",(e,t)=>{t.pattern??(t.pattern=tr),k.init(e,t)});function Jr(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const Br=d("$ZodJWT",(e,t)=>{k.init(e,t),e._zod.check=n=>{Jr(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Qr=d("$ZodBoolean",(e,t)=>{S.init(e,t),e._zod.pattern=sr,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Hr=d("$ZodUnknown",(e,t)=>{S.init(e,t),e._zod.parse=n=>n}),Vr=d("$ZodNever",(e,t)=>{S.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function lt(e,t,n){e.issues.length&&t.issues.push(...nt(n,e.issues)),t.value[n]=e.value}const Wr=d("$ZodArray",(e,t)=>{S.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const s=[];for(let i=0;i<r.length;i++){const a=r[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?s.push(c.then(u=>lt(u,n,i))):lt(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function ce(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...nt(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function pt(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=vo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ft(e,t,n,o,r,s){const i=[],a=r.keySet,c=r.catchall._zod,u=c.def.type,p=c.optout==="optional";for(const h in t){if(a.has(h))continue;if(u==="never"){i.push(h);continue}const l=c.run({value:t[h],issues:[]},o);l instanceof Promise?e.push(l.then(f=>ce(f,n,h,t,p))):ce(l,n,h,t,p)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Gr=d("$ZodObject",(e,t)=>{if(S.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 o=we(()=>pt(t));y(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const p=a[u]._zod;if(p.values){c[u]??(c[u]=new Set);for(const h of p.values)c[u].add(h)}}return c});const r=ne,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=o.value);const u=a.value;if(!r(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const p=[],h=i.shape;for(const l of i.keys){const f=h[l],m=f._zod.optout==="optional",_=f._zod.run({value:u[l],issues:[]},c);_ instanceof Promise?p.push(_.then(v=>ce(v,a,l,u,m))):ce(_,a,l,u,m)}return s?ft(p,u,a,c,o.value,e):p.length?Promise.all(p).then(()=>a):a}}),Kr=d("$ZodObjectJIT",(e,t)=>{Gr.init(e,t);const n=e._zod.parse,o=we(()=>pt(t)),r=l=>{const f=new vr(["shape","payload","ctx"]),m=o.value,_=R=>{const I=Xe(R);return`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`};f.write("const input = payload.value;");const v=Object.create(null);let b=0;for(const R of m.keys)v[R]=`key_${b++}`;f.write("const newResult = {};");for(const R of m.keys){const I=v[R],Z=Xe(R),Fa=l[R]?._zod?.optout==="optional";f.write(`const ${I} = ${_(R)};`),Fa?f.write(`
50
+ if (${I}.issues.length) {
51
51
  if (${Z} in input) {
52
- payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
52
+ payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
53
53
  ...iss,
54
54
  path: iss.path ? [${Z}, ...iss.path] : [${Z}]
55
55
  })));
56
56
  }
57
57
  }
58
58
 
59
- if (${A}.value === undefined) {
59
+ if (${I}.value === undefined) {
60
60
  if (${Z} in input) {
61
61
  newResult[${Z}] = undefined;
62
62
  }
63
63
  } else {
64
- newResult[${Z}] = ${A}.value;
64
+ newResult[${Z}] = ${I}.value;
65
65
  }
66
66
 
67
67
  `):f.write(`
68
- if (${A}.issues.length) {
69
- payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
68
+ if (${I}.issues.length) {
69
+ payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
70
70
  ...iss,
71
71
  path: iss.path ? [${Z}, ...iss.path] : [${Z}]
72
72
  })));
73
73
  }
74
74
 
75
- if (${A}.value === undefined) {
75
+ if (${I}.value === undefined) {
76
76
  if (${Z} in input) {
77
77
  newResult[${Z}] = undefined;
78
78
  }
79
79
  } else {
80
- newResult[${Z}] = ${A}.value;
80
+ newResult[${Z}] = ${I}.value;
81
81
  }
82
82
 
83
- `)}f.write("payload.value = newResult;"),f.write("return payload;");const O=f.compile();return(R,A)=>O(p,R,A)};let s;const i=ne,a=!Ge.jitless,u=a&&_o.value,l=t.catchall;let h;e._zod.parse=(p,f)=>{h??(h=o.value);const _=p.value;return i(_)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=r(t.shape)),p=s(p,f),l?ft([],_,p,f,h,e):p):n(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),p)}});function ht(e,t,n,o){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const r=e.filter(s=>!H(s));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>M(i,o,q())))}),t)}const Yr=d("$ZodUnion",(e,t)=>{S.init(e,t),y(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),y(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),y(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),y(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>ke(s.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,s)=>{if(n)return o(r,s);let i=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},s);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>ht(c,r,e,s)):ht(a,r,e,s)}}),Xr=d("$ZodIntersection",(e,t)=>{S.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,s=t.left._zod.run({value:r,issues:[]},o),i=t.right._zod.run({value:r,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>gt(n,c,u)):gt(n,s,i)}});function Ee(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(K(e)&&K(t)){const n=Object.keys(t),o=Object.keys(e).filter(s=>n.indexOf(s)!==-1),r={...e,...t};for(const s of o){const i=Ee(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const r=e[o],s=t[o],i=Ee(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function gt(e,t,n){const o=new Map;let r;for(const a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(const c of a.keys)o.has(c)||o.set(c,{}),o.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)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);const s=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&r&&e.issues.push({...r,keys:s}),H(e))return e;const i=Ee(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const ei=d("$ZodEnum",(e,t)=>{S.init(e,t);const n=Ke(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>yo.has(typeof r)).map(r=>typeof r=="string"?oe(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return o.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),ti=d("$ZodTransform",(e,t)=>{S.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new We(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(n.value=i,n));if(r instanceof Promise)throw new Q;return n.value=r,n}});function mt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const _t=d("$ZodOptional",(e,t)=>{S.init(e,t),e._zod.optin="optional",e._zod.optout="optional",y(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),y(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ke(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>mt(s,n.value)):mt(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),ni=d("$ZodExactOptional",(e,t)=>{_t.init(e,t),y(e._zod,"values",()=>t.innerType._zod.values),y(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),oi=d("$ZodNullable",(e,t)=>{S.init(e,t),y(e._zod,"optin",()=>t.innerType._zod.optin),y(e._zod,"optout",()=>t.innerType._zod.optout),y(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ke(n.source)}|null)$`):void 0}),y(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),ri=d("$ZodDefault",(e,t)=>{S.init(e,t),e._zod.optin="optional",y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>yt(s,t)):yt(r,t)}});function yt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ii=d("$ZodPrefault",(e,t)=>{S.init(e,t),e._zod.optin="optional",y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),si=d("$ZodNonOptional",(e,t)=>{S.init(e,t),y(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>vt(s,e)):vt(r,e)}});function vt(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 ai=d("$ZodCatch",(e,t)=>{S.init(e,t),y(e._zod,"optin",()=>t.innerType._zod.optin),y(e._zod,"optout",()=>t.innerType._zod.optout),y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>M(i,o,q()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>M(s,o,q()))},input:n.value}),n.issues=[]),n)}}),ci=d("$ZodPipe",(e,t)=>{S.init(e,t),y(e._zod,"values",()=>t.in._zod.values),y(e._zod,"optin",()=>t.in._zod.optin),y(e._zod,"optout",()=>t.out._zod.optout),y(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const s=t.out._zod.run(n,o);return s instanceof Promise?s.then(i=>ue(i,t.in,o)):ue(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>ue(s,t.out,o)):ue(r,t.out,o)}});function ue(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ui=d("$ZodReadonly",(e,t)=>{S.init(e,t),y(e._zod,"propValues",()=>t.innerType._zod.propValues),y(e._zod,"values",()=>t.innerType._zod.values),y(e._zod,"optin",()=>t.innerType?._zod?.optin),y(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(wt):wt(r)}});function wt(e){return e.value=Object.freeze(e.value),e}const di=d("$ZodCustom",(e,t)=>{P.init(e,t),S.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(s=>bt(s,n,o,e));bt(r,n,o,e)}});function bt(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(Y(r))}}var kt;class li{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.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 o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function pi(){return new li}(kt=globalThis).__zod_globalRegistry??(kt.__zod_globalRegistry=pi());const X=globalThis.__zod_globalRegistry;function fi(e,t){return new e({type:"string",...g(t)})}function hi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function zt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function gi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function mi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function _i(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function yi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function vi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function wi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function bi(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function ki(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function zi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function Si(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function $i(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function Ti(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function Ei(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function Ai(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function Ii(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function Oi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function Zi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function Ci(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function Pi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function Ri(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function Ni(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function ji(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Di(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function Li(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function xi(e,t){return new e({type:"boolean",...g(t)})}function Ui(e){return new e({type:"unknown"})}function qi(e,t){return new e({type:"never",...g(t)})}function St(e,t){return new ur({check:"max_length",...g(t),maximum:e})}function de(e,t){return new dr({check:"min_length",...g(t),minimum:e})}function $t(e,t){return new lr({check:"length_equals",...g(t),length:e})}function Fi(e,t){return new pr({check:"string_format",format:"regex",...g(t),pattern:e})}function Mi(e){return new fr({check:"string_format",format:"lowercase",...g(e)})}function Ji(e){return new hr({check:"string_format",format:"uppercase",...g(e)})}function Bi(e,t){return new gr({check:"string_format",format:"includes",...g(t),includes:e})}function Qi(e,t){return new mr({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Hi(e,t){return new _r({check:"string_format",format:"ends_with",...g(t),suffix:e})}function V(e){return new yr({check:"overwrite",tx:e})}function Vi(e){return V(t=>t.normalize(e))}function Wi(){return V(e=>e.trim())}function Gi(){return V(e=>e.toLowerCase())}function Ki(){return V(e=>e.toUpperCase())}function Yi(){return V(e=>mo(e))}function Xi(e,t,n){return new e({type:"array",element:t,...g(n)})}function es(e,t,n){return new e({type:"custom",check:"custom",fn:t,...g(n)})}function ts(e){const t=ns(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Y(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(Y(r))}},e(n.value,n)));return t}function ns(e,t){const n=new P({check:"custom",...g(t)});return n._zod.check=e,n}function Tt(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??X,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 T(e,t,n={path:[],schemaPath:[]}){var o;const r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{const p=i.schema,f=t.processors[r.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,p,l)}const h=e._zod.parent;h&&(i.ref||(i.ref=h),T(h,t,l),t.seen.get(h).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&E(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Et(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=o.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,i[0])}}const r=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const h=e.external.registry.get(i[0])?.id,p=e.external.uri??(_=>_);if(h)return{ref:p(h)};const f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(i[1]===n)return{ref:"#"};const u=`#/${a}/`,l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},s=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:u}=r(i);a.def={...a.schema},u&&(a.defId=u);const l=a.schema;for(const h in l)delete l[h];l.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
83
+ `)}f.write("payload.value = newResult;"),f.write("return payload;");const E=f.compile();return(R,I)=>E(l,R,I)};let s;const i=ne,a=!Ge.jitless,u=a&&mo.value,p=t.catchall;let h;e._zod.parse=(l,f)=>{h??(h=o.value);const m=l.value;return i(m)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=r(t.shape)),l=s(l,f),p?ft([],m,l,f,h,e):l):n(l,f):(l.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),l)}});function ht(e,t,n,o){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const r=e.filter(s=>!H(s));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>M(i,o,q())))}),t)}const Yr=d("$ZodUnion",(e,t)=>{S.init(e,t),y(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),y(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),y(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),y(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>ke(s.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,s)=>{if(n)return o(r,s);let i=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},s);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>ht(c,r,e,s)):ht(a,r,e,s)}}),Xr=d("$ZodIntersection",(e,t)=>{S.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,s=t.left._zod.run({value:r,issues:[]},o),i=t.right._zod.run({value:r,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>gt(n,c,u)):gt(n,s,i)}});function Ee(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(K(e)&&K(t)){const n=Object.keys(t),o=Object.keys(e).filter(s=>n.indexOf(s)!==-1),r={...e,...t};for(const s of o){const i=Ee(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const r=e[o],s=t[o],i=Ee(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function gt(e,t,n){const o=new Map;let r;for(const a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(const c of a.keys)o.has(c)||o.set(c,{}),o.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)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);const s=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&r&&e.issues.push({...r,keys:s}),H(e))return e;const i=Ee(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const ei=d("$ZodEnum",(e,t)=>{S.init(e,t);const n=Ke(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>yo.has(typeof r)).map(r=>typeof r=="string"?oe(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return o.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),ti=d("$ZodTransform",(e,t)=>{S.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new We(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(n.value=i,n));if(r instanceof Promise)throw new Q;return n.value=r,n}});function _t(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const mt=d("$ZodOptional",(e,t)=>{S.init(e,t),e._zod.optin="optional",e._zod.optout="optional",y(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),y(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ke(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>_t(s,n.value)):_t(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),ni=d("$ZodExactOptional",(e,t)=>{mt.init(e,t),y(e._zod,"values",()=>t.innerType._zod.values),y(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),oi=d("$ZodNullable",(e,t)=>{S.init(e,t),y(e._zod,"optin",()=>t.innerType._zod.optin),y(e._zod,"optout",()=>t.innerType._zod.optout),y(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ke(n.source)}|null)$`):void 0}),y(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),ri=d("$ZodDefault",(e,t)=>{S.init(e,t),e._zod.optin="optional",y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>yt(s,t)):yt(r,t)}});function yt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ii=d("$ZodPrefault",(e,t)=>{S.init(e,t),e._zod.optin="optional",y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),si=d("$ZodNonOptional",(e,t)=>{S.init(e,t),y(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>vt(s,e)):vt(r,e)}});function vt(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 ai=d("$ZodCatch",(e,t)=>{S.init(e,t),y(e._zod,"optin",()=>t.innerType._zod.optin),y(e._zod,"optout",()=>t.innerType._zod.optout),y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>M(i,o,q()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>M(s,o,q()))},input:n.value}),n.issues=[]),n)}}),ci=d("$ZodPipe",(e,t)=>{S.init(e,t),y(e._zod,"values",()=>t.in._zod.values),y(e._zod,"optin",()=>t.in._zod.optin),y(e._zod,"optout",()=>t.out._zod.optout),y(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const s=t.out._zod.run(n,o);return s instanceof Promise?s.then(i=>ue(i,t.in,o)):ue(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>ue(s,t.out,o)):ue(r,t.out,o)}});function ue(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ui=d("$ZodReadonly",(e,t)=>{S.init(e,t),y(e._zod,"propValues",()=>t.innerType._zod.propValues),y(e._zod,"values",()=>t.innerType._zod.values),y(e._zod,"optin",()=>t.innerType?._zod?.optin),y(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(wt):wt(r)}});function wt(e){return e.value=Object.freeze(e.value),e}const di=d("$ZodCustom",(e,t)=>{P.init(e,t),S.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(s=>bt(s,n,o,e));bt(r,n,o,e)}});function bt(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(Y(r))}}var kt;class li{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.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 o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function pi(){return new li}(kt=globalThis).__zod_globalRegistry??(kt.__zod_globalRegistry=pi());const X=globalThis.__zod_globalRegistry;function fi(e,t){return new e({type:"string",...g(t)})}function hi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function zt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function gi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function _i(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function mi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function yi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function vi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function wi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function bi(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function ki(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function zi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function Si(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function $i(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function Ti(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function Ei(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function Ai(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function Ii(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function Oi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function Zi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function Ci(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function Pi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function Ri(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function Ni(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function ji(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Di(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function Li(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function xi(e,t){return new e({type:"boolean",...g(t)})}function Ui(e){return new e({type:"unknown"})}function qi(e,t){return new e({type:"never",...g(t)})}function St(e,t){return new ur({check:"max_length",...g(t),maximum:e})}function de(e,t){return new dr({check:"min_length",...g(t),minimum:e})}function $t(e,t){return new lr({check:"length_equals",...g(t),length:e})}function Fi(e,t){return new pr({check:"string_format",format:"regex",...g(t),pattern:e})}function Mi(e){return new fr({check:"string_format",format:"lowercase",...g(e)})}function Ji(e){return new hr({check:"string_format",format:"uppercase",...g(e)})}function Bi(e,t){return new gr({check:"string_format",format:"includes",...g(t),includes:e})}function Qi(e,t){return new _r({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Hi(e,t){return new mr({check:"string_format",format:"ends_with",...g(t),suffix:e})}function V(e){return new yr({check:"overwrite",tx:e})}function Vi(e){return V(t=>t.normalize(e))}function Wi(){return V(e=>e.trim())}function Gi(){return V(e=>e.toLowerCase())}function Ki(){return V(e=>e.toUpperCase())}function Yi(){return V(e=>_o(e))}function Xi(e,t,n){return new e({type:"array",element:t,...g(n)})}function es(e,t,n){return new e({type:"custom",check:"custom",fn:t,...g(n)})}function ts(e){const t=ns(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Y(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(Y(r))}},e(n.value,n)));return t}function ns(e,t){const n=new P({check:"custom",...g(t)});return n._zod.check=e,n}function Tt(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??X,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 T(e,t,n={path:[],schemaPath:[]}){var o;const r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,p);else{const l=i.schema,f=t.processors[r.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,l,p)}const h=e._zod.parent;h&&(i.ref||(i.ref=h),T(h,t,p),t.seen.get(h).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&A(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Et(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=o.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,i[0])}}const r=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const h=e.external.registry.get(i[0])?.id,l=e.external.uri??(m=>m);if(h)return{ref:l(h)};const f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${l("__shared")}#/${a}/${f}`}}if(i[1]===n)return{ref:"#"};const u=`#/${a}/`,p=i[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+p}},s=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:u}=r(i);a.def={...a.schema},u&&(a.defId=u);const p=a.schema;for(const h in p)delete p[h];p.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
84
84
 
85
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function At(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=i=>{const a=e.seen.get(i);if(a.ref===null)return;const c=a.def??a.schema,u={...c},l=a.ref;if(a.ref=null,l){o(l);const p=e.seen.get(l),f=p.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Object.assign(c,f),Object.assign(c,u),i._zod.parent===l)for(const m in c)m==="$ref"||m==="allOf"||m in u||delete c[m];if(f.$ref&&p.def)for(const m in c)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(c[m])===JSON.stringify(p.def[m])&&delete c[m]}const h=i._zod.parent;if(h&&h!==l){o(h);const p=e.seen.get(h);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(const f in c)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(c[f])===JSON.stringify(p.def[f])&&delete c[f]}e.override({zodSchema:i,jsonSchema:c,path:a.path??[]})};for(const i of[...e.seen.entries()].reverse())o(i[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(i)}Object.assign(r,n.def??n.schema);const s=e.external?.defs??{};for(const i of e.seen.entries()){const a=i[1];a.def&&a.defId&&(s[a.defId]=a.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{const i=JSON.parse(JSON.stringify(r));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:le(t,"input",e.processors),output:le(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function E(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return E(o.element,n);if(o.type==="set")return E(o.valueType,n);if(o.type==="lazy")return E(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return E(o.innerType,n);if(o.type==="intersection")return E(o.left,n)||E(o.right,n);if(o.type==="record"||o.type==="map")return E(o.keyType,n)||E(o.valueType,n);if(o.type==="pipe")return E(o.in,n)||E(o.out,n);if(o.type==="object"){for(const r in o.shape)if(E(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(E(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(E(r,n))return!0;return!!(o.rest&&E(o.rest,n))}return!1}const os=(e,t={})=>n=>{const o=Tt({...n,processors:t});return T(e,o),Et(o,e),At(o,e)},le=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=Tt({...r??{},target:s,io:t,processors:n});return T(e,i),Et(i,e),At(i,e)},rs={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},is=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof i=="number"&&(r.maxLength=i),a&&(r.format=rs[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const l=[...c];l.length===1?r.pattern=l[0].source:l.length>1&&(r.allOf=[...l.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},ss=(e,t,n,o)=>{n.type="boolean"},as=(e,t,n,o)=>{n.not={}},cs=(e,t,n,o)=>{},us=(e,t,n,o)=>{const r=e._zod.def,s=Ke(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},ds=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ls=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ps=(e,t,n,o)=>{const r=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(r.minItems=i),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=T(s.element,t,{...o,path:[...o.path,"items"]})},fs=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="object",r.properties={};const i=s.shape;for(const u in i)r.properties[u]=T(i[u],t,{...o,path:[...o.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{const l=s.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(r.required=Array.from(c)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=T(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},hs=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((a,c)=>T(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},gs=(e,t,n,o)=>{const r=e._zod.def,s=T(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=T(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},ms=(e,t,n,o)=>{const r=e._zod.def,s=T(r.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},_s=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},ys=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},vs=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},ws=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},bs=(e,t,n,o)=>{const r=e._zod.def,s=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;T(s,t,o);const i=t.seen.get(e);i.ref=s},ks=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},It=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},zs=d("ZodISODateTime",(e,t)=>{Cr.init(e,t),z.init(e,t)});function Ss(e){return Ni(zs,e)}const $s=d("ZodISODate",(e,t)=>{Pr.init(e,t),z.init(e,t)});function Ts(e){return ji($s,e)}const Es=d("ZodISOTime",(e,t)=>{Rr.init(e,t),z.init(e,t)});function As(e){return Di(Es,e)}const Is=d("ZodISODuration",(e,t)=>{Nr.init(e,t),z.init(e,t)});function Os(e){return Li(Is,e)}const I=d("ZodError",(e,t)=>{rt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Ao(e,n)},flatten:{value:n=>Eo(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ve,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ve,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Zs=Se(I),Cs=$e(I),Ps=ie(I),Rs=se(I),Ns=Zo(I),js=Co(I),Ds=Po(I),Ls=Ro(I),xs=No(I),Us=jo(I),qs=Do(I),Fs=Lo(I),$=d("ZodType",(e,t)=>(S.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:le(e,"input"),output:le(e,"output")}}),e.toJSONSchema=os(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(D(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>L(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>Zs(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Ps(e,n,o),e.parseAsync=async(n,o)=>Cs(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>Rs(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>Ns(e,n,o),e.decode=(n,o)=>js(e,n,o),e.encodeAsync=async(n,o)=>Ds(e,n,o),e.decodeAsync=async(n,o)=>Ls(e,n,o),e.safeEncode=(n,o)=>xs(e,n,o),e.safeDecode=(n,o)=>Us(e,n,o),e.safeEncodeAsync=async(n,o)=>qs(e,n,o),e.safeDecodeAsync=async(n,o)=>Fs(e,n,o),e.refine=(n,o)=>e.check(Pa(n,o)),e.superRefine=n=>e.check(Ra(n)),e.overwrite=n=>e.check(V(n)),e.optional=()=>Nt(e),e.exactOptional=()=>wa(e),e.nullable=()=>jt(e),e.nullish=()=>Nt(jt(e)),e.nonoptional=n=>Ta(e,n),e.array=()=>Ct(e),e.or=n=>Pt([e,n]),e.and=n=>ma(e,n),e.transform=n=>Lt(e,ya(n)),e.default=n=>za(e,n),e.prefault=n=>$a(e,n),e.catch=n=>Aa(e,n),e.pipe=n=>Lt(e,n),e.readonly=()=>Za(e),e.describe=n=>{const o=e.clone();return X.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return X.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return X.get(e);const o=e.clone();return X.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Ot=d("_ZodString",(e,t)=>{Te.init(e,t),$.init(e,t),e._zod.processJSONSchema=(o,r,s)=>is(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(Fi(...o)),e.includes=(...o)=>e.check(Bi(...o)),e.startsWith=(...o)=>e.check(Qi(...o)),e.endsWith=(...o)=>e.check(Hi(...o)),e.min=(...o)=>e.check(de(...o)),e.max=(...o)=>e.check(St(...o)),e.length=(...o)=>e.check($t(...o)),e.nonempty=(...o)=>e.check(de(1,...o)),e.lowercase=o=>e.check(Mi(o)),e.uppercase=o=>e.check(Ji(o)),e.trim=()=>e.check(Wi()),e.normalize=(...o)=>e.check(Vi(...o)),e.toLowerCase=()=>e.check(Gi()),e.toUpperCase=()=>e.check(Ki()),e.slugify=()=>e.check(Yi())}),Ms=d("ZodString",(e,t)=>{Te.init(e,t),Ot.init(e,t),e.email=n=>e.check(hi(Js,n)),e.url=n=>e.check(vi(Bs,n)),e.jwt=n=>e.check(Ri(sa,n)),e.emoji=n=>e.check(wi(Qs,n)),e.guid=n=>e.check(zt(Zt,n)),e.uuid=n=>e.check(gi(pe,n)),e.uuidv4=n=>e.check(mi(pe,n)),e.uuidv6=n=>e.check(_i(pe,n)),e.uuidv7=n=>e.check(yi(pe,n)),e.nanoid=n=>e.check(bi(Hs,n)),e.guid=n=>e.check(zt(Zt,n)),e.cuid=n=>e.check(ki(Vs,n)),e.cuid2=n=>e.check(zi(Ws,n)),e.ulid=n=>e.check(Si(Gs,n)),e.base64=n=>e.check(Zi(oa,n)),e.base64url=n=>e.check(Ci(ra,n)),e.xid=n=>e.check($i(Ks,n)),e.ksuid=n=>e.check(Ti(Ys,n)),e.ipv4=n=>e.check(Ei(Xs,n)),e.ipv6=n=>e.check(Ai(ea,n)),e.cidrv4=n=>e.check(Ii(ta,n)),e.cidrv6=n=>e.check(Oi(na,n)),e.e164=n=>e.check(Pi(ia,n)),e.datetime=n=>e.check(Ss(n)),e.date=n=>e.check(Ts(n)),e.time=n=>e.check(As(n)),e.duration=n=>e.check(Os(n))});function J(e){return fi(Ms,e)}const z=d("ZodStringFormat",(e,t)=>{k.init(e,t),Ot.init(e,t)}),Js=d("ZodEmail",(e,t)=>{zr.init(e,t),z.init(e,t)}),Zt=d("ZodGUID",(e,t)=>{br.init(e,t),z.init(e,t)}),pe=d("ZodUUID",(e,t)=>{kr.init(e,t),z.init(e,t)}),Bs=d("ZodURL",(e,t)=>{Sr.init(e,t),z.init(e,t)}),Qs=d("ZodEmoji",(e,t)=>{$r.init(e,t),z.init(e,t)}),Hs=d("ZodNanoID",(e,t)=>{Tr.init(e,t),z.init(e,t)}),Vs=d("ZodCUID",(e,t)=>{Er.init(e,t),z.init(e,t)}),Ws=d("ZodCUID2",(e,t)=>{Ar.init(e,t),z.init(e,t)}),Gs=d("ZodULID",(e,t)=>{Ir.init(e,t),z.init(e,t)}),Ks=d("ZodXID",(e,t)=>{Or.init(e,t),z.init(e,t)}),Ys=d("ZodKSUID",(e,t)=>{Zr.init(e,t),z.init(e,t)}),Xs=d("ZodIPv4",(e,t)=>{jr.init(e,t),z.init(e,t)}),ea=d("ZodIPv6",(e,t)=>{Dr.init(e,t),z.init(e,t)}),ta=d("ZodCIDRv4",(e,t)=>{Lr.init(e,t),z.init(e,t)}),na=d("ZodCIDRv6",(e,t)=>{xr.init(e,t),z.init(e,t)}),oa=d("ZodBase64",(e,t)=>{Ur.init(e,t),z.init(e,t)}),ra=d("ZodBase64URL",(e,t)=>{Fr.init(e,t),z.init(e,t)}),ia=d("ZodE164",(e,t)=>{Mr.init(e,t),z.init(e,t)}),sa=d("ZodJWT",(e,t)=>{Br.init(e,t),z.init(e,t)}),aa=d("ZodBoolean",(e,t)=>{Qr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ss(e,n,o)});function ca(e){return xi(aa,e)}const ua=d("ZodUnknown",(e,t)=>{Hr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>cs()});function Ae(){return Ui(ua)}const da=d("ZodNever",(e,t)=>{Vr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>as(e,n,o)});function la(e){return qi(da,e)}const pa=d("ZodArray",(e,t)=>{Wr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ps(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(de(n,o)),e.nonempty=n=>e.check(de(1,n)),e.max=(n,o)=>e.check(St(n,o)),e.length=(n,o)=>e.check($t(n,o)),e.unwrap=()=>e.element});function Ct(e,t){return Xi(pa,e,t)}const fa=d("ZodObject",(e,t)=>{Kr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>fs(e,n,o,r),y(e,"shape",()=>t.shape),e.keyof=()=>Oe(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ae()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ae()}),e.strict=()=>e.clone({...e._zod.def,catchall:la()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>ko(e,n),e.safeExtend=n=>zo(e,n),e.merge=n=>So(e,n),e.pick=n=>wo(e,n),e.omit=n=>bo(e,n),e.partial=(...n)=>$o(Rt,e,n[0]),e.required=(...n)=>To(Dt,e,n[0])});function ee(e,t){const n={type:"object",shape:e??{},...g(t)};return new fa(n)}const ha=d("ZodUnion",(e,t)=>{Yr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>hs(e,n,o,r),e.options=t.options});function Pt(e,t){return new ha({type:"union",options:e,...g(t)})}const ga=d("ZodIntersection",(e,t)=>{Xr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>gs(e,n,o,r)});function ma(e,t){return new ga({type:"intersection",left:e,right:t})}const Ie=d("ZodEnum",(e,t)=>{ei.init(e,t),$.init(e,t),e._zod.processJSONSchema=(o,r,s)=>us(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const s={};for(const i of o)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ie({...t,checks:[],...g(r),entries:s})},e.exclude=(o,r)=>{const s={...t.entries};for(const i of o)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Ie({...t,checks:[],...g(r),entries:s})}});function Oe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Ie({type:"enum",entries:n,...g(t)})}const _a=d("ZodTransform",(e,t)=>{ti.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ls(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new We(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Y(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(Y(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function ya(e){return new _a({type:"transform",transform:e})}const Rt=d("ZodOptional",(e,t)=>{_t.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>It(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Nt(e){return new Rt({type:"optional",innerType:e})}const va=d("ZodExactOptional",(e,t)=>{ni.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>It(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function wa(e){return new va({type:"optional",innerType:e})}const ba=d("ZodNullable",(e,t)=>{oi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ms(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function jt(e){return new ba({type:"nullable",innerType:e})}const ka=d("ZodDefault",(e,t)=>{ri.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ys(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function za(e,t){return new ka({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const Sa=d("ZodPrefault",(e,t)=>{ii.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>vs(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function $a(e,t){return new Sa({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const Dt=d("ZodNonOptional",(e,t)=>{si.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>_s(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Ta(e,t){return new Dt({type:"nonoptional",innerType:e,...g(t)})}const Ea=d("ZodCatch",(e,t)=>{ai.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ws(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Aa(e,t){return new Ea({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Ia=d("ZodPipe",(e,t)=>{ci.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>bs(e,n,o,r),e.in=t.in,e.out=t.out});function Lt(e,t){return new Ia({type:"pipe",in:e,out:t})}const Oa=d("ZodReadonly",(e,t)=>{ui.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ks(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Za(e){return new Oa({type:"readonly",innerType:e})}const Ca=d("ZodCustom",(e,t)=>{di.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ds(e,n)});function Pa(e,t={}){return es(Ca,e,t)}function Ra(e){return ts(e)}const Na=ee({title:J(),type:J(),payload:Ae().optional()}),ja=ee({label:J(),action:Na,variant:Oe(["primary","outline","ghost"]).optional()}),Da=ee({orientation:Oe(["horizontal","vertical"]).optional(),wrap:ca().optional()}),La=ee({placeholder:Pt([J(),Ct(J())]).optional(),ctaLabel:J().optional()}),xa=ee({text:J()}),Ua={components:{ActionButton:{schema:ja,description:"A single clickable QNA action button."},ButtonRow:{schema:Da,description:"Container for a group of QNA action buttons."},TextInput:{schema:La,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:xa,description:"A heading displayed above the QNA button group."}}};class xt extends pn{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=Ve,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(t){this._i18n=this._resolveI18n(t),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this.root.appendChild(this._contentEl);const n=t.pageContext?.sku;n&&(this._lastSku=n,await this._fetchAndRender(n)),this.isVisible=!0,co("qna")}onUpdate(t){const n=t.sku;!n||n===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=n,this._fetchAndRender(n)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_cleanupTextInputTimers(){if(!this._contentEl)return;const t=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const n of t)n._cleanup?.()}async _fetchAndRender(t){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const n=this._createLoadingIndicator();this._contentEl.appendChild(n);const o={middlewareUrl:this.config.middlewareUrl},r=crypto.randomUUID(),s=Date.now();this.track(Mt(this.analyticsContext(),{endpoint:"launcher_action",request_id:r,widget:"qna"}));try{const i={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:t,locale:this.config.locale??"tr"},a=this.config.pageContext?.pageType;a!==void 0&&(i.page_type=a);const c=await so(i,o,this._abortController.signal);if(this.track(Jt(this.analyticsContext(),{request_id:r,latency_ms:Date.now()-s,chunk_count:c.actions.length,widget:"qna"})),this.track(Ht(this.analyticsContext(),{message_count:c.actions.length,history_ref:r,redaction_level:"none",widget:"qna"})),!this._contentEl)return;if(this._contentEl.innerHTML="",!this._specIncludesType(c.uiSpecs,"QuestionHeading")&&this.config.showStaticQuestion&&this.config.staticQuestionText){const b=document.createElement("h3");b.className="gengage-qna-heading",b.textContent=this.config.staticQuestionText,this._contentEl.appendChild(b)}const l=this.config.inputPlaceholder,h=c.actions.length>0&&l===!0?c.actions.map(b=>b.title):l===!0?this._i18n.defaultInputPlaceholder:l??this._i18n.defaultInputPlaceholder,p={onAction:this._actionHandler,i18n:this._i18n};this.config.hideButtonRowCta||(p.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(p.ctaText=this.config.ctaText)),h!==void 0&&(p.inputPlaceholder=h);const f=this._buildFallbackActionsSpec(c.actions),m=(c.uiSpecs.length>0?c.uiSpecs:[f]).filter(b=>Object.keys(b.elements).length>0);for(const b of m){const O=this._renderUISpec(b,p);this._contentEl.appendChild(O)}m.length>0&&uo("qna"),!this._specIncludesType(m,"TextInput")&&this._appendStandaloneInput(p,h)}catch(i){if(i instanceof DOMException&&i.name==="AbortError")return;if(fe("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:nn(this.config.locale)}),this.track(Bt(this.analyticsContext(),{request_id:r,error_code:"FETCH_ERROR",error_message:i instanceof Error?i.message:String(i),widget:"qna"})),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const a=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,c={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler};this.config.ctaText!==void 0&&(c.ctaText=this.config.ctaText),this._appendStandaloneInput(c,a)}}}_createLoadingIndicator(){const t=document.createElement("div");t.className="gengage-qna-loading";for(let n=0;n<3;n++){const o=document.createElement("div");o.className="gengage-qna-loading-dot",t.appendChild(o)}return t}_resolveI18n(t){return{...go(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=Qe();return Ft(t,this.config.renderer?.registry)}_renderUISpec(t,n){const o=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??ye,s=(c,u)=>He(c,u,o,r),i=this.config.renderer?.renderUISpec;return i?i(t,n,{registry:o,unknownRenderer:r,defaultRender:s}):s(t,n)}_specIncludesType(t,n){for(const o of t)for(const r of Object.values(o.elements))if(r.type===n)return!0;return!1}_buildFallbackActionsSpec(t){if(t.length===0)return{root:"root",elements:{}};const n={},o=[];for(let r=0;r<t.length;r++){const s=t[r],i=`action-${r}`;o.push(i),n[i]={type:"ActionButton",props:{label:s.title,action:{title:s.title,type:s.type,payload:s.payload}}}}return n.root={type:"ButtonRow",children:o},{root:"root",elements:n}}_appendStandaloneInput(t,n){if(!this._contentEl)return;const o={root:"root",elements:{root:{type:"TextInput",props:{placeholder:n}}}},r=this._renderUISpec(o,t);this._contentEl.appendChild(r)}_handleAction(t){lo(t.title,t.type),this.config.onActionSelected?.(t),fe("gengage:qna:action",t)}_handleOpenChat(){const t=this._contentEl?.querySelector(".gengage-qna-input");t&&t.focus(),this.config.onOpenChat?.(),fe("gengage:qna:open-chat",{})}}function qa(){return new xt}x.GengageQNA=xt,x.createDefaultQnaUISpecRegistry=Qe,x.createQNAWidget=qa,x.defaultQnaUnknownUISpecRenderer=ye,x.qnaCatalog=Ua,x.renderQnaUISpec=He,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
85
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function At(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=i=>{const a=e.seen.get(i);if(a.ref===null)return;const c=a.def??a.schema,u={...c},p=a.ref;if(a.ref=null,p){o(p);const l=e.seen.get(p),f=l.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Object.assign(c,f),Object.assign(c,u),i._zod.parent===p)for(const _ in c)_==="$ref"||_==="allOf"||_ in u||delete c[_];if(f.$ref&&l.def)for(const _ in c)_==="$ref"||_==="allOf"||_ in l.def&&JSON.stringify(c[_])===JSON.stringify(l.def[_])&&delete c[_]}const h=i._zod.parent;if(h&&h!==p){o(h);const l=e.seen.get(h);if(l?.schema.$ref&&(c.$ref=l.schema.$ref,l.def))for(const f in c)f==="$ref"||f==="allOf"||f in l.def&&JSON.stringify(c[f])===JSON.stringify(l.def[f])&&delete c[f]}e.override({zodSchema:i,jsonSchema:c,path:a.path??[]})};for(const i of[...e.seen.entries()].reverse())o(i[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(i)}Object.assign(r,n.def??n.schema);const s=e.external?.defs??{};for(const i of e.seen.entries()){const a=i[1];a.def&&a.defId&&(s[a.defId]=a.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{const i=JSON.parse(JSON.stringify(r));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:le(t,"input",e.processors),output:le(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function A(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return A(o.element,n);if(o.type==="set")return A(o.valueType,n);if(o.type==="lazy")return A(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return A(o.innerType,n);if(o.type==="intersection")return A(o.left,n)||A(o.right,n);if(o.type==="record"||o.type==="map")return A(o.keyType,n)||A(o.valueType,n);if(o.type==="pipe")return A(o.in,n)||A(o.out,n);if(o.type==="object"){for(const r in o.shape)if(A(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(A(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(A(r,n))return!0;return!!(o.rest&&A(o.rest,n))}return!1}const os=(e,t={})=>n=>{const o=Tt({...n,processors:t});return T(e,o),Et(o,e),At(o,e)},le=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=Tt({...r??{},target:s,io:t,processors:n});return T(e,i),Et(i,e),At(i,e)},rs={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},is=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof i=="number"&&(r.maxLength=i),a&&(r.format=rs[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const p=[...c];p.length===1?r.pattern=p[0].source:p.length>1&&(r.allOf=[...p.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},ss=(e,t,n,o)=>{n.type="boolean"},as=(e,t,n,o)=>{n.not={}},cs=(e,t,n,o)=>{},us=(e,t,n,o)=>{const r=e._zod.def,s=Ke(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},ds=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ls=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ps=(e,t,n,o)=>{const r=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(r.minItems=i),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=T(s.element,t,{...o,path:[...o.path,"items"]})},fs=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="object",r.properties={};const i=s.shape;for(const u in i)r.properties[u]=T(i[u],t,{...o,path:[...o.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{const p=s.shape[u]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(r.required=Array.from(c)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=T(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},hs=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((a,c)=>T(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},gs=(e,t,n,o)=>{const r=e._zod.def,s=T(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=T(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},_s=(e,t,n,o)=>{const r=e._zod.def,s=T(r.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},ms=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},ys=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},vs=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},ws=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},bs=(e,t,n,o)=>{const r=e._zod.def,s=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;T(s,t,o);const i=t.seen.get(e);i.ref=s},ks=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},It=(e,t,n,o)=>{const r=e._zod.def;T(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},zs=d("ZodISODateTime",(e,t)=>{Cr.init(e,t),z.init(e,t)});function Ss(e){return Ni(zs,e)}const $s=d("ZodISODate",(e,t)=>{Pr.init(e,t),z.init(e,t)});function Ts(e){return ji($s,e)}const Es=d("ZodISOTime",(e,t)=>{Rr.init(e,t),z.init(e,t)});function As(e){return Di(Es,e)}const Is=d("ZodISODuration",(e,t)=>{Nr.init(e,t),z.init(e,t)});function Os(e){return Li(Is,e)}const O=d("ZodError",(e,t)=>{rt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Ao(e,n)},flatten:{value:n=>Eo(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ve,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ve,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Zs=Se(O),Cs=$e(O),Ps=ie(O),Rs=se(O),Ns=Zo(O),js=Co(O),Ds=Po(O),Ls=Ro(O),xs=No(O),Us=jo(O),qs=Do(O),Fs=Lo(O),$=d("ZodType",(e,t)=>(S.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:le(e,"input"),output:le(e,"output")}}),e.toJSONSchema=os(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(D(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>L(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>Zs(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Ps(e,n,o),e.parseAsync=async(n,o)=>Cs(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>Rs(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>Ns(e,n,o),e.decode=(n,o)=>js(e,n,o),e.encodeAsync=async(n,o)=>Ds(e,n,o),e.decodeAsync=async(n,o)=>Ls(e,n,o),e.safeEncode=(n,o)=>xs(e,n,o),e.safeDecode=(n,o)=>Us(e,n,o),e.safeEncodeAsync=async(n,o)=>qs(e,n,o),e.safeDecodeAsync=async(n,o)=>Fs(e,n,o),e.refine=(n,o)=>e.check(Pa(n,o)),e.superRefine=n=>e.check(Ra(n)),e.overwrite=n=>e.check(V(n)),e.optional=()=>Nt(e),e.exactOptional=()=>wa(e),e.nullable=()=>jt(e),e.nullish=()=>Nt(jt(e)),e.nonoptional=n=>Ta(e,n),e.array=()=>Ct(e),e.or=n=>Pt([e,n]),e.and=n=>_a(e,n),e.transform=n=>Lt(e,ya(n)),e.default=n=>za(e,n),e.prefault=n=>$a(e,n),e.catch=n=>Aa(e,n),e.pipe=n=>Lt(e,n),e.readonly=()=>Za(e),e.describe=n=>{const o=e.clone();return X.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return X.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return X.get(e);const o=e.clone();return X.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Ot=d("_ZodString",(e,t)=>{Te.init(e,t),$.init(e,t),e._zod.processJSONSchema=(o,r,s)=>is(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(Fi(...o)),e.includes=(...o)=>e.check(Bi(...o)),e.startsWith=(...o)=>e.check(Qi(...o)),e.endsWith=(...o)=>e.check(Hi(...o)),e.min=(...o)=>e.check(de(...o)),e.max=(...o)=>e.check(St(...o)),e.length=(...o)=>e.check($t(...o)),e.nonempty=(...o)=>e.check(de(1,...o)),e.lowercase=o=>e.check(Mi(o)),e.uppercase=o=>e.check(Ji(o)),e.trim=()=>e.check(Wi()),e.normalize=(...o)=>e.check(Vi(...o)),e.toLowerCase=()=>e.check(Gi()),e.toUpperCase=()=>e.check(Ki()),e.slugify=()=>e.check(Yi())}),Ms=d("ZodString",(e,t)=>{Te.init(e,t),Ot.init(e,t),e.email=n=>e.check(hi(Js,n)),e.url=n=>e.check(vi(Bs,n)),e.jwt=n=>e.check(Ri(sa,n)),e.emoji=n=>e.check(wi(Qs,n)),e.guid=n=>e.check(zt(Zt,n)),e.uuid=n=>e.check(gi(pe,n)),e.uuidv4=n=>e.check(_i(pe,n)),e.uuidv6=n=>e.check(mi(pe,n)),e.uuidv7=n=>e.check(yi(pe,n)),e.nanoid=n=>e.check(bi(Hs,n)),e.guid=n=>e.check(zt(Zt,n)),e.cuid=n=>e.check(ki(Vs,n)),e.cuid2=n=>e.check(zi(Ws,n)),e.ulid=n=>e.check(Si(Gs,n)),e.base64=n=>e.check(Zi(oa,n)),e.base64url=n=>e.check(Ci(ra,n)),e.xid=n=>e.check($i(Ks,n)),e.ksuid=n=>e.check(Ti(Ys,n)),e.ipv4=n=>e.check(Ei(Xs,n)),e.ipv6=n=>e.check(Ai(ea,n)),e.cidrv4=n=>e.check(Ii(ta,n)),e.cidrv6=n=>e.check(Oi(na,n)),e.e164=n=>e.check(Pi(ia,n)),e.datetime=n=>e.check(Ss(n)),e.date=n=>e.check(Ts(n)),e.time=n=>e.check(As(n)),e.duration=n=>e.check(Os(n))});function J(e){return fi(Ms,e)}const z=d("ZodStringFormat",(e,t)=>{k.init(e,t),Ot.init(e,t)}),Js=d("ZodEmail",(e,t)=>{zr.init(e,t),z.init(e,t)}),Zt=d("ZodGUID",(e,t)=>{br.init(e,t),z.init(e,t)}),pe=d("ZodUUID",(e,t)=>{kr.init(e,t),z.init(e,t)}),Bs=d("ZodURL",(e,t)=>{Sr.init(e,t),z.init(e,t)}),Qs=d("ZodEmoji",(e,t)=>{$r.init(e,t),z.init(e,t)}),Hs=d("ZodNanoID",(e,t)=>{Tr.init(e,t),z.init(e,t)}),Vs=d("ZodCUID",(e,t)=>{Er.init(e,t),z.init(e,t)}),Ws=d("ZodCUID2",(e,t)=>{Ar.init(e,t),z.init(e,t)}),Gs=d("ZodULID",(e,t)=>{Ir.init(e,t),z.init(e,t)}),Ks=d("ZodXID",(e,t)=>{Or.init(e,t),z.init(e,t)}),Ys=d("ZodKSUID",(e,t)=>{Zr.init(e,t),z.init(e,t)}),Xs=d("ZodIPv4",(e,t)=>{jr.init(e,t),z.init(e,t)}),ea=d("ZodIPv6",(e,t)=>{Dr.init(e,t),z.init(e,t)}),ta=d("ZodCIDRv4",(e,t)=>{Lr.init(e,t),z.init(e,t)}),na=d("ZodCIDRv6",(e,t)=>{xr.init(e,t),z.init(e,t)}),oa=d("ZodBase64",(e,t)=>{Ur.init(e,t),z.init(e,t)}),ra=d("ZodBase64URL",(e,t)=>{Fr.init(e,t),z.init(e,t)}),ia=d("ZodE164",(e,t)=>{Mr.init(e,t),z.init(e,t)}),sa=d("ZodJWT",(e,t)=>{Br.init(e,t),z.init(e,t)}),aa=d("ZodBoolean",(e,t)=>{Qr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ss(e,n,o)});function ca(e){return xi(aa,e)}const ua=d("ZodUnknown",(e,t)=>{Hr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>cs()});function Ae(){return Ui(ua)}const da=d("ZodNever",(e,t)=>{Vr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>as(e,n,o)});function la(e){return qi(da,e)}const pa=d("ZodArray",(e,t)=>{Wr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ps(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(de(n,o)),e.nonempty=n=>e.check(de(1,n)),e.max=(n,o)=>e.check(St(n,o)),e.length=(n,o)=>e.check($t(n,o)),e.unwrap=()=>e.element});function Ct(e,t){return Xi(pa,e,t)}const fa=d("ZodObject",(e,t)=>{Kr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>fs(e,n,o,r),y(e,"shape",()=>t.shape),e.keyof=()=>Oe(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ae()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ae()}),e.strict=()=>e.clone({...e._zod.def,catchall:la()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>ko(e,n),e.safeExtend=n=>zo(e,n),e.merge=n=>So(e,n),e.pick=n=>wo(e,n),e.omit=n=>bo(e,n),e.partial=(...n)=>$o(Rt,e,n[0]),e.required=(...n)=>To(Dt,e,n[0])});function ee(e,t){const n={type:"object",shape:e??{},...g(t)};return new fa(n)}const ha=d("ZodUnion",(e,t)=>{Yr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>hs(e,n,o,r),e.options=t.options});function Pt(e,t){return new ha({type:"union",options:e,...g(t)})}const ga=d("ZodIntersection",(e,t)=>{Xr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>gs(e,n,o,r)});function _a(e,t){return new ga({type:"intersection",left:e,right:t})}const Ie=d("ZodEnum",(e,t)=>{ei.init(e,t),$.init(e,t),e._zod.processJSONSchema=(o,r,s)=>us(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const s={};for(const i of o)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ie({...t,checks:[],...g(r),entries:s})},e.exclude=(o,r)=>{const s={...t.entries};for(const i of o)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Ie({...t,checks:[],...g(r),entries:s})}});function Oe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Ie({type:"enum",entries:n,...g(t)})}const ma=d("ZodTransform",(e,t)=>{ti.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ls(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new We(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Y(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(Y(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function ya(e){return new ma({type:"transform",transform:e})}const Rt=d("ZodOptional",(e,t)=>{mt.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>It(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Nt(e){return new Rt({type:"optional",innerType:e})}const va=d("ZodExactOptional",(e,t)=>{ni.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>It(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function wa(e){return new va({type:"optional",innerType:e})}const ba=d("ZodNullable",(e,t)=>{oi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>_s(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function jt(e){return new ba({type:"nullable",innerType:e})}const ka=d("ZodDefault",(e,t)=>{ri.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ys(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function za(e,t){return new ka({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const Sa=d("ZodPrefault",(e,t)=>{ii.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>vs(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function $a(e,t){return new Sa({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const Dt=d("ZodNonOptional",(e,t)=>{si.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ms(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Ta(e,t){return new Dt({type:"nonoptional",innerType:e,...g(t)})}const Ea=d("ZodCatch",(e,t)=>{ai.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ws(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Aa(e,t){return new Ea({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Ia=d("ZodPipe",(e,t)=>{ci.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>bs(e,n,o,r),e.in=t.in,e.out=t.out});function Lt(e,t){return new Ia({type:"pipe",in:e,out:t})}const Oa=d("ZodReadonly",(e,t)=>{ui.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ks(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Za(e){return new Oa({type:"readonly",innerType:e})}const Ca=d("ZodCustom",(e,t)=>{di.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ds(e,n)});function Pa(e,t={}){return es(Ca,e,t)}function Ra(e){return ts(e)}const Na=ee({title:J(),type:J(),payload:Ae().optional()}),ja=ee({label:J(),action:Na,variant:Oe(["primary","outline","ghost"]).optional()}),Da=ee({orientation:Oe(["horizontal","vertical"]).optional(),wrap:ca().optional()}),La=ee({placeholder:Pt([J(),Ct(J())]).optional(),ctaLabel:J().optional()}),xa=ee({text:J()}),Ua={components:{ActionButton:{schema:ja,description:"A single clickable QNA action button."},ButtonRow:{schema:Da,description:"Container for a group of QNA action buttons."},TextInput:{schema:La,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:xa,description:"A heading displayed above the QNA button group."}}};class xt extends pn{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=Ve,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(t){this._i18n=this._resolveI18n(t),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this.root.appendChild(this._contentEl);const n=t.pageContext?.sku;n&&(this._lastSku=n,await this._fetchAndRender(n)),co("qna")}onUpdate(t){const n=t.sku;!n||n===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=n,this._fetchAndRender(n)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_cleanupTextInputTimers(){if(!this._contentEl)return;const t=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const n of t)n._cleanup?.()}async _fetchAndRender(t){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const n=this._createLoadingIndicator();this._contentEl.appendChild(n);const o={middlewareUrl:this.config.middlewareUrl},r=crypto.randomUUID(),s=Date.now();this.track(Mt(this.analyticsContext(),{endpoint:"launcher_action",request_id:r,widget:"qna"}));try{const i={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:t,locale:this.config.locale??"tr"},a=this.config.pageContext?.pageType;a!==void 0&&(i.page_type=a);const c=await so(i,o,this._abortController.signal);if(this.track(Jt(this.analyticsContext(),{request_id:r,latency_ms:Date.now()-s,chunk_count:c.actions.length,widget:"qna"})),this.track(Ht(this.analyticsContext(),{message_count:c.actions.length,history_ref:r,redaction_level:"none",widget:"qna"})),!this._contentEl)return;if(this._contentEl.innerHTML="",!this._specIncludesType(c.uiSpecs,"QuestionHeading")&&this.config.showStaticQuestion&&this.config.staticQuestionText){const b=document.createElement("h3");b.className="gengage-qna-heading",b.textContent=this.config.staticQuestionText,this._contentEl.appendChild(b)}const p=this.config.inputPlaceholder;let h;if(p!==!0)h=p??this._i18n.defaultInputPlaceholder;else if(c.actions.length>0){const b=c.actions.filter(E=>E.type==="user_message"||E.title.includes("?")).map(E=>E.title);h=b.length>0?b:this._i18n.defaultInputPlaceholder}else h=this._i18n.defaultInputPlaceholder;const l={onAction:this._actionHandler,i18n:this._i18n};this.config.hideButtonRowCta||(l.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(l.ctaText=this.config.ctaText)),h!==void 0&&(l.inputPlaceholder=h);const f=this._buildFallbackActionsSpec(c.actions),_=(c.uiSpecs.length>0?c.uiSpecs:[f]).filter(b=>Object.keys(b.elements).length>0);for(const b of _){const E=this._renderUISpec(b,l);this._contentEl.appendChild(E)}_.length>0&&uo("qna"),!this._specIncludesType(_,"TextInput")&&this._appendStandaloneInput(l,h)}catch(i){if(i instanceof DOMException&&i.name==="AbortError")return;if(fe("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:nn(this.config.locale)}),this.track(Bt(this.analyticsContext(),{request_id:r,error_code:"FETCH_ERROR",error_message:i instanceof Error?i.message:String(i),widget:"qna"})),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const a=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,c={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler};this.config.ctaText!==void 0&&(c.ctaText=this.config.ctaText),this._appendStandaloneInput(c,a)}}}_createLoadingIndicator(){const t=document.createElement("div");t.className="gengage-qna-loading";for(let n=0;n<3;n++){const o=document.createElement("div");o.className="gengage-qna-loading-dot",t.appendChild(o)}return t}_resolveI18n(t){return{...go(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=Qe();return Ft(t,this.config.renderer?.registry)}_renderUISpec(t,n){const o=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??ye,s=(c,u)=>He(c,u,o,r),i=this.config.renderer?.renderUISpec;return i?i(t,n,{registry:o,unknownRenderer:r,defaultRender:s}):s(t,n)}_specIncludesType(t,n){for(const o of t)for(const r of Object.values(o.elements))if(r.type===n)return!0;return!1}_buildFallbackActionsSpec(t){if(t.length===0)return{root:"root",elements:{}};const n={},o=[];for(let r=0;r<t.length;r++){const s=t[r],i=`action-${r}`;o.push(i),n[i]={type:"ActionButton",props:{label:s.title,action:{title:s.title,type:s.type,payload:s.payload}}}}return n.root={type:"ButtonRow",children:o},{root:"root",elements:n}}_appendStandaloneInput(t,n){if(!this._contentEl)return;const o={root:"root",elements:{root:{type:"TextInput",props:{placeholder:n}}}},r=this._renderUISpec(o,t);this._contentEl.appendChild(r)}_handleAction(t){lo(t.title,t.type),this.config.onActionSelected?.(t),fe("gengage:qna:action",t)}_handleOpenChat(){const t=this._contentEl?.querySelector(".gengage-qna-input");t&&t.focus(),this.config.onOpenChat?.(),fe("gengage:qna:open-chat",{})}}function qa(){return new xt}x.GengageQNA=xt,x.createDefaultQnaUISpecRegistry=Qe,x.createQNAWidget=qa,x.defaultQnaUnknownUISpecRenderer=ye,x.qnaCatalog=Ua,x.renderQnaUISpec=He,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
86
86
  //# sourceMappingURL=qna.iife.js.map