@gengage/assistant-fe 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +2 -2
- package/dist/assistant-fe.css +1 -1
- package/dist/chat/api.d.ts +12 -2
- package/dist/chat/api.d.ts.map +1 -1
- package/dist/chat/catalog.d.ts +246 -896
- package/dist/chat/catalog.d.ts.map +1 -1
- package/dist/chat/components/AIGroupingCards.d.ts.map +1 -1
- package/dist/chat/components/AISuggestedSearchCards.d.ts.map +1 -1
- package/dist/chat/components/AITopPicks.d.ts.map +1 -1
- package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +11 -2
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
- package/dist/chat/components/ComparisonTable.d.ts +9 -0
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
- package/dist/chat/components/GroundingReviewCard.d.ts.map +1 -1
- package/dist/chat/components/HandoffNotice.d.ts +5 -0
- package/dist/chat/components/HandoffNotice.d.ts.map +1 -0
- package/dist/chat/components/KvkkBanner.d.ts +1 -0
- package/dist/chat/components/KvkkBanner.d.ts.map +1 -1
- package/dist/chat/components/ProactivePopup.d.ts +2 -0
- package/dist/chat/components/ProactivePopup.d.ts.map +1 -1
- package/dist/chat/components/ProductSummaryCard.d.ts +4 -0
- package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -0
- package/dist/chat/components/ReviewHighlights.d.ts +3 -1
- package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
- package/dist/chat/components/ThumbnailsColumn.d.ts.map +1 -1
- package/dist/chat/components/renderUISpec.d.ts +4 -3
- package/dist/chat/components/renderUISpec.d.ts.map +1 -1
- package/dist/chat/heartbeat.d.ts +71 -0
- package/dist/chat/heartbeat.d.ts.map +1 -0
- package/dist/chat/index.d.ts +33 -78
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/kvkk.d.ts +21 -0
- package/dist/chat/kvkk.d.ts.map +1 -0
- package/dist/chat/locales/en.d.ts.map +1 -1
- package/dist/chat/locales/tr.d.ts.map +1 -1
- package/dist/chat/panel-manager.d.ts +81 -0
- package/dist/chat/panel-manager.d.ts.map +1 -0
- package/dist/chat/session-persistence.d.ts +52 -0
- package/dist/chat/session-persistence.d.ts.map +1 -0
- package/dist/chat/types.d.ts +33 -1
- package/dist/chat/types.d.ts.map +1 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +48 -10
- package/dist/chat.iife.js.map +1 -1
- package/dist/chat.js +9 -8
- package/dist/chat.js.map +1 -1
- package/dist/common/analytics-events.d.ts +2 -0
- package/dist/common/analytics-events.d.ts.map +1 -1
- package/dist/common/analytics.d.ts.map +1 -1
- package/dist/common/api-paths.d.ts +5 -0
- package/dist/common/api-paths.d.ts.map +1 -1
- package/dist/common/client.d.ts +4 -1
- package/dist/common/client.d.ts.map +1 -1
- package/dist/common/communication-bridge.d.ts.map +1 -1
- package/dist/common/config-schema.d.ts +33 -195
- package/dist/common/config-schema.d.ts.map +1 -1
- package/dist/common/ga-datalayer.d.ts +62 -0
- package/dist/common/ga-datalayer.d.ts.map +1 -0
- package/dist/common/index.d.ts +7 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/indexed-db.d.ts +1 -1
- package/dist/common/indexed-db.d.ts.map +1 -1
- package/dist/common/merchant-configs.d.ts +22 -0
- package/dist/common/merchant-configs.d.ts.map +1 -0
- package/dist/common/overlay.d.ts +5 -0
- package/dist/common/overlay.d.ts.map +1 -1
- package/dist/common/page-detect.d.ts +31 -0
- package/dist/common/page-detect.d.ts.map +1 -0
- package/dist/common/preflight.d.ts +3 -1
- package/dist/common/preflight.d.ts.map +1 -1
- package/dist/common/price-formatter.d.ts +33 -0
- package/dist/common/price-formatter.d.ts.map +1 -0
- package/dist/common/product-utils.d.ts +26 -0
- package/dist/common/product-utils.d.ts.map +1 -0
- package/dist/common/quantity-stepper.d.ts +22 -0
- package/dist/common/quantity-stepper.d.ts.map +1 -0
- package/dist/common/safe-html.d.ts +10 -6
- package/dist/common/safe-html.d.ts.map +1 -1
- package/dist/common/streaming.d.ts.map +1 -1
- package/dist/common/tts-player.d.ts +12 -0
- package/dist/common/tts-player.d.ts.map +1 -0
- package/dist/common/types.d.ts +51 -0
- package/dist/common/types.d.ts.map +1 -1
- package/dist/common/v1-protocol-adapter.d.ts +9 -0
- package/dist/common/v1-protocol-adapter.d.ts.map +1 -1
- package/dist/common/voice-input.d.ts +74 -0
- package/dist/common/voice-input.d.ts.map +1 -0
- package/dist/common/widget-base.d.ts +17 -1
- package/dist/common/widget-base.d.ts.map +1 -1
- package/dist/common.cjs +1 -1
- package/dist/common.cjs.map +1 -1
- package/dist/common.js +564 -244
- package/dist/common.js.map +1 -1
- package/dist/index-CmlYMq-h.js +4218 -0
- package/dist/index-CmlYMq-h.js.map +1 -0
- package/dist/index-DK4lqi85.cjs +13 -0
- package/dist/index-DK4lqi85.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -53
- package/dist/qna/catalog.d.ts +30 -96
- package/dist/qna/catalog.d.ts.map +1 -1
- package/dist/qna/components/TextInput.d.ts.map +1 -1
- package/dist/qna/index.d.ts +2 -0
- package/dist/qna/index.d.ts.map +1 -1
- package/dist/qna.cjs +1 -1
- package/dist/qna.cjs.map +1 -1
- package/dist/qna.iife.js +46 -8
- package/dist/qna.iife.js.map +1 -1
- package/dist/qna.js +90 -83
- package/dist/qna.js.map +1 -1
- package/dist/quantity-stepper-B8kX8GbN.js +209 -0
- package/dist/quantity-stepper-B8kX8GbN.js.map +1 -0
- package/dist/quantity-stepper-UbAp53Ow.cjs +2 -0
- package/dist/quantity-stepper-UbAp53Ow.cjs.map +1 -0
- package/dist/schemas-DbbfBnZe.cjs +86 -0
- package/dist/schemas-DbbfBnZe.cjs.map +1 -0
- package/dist/schemas-SGuXpngy.js +4558 -0
- package/dist/schemas-SGuXpngy.js.map +1 -0
- package/dist/simrel/api.d.ts.map +1 -1
- package/dist/simrel/catalog.d.ts +32 -240
- package/dist/simrel/catalog.d.ts.map +1 -1
- package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
- package/dist/simrel/components/ProductCard.d.ts +2 -0
- package/dist/simrel/components/ProductCard.d.ts.map +1 -1
- package/dist/simrel/components/renderUISpec.d.ts.map +1 -1
- package/dist/simrel/index.d.ts.map +1 -1
- package/dist/simrel/types.d.ts +5 -0
- package/dist/simrel/types.d.ts.map +1 -1
- package/dist/simrel.cjs +1 -1
- package/dist/simrel.cjs.map +1 -1
- package/dist/simrel.css +1 -1
- package/dist/simrel.iife.js +46 -8
- package/dist/simrel.iife.js.map +1 -1
- package/dist/simrel.js +319 -279
- package/dist/simrel.js.map +1 -1
- package/package.json +26 -7
- package/dist/index-CFA70IGF.js +0 -3626
- package/dist/index-CFA70IGF.js.map +0 -1
- package/dist/index-Dfl89zpe.cjs +0 -13
- package/dist/index-Dfl89zpe.cjs.map +0 -1
- package/dist/types-CeON7iBO.cjs +0 -48
- package/dist/types-CeON7iBO.cjs.map +0 -1
- package/dist/types-yxW8WA7u.js +0 -4132
- package/dist/types-yxW8WA7u.js.map +0 -1
package/dist/qna.iife.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
#${
|
|
1
|
+
(function(j){"use strict";const Lt=({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 Ut(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const o=e.unknownRenderer??Lt,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 xt(e,t){if(!t)return e;const n={...e};for(const[o,r]of Object.entries(t))r&&(n[o]=r);return n}function qt(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 Ft(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 Jt(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 Bt(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 Mt(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 Qt(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 Ht(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 pe(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Ie(e,t){const n=o=>{t(o.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function Vt(){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 Wt(e){return{sessionId:e?.sessionId??Vt(),...e}}const Ze={"--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 Gt(e){return e?{...Ze,...e}:{...Ze}}const P="gengage-global-toast-root",Oe="gengage-global-toast-style",fe="gengage-global-toast-root--visible",Kt=4200,Yt=1500,Xt=15e3;let Ce=!1,L=null;function en(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")?"Baglanti sorunu olustu. Lutfen tekrar deneyin.":"Connection issue. Please try again."}function tn(){Ce||typeof window>"u"||typeof document>"u"||(Ce=!0,Ie("gengage:global:error",e=>{nn(e)}))}function nn(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;cn();const n=sn();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=rn(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(fe),L&&(clearTimeout(L),L=null),L=setTimeout(()=>{on()},an(e.durationMs))}function on(){if(typeof document>"u")return;const e=document.getElementById(P);e&&(e.classList.remove(fe),e.innerHTML="",L&&(clearTimeout(L),L=null))}function rn(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function sn(){const e=document.getElementById(P);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=P,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function an(e){return typeof e!="number"||!Number.isFinite(e)?Kt:Math.min(Xt,Math.max(Yt,Math.round(e)))}function cn(){if(document.getElementById(Oe))return;const e=document.createElement("style");e.id=Oe,e.textContent=`
|
|
2
|
+
#${P} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
top: 16px;
|
|
5
5
|
right: 16px;
|
|
6
6
|
z-index: 2147483646;
|
|
7
7
|
pointer-events: none;
|
|
8
8
|
}
|
|
9
|
-
#${
|
|
9
|
+
#${P}.${fe} {
|
|
10
10
|
pointer-events: auto;
|
|
11
11
|
}
|
|
12
|
-
#${
|
|
12
|
+
#${P} .gengage-global-toast {
|
|
13
13
|
min-width: 260px;
|
|
14
14
|
max-width: min(92vw, 420px);
|
|
15
15
|
border-radius: 12px;
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
line-height: 1.4;
|
|
25
25
|
animation: gengage-global-toast-in 180ms ease-out forwards;
|
|
26
26
|
}
|
|
27
|
-
#${
|
|
27
|
+
#${P} .gengage-global-toast-title {
|
|
28
28
|
margin: 0 0 4px;
|
|
29
29
|
font-size: 12px;
|
|
30
30
|
font-weight: 700;
|
|
31
31
|
}
|
|
32
|
-
#${
|
|
32
|
+
#${P} .gengage-global-toast-message {
|
|
33
33
|
margin: 0;
|
|
34
34
|
font-weight: 500;
|
|
35
35
|
}
|
|
@@ -43,6 +43,44 @@
|
|
|
43
43
|
transform: translateY(0);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
`,document.head.appendChild(
|
|
47
|
-
`);s=o.pop()??"";for(const c of o)if(Ie(c,e))return}s.trim()&&Ie(s,e)}catch(i){if(i instanceof DOMException&&i.name==="AbortError")return;e.onError?.(i instanceof Error?i:new Error(String(i)))}finally{n.releaseLock()}e.onDone?.()}const Pt={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings",proactive_action:"/proactive_action"};function Zt(t){if(t===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const e=t.trim();return e===""?"":e.replace(/\/+$/,"")}function jt(t,e){return`${Zt(e?.middlewareUrl)}/chat${Pt[t]}`}function qt(t){if(typeof t.type!="string")return null;if($t(t))return t;const n=t;switch(n.type){case"outputText":return Dt(n);case"suggestedActions":return Mt(n);case"productList":return Ut(n);case"productDetails":return Bt(n);case"productDetailsSimilars":return Vt(n);case"comparisonTable":return zt(n);case"context":return Qt(n);case"chatStreamEnd":return Ht();case"loading":return Ft(n);case"panelLoading":return Wt(n);case"similarLoading":return Gt(n);case"redirect":return Jt(n);case"error":return Yt(n);case"dummy":return Xt();case"launcherAction":return Kt(n);case"text":return fe(n);case"productItem":return en(n);case"text_image":return Ee(n);case"quick_qna":return Ne(n);case"reviewHighlights":return tn(n);case"aiProductSuggestions":return rn(n);case"aiProductGroupings":return an(n);case"aiSuggestedSearches":return on(n);case"prosAndCons":return nn(n);case"getGroundingReview":return cn(n);case"voice":return un(n);case"visitorDataResponse":return sn(n);case"productListPreview":return dn();case"groupList":return ln(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return fn(n);case"launcherContent":return pn(n);default:return null}}function $t(t){const e=t.type;if(typeof e!="string")return!1;switch(e){case"metadata":return typeof t.sessionId=="string"&&typeof t.model=="string";case"text_chunk":return typeof t.content=="string";case"ui_spec":{const n=t.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const r=U(t.spec);return r?typeof r.root=="string"&&U(r.elements)!==null:!1}case"action":{const n=U(t.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof t.code=="string"&&typeof t.message=="string";case"done":return!0;default:return!1}}function Dt(t){const e=b(t.payload.text,t.payload.plain_text)??"",n=b(t.payload.plain_text,t.payload.text)??e;if(t.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const r={type:"text_chunk",content:e,final:!0},s=t.payload.product_mentions;Array.isArray(s)&&s.length>0&&(r.productMentions=s.filter(o=>typeof o=="object"&&o!==null&&typeof o.sku=="string"&&typeof o.short_name=="string"));const i=t.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(r.skuToProductItem=i);const a=t.payload.conversation_mode;return typeof a=="string"&&a&&(r.conversationMode=a),r}function Mt(t){const e=(t.payload.actions??[]).map(n=>{const r=b(n.title)??"",s=L(n.requestDetails,r),i=s?{label:r,action:s}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Re(e.filter(Le),"chat")}function Ut(t){const e=Oe(t.payload.product_list??[],"chat");e.panelHint="panel";const n=e.spec.elements[e.spec.root];return n&&(typeof t.payload.offset=="number"&&(n.props={...n.props,offset:t.payload.offset}),typeof t.payload.end_of_list=="boolean"&&(n.props={...n.props,endOfList:t.payload.end_of_list})),e}function Bt(t){const e=t.payload.productDetails;return e?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:z(e)}}}},panelHint:"panel"}:mn("chat")}function Vt(t){const e=Oe(t.payload.similarProducts??[],"chat"),n=e.spec.elements[e.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...e,panelHint:"panel"}}function zt(t){const e=t.payload.multiple_product_details??[],n=t.payload.product_comparison_framework,r=t.payload.table,s=[];for(const w of e){const E=z(w);s.push(E)}const i=[];if(r){const w=n?.criteria_view??n?.criteria_view_short??{},E=n?.compared_field_names??Object.keys(r);for(const de of E){const A=r[de];if(!A||!Array.isArray(A))continue;const ne=w[de]??de;i.push({label:ne,values:A.map(we=>typeof we=="string"?we:String(we??""))})}}let a;n?.recommended_choice_sku?a=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(a=n.winner_product[0]?.sku);const o=a?s.find(w=>w.sku===a)??s[0]:s[0],c=[];if(n?.key_differences)for(const w of n.key_differences)typeof w=="string"&&c.push(w);const u=[];if(n?.special_considerations)for(const w of n.special_considerations)typeof w=="string"&&u.push(w);const h=n?.recommended_choice,k=n?.winner_hits,T={};for(const w of s){const E=w.sku;E&&(T[E]={title:w.name??E,type:"launchSingleProduct",payload:{sku:E}})}const C={products:s,attributes:i,highlights:c,productActions:T};return o&&(C.recommended=o),u.length>0&&(C.specialCases=u),h&&(C.recommendedText=h),k&&(C.winnerHits=k),typeof n?.key_differences=="string"&&(C.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(C.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:C}}},panelHint:"panel"}}function Qt(t){return{type:"metadata",sessionId:"",model:"",meta:{panel:t.payload.panel,messages:t.payload.messages,message_id:t.payload.message_id}}}function Ht(){return{type:"done"}}function Ft(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:t.payload.text,thinkingMessages:t.payload.thinking_messages,dynamicLoading:t.payload.is_dynamic===!0}}}function Wt(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function Gt(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function Jt(t){const e=b(t.payload.url);return e?{type:"action",action:{kind:"navigate",url:e,newTab:t.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:t.payload,redirectTarget:b(t.payload.to)}}}function Yt(t){return{type:"error",code:"BACKEND_ERROR",message:b(t.payload?.text,t.payload?.message,t.payload?.error)??"Backend returned an error"}}function Xt(t){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Kt(t){const e=t.payload??{};if(Array.isArray(e.action_list)){const i={action_list:e.action_list},a=typeof e.type=="string"?e.type:void 0,o=typeof e.theme=="string"?e.theme:void 0;return a!==void 0&&(i.type=a),o!==void 0&&(i.theme=o),Ne({payload:i})}const r=U(e.action);if(r){const i={action:r},a=typeof e.text=="string"?e.text:void 0,o=typeof e.image_url=="string"?e.image_url:void 0,c=typeof e.theme=="string"?e.theme:void 0;return a!==void 0&&(i.text=a),o!==void 0&&(i.image_url=o),c!==void 0&&(i.theme=c),Ee({payload:i})}const s=typeof e.text=="string"?e.text:"";if(s){const i={text:s},a=typeof e.type=="string"?e.type:void 0,o=typeof e.theme=="string"?e.theme:void 0,c=U(e.payload)??void 0;return a!==void 0&&(i.type=a),c!==void 0&&(i.payload=c),o!==void 0&&(i.theme=o),fe({payload:i})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:e}}}function fe(t){const e={text:b(t.payload.text)??""};return typeof t.payload.theme=="string"&&(e.theme=t.payload.theme),t.payload.payload!==void 0&&(e.payload=t.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:e}}}}}function en(t){return hn(t.payload,"qna")}function Ee(t){const e=b(t.payload.text)??"",n=L(t.payload.action,e);if(n){const s={label:e||n.title,action:n};return typeof t.payload.image_url=="string"&&(s.image=t.payload.image_url),typeof t.payload.theme=="string"&&(s.theme=t.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:s}}}}}const r={text:e};return typeof t.payload.theme=="string"&&(r.theme=t.payload.theme),fe({payload:r})}function Ne(t){const e=(t.payload.action_list??[]).map(n=>{const r=b(n.title)??"",s=L(n.requestDetails,r),i=s?{label:r,action:s}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Re(e.filter(Le),"qna")}function tn(t){const n={reviews:(t.payload.reviews??[]).map(r=>{const s={};return typeof r.review_class=="string"&&(s.review_class=r.review_class),typeof r.review_text=="string"&&(s.review_text=r.review_text),(typeof r.review_rating=="string"||typeof r.review_rating=="number")&&(s.review_rating=r.review_rating),typeof r.review_tag=="string"&&(s.review_tag=r.review_tag),s})};return typeof t.payload.sku=="string"&&(n.sku=t.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:n}}}}}function nn(t){const e={};return Array.isArray(t.payload.pros)&&(e.pros=t.payload.pros),Array.isArray(t.payload.cons)&&(e.cons=t.payload.cons),typeof t.payload.product_name=="string"&&(e.productName=t.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:e}}}}}function sn(t){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:t.payload}}}function rn(t){const e=t.payload.product_suggestions??[],n=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=gn(s);if(!i)continue;const a={product:i},o=L(s.requestDetails,i.name);o&&(a.action=o),typeof s.role=="string"&&(a.role=s.role),typeof s.reason=="string"&&(a.reason=s.reason),typeof s.review_highlight=="string"&&(a.reviewHighlight=s.review_highlight),Array.isArray(s.labels)&&(a.labels=s.labels),typeof s.expert_quality_score=="number"&&(a.expertQualityScore=s.expert_quality_score),n.push(a)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:t.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function an(t){const e=t.payload.product_groupings??[],n=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=b(s.name)??"",a=s.sku&&s.sku.length>0?{type:"findSimilar",payload:{sku:s.sku}}:void 0,o=L(s.requestDetails??a,i);if(!o)continue;const c={name:i,action:o};if(Array.isArray(s.labels)){const u=s.labels.filter(h=>typeof h=="string");u.length>0&&(c.labels=u)}typeof s.image=="string"&&(c.image=s.image),n.push(c)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:t.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function on(t){const e=t.payload.suggested_searches??[],n=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=b(s.short_name,s.chosen_attribute,s.detailed_user_message)??`Arama ${r+1}`,a={},o=b(s.detailed_user_message);o&&(a.text=o),s.group_skus&&Array.isArray(s.group_skus)&&(a.group_skus=s.group_skus);const c=b(s.sku,s.representative_product_sku);c&&(a.sku=c),a.is_suggested_text=1;const u={type:"inputText",payload:a},h=L(s.requestDetails??u,i);if(!h)continue;const k={shortName:i,action:h},T=b(s.detailed_user_message);T&&T!==i&&(k.detailedMessage=T);const C=b(s.why_different);C&&(k.whyDifferent=C),typeof s.image=="string"&&(k.image=s.image),n.push(k)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:t.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:n}}}}}}function cn(t){const e=L(t.payload.requestDetails,b(t.payload.review_count,t.payload.text,t.payload.title)??"Urun yorumlarini goster");if(!e)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t.payload}};const n={action:e};return t.payload.title&&(n.title=t.payload.title),t.payload.text&&(n.text=t.payload.text),t.payload.review_count&&(n.reviewCount=t.payload.review_count),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function dn(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function un(t){return{type:"metadata",sessionId:"",model:"",meta:{voice:t.payload}}}function ln(t){const e=t.payload.group_list??[],n=[];for(const s of e){const i=s.group_name??"",a=(s.product_list??[]).map(z);n.push({groupName:i,products:a})}const r=[];for(const s of t.payload.filter_tags??[]){const i=s.title??"";if(!i)continue;const a=L(s.requestDetails,i),o={title:i};a&&(o.action=a),r.push(o)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:r}}}},panelHint:"panel"}}function fn(t){return{type:"metadata",sessionId:"",model:"",meta:{formType:t.type,formPayload:t.payload??{}}}}function pn(t){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:t.payload??{}}}}function Re(t,e){const n={},r=[];for(let s=0;s<t.length;s++){const i=t[s];if(!i)continue;const a=`action-${s}`;r.push(a);const o={label:i.label,action:i.action};i.icon!==void 0&&(o.icon=i.icon),i.image!==void 0&&(o.image=i.image),i.description!==void 0&&(o.description=i.description),n[a]={type:"ActionButton",props:o}}return n.root={type:"ActionButtons",props:{buttons:t.map(s=>{const i={label:s.label,action:s.action};return s.image!==void 0&&(i.image=s.image),s.description!==void 0&&(i.description=s.description),s.icon!==void 0&&(i.icon=s.icon),i})},children:r},{type:"ui_spec",widget:e,spec:{root:"root",elements:n}}}function Oe(t,e){const n={},r=[];for(let s=0;s<t.length;s++){const i=t[s];if(!i)continue;const a=`product-${s}`;r.push(a),n[a]={type:"ProductCard",props:{product:z(i),index:s}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:e,spec:{root:"root",elements:n}}}function hn(t,e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:z(t),index:0}}}}}}function mn(t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function gn(t){const e=b(t.sku),n=b(t.short_name),r=U(t.product_item)??t;return _n(r,e,n)}function _n(t,e,n){const r=b(t.sku,e),s=b(t.name,n);if(!r||!s)return null;const i={sku:r,name:s},a=b(t.brand);a&&(i.brand=a);const o=b(t.url);o&&(i.url=o);const c=yn(t.images);if(c.length>0)i.images=c;else{const w=b(t.image,t.image_url,t.imageUrl);w&&(i.images=[w])}const u=J(t.price_discounted);u!==void 0&&(i.price_discounted=u);const h=J(t.price);h!==void 0&&(i.price=h);const k=J(t.rating);k!==void 0&&(i.rating=k);const T=J(t.review_count)??J(t.reviewCount);T!==void 0&&(i.review_count=T);const C=b(t.cart_code,t.cartCode);return C&&(i.cart_code=C),typeof t.in_stock=="boolean"&&(i.in_stock=t.in_stock),typeof t.inStock=="boolean"&&(i.in_stock=t.inStock),z(i)}function L(t,e){const n=U(t);if(!n)return null;const r=n.type;if(typeof r!="string"||r.length===0)return null;const s={title:e||r,type:r};return n.payload!==void 0&&(s.payload=n.payload),s}function U(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function b(...t){for(const e of t)if(typeof e=="string"){const n=e.trim();if(n.length>0)return n}}function yn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):[]}function J(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){const e=t.replace(",","."),n=Number(e);if(Number.isFinite(n))return n}}function Le(t){return t!=null}function z(t){const e=t.price_discounted!=null&&t.price_discounted>0?t.price_discounted:t.price,n=t.price_discounted!=null&&t.price_discounted>0&&t.price!=null?t.price:void 0;let r;n!=null&&e!=null&&n>0&&(r=Math.round((n-e)/n*100));const s=b(t.brand),i=b(t.name)??t.sku,a=s&&!i.startsWith(s)?`${s} ${i}`:i,o={sku:t.sku,name:a,url:b(t.url)??""},c=t.images?.[0];return c&&(o.imageUrl=c),t.images&&t.images.length>1&&(o.images=t.images),e!=null&&(o.price=String(e)),n!=null&&(o.originalPrice=String(n)),r!==void 0&&(o.discountPercent=r),s!==void 0&&(o.brand=s),t.rating!==void 0&&(o.rating=t.rating),t.review_count!==void 0&&(o.reviewCount=t.review_count),t.cart_code!==void 0&&(o.cartCode=t.cart_code),t.in_stock!==void 0&&(o.inStock=t.in_stock),t.variants&&t.variants.length>0&&(o.variants=t.variants),t.discount_reason!==void 0&&(o.discountReason=t.discount_reason),t.promotions&&t.promotions.length>0&&(o.promotions=t.promotions),o}async function vn(t,e,n){const r=jt("launcher_action",e),s={uiSpecs:[],actions:[]},i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};n!==void 0&&(i.signal=n);const a=await fetch(r,i);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const o={onEvent:c=>{const u=qt(c);if(u&&(u.type==="ui_spec"&&s.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const h of Object.values(u.spec.elements))if(h.type==="ActionButton"&&h.props?.action){const k=h.props.action;s.actions.push(k)}}}};return n!==void 0&&(o.signal=n),await Lt(a,o),s}function Pe(t){const e=document.createElement("div");e.className="gengage-qna-buttons",e.setAttribute("role","group"),e.setAttribute("aria-label",t.quickQuestionsAriaLabel??"Quick questions"),t.orientation==="vertical"&&(e.style.flexDirection="column");for(const n of t.actions){const r=document.createElement("button");r.className="gengage-qna-button",r.textContent=n.title,r.type="button",r.addEventListener("click",()=>{const s={title:n.title,type:n.type};n.payload!==void 0&&(s.payload=n.payload),t.onAction(s)}),e.appendChild(r)}if(t.ctaText||t.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta",n.textContent=t.ctaText??t.defaultCtaText??"Başka bir şey sor",n.type="button",n.addEventListener("click",()=>{t.onOpenChat?.()}),e.appendChild(n)}return e}function bn(t){const e=document.createElement("div");e.className="gengage-qna-input-wrapper";const n=document.createElement("input");n.type="text",n.className="gengage-qna-input",n.setAttribute("aria-label",t.askQuestionAriaLabel??"Ask a question");const r=Array.isArray(t.placeholders)?t.placeholders:t.placeholders?[t.placeholders]:[t.defaultInputPlaceholder??"Bir soru sorun..."];let s=0;n.placeholder=r[0]??"";let i=null;r.length>1&&(i=setInterval(()=>{n.classList.add("gengage-qna-input--fade"),setTimeout(()=>{s=(s+1)%r.length,n.placeholder=r[s]??"",n.classList.remove("gengage-qna-input--fade")},180)},3e3));const a=document.createElement("button");a.className="gengage-qna-send",a.type="button",a.textContent=t.ctaLabel??t.sendButtonText??"Sor",a.setAttribute("aria-label",t.sendQuestionAriaLabel??"Send question");const o=()=>{const c=n.value.trim();c&&(t.onSubmit({title:c,type:"user_message",payload:c}),n.value="")};return a.addEventListener("click",o),n.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),o())}),e.appendChild(n),e.appendChild(a),e._cleanup=()=>{i&&clearInterval(i)},e}function se(t,e){if(!t||typeof t!="object")return null;const n=t,r=n.type;if(typeof r!="string"||r.length===0)return null;const s=n.title,i=n.payload,a=typeof s=="string"&&s.length>0?s:e;if(!a)return null;const o={title:a,type:r};return i!==void 0&&(o.payload=i),o}function Ze(t){const e={title:t.title,type:t.type};return t.payload!==void 0&&(e.payload=t.payload),e}function je(t,e){const n=[],r=t.props?.actions;if(Array.isArray(r))for(const a of r){const o=se(a);o&&n.push(o)}const s=t.props?.buttons;if(Array.isArray(s))for(const a of s){if(!a||typeof a!="object")continue;const o=a,c=typeof o.label=="string"?o.label:void 0,u=se(o.action,c);u&&n.push(u)}if(t.children)for(const a of t.children){const o=e.elements[a];if(!o||o.type!=="ActionButton")continue;const c=typeof o.props?.label=="string"?o.props.label:void 0,u=se(o.props?.action,c);u&&n.push(u)}const i=new Set;return n.filter(a=>i.has(a.title)?!1:(i.add(a.title),!0))}const qe={ButtonRow:({element:t,spec:e,context:n})=>{const r=je(t,e).map(Ze),s=t.props?.orientation,i={actions:r,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(i.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(i.ctaText=n.ctaText),(s==="horizontal"||s==="vertical")&&(i.orientation=s),Pe(i)},ActionButtons:({element:t,spec:e,context:n})=>{const s={actions:je(t,e).map(Ze),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),Pe(s)},ActionButton:({element:t,context:e})=>{const n=document.createElement("button");n.className="gengage-qna-button",n.type="button";const r=t.props?.label;typeof r=="string"?n.textContent=r:n.textContent=e.i18n.defaultCtaText;const s=se(t.props?.action,typeof r=="string"?r:void 0);return s&&n.addEventListener("click",()=>e.onAction(s)),n},TextInput:({element:t,context:e})=>{const n=t.props?.placeholder,r=typeof n=="string"||Array.isArray(n)?n:e.inputPlaceholder,s=typeof t.props?.ctaLabel=="string"?t.props.ctaLabel:e.ctaText,i={onSubmit:e.onAction,askQuestionAriaLabel:e.i18n.askQuestionAriaLabel,defaultInputPlaceholder:e.i18n.defaultInputPlaceholder,sendButtonText:e.i18n.sendButton,sendQuestionAriaLabel:e.i18n.sendQuestionAriaLabel};return r!==void 0&&(i.placeholders=r),s!==void 0&&(i.ctaLabel=s),bn(i)},QuestionHeading:({element:t})=>{const e=document.createElement("h3");e.className="gengage-qna-heading";const n=t.props?.text;return e.textContent=typeof n=="string"?n:"",e}},pe=({element:t,renderElement:e})=>{if(!t.children||t.children.length===0)return null;const n=document.createElement("div");for(const r of t.children){const s=e(r);s&&n.appendChild(s)}return n};function $e(){return{...qe}}function De(t,e,n=qe,r=pe){return ot({spec:t,context:e,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:r})}const Me={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},kn={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function xn(t){return t?t.toLowerCase().split("-")[0]??"tr":"tr"}function wn(t){return xn(t)==="en"?kn:Me}var v;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(const a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(v||(v={}));var Ue;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Ue||(Ue={}));const f=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),P=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}},d=v.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class R extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),r}static assert(e){if(!(e instanceof R))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,v.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}R.create=t=>new R(t);const he=(t,e)=>{let n;switch(t.code){case d.invalid_type:t.received===f.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,v.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${v.joinValues(t.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${v.joinValues(t.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${v.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:v.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case d.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case d.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=e.defaultError,v.assertNever(t)}return{message:n}};let Tn=he;function Cn(){return Tn}const An=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}};function l(t,e){const n=Cn(),r=An({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===he?void 0:he].filter(s=>!!s)});t.common.issues.push(r)}class S{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return m;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,a=await s.value;r.push({key:i,value:a})}return S.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return m;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:e.value,value:r}}}const m=Object.freeze({status:"aborted"}),Y=t=>({status:"dirty",value:t}),I=t=>({status:"valid",value:t}),Be=t=>t.status==="aborted",Ve=t=>t.status==="dirty",Q=t=>t.status==="valid",re=t=>typeof Promise<"u"&&t instanceof Promise;var p;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));class Z{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ze=(t,e)=>{if(Q(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new R(t.common.issues);return this._error=n,this._error}}};function _(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{const{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??r??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:s}}class y{get description(){return this._def.description}_getType(e){return P(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(re(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},s=this._parseSync({data:e,path:r.path,parent:r});return ze(r,s)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:n});return Q(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Q(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(re(s)?s:Promise.resolve(s));return ze(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:d.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new W({schema:this,typeName:g.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return $.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return N.create(this)}promise(){return ce.create(this,this._def)}or(e){return ae.create([this,e],this._def)}and(e){return oe.create(this,e,this._def)}transform(e){return new W({..._(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ve({..._(this._def),innerType:this,defaultValue:n,typeName:g.ZodDefault})}brand(){return new Gn({typeName:g.ZodBranded,type:this,..._(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new be({..._(this._def),innerType:this,catchValue:n,typeName:g.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return ke.create(this,e)}readonly(){return xe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Sn=/^c[^\s-]{8,}$/i,In=/^[0-9a-z]+$/,En=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Nn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Rn=/^[a-z0-9_-]{21}$/i,On=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ln=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Pn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let me;const jn=/^(?:(?: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])$/,qn=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,$n=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Dn=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Un=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qe="((\\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])))",Bn=new RegExp(`^${Qe}$`);function He(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Vn(t){return new RegExp(`^${He(t)}$`)}function zn(t){let e=`${Qe}T${He(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Qn(t,e){return!!((e==="v4"||!e)&&jn.test(t)||(e==="v6"||!e)&&$n.test(t))}function Hn(t,e){if(!On.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Fn(t,e){return!!((e==="v4"||!e)&&qn.test(t)||(e==="v6"||!e)&&Dn.test(t))}class j extends y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const i=this._getOrReturnCtx(e);return l(i,{code:d.invalid_type,expected:f.string,received:i.parsedType}),m}const r=new S;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?l(s,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&l(s,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Pn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"email",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")me||(me=new RegExp(Zn,"u")),me.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"emoji",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"uuid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Rn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"nanoid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")Sn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")In.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid2",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")En.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ulid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),l(s,{validation:"url",code:d.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"regex",code:d.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?zn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Vn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"duration",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Qn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ip",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Hn(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"jwt",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Fn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cidr",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Un.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64url",code:d.invalid_string,message:i.message}),r.dirty()):v.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:d.invalid_string,...p.errToObj(r)})}_addCheck(e){return new j({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...p.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...p.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...p.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...p.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...p.errToObj(n)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new j({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}j.create=t=>new j({checks:[],typeName:g.ZodString,coerce:t?.coerce??!1,..._(t)});function Wn(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}class X extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const i=this._getOrReturnCtx(e);return l(i,{code:d.invalid_type,expected:f.number,received:i.parsedType}),m}let r;const s=new S;for(const i of this._def.checks)i.kind==="int"?v.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Wn(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.not_finite,message:i.message}),s.dirty()):v.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,r,s){return new X({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:p.toString(s)}]})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&v.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}X.create=t=>new X({checks:[],typeName:g.ZodNumber,coerce:t?.coerce||!1,..._(t)});class K extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let r;const s=new S;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):v.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:f.bigint,received:n.parsedType}),m}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,r,s){return new K({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:p.toString(s)}]})}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}K.create=t=>new K({checks:[],typeName:g.ZodBigInt,coerce:t?.coerce??!1,..._(t)});class ge extends y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.boolean,received:r.parsedType}),m}return I(e.data)}}ge.create=t=>new ge({typeName:g.ZodBoolean,coerce:t?.coerce||!1,..._(t)});class ie extends y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const i=this._getOrReturnCtx(e);return l(i,{code:d.invalid_type,expected:f.date,received:i.parsedType}),m}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return l(i,{code:d.invalid_date}),m}const r=new S;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):v.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ie({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ie.create=t=>new ie({checks:[],coerce:t?.coerce||!1,typeName:g.ZodDate,..._(t)});class Fe extends y{_parse(e){if(this._getType(e)!==f.symbol){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.symbol,received:r.parsedType}),m}return I(e.data)}}Fe.create=t=>new Fe({typeName:g.ZodSymbol,..._(t)});class We extends y{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.undefined,received:r.parsedType}),m}return I(e.data)}}We.create=t=>new We({typeName:g.ZodUndefined,..._(t)});class Ge extends y{_parse(e){if(this._getType(e)!==f.null){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.null,received:r.parsedType}),m}return I(e.data)}}Ge.create=t=>new Ge({typeName:g.ZodNull,..._(t)});class Je extends y{constructor(){super(...arguments),this._any=!0}_parse(e){return I(e.data)}}Je.create=t=>new Je({typeName:g.ZodAny,..._(t)});class _e extends y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return I(e.data)}}_e.create=t=>new _e({typeName:g.ZodUnknown,..._(t)});class q extends y{_parse(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:f.never,received:n.parsedType}),m}}q.create=t=>new q({typeName:g.ZodNever,..._(t)});class Ye extends y{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.void,received:r.parsedType}),m}return I(e.data)}}Ye.create=t=>new Ye({typeName:g.ZodVoid,..._(t)});class N extends y{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==f.array)return l(n,{code:d.invalid_type,expected:f.array,received:n.parsedType}),m;if(s.exactLength!==null){const a=n.data.length>s.exactLength.value,o=n.data.length<s.exactLength.value;(a||o)&&(l(n,{code:a?d.too_big:d.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(l(n,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(l(n,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,o)=>s.type._parseAsync(new Z(n,a,n.path,o)))).then(a=>S.mergeArray(r,a));const i=[...n.data].map((a,o)=>s.type._parseSync(new Z(n,a,n.path,o)));return S.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new N({...this._def,minLength:{value:e,message:p.toString(n)}})}max(e,n){return new N({...this._def,maxLength:{value:e,message:p.toString(n)}})}length(e,n){return new N({...this._def,exactLength:{value:e,message:p.toString(n)}})}nonempty(e){return this.min(1,e)}}N.create=(t,e)=>new N({type:t,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,..._(e)});function H(t){if(t instanceof x){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=$.create(H(r))}return new x({...t._def,shape:()=>e})}else return t instanceof N?new N({...t._def,type:H(t.element)}):t instanceof $?$.create(H(t.unwrap())):t instanceof G?G.create(H(t.unwrap())):t instanceof B?B.create(t.items.map(e=>H(e))):t}class x extends y{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=v.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==f.object){const u=this._getOrReturnCtx(e);return l(u,{code:d.invalid_type,expected:f.object,received:u.parsedType}),m}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof q&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const h=i[u],k=s.data[u];c.push({key:{status:"valid",value:u},value:h._parse(new Z(s,k,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof q){const u=this._def.unknownKeys;if(u==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(u==="strict")o.length>0&&(l(s,{code:d.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const h of o){const k=s.data[h];c.push({key:{status:"valid",value:h},value:u._parse(new Z(s,k,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const h of c){const k=await h.key,T=await h.value;u.push({key:k,value:T,alwaysSet:h.alwaysSet})}return u}).then(u=>S.mergeObjectSync(r,u)):S.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new x({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{const s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:p.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new x({...this._def,unknownKeys:"strip"})}passthrough(){return new x({...this._def,unknownKeys:"passthrough"})}extend(e){return new x({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new x({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:g.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new x({...this._def,catchall:e})}pick(e){const n={};for(const r of v.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new x({...this._def,shape:()=>n})}omit(e){const n={};for(const r of v.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new x({...this._def,shape:()=>n})}deepPartial(){return H(this)}partial(e){const n={};for(const r of v.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new x({...this._def,shape:()=>n})}required(e){const n={};for(const r of v.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof $;)i=i._def.innerType;n[r]=i}return new x({...this._def,shape:()=>n})}keyof(){return tt(v.objectKeys(this.shape))}}x.create=(t,e)=>new x({shape:()=>t,unknownKeys:"strip",catchall:q.create(),typeName:g.ZodObject,..._(e)}),x.strictCreate=(t,e)=>new x({shape:()=>t,unknownKeys:"strict",catchall:q.create(),typeName:g.ZodObject,..._(e)}),x.lazycreate=(t,e)=>new x({shape:t,unknownKeys:"strip",catchall:q.create(),typeName:g.ZodObject,..._(e)});class ae extends y{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new R(o.ctx.common.issues));return l(n,{code:d.invalid_union,unionErrors:a}),m}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},h=c._parseSync({data:n.data,path:n.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new R(c));return l(n,{code:d.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}ae.create=(t,e)=>new ae({options:t,typeName:g.ZodUnion,..._(e)});function ye(t,e){const n=P(t),r=P(e);if(t===e)return{valid:!0,data:t};if(n===f.object&&r===f.object){const s=v.objectKeys(e),i=v.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(const o of i){const c=ye(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(n===f.array&&r===f.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const a=t[i],o=e[i],c=ye(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===f.date&&r===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class oe extends y{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,a)=>{if(Be(i)||Be(a))return m;const o=ye(i.value,a.value);return o.valid?((Ve(i)||Ve(a))&&n.dirty(),{status:n.value,value:o.data}):(l(r,{code:d.invalid_intersection_types}),m)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}oe.create=(t,e,n)=>new oe({left:t,right:e,typeName:g.ZodIntersection,..._(n)});class B extends y{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.array)return l(r,{code:d.invalid_type,expected:f.array,received:r.parsedType}),m;if(r.data.length<this._def.items.length)return l(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&r.data.length>this._def.items.length&&(l(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Z(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>S.mergeArray(n,a)):S.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new B({...this._def,rest:e})}}B.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new B({items:t,typeName:g.ZodTuple,rest:null,..._(e)})};class Xe extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.map)return l(r,{code:d.invalid_type,expected:f.map,received:r.parsedType}),m;const s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([o,c],u)=>({key:s._parse(new Z(r,o,r.path,[u,"key"])),value:i._parse(new Z(r,c,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,h=await c.value;if(u.status==="aborted"||h.status==="aborted")return m;(u.status==="dirty"||h.status==="dirty")&&n.dirty(),o.set(u.value,h.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,h=c.value;if(u.status==="aborted"||h.status==="aborted")return m;(u.status==="dirty"||h.status==="dirty")&&n.dirty(),o.set(u.value,h.value)}return{status:n.value,value:o}}}}Xe.create=(t,e,n)=>new Xe({valueType:e,keyType:t,typeName:g.ZodMap,..._(n)});class ee extends y{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.set)return l(r,{code:d.invalid_type,expected:f.set,received:r.parsedType}),m;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(l(r,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(l(r,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const h of c){if(h.status==="aborted")return m;h.status==="dirty"&&n.dirty(),u.add(h.value)}return{status:n.value,value:u}}const o=[...r.data.values()].map((c,u)=>i._parse(new Z(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,n){return new ee({...this._def,minSize:{value:e,message:p.toString(n)}})}max(e,n){return new ee({...this._def,maxSize:{value:e,message:p.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}ee.create=(t,e)=>new ee({valueType:t,minSize:null,maxSize:null,typeName:g.ZodSet,..._(e)});class Ke extends y{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Ke.create=(t,e)=>new Ke({getter:t,typeName:g.ZodLazy,..._(e)});class et extends y{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return l(n,{received:n.data,code:d.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}et.create=(t,e)=>new et({value:t,typeName:g.ZodLiteral,..._(e)});function tt(t,e){return new F({values:t,typeName:g.ZodEnum,..._(e)})}class F extends y{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return l(n,{expected:v.joinValues(r),received:n.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return l(n,{received:n.data,code:d.invalid_enum_value,options:r}),m}return I(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return F.create(e,{...this._def,...n})}exclude(e,n=this._def){return F.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}F.create=tt;class nt extends y{_parse(e){const n=v.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==f.string&&r.parsedType!==f.number){const s=v.objectValues(n);return l(r,{expected:v.joinValues(s),received:r.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(v.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=v.objectValues(n);return l(r,{received:r.data,code:d.invalid_enum_value,options:s}),m}return I(e.data)}get enum(){return this._def.values}}nt.create=(t,e)=>new nt({values:t,typeName:g.ZodNativeEnum,..._(e)});class ce extends y{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==f.promise&&n.common.async===!1)return l(n,{code:d.invalid_type,expected:f.promise,received:n.parsedType}),m;const r=n.parsedType===f.promise?n.data:Promise.resolve(n.data);return I(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}ce.create=(t,e)=>new ce({type:t,typeName:g.ZodPromise,..._(e)});class W extends y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{l(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async o=>{if(n.value==="aborted")return m;const c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?m:c.status==="dirty"||n.value==="dirty"?Y(c.value):c});{if(n.value==="aborted")return m;const o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?m:o.status==="dirty"||n.value==="dirty"?Y(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?m:(o.status==="dirty"&&n.dirty(),a(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&n.dirty(),a(o.value).then(()=>({status:n.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Q(a))return m;const o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Q(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:n.value,value:o})):m);v.assertNever(s)}}W.create=(t,e,n)=>new W({schema:t,typeName:g.ZodEffects,effect:e,..._(n)}),W.createWithPreprocess=(t,e,n)=>new W({schema:e,effect:{type:"preprocess",transform:t},typeName:g.ZodEffects,..._(n)});class $ extends y{_parse(e){return this._getType(e)===f.undefined?I(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$.create=(t,e)=>new $({innerType:t,typeName:g.ZodOptional,..._(e)});class G extends y{_parse(e){return this._getType(e)===f.null?I(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}G.create=(t,e)=>new G({innerType:t,typeName:g.ZodNullable,..._(e)});class ve extends y{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===f.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ve.create=(t,e)=>new ve({innerType:t,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class be extends y{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return re(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new R(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new R(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}be.create=(t,e)=>new be({innerType:t,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class st extends y{_parse(e){if(this._getType(e)!==f.nan){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.nan,received:r.parsedType}),m}return{status:"valid",value:e.data}}}st.create=t=>new st({typeName:g.ZodNaN,..._(t)});class Gn extends y{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class ke extends y{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?m:i.status==="dirty"?(n.dirty(),Y(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?m:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new ke({in:e,out:n,typeName:g.ZodPipeline})}}class xe extends y{_parse(e){const n=this._def.innerType._parse(e),r=s=>(Q(s)&&(s.value=Object.freeze(s.value)),s);return re(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}xe.create=(t,e)=>new xe({innerType:t,typeName:g.ZodReadonly,..._(e)});var g;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(g||(g={}));const V=j.create,Jn=ge.create,Yn=_e.create;q.create;const Xn=N.create,te=x.create,Kn=ae.create;oe.create,B.create;const rt=F.create;ce.create,$.create,G.create;const es=te({title:V(),type:V(),payload:Yn().optional()}),ts=te({label:V(),action:es,variant:rt(["primary","outline","ghost"]).optional()}),ns=te({orientation:rt(["horizontal","vertical"]).optional(),wrap:Jn().optional()}),ss=te({placeholder:Kn([V(),Xn(V())]).optional(),ctaLabel:V().optional()}),rs=te({text:V()}),is={components:{ActionButton:{schema:ts,description:"A single clickable QNA action button."},ButtonRow:{schema:ns,description:"Container for a group of QNA action buttons."},TextInput:{schema:ss,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:rs,description:"A heading displayed above the QNA button group."}}};class it extends Nt{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=Me,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this.root.appendChild(this._contentEl);const n=e.pageContext?.sku;n&&(this._lastSku=n,await this._fetchAndRender(n)),this.isVisible=!0}onUpdate(e){const n=e.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._contentEl.querySelector(".gengage-qna-input-wrapper")?._cleanup?.(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._contentEl.innerHTML="";const n=this._createLoadingIndicator();this._contentEl.appendChild(n);const r={middlewareUrl:this.config.middlewareUrl},s=crypto.randomUUID(),i=Date.now();this.track(dt(this.analyticsContext(),{endpoint:"launcher_action",request_id:s,widget:"qna"}));try{const a={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e,locale:this.config.locale??"tr"},o=this.config.pageContext?.pageType;o!==void 0&&(a.page_type=o);const c=await vn(a,r,this._abortController.signal);if(this.track(ut(this.analyticsContext(),{request_id:s,latency_ms:Date.now()-i,chunk_count:c.actions.length,widget:"qna"})),this.track(pt(this.analyticsContext(),{message_count:c.actions.length,history_ref:s,redaction_level:"none",widget:"qna"})),!this._contentEl)return;if(this._contentEl.innerHTML="",!this._specIncludesType(c.uiSpecs,"QuestionHeading")&&this.config.showStaticQuestion&&this.config.staticQuestionText){const A=document.createElement("h3");A.className="gengage-qna-heading",A.textContent=this.config.staticQuestionText,this._contentEl.appendChild(A)}const h=this.config.inputPlaceholder,k=c.actions.length>0&&h===!0?c.actions.map(A=>A.title):h===!0?this._i18n.defaultInputPlaceholder:h,T={onAction:this._actionHandler,i18n:this._i18n};h===void 0&&(T.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(T.ctaText=this.config.ctaText)),k!==void 0&&(T.inputPlaceholder=k);const C=this._buildFallbackActionsSpec(c.actions),E=(c.uiSpecs.length>0?c.uiSpecs:[C]).filter(A=>Object.keys(A.elements).length>0);for(const A of E){const ne=this._renderUISpec(A,T);this._contentEl.appendChild(ne)}if(h!==void 0&&!this._specIncludesType(E,"TextInput")){const A={root:"root",elements:{root:{type:"TextInput",props:{placeholder:k,ctaLabel:this.config.ctaText}}}},ne=this._renderUISpec(A,T);this._contentEl.appendChild(ne)}}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return;ue("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:xt(this.config.locale)}),this.track(lt(this.analyticsContext(),{request_id:s,error_code:"FETCH_ERROR",error_message:a instanceof Error?a.message:String(a),widget:"qna"}))}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let n=0;n<3;n++){const r=document.createElement("div");r.className="gengage-qna-loading-dot",e.appendChild(r)}return e}_resolveI18n(e){return{...wn(e.locale),...e.i18n}}_resolveUISpecRegistry(){const e=$e();return ct(e,this.config.renderer?.registry)}_renderUISpec(e,n){const r=this._resolveUISpecRegistry(),s=this.config.renderer?.unknownRenderer??pe,i=(c,u)=>De(c,u,r,s),a=this.config.renderer?.renderUISpec;return a?a(e,n,{registry:r,unknownRenderer:s,defaultRender:i}):i(e,n)}_specIncludesType(e,n){for(const r of e)for(const s of Object.values(r.elements))if(s.type===n)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const n={},r=[];for(let s=0;s<e.length;s++){const i=e[s],a=`action-${s}`;r.push(a),n[a]={type:"ActionButton",props:{label:i.title,action:{title:i.title,type:i.type,payload:i.payload}}}}return n.root={type:"ButtonRow",children:r},{root:"root",elements:n}}_handleAction(e){this.config.onActionSelected?.(e),ue("gengage:qna:action",e)}_handleOpenChat(){this.config.onOpenChat?.(),ue("gengage:qna:open-chat",{})}}function as(){return new it}D.GengageQNA=it,D.createDefaultQnaUISpecRegistry=$e,D.createQNAWidget=as,D.defaultQnaUnknownUISpecRenderer=pe,D.qnaCatalog=is,D.renderQnaUISpec=De,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
|
|
46
|
+
`,document.head.appendChild(e)}class un{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=Gt(t.theme);this.config={...t,theme:n,session:Wt(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),tn();const o=Ie("gengage:context:update",r=>this.update(r));this._cleanups.push(o);try{await this.onInit(this.config)}catch(r){throw this.destroy(),r}this.isInitialised=!0,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"?Qt:Ht;this.track(o(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(Bt(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-${dn(n)}`;this.root.style.setProperty(r,o)}}}}function dn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Pe(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function ln(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 Re(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!0;try{const r=JSON.parse(o);return Pe(r)?(t.onEvent(r),r.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const r=ln(o);if(r.length>1){for(const s of r)try{const i=JSON.parse(s);if(!Pe(i))continue;if(t.onEvent(i),i.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function pn(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="";try{for(;;){const{done:s,value:i}=await n.read();if(s)break;r+=o.decode(i,{stream:!0});const a=r.split(`
|
|
47
|
+
`);r=a.pop()??"";for(const c of a)if(Re(c,t))return}if(r.trim()&&Re(r,t))return}catch(s){if(s instanceof DOMException&&s.name==="AbortError")return;t.onError?.(s instanceof Error?s:new Error(String(s)))}finally{n.releaseLock()}t.onDone?.()}const fn={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings",proactive_action:"/proactive_action"},hn={process_action:"/message",launcher_action:"/message"};function gn(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 mn(e,t){const n=gn(t?.middlewareUrl);if(t.backendType==="acap"){const o=t.accountId??"",r=hn[e];return`${n}/api/chat/${o}${r}`}return`${n}/chat${fn[e]}`}function _n(e){if(typeof e.type!="string")return null;if(yn(e))return e;const n=e;switch(n.type){case"outputText":return vn(n);case"suggestedActions":return wn(n);case"productList":return bn(n);case"productDetails":return kn(n);case"productDetailsSimilars":return zn(n);case"comparisonTable":return Sn(n);case"context":return $n(n);case"chatStreamEnd":return Tn();case"loading":return En(n);case"panelLoading":return An(n);case"similarLoading":return In(n);case"redirect":return Zn(n);case"error":return On(n);case"dummy":return Cn();case"launcherAction":return Pn(n);case"text":return he(n);case"productItem":return Rn(n);case"text_image":return Ne(n);case"quick_qna":return De(n);case"reviewHighlights":return Nn(n);case"aiProductSuggestions":return Ln(n);case"aiProductGroupings":return Un(n);case"aiSuggestedSearches":return xn(n);case"prosAndCons":return Dn(n);case"getGroundingReview":return qn(n);case"voice":return Jn(n);case"visitorDataResponse":return jn(n);case"productListPreview":return Fn();case"groupList":return Bn(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Mn(n);case"launcherContent":return Hn(n);case"handoff":return Qn(n);default:return null}}function yn(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const o=U(e.spec);return o?typeof o.root=="string"&&U(o.elements)!==null:!1}case"action":{const n=U(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 vn(e){const t=v(e.payload.text,e.payload.plain_text)??"",n=v(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const 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 wn(e){const t=(e.payload.actions??[]).map(n=>{const o=v(n.title)??"",r=R(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 je(t.filter(Ue),"chat")}function bn(e){const t=Le(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})),t}function kn(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:M(t)}}}},panelHint:"panel"}:Wn("chat")}function zn(e){const t=Le(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Sn(e){const t=e.payload.multiple_product_details??[],n=e.payload.product_comparison_framework,o=e.payload.table,r=[];for(const m of t){const _=M(m);r.push(_)}const s=[];if(o){const m=n?.criteria_view??n?.criteria_view_short??{},_=n?.compared_field_names??Object.keys(o);for(const C of _){const $=o[C];if(!$||!Array.isArray($))continue;const B=m[C]??C;s.push({label:B,values:$.map(E=>typeof E=="string"?E:String(E??""))})}}let i;n?.recommended_choice_sku?i=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(i=n.winner_product[0]?.sku);const a=i?r.find(m=>m.sku===i)??r[0]:r[0],c=[];if(Array.isArray(n?.key_differences))for(const m of n.key_differences)typeof m=="string"&&c.push(m);const u=[];if(n?.special_considerations)for(const m of n.special_considerations)typeof m=="string"&&u.push(m);const l=n?.recommended_choice,h=n?.winner_hits,p={};for(const m of r){const _=m.sku;_&&(p[_]={title:m.name??_,type:"launchSingleProduct",payload:{sku:_}})}const f={products:r,attributes:s,highlights:c,productActions:p};return a&&(f.recommended=a),u.length>0&&(f.specialCases=u),l&&(f.recommendedText=l),h&&(f.winnerHits=h),typeof n?.key_differences=="string"&&(f.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(f.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:f}}},panelHint:"panel"}}function $n(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Tn(){return{type:"done"}}function En(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 An(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function In(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Zn(e){const t=v(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:v(e.payload.to)}}}function On(e){return{type:"error",code:"BACKEND_ERROR",message:v(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Cn(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Pn(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),De({payload:s})}const o=U(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),Ne({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=U(t.payload)??void 0;return i!==void 0&&(s.type=i),c!==void 0&&(s.payload=c),a!==void 0&&(s.theme=a),he({payload:s})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function he(e){const t={text:v(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function Rn(e){return Vn(e.payload,"qna")}function Ne(e){const t=v(e.payload.text)??"",n=R(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),he({payload:o})}function De(e){const t=(e.payload.action_list??[]).map(n=>{const o=v(n.title)??"",r=R(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 je(t.filter(Ue),"qna")}function Nn(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 Dn(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 jn(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Ln(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=Gn(r);if(!s)continue;const i={product:s},a=R(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 Un(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=v(r.name)??"",i=r.sku&&r.sku.length>0?{type:"findSimilar",payload:{sku:r.sku}}:void 0,a=R(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 xn(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=v(r.short_name,r.chosen_attribute,r.detailed_user_message)??`Arama ${o+1}`,i={},a=v(r.detailed_user_message);a&&(i.text=a),r.group_skus&&Array.isArray(r.group_skus)&&(i.group_skus=r.group_skus);const c=v(r.sku,r.representative_product_sku);c&&(i.sku=c),i.is_suggested_text=1;const u={type:"inputText",payload:i},l=R(r.requestDetails??u,s);if(!l)continue;const h={shortName:s,action:l},p=v(r.detailed_user_message);p&&p!==s&&(h.detailedMessage=p);const f=v(r.why_different);f&&(h.whyDifferent=f),typeof r.image=="string"&&(h.image=r.image),n.push(h)}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=R(e.payload.requestDetails,v(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 Fn(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Jn(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Bn(e){const t=e.payload.group_list??[],n=[];for(const r of t){const s=r.group_name??"",i=(r.product_list??[]).map(M);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=R(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 Mn(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Qn(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 Hn(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function je(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 Le(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:M(s),index:r}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:o},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Vn(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:M(e),index:0}}}}}}function Wn(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Gn(e){const t=v(e.sku),n=v(e.short_name),o=U(e.product_item)??e;return Kn(o,t,n)}function Kn(e,t,n){const o=v(e.sku,t),r=v(e.name,n);if(!o||!r)return null;const s={sku:o,name:r},i=v(e.brand);i&&(s.brand=i);const a=v(e.url);a&&(s.url=a);const c=Yn(e.images);if(c.length>0)s.images=c;else{const m=v(e.image,e.image_url,e.imageUrl);m&&(s.images=[m])}const u=W(e.price_discounted);u!==void 0&&(s.price_discounted=u);const l=W(e.price);l!==void 0&&(s.price=l);const h=W(e.rating);h!==void 0&&(s.rating=h);const p=W(e.review_count)??W(e.reviewCount);p!==void 0&&(s.review_count=p);const f=v(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),M(s)}function R(e,t){const n=U(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 U(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function v(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function Yn(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function W(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 Ue(e){return e!=null}function M(e){const t=e.price_discounted!=null&&e.price_discounted>0?e.price_discounted:e.price,n=e.price_discounted!=null&&e.price_discounted>0&&e.price!=null?e.price:void 0;let o;n!=null&&t!=null&&n>0&&(o=Math.round((n-t)/n*100));const r=v(e.brand),s=v(e.name)??e.sku,i=r&&!s.toLowerCase().startsWith(r.toLowerCase())?`${r} ${s}`:s,a={sku:e.sku,name:i,url:v(e.url)??""},c=e.images?.[0];return c&&(a.imageUrl=c),e.images&&e.images.length>1&&(a.images=e.images),t!=null&&(a.price=String(t)),n!=null&&(a.originalPrice=String(n)),o!==void 0&&(a.discountPercent=o),r!==void 0&&(a.brand=r),e.rating!==void 0&&(a.rating=e.rating),e.review_count!==void 0&&(a.reviewCount=e.review_count),e.cart_code!==void 0&&(a.cartCode=e.cart_code),e.in_stock!==void 0&&(a.inStock=e.in_stock),e.variants&&e.variants.length>0&&(a.variants=e.variants),e.discount_reason!==void 0&&(a.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(a.promotions=e.promotions),a}async function Xn(e,t,n){const o=mn("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=_n(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 pn(i,a),r}function eo(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function ge(e,t){const n={event:e,...t};eo()&&window.dataLayer.push(n)}function to(e){ge("gengage-on-init",{gengage_widget:e})}function no(e){ge("gengage-show",{gengage_widget:e})}function oo(e,t){ge("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function xe(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??"Başka bir şey sor",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function ro(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??"Bir soru sorun..."];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??"Sor",a.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question");const c=()=>{const u=n.value.trim();u&&(e.onSubmit({title:u,type:"user_message",payload:{text: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 ee(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 qe(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function Fe(e,t){const n=[],o=e.props?.actions;if(Array.isArray(o))for(const i of o){const a=ee(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=ee(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=ee(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 Je={ButtonRow:({element:e,spec:t,context:n})=>{const o=Fe(e,t).map(qe),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),xe(s)},ActionButtons:({element:e,spec:t,context:n})=>{const r={actions:Fe(e,t).map(qe),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),xe(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=ee(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:t.ctaText,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),ro(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}},me=({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 Be(){return{...Je}}function Me(e,t,n=Je,o=me){return Ut({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:o})}const Qe={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},io={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function so(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function ao(e){return so(e)==="en"?io:Qe}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 He extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ve={};function x(e){return Ve}function We(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 _e(e,t){return typeof t=="bigint"?t.toString():t}function ye(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ve(e){return e==null}function we(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Ge=Symbol("evaluating");function y(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Ge)return o===void 0&&(o=Ge,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function q(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function N(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function Ke(e){return JSON.stringify(e)}function co(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ye="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const uo=ye(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function G(e){if(te(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(te(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Xe(e){return G(e)?{...e}:Array.isArray(e)?[...e]:e}const lo=new Set(["string","number","symbol"]);function ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(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 po(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function fo(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=N(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 q(this,"shape",i),i},checks:[]});return D(e,s)}function ho(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=N(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 q(this,"shape",i),i},checks:[]});return D(e,s)}function go(e,t){if(!G(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=N(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return q(this,"shape",s),s}});return D(e,r)}function mo(e,t){if(!G(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=N(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return q(this,"shape",o),o}});return D(e,n)}function _o(e,t){const n=N(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return q(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return D(e,n)}function yo(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=N(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 q(this,"shape",c),c},checks:[]});return D(t,i)}function vo(e,t,n){const o=N(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 q(this,"shape",s),s}});return D(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 et(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function oe(e){return typeof e=="string"?e:e?.message}function F(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const r=oe(e.inst?._zod.def?.error?.(e))??oe(t?.error?.(e))??oe(n.customError?.(e))??oe(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function be(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function K(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const tt=(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,_e,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},nt=d("$ZodError",tt),ot=d("$ZodError",tt,{Parent:Error});function wo(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 bo(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 ke=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=>F(c,s,x())));throw Ye(a,r?.callee),a}return i.value},ze=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=>F(c,s,x())));throw Ye(a,r?.callee),a}return i.value},re=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??nt)(s.issues.map(i=>F(i,r,x())))}:{success:!0,data:s.value}},ko=re(ot),ie=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=>F(i,r,x())))}:{success:!0,data:s.value}},zo=ie(ot),So=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ke(e)(t,n,r)},$o=e=>(t,n,o)=>ke(e)(t,n,o),To=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ze(e)(t,n,r)},Eo=e=>async(t,n,o)=>ze(e)(t,n,o),Ao=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return re(e)(t,n,r)},Io=e=>(t,n,o)=>re(e)(t,n,o),Zo=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ie(e)(t,n,r)},Oo=e=>async(t,n,o)=>ie(e)(t,n,o),Co=/^[cC][^\s-]{8,}$/,Po=/^[0-9a-z]+$/,Ro=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,No=/^[0-9a-vA-V]{20}$/,Do=/^[A-Za-z0-9]{27}$/,jo=/^[a-zA-Z0-9_-]{21}$/,Lo=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Uo=/^([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})$/,rt=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)$/,xo=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,qo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Fo(){return new RegExp(qo,"u")}const Jo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Bo=/^(([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}|:))$/,Mo=/^((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])$/,Qo=/^(([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])$/,Ho=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,it=/^[A-Za-z0-9_-]*$/,Vo=/^\+[1-9]\d{6,14}$/,st="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Wo=new RegExp(`^${st}$`);function at(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 Go(e){return new RegExp(`^${at(e)}$`)}function Ko(e){const t=at({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(`^${st}T(?:${o})$`)}const Yo=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Xo=/^(?:true|false)$/i,er=/^[^A-Z]*$/,tr=/^[^a-z]*$/,O=d("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),nr=d("$ZodCheckMaxLength",(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!ve(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=be(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),or=d("$ZodCheckMinLength",(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!ve(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=be(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),rr=d("$ZodCheckLengthEquals",(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!ve(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=be(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})}}),se=d("$ZodCheckStringFormat",(e,t)=>{var n,o;O.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=()=>{})}),ir=d("$ZodCheckRegex",(e,t)=>{se.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),sr=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=er),se.init(e,t)}),ar=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=tr),se.init(e,t)}),cr=d("$ZodCheckIncludes",(e,t)=>{O.init(e,t);const n=ne(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})}}),ur=d("$ZodCheckStartsWith",(e,t)=>{O.init(e,t);const n=new RegExp(`^${ne(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})}}),dr=d("$ZodCheckEndsWith",(e,t)=>{O.init(e,t);const n=new RegExp(`.*${ne(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})}}),lr=d("$ZodCheckOverwrite",(e,t)=>{O.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class pr{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
|
+
`).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 fr={major:4,minor:3,patch:6},k=d("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=fr;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=ko(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return zo(e,r).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Se=d("$ZodString",(e,t)=>{k.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Yo(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}}),w=d("$ZodStringFormat",(e,t)=>{se.init(e,t),Se.init(e,t)}),hr=d("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Uo),w.init(e,t)}),gr=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=rt(o))}else t.pattern??(t.pattern=rt());w.init(e,t)}),mr=d("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xo),w.init(e,t)}),_r=d("$ZodURL",(e,t)=>{w.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})}}}),yr=d("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Fo()),w.init(e,t)}),vr=d("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=jo),w.init(e,t)}),wr=d("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Co),w.init(e,t)}),br=d("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Po),w.init(e,t)}),kr=d("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ro),w.init(e,t)}),zr=d("$ZodXID",(e,t)=>{t.pattern??(t.pattern=No),w.init(e,t)}),Sr=d("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Do),w.init(e,t)}),$r=d("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ko(t)),w.init(e,t)}),Tr=d("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Wo),w.init(e,t)}),Er=d("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Go(t)),w.init(e,t)}),Ar=d("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Lo),w.init(e,t)}),Ir=d("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Jo),w.init(e,t),e._zod.bag.format="ipv4"}),Zr=d("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Bo),w.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})}}}),Or=d("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Mo),w.init(e,t)}),Cr=d("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Qo),w.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 ct(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Pr=d("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ho),w.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ct(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Rr(e){if(!it.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ct(n)}const Nr=d("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=it),w.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Rr(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Dr=d("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Vo),w.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 Lr=d("$ZodJWT",(e,t)=>{w.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})}}),Ur=d("$ZodBoolean",(e,t)=>{k.init(e,t),e._zod.pattern=Xo,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}}),xr=d("$ZodUnknown",(e,t)=>{k.init(e,t),e._zod.parse=n=>n}),qr=d("$ZodNever",(e,t)=>{k.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ut(e,t,n){e.issues.length&&t.issues.push(...et(n,e.issues)),t.value[n]=e.value}const Fr=d("$ZodArray",(e,t)=>{k.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=>ut(u,n,i))):ut(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function ae(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...et(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function dt(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=po(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function lt(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=>ae(f,n,h,t,l))):ae(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 Jr=d("$ZodObject",(e,t)=>{if(k.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=ye(()=>dt(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=te,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],m=f._zod.optout==="optional",_=f._zod.run({value:u[p],issues:[]},c);_ instanceof Promise?l.push(_.then(C=>ae(C,a,p,u,m))):ae(_,a,p,u,m)}return s?lt(l,u,a,c,o.value,e):l.length?Promise.all(l).then(()=>a):a}}),Br=d("$ZodObjectJIT",(e,t)=>{Jr.init(e,t);const n=e._zod.parse,o=ye(()=>dt(t)),r=p=>{const f=new pr(["shape","payload","ctx"]),m=o.value,_=E=>{const A=Ke(E);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};f.write("const input = payload.value;");const C=Object.create(null);let $=0;for(const E of m.keys)C[E]=`key_${$++}`;f.write("const newResult = {};");for(const E of m.keys){const A=C[E],Z=Ke(E),Na=p[E]?._zod?.optout==="optional";f.write(`const ${A} = ${_(E)};`),Na?f.write(`
|
|
50
|
+
if (${A}.issues.length) {
|
|
51
|
+
if (${Z} in input) {
|
|
52
|
+
payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
|
|
53
|
+
...iss,
|
|
54
|
+
path: iss.path ? [${Z}, ...iss.path] : [${Z}]
|
|
55
|
+
})));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (${A}.value === undefined) {
|
|
60
|
+
if (${Z} in input) {
|
|
61
|
+
newResult[${Z}] = undefined;
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
newResult[${Z}] = ${A}.value;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
`):f.write(`
|
|
68
|
+
if (${A}.issues.length) {
|
|
69
|
+
payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
|
|
70
|
+
...iss,
|
|
71
|
+
path: iss.path ? [${Z}, ...iss.path] : [${Z}]
|
|
72
|
+
})));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (${A}.value === undefined) {
|
|
76
|
+
if (${Z} in input) {
|
|
77
|
+
newResult[${Z}] = undefined;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
newResult[${Z}] = ${A}.value;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
`)}f.write("payload.value = newResult;"),f.write("return payload;");const B=f.compile();return(E,A)=>B(p,E,A)};let s;const i=te,a=!Ve.jitless,u=a&&uo.value,l=t.catchall;let h;e._zod.parse=(p,f)=>{h??(h=o.value);const m=p.value;return i(m)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=r(t.shape)),p=s(p,f),l?lt([],m,p,f,h,e):p):n(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function pt(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=>F(i,o,x())))}),t)}const Mr=d("$ZodUnion",(e,t)=>{k.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=>we(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=>pt(c,r,e,s)):pt(a,r,e,s)}}),Qr=d("$ZodIntersection",(e,t)=>{k.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])=>ft(n,c,u)):ft(n,s,i)}});function $e(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(G(e)&&G(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=$e(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=$e(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 ft(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=$e(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 Hr=d("$ZodEnum",(e,t)=>{k.init(e,t);const n=We(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>lo.has(typeof r)).map(r=>typeof r=="string"?ne(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}}),Vr=d("$ZodTransform",(e,t)=>{k.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new He(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 ht(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const gt=d("$ZodOptional",(e,t)=>{k.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(`^(${we(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=>ht(s,n.value)):ht(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Wr=d("$ZodExactOptional",(e,t)=>{gt.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)}),Gr=d("$ZodNullable",(e,t)=>{k.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(`^(${we(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)}),Kr=d("$ZodDefault",(e,t)=>{k.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=>mt(s,t)):mt(r,t)}});function mt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Yr=d("$ZodPrefault",(e,t)=>{k.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))}),Xr=d("$ZodNonOptional",(e,t)=>{k.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=>_t(s,e)):_t(r,e)}});function _t(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 ei=d("$ZodCatch",(e,t)=>{k.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=>F(i,o,x()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>F(s,o,x()))},input:n.value}),n.issues=[]),n)}}),ti=d("$ZodPipe",(e,t)=>{k.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=>ce(i,t.in,o)):ce(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>ce(s,t.out,o)):ce(r,t.out,o)}});function ce(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ni=d("$ZodReadonly",(e,t)=>{k.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(yt):yt(r)}});function yt(e){return e.value=Object.freeze(e.value),e}const oi=d("$ZodCustom",(e,t)=>{O.init(e,t),k.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=>vt(s,n,o,e));vt(r,n,o,e)}});function vt(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(K(r))}}var wt;class ri{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 ii(){return new ri}(wt=globalThis).__zod_globalRegistry??(wt.__zod_globalRegistry=ii());const Y=globalThis.__zod_globalRegistry;function si(e,t){return new e({type:"string",...g(t)})}function ai(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function bt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function ci(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function ui(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function di(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function li(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function pi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function fi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function hi(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function gi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function mi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function _i(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function yi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function vi(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function wi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function bi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function ki(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function zi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function Si(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function $i(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function Ti(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function Ei(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function Ai(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function Ii(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Zi(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function Oi(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Ci(e,t){return new e({type:"boolean",...g(t)})}function Pi(e){return new e({type:"unknown"})}function Ri(e,t){return new e({type:"never",...g(t)})}function kt(e,t){return new nr({check:"max_length",...g(t),maximum:e})}function ue(e,t){return new or({check:"min_length",...g(t),minimum:e})}function zt(e,t){return new rr({check:"length_equals",...g(t),length:e})}function Ni(e,t){return new ir({check:"string_format",format:"regex",...g(t),pattern:e})}function Di(e){return new sr({check:"string_format",format:"lowercase",...g(e)})}function ji(e){return new ar({check:"string_format",format:"uppercase",...g(e)})}function Li(e,t){return new cr({check:"string_format",format:"includes",...g(t),includes:e})}function Ui(e,t){return new ur({check:"string_format",format:"starts_with",...g(t),prefix:e})}function xi(e,t){return new dr({check:"string_format",format:"ends_with",...g(t),suffix:e})}function V(e){return new lr({check:"overwrite",tx:e})}function qi(e){return V(t=>t.normalize(e))}function Fi(){return V(e=>e.trim())}function Ji(){return V(e=>e.toLowerCase())}function Bi(){return V(e=>e.toUpperCase())}function Mi(){return V(e=>co(e))}function Qi(e,t,n){return new e({type:"array",element:t,...g(n)})}function Hi(e,t,n){return new e({type:"custom",check:"custom",fn:t,...g(n)})}function Vi(e){const t=Wi(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(K(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(K(r))}},e(n.value,n)));return t}function Wi(e,t){const n=new O({check:"custom",...g(t)});return n._zod.check=e,n}function St(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??Y,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 S(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),S(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"&&T(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 $t(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??(m=>m);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>
|
|
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 Tt(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 _ in c)_==="$ref"||_==="allOf"||_ in u||delete c[_];if(f.$ref&&p.def)for(const _ in c)_==="$ref"||_==="allOf"||_ in p.def&&JSON.stringify(c[_])===JSON.stringify(p.def[_])&&delete c[_]}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:de(t,"input",e.processors),output:de(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function T(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return T(o.element,n);if(o.type==="set")return T(o.valueType,n);if(o.type==="lazy")return T(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 T(o.innerType,n);if(o.type==="intersection")return T(o.left,n)||T(o.right,n);if(o.type==="record"||o.type==="map")return T(o.keyType,n)||T(o.valueType,n);if(o.type==="pipe")return T(o.in,n)||T(o.out,n);if(o.type==="object"){for(const r in o.shape)if(T(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(T(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(T(r,n))return!0;return!!(o.rest&&T(o.rest,n))}return!1}const Gi=(e,t={})=>n=>{const o=St({...n,processors:t});return S(e,o),$t(o,e),Tt(o,e)},de=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=St({...r??{},target:s,io:t,processors:n});return S(e,i),$t(i,e),Tt(i,e)},Ki={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Yi=(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=Ki[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}))])}},Xi=(e,t,n,o)=>{n.type="boolean"},es=(e,t,n,o)=>{n.not={}},ts=(e,t,n,o)=>{},ns=(e,t,n,o)=>{const r=e._zod.def,s=We(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},os=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},rs=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},is=(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=S(s.element,t,{...o,path:[...o.path,"items"]})},ss=(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]=S(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=S(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},as=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((a,c)=>S(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},cs=(e,t,n,o)=>{const r=e._zod.def,s=S(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=S(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},us=(e,t,n,o)=>{const r=e._zod.def,s=S(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"}]},ds=(e,t,n,o)=>{const r=e._zod.def;S(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},ls=(e,t,n,o)=>{const r=e._zod.def;S(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},ps=(e,t,n,o)=>{const r=e._zod.def;S(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)))},fs=(e,t,n,o)=>{const r=e._zod.def;S(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},hs=(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;S(s,t,o);const i=t.seen.get(e);i.ref=s},gs=(e,t,n,o)=>{const r=e._zod.def;S(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},Et=(e,t,n,o)=>{const r=e._zod.def;S(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},ms=d("ZodISODateTime",(e,t)=>{$r.init(e,t),b.init(e,t)});function _s(e){return Ai(ms,e)}const ys=d("ZodISODate",(e,t)=>{Tr.init(e,t),b.init(e,t)});function vs(e){return Ii(ys,e)}const ws=d("ZodISOTime",(e,t)=>{Er.init(e,t),b.init(e,t)});function bs(e){return Zi(ws,e)}const ks=d("ZodISODuration",(e,t)=>{Ar.init(e,t),b.init(e,t)});function zs(e){return Oi(ks,e)}const I=d("ZodError",(e,t)=>{nt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>bo(e,n)},flatten:{value:n=>wo(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,_e,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,_e,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ss=ke(I),$s=ze(I),Ts=re(I),Es=ie(I),As=So(I),Is=$o(I),Zs=To(I),Os=Eo(I),Cs=Ao(I),Ps=Io(I),Rs=Zo(I),Ns=Oo(I),z=d("ZodType",(e,t)=>(k.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:de(e,"input"),output:de(e,"output")}}),e.toJSONSchema=Gi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(N(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)=>D(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>Ss(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Ts(e,n,o),e.parseAsync=async(n,o)=>$s(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>Es(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>As(e,n,o),e.decode=(n,o)=>Is(e,n,o),e.encodeAsync=async(n,o)=>Zs(e,n,o),e.decodeAsync=async(n,o)=>Os(e,n,o),e.safeEncode=(n,o)=>Cs(e,n,o),e.safeDecode=(n,o)=>Ps(e,n,o),e.safeEncodeAsync=async(n,o)=>Rs(e,n,o),e.safeDecodeAsync=async(n,o)=>Ns(e,n,o),e.refine=(n,o)=>e.check(Ta(n,o)),e.superRefine=n=>e.check(Ea(n)),e.overwrite=n=>e.check(V(n)),e.optional=()=>Pt(e),e.exactOptional=()=>fa(e),e.nullable=()=>Rt(e),e.nullish=()=>Pt(Rt(e)),e.nonoptional=n=>va(e,n),e.array=()=>Zt(e),e.or=n=>Ot([e,n]),e.and=n=>ua(e,n),e.transform=n=>Dt(e,la(n)),e.default=n=>ma(e,n),e.prefault=n=>ya(e,n),e.catch=n=>ba(e,n),e.pipe=n=>Dt(e,n),e.readonly=()=>Sa(e),e.describe=n=>{const o=e.clone();return Y.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return Y.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Y.get(e);const o=e.clone();return Y.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),At=d("_ZodString",(e,t)=>{Se.init(e,t),z.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Yi(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(Ni(...o)),e.includes=(...o)=>e.check(Li(...o)),e.startsWith=(...o)=>e.check(Ui(...o)),e.endsWith=(...o)=>e.check(xi(...o)),e.min=(...o)=>e.check(ue(...o)),e.max=(...o)=>e.check(kt(...o)),e.length=(...o)=>e.check(zt(...o)),e.nonempty=(...o)=>e.check(ue(1,...o)),e.lowercase=o=>e.check(Di(o)),e.uppercase=o=>e.check(ji(o)),e.trim=()=>e.check(Fi()),e.normalize=(...o)=>e.check(qi(...o)),e.toLowerCase=()=>e.check(Ji()),e.toUpperCase=()=>e.check(Bi()),e.slugify=()=>e.check(Mi())}),Ds=d("ZodString",(e,t)=>{Se.init(e,t),At.init(e,t),e.email=n=>e.check(ai(js,n)),e.url=n=>e.check(pi(Ls,n)),e.jwt=n=>e.check(Ei(Xs,n)),e.emoji=n=>e.check(fi(Us,n)),e.guid=n=>e.check(bt(It,n)),e.uuid=n=>e.check(ci(le,n)),e.uuidv4=n=>e.check(ui(le,n)),e.uuidv6=n=>e.check(di(le,n)),e.uuidv7=n=>e.check(li(le,n)),e.nanoid=n=>e.check(hi(xs,n)),e.guid=n=>e.check(bt(It,n)),e.cuid=n=>e.check(gi(qs,n)),e.cuid2=n=>e.check(mi(Fs,n)),e.ulid=n=>e.check(_i(Js,n)),e.base64=n=>e.check(Si(Gs,n)),e.base64url=n=>e.check($i(Ks,n)),e.xid=n=>e.check(yi(Bs,n)),e.ksuid=n=>e.check(vi(Ms,n)),e.ipv4=n=>e.check(wi(Qs,n)),e.ipv6=n=>e.check(bi(Hs,n)),e.cidrv4=n=>e.check(ki(Vs,n)),e.cidrv6=n=>e.check(zi(Ws,n)),e.e164=n=>e.check(Ti(Ys,n)),e.datetime=n=>e.check(_s(n)),e.date=n=>e.check(vs(n)),e.time=n=>e.check(bs(n)),e.duration=n=>e.check(zs(n))});function J(e){return si(Ds,e)}const b=d("ZodStringFormat",(e,t)=>{w.init(e,t),At.init(e,t)}),js=d("ZodEmail",(e,t)=>{mr.init(e,t),b.init(e,t)}),It=d("ZodGUID",(e,t)=>{hr.init(e,t),b.init(e,t)}),le=d("ZodUUID",(e,t)=>{gr.init(e,t),b.init(e,t)}),Ls=d("ZodURL",(e,t)=>{_r.init(e,t),b.init(e,t)}),Us=d("ZodEmoji",(e,t)=>{yr.init(e,t),b.init(e,t)}),xs=d("ZodNanoID",(e,t)=>{vr.init(e,t),b.init(e,t)}),qs=d("ZodCUID",(e,t)=>{wr.init(e,t),b.init(e,t)}),Fs=d("ZodCUID2",(e,t)=>{br.init(e,t),b.init(e,t)}),Js=d("ZodULID",(e,t)=>{kr.init(e,t),b.init(e,t)}),Bs=d("ZodXID",(e,t)=>{zr.init(e,t),b.init(e,t)}),Ms=d("ZodKSUID",(e,t)=>{Sr.init(e,t),b.init(e,t)}),Qs=d("ZodIPv4",(e,t)=>{Ir.init(e,t),b.init(e,t)}),Hs=d("ZodIPv6",(e,t)=>{Zr.init(e,t),b.init(e,t)}),Vs=d("ZodCIDRv4",(e,t)=>{Or.init(e,t),b.init(e,t)}),Ws=d("ZodCIDRv6",(e,t)=>{Cr.init(e,t),b.init(e,t)}),Gs=d("ZodBase64",(e,t)=>{Pr.init(e,t),b.init(e,t)}),Ks=d("ZodBase64URL",(e,t)=>{Nr.init(e,t),b.init(e,t)}),Ys=d("ZodE164",(e,t)=>{Dr.init(e,t),b.init(e,t)}),Xs=d("ZodJWT",(e,t)=>{Lr.init(e,t),b.init(e,t)}),ea=d("ZodBoolean",(e,t)=>{Ur.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xi(e,n,o)});function ta(e){return Ci(ea,e)}const na=d("ZodUnknown",(e,t)=>{xr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ts()});function Te(){return Pi(na)}const oa=d("ZodNever",(e,t)=>{qr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>es(e,n,o)});function ra(e){return Ri(oa,e)}const ia=d("ZodArray",(e,t)=>{Fr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>is(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(ue(n,o)),e.nonempty=n=>e.check(ue(1,n)),e.max=(n,o)=>e.check(kt(n,o)),e.length=(n,o)=>e.check(zt(n,o)),e.unwrap=()=>e.element});function Zt(e,t){return Qi(ia,e,t)}const sa=d("ZodObject",(e,t)=>{Br.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ss(e,n,o,r),y(e,"shape",()=>t.shape),e.keyof=()=>Ae(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Te()}),e.loose=()=>e.clone({...e._zod.def,catchall:Te()}),e.strict=()=>e.clone({...e._zod.def,catchall:ra()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>go(e,n),e.safeExtend=n=>mo(e,n),e.merge=n=>_o(e,n),e.pick=n=>fo(e,n),e.omit=n=>ho(e,n),e.partial=(...n)=>yo(Ct,e,n[0]),e.required=(...n)=>vo(Nt,e,n[0])});function X(e,t){const n={type:"object",shape:e??{},...g(t)};return new sa(n)}const aa=d("ZodUnion",(e,t)=>{Mr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>as(e,n,o,r),e.options=t.options});function Ot(e,t){return new aa({type:"union",options:e,...g(t)})}const ca=d("ZodIntersection",(e,t)=>{Qr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>cs(e,n,o,r)});function ua(e,t){return new ca({type:"intersection",left:e,right:t})}const Ee=d("ZodEnum",(e,t)=>{Hr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(o,r,s)=>ns(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 Ee({...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 Ee({...t,checks:[],...g(r),entries:s})}});function Ae(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Ee({type:"enum",entries:n,...g(t)})}const da=d("ZodTransform",(e,t)=>{Vr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>rs(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new He(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(K(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(K(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function la(e){return new da({type:"transform",transform:e})}const Ct=d("ZodOptional",(e,t)=>{gt.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Et(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Pt(e){return new Ct({type:"optional",innerType:e})}const pa=d("ZodExactOptional",(e,t)=>{Wr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Et(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function fa(e){return new pa({type:"optional",innerType:e})}const ha=d("ZodNullable",(e,t)=>{Gr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>us(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Rt(e){return new ha({type:"nullable",innerType:e})}const ga=d("ZodDefault",(e,t)=>{Kr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ls(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ma(e,t){return new ga({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Xe(t)}})}const _a=d("ZodPrefault",(e,t)=>{Yr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ps(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function ya(e,t){return new _a({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Xe(t)}})}const Nt=d("ZodNonOptional",(e,t)=>{Xr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ds(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function va(e,t){return new Nt({type:"nonoptional",innerType:e,...g(t)})}const wa=d("ZodCatch",(e,t)=>{ei.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>fs(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ba(e,t){return new wa({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ka=d("ZodPipe",(e,t)=>{ti.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>hs(e,n,o,r),e.in=t.in,e.out=t.out});function Dt(e,t){return new ka({type:"pipe",in:e,out:t})}const za=d("ZodReadonly",(e,t)=>{ni.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>gs(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Sa(e){return new za({type:"readonly",innerType:e})}const $a=d("ZodCustom",(e,t)=>{oi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>os(e,n)});function Ta(e,t={}){return Hi($a,e,t)}function Ea(e){return Vi(e)}const Aa=X({title:J(),type:J(),payload:Te().optional()}),Ia=X({label:J(),action:Aa,variant:Ae(["primary","outline","ghost"]).optional()}),Za=X({orientation:Ae(["horizontal","vertical"]).optional(),wrap:ta().optional()}),Oa=X({placeholder:Ot([J(),Zt(J())]).optional(),ctaLabel:J().optional()}),Ca=X({text:J()}),Pa={components:{ActionButton:{schema:Ia,description:"A single clickable QNA action button."},ButtonRow:{schema:Za,description:"Container for a group of QNA action buttons."},TextInput:{schema:Oa,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:Ca,description:"A heading displayed above the QNA button group."}}};class jt extends un{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=Qe,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,to("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(qt(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 Xn(i,o,this._abortController.signal);if(this.track(Ft(this.analyticsContext(),{request_id:r,latency_ms:Date.now()-s,chunk_count:c.actions.length,widget:"qna"})),this.track(Mt(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 $=document.createElement("h3");$.className="gengage-qna-heading",$.textContent=this.config.staticQuestionText,this._contentEl.appendChild($)}const l=this.config.inputPlaceholder,h=c.actions.length>0&&l===!0?c.actions.map($=>$.title):l===!0?this._i18n.defaultInputPlaceholder:l,p={onAction:this._actionHandler,i18n:this._i18n};l===void 0&&(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),_=(c.uiSpecs.length>0?c.uiSpecs:[f]).filter($=>Object.keys($.elements).length>0);for(const $ of _){const B=this._renderUISpec($,p);this._contentEl.appendChild(B)}if(_.length>0&&no("qna"),l!==void 0&&!this._specIncludesType(_,"TextInput")){const $={root:"root",elements:{root:{type:"TextInput",props:{placeholder:h,ctaLabel:this.config.ctaText}}}},B=this._renderUISpec($,p);this._contentEl.appendChild(B)}}catch(i){if(i instanceof DOMException&&i.name==="AbortError")return;pe("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:en(this.config.locale)}),this.track(Jt(this.analyticsContext(),{request_id:r,error_code:"FETCH_ERROR",error_message:i instanceof Error?i.message:String(i),widget:"qna"}))}}_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{...ao(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=Be();return xt(t,this.config.renderer?.registry)}_renderUISpec(t,n){const o=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??me,s=(c,u)=>Me(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}}_handleAction(t){oo(t.title,t.type),this.config.onActionSelected?.(t),pe("gengage:qna:action",t)}_handleOpenChat(){this.config.onOpenChat?.(),pe("gengage:qna:open-chat",{})}}function Ra(){return new jt}j.GengageQNA=jt,j.createDefaultQnaUISpecRegistry=Be,j.createQNAWidget=Ra,j.defaultQnaUnknownUISpecRenderer=me,j.qnaCatalog=Pa,j.renderQnaUISpec=Me,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
|
|
48
86
|
//# sourceMappingURL=qna.iife.js.map
|