murmur-rag 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/{anthropic-p21yv83k.js → anthropic-9g8r07a0.js} +2 -2
- package/dist/cdn/chunk-c0ztxsjw.js +1 -0
- package/dist/cdn/{embed-zckjbrcx.js → embed-3x3yz3jw.js} +3 -3
- package/dist/cdn/embed-b072jtkd.js +9 -0
- package/dist/cdn/{embed-xdftb0b2.js → embed-gx1epk52.js} +5 -5
- package/dist/cdn/{embed-3vb4wcng.js → embed-hm6mmwpk.js} +2 -2
- package/dist/cdn/{embed-52n5pm9t.js → embed-pm1dj76g.js} +25 -25
- package/dist/cdn/{embed-f7gzw56s.js → embed-q2zmgyqj.js} +2 -2
- package/dist/cdn/{embed-wd4wcxtq.js → embed-strrtkwa.js} +1 -1
- package/dist/cdn/{google-df5pjzyw.js → google-8ag1bn64.js} +3 -3
- package/dist/cdn/{index-0yvq5pe3.js → index-27ae3wqx.js} +1 -1
- package/dist/cdn/{index-tjxzgn54.js → index-3hkf4rah.js} +1 -1
- package/dist/cdn/{index-arpy64fv.js → index-ec42kn0e.js} +1 -1
- package/dist/cdn/index-em6py5z5.js +1 -0
- package/dist/cdn/{index-f5ctpc4w.js → index-xz31ft5m.js} +1 -1
- package/dist/cdn/{mistral-0tm1pmab.js → mistral-x5wz2kx2.js} +1 -1
- package/dist/cdn/murmur-s4gkmy66.js +5 -0
- package/dist/cdn/murmur.js +6 -6
- package/dist/cdn/{openai-t1hcmmxm.js → openai-84wvv6cp.js} +6 -6
- package/dist/cdn/{openai-compatible-vqp1sqdg.js → openai-compatible-5qanv34a.js} +2 -2
- package/dist/cdn/retriever-brdwdchq.js +1 -0
- package/dist/cdn/{transformers.web-nr67a9j3.js → transformers.web-3m8jygmc.js} +1 -1
- package/dist/lib/chunks/index-7xc57jeh.js +86 -0
- package/dist/lib/chunks/{index-6j52e72a.js → index-9ybqwzx2.js} +43 -23
- package/dist/lib/chunks/{index-8h9c8ekq.js → index-ahy8h3ks.js} +16 -6
- package/dist/lib/chunks/{index-p86sy3y4.js → index-pjwdwban.js} +1 -1
- package/dist/lib/chunks/{murmur-t36hd4vt.js → murmur-5e79jear.js} +2 -2
- package/dist/lib/chunks/{retriever-wxshtnm0.js → retriever-62r4an0v.js} +1 -1
- package/dist/lib/embed.js +2 -2
- package/dist/lib/index.js +8 -4
- package/dist/lib/rag/index.js +7 -3
- package/dist/lib/widget/index.js +2 -2
- package/dist/types/core/murmur.d.ts +2 -0
- package/dist/types/rag/ground.d.ts +14 -3
- package/dist/types/rag/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cdn/chunk-nhd6pd73.js +0 -1
- package/dist/cdn/embed-q03dhgpb.js +0 -9
- package/dist/cdn/index-r7h9ewgp.js +0 -1
- package/dist/cdn/murmur-krwan2e5.js +0 -5
- package/dist/cdn/retriever-3yz0vzz9.js +0 -1
- package/dist/lib/chunks/index-b77xqap3.js +0 -58
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var Cf=Symbol.for("vercel.ai.error"),m=class N extends Error{constructor({name:oe,message:Ie,cause:Re}){super(Ie);this[Cf]=!0,this.name=oe,this.cause=Re}static isInstance(oe){return N.hasMarker(oe,"vercel.ai.error")}static hasMarker(oe,Ie){let Re=Symbol.for(Ie);return oe!=null&&typeof oe==="object"&&Re in oe&&typeof oe[Re]==="boolean"&&oe[Re]===!0}},rs="AI_DecisionUnsupportedQuestionTypeError",ns=`vercel.ai.error.${rs}`,Nf=Symbol.for(ns),
|
|
2
|
-
Error message: ${A(oe)}`,cause:oe});this[Uf]=!0,this.text=N}static isInstance(N){return m.hasMarker(N,hs)}},gs="AI_LoadAPIKeyError",ys=`vercel.ai.error.${gs}`,Bf=Symbol.for(ys),
|
|
3
|
-
Error message: ${A(Ie)}`,cause:Ie});this[qf]=!0,this.value=oe,this.context=Re}static isInstance(oe){return m.hasMarker(oe,ks)}static wrap({value:oe,cause:Ie,context:Re}){if(N.isInstance(Ie)&&Ie.value===oe&&Ie.context?.field===Re?.field&&Ie.context?.entityName===Re?.entityName&&Ie.context?.entityId===Re?.entityId)return Ie;return new N({value:oe,cause:Ie,context:Re})}},Ps="AI_UnsupportedFunctionalityError",Es=`vercel.ai.error.${Ps}`,Gf=Symbol.for(Es),u=class extends m{constructor({functionality:N,message:oe=`'${N}' functionality not supported.`}){super({name:Ps,message:oe});this[Gf]=!0,this.functionality=N}static isInstance(N){return m.hasMarker(N,Es)}};function xo(N){if(N===null||typeof N==="string"||typeof N==="number"||typeof N==="boolean")return!0;if(Array.isArray(N))return N.every(xo);if(typeof N==="object")return Object.entries(N).every(([oe,Ie])=>typeof oe==="string"&&(Ie===void 0||xo(Ie)));return!1}function nt(N){return N!=null&&typeof N==="object"&&Object.entries(N).every(([oe,Ie])=>typeof oe==="string"&&(Ie===void 0||xo(Ie)))}function Qr(N){let oe=Object.values(N).filter((Re)=>typeof Re==="number");return Object.entries(N).filter(([Re,De])=>oe.indexOf(+Re)===-1).map(([Re,De])=>De)}function $o(N,oe="|"){return N.map((Ie)=>ko(Ie)).join(oe)}function gn(N,oe){if(typeof oe==="bigint")return oe.toString();return oe}class Ts{constructor(N){this._getter=N,this._value=void 0}get value(){let N=this._getter;if(N!==void 0)this._value=N(),this._getter=void 0;return this._value}}function yn(N){return new Ts(N)}function Zs(N){return N===null||N===void 0}function Mn(N){let oe=N.startsWith("^")?1:0,Ie=N.endsWith("$")?N.length-1:N.length;return N.slice(oe,Ie)}function As(N,oe){let Ie=N/oe,Re=Math.round(Ie),De=4*Number.EPSILON*Math.max(Math.abs(Ie),1);if(Math.abs(Ie-Re)<De)return 0;return Ie-Re}var Os=Symbol("evaluating");function Is(N,oe,Ie){let Re=void 0;Object.defineProperty(N,oe,{get(){if(Re===Os)return;if(Re===void 0)Re=Os,Re=Ie();return Re},set(De){Object.defineProperty(N,oe,{value:De})},configurable:!0})}function lr(N,oe,Ie){Object.defineProperty(N,oe,{value:Ie,writable:!0,enumerable:!0,configurable:!0})}function _n(N){let oe=Object.getOwnPropertyDescriptor(N,"shape");return oe?.get?oe.get.raw:oe?.value}function Er(N){return _n(N._zod.def)??N._zod.def.shape}function Cs(N,oe,Ie){Object.defineProperty(N,oe,{get(){let Re=Ie();return lr(this,oe,Re),Re},enumerable:!0,configurable:!0})}function Ns(N,oe,Ie){if(oe in N)lr(N,oe,Ie);else N[oe]=Ie}function Lr(N,oe,Ie,Re){let De=Er(oe);for(let Le of Ie){let Ue=Object.getOwnPropertyDescriptor(De,Le);if(!Ue.enumerable)continue;if(Ue.get)Cs(N,Le,()=>{let Be=oe._zod.def.shape[Le];return Re?Re(Be,Le):Be});else Ns(N,Le,Re?Re(Ue.value,Le):Ue.value)}}function Xf(N,oe){for(let Ie of Reflect.ownKeys(oe)){let Re=Object.getOwnPropertyDescriptor(oe,Ie);if(!Re.enumerable)continue;if(Re.get)Cs(N,Ie,()=>oe[Ie]);else Ns(N,Ie,Re.value)}}function fr(...N){let oe={};for(let Ie of N){let Re=Object.getOwnPropertyDescriptors(Ie);Object.assign(oe,Re)}return Object.defineProperties({},oe)}function Rs(N){return JSON.stringify(N)}function Ds(N){return N.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var zo="captureStackTrace"in Error?Error.captureStackTrace:(...N)=>{};function Vr(N){return typeof N==="object"&&N!==null&&!Array.isArray(N)}var Ms=yn(()=>{if(cr.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(N){return!1}});function jr(N){if(Vr(N)===!1)return!1;let oe=N.constructor;if(oe===void 0)return!0;if(typeof oe!=="function")return!0;let Ie=oe.prototype;if(Vr(Ie)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Ie,"isPrototypeOf")===!1)return!1;return!0}function So(N){if(jr(N))return{...N};if(Array.isArray(N))return[...N];if(N instanceof Map)return new Map(N);if(N instanceof Set)return new Set(N);return N}var Ls=new Set(["string","number","symbol"]);function Nr(N){return N.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $r(N,oe,Ie){let Re=new N._zod.constr(oe??N._zod.def);if(!oe||Ie?.parent)Re._zod.parent=N;return Re}function zt(N){let oe=N;if(!oe)return{};if(typeof oe==="string")return{error:()=>oe};if(oe?.message!==void 0){if(oe?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");oe.error=oe.message}if(delete oe.message,typeof oe.error==="string")return{...oe,error:()=>oe.error};return oe}function ko(N){if(typeof N==="bigint")return N.toString()+"n";if(typeof N==="string")return`"${N}"`;return`${N}`}function js(N){return Object.keys(N).filter((oe)=>N[oe]._zod.optin!==void 0&&N[oe]._zod.optout==="optional")}var Ln=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Po={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Yf(N,oe){let Ie=N._zod.def,Re=Ie.checks;if(Re&&Re.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let Le={};return Lr(Le,N,jn(N,oe)),$r(N,fr(Ie,{shape:Le,checks:[]}))}function jn(N,oe){let Ie=Er(N),Re=[];for(let De of Reflect.ownKeys(oe)){if(!Object.getOwnPropertyDescriptor(Ie,De)?.enumerable)throw Error(`Unrecognized key: "${String(De)}"`);if(oe[De])Re.push(De)}return Re}function Qf(N,oe){let Ie=N._zod.def,Re=Ie.checks;if(Re&&Re.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let Le=new Set(jn(N,oe)),Ue={};return Lr(Ue,N,Reflect.ownKeys(Er(N)).filter((Be)=>!Le.has(Be))),$r(N,fr(Ie,{shape:Ue,checks:[]}))}function ep(N,oe){if(!jr(oe))throw Error("Invalid input to extend: expected a plain object");let Ie=N._zod.def.checks;if(Ie&&Ie.length>0){let De=Er(N);for(let Le of Reflect.ownKeys(oe))if(Object.getOwnPropertyDescriptor(De,Le)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return $r(N,fr(N._zod.def,{shape:Fs(N,oe)}))}function Fs(N,oe){let Ie={};return Lr(Ie,N,Reflect.ownKeys(Er(N))),Xf(Ie,oe),Ie}function tp(N,oe){if(!jr(oe))throw Error("Invalid input to safeExtend: expected a plain object");return $r(N,fr(N._zod.def,{shape:Fs(N,oe)}))}function rp(N,oe){if(!oe?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(N._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let Ie={};Lr(Ie,N,Reflect.ownKeys(Er(N))),Lr(Ie,oe,Reflect.ownKeys(Er(oe)));let Re=fr(N._zod.def,{shape:Ie,get catchall(){return oe._zod.def.catchall},checks:oe._zod.def.checks??[]});return $r(N,Re)}function Us(N,oe,Ie,Re="partial"){let Le=oe._zod.def.checks;if(Le&&Le.length>0)throw Error(`.${Re}() cannot be used on object schemas containing refinements`);let Be=Ie?new Set(jn(oe,Ie)):void 0,Xe={};return Lr(Xe,oe,Reflect.ownKeys(Er(oe)),N&&((Ye,Qe)=>Be&&!Be.has(Qe)?Ye:new N({type:"optional",innerType:Ye}))),$r(oe,fr(oe._zod.def,{shape:Xe,checks:[]}))}function np(N,oe,Ie){let Re=Ie?new Set(jn(oe,Ie)):void 0,De={};return Lr(De,oe,Reflect.ownKeys(Er(oe)),(Le,Ue)=>Re&&!Re.has(Ue)?Le:new N({type:"nonoptional",innerType:Le})),$r(oe,fr(oe._zod.def,{shape:De}))}function gr(N,oe=0){if(N.aborted===!0)return!0;for(let Ie=oe;Ie<N.issues.length;Ie++)if(N.issues[Ie]?.continue!==!0)return!0;return!1}function Bs(N,oe=0){if(N.aborted===!0)return!0;for(let Ie=oe;Ie<N.issues.length;Ie++)if(N.issues[Ie]?.continue===!1)return!0;return!1}function yr(N,oe){return oe.map((Ie)=>{var Re;return(Re=Ie).path??(Re.path=[]),Ie.path.unshift(N),Ie})}function Yr(N){return typeof N==="string"?N:N?.message}function Eo(N){let oe=[];for(let Ie of N??[]){let Re=Ie._zod.def;if(!/_(length|size)$|_equals$/.test(Re.check))break;let De=Re.maximum??Re.length??Re.size;if(De>=0)oe.push([De,Ie])}return oe}function Fn(N,oe,Ie){var Re;for(let De=oe;De<N.length;De++)(Re=N[De]).schema??(Re.schema=Ie)}function zr(N,oe,Ie){var Re;let De=N.inst?._zod?.traits;if(De?.has("$ZodType"))if(De.has("$ZodCheck"))(Re=N).schema??(Re.schema=N.inst);else N.schema=N.inst;let Le=N.schema!==N.inst?N.schema?._zod.def?.error:void 0,Ue=N.message?N.message:Yr(N.inst?._zod.def?.error?.(N))??Yr(Le?.(N))??Yr(oe?.error?.(N))??Yr(Ie.customError?.(N))??Yr(Ie.localeError?.(N))??"Invalid input",Be={};for(let Xe of Object.keys(N)){if(Xe==="inst"||Xe==="schema"||Xe==="continue"||Xe==="input"||Xe==="__proto__")continue;Be[Xe]=N[Xe]}if(Be.path??(Be.path=[]),Be.message=Ue,oe?.reportInput)Be.input=N.input;return Be}var op=/[\uD800-\uDBFF]/;function Un(N){let oe=N.length;if(!op.test(N))return oe;let Ie=oe;for(let Re=0;Re<oe-1;Re++)if((N.charCodeAt(Re)&64512)===55296&&(N.charCodeAt(Re+1)&64512)===56320)Ie--,Re++;return Ie}function Bn(N){if(Array.isArray(N))return"array";if(typeof N==="string")return"string";return"unknown"}function Js(N){let oe=typeof N;switch(oe){case"number":return Number.isNaN(N)?"nan":"number";case"object":{if(N===null)return"null";if(Array.isArray(N))return"array";let Ie=N;if(Ie&&Object.getPrototypeOf(Ie)!==Object.prototype&&"constructor"in Ie&&Ie.constructor)return Ie.constructor.name}}return oe}function Fr(...N){let[oe,Ie,Re]=N;if(typeof oe==="string")return{message:oe,code:"custom",input:Ie,inst:Re};return{...oe}}function Vs(N,oe){for(let Ie in oe){let Re=Object.getOwnPropertyDescriptor(oe,Ie);if(Re.get)Object.defineProperty(N,Ie,{...Re,enumerable:!1});else ip(N,Ie,Re.value)}}function Or(N,oe,Ie,Re=!0){return Object.defineProperty(N,oe,{configurable:!0,writable:!0,enumerable:Re,value:Ie}),Ie}function vn(N,oe,Ie){return Or(N,oe,Ie,!1)}function Jn(N,oe){for(let Ie in N){let Re=N[Ie];Object.defineProperty(oe,Ie,{configurable:!0,enumerable:!0,get(){return Or(this,Ie,Re(this))},set(De){Or(this,Ie,De)}})}return oe}function ip(N,oe,Ie){Object.defineProperty(N,oe,{configurable:!0,get(){return this==null?Ie:Or(this,oe,Ie.bind(this))},set(Re){Or(this,oe,Re)}})}function sp(N,oe){let Ie=Object.getPrototypeOf(N);return oe in Ie?void 0:Ie}var wo,Cr=!1,cp={configurable:!0,get(){Cr=!0;return}};function Tt(N,oe,Ie){let Re=Object.getPrototypeOf(N._zod);if(oe in Re&&wo!==N._zod){wo=void 0;return}wo=N._zod,Object.defineProperty(Re,oe,{configurable:!0,get(){Object.defineProperty(this,oe,cp);let De=Cr;Cr=!1;try{let Le=Ie(this);if(Cr)delete this[oe];else Object.defineProperty(this,oe,{configurable:!0,writable:!0,value:Le});return Cr=Cr||De,Le}catch(Le){throw delete this[oe],Cr=Cr||De,Le}},set(De){Object.defineProperty(this,oe,{configurable:!0,writable:!0,value:De})}})}function ap(N,oe,Ie,Re){let De=sp(N,oe);if(!De)return;Object.defineProperty(De,oe,{configurable:!0,get(){let Le={configurable:!0,writable:!0,enumerable:Re,value:void 0};return Object.defineProperty(this,oe,Le),Le.value=Ie(this),Object.defineProperty(this,oe,Le),Le.value},set(Le){Object.defineProperty(this,oe,{configurable:!0,writable:!0,enumerable:Re,value:Le})}})}var up="~constantCatch";function Ws(N){let oe=()=>N;return oe[up]=!0,oe}var Ks;var Oo={value:void 0,enumerable:!1},Hs="captureStackTrace"in Error?Error:null;function lp(N){let oe=Hs;if(oe){let Ie=oe.stackTraceLimit;if(typeof Ie==="number"){try{oe.stackTraceLimit=0}catch{return Hs=null,new N}try{return new N}finally{oe.stackTraceLimit=Ie}}}return new N}function ht(N,oe,Ie,Re){let De={};function Le(tt){this.def=tt,this.constr=et,this.traits=new Set}Le.prototype=De;let Ue=Ie,Be=Ue&&new WeakSet;function Xe(tt,ft){if(!tt._zod){Oo.value=new Le(ft);try{Object.defineProperty(tt,"_zod",Oo)}finally{Oo.value=void 0}}else if(tt._zod.traits.has(N))return;if(tt._zod.traits.add(N),oe(tt,ft),Be){let bt=Object.getPrototypeOf(tt),St=tt._zod.constr.prototype,Et=bt;while(Et&&Et!==St)Et=Object.getPrototypeOf(Et);let rr=Et??bt;if(!Be.has(rr))Be.add(rr),Vs(rr,Ue)}let gt=et.prototype;for(let bt in gt){if(!Object.prototype.hasOwnProperty.call(gt,bt))continue;if(!(bt in tt))tt[bt]=gt[bt].bind(tt)}}let Ye=Re?.Parent??Object;class Qe extends Ye{}Object.defineProperty(Qe,"name",{value:N});function et(tt){let ft=Re?.Parent?lp(Qe):this;Xe(ft,tt);let gt=ft._zod.deferred;if(gt){for(let St of gt)St();ft._zod.deferred=void 0}let bt=globalThis.__zod_globalConfig?.postProcessor;if(bt)bt(ft);return ft}return Object.defineProperty(et,"init",{value:Xe}),Object.defineProperty(et,Symbol.hasInstance,{value:(tt)=>{if(Re?.Parent&&tt instanceof Re.Parent)return!0;return tt?._zod?.traits?.has(N)}}),Object.defineProperty(et,"name",{value:N}),et}class Sr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class xn extends Error{constructor(N){super(`Encountered unidirectional transform during encode: ${N}`);this.name="ZodEncodeError"}}(Ks=globalThis).__zod_globalConfig??(Ks.__zod_globalConfig={});var cr=globalThis.__zod_globalConfig;function pr(N){if(N)Object.assign(cr,N);return cr}function fp(){let N=this._zod;return N.message??(N.message=JSON.stringify(N.def,gn,2)),N.message}function pp(N){this._zod.message=N}var dp={get:fp,set:pp,enumerable:!0,configurable:!0},Zo={value:void 0,enumerable:!1},qs=new WeakSet([Object.prototype,Error.prototype]),Gs=(N,oe)=>{N.name="$ZodError",Zo.value=oe,Object.defineProperty(N,"issues",Zo),Zo.value=void 0,Object.defineProperty(N,"message",dp);let Ie=Object.getPrototypeOf(N);if(!qs.has(Ie))qs.add(Ie),Object.defineProperty(Ie,"toString",{configurable:!0,enumerable:!1,get(){let Re=()=>this.message;return Object.defineProperty(this,"toString",{value:Re,configurable:!0,writable:!0}),Re},set(Re){Object.defineProperty(this,"toString",{value:Re,configurable:!0,writable:!0})}})},Xs=ht("$ZodError",Gs),gg=ht("$ZodError",Gs,void 0,{Parent:Error});function mp(N,oe,Ie){if(!Object.prototype.hasOwnProperty.call(N,oe))if(oe==="__proto__")Object.defineProperty(N,oe,{value:Ie(),writable:!0,enumerable:!0,configurable:!0});else N[oe]=Ie();return N[oe]}function Ys(N,oe=(Ie)=>Ie.message){let Ie={},Re=[];for(let De of N.issues)if(De.path.length>0)mp(Ie,De.path[0],()=>[]).push(oe(De));else Re.push(oe(De));return{formErrors:Re,fieldErrors:Ie}}function Qs(N,oe=(Ie)=>Ie.message){let Ie={_errors:[]},Re=(De,Le=[])=>{for(let Ue of De.issues)if(Ue.code==="invalid_union"&&Ue.errors.length)Ue.errors.map((Be)=>Re({issues:Be},[...Le,...Ue.path]));else if(Ue.code==="invalid_key")Re({issues:Ue.issues},[...Le,...Ue.path]);else if(Ue.code==="invalid_element")Re({issues:Ue.issues},[...Le,...Ue.path]);else{let Be=[...Le,...Ue.path];if(Be.length===0)Ie._errors.push(oe(Ue));else{let Xe=Ie,Ye=0;while(Ye<Be.length){let Qe=Be[Ye],et=Ye===Be.length-1;if(Qe==="_errors"){if(et)Xe._errors.push(oe(Ue));Ye++;continue}if(!Object.prototype.hasOwnProperty.call(Xe,Qe))Object.defineProperty(Xe,Qe,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let tt=Xe[Qe];if(et)tt._errors.push(oe(Ue));Xe=tt,Ye++}}}};return Re(N),Ie}function Vn(N,oe){return{callee:oe?.callee??N,Err:oe?.Err}}var Wn=(N)=>{let oe=(Ie,Re,De,Le)=>{let Ue=De?{...De,async:!1}:{async:!1},Be=Ie._zod.run({value:Re,issues:[]},Ue);if(Be instanceof Promise)throw new Sr;if(Be.issues.length){let Xe=new(Le?.Err??N)(Be.issues.map((Ye)=>zr(Ye,Ue,pr())));throw zo(Xe,Le?.callee??oe),Xe}return Be.value};return oe};var Kn=(N)=>{let oe=async(Ie,Re,De,Le)=>{let Ue=De?{...De,async:!0}:{async:!0},Be=Ie._zod.run({value:Re,issues:[]},Ue);if(Be instanceof Promise)Be=await Be;if(Be.issues.length){let Xe=new(Le?.Err??N)(Be.issues.map((Ye)=>zr(Ye,Ue,pr())));throw zo(Xe,Le?.callee??oe),Xe}return Be.value};return oe};var Hn=(N)=>(oe,Ie,Re)=>{let De=Re?{...Re,async:!1}:{async:!1},Le=oe._zod.run({value:Ie,issues:[]},De);if(Le instanceof Promise)throw new Sr;return Le.issues.length?ec(N,Le.issues,De):{success:!0,data:Le.value}};function ec(N,oe,Ie){let Re;return{success:!1,get error(){if(!Re)Re=new N(oe.map((De)=>zr(De,Ie,pr()))),oe=void 0,Ie=void 0;return Re},set error(De){Re=De,oe=void 0,Ie=void 0}}}var qn=(N)=>async(oe,Ie,Re)=>{let De=Re?{...Re,async:!0}:{async:!0},Le=oe._zod.run({value:Ie,issues:[]},De);if(Le instanceof Promise)Le=await Le;return Le.issues.length?ec(N,Le.issues,De):{success:!0,data:Le.value}};var hp=Symbol.for("zod.compile.invalid"),gp=Symbol.for("zod.compile.fallback"),Ao=(N,oe,Ie)=>{let Re=N._zod.bag.validator;if(Re!==void 0){if(Re(oe)!==hp)return!0;if(Re.definite===!0&&Ie===void 0)return!1}return yp(N,oe,Ie)};function yp(N,oe,Ie){let Re=Ie?{...Ie,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},De=N._zod.bag.fallbackRun,Le;if(De)Re[gp]=!0,Le=De({value:oe,issues:[]},Re);else Le=N._zod.run({value:oe,issues:[]},Re);if(Le instanceof Promise)throw new Sr;return Le.issues.length===0}var Io=async(N,oe,Ie)=>{let Re=Ie?{...Ie,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},De=N._zod.run({value:oe,issues:[]},Re);if(De instanceof Promise)De=await De;return De.issues.length===0},tc=(N)=>{let oe=Wn(N),Ie=(Re,De,Le,Ue)=>{let Be=Le?{...Le,direction:"backward"}:{direction:"backward"};return oe(Re,De,Be,Vn(Ie,Ue))};return Ie};var rc=(N)=>{let oe=Wn(N),Ie=(Re,De,Le,Ue)=>oe(Re,De,Le,Vn(Ie,Ue));return Ie};var nc=(N)=>{let oe=Kn(N),Ie=async(Re,De,Le,Ue)=>{let Be=Le?{...Le,direction:"backward"}:{direction:"backward"};return await oe(Re,De,Be,Vn(Ie,Ue))};return Ie};var oc=(N)=>{let oe=Kn(N),Ie=async(Re,De,Le,Ue)=>await oe(Re,De,Le,Vn(Ie,Ue));return Ie};var ic=(N)=>(oe,Ie,Re)=>{let De=Re?{...Re,direction:"backward"}:{direction:"backward"};return Hn(N)(oe,Ie,De)};var sc=(N)=>(oe,Ie,Re)=>Hn(N)(oe,Ie,Re);var cc=(N)=>async(oe,Ie,Re)=>{let De=Re?{...Re,direction:"backward"}:{direction:"backward"};return qn(N)(oe,Ie,De)};var ac=(N)=>async(oe,Ie,Re)=>qn(N)(oe,Ie,Re);var uc=/^[cC][0-9a-z]{6,}$/,lc=/^[0-9a-z]+$/,fc=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,pc=/^[0-9a-vA-V]{20}$/,dc=/^[A-Za-z0-9]{27}$/,mc=/^[a-zA-Z0-9_-]{21}$/;function hc(N){return new RegExp(`^[a-zA-Z0-9_-]{${N}}$`)}var gc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var yc=/^([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})$/,No=(N)=>{if(!N)return/^([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)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${N}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var _c=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var _p="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function vc(){return new RegExp(_p,"u")}var bc=/^(?:(?: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])$/,xc=/^(([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}|:))$/;var wc=/^((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])$/,$c=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Sc=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var kc=/^https?$/,Pc=/^\+[1-9]\d{6,14}$/;var Ec="(?:(?:\\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])))";function vp(N){return new RegExp(`^${N}$`)}var Oc=vp(Ec);function Co(N){return typeof N.precision==="number"?N.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":N.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${N.precision}}`:N.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Tc(N){return new RegExp(`^${Co(N)}$`)}function Zc(N){let oe=["Z"];if(N.offset)oe.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let Ie=`${Co({precision:N.precision,seconds:!0})}(?:${oe.join("|")})`,Re=N.local?`${Ie}|${Co({precision:N.precision})}`:Ie;return new RegExp(`^${Ec}T(?:${Re})$`)}var Ac=/^[\s\S]{0,}$/;var Ic=/^-?\d+n?$/,Ro=/^-?\d+$/,wn=/^-?\d+(?:\.\d+)?$/,Cc=/^(?:true|false)$/i,Nc=/^null$/i;var Rc=/^[^A-Z]*$/,Dc=/^[^a-z]*$/;var or=ht("$ZodCheck",(N,oe)=>{var Ie;N._zod??(N._zod={}),N._zod.def=oe,(Ie=N._zod).onattach??(Ie.onattach=[])});var Do=(N)=>{let oe=N.value;return!Zs(oe)&&oe.length!==void 0},Gn={number:"number",bigint:"bigint",object:"date"},Mo=ht("$ZodCheckLessThan",(N,oe)=>{or.init(N,oe);let Ie=Gn[typeof oe.value];N._zod.check=(Re)=>{if(oe.inclusive?Re.value<=oe.value:Re.value<oe.value)return;Re.issues.push({origin:Gn[typeof Re.value]??Ie,code:"too_big",maximum:typeof oe.value==="object"?oe.value.getTime():oe.value,input:Re.value,inclusive:oe.inclusive,inst:N,continue:!oe.abort})}}),Lo=ht("$ZodCheckGreaterThan",(N,oe)=>{or.init(N,oe);let Ie=Gn[typeof oe.value];N._zod.check=(Re)=>{if(oe.inclusive?Re.value>=oe.value:Re.value>oe.value)return;Re.issues.push({origin:Gn[typeof Re.value]??Ie,code:"too_small",minimum:typeof oe.value==="object"?oe.value.getTime():oe.value,input:Re.value,inclusive:oe.inclusive,inst:N,continue:!oe.abort})}}),Lc=ht("$ZodCheckMultipleOf",(N,oe)=>{or.init(N,oe),N._zod.check=(Ie)=>{if(typeof Ie.value!==typeof oe.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Ie.value==="bigint"?oe.value!==BigInt(0)&&Ie.value%oe.value===BigInt(0):As(Ie.value,oe.value)===0)return;Ie.issues.push({origin:typeof Ie.value,code:"not_multiple_of",divisor:oe.value,input:Ie.value,inst:N,continue:!oe.abort})}}),jc=ht("$ZodCheckNumberFormat",(N,oe)=>{or.init(N,oe),oe.format=oe.format||"float64";let Ie=oe.format?.includes("int"),Re=Ie?"int":"number",[De,Le]=Ln[oe.format];N._zod.check=(Ue)=>{let Be=Ue.value;if(Ie){if(!Number.isInteger(Be)){Ue.issues.push({expected:Re,format:oe.format,code:"invalid_type",continue:!1,input:Be,inst:N});return}if(!Number.isSafeInteger(Be)){if(Be>0)Ue.issues.push({input:Be,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:N,origin:Re,inclusive:!0,continue:!oe.abort});else Ue.issues.push({input:Be,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:N,origin:Re,inclusive:!0,continue:!oe.abort});return}}if(Be<De)Ue.issues.push({origin:"number",input:Be,code:"too_small",minimum:De,inclusive:!0,inst:N,continue:!oe.abort});if(Be>Le)Ue.issues.push({origin:"number",input:Be,code:"too_big",maximum:Le,inclusive:!0,inst:N,continue:!oe.abort})}});var Fc=ht("$ZodCheckMaxLength",(N,oe)=>{var Ie;or.init(N,oe),(Ie=N._zod.def).when??(Ie.when=Do),N._zod.check=(Re)=>{let De=Re.value,Le=De.length;if((typeof De==="string"&&Le>oe.maximum?Un(De):Le)<=oe.maximum)return;let Be=Bn(De);Re.issues.push({origin:Be,code:"too_big",maximum:oe.maximum,inclusive:!0,input:De,inst:N,continue:!oe.abort})}}),Uc=ht("$ZodCheckMinLength",(N,oe)=>{var Ie;or.init(N,oe),(Ie=N._zod.def).when??(Ie.when=Do),N._zod.check=(Re)=>{let De=Re.value,Le=De.length;if((typeof De==="string"&&Le>=oe.minimum&&Le<oe.minimum*2?Un(De):Le)>=oe.minimum)return;let Be=Bn(De);Re.issues.push({origin:Be,code:"too_small",minimum:oe.minimum,inclusive:!0,input:De,inst:N,continue:!oe.abort})}}),Bc=ht("$ZodCheckLengthEquals",(N,oe)=>{var Ie;or.init(N,oe),(Ie=N._zod.def).when??(Ie.when=Do),N._zod.check=(Re)=>{let De=Re.value,Le=De.length,Ue=typeof De==="string"&&Le>=oe.length&&Le<=oe.length*2?Un(De):Le;if(Ue===oe.length)return;let Be=Bn(De),Xe=Ue>oe.length;Re.issues.push({origin:Be,...Xe?{code:"too_big",maximum:oe.length}:{code:"too_small",minimum:oe.length},inclusive:!0,exact:!0,input:Re.value,inst:N,continue:!oe.abort})}}),zn=ht("$ZodCheckStringFormat",(N,oe)=>{var Ie,Re;if(or.init(N,oe),oe.pattern)(Ie=N._zod).check??(Ie.check=(De)=>{if(oe.pattern.lastIndex=0,oe.pattern.test(De.value))return;De.issues.push({origin:"string",code:"invalid_format",format:oe.format,input:De.value,...oe.pattern?{pattern:oe.pattern.toString()}:{},inst:N,continue:!oe.abort})});else(Re=N._zod).check??(Re.check=()=>{})}),Jc=ht("$ZodCheckRegex",(N,oe)=>{zn.init(N,oe),N._zod.check=(Ie)=>{if(oe.pattern.lastIndex=0,oe.pattern.test(Ie.value))return;Ie.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Ie.value,pattern:oe.pattern.toString(),inst:N,continue:!oe.abort})}}),Vc=ht("$ZodCheckLowerCase",(N,oe)=>{oe.pattern??(oe.pattern=Rc),zn.init(N,oe)}),Wc=ht("$ZodCheckUpperCase",(N,oe)=>{oe.pattern??(oe.pattern=Dc),zn.init(N,oe)}),Kc=ht("$ZodCheckIncludes",(N,oe)=>{or.init(N,oe);let Ie=Nr(oe.includes),Re=new RegExp(typeof oe.position==="number"?`^.{${oe.position},}${Ie}`:Ie);oe.pattern=Re,N._zod.check=(De)=>{if(De.value.includes(oe.includes,oe.position))return;De.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:oe.includes,input:De.value,inst:N,continue:!oe.abort})}}),Hc=ht("$ZodCheckStartsWith",(N,oe)=>{or.init(N,oe);let Ie=new RegExp(`^${Nr(oe.prefix)}.*`);oe.pattern??(oe.pattern=Ie),N._zod.check=(Re)=>{if(Re.value.startsWith(oe.prefix))return;Re.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:oe.prefix,input:Re.value,inst:N,continue:!oe.abort})}}),qc=ht("$ZodCheckEndsWith",(N,oe)=>{or.init(N,oe);let Ie=new RegExp(`.*${Nr(oe.suffix)}$`);oe.pattern??(oe.pattern=Ie),N._zod.check=(Re)=>{if(Re.value.endsWith(oe.suffix))return;Re.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:oe.suffix,input:Re.value,inst:N,continue:!oe.abort})}});function Mc(N,oe,Ie){if(N.issues.length)oe.issues.push(...yr(Ie,N.issues))}var Gc=ht("$ZodCheckProperties",(N,oe)=>{or.init(N,oe),vn(N,Symbol.iterator,function*(){yield N});let Ie;N._zod.check=(Re)=>{if(Re.value==null){Re.issues.push({expected:"object",code:"invalid_type",input:Re.value,inst:N});return}Ie??(Ie=Reflect.ownKeys(oe.shape).map((Ue)=>[Ue,oe.shape[Ue]]));let De=Re.value,Le;for(let[Ue,Be]of Ie){let Xe=Be._zod.run({value:De[Ue],issues:[]},{});if(Xe instanceof Promise)Le??(Le=[]),Le.push(Xe.then((Ye)=>Mc(Ye,Re,Ue)));else Mc(Xe,Re,Ue)}if(Le)return Promise.all(Le).then(()=>{return});return}});var Xc=ht("$ZodCheckOverwrite",(N,oe)=>{or.init(N,oe),N._zod.check=(Ie)=>{Ie.value=oe.tx(Ie.value)}});class jo{constructor(N=[],oe={}){this.content=[],this.indent=0,this.args=N,this.closed=oe}indented(N){this.indent+=1;try{N(this)}finally{this.indent-=1}}write(N){if(typeof N==="function"){N(this,{execution:"sync"}),N(this,{execution:"async"});return}let Ie=N.split(`
|
|
1
|
+
var Cf=Symbol.for("vercel.ai.error"),m=class N extends Error{constructor({name:oe,message:Ie,cause:Re}){super(Ie);this[Cf]=!0,this.name=oe,this.cause=Re}static isInstance(oe){return N.hasMarker(oe,"vercel.ai.error")}static hasMarker(oe,Ie){let Re=Symbol.for(Ie);return oe!=null&&typeof oe==="object"&&Re in oe&&typeof oe[Re]==="boolean"&&oe[Re]===!0}},rs="AI_DecisionUnsupportedQuestionTypeError",ns=`vercel.ai.error.${rs}`,Nf=Symbol.for(ns),Gt=class extends m{constructor({questionId:N,questionType:oe,provider:Ie,modelId:Re,message:De=`Question "${N}" has type "${oe}", which is not supported by provider "${Ie}" and model "${Re}".`}){super({name:rs,message:De});this[Nf]=!0,this.questionId=N,this.questionType=oe,this.provider=Ie,this.modelId=Re}static isInstance(N){return m.hasMarker(N,ns)}},os="AI_APICallError",is=`vercel.ai.error.${os}`,Rf=Symbol.for(is),w=class extends m{constructor({message:N,url:oe,requestBodyValues:Ie,statusCode:Re,responseHeaders:De,responseBody:Le,cause:Ue,isRetryable:Be=Re!=null&&(Re===408||Re===409||Re===429||Re>=500),data:Xe}){super({name:os,message:N,cause:Ue});this[Rf]=!0,this.url=oe,this.requestBodyValues=Ie,this.statusCode=Re,this.responseHeaders=De,this.responseBody=Le,this.isRetryable=Be,this.data=Xe}static isInstance(N){return m.hasMarker(N,is)}},ss="AI_EmptyResponseBodyError",cs=`vercel.ai.error.${ss}`,Df=Symbol.for(cs),Dn=class extends m{constructor({message:N="Empty response body"}={}){super({name:ss,message:N});this[Df]=!0}static isInstance(N){return m.hasMarker(N,cs)}},Mf="AI_DecisionRefusalError",Xh=`vercel.ai.error.${Mf}`;function A(N){if(N==null)return"unknown error";if(typeof N==="string")return N;if(N instanceof Error)return N.toString();return JSON.stringify(N)}var as="AI_InvalidArgumentError",us=`vercel.ai.error.${as}`,Lf=Symbol.for(us),b=class extends m{constructor({message:N,cause:oe,argument:Ie}){super({name:as,message:N,cause:oe});this[Lf]=!0,this.argument=Ie}static isInstance(N){return m.hasMarker(N,us)}},ls="AI_InvalidPromptError",fs=`vercel.ai.error.${ls}`,jf=Symbol.for(fs),ye=class extends m{constructor({prompt:N,message:oe,cause:Ie}){super({name:ls,message:`Invalid prompt: ${oe}`,cause:Ie});this[jf]=!0,this.prompt=N}static isInstance(N){return m.hasMarker(N,fs)}},ps="AI_InvalidResponseDataError",ds=`vercel.ai.error.${ps}`,Ff=Symbol.for(ds),P=class extends m{constructor({data:N,message:oe=`Invalid response data: ${JSON.stringify(N)}.`}){super({name:ps,message:oe});this[Ff]=!0,this.data=N}static isInstance(N){return m.hasMarker(N,ds)}},ms="AI_JSONParseError",hs=`vercel.ai.error.${ms}`,Uf=Symbol.for(hs),Ee=class extends m{constructor({text:N,cause:oe}){super({name:ms,message:`JSON parsing failed: Text: ${N}.
|
|
2
|
+
Error message: ${A(oe)}`,cause:oe});this[Uf]=!0,this.text=N}static isInstance(N){return m.hasMarker(N,hs)}},gs="AI_LoadAPIKeyError",ys=`vercel.ai.error.${gs}`,Bf=Symbol.for(ys),qr=class extends m{constructor({message:N}){super({name:gs,message:N});this[Bf]=!0}static isInstance(N){return m.hasMarker(N,ys)}},Jf="AI_LoadSettingError",Yh=`vercel.ai.error.${Jf}`;var Vf="AI_NoContentGeneratedError",Qh=`vercel.ai.error.${Vf}`;var _s="AI_NoSuchModelError",vs=`vercel.ai.error.${_s}`,Wf=Symbol.for(vs),Ge=class extends m{constructor({errorName:N=_s,modelId:oe,modelType:Ie,message:Re=`No such ${Ie}: ${oe}`}){super({name:N,message:Re});this[Wf]=!0,this.modelId=oe,this.modelType=Ie}static isInstance(N){return m.hasMarker(N,vs)}},bs="AI_NoSuchProviderReferenceError",xs=`vercel.ai.error.${bs}`,Kf=Symbol.for(xs),ws=class extends m{constructor({provider:N,reference:oe,message:Ie=`No provider reference found for provider '${N}'. Available providers: ${Object.keys(oe).join(", ")}`}){super({name:bs,message:Ie});this[Kf]=!0,this.provider=N,this.reference=oe}static isInstance(N){return m.hasMarker(N,xs)}},$s="AI_TooManyEmbeddingValuesForCallError",zs=`vercel.ai.error.${$s}`,Hf=Symbol.for(zs),me=class extends m{constructor(N){super({name:$s,message:`Too many values for a single embedding call. The ${N.provider} model "${N.modelId}" can only embed up to ${N.maxEmbeddingsPerCall} values per call, but ${N.values.length} values were provided.`});this[Hf]=!0,this.provider=N.provider,this.modelId=N.modelId,this.maxEmbeddingsPerCall=N.maxEmbeddingsPerCall,this.values=N.values}static isInstance(N){return m.hasMarker(N,zs)}},Ss="AI_TypeValidationError",ks=`vercel.ai.error.${Ss}`,qf=Symbol.for(ks),be=class N extends m{constructor({value:oe,cause:Ie,context:Re}){let De="Type validation failed";if(Re?.field)De+=` for ${Re.field}`;if(Re?.entityName||Re?.entityId){De+=" (";let Le=[];if(Re.entityName)Le.push(Re.entityName);if(Re.entityId)Le.push(`id: "${Re.entityId}"`);De+=Le.join(", "),De+=")"}super({name:Ss,message:`${De}: Value: ${JSON.stringify(oe)}.
|
|
3
|
+
Error message: ${A(Ie)}`,cause:Ie});this[qf]=!0,this.value=oe,this.context=Re}static isInstance(oe){return m.hasMarker(oe,ks)}static wrap({value:oe,cause:Ie,context:Re}){if(N.isInstance(Ie)&&Ie.value===oe&&Ie.context?.field===Re?.field&&Ie.context?.entityName===Re?.entityName&&Ie.context?.entityId===Re?.entityId)return Ie;return new N({value:oe,cause:Ie,context:Re})}},Ps="AI_UnsupportedFunctionalityError",Es=`vercel.ai.error.${Ps}`,Gf=Symbol.for(Es),u=class extends m{constructor({functionality:N,message:oe=`'${N}' functionality not supported.`}){super({name:Ps,message:oe});this[Gf]=!0,this.functionality=N}static isInstance(N){return m.hasMarker(N,Es)}};function xo(N){if(N===null||typeof N==="string"||typeof N==="number"||typeof N==="boolean")return!0;if(Array.isArray(N))return N.every(xo);if(typeof N==="object")return Object.entries(N).every(([oe,Ie])=>typeof oe==="string"&&(Ie===void 0||xo(Ie)));return!1}function nt(N){return N!=null&&typeof N==="object"&&Object.entries(N).every(([oe,Ie])=>typeof oe==="string"&&(Ie===void 0||xo(Ie)))}function Xr(N){let oe=Object.values(N).filter((Re)=>typeof Re==="number");return Object.entries(N).filter(([Re,De])=>oe.indexOf(+Re)===-1).map(([Re,De])=>De)}function $o(N,oe="|"){return N.map((Ie)=>ko(Ie)).join(oe)}function Yr(N,oe){if(typeof oe==="bigint")return oe.toString();return oe}class Ts{constructor(N){this._getter=N,this._value=void 0}get value(){let N=this._getter;if(N!==void 0)this._value=N(),this._getter=void 0;return this._value}}function Qr(N){return new Ts(N)}function Zs(N){return N===null||N===void 0}function Mn(N){let oe=N.startsWith("^")?1:0,Ie=N.endsWith("$")?N.length-1:N.length;return N.slice(oe,Ie)}function As(N,oe){let Ie=N/oe,Re=Math.round(Ie),De=4*Number.EPSILON*Math.max(Math.abs(Ie),1);if(Math.abs(Ie-Re)<De)return 0;return Ie-Re}var Os=Symbol("evaluating");function Is(N,oe,Ie){let Re=void 0;Object.defineProperty(N,oe,{get(){if(Re===Os)return;if(Re===void 0)Re=Os,Re=Ie();return Re},set(De){Object.defineProperty(N,oe,{value:De})},configurable:!0})}function ar(N,oe,Ie){Object.defineProperty(N,oe,{value:Ie,writable:!0,enumerable:!0,configurable:!0})}function yn(N){let oe=Object.getOwnPropertyDescriptor(N,"shape");return oe?.get?oe.get.raw:oe?.value}function kr(N){return yn(N._zod.def)??N._zod.def.shape}function Cs(N,oe,Ie){Object.defineProperty(N,oe,{get(){let Re=Ie();return ar(this,oe,Re),Re},enumerable:!0,configurable:!0})}function Ns(N,oe,Ie){if(oe in N)ar(N,oe,Ie);else N[oe]=Ie}function Dr(N,oe,Ie,Re){let De=kr(oe);for(let Le of Ie){let Ue=Object.getOwnPropertyDescriptor(De,Le);if(!Ue.enumerable)continue;if(Ue.get)Cs(N,Le,()=>{let Be=oe._zod.def.shape[Le];return Re?Re(Be,Le):Be});else Ns(N,Le,Re?Re(Ue.value,Le):Ue.value)}}function Xf(N,oe){for(let Ie of Reflect.ownKeys(oe)){let Re=Object.getOwnPropertyDescriptor(oe,Ie);if(!Re.enumerable)continue;if(Re.get)Cs(N,Ie,()=>oe[Ie]);else Ns(N,Ie,Re.value)}}function ur(...N){let oe={};for(let Ie of N){let Re=Object.getOwnPropertyDescriptors(Ie);Object.assign(oe,Re)}return Object.defineProperties({},oe)}function Rs(N){return JSON.stringify(N)}function Ds(N){return N.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var zo="captureStackTrace"in Error?Error.captureStackTrace:(...N)=>{};function Br(N){return typeof N==="object"&&N!==null&&!Array.isArray(N)}var Ms=Qr(()=>{if(ir.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(N){return!1}});function Mr(N){if(Br(N)===!1)return!1;let oe=N.constructor;if(oe===void 0)return!0;if(typeof oe!=="function")return!0;let Ie=oe.prototype;if(Br(Ie)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Ie,"isPrototypeOf")===!1)return!1;return!0}function So(N){if(Mr(N))return{...N};if(Array.isArray(N))return[...N];if(N instanceof Map)return new Map(N);if(N instanceof Set)return new Set(N);return N}var Ls=new Set(["string","number","symbol"]);function Ir(N){return N.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xr(N,oe,Ie){let Re=new N._zod.constr(oe??N._zod.def);if(!oe||Ie?.parent)Re._zod.parent=N;return Re}function zt(N){let oe=N;if(!oe)return{};if(typeof oe==="string")return{error:()=>oe};if(oe?.message!==void 0){if(oe?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");oe.error=oe.message}if(delete oe.message,typeof oe.error==="string")return{...oe,error:()=>oe.error};return oe}function ko(N){if(typeof N==="bigint")return N.toString()+"n";if(typeof N==="string")return`"${N}"`;return`${N}`}function js(N){return Object.keys(N).filter((oe)=>N[oe]._zod.optin!==void 0&&N[oe]._zod.optout==="optional")}var Ln=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Po={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Yf(N,oe){let Ie=N._zod.def,Re=Ie.checks;if(Re&&Re.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let Le={};return Dr(Le,N,jn(N,oe)),xr(N,ur(Ie,{shape:Le,checks:[]}))}function jn(N,oe){let Ie=kr(N),Re=[];for(let De of Reflect.ownKeys(oe)){if(!Object.getOwnPropertyDescriptor(Ie,De)?.enumerable)throw Error(`Unrecognized key: "${String(De)}"`);if(oe[De])Re.push(De)}return Re}function Qf(N,oe){let Ie=N._zod.def,Re=Ie.checks;if(Re&&Re.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let Le=new Set(jn(N,oe)),Ue={};return Dr(Ue,N,Reflect.ownKeys(kr(N)).filter((Be)=>!Le.has(Be))),xr(N,ur(Ie,{shape:Ue,checks:[]}))}function ep(N,oe){if(!Mr(oe))throw Error("Invalid input to extend: expected a plain object");let Ie=N._zod.def.checks;if(Ie&&Ie.length>0){let De=kr(N);for(let Le of Reflect.ownKeys(oe))if(Object.getOwnPropertyDescriptor(De,Le)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return xr(N,ur(N._zod.def,{shape:Fs(N,oe)}))}function Fs(N,oe){let Ie={};return Dr(Ie,N,Reflect.ownKeys(kr(N))),Xf(Ie,oe),Ie}function tp(N,oe){if(!Mr(oe))throw Error("Invalid input to safeExtend: expected a plain object");return xr(N,ur(N._zod.def,{shape:Fs(N,oe)}))}function rp(N,oe){if(!oe?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(N._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let Ie={};Dr(Ie,N,Reflect.ownKeys(kr(N))),Dr(Ie,oe,Reflect.ownKeys(kr(oe)));let Re=ur(N._zod.def,{shape:Ie,get catchall(){return oe._zod.def.catchall},checks:oe._zod.def.checks??[]});return xr(N,Re)}function Us(N,oe,Ie,Re="partial"){let Le=oe._zod.def.checks;if(Le&&Le.length>0)throw Error(`.${Re}() cannot be used on object schemas containing refinements`);let Be=Ie?new Set(jn(oe,Ie)):void 0,Xe={};return Dr(Xe,oe,Reflect.ownKeys(kr(oe)),N&&((Ye,Qe)=>Be&&!Be.has(Qe)?Ye:new N({type:"optional",innerType:Ye}))),xr(oe,ur(oe._zod.def,{shape:Xe,checks:[]}))}function np(N,oe,Ie){let Re=Ie?new Set(jn(oe,Ie)):void 0,De={};return Dr(De,oe,Reflect.ownKeys(kr(oe)),(Le,Ue)=>Re&&!Re.has(Ue)?Le:new N({type:"nonoptional",innerType:Le})),xr(oe,ur(oe._zod.def,{shape:De}))}function mr(N,oe=0){if(N.aborted===!0)return!0;for(let Ie=oe;Ie<N.issues.length;Ie++)if(N.issues[Ie]?.continue!==!0)return!0;return!1}function Bs(N,oe=0){if(N.aborted===!0)return!0;for(let Ie=oe;Ie<N.issues.length;Ie++)if(N.issues[Ie]?.continue===!1)return!0;return!1}function hr(N,oe){return oe.map((Ie)=>{var Re;return(Re=Ie).path??(Re.path=[]),Ie.path.unshift(N),Ie})}function Gr(N){return typeof N==="string"?N:N?.message}function Eo(N){let oe=[];for(let Ie of N??[]){let Re=Ie._zod.def;if(!/_(length|size)$|_equals$/.test(Re.check))break;let De=Re.maximum??Re.length??Re.size;if(De>=0)oe.push([De,Ie])}return oe}function Fn(N,oe,Ie){var Re;for(let De=oe;De<N.length;De++)(Re=N[De]).schema??(Re.schema=Ie)}function wr(N,oe,Ie){var Re;let De=N.inst?._zod?.traits;if(De?.has("$ZodType"))if(De.has("$ZodCheck"))(Re=N).schema??(Re.schema=N.inst);else N.schema=N.inst;let Le=N.schema!==N.inst?N.schema?._zod.def?.error:void 0,Ue=N.message?N.message:Gr(N.inst?._zod.def?.error?.(N))??Gr(Le?.(N))??Gr(oe?.error?.(N))??Gr(Ie.customError?.(N))??Gr(Ie.localeError?.(N))??"Invalid input",Be={};for(let Xe of Object.keys(N)){if(Xe==="inst"||Xe==="schema"||Xe==="continue"||Xe==="input"||Xe==="__proto__")continue;Be[Xe]=N[Xe]}if(Be.path??(Be.path=[]),Be.message=Ue,oe?.reportInput)Be.input=N.input;return Be}var op=/[\uD800-\uDBFF]/;function Un(N){let oe=N.length;if(!op.test(N))return oe;let Ie=oe;for(let Re=0;Re<oe-1;Re++)if((N.charCodeAt(Re)&64512)===55296&&(N.charCodeAt(Re+1)&64512)===56320)Ie--,Re++;return Ie}function Bn(N){if(Array.isArray(N))return"array";if(typeof N==="string")return"string";return"unknown"}function Js(N){let oe=typeof N;switch(oe){case"number":return Number.isNaN(N)?"nan":"number";case"object":{if(N===null)return"null";if(Array.isArray(N))return"array";let Ie=N;if(Ie&&Object.getPrototypeOf(Ie)!==Object.prototype&&"constructor"in Ie&&Ie.constructor)return Ie.constructor.name}}return oe}function Lr(...N){let[oe,Ie,Re]=N;if(typeof oe==="string")return{message:oe,code:"custom",input:Ie,inst:Re};return{...oe}}function Vs(N,oe){for(let Ie in oe){let Re=Object.getOwnPropertyDescriptor(oe,Ie);if(Re.get)Object.defineProperty(N,Ie,{...Re,enumerable:!1});else ip(N,Ie,Re.value)}}function Pr(N,oe,Ie,Re=!0){return Object.defineProperty(N,oe,{configurable:!0,writable:!0,enumerable:Re,value:Ie}),Ie}function bn(N,oe,Ie){return Pr(N,oe,Ie,!1)}function Jn(N,oe){for(let Ie in N){let Re=N[Ie];Object.defineProperty(oe,Ie,{configurable:!0,enumerable:!0,get(){return Pr(this,Ie,Re(this))},set(De){Pr(this,Ie,De)}})}return oe}function ip(N,oe,Ie){Object.defineProperty(N,oe,{configurable:!0,get(){return this==null?Ie:Pr(this,oe,Ie.bind(this))},set(Re){Pr(this,oe,Re)}})}function sp(N,oe){let Ie=Object.getPrototypeOf(N);return oe in Ie?void 0:Ie}var wo,Ar=!1,cp={configurable:!0,get(){Ar=!0;return}};function Tt(N,oe,Ie){let Re=Object.getPrototypeOf(N._zod);if(oe in Re&&wo!==N._zod){wo=void 0;return}wo=N._zod,Object.defineProperty(Re,oe,{configurable:!0,get(){Object.defineProperty(this,oe,cp);let De=Ar;Ar=!1;try{let Le=Ie(this);if(Ar)delete this[oe];else Object.defineProperty(this,oe,{configurable:!0,writable:!0,value:Le});return Ar=Ar||De,Le}catch(Le){throw delete this[oe],Ar=Ar||De,Le}},set(De){Object.defineProperty(this,oe,{configurable:!0,writable:!0,value:De})}})}function ap(N,oe,Ie,Re){let De=sp(N,oe);if(!De)return;Object.defineProperty(De,oe,{configurable:!0,get(){let Le={configurable:!0,writable:!0,enumerable:Re,value:void 0};return Object.defineProperty(this,oe,Le),Le.value=Ie(this),Object.defineProperty(this,oe,Le),Le.value},set(Le){Object.defineProperty(this,oe,{configurable:!0,writable:!0,enumerable:Re,value:Le})}})}var up="~constantCatch";function Ws(N){let oe=()=>N;return oe[up]=!0,oe}var Ks;var Oo={value:void 0,enumerable:!1},Hs="captureStackTrace"in Error?Error:null;function lp(N){let oe=Hs;if(oe){let Ie=oe.stackTraceLimit;if(typeof Ie==="number"){try{oe.stackTraceLimit=0}catch{return Hs=null,new N}try{return new N}finally{oe.stackTraceLimit=Ie}}}return new N}function ht(N,oe,Ie,Re){let De={};function Le(tt){this.def=tt,this.constr=et,this.traits=new Set}Le.prototype=De;let Ue=Ie,Be=Ue&&new WeakSet;function Xe(tt,ft){if(!tt._zod){Oo.value=new Le(ft);try{Object.defineProperty(tt,"_zod",Oo)}finally{Oo.value=void 0}}else if(tt._zod.traits.has(N))return;if(tt._zod.traits.add(N),oe(tt,ft),Be){let bt=Object.getPrototypeOf(tt),St=tt._zod.constr.prototype,Et=bt;while(Et&&Et!==St)Et=Object.getPrototypeOf(Et);let er=Et??bt;if(!Be.has(er))Be.add(er),Vs(er,Ue)}let gt=et.prototype;for(let bt in gt){if(!Object.prototype.hasOwnProperty.call(gt,bt))continue;if(!(bt in tt))tt[bt]=gt[bt].bind(tt)}}let Ye=Re?.Parent??Object;class Qe extends Ye{}Object.defineProperty(Qe,"name",{value:N});function et(tt){let ft=Re?.Parent?lp(Qe):this;Xe(ft,tt);let gt=ft._zod.deferred;if(gt){for(let St of gt)St();ft._zod.deferred=void 0}let bt=globalThis.__zod_globalConfig?.postProcessor;if(bt)bt(ft);return ft}return Object.defineProperty(et,"init",{value:Xe}),Object.defineProperty(et,Symbol.hasInstance,{value:(tt)=>{if(Re?.Parent&&tt instanceof Re.Parent)return!0;return tt?._zod?.traits?.has(N)}}),Object.defineProperty(et,"name",{value:N}),et}class $r extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class xn extends Error{constructor(N){super(`Encountered unidirectional transform during encode: ${N}`);this.name="ZodEncodeError"}}(Ks=globalThis).__zod_globalConfig??(Ks.__zod_globalConfig={});var ir=globalThis.__zod_globalConfig;function lr(N){if(N)Object.assign(ir,N);return ir}function fp(){let N=this._zod;return N.message??(N.message=JSON.stringify(N.def,Yr,2)),N.message}function pp(N){this._zod.message=N}var dp={get:fp,set:pp,enumerable:!0,configurable:!0},Zo={value:void 0,enumerable:!1},qs=new WeakSet([Object.prototype,Error.prototype]),Gs=(N,oe)=>{N.name="$ZodError",Zo.value=oe,Object.defineProperty(N,"issues",Zo),Zo.value=void 0,Object.defineProperty(N,"message",dp);let Ie=Object.getPrototypeOf(N);if(!qs.has(Ie))qs.add(Ie),Object.defineProperty(Ie,"toString",{configurable:!0,enumerable:!1,get(){let Re=()=>this.message;return Object.defineProperty(this,"toString",{value:Re,configurable:!0,writable:!0}),Re},set(Re){Object.defineProperty(this,"toString",{value:Re,configurable:!0,writable:!0})}})},Xs=ht("$ZodError",Gs),gg=ht("$ZodError",Gs,void 0,{Parent:Error});function mp(N,oe,Ie){if(!Object.prototype.hasOwnProperty.call(N,oe))if(oe==="__proto__")Object.defineProperty(N,oe,{value:Ie(),writable:!0,enumerable:!0,configurable:!0});else N[oe]=Ie();return N[oe]}function Ys(N,oe=(Ie)=>Ie.message){let Ie={},Re=[];for(let De of N.issues)if(De.path.length>0)mp(Ie,De.path[0],()=>[]).push(oe(De));else Re.push(oe(De));return{formErrors:Re,fieldErrors:Ie}}function Qs(N,oe=(Ie)=>Ie.message){let Ie={_errors:[]},Re=(De,Le=[])=>{for(let Ue of De.issues)if(Ue.code==="invalid_union"&&Ue.errors.length)Ue.errors.map((Be)=>Re({issues:Be},[...Le,...Ue.path]));else if(Ue.code==="invalid_key")Re({issues:Ue.issues},[...Le,...Ue.path]);else if(Ue.code==="invalid_element")Re({issues:Ue.issues},[...Le,...Ue.path]);else{let Be=[...Le,...Ue.path];if(Be.length===0)Ie._errors.push(oe(Ue));else{let Xe=Ie,Ye=0;while(Ye<Be.length){let Qe=Be[Ye],et=Ye===Be.length-1;if(Qe==="_errors"){if(et)Xe._errors.push(oe(Ue));Ye++;continue}if(!Object.prototype.hasOwnProperty.call(Xe,Qe))Object.defineProperty(Xe,Qe,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let tt=Xe[Qe];if(et)tt._errors.push(oe(Ue));Xe=tt,Ye++}}}};return Re(N),Ie}function Vn(N,oe){return{callee:oe?.callee??N,Err:oe?.Err}}var Wn=(N)=>{let oe=(Ie,Re,De,Le)=>{let Ue=De?{...De,async:!1}:{async:!1},Be=Ie._zod.run({value:Re,issues:[]},Ue);if(Be instanceof Promise)throw new $r;if(Be.issues.length){let Xe=new(Le?.Err??N)(Be.issues.map((Ye)=>wr(Ye,Ue,lr())));throw zo(Xe,Le?.callee??oe),Xe}return Be.value};return oe};var Kn=(N)=>{let oe=async(Ie,Re,De,Le)=>{let Ue=De?{...De,async:!0}:{async:!0},Be=Ie._zod.run({value:Re,issues:[]},Ue);if(Be instanceof Promise)Be=await Be;if(Be.issues.length){let Xe=new(Le?.Err??N)(Be.issues.map((Ye)=>wr(Ye,Ue,lr())));throw zo(Xe,Le?.callee??oe),Xe}return Be.value};return oe};var Hn=(N)=>(oe,Ie,Re)=>{let De=Re?{...Re,async:!1}:{async:!1},Le=oe._zod.run({value:Ie,issues:[]},De);if(Le instanceof Promise)throw new $r;return Le.issues.length?ec(N,Le.issues,De):{success:!0,data:Le.value}};function ec(N,oe,Ie){let Re;return{success:!1,get error(){if(!Re)Re=new N(oe.map((De)=>wr(De,Ie,lr()))),oe=void 0,Ie=void 0;return Re},set error(De){Re=De,oe=void 0,Ie=void 0}}}var qn=(N)=>async(oe,Ie,Re)=>{let De=Re?{...Re,async:!0}:{async:!0},Le=oe._zod.run({value:Ie,issues:[]},De);if(Le instanceof Promise)Le=await Le;return Le.issues.length?ec(N,Le.issues,De):{success:!0,data:Le.value}};var hp=Symbol.for("zod.compile.invalid"),gp=Symbol.for("zod.compile.fallback"),Ao=(N,oe,Ie)=>{let Re=N._zod.bag.validator;if(Re!==void 0){if(Re(oe)!==hp)return!0;if(Re.definite===!0&&Ie===void 0)return!1}return yp(N,oe,Ie)};function yp(N,oe,Ie){let Re=Ie?{...Ie,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},De=N._zod.bag.fallbackRun,Le;if(De)Re[gp]=!0,Le=De({value:oe,issues:[]},Re);else Le=N._zod.run({value:oe,issues:[]},Re);if(Le instanceof Promise)throw new $r;return Le.issues.length===0}var Io=async(N,oe,Ie)=>{let Re=Ie?{...Ie,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},De=N._zod.run({value:oe,issues:[]},Re);if(De instanceof Promise)De=await De;return De.issues.length===0},tc=(N)=>{let oe=Wn(N),Ie=(Re,De,Le,Ue)=>{let Be=Le?{...Le,direction:"backward"}:{direction:"backward"};return oe(Re,De,Be,Vn(Ie,Ue))};return Ie};var rc=(N)=>{let oe=Wn(N),Ie=(Re,De,Le,Ue)=>oe(Re,De,Le,Vn(Ie,Ue));return Ie};var nc=(N)=>{let oe=Kn(N),Ie=async(Re,De,Le,Ue)=>{let Be=Le?{...Le,direction:"backward"}:{direction:"backward"};return await oe(Re,De,Be,Vn(Ie,Ue))};return Ie};var oc=(N)=>{let oe=Kn(N),Ie=async(Re,De,Le,Ue)=>await oe(Re,De,Le,Vn(Ie,Ue));return Ie};var ic=(N)=>(oe,Ie,Re)=>{let De=Re?{...Re,direction:"backward"}:{direction:"backward"};return Hn(N)(oe,Ie,De)};var sc=(N)=>(oe,Ie,Re)=>Hn(N)(oe,Ie,Re);var cc=(N)=>async(oe,Ie,Re)=>{let De=Re?{...Re,direction:"backward"}:{direction:"backward"};return qn(N)(oe,Ie,De)};var ac=(N)=>async(oe,Ie,Re)=>qn(N)(oe,Ie,Re);var uc=/^[cC][0-9a-z]{6,}$/,lc=/^[0-9a-z]+$/,fc=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,pc=/^[0-9a-vA-V]{20}$/,dc=/^[A-Za-z0-9]{27}$/,mc=/^[a-zA-Z0-9_-]{21}$/;function hc(N){return new RegExp(`^[a-zA-Z0-9_-]{${N}}$`)}var gc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var yc=/^([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})$/,No=(N)=>{if(!N)return/^([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)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${N}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var _c=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var _p="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function vc(){return new RegExp(_p,"u")}var bc=/^(?:(?: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])$/,xc=/^(([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}|:))$/;var wc=/^((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])$/,$c=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Sc=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var kc=/^https?$/,Pc=/^\+[1-9]\d{6,14}$/;var Ec="(?:(?:\\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])))";function vp(N){return new RegExp(`^${N}$`)}var Oc=vp(Ec);function Co(N){return typeof N.precision==="number"?N.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":N.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${N.precision}}`:N.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Tc(N){return new RegExp(`^${Co(N)}$`)}function Zc(N){let oe=["Z"];if(N.offset)oe.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let Ie=`${Co({precision:N.precision,seconds:!0})}(?:${oe.join("|")})`,Re=N.local?`${Ie}|${Co({precision:N.precision})}`:Ie;return new RegExp(`^${Ec}T(?:${Re})$`)}var Ac=/^[\s\S]{0,}$/;var Ic=/^-?\d+n?$/,Ro=/^-?\d+$/,wn=/^-?\d+(?:\.\d+)?$/,Cc=/^(?:true|false)$/i,Nc=/^null$/i;var Rc=/^[^A-Z]*$/,Dc=/^[^a-z]*$/;var rr=ht("$ZodCheck",(N,oe)=>{var Ie;N._zod??(N._zod={}),N._zod.def=oe,(Ie=N._zod).onattach??(Ie.onattach=[])});var Do=(N)=>{let oe=N.value;return!Zs(oe)&&oe.length!==void 0},Gn={number:"number",bigint:"bigint",object:"date"},Mo=ht("$ZodCheckLessThan",(N,oe)=>{rr.init(N,oe);let Ie=Gn[typeof oe.value];N._zod.check=(Re)=>{if(oe.inclusive?Re.value<=oe.value:Re.value<oe.value)return;Re.issues.push({origin:Gn[typeof Re.value]??Ie,code:"too_big",maximum:typeof oe.value==="object"?oe.value.getTime():oe.value,input:Re.value,inclusive:oe.inclusive,inst:N,continue:!oe.abort})}}),Lo=ht("$ZodCheckGreaterThan",(N,oe)=>{rr.init(N,oe);let Ie=Gn[typeof oe.value];N._zod.check=(Re)=>{if(oe.inclusive?Re.value>=oe.value:Re.value>oe.value)return;Re.issues.push({origin:Gn[typeof Re.value]??Ie,code:"too_small",minimum:typeof oe.value==="object"?oe.value.getTime():oe.value,input:Re.value,inclusive:oe.inclusive,inst:N,continue:!oe.abort})}}),Lc=ht("$ZodCheckMultipleOf",(N,oe)=>{rr.init(N,oe),N._zod.check=(Ie)=>{if(typeof Ie.value!==typeof oe.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Ie.value==="bigint"?oe.value!==BigInt(0)&&Ie.value%oe.value===BigInt(0):As(Ie.value,oe.value)===0)return;Ie.issues.push({origin:typeof Ie.value,code:"not_multiple_of",divisor:oe.value,input:Ie.value,inst:N,continue:!oe.abort})}}),jc=ht("$ZodCheckNumberFormat",(N,oe)=>{rr.init(N,oe),oe.format=oe.format||"float64";let Ie=oe.format?.includes("int"),Re=Ie?"int":"number",[De,Le]=Ln[oe.format];N._zod.check=(Ue)=>{let Be=Ue.value;if(Ie){if(!Number.isInteger(Be)){Ue.issues.push({expected:Re,format:oe.format,code:"invalid_type",continue:!1,input:Be,inst:N});return}if(!Number.isSafeInteger(Be)){if(Be>0)Ue.issues.push({input:Be,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:N,origin:Re,inclusive:!0,continue:!oe.abort});else Ue.issues.push({input:Be,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:N,origin:Re,inclusive:!0,continue:!oe.abort});return}}if(Be<De)Ue.issues.push({origin:"number",input:Be,code:"too_small",minimum:De,inclusive:!0,inst:N,continue:!oe.abort});if(Be>Le)Ue.issues.push({origin:"number",input:Be,code:"too_big",maximum:Le,inclusive:!0,inst:N,continue:!oe.abort})}});var Fc=ht("$ZodCheckMaxLength",(N,oe)=>{var Ie;rr.init(N,oe),(Ie=N._zod.def).when??(Ie.when=Do),N._zod.check=(Re)=>{let De=Re.value,Le=De.length;if((typeof De==="string"&&Le>oe.maximum?Un(De):Le)<=oe.maximum)return;let Be=Bn(De);Re.issues.push({origin:Be,code:"too_big",maximum:oe.maximum,inclusive:!0,input:De,inst:N,continue:!oe.abort})}}),Uc=ht("$ZodCheckMinLength",(N,oe)=>{var Ie;rr.init(N,oe),(Ie=N._zod.def).when??(Ie.when=Do),N._zod.check=(Re)=>{let De=Re.value,Le=De.length;if((typeof De==="string"&&Le>=oe.minimum&&Le<oe.minimum*2?Un(De):Le)>=oe.minimum)return;let Be=Bn(De);Re.issues.push({origin:Be,code:"too_small",minimum:oe.minimum,inclusive:!0,input:De,inst:N,continue:!oe.abort})}}),Bc=ht("$ZodCheckLengthEquals",(N,oe)=>{var Ie;rr.init(N,oe),(Ie=N._zod.def).when??(Ie.when=Do),N._zod.check=(Re)=>{let De=Re.value,Le=De.length,Ue=typeof De==="string"&&Le>=oe.length&&Le<=oe.length*2?Un(De):Le;if(Ue===oe.length)return;let Be=Bn(De),Xe=Ue>oe.length;Re.issues.push({origin:Be,...Xe?{code:"too_big",maximum:oe.length}:{code:"too_small",minimum:oe.length},inclusive:!0,exact:!0,input:Re.value,inst:N,continue:!oe.abort})}}),zn=ht("$ZodCheckStringFormat",(N,oe)=>{var Ie,Re;if(rr.init(N,oe),oe.pattern)(Ie=N._zod).check??(Ie.check=(De)=>{if(oe.pattern.lastIndex=0,oe.pattern.test(De.value))return;De.issues.push({origin:"string",code:"invalid_format",format:oe.format,input:De.value,...oe.pattern?{pattern:oe.pattern.toString()}:{},inst:N,continue:!oe.abort})});else(Re=N._zod).check??(Re.check=()=>{})}),Jc=ht("$ZodCheckRegex",(N,oe)=>{zn.init(N,oe),N._zod.check=(Ie)=>{if(oe.pattern.lastIndex=0,oe.pattern.test(Ie.value))return;Ie.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Ie.value,pattern:oe.pattern.toString(),inst:N,continue:!oe.abort})}}),Vc=ht("$ZodCheckLowerCase",(N,oe)=>{oe.pattern??(oe.pattern=Rc),zn.init(N,oe)}),Wc=ht("$ZodCheckUpperCase",(N,oe)=>{oe.pattern??(oe.pattern=Dc),zn.init(N,oe)}),Kc=ht("$ZodCheckIncludes",(N,oe)=>{rr.init(N,oe);let Ie=Ir(oe.includes),Re=new RegExp(typeof oe.position==="number"?`^.{${oe.position},}${Ie}`:Ie);oe.pattern=Re,N._zod.check=(De)=>{if(De.value.includes(oe.includes,oe.position))return;De.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:oe.includes,input:De.value,inst:N,continue:!oe.abort})}}),Hc=ht("$ZodCheckStartsWith",(N,oe)=>{rr.init(N,oe);let Ie=new RegExp(`^${Ir(oe.prefix)}.*`);oe.pattern??(oe.pattern=Ie),N._zod.check=(Re)=>{if(Re.value.startsWith(oe.prefix))return;Re.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:oe.prefix,input:Re.value,inst:N,continue:!oe.abort})}}),qc=ht("$ZodCheckEndsWith",(N,oe)=>{rr.init(N,oe);let Ie=new RegExp(`.*${Ir(oe.suffix)}$`);oe.pattern??(oe.pattern=Ie),N._zod.check=(Re)=>{if(Re.value.endsWith(oe.suffix))return;Re.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:oe.suffix,input:Re.value,inst:N,continue:!oe.abort})}});function Mc(N,oe,Ie){if(N.issues.length)oe.issues.push(...hr(Ie,N.issues))}var Gc=ht("$ZodCheckProperties",(N,oe)=>{rr.init(N,oe),bn(N,Symbol.iterator,function*(){yield N});let Ie;N._zod.check=(Re)=>{if(Re.value==null){Re.issues.push({expected:"object",code:"invalid_type",input:Re.value,inst:N});return}Ie??(Ie=Reflect.ownKeys(oe.shape).map((Ue)=>[Ue,oe.shape[Ue]]));let De=Re.value,Le;for(let[Ue,Be]of Ie){let Xe=Be._zod.run({value:De[Ue],issues:[]},{});if(Xe instanceof Promise)Le??(Le=[]),Le.push(Xe.then((Ye)=>Mc(Ye,Re,Ue)));else Mc(Xe,Re,Ue)}if(Le)return Promise.all(Le).then(()=>{return});return}});var Xc=ht("$ZodCheckOverwrite",(N,oe)=>{rr.init(N,oe),N._zod.check=(Ie)=>{Ie.value=oe.tx(Ie.value)}});class jo{constructor(N=[],oe={}){this.content=[],this.indent=0,this.args=N,this.closed=oe}indented(N){this.indent+=1;try{N(this)}finally{this.indent-=1}}write(N){if(typeof N==="function"){N(this,{execution:"sync"}),N(this,{execution:"async"});return}let Ie=N.split(`
|
|
4
4
|
`).filter((Le)=>Le),Re=Math.min(...Ie.map((Le)=>Le.length-Le.trimStart().length)),De=Ie.map((Le)=>Le.slice(Re)).map((Le)=>" ".repeat(this.indent*2)+Le);for(let Le of De)this.content.push(Le)}compile(){let N=Function,oe=this?.content??[""];return new N(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
5
5
|
${oe.join(`
|
|
6
6
|
`)}
|
|
7
|
-
};`)(...Object.values(this.closed))}}var Qc={major:4,minor:6,patch:7};var At=ht("$ZodType",(N,oe)=>{var Ie;N??(N={}),N._zod.def=oe,N._zod.bag=N._zod.bag||{},N._zod.version=Qc;let Re=N._zod.def.checks,De=N._zod.traits.has("$ZodCheck")?[N,...Re??[]]:Re?.length?[...Re]:[];for(let Le of De)for(let Ue of Le._zod.onattach)Ue(N);if(De.length===0)(Ie=N._zod).deferred??(Ie.deferred=[]),N._zod.deferred?.push(()=>{N._zod.run=N._zod.parse});else{let Le=(Be,Xe,Ye)=>{if(Be.memo)return Be;let Qe=gr(Be),et;for(let tt of Xe){if(tt._zod.def.when){if(Bs(Be))continue;if(!tt._zod.def.when(Be))continue}else if(Qe)continue;let ft=Be.issues.length,gt=tt._zod.check(Be);if(gt instanceof Promise&&Ye?.async===!1)throw new Sr;if(et||gt instanceof Promise)et=(et??Promise.resolve()).then(async()=>{if(await gt,Be.issues.length===ft)return;if(Fn(Be.issues,ft,N),!Qe)Qe=gr(Be,ft)});else{if(Be.issues.length===ft)continue;if(Fn(Be.issues,ft,N),!Qe)Qe=gr(Be,ft)}}if(et)return et.then(()=>Be);return Be},Ue=(Be,Xe,Ye)=>{if(gr(Be))return Be.aborted=!0,Be;let Qe=Le(Xe,De,Ye);if(Qe instanceof Promise){if(Ye.async===!1)throw new Sr;return Qe.then((et)=>N._zod.parse(et,Ye))}return N._zod.parse(Qe,Ye)};N._zod.run=(Be,Xe)=>{if(Xe.skipChecks)return N._zod.parse(Be,Xe);if(Xe.direction==="backward"){let Qe=N._zod.parse({value:Be.value,issues:[]},{...Xe,skipChecks:!0});if(Qe instanceof Promise)return Qe.then((et)=>Ue(et,Be,Xe));return Ue(Qe,Be,Xe)}let Ye=N._zod.parse(Be,Xe);if(Ye instanceof Promise){if(Xe.async===!1)throw new Sr;return Ye.then((Qe)=>Le(Qe,De,Xe))}return Le(Ye,De,Xe)}}},{get "~standard"(){return vn(this,"~standard",Uo(this))},set "~standard"(N){Or(this,"~standard",N)}}),da=(N,oe)=>N.issues.length?{issues:N.issues.map((Ie)=>zr(Ie,oe,pr()))}:{value:N.value};async function bp(N,oe){let Ie={async:!0};return da(await N._zod.run({value:oe,issues:[]},Ie),Ie)}function Uo(N){return{validate:(oe)=>{let Ie={async:!1};try{let Re=N._zod.run({value:oe,issues:[]},Ie);if(!(Re instanceof Promise))return da(Re,Ie)}catch(Re){}return bp(N,oe)},vendor:"zod",version:1}}var eo=ht("$ZodString",(N,oe)=>{At.init(N,oe),N._zod.pattern=oe.pattern??Ac,N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=String(Ie.value)}catch(De){}if(typeof Ie.value==="string")return Ie;return Ie.issues.push({expected:"string",code:"invalid_type",input:Ie.value,inst:N}),Ie}}),Mt=ht("$ZodStringFormat",(N,oe)=>{zn.init(N,oe),eo.init(N,oe)}),ma=ht("$ZodGUID",(N,oe)=>{oe.pattern??(oe.pattern=yc),Mt.init(N,oe)}),ha=ht("$ZodUUID",(N,oe)=>{if(oe.version){let Re={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[oe.version];if(Re===void 0)throw Error(`Invalid UUID version: "${oe.version}"`);oe.pattern??(oe.pattern=No(Re))}else oe.pattern??(oe.pattern=No());Mt.init(N,oe)}),ga=ht("$ZodEmail",(N,oe)=>{oe.pattern??(oe.pattern=_c),Mt.init(N,oe)}),ya=1,Yn=2;function _a(N){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(N);return new URL(N),!0}catch{return!1}}function xp(N,oe){if(!("normalize"in oe)&&!("hostname"in oe)&&!("protocol"in oe))return _a(N)||Yn;return wp(N,oe)}function wp(N,oe){if(!oe.normalize&&oe.protocol?.source===kc.source&&!/^https?:\/\//i.test(N))return ya;try{if(typeof URL<"u"){let Ie=URL;if(typeof Ie.parse==="function")return Ie.parse(N)??Yn}return new URL(N)}catch{return Yn}}var $p=/[\t\n\r]/g;function ea(N){return N.replace($p,"")}function zp(N,oe){return oe.lastIndex=0,oe.test(N.hostname)}function Sp(N,oe){return oe.lastIndex=0,oe.test(N.protocol.endsWith(":")?N.protocol.slice(0,-1):N.protocol)}var va=ht("$ZodURL",(N,oe)=>{Mt.init(N,oe),N._zod.check=(Ie)=>{try{let Re=Ie.value.trim(),De=xp(Re,oe);if(De===ya){Ie.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:Ie.value,inst:N,continue:!oe.abort});return}if(De===Yn){Ie.issues.push({code:"invalid_format",format:"url",input:Ie.value,inst:N,continue:!oe.abort});return}if(De===!0){Ie.value=ea(Re);return}if(oe.hostname&&!zp(De,oe.hostname))Ie.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:oe.hostname.source,input:Ie.value,inst:N,continue:!oe.abort});if(oe.protocol&&!Sp(De,oe.protocol))Ie.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:oe.protocol.source,input:Ie.value,inst:N,continue:!oe.abort});Ie.value=oe.normalize?De.href:ea(Re);return}catch(Re){Ie.issues.push({code:"invalid_format",format:"url",input:Ie.value,inst:N,continue:!oe.abort})}}}),ba=ht("$ZodEmoji",(N,oe)=>{oe.pattern??(oe.pattern=vc()),Mt.init(N,oe)}),xa=ht("$ZodNanoID",(N,oe)=>{if(oe.length!==void 0&&(!Number.isInteger(oe.length)||oe.length<1))throw Error(`Invalid nanoid length: ${oe.length}`);oe.pattern??(oe.pattern=oe.length===void 0?mc:hc(oe.length)),Mt.init(N,oe)}),wa=ht("$ZodCUID",(N,oe)=>{oe.pattern??(oe.pattern=uc),Mt.init(N,oe)}),$a=ht("$ZodCUID2",(N,oe)=>{oe.pattern??(oe.pattern=lc),Mt.init(N,oe)}),za=ht("$ZodULID",(N,oe)=>{oe.pattern??(oe.pattern=fc),Mt.init(N,oe)}),Sa=ht("$ZodXID",(N,oe)=>{oe.pattern??(oe.pattern=pc),Mt.init(N,oe)}),ka=ht("$ZodKSUID",(N,oe)=>{oe.pattern??(oe.pattern=dc),Mt.init(N,oe)}),Pa=ht("$ZodISODateTime",(N,oe)=>{oe.pattern??(oe.pattern=Zc(oe)),Mt.init(N,oe)}),Ea=ht("$ZodISODate",(N,oe)=>{oe.pattern??(oe.pattern=Oc),Mt.init(N,oe)}),Oa=ht("$ZodISOTime",(N,oe)=>{oe.pattern??(oe.pattern=Tc(oe)),Mt.init(N,oe)}),Ta=ht("$ZodISODuration",(N,oe)=>{oe.pattern??(oe.pattern=gc),Mt.init(N,oe)}),Za=ht("$ZodIPv4",(N,oe)=>{oe.pattern??(oe.pattern=bc),Mt.init(N,oe)}),kp=/^[0-9a-fA-F:.]+$/;function Aa(N){if(!kp.test(N))return!1;return _a(`http://[${N}]`)}var Ia=ht("$ZodIPv6",(N,oe)=>{oe.pattern??(oe.pattern=xc),Mt.init(N,oe),N._zod.check=(Ie)=>{if(!Aa(Ie.value))Ie.issues.push({code:"invalid_format",format:"ipv6",input:Ie.value,inst:N,continue:!oe.abort})}});var Ca=ht("$ZodCIDRv4",(N,oe)=>{oe.pattern??(oe.pattern=wc),Mt.init(N,oe)});function Pp(N){let oe=N.split("/");if(oe.length!==2)return!1;let[Ie,Re]=oe;if(!Re)return!1;let De=Number(Re);if(`${De}`!==Re)return!1;if(De<0||De>128)return!1;return Aa(Ie)}var Na=ht("$ZodCIDRv6",(N,oe)=>{oe.pattern??(oe.pattern=$c),Mt.init(N,oe),N._zod.check=(Ie)=>{if(!Pp(Ie.value))Ie.issues.push({code:"invalid_format",format:"cidrv6",input:Ie.value,inst:N,continue:!oe.abort})}});function Ra(N){if(N==="")return!0;if(/\s/.test(N))return!1;if(N.length%4!==0)return!1;try{return atob(N),!0}catch{return!1}}var Bo=/^[0-9a-zA-Z+/]*={0,2}$/,Da=ht("$ZodBase64",(N,oe)=>{oe.pattern??(oe.pattern=Bo),Mt.init(N,oe),N._zod.check=(Ie)=>{if(Ra(Ie.value))return;Ie.issues.push({code:"invalid_format",format:"base64",input:Ie.value,inst:N,continue:!oe.abort})}}),to=/^[A-Za-z0-9_-]*$/;function Ep(N){if(!to.test(N))return!1;let oe=N.replace(/[-_]/g,(Re)=>Re==="-"?"+":"/"),Ie=oe.padEnd(Math.ceil(oe.length/4)*4,"=");return Ra(Ie)}var Ma=ht("$ZodBase64URL",(N,oe)=>{oe.pattern??(oe.pattern=to),Mt.init(N,oe),N._zod.check=(Ie)=>{if(Ep(Ie.value))return;Ie.issues.push({code:"invalid_format",format:"base64url",input:Ie.value,inst:N,continue:!oe.abort})}}),La=ht("$ZodE164",(N,oe)=>{oe.pattern??(oe.pattern=Pc),Mt.init(N,oe)});function Op(N,oe=null){try{let Ie=N.split(".");if(Ie.length!==3)return!1;let[Re]=Ie;if(!Re)return!1;let De=JSON.parse(atob(Re));if("typ"in De&&De?.typ!=="JWT")return!1;if(!De.alg)return!1;if(oe&&(!("alg"in De)||De.alg!==oe))return!1;return!0}catch{return!1}}var ja=ht("$ZodJWT",(N,oe)=>{Mt.init(N,oe),N._zod.check=(Ie)=>{if(Op(Ie.value,oe.alg))return;Ie.issues.push({code:"invalid_format",format:"jwt",input:Ie.value,inst:N,continue:!oe.abort})}});var Jo=ht("$ZodNumber",(N,oe)=>{At.init(N,oe),N._zod.pattern=wn,N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=Number(Ie.value)}catch(Ue){}let De=Ie.value;if(typeof De==="number"&&!Number.isNaN(De)&&Number.isFinite(De))return Ie;let Le=typeof De==="number"?Number.isNaN(De)?"NaN":!Number.isFinite(De)?String(De):void 0:void 0;return Ie.issues.push({expected:"number",code:"invalid_type",input:De,inst:N,...Le?{received:Le}:{}}),Ie}}),Fa=ht("$ZodNumberFormat",(N,oe)=>{jc.init(N,oe),Jo.init(N,oe)}),Ua=ht("$ZodBoolean",(N,oe)=>{At.init(N,oe),N._zod.pattern=Cc,N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=Boolean(Ie.value)}catch(Le){}let De=Ie.value;if(typeof De==="boolean")return Ie;return Ie.issues.push({expected:"boolean",code:"invalid_type",input:De,inst:N}),Ie}}),Ba=ht("$ZodBigInt",(N,oe)=>{At.init(N,oe),N._zod.pattern=Ic,N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=BigInt(Ie.value)}catch(De){}if(typeof Ie.value==="bigint")return Ie;return Ie.issues.push({expected:"bigint",code:"invalid_type",input:Ie.value,inst:N}),Ie}});var Ja=ht("$ZodNull",(N,oe)=>{At.init(N,oe),N._zod.pattern=Nc,N._zod.values=new Set([null]),N._zod.parse=(Ie,Re)=>{let De=Ie.value;if(De===null)return Ie;return Ie.issues.push({expected:"null",code:"invalid_type",input:De,inst:N}),Ie}}),Va=ht("$ZodAny",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie)=>Ie}),Wa=ht("$ZodUnknown",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie)=>Ie}),Ka=ht("$ZodNever",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie,Re)=>(Ie.issues.push({expected:"never",code:"invalid_type",input:Ie.value,inst:N}),Ie)});var Ha=ht("$ZodDate",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=new Date(Ie.value)}catch(Be){}let De=Ie.value,Le=De instanceof Date;if(Le&&!Number.isNaN(De.getTime()))return Ie;return Ie.issues.push({expected:"date",code:"invalid_type",input:De,...Le?{received:"Invalid Date"}:{},inst:N}),Ie}});function Tp(N,oe){let Ie=Eo(N._zod.def.checks);if(!Ie.length)return;let Re=Math.min(...Ie.map((Le)=>Le[0])),De=N._zod.parse;N._zod.parse=(Le,Ue)=>{let Be=oe(Le.value);if(Be>Re&&!Ue?.skipChecks&&Ue?.direction!=="backward"){for(let[Xe,Ye]of Eo(N._zod.def.checks))if(Be>Xe&&Ye._zod.def.when(Le)){let Qe=Le.issues.length;return Ye._zod.check(Le),Le.issues[Qe].continue=!1,Fn(Le.issues,Qe,N),Le}}return De(Le,Ue)}}var Zp=(N)=>Array.isArray(N)?N.length:-1;function ta(N,oe,Ie){if(N.issues.length)oe.issues.push(...yr(Ie,N.issues));oe.value[Ie]=N.value}var qa=ht("$ZodArray",(N,oe)=>{At.init(N,oe);let Ie=cr.memoizer;Ie?.attach(N),N._zod.parse=(Re,De)=>{let Le=Re.value;if(!Array.isArray(Le))return Re.issues.push({expected:"array",code:"invalid_type",input:Le,inst:N}),Re;Re.value=Ie?Ie.alloc(N,Re,Array(Le.length),De):Array(Le.length);let Ue=[],Be=De?.abortEarly;for(let Xe=0;Xe<Le.length;Xe++){let Ye=Le[Xe],Qe=oe.element._zod.run({value:Ye,issues:[]},De);if(Qe instanceof Promise)Ue.push(Qe.then((et)=>ta(et,Re,Xe)));else if(ta(Qe,Re,Xe),Be&&Qe.issues.length!==0&&gr(Qe))break}if(Ue.length)return Promise.all(Ue).then(()=>Re);return Re},Tp(N,Zp)});function Qn(N,oe,Ie,Re,De,Le){let Ue=Ie in Re,Be=Le==="optional";if(!Ue&&Be&&De==="optional")return;if(N.issues.length){if(De!==void 0&&Be&&!Ue)return;oe.issues.push(...yr(Ie,N.issues))}if(!Ue&&De===void 0){if(!N.issues.length)oe.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[Ie]});return}if(N.value===void 0){if(Ue||De==="defaulted"&&!Be)oe.value[Ie]=void 0}else oe.value[Ie]=N.value}var Ap=[];function Ga(N){let oe=Object.keys(N.shape),Ie=Object.getOwnPropertySymbols(N.shape),Re=Ie.length?Ie:Ap,De=Re.length?[...oe,...Re]:oe;for(let Ue of De)if(!N.shape?.[Ue]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(Ue)}": expected a Zod schema`);let Le=js(N.shape);return{...N,allKeys:De,symbolKeys:Re,keySet:new Set(oe),numKeys:oe.length,optionalKeys:new Set(Le)}}function Xa(N,oe,Ie,Re,De,Le,Ue){let Be=[],Xe=De.keySet,Ye=De.catchall._zod,Qe=Ye.def.type,{optin:et,optout:tt}=Ye,ft=0;for(let gt in oe){if(Ue&&Ie.issues.length!==ft){if(gr(Ie,ft))break;ft=Ie.issues.length}if(Xe.has(gt))continue;if(gt==="__proto__"){if(Qe==="never")Be.push(gt);continue}if(Qe==="never"){Be.push(gt);continue}let bt=Ye.run({value:oe[gt],issues:[]},Re);if(bt instanceof Promise)N.push(bt.then((St)=>Qn(St,Ie,gt,oe,et,tt)));else Qn(bt,Ie,gt,oe,et,tt)}if(Be.length)Ie.issues.push({code:"unrecognized_keys",keys:Be,input:oe,inst:Le,continue:!0});if(!N.length)return Ie;return Promise.all(N).then(()=>Ie)}var Ip=ht("$ZodObject",(N,oe)=>{At.init(N,oe);let Ie=Object.getOwnPropertyDescriptor(oe,"shape"),Re=Ie?.get?Ie.get.raw:oe.shape??{};if(Re){let Ye=()=>{let Qe={...Re};return Object.defineProperty(oe,"shape",{value:Qe}),Ye.raw=Qe,Qe};Ye.raw=Re,Object.defineProperty(oe,"shape",{get:Ye})}let De=yn(()=>Ga(oe));Tt(N,"propValues",(Ye)=>{let Qe=Ye.def.shape,et={};for(let tt in Qe){let ft=Qe[tt]._zod;if(ft.values){if(!Object.prototype.hasOwnProperty.call(et,tt))lr(et,tt,new Set);for(let gt of ft.values)et[tt].add(gt);if(ft.optin!==void 0)et[tt].add(void 0)}}return et});let Le=Vr,Ue=oe.catchall,Be,Xe=cr.memoizer;Xe?.attach(N),N._zod.parse=(Ye,Qe)=>{Be??(Be=De.value);let et=Ye.value;if(!Le(et))return Ye.issues.push({expected:"object",code:"invalid_type",input:et,inst:N}),Ye;Ye.value=Xe?Xe.alloc(N,Ye,{},Qe):{};let tt=[],ft=Be.shape,gt=Qe?.abortEarly,bt=Ye.issues.length;for(let St of Be.allKeys){if(gt&&Ye.issues.length!==bt){if(gr(Ye,bt))break;bt=Ye.issues.length}if(St==="__proto__")continue;let Et=ft[St],rr=Et._zod.optin,Pr=Et._zod.optout,Mr=Et._zod.run({value:et[St],issues:[]},Qe);if(Mr instanceof Promise)tt.push(Mr.then((_t)=>Qn(_t,Ye,St,et,rr,Pr)));else Qn(Mr,Ye,St,et,rr,Pr)}if(!Ue)return tt.length?Promise.all(tt).then(()=>Ye):Ye;return Xa(tt,et,Ye,Qe,De.value,N,gt===!0)}}),Ya=ht("$ZodObjectJIT",(N,oe)=>{Ip.init(N,oe);let Ie=N._zod.parse,Re=yn(()=>Ga(oe)),De=cr.memoizer,Le=(ft)=>{let gt=Re.value,bt=gt.symbolKeys,St=new jo(["payload","ctx"],{shape:ft,inst:N,memo:De,syms:bt}),Et=(_t)=>`shape[${_t}]._zod.run({ value: input[${_t}], issues: [] }, ctx)`,rr=(_t,yt)=>`
|
|
7
|
+
};`)(...Object.values(this.closed))}}var Qc={major:4,minor:6,patch:7};var At=ht("$ZodType",(N,oe)=>{var Ie;N??(N={}),N._zod.def=oe,N._zod.bag=N._zod.bag||{},N._zod.version=Qc;let Re=N._zod.def.checks,De=N._zod.traits.has("$ZodCheck")?[N,...Re??[]]:Re?.length?[...Re]:[];for(let Le of De)for(let Ue of Le._zod.onattach)Ue(N);if(De.length===0)(Ie=N._zod).deferred??(Ie.deferred=[]),N._zod.deferred?.push(()=>{N._zod.run=N._zod.parse});else{let Le=(Be,Xe,Ye)=>{if(Be.memo)return Be;let Qe=mr(Be),et;for(let tt of Xe){if(tt._zod.def.when){if(Bs(Be))continue;if(!tt._zod.def.when(Be))continue}else if(Qe)continue;let ft=Be.issues.length,gt=tt._zod.check(Be);if(gt instanceof Promise&&Ye?.async===!1)throw new $r;if(et||gt instanceof Promise)et=(et??Promise.resolve()).then(async()=>{if(await gt,Be.issues.length===ft)return;if(Fn(Be.issues,ft,N),!Qe)Qe=mr(Be,ft)});else{if(Be.issues.length===ft)continue;if(Fn(Be.issues,ft,N),!Qe)Qe=mr(Be,ft)}}if(et)return et.then(()=>Be);return Be},Ue=(Be,Xe,Ye)=>{if(mr(Be))return Be.aborted=!0,Be;let Qe=Le(Xe,De,Ye);if(Qe instanceof Promise){if(Ye.async===!1)throw new $r;return Qe.then((et)=>N._zod.parse(et,Ye))}return N._zod.parse(Qe,Ye)};N._zod.run=(Be,Xe)=>{if(Xe.skipChecks)return N._zod.parse(Be,Xe);if(Xe.direction==="backward"){let Qe=N._zod.parse({value:Be.value,issues:[]},{...Xe,skipChecks:!0});if(Qe instanceof Promise)return Qe.then((et)=>Ue(et,Be,Xe));return Ue(Qe,Be,Xe)}let Ye=N._zod.parse(Be,Xe);if(Ye instanceof Promise){if(Xe.async===!1)throw new $r;return Ye.then((Qe)=>Le(Qe,De,Xe))}return Le(Ye,De,Xe)}}},{get "~standard"(){return bn(this,"~standard",Uo(this))},set "~standard"(N){Pr(this,"~standard",N)}}),da=(N,oe)=>N.issues.length?{issues:N.issues.map((Ie)=>wr(Ie,oe,lr()))}:{value:N.value};async function bp(N,oe){let Ie={async:!0};return da(await N._zod.run({value:oe,issues:[]},Ie),Ie)}function Uo(N){return{validate:(oe)=>{let Ie={async:!1};try{let Re=N._zod.run({value:oe,issues:[]},Ie);if(!(Re instanceof Promise))return da(Re,Ie)}catch(Re){}return bp(N,oe)},vendor:"zod",version:1}}var eo=ht("$ZodString",(N,oe)=>{At.init(N,oe),N._zod.pattern=oe.pattern??Ac,N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=String(Ie.value)}catch(De){}if(typeof Ie.value==="string")return Ie;return Ie.issues.push({expected:"string",code:"invalid_type",input:Ie.value,inst:N}),Ie}}),Mt=ht("$ZodStringFormat",(N,oe)=>{zn.init(N,oe),eo.init(N,oe)}),ma=ht("$ZodGUID",(N,oe)=>{oe.pattern??(oe.pattern=yc),Mt.init(N,oe)}),ha=ht("$ZodUUID",(N,oe)=>{if(oe.version){let Re={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[oe.version];if(Re===void 0)throw Error(`Invalid UUID version: "${oe.version}"`);oe.pattern??(oe.pattern=No(Re))}else oe.pattern??(oe.pattern=No());Mt.init(N,oe)}),ga=ht("$ZodEmail",(N,oe)=>{oe.pattern??(oe.pattern=_c),Mt.init(N,oe)}),ya=1,Yn=2;function _a(N){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(N);return new URL(N),!0}catch{return!1}}function xp(N,oe){if(!("normalize"in oe)&&!("hostname"in oe)&&!("protocol"in oe))return _a(N)||Yn;return wp(N,oe)}function wp(N,oe){if(!oe.normalize&&oe.protocol?.source===kc.source&&!/^https?:\/\//i.test(N))return ya;try{if(typeof URL<"u"){let Ie=URL;if(typeof Ie.parse==="function")return Ie.parse(N)??Yn}return new URL(N)}catch{return Yn}}var $p=/[\t\n\r]/g;function ea(N){return N.replace($p,"")}function zp(N,oe){return oe.lastIndex=0,oe.test(N.hostname)}function Sp(N,oe){return oe.lastIndex=0,oe.test(N.protocol.endsWith(":")?N.protocol.slice(0,-1):N.protocol)}var va=ht("$ZodURL",(N,oe)=>{Mt.init(N,oe),N._zod.check=(Ie)=>{try{let Re=Ie.value.trim(),De=xp(Re,oe);if(De===ya){Ie.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:Ie.value,inst:N,continue:!oe.abort});return}if(De===Yn){Ie.issues.push({code:"invalid_format",format:"url",input:Ie.value,inst:N,continue:!oe.abort});return}if(De===!0){Ie.value=ea(Re);return}if(oe.hostname&&!zp(De,oe.hostname))Ie.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:oe.hostname.source,input:Ie.value,inst:N,continue:!oe.abort});if(oe.protocol&&!Sp(De,oe.protocol))Ie.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:oe.protocol.source,input:Ie.value,inst:N,continue:!oe.abort});Ie.value=oe.normalize?De.href:ea(Re);return}catch(Re){Ie.issues.push({code:"invalid_format",format:"url",input:Ie.value,inst:N,continue:!oe.abort})}}}),ba=ht("$ZodEmoji",(N,oe)=>{oe.pattern??(oe.pattern=vc()),Mt.init(N,oe)}),xa=ht("$ZodNanoID",(N,oe)=>{if(oe.length!==void 0&&(!Number.isInteger(oe.length)||oe.length<1))throw Error(`Invalid nanoid length: ${oe.length}`);oe.pattern??(oe.pattern=oe.length===void 0?mc:hc(oe.length)),Mt.init(N,oe)}),wa=ht("$ZodCUID",(N,oe)=>{oe.pattern??(oe.pattern=uc),Mt.init(N,oe)}),$a=ht("$ZodCUID2",(N,oe)=>{oe.pattern??(oe.pattern=lc),Mt.init(N,oe)}),za=ht("$ZodULID",(N,oe)=>{oe.pattern??(oe.pattern=fc),Mt.init(N,oe)}),Sa=ht("$ZodXID",(N,oe)=>{oe.pattern??(oe.pattern=pc),Mt.init(N,oe)}),ka=ht("$ZodKSUID",(N,oe)=>{oe.pattern??(oe.pattern=dc),Mt.init(N,oe)}),Pa=ht("$ZodISODateTime",(N,oe)=>{oe.pattern??(oe.pattern=Zc(oe)),Mt.init(N,oe)}),Ea=ht("$ZodISODate",(N,oe)=>{oe.pattern??(oe.pattern=Oc),Mt.init(N,oe)}),Oa=ht("$ZodISOTime",(N,oe)=>{oe.pattern??(oe.pattern=Tc(oe)),Mt.init(N,oe)}),Ta=ht("$ZodISODuration",(N,oe)=>{oe.pattern??(oe.pattern=gc),Mt.init(N,oe)}),Za=ht("$ZodIPv4",(N,oe)=>{oe.pattern??(oe.pattern=bc),Mt.init(N,oe)}),kp=/^[0-9a-fA-F:.]+$/;function Aa(N){if(!kp.test(N))return!1;return _a(`http://[${N}]`)}var Ia=ht("$ZodIPv6",(N,oe)=>{oe.pattern??(oe.pattern=xc),Mt.init(N,oe),N._zod.check=(Ie)=>{if(!Aa(Ie.value))Ie.issues.push({code:"invalid_format",format:"ipv6",input:Ie.value,inst:N,continue:!oe.abort})}});var Ca=ht("$ZodCIDRv4",(N,oe)=>{oe.pattern??(oe.pattern=wc),Mt.init(N,oe)});function Pp(N){let oe=N.split("/");if(oe.length!==2)return!1;let[Ie,Re]=oe;if(!Re)return!1;let De=Number(Re);if(`${De}`!==Re)return!1;if(De<0||De>128)return!1;return Aa(Ie)}var Na=ht("$ZodCIDRv6",(N,oe)=>{oe.pattern??(oe.pattern=$c),Mt.init(N,oe),N._zod.check=(Ie)=>{if(!Pp(Ie.value))Ie.issues.push({code:"invalid_format",format:"cidrv6",input:Ie.value,inst:N,continue:!oe.abort})}});function Ra(N){if(N==="")return!0;if(/\s/.test(N))return!1;if(N.length%4!==0)return!1;try{return atob(N),!0}catch{return!1}}var Bo=/^[0-9a-zA-Z+/]*={0,2}$/,Da=ht("$ZodBase64",(N,oe)=>{oe.pattern??(oe.pattern=Bo),Mt.init(N,oe),N._zod.check=(Ie)=>{if(Ra(Ie.value))return;Ie.issues.push({code:"invalid_format",format:"base64",input:Ie.value,inst:N,continue:!oe.abort})}}),to=/^[A-Za-z0-9_-]*$/;function Ep(N){if(!to.test(N))return!1;let oe=N.replace(/[-_]/g,(Re)=>Re==="-"?"+":"/"),Ie=oe.padEnd(Math.ceil(oe.length/4)*4,"=");return Ra(Ie)}var Ma=ht("$ZodBase64URL",(N,oe)=>{oe.pattern??(oe.pattern=to),Mt.init(N,oe),N._zod.check=(Ie)=>{if(Ep(Ie.value))return;Ie.issues.push({code:"invalid_format",format:"base64url",input:Ie.value,inst:N,continue:!oe.abort})}}),La=ht("$ZodE164",(N,oe)=>{oe.pattern??(oe.pattern=Pc),Mt.init(N,oe)});function Op(N,oe=null){try{let Ie=N.split(".");if(Ie.length!==3)return!1;let[Re]=Ie;if(!Re)return!1;let De=JSON.parse(atob(Re));if("typ"in De&&De?.typ!=="JWT")return!1;if(!De.alg)return!1;if(oe&&(!("alg"in De)||De.alg!==oe))return!1;return!0}catch{return!1}}var ja=ht("$ZodJWT",(N,oe)=>{Mt.init(N,oe),N._zod.check=(Ie)=>{if(Op(Ie.value,oe.alg))return;Ie.issues.push({code:"invalid_format",format:"jwt",input:Ie.value,inst:N,continue:!oe.abort})}});var Jo=ht("$ZodNumber",(N,oe)=>{At.init(N,oe),N._zod.pattern=wn,N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=Number(Ie.value)}catch(Ue){}let De=Ie.value;if(typeof De==="number"&&!Number.isNaN(De)&&Number.isFinite(De))return Ie;let Le=typeof De==="number"?Number.isNaN(De)?"NaN":!Number.isFinite(De)?String(De):void 0:void 0;return Ie.issues.push({expected:"number",code:"invalid_type",input:De,inst:N,...Le?{received:Le}:{}}),Ie}}),Fa=ht("$ZodNumberFormat",(N,oe)=>{jc.init(N,oe),Jo.init(N,oe)}),Ua=ht("$ZodBoolean",(N,oe)=>{At.init(N,oe),N._zod.pattern=Cc,N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=Boolean(Ie.value)}catch(Le){}let De=Ie.value;if(typeof De==="boolean")return Ie;return Ie.issues.push({expected:"boolean",code:"invalid_type",input:De,inst:N}),Ie}}),Ba=ht("$ZodBigInt",(N,oe)=>{At.init(N,oe),N._zod.pattern=Ic,N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=BigInt(Ie.value)}catch(De){}if(typeof Ie.value==="bigint")return Ie;return Ie.issues.push({expected:"bigint",code:"invalid_type",input:Ie.value,inst:N}),Ie}});var Ja=ht("$ZodNull",(N,oe)=>{At.init(N,oe),N._zod.pattern=Nc,N._zod.values=new Set([null]),N._zod.parse=(Ie,Re)=>{let De=Ie.value;if(De===null)return Ie;return Ie.issues.push({expected:"null",code:"invalid_type",input:De,inst:N}),Ie}}),Va=ht("$ZodAny",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie)=>Ie}),Wa=ht("$ZodUnknown",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie)=>Ie}),Ka=ht("$ZodNever",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie,Re)=>(Ie.issues.push({expected:"never",code:"invalid_type",input:Ie.value,inst:N}),Ie)});var Ha=ht("$ZodDate",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie,Re)=>{if(oe.coerce)try{Ie.value=new Date(Ie.value)}catch(Be){}let De=Ie.value,Le=De instanceof Date;if(Le&&!Number.isNaN(De.getTime()))return Ie;return Ie.issues.push({expected:"date",code:"invalid_type",input:De,...Le?{received:"Invalid Date"}:{},inst:N}),Ie}});function Tp(N,oe){let Ie=Eo(N._zod.def.checks);if(!Ie.length)return;let Re=Math.min(...Ie.map((Le)=>Le[0])),De=N._zod.parse;N._zod.parse=(Le,Ue)=>{let Be=oe(Le.value);if(Be>Re&&!Ue?.skipChecks&&Ue?.direction!=="backward"){for(let[Xe,Ye]of Eo(N._zod.def.checks))if(Be>Xe&&Ye._zod.def.when(Le)){let Qe=Le.issues.length;return Ye._zod.check(Le),Le.issues[Qe].continue=!1,Fn(Le.issues,Qe,N),Le}}return De(Le,Ue)}}var Zp=(N)=>Array.isArray(N)?N.length:-1;function ta(N,oe,Ie){if(N.issues.length)oe.issues.push(...hr(Ie,N.issues));oe.value[Ie]=N.value}var qa=ht("$ZodArray",(N,oe)=>{At.init(N,oe);let Ie=ir.memoizer;Ie?.attach(N),N._zod.parse=(Re,De)=>{let Le=Re.value;if(!Array.isArray(Le))return Re.issues.push({expected:"array",code:"invalid_type",input:Le,inst:N}),Re;Re.value=Ie?Ie.alloc(N,Re,Array(Le.length),De):Array(Le.length);let Ue=[],Be=De?.abortEarly;for(let Xe=0;Xe<Le.length;Xe++){let Ye=Le[Xe],Qe=oe.element._zod.run({value:Ye,issues:[]},De);if(Qe instanceof Promise)Ue.push(Qe.then((et)=>ta(et,Re,Xe)));else if(ta(Qe,Re,Xe),Be&&Qe.issues.length!==0&&mr(Qe))break}if(Ue.length)return Promise.all(Ue).then(()=>Re);return Re},Tp(N,Zp)});function Qn(N,oe,Ie,Re,De,Le){let Ue=Ie in Re,Be=Le==="optional";if(!Ue&&Be&&De==="optional")return;if(N.issues.length){if(De!==void 0&&Be&&!Ue)return;oe.issues.push(...hr(Ie,N.issues))}if(!Ue&&De===void 0){if(!N.issues.length)oe.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[Ie]});return}if(N.value===void 0){if(Ue||De==="defaulted"&&!Be)oe.value[Ie]=void 0}else oe.value[Ie]=N.value}var Ap=[];function Ga(N){let oe=Object.keys(N.shape),Ie=Object.getOwnPropertySymbols(N.shape),Re=Ie.length?Ie:Ap,De=Re.length?[...oe,...Re]:oe;for(let Ue of De)if(!N.shape?.[Ue]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(Ue)}": expected a Zod schema`);let Le=js(N.shape);return{...N,allKeys:De,symbolKeys:Re,keySet:new Set(oe),numKeys:oe.length,optionalKeys:new Set(Le)}}function Xa(N,oe,Ie,Re,De,Le,Ue){let Be=[],Xe=De.keySet,Ye=De.catchall._zod,Qe=Ye.def.type,{optin:et,optout:tt}=Ye,ft=0;for(let gt in oe){if(Ue&&Ie.issues.length!==ft){if(mr(Ie,ft))break;ft=Ie.issues.length}if(Xe.has(gt))continue;if(gt==="__proto__"){if(Qe==="never")Be.push(gt);continue}if(Qe==="never"){Be.push(gt);continue}let bt=Ye.run({value:oe[gt],issues:[]},Re);if(bt instanceof Promise)N.push(bt.then((St)=>Qn(St,Ie,gt,oe,et,tt)));else Qn(bt,Ie,gt,oe,et,tt)}if(Be.length)Ie.issues.push({code:"unrecognized_keys",keys:Be,input:oe,inst:Le,continue:!0});if(!N.length)return Ie;return Promise.all(N).then(()=>Ie)}var Ip=ht("$ZodObject",(N,oe)=>{At.init(N,oe);let Ie=Object.getOwnPropertyDescriptor(oe,"shape"),Re=Ie?.get?Ie.get.raw:oe.shape??{};if(Re){let Ye=()=>{let Qe={...Re};return Object.defineProperty(oe,"shape",{value:Qe}),Ye.raw=Qe,Qe};Ye.raw=Re,Object.defineProperty(oe,"shape",{get:Ye})}let De=Qr(()=>Ga(oe));Tt(N,"propValues",(Ye)=>{let Qe=Ye.def.shape,et={};for(let tt in Qe){let ft=Qe[tt]._zod;if(ft.values){if(!Object.prototype.hasOwnProperty.call(et,tt))ar(et,tt,new Set);for(let gt of ft.values)et[tt].add(gt);if(ft.optin!==void 0)et[tt].add(void 0)}}return et});let Le=Br,Ue=oe.catchall,Be,Xe=ir.memoizer;Xe?.attach(N),N._zod.parse=(Ye,Qe)=>{Be??(Be=De.value);let et=Ye.value;if(!Le(et))return Ye.issues.push({expected:"object",code:"invalid_type",input:et,inst:N}),Ye;Ye.value=Xe?Xe.alloc(N,Ye,{},Qe):{};let tt=[],ft=Be.shape,gt=Qe?.abortEarly,bt=Ye.issues.length;for(let St of Be.allKeys){if(gt&&Ye.issues.length!==bt){if(mr(Ye,bt))break;bt=Ye.issues.length}if(St==="__proto__")continue;let Et=ft[St],er=Et._zod.optin,Sr=Et._zod.optout,Rr=Et._zod.run({value:et[St],issues:[]},Qe);if(Rr instanceof Promise)tt.push(Rr.then((_t)=>Qn(_t,Ye,St,et,er,Sr)));else Qn(Rr,Ye,St,et,er,Sr)}if(!Ue)return tt.length?Promise.all(tt).then(()=>Ye):Ye;return Xa(tt,et,Ye,Qe,De.value,N,gt===!0)}}),Ya=ht("$ZodObjectJIT",(N,oe)=>{Ip.init(N,oe);let Ie=N._zod.parse,Re=Qr(()=>Ga(oe)),De=ir.memoizer,Le=(ft)=>{let gt=Re.value,bt=gt.symbolKeys,St=new jo(["payload","ctx"],{shape:ft,inst:N,memo:De,syms:bt}),Et=(_t)=>`shape[${_t}]._zod.run({ value: input[${_t}], issues: [] }, ctx)`,er=(_t,yt)=>`
|
|
8
8
|
let ${_t}_ab = false;
|
|
9
9
|
for (let i = 0; i < ${_t}.issues.length; i++) {
|
|
10
10
|
const iss = ${_t}.issues[i];
|
|
@@ -15,10 +15,10 @@ ${oe.join(`
|
|
|
15
15
|
if (${_t}_ab && ctx && ctx.abortEarly) {
|
|
16
16
|
payload.value = newResult;
|
|
17
17
|
return payload;
|
|
18
|
-
}`;St.write("const input = payload.value;");let
|
|
19
|
-
const ${yt}_present = ${
|
|
18
|
+
}`;St.write("const input = payload.value;");let Sr=Object.create(null),Rr=0;for(let _t of gt.allKeys)Sr[_t]=`key_${Rr++}`;St.write(De?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let _t of gt.allKeys){if(_t==="__proto__")continue;let yt=Sr[_t],Ot=typeof _t==="symbol"?`syms[${bt.indexOf(_t)}]`:Rs(_t),Ut=`${Ot} in input`,Bt=ft[_t],dr=Bt?._zod?.optin,Rn=dr!==void 0,vo=Bt?._zod?.optout==="optional";if(St.write(`const ${yt} = ${Et(Ot)};`),Rn&&vo){let bo=dr==="optional"?`${yt}_present`:`${yt}.value !== undefined || ${yt}_present`;St.write(`
|
|
19
|
+
const ${yt}_present = ${Ut};
|
|
20
20
|
if (!${yt}.issues.length || ${yt}_present) {
|
|
21
|
-
if (${yt}.issues.length) {${
|
|
21
|
+
if (${yt}.issues.length) {${er(yt,Ot)}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (${bo}) {
|
|
@@ -27,8 +27,8 @@ ${oe.join(`
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
`)}else if(!Rn)St.write(`
|
|
30
|
-
const ${yt}_present = ${
|
|
31
|
-
if (${yt}.issues.length) {${
|
|
30
|
+
const ${yt}_present = ${Ut};
|
|
31
|
+
if (${yt}.issues.length) {${er(yt,Ot)}
|
|
32
32
|
}
|
|
33
33
|
if (!${yt}_present && !${yt}.issues.length) {
|
|
34
34
|
payload.issues.push({
|
|
@@ -48,29 +48,29 @@ ${oe.join(`
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
`);else if(St.write(`
|
|
51
|
-
if (${yt}.issues.length) {${
|
|
51
|
+
if (${yt}.issues.length) {${er(yt,Ot)}
|
|
52
52
|
}
|
|
53
|
-
`),
|
|
54
|
-
if (${yt}.value !== undefined || ${
|
|
53
|
+
`),dr==="defaulted")St.write(`newResult[${Ot}] = ${yt}.value;`);else St.write(`
|
|
54
|
+
if (${yt}.value !== undefined || ${Ut}) {
|
|
55
55
|
newResult[${Ot}] = ${yt}.value;
|
|
56
56
|
}
|
|
57
|
-
`)}return St.write("payload.value = newResult;"),St.write("return payload;"),St.compile()},Ue,Be=Vr,Xe=!cr.jitless,Qe=Xe&&Ms.value,et=oe.catchall,tt;N._zod.parse=(ft,gt)=>{tt??(tt=Re.value);let bt=ft.value;if(!Be(bt))return ft.issues.push({expected:"object",code:"invalid_type",input:bt,inst:N}),ft;if(Xe&&Qe&>?.async===!1&>.jitless!==!0){if(!Ue)Ue=Le(oe.shape);if(ft=Ue(ft,gt),!et)return ft;return Xa([],bt,ft,gt,tt,N,gt?.abortEarly===!0)}return Ie(ft,gt)}});function ra(N,oe,Ie,Re){for(let Le of N)if(Le.issues.length===0)return oe.value=Le.value,oe;let De=N.filter((Le)=>!gr(Le));if(De.length===1)return oe.value=De[0].value,De[0];return oe.issues.push({code:"invalid_union",input:oe.value,inst:Ie,errors:N.map((Le)=>Le.issues.map((Ue)=>zr(Ue,Re,pr())))}),oe}var Vo=ht("$ZodUnion",(N,oe)=>{At.init(N,oe),Tt(N,"optin",(Re)=>Re.def.options.some((De)=>De._zod.optin==="defaulted")?"defaulted":Re.def.options.some((De)=>De._zod.optin!==void 0)?"optional":void 0),Tt(N,"optout",(Re)=>Re.def.options.some((De)=>De._zod.optout==="optional")?"optional":void 0),Tt(N,"values",(Re)=>{if(Re.def.options.every((De)=>De._zod.values))return new Set(Re.def.options.flatMap((De)=>Array.from(De._zod.values)));return}),Tt(N,"pattern",(Re)=>{if(Re.def.options.every((De)=>De._zod.pattern)){let De=Re.def.options.map((Le)=>Le._zod.pattern);return new RegExp(`^(${De.map((Le)=>Mn(Le.source)).join("|")})$`)}return});let Ie=oe.options.length===1?oe.options[0]._zod.run:null;N._zod.parse=(Re,De)=>{if(Ie)return Ie(Re,De);let Le=!1,Ue=[];for(let Be of oe.options){let Xe=Be._zod.run({value:Re.value,issues:[]},De);if(Xe instanceof Promise)Ue.push(Xe),Le=!0;else{if(Xe.issues.length===0)return Xe;Ue.push(Xe)}}if(!Le)return ra(Ue,Re,N,De);return Promise.all(Ue).then((Be)=>ra(Be,Re,N,De))}});function Cp(N){let oe=new Map;for(let Ie of N.options){let Re=Ie._zod.propValues?.[N.discriminator];if(!Re||Re.size===0)throw Error(`Invalid discriminated union option at index "${N.options.indexOf(Ie)}"`);for(let De of Re)if(oe.has(De)){if(De!==void 0)throw Error(`Duplicate discriminator value "${String(De)}"`);oe.set(De,null)}else oe.set(De,Ie)}return oe}var Qa=ht("$ZodDiscriminatedUnion",(N,oe)=>{oe.inclusive=!1,Vo.init(N,oe);let Ie=N._zod.parse;Tt(N,"propValues",(De)=>{let Le={},Ue=0;for(let Be of De.def.options){let Xe=Be._zod.propValues;if(!Xe||Object.keys(Xe).length===0)throw Error(`Invalid discriminated union option at index "${De.def.options.indexOf(Be)}"`);if(Xe[De.def.discriminator]?.has(void 0))Ue++;for(let[Ye,Qe]of Object.entries(Xe)){if(!Object.prototype.hasOwnProperty.call(Le,Ye))lr(Le,Ye,new Set);for(let et of Qe)Le[Ye].add(et)}}if(!De.def.unionFallback&&Ue>1)Le[De.def.discriminator]?.delete(void 0);return Le}),oe.options.forEach((De,Le)=>{let Ue=_n(De._zod.def);if(Ue&&!Object.prototype.hasOwnProperty.call(Ue,oe.discriminator))throw Error(`Invalid discriminated union option at index "${Le}"`)});let Re=yn(()=>Cp(oe));N._zod.parse=(De,Le)=>{let Ue=De.value;if(!Vr(Ue))return De.issues.push({code:"invalid_type",expected:"object",input:Ue,inst:N}),De;let Be=Ue?.[oe.discriminator],Xe=Re.value.get(Be);if(Xe&&(Be!==void 0||Le.direction!=="backward"))return Xe._zod.run(De,Le);if(oe.unionFallback||Le.direction==="backward")return Ie(De,Le);return De.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:oe.discriminator,options:Array.from(Re.value.keys()).filter((Ye)=>Re.value.get(Ye)!==null),input:Ue,path:[oe.discriminator],inst:N}),De}}),eu=ht("$ZodIntersection",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie,Re)=>{let De=Ie.value,Le=oe.left._zod.run({value:De,issues:[]},Re),Ue=oe.right._zod.run({value:De,issues:[]},Re);if(Le instanceof Promise||Ue instanceof Promise)return Promise.all([Le,Ue]).then(([Xe,Ye])=>na(Ie,Xe,Ye));return na(Ie,Le,Ue)}});function Fo(N,oe){if(N===oe)return{valid:!0,data:N};if(N instanceof Date&&oe instanceof Date&&+N===+oe)return{valid:!0,data:N};if(jr(N)&&jr(oe)){let Ie=Object.keys(oe),Re=Object.keys(N).filter((Le)=>Ie.indexOf(Le)!==-1),De={...N,...oe};if(Object.prototype.hasOwnProperty.call(De,"__proto__"))delete De.__proto__;for(let Le of Re){if(Le==="__proto__")continue;let Ue=Fo(N[Le],oe[Le]);if(!Ue.valid)return{valid:!1,mergeErrorPath:[Le,...Ue.mergeErrorPath]};De[Le]=Ue.data}return{valid:!0,data:De}}if(Array.isArray(N)&&Array.isArray(oe)){if(N.length!==oe.length)return{valid:!1,mergeErrorPath:[]};let Ie=[];for(let Re=0;Re<N.length;Re++){let De=N[Re],Le=oe[Re],Ue=Fo(De,Le);if(!Ue.valid)return{valid:!1,mergeErrorPath:[Re,...Ue.mergeErrorPath]};Ie.push(Ue.data)}return{valid:!0,data:Ie}}return{valid:!1,mergeErrorPath:[]}}function na(N,oe,Ie){let Re=new Map,De,Le=new Map,Ue=(Ye,Qe)=>{let et;if(Ye.code==="unrecognized_keys"&&!Ye.path?.length)De??(De=Ye),et=Ye.keys;else if(Ye.code==="invalid_key"&&Ye.origin==="record"&&Ye.path?.length===1){let tt=String(Ye.path[0]);if(!Le.has(tt))Le.set(tt,Ye);et=[tt]}else return!1;for(let tt of et){if(!Re.has(tt))Re.set(tt,{});Re.get(tt)[Qe]=!0}return!0};for(let Ye of oe.issues)if(!Ue(Ye,"l"))N.issues.push(Ye);for(let Ye of Ie.issues)if(!Ue(Ye,"r"))N.issues.push(Ye);let Be=[...Re].filter(([,Ye])=>Ye.l&&Ye.r).map(([Ye])=>Ye);if(Be.length){let Ye=De?Be.filter((Qe)=>De.keys.includes(Qe)):[];if(Ye.length)N.issues.push({...De,keys:Ye});for(let Qe of Be)if(!Ye.includes(Qe)&&Le.has(Qe))N.issues.push(Le.get(Qe))}let Xe=Fo(oe.value,Ie.value);if(!Xe.valid){if(gr(N))return N;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(Xe.mergeErrorPath)}`)}return N.value=Xe.data,N}var tu=ht("$ZodTuple",(N,oe)=>{At.init(N,oe);let Ie=oe.items,Re=cr.memoizer;Re?.attach(N),N._zod.parse=(De,Le)=>{let Ue=De.value;if(!Array.isArray(Ue))return De.issues.push({input:Ue,inst:N,expected:"tuple",code:"invalid_type"}),De;De.value=Re?Re.alloc(N,De,[],Le):[];let Be=[],Xe=oa(Ie,"optin"),Ye=oa(Ie,"optout");if(!oe.rest){if(Ue.length<Xe)return De.issues.push({code:"too_small",minimum:Xe,inclusive:!0,input:Ue,inst:N,origin:"array"}),De;if(Ue.length>Ie.length)De.issues.push({code:"too_big",maximum:Ie.length,inclusive:!0,input:Ue,inst:N,origin:"array"})}let Qe=Array(Ie.length),et=oe.rest?Le?.abortEarly:void 0,tt=!1;for(let ft=0;ft<Ie.length;ft++){let gt=Ie[ft]._zod.run({value:Ue[ft],issues:[]},Le);if(gt instanceof Promise)Be.push(gt.then((bt)=>{Qe[ft]=bt}));else if(Qe[ft]=gt,et&&!tt&>.issues.length)tt=gr(gt)}if(oe.rest&&!tt){let ft=Ie.length-1,gt=Ue.slice(Ie.length),bt=De.issues.length;for(let St of gt){if(et&&De.issues.length!==bt){if(gr(De,bt))break;bt=De.issues.length}ft++;let Et=oe.rest._zod.run({value:St,issues:[]},Le);if(Et instanceof Promise)Be.push(Et.then((rr)=>ia(rr,De,ft)));else ia(Et,De,ft)}}if(Be.length)return Promise.all(Be).then(()=>sa(Qe,De,Ie,Ue,Ye));return sa(Qe,De,Ie,Ue,Ye)}});function oa(N,oe){for(let Ie=N.length-1;Ie>=0;Ie--)if(!(oe==="optin"?N[Ie]._zod.optin!==void 0:N[Ie]._zod.optout==="optional"))return Ie+1;return 0}function ia(N,oe,Ie){if(N.issues.length)oe.issues.push(...yr(Ie,N.issues));oe.value[Ie]=N.value}function sa(N,oe,Ie,Re,De){for(let Le=0;Le<Ie.length;Le++){let Ue=N[Le],Be=Le<Re.length;if(!Be&&Le>=De&&Ie[Le]._zod.optin==="optional"){oe.value.length=Le;break}if(Ue.issues.length){if(!Be&&Le>=De){oe.value.length=Le;break}oe.issues.push(...yr(Le,Ue.issues))}oe.value[Le]=Ue.value}for(let Le=oe.value.length-1;Le>=Re.length;Le--)if(Ie[Le]._zod.optout==="optional"&&oe.value[Le]===void 0)oe.value.length=Le;else break;return oe}var ru=ht("$ZodRecord",(N,oe)=>{At.init(N,oe);let Ie=cr.memoizer;Ie?.attach(N),N._zod.parse=(Re,De)=>{let Le=Re.value;if(!jr(Le))return Re.issues.push({expected:"record",code:"invalid_type",input:Le,inst:N}),Re;let Ue=[],Be=oe.keyType._zod.values;if(Be&&!oe.partial){Re.value=Ie?Ie.alloc(N,Re,{},De):{};let Xe=new Set;for(let Qe of Be)if(typeof Qe==="string"||typeof Qe==="number"||typeof Qe==="symbol"){if(Xe.add(typeof Qe==="number"?Qe.toString():Qe),Qe==="__proto__")continue;let et=oe.keyType._zod.run({value:Qe,issues:[]},De);if(et instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(et.issues.length){Re.issues.push({code:"invalid_key",origin:"record",issues:et.issues.map((gt)=>zr(gt,De,pr())),input:Qe,path:[Qe],inst:N});continue}let tt=et.value;if(tt==="__proto__")continue;let ft=oe.valueType._zod.run({value:Le[Qe],issues:[]},De);if(ft instanceof Promise)Ue.push(ft.then((gt)=>{if(gt.issues.length)Re.issues.push(...yr(Qe,gt.issues));Re.value[tt]=gt.value}));else{if(ft.issues.length)Re.issues.push(...yr(Qe,ft.issues));Re.value[tt]=ft.value}}let Ye;for(let Qe in Le)if(!Xe.has(Qe))if(oe.mode==="loose"){if(Qe==="__proto__")continue;Re.value[Qe]=Le[Qe]}else Ye=Ye??[],Ye.push(Qe);if(Ye&&Ye.length>0)Re.issues.push({code:"unrecognized_keys",input:Le,inst:N,keys:Ye,continue:!0})}else{Re.value=Ie?Ie.alloc(N,Re,{},De):{};let Xe;for(let Ye of Reflect.ownKeys(Le)){if(Ye==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(Le,Ye))continue;let Qe=oe.keyType._zod.run({value:Ye,issues:[]},De);if(Qe instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof Ye==="string"&&wn.test(Ye)&&Qe.issues.length){let gt=oe.keyType._zod.run({value:Number(Ye),issues:[]},De);if(gt instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(gt.issues.length===0)Qe=gt}if(Qe.issues.length){if(oe.mode==="loose")Re.value[Ye]=Le[Ye];else if(Be)Xe=Xe??[],Xe.push(Ye);else Re.issues.push({code:"invalid_key",origin:"record",issues:Qe.issues.map((gt)=>zr(gt,De,pr())),input:Ye,path:[Ye],inst:N});continue}let tt=Qe.value;if(tt==="__proto__")continue;let ft=oe.valueType._zod.run({value:Le[Ye],issues:[]},De);if(ft instanceof Promise)Ue.push(ft.then((gt)=>{if(gt.issues.length)Re.issues.push(...yr(Ye,gt.issues));Re.value[tt]=gt.value}));else{if(ft.issues.length)Re.issues.push(...yr(Ye,ft.issues));Re.value[tt]=ft.value}}if(Xe&&Xe.length>0)Re.issues.push({code:"unrecognized_keys",input:Le,inst:N,keys:Xe,continue:!0})}if(Ue.length)return Promise.all(Ue).then(()=>Re);return Re}});var nu=ht("$ZodEnum",(N,oe)=>{At.init(N,oe);let Ie=Qr(oe.entries),Re=new Set(Ie);N._zod.values=Re,Tt(N,"pattern",(De)=>{let Le=Qr(De.def.entries).filter((Ue)=>Ls.has(typeof Ue));return new RegExp(Le.length?`^(${Le.map((Ue)=>Nr(Ue.toString())).join("|")})$`:"^[^\\s\\S]$")}),N._zod.parse=(De,Le)=>{let Ue=De.value;if(Re.has(Ue))return De;return De.issues.push({code:"invalid_value",values:Ie,input:Ue,inst:N}),De}}),ou=ht("$ZodLiteral",(N,oe)=>{At.init(N,oe);let Ie=new Set(oe.values);N._zod.values=Ie,Tt(N,"pattern",(Re)=>{let De=Re.def.values;return new RegExp(De.length?`^(${De.map((Le)=>typeof Le==="string"?Nr(Le):Le?Nr(Le.toString()):String(Le)).join("|")})$`:"^[^\\s\\S]$")}),N._zod.parse=(Re,De)=>{let Le=Re.value;if(Ie.has(Le))return Re;return Re.issues.push({code:"invalid_value",values:oe.values,input:Le,inst:N}),Re}});var iu=ht("$ZodTransform",(N,oe)=>{At.init(N,oe),N._zod.optin="optional",cr.memoizer?.guard(N),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")throw new xn(N.constructor.name);let De=oe.transform(Ie.value,Ie);if(Re.async)return(De instanceof Promise?De:Promise.resolve(De)).then((Ue)=>(Ie.value=Ue,Ie));if(De instanceof Promise)throw new Sr;return Ie.value=De,Ie}});function ca(N,oe){return N.value=oe.issues.length?void 0:oe.value,N}var Wo=ht("$ZodOptional",(N,oe)=>{At.init(N,oe),Tt(N,"optin",(Ie)=>Ie.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),N._zod.optout="optional",Tt(N,"values",(Ie)=>{let Re=Ie.def.innerType._zod.values;return Re?new Set([...Re,void 0]):void 0}),Tt(N,"pattern",(Ie)=>{let Re=Ie.def.innerType._zod.pattern;return Re?new RegExp(`^(${Mn(Re.source)})?$`):void 0}),N._zod.parse=(Ie,Re)=>{if(Ie.value===void 0){if(oe.innerType._zod.optin!=="defaulted")return Ie;let De=oe.innerType._zod.run({value:Ie.value,issues:[]},Re);if(De instanceof Promise)return De.then((Le)=>ca(Ie,Le));return ca(Ie,De)}return oe.innerType._zod.run(Ie,Re)}}),su=ht("$ZodExactOptional",(N,oe)=>{Wo.init(N,oe),Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),Tt(N,"pattern",(Ie)=>Ie.def.innerType._zod.pattern),N._zod.parse=(Ie,Re)=>oe.innerType._zod.run(Ie,Re)}),cu=ht("$ZodNullable",(N,oe)=>{At.init(N,oe),Tt(N,"optin",(Ie)=>Ie.def.innerType._zod.optin),Tt(N,"optout",(Ie)=>Ie.def.innerType._zod.optout),Tt(N,"pattern",(Ie)=>{let Re=Ie.def.innerType._zod.pattern;return Re?new RegExp(`^(${Mn(Re.source)}|null)$`):void 0}),Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values?new Set([...Ie.def.innerType._zod.values,null]):void 0),N._zod.parse=(Ie,Re)=>{if(Ie.value===null)return Ie;return oe.innerType._zod.run(Ie,Re)}}),au=ht("$ZodDefault",(N,oe)=>{At.init(N,oe),N._zod.optin="defaulted",Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")return oe.innerType._zod.run(Ie,Re);if(Ie.value===void 0)return Ie.value=oe.defaultValue,Ie;let De=oe.innerType._zod.run(Ie,Re);if(De instanceof Promise)return De.then((Le)=>aa(Le,oe));return aa(De,oe)}});function aa(N,oe){if(N.value===void 0)N.value=oe.defaultValue;return N}var uu=ht("$ZodPrefault",(N,oe)=>{At.init(N,oe),N._zod.optin="defaulted",Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")return oe.innerType._zod.run(Ie,Re);if(Ie.value===void 0)Ie.value=oe.defaultValue;return oe.innerType._zod.run(Ie,Re)}}),lu=ht("$ZodNonOptional",(N,oe)=>{At.init(N,oe),Tt(N,"values",(Ie)=>{let Re=Ie.def.innerType._zod.values;return Re?new Set([...Re].filter((De)=>De!==void 0)):void 0}),N._zod.parse=(Ie,Re)=>{let De=oe.innerType._zod.run(Ie,Re);if(De instanceof Promise)return De.then((Le)=>ua(Le,N));return ua(De,N)}});function ua(N,oe){if(!N.issues.length&&N.value===void 0)N.issues.push({code:"invalid_type",expected:"nonoptional",input:N.value,inst:oe});return N}function la(N,oe,Ie,Re){if(!oe.issues.length){if(N.value=oe.value,oe.memo)N.memo=!0;return N}return N.value=Ie.catchValue({...oe,value:N.value,error:{issues:oe.issues.map((De)=>zr(De,Re,pr()))},input:N.value}),N}var fu=ht("$ZodCatch",(N,oe)=>{At.init(N,oe),Tt(N,"optin",(Ie)=>Ie.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Tt(N,"optout",(Ie)=>Ie.def.innerType._zod.optout),Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")return oe.innerType._zod.run(Ie,Re);let De=oe.innerType._zod.run({value:Ie.value,issues:[]},Re);if(De instanceof Promise)return De.then((Le)=>la(Ie,Le,oe,Re));return la(Ie,De,oe,Re)}});var pu=ht("$ZodPipe",(N,oe)=>{At.init(N,oe),Tt(N,"values",(Ie)=>Ie.def.in._zod.values),Tt(N,"optin",(Ie)=>Ie.def.in._zod.optin),Tt(N,"optout",(Ie)=>Ie.def.out._zod.optout),Tt(N,"propValues",(Ie)=>Ie.def.in._zod.propValues),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward"){let Le=oe.out._zod.run(Ie,Re);if(Le instanceof Promise)return Le.then((Ue)=>Xn(Ue,oe.in,Re));return Xn(Le,oe.in,Re)}let De=oe.in._zod.run(Ie,Re);if(De instanceof Promise)return De.then((Le)=>Xn(Le,oe.out,Re));return Xn(De,oe.out,Re)}});function Xn(N,oe,Ie){if(N.issues.some((Re)=>Re.code!=="unrecognized_keys"))return N.aborted=!0,N;return oe._zod.run({value:N.value,issues:N.issues},Ie)}var du=ht("$ZodReadonly",(N,oe)=>{At.init(N,oe),Tt(N,"propValues",(Ie)=>Ie.def.innerType._zod.propValues),Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),Tt(N,"optin",(Ie)=>Ie.def.innerType?._zod?.optin),Tt(N,"optout",(Ie)=>Ie.def.innerType?._zod?.optout),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")return oe.innerType._zod.run(Ie,Re);let De=oe.innerType._zod.run(Ie,Re);if(De instanceof Promise)return De.then(fa);return fa(De)}});function fa(N){if(!N.memo)N.value=Object.freeze(N.value);return N}var mu=ht("$ZodLazy",(N,oe)=>{At.init(N,oe),Is(N._zod,"innerType",()=>{let Ie=oe;if(!Ie._cachedInner)Ie._cachedInner=oe.getter();return Ie._cachedInner}),Tt(N,"pattern",(Ie)=>Ie.innerType?._zod?.pattern),Tt(N,"propValues",(Ie)=>Ie.innerType?._zod?.propValues),Tt(N,"optin",(Ie)=>Ie.innerType?._zod?.optin??void 0),Tt(N,"optout",(Ie)=>Ie.innerType?._zod?.optout??void 0),N._zod.parse=(Ie,Re)=>N._zod.innerType._zod.run(Ie,Re)}),hu=ht("$ZodCustom",(N,oe)=>{or.init(N,oe),At.init(N,oe),N._zod.parse=(Ie,Re)=>Ie,N._zod.check=(Ie)=>{let Re=Ie.value,De=oe.fn(Re);if(De instanceof Promise)return De.then((Le)=>pa(Le,Ie,Re,N));pa(De,Ie,Re,N);return}});function pa(N,oe,Ie,Re){if(!N){let De={code:"custom",input:Ie,inst:Re,path:[...Re._zod.def.path??[]],continue:!Re._zod.def.abort};if(Re._zod.def.params)De.params=Re._zod.def.params;oe.issues.push(Fr(De))}}class yu extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Ho="~memo",gu=[];function _u(N){return N!==null&&typeof N==="object"}function Ko(N){return N.map((oe)=>oe.path?{...oe,path:oe.path.slice()}:{...oe})}var vu=new WeakMap,Sn=0,oo=1,kn=2;function io(N,oe,Ie){let Re=vu.get(N);if(Re!==void 0)return Re?kn:Sn;if(oe.has(N))return kn;oe.add(N);let De=Sn,Le=(Qe)=>{if(De!==kn&&Qe?._zod){let et=io(Qe,oe,Ie);if(et>De)De=et}},Ue=(Qe,et)=>{let tt=Sn;for(let ft of Reflect.ownKeys(Qe)){let gt=Object.getOwnPropertyDescriptor(Qe,ft);if(et&&!gt.enumerable)continue;let bt=gt.get?oo:gt.value?._zod?io(gt.value,oe,Ie):Sn;if(bt>tt)tt=bt}return tt},Be=(Qe)=>{if(Qe>De)De=Qe},Xe=N._zod.def,Ye=Xe.type;switch(Ye){case"object":{let Qe=_n(Xe);Be(Qe?Ue(Qe,!0):oo),Le(Xe.catchall);break}case"array":Le(Xe.element);break;case"tuple":for(let Qe of Xe.items)Le(Qe);Le(Xe.rest);break;case"record":case"map":Le(Xe.keyType),Le(Xe.valueType);break;case"set":Le(Xe.valueType);break;case"union":for(let Qe of Xe.options)Le(Qe);break;case"intersection":Le(Xe.left),Le(Xe.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":Le(Xe.innerType);break;case"pipe":Le(Xe.in),Le(Xe.out);break;case"function":Le(Xe.input),Le(Xe.output);break;case"lazy":{let Qe=Xe._cachedInner??(Ie?N._zod.innerType:void 0);Be(Qe?io(Qe,oe,!1):oo);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let Qe in Xe){let et=Object.getOwnPropertyDescriptor(Xe,Qe);if(!et||et.get)continue;let tt=et.value;if(!tt||typeof tt!=="object")continue;if(tt._zod)Le(tt);else if(Array.isArray(tt))for(let ft of tt)Le(ft)}}return oe.delete(N),Np(N,De)}function Np(N,oe){if(oe!==oo)vu.set(N,oe===kn);return oe}function Rp(N,oe){let Ie=N.buckets.get(oe);if(!Ie)Ie=new WeakMap,N.buckets.set(oe,Ie);return Ie}var ro,no=[],Dp={alloc(N,oe,Ie){let Re=ro;if(!Re)return Ie;ro=void 0;let De={value:Ie,issues:null};return Re.set(oe.value,De),no.push(De),Ie},guard(N){var oe;(oe=N._zod).deferred??(oe.deferred=[]),N._zod.deferred.push(()=>{let Ie=N._zod.parse,Re=(De,Le)=>{if(Le.direction!=="backward"&&Mp(Le,De.value))throw new yu;return Ie(De,Le)};if(N._zod.parse=Re,N._zod.run===Ie)N._zod.run=Re})},attach(N){var oe;let Ie,Re=!1,De,Le;(oe=N._zod).deferred??(oe.deferred=[]),N._zod.deferred.push(()=>{let Ue=N._zod.parse,Be=(Xe,Ye)=>{if(Ie===void 0){let Et=io(N,new Set,!1);if(Et===Sn){if(N._zod.parse=Ue,N._zod.run===Be)N._zod.run=Ue;return Ue(Xe,Ye)}if(Et===kn||Re)Ie=!0;else Re=!0}let Qe=Xe.value;if(!_u(Qe))return Ue(Xe,Ye);let et=Ye[Ho];if(!et)et={buckets:new WeakMap,backEdges:void 0},Ye[Ho]=et;let tt;if(De===Ye)tt=Le;else tt=Rp(et,N),De=Ye,Le=tt;let ft=tt.get(Qe);if(ft){if(Xe.value=ft.value,ft.issues){if(ft.issues.length)Xe.issues.push(...Ko(ft.issues))}else Xe.memo=!0,et.backEdges??(et.backEdges=new WeakSet),et.backEdges.add(ft.value);return Xe}ro=tt;let gt=no.length,bt=Ue(Xe,Ye);ro=void 0;let St=no.length>gt?no.pop():void 0;if(bt instanceof Promise)return bt.then((Et)=>{if(St)St.issues=Et.issues.length?Ko(Et.issues):gu;return Et});if(St)St.issues=bt.issues.length?Ko(bt.issues):gu;return bt};if(N._zod.parse=Be,N._zod.run===Ue)N._zod.run=Be})}};function bu(){return Dp}function Mp(N,oe){let Ie=N[Ho]?.backEdges;return Ie!==void 0&&_u(oe)&&Ie.has(oe)}var Lp=()=>{let N={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function oe(Le){return N[Le]??null}let Ie={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},Re={nan:"NaN"};function De(Le,Ue){if(Le==="number"&&typeof Ue==="number"&&!Number.isFinite(Ue))return String(Ue);return Re[Le]??Le}return(Le)=>{switch(Le.code){case"invalid_type":{let Ue=De(Le.expected),Be=Js(Le.input),Xe=De(Be,Le.input);return`Invalid input: expected ${Ue}, received ${Xe}`}case"invalid_value":if(Le.values.length===1)return`Invalid input: expected ${ko(Le.values[0])}`;return`Invalid option: expected one of ${$o(Le.values,"|")}`;case"too_big":{let Ue=Le.exact?"exactly ":Le.inclusive?"<=":"<",Be=oe(Le.origin);if(Be)return`Too big: expected ${Le.origin??"value"} to have ${Ue}${Le.maximum.toString()} ${Be.unit??"elements"}`;return`Too big: expected ${Le.origin??"value"} to be ${Ue}${Le.maximum.toString()}`}case"too_small":{let Ue=Le.exact?"exactly ":Le.inclusive?">=":">",Be=oe(Le.origin);if(Be)return`Too small: expected ${Le.origin} to have ${Ue}${Le.minimum.toString()} ${Be.unit}`;return`Too small: expected ${Le.origin} to be ${Ue}${Le.minimum.toString()}`}case"invalid_format":{let Ue=Le;if(Ue.format==="starts_with")return`Invalid string: must start with "${Ue.prefix}"`;if(Ue.format==="ends_with")return`Invalid string: must end with "${Ue.suffix}"`;if(Ue.format==="includes")return`Invalid string: must include "${Ue.includes}"`;if(Ue.format==="regex")return`Invalid string: must match pattern ${Ue.pattern}`;return`Invalid ${Ie[Ue.format]??Le.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${Le.divisor}`;case"unrecognized_keys":return`Unrecognized key${Le.keys.length>1?"s":""}: ${$o(Le.keys,", ")}`;case"invalid_key":return`Invalid key in ${Le.origin}`;case"invalid_union":if(Le.options&&Array.isArray(Le.options)&&Le.options.length>0)return`Invalid discriminator value. Expected ${Le.options.map((Be)=>`'${Be}'`).join(" | ")}`;if(Le.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${Le.origin}`;default:return"Invalid input"}}};function qo(){return{localeError:Lp()}}var xu;class wu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(N,...oe){let Ie=oe[0];if(this._map.set(N,Ie),Ie&&typeof Ie==="object"&&"id"in Ie)this._idmap.set(Ie.id,N);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(N){let oe=this._map.get(N);if(oe&&typeof oe==="object"&&"id"in oe)this._idmap.delete(oe.id);return this._map.delete(N),this}get(N){let oe=N._zod.parent;if(oe){let Ie={...this.get(oe)??{}};delete Ie.id;let Re={...Ie,...this._map.get(N)};return Object.keys(Re).length?Re:void 0}return this._map.get(N)}has(N){return this._map.has(N)}}function jp(){return new wu}(xu=globalThis).__zod_globalRegistry??(xu.__zod_globalRegistry=jp());var Ur=globalThis.__zod_globalRegistry;function so(N){if(N.checks)N.checks=[...N.checks];return N}function $u(N,oe){return new N(so({type:"string",...zt(oe)}))}function Ut(N,oe){return new N(so({type:"string",coerce:!0,...zt(oe)}))}function zu(N,oe){return new N({type:"string",format:"email",check:"string_format",abort:!1,...zt(oe)})}function Su(N,oe){return new N({type:"string",format:"guid",check:"string_format",abort:!1,...zt(oe)})}function ku(N,oe){return new N({type:"string",format:"uuid",check:"string_format",abort:!1,...zt(oe)})}function Pu(N,oe){return new N({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...zt(oe)})}function Eu(N,oe){return new N({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...zt(oe)})}function Ou(N,oe){return new N({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...zt(oe)})}function Tu(N,oe){return new N({type:"string",format:"url",check:"string_format",abort:!1,...zt(oe)})}function Zu(N,oe){return new N({type:"string",format:"emoji",check:"string_format",abort:!1,...zt(oe)})}function Au(N,oe){return new N({type:"string",format:"nanoid",check:"string_format",abort:!1,...zt(oe)})}function Iu(N,oe){return new N({type:"string",format:"cuid",check:"string_format",abort:!1,...zt(oe)})}function Cu(N,oe){return new N({type:"string",format:"cuid2",check:"string_format",abort:!1,...zt(oe)})}function Nu(N,oe){return new N({type:"string",format:"ulid",check:"string_format",abort:!1,...zt(oe)})}function Ru(N,oe){return new N({type:"string",format:"xid",check:"string_format",abort:!1,...zt(oe)})}function Du(N,oe){return new N({type:"string",format:"ksuid",check:"string_format",abort:!1,...zt(oe)})}function Mu(N,oe){return new N({type:"string",format:"ipv4",check:"string_format",abort:!1,...zt(oe)})}function Lu(N,oe){return new N({type:"string",format:"ipv6",check:"string_format",abort:!1,...zt(oe)})}function ju(N,oe){return new N({type:"string",format:"cidrv4",check:"string_format",abort:!1,...zt(oe)})}function Fu(N,oe){return new N({type:"string",format:"cidrv6",check:"string_format",abort:!1,...zt(oe)})}function Uu(N,oe){return new N({type:"string",format:"base64",check:"string_format",abort:!1,...zt(oe)})}function Bu(N,oe){return new N({type:"string",format:"base64url",check:"string_format",abort:!1,...zt(oe)})}function Ju(N,oe){return new N({type:"string",format:"e164",check:"string_format",abort:!1,...zt(oe)})}function Vu(N,oe){return new N({type:"string",format:"jwt",check:"string_format",abort:!1,...zt(oe)})}function Wu(N,oe){return new N({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...zt(oe)})}function Ku(N,oe){return new N({type:"string",format:"date",check:"string_format",...zt(oe)})}function Hu(N,oe){return new N({type:"string",format:"time",check:"string_format",precision:null,...zt(oe)})}function qu(N,oe){return new N({type:"string",format:"duration",check:"string_format",...zt(oe)})}function Gu(N,oe){return new N(so({type:"number",checks:[],...zt(oe)}))}function Gt(N,oe){return new N(so({type:"number",coerce:!0,checks:[],...zt(oe)}))}function Xu(N,oe){return new N({type:"number",check:"number_format",abort:!1,format:"safeint",...zt(oe)})}function Yu(N,oe){return new N({type:"boolean",...zt(oe)})}function Vt(N,oe){return new N({type:"boolean",coerce:!0,...zt(oe)})}function Wt(N,oe){return new N({type:"bigint",coerce:!0,...zt(oe)})}function Qu(N,oe){return new N({type:"null",...zt(oe)})}function el(N){return new N({type:"any"})}function tl(N){return new N({type:"unknown"})}function rl(N,oe){return new N({type:"never",...zt(oe)})}function Ht(N,oe){return new N({type:"date",coerce:!0,...zt(oe)})}function Wr(N,oe){return new Mo({check:"less_than",...zt(oe),value:N,inclusive:!1})}function Tr(N,oe){return new Mo({check:"less_than",...zt(oe),value:N,inclusive:!0})}function Kr(N,oe){return new Lo({check:"greater_than",...zt(oe),value:N,inclusive:!1})}function Zr(N,oe){return new Lo({check:"greater_than",...zt(oe),value:N,inclusive:!0})}function Pn(N,oe){return new Lc({check:"multiple_of",...zt(oe),value:N})}function co(N,oe){return new Fc({check:"max_length",...zt(oe),maximum:N})}function Hr(N,oe){return new Uc({check:"min_length",...zt(oe),minimum:N})}function ao(N,oe){return new Bc({check:"length_equals",...zt(oe),length:N})}function Go(N,oe){return new Jc({check:"string_format",format:"regex",...zt(oe),pattern:N})}function Xo(N){return new Vc({check:"string_format",format:"lowercase",...zt(N)})}function Yo(N){return new Wc({check:"string_format",format:"uppercase",...zt(N)})}function Qo(N,oe){return new Kc({check:"string_format",format:"includes",...zt(oe),includes:N})}function ei(N,oe){return new Hc({check:"string_format",format:"starts_with",...zt(oe),prefix:N})}function ti(N,oe){return new qc({check:"string_format",format:"ends_with",...zt(oe),suffix:N})}function ri(N,oe){return new Gc({check:"properties",shape:N,...zt(oe)})}function Rr(N){return new Xc({check:"overwrite",tx:N})}function ni(N){return Rr((oe)=>oe.normalize(N))}function oi(){return Rr((N)=>N.trim())}function ii(){return Rr((N)=>N.toLowerCase())}function si(){return Rr((N)=>N.toUpperCase())}function ci(){return Rr((N)=>Ds(N))}function nl(N,oe,Ie){return new N({type:"array",element:oe,...zt(Ie)})}function ol(N,oe,Ie){let Re=zt(Ie);return Re.abort??(Re.abort=!0),new N({type:"custom",check:"custom",fn:oe,...Re})}function il(N,oe,Ie){return new N({type:"custom",check:"custom",fn:oe,...zt(Ie)})}function sl(N,oe){let Ie=Fp((Re)=>(Re.addIssue=(De)=>{if(typeof De==="string")Re.issues.push(Fr(De,Re.value,Ie._zod.def));else{let Le=De;if(Le.fatal)Le.continue=!1;if(Le.code??(Le.code="custom"),!("input"in Le))Le.input=Re.value;Le.inst??(Le.inst=Ie),Le.continue??(Le.continue=!Ie._zod.def.abort),Re.issues.push(Fr(Le))}},N(Re.value,Re)),oe);return Ie}function Fp(N,oe){let Ie=new or({check:"custom",...zt(oe)});return Ie._zod.check=N,Ie}function En(N,...oe){for(let Ie of oe)for(let Re of Reflect.ownKeys(Ie))if(Object.prototype.propertyIsEnumerable.call(Ie,Re))lr(N,Re,Ie[Re]);return N}function Tn(N){let oe=N?.target??"draft-2020-12";if(oe==="draft-4")oe="draft-04";if(oe==="draft-7")oe="draft-07";return{processors:N.processors??{},metadataRegistry:N?.metadata??Ur,target:oe,unrepresentable:N?.unrepresentable??"throw",override:N?.override??(()=>{}),io:N?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:N?.cycles??"ref",reused:N?.reused??"inline",intersections:[],deferred:[],external:N?.external??void 0}}function ir(N,oe,Ie,Re,De){let Le=typeof oe.unrepresentable==="function"?oe.unrepresentable({zodSchema:N,path:Re.path,message:De}):oe.unrepresentable;if(Le==="any")return!1;if(Le===void 0||Le==="throw")throw Error(De);return Object.assign(Ie,Le),!0}function Dt(N,oe,Ie={path:[],schemaPath:[]}){var Re;let De=N._zod.def,Le=oe.seen.get(N);if(Le){if(Le.count++,Ie.schemaPath.includes(N))Le.cycle=Ie.path;return Le.schema}let Ue={schema:{},count:1,cycle:void 0,path:Ie.path};oe.seen.set(N,Ue),oe.sharedDefsExtractedFor=void 0,oe.sharedEmitDoneFor=void 0;let Be=N._zod.toJSONSchema?.();if(Be)Ue.schema=Be;else{let Qe={...Ie,schemaPath:[...Ie.schemaPath,N],path:Ie.path};if(N._zod.processJSONSchema)N._zod.processJSONSchema(oe,Ue.schema,Qe);else{let tt=Ue.schema,ft=oe.processors[De.type];if(!ft)throw Error(`[toJSONSchema]: Non-representable type encountered: ${De.type}`);ft(N,oe,tt,Qe)}let et=N._zod.parent;if(et){if(!Ue.ref)Ue.ref=et;Dt(et,oe,Qe),oe.seen.get(et).isParent=!0}}let Xe=oe.metadataRegistry.get(N);if(Xe)En(Ue.schema,Xe);if(oe.io==="input"&&ar(N))delete Ue.schema.examples,delete Ue.schema.default;if(oe.io==="input"&&"_prefault"in Ue.schema)(Re=Ue.schema).default??(Re.default=Ue.schema._prefault);return delete Ue.schema._prefault,oe.seen.get(N).schema}function cl(N){return N.replace(/~/g,"~0").replace(/\//g,"~1")}function Zn(N,oe){let Ie=N.seen.get(oe);if(!Ie)throw Error("Unprocessed schema. This is a bug in Zod.");if(N.external&&N.sharedDefsExtractedFor===N.external)return;let Re=new Map;for(let Ue of N.seen.entries()){let Be=N.metadataRegistry.get(Ue[0])?.id;if(Be){let Xe=Re.get(Be);if(Xe&&Xe!==Ue[0])throw Error(`Duplicate schema id "${Be}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);Re.set(Be,Ue[0])}}let De=(Ue)=>{let Be=N.target==="draft-2020-12"?"$defs":"definitions";if(N.external){let et=N.external.registry.get(Ue[0])?.id,tt=N.external.uri??((gt)=>gt);if(et)return{ref:tt(et)};let ft=Ue[1].defId??Ue[1].schema.id??`schema${N.counter++}`;return Ue[1].defId=ft,{defId:ft,ref:`${tt("__shared")}#/${Be}/${cl(ft)}`}}let Xe="#",Ye=`${Xe}/${Be}/`;if(Ue[1]===Ie&&!Ue[1].schema.id)return{ref:Xe};let Qe=Ue[1].schema.id??`__schema${N.counter++}`;return{defId:Qe,ref:Ye+cl(Qe)}},Le=(Ue)=>{if(Ue[1].schema.$ref)return;let Be=Ue[1],{ref:Xe,defId:Ye}=De(Ue);if(Be.def={...Be.schema},Ye)Be.defId=Ye;let Qe=Be.schema;for(let et in Qe)delete Qe[et];Qe.$ref=Xe};if(N.cycles==="throw")for(let Ue of N.seen.entries()){let Be=Ue[1];if(Be.cycle)throw Error(`Cycle detected: #/${Be.cycle?.join("/")}/<root>
|
|
57
|
+
`)}return St.write("payload.value = newResult;"),St.write("return payload;"),St.compile()},Ue,Be=Br,Xe=!ir.jitless,Qe=Xe&&Ms.value,et=oe.catchall,tt;N._zod.parse=(ft,gt)=>{tt??(tt=Re.value);let bt=ft.value;if(!Be(bt))return ft.issues.push({expected:"object",code:"invalid_type",input:bt,inst:N}),ft;if(Xe&&Qe&>?.async===!1&>.jitless!==!0){if(!Ue)Ue=Le(oe.shape);if(ft=Ue(ft,gt),!et)return ft;return Xa([],bt,ft,gt,tt,N,gt?.abortEarly===!0)}return Ie(ft,gt)}});function ra(N,oe,Ie,Re){for(let Le of N)if(Le.issues.length===0)return oe.value=Le.value,oe;let De=N.filter((Le)=>!mr(Le));if(De.length===1)return oe.value=De[0].value,De[0];return oe.issues.push({code:"invalid_union",input:oe.value,inst:Ie,errors:N.map((Le)=>Le.issues.map((Ue)=>wr(Ue,Re,lr())))}),oe}var Vo=ht("$ZodUnion",(N,oe)=>{At.init(N,oe),Tt(N,"optin",(Re)=>Re.def.options.some((De)=>De._zod.optin==="defaulted")?"defaulted":Re.def.options.some((De)=>De._zod.optin!==void 0)?"optional":void 0),Tt(N,"optout",(Re)=>Re.def.options.some((De)=>De._zod.optout==="optional")?"optional":void 0),Tt(N,"values",(Re)=>{if(Re.def.options.every((De)=>De._zod.values))return new Set(Re.def.options.flatMap((De)=>Array.from(De._zod.values)));return}),Tt(N,"pattern",(Re)=>{if(Re.def.options.every((De)=>De._zod.pattern)){let De=Re.def.options.map((Le)=>Le._zod.pattern);return new RegExp(`^(${De.map((Le)=>Mn(Le.source)).join("|")})$`)}return});let Ie=oe.options.length===1?oe.options[0]._zod.run:null;N._zod.parse=(Re,De)=>{if(Ie)return Ie(Re,De);let Le=!1,Ue=[];for(let Be of oe.options){let Xe=Be._zod.run({value:Re.value,issues:[]},De);if(Xe instanceof Promise)Ue.push(Xe),Le=!0;else{if(Xe.issues.length===0)return Xe;Ue.push(Xe)}}if(!Le)return ra(Ue,Re,N,De);return Promise.all(Ue).then((Be)=>ra(Be,Re,N,De))}});function Cp(N){let oe=new Map;for(let Ie of N.options){let Re=Ie._zod.propValues?.[N.discriminator];if(!Re||Re.size===0)throw Error(`Invalid discriminated union option at index "${N.options.indexOf(Ie)}"`);for(let De of Re)if(oe.has(De)){if(De!==void 0)throw Error(`Duplicate discriminator value "${String(De)}"`);oe.set(De,null)}else oe.set(De,Ie)}return oe}var Qa=ht("$ZodDiscriminatedUnion",(N,oe)=>{oe.inclusive=!1,Vo.init(N,oe);let Ie=N._zod.parse;Tt(N,"propValues",(De)=>{let Le={},Ue=0;for(let Be of De.def.options){let Xe=Be._zod.propValues;if(!Xe||Object.keys(Xe).length===0)throw Error(`Invalid discriminated union option at index "${De.def.options.indexOf(Be)}"`);if(Xe[De.def.discriminator]?.has(void 0))Ue++;for(let[Ye,Qe]of Object.entries(Xe)){if(!Object.prototype.hasOwnProperty.call(Le,Ye))ar(Le,Ye,new Set);for(let et of Qe)Le[Ye].add(et)}}if(!De.def.unionFallback&&Ue>1)Le[De.def.discriminator]?.delete(void 0);return Le}),oe.options.forEach((De,Le)=>{let Ue=yn(De._zod.def);if(Ue&&!Object.prototype.hasOwnProperty.call(Ue,oe.discriminator))throw Error(`Invalid discriminated union option at index "${Le}"`)});let Re=Qr(()=>Cp(oe));N._zod.parse=(De,Le)=>{let Ue=De.value;if(!Br(Ue))return De.issues.push({code:"invalid_type",expected:"object",input:Ue,inst:N}),De;let Be=Ue?.[oe.discriminator],Xe=Re.value.get(Be);if(Xe&&(Be!==void 0||Le.direction!=="backward"))return Xe._zod.run(De,Le);if(oe.unionFallback||Le.direction==="backward")return Ie(De,Le);return De.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:oe.discriminator,options:Array.from(Re.value.keys()).filter((Ye)=>Re.value.get(Ye)!==null),input:Ue,path:[oe.discriminator],inst:N}),De}}),eu=ht("$ZodIntersection",(N,oe)=>{At.init(N,oe),N._zod.parse=(Ie,Re)=>{let De=Ie.value,Le=oe.left._zod.run({value:De,issues:[]},Re),Ue=oe.right._zod.run({value:De,issues:[]},Re);if(Le instanceof Promise||Ue instanceof Promise)return Promise.all([Le,Ue]).then(([Xe,Ye])=>na(Ie,Xe,Ye));return na(Ie,Le,Ue)}});function Fo(N,oe){if(N===oe)return{valid:!0,data:N};if(N instanceof Date&&oe instanceof Date&&+N===+oe)return{valid:!0,data:N};if(Mr(N)&&Mr(oe)){let Ie=Object.keys(oe),Re=Object.keys(N).filter((Le)=>Ie.indexOf(Le)!==-1),De={...N,...oe};if(Object.prototype.hasOwnProperty.call(De,"__proto__"))delete De.__proto__;for(let Le of Re){if(Le==="__proto__")continue;let Ue=Fo(N[Le],oe[Le]);if(!Ue.valid)return{valid:!1,mergeErrorPath:[Le,...Ue.mergeErrorPath]};De[Le]=Ue.data}return{valid:!0,data:De}}if(Array.isArray(N)&&Array.isArray(oe)){if(N.length!==oe.length)return{valid:!1,mergeErrorPath:[]};let Ie=[];for(let Re=0;Re<N.length;Re++){let De=N[Re],Le=oe[Re],Ue=Fo(De,Le);if(!Ue.valid)return{valid:!1,mergeErrorPath:[Re,...Ue.mergeErrorPath]};Ie.push(Ue.data)}return{valid:!0,data:Ie}}return{valid:!1,mergeErrorPath:[]}}function na(N,oe,Ie){let Re=new Map,De,Le=new Map,Ue=(Ye,Qe)=>{let et;if(Ye.code==="unrecognized_keys"&&!Ye.path?.length)De??(De=Ye),et=Ye.keys;else if(Ye.code==="invalid_key"&&Ye.origin==="record"&&Ye.path?.length===1){let tt=String(Ye.path[0]);if(!Le.has(tt))Le.set(tt,Ye);et=[tt]}else return!1;for(let tt of et){if(!Re.has(tt))Re.set(tt,{});Re.get(tt)[Qe]=!0}return!0};for(let Ye of oe.issues)if(!Ue(Ye,"l"))N.issues.push(Ye);for(let Ye of Ie.issues)if(!Ue(Ye,"r"))N.issues.push(Ye);let Be=[...Re].filter(([,Ye])=>Ye.l&&Ye.r).map(([Ye])=>Ye);if(Be.length){let Ye=De?Be.filter((Qe)=>De.keys.includes(Qe)):[];if(Ye.length)N.issues.push({...De,keys:Ye});for(let Qe of Be)if(!Ye.includes(Qe)&&Le.has(Qe))N.issues.push(Le.get(Qe))}let Xe=Fo(oe.value,Ie.value);if(!Xe.valid){if(mr(N))return N;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(Xe.mergeErrorPath)}`)}return N.value=Xe.data,N}var tu=ht("$ZodTuple",(N,oe)=>{At.init(N,oe);let Ie=oe.items,Re=ir.memoizer;Re?.attach(N),N._zod.parse=(De,Le)=>{let Ue=De.value;if(!Array.isArray(Ue))return De.issues.push({input:Ue,inst:N,expected:"tuple",code:"invalid_type"}),De;De.value=Re?Re.alloc(N,De,[],Le):[];let Be=[],Xe=oa(Ie,"optin"),Ye=oa(Ie,"optout");if(!oe.rest){if(Ue.length<Xe)return De.issues.push({code:"too_small",minimum:Xe,inclusive:!0,input:Ue,inst:N,origin:"array"}),De;if(Ue.length>Ie.length)De.issues.push({code:"too_big",maximum:Ie.length,inclusive:!0,input:Ue,inst:N,origin:"array"})}let Qe=Array(Ie.length),et=oe.rest?Le?.abortEarly:void 0,tt=!1;for(let ft=0;ft<Ie.length;ft++){let gt=Ie[ft]._zod.run({value:Ue[ft],issues:[]},Le);if(gt instanceof Promise)Be.push(gt.then((bt)=>{Qe[ft]=bt}));else if(Qe[ft]=gt,et&&!tt&>.issues.length)tt=mr(gt)}if(oe.rest&&!tt){let ft=Ie.length-1,gt=Ue.slice(Ie.length),bt=De.issues.length;for(let St of gt){if(et&&De.issues.length!==bt){if(mr(De,bt))break;bt=De.issues.length}ft++;let Et=oe.rest._zod.run({value:St,issues:[]},Le);if(Et instanceof Promise)Be.push(Et.then((er)=>ia(er,De,ft)));else ia(Et,De,ft)}}if(Be.length)return Promise.all(Be).then(()=>sa(Qe,De,Ie,Ue,Ye));return sa(Qe,De,Ie,Ue,Ye)}});function oa(N,oe){for(let Ie=N.length-1;Ie>=0;Ie--)if(!(oe==="optin"?N[Ie]._zod.optin!==void 0:N[Ie]._zod.optout==="optional"))return Ie+1;return 0}function ia(N,oe,Ie){if(N.issues.length)oe.issues.push(...hr(Ie,N.issues));oe.value[Ie]=N.value}function sa(N,oe,Ie,Re,De){for(let Le=0;Le<Ie.length;Le++){let Ue=N[Le],Be=Le<Re.length;if(!Be&&Le>=De&&Ie[Le]._zod.optin==="optional"){oe.value.length=Le;break}if(Ue.issues.length){if(!Be&&Le>=De){oe.value.length=Le;break}oe.issues.push(...hr(Le,Ue.issues))}oe.value[Le]=Ue.value}for(let Le=oe.value.length-1;Le>=Re.length;Le--)if(Ie[Le]._zod.optout==="optional"&&oe.value[Le]===void 0)oe.value.length=Le;else break;return oe}var ru=ht("$ZodRecord",(N,oe)=>{At.init(N,oe);let Ie=ir.memoizer;Ie?.attach(N),N._zod.parse=(Re,De)=>{let Le=Re.value;if(!Mr(Le))return Re.issues.push({expected:"record",code:"invalid_type",input:Le,inst:N}),Re;let Ue=[],Be=oe.keyType._zod.values;if(Be&&!oe.partial){Re.value=Ie?Ie.alloc(N,Re,{},De):{};let Xe=new Set;for(let Qe of Be)if(typeof Qe==="string"||typeof Qe==="number"||typeof Qe==="symbol"){if(Xe.add(typeof Qe==="number"?Qe.toString():Qe),Qe==="__proto__")continue;let et=oe.keyType._zod.run({value:Qe,issues:[]},De);if(et instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(et.issues.length){Re.issues.push({code:"invalid_key",origin:"record",issues:et.issues.map((gt)=>wr(gt,De,lr())),input:Qe,path:[Qe],inst:N});continue}let tt=et.value;if(tt==="__proto__")continue;let ft=oe.valueType._zod.run({value:Le[Qe],issues:[]},De);if(ft instanceof Promise)Ue.push(ft.then((gt)=>{if(gt.issues.length)Re.issues.push(...hr(Qe,gt.issues));Re.value[tt]=gt.value}));else{if(ft.issues.length)Re.issues.push(...hr(Qe,ft.issues));Re.value[tt]=ft.value}}let Ye;for(let Qe in Le)if(!Xe.has(Qe))if(oe.mode==="loose"){if(Qe==="__proto__")continue;Re.value[Qe]=Le[Qe]}else Ye=Ye??[],Ye.push(Qe);if(Ye&&Ye.length>0)Re.issues.push({code:"unrecognized_keys",input:Le,inst:N,keys:Ye,continue:!0})}else{Re.value=Ie?Ie.alloc(N,Re,{},De):{};let Xe;for(let Ye of Reflect.ownKeys(Le)){if(Ye==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(Le,Ye))continue;let Qe=oe.keyType._zod.run({value:Ye,issues:[]},De);if(Qe instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof Ye==="string"&&wn.test(Ye)&&Qe.issues.length){let gt=oe.keyType._zod.run({value:Number(Ye),issues:[]},De);if(gt instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(gt.issues.length===0)Qe=gt}if(Qe.issues.length){if(oe.mode==="loose")Re.value[Ye]=Le[Ye];else if(Be)Xe=Xe??[],Xe.push(Ye);else Re.issues.push({code:"invalid_key",origin:"record",issues:Qe.issues.map((gt)=>wr(gt,De,lr())),input:Ye,path:[Ye],inst:N});continue}let tt=Qe.value;if(tt==="__proto__")continue;let ft=oe.valueType._zod.run({value:Le[Ye],issues:[]},De);if(ft instanceof Promise)Ue.push(ft.then((gt)=>{if(gt.issues.length)Re.issues.push(...hr(Ye,gt.issues));Re.value[tt]=gt.value}));else{if(ft.issues.length)Re.issues.push(...hr(Ye,ft.issues));Re.value[tt]=ft.value}}if(Xe&&Xe.length>0)Re.issues.push({code:"unrecognized_keys",input:Le,inst:N,keys:Xe,continue:!0})}if(Ue.length)return Promise.all(Ue).then(()=>Re);return Re}});var nu=ht("$ZodEnum",(N,oe)=>{At.init(N,oe);let Ie=Xr(oe.entries),Re=new Set(Ie);N._zod.values=Re,Tt(N,"pattern",(De)=>{let Le=Xr(De.def.entries).filter((Ue)=>Ls.has(typeof Ue));return new RegExp(Le.length?`^(${Le.map((Ue)=>Ir(Ue.toString())).join("|")})$`:"^[^\\s\\S]$")}),N._zod.parse=(De,Le)=>{let Ue=De.value;if(Re.has(Ue))return De;return De.issues.push({code:"invalid_value",values:Ie,input:Ue,inst:N}),De}}),ou=ht("$ZodLiteral",(N,oe)=>{At.init(N,oe);let Ie=new Set(oe.values);N._zod.values=Ie,Tt(N,"pattern",(Re)=>{let De=Re.def.values;return new RegExp(De.length?`^(${De.map((Le)=>typeof Le==="string"?Ir(Le):Le?Ir(Le.toString()):String(Le)).join("|")})$`:"^[^\\s\\S]$")}),N._zod.parse=(Re,De)=>{let Le=Re.value;if(Ie.has(Le))return Re;return Re.issues.push({code:"invalid_value",values:oe.values,input:Le,inst:N}),Re}});var iu=ht("$ZodTransform",(N,oe)=>{At.init(N,oe),N._zod.optin="optional",ir.memoizer?.guard(N),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")throw new xn(N.constructor.name);let De=oe.transform(Ie.value,Ie);if(Re.async)return(De instanceof Promise?De:Promise.resolve(De)).then((Ue)=>(Ie.value=Ue,Ie));if(De instanceof Promise)throw new $r;return Ie.value=De,Ie}});function ca(N,oe){return N.value=oe.issues.length?void 0:oe.value,N}var Wo=ht("$ZodOptional",(N,oe)=>{At.init(N,oe),Tt(N,"optin",(Ie)=>Ie.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),N._zod.optout="optional",Tt(N,"values",(Ie)=>{let Re=Ie.def.innerType._zod.values;return Re?new Set([...Re,void 0]):void 0}),Tt(N,"pattern",(Ie)=>{let Re=Ie.def.innerType._zod.pattern;return Re?new RegExp(`^(${Mn(Re.source)})?$`):void 0}),N._zod.parse=(Ie,Re)=>{if(Ie.value===void 0){if(oe.innerType._zod.optin!=="defaulted")return Ie;let De=oe.innerType._zod.run({value:Ie.value,issues:[]},Re);if(De instanceof Promise)return De.then((Le)=>ca(Ie,Le));return ca(Ie,De)}return oe.innerType._zod.run(Ie,Re)}}),su=ht("$ZodExactOptional",(N,oe)=>{Wo.init(N,oe),Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),Tt(N,"pattern",(Ie)=>Ie.def.innerType._zod.pattern),N._zod.parse=(Ie,Re)=>oe.innerType._zod.run(Ie,Re)}),cu=ht("$ZodNullable",(N,oe)=>{At.init(N,oe),Tt(N,"optin",(Ie)=>Ie.def.innerType._zod.optin),Tt(N,"optout",(Ie)=>Ie.def.innerType._zod.optout),Tt(N,"pattern",(Ie)=>{let Re=Ie.def.innerType._zod.pattern;return Re?new RegExp(`^(${Mn(Re.source)}|null)$`):void 0}),Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values?new Set([...Ie.def.innerType._zod.values,null]):void 0),N._zod.parse=(Ie,Re)=>{if(Ie.value===null)return Ie;return oe.innerType._zod.run(Ie,Re)}}),au=ht("$ZodDefault",(N,oe)=>{At.init(N,oe),N._zod.optin="defaulted",Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")return oe.innerType._zod.run(Ie,Re);if(Ie.value===void 0)return Ie.value=oe.defaultValue,Ie;let De=oe.innerType._zod.run(Ie,Re);if(De instanceof Promise)return De.then((Le)=>aa(Le,oe));return aa(De,oe)}});function aa(N,oe){if(N.value===void 0)N.value=oe.defaultValue;return N}var uu=ht("$ZodPrefault",(N,oe)=>{At.init(N,oe),N._zod.optin="defaulted",Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")return oe.innerType._zod.run(Ie,Re);if(Ie.value===void 0)Ie.value=oe.defaultValue;return oe.innerType._zod.run(Ie,Re)}}),lu=ht("$ZodNonOptional",(N,oe)=>{At.init(N,oe),Tt(N,"values",(Ie)=>{let Re=Ie.def.innerType._zod.values;return Re?new Set([...Re].filter((De)=>De!==void 0)):void 0}),N._zod.parse=(Ie,Re)=>{let De=oe.innerType._zod.run(Ie,Re);if(De instanceof Promise)return De.then((Le)=>ua(Le,N));return ua(De,N)}});function ua(N,oe){if(!N.issues.length&&N.value===void 0)N.issues.push({code:"invalid_type",expected:"nonoptional",input:N.value,inst:oe});return N}function la(N,oe,Ie,Re){if(!oe.issues.length){if(N.value=oe.value,oe.memo)N.memo=!0;return N}return N.value=Ie.catchValue({...oe,value:N.value,error:{issues:oe.issues.map((De)=>wr(De,Re,lr()))},input:N.value}),N}var fu=ht("$ZodCatch",(N,oe)=>{At.init(N,oe),Tt(N,"optin",(Ie)=>Ie.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Tt(N,"optout",(Ie)=>Ie.def.innerType._zod.optout),Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")return oe.innerType._zod.run(Ie,Re);let De=oe.innerType._zod.run({value:Ie.value,issues:[]},Re);if(De instanceof Promise)return De.then((Le)=>la(Ie,Le,oe,Re));return la(Ie,De,oe,Re)}});var pu=ht("$ZodPipe",(N,oe)=>{At.init(N,oe),Tt(N,"values",(Ie)=>Ie.def.in._zod.values),Tt(N,"optin",(Ie)=>Ie.def.in._zod.optin),Tt(N,"optout",(Ie)=>Ie.def.out._zod.optout),Tt(N,"propValues",(Ie)=>Ie.def.in._zod.propValues),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward"){let Le=oe.out._zod.run(Ie,Re);if(Le instanceof Promise)return Le.then((Ue)=>Xn(Ue,oe.in,Re));return Xn(Le,oe.in,Re)}let De=oe.in._zod.run(Ie,Re);if(De instanceof Promise)return De.then((Le)=>Xn(Le,oe.out,Re));return Xn(De,oe.out,Re)}});function Xn(N,oe,Ie){if(N.issues.some((Re)=>Re.code!=="unrecognized_keys"))return N.aborted=!0,N;return oe._zod.run({value:N.value,issues:N.issues},Ie)}var du=ht("$ZodReadonly",(N,oe)=>{At.init(N,oe),Tt(N,"propValues",(Ie)=>Ie.def.innerType._zod.propValues),Tt(N,"values",(Ie)=>Ie.def.innerType._zod.values),Tt(N,"optin",(Ie)=>Ie.def.innerType?._zod?.optin),Tt(N,"optout",(Ie)=>Ie.def.innerType?._zod?.optout),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")return oe.innerType._zod.run(Ie,Re);let De=oe.innerType._zod.run(Ie,Re);if(De instanceof Promise)return De.then(fa);return fa(De)}});function fa(N){if(!N.memo)N.value=Object.freeze(N.value);return N}var mu=ht("$ZodLazy",(N,oe)=>{At.init(N,oe),Is(N._zod,"innerType",()=>{let Ie=oe;if(!Ie._cachedInner)Ie._cachedInner=oe.getter();return Ie._cachedInner}),Tt(N,"pattern",(Ie)=>Ie.innerType?._zod?.pattern),Tt(N,"propValues",(Ie)=>Ie.innerType?._zod?.propValues),Tt(N,"optin",(Ie)=>Ie.innerType?._zod?.optin??void 0),Tt(N,"optout",(Ie)=>Ie.innerType?._zod?.optout??void 0),N._zod.parse=(Ie,Re)=>N._zod.innerType._zod.run(Ie,Re)}),hu=ht("$ZodCustom",(N,oe)=>{rr.init(N,oe),At.init(N,oe),N._zod.parse=(Ie,Re)=>Ie,N._zod.check=(Ie)=>{let Re=Ie.value,De=oe.fn(Re);if(De instanceof Promise)return De.then((Le)=>pa(Le,Ie,Re,N));pa(De,Ie,Re,N);return}});function pa(N,oe,Ie,Re){if(!N){let De={code:"custom",input:Ie,inst:Re,path:[...Re._zod.def.path??[]],continue:!Re._zod.def.abort};if(Re._zod.def.params)De.params=Re._zod.def.params;oe.issues.push(Lr(De))}}class yu extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Ho="~memo",gu=[];function _u(N){return N!==null&&typeof N==="object"}function Ko(N){return N.map((oe)=>oe.path?{...oe,path:oe.path.slice()}:{...oe})}var vu=new WeakMap,Sn=0,oo=1,kn=2;function io(N,oe,Ie){let Re=vu.get(N);if(Re!==void 0)return Re?kn:Sn;if(oe.has(N))return kn;oe.add(N);let De=Sn,Le=(Qe)=>{if(De!==kn&&Qe?._zod){let et=io(Qe,oe,Ie);if(et>De)De=et}},Ue=(Qe,et)=>{let tt=Sn;for(let ft of Reflect.ownKeys(Qe)){let gt=Object.getOwnPropertyDescriptor(Qe,ft);if(et&&!gt.enumerable)continue;let bt=gt.get?oo:gt.value?._zod?io(gt.value,oe,Ie):Sn;if(bt>tt)tt=bt}return tt},Be=(Qe)=>{if(Qe>De)De=Qe},Xe=N._zod.def,Ye=Xe.type;switch(Ye){case"object":{let Qe=yn(Xe);Be(Qe?Ue(Qe,!0):oo),Le(Xe.catchall);break}case"array":Le(Xe.element);break;case"tuple":for(let Qe of Xe.items)Le(Qe);Le(Xe.rest);break;case"record":case"map":Le(Xe.keyType),Le(Xe.valueType);break;case"set":Le(Xe.valueType);break;case"union":for(let Qe of Xe.options)Le(Qe);break;case"intersection":Le(Xe.left),Le(Xe.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":Le(Xe.innerType);break;case"pipe":Le(Xe.in),Le(Xe.out);break;case"function":Le(Xe.input),Le(Xe.output);break;case"lazy":{let Qe=Xe._cachedInner??(Ie?N._zod.innerType:void 0);Be(Qe?io(Qe,oe,!1):oo);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let Qe in Xe){let et=Object.getOwnPropertyDescriptor(Xe,Qe);if(!et||et.get)continue;let tt=et.value;if(!tt||typeof tt!=="object")continue;if(tt._zod)Le(tt);else if(Array.isArray(tt))for(let ft of tt)Le(ft)}}return oe.delete(N),Np(N,De)}function Np(N,oe){if(oe!==oo)vu.set(N,oe===kn);return oe}function Rp(N,oe){let Ie=N.buckets.get(oe);if(!Ie)Ie=new WeakMap,N.buckets.set(oe,Ie);return Ie}var ro,no=[],Dp={alloc(N,oe,Ie){let Re=ro;if(!Re)return Ie;ro=void 0;let De={value:Ie,issues:null};return Re.set(oe.value,De),no.push(De),Ie},guard(N){var oe;(oe=N._zod).deferred??(oe.deferred=[]),N._zod.deferred.push(()=>{let Ie=N._zod.parse,Re=(De,Le)=>{if(Le.direction!=="backward"&&Mp(Le,De.value))throw new yu;return Ie(De,Le)};if(N._zod.parse=Re,N._zod.run===Ie)N._zod.run=Re})},attach(N){var oe;let Ie,Re=!1,De,Le;(oe=N._zod).deferred??(oe.deferred=[]),N._zod.deferred.push(()=>{let Ue=N._zod.parse,Be=(Xe,Ye)=>{if(Ie===void 0){let Et=io(N,new Set,!1);if(Et===Sn){if(N._zod.parse=Ue,N._zod.run===Be)N._zod.run=Ue;return Ue(Xe,Ye)}if(Et===kn||Re)Ie=!0;else Re=!0}let Qe=Xe.value;if(!_u(Qe))return Ue(Xe,Ye);let et=Ye[Ho];if(!et)et={buckets:new WeakMap,backEdges:void 0},Ye[Ho]=et;let tt;if(De===Ye)tt=Le;else tt=Rp(et,N),De=Ye,Le=tt;let ft=tt.get(Qe);if(ft){if(Xe.value=ft.value,ft.issues){if(ft.issues.length)Xe.issues.push(...Ko(ft.issues))}else Xe.memo=!0,et.backEdges??(et.backEdges=new WeakSet),et.backEdges.add(ft.value);return Xe}ro=tt;let gt=no.length,bt=Ue(Xe,Ye);ro=void 0;let St=no.length>gt?no.pop():void 0;if(bt instanceof Promise)return bt.then((Et)=>{if(St)St.issues=Et.issues.length?Ko(Et.issues):gu;return Et});if(St)St.issues=bt.issues.length?Ko(bt.issues):gu;return bt};if(N._zod.parse=Be,N._zod.run===Ue)N._zod.run=Be})}};function bu(){return Dp}function Mp(N,oe){let Ie=N[Ho]?.backEdges;return Ie!==void 0&&_u(oe)&&Ie.has(oe)}var Lp=()=>{let N={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function oe(Le){return N[Le]??null}let Ie={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},Re={nan:"NaN"};function De(Le,Ue){if(Le==="number"&&typeof Ue==="number"&&!Number.isFinite(Ue))return String(Ue);return Re[Le]??Le}return(Le)=>{switch(Le.code){case"invalid_type":{let Ue=De(Le.expected),Be=Js(Le.input),Xe=De(Be,Le.input);return`Invalid input: expected ${Ue}, received ${Xe}`}case"invalid_value":if(Le.values.length===1)return`Invalid input: expected ${ko(Le.values[0])}`;return`Invalid option: expected one of ${$o(Le.values,"|")}`;case"too_big":{let Ue=Le.exact?"exactly ":Le.inclusive?"<=":"<",Be=oe(Le.origin);if(Be)return`Too big: expected ${Le.origin??"value"} to have ${Ue}${Le.maximum.toString()} ${Be.unit??"elements"}`;return`Too big: expected ${Le.origin??"value"} to be ${Ue}${Le.maximum.toString()}`}case"too_small":{let Ue=Le.exact?"exactly ":Le.inclusive?">=":">",Be=oe(Le.origin);if(Be)return`Too small: expected ${Le.origin} to have ${Ue}${Le.minimum.toString()} ${Be.unit}`;return`Too small: expected ${Le.origin} to be ${Ue}${Le.minimum.toString()}`}case"invalid_format":{let Ue=Le;if(Ue.format==="starts_with")return`Invalid string: must start with "${Ue.prefix}"`;if(Ue.format==="ends_with")return`Invalid string: must end with "${Ue.suffix}"`;if(Ue.format==="includes")return`Invalid string: must include "${Ue.includes}"`;if(Ue.format==="regex")return`Invalid string: must match pattern ${Ue.pattern}`;return`Invalid ${Ie[Ue.format]??Le.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${Le.divisor}`;case"unrecognized_keys":return`Unrecognized key${Le.keys.length>1?"s":""}: ${$o(Le.keys,", ")}`;case"invalid_key":return`Invalid key in ${Le.origin}`;case"invalid_union":if(Le.options&&Array.isArray(Le.options)&&Le.options.length>0)return`Invalid discriminator value. Expected ${Le.options.map((Be)=>`'${Be}'`).join(" | ")}`;if(Le.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${Le.origin}`;default:return"Invalid input"}}};function qo(){return{localeError:Lp()}}var xu;class wu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(N,...oe){let Ie=oe[0];if(this._map.set(N,Ie),Ie&&typeof Ie==="object"&&"id"in Ie)this._idmap.set(Ie.id,N);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(N){let oe=this._map.get(N);if(oe&&typeof oe==="object"&&"id"in oe)this._idmap.delete(oe.id);return this._map.delete(N),this}get(N){let oe=N._zod.parent;if(oe){let Ie={...this.get(oe)??{}};delete Ie.id;let Re={...Ie,...this._map.get(N)};return Object.keys(Re).length?Re:void 0}return this._map.get(N)}has(N){return this._map.has(N)}}function jp(){return new wu}(xu=globalThis).__zod_globalRegistry??(xu.__zod_globalRegistry=jp());var jr=globalThis.__zod_globalRegistry;function so(N){if(N.checks)N.checks=[...N.checks];return N}function $u(N,oe){return new N(so({type:"string",...zt(oe)}))}function Vt(N,oe){return new N(so({type:"string",coerce:!0,...zt(oe)}))}function zu(N,oe){return new N({type:"string",format:"email",check:"string_format",abort:!1,...zt(oe)})}function Su(N,oe){return new N({type:"string",format:"guid",check:"string_format",abort:!1,...zt(oe)})}function ku(N,oe){return new N({type:"string",format:"uuid",check:"string_format",abort:!1,...zt(oe)})}function Pu(N,oe){return new N({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...zt(oe)})}function Eu(N,oe){return new N({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...zt(oe)})}function Ou(N,oe){return new N({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...zt(oe)})}function Tu(N,oe){return new N({type:"string",format:"url",check:"string_format",abort:!1,...zt(oe)})}function Zu(N,oe){return new N({type:"string",format:"emoji",check:"string_format",abort:!1,...zt(oe)})}function Au(N,oe){return new N({type:"string",format:"nanoid",check:"string_format",abort:!1,...zt(oe)})}function Iu(N,oe){return new N({type:"string",format:"cuid",check:"string_format",abort:!1,...zt(oe)})}function Cu(N,oe){return new N({type:"string",format:"cuid2",check:"string_format",abort:!1,...zt(oe)})}function Nu(N,oe){return new N({type:"string",format:"ulid",check:"string_format",abort:!1,...zt(oe)})}function Ru(N,oe){return new N({type:"string",format:"xid",check:"string_format",abort:!1,...zt(oe)})}function Du(N,oe){return new N({type:"string",format:"ksuid",check:"string_format",abort:!1,...zt(oe)})}function Mu(N,oe){return new N({type:"string",format:"ipv4",check:"string_format",abort:!1,...zt(oe)})}function Lu(N,oe){return new N({type:"string",format:"ipv6",check:"string_format",abort:!1,...zt(oe)})}function ju(N,oe){return new N({type:"string",format:"cidrv4",check:"string_format",abort:!1,...zt(oe)})}function Fu(N,oe){return new N({type:"string",format:"cidrv6",check:"string_format",abort:!1,...zt(oe)})}function Uu(N,oe){return new N({type:"string",format:"base64",check:"string_format",abort:!1,...zt(oe)})}function Bu(N,oe){return new N({type:"string",format:"base64url",check:"string_format",abort:!1,...zt(oe)})}function Ju(N,oe){return new N({type:"string",format:"e164",check:"string_format",abort:!1,...zt(oe)})}function Vu(N,oe){return new N({type:"string",format:"jwt",check:"string_format",abort:!1,...zt(oe)})}function Wu(N,oe){return new N({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...zt(oe)})}function Ku(N,oe){return new N({type:"string",format:"date",check:"string_format",...zt(oe)})}function Hu(N,oe){return new N({type:"string",format:"time",check:"string_format",precision:null,...zt(oe)})}function qu(N,oe){return new N({type:"string",format:"duration",check:"string_format",...zt(oe)})}function Gu(N,oe){return new N(so({type:"number",checks:[],...zt(oe)}))}function Wt(N,oe){return new N(so({type:"number",coerce:!0,checks:[],...zt(oe)}))}function Xu(N,oe){return new N({type:"number",check:"number_format",abort:!1,format:"safeint",...zt(oe)})}function Yu(N,oe){return new N({type:"boolean",...zt(oe)})}function Ht(N,oe){return new N({type:"boolean",coerce:!0,...zt(oe)})}function Zt(N,oe){return new N({type:"bigint",coerce:!0,...zt(oe)})}function Qu(N,oe){return new N({type:"null",...zt(oe)})}function el(N){return new N({type:"any"})}function tl(N){return new N({type:"unknown"})}function rl(N,oe){return new N({type:"never",...zt(oe)})}function Jt(N,oe){return new N({type:"date",coerce:!0,...zt(oe)})}function Jr(N,oe){return new Mo({check:"less_than",...zt(oe),value:N,inclusive:!1})}function Er(N,oe){return new Mo({check:"less_than",...zt(oe),value:N,inclusive:!0})}function Vr(N,oe){return new Lo({check:"greater_than",...zt(oe),value:N,inclusive:!1})}function Or(N,oe){return new Lo({check:"greater_than",...zt(oe),value:N,inclusive:!0})}function Pn(N,oe){return new Lc({check:"multiple_of",...zt(oe),value:N})}function co(N,oe){return new Fc({check:"max_length",...zt(oe),maximum:N})}function Wr(N,oe){return new Uc({check:"min_length",...zt(oe),minimum:N})}function ao(N,oe){return new Bc({check:"length_equals",...zt(oe),length:N})}function Go(N,oe){return new Jc({check:"string_format",format:"regex",...zt(oe),pattern:N})}function Xo(N){return new Vc({check:"string_format",format:"lowercase",...zt(N)})}function Yo(N){return new Wc({check:"string_format",format:"uppercase",...zt(N)})}function Qo(N,oe){return new Kc({check:"string_format",format:"includes",...zt(oe),includes:N})}function ei(N,oe){return new Hc({check:"string_format",format:"starts_with",...zt(oe),prefix:N})}function ti(N,oe){return new qc({check:"string_format",format:"ends_with",...zt(oe),suffix:N})}function ri(N,oe){return new Gc({check:"properties",shape:N,...zt(oe)})}function Cr(N){return new Xc({check:"overwrite",tx:N})}function ni(N){return Cr((oe)=>oe.normalize(N))}function oi(){return Cr((N)=>N.trim())}function ii(){return Cr((N)=>N.toLowerCase())}function si(){return Cr((N)=>N.toUpperCase())}function ci(){return Cr((N)=>Ds(N))}function nl(N,oe,Ie){return new N({type:"array",element:oe,...zt(Ie)})}function ol(N,oe,Ie){let Re=zt(Ie);return Re.abort??(Re.abort=!0),new N({type:"custom",check:"custom",fn:oe,...Re})}function il(N,oe,Ie){return new N({type:"custom",check:"custom",fn:oe,...zt(Ie)})}function sl(N,oe){let Ie=Fp((Re)=>(Re.addIssue=(De)=>{if(typeof De==="string")Re.issues.push(Lr(De,Re.value,Ie._zod.def));else{let Le=De;if(Le.fatal)Le.continue=!1;if(Le.code??(Le.code="custom"),!("input"in Le))Le.input=Re.value;Le.inst??(Le.inst=Ie),Le.continue??(Le.continue=!Ie._zod.def.abort),Re.issues.push(Lr(Le))}},N(Re.value,Re)),oe);return Ie}function Fp(N,oe){let Ie=new rr({check:"custom",...zt(oe)});return Ie._zod.check=N,Ie}function En(N,...oe){for(let Ie of oe)for(let Re of Reflect.ownKeys(Ie))if(Object.prototype.propertyIsEnumerable.call(Ie,Re))ar(N,Re,Ie[Re]);return N}function Tn(N){let oe=N?.target??"draft-2020-12";if(oe==="draft-4")oe="draft-04";if(oe==="draft-7")oe="draft-07";return{processors:N.processors??{},metadataRegistry:N?.metadata??jr,target:oe,unrepresentable:N?.unrepresentable??"throw",override:N?.override??(()=>{}),io:N?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:N?.cycles??"ref",reused:N?.reused??"inline",intersections:[],deferred:[],external:N?.external??void 0}}function nr(N,oe,Ie,Re,De){let Le=typeof oe.unrepresentable==="function"?oe.unrepresentable({zodSchema:N,path:Re.path,message:De}):oe.unrepresentable;if(Le==="any")return!1;if(Le===void 0||Le==="throw")throw Error(De);return Object.assign(Ie,Le),!0}function Dt(N,oe,Ie={path:[],schemaPath:[]}){var Re;let De=N._zod.def,Le=oe.seen.get(N);if(Le){if(Le.count++,Ie.schemaPath.includes(N))Le.cycle=Ie.path;return Le.schema}let Ue={schema:{},count:1,cycle:void 0,path:Ie.path};oe.seen.set(N,Ue),oe.sharedDefsExtractedFor=void 0,oe.sharedEmitDoneFor=void 0;let Be=N._zod.toJSONSchema?.();if(Be)Ue.schema=Be;else{let Qe={...Ie,schemaPath:[...Ie.schemaPath,N],path:Ie.path};if(N._zod.processJSONSchema)N._zod.processJSONSchema(oe,Ue.schema,Qe);else{let tt=Ue.schema,ft=oe.processors[De.type];if(!ft)throw Error(`[toJSONSchema]: Non-representable type encountered: ${De.type}`);ft(N,oe,tt,Qe)}let et=N._zod.parent;if(et){if(!Ue.ref)Ue.ref=et;Dt(et,oe,Qe),oe.seen.get(et).isParent=!0}}let Xe=oe.metadataRegistry.get(N);if(Xe)En(Ue.schema,Xe);if(oe.io==="input"&&sr(N))delete Ue.schema.examples,delete Ue.schema.default;if(oe.io==="input"&&"_prefault"in Ue.schema)(Re=Ue.schema).default??(Re.default=Ue.schema._prefault);return delete Ue.schema._prefault,oe.seen.get(N).schema}function cl(N){return N.replace(/~/g,"~0").replace(/\//g,"~1")}function Zn(N,oe){let Ie=N.seen.get(oe);if(!Ie)throw Error("Unprocessed schema. This is a bug in Zod.");if(N.external&&N.sharedDefsExtractedFor===N.external)return;let Re=new Map;for(let Ue of N.seen.entries()){let Be=N.metadataRegistry.get(Ue[0])?.id;if(Be){let Xe=Re.get(Be);if(Xe&&Xe!==Ue[0])throw Error(`Duplicate schema id "${Be}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);Re.set(Be,Ue[0])}}let De=(Ue)=>{let Be=N.target==="draft-2020-12"?"$defs":"definitions";if(N.external){let et=N.external.registry.get(Ue[0])?.id,tt=N.external.uri??((gt)=>gt);if(et)return{ref:tt(et)};let ft=Ue[1].defId??Ue[1].schema.id??`schema${N.counter++}`;return Ue[1].defId=ft,{defId:ft,ref:`${tt("__shared")}#/${Be}/${cl(ft)}`}}let Xe="#",Ye=`${Xe}/${Be}/`;if(Ue[1]===Ie&&!Ue[1].schema.id)return{ref:Xe};let Qe=Ue[1].schema.id??`__schema${N.counter++}`;return{defId:Qe,ref:Ye+cl(Qe)}},Le=(Ue)=>{if(Ue[1].schema.$ref)return;let Be=Ue[1],{ref:Xe,defId:Ye}=De(Ue);if(Be.def={...Be.schema},Ye)Be.defId=Ye;let Qe=Be.schema;for(let et in Qe)delete Qe[et];Qe.$ref=Xe};if(N.cycles==="throw")for(let Ue of N.seen.entries()){let Be=Ue[1];if(Be.cycle)throw Error(`Cycle detected: #/${Be.cycle?.join("/")}/<root>
|
|
58
58
|
|
|
59
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let Ue of N.seen.entries()){let Be=Ue[1];if(oe===Ue[0]){Le(Ue);continue}if(N.external){let Ye=N.external.registry.get(Ue[0])?.id;if(oe!==Ue[0]&&Ye){Le(Ue);continue}}if(N.metadataRegistry.get(Ue[0])?.id){Le(Ue);continue}if(Be.cycle){Le(Ue);continue}if(Be.count>1){if(N.reused==="ref")Le(Ue)}}if(N.external)N.sharedDefsExtractedFor=N.external}function ll(N){let oe=N.anyOf;if(!Array.isArray(oe)||oe.length===0||N.type!==void 0)return;let Ie=[];for(let Re of oe){if(!Re||typeof Re!=="object")return;ll(Re);let De=Object.keys(Re);if(De.length!==1||De[0]!=="type")return;let Le=Re.type;for(let Ue of Array.isArray(Le)?Le:[Le]){if(typeof Ue!=="string")return;if(!Ie.includes(Ue))Ie.push(Ue)}}delete N.anyOf,N.type=Ie.length===1?Ie[0]:Ie}var fl=new Set(["type","properties","required","additionalProperties"]),al=["oneOf","anyOf"];function ul(N){let oe=N.additionalProperties;if(oe===void 0||oe===!1||typeof oe!=="object"||oe===null)return null;return Object.keys(oe).length?oe:null}function ai(N){let oe=[];for(let Le of N){if(typeof Le!=="object"||Le.type!=="object")return null;for(let Ue in Le)if(!fl.has(Ue))return null;oe.push(Le)}let Ie={},Re=new Set;for(let Le of oe){for(let Ue in Le.properties){if(Object.prototype.hasOwnProperty.call(Ie,Ue))continue;let Be=[];for(let Ye of oe){let Qe=Ye.properties?.[Ue]??ul(Ye);if(Qe===null||Qe===void 0)continue;if(!Be.some((et)=>JSON.stringify(et)===JSON.stringify(Qe)))Be.push(Qe)}let Xe=Be.length===1?Be[0]:ai(Be)??{allOf:Be};lr(Ie,Ue,Xe)}for(let Ue of Le.required??[])Re.add(Ue)}let De={type:"object",properties:Ie};if(Re.size)De.required=[...Re];if(oe.every((Le)=>Le.additionalProperties===!1))De.additionalProperties=!1;else{let Le=[];for(let Ue of oe){let Be=ul(Ue);if(Be&&!Le.some((Xe)=>JSON.stringify(Xe)===JSON.stringify(Be)))Le.push(Be)}if(Le.length===1)De.additionalProperties=Le[0];else if(Le.length>1)De.additionalProperties={allOf:Le}}return De}function Up(N){let oe=N.allOf;if(!Array.isArray(oe)||oe.length<2)return;for(let De of fl)if(De in N)return;let Ie=oe.filter((De)=>al.some((Le)=>Array.isArray(De[Le]))),Re=null;if(!Ie.length)Re=ai(oe);else{let De=Ie[0],Le=al.find((Xe)=>Array.isArray(De[Xe]));if(Object.keys(De).length!==1)return;let Ue=oe.filter((Xe)=>Xe!==De),Be=De[Le].map((Xe)=>ai([...Ue,Xe]));if(Be.some((Xe)=>!Xe))return;Re={[Le]:Be}}if(!Re)return;delete N.allOf,En(N,Re)}function An(N,oe){let Ie=N.seen.get(oe);if(!Ie)throw Error("Unprocessed schema. This is a bug in Zod.");let Re=(Be)=>{let Xe=N.seen.get(Be);if(Xe.ref===null)return;let Ye=Xe.def??Xe.schema,Qe={...Ye},et=Xe.ref;if(Xe.ref=null,et){Re(et);let ft=N.seen.get(et),gt=ft.schema;if(gt.$ref&&(N.target==="draft-07"||N.target==="draft-04"||N.target==="openapi-3.0"))Ye.allOf=Ye.allOf??[],Ye.allOf.push(gt);else En(Ye,gt);if(En(Ye,Qe),Be._zod.parent===et)for(let St in Ye){if(St==="$ref"||St==="allOf")continue;if(!(St in Qe))delete Ye[St]}if(gt.$ref&&ft.def)for(let St in Ye){if(St==="$ref"||St==="allOf")continue;if(St in ft.def&&JSON.stringify(Ye[St])===JSON.stringify(ft.def[St]))delete Ye[St]}}let tt=Be._zod.parent;if(tt&&tt!==et){Re(tt);let ft=N.seen.get(tt);if(ft?.schema.$ref){if(Ye.$ref=ft.schema.$ref,ft.def)for(let gt in Ye){if(gt==="$ref"||gt==="allOf")continue;if(gt in ft.def&&JSON.stringify(Ye[gt])===JSON.stringify(ft.def[gt]))delete Ye[gt]}}}N.override({zodSchema:Be,jsonSchema:Ye,path:Xe.path??[]})};if(!N.external||N.sharedEmitDoneFor!==N.external){for(let Be of[...N.seen.entries()].reverse())Re(Be[0]);if(N.target!=="openapi-3.0")for(let Be of N.seen.entries())ll(Be[1].def??Be[1].schema);for(let Be of N.deferred)Be();if(N.intersections.length){let Be=new Map;for(let Xe of N.seen.values())for(let Ye of[Xe.schema,Xe.def]){let Qe=Ye?.allOf;if(!Array.isArray(Qe))continue;let et=Be.get(Qe);if(et)et.push(Ye);else Be.set(Qe,[Ye])}for(let Xe of N.intersections)for(let Ye of Be.get(Xe)??[])Up(Ye)}}let De={};if(N.target==="draft-2020-12")De.$schema="https://json-schema.org/draft/2020-12/schema";else if(N.target==="draft-07")De.$schema="http://json-schema.org/draft-07/schema#";else if(N.target==="draft-04")De.$schema="http://json-schema.org/draft-04/schema#";else if(N.target==="openapi-3.0");if(N.external?.uri){let Be=N.external.registry.get(oe)?.id;if(!Be)throw Error("Schema is missing an `id` property");De.$id=N.external.uri(Be)}En(De,Ie.defId?Ie.schema:Ie.def??Ie.schema);let Le=N.metadataRegistry.get(oe)?.id;if(Le!==void 0&&De.id===Le)delete De.id;let Ue=N.external?.defs??{};if(!N.external||N.sharedEmitDoneFor!==N.external)for(let Be of N.seen.entries()){let Xe=Be[1];if(Xe.def&&Xe.defId){if(Xe.def.id===Xe.defId)delete Xe.def.id;lr(Ue,Xe.defId,Xe.def)}}if(N.external)N.sharedEmitDoneFor=N.external;if(N.external);else if(Object.keys(Ue).length>0)if(N.target==="draft-2020-12")De.$defs=Ue;else De.definitions=Ue;try{let Be=JSON.parse(JSON.stringify(De));return Object.defineProperty(Be,"~standard",{value:{...oe["~standard"],jsonSchema:{input:On(oe,"input",N.processors),output:On(oe,"output",N.processors)}},enumerable:!1,writable:!1}),Be}catch(Be){throw Error("Error converting schema to JSON.")}}function ar(N,oe){let Ie=oe??{seen:new Set};if(Ie.seen.has(N))return!1;Ie.seen.add(N);let Re=N._zod.def;if(Re.type==="transform")return!0;if(Re.type==="array")return ar(Re.element,Ie);if(Re.type==="set")return ar(Re.valueType,Ie);if(Re.type==="lazy")return ar(Re.getter(),Ie);if(Re.type==="promise"||Re.type==="optional"||Re.type==="nonoptional"||Re.type==="nullable"||Re.type==="readonly"||Re.type==="default"||Re.type==="prefault"||Re.type==="catch")return ar(Re.innerType,Ie);if(Re.type==="intersection")return ar(Re.left,Ie)||ar(Re.right,Ie);if(Re.type==="record"||Re.type==="map")return ar(Re.keyType,Ie)||ar(Re.valueType,Ie);if(Re.type==="pipe"){if(N._zod.traits.has("$ZodCodec"))return!0;return ar(Re.in,Ie)||ar(Re.out,Ie)}if(Re.type==="object"){for(let De in Re.shape)if(ar(Re.shape[De],Ie))return!0;return!1}if(Re.type==="union"){for(let De of Re.options)if(ar(De,Ie))return!0;return!1}if(Re.type==="tuple"){for(let De of Re.items)if(ar(De,Ie))return!0;if(Re.rest&&ar(Re.rest,Ie))return!0;return!1}return!1}var pl=(N,oe={})=>(Ie)=>{let Re=Tn({...Ie,processors:oe});return Dt(N,Re),Zn(Re,N),An(Re,N)},On=(N,oe,Ie={})=>(Re)=>{let{libraryOptions:De,target:Le}=Re??{},Ue=Tn({...De??{},target:Le,io:oe,processors:Ie});return Dt(N,Ue),Zn(Ue,N),An(Ue,N)};var qr=(N,oe,Ie)=>{if(N[oe]===void 0||Ie>N[oe])N[oe]=Ie},Gr=(N,oe,Ie)=>{if(N[oe]===void 0||Ie<N[oe])N[oe]=Ie},dl=(N,oe)=>{qr(N,"minimum",oe),Gr(N,"maximum",oe)},_l=(N,oe)=>{if(N.multipleOf??(N.multipleOf=[]),!N.multipleOf.includes(oe))N.multipleOf.push(oe)},vl=(N,oe)=>{N.patterns??(N.patterns=new Set),N.patterns.add(oe)},bl=(N,oe)=>{N.mime=N.mime?N.mime.filter((Ie)=>oe.includes(Ie)):[...oe]},xl=(N,oe)=>{if(N.format=oe,oe.includes("int"))N.isInt=!0},ml=(N,oe)=>qr(N,"minimum",oe.minimum),hl=(N,oe)=>Gr(N,"maximum",oe.maximum),gl=(N)=>(oe,Ie)=>{xl(oe,Ie.format);let[Re,De]=N[Ie.format];qr(oe,"minimum",Re),Gr(oe,"maximum",De)},Bp={greater_than:(N,oe)=>qr(N,oe.inclusive?"minimum":"exclusiveMinimum",oe.value),less_than:(N,oe)=>Gr(N,oe.inclusive?"maximum":"exclusiveMaximum",oe.value),multiple_of:(N,oe)=>_l(N,oe.value),number_format:gl(Ln),bigint_format:gl(Po),min_length:ml,max_length:hl,length_equals:(N,oe)=>dl(N,oe.length),min_size:ml,max_size:hl,size_equals:(N,oe)=>dl(N,oe.size),string_format:(N,oe)=>{if(xl(N,oe.format),oe.pattern)vl(N,oe.pattern);if(oe.format==="base64"||oe.format==="base64url")N.contentEncoding=oe.format;if(oe.local||oe.precision===-1)N.laxFormat=!0},mime_type:(N,oe)=>bl(N,oe.mime)};function nr(N){let oe={},Ie=N._zod.def,Re=N._zod.traits.has("$ZodCheck")?[N,...Ie.checks??[]]:Ie.checks??[];for(let Le of Re)Bp[Le._zod.def.check]?.(oe,Le._zod.def);let De=N._zod.bag;if(De.minimum!==void 0)qr(oe,"minimum",De.minimum);if(De.exclusiveMinimum!==void 0)qr(oe,"exclusiveMinimum",De.exclusiveMinimum);if(De.maximum!==void 0)Gr(oe,"maximum",De.maximum);if(De.exclusiveMaximum!==void 0)Gr(oe,"exclusiveMaximum",De.exclusiveMaximum);if(De.multipleOf!==void 0)_l(oe,De.multipleOf);if(De.format!==void 0){if(oe.format??(oe.format=De.format),De.format.includes("int"))oe.isInt=!0}if(De.mime)bl(oe,De.mime);for(let Le of De.patterns??[])vl(oe,Le);return oe}var Jp={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vp=new Map([[Bo,zc],[to,Sc]]),wl=(N)=>Vp.get(N)??N,fi=(N,oe,Ie,Re)=>{let De=Ie;De.type="string";let{minimum:Le,maximum:Ue,format:Be,patterns:Xe,contentEncoding:Ye,laxFormat:Qe}=nr(N);if(typeof Le==="number")De.minLength=Le;if(typeof Ue==="number")De.maxLength=Ue;if(Be){if(De.format=Jp[Be]??Be,De.format==="")delete De.format;if(Be==="time"||Qe)delete De.format}if(Ye)De.contentEncoding=Ye;if(Xe&&Xe.size>0){let et=[...Xe].map(wl);if(et.length===1)De.pattern=et[0].source;else if(et.length>1)De.allOf=[...et.map((tt)=>({...oe.target==="draft-07"||oe.target==="draft-04"||oe.target==="openapi-3.0"?{type:"string"}:{},pattern:tt.source}))]}},pi=(N,oe,Ie,Re)=>{let De=Ie,{minimum:Le,maximum:Ue,multipleOf:Be,exclusiveMaximum:Xe,exclusiveMinimum:Ye,isInt:Qe}=nr(N);De.type=Qe?"integer":"number";let et=typeof Ye==="number"&&Ye>=(Le??Number.NEGATIVE_INFINITY),tt=typeof Xe==="number"&&Xe<=(Ue??Number.POSITIVE_INFINITY),ft=oe.target==="draft-04"||oe.target==="openapi-3.0";if(et)if(ft)De.minimum=Ye,De.exclusiveMinimum=!0;else De.exclusiveMinimum=Ye;else if(typeof Le==="number")De.minimum=Le;if(tt)if(ft)De.maximum=Xe,De.exclusiveMaximum=!0;else De.exclusiveMaximum=Xe;else if(typeof Ue==="number")De.maximum=Ue;if(Be){let gt=new Set;for(let Et of Be)if(Number.isFinite(Et)&&Et!==0)gt.add(Math.abs(Et));else ir(N,oe,De,Re,`A multipleOf divisor of ${Et} cannot be represented in JSON Schema`);let[bt,...St]=gt;if(bt!==void 0)De.multipleOf=bt;if(St.length)De.allOf=[...De.allOf??[],...St.map((Et)=>({multipleOf:Et}))]}},di=(N,oe,Ie,Re)=>{Ie.type="boolean"},mi=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"BigInt cannot be represented in JSON Schema")},$l=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"Symbols cannot be represented in JSON Schema")},hi=(N,oe,Ie,Re)=>{if(oe.target==="openapi-3.0")Ie.type="string",Ie.nullable=!0,Ie.enum=[null];else Ie.type="null"},zl=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"Undefined cannot be represented in JSON Schema")},Sl=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"Void cannot be represented in JSON Schema")},gi=(N,oe,Ie,Re)=>{Ie.not={}},yi=(N,oe,Ie,Re)=>{},_i=(N,oe,Ie,Re)=>{},vi=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"Date cannot be represented in JSON Schema")},bi=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=Qr(De.entries);if(Le.length===0){Ie.not={};return}if(Le.every((Ue)=>typeof Ue==="number"))Ie.type="number";if(Le.every((Ue)=>typeof Ue==="string"))Ie.type="string";Ie.enum=Le},xi=(N,oe,Ie,Re)=>{let De=N._zod.def;if(De.values.length===0){Ie.not={};return}let Le=[];for(let Ue of De.values)if(Ue===void 0){if(ir(N,oe,Ie,Re,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof Ue==="bigint"){if(ir(N,oe,Ie,Re,"BigInt literals cannot be represented in JSON Schema"))return;Le.push(Number(Ue))}else Le.push(Ue);if(Le.length===0);else if(Le.length===1){let Ue=Le[0];if(Ie.type=Ue===null?"null":typeof Ue,oe.target==="draft-04"||oe.target==="openapi-3.0")Ie.enum=[Ue];else Ie.const=Ue}else{if(Le.every((Ue)=>typeof Ue==="number"))Ie.type="number";if(Le.every((Ue)=>typeof Ue==="string"))Ie.type="string";if(Le.every((Ue)=>typeof Ue==="boolean"))Ie.type="boolean";if(Le.every((Ue)=>Ue===null))Ie.type="null";Ie.enum=Le}},kl=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"NaN cannot be represented in JSON Schema")},Pl=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.pattern;if(!Le)throw Error("Pattern not found in template literal");De.type="string",De.pattern=Le.source},El=(N,oe,Ie,Re)=>{let De=Ie;De.type="string",De.format="binary",De.contentEncoding="binary";let{minimum:Le,maximum:Ue,mime:Be}=nr(N);if(Le!==void 0)De.minLength=Le;if(Ue!==void 0)De.maxLength=Ue;if(!Be)return;if(Be.length===0)De.not={};else if(Be.length===1)De.contentMediaType=Be[0];else De.anyOf=Be.map((Xe)=>({contentMediaType:Xe}))},Ol=(N,oe,Ie,Re)=>{Ie.type="boolean"},wi=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"Custom types cannot be represented in JSON Schema")},Tl=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"Function types cannot be represented in JSON Schema")},$i=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"Transforms cannot be represented in JSON Schema")},Zl=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"Map cannot be represented in JSON Schema")},Al=(N,oe,Ie,Re)=>{ir(N,oe,Ie,Re,"Set cannot be represented in JSON Schema")},zi=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.def,{minimum:Ue,maximum:Be}=nr(N);if(typeof Ue==="number")De.minItems=Ue;if(typeof Be==="number")De.maxItems=Be;De.type="array",De.items=Dt(Le.element,oe,{...Re,path:[...Re.path,"items"]})};function In(N){let oe=N._zod.def;if(oe.type==="pipe"&&oe.in._zod.traits.has("$ZodTransform"))return In(oe.out);if(oe.type==="catch")return In(oe.innerType);return N._zod.optin}var Si=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.def,Ue=Le.shape;if(Object.getOwnPropertySymbols(Ue).length&&ir(N,oe,De,Re,"Symbol keys cannot be represented in JSON Schema"))return;De.type="object",De.properties={};for(let Ye in Ue)lr(De.properties,Ye,Dt(Ue[Ye],oe,{...Re,path:[...Re.path,"properties",Ye]}));let Xe=[];for(let Ye of Object.keys(Ue)){let Qe=Le.shape[Ye];if(oe.io==="input"?In(Qe)===void 0:Qe._zod.optout===void 0)Xe.push(Ye)}if(Xe.length>0)De.required=Xe;if(Le.catchall?._zod.def.type==="never")De.additionalProperties=!1;else if(!Le.catchall){if(oe.io==="output")De.additionalProperties=!1}else if(Le.catchall)De.additionalProperties=Dt(Le.catchall,oe,{...Re,path:[...Re.path,"additionalProperties"]})},ki=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=De.inclusive===!1,Ue=De.options.map((Be,Xe)=>Dt(Be,oe,{...Re,path:[...Re.path,Le?"oneOf":"anyOf",Xe]}));if(Le)Ie.oneOf=Ue;else Ie.anyOf=Ue},Pi=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=Dt(De.left,oe,{...Re,path:[...Re.path,"allOf",0]}),Ue=Dt(De.right,oe,{...Re,path:[...Re.path,"allOf",1]}),Be=(Ye)=>("allOf"in Ye)&&Object.keys(Ye).length===1,Xe=[...Be(Le)?Le.allOf:[Le],...Be(Ue)?Ue.allOf:[Ue]];Ie.allOf=Xe,oe.intersections.push(Xe)},Ei=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.def;De.type="array";let Ue=oe.target==="draft-2020-12"?"prefixItems":"items",Be=oe.target==="draft-2020-12"?"items":oe.target==="openapi-3.0"?"items":"additionalItems",Xe=Le.items.map((bt,St)=>Dt(bt,oe,{...Re,path:[...Re.path,Ue,St]})),Ye=Le.rest?Dt(Le.rest,oe,{...Re,path:[...Re.path,Be,...oe.target==="openapi-3.0"?[Le.items.length]:[]]}):null,Qe=Le.items.length;while(Qe>0){let bt=Le.items[Qe-1];if(!(oe.io==="input"?In(bt)!==void 0:bt._zod.optout==="optional"))break;Qe--}let et=Le.items.length,tt=!Le.rest;if(oe.target==="draft-2020-12"){if(De.prefixItems=Xe,tt)De.items=!1;else if(Ye)De.items=Ye;if(Qe>0)De.minItems=Qe;if(tt)De.maxItems=et}else if(oe.target==="openapi-3.0"){if(De.items={anyOf:Xe},Ye)De.items.anyOf.push(Ye);if(Qe>0)De.minItems=Qe;if(tt)De.maxItems=et}else{if(De.items=Xe,tt)De.additionalItems=!1;else if(Ye)De.additionalItems=Ye;if(Qe>0)De.minItems=Qe;if(tt)De.maxItems=et}let{minimum:ft,maximum:gt}=nr(N);if(typeof ft==="number")De.minItems=ft;if(typeof gt==="number")De.maxItems=gt};function ui(N,oe,Ie){if(oe.$ref){if(Ie.has(oe))return oe;Ie.add(oe);let gt=N.get(oe)?.def;if(!gt)return oe;let bt=ui(N,gt,Ie);return bt===gt?oe:bt}for(let gt of["anyOf","oneOf"]){let bt=oe[gt];if(!Array.isArray(bt))continue;let St=bt.map((Et)=>ui(N,Et,Ie));if(St.some((Et,rr)=>Et!==bt[rr]))oe={...oe,[gt]:St}}let Re=Array.isArray(oe.type)?oe.type:[oe.type],De=!Re.includes("string")&&Re.some((gt)=>gt==="number"||gt==="integer"),Le=oe.enum??(oe.const!==void 0?[oe.const]:void 0);if(!De&&!Le?.some((gt)=>typeof gt==="number"))return oe;let{minimum:Ue,maximum:Be,exclusiveMinimum:Xe,exclusiveMaximum:Ye,multipleOf:Qe,format:et,id:tt,...ft}=oe;if(ft.enum)ft.enum=ft.enum.map((gt)=>typeof gt==="number"?String(gt):gt);else if(typeof ft.const==="number")ft.const=String(ft.const);if(!De)return ft;if(ft.type="string",!Le)ft.pattern=(Re.includes("number")?wn:Ro).source;return ft}var li=new WeakMap;function Wp(N){let oe=new Map;for(let Re of N.seen.values())if(Re.def&&!oe.has(Re.schema))oe.set(Re.schema,Re);let Ie=new Map;for(let Re of li.get(N)??[]){let De=N.seen.get(Re),Le=(De?.def??De?.schema)?.propertyNames;if(!Le||Le===!0||Ie.has(Le))continue;let Ue=ui(oe,Le,new Set);if(Ue!==Le)Ie.set(Le,Ue)}if(!Ie.size)return;for(let Re of N.seen.values())for(let De of[Re.schema,Re.def]){let Le=De&&Ie.get(De.propertyNames);if(Le)De.propertyNames=Le}}var Oi=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.def;De.type="object";let Ue=Le.keyType,Be=nr(Ue).patterns;if(Le.mode==="loose"&&Be&&Be.size>0){let Qe=Dt(Le.valueType,oe,{...Re,path:[...Re.path,"patternProperties","*"]});De.patternProperties={};for(let et of Be)lr(De.patternProperties,wl(et).source,Qe)}else{if(oe.target==="draft-07"||oe.target==="draft-2020-12"){De.propertyNames=Dt(Le.keyType,oe,{...Re,path:[...Re.path,"propertyNames"]});let Qe=li.get(oe);if(!Qe)Qe=[],li.set(oe,Qe),oe.deferred.push(()=>Wp(oe));Qe.push(N)}De.additionalProperties=Dt(Le.valueType,oe,{...Re,path:[...Re.path,"additionalProperties"]})}let Xe=Ue._zod.values,Ye=oe.io==="input"&&In(Le.valueType)!==void 0;if(Xe&&!Le.partial&&!Ye){let Qe=[...Xe].filter((et)=>typeof et==="string"||typeof et==="number");if(Qe.length>0)De.required=Qe.map(String)}},Ti=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=Dt(De.innerType,oe,Re),Ue=oe.seen.get(N);if(oe.target==="openapi-3.0")Ue.ref=De.innerType,Ie.nullable=!0;else Ie.anyOf=[Le,{type:"null"}]},Zi=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType},Ai=Symbol();function Il(N,oe,Ie,Re,De){let Le=!1,Ue=JSON.stringify(N,(Be,Xe)=>{if(typeof Xe!=="bigint")return Xe;return Le=!0,null});if(!Le)return JSON.parse(Ue);return ir(oe,Ie,Re,De,"BigInt defaults cannot be represented in JSON Schema"),Ai}var Ii=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType;let Ue=Il(De.defaultValue,N,oe,Ie,Re);if(Ue!==Ai)Ie.default=Ue},Ci=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);if(Le.ref=De.innerType,oe.io!=="input")return;let Ue=Il(De.defaultValue,N,oe,Ie,Re);if(Ue!==Ai)Ie._prefault=Ue},Ni=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType;let Ue;try{Ue=De.catchValue(void 0)}catch{ir(N,oe,Ie,Re,"Dynamic catch values are not supported in JSON Schema");return}Ie.default=Ue},Ri=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=De.in._zod.traits.has("$ZodTransform"),Ue=oe.io==="input"?Le?De.out:De.in:De.out;Dt(Ue,oe,Re);let Be=oe.seen.get(N);Be.ref=Ue},Di=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType,Ie.readOnly=!0},Cl=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType},uo=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType},Mi=(N,oe,Ie,Re)=>{let De=N._zod.innerType;Dt(De,oe,Re);let Le=oe.seen.get(N);Le.ref=De},yl={string:fi,number:pi,boolean:di,bigint:mi,symbol:$l,null:hi,undefined:zl,void:Sl,never:gi,any:yi,unknown:_i,date:vi,enum:bi,literal:xi,nan:kl,template_literal:Pl,file:El,success:Ol,custom:wi,function:Tl,transform:$i,map:Zl,set:Al,array:zi,object:Si,union:ki,intersection:Pi,tuple:Ei,record:Oi,nullable:Ti,nonoptional:Zi,default:Ii,prefault:Ci,catch:Ni,pipe:Ri,readonly:Di,promise:Cl,optional:uo,lazy:Mi};function rt(N,oe){if("_idmap"in N){let Re=N,De=Tn({...oe,processors:yl}),Le={};for(let Xe of Re._idmap.entries()){let[Ye,Qe]=Xe;Dt(Qe,De)}let Ue={},Be={registry:Re,uri:oe?.uri,defs:Le};De.external=Be;for(let Xe of Re._idmap.entries()){let[Ye,Qe]=Xe;Zn(De,Qe),lr(Ue,Ye,An(De,Qe))}if(Object.keys(Le).length>0){let Xe=De.target==="draft-2020-12"?"$defs":"definitions";Ue.__shared={[Xe]:Le}}return{schemas:Ue}}let Ie=Tn({...oe,processors:yl});return Dt(N,Ie),Zn(Ie,N),An(Ie,N)}var Nl=new WeakSet([Object.prototype,Error.prototype]);function lo(N,oe,Ie){Object.defineProperty(N,oe,{configurable:!0,enumerable:!1,get(){let Re=Ie(this);return Object.defineProperty(this,oe,{value:Re,configurable:!0,writable:!0}),Re},set(Re){Object.defineProperty(this,oe,{value:Re,configurable:!0,writable:!0})}})}var Qp=(N,oe)=>{Xs.init(N,oe),N.name="ZodError";let Ie=Object.getPrototypeOf(N);if(Nl.has(Ie))return;Nl.add(Ie),lo(Ie,"format",(Re)=>(De)=>Qs(Re,De)),lo(Ie,"flatten",(Re)=>(De)=>Ys(Re,De)),lo(Ie,"addIssue",(Re)=>(De)=>{Re.issues.push(De),Re.message=JSON.stringify(Re.issues,gn,2)}),lo(Ie,"addIssues",(Re)=>(De)=>{Re.issues.push(...De),Re.message=JSON.stringify(Re.issues,gn,2)}),Object.defineProperty(Ie,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var dr=ht("ZodError",Qp,void 0,{Parent:Error});var Rl=Wn(dr),Dl=Kn(dr),Ml=Hn(dr),Ve=qn(dr),Ll=tc(dr),jl=rc(dr),Fl=nc(dr),Ul=oc(dr),Bl=ic(dr),Jl=sc(dr),Vl=cc(dr),Wl=ac(dr);function td(){if(!cr.localeError)pr(qo())}function Cn(){if(!cr.memoizer)pr({memoizer:bu()})}var It=ht("ZodType",(N,oe)=>(td(),At.init(N,oe),N.def=oe,N.type=oe.type,N),{check(...N){let oe=this.def;return this.clone(fr(oe,{checks:[...oe.checks??[],...N.map((Ie)=>typeof Ie==="function"?{_zod:{check:Ie,def:{check:"custom"},onattach:[]}}:Ie)]}),{parent:!0})},with(...N){return this.check(...N)},clone(N,oe){return $r(this,N,oe)},brand(){return this},register(N,oe){return N.add(this,oe),this},refine(N,oe){return this.check(qd(N,oe))},superRefine(N,oe){return this.check(Gd(N,oe))},overwrite(N){return this.check(Rr(N))},optional(){return Hl(this)},exactOptional(){return Rd(this)},nullable(){return ql(this)},nullish(){return Hl(ql(this))},nonoptional(N){return Ud(this,N)},array(){return o(this)},or(N){return l([this,N])},and(N){return ot(this,N)},transform(N){return Gl(this,Nd(N))},default(N){return Ld(this,N)},prefault(N){return Fd(this,N)},catch(N){return Jd(this,N)},pipe(N){return Gl(this,N)},readonly(){return Kd(this)},describe(N){let oe=this.clone();return Ur.add(oe,{description:N}),oe},meta(...N){if(N.length===0)return Ur.get(this);let oe=this.clone();return Ur.add(oe,N[0]),oe},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(N,...oe){return oe.length===0?N(this):N(this,...oe)},get "~standard"(){return vn(this,"~standard",{...Uo(this),jsonSchema:{input:On(this,"input"),output:On(this,"output")}})},set "~standard"(N){Or(this,"~standard",N)},parse:function N(oe,Ie){return Rl(this,oe,Ie,{callee:N})},parseAsync:async function N(oe,Ie){return await Dl(this,oe,Ie,{callee:N})},safeParse(N,oe){return Ml(this,N,oe)},async safeParseAsync(N,oe){return Ve(this,N,oe)},get spa(){return this?.safeParseAsync},set spa(N){Or(this,"spa",N)},validate(N,oe){return Ao(this,N,oe)},validateAsync(N,oe){return Io(this,N,oe)},encode:function N(oe,Ie){return Ll(this,oe,Ie,{callee:N})},decode:function N(oe,Ie){return jl(this,oe,Ie,{callee:N})},encodeAsync:async function N(oe,Ie){return await Fl(this,oe,Ie,{callee:N})},decodeAsync:async function N(oe,Ie){return await Ul(this,oe,Ie,{callee:N})},safeEncode(N,oe){return Bl(this,N,oe)},safeDecode(N,oe){return Jl(this,N,oe)},async safeEncodeAsync(N,oe){return Vl(this,N,oe)},async safeDecodeAsync(N,oe){return Wl(this,N,oe)},toJSONSchema(N){return pl(this,{})(N)},get description(){return Ur.get(this)?.description},get _def(){return this._zod.def}}),Xl=ht("_ZodString",(N,oe)=>{eo.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>fi(N,Ie,Re,De)},Jn({format:(N)=>nr(N).format??null,minLength:(N)=>nr(N).minimum??null,maxLength:(N)=>nr(N).maximum??null},{regex(...N){return this.check(Go(...N))},includes(...N){return this.check(Qo(...N))},startsWith(...N){return this.check(ei(...N))},endsWith(...N){return this.check(ti(...N))},min(...N){return this.check(Hr(...N))},max(...N){return this.check(co(...N))},length(...N){return this.check(ao(...N))},nonempty(...N){return this.check(Hr(1,...N))},lowercase(N){return this.check(Xo(N))},uppercase(N){return this.check(Yo(N))},trim(){return this.check(oi())},normalize(...N){return this.check(ni(...N))},toLowerCase(){return this.check(ii())},toUpperCase(){return this.check(si())},slugify(){return this.check(ci())}})),Pt=ht("ZodString",(N,oe)=>{eo.init(N,oe),Xl.init(N,oe)},{email(N){return this.check(zu(sd,N))},url(N){return this.check(Tu(ad,N))},jwt(N){return this.check(Vu($d,N))},emoji(N){return this.check(Zu(ud,N))},guid(N){return this.check(Su(cd,N))},uuid(N){return this.check(ku(fo,N))},uuidv4(N){return this.check(Pu(fo,N))},uuidv6(N){return this.check(Eu(fo,N))},uuidv7(N){return this.check(Ou(fo,N))},nanoid(N){return this.check(Au(ld,N))},cuid(N){return this.check(Iu(fd,N))},cuid2(N){return this.check(Cu(pd,N))},ulid(N){return this.check(Nu(dd,N))},base64(N){return this.check(Uu(bd,N))},base64url(N){return this.check(Bu(xd,N))},xid(N){return this.check(Ru(md,N))},ksuid(N){return this.check(Du(hd,N))},ipv4(N){return this.check(Mu(gd,N))},ipv6(N){return this.check(Lu(yd,N))},cidrv4(N){return this.check(ju(_d,N))},cidrv6(N){return this.check(Fu(vd,N))},e164(N){return this.check(Ju(wd,N))},datetime(N){return this.check(Wu(rd,N))},date(N){return this.check(Ku(nd,N))},time(N){return this.check(Hu(od,N))},duration(N){return this.check(qu(id,N))}});function e(N){return $u(Pt,N)}var Ft=ht("ZodStringFormat",(N,oe)=>{Mt.init(N,oe),Xl.init(N,oe)}),rd=ht("ZodISODateTime",(N,oe)=>{Pa.init(N,oe),Ft.init(N,oe)}),nd=ht("ZodISODate",(N,oe)=>{Ea.init(N,oe),Ft.init(N,oe)}),od=ht("ZodISOTime",(N,oe)=>{Oa.init(N,oe),Ft.init(N,oe)}),id=ht("ZodISODuration",(N,oe)=>{Ta.init(N,oe),Ft.init(N,oe)}),sd=ht("ZodEmail",(N,oe)=>{ga.init(N,oe),Ft.init(N,oe)});var cd=ht("ZodGUID",(N,oe)=>{ma.init(N,oe),Ft.init(N,oe)});var fo=ht("ZodUUID",(N,oe)=>{ha.init(N,oe),Ft.init(N,oe)});var ad=ht("ZodURL",(N,oe)=>{va.init(N,oe),Ft.init(N,oe)});var ud=ht("ZodEmoji",(N,oe)=>{ba.init(N,oe),Ft.init(N,oe)});var ld=ht("ZodNanoID",(N,oe)=>{xa.init(N,oe),Ft.init(N,oe)});var fd=ht("ZodCUID",(N,oe)=>{wa.init(N,oe),Ft.init(N,oe)});var pd=ht("ZodCUID2",(N,oe)=>{$a.init(N,oe),Ft.init(N,oe)});var dd=ht("ZodULID",(N,oe)=>{za.init(N,oe),Ft.init(N,oe)});var md=ht("ZodXID",(N,oe)=>{Sa.init(N,oe),Ft.init(N,oe)});var hd=ht("ZodKSUID",(N,oe)=>{ka.init(N,oe),Ft.init(N,oe)});var gd=ht("ZodIPv4",(N,oe)=>{Za.init(N,oe),Ft.init(N,oe)});var yd=ht("ZodIPv6",(N,oe)=>{Ia.init(N,oe),Ft.init(N,oe)});var _d=ht("ZodCIDRv4",(N,oe)=>{Ca.init(N,oe),Ft.init(N,oe)});var vd=ht("ZodCIDRv6",(N,oe)=>{Na.init(N,oe),Ft.init(N,oe)});var bd=ht("ZodBase64",(N,oe)=>{Da.init(N,oe),Ft.init(N,oe)});var xd=ht("ZodBase64URL",(N,oe)=>{Ma.init(N,oe),Ft.init(N,oe)});var wd=ht("ZodE164",(N,oe)=>{La.init(N,oe),Ft.init(N,oe)});var $d=ht("ZodJWT",(N,oe)=>{ja.init(N,oe),Ft.init(N,oe)});var wt=ht("ZodNumber",(N,oe)=>{Jo.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>pi(N,Ie,Re,De),N.isFinite=!0},Jn({minValue:(N)=>{let{minimum:oe,exclusiveMinimum:Ie}=nr(N);return Math.max(oe??Number.NEGATIVE_INFINITY,Ie??Number.NEGATIVE_INFINITY)},maxValue:(N)=>{let{maximum:oe,exclusiveMaximum:Ie}=nr(N);return Math.min(oe??Number.POSITIVE_INFINITY,Ie??Number.POSITIVE_INFINITY)},isInt:(N)=>{let{isInt:oe,multipleOf:Ie}=nr(N);return!!oe||!!Ie?.some(Number.isSafeInteger)},format:(N)=>nr(N).format??null},{gt(N,oe){return this.check(Kr(N,oe))},gte(N,oe){return this.check(Zr(N,oe))},min(N,oe){return this.check(Zr(N,oe))},lt(N,oe){return this.check(Wr(N,oe))},lte(N,oe){return this.check(Tr(N,oe))},max(N,oe){return this.check(Tr(N,oe))},int(N){return this.check(Kl(N))},safe(N){return this.check(Kl(N))},positive(N){return this.check(Kr(0,N))},nonnegative(N){return this.check(Zr(0,N))},negative(N){return this.check(Wr(0,N))},nonpositive(N){return this.check(Tr(0,N))},multipleOf(N,oe){return this.check(Pn(N,oe))},step(N,oe){return this.check(Pn(N,oe))},finite(){return this}}));function r(N){return Gu(wt,N)}var zd=ht("ZodNumberFormat",(N,oe)=>{Fa.init(N,oe),wt.init(N,oe)});function Kl(N){return Xu(zd,N)}var Rt=ht("ZodBoolean",(N,oe)=>{Ua.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>di(N,Ie,Re,De)});function c(N){return Yu(Rt,N)}var Zt=ht("ZodBigInt",(N,oe)=>{Ba.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>mi(N,Ie,Re,De)},Jn({minValue:(N)=>nr(N).minimum??null,maxValue:(N)=>nr(N).maximum??null,format:(N)=>nr(N).format??null},{gte(N,oe){return this.check(Zr(N,oe))},min(N,oe){return this.check(Zr(N,oe))},gt(N,oe){return this.check(Kr(N,oe))},lt(N,oe){return this.check(Wr(N,oe))},lte(N,oe){return this.check(Tr(N,oe))},max(N,oe){return this.check(Tr(N,oe))},positive(N){return this.check(Kr(BigInt(0),N))},negative(N){return this.check(Wr(BigInt(0),N))},nonpositive(N){return this.check(Tr(BigInt(0),N))},nonnegative(N){return this.check(Zr(BigInt(0),N))},multipleOf(N,oe){return this.check(Pn(N,oe))}}));var Sd=ht("ZodNull",(N,oe)=>{Ja.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>hi(N,Ie,Re,De)});function We(N){return Qu(Sd,N)}var kd=ht("ZodAny",(N,oe)=>{Va.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>yi(N,Ie,Re,De)});function ie(){return el(kd)}var Pd=ht("ZodUnknown",(N,oe)=>{Wa.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>_i(N,Ie,Re,De)});function v(){return tl(Pd)}var Ed=ht("ZodNever",(N,oe)=>{Ka.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>gi(N,Ie,Re,De)});function Ae(N){return rl(Ed,N)}var Jt=ht("ZodDate",(N,oe)=>{Ha.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>vi(N,Ie,Re,De),N.min=(Ie,Re)=>N.check(Zr(Ie,Re)),N.max=(Ie,Re)=>N.check(Tr(Ie,Re))},Jn({minDate:(N)=>{let{minimum:oe}=nr(N);return oe?new Date(oe):null},maxDate:(N)=>{let{maximum:oe}=nr(N);return oe?new Date(oe):null}},{}));var Od=ht("ZodArray",(N,oe)=>{Cn(),qa.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>zi(N,Ie,Re,De),N.element=oe.element},{min(N,oe){return this.check(Hr(N,oe))},nonempty(N){return this.check(Hr(1,N))},max(N,oe){return this.check(co(N,oe))},length(N,oe){return this.check(ao(N,oe))},unwrap(){return this.element}});function o(N,oe){return nl(Od,N,oe)}var Ui=ht("ZodObject",(N,oe)=>{Cn(),Ya.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Si(N,Ie,Re,De),ap(N,"shape",(Ie)=>Ie._zod.def.shape,!1)},{keyof(){return i(Object.keys(this._zod.def.shape))},catchall(N){return this.clone(fr(this._zod.def,{catchall:N}))},passthrough(){return this.clone(fr(this._zod.def,{catchall:v()}))},loose(){return this.clone(fr(this._zod.def,{catchall:v()}))},strict(){return this.clone(fr(this._zod.def,{catchall:Ae()}))},strip(){return this.clone(fr(this._zod.def,{catchall:void 0}))},extend(N){return ep(this,N)},safeExtend(N){return tp(this,N)},merge(N){return rp(this,N)},pick(N){return Yf(this,N)},omit(N){return Qf(this,N)},partial(...N){return Us(Bi,this,N[0])},exactPartial(...N){return Us(Ql,this,N[0],"exactPartial")},required(...N){return np(ef,this,N[0])}});function t(N,oe){let Ie={type:"object",shape:N??{},...zt(oe)};return new Ui(Ie)}function se(N,oe){return new Ui({type:"object",shape:N,catchall:Ae(),...zt(oe)})}function U(N,oe){return new Ui({type:"object",shape:N,catchall:v(),...zt(oe)})}var Yl=ht("ZodUnion",(N,oe)=>{Vo.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>ki(N,Ie,Re,De),N.options=oe.options});function l(N,oe){return new Yl({type:"union",options:N,...zt(oe)})}var Td=ht("ZodDiscriminatedUnion",(N,oe)=>{Yl.init(N,oe),Qa.init(N,oe)});function f(N,oe,Ie){return new Td({type:"union",options:oe,discriminator:N,...zt(Ie)})}var Zd=ht("ZodIntersection",(N,oe)=>{eu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Pi(N,Ie,Re,De)});function ot(N,oe){return new Zd({type:"intersection",left:N,right:oe})}var Ad=ht("ZodTuple",(N,oe)=>{Cn(),tu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ei(N,Ie,Re,De)},{rest(N){return this.clone({...this._zod.def,rest:N})},partial(){let N=this._zod.def;if(N.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...N,items:N.items.map((oe)=>new Bi({type:"optional",innerType:oe}))})}});function ce(N,oe,Ie){let Re=oe instanceof At,De=Re?Ie:oe;return new Ad({type:"tuple",items:N,rest:Re?oe:null,...zt(De)})}var ji=ht("ZodRecord",(N,oe)=>{Cn(),ru.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Oi(N,Ie,Re,De),N.keyType=oe.keyType,N.valueType=oe.valueType});function y(N,oe,Ie){if(!oe||!oe._zod)return new ji({type:"record",keyType:e(),valueType:N,...zt(oe)});return new ji({type:"record",keyType:N,valueType:oe,...zt(Ie)})}function bn(N,oe,Ie){return new ji({type:"record",keyType:N,valueType:oe,...zt(Ie),partial:!0})}var Fi=ht("ZodEnum",(N,oe)=>{nu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Re,De,Le)=>bi(N,Re,De,Le),N.enum=oe.entries,N.options=[...N._zod.values];let Ie=new Set(Object.keys(oe.entries));N.extract=(Re,De)=>{let Le={};for(let Ue of Re)if(Ie.has(Ue))Le[Ue]=oe.entries[Ue];else throw Error(`Key ${Ue} not found in enum`);return new Fi({...oe,checks:[],...zt(De),entries:Le})},N.exclude=(Re,De)=>{let Le={...oe.entries};for(let Ue of Re)if(Ie.has(Ue))delete Le[Ue];else throw Error(`Key ${Ue} not found in enum`);return new Fi({...oe,checks:[],...zt(De),entries:Le})}});function i(N,oe){let Ie=Array.isArray(N)?Object.fromEntries(N.map((Re)=>[Re,Re])):N;return new Fi({type:"enum",entries:Ie,...zt(oe)})}var Id=ht("ZodLiteral",(N,oe)=>{ou.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>xi(N,Ie,Re,De),N.values=new Set(oe.values),Object.defineProperty(N,"value",{get(){if(oe.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return oe.values[0]}})});function n(N,oe){return new Id({type:"literal",values:Array.isArray(N)?N:[N],...zt(oe)})}var Cd=ht("ZodTransform",(N,oe)=>{Cn(),iu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>$i(N,Ie,Re,De),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")throw new xn(N.constructor.name);Ie.addIssue=(Le)=>{if(typeof Le==="string")Ie.issues.push(Fr(Le,Ie.value,oe));else{let Ue=Le;if(Ue.fatal)Ue.continue=!1;if(Ue.code??(Ue.code="custom"),!("input"in Ue))Ue.input=Ie.value;Ue.inst??(Ue.inst=N),Ie.issues.push(Fr(Ue))}};let De=oe.transform(Ie.value,Ie);if(De instanceof Promise)return De.then((Le)=>(Ie.value=Le,Ie));return Ie.value=De,Ie}});function Nd(N){return new Cd({type:"transform",transform:N})}var Bi=ht("ZodOptional",(N,oe)=>{Wo.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>uo(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Hl(N){return new Bi({type:"optional",innerType:N})}var Ql=ht("ZodExactOptional",(N,oe)=>{su.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>uo(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Rd(N){return new Ql({type:"optional",innerType:N})}var Dd=ht("ZodNullable",(N,oe)=>{cu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ti(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function ql(N){return new Dd({type:"nullable",innerType:N})}var Md=ht("ZodDefault",(N,oe)=>{au.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ii(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType,N.removeDefault=N.unwrap});function Ld(N,oe){return new Md({type:"default",innerType:N,get defaultValue(){return typeof oe==="function"?oe():So(oe)}})}var jd=ht("ZodPrefault",(N,oe)=>{uu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ci(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Fd(N,oe){return new jd({type:"prefault",innerType:N,get defaultValue(){return typeof oe==="function"?oe():So(oe)}})}var ef=ht("ZodNonOptional",(N,oe)=>{lu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Zi(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Ud(N,oe){return new ef({type:"nonoptional",innerType:N,...zt(oe)})}var Bd=ht("ZodCatch",(N,oe)=>{fu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ni(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType,N.removeCatch=N.unwrap});function Jd(N,oe){return new Bd({type:"catch",innerType:N,catchValue:typeof oe==="function"?oe:Ws(oe)})}var Vd=ht("ZodPipe",(N,oe)=>{pu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ri(N,Ie,Re,De),N.in=oe.in,N.out=oe.out});function Gl(N,oe){return new Vd({type:"pipe",in:N,out:oe})}var Wd=ht("ZodReadonly",(N,oe)=>{du.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Di(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Kd(N){return new Wd({type:"readonly",innerType:N})}var Hd=ht("ZodLazy",(N,oe)=>{mu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Mi(N,Ie,Re,De),N.unwrap=()=>N._zod.def.getter()});function Ne(N){return new Hd({type:"lazy",getter:N})}var Ji=ht("ZodCustom",(N,oe)=>{hu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>wi(N,Ie,Re,De)});function Kt(N,oe){return ol(Ji,N??(()=>!0),oe)}function qd(N,oe={}){return il(Ji,N,oe)}function Gd(N,oe){return sl(N,oe)}var Xd=ht("ZodInstanceOf",(N,oe)=>{Ji.init(N,oe)},{properties(N,oe){return this.check(ri(N,oe))}});function Qt(N,oe={}){let Ie=new Xd({type:"custom",check:"custom",fn:(Re)=>Re instanceof N,abort:!0,...zt(oe)});return Ie._zod.bag.Class=N,Ie._zod.check=(Re)=>{if(!(Re.value instanceof N))Re.issues.push({code:"invalid_type",expected:N.name,input:Re.value,inst:Ie,path:[...Ie._zod.def.path??[]]})},Ie}function G(N){let oe=Ne(()=>l([e(N),r(),c(),We(),o(oe),y(e(),oe)]));return oe}class po extends Error{constructor(N,oe){super(N),this.name="ParseError",this.type=oe.type,this.field=oe.field,this.value=oe.value,this.line=oe.line}}var tf=10,Yd=13,Br=32;function Vi(N){}function of(N){if(typeof N=="function")throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:oe=Vi,onError:Ie=Vi,onRetry:Re=Vi,onComment:De,maxBufferSize:Le}=N,Ue=[],Be=0,Xe=!0,Ye,Qe="",et=0,tt,ft=!1;function gt(_t){if(ft)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(Xe&&(Xe=!1,_t.charCodeAt(0)===239&&_t.charCodeAt(1)===187&&_t.charCodeAt(2)===191&&(_t=_t.slice(3))),Ue.length===0){let er=St(_t);er!==""&&(Ue.push(er),Be=er.length),bt();return}if(_t.indexOf(`
|
|
59
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let Ue of N.seen.entries()){let Be=Ue[1];if(oe===Ue[0]){Le(Ue);continue}if(N.external){let Ye=N.external.registry.get(Ue[0])?.id;if(oe!==Ue[0]&&Ye){Le(Ue);continue}}if(N.metadataRegistry.get(Ue[0])?.id){Le(Ue);continue}if(Be.cycle){Le(Ue);continue}if(Be.count>1){if(N.reused==="ref")Le(Ue)}}if(N.external)N.sharedDefsExtractedFor=N.external}function ll(N){let oe=N.anyOf;if(!Array.isArray(oe)||oe.length===0||N.type!==void 0)return;let Ie=[];for(let Re of oe){if(!Re||typeof Re!=="object")return;ll(Re);let De=Object.keys(Re);if(De.length!==1||De[0]!=="type")return;let Le=Re.type;for(let Ue of Array.isArray(Le)?Le:[Le]){if(typeof Ue!=="string")return;if(!Ie.includes(Ue))Ie.push(Ue)}}delete N.anyOf,N.type=Ie.length===1?Ie[0]:Ie}var fl=new Set(["type","properties","required","additionalProperties"]),al=["oneOf","anyOf"];function ul(N){let oe=N.additionalProperties;if(oe===void 0||oe===!1||typeof oe!=="object"||oe===null)return null;return Object.keys(oe).length?oe:null}function ai(N){let oe=[];for(let Le of N){if(typeof Le!=="object"||Le.type!=="object")return null;for(let Ue in Le)if(!fl.has(Ue))return null;oe.push(Le)}let Ie={},Re=new Set;for(let Le of oe){for(let Ue in Le.properties){if(Object.prototype.hasOwnProperty.call(Ie,Ue))continue;let Be=[];for(let Ye of oe){let Qe=Ye.properties?.[Ue]??ul(Ye);if(Qe===null||Qe===void 0)continue;if(!Be.some((et)=>JSON.stringify(et)===JSON.stringify(Qe)))Be.push(Qe)}let Xe=Be.length===1?Be[0]:ai(Be)??{allOf:Be};ar(Ie,Ue,Xe)}for(let Ue of Le.required??[])Re.add(Ue)}let De={type:"object",properties:Ie};if(Re.size)De.required=[...Re];if(oe.every((Le)=>Le.additionalProperties===!1))De.additionalProperties=!1;else{let Le=[];for(let Ue of oe){let Be=ul(Ue);if(Be&&!Le.some((Xe)=>JSON.stringify(Xe)===JSON.stringify(Be)))Le.push(Be)}if(Le.length===1)De.additionalProperties=Le[0];else if(Le.length>1)De.additionalProperties={allOf:Le}}return De}function Up(N){let oe=N.allOf;if(!Array.isArray(oe)||oe.length<2)return;for(let De of fl)if(De in N)return;let Ie=oe.filter((De)=>al.some((Le)=>Array.isArray(De[Le]))),Re=null;if(!Ie.length)Re=ai(oe);else{let De=Ie[0],Le=al.find((Xe)=>Array.isArray(De[Xe]));if(Object.keys(De).length!==1)return;let Ue=oe.filter((Xe)=>Xe!==De),Be=De[Le].map((Xe)=>ai([...Ue,Xe]));if(Be.some((Xe)=>!Xe))return;Re={[Le]:Be}}if(!Re)return;delete N.allOf,En(N,Re)}function An(N,oe){let Ie=N.seen.get(oe);if(!Ie)throw Error("Unprocessed schema. This is a bug in Zod.");let Re=(Be)=>{let Xe=N.seen.get(Be);if(Xe.ref===null)return;let Ye=Xe.def??Xe.schema,Qe={...Ye},et=Xe.ref;if(Xe.ref=null,et){Re(et);let ft=N.seen.get(et),gt=ft.schema;if(gt.$ref&&(N.target==="draft-07"||N.target==="draft-04"||N.target==="openapi-3.0"))Ye.allOf=Ye.allOf??[],Ye.allOf.push(gt);else En(Ye,gt);if(En(Ye,Qe),Be._zod.parent===et)for(let St in Ye){if(St==="$ref"||St==="allOf")continue;if(!(St in Qe))delete Ye[St]}if(gt.$ref&&ft.def)for(let St in Ye){if(St==="$ref"||St==="allOf")continue;if(St in ft.def&&JSON.stringify(Ye[St])===JSON.stringify(ft.def[St]))delete Ye[St]}}let tt=Be._zod.parent;if(tt&&tt!==et){Re(tt);let ft=N.seen.get(tt);if(ft?.schema.$ref){if(Ye.$ref=ft.schema.$ref,ft.def)for(let gt in Ye){if(gt==="$ref"||gt==="allOf")continue;if(gt in ft.def&&JSON.stringify(Ye[gt])===JSON.stringify(ft.def[gt]))delete Ye[gt]}}}N.override({zodSchema:Be,jsonSchema:Ye,path:Xe.path??[]})};if(!N.external||N.sharedEmitDoneFor!==N.external){for(let Be of[...N.seen.entries()].reverse())Re(Be[0]);if(N.target!=="openapi-3.0")for(let Be of N.seen.entries())ll(Be[1].def??Be[1].schema);for(let Be of N.deferred)Be();if(N.intersections.length){let Be=new Map;for(let Xe of N.seen.values())for(let Ye of[Xe.schema,Xe.def]){let Qe=Ye?.allOf;if(!Array.isArray(Qe))continue;let et=Be.get(Qe);if(et)et.push(Ye);else Be.set(Qe,[Ye])}for(let Xe of N.intersections)for(let Ye of Be.get(Xe)??[])Up(Ye)}}let De={};if(N.target==="draft-2020-12")De.$schema="https://json-schema.org/draft/2020-12/schema";else if(N.target==="draft-07")De.$schema="http://json-schema.org/draft-07/schema#";else if(N.target==="draft-04")De.$schema="http://json-schema.org/draft-04/schema#";else if(N.target==="openapi-3.0");if(N.external?.uri){let Be=N.external.registry.get(oe)?.id;if(!Be)throw Error("Schema is missing an `id` property");De.$id=N.external.uri(Be)}En(De,Ie.defId?Ie.schema:Ie.def??Ie.schema);let Le=N.metadataRegistry.get(oe)?.id;if(Le!==void 0&&De.id===Le)delete De.id;let Ue=N.external?.defs??{};if(!N.external||N.sharedEmitDoneFor!==N.external)for(let Be of N.seen.entries()){let Xe=Be[1];if(Xe.def&&Xe.defId){if(Xe.def.id===Xe.defId)delete Xe.def.id;ar(Ue,Xe.defId,Xe.def)}}if(N.external)N.sharedEmitDoneFor=N.external;if(N.external);else if(Object.keys(Ue).length>0)if(N.target==="draft-2020-12")De.$defs=Ue;else De.definitions=Ue;try{let Be=JSON.parse(JSON.stringify(De));return Object.defineProperty(Be,"~standard",{value:{...oe["~standard"],jsonSchema:{input:On(oe,"input",N.processors),output:On(oe,"output",N.processors)}},enumerable:!1,writable:!1}),Be}catch(Be){throw Error("Error converting schema to JSON.")}}function sr(N,oe){let Ie=oe??{seen:new Set};if(Ie.seen.has(N))return!1;Ie.seen.add(N);let Re=N._zod.def;if(Re.type==="transform")return!0;if(Re.type==="array")return sr(Re.element,Ie);if(Re.type==="set")return sr(Re.valueType,Ie);if(Re.type==="lazy")return sr(Re.getter(),Ie);if(Re.type==="promise"||Re.type==="optional"||Re.type==="nonoptional"||Re.type==="nullable"||Re.type==="readonly"||Re.type==="default"||Re.type==="prefault"||Re.type==="catch")return sr(Re.innerType,Ie);if(Re.type==="intersection")return sr(Re.left,Ie)||sr(Re.right,Ie);if(Re.type==="record"||Re.type==="map")return sr(Re.keyType,Ie)||sr(Re.valueType,Ie);if(Re.type==="pipe"){if(N._zod.traits.has("$ZodCodec"))return!0;return sr(Re.in,Ie)||sr(Re.out,Ie)}if(Re.type==="object"){for(let De in Re.shape)if(sr(Re.shape[De],Ie))return!0;return!1}if(Re.type==="union"){for(let De of Re.options)if(sr(De,Ie))return!0;return!1}if(Re.type==="tuple"){for(let De of Re.items)if(sr(De,Ie))return!0;if(Re.rest&&sr(Re.rest,Ie))return!0;return!1}return!1}var pl=(N,oe={})=>(Ie)=>{let Re=Tn({...Ie,processors:oe});return Dt(N,Re),Zn(Re,N),An(Re,N)},On=(N,oe,Ie={})=>(Re)=>{let{libraryOptions:De,target:Le}=Re??{},Ue=Tn({...De??{},target:Le,io:oe,processors:Ie});return Dt(N,Ue),Zn(Ue,N),An(Ue,N)};var Kr=(N,oe,Ie)=>{if(N[oe]===void 0||Ie>N[oe])N[oe]=Ie},Hr=(N,oe,Ie)=>{if(N[oe]===void 0||Ie<N[oe])N[oe]=Ie},dl=(N,oe)=>{Kr(N,"minimum",oe),Hr(N,"maximum",oe)},_l=(N,oe)=>{if(N.multipleOf??(N.multipleOf=[]),!N.multipleOf.includes(oe))N.multipleOf.push(oe)},vl=(N,oe)=>{N.patterns??(N.patterns=new Set),N.patterns.add(oe)},bl=(N,oe)=>{N.mime=N.mime?N.mime.filter((Ie)=>oe.includes(Ie)):[...oe]},xl=(N,oe)=>{if(N.format=oe,oe.includes("int"))N.isInt=!0},ml=(N,oe)=>Kr(N,"minimum",oe.minimum),hl=(N,oe)=>Hr(N,"maximum",oe.maximum),gl=(N)=>(oe,Ie)=>{xl(oe,Ie.format);let[Re,De]=N[Ie.format];Kr(oe,"minimum",Re),Hr(oe,"maximum",De)},Bp={greater_than:(N,oe)=>Kr(N,oe.inclusive?"minimum":"exclusiveMinimum",oe.value),less_than:(N,oe)=>Hr(N,oe.inclusive?"maximum":"exclusiveMaximum",oe.value),multiple_of:(N,oe)=>_l(N,oe.value),number_format:gl(Ln),bigint_format:gl(Po),min_length:ml,max_length:hl,length_equals:(N,oe)=>dl(N,oe.length),min_size:ml,max_size:hl,size_equals:(N,oe)=>dl(N,oe.size),string_format:(N,oe)=>{if(xl(N,oe.format),oe.pattern)vl(N,oe.pattern);if(oe.format==="base64"||oe.format==="base64url")N.contentEncoding=oe.format;if(oe.local||oe.precision===-1)N.laxFormat=!0},mime_type:(N,oe)=>bl(N,oe.mime)};function tr(N){let oe={},Ie=N._zod.def,Re=N._zod.traits.has("$ZodCheck")?[N,...Ie.checks??[]]:Ie.checks??[];for(let Le of Re)Bp[Le._zod.def.check]?.(oe,Le._zod.def);let De=N._zod.bag;if(De.minimum!==void 0)Kr(oe,"minimum",De.minimum);if(De.exclusiveMinimum!==void 0)Kr(oe,"exclusiveMinimum",De.exclusiveMinimum);if(De.maximum!==void 0)Hr(oe,"maximum",De.maximum);if(De.exclusiveMaximum!==void 0)Hr(oe,"exclusiveMaximum",De.exclusiveMaximum);if(De.multipleOf!==void 0)_l(oe,De.multipleOf);if(De.format!==void 0){if(oe.format??(oe.format=De.format),De.format.includes("int"))oe.isInt=!0}if(De.mime)bl(oe,De.mime);for(let Le of De.patterns??[])vl(oe,Le);return oe}var Jp={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vp=new Map([[Bo,zc],[to,Sc]]),wl=(N)=>Vp.get(N)??N,fi=(N,oe,Ie,Re)=>{let De=Ie;De.type="string";let{minimum:Le,maximum:Ue,format:Be,patterns:Xe,contentEncoding:Ye,laxFormat:Qe}=tr(N);if(typeof Le==="number")De.minLength=Le;if(typeof Ue==="number")De.maxLength=Ue;if(Be){if(De.format=Jp[Be]??Be,De.format==="")delete De.format;if(Be==="time"||Qe)delete De.format}if(Ye)De.contentEncoding=Ye;if(Xe&&Xe.size>0){let et=[...Xe].map(wl);if(et.length===1)De.pattern=et[0].source;else if(et.length>1)De.allOf=[...et.map((tt)=>({...oe.target==="draft-07"||oe.target==="draft-04"||oe.target==="openapi-3.0"?{type:"string"}:{},pattern:tt.source}))]}},pi=(N,oe,Ie,Re)=>{let De=Ie,{minimum:Le,maximum:Ue,multipleOf:Be,exclusiveMaximum:Xe,exclusiveMinimum:Ye,isInt:Qe}=tr(N);De.type=Qe?"integer":"number";let et=typeof Ye==="number"&&Ye>=(Le??Number.NEGATIVE_INFINITY),tt=typeof Xe==="number"&&Xe<=(Ue??Number.POSITIVE_INFINITY),ft=oe.target==="draft-04"||oe.target==="openapi-3.0";if(et)if(ft)De.minimum=Ye,De.exclusiveMinimum=!0;else De.exclusiveMinimum=Ye;else if(typeof Le==="number")De.minimum=Le;if(tt)if(ft)De.maximum=Xe,De.exclusiveMaximum=!0;else De.exclusiveMaximum=Xe;else if(typeof Ue==="number")De.maximum=Ue;if(Be){let gt=new Set;for(let Et of Be)if(Number.isFinite(Et)&&Et!==0)gt.add(Math.abs(Et));else nr(N,oe,De,Re,`A multipleOf divisor of ${Et} cannot be represented in JSON Schema`);let[bt,...St]=gt;if(bt!==void 0)De.multipleOf=bt;if(St.length)De.allOf=[...De.allOf??[],...St.map((Et)=>({multipleOf:Et}))]}},di=(N,oe,Ie,Re)=>{Ie.type="boolean"},mi=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"BigInt cannot be represented in JSON Schema")},$l=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"Symbols cannot be represented in JSON Schema")},hi=(N,oe,Ie,Re)=>{if(oe.target==="openapi-3.0")Ie.type="string",Ie.nullable=!0,Ie.enum=[null];else Ie.type="null"},zl=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"Undefined cannot be represented in JSON Schema")},Sl=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"Void cannot be represented in JSON Schema")},gi=(N,oe,Ie,Re)=>{Ie.not={}},yi=(N,oe,Ie,Re)=>{},_i=(N,oe,Ie,Re)=>{},vi=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"Date cannot be represented in JSON Schema")},bi=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=Xr(De.entries);if(Le.length===0){Ie.not={};return}if(Le.every((Ue)=>typeof Ue==="number"))Ie.type="number";if(Le.every((Ue)=>typeof Ue==="string"))Ie.type="string";Ie.enum=Le},xi=(N,oe,Ie,Re)=>{let De=N._zod.def;if(De.values.length===0){Ie.not={};return}let Le=[];for(let Ue of De.values)if(Ue===void 0){if(nr(N,oe,Ie,Re,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof Ue==="bigint"){if(nr(N,oe,Ie,Re,"BigInt literals cannot be represented in JSON Schema"))return;Le.push(Number(Ue))}else Le.push(Ue);if(Le.length===0);else if(Le.length===1){let Ue=Le[0];if(Ie.type=Ue===null?"null":typeof Ue,oe.target==="draft-04"||oe.target==="openapi-3.0")Ie.enum=[Ue];else Ie.const=Ue}else{if(Le.every((Ue)=>typeof Ue==="number"))Ie.type="number";if(Le.every((Ue)=>typeof Ue==="string"))Ie.type="string";if(Le.every((Ue)=>typeof Ue==="boolean"))Ie.type="boolean";if(Le.every((Ue)=>Ue===null))Ie.type="null";Ie.enum=Le}},kl=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"NaN cannot be represented in JSON Schema")},Pl=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.pattern;if(!Le)throw Error("Pattern not found in template literal");De.type="string",De.pattern=Le.source},El=(N,oe,Ie,Re)=>{let De=Ie;De.type="string",De.format="binary",De.contentEncoding="binary";let{minimum:Le,maximum:Ue,mime:Be}=tr(N);if(Le!==void 0)De.minLength=Le;if(Ue!==void 0)De.maxLength=Ue;if(!Be)return;if(Be.length===0)De.not={};else if(Be.length===1)De.contentMediaType=Be[0];else De.anyOf=Be.map((Xe)=>({contentMediaType:Xe}))},Ol=(N,oe,Ie,Re)=>{Ie.type="boolean"},wi=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"Custom types cannot be represented in JSON Schema")},Tl=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"Function types cannot be represented in JSON Schema")},$i=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"Transforms cannot be represented in JSON Schema")},Zl=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"Map cannot be represented in JSON Schema")},Al=(N,oe,Ie,Re)=>{nr(N,oe,Ie,Re,"Set cannot be represented in JSON Schema")},zi=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.def,{minimum:Ue,maximum:Be}=tr(N);if(typeof Ue==="number")De.minItems=Ue;if(typeof Be==="number")De.maxItems=Be;De.type="array",De.items=Dt(Le.element,oe,{...Re,path:[...Re.path,"items"]})};function In(N){let oe=N._zod.def;if(oe.type==="pipe"&&oe.in._zod.traits.has("$ZodTransform"))return In(oe.out);if(oe.type==="catch")return In(oe.innerType);return N._zod.optin}var Si=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.def,Ue=Le.shape;if(Object.getOwnPropertySymbols(Ue).length&&nr(N,oe,De,Re,"Symbol keys cannot be represented in JSON Schema"))return;De.type="object",De.properties={};for(let Ye in Ue)ar(De.properties,Ye,Dt(Ue[Ye],oe,{...Re,path:[...Re.path,"properties",Ye]}));let Xe=[];for(let Ye of Object.keys(Ue)){let Qe=Le.shape[Ye];if(oe.io==="input"?In(Qe)===void 0:Qe._zod.optout===void 0)Xe.push(Ye)}if(Xe.length>0)De.required=Xe;if(Le.catchall?._zod.def.type==="never")De.additionalProperties=!1;else if(!Le.catchall){if(oe.io==="output")De.additionalProperties=!1}else if(Le.catchall)De.additionalProperties=Dt(Le.catchall,oe,{...Re,path:[...Re.path,"additionalProperties"]})},ki=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=De.inclusive===!1,Ue=De.options.map((Be,Xe)=>Dt(Be,oe,{...Re,path:[...Re.path,Le?"oneOf":"anyOf",Xe]}));if(Le)Ie.oneOf=Ue;else Ie.anyOf=Ue},Pi=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=Dt(De.left,oe,{...Re,path:[...Re.path,"allOf",0]}),Ue=Dt(De.right,oe,{...Re,path:[...Re.path,"allOf",1]}),Be=(Ye)=>("allOf"in Ye)&&Object.keys(Ye).length===1,Xe=[...Be(Le)?Le.allOf:[Le],...Be(Ue)?Ue.allOf:[Ue]];Ie.allOf=Xe,oe.intersections.push(Xe)},Ei=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.def;De.type="array";let Ue=oe.target==="draft-2020-12"?"prefixItems":"items",Be=oe.target==="draft-2020-12"?"items":oe.target==="openapi-3.0"?"items":"additionalItems",Xe=Le.items.map((bt,St)=>Dt(bt,oe,{...Re,path:[...Re.path,Ue,St]})),Ye=Le.rest?Dt(Le.rest,oe,{...Re,path:[...Re.path,Be,...oe.target==="openapi-3.0"?[Le.items.length]:[]]}):null,Qe=Le.items.length;while(Qe>0){let bt=Le.items[Qe-1];if(!(oe.io==="input"?In(bt)!==void 0:bt._zod.optout==="optional"))break;Qe--}let et=Le.items.length,tt=!Le.rest;if(oe.target==="draft-2020-12"){if(De.prefixItems=Xe,tt)De.items=!1;else if(Ye)De.items=Ye;if(Qe>0)De.minItems=Qe;if(tt)De.maxItems=et}else if(oe.target==="openapi-3.0"){if(De.items={anyOf:Xe},Ye)De.items.anyOf.push(Ye);if(Qe>0)De.minItems=Qe;if(tt)De.maxItems=et}else{if(De.items=Xe,tt)De.additionalItems=!1;else if(Ye)De.additionalItems=Ye;if(Qe>0)De.minItems=Qe;if(tt)De.maxItems=et}let{minimum:ft,maximum:gt}=tr(N);if(typeof ft==="number")De.minItems=ft;if(typeof gt==="number")De.maxItems=gt};function ui(N,oe,Ie){if(oe.$ref){if(Ie.has(oe))return oe;Ie.add(oe);let gt=N.get(oe)?.def;if(!gt)return oe;let bt=ui(N,gt,Ie);return bt===gt?oe:bt}for(let gt of["anyOf","oneOf"]){let bt=oe[gt];if(!Array.isArray(bt))continue;let St=bt.map((Et)=>ui(N,Et,Ie));if(St.some((Et,er)=>Et!==bt[er]))oe={...oe,[gt]:St}}let Re=Array.isArray(oe.type)?oe.type:[oe.type],De=!Re.includes("string")&&Re.some((gt)=>gt==="number"||gt==="integer"),Le=oe.enum??(oe.const!==void 0?[oe.const]:void 0);if(!De&&!Le?.some((gt)=>typeof gt==="number"))return oe;let{minimum:Ue,maximum:Be,exclusiveMinimum:Xe,exclusiveMaximum:Ye,multipleOf:Qe,format:et,id:tt,...ft}=oe;if(ft.enum)ft.enum=ft.enum.map((gt)=>typeof gt==="number"?String(gt):gt);else if(typeof ft.const==="number")ft.const=String(ft.const);if(!De)return ft;if(ft.type="string",!Le)ft.pattern=(Re.includes("number")?wn:Ro).source;return ft}var li=new WeakMap;function Wp(N){let oe=new Map;for(let Re of N.seen.values())if(Re.def&&!oe.has(Re.schema))oe.set(Re.schema,Re);let Ie=new Map;for(let Re of li.get(N)??[]){let De=N.seen.get(Re),Le=(De?.def??De?.schema)?.propertyNames;if(!Le||Le===!0||Ie.has(Le))continue;let Ue=ui(oe,Le,new Set);if(Ue!==Le)Ie.set(Le,Ue)}if(!Ie.size)return;for(let Re of N.seen.values())for(let De of[Re.schema,Re.def]){let Le=De&&Ie.get(De.propertyNames);if(Le)De.propertyNames=Le}}var Oi=(N,oe,Ie,Re)=>{let De=Ie,Le=N._zod.def;De.type="object";let Ue=Le.keyType,Be=tr(Ue).patterns;if(Le.mode==="loose"&&Be&&Be.size>0){let Qe=Dt(Le.valueType,oe,{...Re,path:[...Re.path,"patternProperties","*"]});De.patternProperties={};for(let et of Be)ar(De.patternProperties,wl(et).source,Qe)}else{if(oe.target==="draft-07"||oe.target==="draft-2020-12"){De.propertyNames=Dt(Le.keyType,oe,{...Re,path:[...Re.path,"propertyNames"]});let Qe=li.get(oe);if(!Qe)Qe=[],li.set(oe,Qe),oe.deferred.push(()=>Wp(oe));Qe.push(N)}De.additionalProperties=Dt(Le.valueType,oe,{...Re,path:[...Re.path,"additionalProperties"]})}let Xe=Ue._zod.values,Ye=oe.io==="input"&&In(Le.valueType)!==void 0;if(Xe&&!Le.partial&&!Ye){let Qe=[...Xe].filter((et)=>typeof et==="string"||typeof et==="number");if(Qe.length>0)De.required=Qe.map(String)}},Ti=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=Dt(De.innerType,oe,Re),Ue=oe.seen.get(N);if(oe.target==="openapi-3.0")Ue.ref=De.innerType,Ie.nullable=!0;else Ie.anyOf=[Le,{type:"null"}]},Zi=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType},Ai=Symbol();function Il(N,oe,Ie,Re,De){let Le=!1,Ue=JSON.stringify(N,(Be,Xe)=>{if(typeof Xe!=="bigint")return Xe;return Le=!0,null});if(!Le)return JSON.parse(Ue);return nr(oe,Ie,Re,De,"BigInt defaults cannot be represented in JSON Schema"),Ai}var Ii=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType;let Ue=Il(De.defaultValue,N,oe,Ie,Re);if(Ue!==Ai)Ie.default=Ue},Ci=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);if(Le.ref=De.innerType,oe.io!=="input")return;let Ue=Il(De.defaultValue,N,oe,Ie,Re);if(Ue!==Ai)Ie._prefault=Ue},Ni=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType;let Ue;try{Ue=De.catchValue(void 0)}catch{nr(N,oe,Ie,Re,"Dynamic catch values are not supported in JSON Schema");return}Ie.default=Ue},Ri=(N,oe,Ie,Re)=>{let De=N._zod.def,Le=De.in._zod.traits.has("$ZodTransform"),Ue=oe.io==="input"?Le?De.out:De.in:De.out;Dt(Ue,oe,Re);let Be=oe.seen.get(N);Be.ref=Ue},Di=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType,Ie.readOnly=!0},Cl=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType},uo=(N,oe,Ie,Re)=>{let De=N._zod.def;Dt(De.innerType,oe,Re);let Le=oe.seen.get(N);Le.ref=De.innerType},Mi=(N,oe,Ie,Re)=>{let De=N._zod.innerType;Dt(De,oe,Re);let Le=oe.seen.get(N);Le.ref=De},yl={string:fi,number:pi,boolean:di,bigint:mi,symbol:$l,null:hi,undefined:zl,void:Sl,never:gi,any:yi,unknown:_i,date:vi,enum:bi,literal:xi,nan:kl,template_literal:Pl,file:El,success:Ol,custom:wi,function:Tl,transform:$i,map:Zl,set:Al,array:zi,object:Si,union:ki,intersection:Pi,tuple:Ei,record:Oi,nullable:Ti,nonoptional:Zi,default:Ii,prefault:Ci,catch:Ni,pipe:Ri,readonly:Di,promise:Cl,optional:uo,lazy:Mi};function rt(N,oe){if("_idmap"in N){let Re=N,De=Tn({...oe,processors:yl}),Le={};for(let Xe of Re._idmap.entries()){let[Ye,Qe]=Xe;Dt(Qe,De)}let Ue={},Be={registry:Re,uri:oe?.uri,defs:Le};De.external=Be;for(let Xe of Re._idmap.entries()){let[Ye,Qe]=Xe;Zn(De,Qe),ar(Ue,Ye,An(De,Qe))}if(Object.keys(Le).length>0){let Xe=De.target==="draft-2020-12"?"$defs":"definitions";Ue.__shared={[Xe]:Le}}return{schemas:Ue}}let Ie=Tn({...oe,processors:yl});return Dt(N,Ie),Zn(Ie,N),An(Ie,N)}var Nl=new WeakSet([Object.prototype,Error.prototype]);function lo(N,oe,Ie){Object.defineProperty(N,oe,{configurable:!0,enumerable:!1,get(){let Re=Ie(this);return Object.defineProperty(this,oe,{value:Re,configurable:!0,writable:!0}),Re},set(Re){Object.defineProperty(this,oe,{value:Re,configurable:!0,writable:!0})}})}var Qp=(N,oe)=>{Xs.init(N,oe),N.name="ZodError";let Ie=Object.getPrototypeOf(N);if(Nl.has(Ie))return;Nl.add(Ie),lo(Ie,"format",(Re)=>(De)=>Qs(Re,De)),lo(Ie,"flatten",(Re)=>(De)=>Ys(Re,De)),lo(Ie,"addIssue",(Re)=>(De)=>{Re.issues.push(De),Re.message=JSON.stringify(Re.issues,Yr,2)}),lo(Ie,"addIssues",(Re)=>(De)=>{Re.issues.push(...De),Re.message=JSON.stringify(Re.issues,Yr,2)}),Object.defineProperty(Ie,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var fr=ht("ZodError",Qp,void 0,{Parent:Error});var Rl=Wn(fr),Dl=Kn(fr),Ml=Hn(fr),Ve=qn(fr),Ll=tc(fr),jl=rc(fr),Fl=nc(fr),Ul=oc(fr),Bl=ic(fr),Jl=sc(fr),Vl=cc(fr),Wl=ac(fr);function td(){if(!ir.localeError)lr(qo())}function Cn(){if(!ir.memoizer)lr({memoizer:bu()})}var It=ht("ZodType",(N,oe)=>(td(),At.init(N,oe),N.def=oe,N.type=oe.type,N),{check(...N){let oe=this.def;return this.clone(ur(oe,{checks:[...oe.checks??[],...N.map((Ie)=>typeof Ie==="function"?{_zod:{check:Ie,def:{check:"custom"},onattach:[]}}:Ie)]}),{parent:!0})},with(...N){return this.check(...N)},clone(N,oe){return xr(this,N,oe)},brand(){return this},register(N,oe){return N.add(this,oe),this},refine(N,oe){return this.check(qd(N,oe))},superRefine(N,oe){return this.check(Gd(N,oe))},overwrite(N){return this.check(Cr(N))},optional(){return Hl(this)},exactOptional(){return Rd(this)},nullable(){return ql(this)},nullish(){return Hl(ql(this))},nonoptional(N){return Ud(this,N)},array(){return o(this)},or(N){return l([this,N])},and(N){return ot(this,N)},transform(N){return Gl(this,Nd(N))},default(N){return Ld(this,N)},prefault(N){return Fd(this,N)},catch(N){return Jd(this,N)},pipe(N){return Gl(this,N)},readonly(){return Kd(this)},describe(N){let oe=this.clone();return jr.add(oe,{description:N}),oe},meta(...N){if(N.length===0)return jr.get(this);let oe=this.clone();return jr.add(oe,N[0]),oe},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(N,...oe){return oe.length===0?N(this):N(this,...oe)},get "~standard"(){return bn(this,"~standard",{...Uo(this),jsonSchema:{input:On(this,"input"),output:On(this,"output")}})},set "~standard"(N){Pr(this,"~standard",N)},parse:function N(oe,Ie){return Rl(this,oe,Ie,{callee:N})},parseAsync:async function N(oe,Ie){return await Dl(this,oe,Ie,{callee:N})},safeParse(N,oe){return Ml(this,N,oe)},async safeParseAsync(N,oe){return Ve(this,N,oe)},get spa(){return this?.safeParseAsync},set spa(N){Pr(this,"spa",N)},validate(N,oe){return Ao(this,N,oe)},validateAsync(N,oe){return Io(this,N,oe)},encode:function N(oe,Ie){return Ll(this,oe,Ie,{callee:N})},decode:function N(oe,Ie){return jl(this,oe,Ie,{callee:N})},encodeAsync:async function N(oe,Ie){return await Fl(this,oe,Ie,{callee:N})},decodeAsync:async function N(oe,Ie){return await Ul(this,oe,Ie,{callee:N})},safeEncode(N,oe){return Bl(this,N,oe)},safeDecode(N,oe){return Jl(this,N,oe)},async safeEncodeAsync(N,oe){return Vl(this,N,oe)},async safeDecodeAsync(N,oe){return Wl(this,N,oe)},toJSONSchema(N){return pl(this,{})(N)},get description(){return jr.get(this)?.description},get _def(){return this._zod.def}}),Xl=ht("_ZodString",(N,oe)=>{eo.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>fi(N,Ie,Re,De)},Jn({format:(N)=>tr(N).format??null,minLength:(N)=>tr(N).minimum??null,maxLength:(N)=>tr(N).maximum??null},{regex(...N){return this.check(Go(...N))},includes(...N){return this.check(Qo(...N))},startsWith(...N){return this.check(ei(...N))},endsWith(...N){return this.check(ti(...N))},min(...N){return this.check(Wr(...N))},max(...N){return this.check(co(...N))},length(...N){return this.check(ao(...N))},nonempty(...N){return this.check(Wr(1,...N))},lowercase(N){return this.check(Xo(N))},uppercase(N){return this.check(Yo(N))},trim(){return this.check(oi())},normalize(...N){return this.check(ni(...N))},toLowerCase(){return this.check(ii())},toUpperCase(){return this.check(si())},slugify(){return this.check(ci())}})),Pt=ht("ZodString",(N,oe)=>{eo.init(N,oe),Xl.init(N,oe)},{email(N){return this.check(zu(sd,N))},url(N){return this.check(Tu(ad,N))},jwt(N){return this.check(Vu($d,N))},emoji(N){return this.check(Zu(ud,N))},guid(N){return this.check(Su(cd,N))},uuid(N){return this.check(ku(fo,N))},uuidv4(N){return this.check(Pu(fo,N))},uuidv6(N){return this.check(Eu(fo,N))},uuidv7(N){return this.check(Ou(fo,N))},nanoid(N){return this.check(Au(ld,N))},cuid(N){return this.check(Iu(fd,N))},cuid2(N){return this.check(Cu(pd,N))},ulid(N){return this.check(Nu(dd,N))},base64(N){return this.check(Uu(bd,N))},base64url(N){return this.check(Bu(xd,N))},xid(N){return this.check(Ru(md,N))},ksuid(N){return this.check(Du(hd,N))},ipv4(N){return this.check(Mu(gd,N))},ipv6(N){return this.check(Lu(yd,N))},cidrv4(N){return this.check(ju(_d,N))},cidrv6(N){return this.check(Fu(vd,N))},e164(N){return this.check(Ju(wd,N))},datetime(N){return this.check(Wu(rd,N))},date(N){return this.check(Ku(nd,N))},time(N){return this.check(Hu(od,N))},duration(N){return this.check(qu(id,N))}});function e(N){return $u(Pt,N)}var Ft=ht("ZodStringFormat",(N,oe)=>{Mt.init(N,oe),Xl.init(N,oe)}),rd=ht("ZodISODateTime",(N,oe)=>{Pa.init(N,oe),Ft.init(N,oe)}),nd=ht("ZodISODate",(N,oe)=>{Ea.init(N,oe),Ft.init(N,oe)}),od=ht("ZodISOTime",(N,oe)=>{Oa.init(N,oe),Ft.init(N,oe)}),id=ht("ZodISODuration",(N,oe)=>{Ta.init(N,oe),Ft.init(N,oe)}),sd=ht("ZodEmail",(N,oe)=>{ga.init(N,oe),Ft.init(N,oe)});var cd=ht("ZodGUID",(N,oe)=>{ma.init(N,oe),Ft.init(N,oe)});var fo=ht("ZodUUID",(N,oe)=>{ha.init(N,oe),Ft.init(N,oe)});var ad=ht("ZodURL",(N,oe)=>{va.init(N,oe),Ft.init(N,oe)});var ud=ht("ZodEmoji",(N,oe)=>{ba.init(N,oe),Ft.init(N,oe)});var ld=ht("ZodNanoID",(N,oe)=>{xa.init(N,oe),Ft.init(N,oe)});var fd=ht("ZodCUID",(N,oe)=>{wa.init(N,oe),Ft.init(N,oe)});var pd=ht("ZodCUID2",(N,oe)=>{$a.init(N,oe),Ft.init(N,oe)});var dd=ht("ZodULID",(N,oe)=>{za.init(N,oe),Ft.init(N,oe)});var md=ht("ZodXID",(N,oe)=>{Sa.init(N,oe),Ft.init(N,oe)});var hd=ht("ZodKSUID",(N,oe)=>{ka.init(N,oe),Ft.init(N,oe)});var gd=ht("ZodIPv4",(N,oe)=>{Za.init(N,oe),Ft.init(N,oe)});var yd=ht("ZodIPv6",(N,oe)=>{Ia.init(N,oe),Ft.init(N,oe)});var _d=ht("ZodCIDRv4",(N,oe)=>{Ca.init(N,oe),Ft.init(N,oe)});var vd=ht("ZodCIDRv6",(N,oe)=>{Na.init(N,oe),Ft.init(N,oe)});var bd=ht("ZodBase64",(N,oe)=>{Da.init(N,oe),Ft.init(N,oe)});var xd=ht("ZodBase64URL",(N,oe)=>{Ma.init(N,oe),Ft.init(N,oe)});var wd=ht("ZodE164",(N,oe)=>{La.init(N,oe),Ft.init(N,oe)});var $d=ht("ZodJWT",(N,oe)=>{ja.init(N,oe),Ft.init(N,oe)});var wt=ht("ZodNumber",(N,oe)=>{Jo.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>pi(N,Ie,Re,De),N.isFinite=!0},Jn({minValue:(N)=>{let{minimum:oe,exclusiveMinimum:Ie}=tr(N);return Math.max(oe??Number.NEGATIVE_INFINITY,Ie??Number.NEGATIVE_INFINITY)},maxValue:(N)=>{let{maximum:oe,exclusiveMaximum:Ie}=tr(N);return Math.min(oe??Number.POSITIVE_INFINITY,Ie??Number.POSITIVE_INFINITY)},isInt:(N)=>{let{isInt:oe,multipleOf:Ie}=tr(N);return!!oe||!!Ie?.some(Number.isSafeInteger)},format:(N)=>tr(N).format??null},{gt(N,oe){return this.check(Vr(N,oe))},gte(N,oe){return this.check(Or(N,oe))},min(N,oe){return this.check(Or(N,oe))},lt(N,oe){return this.check(Jr(N,oe))},lte(N,oe){return this.check(Er(N,oe))},max(N,oe){return this.check(Er(N,oe))},int(N){return this.check(Kl(N))},safe(N){return this.check(Kl(N))},positive(N){return this.check(Vr(0,N))},nonnegative(N){return this.check(Or(0,N))},negative(N){return this.check(Jr(0,N))},nonpositive(N){return this.check(Er(0,N))},multipleOf(N,oe){return this.check(Pn(N,oe))},step(N,oe){return this.check(Pn(N,oe))},finite(){return this}}));function r(N){return Gu(wt,N)}var zd=ht("ZodNumberFormat",(N,oe)=>{Fa.init(N,oe),wt.init(N,oe)});function Kl(N){return Xu(zd,N)}var Rt=ht("ZodBoolean",(N,oe)=>{Ua.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>di(N,Ie,Re,De)});function c(N){return Yu(Rt,N)}var Kt=ht("ZodBigInt",(N,oe)=>{Ba.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>mi(N,Ie,Re,De)},Jn({minValue:(N)=>tr(N).minimum??null,maxValue:(N)=>tr(N).maximum??null,format:(N)=>tr(N).format??null},{gte(N,oe){return this.check(Or(N,oe))},min(N,oe){return this.check(Or(N,oe))},gt(N,oe){return this.check(Vr(N,oe))},lt(N,oe){return this.check(Jr(N,oe))},lte(N,oe){return this.check(Er(N,oe))},max(N,oe){return this.check(Er(N,oe))},positive(N){return this.check(Vr(BigInt(0),N))},negative(N){return this.check(Jr(BigInt(0),N))},nonpositive(N){return this.check(Er(BigInt(0),N))},nonnegative(N){return this.check(Or(BigInt(0),N))},multipleOf(N,oe){return this.check(Pn(N,oe))}}));var Sd=ht("ZodNull",(N,oe)=>{Ja.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>hi(N,Ie,Re,De)});function We(N){return Qu(Sd,N)}var kd=ht("ZodAny",(N,oe)=>{Va.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>yi(N,Ie,Re,De)});function ie(){return el(kd)}var Pd=ht("ZodUnknown",(N,oe)=>{Wa.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>_i(N,Ie,Re,De)});function v(){return tl(Pd)}var Ed=ht("ZodNever",(N,oe)=>{Ka.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>gi(N,Ie,Re,De)});function Ae(N){return rl(Ed,N)}var Qt=ht("ZodDate",(N,oe)=>{Ha.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>vi(N,Ie,Re,De),N.min=(Ie,Re)=>N.check(Or(Ie,Re)),N.max=(Ie,Re)=>N.check(Er(Ie,Re))},Jn({minDate:(N)=>{let{minimum:oe}=tr(N);return oe?new Date(oe):null},maxDate:(N)=>{let{maximum:oe}=tr(N);return oe?new Date(oe):null}},{}));var Od=ht("ZodArray",(N,oe)=>{Cn(),qa.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>zi(N,Ie,Re,De),N.element=oe.element},{min(N,oe){return this.check(Wr(N,oe))},nonempty(N){return this.check(Wr(1,N))},max(N,oe){return this.check(co(N,oe))},length(N,oe){return this.check(ao(N,oe))},unwrap(){return this.element}});function o(N,oe){return nl(Od,N,oe)}var Ui=ht("ZodObject",(N,oe)=>{Cn(),Ya.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Si(N,Ie,Re,De),ap(N,"shape",(Ie)=>Ie._zod.def.shape,!1)},{keyof(){return i(Object.keys(this._zod.def.shape))},catchall(N){return this.clone(ur(this._zod.def,{catchall:N}))},passthrough(){return this.clone(ur(this._zod.def,{catchall:v()}))},loose(){return this.clone(ur(this._zod.def,{catchall:v()}))},strict(){return this.clone(ur(this._zod.def,{catchall:Ae()}))},strip(){return this.clone(ur(this._zod.def,{catchall:void 0}))},extend(N){return ep(this,N)},safeExtend(N){return tp(this,N)},merge(N){return rp(this,N)},pick(N){return Yf(this,N)},omit(N){return Qf(this,N)},partial(...N){return Us(Bi,this,N[0])},exactPartial(...N){return Us(Ql,this,N[0],"exactPartial")},required(...N){return np(ef,this,N[0])}});function t(N,oe){let Ie={type:"object",shape:N??{},...zt(oe)};return new Ui(Ie)}function se(N,oe){return new Ui({type:"object",shape:N,catchall:Ae(),...zt(oe)})}function U(N,oe){return new Ui({type:"object",shape:N,catchall:v(),...zt(oe)})}var Yl=ht("ZodUnion",(N,oe)=>{Vo.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>ki(N,Ie,Re,De),N.options=oe.options});function l(N,oe){return new Yl({type:"union",options:N,...zt(oe)})}var Td=ht("ZodDiscriminatedUnion",(N,oe)=>{Yl.init(N,oe),Qa.init(N,oe)});function f(N,oe,Ie){return new Td({type:"union",options:oe,discriminator:N,...zt(Ie)})}var Zd=ht("ZodIntersection",(N,oe)=>{eu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Pi(N,Ie,Re,De)});function ot(N,oe){return new Zd({type:"intersection",left:N,right:oe})}var Ad=ht("ZodTuple",(N,oe)=>{Cn(),tu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ei(N,Ie,Re,De)},{rest(N){return this.clone({...this._zod.def,rest:N})},partial(){let N=this._zod.def;if(N.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...N,items:N.items.map((oe)=>new Bi({type:"optional",innerType:oe}))})}});function ce(N,oe,Ie){let Re=oe instanceof At,De=Re?Ie:oe;return new Ad({type:"tuple",items:N,rest:Re?oe:null,...zt(De)})}var ji=ht("ZodRecord",(N,oe)=>{Cn(),ru.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Oi(N,Ie,Re,De),N.keyType=oe.keyType,N.valueType=oe.valueType});function y(N,oe,Ie){if(!oe||!oe._zod)return new ji({type:"record",keyType:e(),valueType:N,...zt(oe)});return new ji({type:"record",keyType:N,valueType:oe,...zt(Ie)})}function vn(N,oe,Ie){return new ji({type:"record",keyType:N,valueType:oe,...zt(Ie),partial:!0})}var Fi=ht("ZodEnum",(N,oe)=>{nu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Re,De,Le)=>bi(N,Re,De,Le),N.enum=oe.entries,N.options=[...N._zod.values];let Ie=new Set(Object.keys(oe.entries));N.extract=(Re,De)=>{let Le={};for(let Ue of Re)if(Ie.has(Ue))Le[Ue]=oe.entries[Ue];else throw Error(`Key ${Ue} not found in enum`);return new Fi({...oe,checks:[],...zt(De),entries:Le})},N.exclude=(Re,De)=>{let Le={...oe.entries};for(let Ue of Re)if(Ie.has(Ue))delete Le[Ue];else throw Error(`Key ${Ue} not found in enum`);return new Fi({...oe,checks:[],...zt(De),entries:Le})}});function i(N,oe){let Ie=Array.isArray(N)?Object.fromEntries(N.map((Re)=>[Re,Re])):N;return new Fi({type:"enum",entries:Ie,...zt(oe)})}var Id=ht("ZodLiteral",(N,oe)=>{ou.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>xi(N,Ie,Re,De),N.values=new Set(oe.values),Object.defineProperty(N,"value",{get(){if(oe.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return oe.values[0]}})});function n(N,oe){return new Id({type:"literal",values:Array.isArray(N)?N:[N],...zt(oe)})}var Cd=ht("ZodTransform",(N,oe)=>{Cn(),iu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>$i(N,Ie,Re,De),N._zod.parse=(Ie,Re)=>{if(Re.direction==="backward")throw new xn(N.constructor.name);Ie.addIssue=(Le)=>{if(typeof Le==="string")Ie.issues.push(Lr(Le,Ie.value,oe));else{let Ue=Le;if(Ue.fatal)Ue.continue=!1;if(Ue.code??(Ue.code="custom"),!("input"in Ue))Ue.input=Ie.value;Ue.inst??(Ue.inst=N),Ie.issues.push(Lr(Ue))}};let De=oe.transform(Ie.value,Ie);if(De instanceof Promise)return De.then((Le)=>(Ie.value=Le,Ie));return Ie.value=De,Ie}});function Nd(N){return new Cd({type:"transform",transform:N})}var Bi=ht("ZodOptional",(N,oe)=>{Wo.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>uo(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Hl(N){return new Bi({type:"optional",innerType:N})}var Ql=ht("ZodExactOptional",(N,oe)=>{su.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>uo(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Rd(N){return new Ql({type:"optional",innerType:N})}var Dd=ht("ZodNullable",(N,oe)=>{cu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ti(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function ql(N){return new Dd({type:"nullable",innerType:N})}var Md=ht("ZodDefault",(N,oe)=>{au.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ii(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType,N.removeDefault=N.unwrap});function Ld(N,oe){return new Md({type:"default",innerType:N,get defaultValue(){return typeof oe==="function"?oe():So(oe)}})}var jd=ht("ZodPrefault",(N,oe)=>{uu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ci(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Fd(N,oe){return new jd({type:"prefault",innerType:N,get defaultValue(){return typeof oe==="function"?oe():So(oe)}})}var ef=ht("ZodNonOptional",(N,oe)=>{lu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Zi(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Ud(N,oe){return new ef({type:"nonoptional",innerType:N,...zt(oe)})}var Bd=ht("ZodCatch",(N,oe)=>{fu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ni(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType,N.removeCatch=N.unwrap});function Jd(N,oe){return new Bd({type:"catch",innerType:N,catchValue:typeof oe==="function"?oe:Ws(oe)})}var Vd=ht("ZodPipe",(N,oe)=>{pu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Ri(N,Ie,Re,De),N.in=oe.in,N.out=oe.out});function Gl(N,oe){return new Vd({type:"pipe",in:N,out:oe})}var Wd=ht("ZodReadonly",(N,oe)=>{du.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Di(N,Ie,Re,De),N.unwrap=()=>N._zod.def.innerType});function Kd(N){return new Wd({type:"readonly",innerType:N})}var Hd=ht("ZodLazy",(N,oe)=>{mu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>Mi(N,Ie,Re,De),N.unwrap=()=>N._zod.def.getter()});function $e(N){return new Hd({type:"lazy",getter:N})}var Ji=ht("ZodCustom",(N,oe)=>{hu.init(N,oe),It.init(N,oe),N._zod.processJSONSchema=(Ie,Re,De)=>wi(N,Ie,Re,De)});function Yt(N,oe){return ol(Ji,N??(()=>!0),oe)}function qd(N,oe={}){return il(Ji,N,oe)}function Gd(N,oe){return sl(N,oe)}var Xd=ht("ZodInstanceOf",(N,oe)=>{Ji.init(N,oe)},{properties(N,oe){return this.check(ri(N,oe))}});function Xt(N,oe={}){let Ie=new Xd({type:"custom",check:"custom",fn:(Re)=>Re instanceof N,abort:!0,...zt(oe)});return Ie._zod.bag.Class=N,Ie._zod.check=(Re)=>{if(!(Re.value instanceof N))Re.issues.push({code:"invalid_type",expected:N.name,input:Re.value,inst:Ie,path:[...Ie._zod.def.path??[]]})},Ie}function G(N){let oe=$e(()=>l([e(N),r(),c(),We(),o(oe),y(e(),oe)]));return oe}class po extends Error{constructor(N,oe){super(N),this.name="ParseError",this.type=oe.type,this.field=oe.field,this.value=oe.value,this.line=oe.line}}var tf=10,Yd=13,Fr=32;function Vi(N){}function of(N){if(typeof N=="function")throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:oe=Vi,onError:Ie=Vi,onRetry:Re=Vi,onComment:De,maxBufferSize:Le}=N,Ue=[],Be=0,Xe=!0,Ye,Qe="",et=0,tt,ft=!1;function gt(_t){if(ft)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(Xe&&(Xe=!1,_t.charCodeAt(0)===239&&_t.charCodeAt(1)===187&&_t.charCodeAt(2)===191&&(_t=_t.slice(3))),Ue.length===0){let Ut=St(_t);Ut!==""&&(Ue.push(Ut),Be=Ut.length),bt();return}if(_t.indexOf(`
|
|
60
60
|
`)===-1&&_t.indexOf("\r")===-1){Ue.push(_t),Be+=_t.length,bt();return}Ue.push(_t);let yt=Ue.join("");Ue.length=0,Be=0;let Ot=St(yt);Ot!==""&&(Ue.push(Ot),Be=Ot.length),bt()}function bt(){Le!==void 0&&(Be+Qe.length<=Le||(ft=!0,Ue.length=0,Be=0,Ye=void 0,Qe="",et=0,tt=void 0,Ie(new po(`Buffered data exceeded max buffer size of ${Le} characters`,{type:"max-buffer-size-exceeded"}))))}function St(_t){let yt=0;if(_t.indexOf("\r")===-1){let Ot=_t.indexOf(`
|
|
61
61
|
`,yt);for(;Ot!==-1;){if(yt===Ot){et>0&&oe({id:Ye,event:tt,data:Qe}),Ye=void 0,Qe="",et=0,tt=void 0,yt=Ot+1,Ot=_t.indexOf(`
|
|
62
|
-
`,yt);continue}let
|
|
63
|
-
`,yt);continue}Qe=et===0?
|
|
64
|
-
${
|
|
65
|
-
`,yt)}return _t.slice(yt)}for(;yt<_t.length;){let Ot=_t.indexOf("\r",yt),
|
|
66
|
-
`,yt),
|
|
67
|
-
${ts}`,et++;return}if(nf(_t,yt,
|
|
68
|
-
${yt}`,et++;break;case"id":yt.includes("\x00")||(Ye=yt);break;case"retry":/^\d+$/.test(yt)?Re(parseInt(yt,10)):Ie(new po(`Invalid \`retry\` value: "${yt}"`,{type:"invalid-retry",value:yt,line:Ot}));break;default:Ie(new po(`Unknown field "${_t.length>20?`${_t.slice(0,20)}…`:_t}"`,{type:"unknown-field",field:_t,value:yt,line:Ot}));break}}function Pr(){et>0&&oe({id:Ye,event:tt,data:Qe}),Ye=void 0,Qe="",et=0,tt=void 0}function Mr(_t={}){if(_t.consume&&Ue.length>0){let yt=Ue.join("");Et(yt,0,yt.length)}Xe=!0,Ye=void 0,Qe="",et=0,tt=void 0,Ue.length=0,Be=0,ft=!1}return{feed:gt,reset:Mr}}function rf(N,oe,Ie){return Ie===100&&N.charCodeAt(oe+1)===97&&N.charCodeAt(oe+2)===116&&N.charCodeAt(oe+3)===97&&N.charCodeAt(oe+4)===58}function nf(N,oe,Ie){return Ie===101&&N.charCodeAt(oe+1)===118&&N.charCodeAt(oe+2)===101&&N.charCodeAt(oe+3)===110&&N.charCodeAt(oe+4)===116&&N.charCodeAt(oe+5)===58}class mo extends TransformStream{constructor({onError:N,onRetry:oe,onComment:Ie,maxBufferSize:Re}={}){let De;super({start(Le){De=of({onEvent:(Ue)=>{Le.enqueue(Ue)},onError(Ue){typeof N=="function"&&N(Ue),(N==="terminate"||Ue.type==="max-buffer-size-exceeded")&&Le.error(Ue)},onRetry:oe,onComment:Ie,maxBufferSize:Re})},transform(Le){De.feed(Le)}})}}var k=Symbol.for("workflow-serialize"),T=Symbol.for("workflow-deserialize");function $e(N){return N===void 0?[]:Array.isArray(N)?N:[N]}function d(...N){return N.reduce((oe,Ie)=>({...oe,...Ie}),{})}function Qd(N){return Object.fromEntries(Object.entries(N).filter(([oe,Ie])=>Ie!=null))}async function Oe(N,oe){if(N==null)return;let Ie=oe?.abortSignal;return new Promise((Re,De)=>{if(Ie?.aborted){De(sf());return}let Le=setTimeout(()=>{Ue(),Re()},N),Ue=()=>{clearTimeout(Le),Ie?.removeEventListener("abort",Be)},Be=()=>{Ue(),De(sf())};Ie?.addEventListener("abort",Be)})}function sf(){return new DOMException("Delay was aborted","AbortError")}function em(N){let oe=N??globalThis.WebSocket;if(oe==null)throw Error("No WebSocket implementation available.");return oe}function Lt(N){let oe=new URL(N);if(oe.protocol==="http:")oe.protocol="ws:";else if(oe.protocol==="https:")oe.protocol="wss:";return oe}var cf=new TextDecoder;async function tm(N){if(typeof N==="string")return N;if(N instanceof ArrayBuffer)return cf.decode(N);if(ArrayBuffer.isView(N))return cf.decode(N);if(typeof Blob<"u"&&N instanceof Blob)return N.text();return String(N)}var rm=1;async function ue(N,{highWaterMark:oe=1048576,pollIntervalMs:Ie=20,abortSignal:Re}={}){while(N.readyState===rm&&(N.bufferedAmount??0)>oe){if(Re?.aborted===!0)return;await Oe(Ie)}}function fe({url:N,protocols:oe,headers:Ie,webSocket:Re,abortSignal:De,onOpen:Le,onMessageText:Ue,onProcessingError:Be,onSocketError:Xe,onClose:Ye,onAbort:Qe}){let et,tt,ft=(St)=>{if(tt!=null)De?.removeEventListener("abort",tt),tt=void 0;try{et?.close(St)}catch{}};if(De?.aborted)return Qe?.(De.reason??Error("Aborted")),{socket:void 0,close:ft};try{et=new(em(Re))(N,oe,{headers:Qd(Ie??{})})}catch(St){return Be(St),{socket:void 0,close:ft}}if(De!=null&&Qe!=null)tt=()=>Qe(De.reason??Error("Aborted")),De.addEventListener("abort",tt,{once:!0});let gt=et;et.onopen=()=>{try{Le?.(gt)}catch(St){Be(St)}};let bt=Promise.resolve();return et.onmessage=(St)=>{bt=bt.then(()=>tm(St.data)).then((Et)=>Ue(Et)).catch(Be)},et.onerror=()=>{bt=bt.then(()=>Xe?.()).catch(Be)},et.onclose=(St)=>{let Et=St,rr=typeof Et?.code==="number"?Et.code:void 0,Pr=typeof Et?.reason==="string"?Et.reason:void 0;bt=bt.then(()=>Ye?.({code:rr,reason:Pr})).catch(Be)},{socket:et,close:ft}}function ae(N){let oe=!1;return new ReadableStream({async pull(Ie){if(oe)return;try{let{value:Re,done:De}=await N.next();if(De)Ie.close();else Ie.enqueue(Re)}catch(Re){Ie.error(Re)}},async cancel(Ie){if(oe=!0,N.return)try{await N.return(Ie)}catch{}}})}var{btoa:nm,atob:om}=globalThis;function j(N){let oe=N.replace(/-/g,"+").replace(/_/g,"/"),Ie=om(oe);return Uint8Array.from(Ie,(Re)=>Re.codePointAt(0))}function X(N){if(typeof globalThis.Buffer?.from==="function")return globalThis.Buffer.from(N.buffer,N.byteOffset,N.byteLength).toString("base64");let oe=[],Ie=4096;for(let Re=0;Re<N.length;Re+=Ie)oe.push(String.fromCodePoint(...N.subarray(Re,Re+Ie)));return nm(oe.join(""))}function M(N){return N instanceof Uint8Array?X(N):N}function we(N){if(N.type==="stream"){let oe=new u({functionality:"streaming file upload"});throw N.stream.cancel(oe).catch(()=>{}),oe}if(N.type==="text")return new TextEncoder().encode(N.text);if(N.data instanceof Uint8Array)return N.data;if(N.data instanceof ArrayBuffer)return new Uint8Array(N.data);return j(N.data)}function Yt(N){let oe=new Set,Ie=new Set,Re=!1,De=!1;return new TransformStream({transform(Le,Ue){switch(Le.type){case"text-start":case"text-delta":case"text-end":return;case"tool-input-start":if(Le.toolName===N){oe.add(Le.id),Ue.enqueue({type:"text-start",id:Le.id,...Le.providerMetadata&&{providerMetadata:Le.providerMetadata}});return}break;case"tool-input-delta":if(oe.has(Le.id)){if(Le.delta.length>0)Ie.add(Le.id);Ue.enqueue({type:"text-delta",id:Le.id,delta:Le.delta,...Le.providerMetadata&&{providerMetadata:Le.providerMetadata}});return}break;case"tool-input-end":if(oe.has(Le.id))return;break;case"tool-call":if(Le.toolName===N){if(!Ie.has(Le.toolCallId))Ue.enqueue({type:"text-delta",id:Le.toolCallId,delta:Le.input,...Le.providerMetadata&&{providerMetadata:Le.providerMetadata}});Ue.enqueue({type:"text-end",id:Le.toolCallId,...Le.providerMetadata&&{providerMetadata:Le.providerMetadata}}),Re=!0;return}if(!Le.providerExecuted)De=!0;break;case"finish":if(Re&&!De&&Le.finishReason.unified==="tool-calls"){Ue.enqueue({...Le,finishReason:{...Le.finishReason,unified:"stop"}});return}}Ue.enqueue(Le)}})}function st(N,oe={}){let{useArrayBrackets:Ie=!0}=oe,Re=new FormData;for(let[De,Le]of Object.entries(N)){if(Le==null)continue;if(Array.isArray(Le)){if(Le.length===1){Re.append(De,Le[0]);continue}let Ue=Ie?`${De}[]`:De;for(let Be of Le)Re.append(Ue,Be);continue}Re.append(De,Le)}return Re}function ee({id:N,model:oe,created:Ie}){return{id:N??void 0,modelId:oe??void 0,timestamp:Ie!=null?new Date(Ie*1000):void 0}}function te(){return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0}}function le({tools:N=[],providerToolNames:oe}){let Ie={},Re={};for(let De of N)if(De.type==="provider"&&De.id in oe){let Le=oe[De.id];Ie[De.name]=Le,Re[Le]=De.name}return{toProviderToolName:(De)=>Ie[De]??De,toCustomToolName:(De)=>Re[De]??De}}var hf=Symbol.for("vercel.ai.providerStreamError");function xe({message:N,type:oe,code:Ie,statusCode:Re,isRetryable:De,data:Le}){let Ue={message:N,type:oe,code:Ie,statusCode:Re,isRetryable:De,data:Le};return Object.defineProperty(Ue,hf,{value:!0}),Ue}function at(N){return typeof N==="object"&&N!=null&&N[hf]===!0}var je=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){if(this._promise)return this._promise;return this._promise=new Promise((N,oe)=>{if(this.status.type==="resolved")N(this.status.value);else if(this.status.type==="rejected")oe(this.status.error);this._resolve=N,this._reject=oe}),this._promise}resolve(N){if(this.status={type:"resolved",value:N},this._promise)this._resolve?.(N)}reject(N){if(this.status={type:"rejected",error:N},this._promise)this._reject?.(N)}isResolved(){return this.status.type==="resolved"}isRejected(){return this.status.type==="rejected"}isPending(){return this.status.type==="pending"}};function wr(N){return Object.fromEntries([...N.headers])}function ke(N=globalThis){if(N.navigator?.userAgent)return N.navigator.userAgent.toLowerCase();if(N.process?.versions?.node)return`node.js/${N.process.version}`;if(N.EdgeRuntime)return"vercel-edge";return""}function Z(N){return(N instanceof Error||typeof DOMException==="function"&&N instanceof DOMException)&&(N.name==="AbortError"||N.name==="ResponseAborted"||N.name==="TimeoutError")}var im=["fetch failed","failed to fetch"],sm=new Set(["ConnectionRefused","ConnectionClosed","FailedToOpenSocket","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE","UND_ERR_SOCKET","UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT","UND_ERR_CONNECT_TIMEOUT"]);function cm(N){let oe=new Set,Ie=N;while(Ie instanceof Error&&!oe.has(Ie)){oe.add(Ie);let Re=Ie;if(typeof Re.code==="string"&&sm.has(Re.code))return Re;Ie=Ie.cause}}function Nn({error:N,url:oe,requestBodyValues:Ie}){if(Z(N))return N;if(N instanceof TypeError&&im.includes(N.message.toLowerCase())){let De=N.cause;if(De!=null)return new w({message:`Cannot connect to API: ${De.message}`,cause:De,url:oe,requestBodyValues:Ie,isRetryable:!0})}let Re=cm(N);if(Re!=null){if(w.isInstance(N))return new w({message:N.message,cause:N.cause,url:N.url,requestBodyValues:N.requestBodyValues,statusCode:N.statusCode,responseHeaders:N.responseHeaders,responseBody:N.responseBody,data:N.data,isRetryable:!0});return new w({message:`Cannot connect to API: ${N instanceof Error?N.message:Re.message}`,cause:N,url:oe,requestBodyValues:Ie,isRetryable:!0})}return N}var yo="5.0.70";function qe(N){if(N==null)return{};let oe={};if(N instanceof Headers)N.forEach((Ie,Re)=>{oe[Re.toLowerCase()]=Ie});else{if(!Array.isArray(N))N=Object.entries(N);for(let[Ie,Re]of N)if(Re!=null)oe[Ie.toLowerCase()]=Re}return oe}function F(N,...oe){let Ie=new Headers(qe(N)),Re=Ie.get("user-agent")||"";return Ie.set("user-agent",[Re,...oe].filter(Boolean).join(" ")),Object.fromEntries(Ie.entries())}var am=()=>globalThis.fetch,Xt=async({url:N,headers:oe={},failedResponseHandler:Ie,successfulResponseHandler:Re,abortSignal:De,fetch:Le=am()})=>{try{let Ue=await Le(N,{method:"DELETE",headers:F(oe,`ai-sdk-provider-utils/${yo}`,ke()),signal:De}),Be=wr(Ue);if(!Ue.ok){let Xe;try{Xe=await Ie({response:Ue,url:N,requestBodyValues:{}})}catch(Ye){if(Z(Ye)||w.isInstance(Ye))throw Ye;throw new w({message:"Failed to process error response",cause:Ye,statusCode:Ue.status,url:N,responseHeaders:Be,requestBodyValues:{}})}throw Xe.value}try{return await Re({response:Ue,url:N,requestBodyValues:{}})}catch(Xe){if(Xe instanceof Error){if(Z(Xe)||w.isInstance(Xe))throw Xe}throw new w({message:"Failed to process successful response",cause:Xe,statusCode:Ue.status,url:N,responseHeaders:Be,requestBodyValues:{}})}}catch(Ue){throw Nn({error:Ue,url:N,requestBodyValues:{}})}},gf=[{mediaType:"image/gif",bytesPrefix:[71,73,70,56,55,97]},{mediaType:"image/gif",bytesPrefix:[71,73,70,56,57,97]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77,null,null,null,null,0,0,0,0]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,null,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,null,102,116,121,112,104,101,105,99]}],yf=[{mediaType:"application/pdf",bytesPrefix:[37,80,68,70]}],_f=[{mediaType:"audio/aac",bytesPrefix:[255,240]},{mediaType:"audio/aac",bytesPrefix:[255,241]},{mediaType:"audio/aac",bytesPrefix:[255,248]},{mediaType:"audio/aac",bytesPrefix:[255,249]},{mediaType:"audio/mpeg",bytesPrefix:[255,251]},{mediaType:"audio/mpeg",bytesPrefix:[255,250]},{mediaType:"audio/mpeg",bytesPrefix:[255,243]},{mediaType:"audio/mpeg",bytesPrefix:[255,242]},{mediaType:"audio/mpeg",bytesPrefix:[255,227]},{mediaType:"audio/mpeg",bytesPrefix:[255,226]},{mediaType:"audio/wav",bytesPrefix:[82,73,70,70,null,null,null,null,87,65,86,69]},{mediaType:"audio/ogg",bytesPrefix:[79,103,103,83]},{mediaType:"audio/flac",bytesPrefix:[102,76,97,67]},{mediaType:"audio/aac",bytesPrefix:[64,21,0,0]},{mediaType:"audio/webm",bytesPrefix:[26,69,223,163]}],um=[..._f,{mediaType:"audio/mp4",bytesPrefix:[0,0,0,null,102,116,121,112]}],vf=[{mediaType:"video/mp4",bytesPrefix:[0,0,0,null,102,116,121,112]},{mediaType:"video/webm",bytesPrefix:[26,69,223,163]},{mediaType:"video/quicktime",bytesPrefix:[0,0,0,20,102,116,121,112,113,116]},{mediaType:"video/x-msvideo",bytesPrefix:[82,73,70,70]}],lm=18,fm=131084;function af(N,oe){if(typeof N!=="string")return N.length>oe?N.subarray(0,oe):N;let Ie=Math.ceil(oe/3)*4,Re=j(N.substring(0,Math.min(N.length,Ie)));return Re.length>oe?Re.subarray(0,oe):Re}function pm(N){return N.length>10&&N[0]===73&&N[1]===68&&N[2]===51}var dm=(N)=>{let oe=(N[6]&127)<<21|(N[7]&127)<<14|(N[8]&127)<<7|N[9]&127;return N.subarray(oe+10)};function uf({data:N,signatures:oe}){let Ie=af(N,lm);if(pm(Ie))Ie=dm(af(N,fm));for(let Re of oe)if(Ie.length>=Re.bytesPrefix.length&&Re.bytesPrefix.every((De,Le)=>De===null||Ie[Le]===De))return Re.mediaType}var mm={image:gf,audio:um,video:vf,application:yf};function Te({data:N,topLevelType:oe}){if(oe===void 0)return uf({data:N,signatures:[...gf,...yf,..._f,...vf]});let Ie=mm[oe];if(Ie===void 0)return;return uf({data:N,signatures:Ie})}function z(N){let oe=N.indexOf("/");return oe===-1?N:N.substring(0,oe)}function K(N){let oe=N.indexOf("/");if(oe===-1)return!1;let Ie=N.substring(oe+1);return Ie.length>0&&Ie!=="*"}async function it(N){try{await N.body?.cancel()}catch{}}var bf="AI_DownloadError",xf=`vercel.ai.error.${bf}`,hm=Symbol.for(xf),B=class extends m{constructor({url:N,statusCode:oe,statusText:Ie,cause:Re,message:De=Re==null?`Failed to download ${N}: ${oe} ${Ie}`:`Failed to download ${N}: ${Re}`}){super({name:bf,message:De,cause:Re});this[hm]=!0,this.url=N,this.statusCode=oe,this.statusText=Ie}static isInstance(N){return m.hasMarker(N,xf)}};function gm(N=globalThis){return N.window!=null}function He(N,oe){try{return new URL(N).origin===new URL(oe).origin}catch{return!1}}function ym(N){let oe;try{oe=new URL(N)}catch{throw new B({url:N,message:`Invalid URL: ${N}`})}if(oe.protocol==="data:")return;if(oe.protocol!=="http:"&&oe.protocol!=="https:")throw new B({url:N,message:`URL scheme must be http, https, or data, got ${oe.protocol}`});let Ie=oe.hostname.toLowerCase().replace(/\.+$/,"");if(!Ie)throw new B({url:N,message:"URL must have a hostname"});if(Ie==="localhost"||Ie.endsWith(".local")||Ie.endsWith(".localhost")||Ie.endsWith(".internal"))throw new B({url:N,message:`URL with hostname ${Ie} is not allowed`});if(Ie.startsWith("[")&&Ie.endsWith("]")){if(wf(Ie.slice(1,-1)))throw new B({url:N,message:`URL with IPv6 address ${Ie} is not allowed`});return}if(Gi(Ie)){if(Xi(Ie))throw new B({url:N,message:`URL with IP address ${Ie} is not allowed`})}}function _m({address:N,family:oe,hostname:Ie}){if(oe===4?!Gi(N)||Xi(N):oe===6?wf(N):!0)throw new B({url:Ie,message:`Hostname ${Ie} resolved to disallowed IP address ${N}`})}function Gi(N){let oe=N.split(".");if(oe.length!==4)return!1;return oe.every((Ie)=>{let Re=Number(Ie);return Number.isInteger(Re)&&Re>=0&&Re<=255&&String(Re)===Ie})}function Xi(N){let[oe,Ie,Re]=N.split(".").map(Number);if(oe===0)return!0;if(oe===10)return!0;if(oe===100&&Ie>=64&&Ie<=127)return!0;if(oe===127)return!0;if(oe===169&&Ie===254)return!0;if(oe===172&&Ie>=16&&Ie<=31)return!0;if(oe===192&&Ie===0&&Re===0)return!0;if(oe===192&&Ie===0&&Re===2)return!0;if(oe===192&&Ie===168)return!0;if(oe===198&&(Ie===18||Ie===19))return!0;if(oe===198&&Ie===51&&Re===100)return!0;if(oe===203&&Ie===0&&Re===113)return!0;if(oe>=224)return!0;return!1}function vm(N){let oe=N.toLowerCase(),Ie=oe.indexOf("%");if(Ie!==-1)oe=oe.slice(0,Ie);let Re=oe.split("::");if(Re.length>2)return null;let De=(Ue)=>{if(Ue==="")return[];let Be=[],Xe=Ue.split(":");for(let Ye=0;Ye<Xe.length;Ye++){let Qe=Xe[Ye];if(Qe.includes(".")){if(Ye!==Xe.length-1||!Gi(Qe))return null;let[et,tt,ft,gt]=Qe.split(".").map(Number);Be.push(et<<8|tt,ft<<8|gt);continue}if(!/^[0-9a-f]{1,4}$/.test(Qe))return null;Be.push(parseInt(Qe,16))}return Be},Le=De(Re[0]);if(Le===null)return null;if(Re.length===2){let Ue=De(Re[1]);if(Ue===null)return null;let Be=8-Le.length-Ue.length;if(Be<0)return null;return[...Le,...Array(Be).fill(0),...Ue]}return Le.length===8?Le:null}function wf(N){let oe=vm(N);if(oe===null)return!0;let Ie=(Re)=>oe.slice(0,Re).every((De)=>De===0);if(Ie(7)&&(oe[7]===0||oe[7]===1))return!0;if((oe[0]&65024)===64512)return!0;if((oe[0]&65472)===65152)return!0;if((oe[0]&65472)===65216)return!0;if((oe[0]&65280)===65280)return!0;if(oe[0]===8193&&oe[1]===3512)return!0;if(oe[0]===16383&&(oe[1]&61440)===0)return!0;if(Ie(6)||Ie(5)&&oe[5]===65535||Ie(4)&&oe[4]===65535&&oe[5]===0||oe[0]===100&&oe[1]===65435&&oe[2]===0&&oe[3]===0&&oe[4]===0&&oe[5]===0||oe[0]===100&&oe[1]===65435&&oe[2]===1)return Xi(`${oe[6]>>8&255}.${oe[6]&255}.${oe[7]>>8&255}.${oe[7]&255}`);return!1}function bm(N){return(oe,Ie,Re)=>{N(oe,{...Ie,all:!0},(De,Le)=>{if(De){Re(De);return}try{let[Ue]=Le;if(Ue==null)throw Error(`Hostname ${oe} did not resolve to an address`);for(let{address:Be,family:Xe}of Le)_m({address:Be,family:Xe,hostname:oe});if(Ie.all===!0)Re(null,Le);else Re(null,Ue.address,Ue.family)}catch(Ue){Re(Ue instanceof Error?Ue:Error(String(Ue)))}})}}var xm;function wm(){let N=globalThis.process;return N?.release?.name==="node"&&N.versions?.bun==null&&N.versions?.deno==null&&N.title!=="workerd"&&globalThis.EdgeRuntime==null}async function $m(){if(!wm())return globalThis.fetch;return xm??=Promise.resolve().then(zm)}function zm(){let N=lf("node:module"),{lookup:oe}=lf("node:dns"),{Agent:Ie,fetch:Re}=N.createRequire($f())("undici"),De=new Ie({connect:{lookup:bm(oe)}});return(Le,Ue)=>Re(Le,{...Ue,dispatcher:De})}function lf(N){let oe=globalThis.process?.getBuiltinModule?.(N);if(oe==null)throw Error(`Node.js built-in module ${N} is unavailable`);return oe}function $f(){let N=Error.prepareStackTrace;try{Error.prepareStackTrace=(De,Le)=>Le;let oe=Error("Capture current module path");Error.captureStackTrace(oe,$f);let[Ie]=oe.stack,Re=Ie?.getFileName();if(Re==null)throw Error("Unable to determine the current module path");return Re}finally{Error.prepareStackTrace=N}}var Sm=["connection","keep-alive","te","trailer","transfer-encoding","upgrade","host","forwarded","proxy-authorization","via","x-forwarded-for","x-forwarded-host","x-forwarded-proto","x-real-ip","metadata","metadata-flavor","x-aws-ec2-metadata-token","x-metadata-token","cookie","set-cookie"];function zf(N){let oe=new Headers(N);for(let Ie of Sm)oe.delete(Ie);return oe}var km=10,Pm=new Set([301,302,303,307,308]);async function Em(N){return N==null||N===globalThis.fetch?await $m():N}async function Sf({url:N,headers:oe,abortSignal:Ie,maxRedirects:Re=km,fetch:De,trustedOrigin:Le}){let Ue=oe===void 0?void 0:zf(oe),Be=(Ye)=>{let Qe={signal:Ie,redirect:Ye};if(Ue!==void 0)Qe.headers=new Headers(Ue);return Qe},Xe=N;for(let Ye=0;Ye<=Re;Ye++){let Qe=Le!==void 0&&He(Xe,Le);if(!Qe)ym(Xe);let et=Qe&&De!=null?De:Qe?globalThis.fetch:await Em(De),tt=await et(Xe,Be("manual"));if(tt.type==="opaqueredirect"){if(!gm())throw new B({url:N,message:`Redirect from ${Xe} could not be validated and was blocked`});return await et(Xe,Be("follow"))}let ft=tt.headers?.get("location");if(Pm.has(tt.status)&&ft){it(tt);let gt=new URL(ft,Xe).toString();if(Ue!==void 0&&!He(gt,Xe)){let bt=Ue.get("user-agent");Ue=new Headers(bt==null?void 0:{"user-agent":bt})}Xe=gt;continue}return tt}throw new B({url:N,message:`Too many redirects (max ${Re})`})}var Om=new Set(["accept","accept-language","baggage","cache-control","idempotency-key","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","pragma","range","traceparent","tracestate","user-agent","x-correlation-id","x-request-id"]);async function Nt({headers:N,credentialedOrigin:oe,untrustedFirstHopHeaders:Ie,...Re}){let De;if(N!==void 0){De=zf(N);let Le=oe??Re.trustedOrigin;if(Le===void 0||!He(Re.url,Le)){let Ue=new Set([...Om,...(Ie??[]).map((Be)=>Be.toLowerCase())]);De=new Headers([...De].filter(([Be])=>Ue.has(Be)))}}return Sf({...Re,headers:De})}var $t=2147483648;async function vt({response:N,url:oe,maxBytes:Ie=$t}){let Re=N.headers.get("content-length");if(Re!=null){let Qe=parseInt(Re,10);if(!isNaN(Qe)&&Qe>Ie)throw await it(N),new B({url:oe,message:`Download of ${oe} exceeded maximum size of ${Ie} bytes (Content-Length: ${Qe}).`})}let De=N.body;if(De==null)return new Uint8Array(0);let Le=De.getReader(),Ue=[],Be=0;try{while(!0){let{done:Qe,value:et}=await Le.read();if(Qe)break;if(Be+=et.length,Be>Ie)throw new B({url:oe,message:`Download of ${oe} exceeded maximum size of ${Ie} bytes.`});Ue.push(et.byteLength<et.buffer.byteLength?new Uint8Array(et):et)}}finally{try{await Le.cancel()}catch{}finally{Le.releaseLock()}}let Xe=new Uint8Array(Be),Ye=0;for(let Qe of Ue)Xe.set(Qe,Ye),Ye+=Qe.length;return Xe}async function Me(N,oe){try{let Ie=await Nt({url:N,abortSignal:oe?.abortSignal});if(!Ie.ok)throw await it(Ie),new B({url:N,statusCode:Ie.status,statusText:Ie.statusText});let Re=await vt({response:Ie,url:N,maxBytes:oe?.maxBytes??2147483648}),De=Ie.headers.get("content-type")??void 0;return new Blob([Re],De?{type:De}:void 0)}catch(Ie){if(B.isInstance(Ie))throw Ie;throw new B({url:N,cause:Ie})}}var en=Symbol.for("vercel.ai.embeddingModel.maxInputBytesPerCall"),tn=Symbol.for("vercel.ai.embeddingModel.providerOptionsTransformer");function de(N){let oe=encodeURIComponent(N);return oe==="."?"%252E":oe===".."?"%252E%252E":oe}function Pe(...N){return N.filter((oe)=>oe!=null)}var V=({prefix:N,size:oe=16,alphabet:Ie="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:Re="-"}={})=>{let De=()=>{let Le=Ie.length,Ue=Array(oe);for(let Be=0;Be<oe;Be++)Ue[Be]=Ie[Math.random()*Le|0];return Ue.join("")};if(N==null)return De;if(Ie.includes(Re))throw new b({argument:"separator",message:`The separator "${Re}" must not be part of the alphabet "${Ie}".`});return()=>`${N}${Re}${De()}`},C=V(),Tm=()=>globalThis.fetch,R=async({url:N,headers:oe={},successfulResponseHandler:Ie,failedResponseHandler:Re,abortSignal:De,fetch:Le,validateUrl:Ue,credentialedOrigin:Be,trustedOrigin:Xe})=>{try{let Ye=Le??Tm(),Qe=F(Be!==void 0&&!He(N,Be)?{}:oe,`ai-sdk-provider-utils/${yo}`,ke()),et=Ue?await Sf({url:N,headers:Qe,abortSignal:De,fetch:Le,trustedOrigin:Xe}):await Ye(N,{method:"GET",headers:Qe,signal:De}),tt=wr(et);if(!et.ok){let ft;try{ft=await Re({response:et,url:N,requestBodyValues:{}})}catch(gt){if(Z(gt)||w.isInstance(gt))throw gt;throw new w({message:"Failed to process error response",cause:gt,statusCode:et.status,url:N,responseHeaders:tt,requestBodyValues:{}})}throw ft.value}try{return await Ie({response:et,url:N,requestBodyValues:{}})}catch(ft){if(ft instanceof Error){if(Z(ft)||w.isInstance(ft))throw ft}throw new w({message:"Failed to process successful response",cause:ft,statusCode:et.status,url:N,responseHeaders:tt,requestBodyValues:{}})}}catch(Ye){throw Nn({error:Ye,url:N,requestBodyValues:{}})}},Zm="JSON schema:",Am="You MUST answer with a JSON object that matches the JSON schema above.",Im="You MUST answer with JSON.";function Cm({prompt:N,schema:oe,schemaPrefix:Ie=oe!=null?Zm:void 0,schemaSuffix:Re=oe!=null?Am:Im}){return[N!=null&&N.length>0?N:void 0,N!=null&&N.length>0?"":void 0,Ie,oe!=null?JSON.stringify(oe):void 0,Re].filter((De)=>De!=null).join(`
|
|
69
|
-
`)}function jt({messages:N,schema:oe,schemaPrefix:Ie,schemaSuffix:Re}){let De=N[0]?.role==="system"?{...N[0]}:{role:"system",content:""};return De.content=Cm({prompt:De.content,schema:oe,schemaPrefix:Ie,schemaSuffix:Re}),[De,...N[0]?.role==="system"?N.slice(1):N]}function xt(N){return globalThis.Buffer?.isBuffer(N)??!1}function Fe(N){return N!=null}function nn(N){return typeof N==="object"&&N!==null&&!(N instanceof Uint8Array)&&!(N instanceof URL)&&!(N instanceof ArrayBuffer)&&!xt(N)&&!("type"in N)}function L(N){return N!=null&&typeof N==="object"&&!Array.isArray(N)}function Ze({mediaType:N,url:oe,supportedUrls:Ie}){N=N.toLowerCase();let Re=!N.includes("/");return Object.entries(Ie).map(([De,Le])=>{let Ue=De.toLowerCase();return Ue==="*"||Ue==="*/*"?{mediaTypePrefix:"",regexes:Le}:{mediaTypePrefix:Ue.replace(/\*/,""),regexes:Le}}).filter(({mediaTypePrefix:De})=>{if(De==="")return!0;if(Re)return`${N}/`===De;return De.endsWith("/")?N.startsWith(De):N===De}).flatMap(({regexes:De})=>De).some((De)=>Nm(De,oe))}function Nm(N,oe){if(!N.global&&!N.sticky)return N.test(oe);let Ie=N.lastIndex;N.lastIndex=0;try{return N.test(oe)}finally{N.lastIndex=Ie}}function he({apiKey:N,environmentVariableName:oe,apiKeyParameterName:Ie="apiKey",description:Re}){if(typeof N==="string")return N;if(N!=null)throw new Xr({message:`${Re} API key must be a string.`});if(typeof process>"u")throw new Xr({message:`${Re} API key is missing. Pass it using the '${Ie}' parameter. Environment variables are not supported in this environment.`});if(N=process.env[oe],N==null)throw new Xr({message:`${Re} API key is missing. Pass it using the '${Ie}' parameter or the ${oe} environment variable.`});if(typeof N!=="string")throw new Xr({message:`${Re} API key must be a string. The value of the ${oe} environment variable is not a string.`});return N}function pe({settingValue:N,environmentVariableName:oe}){if(typeof N==="string")return N;if(N!=null||typeof process>"u")return;if(N=process.env[oe],N==null||typeof N!=="string")return;return N}function W(N){return N!==void 0&&N!=="provider-default"}function Se({reasoning:N,effortMap:oe,warnings:Ie}){let Re=oe[N];if(Re==null){Ie.push({type:"unsupported",feature:"reasoning",details:`reasoning "${N}" is not supported by this model.`});return}if(Re!==N)Ie.push({type:"compatibility",feature:"reasoning",details:`reasoning "${N}" is not directly supported by this model. mapped to effort "${Re}".`});return Re}var Rm={minimal:0.02,low:0.1,medium:0.3,high:0.6,xhigh:0.9,max:0.95};function lt({reasoning:N,maxOutputTokens:oe,maxReasoningBudget:Ie,minReasoningBudget:Re=1024,budgetPercentages:De=Rm,warnings:Le}){let Ue=De[N];if(Ue==null){Le.push({type:"unsupported",feature:"reasoning",details:`reasoning "${N}" is not supported by this model.`});return}return Math.min(Ie,Math.max(Re,Math.round(oe*Ue)))}function ct(N){let[oe,Ie=""]=N.toLowerCase().split("/");return{mpeg:"mp3","x-wav":"wav",opus:"ogg",mp4:"m4a","x-m4a":"m4a"}[Ie]??Ie}function ge({total:N,pending:oe,completed:Ie,failed:Re}){if(ho(N)&&ho(oe)&&ho(Ie)&&ho(Re)&&oe+Ie+Re===N)return{total:N,pending:oe,completed:Ie,failed:Re}}function ho(N){return N!=null&&Number.isSafeInteger(N)&&N>=0}var Dm=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Mm=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function ff(N){let oe=JSON.parse(N);if(oe===null||typeof oe!=="object")return oe;if(Dm.test(N)===!1&&Mm.test(N)===!1)return oe;return Lm(oe)}function Lm(N){let oe=[N];while(oe.length){let Ie=oe;oe=[];for(let Re of Ie){if(Object.prototype.hasOwnProperty.call(Re,"__proto__"))throw SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(Re,"constructor")&&Re.constructor!==null&&typeof Re.constructor==="object"&&Object.prototype.hasOwnProperty.call(Re.constructor,"prototype"))throw SyntaxError("Object contains forbidden prototype property");for(let De in Re){let Le=Re[De];if(Le&&typeof Le==="object")oe.push(Le)}}}return N}function Q(N){let{stackTraceLimit:oe}=Error;try{Error.stackTraceLimit=0}catch{return ff(N)}try{return ff(N)}finally{Error.stackTraceLimit=oe}}function Yi(N){if(N.type==="object"||Array.isArray(N.type)&&N.type.includes("object")){let{additionalProperties:Ie}=N;N.additionalProperties=Ie!=null&&typeof Ie!=="boolean"?Dr(Ie):!1;let{properties:Re}=N;if(Re!=null)for(let De of Object.keys(Re))Re[De]=Dr(Re[De])}if(N.items!=null)N.items=Array.isArray(N.items)?N.items.map(Dr):Dr(N.items);if(N.anyOf!=null)N.anyOf=N.anyOf.map(Dr);if(N.allOf!=null)N.allOf=N.allOf.map(Dr);if(N.oneOf!=null)N.oneOf=N.oneOf.map(Dr);let{definitions:oe}=N;if(oe!=null)for(let Ie of Object.keys(oe))oe[Ie]=Dr(oe[Ie]);return N}function Dr(N){if(typeof N==="boolean")return N;return Yi(N)}var jm=Symbol("Let zodToJsonSchema decide on which parser to use"),pf={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Fm=(N)=>typeof N==="string"?{...pf,name:N}:{...pf,...N};function mr(){return{}}function Um(N,oe){let Ie={type:"array"};if(N.type?._def&&N.type?._def?.typeName!=="ZodAny")Ie.items=Ct(N.type._def,{...oe,currentPath:[...oe.currentPath,"items"]});if(N.minLength)Ie.minItems=N.minLength.value;if(N.maxLength)Ie.maxItems=N.maxLength.value;if(N.exactLength)Ie.minItems=N.exactLength.value,Ie.maxItems=N.exactLength.value;return Ie}function Bm(N){let oe={type:"integer",format:"int64"};if(!N.checks)return oe;for(let Ie of N.checks)switch(Ie.kind){case"min":if(Ie.inclusive)oe.minimum=Ie.value;else oe.exclusiveMinimum=Ie.value;break;case"max":if(Ie.inclusive)oe.maximum=Ie.value;else oe.exclusiveMaximum=Ie.value;break;case"multipleOf":oe.multipleOf=Ie.value}return oe}function Jm(){return{type:"boolean"}}function kf(N,oe){return Ct(N.type._def,oe)}var Vm=(N,oe)=>Ct(N.innerType._def,oe);function Pf(N,oe,Ie){let Re=Ie??oe.dateStrategy;if(Array.isArray(Re))return{anyOf:Re.map((De)=>Pf(N,oe,De))};switch(Re){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Wm(N)}}var Wm=(N)=>{let oe={type:"integer",format:"unix-time"};for(let Ie of N.checks)switch(Ie.kind){case"min":oe.minimum=Ie.value;break;case"max":oe.maximum=Ie.value}return oe};function Km(N,oe){return{...Ct(N.innerType._def,oe),default:N.defaultValue()}}function Hm(N,oe){return oe.effectStrategy==="input"?Ct(N.schema._def,oe):mr()}function qm(N){return{type:"string",enum:Array.from(N.values)}}var Gm=(N)=>{if("type"in N&&N.type==="string")return!1;return"allOf"in N};function Xm(N,oe){let Ie=[Ct(N.left._def,{...oe,currentPath:[...oe.currentPath,"allOf","0"]}),Ct(N.right._def,{...oe,currentPath:[...oe.currentPath,"allOf","1"]})].filter((De)=>!!De),Re=[];return Ie.forEach((De)=>{if(Gm(De))Re.push(...De.allOf);else{let Le=De;if("additionalProperties"in De&&De.additionalProperties===!1){let{additionalProperties:Ue,...Be}=De;Le=Be}Re.push(Le)}}),Re.length?{allOf:Re}:void 0}function Ym(N){let oe=typeof N.value;if(oe!=="bigint"&&oe!=="number"&&oe!=="boolean"&&oe!=="string")return{type:Array.isArray(N.value)?"array":"object"};return{type:oe==="bigint"?"integer":oe,const:N.value}}var Wi=void 0,vr={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(Wi===void 0)Wi=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return Wi},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Ef(N,oe){let Ie={type:"string"};if(N.checks)for(let Re of N.checks)switch(Re.kind){case"min":Ie.minLength=typeof Ie.minLength==="number"?Math.max(Ie.minLength,Re.value):Re.value;break;case"max":Ie.maxLength=typeof Ie.maxLength==="number"?Math.min(Ie.maxLength,Re.value):Re.value;break;case"email":switch(oe.emailStrategy){case"format:email":br(Ie,"email",Re.message,oe);break;case"format:idn-email":br(Ie,"idn-email",Re.message,oe);break;case"pattern:zod":ur(Ie,vr.email,Re.message,oe)}break;case"url":br(Ie,"uri",Re.message,oe);break;case"uuid":br(Ie,"uuid",Re.message,oe);break;case"regex":ur(Ie,Re.regex,Re.message,oe);break;case"cuid":ur(Ie,vr.cuid,Re.message,oe);break;case"cuid2":ur(Ie,vr.cuid2,Re.message,oe);break;case"startsWith":ur(Ie,RegExp(`^${Ki(Re.value,oe)}`),Re.message,oe);break;case"endsWith":ur(Ie,RegExp(`${Ki(Re.value,oe)}$`),Re.message,oe);break;case"datetime":br(Ie,"date-time",Re.message,oe);break;case"date":br(Ie,"date",Re.message,oe);break;case"time":br(Ie,"time",Re.message,oe);break;case"duration":br(Ie,"duration",Re.message,oe);break;case"length":Ie.minLength=typeof Ie.minLength==="number"?Math.max(Ie.minLength,Re.value):Re.value,Ie.maxLength=typeof Ie.maxLength==="number"?Math.min(Ie.maxLength,Re.value):Re.value;break;case"includes":ur(Ie,RegExp(Ki(Re.value,oe)),Re.message,oe);break;case"ip":if(Re.version!=="v6")br(Ie,"ipv4",Re.message,oe);if(Re.version!=="v4")br(Ie,"ipv6",Re.message,oe);break;case"base64url":ur(Ie,vr.base64url,Re.message,oe);break;case"jwt":ur(Ie,vr.jwt,Re.message,oe);break;case"cidr":if(Re.version!=="v6")ur(Ie,vr.ipv4Cidr,Re.message,oe);if(Re.version!=="v4")ur(Ie,vr.ipv6Cidr,Re.message,oe);break;case"emoji":ur(Ie,vr.emoji(),Re.message,oe);break;case"ulid":ur(Ie,vr.ulid,Re.message,oe);break;case"base64":switch(oe.base64Strategy){case"format:binary":br(Ie,"binary",Re.message,oe);break;case"contentEncoding:base64":Ie.contentEncoding="base64";break;case"pattern:zod":ur(Ie,vr.base64,Re.message,oe)}break;case"nanoid":ur(Ie,vr.nanoid,Re.message,oe)}return Ie}function Ki(N,oe){return oe.patternStrategy==="escape"?eh(N):N}var Qm=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function eh(N){let oe="";for(let Ie=0;Ie<N.length;Ie++){if(!Qm.has(N[Ie]))oe+="\\";oe+=N[Ie]}return oe}function br(N,oe,Ie,Re){if(N.format||N.anyOf?.some((De)=>De.format)){if(!N.anyOf)N.anyOf=[];if(N.format)N.anyOf.push({format:N.format}),delete N.format;N.anyOf.push({format:oe,...Ie&&Re.errorMessages&&{errorMessage:{format:Ie}}})}else N.format=oe}function ur(N,oe,Ie,Re){if(N.pattern||N.allOf?.some((De)=>De.pattern)){if(!N.allOf)N.allOf=[];if(N.pattern)N.allOf.push({pattern:N.pattern}),delete N.pattern;N.allOf.push({pattern:df(oe,Re),...Ie&&Re.errorMessages&&{errorMessage:{pattern:Ie}}})}else N.pattern=df(oe,Re)}function df(N,oe){if(!oe.applyRegexFlags||!N.flags)return N.source;let Ie={i:N.flags.includes("i"),m:N.flags.includes("m"),s:N.flags.includes("s")},Re=Ie.i?N.source.toLowerCase():N.source,De="",Le=!1,Ue=!1,Be=!1;for(let Xe=0;Xe<Re.length;Xe++){if(Le){De+=Re[Xe],Le=!1;continue}if(Ie.i){if(Ue){if(Re[Xe].match(/[a-z]/)){if(Be)De+=Re[Xe],De+=`${Re[Xe-2]}-${Re[Xe]}`.toUpperCase(),Be=!1;else if(Re[Xe+1]==="-"&&Re[Xe+2]?.match(/[a-z]/))De+=Re[Xe],Be=!0;else De+=`${Re[Xe]}${Re[Xe].toUpperCase()}`;continue}}else if(Re[Xe].match(/[a-z]/)){De+=`[${Re[Xe]}${Re[Xe].toUpperCase()}]`;continue}}if(Ie.m){if(Re[Xe]==="^"){De+=`(^|(?<=[\r
|
|
62
|
+
`,yt);continue}let Ut=_t.charCodeAt(yt);if(rf(_t,yt,Ut)){let Bt=_t.charCodeAt(yt+5)===Fr?yt+6:yt+5,dr=_t.slice(Bt,Ot);if(et===0&&_t.charCodeAt(Ot+1)===tf){oe({id:Ye,event:tt,data:dr}),Ye=void 0,Qe="",tt=void 0,yt=Ot+2,Ot=_t.indexOf(`
|
|
63
|
+
`,yt);continue}Qe=et===0?dr:`${Qe}
|
|
64
|
+
${dr}`,et++}else nf(_t,yt,Ut)?tt=_t.slice(_t.charCodeAt(yt+6)===Fr?yt+7:yt+6,Ot)||void 0:Et(_t,yt,Ot);yt=Ot+1,Ot=_t.indexOf(`
|
|
65
|
+
`,yt)}return _t.slice(yt)}for(;yt<_t.length;){let Ot=_t.indexOf("\r",yt),Ut=_t.indexOf(`
|
|
66
|
+
`,yt),Bt=-1;if(Ot!==-1&&Ut!==-1?Bt=Ot<Ut?Ot:Ut:Ot!==-1?Ot===_t.length-1?Bt=-1:Bt=Ot:Ut!==-1&&(Bt=Ut),Bt===-1)break;Et(_t,yt,Bt),yt=Bt+1,_t.charCodeAt(yt-1)===Yd&&_t.charCodeAt(yt)===tf&&yt++}return _t.slice(yt)}function Et(_t,yt,Ot){if(yt===Ot){Sr();return}let Ut=_t.charCodeAt(yt);if(rf(_t,yt,Ut)){let Ur=_t.charCodeAt(yt+5)===Fr?yt+6:yt+5,ts=_t.slice(Ur,Ot);Qe=et===0?ts:`${Qe}
|
|
67
|
+
${ts}`,et++;return}if(nf(_t,yt,Ut)){tt=_t.slice(_t.charCodeAt(yt+6)===Fr?yt+7:yt+6,Ot)||void 0;return}if(Ut===105&&_t.charCodeAt(yt+1)===100&&_t.charCodeAt(yt+2)===58){let Ur=_t.slice(_t.charCodeAt(yt+3)===Fr?yt+4:yt+3,Ot);Ur.includes("\x00")||(Ye=Ur);return}if(Ut===58){if(De){let Ur=_t.slice(yt,Ot);De(Ur.slice(_t.charCodeAt(yt+1)===Fr?2:1))}return}let Bt=_t.slice(yt,Ot),dr=Bt.indexOf(":");if(dr===-1){er(Bt,"",Bt);return}let Rn=Bt.slice(0,dr),vo=Bt.charCodeAt(dr+1)===Fr?2:1,bo=Bt.slice(dr+vo);er(Rn,bo,Bt)}function er(_t,yt,Ot){switch(_t){case"event":tt=yt||void 0;break;case"data":Qe=et===0?yt:`${Qe}
|
|
68
|
+
${yt}`,et++;break;case"id":yt.includes("\x00")||(Ye=yt);break;case"retry":/^\d+$/.test(yt)?Re(parseInt(yt,10)):Ie(new po(`Invalid \`retry\` value: "${yt}"`,{type:"invalid-retry",value:yt,line:Ot}));break;default:Ie(new po(`Unknown field "${_t.length>20?`${_t.slice(0,20)}…`:_t}"`,{type:"unknown-field",field:_t,value:yt,line:Ot}));break}}function Sr(){et>0&&oe({id:Ye,event:tt,data:Qe}),Ye=void 0,Qe="",et=0,tt=void 0}function Rr(_t={}){if(_t.consume&&Ue.length>0){let yt=Ue.join("");Et(yt,0,yt.length)}Xe=!0,Ye=void 0,Qe="",et=0,tt=void 0,Ue.length=0,Be=0,ft=!1}return{feed:gt,reset:Rr}}function rf(N,oe,Ie){return Ie===100&&N.charCodeAt(oe+1)===97&&N.charCodeAt(oe+2)===116&&N.charCodeAt(oe+3)===97&&N.charCodeAt(oe+4)===58}function nf(N,oe,Ie){return Ie===101&&N.charCodeAt(oe+1)===118&&N.charCodeAt(oe+2)===101&&N.charCodeAt(oe+3)===110&&N.charCodeAt(oe+4)===116&&N.charCodeAt(oe+5)===58}class mo extends TransformStream{constructor({onError:N,onRetry:oe,onComment:Ie,maxBufferSize:Re}={}){let De;super({start(Le){De=of({onEvent:(Ue)=>{Le.enqueue(Ue)},onError(Ue){typeof N=="function"&&N(Ue),(N==="terminate"||Ue.type==="max-buffer-size-exceeded")&&Le.error(Ue)},onRetry:oe,onComment:Ie,maxBufferSize:Re})},transform(Le){De.feed(Le)}})}}var k=Symbol.for("workflow-serialize"),T=Symbol.for("workflow-deserialize");function Ne(N){return N===void 0?[]:Array.isArray(N)?N:[N]}function d(...N){return N.reduce((oe,Ie)=>({...oe,...Ie}),{})}function Qd(N){return Object.fromEntries(Object.entries(N).filter(([oe,Ie])=>Ie!=null))}async function Oe(N,oe){if(N==null)return;let Ie=oe?.abortSignal;return new Promise((Re,De)=>{if(Ie?.aborted){De(sf());return}let Le=setTimeout(()=>{Ue(),Re()},N),Ue=()=>{clearTimeout(Le),Ie?.removeEventListener("abort",Be)},Be=()=>{Ue(),De(sf())};Ie?.addEventListener("abort",Be)})}function sf(){return new DOMException("Delay was aborted","AbortError")}function em(N){let oe=N??globalThis.WebSocket;if(oe==null)throw Error("No WebSocket implementation available.");return oe}function Lt(N){let oe=new URL(N);if(oe.protocol==="http:")oe.protocol="ws:";else if(oe.protocol==="https:")oe.protocol="wss:";return oe}var cf=new TextDecoder;async function tm(N){if(typeof N==="string")return N;if(N instanceof ArrayBuffer)return cf.decode(N);if(ArrayBuffer.isView(N))return cf.decode(N);if(typeof Blob<"u"&&N instanceof Blob)return N.text();return String(N)}var rm=1;async function ue(N,{highWaterMark:oe=1048576,pollIntervalMs:Ie=20,abortSignal:Re}={}){while(N.readyState===rm&&(N.bufferedAmount??0)>oe){if(Re?.aborted===!0)return;await Oe(Ie)}}function fe({url:N,protocols:oe,headers:Ie,webSocket:Re,abortSignal:De,onOpen:Le,onMessageText:Ue,onProcessingError:Be,onSocketError:Xe,onClose:Ye,onAbort:Qe}){let et,tt,ft=(St)=>{if(tt!=null)De?.removeEventListener("abort",tt),tt=void 0;try{et?.close(St)}catch{}};if(De?.aborted)return Qe?.(De.reason??Error("Aborted")),{socket:void 0,close:ft};try{et=new(em(Re))(N,oe,{headers:Qd(Ie??{})})}catch(St){return Be(St),{socket:void 0,close:ft}}if(De!=null&&Qe!=null)tt=()=>Qe(De.reason??Error("Aborted")),De.addEventListener("abort",tt,{once:!0});let gt=et;et.onopen=()=>{try{Le?.(gt)}catch(St){Be(St)}};let bt=Promise.resolve();return et.onmessage=(St)=>{bt=bt.then(()=>tm(St.data)).then((Et)=>Ue(Et)).catch(Be)},et.onerror=()=>{bt=bt.then(()=>Xe?.()).catch(Be)},et.onclose=(St)=>{let Et=St,er=typeof Et?.code==="number"?Et.code:void 0,Sr=typeof Et?.reason==="string"?Et.reason:void 0;bt=bt.then(()=>Ye?.({code:er,reason:Sr})).catch(Be)},{socket:et,close:ft}}function ae(N){let oe=!1;return new ReadableStream({async pull(Ie){if(oe)return;try{let{value:Re,done:De}=await N.next();if(De)Ie.close();else Ie.enqueue(Re)}catch(Re){Ie.error(Re)}},async cancel(Ie){if(oe=!0,N.return)try{await N.return(Ie)}catch{}}})}var{btoa:nm,atob:om}=globalThis;function j(N){let oe=N.replace(/-/g,"+").replace(/_/g,"/"),Ie=om(oe);return Uint8Array.from(Ie,(Re)=>Re.codePointAt(0))}function X(N){if(typeof globalThis.Buffer?.from==="function")return globalThis.Buffer.from(N.buffer,N.byteOffset,N.byteLength).toString("base64");let oe=[],Ie=4096;for(let Re=0;Re<N.length;Re+=Ie)oe.push(String.fromCodePoint(...N.subarray(Re,Re+Ie)));return nm(oe.join(""))}function M(N){return N instanceof Uint8Array?X(N):N}function we(N){if(N.type==="stream"){let oe=new u({functionality:"streaming file upload"});throw N.stream.cancel(oe).catch(()=>{}),oe}if(N.type==="text")return new TextEncoder().encode(N.text);if(N.data instanceof Uint8Array)return N.data;if(N.data instanceof ArrayBuffer)return new Uint8Array(N.data);return j(N.data)}function en(N){let oe=new Set,Ie=new Set,Re=!1,De=!1;return new TransformStream({transform(Le,Ue){switch(Le.type){case"text-start":case"text-delta":case"text-end":return;case"tool-input-start":if(Le.toolName===N){oe.add(Le.id),Ue.enqueue({type:"text-start",id:Le.id,...Le.providerMetadata&&{providerMetadata:Le.providerMetadata}});return}break;case"tool-input-delta":if(oe.has(Le.id)){if(Le.delta.length>0)Ie.add(Le.id);Ue.enqueue({type:"text-delta",id:Le.id,delta:Le.delta,...Le.providerMetadata&&{providerMetadata:Le.providerMetadata}});return}break;case"tool-input-end":if(oe.has(Le.id))return;break;case"tool-call":if(Le.toolName===N){if(!Ie.has(Le.toolCallId))Ue.enqueue({type:"text-delta",id:Le.toolCallId,delta:Le.input,...Le.providerMetadata&&{providerMetadata:Le.providerMetadata}});Ue.enqueue({type:"text-end",id:Le.toolCallId,...Le.providerMetadata&&{providerMetadata:Le.providerMetadata}}),Re=!0;return}if(!Le.providerExecuted)De=!0;break;case"finish":if(Re&&!De&&Le.finishReason.unified==="tool-calls"){Ue.enqueue({...Le,finishReason:{...Le.finishReason,unified:"stop"}});return}}Ue.enqueue(Le)}})}function st(N,oe={}){let{useArrayBrackets:Ie=!0}=oe,Re=new FormData;for(let[De,Le]of Object.entries(N)){if(Le==null)continue;if(Array.isArray(Le)){if(Le.length===1){Re.append(De,Le[0]);continue}let Ue=Ie?`${De}[]`:De;for(let Be of Le)Re.append(Ue,Be);continue}Re.append(De,Le)}return Re}function ee({id:N,model:oe,created:Ie}){return{id:N??void 0,modelId:oe??void 0,timestamp:Ie!=null?new Date(Ie*1000):void 0}}function te(){return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0}}function le({tools:N=[],providerToolNames:oe}){let Ie={},Re={};for(let De of N)if(De.type==="provider"&&De.id in oe){let Le=oe[De.id];Ie[De.name]=Le,Re[Le]=De.name}return{toProviderToolName:(De)=>Ie[De]??De,toCustomToolName:(De)=>Re[De]??De}}var hf=Symbol.for("vercel.ai.providerStreamError");function xe({message:N,type:oe,code:Ie,statusCode:Re,isRetryable:De,data:Le}){let Ue={message:N,type:oe,code:Ie,statusCode:Re,isRetryable:De,data:Le};return Object.defineProperty(Ue,hf,{value:!0}),Ue}function at(N){return typeof N==="object"&&N!=null&&N[hf]===!0}var je=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){if(this._promise)return this._promise;return this._promise=new Promise((N,oe)=>{if(this.status.type==="resolved")N(this.status.value);else if(this.status.type==="rejected")oe(this.status.error);this._resolve=N,this._reject=oe}),this._promise}resolve(N){if(this.status={type:"resolved",value:N},this._promise)this._resolve?.(N)}reject(N){if(this.status={type:"rejected",error:N},this._promise)this._reject?.(N)}isResolved(){return this.status.type==="resolved"}isRejected(){return this.status.type==="rejected"}isPending(){return this.status.type==="pending"}};function br(N){return Object.fromEntries([...N.headers])}function ke(N=globalThis){if(N.navigator?.userAgent)return N.navigator.userAgent.toLowerCase();if(N.process?.versions?.node)return`node.js/${N.process.version}`;if(N.EdgeRuntime)return"vercel-edge";return""}function Z(N){return(N instanceof Error||typeof DOMException==="function"&&N instanceof DOMException)&&(N.name==="AbortError"||N.name==="ResponseAborted"||N.name==="TimeoutError")}var im=["fetch failed","failed to fetch"],sm=new Set(["ConnectionRefused","ConnectionClosed","FailedToOpenSocket","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE","UND_ERR_SOCKET","UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT","UND_ERR_CONNECT_TIMEOUT"]);function cm(N){let oe=new Set,Ie=N;while(Ie instanceof Error&&!oe.has(Ie)){oe.add(Ie);let Re=Ie;if(typeof Re.code==="string"&&sm.has(Re.code))return Re;Ie=Ie.cause}}function Nn({error:N,url:oe,requestBodyValues:Ie}){if(Z(N))return N;if(N instanceof TypeError&&im.includes(N.message.toLowerCase())){let De=N.cause;if(De!=null)return new w({message:`Cannot connect to API: ${De.message}`,cause:De,url:oe,requestBodyValues:Ie,isRetryable:!0})}let Re=cm(N);if(Re!=null){if(w.isInstance(N))return new w({message:N.message,cause:N.cause,url:N.url,requestBodyValues:N.requestBodyValues,statusCode:N.statusCode,responseHeaders:N.responseHeaders,responseBody:N.responseBody,data:N.data,isRetryable:!0});return new w({message:`Cannot connect to API: ${N instanceof Error?N.message:Re.message}`,cause:N,url:oe,requestBodyValues:Ie,isRetryable:!0})}return N}var yo="5.0.70";function qe(N){if(N==null)return{};let oe={};if(N instanceof Headers)N.forEach((Ie,Re)=>{oe[Re.toLowerCase()]=Ie});else{if(!Array.isArray(N))N=Object.entries(N);for(let[Ie,Re]of N)if(Re!=null)oe[Ie.toLowerCase()]=Re}return oe}function F(N,...oe){let Ie=new Headers(qe(N)),Re=Ie.get("user-agent")||"";return Ie.set("user-agent",[Re,...oe].filter(Boolean).join(" ")),Object.fromEntries(Ie.entries())}var am=()=>globalThis.fetch,tn=async({url:N,headers:oe={},failedResponseHandler:Ie,successfulResponseHandler:Re,abortSignal:De,fetch:Le=am()})=>{try{let Ue=await Le(N,{method:"DELETE",headers:F(oe,`ai-sdk-provider-utils/${yo}`,ke()),signal:De}),Be=br(Ue);if(!Ue.ok){let Xe;try{Xe=await Ie({response:Ue,url:N,requestBodyValues:{}})}catch(Ye){if(Z(Ye)||w.isInstance(Ye))throw Ye;throw new w({message:"Failed to process error response",cause:Ye,statusCode:Ue.status,url:N,responseHeaders:Be,requestBodyValues:{}})}throw Xe.value}try{return await Re({response:Ue,url:N,requestBodyValues:{}})}catch(Xe){if(Xe instanceof Error){if(Z(Xe)||w.isInstance(Xe))throw Xe}throw new w({message:"Failed to process successful response",cause:Xe,statusCode:Ue.status,url:N,responseHeaders:Be,requestBodyValues:{}})}}catch(Ue){throw Nn({error:Ue,url:N,requestBodyValues:{}})}},gf=[{mediaType:"image/gif",bytesPrefix:[71,73,70,56,55,97]},{mediaType:"image/gif",bytesPrefix:[71,73,70,56,57,97]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77,null,null,null,null,0,0,0,0]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,null,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,null,102,116,121,112,104,101,105,99]}],yf=[{mediaType:"application/pdf",bytesPrefix:[37,80,68,70]}],_f=[{mediaType:"audio/aac",bytesPrefix:[255,240]},{mediaType:"audio/aac",bytesPrefix:[255,241]},{mediaType:"audio/aac",bytesPrefix:[255,248]},{mediaType:"audio/aac",bytesPrefix:[255,249]},{mediaType:"audio/mpeg",bytesPrefix:[255,251]},{mediaType:"audio/mpeg",bytesPrefix:[255,250]},{mediaType:"audio/mpeg",bytesPrefix:[255,243]},{mediaType:"audio/mpeg",bytesPrefix:[255,242]},{mediaType:"audio/mpeg",bytesPrefix:[255,227]},{mediaType:"audio/mpeg",bytesPrefix:[255,226]},{mediaType:"audio/wav",bytesPrefix:[82,73,70,70,null,null,null,null,87,65,86,69]},{mediaType:"audio/ogg",bytesPrefix:[79,103,103,83]},{mediaType:"audio/flac",bytesPrefix:[102,76,97,67]},{mediaType:"audio/aac",bytesPrefix:[64,21,0,0]},{mediaType:"audio/webm",bytesPrefix:[26,69,223,163]}],um=[..._f,{mediaType:"audio/mp4",bytesPrefix:[0,0,0,null,102,116,121,112]}],vf=[{mediaType:"video/mp4",bytesPrefix:[0,0,0,null,102,116,121,112]},{mediaType:"video/webm",bytesPrefix:[26,69,223,163]},{mediaType:"video/quicktime",bytesPrefix:[0,0,0,20,102,116,121,112,113,116]},{mediaType:"video/x-msvideo",bytesPrefix:[82,73,70,70]}],lm=18,fm=131084;function af(N,oe){if(typeof N!=="string")return N.length>oe?N.subarray(0,oe):N;let Ie=Math.ceil(oe/3)*4,Re=j(N.substring(0,Math.min(N.length,Ie)));return Re.length>oe?Re.subarray(0,oe):Re}function pm(N){return N.length>10&&N[0]===73&&N[1]===68&&N[2]===51}var dm=(N)=>{let oe=(N[6]&127)<<21|(N[7]&127)<<14|(N[8]&127)<<7|N[9]&127;return N.subarray(oe+10)};function uf({data:N,signatures:oe}){let Ie=af(N,lm);if(pm(Ie))Ie=dm(af(N,fm));for(let Re of oe)if(Ie.length>=Re.bytesPrefix.length&&Re.bytesPrefix.every((De,Le)=>De===null||Ie[Le]===De))return Re.mediaType}var mm={image:gf,audio:um,video:vf,application:yf};function Te({data:N,topLevelType:oe}){if(oe===void 0)return uf({data:N,signatures:[...gf,...yf,..._f,...vf]});let Ie=mm[oe];if(Ie===void 0)return;return uf({data:N,signatures:Ie})}function z(N){let oe=N.indexOf("/");return oe===-1?N:N.substring(0,oe)}function K(N){let oe=N.indexOf("/");if(oe===-1)return!1;let Ie=N.substring(oe+1);return Ie.length>0&&Ie!=="*"}async function it(N){try{await N.body?.cancel()}catch{}}var bf="AI_DownloadError",xf=`vercel.ai.error.${bf}`,hm=Symbol.for(xf),B=class extends m{constructor({url:N,statusCode:oe,statusText:Ie,cause:Re,message:De=Re==null?`Failed to download ${N}: ${oe} ${Ie}`:`Failed to download ${N}: ${Re}`}){super({name:bf,message:De,cause:Re});this[hm]=!0,this.url=N,this.statusCode=oe,this.statusText=Ie}static isInstance(N){return m.hasMarker(N,xf)}};function gm(N=globalThis){return N.window!=null}function He(N,oe){try{return new URL(N).origin===new URL(oe).origin}catch{return!1}}function ym(N){let oe;try{oe=new URL(N)}catch{throw new B({url:N,message:`Invalid URL: ${N}`})}if(oe.protocol==="data:")return;if(oe.protocol!=="http:"&&oe.protocol!=="https:")throw new B({url:N,message:`URL scheme must be http, https, or data, got ${oe.protocol}`});let Ie=oe.hostname.toLowerCase().replace(/\.+$/,"");if(!Ie)throw new B({url:N,message:"URL must have a hostname"});if(Ie==="localhost"||Ie.endsWith(".local")||Ie.endsWith(".localhost")||Ie.endsWith(".internal"))throw new B({url:N,message:`URL with hostname ${Ie} is not allowed`});if(Ie.startsWith("[")&&Ie.endsWith("]")){if(wf(Ie.slice(1,-1)))throw new B({url:N,message:`URL with IPv6 address ${Ie} is not allowed`});return}if(Gi(Ie)){if(Xi(Ie))throw new B({url:N,message:`URL with IP address ${Ie} is not allowed`})}}function _m({address:N,family:oe,hostname:Ie}){if(oe===4?!Gi(N)||Xi(N):oe===6?wf(N):!0)throw new B({url:Ie,message:`Hostname ${Ie} resolved to disallowed IP address ${N}`})}function Gi(N){let oe=N.split(".");if(oe.length!==4)return!1;return oe.every((Ie)=>{let Re=Number(Ie);return Number.isInteger(Re)&&Re>=0&&Re<=255&&String(Re)===Ie})}function Xi(N){let[oe,Ie,Re]=N.split(".").map(Number);if(oe===0)return!0;if(oe===10)return!0;if(oe===100&&Ie>=64&&Ie<=127)return!0;if(oe===127)return!0;if(oe===169&&Ie===254)return!0;if(oe===172&&Ie>=16&&Ie<=31)return!0;if(oe===192&&Ie===0&&Re===0)return!0;if(oe===192&&Ie===0&&Re===2)return!0;if(oe===192&&Ie===168)return!0;if(oe===198&&(Ie===18||Ie===19))return!0;if(oe===198&&Ie===51&&Re===100)return!0;if(oe===203&&Ie===0&&Re===113)return!0;if(oe>=224)return!0;return!1}function vm(N){let oe=N.toLowerCase(),Ie=oe.indexOf("%");if(Ie!==-1)oe=oe.slice(0,Ie);let Re=oe.split("::");if(Re.length>2)return null;let De=(Ue)=>{if(Ue==="")return[];let Be=[],Xe=Ue.split(":");for(let Ye=0;Ye<Xe.length;Ye++){let Qe=Xe[Ye];if(Qe.includes(".")){if(Ye!==Xe.length-1||!Gi(Qe))return null;let[et,tt,ft,gt]=Qe.split(".").map(Number);Be.push(et<<8|tt,ft<<8|gt);continue}if(!/^[0-9a-f]{1,4}$/.test(Qe))return null;Be.push(parseInt(Qe,16))}return Be},Le=De(Re[0]);if(Le===null)return null;if(Re.length===2){let Ue=De(Re[1]);if(Ue===null)return null;let Be=8-Le.length-Ue.length;if(Be<0)return null;return[...Le,...Array(Be).fill(0),...Ue]}return Le.length===8?Le:null}function wf(N){let oe=vm(N);if(oe===null)return!0;let Ie=(Re)=>oe.slice(0,Re).every((De)=>De===0);if(Ie(7)&&(oe[7]===0||oe[7]===1))return!0;if((oe[0]&65024)===64512)return!0;if((oe[0]&65472)===65152)return!0;if((oe[0]&65472)===65216)return!0;if((oe[0]&65280)===65280)return!0;if(oe[0]===8193&&oe[1]===3512)return!0;if(oe[0]===16383&&(oe[1]&61440)===0)return!0;if(Ie(6)||Ie(5)&&oe[5]===65535||Ie(4)&&oe[4]===65535&&oe[5]===0||oe[0]===100&&oe[1]===65435&&oe[2]===0&&oe[3]===0&&oe[4]===0&&oe[5]===0||oe[0]===100&&oe[1]===65435&&oe[2]===1)return Xi(`${oe[6]>>8&255}.${oe[6]&255}.${oe[7]>>8&255}.${oe[7]&255}`);return!1}function bm(N){return(oe,Ie,Re)=>{N(oe,{...Ie,all:!0},(De,Le)=>{if(De){Re(De);return}try{let[Ue]=Le;if(Ue==null)throw Error(`Hostname ${oe} did not resolve to an address`);for(let{address:Be,family:Xe}of Le)_m({address:Be,family:Xe,hostname:oe});if(Ie.all===!0)Re(null,Le);else Re(null,Ue.address,Ue.family)}catch(Ue){Re(Ue instanceof Error?Ue:Error(String(Ue)))}})}}var xm;function wm(){let N=globalThis.process;return N?.release?.name==="node"&&N.versions?.bun==null&&N.versions?.deno==null&&N.title!=="workerd"&&globalThis.EdgeRuntime==null}async function $m(){if(!wm())return globalThis.fetch;return xm??=Promise.resolve().then(zm)}function zm(){let N=lf("node:module"),{lookup:oe}=lf("node:dns"),{Agent:Ie,fetch:Re}=N.createRequire($f())("undici"),De=new Ie({connect:{lookup:bm(oe)}});return(Le,Ue)=>Re(Le,{...Ue,dispatcher:De})}function lf(N){let oe=globalThis.process?.getBuiltinModule?.(N);if(oe==null)throw Error(`Node.js built-in module ${N} is unavailable`);return oe}function $f(){let N=Error.prepareStackTrace;try{Error.prepareStackTrace=(De,Le)=>Le;let oe=Error("Capture current module path");Error.captureStackTrace(oe,$f);let[Ie]=oe.stack,Re=Ie?.getFileName();if(Re==null)throw Error("Unable to determine the current module path");return Re}finally{Error.prepareStackTrace=N}}var Sm=["connection","keep-alive","te","trailer","transfer-encoding","upgrade","host","forwarded","proxy-authorization","via","x-forwarded-for","x-forwarded-host","x-forwarded-proto","x-real-ip","metadata","metadata-flavor","x-aws-ec2-metadata-token","x-metadata-token","cookie","set-cookie"];function zf(N){let oe=new Headers(N);for(let Ie of Sm)oe.delete(Ie);return oe}var km=10,Pm=new Set([301,302,303,307,308]);async function Em(N){return N==null||N===globalThis.fetch?await $m():N}async function Sf({url:N,headers:oe,abortSignal:Ie,maxRedirects:Re=km,fetch:De,trustedOrigin:Le}){let Ue=oe===void 0?void 0:zf(oe),Be=(Ye)=>{let Qe={signal:Ie,redirect:Ye};if(Ue!==void 0)Qe.headers=new Headers(Ue);return Qe},Xe=N;for(let Ye=0;Ye<=Re;Ye++){let Qe=Le!==void 0&&He(Xe,Le);if(!Qe)ym(Xe);let et=Qe&&De!=null?De:Qe?globalThis.fetch:await Em(De),tt=await et(Xe,Be("manual"));if(tt.type==="opaqueredirect"){if(!gm())throw new B({url:N,message:`Redirect from ${Xe} could not be validated and was blocked`});return await et(Xe,Be("follow"))}let ft=tt.headers?.get("location");if(Pm.has(tt.status)&&ft){it(tt);let gt=new URL(ft,Xe).toString();if(Ue!==void 0&&!He(gt,Xe)){let bt=Ue.get("user-agent");Ue=new Headers(bt==null?void 0:{"user-agent":bt})}Xe=gt;continue}return tt}throw new B({url:N,message:`Too many redirects (max ${Re})`})}var Om=new Set(["accept","accept-language","baggage","cache-control","idempotency-key","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","pragma","range","traceparent","tracestate","user-agent","x-correlation-id","x-request-id"]);async function $t({headers:N,credentialedOrigin:oe,untrustedFirstHopHeaders:Ie,...Re}){let De;if(N!==void 0){De=zf(N);let Le=oe??Re.trustedOrigin;if(Le===void 0||!He(Re.url,Le)){let Ue=new Set([...Om,...(Ie??[]).map((Be)=>Be.toLowerCase())]);De=new Headers([...De].filter(([Be])=>Ue.has(Be)))}}return Sf({...Re,headers:De})}var Nt=2147483648;async function vt({response:N,url:oe,maxBytes:Ie=Nt}){let Re=N.headers.get("content-length");if(Re!=null){let Qe=parseInt(Re,10);if(!isNaN(Qe)&&Qe>Ie)throw await it(N),new B({url:oe,message:`Download of ${oe} exceeded maximum size of ${Ie} bytes (Content-Length: ${Qe}).`})}let De=N.body;if(De==null)return new Uint8Array(0);let Le=De.getReader(),Ue=[],Be=0;try{while(!0){let{done:Qe,value:et}=await Le.read();if(Qe)break;if(Be+=et.length,Be>Ie)throw new B({url:oe,message:`Download of ${oe} exceeded maximum size of ${Ie} bytes.`});Ue.push(et.byteLength<et.buffer.byteLength?new Uint8Array(et):et)}}finally{try{await Le.cancel()}catch{}finally{Le.releaseLock()}}let Xe=new Uint8Array(Be),Ye=0;for(let Qe of Ue)Xe.set(Qe,Ye),Ye+=Qe.length;return Xe}async function Me(N,oe){try{let Ie=await $t({url:N,abortSignal:oe?.abortSignal});if(!Ie.ok)throw await it(Ie),new B({url:N,statusCode:Ie.status,statusText:Ie.statusText});let Re=await vt({response:Ie,url:N,maxBytes:oe?.maxBytes??2147483648}),De=Ie.headers.get("content-type")??void 0;return new Blob([Re],De?{type:De}:void 0)}catch(Ie){if(B.isInstance(Ie))throw Ie;throw new B({url:N,cause:Ie})}}var nn=Symbol.for("vercel.ai.embeddingModel.maxInputBytesPerCall"),rn=Symbol.for("vercel.ai.embeddingModel.providerOptionsTransformer");function de(N){let oe=encodeURIComponent(N);return oe==="."?"%252E":oe===".."?"%252E%252E":oe}function Pe(...N){return N.filter((oe)=>oe!=null)}var V=({prefix:N,size:oe=16,alphabet:Ie="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:Re="-"}={})=>{let De=()=>{let Le=Ie.length,Ue=Array(oe);for(let Be=0;Be<oe;Be++)Ue[Be]=Ie[Math.random()*Le|0];return Ue.join("")};if(N==null)return De;if(Ie.includes(Re))throw new b({argument:"separator",message:`The separator "${Re}" must not be part of the alphabet "${Ie}".`});return()=>`${N}${Re}${De()}`},C=V(),Tm=()=>globalThis.fetch,R=async({url:N,headers:oe={},successfulResponseHandler:Ie,failedResponseHandler:Re,abortSignal:De,fetch:Le,validateUrl:Ue,credentialedOrigin:Be,trustedOrigin:Xe})=>{try{let Ye=Le??Tm(),Qe=F(Be!==void 0&&!He(N,Be)?{}:oe,`ai-sdk-provider-utils/${yo}`,ke()),et=Ue?await Sf({url:N,headers:Qe,abortSignal:De,fetch:Le,trustedOrigin:Xe}):await Ye(N,{method:"GET",headers:Qe,signal:De}),tt=br(et);if(!et.ok){let ft;try{ft=await Re({response:et,url:N,requestBodyValues:{}})}catch(gt){if(Z(gt)||w.isInstance(gt))throw gt;throw new w({message:"Failed to process error response",cause:gt,statusCode:et.status,url:N,responseHeaders:tt,requestBodyValues:{}})}throw ft.value}try{return await Ie({response:et,url:N,requestBodyValues:{}})}catch(ft){if(ft instanceof Error){if(Z(ft)||w.isInstance(ft))throw ft}throw new w({message:"Failed to process successful response",cause:ft,statusCode:et.status,url:N,responseHeaders:tt,requestBodyValues:{}})}}catch(Ye){throw Nn({error:Ye,url:N,requestBodyValues:{}})}},Zm="JSON schema:",Am="You MUST answer with a JSON object that matches the JSON schema above.",Im="You MUST answer with JSON.";function Cm({prompt:N,schema:oe,schemaPrefix:Ie=oe!=null?Zm:void 0,schemaSuffix:Re=oe!=null?Am:Im}){return[N!=null&&N.length>0?N:void 0,N!=null&&N.length>0?"":void 0,Ie,oe!=null?JSON.stringify(oe):void 0,Re].filter((De)=>De!=null).join(`
|
|
69
|
+
`)}function jt({messages:N,schema:oe,schemaPrefix:Ie,schemaSuffix:Re}){let De=N[0]?.role==="system"?{...N[0]}:{role:"system",content:""};return De.content=Cm({prompt:De.content,schema:oe,schemaPrefix:Ie,schemaSuffix:Re}),[De,...N[0]?.role==="system"?N.slice(1):N]}function xt(N){return globalThis.Buffer?.isBuffer(N)??!1}function Fe(N){return N!=null}function on(N){return typeof N==="object"&&N!==null&&!(N instanceof Uint8Array)&&!(N instanceof URL)&&!(N instanceof ArrayBuffer)&&!xt(N)&&!("type"in N)}function L(N){return N!=null&&typeof N==="object"&&!Array.isArray(N)}function Ze({mediaType:N,url:oe,supportedUrls:Ie}){N=N.toLowerCase();let Re=!N.includes("/");return Object.entries(Ie).map(([De,Le])=>{let Ue=De.toLowerCase();return Ue==="*"||Ue==="*/*"?{mediaTypePrefix:"",regexes:Le}:{mediaTypePrefix:Ue.replace(/\*/,""),regexes:Le}}).filter(({mediaTypePrefix:De})=>{if(De==="")return!0;if(Re)return`${N}/`===De;return De.endsWith("/")?N.startsWith(De):N===De}).flatMap(({regexes:De})=>De).some((De)=>Nm(De,oe))}function Nm(N,oe){if(!N.global&&!N.sticky)return N.test(oe);let Ie=N.lastIndex;N.lastIndex=0;try{return N.test(oe)}finally{N.lastIndex=Ie}}function he({apiKey:N,environmentVariableName:oe,apiKeyParameterName:Ie="apiKey",description:Re}){if(typeof N==="string")return N;if(N!=null)throw new qr({message:`${Re} API key must be a string.`});if(typeof process>"u")throw new qr({message:`${Re} API key is missing. Pass it using the '${Ie}' parameter. Environment variables are not supported in this environment.`});if(N=process.env[oe],N==null)throw new qr({message:`${Re} API key is missing. Pass it using the '${Ie}' parameter or the ${oe} environment variable.`});if(typeof N!=="string")throw new qr({message:`${Re} API key must be a string. The value of the ${oe} environment variable is not a string.`});return N}function pe({settingValue:N,environmentVariableName:oe}){if(typeof N==="string")return N;if(N!=null||typeof process>"u")return;if(N=process.env[oe],N==null||typeof N!=="string")return;return N}function W(N){return N!==void 0&&N!=="provider-default"}function Se({reasoning:N,effortMap:oe,warnings:Ie}){let Re=oe[N];if(Re==null){Ie.push({type:"unsupported",feature:"reasoning",details:`reasoning "${N}" is not supported by this model.`});return}if(Re!==N)Ie.push({type:"compatibility",feature:"reasoning",details:`reasoning "${N}" is not directly supported by this model. mapped to effort "${Re}".`});return Re}var Rm={minimal:0.02,low:0.1,medium:0.3,high:0.6,xhigh:0.9,max:0.95};function lt({reasoning:N,maxOutputTokens:oe,maxReasoningBudget:Ie,minReasoningBudget:Re=1024,budgetPercentages:De=Rm,warnings:Le}){let Ue=De[N];if(Ue==null){Le.push({type:"unsupported",feature:"reasoning",details:`reasoning "${N}" is not supported by this model.`});return}return Math.min(Ie,Math.max(Re,Math.round(oe*Ue)))}function ct(N){let[oe,Ie=""]=N.toLowerCase().split("/");return{mpeg:"mp3","x-wav":"wav",opus:"ogg",mp4:"m4a","x-m4a":"m4a"}[Ie]??Ie}function ge({total:N,pending:oe,completed:Ie,failed:Re}){if(ho(N)&&ho(oe)&&ho(Ie)&&ho(Re)&&oe+Ie+Re===N)return{total:N,pending:oe,completed:Ie,failed:Re}}function ho(N){return N!=null&&Number.isSafeInteger(N)&&N>=0}var Dm=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Mm=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function ff(N){let oe=JSON.parse(N);if(oe===null||typeof oe!=="object")return oe;if(Dm.test(N)===!1&&Mm.test(N)===!1)return oe;return Lm(oe)}function Lm(N){let oe=[N];while(oe.length){let Ie=oe;oe=[];for(let Re of Ie){if(Object.prototype.hasOwnProperty.call(Re,"__proto__"))throw SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(Re,"constructor")&&Re.constructor!==null&&typeof Re.constructor==="object"&&Object.prototype.hasOwnProperty.call(Re.constructor,"prototype"))throw SyntaxError("Object contains forbidden prototype property");for(let De in Re){let Le=Re[De];if(Le&&typeof Le==="object")oe.push(Le)}}}return N}function Q(N){let{stackTraceLimit:oe}=Error;try{Error.stackTraceLimit=0}catch{return ff(N)}try{return ff(N)}finally{Error.stackTraceLimit=oe}}function Yi(N){if(N.type==="object"||Array.isArray(N.type)&&N.type.includes("object")){let{additionalProperties:Ie}=N;N.additionalProperties=Ie!=null&&typeof Ie!=="boolean"?Nr(Ie):!1;let{properties:Re}=N;if(Re!=null)for(let De of Object.keys(Re))Re[De]=Nr(Re[De])}if(N.items!=null)N.items=Array.isArray(N.items)?N.items.map(Nr):Nr(N.items);if(N.anyOf!=null)N.anyOf=N.anyOf.map(Nr);if(N.allOf!=null)N.allOf=N.allOf.map(Nr);if(N.oneOf!=null)N.oneOf=N.oneOf.map(Nr);let{definitions:oe}=N;if(oe!=null)for(let Ie of Object.keys(oe))oe[Ie]=Nr(oe[Ie]);return N}function Nr(N){if(typeof N==="boolean")return N;return Yi(N)}var jm=Symbol("Let zodToJsonSchema decide on which parser to use"),pf={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Fm=(N)=>typeof N==="string"?{...pf,name:N}:{...pf,...N};function pr(){return{}}function Um(N,oe){let Ie={type:"array"};if(N.type?._def&&N.type?._def?.typeName!=="ZodAny")Ie.items=Ct(N.type._def,{...oe,currentPath:[...oe.currentPath,"items"]});if(N.minLength)Ie.minItems=N.minLength.value;if(N.maxLength)Ie.maxItems=N.maxLength.value;if(N.exactLength)Ie.minItems=N.exactLength.value,Ie.maxItems=N.exactLength.value;return Ie}function Bm(N){let oe={type:"integer",format:"int64"};if(!N.checks)return oe;for(let Ie of N.checks)switch(Ie.kind){case"min":if(Ie.inclusive)oe.minimum=Ie.value;else oe.exclusiveMinimum=Ie.value;break;case"max":if(Ie.inclusive)oe.maximum=Ie.value;else oe.exclusiveMaximum=Ie.value;break;case"multipleOf":oe.multipleOf=Ie.value}return oe}function Jm(){return{type:"boolean"}}function kf(N,oe){return Ct(N.type._def,oe)}var Vm=(N,oe)=>Ct(N.innerType._def,oe);function Pf(N,oe,Ie){let Re=Ie??oe.dateStrategy;if(Array.isArray(Re))return{anyOf:Re.map((De)=>Pf(N,oe,De))};switch(Re){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Wm(N)}}var Wm=(N)=>{let oe={type:"integer",format:"unix-time"};for(let Ie of N.checks)switch(Ie.kind){case"min":oe.minimum=Ie.value;break;case"max":oe.maximum=Ie.value}return oe};function Km(N,oe){return{...Ct(N.innerType._def,oe),default:N.defaultValue()}}function Hm(N,oe){return oe.effectStrategy==="input"?Ct(N.schema._def,oe):pr()}function qm(N){return{type:"string",enum:Array.from(N.values)}}var Gm=(N)=>{if("type"in N&&N.type==="string")return!1;return"allOf"in N};function Xm(N,oe){let Ie=[Ct(N.left._def,{...oe,currentPath:[...oe.currentPath,"allOf","0"]}),Ct(N.right._def,{...oe,currentPath:[...oe.currentPath,"allOf","1"]})].filter((De)=>!!De),Re=[];return Ie.forEach((De)=>{if(Gm(De))Re.push(...De.allOf);else{let Le=De;if("additionalProperties"in De&&De.additionalProperties===!1){let{additionalProperties:Ue,...Be}=De;Le=Be}Re.push(Le)}}),Re.length?{allOf:Re}:void 0}function Ym(N){let oe=typeof N.value;if(oe!=="bigint"&&oe!=="number"&&oe!=="boolean"&&oe!=="string")return{type:Array.isArray(N.value)?"array":"object"};return{type:oe==="bigint"?"integer":oe,const:N.value}}var Wi=void 0,yr={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(Wi===void 0)Wi=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return Wi},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Ef(N,oe){let Ie={type:"string"};if(N.checks)for(let Re of N.checks)switch(Re.kind){case"min":Ie.minLength=typeof Ie.minLength==="number"?Math.max(Ie.minLength,Re.value):Re.value;break;case"max":Ie.maxLength=typeof Ie.maxLength==="number"?Math.min(Ie.maxLength,Re.value):Re.value;break;case"email":switch(oe.emailStrategy){case"format:email":_r(Ie,"email",Re.message,oe);break;case"format:idn-email":_r(Ie,"idn-email",Re.message,oe);break;case"pattern:zod":cr(Ie,yr.email,Re.message,oe)}break;case"url":_r(Ie,"uri",Re.message,oe);break;case"uuid":_r(Ie,"uuid",Re.message,oe);break;case"regex":cr(Ie,Re.regex,Re.message,oe);break;case"cuid":cr(Ie,yr.cuid,Re.message,oe);break;case"cuid2":cr(Ie,yr.cuid2,Re.message,oe);break;case"startsWith":cr(Ie,RegExp(`^${Ki(Re.value,oe)}`),Re.message,oe);break;case"endsWith":cr(Ie,RegExp(`${Ki(Re.value,oe)}$`),Re.message,oe);break;case"datetime":_r(Ie,"date-time",Re.message,oe);break;case"date":_r(Ie,"date",Re.message,oe);break;case"time":_r(Ie,"time",Re.message,oe);break;case"duration":_r(Ie,"duration",Re.message,oe);break;case"length":Ie.minLength=typeof Ie.minLength==="number"?Math.max(Ie.minLength,Re.value):Re.value,Ie.maxLength=typeof Ie.maxLength==="number"?Math.min(Ie.maxLength,Re.value):Re.value;break;case"includes":cr(Ie,RegExp(Ki(Re.value,oe)),Re.message,oe);break;case"ip":if(Re.version!=="v6")_r(Ie,"ipv4",Re.message,oe);if(Re.version!=="v4")_r(Ie,"ipv6",Re.message,oe);break;case"base64url":cr(Ie,yr.base64url,Re.message,oe);break;case"jwt":cr(Ie,yr.jwt,Re.message,oe);break;case"cidr":if(Re.version!=="v6")cr(Ie,yr.ipv4Cidr,Re.message,oe);if(Re.version!=="v4")cr(Ie,yr.ipv6Cidr,Re.message,oe);break;case"emoji":cr(Ie,yr.emoji(),Re.message,oe);break;case"ulid":cr(Ie,yr.ulid,Re.message,oe);break;case"base64":switch(oe.base64Strategy){case"format:binary":_r(Ie,"binary",Re.message,oe);break;case"contentEncoding:base64":Ie.contentEncoding="base64";break;case"pattern:zod":cr(Ie,yr.base64,Re.message,oe)}break;case"nanoid":cr(Ie,yr.nanoid,Re.message,oe)}return Ie}function Ki(N,oe){return oe.patternStrategy==="escape"?eh(N):N}var Qm=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function eh(N){let oe="";for(let Ie=0;Ie<N.length;Ie++){if(!Qm.has(N[Ie]))oe+="\\";oe+=N[Ie]}return oe}function _r(N,oe,Ie,Re){if(N.format||N.anyOf?.some((De)=>De.format)){if(!N.anyOf)N.anyOf=[];if(N.format)N.anyOf.push({format:N.format}),delete N.format;N.anyOf.push({format:oe,...Ie&&Re.errorMessages&&{errorMessage:{format:Ie}}})}else N.format=oe}function cr(N,oe,Ie,Re){if(N.pattern||N.allOf?.some((De)=>De.pattern)){if(!N.allOf)N.allOf=[];if(N.pattern)N.allOf.push({pattern:N.pattern}),delete N.pattern;N.allOf.push({pattern:df(oe,Re),...Ie&&Re.errorMessages&&{errorMessage:{pattern:Ie}}})}else N.pattern=df(oe,Re)}function df(N,oe){if(!oe.applyRegexFlags||!N.flags)return N.source;let Ie={i:N.flags.includes("i"),m:N.flags.includes("m"),s:N.flags.includes("s")},Re=Ie.i?N.source.toLowerCase():N.source,De="",Le=!1,Ue=!1,Be=!1;for(let Xe=0;Xe<Re.length;Xe++){if(Le){De+=Re[Xe],Le=!1;continue}if(Ie.i){if(Ue){if(Re[Xe].match(/[a-z]/)){if(Be)De+=Re[Xe],De+=`${Re[Xe-2]}-${Re[Xe]}`.toUpperCase(),Be=!1;else if(Re[Xe+1]==="-"&&Re[Xe+2]?.match(/[a-z]/))De+=Re[Xe],Be=!0;else De+=`${Re[Xe]}${Re[Xe].toUpperCase()}`;continue}}else if(Re[Xe].match(/[a-z]/)){De+=`[${Re[Xe]}${Re[Xe].toUpperCase()}]`;continue}}if(Ie.m){if(Re[Xe]==="^"){De+=`(^|(?<=[\r
|
|
70
70
|
]))`;continue}else if(Re[Xe]==="$"){De+=`($|(?=[\r
|
|
71
71
|
]))`;continue}}if(Ie.s&&Re[Xe]==="."){De+=Ue?`${Re[Xe]}\r
|
|
72
72
|
`:`[${Re[Xe]}\r
|
|
73
|
-
]`;continue}if(De+=Re[Xe],Re[Xe]==="\\")Le=!0;else if(Ue&&Re[Xe]==="]")Ue=!1;else if(!Ue&&Re[Xe]==="[")Ue=!0}try{new RegExp(De)}catch{return console.warn(`Could not convert regex pattern at ${oe.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),N.source}return De}function Of(N,oe){let Ie={type:"object",additionalProperties:Ct(N.valueType._def,{...oe,currentPath:[...oe.currentPath,"additionalProperties"]})??oe.allowedAdditionalProperties};if(N.keyType?._def.typeName==="ZodString"&&N.keyType._def.checks?.length){let{type:Re,...De}=Ef(N.keyType._def,oe);return{...Ie,propertyNames:De}}else if(N.keyType?._def.typeName==="ZodEnum")return{...Ie,propertyNames:{enum:N.keyType._def.values}};else if(N.keyType?._def.typeName==="ZodBranded"&&N.keyType._def.type._def.typeName==="ZodString"&&N.keyType._def.type._def.checks?.length){let{type:Re,...De}=kf(N.keyType._def,oe);return{...Ie,propertyNames:De}}return Ie}function th(N,oe){if(oe.mapStrategy==="record")return Of(N,oe);return{type:"array",maxItems:125,items:{type:"array",items:[Ct(N.keyType._def,{...oe,currentPath:[...oe.currentPath,"items","items","0"]})||mr(),Ct(N.valueType._def,{...oe,currentPath:[...oe.currentPath,"items","items","1"]})||mr()],minItems:2,maxItems:2}}}function rh(N){let oe=N.values,Ie=Object.keys(N.values).filter((De)=>typeof oe[oe[De]]!=="number").map((De)=>oe[De]),Re=Array.from(new Set(Ie.map((De)=>typeof De)));return{type:Re.length===1?Re[0]==="string"?"string":"number":["string","number"],enum:Ie}}function nh(){return{not:mr()}}function oh(){return{type:"null"}}var Hi={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function ih(N,oe){let Ie=N.options instanceof Map?Array.from(N.options.values()):N.options;if(Ie.every((Re)=>(Re._def.typeName in Hi)&&(!Re._def.checks||!Re._def.checks.length))){let Re=Ie.reduce((De,Le)=>{let Ue=Hi[Le._def.typeName];return Ue&&!De.includes(Ue)?[...De,Ue]:De},[]);return{type:Re.length>1?Re:Re[0]}}else if(Ie.every((Re)=>Re._def.typeName==="ZodLiteral"&&!Re.description)){let Re=Ie.reduce((De,Le)=>{let Ue=typeof Le._def.value;switch(Ue){case"string":case"number":case"boolean":return[...De,Ue];case"bigint":return[...De,"integer"];case"object":if(Le._def.value===null)return[...De,"null"];default:return De}},[]);if(Re.length===Ie.length){let De=Re.filter((Le,Ue,Be)=>Be.indexOf(Le)===Ue);return{type:De.length>1?De:De[0],enum:Ie.reduce((Le,Ue)=>Le.includes(Ue._def.value)?Le:[...Le,Ue._def.value],[])}}}else if(Ie.every((Re)=>Re._def.typeName==="ZodEnum"))return{type:"string",enum:Ie.reduce((Re,De)=>[...Re,...De._def.values.filter((Le)=>!Re.includes(Le))],[])};return sh(N,oe)}var sh=(N,oe)=>{let Ie=(N.options instanceof Map?Array.from(N.options.values()):N.options).map((Re,De)=>Ct(Re._def,{...oe,currentPath:[...oe.currentPath,"anyOf",`${De}`]})).filter((Re)=>!!Re&&(!oe.strictUnions||typeof Re==="object"&&Object.keys(Re).length>0));return Ie.length?{anyOf:Ie}:void 0};function ch(N,oe){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(N.innerType._def.typeName)&&(!N.innerType._def.checks||!N.innerType._def.checks.length))return{type:[Hi[N.innerType._def.typeName],"null"]};let Ie=Ct(N.innerType._def,{...oe,currentPath:[...oe.currentPath,"anyOf","0"]});return Ie&&{anyOf:[Ie,{type:"null"}]}}function ah(N){let oe={type:"number"};if(!N.checks)return oe;for(let Ie of N.checks)switch(Ie.kind){case"int":oe.type="integer";break;case"min":if(Ie.inclusive)oe.minimum=Ie.value;else oe.exclusiveMinimum=Ie.value;break;case"max":if(Ie.inclusive)oe.maximum=Ie.value;else oe.exclusiveMaximum=Ie.value;break;case"multipleOf":oe.multipleOf=Ie.value}return oe}function uh(N,oe){let Ie={type:"object",properties:{}},Re=[],De=N.shape();for(let Ue in De){let Be=De[Ue];if(Be===void 0||Be._def===void 0)continue;let Xe=fh(Be),Ye=Ct(Be._def,{...oe,currentPath:[...oe.currentPath,"properties",Ue],propertyPath:[...oe.currentPath,"properties",Ue]});if(Ye===void 0)continue;if(Ie.properties[Ue]=Ye,!Xe)Re.push(Ue)}if(Re.length)Ie.required=Re;let Le=lh(N,oe);if(Le!==void 0)Ie.additionalProperties=Le;return Ie}function lh(N,oe){if(N.catchall._def.typeName!=="ZodNever")return Ct(N.catchall._def,{...oe,currentPath:[...oe.currentPath,"additionalProperties"]});switch(N.unknownKeys){case"passthrough":return oe.allowedAdditionalProperties;case"strict":return oe.rejectedAdditionalProperties;case"strip":return oe.removeAdditionalStrategy==="strict"?oe.allowedAdditionalProperties:oe.rejectedAdditionalProperties}}function fh(N){try{return N.isOptional()}catch{return!0}}var ph=(N,oe)=>{if(oe.currentPath.toString()===oe.propertyPath?.toString())return Ct(N.innerType._def,oe);let Ie=Ct(N.innerType._def,{...oe,currentPath:[...oe.currentPath,"anyOf","1"]});return Ie?{anyOf:[{not:mr()},Ie]}:mr()},dh=(N,oe)=>{if(oe.pipeStrategy==="input")return Ct(N.in._def,oe);else if(oe.pipeStrategy==="output")return Ct(N.out._def,oe);let Ie=Ct(N.in._def,{...oe,currentPath:[...oe.currentPath,"allOf","0"]});return{allOf:[Ie,Ct(N.out._def,{...oe,currentPath:[...oe.currentPath,"allOf",Ie?"1":"0"]})].filter((Re)=>Re!==void 0)}};function mh(N,oe){return Ct(N.type._def,oe)}function hh(N,oe){let Ie={type:"array",uniqueItems:!0,items:Ct(N.valueType._def,{...oe,currentPath:[...oe.currentPath,"items"]})};if(N.minSize)Ie.minItems=N.minSize.value;if(N.maxSize)Ie.maxItems=N.maxSize.value;return Ie}function gh(N,oe){if(N.rest)return{type:"array",minItems:N.items.length,items:N.items.map((Ie,Re)=>Ct(Ie._def,{...oe,currentPath:[...oe.currentPath,"items",`${Re}`]})).reduce((Ie,Re)=>Re===void 0?Ie:[...Ie,Re],[]),additionalItems:Ct(N.rest._def,{...oe,currentPath:[...oe.currentPath,"additionalItems"]})};else return{type:"array",minItems:N.items.length,maxItems:N.items.length,items:N.items.map((Ie,Re)=>Ct(Ie._def,{...oe,currentPath:[...oe.currentPath,"items",`${Re}`]})).reduce((Ie,Re)=>Re===void 0?Ie:[...Ie,Re],[])}}function yh(){return{not:mr()}}function _h(){return mr()}var vh=(N,oe)=>Ct(N.innerType._def,oe),bh=(N,oe,Ie)=>{switch(oe){case"ZodString":return Ef(N,Ie);case"ZodNumber":return ah(N);case"ZodObject":return uh(N,Ie);case"ZodBigInt":return Bm(N);case"ZodBoolean":return Jm();case"ZodDate":return Pf(N,Ie);case"ZodUndefined":return yh();case"ZodNull":return oh();case"ZodArray":return Um(N,Ie);case"ZodUnion":case"ZodDiscriminatedUnion":return ih(N,Ie);case"ZodIntersection":return Xm(N,Ie);case"ZodTuple":return gh(N,Ie);case"ZodRecord":return Of(N,Ie);case"ZodLiteral":return Ym(N);case"ZodEnum":return qm(N);case"ZodNativeEnum":return rh(N);case"ZodNullable":return ch(N,Ie);case"ZodOptional":return ph(N,Ie);case"ZodMap":return th(N,Ie);case"ZodSet":return hh(N,Ie);case"ZodLazy":return()=>N.getter()._def;case"ZodPromise":return mh(N,Ie);case"ZodNaN":case"ZodNever":return nh();case"ZodEffects":return Hm(N,Ie);case"ZodAny":return mr();case"ZodUnknown":return _h();case"ZodDefault":return Km(N,Ie);case"ZodBranded":return kf(N,Ie);case"ZodReadonly":return vh(N,Ie);case"ZodCatch":return Vm(N,Ie);case"ZodPipeline":return dh(N,Ie);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return((Re)=>{return})(oe)}},xh=(N,oe)=>{let Ie=0;for(;Ie<N.length&&Ie<oe.length;Ie++)if(N[Ie]!==oe[Ie])break;return[(N.length-Ie).toString(),...oe.slice(Ie)].join("/")};function Ct(N,oe,Ie=!1){let Re=oe.seen.get(N);if(oe.override){let Be=oe.override?.(N,oe,Re,Ie);if(Be!==jm)return Be}if(Re&&!Ie){let Be=wh(Re,oe);if(Be!==void 0)return Be}let De={def:N,path:oe.currentPath,jsonSchema:void 0};oe.seen.set(N,De);let Le=bh(N,N.typeName,oe),Ue=typeof Le==="function"?Ct(Le(),oe):Le;if(Ue)$h(N,oe,Ue);if(oe.postProcess){let Be=oe.postProcess(Ue,N,oe);return De.jsonSchema=Ue,Be}return De.jsonSchema=Ue,Ue}var wh=(N,oe)=>{switch(oe.$refStrategy){case"root":return{$ref:N.path.join("/")};case"relative":return{$ref:xh(oe.currentPath,N.path)};case"none":case"seen":if(N.path.length<oe.currentPath.length&&N.path.every((Ie,Re)=>oe.currentPath[Re]===Ie))return console.warn(`Recursive reference detected at ${oe.currentPath.join("/")}! Defaulting to any`),mr();return oe.$refStrategy==="seen"?mr():void 0}},$h=(N,oe,Ie)=>{if(N.description)Ie.description=N.description;return Ie},zh=(N)=>{let oe=Fm(N),Ie=oe.name!==void 0?[...oe.basePath,oe.definitionPath,oe.name]:oe.basePath;return{...oe,currentPath:Ie,propertyPath:void 0,seen:new Map(Object.entries(oe.definitions).map(([Re,De])=>[De._def,{def:De._def,path:[...oe.basePath,oe.definitionPath,Re],jsonSchema:void 0}]))}},Sh=(N,oe)=>{let Ie=zh(oe),Re=typeof oe==="object"&&oe.definitions?Object.entries(oe.definitions).reduce((Xe,[Ye,Qe])=>({...Xe,[Ye]:Ct(Qe._def,{...Ie,currentPath:[...Ie.basePath,Ie.definitionPath,Ye]},!0)??mr()}),{}):void 0,De=typeof oe==="string"?oe:oe?.nameStrategy==="title"?void 0:oe?.name,Le=Ct(N._def,De===void 0?Ie:{...Ie,currentPath:[...Ie.basePath,Ie.definitionPath,De]},!1)??mr(),Ue=typeof oe==="object"&&oe.name!==void 0&&oe.nameStrategy==="title"?oe.name:void 0;if(Ue!==void 0)Le.title=Ue;let Be=De===void 0?Re?{...Le,[Ie.definitionPath]:Re}:Le:{$ref:[...Ie.$refStrategy==="relative"?[]:Ie.basePath,Ie.definitionPath,De].join("/"),[Ie.definitionPath]:{...Re,[De]:Le}};return Be.$schema="http://json-schema.org/draft-07/schema#",Be},qi=Symbol.for("vercel.ai.schema");function a(N){let oe;return()=>{if(oe==null)oe=N();return oe}}function _o(N,{validate:oe}={}){return{[qi]:!0,_type:void 0,get jsonSchema(){if(typeof N==="function")N=N();return N},validate:oe}}function kh(N){return typeof N==="object"&&N!==null&&qi in N&&N[qi]===!0&&"jsonSchema"in N&&"validate"in N}function ze(N){return N==null?_o({type:"object",properties:{},additionalProperties:!1}):kh(N)?N:("~standard"in N)?N["~standard"].vendor==="zod"?s(N):Ph(N):N()}function Ph(N){return _o(()=>{if(!Eh(N))throw Error(`Standard schema vendor '${N["~standard"].vendor}' does not support JSON Schema conversion.`);return Yi(N["~standard"].jsonSchema.input({target:"draft-07"}))},{validate:async(oe)=>{let Ie=await N["~standard"].validate(oe);return"value"in Ie?{success:!0,value:Ie.value}:{success:!1,error:new be({value:oe,cause:Ie.issues})}}})}function Eh(N){return N["~standard"].jsonSchema!=null}function Oh(N,oe){let Ie=oe?.useReferences??!1;return _o(()=>Sh(N,{$refStrategy:Ie?"root":"none"}),{validate:async(Re)=>{let De=await N.safeParseAsync(Re);return De.success?{success:!0,value:De.data}:{success:!1,error:De.error}}})}function Th(N,oe){let Ie=oe?.useReferences??!1;return _o(()=>Yi(rt(N,{target:"draft-7",io:"input",reused:Ie?"ref":"inline"})),{validate:async(Re)=>{let De=await Ve(N,Re);return De.success?{success:!0,value:De.data}:{success:!1,error:De.error}}})}function Zh(N){return"_zod"in N}function s(N,oe){if(Zh(N))return Th(N,oe);else return Oh(N,oe)}async function x({value:N,schema:oe,context:Ie}){let Re=await q({value:N,schema:oe,context:Ie});if(!Re.success)throw be.wrap({value:N,cause:Re.error,context:Ie});return Re.value}async function q({value:N,schema:oe,context:Ie}){let Re=ze(oe);try{if(Re.validate==null)return{success:!0,value:N,rawValue:N};let De=await Re.validate(N);if(De.success)return{success:!0,value:De.value,rawValue:N};return{success:!1,error:be.wrap({value:N,cause:De.error,context:Ie}),rawValue:N}}catch(De){return{success:!1,error:be.wrap({value:N,cause:De,context:Ie}),rawValue:N}}}async function ut({text:N,schema:oe}){try{let Ie=Q(N);if(oe==null)return Ie;return await x({value:Ie,schema:oe})}catch(Ie){if(Ee.isInstance(Ie)||be.isInstance(Ie))throw Ie;throw new Ee({text:N,cause:Ie})}}async function J({text:N,schema:oe}){try{let Ie=Q(N);if(oe==null)return{success:!0,value:Ie,rawValue:Ie};return await q({value:Ie,schema:oe})}catch(Ie){return{success:!1,error:Ee.isInstance(Ie)?Ie:new Ee({text:N,cause:Ie}),rawValue:void 0}}}function dt({stream:N,schema:oe}){return N.pipeThrough(new TextDecoderStream).pipeThrough(new mo).pipeThrough(new TransformStream({async transform({data:Ie},Re){if(Ie==="[DONE]")return;Re.enqueue(await J({text:Ie,schema:oe}))}}))}async function h({provider:N,providerOptions:oe,schema:Ie}){if(oe?.[N]==null)return;let Re=await q({value:oe[N],schema:Ie});if(!Re.success)throw new b({argument:"providerOptions",message:`invalid ${N} provider options`,cause:Re.error});return Re.value}var Ah=()=>globalThis.fetch;function mf(N){return N.replace(/[\r\n]/g,"").replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}function Ih(N,oe){let Ie=new TextEncoder,Re=!1,De,Le=new Set;async function*Ue(){for(let Be of N){if(Re)return;let Xe=`--${oe}\r
|
|
73
|
+
]`;continue}if(De+=Re[Xe],Re[Xe]==="\\")Le=!0;else if(Ue&&Re[Xe]==="]")Ue=!1;else if(!Ue&&Re[Xe]==="[")Ue=!0}try{new RegExp(De)}catch{return console.warn(`Could not convert regex pattern at ${oe.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),N.source}return De}function Of(N,oe){let Ie={type:"object",additionalProperties:Ct(N.valueType._def,{...oe,currentPath:[...oe.currentPath,"additionalProperties"]})??oe.allowedAdditionalProperties};if(N.keyType?._def.typeName==="ZodString"&&N.keyType._def.checks?.length){let{type:Re,...De}=Ef(N.keyType._def,oe);return{...Ie,propertyNames:De}}else if(N.keyType?._def.typeName==="ZodEnum")return{...Ie,propertyNames:{enum:N.keyType._def.values}};else if(N.keyType?._def.typeName==="ZodBranded"&&N.keyType._def.type._def.typeName==="ZodString"&&N.keyType._def.type._def.checks?.length){let{type:Re,...De}=kf(N.keyType._def,oe);return{...Ie,propertyNames:De}}return Ie}function th(N,oe){if(oe.mapStrategy==="record")return Of(N,oe);return{type:"array",maxItems:125,items:{type:"array",items:[Ct(N.keyType._def,{...oe,currentPath:[...oe.currentPath,"items","items","0"]})||pr(),Ct(N.valueType._def,{...oe,currentPath:[...oe.currentPath,"items","items","1"]})||pr()],minItems:2,maxItems:2}}}function rh(N){let oe=N.values,Ie=Object.keys(N.values).filter((De)=>typeof oe[oe[De]]!=="number").map((De)=>oe[De]),Re=Array.from(new Set(Ie.map((De)=>typeof De)));return{type:Re.length===1?Re[0]==="string"?"string":"number":["string","number"],enum:Ie}}function nh(){return{not:pr()}}function oh(){return{type:"null"}}var Hi={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function ih(N,oe){let Ie=N.options instanceof Map?Array.from(N.options.values()):N.options;if(Ie.every((Re)=>(Re._def.typeName in Hi)&&(!Re._def.checks||!Re._def.checks.length))){let Re=Ie.reduce((De,Le)=>{let Ue=Hi[Le._def.typeName];return Ue&&!De.includes(Ue)?[...De,Ue]:De},[]);return{type:Re.length>1?Re:Re[0]}}else if(Ie.every((Re)=>Re._def.typeName==="ZodLiteral"&&!Re.description)){let Re=Ie.reduce((De,Le)=>{let Ue=typeof Le._def.value;switch(Ue){case"string":case"number":case"boolean":return[...De,Ue];case"bigint":return[...De,"integer"];case"object":if(Le._def.value===null)return[...De,"null"];default:return De}},[]);if(Re.length===Ie.length){let De=Re.filter((Le,Ue,Be)=>Be.indexOf(Le)===Ue);return{type:De.length>1?De:De[0],enum:Ie.reduce((Le,Ue)=>Le.includes(Ue._def.value)?Le:[...Le,Ue._def.value],[])}}}else if(Ie.every((Re)=>Re._def.typeName==="ZodEnum"))return{type:"string",enum:Ie.reduce((Re,De)=>[...Re,...De._def.values.filter((Le)=>!Re.includes(Le))],[])};return sh(N,oe)}var sh=(N,oe)=>{let Ie=(N.options instanceof Map?Array.from(N.options.values()):N.options).map((Re,De)=>Ct(Re._def,{...oe,currentPath:[...oe.currentPath,"anyOf",`${De}`]})).filter((Re)=>!!Re&&(!oe.strictUnions||typeof Re==="object"&&Object.keys(Re).length>0));return Ie.length?{anyOf:Ie}:void 0};function ch(N,oe){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(N.innerType._def.typeName)&&(!N.innerType._def.checks||!N.innerType._def.checks.length))return{type:[Hi[N.innerType._def.typeName],"null"]};let Ie=Ct(N.innerType._def,{...oe,currentPath:[...oe.currentPath,"anyOf","0"]});return Ie&&{anyOf:[Ie,{type:"null"}]}}function ah(N){let oe={type:"number"};if(!N.checks)return oe;for(let Ie of N.checks)switch(Ie.kind){case"int":oe.type="integer";break;case"min":if(Ie.inclusive)oe.minimum=Ie.value;else oe.exclusiveMinimum=Ie.value;break;case"max":if(Ie.inclusive)oe.maximum=Ie.value;else oe.exclusiveMaximum=Ie.value;break;case"multipleOf":oe.multipleOf=Ie.value}return oe}function uh(N,oe){let Ie={type:"object",properties:{}},Re=[],De=N.shape();for(let Ue in De){let Be=De[Ue];if(Be===void 0||Be._def===void 0)continue;let Xe=fh(Be),Ye=Ct(Be._def,{...oe,currentPath:[...oe.currentPath,"properties",Ue],propertyPath:[...oe.currentPath,"properties",Ue]});if(Ye===void 0)continue;if(Ie.properties[Ue]=Ye,!Xe)Re.push(Ue)}if(Re.length)Ie.required=Re;let Le=lh(N,oe);if(Le!==void 0)Ie.additionalProperties=Le;return Ie}function lh(N,oe){if(N.catchall._def.typeName!=="ZodNever")return Ct(N.catchall._def,{...oe,currentPath:[...oe.currentPath,"additionalProperties"]});switch(N.unknownKeys){case"passthrough":return oe.allowedAdditionalProperties;case"strict":return oe.rejectedAdditionalProperties;case"strip":return oe.removeAdditionalStrategy==="strict"?oe.allowedAdditionalProperties:oe.rejectedAdditionalProperties}}function fh(N){try{return N.isOptional()}catch{return!0}}var ph=(N,oe)=>{if(oe.currentPath.toString()===oe.propertyPath?.toString())return Ct(N.innerType._def,oe);let Ie=Ct(N.innerType._def,{...oe,currentPath:[...oe.currentPath,"anyOf","1"]});return Ie?{anyOf:[{not:pr()},Ie]}:pr()},dh=(N,oe)=>{if(oe.pipeStrategy==="input")return Ct(N.in._def,oe);else if(oe.pipeStrategy==="output")return Ct(N.out._def,oe);let Ie=Ct(N.in._def,{...oe,currentPath:[...oe.currentPath,"allOf","0"]});return{allOf:[Ie,Ct(N.out._def,{...oe,currentPath:[...oe.currentPath,"allOf",Ie?"1":"0"]})].filter((Re)=>Re!==void 0)}};function mh(N,oe){return Ct(N.type._def,oe)}function hh(N,oe){let Ie={type:"array",uniqueItems:!0,items:Ct(N.valueType._def,{...oe,currentPath:[...oe.currentPath,"items"]})};if(N.minSize)Ie.minItems=N.minSize.value;if(N.maxSize)Ie.maxItems=N.maxSize.value;return Ie}function gh(N,oe){if(N.rest)return{type:"array",minItems:N.items.length,items:N.items.map((Ie,Re)=>Ct(Ie._def,{...oe,currentPath:[...oe.currentPath,"items",`${Re}`]})).reduce((Ie,Re)=>Re===void 0?Ie:[...Ie,Re],[]),additionalItems:Ct(N.rest._def,{...oe,currentPath:[...oe.currentPath,"additionalItems"]})};else return{type:"array",minItems:N.items.length,maxItems:N.items.length,items:N.items.map((Ie,Re)=>Ct(Ie._def,{...oe,currentPath:[...oe.currentPath,"items",`${Re}`]})).reduce((Ie,Re)=>Re===void 0?Ie:[...Ie,Re],[])}}function yh(){return{not:pr()}}function _h(){return pr()}var vh=(N,oe)=>Ct(N.innerType._def,oe),bh=(N,oe,Ie)=>{switch(oe){case"ZodString":return Ef(N,Ie);case"ZodNumber":return ah(N);case"ZodObject":return uh(N,Ie);case"ZodBigInt":return Bm(N);case"ZodBoolean":return Jm();case"ZodDate":return Pf(N,Ie);case"ZodUndefined":return yh();case"ZodNull":return oh();case"ZodArray":return Um(N,Ie);case"ZodUnion":case"ZodDiscriminatedUnion":return ih(N,Ie);case"ZodIntersection":return Xm(N,Ie);case"ZodTuple":return gh(N,Ie);case"ZodRecord":return Of(N,Ie);case"ZodLiteral":return Ym(N);case"ZodEnum":return qm(N);case"ZodNativeEnum":return rh(N);case"ZodNullable":return ch(N,Ie);case"ZodOptional":return ph(N,Ie);case"ZodMap":return th(N,Ie);case"ZodSet":return hh(N,Ie);case"ZodLazy":return()=>N.getter()._def;case"ZodPromise":return mh(N,Ie);case"ZodNaN":case"ZodNever":return nh();case"ZodEffects":return Hm(N,Ie);case"ZodAny":return pr();case"ZodUnknown":return _h();case"ZodDefault":return Km(N,Ie);case"ZodBranded":return kf(N,Ie);case"ZodReadonly":return vh(N,Ie);case"ZodCatch":return Vm(N,Ie);case"ZodPipeline":return dh(N,Ie);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return((Re)=>{return})(oe)}},xh=(N,oe)=>{let Ie=0;for(;Ie<N.length&&Ie<oe.length;Ie++)if(N[Ie]!==oe[Ie])break;return[(N.length-Ie).toString(),...oe.slice(Ie)].join("/")};function Ct(N,oe,Ie=!1){let Re=oe.seen.get(N);if(oe.override){let Be=oe.override?.(N,oe,Re,Ie);if(Be!==jm)return Be}if(Re&&!Ie){let Be=wh(Re,oe);if(Be!==void 0)return Be}let De={def:N,path:oe.currentPath,jsonSchema:void 0};oe.seen.set(N,De);let Le=bh(N,N.typeName,oe),Ue=typeof Le==="function"?Ct(Le(),oe):Le;if(Ue)$h(N,oe,Ue);if(oe.postProcess){let Be=oe.postProcess(Ue,N,oe);return De.jsonSchema=Ue,Be}return De.jsonSchema=Ue,Ue}var wh=(N,oe)=>{switch(oe.$refStrategy){case"root":return{$ref:N.path.join("/")};case"relative":return{$ref:xh(oe.currentPath,N.path)};case"none":case"seen":if(N.path.length<oe.currentPath.length&&N.path.every((Ie,Re)=>oe.currentPath[Re]===Ie))return console.warn(`Recursive reference detected at ${oe.currentPath.join("/")}! Defaulting to any`),pr();return oe.$refStrategy==="seen"?pr():void 0}},$h=(N,oe,Ie)=>{if(N.description)Ie.description=N.description;return Ie},zh=(N)=>{let oe=Fm(N),Ie=oe.name!==void 0?[...oe.basePath,oe.definitionPath,oe.name]:oe.basePath;return{...oe,currentPath:Ie,propertyPath:void 0,seen:new Map(Object.entries(oe.definitions).map(([Re,De])=>[De._def,{def:De._def,path:[...oe.basePath,oe.definitionPath,Re],jsonSchema:void 0}]))}},Sh=(N,oe)=>{let Ie=zh(oe),Re=typeof oe==="object"&&oe.definitions?Object.entries(oe.definitions).reduce((Xe,[Ye,Qe])=>({...Xe,[Ye]:Ct(Qe._def,{...Ie,currentPath:[...Ie.basePath,Ie.definitionPath,Ye]},!0)??pr()}),{}):void 0,De=typeof oe==="string"?oe:oe?.nameStrategy==="title"?void 0:oe?.name,Le=Ct(N._def,De===void 0?Ie:{...Ie,currentPath:[...Ie.basePath,Ie.definitionPath,De]},!1)??pr(),Ue=typeof oe==="object"&&oe.name!==void 0&&oe.nameStrategy==="title"?oe.name:void 0;if(Ue!==void 0)Le.title=Ue;let Be=De===void 0?Re?{...Le,[Ie.definitionPath]:Re}:Le:{$ref:[...Ie.$refStrategy==="relative"?[]:Ie.basePath,Ie.definitionPath,De].join("/"),[Ie.definitionPath]:{...Re,[De]:Le}};return Be.$schema="http://json-schema.org/draft-07/schema#",Be},qi=Symbol.for("vercel.ai.schema");function a(N){let oe;return()=>{if(oe==null)oe=N();return oe}}function _o(N,{validate:oe}={}){return{[qi]:!0,_type:void 0,get jsonSchema(){if(typeof N==="function")N=N();return N},validate:oe}}function kh(N){return typeof N==="object"&&N!==null&&qi in N&&N[qi]===!0&&"jsonSchema"in N&&"validate"in N}function ze(N){return N==null?_o({type:"object",properties:{},additionalProperties:!1}):kh(N)?N:("~standard"in N)?N["~standard"].vendor==="zod"?s(N):Ph(N):N()}function Ph(N){return _o(()=>{if(!Eh(N))throw Error(`Standard schema vendor '${N["~standard"].vendor}' does not support JSON Schema conversion.`);return Yi(N["~standard"].jsonSchema.input({target:"draft-07"}))},{validate:async(oe)=>{let Ie=await N["~standard"].validate(oe);return"value"in Ie?{success:!0,value:Ie.value}:{success:!1,error:new be({value:oe,cause:Ie.issues})}}})}function Eh(N){return N["~standard"].jsonSchema!=null}function Oh(N,oe){let Ie=oe?.useReferences??!1;return _o(()=>Sh(N,{$refStrategy:Ie?"root":"none"}),{validate:async(Re)=>{let De=await N.safeParseAsync(Re);return De.success?{success:!0,value:De.data}:{success:!1,error:De.error}}})}function Th(N,oe){let Ie=oe?.useReferences??!1;return _o(()=>Yi(rt(N,{target:"draft-7",io:"input",reused:Ie?"ref":"inline"})),{validate:async(Re)=>{let De=await Ve(N,Re);return De.success?{success:!0,value:De.data}:{success:!1,error:De.error}}})}function Zh(N){return"_zod"in N}function s(N,oe){if(Zh(N))return Th(N,oe);else return Oh(N,oe)}async function x({value:N,schema:oe,context:Ie}){let Re=await q({value:N,schema:oe,context:Ie});if(!Re.success)throw be.wrap({value:N,cause:Re.error,context:Ie});return Re.value}async function q({value:N,schema:oe,context:Ie}){let Re=ze(oe);try{if(Re.validate==null)return{success:!0,value:N,rawValue:N};let De=await Re.validate(N);if(De.success)return{success:!0,value:De.value,rawValue:N};return{success:!1,error:be.wrap({value:N,cause:De.error,context:Ie}),rawValue:N}}catch(De){return{success:!1,error:be.wrap({value:N,cause:De,context:Ie}),rawValue:N}}}async function ut({text:N,schema:oe}){try{let Ie=Q(N);if(oe==null)return Ie;return await x({value:Ie,schema:oe})}catch(Ie){if(Ee.isInstance(Ie)||be.isInstance(Ie))throw Ie;throw new Ee({text:N,cause:Ie})}}async function J({text:N,schema:oe}){try{let Ie=Q(N);if(oe==null)return{success:!0,value:Ie,rawValue:Ie};return await q({value:Ie,schema:oe})}catch(Ie){return{success:!1,error:Ee.isInstance(Ie)?Ie:new Ee({text:N,cause:Ie}),rawValue:void 0}}}function dt({stream:N,schema:oe}){return N.pipeThrough(new TextDecoderStream).pipeThrough(new mo).pipeThrough(new TransformStream({async transform({data:Ie},Re){if(Ie==="[DONE]")return;Re.enqueue(await J({text:Ie,schema:oe}))}}))}async function h({provider:N,providerOptions:oe,schema:Ie}){if(oe?.[N]==null)return;let Re=await q({value:oe[N],schema:Ie});if(!Re.success)throw new b({argument:"providerOptions",message:`invalid ${N} provider options`,cause:Re.error});return Re.value}var Ah=()=>globalThis.fetch;function mf(N){return N.replace(/[\r\n]/g,"").replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}function Ih(N,oe){let Ie=new TextEncoder,Re=!1,De,Le=new Set;async function*Ue(){for(let Be of N){if(Re)return;let Xe=`--${oe}\r
|
|
74
74
|
Content-Disposition: form-data; name="${mf(Be.name)}"`;if(Be.type==="field"){yield Ie.encode(`${Xe}\r
|
|
75
75
|
\r
|
|
76
76
|
${Be.value}\r
|
|
@@ -79,5 +79,5 @@ Content-Type: ${Qe}\r
|
|
|
79
79
|
\r
|
|
80
80
|
`),Be.content instanceof Uint8Array)yield Be.content;else{let et=Be.content.getReader();De=et,Le.add(Be.content);let tt=!1;try{while(!0){let{done:ft,value:gt}=await et.read();if(ft||Re){tt=ft;break}yield gt}}finally{if(De=void 0,!tt)await et.cancel().catch(()=>{});et.releaseLock()}if(Re)return}yield Ie.encode(`\r
|
|
81
81
|
`)}yield Ie.encode(`--${oe}--\r
|
|
82
|
-
`)}return{stream:ae(Ue()),async dispose(Be){if(Re)return;Re=!0;let Xe=De;if(Xe!=null)await Xe.cancel(Be).catch(()=>{});for(let Ye of N)if(Ye.type==="file"&&!(Ye.content instanceof Uint8Array)&&!Le.has(Ye.content))await Ye.content.cancel(Be).catch(()=>{})}}}var rn=async({url:N,headers:oe={},parts:Ie,failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue=Ah()})=>{let Be=`ai-sdk-multipart-${C()}`,Xe=Object.fromEntries(Ie.map((Qe)=>[Qe.name,Qe.type==="field"?Qe.value:`<file:${Qe.filename??Qe.name}>`])),Ye=Ih(Ie,Be);try{let Qe=await Ue(N,{method:"POST",headers:F({...oe,"Content-Type":`multipart/form-data; boundary=${Be}`},`ai-sdk-provider-utils/${yo}`,ke()),body:Ye.stream,duplex:"half",signal:Le}),et=wr(Qe);if(!Qe.ok){let tt;try{tt=await Re({response:Qe,url:N,requestBodyValues:Xe})}catch(ft){if(Z(ft)||w.isInstance(ft))throw ft;throw new w({message:"Failed to process error response",cause:ft,statusCode:Qe.status,url:N,responseHeaders:et,requestBodyValues:Xe})}throw tt.value}try{return await De({response:Qe,url:N,requestBodyValues:Xe})}catch(tt){if(tt instanceof Error){if(Z(tt)||w.isInstance(tt))throw tt}throw new w({message:"Failed to process successful response",cause:tt,statusCode:Qe.status,url:N,responseHeaders:et,requestBodyValues:Xe})}}catch(Qe){throw await Ye.dispose(Qe),Nn({error:Qe,url:N,requestBodyValues:Xe})}},Ch=()=>globalThis.fetch,g=async({url:N,headers:oe,body:Ie,failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue})=>await ve({url:N,headers:{"Content-Type":"application/json",...oe},body:{content:JSON.stringify(Ie),values:Ie},failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue}),ne=async({url:N,headers:oe,formData:Ie,failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue})=>await ve({url:N,headers:oe,body:{content:Ie,values:Object.fromEntries(Ie.entries())},failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue}),ve=async({url:N,headers:oe={},body:Ie,successfulResponseHandler:Re,failedResponseHandler:De,abortSignal:Le,fetch:Ue=Ch()})=>{try{let Be=await Ue(N,{method:"POST",headers:F(oe,`ai-sdk-provider-utils/${yo}`,ke()),body:Ie.content,signal:Le}),Xe=wr(Be);if(!Be.ok){let Ye;try{Ye=await De({response:Be,url:N,requestBodyValues:Ie.values})}catch(Qe){if(Z(Qe)||w.isInstance(Qe))throw Qe;throw new w({message:"Failed to process error response",cause:Qe,statusCode:Be.status,url:N,responseHeaders:Xe,requestBodyValues:Ie.values})}throw Ye.value}try{return await Re({response:Be,url:N,requestBodyValues:Ie.values})}catch(Ye){if(Ye instanceof Error){if(Z(Ye)||w.isInstance(Ye))throw Ye}throw new w({message:"Failed to process successful response",cause:Ye,statusCode:Be.status,url:N,responseHeaders:Xe,requestBodyValues:Ie.values})}}catch(Be){throw Nn({error:Be,url:N,requestBodyValues:Ie.values})}};function Qi(N){return N}function re({id:N,inputSchema:oe}){return({execute:Ie,outputSchema:Re,needsApproval:De,toModelOutput:Le,onInputStart:Ue,onInputDelta:Be,onInputAvailable:Xe,...Ye})=>Qi({type:"provider",isProviderExecuted:!1,id:N,args:Ye,inputSchema:oe,outputSchema:Re,execute:Ie,needsApproval:De,toModelOutput:Le,onInputStart:Ue,onInputDelta:Be,onInputAvailable:Xe})}function Je({id:N,inputSchema:oe,outputSchema:Ie}){return({execute:Re,needsApproval:De,toModelOutput:Le,onInputStart:Ue,onInputDelta:Be,onInputAvailable:Xe,...Ye})=>Qi({type:"provider",isProviderExecuted:!1,id:N,args:Ye,inputSchema:oe,outputSchema:Ie,execute:Re,needsApproval:De,toModelOutput:Le,onInputStart:Ue,onInputDelta:Be,onInputAvailable:Xe})}function S({id:N,inputSchema:oe,outputSchema:Ie,supportsDeferredResults:Re}){return({onInputStart:De,onInputDelta:Le,onInputAvailable:Ue,...Be})=>Qi({type:"provider",isProviderExecuted:!0,id:N,args:Be,inputSchema:oe,outputSchema:Ie,onInputStart:De,onInputDelta:Le,onInputAvailable:Ue,supportsDeferredResults:Re})}async function _(N){if(typeof N==="function")N=N();return N}function O({part:N}){if(K(N.mediaType))return N.mediaType;if(N.data.type==="data"){let oe=Te({data:N.data.data,topLevelType:z(N.mediaType)});if(oe)return oe;throw new u({functionality:`file of media type "${N.mediaType}" must specify subtype since it could not be auto-detected`})}throw new u({functionality:`file of media type "${N.mediaType}" must specify subtype since it is not passed as inline bytes`})}function H({reference:N,provider:oe}){let Ie=N[oe];if(Ie!=null)return Ie;throw new ws({provider:oe,reference:N})}var on=({maxRetries:N=2,initialDelayInMs:oe=2000,backoffFactor:Ie=2,abortSignal:Re,shouldRetry:De,getDelayInMs:Le=({exponentialBackoffDelay:Be})=>Be,createRetryError:Ue=({message:Be})=>Error(Be)})=>async(Be)=>Tf(Be,{maxRetries:N,delayInMs:oe,backoffFactor:Ie,abortSignal:Re,shouldRetry:De,getDelayInMs:Le,createRetryError:Ue});async function Tf(N,{maxRetries:oe,delayInMs:Ie,backoffFactor:Re,abortSignal:De,shouldRetry:Le,getDelayInMs:Ue,createRetryError:Be},Xe=[]){try{return await N()}catch(Ye){if(Z(Ye))throw Ye;if(oe===0)throw Ye;let Qe=A(Ye),et=[...Xe,Ye],tt=et.length;if(tt>oe)throw Be({message:`Failed after ${tt} attempts. Last error: ${Qe}`,reason:"maxRetriesExceeded",errors:et});if(await Le(Ye)&&tt<=oe)return await Oe(Ue({error:Ye,exponentialBackoffDelay:Ie}),{abortSignal:De}),Tf(N,{maxRetries:oe,delayInMs:Re*Ie,backoffFactor:Re,abortSignal:De,shouldRetry:Le,getDelayInMs:Ue,createRetryError:Be},et);if(tt===1)throw Ye;throw Be({message:`Failed after ${tt} attempts with non-retryable error: '${Qe}'`,reason:"errorNotRetryable",errors:et})}}var Nh=new TextDecoder,Rh=67108864;function Zf({stream:N,url:oe,requestBodyValues:Ie,statusCode:Re,responseHeaders:De}){let Le=N.getReader(),Ue=!1,Be=()=>{if(!Ue)Le.releaseLock(),Ue=!0};return new ReadableStream({async pull(Xe){try{let{done:Ye,value:Qe}=await Le.read();if(Ye)Be(),Xe.close();else Xe.enqueue(Qe)}catch(Ye){if(Be(),Z(Ye)){Xe.error(Ye);return}Xe.error(Nn({error:new w({message:"Failed to process successful response",cause:Ye,statusCode:Re,url:oe,responseHeaders:De,requestBodyValues:Ie}),url:oe,requestBodyValues:Ie}))}},async cancel(Xe){try{await Le.cancel(Xe)}finally{Be()}}})}async function es({response:N,url:oe}){return Nh.decode(await vt({response:N,url:oe}))}var I=({errorSchema:N,errorToMessage:oe,isRetryable:Ie})=>async({response:Re,url:De,requestBodyValues:Le})=>{let Ue=await es({response:Re,url:De}),Be=wr(Re);if(Ue.trim()==="")return{responseHeaders:Be,value:new w({message:Re.statusText,url:De,requestBodyValues:Le,statusCode:Re.status,responseHeaders:Be,responseBody:Ue,isRetryable:Ie?.(Re)})};try{let Xe=await ut({text:Ue,schema:N});return{responseHeaders:Be,value:new w({message:oe(Xe),url:De,requestBodyValues:Le,statusCode:Re.status,responseHeaders:Be,responseBody:Ue,data:Xe,isRetryable:Ie?.(Re,Xe)})}}catch{return{responseHeaders:Be,value:new w({message:Re.statusText,url:De,requestBodyValues:Le,statusCode:Re.status,responseHeaders:Be,responseBody:Ue,isRetryable:Ie?.(Re)})}}},D=(N)=>async({response:oe,url:Ie,requestBodyValues:Re})=>{let De=wr(oe);if(oe.body==null)throw new Dn({});return{responseHeaders:De,value:dt({stream:Zf({stream:oe.body,url:Ie,requestBodyValues:Re,statusCode:oe.status,responseHeaders:De}),schema:N})}},p=(N)=>async({response:oe,url:Ie,requestBodyValues:Re})=>{let De=await es({response:oe,url:Ie}),Le=await J({text:De,schema:N}),Ue=wr(oe);if(!Le.success)throw new w({message:"Invalid JSON response",cause:Le.error,statusCode:oe.status,responseHeaders:Ue,responseBody:De,url:Ie,requestBodyValues:Re});return{responseHeaders:Ue,value:Le.value,rawValue:Le.rawValue}},_e=(N,{maxLineBytes:oe=Rh}={})=>{if(!Number.isSafeInteger(oe)||oe<=0)throw new b({argument:"maxLineBytes",message:"maxLineBytes must be a positive safe integer."});return async({response:Ie,url:Re})=>{let De=wr(Ie);if(Ie.body==null)throw new Dn({});return{responseHeaders:De,value:Dh({stream:Ie.body,schema:N,url:Re,maxLineBytes:oe})}}};async function*Dh({stream:N,schema:oe,url:Ie,maxLineBytes:Re}){let De=N.getReader(),Le=new TextDecoder,Ue="",Be=0,Xe=!1;try{while(!0){let{done:Qe,value:et}=await De.read();if(Qe){Xe=!0,Ue+=Le.decode();break}let tt=0;while(tt<et.length){let ft=et.indexOf(10,tt),gt=ft===-1?et.length:ft;if(Be+=gt-tt,Be>Re)throw new B({message:`JSON Lines response exceeded maximum line size of ${Re} bytes.`,url:Ie});let bt=ft===-1?gt:ft+1;if(Ue+=Le.decode(et.subarray(tt,bt),{stream:!0}),ft===-1)break;let St=Ue.slice(0,-1).replace(/\r$/,"");if(Ue="",Be=0,tt=bt,St.trim().length>0)yield await ut({text:St,schema:oe})}}let Ye=Ue.replace(/\r$/,"");if(Ye.trim().length>0)yield await ut({text:Ye,schema:oe})}finally{if(!Xe)await De.cancel().catch(()=>{});De.releaseLock()}}var pt=()=>async({response:N,url:oe,requestBodyValues:Ie})=>{let Re=wr(N);if(!N.body)throw new w({message:"Response body is empty",url:oe,requestBodyValues:Ie,statusCode:N.status,responseHeaders:Re,responseBody:void 0});try{let De=await N.arrayBuffer();return{responseHeaders:Re,value:new Uint8Array(De)}}catch(De){throw new w({message:"Failed to read response as array buffer",url:oe,requestBodyValues:Ie,statusCode:N.status,responseHeaders:Re,responseBody:void 0,cause:De})}},sn=()=>async({response:N,url:oe,requestBodyValues:Ie})=>{let Re=wr(N);if(N.body==null)throw new Dn({});return{responseHeaders:Re,value:Zf({stream:N.body,url:oe,requestBodyValues:Ie,statusCode:N.status,responseHeaders:Re})}},an=()=>async({response:N,url:oe,requestBodyValues:Ie})=>{let Re=wr(N),De=await es({response:N,url:oe});return{responseHeaders:Re,value:new w({message:N.statusText,url:oe,requestBodyValues:Ie,statusCode:N.status,responseHeaders:Re,responseBody:De})}};function go(N){if(N===null||N===void 0)return!0;let oe=typeof N;if(oe==="string"||oe==="number"||oe==="boolean")return!0;if(oe==="function"||oe==="symbol"||oe==="bigint")return!1;if(Array.isArray(N))return N.every(go);if(Object.getPrototypeOf(N)===Object.prototype)return Object.values(N).every(go);return!1}var Af="AI_SerializationError",If=`vercel.ai.error.${Af}`,Mh=Symbol.for(If),Lh=class extends m{constructor({message:N="Failed to serialize value.",cause:oe}={}){super({name:Af,message:N,cause:oe});this[Mh]=!0}static isInstance(N){return m.hasMarker(N,If)}};function E(N){let oe={};for(let[Ie,Re]of Object.entries(N.config))if(Ie==="headers"){let De=jh(Re);if(go(De))oe[Ie]=De}else if(go(Re))oe[Ie]=Re;return{modelId:N.modelId,config:oe}}function jh(N){let oe=N;if(typeof N==="function")oe=N();if(oe instanceof Promise)throw new Lh({message:"Cannot serialize asynchronous model options."});return oe}var ln="speech-stream.start",cn="speech-stream.text-delta",un="speech-stream.text-done";function dn(N){let oe;try{oe=Q(N)}catch{return}if(!L(oe))return;let Ie=oe;switch(Ie.type){case"stream-start":{if(!Array.isArray(Ie.warnings))return;let Re=Ie.warnings.filter((De)=>!Uh(De));return Re.every(Bh)?{...Ie,warnings:Re}:void 0}case"audio":return kr(Ie.audio)&&Jh(Ie.audioFormat)&&Ir(Ie.id,kr)&&Ir(Ie.providerMetadata,L)?Ie:void 0;case"finish":return Ir(Ie.usage,Vh)&&Ir(Ie.providerMetadata,L)?Ie:void 0;case"response-metadata":{if(!(Ir(Ie.modelId,kr)&&Ir(Ie.headers,L)))return;let Re=Ie.timestamp;if(Re==null)return{...Ie,timestamp:void 0};if(typeof Re!=="string")return;let De=new Date(Re);return Number.isNaN(De.getTime())?void 0:{...Ie,timestamp:De}}case"raw":return"rawValue"in Ie?Ie:void 0;case"error":return"error"in Ie?Ie:void 0;default:return}}function kr(N){return typeof N==="string"}function Ir(N,oe){return N===void 0||oe(N)}var Fh=new Set(["compatibility","deprecated","other","unsupported"]);function Uh(N){return L(N)&&kr(N.type)&&!Fh.has(N.type)}function Bh(N){if(!L(N))return!1;switch(N.type){case"compatibility":case"unsupported":return kr(N.feature)&&Ir(N.details,kr);case"deprecated":return kr(N.setting)&&kr(N.message);case"other":return kr(N.message);default:return!1}}function Jh(N){return L(N)&&kr(N.type)&&N.type.length>0&&Ir(N.rate,(oe)=>typeof oe==="number"&&Number.isFinite(oe)&&oe>0)}function Vh(N){return L(N)&&["inputCharacters","inputTokens","outputTokens"].every((oe)=>Ir(N[oe],(Ie)=>typeof Ie==="number"))}function Wh(N){if(typeof N!=="string")return!1;let oe=N.trimStart()[0];return oe==="{"||oe==="["}var Kh=class{constructor(N=""){this.structure={kind:"undetermined"},this.append(N)}get hasCompleteStructuredValue(){return this.structure.kind==="structured"&&this.structure.complete===!0}append(N){let oe=this.structure;for(let Ie of N){if(oe.kind==="undetermined"){if(/\s/.test(Ie))continue;if(Ie!=="{"&&Ie!=="["){oe={kind:"other"};continue}oe={kind:"structured",stack:[Ie],inString:!1,escaped:!1,complete:!1};continue}if(oe.kind!=="structured"||oe.complete)continue;if(oe.inString){if(oe.escaped)oe.escaped=!1;else if(Ie==="\\")oe.escaped=!0;else if(Ie==='"')oe.inString=!1;continue}if(Ie==='"')oe.inString=!0;else if(Ie==="{"||Ie==="[")oe.stack.push(Ie);else if(Ie==="}"||Ie==="]"){let Re=Ie==="}"?"{":"[";if(oe.stack.at(-1)!==Re){oe={kind:"other"};continue}if(oe.stack.pop(),oe.stack.length===0)oe.complete=!0}}this.structure=oe}},Ce=class{constructor(N,oe={}){this.toolCalls=[],this.toolCallsById=new Map,this.toolCallsByIndex=new Map,this.usedToolCallIds=new Set,this.nextGeneratedIdSuffixes=new Map,this.controller=N,this._generateId=oe.generateId??C,this.typeValidation=oe.typeValidation??"none",this.extractMetadata=oe.extractMetadata,this.buildToolCallProviderMetadata=oe.buildToolCallProviderMetadata}processDelta(N){let oe=N.function?.name,Ie=typeof oe==="string"&&oe.trim().length===0,Re=this.getNonBlankString(N.id),De=this.getNonBlankString(oe),Le=N.function?.arguments,{index:Ue}=N,Be=this.resolveToolCall({wireId:Re,index:Ue,name:De,hasExplicitCallStart:De!=null&&Wh(Le),hasEmptyArguments:Le==null||Le.trim().length===0});if(Be.kind==="ambiguous")return;let Xe;if(Be.kind==="new"){if(Ie)return;Xe=this.processNewToolCall(N,{wireId:Re,index:Ue,name:De})}else{if(Xe=Be.toolCall,Re!=null)this.associateWireId(Xe,Re);this.processExistingToolCall(Xe,N)}if(Ue!=null)this.associateIndex(Xe,Ue)}flush(){let N=this.toolCalls.every((oe)=>oe.index!=null)?[...this.toolCalls].sort((oe,Ie)=>oe.index-Ie.index||oe.sequence-Ie.sequence):this.toolCalls;for(let oe of N)if(!oe.hasFinished)this.finishToolCall(oe)}resolveToolCall({wireId:N,index:oe,name:Ie,hasExplicitCallStart:Re,hasEmptyArguments:De}){let Le=oe!=null?this.toolCallsByIndex.get(oe):void 0,Ue=this.filterToolCallsByName(Le,Ie);if(N!=null){let Xe=this.toolCallsById.get(N);if(Xe!=null){if(oe!=null){let Ye=Ue.filter((et)=>Xe.has(et)),Qe=this.resolveMatchingToolCall(Ye,Re);if(Qe.kind!=="new")return Qe;if(Ie!=null)return{kind:"new"};if(Le!=null)return{kind:"ambiguous"};return this.resolveMatchingToolCall([...Xe],!1)}if(Ie!=null){let Ye=[...Xe].filter((Qe)=>Qe.function.name===Ie);return this.resolveMatchingToolCall(Ye,Re)}return this.resolveMatchingToolCall([...Xe],!1)}if(Ue.length>0)return Re?{kind:"new"}:this.resolveMatchingToolCall(Ue,Ie!=null&&De);return{kind:"new"}}if(Le!=null)return this.resolveMatchingToolCall(Ue,Re);if(Ie!=null)return{kind:"new"};let Be=this.toolCalls.filter((Xe)=>!Xe.hasFinished);return this.resolveMatchingToolCall(Be,!1)}filterToolCallsByName(N,oe){if(N==null)return[];return[...N].filter((Ie)=>oe==null||Ie.function.name===oe)}resolveMatchingToolCall(N,oe){if(N.length===0)return{kind:"new"};let Ie=N.filter((Re)=>!Re.argumentState.hasCompleteStructuredValue);if(!oe&&N.length===1)return{kind:"existing",toolCall:N[0]};if(Ie.length===1)return{kind:"existing",toolCall:Ie[0]};if(Ie.length>1||!oe)return{kind:"ambiguous"};return{kind:"new"}}processNewToolCall(N,{wireId:oe,index:Ie,name:Re}){if(this.typeValidation==="required"){if(N.type!=="function")throw new P({data:N,message:"Expected 'function' type."})}else if(this.typeValidation==="if-present"){if(N.type!=null&&N.type!=="function")throw new P({data:N,message:"Expected 'function' type."})}if(Re==null)throw new P({data:N,message:"Expected 'function.name' to be a string."});let De=this.createToolCallId(oe);this.controller.enqueue({type:"tool-input-start",id:De,toolName:Re});let Le=this.extractMetadata?.(N),Ue=N.function?.arguments??"",Be={id:De,index:Ie??void 0,sequence:this.toolCalls.length,type:"function",function:{name:Re,arguments:Ue},argumentState:new Kh(Ue),hasFinished:!1,metadata:Le};if(this.toolCalls.push(Be),oe!=null)this.associateWireId(Be,oe);if(Be.function.arguments.length>0)this.controller.enqueue({type:"tool-input-delta",id:Be.id,delta:Be.function.arguments});return Be}associateWireId(N,oe){let Ie=this.toolCallsById.get(oe);if(Ie==null)Ie=new Set,this.toolCallsById.set(oe,Ie);Ie.add(N)}associateIndex(N,oe){let Ie=this.toolCallsByIndex.get(oe);if(Ie==null)Ie=new Set,this.toolCallsByIndex.set(oe,Ie);Ie.add(N)}createToolCallId(N){if(N!=null&&!this.usedToolCallIds.has(N))return this.usedToolCallIds.add(N),N;let oe=this.getNonBlankString(this._generateId())??"tool-call";if(!this.usedToolCallIds.has(oe))return this.usedToolCallIds.add(oe),oe;let Ie=this.nextGeneratedIdSuffixes.get(oe)??1,Re=Ie+this.usedToolCallIds.size;for(let De=Ie;De<=Re;De++){let Le=`${oe}-${De}`;if(!this.usedToolCallIds.has(Le))return this.usedToolCallIds.add(Le),this.nextGeneratedIdSuffixes.set(oe,De+1),Le}throw Error("Failed to create a unique tool call ID.")}getNonBlankString(N){return N!=null&&N.trim().length>0?N:void 0}processExistingToolCall(N,oe){if(N.hasFinished)return;if(oe.function?.arguments!=null)N.argumentState.append(oe.function.arguments),N.function.arguments+=oe.function.arguments,this.controller.enqueue({type:"tool-input-delta",id:N.id,delta:oe.function.arguments})}finishToolCall(N){this.controller.enqueue({type:"tool-input-end",id:N.id});let oe=this.buildToolCallProviderMetadata?.(N.metadata);this.controller.enqueue({type:"tool-call",toolCallId:N.id,toolName:N.function.name,input:N.function.arguments,...oe?{providerMetadata:oe}:{}}),N.hasFinished=!0}};var pn="transcription-stream.start",mn="transcription-stream.audio-done";function fn(N){let oe;try{oe=Q(N)}catch{return}if(oe==null||typeof oe!=="object"||Array.isArray(oe))return;let Ie=oe;switch(Ie.type){case"stream-start":return Array.isArray(Ie.warnings)&&Ie.warnings.every(Hh)?Ie:void 0;case"transcript-delta":return xr(Ie.delta)&&sr(Ie.id,xr)&&sr(Ie.providerMetadata,L)?Ie:void 0;case"transcript-partial":return xr(Ie.text)&&sr(Ie.id,xr)&&sr(Ie.startSecond,Ar)&&sr(Ie.durationInSeconds,Ar)&&sr(Ie.channelIndex,Ar)&&sr(Ie.providerMetadata,L)?Ie:void 0;case"transcript-final":return xr(Ie.text)&&sr(Ie.id,xr)&&sr(Ie.startSecond,Ar)&&sr(Ie.endSecond,Ar)&&sr(Ie.channelIndex,Ar)&&sr(Ie.providerMetadata,L)?Ie:void 0;case"finish":return xr(Ie.text)&&Array.isArray(Ie.segments)&&Ie.segments.every(qh)&&sr(Ie.language,xr)&&sr(Ie.durationInSeconds,Ar)&&sr(Ie.usage,L)&&sr(Ie.providerMetadata,L)?Ie:void 0;case"response-metadata":{if(!(sr(Ie.modelId,xr)&&sr(Ie.headers,L)))return;let Re=Ie.timestamp;if(Re==null)return{...Ie,timestamp:void 0};if(typeof Re!=="string")return;let De=new Date(Re);return Number.isNaN(De.getTime())?void 0:{...Ie,timestamp:De}}case"raw":return"rawValue"in Ie?Ie:void 0;case"error":return"error"in Ie?Ie:void 0;default:return}}function xr(N){return typeof N==="string"}function Ar(N){return typeof N==="number"}function sr(N,oe){return N===void 0||oe(N)}function Hh(N){return L(N)&&xr(N.type)}function qh(N){return L(N)&&xr(N.text)&&Ar(N.startSecond)&&Ar(N.endSecond)}function mt(N){if(N?.trim()==="")throw new b({argument:"baseURL",message:"baseURL must be a non-empty string."});return N}function Y(N){return N?.replace(/\/$/,"")}function qt(N){return N!=null&&typeof N.execute==="function"}function Gh(N){return N!=null&&typeof N[Symbol.asyncIterator]==="function"}async function*hn({tool:N,input:oe,options:Ie}){let Re=N.execute(oe,Ie);if(Gh(Re)){let De;for await(let Le of Re)De=Le,yield{type:"preliminary",output:Le};yield{type:"final",output:De}}else yield{type:"final",output:await Re}}function Ke(N,oe){return Object.defineProperty({...N},"experimental_toolCaller",{value:oe})}function kt(N){return N?.experimental_toolCaller}
|
|
83
|
-
export{m,
|
|
82
|
+
`)}return{stream:ae(Ue()),async dispose(Be){if(Re)return;Re=!0;let Xe=De;if(Xe!=null)await Xe.cancel(Be).catch(()=>{});for(let Ye of N)if(Ye.type==="file"&&!(Ye.content instanceof Uint8Array)&&!Le.has(Ye.content))await Ye.content.cancel(Be).catch(()=>{})}}}var sn=async({url:N,headers:oe={},parts:Ie,failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue=Ah()})=>{let Be=`ai-sdk-multipart-${C()}`,Xe=Object.fromEntries(Ie.map((Qe)=>[Qe.name,Qe.type==="field"?Qe.value:`<file:${Qe.filename??Qe.name}>`])),Ye=Ih(Ie,Be);try{let Qe=await Ue(N,{method:"POST",headers:F({...oe,"Content-Type":`multipart/form-data; boundary=${Be}`},`ai-sdk-provider-utils/${yo}`,ke()),body:Ye.stream,duplex:"half",signal:Le}),et=br(Qe);if(!Qe.ok){let tt;try{tt=await Re({response:Qe,url:N,requestBodyValues:Xe})}catch(ft){if(Z(ft)||w.isInstance(ft))throw ft;throw new w({message:"Failed to process error response",cause:ft,statusCode:Qe.status,url:N,responseHeaders:et,requestBodyValues:Xe})}throw tt.value}try{return await De({response:Qe,url:N,requestBodyValues:Xe})}catch(tt){if(tt instanceof Error){if(Z(tt)||w.isInstance(tt))throw tt}throw new w({message:"Failed to process successful response",cause:tt,statusCode:Qe.status,url:N,responseHeaders:et,requestBodyValues:Xe})}}catch(Qe){throw await Ye.dispose(Qe),Nn({error:Qe,url:N,requestBodyValues:Xe})}},Ch=()=>globalThis.fetch,g=async({url:N,headers:oe,body:Ie,failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue})=>await ve({url:N,headers:{"Content-Type":"application/json",...oe},body:{content:JSON.stringify(Ie),values:Ie},failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue}),ne=async({url:N,headers:oe,formData:Ie,failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue})=>await ve({url:N,headers:oe,body:{content:Ie,values:Object.fromEntries(Ie.entries())},failedResponseHandler:Re,successfulResponseHandler:De,abortSignal:Le,fetch:Ue}),ve=async({url:N,headers:oe={},body:Ie,successfulResponseHandler:Re,failedResponseHandler:De,abortSignal:Le,fetch:Ue=Ch()})=>{try{let Be=await Ue(N,{method:"POST",headers:F(oe,`ai-sdk-provider-utils/${yo}`,ke()),body:Ie.content,signal:Le}),Xe=br(Be);if(!Be.ok){let Ye;try{Ye=await De({response:Be,url:N,requestBodyValues:Ie.values})}catch(Qe){if(Z(Qe)||w.isInstance(Qe))throw Qe;throw new w({message:"Failed to process error response",cause:Qe,statusCode:Be.status,url:N,responseHeaders:Xe,requestBodyValues:Ie.values})}throw Ye.value}try{return await Re({response:Be,url:N,requestBodyValues:Ie.values})}catch(Ye){if(Ye instanceof Error){if(Z(Ye)||w.isInstance(Ye))throw Ye}throw new w({message:"Failed to process successful response",cause:Ye,statusCode:Be.status,url:N,responseHeaders:Xe,requestBodyValues:Ie.values})}}catch(Be){throw Nn({error:Be,url:N,requestBodyValues:Ie.values})}};function Qi(N){return N}function re({id:N,inputSchema:oe}){return({execute:Ie,outputSchema:Re,needsApproval:De,toModelOutput:Le,onInputStart:Ue,onInputDelta:Be,onInputAvailable:Xe,...Ye})=>Qi({type:"provider",isProviderExecuted:!1,id:N,args:Ye,inputSchema:oe,outputSchema:Re,execute:Ie,needsApproval:De,toModelOutput:Le,onInputStart:Ue,onInputDelta:Be,onInputAvailable:Xe})}function Je({id:N,inputSchema:oe,outputSchema:Ie}){return({execute:Re,needsApproval:De,toModelOutput:Le,onInputStart:Ue,onInputDelta:Be,onInputAvailable:Xe,...Ye})=>Qi({type:"provider",isProviderExecuted:!1,id:N,args:Ye,inputSchema:oe,outputSchema:Ie,execute:Re,needsApproval:De,toModelOutput:Le,onInputStart:Ue,onInputDelta:Be,onInputAvailable:Xe})}function S({id:N,inputSchema:oe,outputSchema:Ie,supportsDeferredResults:Re}){return({onInputStart:De,onInputDelta:Le,onInputAvailable:Ue,...Be})=>Qi({type:"provider",isProviderExecuted:!0,id:N,args:Be,inputSchema:oe,outputSchema:Ie,onInputStart:De,onInputDelta:Le,onInputAvailable:Ue,supportsDeferredResults:Re})}async function _(N){if(typeof N==="function")N=N();return N}function O({part:N}){if(K(N.mediaType))return N.mediaType;if(N.data.type==="data"){let oe=Te({data:N.data.data,topLevelType:z(N.mediaType)});if(oe)return oe;throw new u({functionality:`file of media type "${N.mediaType}" must specify subtype since it could not be auto-detected`})}throw new u({functionality:`file of media type "${N.mediaType}" must specify subtype since it is not passed as inline bytes`})}function H({reference:N,provider:oe}){let Ie=N[oe];if(Ie!=null)return Ie;throw new ws({provider:oe,reference:N})}var an=({maxRetries:N=2,initialDelayInMs:oe=2000,backoffFactor:Ie=2,abortSignal:Re,shouldRetry:De,getDelayInMs:Le=({exponentialBackoffDelay:Be})=>Be,createRetryError:Ue=({message:Be})=>Error(Be)})=>async(Be)=>Tf(Be,{maxRetries:N,delayInMs:oe,backoffFactor:Ie,abortSignal:Re,shouldRetry:De,getDelayInMs:Le,createRetryError:Ue});async function Tf(N,{maxRetries:oe,delayInMs:Ie,backoffFactor:Re,abortSignal:De,shouldRetry:Le,getDelayInMs:Ue,createRetryError:Be},Xe=[]){try{return await N()}catch(Ye){if(Z(Ye))throw Ye;if(oe===0)throw Ye;let Qe=A(Ye),et=[...Xe,Ye],tt=et.length;if(tt>oe)throw Be({message:`Failed after ${tt} attempts. Last error: ${Qe}`,reason:"maxRetriesExceeded",errors:et});if(await Le(Ye)&&tt<=oe)return await Oe(Ue({error:Ye,exponentialBackoffDelay:Ie}),{abortSignal:De}),Tf(N,{maxRetries:oe,delayInMs:Re*Ie,backoffFactor:Re,abortSignal:De,shouldRetry:Le,getDelayInMs:Ue,createRetryError:Be},et);if(tt===1)throw Ye;throw Be({message:`Failed after ${tt} attempts with non-retryable error: '${Qe}'`,reason:"errorNotRetryable",errors:et})}}var Nh=new TextDecoder,Rh=67108864;function Zf({stream:N,url:oe,requestBodyValues:Ie,statusCode:Re,responseHeaders:De}){let Le=N.getReader(),Ue=!1,Be=()=>{if(!Ue)Le.releaseLock(),Ue=!0};return new ReadableStream({async pull(Xe){try{let{done:Ye,value:Qe}=await Le.read();if(Ye)Be(),Xe.close();else Xe.enqueue(Qe)}catch(Ye){if(Be(),Z(Ye)){Xe.error(Ye);return}Xe.error(Nn({error:new w({message:"Failed to process successful response",cause:Ye,statusCode:Re,url:oe,responseHeaders:De,requestBodyValues:Ie}),url:oe,requestBodyValues:Ie}))}},async cancel(Xe){try{await Le.cancel(Xe)}finally{Be()}}})}async function es({response:N,url:oe}){return Nh.decode(await vt({response:N,url:oe}))}var I=({errorSchema:N,errorToMessage:oe,isRetryable:Ie})=>async({response:Re,url:De,requestBodyValues:Le})=>{let Ue=await es({response:Re,url:De}),Be=br(Re);if(Ue.trim()==="")return{responseHeaders:Be,value:new w({message:Re.statusText,url:De,requestBodyValues:Le,statusCode:Re.status,responseHeaders:Be,responseBody:Ue,isRetryable:Ie?.(Re)})};try{let Xe=await ut({text:Ue,schema:N});return{responseHeaders:Be,value:new w({message:oe(Xe),url:De,requestBodyValues:Le,statusCode:Re.status,responseHeaders:Be,responseBody:Ue,data:Xe,isRetryable:Ie?.(Re,Xe)})}}catch{return{responseHeaders:Be,value:new w({message:Re.statusText,url:De,requestBodyValues:Le,statusCode:Re.status,responseHeaders:Be,responseBody:Ue,isRetryable:Ie?.(Re)})}}},D=(N)=>async({response:oe,url:Ie,requestBodyValues:Re})=>{let De=br(oe);if(oe.body==null)throw new Dn({});return{responseHeaders:De,value:dt({stream:Zf({stream:oe.body,url:Ie,requestBodyValues:Re,statusCode:oe.status,responseHeaders:De}),schema:N})}},p=(N)=>async({response:oe,url:Ie,requestBodyValues:Re})=>{let De=await es({response:oe,url:Ie}),Le=await J({text:De,schema:N}),Ue=br(oe);if(!Le.success)throw new w({message:"Invalid JSON response",cause:Le.error,statusCode:oe.status,responseHeaders:Ue,responseBody:De,url:Ie,requestBodyValues:Re});return{responseHeaders:Ue,value:Le.value,rawValue:Le.rawValue}},_e=(N,{maxLineBytes:oe=Rh}={})=>{if(!Number.isSafeInteger(oe)||oe<=0)throw new b({argument:"maxLineBytes",message:"maxLineBytes must be a positive safe integer."});return async({response:Ie,url:Re})=>{let De=br(Ie);if(Ie.body==null)throw new Dn({});return{responseHeaders:De,value:Dh({stream:Ie.body,schema:N,url:Re,maxLineBytes:oe})}}};async function*Dh({stream:N,schema:oe,url:Ie,maxLineBytes:Re}){let De=N.getReader(),Le=new TextDecoder,Ue="",Be=0,Xe=!1;try{while(!0){let{done:Qe,value:et}=await De.read();if(Qe){Xe=!0,Ue+=Le.decode();break}let tt=0;while(tt<et.length){let ft=et.indexOf(10,tt),gt=ft===-1?et.length:ft;if(Be+=gt-tt,Be>Re)throw new B({message:`JSON Lines response exceeded maximum line size of ${Re} bytes.`,url:Ie});let bt=ft===-1?gt:ft+1;if(Ue+=Le.decode(et.subarray(tt,bt),{stream:!0}),ft===-1)break;let St=Ue.slice(0,-1).replace(/\r$/,"");if(Ue="",Be=0,tt=bt,St.trim().length>0)yield await ut({text:St,schema:oe})}}let Ye=Ue.replace(/\r$/,"");if(Ye.trim().length>0)yield await ut({text:Ye,schema:oe})}finally{if(!Xe)await De.cancel().catch(()=>{});De.releaseLock()}}var pt=()=>async({response:N,url:oe,requestBodyValues:Ie})=>{let Re=br(N);if(!N.body)throw new w({message:"Response body is empty",url:oe,requestBodyValues:Ie,statusCode:N.status,responseHeaders:Re,responseBody:void 0});try{let De=await N.arrayBuffer();return{responseHeaders:Re,value:new Uint8Array(De)}}catch(De){throw new w({message:"Failed to read response as array buffer",url:oe,requestBodyValues:Ie,statusCode:N.status,responseHeaders:Re,responseBody:void 0,cause:De})}},ln=()=>async({response:N,url:oe,requestBodyValues:Ie})=>{let Re=br(N);if(N.body==null)throw new Dn({});return{responseHeaders:Re,value:Zf({stream:N.body,url:oe,requestBodyValues:Ie,statusCode:N.status,responseHeaders:Re})}},cn=()=>async({response:N,url:oe,requestBodyValues:Ie})=>{let Re=br(N),De=await es({response:N,url:oe});return{responseHeaders:Re,value:new w({message:N.statusText,url:oe,requestBodyValues:Ie,statusCode:N.status,responseHeaders:Re,responseBody:De})}};function go(N){if(N===null||N===void 0)return!0;let oe=typeof N;if(oe==="string"||oe==="number"||oe==="boolean")return!0;if(oe==="function"||oe==="symbol"||oe==="bigint")return!1;if(Array.isArray(N))return N.every(go);if(Object.getPrototypeOf(N)===Object.prototype)return Object.values(N).every(go);return!1}var Af="AI_SerializationError",If=`vercel.ai.error.${Af}`,Mh=Symbol.for(If),Lh=class extends m{constructor({message:N="Failed to serialize value.",cause:oe}={}){super({name:Af,message:N,cause:oe});this[Mh]=!0}static isInstance(N){return m.hasMarker(N,If)}};function E(N){let oe={};for(let[Ie,Re]of Object.entries(N.config))if(Ie==="headers"){let De=jh(Re);if(go(De))oe[Ie]=De}else if(go(Re))oe[Ie]=Re;return{modelId:N.modelId,config:oe}}function jh(N){let oe=N;if(typeof N==="function")oe=N();if(oe instanceof Promise)throw new Lh({message:"Cannot serialize asynchronous model options."});return oe}var un="speech-stream.start",dn="speech-stream.text-delta",pn="speech-stream.text-done";function mn(N){let oe;try{oe=Q(N)}catch{return}if(!L(oe))return;let Ie=oe;switch(Ie.type){case"stream-start":{if(!Array.isArray(Ie.warnings))return;let Re=Ie.warnings.filter((De)=>!Uh(De));return Re.every(Bh)?{...Ie,warnings:Re}:void 0}case"audio":return zr(Ie.audio)&&Jh(Ie.audioFormat)&&Zr(Ie.id,zr)&&Zr(Ie.providerMetadata,L)?Ie:void 0;case"finish":return Zr(Ie.usage,Vh)&&Zr(Ie.providerMetadata,L)?Ie:void 0;case"response-metadata":{if(!(Zr(Ie.modelId,zr)&&Zr(Ie.headers,L)))return;let Re=Ie.timestamp;if(Re==null)return{...Ie,timestamp:void 0};if(typeof Re!=="string")return;let De=new Date(Re);return Number.isNaN(De.getTime())?void 0:{...Ie,timestamp:De}}case"raw":return"rawValue"in Ie?Ie:void 0;case"error":return"error"in Ie?Ie:void 0;default:return}}function zr(N){return typeof N==="string"}function Zr(N,oe){return N===void 0||oe(N)}var Fh=new Set(["compatibility","deprecated","other","unsupported"]);function Uh(N){return L(N)&&zr(N.type)&&!Fh.has(N.type)}function Bh(N){if(!L(N))return!1;switch(N.type){case"compatibility":case"unsupported":return zr(N.feature)&&Zr(N.details,zr);case"deprecated":return zr(N.setting)&&zr(N.message);case"other":return zr(N.message);default:return!1}}function Jh(N){return L(N)&&zr(N.type)&&N.type.length>0&&Zr(N.rate,(oe)=>typeof oe==="number"&&Number.isFinite(oe)&&oe>0)}function Vh(N){return L(N)&&["inputCharacters","inputTokens","outputTokens"].every((oe)=>Zr(N[oe],(Ie)=>typeof Ie==="number"))}function Wh(N){if(typeof N!=="string")return!1;let oe=N.trimStart()[0];return oe==="{"||oe==="["}var Kh=class{constructor(N=""){this.structure={kind:"undetermined"},this.append(N)}get hasCompleteStructuredValue(){return this.structure.kind==="structured"&&this.structure.complete===!0}append(N){let oe=this.structure;for(let Ie of N){if(oe.kind==="undetermined"){if(/\s/.test(Ie))continue;if(Ie!=="{"&&Ie!=="["){oe={kind:"other"};continue}oe={kind:"structured",stack:[Ie],inString:!1,escaped:!1,complete:!1};continue}if(oe.kind!=="structured"||oe.complete)continue;if(oe.inString){if(oe.escaped)oe.escaped=!1;else if(Ie==="\\")oe.escaped=!0;else if(Ie==='"')oe.inString=!1;continue}if(Ie==='"')oe.inString=!0;else if(Ie==="{"||Ie==="[")oe.stack.push(Ie);else if(Ie==="}"||Ie==="]"){let Re=Ie==="}"?"{":"[";if(oe.stack.at(-1)!==Re){oe={kind:"other"};continue}if(oe.stack.pop(),oe.stack.length===0)oe.complete=!0}}this.structure=oe}},Ce=class{constructor(N,oe={}){this.toolCalls=[],this.toolCallsById=new Map,this.toolCallsByIndex=new Map,this.usedToolCallIds=new Set,this.nextGeneratedIdSuffixes=new Map,this.controller=N,this._generateId=oe.generateId??C,this.typeValidation=oe.typeValidation??"none",this.extractMetadata=oe.extractMetadata,this.buildToolCallProviderMetadata=oe.buildToolCallProviderMetadata}processDelta(N){let oe=N.function?.name,Ie=typeof oe==="string"&&oe.trim().length===0,Re=this.getNonBlankString(N.id),De=this.getNonBlankString(oe),Le=N.function?.arguments,{index:Ue}=N,Be=this.resolveToolCall({wireId:Re,index:Ue,name:De,hasExplicitCallStart:De!=null&&Wh(Le),hasEmptyArguments:Le==null||Le.trim().length===0});if(Be.kind==="ambiguous")return;let Xe;if(Be.kind==="new"){if(Ie)return;Xe=this.processNewToolCall(N,{wireId:Re,index:Ue,name:De})}else{if(Xe=Be.toolCall,Re!=null)this.associateWireId(Xe,Re);this.processExistingToolCall(Xe,N)}if(Ue!=null)this.associateIndex(Xe,Ue)}flush(){let N=this.toolCalls.every((oe)=>oe.index!=null)?[...this.toolCalls].sort((oe,Ie)=>oe.index-Ie.index||oe.sequence-Ie.sequence):this.toolCalls;for(let oe of N)if(!oe.hasFinished)this.finishToolCall(oe)}resolveToolCall({wireId:N,index:oe,name:Ie,hasExplicitCallStart:Re,hasEmptyArguments:De}){let Le=oe!=null?this.toolCallsByIndex.get(oe):void 0,Ue=this.filterToolCallsByName(Le,Ie);if(N!=null){let Xe=this.toolCallsById.get(N);if(Xe!=null){if(oe!=null){let Ye=Ue.filter((et)=>Xe.has(et)),Qe=this.resolveMatchingToolCall(Ye,Re);if(Qe.kind!=="new")return Qe;if(Ie!=null)return{kind:"new"};if(Le!=null)return{kind:"ambiguous"};return this.resolveMatchingToolCall([...Xe],!1)}if(Ie!=null){let Ye=[...Xe].filter((Qe)=>Qe.function.name===Ie);return this.resolveMatchingToolCall(Ye,Re)}return this.resolveMatchingToolCall([...Xe],!1)}if(Ue.length>0)return Re?{kind:"new"}:this.resolveMatchingToolCall(Ue,Ie!=null&&De);return{kind:"new"}}if(Le!=null)return this.resolveMatchingToolCall(Ue,Re);if(Ie!=null)return{kind:"new"};let Be=this.toolCalls.filter((Xe)=>!Xe.hasFinished);return this.resolveMatchingToolCall(Be,!1)}filterToolCallsByName(N,oe){if(N==null)return[];return[...N].filter((Ie)=>oe==null||Ie.function.name===oe)}resolveMatchingToolCall(N,oe){if(N.length===0)return{kind:"new"};let Ie=N.filter((Re)=>!Re.argumentState.hasCompleteStructuredValue);if(!oe&&N.length===1)return{kind:"existing",toolCall:N[0]};if(Ie.length===1)return{kind:"existing",toolCall:Ie[0]};if(Ie.length>1||!oe)return{kind:"ambiguous"};return{kind:"new"}}processNewToolCall(N,{wireId:oe,index:Ie,name:Re}){if(this.typeValidation==="required"){if(N.type!=="function")throw new P({data:N,message:"Expected 'function' type."})}else if(this.typeValidation==="if-present"){if(N.type!=null&&N.type!=="function")throw new P({data:N,message:"Expected 'function' type."})}if(Re==null)throw new P({data:N,message:"Expected 'function.name' to be a string."});let De=this.createToolCallId(oe);this.controller.enqueue({type:"tool-input-start",id:De,toolName:Re});let Le=this.extractMetadata?.(N),Ue=N.function?.arguments??"",Be={id:De,index:Ie??void 0,sequence:this.toolCalls.length,type:"function",function:{name:Re,arguments:Ue},argumentState:new Kh(Ue),hasFinished:!1,metadata:Le};if(this.toolCalls.push(Be),oe!=null)this.associateWireId(Be,oe);if(Be.function.arguments.length>0)this.controller.enqueue({type:"tool-input-delta",id:Be.id,delta:Be.function.arguments});return Be}associateWireId(N,oe){let Ie=this.toolCallsById.get(oe);if(Ie==null)Ie=new Set,this.toolCallsById.set(oe,Ie);Ie.add(N)}associateIndex(N,oe){let Ie=this.toolCallsByIndex.get(oe);if(Ie==null)Ie=new Set,this.toolCallsByIndex.set(oe,Ie);Ie.add(N)}createToolCallId(N){if(N!=null&&!this.usedToolCallIds.has(N))return this.usedToolCallIds.add(N),N;let oe=this.getNonBlankString(this._generateId())??"tool-call";if(!this.usedToolCallIds.has(oe))return this.usedToolCallIds.add(oe),oe;let Ie=this.nextGeneratedIdSuffixes.get(oe)??1,Re=Ie+this.usedToolCallIds.size;for(let De=Ie;De<=Re;De++){let Le=`${oe}-${De}`;if(!this.usedToolCallIds.has(Le))return this.usedToolCallIds.add(Le),this.nextGeneratedIdSuffixes.set(oe,De+1),Le}throw Error("Failed to create a unique tool call ID.")}getNonBlankString(N){return N!=null&&N.trim().length>0?N:void 0}processExistingToolCall(N,oe){if(N.hasFinished)return;if(oe.function?.arguments!=null)N.argumentState.append(oe.function.arguments),N.function.arguments+=oe.function.arguments,this.controller.enqueue({type:"tool-input-delta",id:N.id,delta:oe.function.arguments})}finishToolCall(N){this.controller.enqueue({type:"tool-input-end",id:N.id});let oe=this.buildToolCallProviderMetadata?.(N.metadata);this.controller.enqueue({type:"tool-call",toolCallId:N.id,toolName:N.function.name,input:N.function.arguments,...oe?{providerMetadata:oe}:{}}),N.hasFinished=!0}};var fn="transcription-stream.start",hn="transcription-stream.audio-done";function gn(N){let oe;try{oe=Q(N)}catch{return}if(oe==null||typeof oe!=="object"||Array.isArray(oe))return;let Ie=oe;switch(Ie.type){case"stream-start":return Array.isArray(Ie.warnings)&&Ie.warnings.every(Hh)?Ie:void 0;case"transcript-delta":return vr(Ie.delta)&&or(Ie.id,vr)&&or(Ie.providerMetadata,L)?Ie:void 0;case"transcript-partial":return vr(Ie.text)&&or(Ie.id,vr)&&or(Ie.startSecond,Tr)&&or(Ie.durationInSeconds,Tr)&&or(Ie.channelIndex,Tr)&&or(Ie.providerMetadata,L)?Ie:void 0;case"transcript-final":return vr(Ie.text)&&or(Ie.id,vr)&&or(Ie.startSecond,Tr)&&or(Ie.endSecond,Tr)&&or(Ie.channelIndex,Tr)&&or(Ie.providerMetadata,L)?Ie:void 0;case"finish":return vr(Ie.text)&&Array.isArray(Ie.segments)&&Ie.segments.every(qh)&&or(Ie.language,vr)&&or(Ie.durationInSeconds,Tr)&&or(Ie.usage,L)&&or(Ie.providerMetadata,L)?Ie:void 0;case"response-metadata":{if(!(or(Ie.modelId,vr)&&or(Ie.headers,L)))return;let Re=Ie.timestamp;if(Re==null)return{...Ie,timestamp:void 0};if(typeof Re!=="string")return;let De=new Date(Re);return Number.isNaN(De.getTime())?void 0:{...Ie,timestamp:De}}case"raw":return"rawValue"in Ie?Ie:void 0;case"error":return"error"in Ie?Ie:void 0;default:return}}function vr(N){return typeof N==="string"}function Tr(N){return typeof N==="number"}function or(N,oe){return N===void 0||oe(N)}function Hh(N){return L(N)&&vr(N.type)}function qh(N){return L(N)&&vr(N.text)&&Tr(N.startSecond)&&Tr(N.endSecond)}function mt(N){if(N?.trim()==="")throw new b({argument:"baseURL",message:"baseURL must be a non-empty string."});return N}function Y(N){return N?.replace(/\/$/,"")}function qt(N){return N!=null&&typeof N.execute==="function"}function Gh(N){return N!=null&&typeof N[Symbol.asyncIterator]==="function"}async function*_n({tool:N,input:oe,options:Ie}){let Re=N.execute(oe,Ie);if(Gh(Re)){let De;for await(let Le of Re)De=Le,yield{type:"preliminary",output:Le};yield{type:"final",output:De}}else yield{type:"final",output:await Re}}function Ke(N,oe){return Object.defineProperty({...N},"experimental_toolCaller",{value:oe})}function kt(N){return N?.experimental_toolCaller}
|
|
83
|
+
export{m,Gt,w,A,b,ye,P,Ee,Ge,me,be,u,nt,Vt,Wt,Ht,Zt,Jt,rt,Ve,Pt,e,wt,r,Rt,c,Kt,We,ie,v,Ae,Qt,o,t,se,U,l,f,ot,ce,y,vn,i,n,$e,Yt,Xt,G,k,T,Ne,d,Oe,Lt,ue,fe,ae,j,X,M,we,en,st,ee,te,le,xe,at,je,ke,Z,qe,F,tn,Te,z,K,it,B,He,$t,Nt,vt,Me,nn,rn,de,Pe,V,C,R,jt,xt,Fe,on,L,Ze,he,pe,W,Se,lt,ct,ge,Q,a,ze,s,x,q,ut,J,dt,h,sn,g,ne,ve,re,Je,S,_,O,H,an,I,D,p,_e,pt,ln,cn,E,un,dn,pn,mn,Ce,fn,hn,gn,mt,Y,qt,_n,Ke,kt};
|