@gengage/assistant-fe 0.6.22 → 0.6.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-paths-DE3_TyTw.js → api-paths-BmN07ddR.js} +144 -154
- package/dist/chat/catalog.d.ts +8 -0
- package/dist/chat/types.d.ts +2 -1
- package/dist/{chat-rvSffJXw.js → chat-CIfQyuBl.js} +26 -21
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +44 -44
- package/dist/chat.js +2 -2
- package/dist/{common-BWnFHbvv.js → common-sx2gD-IP.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-Tk4ZjgMi.js → connection-warning-D5T4gHSM.js} +1 -1
- package/dist/{fastIntent-DIhMlxVd.js → fastIntent-BFAGybCb.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +17 -17
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +7 -7
- package/dist/qna.js +1 -1
- package/dist/{runtime-CjJy8KKu.js → runtime-BD2fW-ed.js} +3 -3
- package/dist/{runtime-H5hNQQKm.js → runtime-DM7DHhH9.js} +1816 -1778
- package/dist/{runtime-wEP7N2Hr.js → runtime-DQ3ULuNF.js} +3 -3
- package/dist/{simbut-BlBLtgVy.js → simbut-hkt_4H97.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-S6-OsWJ9.js → simrel-BbkK5Bwt.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +6 -6
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-e4JwEf2I.js → widget-base-BPKfPh0N.js} +1 -1
- package/package.json +1 -1
package/dist/qna.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(M){Object.defineProperty(M,Symbol.toStringTag,{value:"Module"});var
|
|
1
|
+
(function(M){Object.defineProperty(M,Symbol.toStringTag,{value:"Module"});var $n=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function In(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const n=e.unknownRenderer??$n,r=i=>{const a=e.spec.elements[i];if(!a)return null;const s=e.registry[a.type];return s?s({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r}):n({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r})},o=r(e.spec.root);return o&&t.appendChild(o),t}function Pn(e,t){if(!t)return e;const n={...e};for(const[r,o]of Object.entries(t))o&&(n[r]=o);return n}var Cn=["http:","https:"];function xn(e){const t=e.trim();if(!t)return!1;if(t.startsWith("/")&&!t.startsWith("//"))return!0;try{return Cn.includes(new URL(t).protocol)}catch{return!1}}function On(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function Ae(e,t){const n={event:e,...t};On()&&window.dataLayer.push(n)}function Zn(e){Ae("gengage-on-init",{gengage_widget:e})}function Rn(e){Ae("gengage-show",{gengage_widget:e})}function Ln(e,t){Ae("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function Te(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Ye(e,t){const n=r=>{t(r.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function Nn(){const e=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=e,sessionStorage.setItem("gengage_session_id",e),window.gengage||(window.gengage={}),window.gengage.sessionId=e,e}function qn(e){return{sessionId:e?.sessionId??Nn(),...e}}var Xe={"--gengage-chat-offset":"20px","--gengage-chat-launcher-width":"56px","--gengage-chat-launcher-height":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"12px","--gengage-simrel-card-radius":"0.75rem","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--surface-card-muted":"#f8fafc","--text-secondary":"#4b5563","--text-muted":"#6b7280","--border-default":"rgba(17, 24, 39, 0.10)"};function jn(e){if(!e)return{...Xe};const t={...Xe,...e},n=e["--gengage-chat-launcher-size"];return n!==void 0&&(e["--gengage-chat-launcher-width"]===void 0&&(t["--gengage-chat-launcher-width"]=n),e["--gengage-chat-launcher-height"]===void 0&&(t["--gengage-chat-launcher-height"]=n)),t}var R={primaryColor:"#b7102a",primaryForeground:"#ffffff",backgroundColor:"#ffffff",foregroundColor:"#111827",borderRadius:"0.75rem",fontFamily:'"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px",zIndex:"1000","--glov-chatbot-width":"420px","--glov-left-spacing":"260px","--chatbot-padding":"16px","--root-wrapper-background-color":"#f8f9fa","--root-wrapper-border-color":"#edeeef","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem","--client-primary":"#b7102a","--client-primary-hover":"color-mix(in srgb, #b7102a 88%, black 12%)","--client-primary-active":"color-mix(in srgb, #b7102a 78%, black 22%)","--client-primary-subtle":"color-mix(in srgb, #b7102a 12%, white)","--client-primary-soft":"color-mix(in srgb, #b7102a 20%, white)","--client-on-primary":"#ffffff","--client-focus-ring":"color-mix(in srgb, #b7102a 32%, transparent)","--surface-page":"#f6f7fb","--surface-shell":"#10131a","--surface-card":"#ffffff","--surface-card-muted":"#f8fafc","--surface-card-soft":"#f8fafc","--surface-elevated":"#ffffff","--surface-input":"#ffffff","--surface-overlay":"rgba(16, 19, 26, 0.52)","--text-primary":"#111827","--text-secondary":"#4b5563","--text-muted":"#6b7280","--text-inverse":"#f9fafb","--border-subtle":"rgba(17, 24, 39, 0.06)","--border-default":"rgba(17, 24, 39, 0.10)","--border-strong":"rgba(17, 24, 39, 0.18)","--shadow-1":"0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)","--shadow-2":"0 4px 12px rgba(16, 24, 40, 0.08)","--shadow-3":"0 10px 24px rgba(16, 24, 40, 0.12)","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--success":"#16a34a","--warning":"#d97706","--error":"#dc2626","--info":"#2563eb","--rating":"#f5b301","--ai-accent-start":"#0b24d6","--ai-accent-end":"#f768f2","--ai-accent-soft":"linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"},D="gengage-global-toast-root",et="gengage-global-toast-style",$e="gengage-global-toast-root--visible",Dn=4200,Un=1500,Bn=15e3,Mn=["--gengage-font-family","--surface-card","--text-primary","--text-muted","--border-default","--radius-card","--shadow-3","--error","--ds-toast-error-bg","--ds-toast-error-border","--ds-toast-error-accent","--ds-toast-error-fg","--ds-toast-error-shadow"],tt=!1,F=null,Fn=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i];function nt(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function Hn(e){if(typeof navigator<"u"&&navigator.onLine===!1)return!0;const t=e instanceof Error?e.message.trim():"";return t?Fn.some(n=>n.test(t)):!1}function Jn(e,t){return Hn(t)?nt(e)?"Bağlantı sorunu oluştu. Lütfen tekrar deneyin.":"Connection issue. Please try again.":nt(e)?"Bir hata oluştu. Lütfen tekrar deneyin.":"Something went wrong. Please try again."}function Qn(){tt||typeof window>"u"||typeof document>"u"||(tt=!0,Ye("gengage:global:error",e=>{Ie(e)}))}function Ie(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;Yn();const n=Vn();Gn(n),n.innerHTML="";const r=document.createElement("section");r.className="gengage-global-toast gengage-global-toast--error",r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="gengage-global-toast-title",o.textContent=Wn(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,r.appendChild(o),r.appendChild(i),n.appendChild(r),n.classList.add($e),F&&(clearTimeout(F),F=null),e.sticky!==!0&&(F=setTimeout(()=>{rt()},Kn(e.durationMs)))}function rt(){if(typeof document>"u")return;const e=document.getElementById(D);e&&(e.classList.remove($e),e.innerHTML="",F&&(clearTimeout(F),F=null))}function Wn(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function Vn(){const e=document.getElementById(D);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=D,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function Gn(e){if(typeof document>"u"||typeof window>"u")return;const t=document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");if(!t)return;const n=window.getComputedStyle(t);for(const r of Mn){const o=n.getPropertyValue(r).trim();o?e.style.setProperty(r,o):e.style.removeProperty(r)}}function Kn(e){return typeof e!="number"||!Number.isFinite(e)?Dn:Math.min(Bn,Math.max(Un,Math.round(e)))}function Yn(){if(document.getElementById(et))return;const e=document.createElement("style");e.id=et;const t=R["--surface-card"]??R.backgroundColor??"#ffffff",n=R["--text-primary"]??R.foregroundColor??"#111827",r=R["--border-default"]??"rgba(17, 24, 39, 0.10)",o=R["--error"]??"#dc2626",i=R["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",a=R["--radius-card"]??"16px",s=R["--text-muted"]??"#6b7280";e.textContent=`
|
|
2
2
|
#${D} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
top: 16px;
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
transform: translateY(0);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,document.head.appendChild(e)}var te=null;function
|
|
48
|
-
`);o=g.pop()??"";for(const h of g)if(lt(h,t))return}if(o.trim()&<(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||n.releaseLock()}t.onDone?.()}var pr={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function gr(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 hr(e,t){return`${gr(t?.middlewareUrl)}/chat${pr[e]}`}var dt=3,mr=(e,t)=>{const n=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!n)return"";const r=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,"").trim():n;return r?r.split(/\s+/).slice(0,3).join(" ").trim():""},xe=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(n=>mr(n,t)).filter(Boolean):[];function yr(e){const t=(e.display_keywords??[]).flatMap(o=>xe(o,{stripLeadingStopWords:!0})),n=t.filter((o,i)=>t.indexOf(o)===i);if(n.length>0)return n.slice(0,dt);const r=[...xe(e.chosen_attribute,{stripLeadingStopWords:!0}),...xe(e.short_name)];return r.filter((o,i)=>r.indexOf(o)===i).slice(0,dt)}function _r(e){return yr(e).join(" • ")}function vr(e){return e==="beauty_consulting"||e==="account_expert"}function Oe(...e){for(const t of e){if(typeof t!="string")continue;const n=t.trim();if(n.length>0)return n}}function Ze(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim()):[]}function ft(e){const t={...e},n=Oe(t.sku),r=Ze(t.group_skus);if(n?t.sku=n:delete t.sku,r.length>0?t.group_skus=r:delete t.group_skus,n||r.length>0)delete t.image_url;else{const o=Oe(t.image_url);o?t.image_url=o:delete t.image_url}return t}function br(e){if(typeof e.type!="string")return null;if(wr(e))return e;const t=e;switch(t.type){case"outputText":return kr(t);case"suggestedActions":return Sr(t);case"productList":return zr(t);case"productDetails":return Er(t);case"productDetailsSimilars":return Ar(t);case"comparisonTable":return Tr(t);case"context":return Cr(t);case"chatStreamEnd":return xr();case"loading":return Or(t);case"panelLoading":return Zr(t);case"similarLoading":return Rr(t);case"redirect":return Lr(t);case"error":return Nr(t);case"dummy":return qr(t);case"launcherAction":return jr(t);case"text":return Re(t);case"productItem":return Dr(t);case"text_image":return pt(t);case"quick_qna":return gt(t);case"reviewHighlights":return Ur(t);case"aiProductSuggestions":return Fr(t);case"aiProductGroupings":return Hr(t);case"aiSuggestedSearches":return Qr(t);case"prosAndCons":return Br(t);case"getGroundingReview":return Wr(t);case"voice":return Gr(t);case"visitorDataResponse":return Mr(t);case"productListPreview":return Vr();case"groupList":return Kr(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Yr(t);case"launcherContent":return eo(t);case"handoff":return Xr(t);case"uiSpec":return so(t);default:return null}}function wr(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const r=C(e.spec);return r?typeof r.root=="string"&&C(r.elements)!==null:!1}case"action":{const n=C(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 kr(e){const t=v(e.payload.text,e.payload.plain_text)??"",n=v(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const r={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(r.productMentions=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(r.skuToProductItem=i);const a=e.payload.conversation_mode;typeof a=="string"&&a&&(r.conversationMode=a);const s=e.payload.render_hint;return typeof s=="string"&&s&&(r.renderHint=s),e.payload.kvkk===!0&&(r.kvkk=!0),r}function Sr(e){return ht((e.payload.actions??[]).map(t=>{const n=v(t.title)??"",r=O(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(oe),"chat")}function zr(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(a=>{const s=v(a.style_label);if(!s)return null;const c=v(a.style_mood),u=v(a.image_url??void 0),d=(Array.isArray(a.product_list)?a.product_list:[]).map(f=>{const g=C(f);return g?Le(C(g.product_detail)??C(g.product)??g):null}).filter(oe),p=Array.isArray(a.recommendation_groups)?a.recommendation_groups.map(f=>({label:v(f.label)??"",reason:v(f.reason)??"",skus:Array.isArray(f.skus)?f.skus.filter(g=>typeof g=="string"&&g.trim().length>0):[]})):[];return{style_label:s,style_mood:c??"",...u?{image_url:u}:{},...typeof a.status=="string"?{status:a.status}:{},product_list:d,recommendation_groups:p}}).filter(oe),n=e.payload.product_list??[],r=vr(e.payload.source)&&t.length>0?t[0].product_list:null,o=r?to(r,"chat"):mt(n,"chat");o.panelHint="panel";const i=o.spec.elements[o.spec.root];if(i){const a={};typeof e.payload.offset=="number"&&(a.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(a.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(a.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(a.source=e.payload.source),t.length>0&&(a.styleVariations=t),e.payload.replace_panel===!0&&(a.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(a.rankingState=e.payload.ranking_state);const s=e.payload.sequence_id??e.payload.search_id;typeof s=="string"&&s.length>0&&(a.sequenceId=s),Object.keys(a).length>0&&(i.props={...i.props,...a})}return o}function Er(e){const t=e.payload.productDetails;if(!t)return ro("chat");const n=K(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...n}}}}},panelHint:"panel"}}function Ar(e){const t=mt(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Tr(e){const t=e.payload.multiple_product_details??[],n=e.payload,r={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,a=[];for(const _ of t){const w=K(_);a.push(w)}const s=$r(o,a,r,i);let c;r?.recommended_choice_sku?c=r.recommended_choice_sku:r?.winner_product&&r.winner_product.length>0&&(c=r.winner_product[0]?.product_detail?.sku??r.winner_product[0]?.sku);const u=c?a.find(_=>_.sku===c)??a[0]:a[0],d=[];if(Array.isArray(r?.key_differences))for(const _ of r.key_differences)typeof _=="string"&&d.push(_);const p=yt(r?.special_considerations),f=r?.recommended_choice,g=r?.winner_hits,h={};for(const _ of a){const w=_.sku;w&&(h[w]={title:_.name??w,type:"launchSingleProduct",payload:{sku:w}})}const m={products:a,attributes:s,highlights:d,productActions:h};return u&&(m.recommended=u),p.length>0&&(m.specialCases=p),f&&(m.recommendedText=f),g&&(m.winnerHits=g),typeof r?.key_differences=="string"&&(m.keyDifferencesHtml=r.key_differences),r?.special_considerations&&(m.specialConsiderations=r.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function $r(e,t,n,r){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const p=n.criteria_view??n.criteria_view_short??{},f=n.compared_field_names??Object.keys(e),g=[];for(const h of f){const m=e[h];if(!m||!Array.isArray(m))continue;const _=p[h]??h;g.push({label:_,values:m.map(w=>typeof w=="string"?w:String(w??""))})}return g}const a=e,s=t.map(p=>String(p.sku??"")).filter(p=>p.length>0),c=n.criteria_view??n.criteria_view_short??{},u=(r&&r.length>0?r:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:Ir(a)).filter(p=>p!=="name"&&p!=="name_short"&&!p.endsWith("_short")),d=[];for(const p of u){const f=s.map(h=>{const m=a[h];if(!m||typeof m!="object")return"";const _=m[`${p}_short`],w=m[p];return Pr(_??w)});if(f.every(h=>h.length===0))continue;const g=c[p]??p;d.push({label:g,values:f})}return d}function Ir(e){const t=[],n=new Set;for(const r of Object.values(e))if(!(!r||typeof r!="object"))for(const o of Object.keys(r))n.has(o)||(n.add(o),t.push(o));return t}function Pr(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Cr(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function xr(){return{type:"done"}}function Or(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 Zr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Rr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Lr(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 Nr(e){return{type:"error",code:"BACKEND_ERROR",message:v(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function qr(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function jr(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.theme=a),gt({type:"quick_qna",payload:o})}const n=C(t.action);if(n){const o={action:n},i=typeof t.text=="string"?t.text:void 0,a=typeof t.image_url=="string"?t.image_url:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),a!==void 0&&(o.image_url=a),s!==void 0&&(o.theme=s),pt({type:"text_image",payload:o})}const r=typeof t.text=="string"?t.text:"";if(r){const o={text:r},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0,s=C(t.payload)??void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.payload=s),a!==void 0&&(o.theme=a),Re({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Re(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 Dr(e){return no(e.payload,"qna")}function pt(e){const t=v(e.payload.text)??"",n=O(e.payload.action,t);if(n){const o={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const r={text:t};return typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),Re({type:"text",payload:r})}function gt(e){return ht((e.payload.action_list??[]).map(t=>{const n=v(t.title)??"",r=O(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(oe),"qna")}function Ur(e){const t={reviews:(e.payload.reviews??[]).map(n=>{const r={};return typeof n.review_class=="string"&&(r.review_class=n.review_class),typeof n.review_text=="string"&&(r.review_text=n.review_text),(typeof n.review_rating=="string"||typeof n.review_rating=="number")&&(r.review_rating=n.review_rating),typeof n.review_tag=="string"&&(r.review_tag=n.review_tag),r})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function Br(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 Mr(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Fr(e){const t=e.payload.product_suggestions??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=oo(o);if(!i)continue;const a={product:i},s=O(o.requestDetails,i.name);s&&(a.action=s),typeof o.role=="string"&&(a.role=o.role),typeof o.reason=="string"&&(a.reason=o.reason),typeof o.review_highlight=="string"&&(a.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(a.labels=o.labels),typeof o.expert_quality_score=="number"&&(a.expertQualityScore=o.expert_quality_score),n.push(a)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function Hr(e){const t=e.payload.product_groupings??[],n=[],r=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const a=v(i.name)??"",s=v(i.description),c=v(i.highlight),u=Array.isArray(i.labels)?yt(i.labels):[],d=v(i.sku,i.repr_sku),p=v(i.image,i.repr_image),f=Jr(i,a,d),g=(Array.isArray(i.group_products)?i.group_products:[]).map(_=>{const w=C(_);return w?Le(w):null}).filter(oe),h=p??v(...g.map(_=>_.imageUrl));if(a&&g.length>0){const _={groupName:a,products:g};h&&(_.image=h),s&&(_.description=s),c&&(_.highlight=c),u.length>0&&(_.labels=u),n.push(_)}if(!f)continue;const m={name:a,action:f};u.length>0&&(m.labels=u),p!==void 0&&(m.image=p),r.push(m)}return n.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n}}}},panelHint:"panel"}:r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:r}}}}}}function Jr(e,t,n){const r=C(e.requestDetails);if(r){if(r.type!=="findSimilar")return O(r,t);const a={...C(r.payload)??{}};n&&!Oe(a.sku)&&(a.sku=n);const s=Ze(e.group_skus);return s.length>0&&(a.group_skus=s),O({...r,payload:ft(a)},t)}const o={};n&&(o.sku=n);const i=Ze(e.group_skus);return i.length>0&&(o.group_skus=i),Object.keys(o).length===0?null:O({type:"findSimilar",payload:ft(o)},t)}function Qr(e){const t=e.payload.suggested_searches??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=v(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${r+1}`,a={},s=v(o.detailed_user_message);s&&(a.text=s);const c=C(C(o.requestDetails)?.payload),u=c?.group_skus;o.group_skus&&Array.isArray(o.group_skus)?a.group_skus=o.group_skus:Array.isArray(u)&&(a.group_skus=u.filter(w=>typeof w=="string"));const d=v(o.sku,o.representative_product_sku,c?.sku);d&&(a.sku=d),a.is_suggested_text=1;const p={type:"inputText",payload:a},f=O(o.requestDetails,i),g=f?.type==="findSimilar"&&typeof a.text=="string"?O(p,i):f??O(p,i);if(!g)continue;const h={shortName:i,action:g},m=v(o.detailed_user_message);m&&m!==i&&(h.detailedMessage=m);const _=_r(o);_&&_!==i&&_!==(m??"")&&(h.whyDifferent=_),typeof o.image=="string"&&(h.image=o.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 Wr(e){const t=e.payload,n=O(t.requestDetails??t.request_details,v(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!n)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const r={action:n};return t.title&&(r.title=t.title),t.text&&(r.text=t.text),t.review_count?r.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(r.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:r}}}}}function Vr(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Gr(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Kr(e){const t=e.payload.group_list??[],n=[];for(const o of t){const i=o.group_name??"",a=(o.product_list??[]).map(K);n.push({groupName:i,products:a})}const r=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const a=O(o.requestDetails,i),s={title:i};a&&(s.action=a),r.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:r}}}},panelHint:"panel"}}function Yr(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Xr(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 eo(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function ht(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`action-${o}`;r.push(a);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),n[a]={type:"ActionButton",props:s}}return n.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function mt(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=K(i),s=`product-${o}`;r.push(s);const c={product:a,index:o};a.sku&&(c.action={title:a.name,type:"launchSingleProduct",payload:{sku:a.sku}}),n[s]={type:"ProductCard",props:c}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function to(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`product-${o}`;r.push(a);const s={product:i,index:o},c=i.sku;c&&(s.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),n[a]={type:"ProductCard",props:s}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function no(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:K(e),index:0}}}}}}function ro(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function oo(e){const t=v(e.sku),n=v(e.short_name),r={...C(e.product_item)??e},o=v(e.discount_reason,e.discountReason);return o&&!v(r.discount_reason,r.discountReason)&&(r.discount_reason=o),Le(r,t,n)}function Le(e,t,n){const r=v(e.sku,t),o=v(e.name,n);if(!r||!o)return null;const i={sku:r,name:o},a=v(e.brand);a&&(i.brand=a);const s=v(e.url);s&&(i.url=s);const c=io(e.images);if(c.length>0)i.images=c;else{const m=v(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const u=re(e.price_discounted);u!==void 0&&(i.price_discounted=u);const d=re(e.price);d!==void 0&&(i.price=d);const p=re(e.rating);p!==void 0&&(i.rating=p);const f=re(e.review_count)??re(e.reviewCount);f!==void 0&&(i.review_count=f);const g=v(e.cart_code,e.cartCode);g&&(i.cart_code=g),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const h=v(e.discount_reason,e.discountReason);return h&&(i.discount_reason=h),K(i)}function O(e,t){const n=C(e);if(!n)return null;const r=n.type;if(typeof r!="string"||r.length===0)return null;const o={title:t||r,type:r};return n.payload!==void 0&&(o.payload=n.payload),o}function C(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 io(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function yt(e){if(typeof e=="string"){const t=e.trim();return t?[t]:[]}return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0):[]}function re(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 oe(e){return e!=null}var ao=new Set(["sku","name","brand","images","price","price_discounted","price_discount_rate","price_currency","discount_reason","url","rating","review_count","cart_code","in_stock","description","description_html","features","specifications","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function K(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,r=t&&e.price!=null?e.price:void 0;let o;r!=null&&n!=null&&r>0?o=Math.round((r-n)/r*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=v(e.brand),a=v(e.name)??e.sku,s=i&&!a.toLowerCase().startsWith(i.toLowerCase())?`${i} ${a}`:a,c={sku:e.sku,name:s,url:v(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&n>0&&(c.price=String(n)),r!=null&&r>0&&(c.originalPrice=String(r)),o!==void 0&&(c.discountPercent=o),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.category_names&&e.category_names.length>0&&(c.categoryNames=e.category_names),e.short_name!==void 0&&(c.shortName=e.short_name);const d=e,p={};let f=!1;for(const g of Object.keys(d))ao.has(g)||(p[g]=d[g],f=!0);return f&&(c.extras=p),c}function so(e){const t=e.payload.type,{type:n,...r}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:r}}}}}var co=7200*1e3,_t=200,uo=5*1024*1024,lo="gengage_request_response_cache",fo=1,L="responses",po=new Set(["addToCart","like"]),N=new Map,vt=null;async function go(e,t={},n={}){const r=ho(e,t);if(!r)return fetch(e,t);const o=Date.now(),i=await yo(r,o);if(i)return bo(i);const a=await fetch(e,t);return a.ok&&_o(r,a.clone(),o,{ttlMs:n.ttlMs??co,maxEntries:n.maxEntries??_t,maxBodyBytes:n.maxBodyBytes??uo}),a}function ho(e,t={}){if(typeof Request<"u"&&e instanceof Request)return null;const n=String(t.method||"GET").toUpperCase();return n!=="POST"||typeof t.body!="string"||mo(t.body)?null:`rr:${To(Ao({url:String(e),method:n,headers:wo(t.headers),body:t.body}))}`}function mo(e){try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t.type;return typeof n=="string"&&po.has(n)}catch{return!1}}async function yo(e,t){const n=N.get(e);if(n)if(n.expiresAt<=t)N.delete(e);else return n.lastAccessedAt=t,N.delete(e),N.set(e,n),Ne(n),n;const r=await So(e);return r?r.expiresAt<=t?(N.delete(e),zo(e),null):(r.lastAccessedAt=t,N.set(e,r),Ne(r),bt(_t),r):null}async function _o(e,t,n,r){try{const o=await t.text();if($o(o)>r.maxBodyBytes||vo(o))return;const i={key:e,status:t.status,statusText:t.statusText,headers:ko(t.headers),body:o,createdAt:n,expiresAt:n+r.ttlMs,lastAccessedAt:n};N.set(e,i),bt(r.maxEntries),await Ne(i),await Eo(r.maxEntries,n)}catch{}}function vo(e){return/"_error"\s*:/u.test(e)||/"type"\s*:\s*"error"/u.test(e)}function bo(e){return new Response(e.body,{status:e.status,statusText:e.statusText,headers:new Headers(e.headers)})}function wo(e){const t=new Headers(e),n=[];return t.forEach((r,o)=>{const i=o.toLowerCase();i!=="authorization"&&i!=="cookie"&&n.push([i,r])}),n.sort(([r],[o])=>r.localeCompare(o))}function ko(e){const t=[];return e.forEach((n,r)=>{const o=r.toLowerCase();o!=="set-cookie"&&t.push([o,n])}),t.sort(([n],[r])=>n.localeCompare(r))}function bt(e){for(;N.size>e;){const t=[...N.values()].sort((n,r)=>n.lastAccessedAt-r.lastAccessedAt)[0];if(!t)break;N.delete(t.key)}}async function de(){return typeof indexedDB>"u"?null:(vt??=new Promise(e=>{const t=indexedDB.open(lo,fo);t.onupgradeneeded=()=>{const n=t.result;n.objectStoreNames.contains(L)||n.createObjectStore(L,{keyPath:"key"}).createIndex("lastAccessedAt","lastAccessedAt",{unique:!1})},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}),vt)}async function So(e){const t=await de();return t?new Promise(n=>{const r=t.transaction(L,"readonly"),o=r.objectStore(L).get(e);o.onsuccess=()=>n(o.result??null),o.onerror=()=>n(null),r.onerror=()=>n(null)}):null}async function Ne(e){const t=await de();t&&await new Promise(n=>{const r=t.transaction(L,"readwrite");r.objectStore(L).put(e),r.oncomplete=()=>n(),r.onerror=()=>n(),r.onabort=()=>n()})}async function zo(e){const t=await de();t&&await new Promise(n=>{const r=t.transaction(L,"readwrite");r.objectStore(L).delete(e),r.oncomplete=()=>n(),r.onerror=()=>n(),r.onabort=()=>n()})}async function Eo(e,t){const n=await de();n&&await new Promise(r=>{const o=n.transaction(L,"readwrite"),i=o.objectStore(L),a=[],s=i.openCursor();s.onsuccess=()=>{const c=s.result;if(!c){const u=a.filter(p=>p.expiresAt<=t),d=a.filter(p=>p.expiresAt>t).sort((p,f)=>p.lastAccessedAt-f.lastAccessedAt).slice(0,Math.max(0,a.length-u.length-e));for(const p of[...u,...d])i.delete(p.key);return}a.push(c.value),c.continue()},s.onerror=()=>r(),o.oncomplete=()=>r(),o.onerror=()=>r(),o.onabort=()=>r()})}function Ao(e){return JSON.stringify(qe(e))}function qe(e){return Array.isArray(e)?e.map(qe):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,qe(n)]))}function To(e){let t=14695981039346656037n;const n=1099511628211n;for(let r=0;r<e.length;r+=1)t^=BigInt(e.charCodeAt(r)),t=BigInt.asUintN(64,t*n);return t.toString(16).padStart(16,"0")}function $o(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).byteLength:e.length}async function Io(e,t,n){const r=hr("launcher_action",t),o={uiSpecs:[],actions:[]},i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);const a=await go(r,i);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const s={onEvent:c=>{const u=br(c);if(u&&(u.type==="ui_spec"&&o.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const d of Object.values(u.spec.elements))if(d.type==="ActionButton"&&d.props?.action){const p=d.props.action;o.actions.push(p)}}}};return n!==void 0&&(s.signal=n),await fr(a,s),o}function wt(e){const t=document.createElement("div");t.className="gengage-qna-buttons gds-toolbar",t.dataset.gengagePart="qna-button-row",t.setAttribute("role","group"),t.setAttribute("aria-label",e.quickQuestionsAriaLabel??"Quick questions"),e.orientation==="vertical"&&(t.style.flexDirection="column");for(const n of e.actions){const r=document.createElement("button");r.className="gengage-qna-button gds-chip",r.dataset.gengagePart="qna-quick-question",r.textContent=n.title,r.type="button",r.addEventListener("click",()=>{const o={title:n.title,type:n.type};n.payload!==void 0&&(o.payload=n.payload),e.onAction(o)}),t.appendChild(r)}if(e.ctaText||e.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta gds-btn gds-btn-secondary",n.dataset.gengagePart="qna-cta",n.textContent=e.ctaText??e.defaultCtaText??"Ask something else",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function Po(e){const t=document.createElement("div");t.className="gengage-qna-input-wrapper",t.dataset.gengagePart="qna-input-wrapper";const n=document.createElement("div");n.className="gengage-qna-input-combo",n.dataset.gengagePart="qna-input-combo";const r=document.createElement("input");r.type="text",r.className="gengage-qna-input",r.dataset.gengagePart="qna-input",r.setAttribute("aria-label",e.askQuestionAriaLabel??"Ask a question");const o=Array.isArray(e.placeholders)?e.placeholders:e.placeholders?[e.placeholders]:[e.defaultInputPlaceholder??"Ask a question..."];let i=0,a=o[0]??"";r.placeholder=a;let s=null,c=null,u=!1;const d=()=>{s&&clearInterval(s),s=null,c&&clearTimeout(c),c=null,r.classList.remove("gengage-qna-input--fade")},p=()=>o.length>1&&!u&&r.value.trim().length===0,f=()=>{d(),p()&&(s=setInterval(()=>{p()&&(r.classList.add("gengage-qna-input--fade"),c=setTimeout(()=>{i=(i+1)%o.length,a=o[i]??"",r.placeholder=a,r.classList.remove("gengage-qna-input--fade")},180))},3e3))},g=document.createElement("div");g.className="gengage-qna-input-actions",g.dataset.gengagePart="qna-input-actions";const h=document.createElement("button");h.className="gengage-qna-icon-btn gengage-qna-clear gengage-qna-icon-btn--hidden",h.type="button",h.dataset.gengagePart="qna-clear",h.setAttribute("aria-label","Clear question"),h.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18" /><path d="M6 6L18 18" /></svg>';const m=document.createElement("button");m.className="gengage-qna-icon-btn gengage-qna-send gengage-qna-icon-btn--hidden",m.type="button",m.dataset.gengagePart="qna-send",m.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question"),m.disabled=!0,m.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M22 2L11 13" /><path d="M22 2L15 22L11 13L2 9L22 2Z" /></svg><span class="gengage-qna-sr-only">${e.ctaLabel??e.sendButtonText??"Ask"}</span>`;const _=()=>{const k=r.value.trim().length>0;h.classList.toggle("gengage-qna-icon-btn--hidden",!k),m.classList.toggle("gengage-qna-icon-btn--hidden",!k),m.classList.toggle("gengage-qna-send--active",k),m.disabled=!k},w=()=>{const k=r.value.trim();k&&(e.onSubmit({title:k,type:"user_message",payload:k}),r.value="",_(),f())};return h.addEventListener("click",()=>{r.value="",_(),r.focus({preventScroll:!0})}),m.addEventListener("click",w),r.addEventListener("focus",()=>{u=!0,d(),r.placeholder=""}),r.addEventListener("blur",()=>{u=!1,r.value.trim().length===0&&(r.placeholder=a),f()}),r.addEventListener("input",()=>{if(_(),r.value.trim().length>0){d();return}r.placeholder=u?"":a,f()}),r.addEventListener("keydown",k=>{k.key==="Enter"&&(k.preventDefault(),w()),k.key==="Escape"&&r.value.length>0&&(r.value="",_(),f())}),g.appendChild(h),g.appendChild(m),n.appendChild(r),n.appendChild(g),t.appendChild(n),_(),f(),t._cleanup=()=>{d()},t}function fe(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.type;if(typeof r!="string"||r.length===0)return null;const o=n.title,i=n.payload,a=typeof o=="string"&&o.length>0?o:t;if(!a)return null;const s={title:a,type:r};return i!==void 0&&(s.payload=i),s}function kt(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function St(e,t){const n=[],r=e.props?.actions;if(Array.isArray(r))for(const a of r){const s=fe(a);s&&n.push(s)}const o=e.props?.buttons;if(Array.isArray(o))for(const a of o){if(!a||typeof a!="object")continue;const s=a,c=typeof s.label=="string"?s.label:void 0,u=fe(s.action,c);u&&n.push(u)}if(e.children)for(const a of e.children){const s=t.elements[a];if(!s||s.type!=="ActionButton")continue;const c=typeof s.props?.label=="string"?s.props.label:void 0,u=fe(s.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))}var zt={ButtonRow:({element:e,spec:t,context:n})=>{const r=St(e,t).map(kt),o=e.props?.orientation,i={actions:r,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(i.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(i.ctaText=n.ctaText),(o==="horizontal"||o==="vertical")&&(i.orientation=o),wt(i)},ActionButtons:({element:e,spec:t,context:n})=>{const r={actions:St(e,t).map(kt),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),wt(r)},ActionButton:({element:e,context:t})=>{const n=document.createElement("button");n.className="gengage-qna-button gds-chip",n.type="button",n.dataset.gengagePart="qna-action-button";const r=e.props?.label;typeof r=="string"?n.textContent=r:n.textContent=t.i18n.defaultCtaText;const o=fe(e.props?.action,typeof r=="string"?r:void 0);return o&&n.addEventListener("click",()=>t.onAction(o)),n},TextInput:({element:e,context:t})=>{const n=e.props?.placeholder,r=typeof n=="string"||Array.isArray(n)?n:t.inputPlaceholder,o=typeof e.props?.ctaLabel=="string"?e.props.ctaLabel:void 0,i={onSubmit:t.onAction,askQuestionAriaLabel:t.i18n.askQuestionAriaLabel,defaultInputPlaceholder:t.i18n.defaultInputPlaceholder,sendButtonText:t.i18n.sendButton,sendQuestionAriaLabel:t.i18n.sendQuestionAriaLabel};return r!==void 0&&(i.placeholders=r),o!==void 0&&(i.ctaLabel=o),Po(i)},QuestionHeading:({element:e,context:t})=>{const n=document.createElement("h3");n.className="gengage-qna-heading",n.dataset.gengagePart="qna-heading";const r=e.props?.text,o=t.headingTitleOverride;return n.textContent=typeof o=="string"&&o.trim().length>0?o:typeof r=="string"?r:"",n},ProductCard:()=>null},je=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function Et(){return{...zt}}function At(e,t,n=zt,r=je){return $n({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:r})}function Co(e){if(!e)return;const t=e.extra;if(t&&typeof t=="object"&&!Array.isArray(t)){const r=t.visible_skus??t.visibleSkus;if(Array.isArray(r)){const o=r.filter(i=>typeof i=="string"&&i.trim().length>0).map(i=>i.trim()).slice(0,200);if(o.length>0)return o}}const n=typeof e.sku=="string"&&e.sku.trim()?e.sku.trim():void 0;return n?[n]:void 0}function Tt(e,t){if(!e)return null;const n=e.action;if(!n||typeof n!="object")return null;const r=n,o=r.type;if(typeof o!="string"||o.length===0)return null;const i=r.title,a=typeof i=="string"&&i.length>0?i:typeof t=="string"&&t.length>0?t:"";if(!a)return null;const s=r.payload,c={title:a,type:o};return s!==void 0&&(c.payload=s),c}function xo(e,t){const n=e.elements[e.root];if(!n)return!1;const r=o=>{if(o.type!=="ActionButton")return!1;const i=o.props;if(!i||typeof i!="object")return!1;const a=typeof i.label=="string"?i.label:void 0;return a===t?!0:Tt(i,a)?.title===t};if(n.type==="ActionButton")return r(n);if(n.children)for(const o of n.children){const i=e.elements[o];if(i&&r(i))return!0}if(n.type==="ActionButtons"&&Array.isArray(n.props?.buttons)){for(const o of n.props.buttons)if(o?.label===t||o?.action?.title===t)return!0}return!1}var $t=0;function It(){return $t+=1,`gengage-merge-${$t}`}function Oo(e,t){const n=e.elements[e.root];if(!n||n.type!=="ButtonRow")return;const r=It();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r]}function Zo(e,t){const n=e.elements[e.root];if(!n||n.type!=="ActionButtons")return;const r=It();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r];const o=n.props?.buttons??[],i={label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}};n.props={...n.props,buttons:[i,...o]}}function Ro(e){const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,...o.payload!==void 0?{payload:o.payload}:{}}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}function Lo(e){return e.find(t=>{const n=t.elements[t.root];return n?.type==="ActionButtons"||n?.type==="ButtonRow"})}function Pt(e,t){const n=e.productContextQuickPillLabel,r={text:n};return t&&t.length>0&&(r.sku_list=t),{title:n,type:"user_message",payload:r}}function No(e,t,n){const r=n?.skuList,o=[],i=[];for(const c of e){const u=c.elements[c.root];if(u?.type==="ActionButton"){const d=u.props;if(Tt(d,typeof d?.label=="string"?d.label:void 0)?.type==="findSimilar"){o.push(Pt(t,r));continue}}i.push(c)}if(o.length===0)return e;const a=Pt(t,r),s=Lo(i);if(!s)return[...i,Ro([a])];if(!xo(s,a.title)){const c=s.elements[s.root];c?.type==="ActionButtons"?Zo(s,a):c?.type==="ButtonRow"&&Oo(s,a)}return i}var Ct={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor",redirectingToChat:"Sohbete yönlendiriliyor...",productContextQuickPillLabel:"Bu ürün hakkında ne bilmeliyim?"},qo={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else",redirectingToChat:"Redirecting to chat...",productContextQuickPillLabel:"What should I know about this product?"};function jo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Do(e){return jo(e)==="en"?qo:Ct}var xt=class extends nr{constructor(...e){super(...e),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=Ct,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this._contentEl.dataset.gengagePart="qna-container",this._contentEl.lang=ot(e.locale);const t=this._createChrome(e);if(t){const r=document.createElement("div");r.className="gengage-qna-chrome-widget",r.dataset.gengagePart="qna-chrome-widget",r.appendChild(this._contentEl),t.appendChild(r),this.root.appendChild(t)}else this.root.appendChild(this._contentEl);const n=e.pageContext?.sku;n&&(this._lastSku=n,await this._fetchAndRender(n)),On("qna")}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_resolvedQnaHeaderTitle(){const e=this.config.headerTitle??this.config.headingTitle;if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}_cleanupTextInputTimers(){if(!this._contentEl)return;const e=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const t of e)t._cleanup?.()}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const t=this._createLoadingIndicator();this._contentEl.appendChild(t);const n={middlewareUrl:this.config.middlewareUrl},r=lr({source:"qna",locale:this.config.locale});try{const o=this.config.session?.sessionId??"",i={account_id:this.config.accountId,session_id:o,correlation_id:o,sku:e,locale:ot(this.config.locale)};this.config.session?.userId!==void 0&&(i.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(i.view_id=this.config.session.viewId);const a=this.config.pageContext?.pageType;a!==void 0&&(i.page_type=a);const s=await Io(i,n,this._abortController.signal);if(!this._contentEl)return;this._contentEl.innerHTML="";const c=document.createElement("div");c.className="gengage-qna-panel gds-panel",c.dataset.gengagePart="qna-panel",this._contentEl.appendChild(c);const u=this._specIncludesType(s.uiSpecs,"QuestionHeading"),d=this._resolvedQnaHeaderTitle()??(this.config.showStaticQuestion&&this.config.staticQuestionText?this.config.staticQuestionText:void 0);if(!u&&d){const k=document.createElement("h3");k.className="gengage-qna-heading",k.textContent=d,c.appendChild(k)}const p=this.config.inputPlaceholder;let f;if(p!==!0)f=p??this._i18n.defaultInputPlaceholder;else if(s.actions.length>0){const k=s.actions.filter(I=>I.type==="user_message"||I.title.includes("?")).map(I=>I.title);f=k.length>0?k:this._i18n.defaultInputPlaceholder}else f=this._i18n.defaultInputPlaceholder;const g={onAction:this._actionHandler,i18n:this._i18n},h=this._resolvedQnaHeaderTitle();h!==void 0&&(g.headingTitleOverride=h),this.config.hideButtonRowCta||(g.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(g.ctaText=this.config.ctaText)),f!==void 0&&(g.inputPlaceholder=f);const m=this._buildFallbackActionsSpec(s.actions),_=Co(this.config.pageContext),w=(s.uiSpecs.length>0?No(s.uiSpecs,this._i18n,{skuList:_}):[m]).filter(k=>Object.keys(k.elements).length>0);for(const k of w){const I=this._renderUISpec(k,g);c.appendChild(I)}w.length>0&&Zn("qna"),this._specIncludesType(w,"TextInput")||this._insertStandaloneInputBeforePills(c,g,f)}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;if(Te("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:Hn(this.config.locale,o)}),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const i=document.createElement("div");i.className="gengage-qna-panel",this._contentEl.appendChild(i);const a=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,s={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler},c=this._resolvedQnaHeaderTitle();c!==void 0&&(s.headingTitleOverride=c),this.config.ctaText!==void 0&&(s.ctaText=this.config.ctaText),this._appendStandaloneInput(s,a,i)}}finally{r()}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let t=0;t<3;t++){const n=document.createElement("div");n.className="gengage-qna-loading-dot",e.appendChild(n)}return e}_resolveI18n(e){return{...Do(e.locale),...e.i18n}}_createChrome(e){const t=e.chrome;if(!t)return null;const n=typeof t.title=="string"?t.title.trim():"",r=typeof t.subtitle=="string"?t.subtitle.trim():"",o=typeof t.startButtonLabel=="string"?t.startButtonLabel.trim():"",i=typeof t.imageUrl=="string"?t.imageUrl.trim():"",a=typeof t.imagePadding=="string"?t.imagePadding.trim():"",s=document.createElement("section");s.className="gengage-qna-chrome",s.dataset.gengagePart="qna-chrome",t.layout==="side-image"&&(s.classList.add("gengage-qna-chrome--side-image"),s.dataset.gengageChromeLayout="side-image"),a&&s.style.setProperty("--gengage-qna-chrome-image-padding",a);const c=document.createElement("div");if(c.className="gengage-qna-chrome-copy",c.dataset.gengagePart="qna-chrome-copy",n){const u=document.createElement("h2");u.className="gengage-qna-chrome-title",u.dataset.gengagePart="qna-chrome-title",u.textContent=n,c.appendChild(u)}if(r){const u=document.createElement("p");u.className="gengage-qna-chrome-subtitle",u.dataset.gengagePart="qna-chrome-subtitle",u.textContent=r,c.appendChild(u)}if(c.children.length>0&&s.appendChild(c),i&&Cn(i)){const u=document.createElement("img");u.className="gengage-qna-chrome-image",u.dataset.gengagePart="qna-chrome-image",u.src=i,u.alt=typeof t.imageAlt=="string"?t.imageAlt:"",u.loading="lazy",u.addEventListener("error",()=>{u.style.display="none"},{once:!0}),s.appendChild(u)}if(o){const u=document.createElement("button");u.className="gengage-qna-chrome-start",u.dataset.gengagePart="qna-chrome-start",u.type="button",u.textContent=o,u.addEventListener("click",()=>this._handleOpenChat()),s.appendChild(u)}return s.children.length===0?null:s}_resolveUISpecRegistry(){return In(Et(),this.config.renderer?.registry)}_renderUISpec(e,t){const n=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??je,o=(a,s)=>At(a,s,n,r),i=this.config.renderer?.renderUISpec;return i?i(e,t,{registry:n,unknownRenderer:r,defaultRender:o}):o(e,t)}_specIncludesType(e,t){for(const n of e)for(const r of Object.values(n.elements))if(r.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,payload:o.payload}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}_insertStandaloneInputBeforePills(e,t,n){const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:n}}}},o=this._renderUISpec(r,t),i=o.querySelector(".gengage-qna-input-wrapper");if(!i)return;const a=e.querySelector(".gengage-qna-uispec"),s=e.querySelector(".gengage-qna-uispec > .gengage-qna-buttons"),c=this.config.inputAfterPills===!0;if(s)c?s.insertAdjacentElement("afterend",i):s.insertAdjacentElement("beforebegin",i);else if(a){const u=a.querySelector(":scope > .gengage-qna-heading");!c&&u?u.insertAdjacentElement("afterend",i):a.appendChild(i)}else{e.appendChild(o);return}o.remove()}_appendStandaloneInput(e,t,n){if(!this._contentEl)return;const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:t}}}},o=this._renderUISpec(r,e);(n??this._contentEl).appendChild(o)}_handleAction(e){this._showTransitionIndicator(),Rn(e.title,e.type),this.config.onActionSelected?.(e),setTimeout(()=>Te("gengage:qna:action",e),350)}_handleOpenChat(){this._showTransitionIndicator(),this.config.onOpenChat?.(),setTimeout(()=>Te("gengage:qna:open-chat",{}),350)}_showTransitionIndicator(){if(!this._contentEl)return;this._contentEl.querySelector(".gengage-qna-transition-indicator")?.remove(),this._contentEl.classList.add("gengage-qna--transitioning");const e=this._i18n.redirectingToChat??"Redirecting to chat...",t=document.createElement("div");t.className="gengage-qna-transition-indicator",t.textContent=e,(this._contentEl.querySelector(".gengage-qna-panel")??this._contentEl).appendChild(t),setTimeout(()=>{this._contentEl?.classList.remove("gengage-qna--transitioning"),t.remove()},600)}};function Uo(){return new xt}var Ot;function l(e,t,n){function r(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const u=a.prototype,d=Object.keys(u);for(let p=0;p<d.length;p++){const f=d[p];f in s||(s[f]=u[f].bind(s))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(s){var c;const u=n?.Parent?new i:this;r(u,s),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var Y=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Zt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Ot=globalThis).__zod_globalConfig??(Ot.__zod_globalConfig={});var pe=globalThis.__zod_globalConfig;function J(e){return e&&Object.assign(pe,e),pe}function Rt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}function De(e,t){return typeof t=="bigint"?t.toString():t}function Ue(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function Be(e){return e==null}function Me(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var Lt=Symbol("evaluating");function b(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Lt)return r===void 0&&(r=Lt,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Q(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function U(...e){const t={};for(const n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Nt(e){return JSON.stringify(e)}function Bo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Mo=Ue(()=>{if(pe.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function ie(e){if(ge(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ge(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function jt(e){return ie(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Fo=new Set(["string","number","symbol"]);function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function B(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function y(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ho(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var yu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Jo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return B(e,U(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=n.shape[i])}return Q(this,"shape",o),o},checks:[]}))}function Qo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return B(e,U(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return Q(this,"shape",o),o},checks:[]}))}function Wo(e,t){if(!ie(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const r=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return B(e,U(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Q(this,"shape",r),r}}))}function Vo(e,t){if(!ie(t))throw new Error("Invalid input to safeExtend: expected a plain object");return B(e,U(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Q(this,"shape",n),n}}))}function Go(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return B(e,U(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Q(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ko(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return B(t,U(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const a in n){if(!(a in o))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=e?new e({type:"optional",innerType:o[a]}):o[a])}else for(const a in o)i[a]=e?new e({type:"optional",innerType:o[a]}):o[a];return Q(this,"shape",i),i},checks:[]}))}function Yo(e,t,n){return B(t,U(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)o[i]=new e({type:"nonoptional",innerType:r[i]});return Q(this,"shape",o),o}}))}function X(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Xo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Dt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function me(e){return typeof e=="string"?e:e?.message}function W(e,t,n){const r=e.message?e.message:me(e.inst?._zod.def?.error?.(e))??me(t?.error?.(e))??me(n.customError?.(e))??me(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:a,...s}=e;return s.path??(s.path=[]),s.message=r,t?.reportInput&&(s.input=a),s}function Fe(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ae(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}var Ut=(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,De,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Bt=l("$ZodError",Ut),Mt=l("$ZodError",Ut,{Parent:Error});function ei(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function ti(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>r({issues:s},[...i,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...i,...a.path]);else{const s=[...i,...a.path];if(s.length===0)n._errors.push(t(a));else{let c=n,u=0;for(;u<s.length;){const d=s[u];u!==s.length-1?c[d]=c[d]||{_errors:[]}:(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(a))),c=c[d],u++}}}};return r(e),n}var He=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Y;if(a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>W(c,i,J())));throw qt(s,o?.callee),s}return a.value},Je=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>W(c,i,J())));throw qt(s,o?.callee),s}return a.value},ye=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Y;return i.issues.length?{success:!1,error:new(e??Bt)(i.issues.map(a=>W(a,o,J())))}:{success:!0,data:i.value}},ni=ye(Mt),_e=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>W(a,o,J())))}:{success:!0,data:i.value}},ri=_e(Mt),oi=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return He(e)(t,n,o)},ii=e=>(t,n,r)=>He(e)(t,n,r),ai=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Je(e)(t,n,o)},si=e=>async(t,n,r)=>Je(e)(t,n,r),ci=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ye(e)(t,n,o)},ui=e=>(t,n,r)=>ye(e)(t,n,r),li=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return _e(e)(t,n,o)},di=e=>async(t,n,r)=>_e(e)(t,n,r),fi=/^[cC][0-9a-z]{6,}$/,pi=/^[0-9a-z]+$/,gi=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hi=/^[0-9a-vA-V]{20}$/,mi=/^[A-Za-z0-9]{27}$/,yi=/^[a-zA-Z0-9_-]{21}$/,_i=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vi=/^([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})$/,Ft=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)$/,bi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,wi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ki(){return new RegExp(wi,"u")}var Si=/^(?:(?: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])$/,zi=/^(([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}|:))$/,Ei=/^((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])$/,Ai=/^(([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])$/,Ti=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ht=/^[A-Za-z0-9_-]*$/,$i=/^https?$/,Ii=/^\+[1-9]\d{6,14}$/,Jt="(?:(?:\\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])))",Pi=new RegExp(`^${Jt}$`);function Qt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ci(e){return new RegExp(`^${Qt(e)}$`)}function xi(e){const t=Qt({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Jt}T(?:${r})$`)}var Oi=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Zi=/^(?:true|false)$/i,Ri=/^[^A-Z]*$/,Li=/^[^a-z]*$/,q=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ni=l("$ZodCheckMaxLength",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Be(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=Fe(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),qi=l("$ZodCheckMinLength",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Be(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=Fe(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ji=l("$ZodCheckLengthEquals",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Be(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const a=Fe(o),s=i>t.length;r.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ve=l("$ZodCheckStringFormat",(e,t)=>{var n,r;q.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Di=l("$ZodCheckRegex",(e,t)=>{ve.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})}}),Ui=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ri),ve.init(e,t)}),Bi=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Li),ve.init(e,t)}),Mi=l("$ZodCheckIncludes",(e,t)=>{q.init(e,t);const n=he(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Fi=l("$ZodCheckStartsWith",(e,t)=>{q.init(e,t);const n=new RegExp(`^${he(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Hi=l("$ZodCheckEndsWith",(e,t)=>{q.init(e,t);const n=new RegExp(`.*${he(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Ji=l("$ZodCheckOverwrite",(e,t)=>{q.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),Qi=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const t=e.split(`
|
|
47
|
+
`,document.head.appendChild(e)}var te=null;function Xn(){if(te!==null)return te;try{te=localStorage.getItem("gengage:debug")==="1"}catch{te=!1}return te}function Pe(e,t,n){if(!Xn())return;const r=[`[gengage:${e}]`,t];n!==void 0&&r.push(n),console.debug(...r)}var er=("0.6.23".trim(),"0.6.23".trim()),tr=("iife-build".trim(),"iife-build".trim());function nr(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${er} (${tr})`))}var rr=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=jn(e.theme);nr(),this.config={...e,theme:t,session:qn(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),Qn();const n=Ye("gengage:context:update",r=>this.update(r));this._cleanups.push(n),Pe("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(r){throw this.destroy(),r}this._destroying||(this.isInitialised=!0,Pe("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}emit(e,...t){this._handlers.get(e)?.forEach(n=>n(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const n=document.querySelector(e);if(!n)throw new Error(`[gengage] Mount target not found: "${e}"`);return n}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,n]of Object.entries(e))if(n!==void 0){const r=t.startsWith("--")?t:`--gengage-${or(t)}`;this.root.style.setProperty(r,n)}}}};function or(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function ot(e){const t=e?.trim();return t||"tr"}var ir=8e3,ar=5e3,sr="https://www.google.com/favicon.ico",j=new Map,it=!1,G=null,ne=null,H=!1;function cr(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function at(e){return cr(e)?"İnternet bağlantısında sorun var gibi görünüyor. İstek sürerken yeniden deneyeceğiz.":"Your internet connection looks unstable. We'll keep retrying while this request is active."}function st(){let e;for(const t of j.values())e=t;return e}function Ce(){G&&(clearTimeout(G),G=null)}function ur(){ne&&(clearInterval(ne),ne=null)}async function ct(){try{if(typeof navigator<"u"&&navigator.onLine===!1)return!1;if(typeof window<"u"){const n=window.location.hostname;if(n==="localhost"||n==="127.0.0.1")return navigator.onLine}const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);try{return await fetch(sr,{method:"HEAD",mode:"no-cors",cache:"no-cache",signal:e.signal}),!0}catch{return navigator.onLine}finally{clearTimeout(t)}}catch{return typeof navigator>"u"?!0:navigator.onLine}}function ue(){H=!1,ur(),rt()}function le(){G||H||j.size===0||(G=setTimeout(async()=>{G=null,!(H||j.size===0)&&!await ct()&&j.size>0&&(H=!0,Ie({source:"sdk",message:at(st()),sticky:!0}),ne||(ne=setInterval(async()=>{if(j.size===0){ue();return}await ct()&&(ue(),le())},ar)))},ir))}function lr(){it||typeof window>"u"||(it=!0,window.addEventListener("online",()=>{ue(),le()}),window.addEventListener("offline",()=>{j.size===0||H||(H=!0,Ce(),Ie({source:"sdk",message:at(st()),sticky:!0}))}))}function dr(e){lr();const t=Symbol(e.source);j.set(t,e.locale),le();let n=!1;return()=>{if(!n){if(n=!0,j.delete(t),j.size===0){Ce(),ue();return}H||(Ce(),le())}}}function ut(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function fr(e){const t=[];let n=0,r=!1,o=!1,i=0;for(let a=0;a<e.length;a++){const s=e[a];if(o){o=!1;continue}if(s==="\\"&&r){o=!0;continue}if(s==='"'){r=!r;continue}r||(s==="{"&&n++,s==="}"&&(n--,n===0&&(t.push(e.slice(i,a+1)),i=a+1)))}return t.length>0?t:[e]}function lt(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const r=n.startsWith("data: ")?n.slice(6):n;if(r==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(r);return ut(o)?(Pe("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=fr(r);if(o.length>1){for(const i of o)try{const a=JSON.parse(i);if(!ut(a))continue;if(t.onEvent(a),a.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function pr(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const n=e.body.getReader(),r=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,a=Symbol("idle-timeout");let s=!1;try{for(;;){const c=n.read();let u;const d=await(i>0?Promise.race([c.then(h=>(clearTimeout(u),h)),new Promise(h=>{u=setTimeout(()=>h(a),i)})]):c);if(d===a){s=!0,await n.cancel();break}const{done:p,value:f}=d;if(p)break;o+=r.decode(f,{stream:!0});const g=o.split(`
|
|
48
|
+
`);o=g.pop()??"";for(const h of g)if(lt(h,t))return}if(o.trim()&<(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||n.releaseLock()}t.onDone?.()}var gr={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function hr(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 mr(e,t){return`${hr(t?.middlewareUrl)}/chat${gr[e]}`}var dt=3,yr=(e,t)=>{const n=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!n)return"";const r=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,"").trim():n;return r?r.split(/\s+/).slice(0,3).join(" ").trim():""},xe=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(n=>yr(n,t)).filter(Boolean):[];function _r(e){const t=(e.display_keywords??[]).flatMap(o=>xe(o,{stripLeadingStopWords:!0})),n=t.filter((o,i)=>t.indexOf(o)===i);if(n.length>0)return n.slice(0,dt);const r=[...xe(e.chosen_attribute,{stripLeadingStopWords:!0}),...xe(e.short_name)];return r.filter((o,i)=>r.indexOf(o)===i).slice(0,dt)}function vr(e){return _r(e).join(" • ")}function br(e){return e==="beauty_consulting"||e==="account_expert"}function Oe(...e){for(const t of e){if(typeof t!="string")continue;const n=t.trim();if(n.length>0)return n}}function Ze(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim()):[]}function ft(e){const t={...e},n=Oe(t.sku),r=Ze(t.group_skus);if(n?t.sku=n:delete t.sku,r.length>0?t.group_skus=r:delete t.group_skus,n||r.length>0)delete t.image_url;else{const o=Oe(t.image_url);o?t.image_url=o:delete t.image_url}return t}function wr(e){if(typeof e.type!="string")return null;if(kr(e))return e;const t=e;switch(t.type){case"outputText":return Sr(t);case"suggestedActions":return zr(t);case"productList":return Er(t);case"productDetails":return Ar(t);case"productDetailsSimilars":return Tr(t);case"comparisonTable":return $r(t);case"context":return xr(t);case"chatStreamEnd":return Or();case"loading":return Zr(t);case"panelLoading":return Rr(t);case"similarLoading":return Lr(t);case"redirect":return Nr(t);case"error":return qr(t);case"dummy":return jr(t);case"launcherAction":return Dr(t);case"text":return Re(t);case"productItem":return Ur(t);case"text_image":return pt(t);case"quick_qna":return gt(t);case"reviewHighlights":return Br(t);case"aiProductSuggestions":return Hr(t);case"aiProductGroupings":return Jr(t);case"aiSuggestedSearches":return Wr(t);case"prosAndCons":return Mr(t);case"getGroundingReview":return Vr(t);case"voice":return Kr(t);case"visitorDataResponse":return Fr(t);case"productListPreview":return Gr();case"groupList":return Yr(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Xr(t);case"launcherContent":return to(t);case"handoff":return eo(t);case"uiSpec":return co(t);default:return null}}function kr(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const r=C(e.spec);return r?typeof r.root=="string"&&C(r.elements)!==null:!1}case"action":{const n=C(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 Sr(e){const t=v(e.payload.text,e.payload.plain_text)??"",n=v(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const r={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(r.productMentions=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(r.skuToProductItem=i);const a=e.payload.conversation_mode;typeof a=="string"&&a&&(r.conversationMode=a);const s=e.payload.render_hint;return typeof s=="string"&&s&&(r.renderHint=s),e.payload.kvkk===!0&&(r.kvkk=!0),r}function zr(e){return mt((e.payload.actions??[]).map(t=>{const n=v(t.title)??"",r=O(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(oe),"chat")}function Er(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(a=>{const s=v(a.style_label);if(!s)return null;const c=v(a.style_mood),u=v(a.image_url??void 0),d=(Array.isArray(a.product_list)?a.product_list:[]).map(f=>{const g=C(f);return g?Le(C(g.product_detail)??C(g.product)??g):null}).filter(oe),p=Array.isArray(a.recommendation_groups)?a.recommendation_groups.map(f=>({label:v(f.label)??"",reason:v(f.reason)??"",skus:Array.isArray(f.skus)?f.skus.filter(g=>typeof g=="string"&&g.trim().length>0):[]})):[];return{style_label:s,style_mood:c??"",...u?{image_url:u}:{},...typeof a.status=="string"?{status:a.status}:{},product_list:d,recommendation_groups:p}}).filter(oe),n=e.payload.product_list??[],r=br(e.payload.source)&&t.length>0?t[0].product_list:null,o=r?no(r,"chat"):yt(n,"chat");o.panelHint="panel";const i=o.spec.elements[o.spec.root];if(i){const a={};typeof e.payload.offset=="number"&&(a.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(a.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(a.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(a.source=e.payload.source),t.length>0&&(a.styleVariations=t),e.payload.replace_panel===!0&&(a.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(a.rankingState=e.payload.ranking_state);const s=e.payload.sequence_id??e.payload.search_id;typeof s=="string"&&s.length>0&&(a.sequenceId=s),Object.keys(a).length>0&&(i.props={...i.props,...a})}return o}function Ar(e){const t=e.payload.productDetails;if(!t)return oo("chat");const n=K(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...n}}}}},panelHint:"panel"}}function Tr(e){const t=yt(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function $r(e){const t=e.payload.multiple_product_details??[],n=e.payload,r={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,a=[];for(const _ of t){const w=K(_);a.push(w)}const s=Ir(o,a,r,i);let c;r?.recommended_choice_sku?c=r.recommended_choice_sku:r?.winner_product&&r.winner_product.length>0&&(c=r.winner_product[0]?.product_detail?.sku??r.winner_product[0]?.sku);const u=c?a.find(_=>_.sku===c)??a[0]:a[0],d=[];if(Array.isArray(r?.key_differences))for(const _ of r.key_differences)typeof _=="string"&&d.push(_);const p=_t(r?.special_considerations),f=r?.recommended_choice,g=r?.winner_hits,h={};for(const _ of a){const w=_.sku;w&&(h[w]={title:_.name??w,type:"launchSingleProduct",payload:{sku:w}})}const m={products:a,attributes:s,highlights:d,productActions:h};return u&&(m.recommended=u),p.length>0&&(m.specialCases=p),f&&(m.recommendedText=f),g&&(m.winnerHits=g),typeof r?.key_differences=="string"&&(m.keyDifferencesHtml=r.key_differences),r?.special_considerations&&(m.specialConsiderations=r.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function Ir(e,t,n,r){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const p=n.criteria_view??n.criteria_view_short??{},f=n.compared_field_names??Object.keys(e),g=[];for(const h of f){const m=e[h];if(!m||!Array.isArray(m))continue;const _=p[h]??h;g.push({label:_,values:m.map(w=>typeof w=="string"?w:String(w??""))})}return g}const a=e,s=t.map(p=>String(p.sku??"")).filter(p=>p.length>0),c=n.criteria_view??n.criteria_view_short??{},u=(r&&r.length>0?r:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:Pr(a)).filter(p=>p!=="name"&&p!=="name_short"&&!p.endsWith("_short")),d=[];for(const p of u){const f=s.map(h=>{const m=a[h];if(!m||typeof m!="object")return"";const _=m[`${p}_short`],w=m[p];return Cr(_??w)});if(f.every(h=>h.length===0))continue;const g=c[p]??p;d.push({label:g,values:f})}return d}function Pr(e){const t=[],n=new Set;for(const r of Object.values(e))if(!(!r||typeof r!="object"))for(const o of Object.keys(r))n.has(o)||(n.add(o),t.push(o));return t}function Cr(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function xr(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Or(){return{type:"done"}}function Zr(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 Rr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Lr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Nr(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 qr(e){return{type:"error",code:"BACKEND_ERROR",message:v(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function jr(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Dr(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.theme=a),gt({type:"quick_qna",payload:o})}const n=C(t.action);if(n){const o={action:n},i=typeof t.text=="string"?t.text:void 0,a=typeof t.image_url=="string"?t.image_url:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),a!==void 0&&(o.image_url=a),s!==void 0&&(o.theme=s),pt({type:"text_image",payload:o})}const r=typeof t.text=="string"?t.text:"";if(r){const o={text:r},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0,s=C(t.payload)??void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.payload=s),a!==void 0&&(o.theme=a),Re({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Re(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 Ur(e){return ro(e.payload,"qna")}function pt(e){const t=v(e.payload.text)??"",n=O(e.payload.action,t);if(n){const o={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const r={text:t};return typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),Re({type:"text",payload:r})}function gt(e){return mt((e.payload.action_list??[]).map(t=>{const n=v(t.title)??"",r=O(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(oe),"qna")}function Br(e){const t={reviews:(e.payload.reviews??[]).map(n=>{const r={};return typeof n.review_class=="string"&&(r.review_class=n.review_class),typeof n.review_text=="string"&&(r.review_text=n.review_text),(typeof n.review_rating=="string"||typeof n.review_rating=="number")&&(r.review_rating=n.review_rating),typeof n.review_tag=="string"&&(r.review_tag=n.review_tag),r})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function Mr(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 Fr(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Hr(e){const t=e.payload.product_suggestions??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=io(o);if(!i)continue;const a={product:i},s=O(o.requestDetails,i.name);s&&(a.action=s),typeof o.role=="string"&&(a.role=o.role),typeof o.reason=="string"&&(a.reason=o.reason),typeof o.review_highlight=="string"&&(a.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(a.labels=o.labels),typeof o.expert_quality_score=="number"&&(a.expertQualityScore=o.expert_quality_score),n.push(a)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function Jr(e){const t=e.payload.product_groupings??[],n=[],r=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const a=v(i.name)??"",s=v(i.description),c=v(i.highlight),u=Array.isArray(i.labels)?_t(i.labels):[],d=v(i.sku,i.repr_sku),p=v(i.image,i.repr_image),f=Qr(i,a,d),g=(Array.isArray(i.group_products)?i.group_products:[]).map(_=>{const w=C(_);return w?Le(w):null}).filter(oe),h=p??v(...g.map(_=>_.imageUrl));if(a&&g.length>0){const _={groupName:a,products:g};h&&(_.image=h),s&&(_.description=s),c&&(_.highlight=c),u.length>0&&(_.labels=u),n.push(_)}if(!f)continue;const m={name:a,action:f};u.length>0&&(m.labels=u),p!==void 0&&(m.image=p),r.push(m)}return n.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n}}}},panelHint:"panel"}:r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:r}}}}}}function Qr(e,t,n){const r=C(e.requestDetails);if(r){if(r.type!=="findSimilar")return O(r,t);const a={...C(r.payload)??{}};n&&!Oe(a.sku)&&(a.sku=n);const s=Ze(e.group_skus);return s.length>0&&(a.group_skus=s),O({...r,payload:ft(a)},t)}const o={};n&&(o.sku=n);const i=Ze(e.group_skus);return i.length>0&&(o.group_skus=i),Object.keys(o).length===0?null:O({type:"findSimilar",payload:ft(o)},t)}function Wr(e){const t=e.payload.suggested_searches??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=v(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${r+1}`,a={},s=v(o.detailed_user_message);s&&(a.text=s);const c=C(C(o.requestDetails)?.payload),u=c?.group_skus;o.group_skus&&Array.isArray(o.group_skus)?a.group_skus=o.group_skus:Array.isArray(u)&&(a.group_skus=u.filter(w=>typeof w=="string"));const d=v(o.sku,o.representative_product_sku,c?.sku);d&&(a.sku=d),a.is_suggested_text=1;const p={type:"inputText",payload:a},f=O(o.requestDetails,i),g=f?.type==="findSimilar"&&typeof a.text=="string"?O(p,i):f??O(p,i);if(!g)continue;const h={shortName:i,action:g},m=v(o.detailed_user_message);m&&m!==i&&(h.detailedMessage=m);const _=vr(o);_&&_!==i&&_!==(m??"")&&(h.whyDifferent=_),typeof o.image=="string"&&(h.image=o.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 Vr(e){const t=e.payload,n=O(t.requestDetails??t.request_details,v(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!n)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const r={action:n};return t.title&&(r.title=t.title),t.text&&(r.text=t.text),t.review_count?r.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(r.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:r}}}}}function Gr(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Kr(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Yr(e){const t=e.payload.group_list??[],n=[];for(const o of t){const i=o.group_name??"",a=(o.product_list??[]).map(K);n.push({groupName:i,products:a})}const r=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const a=O(o.requestDetails,i),s={title:i};a&&(s.action=a),r.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:r}}}},panelHint:"panel"}}function Xr(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function eo(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 to(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function ht(e,t){const n={product:e,index:t},r=e,o=typeof r.sku=="string"?r.sku:void 0;return o&&(n.action={title:typeof r.name=="string"?r.name:"",type:"launchSingleProduct",payload:{sku:o}}),{type:"ProductCard",props:n}}function mt(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`action-${o}`;r.push(a);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),n[a]={type:"ActionButton",props:s}}return n.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function yt(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=K(i),s=`product-${o}`;r.push(s),n[s]=ht(a,o)}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function no(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`product-${o}`;r.push(a),n[a]=ht(i,o)}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function ro(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:K(e),index:0}}}}}}function oo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function io(e){const t=v(e.sku),n=v(e.short_name),r={...C(e.product_item)??e},o=v(e.discount_reason,e.discountReason);return o&&!v(r.discount_reason,r.discountReason)&&(r.discount_reason=o),Le(r,t,n)}function Le(e,t,n){const r=v(e.sku,t),o=v(e.name,n);if(!r||!o)return null;const i={sku:r,name:o},a=v(e.brand);a&&(i.brand=a);const s=v(e.url);s&&(i.url=s);const c=ao(e.images);if(c.length>0)i.images=c;else{const m=v(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const u=re(e.price_discounted);u!==void 0&&(i.price_discounted=u);const d=re(e.price);d!==void 0&&(i.price=d);const p=re(e.rating);p!==void 0&&(i.rating=p);const f=re(e.review_count)??re(e.reviewCount);f!==void 0&&(i.review_count=f);const g=v(e.cart_code,e.cartCode);g&&(i.cart_code=g),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const h=v(e.discount_reason,e.discountReason);return h&&(i.discount_reason=h),K(i)}function O(e,t){const n=C(e);if(!n)return null;const r=n.type;if(typeof r!="string"||r.length===0)return null;const o={title:t||r,type:r};return n.payload!==void 0&&(o.payload=n.payload),o}function C(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 ao(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function _t(e){if(typeof e=="string"){const t=e.trim();return t?[t]:[]}return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0):[]}function re(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 oe(e){return e!=null}var so=new Set(["sku","name","brand","images","price","price_discounted","price_discount_rate","price_currency","discount_reason","url","rating","review_count","cart_code","in_stock","description","description_html","features","specifications","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function K(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,r=t&&e.price!=null?e.price:void 0;let o;r!=null&&n!=null&&r>0?o=Math.round((r-n)/r*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=v(e.brand),a=v(e.name)??e.sku,s=i&&!a.toLowerCase().startsWith(i.toLowerCase())?`${i} ${a}`:a,c={sku:e.sku,name:s,url:v(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&n>0&&(c.price=String(n)),r!=null&&r>0&&(c.originalPrice=String(r)),o!==void 0&&(c.discountPercent=o),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.category_names&&e.category_names.length>0&&(c.categoryNames=e.category_names),e.short_name!==void 0&&(c.shortName=e.short_name);const d=e,p={};let f=!1;for(const g of Object.keys(d))so.has(g)||(p[g]=d[g],f=!0);return f&&(c.extras=p),c}function co(e){const t=e.payload.type,{type:n,...r}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:r}}}}}var uo=7200*1e3,vt=200,lo=5*1024*1024,fo="gengage_request_response_cache",po=1,L="responses",go=new Set(["addToCart","like"]),N=new Map,bt=null;async function ho(e,t={},n={}){const r=mo(e,t);if(!r)return fetch(e,t);const o=Date.now(),i=await _o(r,o);if(i)return wo(i);const a=await fetch(e,t);return a.ok&&vo(r,a.clone(),o,{ttlMs:n.ttlMs??uo,maxEntries:n.maxEntries??vt,maxBodyBytes:n.maxBodyBytes??lo}),a}function mo(e,t={}){if(typeof Request<"u"&&e instanceof Request)return null;const n=String(t.method||"GET").toUpperCase();return n!=="POST"||typeof t.body!="string"||yo(t.body)?null:`rr:${$o(To({url:String(e),method:n,headers:ko(t.headers),body:t.body}))}`}function yo(e){try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t.type;return typeof n=="string"&&go.has(n)}catch{return!1}}async function _o(e,t){const n=N.get(e);if(n)if(n.expiresAt<=t)N.delete(e);else return n.lastAccessedAt=t,N.delete(e),N.set(e,n),Ne(n),n;const r=await zo(e);return r?r.expiresAt<=t?(N.delete(e),Eo(e),null):(r.lastAccessedAt=t,N.set(e,r),Ne(r),wt(vt),r):null}async function vo(e,t,n,r){try{const o=await t.text();if(Io(o)>r.maxBodyBytes||bo(o))return;const i={key:e,status:t.status,statusText:t.statusText,headers:So(t.headers),body:o,createdAt:n,expiresAt:n+r.ttlMs,lastAccessedAt:n};N.set(e,i),wt(r.maxEntries),await Ne(i),await Ao(r.maxEntries,n)}catch{}}function bo(e){return/"_error"\s*:/u.test(e)||/"type"\s*:\s*"error"/u.test(e)}function wo(e){return new Response(e.body,{status:e.status,statusText:e.statusText,headers:new Headers(e.headers)})}function ko(e){const t=new Headers(e),n=[];return t.forEach((r,o)=>{const i=o.toLowerCase();i!=="authorization"&&i!=="cookie"&&n.push([i,r])}),n.sort(([r],[o])=>r.localeCompare(o))}function So(e){const t=[];return e.forEach((n,r)=>{const o=r.toLowerCase();o!=="set-cookie"&&t.push([o,n])}),t.sort(([n],[r])=>n.localeCompare(r))}function wt(e){for(;N.size>e;){const t=[...N.values()].sort((n,r)=>n.lastAccessedAt-r.lastAccessedAt)[0];if(!t)break;N.delete(t.key)}}async function de(){return typeof indexedDB>"u"?null:(bt??=new Promise(e=>{const t=indexedDB.open(fo,po);t.onupgradeneeded=()=>{const n=t.result;n.objectStoreNames.contains(L)||n.createObjectStore(L,{keyPath:"key"}).createIndex("lastAccessedAt","lastAccessedAt",{unique:!1})},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}),bt)}async function zo(e){const t=await de();return t?new Promise(n=>{const r=t.transaction(L,"readonly"),o=r.objectStore(L).get(e);o.onsuccess=()=>n(o.result??null),o.onerror=()=>n(null),r.onerror=()=>n(null)}):null}async function Ne(e){const t=await de();t&&await new Promise(n=>{const r=t.transaction(L,"readwrite");r.objectStore(L).put(e),r.oncomplete=()=>n(),r.onerror=()=>n(),r.onabort=()=>n()})}async function Eo(e){const t=await de();t&&await new Promise(n=>{const r=t.transaction(L,"readwrite");r.objectStore(L).delete(e),r.oncomplete=()=>n(),r.onerror=()=>n(),r.onabort=()=>n()})}async function Ao(e,t){const n=await de();n&&await new Promise(r=>{const o=n.transaction(L,"readwrite"),i=o.objectStore(L),a=[],s=i.openCursor();s.onsuccess=()=>{const c=s.result;if(!c){const u=a.filter(p=>p.expiresAt<=t),d=a.filter(p=>p.expiresAt>t).sort((p,f)=>p.lastAccessedAt-f.lastAccessedAt).slice(0,Math.max(0,a.length-u.length-e));for(const p of[...u,...d])i.delete(p.key);return}a.push(c.value),c.continue()},s.onerror=()=>r(),o.oncomplete=()=>r(),o.onerror=()=>r(),o.onabort=()=>r()})}function To(e){return JSON.stringify(qe(e))}function qe(e){return Array.isArray(e)?e.map(qe):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,qe(n)]))}function $o(e){let t=14695981039346656037n;const n=1099511628211n;for(let r=0;r<e.length;r+=1)t^=BigInt(e.charCodeAt(r)),t=BigInt.asUintN(64,t*n);return t.toString(16).padStart(16,"0")}function Io(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).byteLength:e.length}async function Po(e,t,n){const r=mr("launcher_action",t),o={uiSpecs:[],actions:[]},i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);const a=await ho(r,i);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const s={onEvent:c=>{const u=wr(c);if(u&&(u.type==="ui_spec"&&o.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const d of Object.values(u.spec.elements))if(d.type==="ActionButton"&&d.props?.action){const p=d.props.action;o.actions.push(p)}}}};return n!==void 0&&(s.signal=n),await pr(a,s),o}function kt(e){const t=document.createElement("div");t.className="gengage-qna-buttons gds-toolbar",t.dataset.gengagePart="qna-button-row",t.setAttribute("role","group"),t.setAttribute("aria-label",e.quickQuestionsAriaLabel??"Quick questions"),e.orientation==="vertical"&&(t.style.flexDirection="column");for(const n of e.actions){const r=document.createElement("button");r.className="gengage-qna-button gds-chip",r.dataset.gengagePart="qna-quick-question",r.textContent=n.title,r.type="button",r.addEventListener("click",()=>{const o={title:n.title,type:n.type};n.payload!==void 0&&(o.payload=n.payload),e.onAction(o)}),t.appendChild(r)}if(e.ctaText||e.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta gds-btn gds-btn-secondary",n.dataset.gengagePart="qna-cta",n.textContent=e.ctaText??e.defaultCtaText??"Ask something else",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function Co(e){const t=document.createElement("div");t.className="gengage-qna-input-wrapper",t.dataset.gengagePart="qna-input-wrapper";const n=document.createElement("div");n.className="gengage-qna-input-combo",n.dataset.gengagePart="qna-input-combo";const r=document.createElement("input");r.type="text",r.className="gengage-qna-input",r.dataset.gengagePart="qna-input",r.setAttribute("aria-label",e.askQuestionAriaLabel??"Ask a question");const o=Array.isArray(e.placeholders)?e.placeholders:e.placeholders?[e.placeholders]:[e.defaultInputPlaceholder??"Ask a question..."];let i=0,a=o[0]??"";r.placeholder=a;let s=null,c=null,u=!1;const d=()=>{s&&clearInterval(s),s=null,c&&clearTimeout(c),c=null,r.classList.remove("gengage-qna-input--fade")},p=()=>o.length>1&&!u&&r.value.trim().length===0,f=()=>{d(),p()&&(s=setInterval(()=>{p()&&(r.classList.add("gengage-qna-input--fade"),c=setTimeout(()=>{i=(i+1)%o.length,a=o[i]??"",r.placeholder=a,r.classList.remove("gengage-qna-input--fade")},180))},3e3))},g=document.createElement("div");g.className="gengage-qna-input-actions",g.dataset.gengagePart="qna-input-actions";const h=document.createElement("button");h.className="gengage-qna-icon-btn gengage-qna-clear gengage-qna-icon-btn--hidden",h.type="button",h.dataset.gengagePart="qna-clear",h.setAttribute("aria-label","Clear question"),h.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18" /><path d="M6 6L18 18" /></svg>';const m=document.createElement("button");m.className="gengage-qna-icon-btn gengage-qna-send gengage-qna-icon-btn--hidden",m.type="button",m.dataset.gengagePart="qna-send",m.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question"),m.disabled=!0,m.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M22 2L11 13" /><path d="M22 2L15 22L11 13L2 9L22 2Z" /></svg><span class="gengage-qna-sr-only">${e.ctaLabel??e.sendButtonText??"Ask"}</span>`;const _=()=>{const k=r.value.trim().length>0;h.classList.toggle("gengage-qna-icon-btn--hidden",!k),m.classList.toggle("gengage-qna-icon-btn--hidden",!k),m.classList.toggle("gengage-qna-send--active",k),m.disabled=!k},w=()=>{const k=r.value.trim();k&&(e.onSubmit({title:k,type:"user_message",payload:k}),r.value="",_(),f())};return h.addEventListener("click",()=>{r.value="",_(),r.focus({preventScroll:!0})}),m.addEventListener("click",w),r.addEventListener("focus",()=>{u=!0,d(),r.placeholder=""}),r.addEventListener("blur",()=>{u=!1,r.value.trim().length===0&&(r.placeholder=a),f()}),r.addEventListener("input",()=>{if(_(),r.value.trim().length>0){d();return}r.placeholder=u?"":a,f()}),r.addEventListener("keydown",k=>{k.key==="Enter"&&(k.preventDefault(),w()),k.key==="Escape"&&r.value.length>0&&(r.value="",_(),f())}),g.appendChild(h),g.appendChild(m),n.appendChild(r),n.appendChild(g),t.appendChild(n),_(),f(),t._cleanup=()=>{d()},t}function fe(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.type;if(typeof r!="string"||r.length===0)return null;const o=n.title,i=n.payload,a=typeof o=="string"&&o.length>0?o:t;if(!a)return null;const s={title:a,type:r};return i!==void 0&&(s.payload=i),s}function St(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function zt(e,t){const n=[],r=e.props?.actions;if(Array.isArray(r))for(const a of r){const s=fe(a);s&&n.push(s)}const o=e.props?.buttons;if(Array.isArray(o))for(const a of o){if(!a||typeof a!="object")continue;const s=a,c=typeof s.label=="string"?s.label:void 0,u=fe(s.action,c);u&&n.push(u)}if(e.children)for(const a of e.children){const s=t.elements[a];if(!s||s.type!=="ActionButton")continue;const c=typeof s.props?.label=="string"?s.props.label:void 0,u=fe(s.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))}var Et={ButtonRow:({element:e,spec:t,context:n})=>{const r=zt(e,t).map(St),o=e.props?.orientation,i={actions:r,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(i.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(i.ctaText=n.ctaText),(o==="horizontal"||o==="vertical")&&(i.orientation=o),kt(i)},ActionButtons:({element:e,spec:t,context:n})=>{const r={actions:zt(e,t).map(St),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),kt(r)},ActionButton:({element:e,context:t})=>{const n=document.createElement("button");n.className="gengage-qna-button gds-chip",n.type="button",n.dataset.gengagePart="qna-action-button";const r=e.props?.label;typeof r=="string"?n.textContent=r:n.textContent=t.i18n.defaultCtaText;const o=fe(e.props?.action,typeof r=="string"?r:void 0);return o&&n.addEventListener("click",()=>t.onAction(o)),n},TextInput:({element:e,context:t})=>{const n=e.props?.placeholder,r=typeof n=="string"||Array.isArray(n)?n:t.inputPlaceholder,o=typeof e.props?.ctaLabel=="string"?e.props.ctaLabel:void 0,i={onSubmit:t.onAction,askQuestionAriaLabel:t.i18n.askQuestionAriaLabel,defaultInputPlaceholder:t.i18n.defaultInputPlaceholder,sendButtonText:t.i18n.sendButton,sendQuestionAriaLabel:t.i18n.sendQuestionAriaLabel};return r!==void 0&&(i.placeholders=r),o!==void 0&&(i.ctaLabel=o),Co(i)},QuestionHeading:({element:e,context:t})=>{const n=document.createElement("h3");n.className="gengage-qna-heading",n.dataset.gengagePart="qna-heading";const r=e.props?.text,o=t.headingTitleOverride;return n.textContent=typeof o=="string"&&o.trim().length>0?o:typeof r=="string"?r:"",n},ProductCard:()=>null},je=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function At(){return{...Et}}function Tt(e,t,n=Et,r=je){return In({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:r})}function xo(e){if(!e)return;const t=e.extra;if(t&&typeof t=="object"&&!Array.isArray(t)){const r=t.visible_skus??t.visibleSkus;if(Array.isArray(r)){const o=r.filter(i=>typeof i=="string"&&i.trim().length>0).map(i=>i.trim()).slice(0,200);if(o.length>0)return o}}const n=typeof e.sku=="string"&&e.sku.trim()?e.sku.trim():void 0;return n?[n]:void 0}function $t(e,t){if(!e)return null;const n=e.action;if(!n||typeof n!="object")return null;const r=n,o=r.type;if(typeof o!="string"||o.length===0)return null;const i=r.title,a=typeof i=="string"&&i.length>0?i:typeof t=="string"&&t.length>0?t:"";if(!a)return null;const s=r.payload,c={title:a,type:o};return s!==void 0&&(c.payload=s),c}function Oo(e,t){const n=e.elements[e.root];if(!n)return!1;const r=o=>{if(o.type!=="ActionButton")return!1;const i=o.props;if(!i||typeof i!="object")return!1;const a=typeof i.label=="string"?i.label:void 0;return a===t?!0:$t(i,a)?.title===t};if(n.type==="ActionButton")return r(n);if(n.children)for(const o of n.children){const i=e.elements[o];if(i&&r(i))return!0}if(n.type==="ActionButtons"&&Array.isArray(n.props?.buttons)){for(const o of n.props.buttons)if(o?.label===t||o?.action?.title===t)return!0}return!1}var It=0;function Pt(){return It+=1,`gengage-merge-${It}`}function Zo(e,t){const n=e.elements[e.root];if(!n||n.type!=="ButtonRow")return;const r=Pt();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r]}function Ro(e,t){const n=e.elements[e.root];if(!n||n.type!=="ActionButtons")return;const r=Pt();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r];const o=n.props?.buttons??[],i={label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}};n.props={...n.props,buttons:[i,...o]}}function Lo(e){const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,...o.payload!==void 0?{payload:o.payload}:{}}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}function No(e){return e.find(t=>{const n=t.elements[t.root];return n?.type==="ActionButtons"||n?.type==="ButtonRow"})}function Ct(e,t){const n=e.productContextQuickPillLabel,r={text:n};return t&&t.length>0&&(r.sku_list=t),{title:n,type:"user_message",payload:r}}function qo(e,t,n){const r=n?.skuList,o=[],i=[];for(const c of e){const u=c.elements[c.root];if(u?.type==="ActionButton"){const d=u.props;if($t(d,typeof d?.label=="string"?d.label:void 0)?.type==="findSimilar"){o.push(Ct(t,r));continue}}i.push(c)}if(o.length===0)return e;const a=Ct(t,r),s=No(i);if(!s)return[...i,Lo([a])];if(!Oo(s,a.title)){const c=s.elements[s.root];c?.type==="ActionButtons"?Ro(s,a):c?.type==="ButtonRow"&&Zo(s,a)}return i}var xt={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor",redirectingToChat:"Sohbete yönlendiriliyor...",productContextQuickPillLabel:"Bu ürün hakkında ne bilmeliyim?"},jo={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else",redirectingToChat:"Redirecting to chat...",productContextQuickPillLabel:"What should I know about this product?"};function Do(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Uo(e){return Do(e)==="en"?jo:xt}var Ot=class extends rr{constructor(...e){super(...e),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=xt,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this._contentEl.dataset.gengagePart="qna-container",this._contentEl.lang=ot(e.locale);const t=this._createChrome(e);if(t){const r=document.createElement("div");r.className="gengage-qna-chrome-widget",r.dataset.gengagePart="qna-chrome-widget",r.appendChild(this._contentEl),t.appendChild(r),this.root.appendChild(t)}else this.root.appendChild(this._contentEl);const n=e.pageContext?.sku;n&&(this._lastSku=n,await this._fetchAndRender(n)),Zn("qna")}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_resolvedQnaHeaderTitle(){const e=this.config.headerTitle??this.config.headingTitle;if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}_cleanupTextInputTimers(){if(!this._contentEl)return;const e=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const t of e)t._cleanup?.()}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const t=this._createLoadingIndicator();this._contentEl.appendChild(t);const n={middlewareUrl:this.config.middlewareUrl},r=dr({source:"qna",locale:this.config.locale});try{const o=this.config.session?.sessionId??"",i={account_id:this.config.accountId,session_id:o,correlation_id:o,sku:e,locale:ot(this.config.locale)};this.config.session?.userId!==void 0&&(i.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(i.view_id=this.config.session.viewId);const a=this.config.pageContext?.pageType;a!==void 0&&(i.page_type=a);const s=await Po(i,n,this._abortController.signal);if(!this._contentEl)return;this._contentEl.innerHTML="";const c=document.createElement("div");c.className="gengage-qna-panel gds-panel",c.dataset.gengagePart="qna-panel",this._contentEl.appendChild(c);const u=this._specIncludesType(s.uiSpecs,"QuestionHeading"),d=this._resolvedQnaHeaderTitle()??(this.config.showStaticQuestion&&this.config.staticQuestionText?this.config.staticQuestionText:void 0);if(!u&&d){const k=document.createElement("h3");k.className="gengage-qna-heading",k.textContent=d,c.appendChild(k)}const p=this.config.inputPlaceholder;let f;if(p!==!0)f=p??this._i18n.defaultInputPlaceholder;else if(s.actions.length>0){const k=s.actions.filter(I=>I.type==="user_message"||I.title.includes("?")).map(I=>I.title);f=k.length>0?k:this._i18n.defaultInputPlaceholder}else f=this._i18n.defaultInputPlaceholder;const g={onAction:this._actionHandler,i18n:this._i18n},h=this._resolvedQnaHeaderTitle();h!==void 0&&(g.headingTitleOverride=h),this.config.hideButtonRowCta||(g.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(g.ctaText=this.config.ctaText)),f!==void 0&&(g.inputPlaceholder=f);const m=this._buildFallbackActionsSpec(s.actions),_=xo(this.config.pageContext),w=(s.uiSpecs.length>0?qo(s.uiSpecs,this._i18n,{skuList:_}):[m]).filter(k=>Object.keys(k.elements).length>0);for(const k of w){const I=this._renderUISpec(k,g);c.appendChild(I)}w.length>0&&Rn("qna"),this._specIncludesType(w,"TextInput")||this._insertStandaloneInputBeforePills(c,g,f)}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;if(Te("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:Jn(this.config.locale,o)}),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const i=document.createElement("div");i.className="gengage-qna-panel",this._contentEl.appendChild(i);const a=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,s={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler},c=this._resolvedQnaHeaderTitle();c!==void 0&&(s.headingTitleOverride=c),this.config.ctaText!==void 0&&(s.ctaText=this.config.ctaText),this._appendStandaloneInput(s,a,i)}}finally{r()}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let t=0;t<3;t++){const n=document.createElement("div");n.className="gengage-qna-loading-dot",e.appendChild(n)}return e}_resolveI18n(e){return{...Uo(e.locale),...e.i18n}}_createChrome(e){const t=e.chrome;if(!t)return null;const n=typeof t.title=="string"?t.title.trim():"",r=typeof t.subtitle=="string"?t.subtitle.trim():"",o=typeof t.startButtonLabel=="string"?t.startButtonLabel.trim():"",i=typeof t.imageUrl=="string"?t.imageUrl.trim():"",a=typeof t.imagePadding=="string"?t.imagePadding.trim():"",s=document.createElement("section");s.className="gengage-qna-chrome",s.dataset.gengagePart="qna-chrome",t.layout==="side-image"&&(s.classList.add("gengage-qna-chrome--side-image"),s.dataset.gengageChromeLayout="side-image"),a&&s.style.setProperty("--gengage-qna-chrome-image-padding",a);const c=document.createElement("div");if(c.className="gengage-qna-chrome-copy",c.dataset.gengagePart="qna-chrome-copy",n){const u=document.createElement("h2");u.className="gengage-qna-chrome-title",u.dataset.gengagePart="qna-chrome-title",u.textContent=n,c.appendChild(u)}if(r){const u=document.createElement("p");u.className="gengage-qna-chrome-subtitle",u.dataset.gengagePart="qna-chrome-subtitle",u.textContent=r,c.appendChild(u)}if(c.children.length>0&&s.appendChild(c),i&&xn(i)){const u=document.createElement("img");u.className="gengage-qna-chrome-image",u.dataset.gengagePart="qna-chrome-image",u.src=i,u.alt=typeof t.imageAlt=="string"?t.imageAlt:"",u.loading="lazy",u.addEventListener("error",()=>{u.style.display="none"},{once:!0}),s.appendChild(u)}if(o){const u=document.createElement("button");u.className="gengage-qna-chrome-start",u.dataset.gengagePart="qna-chrome-start",u.type="button",u.textContent=o,u.addEventListener("click",()=>this._handleOpenChat()),s.appendChild(u)}return s.children.length===0?null:s}_resolveUISpecRegistry(){return Pn(At(),this.config.renderer?.registry)}_renderUISpec(e,t){const n=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??je,o=(a,s)=>Tt(a,s,n,r),i=this.config.renderer?.renderUISpec;return i?i(e,t,{registry:n,unknownRenderer:r,defaultRender:o}):o(e,t)}_specIncludesType(e,t){for(const n of e)for(const r of Object.values(n.elements))if(r.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,payload:o.payload}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}_insertStandaloneInputBeforePills(e,t,n){const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:n}}}},o=this._renderUISpec(r,t),i=o.querySelector(".gengage-qna-input-wrapper");if(!i)return;const a=e.querySelector(".gengage-qna-uispec"),s=e.querySelector(".gengage-qna-uispec > .gengage-qna-buttons"),c=this.config.inputAfterPills===!0;if(s)c?s.insertAdjacentElement("afterend",i):s.insertAdjacentElement("beforebegin",i);else if(a){const u=a.querySelector(":scope > .gengage-qna-heading");!c&&u?u.insertAdjacentElement("afterend",i):a.appendChild(i)}else{e.appendChild(o);return}o.remove()}_appendStandaloneInput(e,t,n){if(!this._contentEl)return;const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:t}}}},o=this._renderUISpec(r,e);(n??this._contentEl).appendChild(o)}_handleAction(e){this._showTransitionIndicator(),Ln(e.title,e.type),this.config.onActionSelected?.(e),setTimeout(()=>Te("gengage:qna:action",e),350)}_handleOpenChat(){this._showTransitionIndicator(),this.config.onOpenChat?.(),setTimeout(()=>Te("gengage:qna:open-chat",{}),350)}_showTransitionIndicator(){if(!this._contentEl)return;this._contentEl.querySelector(".gengage-qna-transition-indicator")?.remove(),this._contentEl.classList.add("gengage-qna--transitioning");const e=this._i18n.redirectingToChat??"Redirecting to chat...",t=document.createElement("div");t.className="gengage-qna-transition-indicator",t.textContent=e,(this._contentEl.querySelector(".gengage-qna-panel")??this._contentEl).appendChild(t),setTimeout(()=>{this._contentEl?.classList.remove("gengage-qna--transitioning"),t.remove()},600)}};function Bo(){return new Ot}var Zt;function l(e,t,n){function r(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const u=a.prototype,d=Object.keys(u);for(let p=0;p<d.length;p++){const f=d[p];f in s||(s[f]=u[f].bind(s))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(s){var c;const u=n?.Parent?new i:this;r(u,s),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var Y=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Rt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Zt=globalThis).__zod_globalConfig??(Zt.__zod_globalConfig={});var pe=globalThis.__zod_globalConfig;function J(e){return e&&Object.assign(pe,e),pe}function Lt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}function De(e,t){return typeof t=="bigint"?t.toString():t}function Ue(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function Be(e){return e==null}function Me(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var Nt=Symbol("evaluating");function b(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Nt)return r===void 0&&(r=Nt,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Q(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function U(...e){const t={};for(const n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function qt(e){return JSON.stringify(e)}function Mo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var jt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Fo=Ue(()=>{if(pe.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function ie(e){if(ge(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ge(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Dt(e){return ie(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ho=new Set(["string","number","symbol"]);function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function B(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function y(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Jo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var _u={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Qo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return B(e,U(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=n.shape[i])}return Q(this,"shape",o),o},checks:[]}))}function Wo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return B(e,U(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return Q(this,"shape",o),o},checks:[]}))}function Vo(e,t){if(!ie(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const r=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return B(e,U(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Q(this,"shape",r),r}}))}function Go(e,t){if(!ie(t))throw new Error("Invalid input to safeExtend: expected a plain object");return B(e,U(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Q(this,"shape",n),n}}))}function Ko(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return B(e,U(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Q(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Yo(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return B(t,U(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const a in n){if(!(a in o))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=e?new e({type:"optional",innerType:o[a]}):o[a])}else for(const a in o)i[a]=e?new e({type:"optional",innerType:o[a]}):o[a];return Q(this,"shape",i),i},checks:[]}))}function Xo(e,t,n){return B(t,U(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)o[i]=new e({type:"nonoptional",innerType:r[i]});return Q(this,"shape",o),o}}))}function X(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ei(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ut(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function me(e){return typeof e=="string"?e:e?.message}function W(e,t,n){const r=e.message?e.message:me(e.inst?._zod.def?.error?.(e))??me(t?.error?.(e))??me(n.customError?.(e))??me(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:a,...s}=e;return s.path??(s.path=[]),s.message=r,t?.reportInput&&(s.input=a),s}function Fe(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ae(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}var Bt=(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,De,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Mt=l("$ZodError",Bt),Ft=l("$ZodError",Bt,{Parent:Error});function ti(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function ni(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>r({issues:s},[...i,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...i,...a.path]);else{const s=[...i,...a.path];if(s.length===0)n._errors.push(t(a));else{let c=n,u=0;for(;u<s.length;){const d=s[u];u!==s.length-1?c[d]=c[d]||{_errors:[]}:(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(a))),c=c[d],u++}}}};return r(e),n}var He=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Y;if(a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>W(c,i,J())));throw jt(s,o?.callee),s}return a.value},Je=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>W(c,i,J())));throw jt(s,o?.callee),s}return a.value},ye=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Y;return i.issues.length?{success:!1,error:new(e??Mt)(i.issues.map(a=>W(a,o,J())))}:{success:!0,data:i.value}},ri=ye(Ft),_e=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>W(a,o,J())))}:{success:!0,data:i.value}},oi=_e(Ft),ii=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return He(e)(t,n,o)},ai=e=>(t,n,r)=>He(e)(t,n,r),si=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Je(e)(t,n,o)},ci=e=>async(t,n,r)=>Je(e)(t,n,r),ui=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ye(e)(t,n,o)},li=e=>(t,n,r)=>ye(e)(t,n,r),di=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return _e(e)(t,n,o)},fi=e=>async(t,n,r)=>_e(e)(t,n,r),pi=/^[cC][0-9a-z]{6,}$/,gi=/^[0-9a-z]+$/,hi=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mi=/^[0-9a-vA-V]{20}$/,yi=/^[A-Za-z0-9]{27}$/,_i=/^[a-zA-Z0-9_-]{21}$/,vi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,bi=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ht=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,wi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ki="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Si(){return new RegExp(ki,"u")}var zi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ei=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ai=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ti=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$i=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jt=/^[A-Za-z0-9_-]*$/,Ii=/^https?$/,Pi=/^\+[1-9]\d{6,14}$/,Qt="(?:(?:\\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])))",Ci=new RegExp(`^${Qt}$`);function Wt(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 xi(e){return new RegExp(`^${Wt(e)}$`)}function Oi(e){const t=Wt({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Qt}T(?:${r})$`)}var Zi=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ri=/^(?:true|false)$/i,Li=/^[^A-Z]*$/,Ni=/^[^a-z]*$/,q=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),qi=l("$ZodCheckMaxLength",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Be(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=Fe(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ji=l("$ZodCheckMinLength",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Be(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=Fe(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Di=l("$ZodCheckLengthEquals",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Be(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const a=Fe(o),s=i>t.length;r.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ve=l("$ZodCheckStringFormat",(e,t)=>{var n,r;q.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ui=l("$ZodCheckRegex",(e,t)=>{ve.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Bi=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Li),ve.init(e,t)}),Mi=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ni),ve.init(e,t)}),Fi=l("$ZodCheckIncludes",(e,t)=>{q.init(e,t);const n=he(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Hi=l("$ZodCheckStartsWith",(e,t)=>{q.init(e,t);const n=new RegExp(`^${he(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ji=l("$ZodCheckEndsWith",(e,t)=>{q.init(e,t);const n=new RegExp(`.*${he(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Qi=l("$ZodCheckOverwrite",(e,t)=>{q.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),Wi=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const t=e.split(`
|
|
49
49
|
`).filter(o=>o),n=Math.min(...t.map(o=>o.length-o.trimStart().length)),r=t.map(o=>o.slice(n)).map(o=>" ".repeat(this.indent*2)+o);for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args,n=[...(this?.content??[""]).map(r=>` ${r}`)];return new e(...t,n.join(`
|
|
50
|
-
`))}},
|
|
50
|
+
`))}},Vi={major:4,minor:4,patch:3},A=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vi;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,s,c)=>{let u=X(a),d;for(const p of s){if(p._zod.def.when){if(ei(a)||!p._zod.def.when(a))continue}else if(u)continue;const f=a.issues.length,g=p._zod.check(a);if(g instanceof Promise&&c?.async===!1)throw new Y;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await g,a.issues.length!==f&&(u||(u=X(a,f)))});else{if(a.issues.length===f)continue;u||(u=X(a,f))}}return d?d.then(()=>a):a},i=(a,s,c)=>{if(X(a))return a.aborted=!0,a;const u=o(s,r,c);if(u instanceof Promise){if(c.async===!1)throw new Y;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(d=>i(d,a,s)):i(u,a,s)}const c=e._zod.parse(a,s);if(c instanceof Promise){if(s.async===!1)throw new Y;return c.then(u=>o(u,r,s))}return o(c,r,s)}}b(e,"~standard",()=>({validate:o=>{try{const i=ri(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return oi(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Qe=l("$ZodString",(e,t)=>{A.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Zi(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),S=l("$ZodStringFormat",(e,t)=>{ve.init(e,t),Qe.init(e,t)}),Gi=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=bi),S.init(e,t)}),Ki=l("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ht(n))}else t.pattern??(t.pattern=Ht());S.init(e,t)}),Yi=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=wi),S.init(e,t)}),Xi=l("$ZodURL",(e,t)=>{S.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Ii.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ea=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Si()),S.init(e,t)}),ta=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=_i),S.init(e,t)}),na=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pi),S.init(e,t)}),ra=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=gi),S.init(e,t)}),oa=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=hi),S.init(e,t)}),ia=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=mi),S.init(e,t)}),aa=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=yi),S.init(e,t)}),sa=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Oi(t)),S.init(e,t)}),ca=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ci),S.init(e,t)}),ua=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=xi(t)),S.init(e,t)}),la=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=vi),S.init(e,t)}),da=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=zi),S.init(e,t),e._zod.bag.format="ipv4"}),fa=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ei),S.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),pa=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ai),S.init(e,t)}),ga=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ti),S.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Vt(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ha=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$i),S.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Vt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function ma(e){if(!Jt.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/");return Vt(t.padEnd(Math.ceil(t.length/4)*4,"="))}var ya=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Jt),S.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{ma(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),_a=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Pi),S.init(e,t)});function va(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var ba=l("$ZodJWT",(e,t)=>{S.init(e,t),e._zod.check=n=>{va(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),wa=l("$ZodBoolean",(e,t)=>{A.init(e,t),e._zod.pattern=Ri,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),ka=l("$ZodUnknown",(e,t)=>{A.init(e,t),e._zod.parse=n=>n}),Sa=l("$ZodNever",(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Gt(e,t,n){e.issues.length&&t.issues.push(...Ut(n,e.issues)),t.value[n]=e.value}var za=l("$ZodArray",(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const s=o[a],c=t.element._zod.run({value:s,issues:[]},r);c instanceof Promise?i.push(c.then(u=>Gt(u,n,a))):Gt(c,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function be(e,t,n,r,o,i){const a=n in r;if(e.issues.length){if(o&&i&&!a)return;t.issues.push(...Ut(n,e.issues))}if(!a&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}function Kt(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Jo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Yt(e,t,n,r,o,i){const a=[],s=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optin==="optional",p=c.optout==="optional";for(const f in t){if(f==="__proto__"||s.has(f))continue;if(u==="never"){a.push(f);continue}const g=c.run({value:t[f],issues:[]},r);g instanceof Promise?e.push(g.then(h=>be(h,n,f,t,d,p))):be(g,n,f,t,d,p)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var Ea=l("$ZodObject",(e,t)=>{if(A.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const s={...a};return Object.defineProperty(t,"shape",{value:s}),s}})}const n=Ue(()=>Kt(t));b(e._zod,"propValues",()=>{const a=t.shape,s={};for(const c in a){const u=a[c]._zod;if(u.values){s[c]??(s[c]=new Set);for(const d of u.values)s[c].add(d)}}return s});const r=ge,o=t.catchall;let i;e._zod.parse=(a,s)=>{i??(i=n.value);const c=a.value;if(!r(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),a;a.value={};const u=[],d=i.shape;for(const p of i.keys){const f=d[p],g=f._zod.optin==="optional",h=f._zod.optout==="optional",m=f._zod.run({value:c[p],issues:[]},s);m instanceof Promise?u.push(m.then(_=>be(_,a,p,c,g,h))):be(m,a,p,c,g,h)}return o?Yt(u,c,a,s,n.value,e):u.length?Promise.all(u).then(()=>a):a}}),Aa=l("$ZodObjectJIT",(e,t)=>{Ea.init(e,t);const n=e._zod.parse,r=Ue(()=>Kt(t)),o=f=>{const g=new Wi(["shape","payload","ctx"]),h=r.value,m=I=>{const E=qt(I);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};g.write("const input = payload.value;");const _=Object.create(null);let w=0;for(const I of h.keys)_[I]=`key_${w++}`;g.write("const newResult = {};");for(const I of h.keys){const E=_[I],P=qt(I),An=f[I],Tn=An?._zod?.optin==="optional",yu=An?._zod?.optout==="optional";g.write(`const ${E} = ${m(I)};`),Tn&&yu?g.write(`
|
|
51
51
|
if (${E}.issues.length) {
|
|
52
52
|
if (${P} in input) {
|
|
53
53
|
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
newResult[${P}] = ${E}.value;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
`):
|
|
68
|
+
`):Tn?g.write(`
|
|
69
69
|
if (${E}.issues.length) {
|
|
70
70
|
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
71
71
|
...iss,
|
|
@@ -106,6 +106,6 @@
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
`)}g.write("payload.value = newResult;"),g.write("return payload;");const k=g.compile();return(I,E)=>k(f,I,E)};let i;const a=ge,s=!pe.jitless,u=s&&Mo.value,d=t.catchall;let p;e._zod.parse=(f,g)=>{p??(p=r.value);const h=f.value;return a(h)?s&&u&&g?.async===!1&&g.jitless!==!0?(i||(i=o(t.shape)),f=i(f,g),d?Kt([],h,f,g,p,e):f):n(f,g):(f.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),f)}});function Yt(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!X(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>W(a,r,J())))}),t)}var Aa=l("$ZodUnion",(e,t)=>{A.init(e,t),b(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),b(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),b(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),b(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Me(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const a=[];for(const s of t.options){const c=s._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)a.push(c),i=!0;else{if(c.issues.length===0)return c;a.push(c)}}return i?Promise.all(a).then(s=>Yt(s,r,e,o)):Yt(a,r,e,o)}}),Ta=l("$ZodIntersection",(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([s,c])=>Xt(n,s,c)):Xt(n,i,a)}});function We(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(ie(e)&&ie(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const a=We(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],a=We(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Xt(e,t,n){const r=new Map;let o;for(const s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(const c of s.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(s);for(const s of n.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(s);const i=[...r].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),X(e))return e;const a=We(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var $a=l("$ZodEnum",(e,t)=>{A.init(e,t);const n=Rt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Fo.has(typeof o)).map(o=>typeof o=="string"?he(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return r.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),Ia=l("$ZodTransform",(e,t)=>{A.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Zt(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new Y;return n.value=o,n.fallback=!0,n}});function en(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var tn=l("$ZodOptional",(e,t)=>{A.init(e,t),e._zod.optin="optional",e._zod.optout="optional",b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Me(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(a=>en(a,o)):en(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Pa=l("$ZodExactOptional",(e,t)=>{tn.init(e,t),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Ca=l("$ZodNullable",(e,t)=>{A.init(e,t),b(e._zod,"optin",()=>t.innerType._zod.optin),b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Me(n.source)}|null)$`):void 0}),b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),xa=l("$ZodDefault",(e,t)=>{A.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>nn(i,t)):nn(o,t)}});function nn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Oa=l("$ZodPrefault",(e,t)=>{A.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Za=l("$ZodNonOptional",(e,t)=>{A.init(e,t),b(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>rn(i,e)):rn(o,e)}});function rn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Ra=l("$ZodCatch",(e,t)=>{A.init(e,t),e._zod.optin="optional",b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>W(a,r,J()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>W(i,r,J()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),La=l("$ZodPipe",(e,t)=>{A.init(e,t),b(e._zod,"values",()=>t.in._zod.values),b(e._zod,"optin",()=>t.in._zod.optin),b(e._zod,"optout",()=>t.out._zod.optout),b(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(a=>we(a,t.in,r)):we(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>we(i,t.out,r)):we(o,t.out,r)}});function we(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Na=l("$ZodReadonly",(e,t)=>{A.init(e,t),b(e._zod,"propValues",()=>t.innerType._zod.propValues),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"optin",()=>t.innerType?._zod?.optin),b(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(on):on(o)}});function on(e){return e.value=Object.freeze(e.value),e}var qa=l("$ZodCustom",(e,t)=>{q.init(e,t),A.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>an(i,n,r,e));an(o,n,r,e)}});function an(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(ae(o))}}var sn,ja=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Da(){return new ja}(sn=globalThis).__zod_globalRegistry??(sn.__zod_globalRegistry=Da());var se=globalThis.__zod_globalRegistry;function Ua(e,t){return new e({type:"string",...y(t)})}function Ba(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function cn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Ma(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Fa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Ha(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Ja(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function Qa(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Wa(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Va(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Ga(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Ka(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function Ya(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function Xa(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function es(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function ts(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function ns(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function rs(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function os(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function is(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function as(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function ss(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function cs(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function us(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function ls(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function ds(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function fs(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function ps(e,t){return new e({type:"boolean",...y(t)})}function gs(e){return new e({type:"unknown"})}function hs(e,t){return new e({type:"never",...y(t)})}function un(e,t){return new Ni({check:"max_length",...y(t),maximum:e})}function ke(e,t){return new qi({check:"min_length",...y(t),minimum:e})}function ln(e,t){return new ji({check:"length_equals",...y(t),length:e})}function ms(e,t){return new Di({check:"string_format",format:"regex",...y(t),pattern:e})}function ys(e){return new Ui({check:"string_format",format:"lowercase",...y(e)})}function _s(e){return new Bi({check:"string_format",format:"uppercase",...y(e)})}function vs(e,t){return new Mi({check:"string_format",format:"includes",...y(t),includes:e})}function bs(e,t){return new Fi({check:"string_format",format:"starts_with",...y(t),prefix:e})}function ws(e,t){return new Hi({check:"string_format",format:"ends_with",...y(t),suffix:e})}function ee(e){return new Ji({check:"overwrite",tx:e})}function ks(e){return ee(t=>t.normalize(e))}function Ss(){return ee(e=>e.trim())}function zs(){return ee(e=>e.toLowerCase())}function Es(){return ee(e=>e.toUpperCase())}function As(){return ee(e=>Bo(e))}function Ts(e,t,n){return new e({type:"array",element:t,...y(n)})}function $s(e,t,n){return new e({type:"custom",check:"custom",fn:t,...y(n)})}function Is(e,t){const n=Ps(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(ae(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(ae(i))}},e(r.value,r)),t);return n}function Ps(e,t){const n=new q({check:"custom",...y(t)});return n._zod.check=e,n}function dn(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??se,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function $(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{const p=a.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,u)}const d=e._zod.parent;d&&(a.ref||(a.ref=d),$(d,t,u),t.seen.get(d).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&x(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function fn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const a of e.seen.entries()){const s=e.metadataRegistry.get(a[0])?.id;if(s){const c=r.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(s,a[0])}}const o=a=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(a[0])?.id,p=e.external.uri??(g=>g);if(d)return{ref:p(d)};const f=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=f,{defId:f,ref:`${p("__shared")}#/${s}/${f}`}}if(a[1]===n)return{ref:"#"};const c=`#/${s}/`,u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},i=a=>{if(a[1].schema.$ref)return;const s=a[1],{ref:c,defId:u}=o(a);s.def={...s.schema},u&&(s.defId=u);const d=s.schema;for(const p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(const a of e.seen.entries()){const s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
109
|
+
`)}g.write("payload.value = newResult;"),g.write("return payload;");const k=g.compile();return(I,E)=>k(f,I,E)};let i;const a=ge,s=!pe.jitless,u=s&&Fo.value,d=t.catchall;let p;e._zod.parse=(f,g)=>{p??(p=r.value);const h=f.value;return a(h)?s&&u&&g?.async===!1&&g.jitless!==!0?(i||(i=o(t.shape)),f=i(f,g),d?Yt([],h,f,g,p,e):f):n(f,g):(f.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),f)}});function Xt(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!X(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>W(a,r,J())))}),t)}var Ta=l("$ZodUnion",(e,t)=>{A.init(e,t),b(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),b(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),b(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),b(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Me(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const a=[];for(const s of t.options){const c=s._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)a.push(c),i=!0;else{if(c.issues.length===0)return c;a.push(c)}}return i?Promise.all(a).then(s=>Xt(s,r,e,o)):Xt(a,r,e,o)}}),$a=l("$ZodIntersection",(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([s,c])=>en(n,s,c)):en(n,i,a)}});function We(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(ie(e)&&ie(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const a=We(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],a=We(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function en(e,t,n){const r=new Map;let o;for(const s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(const c of s.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(s);for(const s of n.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(s);const i=[...r].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),X(e))return e;const a=We(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var Ia=l("$ZodEnum",(e,t)=>{A.init(e,t);const n=Lt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Ho.has(typeof o)).map(o=>typeof o=="string"?he(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return r.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),Pa=l("$ZodTransform",(e,t)=>{A.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Rt(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new Y;return n.value=o,n.fallback=!0,n}});function tn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var nn=l("$ZodOptional",(e,t)=>{A.init(e,t),e._zod.optin="optional",e._zod.optout="optional",b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Me(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(a=>tn(a,o)):tn(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Ca=l("$ZodExactOptional",(e,t)=>{nn.init(e,t),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),xa=l("$ZodNullable",(e,t)=>{A.init(e,t),b(e._zod,"optin",()=>t.innerType._zod.optin),b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Me(n.source)}|null)$`):void 0}),b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Oa=l("$ZodDefault",(e,t)=>{A.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>rn(i,t)):rn(o,t)}});function rn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Za=l("$ZodPrefault",(e,t)=>{A.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Ra=l("$ZodNonOptional",(e,t)=>{A.init(e,t),b(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>on(i,e)):on(o,e)}});function on(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var La=l("$ZodCatch",(e,t)=>{A.init(e,t),e._zod.optin="optional",b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>W(a,r,J()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>W(i,r,J()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Na=l("$ZodPipe",(e,t)=>{A.init(e,t),b(e._zod,"values",()=>t.in._zod.values),b(e._zod,"optin",()=>t.in._zod.optin),b(e._zod,"optout",()=>t.out._zod.optout),b(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(a=>we(a,t.in,r)):we(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>we(i,t.out,r)):we(o,t.out,r)}});function we(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var qa=l("$ZodReadonly",(e,t)=>{A.init(e,t),b(e._zod,"propValues",()=>t.innerType._zod.propValues),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"optin",()=>t.innerType?._zod?.optin),b(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(an):an(o)}});function an(e){return e.value=Object.freeze(e.value),e}var ja=l("$ZodCustom",(e,t)=>{q.init(e,t),A.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>sn(i,n,r,e));sn(o,n,r,e)}});function sn(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(ae(o))}}var cn,Da=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ua(){return new Da}(cn=globalThis).__zod_globalRegistry??(cn.__zod_globalRegistry=Ua());var se=globalThis.__zod_globalRegistry;function Ba(e,t){return new e({type:"string",...y(t)})}function Ma(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function un(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Fa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Ha(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Ja(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Qa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function Wa(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Va(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Ga(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Ka(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Ya(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function Xa(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function es(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function ts(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function ns(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function rs(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function os(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function is(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function as(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function ss(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function cs(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function us(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function ls(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function ds(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function fs(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function ps(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function gs(e,t){return new e({type:"boolean",...y(t)})}function hs(e){return new e({type:"unknown"})}function ms(e,t){return new e({type:"never",...y(t)})}function ln(e,t){return new qi({check:"max_length",...y(t),maximum:e})}function ke(e,t){return new ji({check:"min_length",...y(t),minimum:e})}function dn(e,t){return new Di({check:"length_equals",...y(t),length:e})}function ys(e,t){return new Ui({check:"string_format",format:"regex",...y(t),pattern:e})}function _s(e){return new Bi({check:"string_format",format:"lowercase",...y(e)})}function vs(e){return new Mi({check:"string_format",format:"uppercase",...y(e)})}function bs(e,t){return new Fi({check:"string_format",format:"includes",...y(t),includes:e})}function ws(e,t){return new Hi({check:"string_format",format:"starts_with",...y(t),prefix:e})}function ks(e,t){return new Ji({check:"string_format",format:"ends_with",...y(t),suffix:e})}function ee(e){return new Qi({check:"overwrite",tx:e})}function Ss(e){return ee(t=>t.normalize(e))}function zs(){return ee(e=>e.trim())}function Es(){return ee(e=>e.toLowerCase())}function As(){return ee(e=>e.toUpperCase())}function Ts(){return ee(e=>Mo(e))}function $s(e,t,n){return new e({type:"array",element:t,...y(n)})}function Is(e,t,n){return new e({type:"custom",check:"custom",fn:t,...y(n)})}function Ps(e,t){const n=Cs(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(ae(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(ae(i))}},e(r.value,r)),t);return n}function Cs(e,t){const n=new q({check:"custom",...y(t)});return n._zod.check=e,n}function fn(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??se,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function $(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{const p=a.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,u)}const d=e._zod.parent;d&&(a.ref||(a.ref=d),$(d,t,u),t.seen.get(d).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&x(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function pn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const a of e.seen.entries()){const s=e.metadataRegistry.get(a[0])?.id;if(s){const c=r.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(s,a[0])}}const o=a=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(a[0])?.id,p=e.external.uri??(g=>g);if(d)return{ref:p(d)};const f=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=f,{defId:f,ref:`${p("__shared")}#/${s}/${f}`}}if(a[1]===n)return{ref:"#"};const c=`#/${s}/`,u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},i=a=>{if(a[1].schema.$ref)return;const s=a[1],{ref:c,defId:u}=o(a);s.def={...s.schema},u&&(s.defId=u);const d=s.schema;for(const p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(const a of e.seen.entries()){const s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
110
110
|
|
|
111
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const s=a[1];if(t===a[0]){i(a);continue}if(e.external){const c=e.external.registry.get(a[0])?.id;if(t!==a[0]&&c){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}if(s.count>1&&e.reused==="ref"){i(a);continue}}}function pn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=s=>{const c=e.seen.get(s);if(c.ref===null)return;const u=c.def??c.schema,d={...u},p=c.ref;if(c.ref=null,p){r(p);const g=e.seen.get(p),h=g.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Object.assign(u,h),Object.assign(u,d),s._zod.parent===p)for(const m in u)m==="$ref"||m==="allOf"||m in d||delete u[m];if(h.$ref&&g.def)for(const m in u)m==="$ref"||m==="allOf"||m in g.def&&JSON.stringify(u[m])===JSON.stringify(g.def[m])&&delete u[m]}const f=s._zod.parent;if(f&&f!==p){r(f);const g=e.seen.get(f);if(g?.schema.$ref&&(u.$ref=g.schema.$ref,g.def))for(const h in u)h==="$ref"||h==="allOf"||h in g.def&&JSON.stringify(u[h])===JSON.stringify(g.def[h])&&delete u[h]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};for(const s of[...e.seen.entries()].reverse())r(s[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const a=e.external?.defs??{};for(const s of e.seen.entries()){const c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,a[c.defId]=c.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Se(t,"input",e.processors),output:Se(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function x(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return x(r.element,n);if(r.type==="set")return x(r.valueType,n);if(r.type==="lazy")return x(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return x(r.innerType,n);if(r.type==="intersection")return x(r.left,n)||x(r.right,n);if(r.type==="record"||r.type==="map")return x(r.keyType,n)||x(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:x(r.in,n)||x(r.out,n);if(r.type==="object"){for(const o in r.shape)if(x(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(x(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(x(o,n))return!0;return!!(r.rest&&x(r.rest,n))}return!1}var Cs=(e,t={})=>n=>{const r=dn({...n,processors:t});return $(e,r),fn(r,e),pn(r,e)},Se=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=dn({...o??{},target:i,io:t,processors:n});return $(e,a),fn(a,e),pn(a,e)},xs={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Os=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),s&&(o.format=xs[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Zs=(e,t,n,r)=>{n.type="boolean"},Rs=(e,t,n,r)=>{n.not={}},Ls=(e,t,n,r)=>{},Ns=(e,t,n,r)=>{const o=e._zod.def,i=Rt(o.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},qs=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},js=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ds=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=$(i.element,t,{...r,path:[...r.path,"items"]})},Us=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const u in a)o.properties[u]=$(a[u],t,{...r,path:[...r.path,"properties",u]});const s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{const d=i.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=$(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Bs=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((s,c)=>$(s,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=a:n.anyOf=a},Ms=(e,t,n,r)=>{const o=e._zod.def,i=$(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=$(o.right,t,{...r,path:[...r.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1;n.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]},Fs=(e,t,n,r)=>{const o=e._zod.def,i=$(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Hs=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Js=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Qs=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Ws=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},Vs=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?o.out:o.in:o.out;$(a,t,r);const s=t.seen.get(e);s.ref=a},Gs=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},gn=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Ks=l("ZodISODateTime",(e,t)=>{aa.init(e,t),z.init(e,t)});function Ys(e){return us(Ks,e)}var Xs=l("ZodISODate",(e,t)=>{sa.init(e,t),z.init(e,t)});function ec(e){return ls(Xs,e)}var tc=l("ZodISOTime",(e,t)=>{ca.init(e,t),z.init(e,t)});function nc(e){return ds(tc,e)}var rc=l("ZodISODuration",(e,t)=>{ua.init(e,t),z.init(e,t)});function oc(e){return fs(rc,e)}var ic=(e,t)=>{Bt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>ti(e,n)},flatten:{value:n=>ei(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,De,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,De,2)}},isEmpty:{get(){return e.issues.length===0}}})},Z=l("ZodError",ic,{Parent:Error}),ac=He(Z),sc=Je(Z),cc=ye(Z),uc=_e(Z),lc=oi(Z),dc=ii(Z),fc=ai(Z),pc=si(Z),gc=ci(Z),hc=ui(Z),mc=li(Z),yc=di(Z),hn=new WeakMap;function ze(e,t,n){const r=Object.getPrototypeOf(e);let o=hn.get(r);if(o||(o=new Set,hn.set(r,o)),!o.has(t)){o.add(t);for(const i in n){const a=n[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){const s=a.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:s}),s},set(s){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:s})}})}}}var T=l("ZodType",(e,t)=>(A.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Se(e,"input"),output:Se(e,"output")}}),e.toJSONSchema=Cs(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>ac(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>cc(e,n,r),e.parseAsync=async(n,r)=>sc(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>uc(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>lc(e,n,r),e.decode=(n,r)=>dc(e,n,r),e.encodeAsync=async(n,r)=>fc(e,n,r),e.decodeAsync=async(n,r)=>pc(e,n,r),e.safeEncode=(n,r)=>gc(e,n,r),e.safeDecode=(n,r)=>hc(e,n,r),e.safeEncodeAsync=async(n,r)=>mc(e,n,r),e.safeDecodeAsync=async(n,r)=>yc(e,n,r),ze(e,"ZodType",{check(...n){const r=this.def;return this.clone(U(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return B(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(cu(n,r))},superRefine(n,r){return this.check(uu(n,r))},overwrite(n){return this.check(ee(n))},optional(){return wn(this)},exactOptional(){return Vc(this)},nullable(){return kn(this)},nullish(){return wn(kn(this))},nonoptional(n){return tu(this,n)},array(){return _n(this)},or(n){return vn([this,n])},and(n){return Hc(this,n)},transform(n){return zn(this,Qc(n))},default(n){return Yc(this,n)},prefault(n){return eu(this,n)},catch(n){return ru(this,n)},pipe(n){return zn(this,n)},readonly(){return au(this)},describe(n){const r=this.clone();return se.add(r,{description:n}),r},meta(...n){if(n.length===0)return se.get(this);const r=this.clone();return se.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return se.get(e)?.description},configurable:!0}),e)),mn=l("_ZodString",(e,t)=>{Qe.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Os(e,r,o,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ze(e,"_ZodString",{regex(...r){return this.check(ms(...r))},includes(...r){return this.check(vs(...r))},startsWith(...r){return this.check(bs(...r))},endsWith(...r){return this.check(ws(...r))},min(...r){return this.check(ke(...r))},max(...r){return this.check(un(...r))},length(...r){return this.check(ln(...r))},nonempty(...r){return this.check(ke(1,...r))},lowercase(r){return this.check(ys(r))},uppercase(r){return this.check(_s(r))},trim(){return this.check(Ss())},normalize(...r){return this.check(ks(...r))},toLowerCase(){return this.check(zs())},toUpperCase(){return this.check(Es())},slugify(){return this.check(As())}})}),_c=l("ZodString",(e,t)=>{Qe.init(e,t),mn.init(e,t),e.email=n=>e.check(Ba(vc,n)),e.url=n=>e.check(Qa(bc,n)),e.jwt=n=>e.check(cs(Rc,n)),e.emoji=n=>e.check(Wa(wc,n)),e.guid=n=>e.check(cn(yn,n)),e.uuid=n=>e.check(Ma(Ee,n)),e.uuidv4=n=>e.check(Fa(Ee,n)),e.uuidv6=n=>e.check(Ha(Ee,n)),e.uuidv7=n=>e.check(Ja(Ee,n)),e.nanoid=n=>e.check(Va(kc,n)),e.guid=n=>e.check(cn(yn,n)),e.cuid=n=>e.check(Ga(Sc,n)),e.cuid2=n=>e.check(Ka(zc,n)),e.ulid=n=>e.check(Ya(Ec,n)),e.base64=n=>e.check(is(xc,n)),e.base64url=n=>e.check(as(Oc,n)),e.xid=n=>e.check(Xa(Ac,n)),e.ksuid=n=>e.check(es(Tc,n)),e.ipv4=n=>e.check(ts($c,n)),e.ipv6=n=>e.check(ns(Ic,n)),e.cidrv4=n=>e.check(rs(Pc,n)),e.cidrv6=n=>e.check(os(Cc,n)),e.e164=n=>e.check(ss(Zc,n)),e.datetime=n=>e.check(Ys(n)),e.date=n=>e.check(ec(n)),e.time=n=>e.check(nc(n)),e.duration=n=>e.check(oc(n))});function V(e){return Ua(_c,e)}var z=l("ZodStringFormat",(e,t)=>{S.init(e,t),mn.init(e,t)}),vc=l("ZodEmail",(e,t)=>{Ki.init(e,t),z.init(e,t)}),yn=l("ZodGUID",(e,t)=>{Vi.init(e,t),z.init(e,t)}),Ee=l("ZodUUID",(e,t)=>{Gi.init(e,t),z.init(e,t)}),bc=l("ZodURL",(e,t)=>{Yi.init(e,t),z.init(e,t)}),wc=l("ZodEmoji",(e,t)=>{Xi.init(e,t),z.init(e,t)}),kc=l("ZodNanoID",(e,t)=>{ea.init(e,t),z.init(e,t)}),Sc=l("ZodCUID",(e,t)=>{ta.init(e,t),z.init(e,t)}),zc=l("ZodCUID2",(e,t)=>{na.init(e,t),z.init(e,t)}),Ec=l("ZodULID",(e,t)=>{ra.init(e,t),z.init(e,t)}),Ac=l("ZodXID",(e,t)=>{oa.init(e,t),z.init(e,t)}),Tc=l("ZodKSUID",(e,t)=>{ia.init(e,t),z.init(e,t)}),$c=l("ZodIPv4",(e,t)=>{la.init(e,t),z.init(e,t)}),Ic=l("ZodIPv6",(e,t)=>{da.init(e,t),z.init(e,t)}),Pc=l("ZodCIDRv4",(e,t)=>{fa.init(e,t),z.init(e,t)}),Cc=l("ZodCIDRv6",(e,t)=>{pa.init(e,t),z.init(e,t)}),xc=l("ZodBase64",(e,t)=>{ga.init(e,t),z.init(e,t)}),Oc=l("ZodBase64URL",(e,t)=>{ma.init(e,t),z.init(e,t)}),Zc=l("ZodE164",(e,t)=>{ya.init(e,t),z.init(e,t)}),Rc=l("ZodJWT",(e,t)=>{va.init(e,t),z.init(e,t)}),Lc=l("ZodBoolean",(e,t)=>{ba.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zs(e,n,r,o)});function Nc(e){return ps(Lc,e)}var qc=l("ZodUnknown",(e,t)=>{wa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ls(e,n,r,o)});function Ve(){return gs(qc)}var jc=l("ZodNever",(e,t)=>{ka.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rs(e,n,r,o)});function Dc(e){return hs(jc,e)}var Uc=l("ZodArray",(e,t)=>{Sa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ds(e,n,r,o),e.element=t.element,ze(e,"ZodArray",{min(n,r){return this.check(ke(n,r))},nonempty(n){return this.check(ke(1,n))},max(n,r){return this.check(un(n,r))},length(n,r){return this.check(ln(n,r))},unwrap(){return this.element}})});function _n(e,t){return Ts(Uc,e,t)}var Bc=l("ZodObject",(e,t)=>{Ea.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Us(e,n,r,o),b(e,"shape",()=>t.shape),ze(e,"ZodObject",{keyof(){return Ke(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Ve()})},loose(){return this.clone({...this._zod.def,catchall:Ve()})},strict(){return this.clone({...this._zod.def,catchall:Dc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Wo(this,n)},safeExtend(n){return Vo(this,n)},merge(n){return Go(this,n)},pick(n){return Jo(this,n)},omit(n){return Qo(this,n)},partial(...n){return Ko(bn,this,n[0])},required(...n){return Yo(Sn,this,n[0])}})});function ce(e,t){return new Bc({type:"object",shape:e??{},...y(t)})}var Mc=l("ZodUnion",(e,t)=>{Aa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bs(e,n,r,o),e.options=t.options});function vn(e,t){return new Mc({type:"union",options:e,...y(t)})}var Fc=l("ZodIntersection",(e,t)=>{Ta.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ms(e,n,r,o)});function Hc(e,t){return new Fc({type:"intersection",left:e,right:t})}var Ge=l("ZodEnum",(e,t)=>{$a.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Ns(e,r,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const a of r)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Ge({...t,checks:[],...y(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const a of r)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Ge({...t,checks:[],...y(o),entries:i})}});function Ke(e,t){return new Ge({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e,...y(t)})}var Jc=l("ZodTransform",(e,t)=>{Ia.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>js(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Zt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(ae(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(ae(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function Qc(e){return new Jc({type:"transform",transform:e})}var bn=l("ZodOptional",(e,t)=>{tn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function wn(e){return new bn({type:"optional",innerType:e})}var Wc=l("ZodExactOptional",(e,t)=>{Pa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Vc(e){return new Wc({type:"optional",innerType:e})}var Gc=l("ZodNullable",(e,t)=>{Ca.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function kn(e){return new Gc({type:"nullable",innerType:e})}var Kc=l("ZodDefault",(e,t)=>{xa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Js(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Yc(e,t){return new Kc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():jt(t)}})}var Xc=l("ZodPrefault",(e,t)=>{Oa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function eu(e,t){return new Xc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():jt(t)}})}var Sn=l("ZodNonOptional",(e,t)=>{Za.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function tu(e,t){return new Sn({type:"nonoptional",innerType:e,...y(t)})}var nu=l("ZodCatch",(e,t)=>{Ra.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ws(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ru(e,t){return new nu({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var ou=l("ZodPipe",(e,t)=>{La.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vs(e,n,r,o),e.in=t.in,e.out=t.out});function zn(e,t){return new ou({type:"pipe",in:e,out:t})}var iu=l("ZodReadonly",(e,t)=>{Na.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function au(e){return new iu({type:"readonly",innerType:e})}var su=l("ZodCustom",(e,t)=>{qa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qs(e,n,r,o)});function cu(e,t={}){return $s(su,e,t)}function uu(e,t){return Is(e,t)}var lu=ce({title:V(),type:V(),payload:Ve().optional()}),du=ce({label:V(),action:lu,variant:Ke(["primary","outline","ghost"]).optional()}),fu=ce({orientation:Ke(["horizontal","vertical"]).optional(),wrap:Nc().optional()}),pu=ce({placeholder:vn([V(),_n(V())]).optional(),ctaLabel:V().optional()}),gu=ce({text:V()}),hu={components:{ActionButton:{schema:du,description:"A single clickable QNA action button."},ButtonRow:{schema:fu,description:"Container for a group of QNA action buttons."},TextInput:{schema:pu,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:gu,description:"A heading displayed above the QNA button group."}}};M.GengageQNA=xt,M.createDefaultQnaUISpecRegistry=Et,M.createQNAWidget=Uo,M.defaultQnaUnknownUISpecRenderer=je,M.qnaCatalog=hu,M.renderQnaUISpec=At})(this.Gengage=this.Gengage||{});
|
|
111
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const s=a[1];if(t===a[0]){i(a);continue}if(e.external){const c=e.external.registry.get(a[0])?.id;if(t!==a[0]&&c){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}if(s.count>1&&e.reused==="ref"){i(a);continue}}}function gn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=s=>{const c=e.seen.get(s);if(c.ref===null)return;const u=c.def??c.schema,d={...u},p=c.ref;if(c.ref=null,p){r(p);const g=e.seen.get(p),h=g.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Object.assign(u,h),Object.assign(u,d),s._zod.parent===p)for(const m in u)m==="$ref"||m==="allOf"||m in d||delete u[m];if(h.$ref&&g.def)for(const m in u)m==="$ref"||m==="allOf"||m in g.def&&JSON.stringify(u[m])===JSON.stringify(g.def[m])&&delete u[m]}const f=s._zod.parent;if(f&&f!==p){r(f);const g=e.seen.get(f);if(g?.schema.$ref&&(u.$ref=g.schema.$ref,g.def))for(const h in u)h==="$ref"||h==="allOf"||h in g.def&&JSON.stringify(u[h])===JSON.stringify(g.def[h])&&delete u[h]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};for(const s of[...e.seen.entries()].reverse())r(s[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const a=e.external?.defs??{};for(const s of e.seen.entries()){const c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,a[c.defId]=c.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Se(t,"input",e.processors),output:Se(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function x(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return x(r.element,n);if(r.type==="set")return x(r.valueType,n);if(r.type==="lazy")return x(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return x(r.innerType,n);if(r.type==="intersection")return x(r.left,n)||x(r.right,n);if(r.type==="record"||r.type==="map")return x(r.keyType,n)||x(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:x(r.in,n)||x(r.out,n);if(r.type==="object"){for(const o in r.shape)if(x(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(x(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(x(o,n))return!0;return!!(r.rest&&x(r.rest,n))}return!1}var xs=(e,t={})=>n=>{const r=fn({...n,processors:t});return $(e,r),pn(r,e),gn(r,e)},Se=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=fn({...o??{},target:i,io:t,processors:n});return $(e,a),pn(a,e),gn(a,e)},Os={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Zs=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),s&&(o.format=Os[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Rs=(e,t,n,r)=>{n.type="boolean"},Ls=(e,t,n,r)=>{n.not={}},Ns=(e,t,n,r)=>{},qs=(e,t,n,r)=>{const o=e._zod.def,i=Lt(o.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},js=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ds=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Us=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=$(i.element,t,{...r,path:[...r.path,"items"]})},Bs=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const u in a)o.properties[u]=$(a[u],t,{...r,path:[...r.path,"properties",u]});const s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{const d=i.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=$(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Ms=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((s,c)=>$(s,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=a:n.anyOf=a},Fs=(e,t,n,r)=>{const o=e._zod.def,i=$(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=$(o.right,t,{...r,path:[...r.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1;n.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]},Hs=(e,t,n,r)=>{const o=e._zod.def,i=$(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Js=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Qs=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Ws=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Vs=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},Gs=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?o.out:o.in:o.out;$(a,t,r);const s=t.seen.get(e);s.ref=a},Ks=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},hn=(e,t,n,r)=>{const o=e._zod.def;$(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Ys=l("ZodISODateTime",(e,t)=>{sa.init(e,t),z.init(e,t)});function Xs(e){return ls(Ys,e)}var ec=l("ZodISODate",(e,t)=>{ca.init(e,t),z.init(e,t)});function tc(e){return ds(ec,e)}var nc=l("ZodISOTime",(e,t)=>{ua.init(e,t),z.init(e,t)});function rc(e){return fs(nc,e)}var oc=l("ZodISODuration",(e,t)=>{la.init(e,t),z.init(e,t)});function ic(e){return ps(oc,e)}var ac=(e,t)=>{Mt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>ni(e,n)},flatten:{value:n=>ti(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,De,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,De,2)}},isEmpty:{get(){return e.issues.length===0}}})},Z=l("ZodError",ac,{Parent:Error}),sc=He(Z),cc=Je(Z),uc=ye(Z),lc=_e(Z),dc=ii(Z),fc=ai(Z),pc=si(Z),gc=ci(Z),hc=ui(Z),mc=li(Z),yc=di(Z),_c=fi(Z),mn=new WeakMap;function ze(e,t,n){const r=Object.getPrototypeOf(e);let o=mn.get(r);if(o||(o=new Set,mn.set(r,o)),!o.has(t)){o.add(t);for(const i in n){const a=n[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){const s=a.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:s}),s},set(s){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:s})}})}}}var T=l("ZodType",(e,t)=>(A.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Se(e,"input"),output:Se(e,"output")}}),e.toJSONSchema=xs(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>sc(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>uc(e,n,r),e.parseAsync=async(n,r)=>cc(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>lc(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>dc(e,n,r),e.decode=(n,r)=>fc(e,n,r),e.encodeAsync=async(n,r)=>pc(e,n,r),e.decodeAsync=async(n,r)=>gc(e,n,r),e.safeEncode=(n,r)=>hc(e,n,r),e.safeDecode=(n,r)=>mc(e,n,r),e.safeEncodeAsync=async(n,r)=>yc(e,n,r),e.safeDecodeAsync=async(n,r)=>_c(e,n,r),ze(e,"ZodType",{check(...n){const r=this.def;return this.clone(U(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return B(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(uu(n,r))},superRefine(n,r){return this.check(lu(n,r))},overwrite(n){return this.check(ee(n))},optional(){return kn(this)},exactOptional(){return Gc(this)},nullable(){return Sn(this)},nullish(){return kn(Sn(this))},nonoptional(n){return nu(this,n)},array(){return vn(this)},or(n){return bn([this,n])},and(n){return Jc(this,n)},transform(n){return En(this,Wc(n))},default(n){return Xc(this,n)},prefault(n){return tu(this,n)},catch(n){return ou(this,n)},pipe(n){return En(this,n)},readonly(){return su(this)},describe(n){const r=this.clone();return se.add(r,{description:n}),r},meta(...n){if(n.length===0)return se.get(this);const r=this.clone();return se.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return se.get(e)?.description},configurable:!0}),e)),yn=l("_ZodString",(e,t)=>{Qe.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Zs(e,r,o,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ze(e,"_ZodString",{regex(...r){return this.check(ys(...r))},includes(...r){return this.check(bs(...r))},startsWith(...r){return this.check(ws(...r))},endsWith(...r){return this.check(ks(...r))},min(...r){return this.check(ke(...r))},max(...r){return this.check(ln(...r))},length(...r){return this.check(dn(...r))},nonempty(...r){return this.check(ke(1,...r))},lowercase(r){return this.check(_s(r))},uppercase(r){return this.check(vs(r))},trim(){return this.check(zs())},normalize(...r){return this.check(Ss(...r))},toLowerCase(){return this.check(Es())},toUpperCase(){return this.check(As())},slugify(){return this.check(Ts())}})}),vc=l("ZodString",(e,t)=>{Qe.init(e,t),yn.init(e,t),e.email=n=>e.check(Ma(bc,n)),e.url=n=>e.check(Wa(wc,n)),e.jwt=n=>e.check(us(Lc,n)),e.emoji=n=>e.check(Va(kc,n)),e.guid=n=>e.check(un(_n,n)),e.uuid=n=>e.check(Fa(Ee,n)),e.uuidv4=n=>e.check(Ha(Ee,n)),e.uuidv6=n=>e.check(Ja(Ee,n)),e.uuidv7=n=>e.check(Qa(Ee,n)),e.nanoid=n=>e.check(Ga(Sc,n)),e.guid=n=>e.check(un(_n,n)),e.cuid=n=>e.check(Ka(zc,n)),e.cuid2=n=>e.check(Ya(Ec,n)),e.ulid=n=>e.check(Xa(Ac,n)),e.base64=n=>e.check(as(Oc,n)),e.base64url=n=>e.check(ss(Zc,n)),e.xid=n=>e.check(es(Tc,n)),e.ksuid=n=>e.check(ts($c,n)),e.ipv4=n=>e.check(ns(Ic,n)),e.ipv6=n=>e.check(rs(Pc,n)),e.cidrv4=n=>e.check(os(Cc,n)),e.cidrv6=n=>e.check(is(xc,n)),e.e164=n=>e.check(cs(Rc,n)),e.datetime=n=>e.check(Xs(n)),e.date=n=>e.check(tc(n)),e.time=n=>e.check(rc(n)),e.duration=n=>e.check(ic(n))});function V(e){return Ba(vc,e)}var z=l("ZodStringFormat",(e,t)=>{S.init(e,t),yn.init(e,t)}),bc=l("ZodEmail",(e,t)=>{Yi.init(e,t),z.init(e,t)}),_n=l("ZodGUID",(e,t)=>{Gi.init(e,t),z.init(e,t)}),Ee=l("ZodUUID",(e,t)=>{Ki.init(e,t),z.init(e,t)}),wc=l("ZodURL",(e,t)=>{Xi.init(e,t),z.init(e,t)}),kc=l("ZodEmoji",(e,t)=>{ea.init(e,t),z.init(e,t)}),Sc=l("ZodNanoID",(e,t)=>{ta.init(e,t),z.init(e,t)}),zc=l("ZodCUID",(e,t)=>{na.init(e,t),z.init(e,t)}),Ec=l("ZodCUID2",(e,t)=>{ra.init(e,t),z.init(e,t)}),Ac=l("ZodULID",(e,t)=>{oa.init(e,t),z.init(e,t)}),Tc=l("ZodXID",(e,t)=>{ia.init(e,t),z.init(e,t)}),$c=l("ZodKSUID",(e,t)=>{aa.init(e,t),z.init(e,t)}),Ic=l("ZodIPv4",(e,t)=>{da.init(e,t),z.init(e,t)}),Pc=l("ZodIPv6",(e,t)=>{fa.init(e,t),z.init(e,t)}),Cc=l("ZodCIDRv4",(e,t)=>{pa.init(e,t),z.init(e,t)}),xc=l("ZodCIDRv6",(e,t)=>{ga.init(e,t),z.init(e,t)}),Oc=l("ZodBase64",(e,t)=>{ha.init(e,t),z.init(e,t)}),Zc=l("ZodBase64URL",(e,t)=>{ya.init(e,t),z.init(e,t)}),Rc=l("ZodE164",(e,t)=>{_a.init(e,t),z.init(e,t)}),Lc=l("ZodJWT",(e,t)=>{ba.init(e,t),z.init(e,t)}),Nc=l("ZodBoolean",(e,t)=>{wa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rs(e,n,r,o)});function qc(e){return gs(Nc,e)}var jc=l("ZodUnknown",(e,t)=>{ka.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ns(e,n,r,o)});function Ve(){return hs(jc)}var Dc=l("ZodNever",(e,t)=>{Sa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ls(e,n,r,o)});function Uc(e){return ms(Dc,e)}var Bc=l("ZodArray",(e,t)=>{za.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Us(e,n,r,o),e.element=t.element,ze(e,"ZodArray",{min(n,r){return this.check(ke(n,r))},nonempty(n){return this.check(ke(1,n))},max(n,r){return this.check(ln(n,r))},length(n,r){return this.check(dn(n,r))},unwrap(){return this.element}})});function vn(e,t){return $s(Bc,e,t)}var Mc=l("ZodObject",(e,t)=>{Aa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bs(e,n,r,o),b(e,"shape",()=>t.shape),ze(e,"ZodObject",{keyof(){return Ke(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Ve()})},loose(){return this.clone({...this._zod.def,catchall:Ve()})},strict(){return this.clone({...this._zod.def,catchall:Uc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Vo(this,n)},safeExtend(n){return Go(this,n)},merge(n){return Ko(this,n)},pick(n){return Qo(this,n)},omit(n){return Wo(this,n)},partial(...n){return Yo(wn,this,n[0])},required(...n){return Xo(zn,this,n[0])}})});function ce(e,t){return new Mc({type:"object",shape:e??{},...y(t)})}var Fc=l("ZodUnion",(e,t)=>{Ta.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ms(e,n,r,o),e.options=t.options});function bn(e,t){return new Fc({type:"union",options:e,...y(t)})}var Hc=l("ZodIntersection",(e,t)=>{$a.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fs(e,n,r,o)});function Jc(e,t){return new Hc({type:"intersection",left:e,right:t})}var Ge=l("ZodEnum",(e,t)=>{Ia.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,i)=>qs(e,r,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const a of r)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Ge({...t,checks:[],...y(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const a of r)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Ge({...t,checks:[],...y(o),entries:i})}});function Ke(e,t){return new Ge({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e,...y(t)})}var Qc=l("ZodTransform",(e,t)=>{Pa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ds(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Rt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(ae(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(ae(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function Wc(e){return new Qc({type:"transform",transform:e})}var wn=l("ZodOptional",(e,t)=>{nn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function kn(e){return new wn({type:"optional",innerType:e})}var Vc=l("ZodExactOptional",(e,t)=>{Ca.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Gc(e){return new Vc({type:"optional",innerType:e})}var Kc=l("ZodNullable",(e,t)=>{xa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Sn(e){return new Kc({type:"nullable",innerType:e})}var Yc=l("ZodDefault",(e,t)=>{Oa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xc(e,t){return new Yc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Dt(t)}})}var eu=l("ZodPrefault",(e,t)=>{Za.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ws(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function tu(e,t){return new eu({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Dt(t)}})}var zn=l("ZodNonOptional",(e,t)=>{Ra.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Js(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function nu(e,t){return new zn({type:"nonoptional",innerType:e,...y(t)})}var ru=l("ZodCatch",(e,t)=>{La.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ou(e,t){return new ru({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var iu=l("ZodPipe",(e,t)=>{Na.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gs(e,n,r,o),e.in=t.in,e.out=t.out});function En(e,t){return new iu({type:"pipe",in:e,out:t})}var au=l("ZodReadonly",(e,t)=>{qa.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ks(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function su(e){return new au({type:"readonly",innerType:e})}var cu=l("ZodCustom",(e,t)=>{ja.init(e,t),T.init(e,t),e._zod.processJSONSchema=(n,r,o)=>js(e,n,r,o)});function uu(e,t={}){return Is(cu,e,t)}function lu(e,t){return Ps(e,t)}var du=ce({title:V(),type:V(),payload:Ve().optional()}),fu=ce({label:V(),action:du,variant:Ke(["primary","outline","ghost"]).optional()}),pu=ce({orientation:Ke(["horizontal","vertical"]).optional(),wrap:qc().optional()}),gu=ce({placeholder:bn([V(),vn(V())]).optional(),ctaLabel:V().optional()}),hu=ce({text:V()}),mu={components:{ActionButton:{schema:fu,description:"A single clickable QNA action button."},ButtonRow:{schema:pu,description:"Container for a group of QNA action buttons."},TextInput:{schema:gu,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:hu,description:"A heading displayed above the QNA button group."}}};M.GengageQNA=Ot,M.createDefaultQnaUISpecRegistry=At,M.createQNAWidget=Bo,M.defaultQnaUnknownUISpecRenderer=je,M.qnaCatalog=mu,M.renderQnaUISpec=Tt})(this.Gengage=this.Gengage||{});
|