barejs 0.1.50 → 0.1.52

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/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- var{defineProperty:Oi,getOwnPropertyNames:su,getOwnPropertyDescriptor:au}=Object,cu=Object.prototype.hasOwnProperty;function uu(e){return this[e]}var fu=(e)=>{var t=(Is??=new WeakMap).get(e),r;if(t)return t;if(t=Oi({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var n of su(e))if(!cu.call(t,n))Oi(t,n,{get:uu.bind(e,n),enumerable:!(r=au(e,n))||r.enumerable})}return Is.set(e,t),t},Is;var du=(e)=>e;function mu(e,t){this[e]=du.bind(null,t)}var $i=(e,t)=>{for(var r in t)Oi(e,r,{get:t[r],enumerable:!0,configurable:!0,set:mu.bind(t,r)})};var pu=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var zc={};$i(zc,{BARE_CONFIG:()=>Hn,initConfig:()=>hi});var fs,Hn,hi=(e={})=>(Hn={...fs,...e,hash:{...fs.hash,...e.hash}},Hn);var Ii=pu(()=>{fs={hash:{algorithm:"argon2id",memoryCost:65536,timeCost:2},port:3000},Hn=fs});var ai={};$i(ai,{BRAND:()=>Dl,DIRTY:()=>Wr,EMPTY_PATH:()=>Il,INVALID:()=>P,NEVER:()=>Ry,OK:()=>Ge,ParseStatus:()=>Ue,Schema:()=>L,ZodAny:()=>Yr,ZodArray:()=>Mt,ZodBigInt:()=>Ar,ZodBoolean:()=>An,ZodBranded:()=>si,ZodCatch:()=>Un,ZodDate:()=>Jr,ZodDefault:()=>Mn,ZodDiscriminatedUnion:()=>ii,ZodEffects:()=>Lt,ZodEnum:()=>kr,ZodError:()=>Ze,ZodFirstPartyTypeKind:()=>N,ZodFunction:()=>Fn,ZodIntersection:()=>Pn,ZodIssueCode:()=>h,ZodLazy:()=>Nn,ZodLiteral:()=>Sn,ZodMap:()=>yo,ZodNaN:()=>go,ZodNativeEnum:()=>jn,ZodNever:()=>zt,ZodNull:()=>Cn,ZodNullable:()=>fr,ZodNumber:()=>Fr,ZodObject:()=>he,ZodOptional:()=>Ut,ZodParsedType:()=>R,ZodPipeline:()=>xo,ZodPromise:()=>Qr,ZodReadonly:()=>En,ZodRecord:()=>lo,ZodSchema:()=>L,ZodSet:()=>Xr,ZodString:()=>jt,ZodSymbol:()=>mo,ZodTransformer:()=>Lt,ZodTuple:()=>Wt,ZodType:()=>L,ZodUndefined:()=>kn,ZodUnion:()=>Tn,ZodUnknown:()=>Rr,ZodVoid:()=>po,addIssueToContext:()=>b,any:()=>Yl,array:()=>ey,bigint:()=>Hl,boolean:()=>Ya,coerce:()=>wy,custom:()=>za,date:()=>Vl,datetimeRegex:()=>Ha,defaultErrorMap:()=>cr,discriminatedUnion:()=>oy,effect:()=>gy,enum:()=>py,function:()=>fy,getErrorMap:()=>$n,getParsedType:()=>Vt,instanceof:()=>ql,intersection:()=>iy,isAborted:()=>ni,isAsync:()=>wn,isDirty:()=>oi,isValid:()=>wr,late:()=>Gl,lazy:()=>dy,literal:()=>my,makeIssue:()=>fo,map:()=>cy,nan:()=>vl,nativeEnum:()=>ly,never:()=>Ql,null:()=>Jl,nullable:()=>hy,number:()=>Ja,object:()=>ty,objectUtil:()=>Zi,oboolean:()=>$y,onumber:()=>Oy,optional:()=>xy,ostring:()=>_y,pipeline:()=>by,preprocess:()=>Iy,promise:()=>yy,quotelessJson:()=>gl,record:()=>ay,set:()=>uy,setErrorMap:()=>hl,strictObject:()=>ry,string:()=>Wa,symbol:()=>zl,transformer:()=>gy,tuple:()=>sy,undefined:()=>Wl,union:()=>ny,unknown:()=>Xl,util:()=>D,void:()=>Zl});var us={};$i(us,{Any:()=>Ir,Argument:()=>nc,Array:()=>cn,AsyncIterator:()=>un,Awaited:()=>Bn,BigInt:()=>ln,Boolean:()=>Go,Capitalize:()=>bc,Composite:()=>ic,Const:()=>sc,Constructor:()=>fn,ConstructorParameters:()=>ac,Date:()=>ci,Enum:()=>cc,Exclude:()=>Dn,Extends:()=>On,Extract:()=>Gn,Function:()=>vt,Index:()=>xr,InstanceType:()=>pc,Instantiate:()=>yc,Integer:()=>gc,Intersect:()=>Ke,Iterator:()=>yn,KeyOf:()=>gn,Literal:()=>W,Lowercase:()=>_c,Mapped:()=>Zs,Module:()=>Uc,Never:()=>E,Not:()=>Ec,Null:()=>ui,Number:()=>dt,Object:()=>X,Omit:()=>Cr,Optional:()=>Le,Parameters:()=>Lc,Partial:()=>qn,Pick:()=>Tr,Promise:()=>Ho,Readonly:()=>Ye,ReadonlyOptional:()=>li,Record:()=>yi,Recursive:()=>Kc,Ref:()=>lt,RegExp:()=>Bc,Required:()=>vn,Rest:()=>Dc,ReturnType:()=>Gc,String:()=>kt,Symbol:()=>fi,TemplateLiteral:()=>vo,Transform:()=>Hc,Tuple:()=>mt,Uint8Array:()=>mi,Uncapitalize:()=>Oc,Undefined:()=>di,Union:()=>J,Unknown:()=>br,Unsafe:()=>As,Uppercase:()=>$c,Void:()=>Vc});function Ao(e){return ze(e)&&globalThis.Symbol.asyncIterator in e}function ko(e){return ze(e)&&globalThis.Symbol.iterator in e}function Co(e){return e instanceof globalThis.Promise}function on(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function sn(e){return e instanceof globalThis.Uint8Array}function To(e,t){return t in e}function ze(e){return e!==null&&typeof e==="object"}function _e(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function ve(e){return e===void 0}function Pr(e){return e===null}function Nr(e){return typeof e==="boolean"}function M(e){return typeof e==="number"}function Po(e){return globalThis.Number.isInteger(e)}function nt(e){return typeof e==="bigint"}function ke(e){return typeof e==="string"}function No(e){return typeof e==="function"}function Sr(e){return typeof e==="symbol"}function So(e){return nt(e)||Nr(e)||Pr(e)||M(e)||ke(e)||Sr(e)||ve(e)}var ne;(function(e){e.InstanceMode="default",e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(s,a){return e.ExactOptionalPropertyTypes?a in s:s[a]!==void 0}e.IsExactOptionalProperty=t;function r(s){let a=ze(s);return e.AllowArrayObject?a:a&&!_e(s)}e.IsObjectLike=r;function n(s){return r(s)&&!(s instanceof Date)&&!(s instanceof Uint8Array)}e.IsRecordLike=n;function o(s){return e.AllowNaN?M(s):Number.isFinite(s)}e.IsNumberLike=o;function i(s){let a=ve(s);return e.AllowNullVoid?a||s===null:a}e.IsVoidLike=i})(ne||(ne={}));var bs=new Map;function wi(e){return bs.has(e)}function Ri(e){return bs.get(e)}var _s=new Map;function Wn(e){return _s.has(e)}function Fi(e){return _s.get(e)}function Os(e){return ae(e)&&!Oe(e)&&!pr(e)&&Symbol.asyncIterator in e}function Oe(e){return Array.isArray(e)}function Uo(e){return typeof e==="bigint"}function mr(e){return typeof e==="boolean"}function an(e){return e instanceof globalThis.Date}function $s(e){return typeof e==="function"}function ws(e){return ae(e)&&!Oe(e)&&!pr(e)&&Symbol.iterator in e}function Rs(e){return e===null}function ot(e){return typeof e==="number"}function ae(e){return typeof e==="object"&&e!==null}function Eo(e){return e instanceof globalThis.RegExp}function oe(e){return typeof e==="string"}function Fs(e){return typeof e==="symbol"}function pr(e){return e instanceof globalThis.Uint8Array}function ie(e){return e===void 0}function lu(e){return globalThis.Object.freeze(e).map((t)=>Jn(t))}function yu(e){return e}function gu(e){return e}function xu(e){return e}function hu(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Jn(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Jn(e[r]);return globalThis.Object.freeze(t)}function Jn(e){return Oe(e)?lu(e):an(e)?yu(e):pr(e)?gu(e):Eo(e)?xu(e):ae(e)?hu(e):e}function Iu(e){return e.map((t)=>Lo(t))}function bu(e){return new Date(e.getTime())}function _u(e){return new Uint8Array(e)}function Ou(e){return new RegExp(e.source,e.flags)}function $u(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Lo(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Lo(e[r]);return t}function Lo(e){return Oe(e)?Iu(e):an(e)?bu(e):pr(e)?_u(e):Eo(e)?Ou(e):ae(e)?$u(e):e}function ce(e){return Lo(e)}function l(e,t){let r=t!==void 0?{...t,...e}:e;switch(ne.InstanceMode){case"freeze":return Jn(r);case"clone":return ce(r);default:return r}}var de=Symbol.for("TypeBox.Transform"),Gt=Symbol.for("TypeBox.Readonly"),Se=Symbol.for("TypeBox.Optional"),qt=Symbol.for("TypeBox.Hint"),x=Symbol.for("TypeBox.Kind");function As(e={}){return l({[x]:e[x]??"Unsafe"},e)}class z extends Error{constructor(e){super(e)}}function H(e){return l({[x]:"MappedResult",properties:e})}function wu(e,t){let{[t]:r,...n}=e;return n}function ye(e,t){return t.reduce((r,n)=>wu(r,n),e)}function cn(e,t){return l({[x]:"Array",type:"array",items:e},t)}function un(e,t){return l({[x]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function fn(e,t,r){return l({[x]:"Constructor",type:"Constructor",parameters:e,returns:t},r)}function vt(e,t,r){return l({[x]:"Function",type:"Function",parameters:e,returns:t},r)}function se(e,t,r){return l({[x]:"Computed",target:e,parameters:t},r)}function E(e){return l({[x]:"Never",not:{}},e)}function dn(e){return ae(e)&&e[Gt]==="Readonly"}function We(e){return ae(e)&&e[Se]==="Optional"}function Ai(e){return G(e,"Any")}function ki(e){return G(e,"Argument")}function Ot(e){return G(e,"Array")}function Mr(e){return G(e,"AsyncIterator")}function Ur(e){return G(e,"BigInt")}function Xt(e){return G(e,"Boolean")}function $t(e){return G(e,"Computed")}function wt(e){return G(e,"Constructor")}function Ru(e){return G(e,"Date")}function Rt(e){return G(e,"Function")}function Ft(e){return G(e,"Integer")}function ge(e){return G(e,"Intersect")}function Er(e){return G(e,"Iterator")}function G(e,t){return ae(e)&&x in e&&e[x]===t}function Ko(e){return mr(e)||ot(e)||oe(e)}function it(e){return G(e,"Literal")}function st(e){return G(e,"MappedKey")}function ue(e){return G(e,"MappedResult")}function lr(e){return G(e,"Never")}function Fu(e){return G(e,"Not")}function Yn(e){return G(e,"Null")}function At(e){return G(e,"Number")}function be(e){return G(e,"Object")}function Lr(e){return G(e,"Promise")}function Kr(e){return G(e,"Record")}function Ie(e){return G(e,"Ref")}function Ci(e){return G(e,"RegExp")}function Qt(e){return G(e,"String")}function Xn(e){return G(e,"Symbol")}function at(e){return G(e,"TemplateLiteral")}function Au(e){return G(e,"This")}function V(e){return ae(e)&&de in e}function ct(e){return G(e,"Tuple")}function Zt(e){return G(e,"Undefined")}function v(e){return G(e,"Union")}function ku(e){return G(e,"Uint8Array")}function Cu(e){return G(e,"Unknown")}function Tu(e){return G(e,"Unsafe")}function Pu(e){return G(e,"Void")}function Nu(e){return ae(e)&&x in e&&oe(e[x])}function me(e){return Ai(e)||ki(e)||Ot(e)||Xt(e)||Ur(e)||Mr(e)||$t(e)||wt(e)||Ru(e)||Rt(e)||Ft(e)||ge(e)||Er(e)||it(e)||st(e)||ue(e)||lr(e)||Fu(e)||Yn(e)||At(e)||be(e)||Lr(e)||Kr(e)||Ie(e)||Ci(e)||Qt(e)||Xn(e)||at(e)||Au(e)||ct(e)||Zt(e)||v(e)||ku(e)||Cu(e)||Tu(e)||Pu(e)||Nu(e)}function Su(e){return l(ye(e,[Se]))}function ju(e){return l({...e,[Se]:"Optional"})}function Mu(e,t){return t===!1?Su(e):ju(e)}function Le(e,t){let r=t??!0;return ue(e)?ks(e,r):Mu(e,r)}function Uu(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Le(e[n],t);return r}function Eu(e,t){return Uu(e.properties,t)}function ks(e,t){let r=Eu(e,t);return H(r)}function Qn(e,t={}){let r=e.every((o)=>be(o)),n=me(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return l(t.unevaluatedProperties===!1||me(t.unevaluatedProperties)||r?{...n,[x]:"Intersect",type:"object",allOf:e}:{...n,[x]:"Intersect",allOf:e},t)}function Lu(e){return e.every((t)=>We(t))}function Ku(e){return ye(e,[Se])}function Cs(e){return e.map((t)=>We(t)?Ku(t):t)}function Bu(e,t){return Lu(e)?Le(Qn(Cs(e),t)):Qn(Cs(e),t)}function Bo(e,t={}){if(e.length===1)return l(e[0],t);if(e.length===0)return E(t);if(e.some((r)=>V(r)))throw Error("Cannot intersect transform types");return Bu(e,t)}function Ke(e,t){if(e.length===1)return l(e[0],t);if(e.length===0)return E(t);if(e.some((r)=>V(r)))throw Error("Cannot intersect transform types");return Qn(e,t)}function Zn(e,t){return l({[x]:"Union",anyOf:e},t)}function Du(e){return e.some((t)=>We(t))}function Ts(e){return e.map((t)=>We(t)?Gu(t):t)}function Gu(e){return ye(e,[Se])}function qu(e,t){return Du(e)?Le(Zn(Ts(e),t)):Zn(Ts(e),t)}function Ht(e,t){return e.length===1?l(e[0],t):e.length===0?E(t):qu(e,t)}function J(e,t){return e.length===0?E(t):e.length===1?l(e[0],t):Zn(e,t)}class Ti extends z{}function vu(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Pi(e,t,r){return e[t]===r&&e.charCodeAt(t-1)!==92}function tr(e,t){return Pi(e,t,"(")}function eo(e,t){return Pi(e,t,")")}function Ps(e,t){return Pi(e,t,"|")}function Hu(e){if(!(tr(e,0)&&eo(e,e.length-1)))return!1;let t=0;for(let r=0;r<e.length;r++){if(tr(e,r))t+=1;if(eo(e,r))t-=1;if(t===0&&r!==e.length-1)return!1}return!0}function Vu(e){return e.slice(1,e.length-1)}function zu(e){let t=0;for(let r=0;r<e.length;r++){if(tr(e,r))t+=1;if(eo(e,r))t-=1;if(Ps(e,r)&&t===0)return!0}return!1}function Wu(e){for(let t=0;t<e.length;t++)if(tr(e,t))return!0;return!1}function Ju(e){let[t,r]=[0,0],n=[];for(let i=0;i<e.length;i++){if(tr(e,i))t+=1;if(eo(e,i))t-=1;if(Ps(e,i)&&t===0){let s=e.slice(r,i);if(s.length>0)n.push(mn(s));r=i+1}}let o=e.slice(r);if(o.length>0)n.push(mn(o));if(n.length===0)return{type:"const",const:""};if(n.length===1)return n[0];return{type:"or",expr:n}}function Yu(e){function t(o,i){if(!tr(o,i))throw new Ti("TemplateLiteralParser: Index must point to open parens");let s=0;for(let a=i;a<o.length;a++){if(tr(o,a))s+=1;if(eo(o,a))s-=1;if(s===0)return[i,a]}throw new Ti("TemplateLiteralParser: Unclosed group parens in expression")}function r(o,i){for(let s=i;s<o.length;s++)if(tr(o,s))return[i,s];return[i,o.length]}let n=[];for(let o=0;o<e.length;o++)if(tr(e,o)){let[i,s]=t(e,o),a=e.slice(i,s+1);n.push(mn(a)),o=s}else{let[i,s]=r(e,o),a=e.slice(i,s);if(a.length>0)n.push(mn(a));o=s-1}return n.length===0?{type:"const",const:""}:n.length===1?n[0]:{type:"and",expr:n}}function mn(e){return Hu(e)?mn(Vu(e)):zu(e)?Ju(e):Wu(e)?Yu(e):{type:"const",const:vu(e)}}function pn(e){return mn(e.slice(1,e.length-1))}class Ns extends z{}function Xu(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="0"&&e.expr[1].type==="const"&&e.expr[1].const==="[1-9][0-9]*"}function Qu(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="true"&&e.expr[1].type==="const"&&e.expr[1].const==="false"}function Zu(e){return e.type==="const"&&e.const===".*"}function Br(e){return Xu(e)||Zu(e)?!1:Qu(e)?!0:e.type==="and"?e.expr.every((t)=>Br(t)):e.type==="or"?e.expr.every((t)=>Br(t)):e.type==="const"?!0:(()=>{throw new Ns("Unknown expression type")})()}function Ss(e){let t=pn(e.pattern);return Br(t)}class js extends z{}function*Ms(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let r of Ms(e.slice(1)))yield`${t}${r}`}function*ef(e){return yield*Ms(e.expr.map((t)=>[...to(t)]))}function*tf(e){for(let t of e.expr)yield*to(t)}function*rf(e){return yield e.const}function*to(e){return e.type==="and"?yield*ef(e):e.type==="or"?yield*tf(e):e.type==="const"?yield*rf(e):(()=>{throw new js("Unknown expression")})()}function Do(e){let t=pn(e.pattern);return Br(t)?[...to(t)]:[]}function W(e,t){return l({[x]:"Literal",const:e,type:typeof e},t)}function Go(e){return l({[x]:"Boolean",type:"boolean"},e)}function ln(e){return l({[x]:"BigInt",type:"bigint"},e)}function dt(e){return l({[x]:"Number",type:"number"},e)}function kt(e){return l({[x]:"String",type:"string"},e)}function*nf(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield Go():t==="number"?yield dt():t==="bigint"?yield ln():t==="string"?yield kt():yield(()=>{let r=t.split("|").map((n)=>W(n.trim()));return r.length===0?E():r.length===1?r[0]:Ht(r)})()}function*of(e){if(e[1]!=="{"){let t=W("$"),r=Ni(e.slice(1));return yield*[t,...r]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let r=nf(e.slice(2,t)),n=Ni(e.slice(t+1));return yield*[...r,...n]}yield W(e)}function*Ni(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let r=W(e.slice(0,t)),n=of(e.slice(t));return yield*[r,...n]}yield W(e)}function Us(e){return[...Ni(e)]}var Es="(true|false)",qo="(0|[1-9][0-9]*)",Ls="(.*)";var yr="^(0|[1-9][0-9]*)$",gr="^(.*)$",Ks="^(?!.*)$";class Bs extends z{}function sf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ds(e,t){return at(e)?e.pattern.slice(1,e.pattern.length-1):v(e)?`(${e.anyOf.map((r)=>Ds(r,t)).join("|")})`:At(e)?`${t}${qo}`:Ft(e)?`${t}${qo}`:Ur(e)?`${t}${qo}`:Qt(e)?`${t}${Ls}`:it(e)?`${t}${sf(e.const.toString())}`:Xt(e)?`${t}${Es}`:(()=>{throw new Bs(`Unexpected Kind '${e[x]}'`)})()}function Si(e){return`^${e.map((t)=>Ds(t,"")).join("")}$`}function Dr(e){let r=Do(e).map((n)=>W(n));return Ht(r)}function vo(e,t){let r=oe(e)?Si(Us(e)):Si(e);return l({[x]:"TemplateLiteral",type:"string",pattern:r},t)}function af(e){return Do(e).map((r)=>r.toString())}function cf(e){let t=[];for(let r of e)t.push(...Je(r));return t}function uf(e){return[e.toString()]}function Je(e){return[...new Set(at(e)?af(e):v(e)?cf(e.anyOf):it(e)?uf(e.const):At(e)?["[number]"]:Ft(e)?["[number]"]:[])]}function ff(e,t,r){let n={};for(let o of Object.getOwnPropertyNames(t))n[o]=xr(e,Je(t[o]),r);return n}function df(e,t,r){return ff(e,t.properties,r)}function Gs(e,t,r){let n=df(e,t,r);return H(n)}function vs(e,t){return e.map((r)=>Hs(r,t))}function mf(e){return e.filter((t)=>!lr(t))}function pf(e,t){return Bo(mf(vs(e,t)))}function lf(e){return e.some((t)=>lr(t))?[]:e}function yf(e,t){return Ht(lf(vs(e,t)))}function gf(e,t){return t in e?e[t]:t==="[number]"?Ht(e):E()}function xf(e,t){return t==="[number]"?e:E()}function hf(e,t){return t in e?e[t]:E()}function Hs(e,t){return ge(e)?pf(e.allOf,t):v(e)?yf(e.anyOf,t):ct(e)?gf(e.items??[],t):Ot(e)?xf(e.items,t):be(e)?hf(e.properties,t):E()}function ro(e,t){return t.map((r)=>Hs(e,r))}function qs(e,t){return Ht(ro(e,t))}function xr(e,t,r){if(Ie(e)||Ie(t)){if(!me(e)||!me(t))throw new z("Index types using Ref parameters require both Type and Key to be of TSchema");return se("Index",[e,t])}if(ue(t))return Gs(e,t,r);if(st(t))return Vs(e,t,r);return l(me(t)?qs(e,Je(t)):qs(e,t),r)}function If(e,t,r){return{[t]:xr(e,[t],ce(r))}}function bf(e,t,r){return t.reduce((n,o)=>({...n,...If(e,o,r)}),{})}function _f(e,t,r){return bf(e,t.keys,r)}function Vs(e,t,r){let n=_f(e,t,r);return H(n)}function yn(e,t){return l({[x]:"Iterator",type:"Iterator",items:e},t)}function Of(e){return globalThis.Object.keys(e).filter((t)=>!We(e[t]))}function $f(e,t){let r=Of(e),n=r.length>0?{[x]:"Object",type:"object",required:r,properties:e}:{[x]:"Object",type:"object",properties:e};return l(n,t)}var X=$f;function Ho(e,t){return l({[x]:"Promise",type:"Promise",item:e},t)}function wf(e){return l(ye(e,[Gt]))}function Rf(e){return l({...e,[Gt]:"Readonly"})}function Ff(e,t){return t===!1?wf(e):Rf(e)}function Ye(e,t){let r=t??!0;return ue(e)?zs(e,r):Ff(e,r)}function Af(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Ye(e[n],t);return r}function kf(e,t){return Af(e.properties,t)}function zs(e,t){let r=kf(e,t);return H(r)}function mt(e,t){return l(e.length>0?{[x]:"Tuple",type:"array",items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[x]:"Tuple",type:"array",minItems:e.length,maxItems:e.length},t)}function Ws(e,t){return e.includes(t)}function Js(e){return[...new Set(e)]}function Cf(e,t){return e.filter((r)=>t.includes(r))}function Tf(e,t){return e.reduce((r,n)=>Cf(r,n),t)}function Ys(e){return e.length===1?e[0]:e.length>1?Tf(e.slice(1),e[0]):[]}function Xs(e){let t=[];for(let r of e)t.push(...r);return t}function Qs(e,t){return e in t?pt(e,t[e]):H(t)}function Pf(e){return{[e]:W(e)}}function Nf(e){let t={};for(let r of e)t[r]=W(r);return t}function Sf(e,t){return Ws(t,e)?Pf(e):Nf(t)}function jf(e,t){let r=Sf(e,t);return Qs(e,r)}function no(e,t){return t.map((r)=>pt(e,r))}function Mf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(t))r[n]=pt(e,t[n]);return r}function pt(e,t){let r={...t};return We(t)?Le(pt(e,ye(t,[Se]))):dn(t)?Ye(pt(e,ye(t,[Gt]))):ue(t)?Qs(e,t.properties):st(t)?jf(e,t.keys):wt(t)?fn(no(e,t.parameters),pt(e,t.returns),r):Rt(t)?vt(no(e,t.parameters),pt(e,t.returns),r):Mr(t)?un(pt(e,t.items),r):Er(t)?yn(pt(e,t.items),r):ge(t)?Ke(no(e,t.allOf),r):v(t)?J(no(e,t.anyOf),r):ct(t)?mt(no(e,t.items??[]),r):be(t)?X(Mf(e,t.properties),r):Ot(t)?cn(pt(e,t.items),r):Lr(t)?Ho(pt(e,t.item),r):t}function Uf(e,t){let r={};for(let n of e)r[n]=pt(n,t);return r}function Zs(e,t,r){let n=me(e)?Je(e):e,o=t({[x]:"MappedKey",keys:n}),i=Uf(n,o);return X(i,r)}function lt(...e){let[t,r]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new z("Ref: $ref must be a string");return l({[x]:"Ref",$ref:t},r)}function ea(e){let t=[];for(let r of e)t.push(yt(r));return t}function Ef(e){let t=ea(e);return Xs(t)}function Lf(e){let t=ea(e);return Ys(t)}function Kf(e){return e.map((t,r)=>r.toString())}function Bf(e){return["[number]"]}function Df(e){return globalThis.Object.getOwnPropertyNames(e)}function Gf(e){if(!ji)return[];return globalThis.Object.getOwnPropertyNames(e).map((r)=>r[0]==="^"&&r[r.length-1]==="$"?r.slice(1,r.length-1):r)}function yt(e){return ge(e)?Ef(e.allOf):v(e)?Lf(e.anyOf):ct(e)?Kf(e.items??[]):Ot(e)?Bf(e.items):be(e)?Df(e.properties):Kr(e)?Gf(e.patternProperties):[]}var ji=!1;function rr(e){ji=!0;let t=yt(e);return ji=!1,`^(${t.map((n)=>`(${n})`).join("|")})$`}function qf(e,t){return se("KeyOf",[se(e,t)])}function vf(e){return se("KeyOf",[lt(e)])}function Hf(e,t){let r=yt(e),n=Vf(r),o=Ht(n);return l(o,t)}function Vf(e){return e.map((t)=>t==="[number]"?dt():W(t))}function gn(e,t){return $t(e)?qf(e.target,e.parameters):Ie(e)?vf(e.$ref):ue(e)?ta(e,t):Hf(e,t)}function zf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=gn(e[n],ce(t));return r}function Wf(e,t){return zf(e.properties,t)}function ta(e,t){let r=Wf(e,t);return H(r)}function Vo(e){let t=yt(e),r=ro(e,t);return t.map((n,o)=>[t[o],r[o]])}function Jf(e){return e.allOf.every((t)=>nr(t))}function Yf(e){return e.anyOf.some((t)=>nr(t))}function Xf(e){return!nr(e.not)}function nr(e){return e[x]==="Intersect"?Jf(e):e[x]==="Union"?Yf(e):e[x]==="Not"?Xf(e):e[x]==="Undefined"?!0:!1}function Qf(e){switch(e.errorType){case p.ArrayContains:return"Expected array to contain at least one matching value";case p.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case p.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case p.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case p.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case p.ArrayUniqueItems:return"Expected array elements to be unique";case p.Array:return"Expected array";case p.AsyncIterator:return"Expected AsyncIterator";case p.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case p.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case p.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case p.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case p.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case p.BigInt:return"Expected bigint";case p.Boolean:return"Expected boolean";case p.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case p.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case p.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case p.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case p.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case p.Date:return"Expected Date";case p.Function:return"Expected function";case p.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case p.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case p.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case p.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case p.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case p.Integer:return"Expected integer";case p.IntersectUnevaluatedProperties:return"Unexpected property";case p.Intersect:return"Expected all values to match";case p.Iterator:return"Expected Iterator";case p.Literal:return`Expected ${typeof e.schema.const==="string"?`'${e.schema.const}'`:e.schema.const}`;case p.Never:return"Never";case p.Not:return"Value should not match";case p.Null:return"Expected null";case p.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case p.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case p.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case p.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case p.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case p.Number:return"Expected number";case p.Object:return"Expected object";case p.ObjectAdditionalProperties:return"Unexpected property";case p.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case p.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case p.ObjectRequiredProperty:return"Expected required property";case p.Promise:return"Expected Promise";case p.RegExp:return"Expected string to match regular expression";case p.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case p.StringFormat:return`Expected string to match '${e.schema.format}' format`;case p.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case p.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case p.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case p.String:return"Expected string";case p.Symbol:return"Expected symbol";case p.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case p.Tuple:return"Expected tuple";case p.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case p.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case p.Uint8Array:return"Expected Uint8Array";case p.Undefined:return"Expected undefined";case p.Union:return"Expected union value";case p.Void:return"Expected void";case p.Kind:return`Expected kind '${e.schema[x]}'`;default:return"Unknown error type"}}var Zf=Qf;function ra(){return Zf}class na extends z{constructor(e){super(`Unable to dereference schema with $id '${e.$ref}'`);this.schema=e}}function ed(e,t){let r=t.find((n)=>n.$id===e.$ref);if(r===void 0)throw new na(e);return Ce(r,t)}function hr(e,t){if(!ke(e.$id)||t.some((r)=>r.$id===e.$id))return t;return t.push(e),t}function Ce(e,t){return e[x]==="This"||e[x]==="Ref"?ed(e,t):e}class oa extends z{constructor(e){super("Unable to hash value");this.value=e}}var ut;(function(e){e[e.Undefined=0]="Undefined",e[e.Null=1]="Null",e[e.Boolean=2]="Boolean",e[e.Number=3]="Number",e[e.String=4]="String",e[e.Object=5]="Object",e[e.Array=6]="Array",e[e.Date=7]="Date",e[e.Uint8Array=8]="Uint8Array",e[e.Symbol=9]="Symbol",e[e.BigInt=10]="BigInt"})(ut||(ut={}));var xn=BigInt("14695981039346656037"),[td,rd]=[BigInt("1099511628211"),BigInt("18446744073709551616")],nd=Array.from({length:256}).map((e,t)=>BigInt(t)),ia=new Float64Array(1),sa=new DataView(ia.buffer),aa=new Uint8Array(ia.buffer);function*od(e){let t=e===0?1:Math.ceil(Math.floor(Math.log2(e)+1)/8);for(let r=0;r<t;r++)yield e>>8*(t-1-r)&255}function id(e){Be(ut.Array);for(let t of e)hn(t)}function sd(e){Be(ut.Boolean),Be(e?1:0)}function ad(e){Be(ut.BigInt),sa.setBigInt64(0,e);for(let t of aa)Be(t)}function cd(e){Be(ut.Date),hn(e.getTime())}function ud(e){Be(ut.Null)}function fd(e){Be(ut.Number),sa.setFloat64(0,e);for(let t of aa)Be(t)}function dd(e){Be(ut.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())hn(t),hn(e[t])}function md(e){Be(ut.String);for(let t=0;t<e.length;t++)for(let r of od(e.charCodeAt(t)))Be(r)}function pd(e){Be(ut.Symbol),hn(e.description)}function ld(e){Be(ut.Uint8Array);for(let t=0;t<e.length;t++)Be(e[t])}function yd(e){return Be(ut.Undefined)}function hn(e){if(_e(e))return id(e);if(Nr(e))return sd(e);if(nt(e))return ad(e);if(on(e))return cd(e);if(Pr(e))return ud(e);if(M(e))return fd(e);if(ze(e))return dd(e);if(ke(e))return md(e);if(Sr(e))return pd(e);if(sn(e))return ld(e);if(ve(e))return yd(e);throw new oa(e)}function Be(e){xn=xn^nd[e],xn=xn*td%rd}function In(e){return xn=BigInt("14695981039346656037"),hn(e),xn}function Ir(e){return l({[x]:"Any"},e)}function br(e){return l({[x]:"Unknown"},e)}var gd=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function ca(e){try{return new RegExp(e),!0}catch{return!1}}function Mi(e){if(!oe(e))return!1;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=7&&r<=13||r===27||r===127)return!1}return!0}function ua(e){return Ui(e)||pe(e)}function oo(e){return ie(e)||Uo(e)}function te(e){return ie(e)||ot(e)}function Ui(e){return ie(e)||mr(e)}function Q(e){return ie(e)||oe(e)}function xd(e){return ie(e)||oe(e)&&Mi(e)&&ca(e)}function hd(e){return ie(e)||oe(e)&&Mi(e)}function fa(e){return ie(e)||pe(e)}function zo(e){return ae(e)&&e[Se]==="Optional"}function Ct(e){return q(e,"Any")&&Q(e.$id)}function Id(e){return q(e,"Argument")&&ot(e.index)}function Gr(e){return q(e,"Array")&&e.type==="array"&&Q(e.$id)&&pe(e.items)&&te(e.minItems)&&te(e.maxItems)&&Ui(e.uniqueItems)&&fa(e.contains)&&te(e.minContains)&&te(e.maxContains)}function Ei(e){return q(e,"AsyncIterator")&&e.type==="AsyncIterator"&&Q(e.$id)&&pe(e.items)}function Wo(e){return q(e,"BigInt")&&e.type==="bigint"&&Q(e.$id)&&oo(e.exclusiveMaximum)&&oo(e.exclusiveMinimum)&&oo(e.maximum)&&oo(e.minimum)&&oo(e.multipleOf)}function qr(e){return q(e,"Boolean")&&e.type==="boolean"&&Q(e.$id)}function bd(e){return q(e,"Computed")&&oe(e.target)&&Oe(e.parameters)&&e.parameters.every((t)=>pe(t))}function Jo(e){return q(e,"Constructor")&&e.type==="Constructor"&&Q(e.$id)&&Oe(e.parameters)&&e.parameters.every((t)=>pe(t))&&pe(e.returns)}function Yo(e){return q(e,"Date")&&e.type==="Date"&&Q(e.$id)&&te(e.exclusiveMaximumTimestamp)&&te(e.exclusiveMinimumTimestamp)&&te(e.maximumTimestamp)&&te(e.minimumTimestamp)&&te(e.multipleOfTimestamp)}function Xo(e){return q(e,"Function")&&e.type==="Function"&&Q(e.$id)&&Oe(e.parameters)&&e.parameters.every((t)=>pe(t))&&pe(e.returns)}function or(e){return q(e,"Integer")&&e.type==="integer"&&Q(e.$id)&&te(e.exclusiveMaximum)&&te(e.exclusiveMinimum)&&te(e.maximum)&&te(e.minimum)&&te(e.multipleOf)}function da(e){return ae(e)&&Object.entries(e).every(([t,r])=>Mi(t)&&pe(r))}function vr(e){return q(e,"Intersect")&&(oe(e.type)&&e.type!=="object"?!1:!0)&&Oe(e.allOf)&&e.allOf.every((t)=>pe(t)&&!Fd(t))&&Q(e.type)&&(Ui(e.unevaluatedProperties)||fa(e.unevaluatedProperties))&&Q(e.$id)}function Li(e){return q(e,"Iterator")&&e.type==="Iterator"&&Q(e.$id)&&pe(e.items)}function q(e,t){return ae(e)&&x in e&&e[x]===t}function ma(e){return _r(e)&&oe(e.const)}function pa(e){return _r(e)&&ot(e.const)}function la(e){return _r(e)&&mr(e.const)}function _r(e){return q(e,"Literal")&&Q(e.$id)&&_d(e.const)}function _d(e){return mr(e)||ot(e)||oe(e)}function Od(e){return q(e,"MappedKey")&&Oe(e.keys)&&e.keys.every((t)=>ot(t)||oe(t))}function $d(e){return q(e,"MappedResult")&&da(e.properties)}function Or(e){return q(e,"Never")&&ae(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function bn(e){return q(e,"Not")&&pe(e.not)}function Ki(e){return q(e,"Null")&&e.type==="null"&&Q(e.$id)}function Xe(e){return q(e,"Number")&&e.type==="number"&&Q(e.$id)&&te(e.exclusiveMaximum)&&te(e.exclusiveMinimum)&&te(e.maximum)&&te(e.minimum)&&te(e.multipleOf)}function xe(e){return q(e,"Object")&&e.type==="object"&&Q(e.$id)&&da(e.properties)&&ua(e.additionalProperties)&&te(e.minProperties)&&te(e.maxProperties)}function Bi(e){return q(e,"Promise")&&e.type==="Promise"&&Q(e.$id)&&pe(e.item)}function je(e){return q(e,"Record")&&e.type==="object"&&Q(e.$id)&&ua(e.additionalProperties)&&ae(e.patternProperties)&&((t)=>{let r=Object.getOwnPropertyNames(t.patternProperties);return r.length===1&&ca(r[0])&&ae(t.patternProperties)&&pe(t.patternProperties[r[0]])})(e)}function wd(e){return q(e,"Ref")&&Q(e.$id)&&oe(e.$ref)}function io(e){return q(e,"RegExp")&&Q(e.$id)&&oe(e.source)&&oe(e.flags)&&te(e.maxLength)&&te(e.minLength)}function Tt(e){return q(e,"String")&&e.type==="string"&&Q(e.$id)&&te(e.minLength)&&te(e.maxLength)&&xd(e.pattern)&&hd(e.format)}function so(e){return q(e,"Symbol")&&e.type==="symbol"&&Q(e.$id)}function ao(e){return q(e,"TemplateLiteral")&&e.type==="string"&&oe(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function Rd(e){return q(e,"This")&&Q(e.$id)&&oe(e.$ref)}function Fd(e){return ae(e)&&de in e}function Qo(e){return q(e,"Tuple")&&e.type==="array"&&Q(e.$id)&&ot(e.minItems)&&ot(e.maxItems)&&e.minItems===e.maxItems&&(ie(e.items)&&ie(e.additionalItems)&&e.minItems===0||Oe(e.items)&&e.items.every((t)=>pe(t)))}function Hr(e){return q(e,"Undefined")&&e.type==="undefined"&&Q(e.$id)}function ir(e){return q(e,"Union")&&Q(e.$id)&&ae(e)&&Oe(e.anyOf)&&e.anyOf.every((t)=>pe(t))}function co(e){return q(e,"Uint8Array")&&e.type==="Uint8Array"&&Q(e.$id)&&te(e.minByteLength)&&te(e.maxByteLength)}function Pt(e){return q(e,"Unknown")&&Q(e.$id)}function Ad(e){return q(e,"Unsafe")}function Zo(e){return q(e,"Void")&&e.type==="void"&&Q(e.$id)}function kd(e){return ae(e)&&x in e&&oe(e[x])&&!gd.includes(e[x])}function pe(e){return ae(e)&&(Ct(e)||Id(e)||Gr(e)||qr(e)||Wo(e)||Ei(e)||bd(e)||Jo(e)||Yo(e)||Xo(e)||or(e)||vr(e)||Li(e)||_r(e)||Od(e)||$d(e)||Or(e)||bn(e)||Ki(e)||Xe(e)||xe(e)||Bi(e)||je(e)||wd(e)||io(e)||Tt(e)||so(e)||ao(e)||Rd(e)||Qo(e)||Hr(e)||ir(e)||co(e)||Pt(e)||Ad(e)||Zo(e)||kd(e))}class ba extends z{}var y;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(y||(y={}));function gt(e){return e===y.False?e:y.True}function _n(e){throw new ba(e)}function $e(e){return Or(e)||vr(e)||ir(e)||Pt(e)||Ct(e)}function we(e,t){return Or(t)?$a(e,t):vr(t)?ei(e,t):ir(t)?Hi(e,t):Pt(t)?Aa(e,t):Ct(t)?vi(e,t):_n("StructuralRight")}function vi(e,t){return y.True}function Cd(e,t){return vr(t)?ei(e,t):ir(t)&&t.anyOf.some((r)=>Ct(r)||Pt(r))?y.True:ir(t)?y.Union:Pt(t)?y.True:Ct(t)?y.True:y.Union}function Td(e,t){return Pt(e)?y.False:Ct(e)?y.Union:Or(e)?y.True:y.False}function Pd(e,t){return xe(t)&&ti(t)?y.True:$e(t)?we(e,t):!Gr(t)?y.False:gt(Z(e.items,t.items))}function Nd(e,t){return $e(t)?we(e,t):!Ei(t)?y.False:gt(Z(e.items,t.items))}function Sd(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Wo(t)?y.True:y.False}function _a(e,t){return la(e)?y.True:qr(e)?y.True:y.False}function jd(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):qr(t)?y.True:y.False}function Md(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):!Jo(t)?y.False:e.parameters.length>t.parameters.length?y.False:!e.parameters.every((r,n)=>gt(Z(t.parameters[n],r))===y.True)?y.False:gt(Z(e.returns,t.returns))}function Ud(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Yo(t)?y.True:y.False}function Ed(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):!Xo(t)?y.False:e.parameters.length>t.parameters.length?y.False:!e.parameters.every((r,n)=>gt(Z(t.parameters[n],r))===y.True)?y.False:gt(Z(e.returns,t.returns))}function Oa(e,t){return _r(e)&&ot(e.const)?y.True:Xe(e)||or(e)?y.True:y.False}function Ld(e,t){return or(t)||Xe(t)?y.True:$e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):y.False}function ei(e,t){return t.allOf.every((r)=>Z(e,r)===y.True)?y.True:y.False}function Kd(e,t){return e.allOf.some((r)=>Z(r,t)===y.True)?y.True:y.False}function Bd(e,t){return $e(t)?we(e,t):!Li(t)?y.False:gt(Z(e.items,t.items))}function Dd(e,t){return _r(t)&&t.const===e.const?y.True:$e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Tt(t)?Fa(e,t):Xe(t)?wa(e,t):or(t)?Oa(e,t):qr(t)?_a(e,t):y.False}function $a(e,t){return y.False}function Gd(e,t){return y.True}function ga(e){let[t,r]=[e,0];while(!0){if(!bn(t))break;t=t.not,r+=1}return r%2===0?t:br()}function qd(e,t){return bn(e)?Z(ga(e),t):bn(t)?Z(e,ga(t)):_n("Invalid fallthrough for Not")}function vd(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Ki(t)?y.True:y.False}function wa(e,t){return pa(e)?y.True:Xe(e)||or(e)?y.True:y.False}function Hd(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):or(t)||Xe(t)?y.True:y.False}function Qe(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function xa(e){return ti(e)}function ha(e){return Qe(e,0)||Qe(e,1)&&"description"in e.properties&&ir(e.properties.description)&&e.properties.description.anyOf.length===2&&(Tt(e.properties.description.anyOf[0])&&Hr(e.properties.description.anyOf[1])||Tt(e.properties.description.anyOf[1])&&Hr(e.properties.description.anyOf[0]))}function Di(e){return Qe(e,0)}function Ia(e){return Qe(e,0)}function Vd(e){return Qe(e,0)}function zd(e){return Qe(e,0)}function Wd(e){return ti(e)}function Jd(e){let t=dt();return Qe(e,0)||Qe(e,1)&&"length"in e.properties&&gt(Z(e.properties.length,t))===y.True}function Yd(e){return Qe(e,0)}function ti(e){let t=dt();return Qe(e,0)||Qe(e,1)&&"length"in e.properties&&gt(Z(e.properties.length,t))===y.True}function Xd(e){let t=vt([Ir()],Ir());return Qe(e,0)||Qe(e,1)&&"then"in e.properties&&gt(Z(e.properties.then,t))===y.True}function Ra(e,t){return Z(e,t)===y.False?y.False:zo(e)&&!zo(t)?y.False:y.True}function De(e,t){return Pt(e)?y.False:Ct(e)?y.Union:Or(e)||ma(e)&&xa(t)||pa(e)&&Di(t)||la(e)&&Ia(t)||so(e)&&ha(t)||Wo(e)&&Vd(t)||Tt(e)&&xa(t)||so(e)&&ha(t)||Xe(e)&&Di(t)||or(e)&&Di(t)||qr(e)&&Ia(t)||co(e)&&Wd(t)||Yo(e)&&zd(t)||Jo(e)&&Yd(t)||Xo(e)&&Jd(t)?y.True:je(e)&&Tt(Gi(e))?(()=>t[qt]==="Record"?y.True:y.False)():je(e)&&Xe(Gi(e))?(()=>Qe(t,0)?y.True:y.False)():y.False}function Qd(e,t){return $e(t)?we(e,t):je(t)?xt(e,t):!xe(t)?y.False:(()=>{for(let r of Object.getOwnPropertyNames(t.properties)){if(!(r in e.properties)&&!zo(t.properties[r]))return y.False;if(zo(t.properties[r]))return y.True;if(Ra(e.properties[r],t.properties[r])===y.False)return y.False}return y.True})()}function Zd(e,t){return $e(t)?we(e,t):xe(t)&&Xd(t)?y.True:!Bi(t)?y.False:gt(Z(e.item,t.item))}function Gi(e){return yr in e.patternProperties?dt():(gr in e.patternProperties)?kt():_n("Unknown record key pattern")}function qi(e){return yr in e.patternProperties?e.patternProperties[yr]:(gr in e.patternProperties)?e.patternProperties[gr]:_n("Unable to get record value schema")}function xt(e,t){let[r,n]=[Gi(t),qi(t)];return ma(e)&&Xe(r)&&gt(Z(e,n))===y.True?y.True:co(e)&&Xe(r)?Z(e,n):Tt(e)&&Xe(r)?Z(e,n):Gr(e)&&Xe(r)?Z(e,n):xe(e)?(()=>{for(let o of Object.getOwnPropertyNames(e.properties))if(Ra(n,e.properties[o])===y.False)return y.False;return y.True})():y.False}function em(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):!je(t)?y.False:Z(qi(e),qi(t))}function tm(e,t){let r=io(e)?kt():e,n=io(t)?kt():t;return Z(r,n)}function Fa(e,t){return _r(e)&&oe(e.const)?y.True:Tt(e)?y.True:y.False}function rm(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Tt(t)?y.True:y.False}function nm(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):so(t)?y.True:y.False}function om(e,t){return ao(e)?Z(Dr(e),t):ao(t)?Z(e,Dr(t)):_n("Invalid fallthrough for TemplateLiteral")}function im(e,t){return Gr(t)&&e.items!==void 0&&e.items.every((r)=>Z(r,t.items)===y.True)}function sm(e,t){return Or(e)?y.True:Pt(e)?y.False:Ct(e)?y.Union:y.False}function am(e,t){return $e(t)?we(e,t):xe(t)&&ti(t)?y.True:Gr(t)&&im(e,t)?y.True:!Qo(t)?y.False:ie(e.items)&&!ie(t.items)||!ie(e.items)&&ie(t.items)?y.False:ie(e.items)&&!ie(t.items)?y.True:e.items.every((r,n)=>Z(r,t.items[n])===y.True)?y.True:y.False}function cm(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):co(t)?y.True:y.False}function um(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Zo(t)?mm(e,t):Hr(t)?y.True:y.False}function Hi(e,t){return t.anyOf.some((r)=>Z(e,r)===y.True)?y.True:y.False}function fm(e,t){return e.anyOf.every((r)=>Z(r,t)===y.True)?y.True:y.False}function Aa(e,t){return y.True}function dm(e,t){return Or(t)?$a(e,t):vr(t)?ei(e,t):ir(t)?Hi(e,t):Ct(t)?vi(e,t):Tt(t)?Fa(e,t):Xe(t)?wa(e,t):or(t)?Oa(e,t):qr(t)?_a(e,t):Gr(t)?Td(e,t):Qo(t)?sm(e,t):xe(t)?De(e,t):Pt(t)?y.True:y.False}function mm(e,t){return Hr(e)?y.True:Hr(e)?y.True:y.False}function pm(e,t){return vr(t)?ei(e,t):ir(t)?Hi(e,t):Pt(t)?Aa(e,t):Ct(t)?vi(e,t):xe(t)?De(e,t):Zo(t)?y.True:y.False}function Z(e,t){return ao(e)||ao(t)?om(e,t):io(e)||io(t)?tm(e,t):bn(e)||bn(t)?qd(e,t):Ct(e)?Cd(e,t):Gr(e)?Pd(e,t):Wo(e)?Sd(e,t):qr(e)?jd(e,t):Ei(e)?Nd(e,t):Jo(e)?Md(e,t):Yo(e)?Ud(e,t):Xo(e)?Ed(e,t):or(e)?Ld(e,t):vr(e)?Kd(e,t):Li(e)?Bd(e,t):_r(e)?Dd(e,t):Or(e)?Gd(e,t):Ki(e)?vd(e,t):Xe(e)?Hd(e,t):xe(e)?Qd(e,t):je(e)?em(e,t):Tt(e)?rm(e,t):so(e)?nm(e,t):Qo(e)?am(e,t):Bi(e)?Zd(e,t):co(e)?cm(e,t):Hr(e)?um(e,t):ir(e)?fm(e,t):Pt(e)?dm(e,t):Zo(e)?pm(e,t):_n(`Unknown left type operand '${e[x]}'`)}function $r(e,t){return Z(e,t)}function lm(e,t,r,n,o){let i={};for(let s of globalThis.Object.getOwnPropertyNames(e))i[s]=On(e[s],t,r,n,ce(o));return i}function ym(e,t,r,n,o){return lm(e.properties,t,r,n,o)}function ka(e,t,r,n,o){let i=ym(e,t,r,n,o);return H(i)}function gm(e,t,r,n){let o=$r(e,t);return o===y.Union?J([r,n]):o===y.True?r:n}function On(e,t,r,n,o){return ue(e)?ka(e,t,r,n,o):st(e)?l(Ca(e,t,r,n,o)):l(gm(e,t,r,n),o)}function xm(e,t,r,n,o){return{[e]:On(W(e),t,r,n,ce(o))}}function hm(e,t,r,n,o){return e.reduce((i,s)=>({...i,...xm(s,t,r,n,o)}),{})}function Im(e,t,r,n,o){return hm(e.keys,t,r,n,o)}function Ca(e,t,r,n,o){let i=Im(e,t,r,n,o);return H(i)}class Ta extends z{constructor(e){super("Unknown type");this.schema=e}}function bm(e){return e[x]==="Any"||e[x]==="Unknown"}function K(e){return e!==void 0}function _m(e,t,r){return!0}function Om(e,t,r){return!0}function $m(e,t,r){if(!_e(r))return!1;if(K(e.minItems)&&!(r.length>=e.minItems))return!1;if(K(e.maxItems)&&!(r.length<=e.maxItems))return!1;if(!r.every((i)=>Te(e.items,t,i)))return!1;if(e.uniqueItems===!0&&!function(){let i=new Set;for(let s of r){let a=In(s);if(i.has(a))return!1;else i.add(a)}return!0}())return!1;if(!(K(e.contains)||M(e.minContains)||M(e.maxContains)))return!0;let n=K(e.contains)?e.contains:E(),o=r.reduce((i,s)=>Te(n,t,s)?i+1:i,0);if(o===0)return!1;if(M(e.minContains)&&o<e.minContains)return!1;if(M(e.maxContains)&&o>e.maxContains)return!1;return!0}function wm(e,t,r){return Ao(r)}function Rm(e,t,r){if(!nt(r))return!1;if(K(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(K(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(K(e.maximum)&&!(r<=e.maximum))return!1;if(K(e.minimum)&&!(r>=e.minimum))return!1;if(K(e.multipleOf)&&r%e.multipleOf!==BigInt(0))return!1;return!0}function Fm(e,t,r){return Nr(r)}function Am(e,t,r){return Te(e.returns,t,r.prototype)}function km(e,t,r){if(!on(r))return!1;if(K(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp))return!1;if(K(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp))return!1;if(K(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp))return!1;if(K(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp))return!1;if(K(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0)return!1;return!0}function Cm(e,t,r){return No(r)}function Tm(e,t,r){let n=globalThis.Object.values(e.$defs),o=e.$defs[e.$ref];return Te(o,[...t,...n],r)}function Pm(e,t,r){if(!Po(r))return!1;if(K(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(K(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(K(e.maximum)&&!(r<=e.maximum))return!1;if(K(e.minimum)&&!(r>=e.minimum))return!1;if(K(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Nm(e,t,r){let n=e.allOf.every((o)=>Te(o,t,r));if(e.unevaluatedProperties===!1){let o=new RegExp(rr(e)),i=Object.getOwnPropertyNames(r).every((s)=>o.test(s));return n&&i}else if(me(e.unevaluatedProperties)){let o=new RegExp(rr(e)),i=Object.getOwnPropertyNames(r).every((s)=>o.test(s)||Te(e.unevaluatedProperties,t,r[s]));return n&&i}else return n}function Sm(e,t,r){return ko(r)}function jm(e,t,r){return r===e.const}function Mm(e,t,r){return!1}function Um(e,t,r){return!Te(e.not,t,r)}function Em(e,t,r){return Pr(r)}function Lm(e,t,r){if(!ne.IsNumberLike(r))return!1;if(K(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(K(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(K(e.minimum)&&!(r>=e.minimum))return!1;if(K(e.maximum)&&!(r<=e.maximum))return!1;if(K(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Km(e,t,r){if(!ne.IsObjectLike(r))return!1;if(K(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(K(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let n=Object.getOwnPropertyNames(e.properties);for(let o of n){let i=e.properties[o];if(e.required&&e.required.includes(o)){if(!Te(i,t,r[o]))return!1;if((nr(i)||bm(i))&&!(o in r))return!1}else if(ne.IsExactOptionalProperty(r,o)&&!Te(i,t,r[o]))return!1}if(e.additionalProperties===!1){let o=Object.getOwnPropertyNames(r);if(e.required&&e.required.length===n.length&&o.length===n.length)return!0;else return o.every((i)=>n.includes(i))}else if(typeof e.additionalProperties==="object")return Object.getOwnPropertyNames(r).every((i)=>n.includes(i)||Te(e.additionalProperties,t,r[i]));else return!0}function Bm(e,t,r){return Co(r)}function Dm(e,t,r){if(!ne.IsRecordLike(r))return!1;if(K(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(K(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let[n,o]=Object.entries(e.patternProperties)[0],i=new RegExp(n),s=Object.entries(r).every(([u,m])=>i.test(u)?Te(o,t,m):!0),a=typeof e.additionalProperties==="object"?Object.entries(r).every(([u,m])=>!i.test(u)?Te(e.additionalProperties,t,m):!0):!0,c=e.additionalProperties===!1?Object.getOwnPropertyNames(r).every((u)=>i.test(u)):!0;return s&&a&&c}function Gm(e,t,r){return Te(Ce(e,t),t,r)}function qm(e,t,r){let n=new RegExp(e.source,e.flags);if(K(e.minLength)){if(!(r.length>=e.minLength))return!1}if(K(e.maxLength)){if(!(r.length<=e.maxLength))return!1}return n.test(r)}function vm(e,t,r){if(!ke(r))return!1;if(K(e.minLength)){if(!(r.length>=e.minLength))return!1}if(K(e.maxLength)){if(!(r.length<=e.maxLength))return!1}if(K(e.pattern)){if(!new RegExp(e.pattern).test(r))return!1}if(K(e.format)){if(!wi(e.format))return!1;return Ri(e.format)(r)}return!0}function Hm(e,t,r){return Sr(r)}function Vm(e,t,r){return ke(r)&&new RegExp(e.pattern).test(r)}function zm(e,t,r){return Te(Ce(e,t),t,r)}function Wm(e,t,r){if(!_e(r))return!1;if(e.items===void 0&&r.length!==0)return!1;if(r.length!==e.maxItems)return!1;if(!e.items)return!0;for(let n=0;n<e.items.length;n++)if(!Te(e.items[n],t,r[n]))return!1;return!0}function Jm(e,t,r){return ve(r)}function Ym(e,t,r){return e.anyOf.some((n)=>Te(n,t,r))}function Xm(e,t,r){if(!sn(r))return!1;if(K(e.maxByteLength)&&!(r.length<=e.maxByteLength))return!1;if(K(e.minByteLength)&&!(r.length>=e.minByteLength))return!1;return!0}function Qm(e,t,r){return!0}function Zm(e,t,r){return ne.IsVoidLike(r)}function ep(e,t,r){if(!Wn(e[x]))return!1;return Fi(e[x])(e,r)}function Te(e,t,r){let n=K(e.$id)?hr(e,t):t,o=e;switch(o[x]){case"Any":return _m(o,n,r);case"Argument":return Om(o,n,r);case"Array":return $m(o,n,r);case"AsyncIterator":return wm(o,n,r);case"BigInt":return Rm(o,n,r);case"Boolean":return Fm(o,n,r);case"Constructor":return Am(o,n,r);case"Date":return km(o,n,r);case"Function":return Cm(o,n,r);case"Import":return Tm(o,n,r);case"Integer":return Pm(o,n,r);case"Intersect":return Nm(o,n,r);case"Iterator":return Sm(o,n,r);case"Literal":return jm(o,n,r);case"Never":return Mm(o,n,r);case"Not":return Um(o,n,r);case"Null":return Em(o,n,r);case"Number":return Lm(o,n,r);case"Object":return Km(o,n,r);case"Promise":return Bm(o,n,r);case"Record":return Dm(o,n,r);case"Ref":return Gm(o,n,r);case"RegExp":return qm(o,n,r);case"String":return vm(o,n,r);case"Symbol":return Hm(o,n,r);case"TemplateLiteral":return Vm(o,n,r);case"This":return zm(o,n,r);case"Tuple":return Wm(o,n,r);case"Undefined":return Jm(o,n,r);case"Union":return Ym(o,n,r);case"Uint8Array":return Xm(o,n,r);case"Unknown":return Qm(o,n,r);case"Void":return Zm(o,n,r);default:if(!Wn(o[x]))throw new Ta(o);return ep(o,n,r)}}function Vr(...e){return e.length===3?Te(e[0],e[1],e[2]):Te(e[0],[],e[1])}var p;(function(e){e[e.ArrayContains=0]="ArrayContains",e[e.ArrayMaxContains=1]="ArrayMaxContains",e[e.ArrayMaxItems=2]="ArrayMaxItems",e[e.ArrayMinContains=3]="ArrayMinContains",e[e.ArrayMinItems=4]="ArrayMinItems",e[e.ArrayUniqueItems=5]="ArrayUniqueItems",e[e.Array=6]="Array",e[e.AsyncIterator=7]="AsyncIterator",e[e.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",e[e.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",e[e.BigIntMaximum=10]="BigIntMaximum",e[e.BigIntMinimum=11]="BigIntMinimum",e[e.BigIntMultipleOf=12]="BigIntMultipleOf",e[e.BigInt=13]="BigInt",e[e.Boolean=14]="Boolean",e[e.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",e[e.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",e[e.DateMaximumTimestamp=17]="DateMaximumTimestamp",e[e.DateMinimumTimestamp=18]="DateMinimumTimestamp",e[e.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",e[e.Date=20]="Date",e[e.Function=21]="Function",e[e.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",e[e.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",e[e.IntegerMaximum=24]="IntegerMaximum",e[e.IntegerMinimum=25]="IntegerMinimum",e[e.IntegerMultipleOf=26]="IntegerMultipleOf",e[e.Integer=27]="Integer",e[e.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",e[e.Intersect=29]="Intersect",e[e.Iterator=30]="Iterator",e[e.Kind=31]="Kind",e[e.Literal=32]="Literal",e[e.Never=33]="Never",e[e.Not=34]="Not",e[e.Null=35]="Null",e[e.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",e[e.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",e[e.NumberMaximum=38]="NumberMaximum",e[e.NumberMinimum=39]="NumberMinimum",e[e.NumberMultipleOf=40]="NumberMultipleOf",e[e.Number=41]="Number",e[e.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",e[e.ObjectMaxProperties=43]="ObjectMaxProperties",e[e.ObjectMinProperties=44]="ObjectMinProperties",e[e.ObjectRequiredProperty=45]="ObjectRequiredProperty",e[e.Object=46]="Object",e[e.Promise=47]="Promise",e[e.RegExp=48]="RegExp",e[e.StringFormatUnknown=49]="StringFormatUnknown",e[e.StringFormat=50]="StringFormat",e[e.StringMaxLength=51]="StringMaxLength",e[e.StringMinLength=52]="StringMinLength",e[e.StringPattern=53]="StringPattern",e[e.String=54]="String",e[e.Symbol=55]="Symbol",e[e.TupleLength=56]="TupleLength",e[e.Tuple=57]="Tuple",e[e.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",e[e.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",e[e.Uint8Array=60]="Uint8Array",e[e.Undefined=61]="Undefined",e[e.Union=62]="Union",e[e.Void=63]="Void"})(p||(p={}));class Pa extends z{constructor(e){super("Unknown type");this.schema=e}}function sr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function B(e){return e!==void 0}class Vi{constructor(e){this.iterator=e}[Symbol.iterator](){return this.iterator}First(){let e=this.iterator.next();return e.done?void 0:e.value}}function _(e,t,r,n,o=[]){return{type:e,schema:t,path:r,value:n,message:ra()({errorType:e,path:r,schema:t,value:n,errors:o}),errors:o}}function*tp(e,t,r,n){}function*rp(e,t,r,n){}function*np(e,t,r,n){if(!_e(n))return yield _(p.Array,e,r,n);if(B(e.minItems)&&!(n.length>=e.minItems))yield _(p.ArrayMinItems,e,r,n);if(B(e.maxItems)&&!(n.length<=e.maxItems))yield _(p.ArrayMaxItems,e,r,n);for(let s=0;s<n.length;s++)yield*Pe(e.items,t,`${r}/${s}`,n[s]);if(e.uniqueItems===!0&&!function(){let s=new Set;for(let a of n){let c=In(a);if(s.has(c))return!1;else s.add(c)}return!0}())yield _(p.ArrayUniqueItems,e,r,n);if(!(B(e.contains)||B(e.minContains)||B(e.maxContains)))return;let o=B(e.contains)?e.contains:E(),i=n.reduce((s,a,c)=>Pe(o,t,`${r}${c}`,a).next().done===!0?s+1:s,0);if(i===0)yield _(p.ArrayContains,e,r,n);if(M(e.minContains)&&i<e.minContains)yield _(p.ArrayMinContains,e,r,n);if(M(e.maxContains)&&i>e.maxContains)yield _(p.ArrayMaxContains,e,r,n)}function*op(e,t,r,n){if(!Ao(n))yield _(p.AsyncIterator,e,r,n)}function*ip(e,t,r,n){if(!nt(n))return yield _(p.BigInt,e,r,n);if(B(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield _(p.BigIntExclusiveMaximum,e,r,n);if(B(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield _(p.BigIntExclusiveMinimum,e,r,n);if(B(e.maximum)&&!(n<=e.maximum))yield _(p.BigIntMaximum,e,r,n);if(B(e.minimum)&&!(n>=e.minimum))yield _(p.BigIntMinimum,e,r,n);if(B(e.multipleOf)&&n%e.multipleOf!==BigInt(0))yield _(p.BigIntMultipleOf,e,r,n)}function*sp(e,t,r,n){if(!Nr(n))yield _(p.Boolean,e,r,n)}function*ap(e,t,r,n){yield*Pe(e.returns,t,r,n.prototype)}function*cp(e,t,r,n){if(!on(n))return yield _(p.Date,e,r,n);if(B(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp))yield _(p.DateExclusiveMaximumTimestamp,e,r,n);if(B(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp))yield _(p.DateExclusiveMinimumTimestamp,e,r,n);if(B(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp))yield _(p.DateMaximumTimestamp,e,r,n);if(B(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp))yield _(p.DateMinimumTimestamp,e,r,n);if(B(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)yield _(p.DateMultipleOfTimestamp,e,r,n)}function*up(e,t,r,n){if(!No(n))yield _(p.Function,e,r,n)}function*fp(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref];yield*Pe(i,[...t,...o],r,n)}function*dp(e,t,r,n){if(!Po(n))return yield _(p.Integer,e,r,n);if(B(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield _(p.IntegerExclusiveMaximum,e,r,n);if(B(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield _(p.IntegerExclusiveMinimum,e,r,n);if(B(e.maximum)&&!(n<=e.maximum))yield _(p.IntegerMaximum,e,r,n);if(B(e.minimum)&&!(n>=e.minimum))yield _(p.IntegerMinimum,e,r,n);if(B(e.multipleOf)&&n%e.multipleOf!==0)yield _(p.IntegerMultipleOf,e,r,n)}function*mp(e,t,r,n){let o=!1;for(let i of e.allOf)for(let s of Pe(i,t,r,n))o=!0,yield s;if(o)return yield _(p.Intersect,e,r,n);if(e.unevaluatedProperties===!1){let i=new RegExp(rr(e));for(let s of Object.getOwnPropertyNames(n))if(!i.test(s))yield _(p.IntersectUnevaluatedProperties,e,`${r}/${s}`,n)}if(typeof e.unevaluatedProperties==="object"){let i=new RegExp(rr(e));for(let s of Object.getOwnPropertyNames(n))if(!i.test(s)){let a=Pe(e.unevaluatedProperties,t,`${r}/${s}`,n[s]).next();if(!a.done)yield a.value}}}function*pp(e,t,r,n){if(!ko(n))yield _(p.Iterator,e,r,n)}function*lp(e,t,r,n){if(n!==e.const)yield _(p.Literal,e,r,n)}function*yp(e,t,r,n){yield _(p.Never,e,r,n)}function*gp(e,t,r,n){if(Pe(e.not,t,r,n).next().done===!0)yield _(p.Not,e,r,n)}function*xp(e,t,r,n){if(!Pr(n))yield _(p.Null,e,r,n)}function*hp(e,t,r,n){if(!ne.IsNumberLike(n))return yield _(p.Number,e,r,n);if(B(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield _(p.NumberExclusiveMaximum,e,r,n);if(B(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield _(p.NumberExclusiveMinimum,e,r,n);if(B(e.maximum)&&!(n<=e.maximum))yield _(p.NumberMaximum,e,r,n);if(B(e.minimum)&&!(n>=e.minimum))yield _(p.NumberMinimum,e,r,n);if(B(e.multipleOf)&&n%e.multipleOf!==0)yield _(p.NumberMultipleOf,e,r,n)}function*Ip(e,t,r,n){if(!ne.IsObjectLike(n))return yield _(p.Object,e,r,n);if(B(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield _(p.ObjectMinProperties,e,r,n);if(B(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield _(p.ObjectMaxProperties,e,r,n);let o=Array.isArray(e.required)?e.required:[],i=Object.getOwnPropertyNames(e.properties),s=Object.getOwnPropertyNames(n);for(let a of o){if(s.includes(a))continue;yield _(p.ObjectRequiredProperty,e.properties[a],`${r}/${sr(a)}`,void 0)}if(e.additionalProperties===!1){for(let a of s)if(!i.includes(a))yield _(p.ObjectAdditionalProperties,e,`${r}/${sr(a)}`,n[a])}if(typeof e.additionalProperties==="object")for(let a of s){if(i.includes(a))continue;yield*Pe(e.additionalProperties,t,`${r}/${sr(a)}`,n[a])}for(let a of i){let c=e.properties[a];if(e.required&&e.required.includes(a)){if(yield*Pe(c,t,`${r}/${sr(a)}`,n[a]),nr(e)&&!(a in n))yield _(p.ObjectRequiredProperty,c,`${r}/${sr(a)}`,void 0)}else if(ne.IsExactOptionalProperty(n,a))yield*Pe(c,t,`${r}/${sr(a)}`,n[a])}}function*bp(e,t,r,n){if(!Co(n))yield _(p.Promise,e,r,n)}function*_p(e,t,r,n){if(!ne.IsRecordLike(n))return yield _(p.Object,e,r,n);if(B(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield _(p.ObjectMinProperties,e,r,n);if(B(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield _(p.ObjectMaxProperties,e,r,n);let[o,i]=Object.entries(e.patternProperties)[0],s=new RegExp(o);for(let[a,c]of Object.entries(n))if(s.test(a))yield*Pe(i,t,`${r}/${sr(a)}`,c);if(typeof e.additionalProperties==="object"){for(let[a,c]of Object.entries(n))if(!s.test(a))yield*Pe(e.additionalProperties,t,`${r}/${sr(a)}`,c)}if(e.additionalProperties===!1)for(let[a,c]of Object.entries(n)){if(s.test(a))continue;return yield _(p.ObjectAdditionalProperties,e,`${r}/${sr(a)}`,c)}}function*Op(e,t,r,n){yield*Pe(Ce(e,t),t,r,n)}function*$p(e,t,r,n){if(!ke(n))return yield _(p.String,e,r,n);if(B(e.minLength)&&!(n.length>=e.minLength))yield _(p.StringMinLength,e,r,n);if(B(e.maxLength)&&!(n.length<=e.maxLength))yield _(p.StringMaxLength,e,r,n);if(!new RegExp(e.source,e.flags).test(n))return yield _(p.RegExp,e,r,n)}function*wp(e,t,r,n){if(!ke(n))return yield _(p.String,e,r,n);if(B(e.minLength)&&!(n.length>=e.minLength))yield _(p.StringMinLength,e,r,n);if(B(e.maxLength)&&!(n.length<=e.maxLength))yield _(p.StringMaxLength,e,r,n);if(ke(e.pattern)){if(!new RegExp(e.pattern).test(n))yield _(p.StringPattern,e,r,n)}if(ke(e.format)){if(!wi(e.format))yield _(p.StringFormatUnknown,e,r,n);else if(!Ri(e.format)(n))yield _(p.StringFormat,e,r,n)}}function*Rp(e,t,r,n){if(!Sr(n))yield _(p.Symbol,e,r,n)}function*Fp(e,t,r,n){if(!ke(n))return yield _(p.String,e,r,n);if(!new RegExp(e.pattern).test(n))yield _(p.StringPattern,e,r,n)}function*Ap(e,t,r,n){yield*Pe(Ce(e,t),t,r,n)}function*kp(e,t,r,n){if(!_e(n))return yield _(p.Tuple,e,r,n);if(e.items===void 0&&n.length!==0)return yield _(p.TupleLength,e,r,n);if(n.length!==e.maxItems)return yield _(p.TupleLength,e,r,n);if(!e.items)return;for(let o=0;o<e.items.length;o++)yield*Pe(e.items[o],t,`${r}/${o}`,n[o])}function*Cp(e,t,r,n){if(!ve(n))yield _(p.Undefined,e,r,n)}function*Tp(e,t,r,n){if(Vr(e,t,n))return;let o=e.anyOf.map((i)=>new Vi(Pe(i,t,r,n)));yield _(p.Union,e,r,n,o)}function*Pp(e,t,r,n){if(!sn(n))return yield _(p.Uint8Array,e,r,n);if(B(e.maxByteLength)&&!(n.length<=e.maxByteLength))yield _(p.Uint8ArrayMaxByteLength,e,r,n);if(B(e.minByteLength)&&!(n.length>=e.minByteLength))yield _(p.Uint8ArrayMinByteLength,e,r,n)}function*Np(e,t,r,n){}function*Sp(e,t,r,n){if(!ne.IsVoidLike(n))yield _(p.Void,e,r,n)}function*jp(e,t,r,n){if(!Fi(e[x])(e,n))yield _(p.Kind,e,r,n)}function*Pe(e,t,r,n){let o=B(e.$id)?[...t,e]:t,i=e;switch(i[x]){case"Any":return yield*tp(i,o,r,n);case"Argument":return yield*rp(i,o,r,n);case"Array":return yield*np(i,o,r,n);case"AsyncIterator":return yield*op(i,o,r,n);case"BigInt":return yield*ip(i,o,r,n);case"Boolean":return yield*sp(i,o,r,n);case"Constructor":return yield*ap(i,o,r,n);case"Date":return yield*cp(i,o,r,n);case"Function":return yield*up(i,o,r,n);case"Import":return yield*fp(i,o,r,n);case"Integer":return yield*dp(i,o,r,n);case"Intersect":return yield*mp(i,o,r,n);case"Iterator":return yield*pp(i,o,r,n);case"Literal":return yield*lp(i,o,r,n);case"Never":return yield*yp(i,o,r,n);case"Not":return yield*gp(i,o,r,n);case"Null":return yield*xp(i,o,r,n);case"Number":return yield*hp(i,o,r,n);case"Object":return yield*Ip(i,o,r,n);case"Promise":return yield*bp(i,o,r,n);case"Record":return yield*_p(i,o,r,n);case"Ref":return yield*Op(i,o,r,n);case"RegExp":return yield*$p(i,o,r,n);case"String":return yield*wp(i,o,r,n);case"Symbol":return yield*Rp(i,o,r,n);case"TemplateLiteral":return yield*Fp(i,o,r,n);case"This":return yield*Ap(i,o,r,n);case"Tuple":return yield*kp(i,o,r,n);case"Undefined":return yield*Cp(i,o,r,n);case"Union":return yield*Tp(i,o,r,n);case"Uint8Array":return yield*Pp(i,o,r,n);case"Unknown":return yield*Np(i,o,r,n);case"Void":return yield*Sp(i,o,r,n);default:if(!Wn(i[x]))throw new Pa(e);return yield*jp(i,o,r,n)}}function Na(...e){let t=e.length===3?Pe(e[0],e[1],"",e[2]):Pe(e[0],[],"",e[1]);return new Vi(t)}class zi extends z{constructor(e,t,r){super("Unable to decode value as it does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class Sa extends z{constructor(e,t,r,n){super(n instanceof Error?n.message:"Unknown error");this.schema=e,this.path=t,this.value=r,this.error=n}}function le(e,t,r){try{return V(e)?e[de].Decode(r):r}catch(n){throw new Sa(e,t,r,n)}}function Mp(e,t,r,n){return _e(n)?le(e,r,n.map((o,i)=>Nt(e.items,t,`${r}/${i}`,o))):le(e,r,n)}function Up(e,t,r,n){if(!ze(n)||So(n))return le(e,r,n);let o=Vo(e),i=o.map((m)=>m[0]),s={...n};for(let[m,g]of o)if(m in s)s[m]=Nt(g,t,`${r}/${m}`,s[m]);if(!V(e.unevaluatedProperties))return le(e,r,s);let a=Object.getOwnPropertyNames(s),c=e.unevaluatedProperties,u={...s};for(let m of a)if(!i.includes(m))u[m]=le(c,`${r}/${m}`,u[m]);return le(e,r,u)}function Ep(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref],s=Nt(i,[...t,...o],r,n);return le(e,r,s)}function Lp(e,t,r,n){return le(e,r,Nt(e.not,t,r,n))}function Kp(e,t,r,n){if(!ze(n))return le(e,r,n);let o=yt(e),i={...n};for(let u of o){if(!To(i,u))continue;if(ve(i[u])&&(!Zt(e.properties[u])||ne.IsExactOptionalProperty(i,u)))continue;i[u]=Nt(e.properties[u],t,`${r}/${u}`,i[u])}if(!me(e.additionalProperties))return le(e,r,i);let s=Object.getOwnPropertyNames(i),a=e.additionalProperties,c={...i};for(let u of s)if(!o.includes(u))c[u]=le(a,`${r}/${u}`,c[u]);return le(e,r,c)}function Bp(e,t,r,n){if(!ze(n))return le(e,r,n);let o=Object.getOwnPropertyNames(e.patternProperties)[0],i=new RegExp(o),s={...n};for(let m of Object.getOwnPropertyNames(n))if(i.test(m))s[m]=Nt(e.patternProperties[o],t,`${r}/${m}`,s[m]);if(!me(e.additionalProperties))return le(e,r,s);let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,u={...s};for(let m of a)if(!i.test(m))u[m]=le(c,`${r}/${m}`,u[m]);return le(e,r,u)}function Dp(e,t,r,n){let o=Ce(e,t);return le(e,r,Nt(o,t,r,n))}function Gp(e,t,r,n){let o=Ce(e,t);return le(e,r,Nt(o,t,r,n))}function qp(e,t,r,n){return _e(n)&&_e(e.items)?le(e,r,e.items.map((o,i)=>Nt(o,t,`${r}/${i}`,n[i]))):le(e,r,n)}function vp(e,t,r,n){for(let o of e.anyOf){if(!Vr(o,t,n))continue;let i=Nt(o,t,r,n);return le(e,r,i)}return le(e,r,n)}function Nt(e,t,r,n){let o=hr(e,t),i=e;switch(e[x]){case"Array":return Mp(i,o,r,n);case"Import":return Ep(i,o,r,n);case"Intersect":return Up(i,o,r,n);case"Not":return Lp(i,o,r,n);case"Object":return Kp(i,o,r,n);case"Record":return Bp(i,o,r,n);case"Ref":return Dp(i,o,r,n);case"Symbol":return le(i,r,n);case"This":return Gp(i,o,r,n);case"Tuple":return qp(i,o,r,n);case"Union":return vp(i,o,r,n);default:return le(i,r,n)}}function ja(e,t,r){return Nt(e,t,"",r)}class Wi extends z{constructor(e,t,r){super("The encoded value does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class Ma extends z{constructor(e,t,r,n){super(`${n instanceof Error?n.message:"Unknown error"}`);this.schema=e,this.path=t,this.value=r,this.error=n}}function Me(e,t,r){try{return V(e)?e[de].Encode(r):r}catch(n){throw new Ma(e,t,r,n)}}function Hp(e,t,r,n){let o=Me(e,r,n);return _e(o)?o.map((i,s)=>St(e.items,t,`${r}/${s}`,i)):o}function Vp(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref],s=Me(e,r,n);return St(i,[...t,...o],r,s)}function zp(e,t,r,n){let o=Me(e,r,n);if(!ze(n)||So(n))return o;let i=Vo(e),s=i.map((g)=>g[0]),a={...o};for(let[g,I]of i)if(g in a)a[g]=St(I,t,`${r}/${g}`,a[g]);if(!V(e.unevaluatedProperties))return a;let c=Object.getOwnPropertyNames(a),u=e.unevaluatedProperties,m={...a};for(let g of c)if(!s.includes(g))m[g]=Me(u,`${r}/${g}`,m[g]);return m}function Wp(e,t,r,n){return Me(e.not,r,Me(e,r,n))}function Jp(e,t,r,n){let o=Me(e,r,n);if(!ze(o))return o;let i=yt(e),s={...o};for(let m of i){if(!To(s,m))continue;if(ve(s[m])&&(!Zt(e.properties[m])||ne.IsExactOptionalProperty(s,m)))continue;s[m]=St(e.properties[m],t,`${r}/${m}`,s[m])}if(!me(e.additionalProperties))return s;let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,u={...s};for(let m of a)if(!i.includes(m))u[m]=Me(c,`${r}/${m}`,u[m]);return u}function Yp(e,t,r,n){let o=Me(e,r,n);if(!ze(n))return o;let i=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(i),a={...o};for(let g of Object.getOwnPropertyNames(n))if(s.test(g))a[g]=St(e.patternProperties[i],t,`${r}/${g}`,a[g]);if(!me(e.additionalProperties))return a;let c=Object.getOwnPropertyNames(a),u=e.additionalProperties,m={...a};for(let g of c)if(!s.test(g))m[g]=Me(u,`${r}/${g}`,m[g]);return m}function Xp(e,t,r,n){let o=Ce(e,t),i=St(o,t,r,n);return Me(e,r,i)}function Qp(e,t,r,n){let o=Ce(e,t),i=St(o,t,r,n);return Me(e,r,i)}function Zp(e,t,r,n){let o=Me(e,r,n);return _e(e.items)?e.items.map((i,s)=>St(i,t,`${r}/${s}`,o[s])):[]}function el(e,t,r,n){for(let o of e.anyOf){if(!Vr(o,t,n))continue;let i=St(o,t,r,n);return Me(e,r,i)}for(let o of e.anyOf){let i=St(o,t,r,n);if(!Vr(e,t,i))continue;return Me(e,r,i)}return Me(e,r,n)}function St(e,t,r,n){let o=hr(e,t),i=e;switch(e[x]){case"Array":return Hp(i,o,r,n);case"Import":return Vp(i,o,r,n);case"Intersect":return zp(i,o,r,n);case"Not":return Wp(i,o,r,n);case"Object":return Jp(i,o,r,n);case"Record":return Yp(i,o,r,n);case"Ref":return Xp(i,o,r,n);case"This":return Qp(i,o,r,n);case"Tuple":return Zp(i,o,r,n);case"Union":return el(i,o,r,n);default:return Me(i,r,n)}}function Ua(e,t,r){return St(e,t,"",r)}function tl(e,t){return V(e)||Fe(e.items,t)}function rl(e,t){return V(e)||Fe(e.items,t)}function nl(e,t){return V(e)||Fe(e.returns,t)||e.parameters.some((r)=>Fe(r,t))}function ol(e,t){return V(e)||Fe(e.returns,t)||e.parameters.some((r)=>Fe(r,t))}function il(e,t){return V(e)||V(e.unevaluatedProperties)||e.allOf.some((r)=>Fe(r,t))}function sl(e,t){let r=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((o,i)=>[...o,e.$defs[i]],[]),n=e.$defs[e.$ref];return V(e)||Fe(n,[...r,...t])}function al(e,t){return V(e)||Fe(e.items,t)}function cl(e,t){return V(e)||Fe(e.not,t)}function ul(e,t){return V(e)||Object.values(e.properties).some((r)=>Fe(r,t))||me(e.additionalProperties)&&Fe(e.additionalProperties,t)}function fl(e,t){return V(e)||Fe(e.item,t)}function dl(e,t){let r=Object.getOwnPropertyNames(e.patternProperties)[0],n=e.patternProperties[r];return V(e)||Fe(n,t)||me(e.additionalProperties)&&V(e.additionalProperties)}function ml(e,t){if(V(e))return!0;return Fe(Ce(e,t),t)}function pl(e,t){if(V(e))return!0;return Fe(Ce(e,t),t)}function ll(e,t){return V(e)||!ve(e.items)&&e.items.some((r)=>Fe(r,t))}function yl(e,t){return V(e)||e.anyOf.some((r)=>Fe(r,t))}function Fe(e,t){let r=hr(e,t),n=e;if(e.$id&&Ji.has(e.$id))return!1;if(e.$id)Ji.add(e.$id);switch(e[x]){case"Array":return tl(n,r);case"AsyncIterator":return rl(n,r);case"Constructor":return nl(n,r);case"Function":return ol(n,r);case"Import":return sl(n,r);case"Intersect":return il(n,r);case"Iterator":return al(n,r);case"Not":return cl(n,r);case"Object":return ul(n,r);case"Promise":return fl(n,r);case"Record":return dl(n,r);case"Ref":return ml(n,r);case"This":return pl(n,r);case"Tuple":return ll(n,r);case"Union":return yl(n,r);default:return V(e)}}var Ji=new Set;function Ea(e,t){return Ji.clear(),Fe(e,t)}class La{constructor(e,t,r,n){this.schema=e,this.references=t,this.checkFunc=r,this.code=n,this.hasTransform=Ea(e,t)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(e){return Na(this.schema,this.references,e)}Check(e){return this.checkFunc(e)}Decode(e){if(!this.checkFunc(e))throw new zi(this.schema,e,this.Errors(e).First());return this.hasTransform?ja(this.schema,this.references,e):e}Encode(e){let t=this.hasTransform?Ua(this.schema,this.references,e):e;if(!this.checkFunc(t))throw new Wi(this.schema,e,this.Errors(e).First());return t}}var ar;(function(e){function t(i){return i===36}e.DollarSign=t;function r(i){return i===95}e.IsUnderscore=r;function n(i){return i>=65&&i<=90||i>=97&&i<=122}e.IsAlpha=n;function o(i){return i>=48&&i<=57}e.IsNumeric=o})(ar||(ar={}));var ri;(function(e){function t(i){if(i.length===0)return!1;return ar.IsNumeric(i.charCodeAt(0))}function r(i){if(t(i))return!1;for(let s=0;s<i.length;s++){let a=i.charCodeAt(s);if(!(ar.IsAlpha(a)||ar.IsNumeric(a)||ar.DollarSign(a)||ar.IsUnderscore(a)))return!1}return!0}function n(i){return i.replace(/'/g,"\\'")}function o(i,s){return r(s)?`${i}.${s}`:`${i}['${n(s)}']`}e.Encode=o})(ri||(ri={}));var Yi;(function(e){function t(r){let n=[];for(let o=0;o<r.length;o++){let i=r.charCodeAt(o);if(ar.IsNumeric(i)||ar.IsAlpha(i))n.push(r.charAt(o));else n.push(`_${i}_`)}return n.join("").replace(/__/g,"_")}e.Encode=t})(Yi||(Yi={}));var Xi;(function(e){function t(r){return r.replace(/'/g,"\\'")}e.Escape=t})(Xi||(Xi={}));class Ka extends z{constructor(e){super("Unknown type");this.schema=e}}class Qi extends z{constructor(e){super("Preflight validation check failed to guard for the given schema");this.schema=e}}var zr;(function(e){function t(s,a,c){return ne.ExactOptionalPropertyTypes?`('${a}' in ${s} ? ${c} : true)`:`(${ri.Encode(s,a)} !== undefined ? ${c} : true)`}e.IsExactOptionalProperty=t;function r(s){return!ne.AllowArrayObject?`(typeof ${s} === 'object' && ${s} !== null && !Array.isArray(${s}))`:`(typeof ${s} === 'object' && ${s} !== null)`}e.IsObjectLike=r;function n(s){return!ne.AllowArrayObject?`(typeof ${s} === 'object' && ${s} !== null && !Array.isArray(${s}) && !(${s} instanceof Date) && !(${s} instanceof Uint8Array))`:`(typeof ${s} === 'object' && ${s} !== null && !(${s} instanceof Date) && !(${s} instanceof Uint8Array))`}e.IsRecordLike=n;function o(s){return ne.AllowNaN?`typeof ${s} === 'number'`:`Number.isFinite(${s})`}e.IsNumberLike=o;function i(s){return ne.AllowNullVoid?`(${s} === undefined || ${s} === null)`:`${s} === undefined`}e.IsVoidLike=i})(zr||(zr={}));var uo;(function(e){function t(f){return f[x]==="Any"||f[x]==="Unknown"}function*r(f,w,d){yield"true"}function*n(f,w,d){yield"true"}function*o(f,w,d){yield`Array.isArray(${d})`;let[S,F]=[Ro("value","any"),Ro("acc","number")];if(M(f.maxItems))yield`${d}.length <= ${f.maxItems}`;if(M(f.minItems))yield`${d}.length >= ${f.minItems}`;let A=bt(f.items,w,"value");if(yield`${d}.every((${S}) => ${A})`,pe(f.contains)||M(f.minContains)||M(f.maxContains)){let re=pe(f.contains)?f.contains:E(),Ve=bt(re,w,"value"),Yt=M(f.minContains)?[`(count >= ${f.minContains})`]:[],_t=M(f.maxContains)?[`(count <= ${f.maxContains})`]:[],Dt=`const count = value.reduce((${F}, ${S}) => ${Ve} ? acc + 1 : acc, 0)`,Fo=["(count > 0)",...Yt,..._t].join(" && ");yield`((${S}) => { ${Dt}; return ${Fo}})(${d})`}if(f.uniqueItems===!0)yield`((${S}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${d})`}function*i(f,w,d){yield`(typeof value === 'object' && Symbol.asyncIterator in ${d})`}function*s(f,w,d){if(yield`(typeof ${d} === 'bigint')`,nt(f.exclusiveMaximum))yield`${d} < BigInt(${f.exclusiveMaximum})`;if(nt(f.exclusiveMinimum))yield`${d} > BigInt(${f.exclusiveMinimum})`;if(nt(f.maximum))yield`${d} <= BigInt(${f.maximum})`;if(nt(f.minimum))yield`${d} >= BigInt(${f.minimum})`;if(nt(f.multipleOf))yield`(${d} % BigInt(${f.multipleOf})) === 0`}function*a(f,w,d){yield`(typeof ${d} === 'boolean')`}function*c(f,w,d){yield*rn(f.returns,w,`${d}.prototype`)}function*u(f,w,d){if(yield`(${d} instanceof Date) && Number.isFinite(${d}.getTime())`,M(f.exclusiveMaximumTimestamp))yield`${d}.getTime() < ${f.exclusiveMaximumTimestamp}`;if(M(f.exclusiveMinimumTimestamp))yield`${d}.getTime() > ${f.exclusiveMinimumTimestamp}`;if(M(f.maximumTimestamp))yield`${d}.getTime() <= ${f.maximumTimestamp}`;if(M(f.minimumTimestamp))yield`${d}.getTime() >= ${f.minimumTimestamp}`;if(M(f.multipleOfTimestamp))yield`(${d}.getTime() % ${f.multipleOfTimestamp}) === 0`}function*m(f,w,d){yield`(typeof ${d} === 'function')`}function*g(f,w,d){let S=globalThis.Object.getOwnPropertyNames(f.$defs).reduce((F,A)=>[...F,f.$defs[A]],[]);yield*rn(lt(f.$ref),[...w,...S],d)}function*I(f,w,d){if(yield`Number.isInteger(${d})`,M(f.exclusiveMaximum))yield`${d} < ${f.exclusiveMaximum}`;if(M(f.exclusiveMinimum))yield`${d} > ${f.exclusiveMinimum}`;if(M(f.maximum))yield`${d} <= ${f.maximum}`;if(M(f.minimum))yield`${d} >= ${f.minimum}`;if(M(f.multipleOf))yield`(${d} % ${f.multipleOf}) === 0`}function*O(f,w,d){let S=f.allOf.map((F)=>bt(F,w,d)).join(" && ");if(f.unevaluatedProperties===!1){let F=nn(`${new RegExp(rr(f))};`),A=`Object.getOwnPropertyNames(${d}).every(key => ${F}.test(key))`;yield`(${S} && ${A})`}else if(pe(f.unevaluatedProperties)){let F=nn(`${new RegExp(rr(f))};`),A=`Object.getOwnPropertyNames(${d}).every(key => ${F}.test(key) || ${bt(f.unevaluatedProperties,w,`${d}[key]`)})`;yield`(${S} && ${A})`}else yield`(${S})`}function*T(f,w,d){yield`(typeof value === 'object' && Symbol.iterator in ${d})`}function*C(f,w,d){if(typeof f.const==="number"||typeof f.const==="boolean")yield`(${d} === ${f.const})`;else yield`(${d} === '${Xi.Escape(f.const)}')`}function*Y(f,w,d){yield"false"}function*fe(f,w,d){yield`(!${bt(f.not,w,d)})`}function*Ee(f,w,d){yield`(${d} === null)`}function*j(f,w,d){if(yield zr.IsNumberLike(d),M(f.exclusiveMaximum))yield`${d} < ${f.exclusiveMaximum}`;if(M(f.exclusiveMinimum))yield`${d} > ${f.exclusiveMinimum}`;if(M(f.maximum))yield`${d} <= ${f.maximum}`;if(M(f.minimum))yield`${d} >= ${f.minimum}`;if(M(f.multipleOf))yield`(${d} % ${f.multipleOf}) === 0`}function*Ae(f,w,d){if(yield zr.IsObjectLike(d),M(f.minProperties))yield`Object.getOwnPropertyNames(${d}).length >= ${f.minProperties}`;if(M(f.maxProperties))yield`Object.getOwnPropertyNames(${d}).length <= ${f.maxProperties}`;let S=Object.getOwnPropertyNames(f.properties);for(let F of S){let A=ri.Encode(d,F),re=f.properties[F];if(f.required&&f.required.includes(F)){if(yield*rn(re,w,A),nr(re)||t(re))yield`('${F}' in ${d})`}else{let Ve=bt(re,w,A);yield zr.IsExactOptionalProperty(d,F,Ve)}}if(f.additionalProperties===!1)if(f.required&&f.required.length===S.length)yield`Object.getOwnPropertyNames(${d}).length === ${S.length}`;else{let F=`[${S.map((A)=>`'${A}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${d}).every(key => ${F}.includes(key))`}if(typeof f.additionalProperties==="object"){let F=bt(f.additionalProperties,w,`${d}[key]`),A=`[${S.map((re)=>`'${re}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${d}).every(key => ${A}.includes(key) || ${F}))`}}function*ht(f,w,d){yield`${d} instanceof Promise`}function*Re(f,w,d){if(yield zr.IsRecordLike(d),M(f.minProperties))yield`Object.getOwnPropertyNames(${d}).length >= ${f.minProperties}`;if(M(f.maxProperties))yield`Object.getOwnPropertyNames(${d}).length <= ${f.maxProperties}`;let[S,F]=Object.entries(f.patternProperties)[0],A=nn(`${new RegExp(S)}`),re=bt(F,w,"value"),Ve=pe(f.additionalProperties)?bt(f.additionalProperties,w,d):f.additionalProperties===!1?"false":"true",Yt=`(${A}.test(key) ? ${re} : ${Ve})`;yield`(Object.entries(${d}).every(([key, value]) => ${Yt}))`}function*et(f,w,d){let S=Ce(f,w);if(Ne.functions.has(f.$ref))return yield`${wo(f.$ref)}(${d})`;yield*rn(S,w,d)}function*qe(f,w,d){let S=nn(`${new RegExp(f.source,f.flags)};`);if(yield`(typeof ${d} === 'string')`,M(f.maxLength))yield`${d}.length <= ${f.maxLength}`;if(M(f.minLength))yield`${d}.length >= ${f.minLength}`;yield`${S}.test(${d})`}function*tt(f,w,d){if(yield`(typeof ${d} === 'string')`,M(f.maxLength))yield`${d}.length <= ${f.maxLength}`;if(M(f.minLength))yield`${d}.length >= ${f.minLength}`;if(f.pattern!==void 0)yield`${nn(`${new RegExp(f.pattern)};`)}.test(${d})`;if(f.format!==void 0)yield`format('${f.format}', ${d})`}function*dr(f,w,d){yield`(typeof ${d} === 'symbol')`}function*tn(f,w,d){yield`(typeof ${d} === 'string')`,yield`${nn(`${new RegExp(f.pattern)};`)}.test(${d})`}function*Vn(f,w,d){yield`${wo(f.$ref)}(${d})`}function*ee(f,w,d){if(yield`Array.isArray(${d})`,f.items===void 0)return yield`${d}.length === 0`;yield`(${d}.length === ${f.maxItems})`;for(let S=0;S<f.items.length;S++)yield`${bt(f.items[S],w,`${d}[${S}]`)}`}function*rt(f,w,d){yield`${d} === undefined`}function*It(f,w,d){yield`(${f.anyOf.map((F)=>bt(F,w,d)).join(" || ")})`}function*Jt(f,w,d){if(yield`${d} instanceof Uint8Array`,M(f.maxByteLength))yield`(${d}.length <= ${f.maxByteLength})`;if(M(f.minByteLength))yield`(${d}.length >= ${f.minByteLength})`}function*zn(f,w,d){yield"true"}function*$o(f,w,d){yield zr.IsVoidLike(d)}function*tu(f,w,d){let S=Ne.instances.size;Ne.instances.set(S,f),yield`kind('${f[x]}', ${S}, ${d})`}function*rn(f,w,d,S=!0){let F=ke(f.$id)?[...w,f]:w,A=f;if(S&&ke(f.$id)){let re=wo(f.$id);if(Ne.functions.has(re))return yield`${re}(${d})`;else{Ne.functions.set(re,"<deferred>");let Ve=gs(re,f,w,"value",!1);return Ne.functions.set(re,Ve),yield`${re}(${d})`}}switch(A[x]){case"Any":return yield*r(A,F,d);case"Argument":return yield*n(A,F,d);case"Array":return yield*o(A,F,d);case"AsyncIterator":return yield*i(A,F,d);case"BigInt":return yield*s(A,F,d);case"Boolean":return yield*a(A,F,d);case"Constructor":return yield*c(A,F,d);case"Date":return yield*u(A,F,d);case"Function":return yield*m(A,F,d);case"Import":return yield*g(A,F,d);case"Integer":return yield*I(A,F,d);case"Intersect":return yield*O(A,F,d);case"Iterator":return yield*T(A,F,d);case"Literal":return yield*C(A,F,d);case"Never":return yield*Y(A,F,d);case"Not":return yield*fe(A,F,d);case"Null":return yield*Ee(A,F,d);case"Number":return yield*j(A,F,d);case"Object":return yield*Ae(A,F,d);case"Promise":return yield*ht(A,F,d);case"Record":return yield*Re(A,F,d);case"Ref":return yield*et(A,F,d);case"RegExp":return yield*qe(A,F,d);case"String":return yield*tt(A,F,d);case"Symbol":return yield*dr(A,F,d);case"TemplateLiteral":return yield*tn(A,F,d);case"This":return yield*Vn(A,F,d);case"Tuple":return yield*ee(A,F,d);case"Undefined":return yield*rt(A,F,d);case"Union":return yield*It(A,F,d);case"Uint8Array":return yield*Jt(A,F,d);case"Unknown":return yield*zn(A,F,d);case"Void":return yield*$o(A,F,d);default:if(!Wn(A[x]))throw new Ka(f);return yield*tu(A,F,d)}}let Ne={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function bt(f,w,d,S=!0){return`(${[...rn(f,w,d,S)].join(" && ")})`}function wo(f){return`check_${Yi.Encode(f)}`}function nn(f){let w=`local_${Ne.variables.size}`;return Ne.variables.set(w,`const ${w} = ${f}`),w}function gs(f,w,d,S,F=!0){let[A,re]=[`
3
- `,(Dt)=>"".padStart(Dt," ")],Ve=Ro("value","any"),Yt=xs("boolean"),_t=[...rn(w,d,S,F)].map((Dt)=>`${re(4)}${Dt}`).join(` &&${A}`);return`function ${f}(${Ve})${Yt} {${A}${re(2)}return (${A}${_t}${A}${re(2)})
4
- }`}function Ro(f,w){let d=Ne.language==="typescript"?`: ${w}`:"";return`${f}${d}`}function xs(f){return Ne.language==="typescript"?`: ${f}`:""}function ru(f,w,d){let S=gs("check",f,w,"value"),F=Ro("value","any"),A=xs("boolean"),re=[...Ne.functions.values()],Ve=[...Ne.variables.values()],Yt=ke(f.$id)?`return function check(${F})${A} {
5
- return ${wo(f.$id)}(value)
6
- }`:`return ${S}`;return[...Ve,...re,Yt].join(`
7
- `)}function hs(...f){let w={language:"javascript"},[d,S,F]=f.length===2&&_e(f[1])?[f[0],f[1],w]:f.length===2&&!_e(f[1])?[f[0],[],f[1]]:f.length===3?[f[0],f[1],f[2]]:f.length===1?[f[0],[],w]:[null,[],w];if(Ne.language=F.language,Ne.variables.clear(),Ne.functions.clear(),Ne.instances.clear(),!pe(d))throw new Qi(d);for(let A of S)if(!pe(A))throw new Qi(A);return ru(d,S,F)}e.Code=hs;function nu(f,w=[]){let d=hs(f,w,{language:"javascript"}),S=globalThis.Function("kind","format","hash",d),F=new Map(Ne.instances);function A(_t,Dt,Fo){if(!Wn(_t)||!F.has(Dt))return!1;let ou=Fi(_t),iu=F.get(Dt);return ou(iu,Fo)}function re(_t,Dt){if(!wi(_t))return!1;return Ri(_t)(Dt)}function Ve(_t){return In(_t)}let Yt=S(A,re,Ve);return new La(f,w,Yt,d)}e.Compile=nu})(uo||(uo={}));var D;(function(e){e.assertEqual=(o)=>{};function t(o){}e.assertIs=t;function r(o){throw Error()}e.assertNever=r,e.arrayToEnum=(o)=>{let i={};for(let s of o)i[s]=s;return i},e.getValidEnumValues=(o)=>{let i=e.objectKeys(o).filter((a)=>typeof o[o[a]]!=="number"),s={};for(let a of i)s[a]=o[a];return e.objectValues(s)},e.objectValues=(o)=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys==="function"?(o)=>Object.keys(o):(o)=>{let i=[];for(let s in o)if(Object.prototype.hasOwnProperty.call(o,s))i.push(s);return i},e.find=(o,i)=>{for(let s of o)if(i(s))return s;return},e.isInteger=typeof Number.isInteger==="function"?(o)=>Number.isInteger(o):(o)=>typeof o==="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,i=" | "){return o.map((s)=>typeof s==="string"?`'${s}'`:s).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(o,i)=>{if(typeof i==="bigint")return i.toString();return i}})(D||(D={}));var Zi;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Zi||(Zi={}));var R=D.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Vt=(e)=>{switch(typeof e){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN(e)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":if(Array.isArray(e))return R.array;if(e===null)return R.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return R.promise;if(typeof Map<"u"&&e instanceof Map)return R.map;if(typeof Set<"u"&&e instanceof Set)return R.set;if(typeof Date<"u"&&e instanceof Date)return R.date;return R.object;default:return R.unknown}};var h=D.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),gl=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Ze extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(r)=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(o){return o.message},r={_errors:[]},n=(o)=>{for(let i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let s=r,a=0;while(a<i.path.length){let c=i.path[a];if(a!==i.path.length-1)s[c]=s[c]||{_errors:[]};else s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i));s=s[c],a++}}};return n(this),r}static assert(e){if(!(e instanceof Ze))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,D.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(t)=>t.message){let t={},r=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];t[o]=t[o]||[],t[o].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}Ze.create=(e)=>new Ze(e);var xl=(e,t)=>{let r;switch(e.code){case h.invalid_type:if(e.received===R.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case h.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,D.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${D.joinValues(e.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${D.joinValues(e.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${D.joinValues(e.options)}, received '${e.received}'`;break;case h.invalid_arguments:r="Invalid function arguments";break;case h.invalid_return_type:r="Invalid function return type";break;case h.invalid_date:r="Invalid date";break;case h.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")r=`${r} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)r=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)r=`Invalid input: must end with "${e.validation.endsWith}"`;else D.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case h.too_small:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else r="Invalid input";break;case h.too_big:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else r="Invalid input";break;case h.custom:r="Invalid input";break;case h.invalid_intersection_types:r="Intersection results could not be merged";break;case h.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case h.not_finite:r="Number must be finite";break;default:r=t.defaultError,D.assertNever(e)}return{message:r}},cr=xl;var Ba=cr;function hl(e){Ba=e}function $n(){return Ba}var fo=(e)=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,i=[...r,...o.path||[]],s={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let a="",c=n.filter((u)=>!!u).slice().reverse();for(let u of c)a=u(s,{data:t,defaultError:a}).message;return{...o,path:i,message:a}},Il=[];function b(e,t){let r=$n(),n=fo({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===cr?void 0:cr].filter((o)=>!!o)});e.common.issues.push(n)}class Ue{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,t){let r=[];for(let n of t){if(n.status==="aborted")return P;if(n.status==="dirty")e.dirty();r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let n of t){let o=await n.key,i=await n.value;r.push({key:o,value:i})}return Ue.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:o,value:i}=n;if(o.status==="aborted")return P;if(i.status==="aborted")return P;if(o.status==="dirty")e.dirty();if(i.status==="dirty")e.dirty();if(o.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet))r[o.value]=i.value}return{status:e.value,value:r}}}var P=Object.freeze({status:"aborted"}),Wr=(e)=>({status:"dirty",value:e}),Ge=(e)=>({status:"valid",value:e}),ni=(e)=>e.status==="aborted",oi=(e)=>e.status==="dirty",wr=(e)=>e.status==="valid",wn=(e)=>typeof Promise<"u"&&e instanceof Promise;var k;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(k||(k={}));class Et{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var Da=(e,t)=>{if(wr(t))return{success:!0,data:t.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Ze(e.common.issues);return this._error=r,this._error}}}};function U(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:o};return{errorMap:(s,a)=>{let{message:c}=e;if(s.code==="invalid_enum_value")return{message:c??a.defaultError};if(typeof a.data>"u")return{message:c??n??a.defaultError};if(s.code!=="invalid_type")return{message:a.defaultError};return{message:c??r??a.defaultError}},description:o}}class L{get description(){return this._def.description}_getType(e){return Vt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Vt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ue,ctx:{common:e.parent.common,data:e.data,parsedType:Vt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(wn(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Vt(e)},n=this._parseSync({data:e,path:r.path,parent:r});return Da(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Vt(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return wr(r)?{value:r.value}:{issues:t.common.issues}}catch(r){if(r?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((r)=>wr(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Vt(e)},n=this._parse({data:e,path:r.path,parent:r}),o=await(wn(n)?n:Promise.resolve(n));return Da(r,o)}refine(e,t){let r=(n)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(n);else return t};return this._refinement((n,o)=>{let i=e(n),s=()=>o.addIssue({code:h.custom,...r(n)});if(typeof Promise<"u"&&i instanceof Promise)return i.then((a)=>{if(!a)return s(),!1;else return!0});if(!i)return s(),!1;else return!0})}refinement(e,t){return this._refinement((r,n)=>{if(!e(r))return n.addIssue(typeof t==="function"?t(r,n):t),!1;else return!0})}_refinement(e){return new Lt({schema:this,typeName:N.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(t)=>this["~validate"](t)}}optional(){return Ut.create(this,this._def)}nullable(){return fr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Mt.create(this)}promise(){return Qr.create(this,this._def)}or(e){return Tn.create([this,e],this._def)}and(e){return Pn.create(this,e,this._def)}transform(e){return new Lt({...U(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Mn({...U(this._def),innerType:this,defaultValue:t,typeName:N.ZodDefault})}brand(){return new si({typeName:N.ZodBranded,type:this,...U(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new Un({...U(this._def),innerType:this,catchValue:t,typeName:N.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return xo.create(this,e)}readonly(){return En.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var bl=/^c[^\s-]{8,}$/i,_l=/^[0-9a-z]+$/,Ol=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$l=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,wl=/^[a-z0-9_-]{21}$/i,Rl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Fl=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Al=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,kl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",es,Cl=/^(?:(?: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])$/,Tl=/^(?:(?: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])$/,Pl=/^(([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]))$/,Nl=/^(([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])$/,Sl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,jl=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,qa="((\\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])))",Ml=new RegExp(`^${qa}$`);function va(e){let t="[0-5]\\d";if(e.precision)t=`${t}\\.\\d{${e.precision}}`;else if(e.precision==null)t=`${t}(\\.\\d+)?`;let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Ul(e){return new RegExp(`^${va(e)}$`)}function Ha(e){let t=`${qa}T${va(e)}`,r=[];if(r.push(e.local?"Z?":"Z"),e.offset)r.push("([+-]\\d{2}:?\\d{2})");return t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function El(e,t){if((t==="v4"||!t)&&Cl.test(e))return!0;if((t==="v6"||!t)&&Pl.test(e))return!0;return!1}function Ll(e,t){if(!Rl.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));if(typeof o!=="object"||o===null)return!1;if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&o.alg!==t)return!1;return!0}catch{return!1}}function Kl(e,t){if((t==="v4"||!t)&&Tl.test(e))return!0;if((t==="v6"||!t)&&Nl.test(e))return!0;return!1}class jt extends L{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==R.string){let o=this._getOrReturnCtx(e);return b(o,{code:h.invalid_type,expected:R.string,received:o.parsedType}),P}let r=new Ue,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.length<o.value)n=this._getOrReturnCtx(e,n),b(n,{code:h.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="max"){if(e.data.length>o.value)n=this._getOrReturnCtx(e,n),b(n,{code:h.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="length"){let i=e.data.length>o.value,s=e.data.length<o.value;if(i||s){if(n=this._getOrReturnCtx(e,n),i)b(n,{code:h.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});else if(s)b(n,{code:h.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});r.dirty()}}else if(o.kind==="email"){if(!Al.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"email",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="emoji"){if(!es)es=new RegExp(kl,"u");if(!es.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"emoji",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="uuid"){if(!$l.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"uuid",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="nanoid"){if(!wl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"nanoid",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid"){if(!bl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"cuid",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid2"){if(!_l.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"cuid2",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ulid"){if(!Ol.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"ulid",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),b(n,{validation:"url",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="regex"){if(o.regex.lastIndex=0,!o.regex.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"regex",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="trim")e.data=e.data.trim();else if(o.kind==="includes"){if(!e.data.includes(o.value,o.position))n=this._getOrReturnCtx(e,n),b(n,{code:h.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()}else if(o.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(o.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(o.kind==="startsWith"){if(!e.data.startsWith(o.value))n=this._getOrReturnCtx(e,n),b(n,{code:h.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="endsWith"){if(!e.data.endsWith(o.value))n=this._getOrReturnCtx(e,n),b(n,{code:h.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="datetime"){if(!Ha(o).test(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:h.invalid_string,validation:"datetime",message:o.message}),r.dirty()}else if(o.kind==="date"){if(!Ml.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:h.invalid_string,validation:"date",message:o.message}),r.dirty()}else if(o.kind==="time"){if(!Ul(o).test(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:h.invalid_string,validation:"time",message:o.message}),r.dirty()}else if(o.kind==="duration"){if(!Fl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"duration",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ip"){if(!El(e.data,o.version))n=this._getOrReturnCtx(e,n),b(n,{validation:"ip",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="jwt"){if(!Ll(e.data,o.alg))n=this._getOrReturnCtx(e,n),b(n,{validation:"jwt",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cidr"){if(!Kl(e.data,o.version))n=this._getOrReturnCtx(e,n),b(n,{validation:"cidr",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64"){if(!Sl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"base64",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64url"){if(!jl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"base64url",code:h.invalid_string,message:o.message}),r.dirty()}else D.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:h.invalid_string,...k.errToObj(r)})}_addCheck(e){return new jt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...k.errToObj(e)})}url(e){return this._addCheck({kind:"url",...k.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...k.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...k.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...k.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...k.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...k.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...k.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...k.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...k.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...k.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...k.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...k.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...k.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...k.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...k.errToObj(t)})}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new jt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxLength(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}jt.create=(e)=>new jt({checks:[],typeName:N.ZodString,coerce:e?.coerce??!1,...U(e)});function Bl(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,i=Number.parseInt(e.toFixed(o).replace(".","")),s=Number.parseInt(t.toFixed(o).replace(".",""));return i%s/10**o}class Fr extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce)e.data=Number(e.data);if(this._getType(e)!==R.number){let o=this._getOrReturnCtx(e);return b(o,{code:h.invalid_type,expected:R.number,received:o.parsedType}),P}let r=void 0,n=new Ue;for(let o of this._def.checks)if(o.kind==="int"){if(!D.isInteger(e.data))r=this._getOrReturnCtx(e,r),b(r,{code:h.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty()}else if(o.kind==="min"){if(o.inclusive?e.data<o.value:e.data<=o.value)r=this._getOrReturnCtx(e,r),b(r,{code:h.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="max"){if(o.inclusive?e.data>o.value:e.data>=o.value)r=this._getOrReturnCtx(e,r),b(r,{code:h.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(Bl(e.data,o.value)!==0)r=this._getOrReturnCtx(e,r),b(r,{code:h.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else if(o.kind==="finite"){if(!Number.isFinite(e.data))r=this._getOrReturnCtx(e,r),b(r,{code:h.not_finite,message:o.message}),n.dirty()}else D.assertNever(o);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,n){return new Fr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(n)}]})}_addCheck(e){return new Fr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&D.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;else if(r.kind==="min"){if(t===null||r.value>t)t=r.value}else if(r.kind==="max"){if(e===null||r.value<e)e=r.value}return Number.isFinite(t)&&Number.isFinite(e)}}Fr.create=(e)=>new Fr({checks:[],typeName:N.ZodNumber,coerce:e?.coerce||!1,...U(e)});class Ar extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==R.bigint)return this._getInvalidInput(e);let r=void 0,n=new Ue;for(let o of this._def.checks)if(o.kind==="min"){if(o.inclusive?e.data<o.value:e.data<=o.value)r=this._getOrReturnCtx(e,r),b(r,{code:h.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()}else if(o.kind==="max"){if(o.inclusive?e.data>o.value:e.data>=o.value)r=this._getOrReturnCtx(e,r),b(r,{code:h.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(e.data%o.value!==BigInt(0))r=this._getOrReturnCtx(e,r),b(r,{code:h.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else D.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return b(t,{code:h.invalid_type,expected:R.bigint,received:t.parsedType}),P}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,n){return new Ar({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(n)}]})}_addCheck(e){return new Ar({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}Ar.create=(e)=>new Ar({checks:[],typeName:N.ZodBigInt,coerce:e?.coerce??!1,...U(e)});class An extends L{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==R.boolean){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.boolean,received:r.parsedType}),P}return Ge(e.data)}}An.create=(e)=>new An({typeName:N.ZodBoolean,coerce:e?.coerce||!1,...U(e)});class Jr extends L{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==R.date){let o=this._getOrReturnCtx(e);return b(o,{code:h.invalid_type,expected:R.date,received:o.parsedType}),P}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return b(o,{code:h.invalid_date}),P}let r=new Ue,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.getTime()<o.value)n=this._getOrReturnCtx(e,n),b(n,{code:h.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()}else if(o.kind==="max"){if(e.data.getTime()>o.value)n=this._getOrReturnCtx(e,n),b(n,{code:h.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()}else D.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Jr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e!=null?new Date(e):null}}Jr.create=(e)=>new Jr({checks:[],coerce:e?.coerce||!1,typeName:N.ZodDate,...U(e)});class mo extends L{_parse(e){if(this._getType(e)!==R.symbol){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.symbol,received:r.parsedType}),P}return Ge(e.data)}}mo.create=(e)=>new mo({typeName:N.ZodSymbol,...U(e)});class kn extends L{_parse(e){if(this._getType(e)!==R.undefined){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.undefined,received:r.parsedType}),P}return Ge(e.data)}}kn.create=(e)=>new kn({typeName:N.ZodUndefined,...U(e)});class Cn extends L{_parse(e){if(this._getType(e)!==R.null){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.null,received:r.parsedType}),P}return Ge(e.data)}}Cn.create=(e)=>new Cn({typeName:N.ZodNull,...U(e)});class Yr extends L{constructor(){super(...arguments);this._any=!0}_parse(e){return Ge(e.data)}}Yr.create=(e)=>new Yr({typeName:N.ZodAny,...U(e)});class Rr extends L{constructor(){super(...arguments);this._unknown=!0}_parse(e){return Ge(e.data)}}Rr.create=(e)=>new Rr({typeName:N.ZodUnknown,...U(e)});class zt extends L{_parse(e){let t=this._getOrReturnCtx(e);return b(t,{code:h.invalid_type,expected:R.never,received:t.parsedType}),P}}zt.create=(e)=>new zt({typeName:N.ZodNever,...U(e)});class po extends L{_parse(e){if(this._getType(e)!==R.undefined){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.void,received:r.parsedType}),P}return Ge(e.data)}}po.create=(e)=>new po({typeName:N.ZodVoid,...U(e)});class Mt extends L{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==R.array)return b(t,{code:h.invalid_type,expected:R.array,received:t.parsedType}),P;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,s=t.data.length<n.exactLength.value;if(i||s)b(t,{code:i?h.too_big:h.too_small,minimum:s?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty()}if(n.minLength!==null){if(t.data.length<n.minLength.value)b(t,{code:h.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()}if(n.maxLength!==null){if(t.data.length>n.maxLength.value)b(t,{code:h.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()}if(t.common.async)return Promise.all([...t.data].map((i,s)=>n.type._parseAsync(new Et(t,i,t.path,s)))).then((i)=>Ue.mergeArray(r,i));let o=[...t.data].map((i,s)=>n.type._parseSync(new Et(t,i,t.path,s)));return Ue.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new Mt({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new Mt({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new Mt({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}Mt.create=(e,t)=>new Mt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:N.ZodArray,...U(t)});function Rn(e){if(e instanceof he){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Ut.create(Rn(n))}return new he({...e._def,shape:()=>t})}else if(e instanceof Mt)return new Mt({...e._def,type:Rn(e.element)});else if(e instanceof Ut)return Ut.create(Rn(e.unwrap()));else if(e instanceof fr)return fr.create(Rn(e.unwrap()));else if(e instanceof Wt)return Wt.create(e.items.map((t)=>Rn(t)));else return e}class he extends L{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=D.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==R.object){let c=this._getOrReturnCtx(e);return b(c,{code:h.invalid_type,expected:R.object,received:c.parsedType}),P}let{status:r,ctx:n}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof zt&&this._def.unknownKeys==="strip")){for(let c in n.data)if(!i.includes(c))s.push(c)}let a=[];for(let c of i){let u=o[c],m=n.data[c];a.push({key:{status:"valid",value:c},value:u._parse(new Et(n,m,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof zt){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of s)a.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict"){if(s.length>0)b(n,{code:h.unrecognized_keys,keys:s}),r.dirty()}else if(c==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of s){let m=n.data[u];a.push({key:{status:"valid",value:u},value:c._parse(new Et(n,m,n.path,u)),alwaysSet:u in n.data})}}if(n.common.async)return Promise.resolve().then(async()=>{let c=[];for(let u of a){let m=await u.key,g=await u.value;c.push({key:m,value:g,alwaysSet:u.alwaysSet})}return c}).then((c)=>Ue.mergeObjectSync(r,c));else return Ue.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new he({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{let n=this._def.errorMap?.(t,r).message??r.defaultError;if(t.code==="unrecognized_keys")return{message:k.errToObj(e).message??n};return{message:n}}}:{}})}strip(){return new he({...this._def,unknownKeys:"strip"})}passthrough(){return new he({...this._def,unknownKeys:"passthrough"})}extend(e){return new he({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new he({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:N.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new he({...this._def,catchall:e})}pick(e){let t={};for(let r of D.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new he({...this._def,shape:()=>t})}omit(e){let t={};for(let r of D.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new he({...this._def,shape:()=>t})}deepPartial(){return Rn(this)}partial(e){let t={};for(let r of D.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new he({...this._def,shape:()=>t})}required(e){let t={};for(let r of D.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];while(o instanceof Ut)o=o._def.innerType;t[r]=o}return new he({...this._def,shape:()=>t})}keyof(){return Va(D.objectKeys(this.shape))}}he.create=(e,t)=>new he({shape:()=>e,unknownKeys:"strip",catchall:zt.create(),typeName:N.ZodObject,...U(t)});he.strictCreate=(e,t)=>new he({shape:()=>e,unknownKeys:"strict",catchall:zt.create(),typeName:N.ZodObject,...U(t)});he.lazycreate=(e,t)=>new he({shape:e,unknownKeys:"strip",catchall:zt.create(),typeName:N.ZodObject,...U(t)});class Tn extends L{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function n(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;let i=o.map((s)=>new Ze(s.ctx.common.issues));return b(t,{code:h.invalid_union,unionErrors:i}),P}if(t.common.async)return Promise.all(r.map(async(o)=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);else{let o=void 0,i=[];for(let a of r){let c={...t,common:{...t.common,issues:[]},parent:null},u=a._parseSync({data:t.data,path:t.path,parent:c});if(u.status==="valid")return u;else if(u.status==="dirty"&&!o)o={result:u,ctx:c};if(c.common.issues.length)i.push(c.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let s=i.map((a)=>new Ze(a));return b(t,{code:h.invalid_union,unionErrors:s}),P}}get options(){return this._def.options}}Tn.create=(e,t)=>new Tn({options:e,typeName:N.ZodUnion,...U(t)});var ur=(e)=>{if(e instanceof Nn)return ur(e.schema);else if(e instanceof Lt)return ur(e.innerType());else if(e instanceof Sn)return[e.value];else if(e instanceof kr)return e.options;else if(e instanceof jn)return D.objectValues(e.enum);else if(e instanceof Mn)return ur(e._def.innerType);else if(e instanceof kn)return[void 0];else if(e instanceof Cn)return[null];else if(e instanceof Ut)return[void 0,...ur(e.unwrap())];else if(e instanceof fr)return[null,...ur(e.unwrap())];else if(e instanceof si)return ur(e.unwrap());else if(e instanceof En)return ur(e.unwrap());else if(e instanceof Un)return ur(e._def.innerType);else return[]};class ii extends L{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.object)return b(t,{code:h.invalid_type,expected:R.object,received:t.parsedType}),P;let r=this.discriminator,n=t.data[r],o=this.optionsMap.get(n);if(!o)return b(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),P;if(t.common.async)return o._parseAsync({data:t.data,path:t.path,parent:t});else return o._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let o of t){let i=ur(o.shape[e]);if(!i.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of i){if(n.has(s))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);n.set(s,o)}}return new ii({typeName:N.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...U(r)})}}function ts(e,t){let r=Vt(e),n=Vt(t);if(e===t)return{valid:!0,data:e};else if(r===R.object&&n===R.object){let o=D.objectKeys(t),i=D.objectKeys(e).filter((a)=>o.indexOf(a)!==-1),s={...e,...t};for(let a of i){let c=ts(e[a],t[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(r===R.array&&n===R.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let i=0;i<e.length;i++){let s=e[i],a=t[i],c=ts(s,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else if(r===R.date&&n===R.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class Pn extends L{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(o,i)=>{if(ni(o)||ni(i))return P;let s=ts(o.value,i.value);if(!s.valid)return b(r,{code:h.invalid_intersection_types}),P;if(oi(o)||oi(i))t.dirty();return{status:t.value,value:s.data}};if(r.common.async)return Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,i])=>n(o,i));else return n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Pn.create=(e,t,r)=>new Pn({left:e,right:t,typeName:N.ZodIntersection,...U(r)});class Wt extends L{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==R.array)return b(r,{code:h.invalid_type,expected:R.array,received:r.parsedType}),P;if(r.data.length<this._def.items.length)return b(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),P;if(!this._def.rest&&r.data.length>this._def.items.length)b(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let o=[...r.data].map((i,s)=>{let a=this._def.items[s]||this._def.rest;if(!a)return null;return a._parse(new Et(r,i,r.path,s))}).filter((i)=>!!i);if(r.common.async)return Promise.all(o).then((i)=>Ue.mergeArray(t,i));else return Ue.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new Wt({...this._def,rest:e})}}Wt.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new Wt({items:e,typeName:N.ZodTuple,rest:null,...U(t)})};class lo extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==R.object)return b(r,{code:h.invalid_type,expected:R.object,received:r.parsedType}),P;let n=[],o=this._def.keyType,i=this._def.valueType;for(let s in r.data)n.push({key:o._parse(new Et(r,s,r.path,s)),value:i._parse(new Et(r,r.data[s],r.path,s)),alwaysSet:s in r.data});if(r.common.async)return Ue.mergeObjectAsync(t,n);else return Ue.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){if(t instanceof L)return new lo({keyType:e,valueType:t,typeName:N.ZodRecord,...U(r)});return new lo({keyType:jt.create(),valueType:e,typeName:N.ZodRecord,...U(t)})}}class yo extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==R.map)return b(r,{code:h.invalid_type,expected:R.map,received:r.parsedType}),P;let n=this._def.keyType,o=this._def.valueType,i=[...r.data.entries()].map(([s,a],c)=>({key:n._parse(new Et(r,s,r.path,[c,"key"])),value:o._parse(new Et(r,a,r.path,[c,"value"]))}));if(r.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let a of i){let c=await a.key,u=await a.value;if(c.status==="aborted"||u.status==="aborted")return P;if(c.status==="dirty"||u.status==="dirty")t.dirty();s.set(c.value,u.value)}return{status:t.value,value:s}})}else{let s=new Map;for(let a of i){let{key:c,value:u}=a;if(c.status==="aborted"||u.status==="aborted")return P;if(c.status==="dirty"||u.status==="dirty")t.dirty();s.set(c.value,u.value)}return{status:t.value,value:s}}}}yo.create=(e,t,r)=>new yo({valueType:t,keyType:e,typeName:N.ZodMap,...U(r)});class Xr extends L{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==R.set)return b(r,{code:h.invalid_type,expected:R.set,received:r.parsedType}),P;let n=this._def;if(n.minSize!==null){if(r.data.size<n.minSize.value)b(r,{code:h.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()}if(n.maxSize!==null){if(r.data.size>n.maxSize.value)b(r,{code:h.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty()}let o=this._def.valueType;function i(a){let c=new Set;for(let u of a){if(u.status==="aborted")return P;if(u.status==="dirty")t.dirty();c.add(u.value)}return{status:t.value,value:c}}let s=[...r.data.values()].map((a,c)=>o._parse(new Et(r,a,r.path,c)));if(r.common.async)return Promise.all(s).then((a)=>i(a));else return i(s)}min(e,t){return new Xr({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new Xr({...this._def,maxSize:{value:e,message:k.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Xr.create=(e,t)=>new Xr({valueType:e,minSize:null,maxSize:null,typeName:N.ZodSet,...U(t)});class Fn extends L{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.function)return b(t,{code:h.invalid_type,expected:R.function,received:t.parsedType}),P;function r(s,a){return fo({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$n(),cr].filter((c)=>!!c),issueData:{code:h.invalid_arguments,argumentsError:a}})}function n(s,a){return fo({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$n(),cr].filter((c)=>!!c),issueData:{code:h.invalid_return_type,returnTypeError:a}})}let o={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Qr){let s=this;return Ge(async function(...a){let c=new Ze([]),u=await s._def.args.parseAsync(a,o).catch((I)=>{throw c.addIssue(r(a,I)),c}),m=await Reflect.apply(i,this,u);return await s._def.returns._def.type.parseAsync(m,o).catch((I)=>{throw c.addIssue(n(m,I)),c})})}else{let s=this;return Ge(function(...a){let c=s._def.args.safeParse(a,o);if(!c.success)throw new Ze([r(a,c.error)]);let u=Reflect.apply(i,this,c.data),m=s._def.returns.safeParse(u,o);if(!m.success)throw new Ze([n(u,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Fn({...this._def,args:Wt.create(e).rest(Rr.create())})}returns(e){return new Fn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Fn({args:e?e:Wt.create([]).rest(Rr.create()),returns:t||Rr.create(),typeName:N.ZodFunction,...U(r)})}}class Nn extends L{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Nn.create=(e,t)=>new Nn({getter:e,typeName:N.ZodLazy,...U(t)});class Sn extends L{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return b(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}}Sn.create=(e,t)=>new Sn({value:e,typeName:N.ZodLiteral,...U(t)});function Va(e,t){return new kr({values:e,typeName:N.ZodEnum,...U(t)})}class kr extends L{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return b(t,{expected:D.joinValues(r),received:t.parsedType,code:h.invalid_type}),P}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return b(t,{received:t.data,code:h.invalid_enum_value,options:r}),P}return Ge(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return kr.create(e,{...this._def,...t})}exclude(e,t=this._def){return kr.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}}kr.create=Va;class jn extends L{_parse(e){let t=D.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==R.string&&r.parsedType!==R.number){let n=D.objectValues(t);return b(r,{expected:D.joinValues(n),received:r.parsedType,code:h.invalid_type}),P}if(!this._cache)this._cache=new Set(D.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=D.objectValues(t);return b(r,{received:r.data,code:h.invalid_enum_value,options:n}),P}return Ge(e.data)}get enum(){return this._def.values}}jn.create=(e,t)=>new jn({values:e,typeName:N.ZodNativeEnum,...U(t)});class Qr extends L{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.promise&&t.common.async===!1)return b(t,{code:h.invalid_type,expected:R.promise,received:t.parsedType}),P;let r=t.parsedType===R.promise?t.data:Promise.resolve(t.data);return Ge(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Qr.create=(e,t)=>new Qr({type:e,typeName:N.ZodPromise,...U(t)});class Lt extends L{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===N.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:(i)=>{if(b(r,i),i.fatal)t.abort();else t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let i=n.transform(r.data,o);if(r.common.async)return Promise.resolve(i).then(async(s)=>{if(t.value==="aborted")return P;let a=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});if(a.status==="aborted")return P;if(a.status==="dirty")return Wr(a.value);if(t.value==="dirty")return Wr(a.value);return a});else{if(t.value==="aborted")return P;let s=this._def.schema._parseSync({data:i,path:r.path,parent:r});if(s.status==="aborted")return P;if(s.status==="dirty")return Wr(s.value);if(t.value==="dirty")return Wr(s.value);return s}}if(n.type==="refinement"){let i=(s)=>{let a=n.refinement(s,o);if(r.common.async)return Promise.resolve(a);if(a instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(s.status==="aborted")return P;if(s.status==="dirty")t.dirty();return i(s.value),{status:t.value,value:s.value}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((s)=>{if(s.status==="aborted")return P;if(s.status==="dirty")t.dirty();return i(s.value).then(()=>({status:t.value,value:s.value}))})}if(n.type==="transform")if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!wr(i))return P;let s=n.transform(i.value,o);if(s instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((i)=>{if(!wr(i))return P;return Promise.resolve(n.transform(i.value,o)).then((s)=>({status:t.value,value:s}))});D.assertNever(n)}}Lt.create=(e,t,r)=>new Lt({schema:e,typeName:N.ZodEffects,effect:t,...U(r)});Lt.createWithPreprocess=(e,t,r)=>new Lt({schema:t,effect:{type:"preprocess",transform:e},typeName:N.ZodEffects,...U(r)});class Ut extends L{_parse(e){if(this._getType(e)===R.undefined)return Ge(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ut.create=(e,t)=>new Ut({innerType:e,typeName:N.ZodOptional,...U(t)});class fr extends L{_parse(e){if(this._getType(e)===R.null)return Ge(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fr.create=(e,t)=>new fr({innerType:e,typeName:N.ZodNullable,...U(t)});class Mn extends L{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;if(t.parsedType===R.undefined)r=this._def.defaultValue();return this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Mn.create=(e,t)=>new Mn({innerType:e,typeName:N.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...U(t)});class Un extends L{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});if(wn(n))return n.then((o)=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ze(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ze(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Un.create=(e,t)=>new Un({innerType:e,typeName:N.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...U(t)});class go extends L{_parse(e){if(this._getType(e)!==R.nan){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.nan,received:r.parsedType}),P}return{status:"valid",value:e.data}}}go.create=(e)=>new go({typeName:N.ZodNaN,...U(e)});var Dl=Symbol("zod_brand");class si extends L{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class xo extends L{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});if(o.status==="aborted")return P;if(o.status==="dirty")return t.dirty(),Wr(o.value);else return this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();else{let n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});if(n.status==="aborted")return P;if(n.status==="dirty")return t.dirty(),{status:"dirty",value:n.value};else return this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new xo({in:e,out:t,typeName:N.ZodPipeline})}}class En extends L{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(wr(n))n.value=Object.freeze(n.value);return n};return wn(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}}En.create=(e,t)=>new En({innerType:e,typeName:N.ZodReadonly,...U(t)});function Ga(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function za(e,t={},r){if(e)return Yr.create().superRefine((n,o)=>{let i=e(n);if(i instanceof Promise)return i.then((s)=>{if(!s){let a=Ga(t,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!i){let s=Ga(t,n),a=s.fatal??r??!0;o.addIssue({code:"custom",...s,fatal:a})}return});return Yr.create()}var Gl={object:he.lazycreate},N;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(N||(N={}));var ql=(e,t={message:`Input not instance of ${e.name}`})=>za((r)=>r instanceof e,t),Wa=jt.create,Ja=Fr.create,vl=go.create,Hl=Ar.create,Ya=An.create,Vl=Jr.create,zl=mo.create,Wl=kn.create,Jl=Cn.create,Yl=Yr.create,Xl=Rr.create,Ql=zt.create,Zl=po.create,ey=Mt.create,{create:ty,strictCreate:ry}=he,ny=Tn.create,oy=ii.create,iy=Pn.create,sy=Wt.create,ay=lo.create,cy=yo.create,uy=Xr.create,fy=Fn.create,dy=Nn.create,my=Sn.create,py=kr.create,ly=jn.create,yy=Qr.create,gy=Lt.create,xy=Ut.create,hy=fr.create,Iy=Lt.createWithPreprocess,by=xo.create,_y=()=>Wa().optional(),Oy=()=>Ja().optional(),$y=()=>Ya().optional(),wy={string:(e)=>jt.create({...e,coerce:!0}),number:(e)=>Fr.create({...e,coerce:!0}),boolean:(e)=>An.create({...e,coerce:!0}),bigint:(e)=>Ar.create({...e,coerce:!0}),date:(e)=>Jr.create({...e,coerce:!0})};var Ry=P;var Fy=ai,He=(e,t=400)=>Response.json(e,{status:t,headers:{"Content-Type":"application/json"}}),Qa=(e)=>{let t=uo.Compile(e),r=async(n,o)=>{try{let i=n instanceof Object&&"req"in n,s=i?await n.jsonBody():await n.json();if(!t.Check(s)){let a=t.Errors(s).First();return He({status:"error",code:"VALIDATION_FAILED",message:a?.message||"Invalid input",path:a?.path||"body"})}if(i)n.body=s;return o?o():void 0}catch{return He({status:"error",message:"Malformed JSON payload"})}};return r.__schema=e,r},Za=(e)=>{let t=e.properties||{},r=Object.keys(t),n=r.length,o=Array.isArray(e.required)?new Set(e.required):null,i=async(s,a)=>{try{let c=s instanceof Object&&"req"in s,u=c?await s.jsonBody():await s.json();if(!u||typeof u!=="object"||Array.isArray(u))return He({status:"error",message:"Invalid JSON object payload"});for(let m=0;m<n;m++){let g=r[m];if(!(Object.hasOwn(u,g)&&u[g]!==void 0)){if(!o||o.has(g))return He({status:"error",code:"TYPE_MISMATCH",message:`Field '${g}' must be of type ${t[g]?.type}`,field:g});continue}if(typeof u[g]!==t[g]?.type)return He({status:"error",code:"TYPE_MISMATCH",message:`Field '${g}' must be of type ${t[g]?.type}`,field:g})}if(c)s.body=u;return a?a():void 0}catch{return He({status:"error",message:"Invalid JSON payload"})}};return i.__schema=e,i},ec=(e)=>{let t=async(r,n)=>{try{let o=r instanceof Object&&"req"in r,i=o?await r.jsonBody():await r.json(),s=await e.safeParseAsync(i);if(!s.success)return He({status:"error",code:"ZOD_ERROR",errors:s.error.flatten()});if(o)r.body=s.data;return n?n():void 0}catch{return He({status:"error",message:"Invalid JSON payload"})}};return t.__schema=e,t},Ay=(e)=>{if(e&&"_def"in e)return ec(e);if(e&&(e.kind||e.type||e[Symbol.for("TypeBox.Kind")]))return Qa(e);return Za(e)};var ho=(e)=>{if(e&&"_def"in e)return(r)=>{let n=e.safeParse(r);return n.success?{ok:!0,data:n.data}:{ok:!1,error:n.error.flatten()}};let t=uo.Compile(e);return(r)=>{if(t.Check(r))return{ok:!0,data:r};let n=t.Errors(r).First();return{ok:!1,error:{message:n?.message||"Invalid input",path:n?.path}}}},rs=(e,t)=>{let r=e?.properties;if(!r||typeof r!=="object")return null;let n=[];for(let[o,i]of Object.entries(r)){let s=JSON.stringify(o),a=`${t}[${s}]`,c=rs(i,a);if(c)n.push(`${s}: (${a} && typeof ${a} === 'object' && !Array.isArray(${a})) ? ${c} : ${a}`);else n.push(`${s}: ${a}`)}return`{ ${n.join(", ")} }`},ky=(e)=>{if(!e||"_def"in e)return null;if(e.type==="array"&&e.items){let r=rs(e.items,"item");if(!r)return null;return Function(`return function(arr) {
2
+ var{defineProperty:Ps,getOwnPropertyNames:yu,getOwnPropertyDescriptor:gu}=Object,hu=Object.prototype.hasOwnProperty;function xu(e){return this[e]}var Iu=(e)=>{var t=($i??=new WeakMap).get(e),r;if(t)return t;if(t=Ps({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var n of yu(e))if(!hu.call(t,n))Ps(t,n,{get:xu.bind(e,n),enumerable:!(r=gu(e,n))||r.enumerable})}return $i.set(e,t),t},$i;var bu=(e)=>e;function Ru(e,t){this[e]=bu.bind(null,t)}var ks=(e,t)=>{for(var r in t)Ps(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Ru.bind(t,r)})};var _u=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var eu={};ks(eu,{BARE_CONFIG:()=>Xn,initConfig:()=>bs});var yi,Xn,bs=(e={})=>(Xn={...yi,...e,hash:{...yi.hash,...e.hash}},Xn);var Rs=_u(()=>{yi={hash:{algorithm:"argon2id",memoryCost:65536,timeCost:2},port:3000},Xn=yi});var us={};ks(us,{BRAND:()=>Xl,DIRTY:()=>tn,EMPTY_PATH:()=>kl,INVALID:()=>j,NEVER:()=>My,OK:()=>rt,ParseStatus:()=>Xe,Schema:()=>z,ZodAny:()=>nn,ZodArray:()=>qt,ZodBigInt:()=>Mr,ZodBoolean:()=>Nn,ZodBranded:()=>cs,ZodCatch:()=>Dn,ZodDate:()=>rn,ZodDefault:()=>vn,ZodDiscriminatedUnion:()=>as,ZodEffects:()=>zt,ZodEnum:()=>jr,ZodError:()=>pt,ZodFirstPartyTypeKind:()=>U,ZodFunction:()=>Fn,ZodIntersection:()=>Un,ZodIssueCode:()=>b,ZodLazy:()=>Ln,ZodLiteral:()=>Kn,ZodMap:()=>xo,ZodNaN:()=>Io,ZodNativeEnum:()=>Bn,ZodNever:()=>tr,ZodNull:()=>jn,ZodNullable:()=>hr,ZodNumber:()=>Nr,ZodObject:()=>Fe,ZodOptional:()=>Gt,ZodParsedType:()=>S,ZodPipeline:()=>bo,ZodPromise:()=>sn,ZodReadonly:()=>qn,ZodRecord:()=>ho,ZodSchema:()=>z,ZodSet:()=>on,ZodString:()=>Dt,ZodSymbol:()=>yo,ZodTransformer:()=>zt,ZodTuple:()=>rr,ZodType:()=>z,ZodUndefined:()=>Mn,ZodUnion:()=>En,ZodUnknown:()=>Fr,ZodVoid:()=>go,addIssueToContext:()=>_,any:()=>sy,array:()=>uy,bigint:()=>ey,boolean:()=>rc,coerce:()=>Ny,custom:()=>Za,date:()=>ty,datetimeRegex:()=>Ya,defaultErrorMap:()=>yr,discriminatedUnion:()=>py,effect:()=>$y,enum:()=>_y,function:()=>Iy,getErrorMap:()=>Cn,getParsedType:()=>er,instanceof:()=>Ql,intersection:()=>ly,isAborted:()=>ss,isAsync:()=>An,isDirty:()=>is,isValid:()=>Tr,late:()=>Yl,lazy:()=>by,literal:()=>Ry,makeIssue:()=>lo,map:()=>hy,nan:()=>Zl,nativeEnum:()=>Oy,never:()=>ay,null:()=>oy,nullable:()=>Py,number:()=>tc,object:()=>dy,objectUtil:()=>oi,oboolean:()=>Fy,onumber:()=>Ty,optional:()=>Sy,ostring:()=>Ay,pipeline:()=>Cy,preprocess:()=>ky,promise:()=>wy,quotelessJson:()=>$l,record:()=>gy,set:()=>xy,setErrorMap:()=>Pl,strictObject:()=>fy,string:()=>ec,symbol:()=>ry,transformer:()=>$y,tuple:()=>yy,undefined:()=>ny,union:()=>my,unknown:()=>iy,util:()=>X,void:()=>cy});var li={};ks(li,{Any:()=>Sr,Argument:()=>dc,Array:()=>ln,AsyncIterator:()=>yn,Awaited:()=>Hn,BigInt:()=>bn,Boolean:()=>Go,Capitalize:()=>Pc,Composite:()=>mc,Const:()=>pc,Constructor:()=>gn,ConstructorParameters:()=>lc,Date:()=>ds,Enum:()=>yc,Exclude:()=>zn,Extends:()=>kn,Extract:()=>Vn,Function:()=>Qt,Index:()=>wr,InstanceType:()=>bc,Instantiate:()=>_c,Integer:()=>Oc,Intersect:()=>Ze,Iterator:()=>Rn,KeyOf:()=>_n,Literal:()=>ie,Lowercase:()=>kc,Mapped:()=>sa,Module:()=>qc,Never:()=>q,Not:()=>Gc,Null:()=>fs,Number:()=>_t,Object:()=>ue,Omit:()=>Er,Optional:()=>Qe,Parameters:()=>Hc,Partial:()=>Jn,Pick:()=>Ur,Promise:()=>Vo,Readonly:()=>dt,ReadonlyOptional:()=>gs,Record:()=>hs,Recursive:()=>zc,Ref:()=>$t,RegExp:()=>Vc,Required:()=>Wn,Rest:()=>Jc,ReturnType:()=>Wc,String:()=>Et,Symbol:()=>ms,TemplateLiteral:()=>zo,Transform:()=>Qc,Tuple:()=>Ot,Uint8Array:()=>ls,Uncapitalize:()=>Cc,Undefined:()=>ps,Union:()=>ce,Unknown:()=>Pr,Unsafe:()=>Ni,Uppercase:()=>Ac,Void:()=>Zc});function Co(e){return at(e)&&globalThis.Symbol.asyncIterator in e}function Ao(e){return at(e)&&globalThis.Symbol.iterator in e}function To(e){return e instanceof globalThis.Promise}function fn(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function mn(e){return e instanceof globalThis.Uint8Array}function Fo(e,t){return t in e}function at(e){return e!==null&&typeof e==="object"}function Le(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function nt(e){return e===void 0}function Lr(e){return e===null}function Kr(e){return typeof e==="boolean"}function B(e){return typeof e==="number"}function No(e){return globalThis.Number.isInteger(e)}function lt(e){return typeof e==="bigint"}function qe(e){return typeof e==="string"}function Mo(e){return typeof e==="function"}function Br(e){return typeof e==="symbol"}function jo(e){return lt(e)||Kr(e)||Lr(e)||B(e)||qe(e)||Br(e)||nt(e)}var ge;(function(e){e.InstanceMode="default",e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(i,a){return e.ExactOptionalPropertyTypes?a in i:i[a]!==void 0}e.IsExactOptionalProperty=t;function r(i){let a=at(i);return e.AllowArrayObject?a:a&&!Le(i)}e.IsObjectLike=r;function n(i){return r(i)&&!(i instanceof Date)&&!(i instanceof Uint8Array)}e.IsRecordLike=n;function o(i){return e.AllowNaN?B(i):Number.isFinite(i)}e.IsNumberLike=o;function s(i){let a=nt(i);return e.AllowNullVoid?a||i===null:a}e.IsVoidLike=s})(ge||(ge={}));var Si=new Map;function Cs(e){return Si.has(e)}function As(e){return Si.get(e)}var Pi=new Map;function Yn(e){return Pi.has(e)}function Ts(e){return Pi.get(e)}function ki(e){return be(e)&&!Ke(e)&&!br(e)&&Symbol.asyncIterator in e}function Ke(e){return Array.isArray(e)}function Lo(e){return typeof e==="bigint"}function Ir(e){return typeof e==="boolean"}function pn(e){return e instanceof globalThis.Date}function Ci(e){return typeof e==="function"}function Ai(e){return be(e)&&!Ke(e)&&!br(e)&&Symbol.iterator in e}function Ti(e){return e===null}function yt(e){return typeof e==="number"}function be(e){return typeof e==="object"&&e!==null}function Ko(e){return e instanceof globalThis.RegExp}function he(e){return typeof e==="string"}function Fi(e){return typeof e==="symbol"}function br(e){return e instanceof globalThis.Uint8Array}function xe(e){return e===void 0}function Ou(e){return globalThis.Object.freeze(e).map((t)=>Qn(t))}function wu(e){return e}function $u(e){return e}function Su(e){return e}function Pu(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Qn(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Qn(e[r]);return globalThis.Object.freeze(t)}function Qn(e){return Ke(e)?Ou(e):pn(e)?wu(e):br(e)?$u(e):Ko(e)?Su(e):be(e)?Pu(e):e}function ku(e){return e.map((t)=>Bo(t))}function Cu(e){return new Date(e.getTime())}function Au(e){return new Uint8Array(e)}function Tu(e){return new RegExp(e.source,e.flags)}function Fu(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Bo(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Bo(e[r]);return t}function Bo(e){return Ke(e)?ku(e):pn(e)?Cu(e):br(e)?Au(e):Ko(e)?Tu(e):be(e)?Fu(e):e}function Re(e){return Bo(e)}function g(e,t){let r=t!==void 0?{...t,...e}:e;switch(ge.InstanceMode){case"freeze":return Qn(r);case"clone":return Re(r);default:return r}}var we=Symbol.for("TypeBox.Transform"),Xt=Symbol.for("TypeBox.Readonly"),Ve=Symbol.for("TypeBox.Optional"),Yt=Symbol.for("TypeBox.Hint"),I=Symbol.for("TypeBox.Kind");function Ni(e={}){return g({[I]:e[I]??"Unsafe"},e)}class se extends Error{constructor(e){super(e)}}function te(e){return g({[I]:"MappedResult",properties:e})}function Nu(e,t){let{[t]:r,...n}=e;return n}function Ce(e,t){return t.reduce((r,n)=>Nu(r,n),e)}function ln(e,t){return g({[I]:"Array",type:"array",items:e},t)}function yn(e,t){return g({[I]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function gn(e,t,r){return g({[I]:"Constructor",type:"Constructor",parameters:e,returns:t},r)}function Qt(e,t,r){return g({[I]:"Function",type:"Function",parameters:e,returns:t},r)}function Ie(e,t,r){return g({[I]:"Computed",target:e,parameters:t},r)}function q(e){return g({[I]:"Never",not:{}},e)}function hn(e){return be(e)&&e[Xt]==="Readonly"}function ct(e){return be(e)&&e[Ve]==="Optional"}function Fs(e){return Q(e,"Any")}function Ns(e){return Q(e,"Argument")}function At(e){return Q(e,"Array")}function Dr(e){return Q(e,"AsyncIterator")}function qr(e){return Q(e,"BigInt")}function or(e){return Q(e,"Boolean")}function Tt(e){return Q(e,"Computed")}function Ft(e){return Q(e,"Constructor")}function Mu(e){return Q(e,"Date")}function Nt(e){return Q(e,"Function")}function Mt(e){return Q(e,"Integer")}function Ae(e){return Q(e,"Intersect")}function Gr(e){return Q(e,"Iterator")}function Q(e,t){return be(e)&&I in e&&e[I]===t}function vo(e){return Ir(e)||yt(e)||he(e)}function gt(e){return Q(e,"Literal")}function ht(e){return Q(e,"MappedKey")}function _e(e){return Q(e,"MappedResult")}function Rr(e){return Q(e,"Never")}function ju(e){return Q(e,"Not")}function Zn(e){return Q(e,"Null")}function jt(e){return Q(e,"Number")}function Ee(e){return Q(e,"Object")}function Hr(e){return Q(e,"Promise")}function zr(e){return Q(e,"Record")}function Me(e){return Q(e,"Ref")}function Ms(e){return Q(e,"RegExp")}function sr(e){return Q(e,"String")}function eo(e){return Q(e,"Symbol")}function xt(e){return Q(e,"TemplateLiteral")}function Eu(e){return Q(e,"This")}function ne(e){return be(e)&&we in e}function It(e){return Q(e,"Tuple")}function ir(e){return Q(e,"Undefined")}function ee(e){return Q(e,"Union")}function Uu(e){return Q(e,"Uint8Array")}function Lu(e){return Q(e,"Unknown")}function Ku(e){return Q(e,"Unsafe")}function Bu(e){return Q(e,"Void")}function vu(e){return be(e)&&I in e&&he(e[I])}function $e(e){return Fs(e)||Ns(e)||At(e)||or(e)||qr(e)||Dr(e)||Tt(e)||Ft(e)||Mu(e)||Nt(e)||Mt(e)||Ae(e)||Gr(e)||gt(e)||ht(e)||_e(e)||Rr(e)||ju(e)||Zn(e)||jt(e)||Ee(e)||Hr(e)||zr(e)||Me(e)||Ms(e)||sr(e)||eo(e)||xt(e)||Eu(e)||It(e)||ir(e)||ee(e)||Uu(e)||Lu(e)||Ku(e)||Bu(e)||vu(e)}function Du(e){return g(Ce(e,[Ve]))}function qu(e){return g({...e,[Ve]:"Optional"})}function Gu(e,t){return t===!1?Du(e):qu(e)}function Qe(e,t){let r=t??!0;return _e(e)?Mi(e,r):Gu(e,r)}function Hu(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Qe(e[n],t);return r}function zu(e,t){return Hu(e.properties,t)}function Mi(e,t){let r=zu(e,t);return te(r)}function to(e,t={}){let r=e.every((o)=>Ee(o)),n=$e(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return g(t.unevaluatedProperties===!1||$e(t.unevaluatedProperties)||r?{...n,[I]:"Intersect",type:"object",allOf:e}:{...n,[I]:"Intersect",allOf:e},t)}function Vu(e){return e.every((t)=>ct(t))}function Ju(e){return Ce(e,[Ve])}function ji(e){return e.map((t)=>ct(t)?Ju(t):t)}function Wu(e,t){return Vu(e)?Qe(to(ji(e),t)):to(ji(e),t)}function Do(e,t={}){if(e.length===1)return g(e[0],t);if(e.length===0)return q(t);if(e.some((r)=>ne(r)))throw Error("Cannot intersect transform types");return Wu(e,t)}function Ze(e,t){if(e.length===1)return g(e[0],t);if(e.length===0)return q(t);if(e.some((r)=>ne(r)))throw Error("Cannot intersect transform types");return to(e,t)}function ro(e,t){return g({[I]:"Union",anyOf:e},t)}function Xu(e){return e.some((t)=>ct(t))}function Ei(e){return e.map((t)=>ct(t)?Yu(t):t)}function Yu(e){return Ce(e,[Ve])}function Qu(e,t){return Xu(e)?Qe(ro(Ei(e),t)):ro(Ei(e),t)}function Zt(e,t){return e.length===1?g(e[0],t):e.length===0?q(t):Qu(e,t)}function ce(e,t){return e.length===0?q(t):e.length===1?g(e[0],t):ro(e,t)}class js extends se{}function Zu(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Es(e,t,r){return e[t]===r&&e.charCodeAt(t-1)!==92}function cr(e,t){return Es(e,t,"(")}function no(e,t){return Es(e,t,")")}function Ui(e,t){return Es(e,t,"|")}function ed(e){if(!(cr(e,0)&&no(e,e.length-1)))return!1;let t=0;for(let r=0;r<e.length;r++){if(cr(e,r))t+=1;if(no(e,r))t-=1;if(t===0&&r!==e.length-1)return!1}return!0}function td(e){return e.slice(1,e.length-1)}function rd(e){let t=0;for(let r=0;r<e.length;r++){if(cr(e,r))t+=1;if(no(e,r))t-=1;if(Ui(e,r)&&t===0)return!0}return!1}function nd(e){for(let t=0;t<e.length;t++)if(cr(e,t))return!0;return!1}function od(e){let[t,r]=[0,0],n=[];for(let s=0;s<e.length;s++){if(cr(e,s))t+=1;if(no(e,s))t-=1;if(Ui(e,s)&&t===0){let i=e.slice(r,s);if(i.length>0)n.push(xn(i));r=s+1}}let o=e.slice(r);if(o.length>0)n.push(xn(o));if(n.length===0)return{type:"const",const:""};if(n.length===1)return n[0];return{type:"or",expr:n}}function sd(e){function t(o,s){if(!cr(o,s))throw new js("TemplateLiteralParser: Index must point to open parens");let i=0;for(let a=s;a<o.length;a++){if(cr(o,a))i+=1;if(no(o,a))i-=1;if(i===0)return[s,a]}throw new js("TemplateLiteralParser: Unclosed group parens in expression")}function r(o,s){for(let i=s;i<o.length;i++)if(cr(o,i))return[s,i];return[s,o.length]}let n=[];for(let o=0;o<e.length;o++)if(cr(e,o)){let[s,i]=t(e,o),a=e.slice(s,i+1);n.push(xn(a)),o=i}else{let[s,i]=r(e,o),a=e.slice(s,i);if(a.length>0)n.push(xn(a));o=i-1}return n.length===0?{type:"const",const:""}:n.length===1?n[0]:{type:"and",expr:n}}function xn(e){return ed(e)?xn(td(e)):rd(e)?od(e):nd(e)?sd(e):{type:"const",const:Zu(e)}}function In(e){return xn(e.slice(1,e.length-1))}class Li extends se{}function id(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="0"&&e.expr[1].type==="const"&&e.expr[1].const==="[1-9][0-9]*"}function ad(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="true"&&e.expr[1].type==="const"&&e.expr[1].const==="false"}function cd(e){return e.type==="const"&&e.const===".*"}function Vr(e){return id(e)||cd(e)?!1:ad(e)?!0:e.type==="and"?e.expr.every((t)=>Vr(t)):e.type==="or"?e.expr.every((t)=>Vr(t)):e.type==="const"?!0:(()=>{throw new Li("Unknown expression type")})()}function Ki(e){let t=In(e.pattern);return Vr(t)}class Bi extends se{}function*vi(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let r of vi(e.slice(1)))yield`${t}${r}`}function*ud(e){return yield*vi(e.expr.map((t)=>[...oo(t)]))}function*dd(e){for(let t of e.expr)yield*oo(t)}function*fd(e){return yield e.const}function*oo(e){return e.type==="and"?yield*ud(e):e.type==="or"?yield*dd(e):e.type==="const"?yield*fd(e):(()=>{throw new Bi("Unknown expression")})()}function qo(e){let t=In(e.pattern);return Vr(t)?[...oo(t)]:[]}function ie(e,t){return g({[I]:"Literal",const:e,type:typeof e},t)}function Go(e){return g({[I]:"Boolean",type:"boolean"},e)}function bn(e){return g({[I]:"BigInt",type:"bigint"},e)}function _t(e){return g({[I]:"Number",type:"number"},e)}function Et(e){return g({[I]:"String",type:"string"},e)}function*md(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield Go():t==="number"?yield _t():t==="bigint"?yield bn():t==="string"?yield Et():yield(()=>{let r=t.split("|").map((n)=>ie(n.trim()));return r.length===0?q():r.length===1?r[0]:Zt(r)})()}function*pd(e){if(e[1]!=="{"){let t=ie("$"),r=Us(e.slice(1));return yield*[t,...r]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let r=md(e.slice(2,t)),n=Us(e.slice(t+1));return yield*[...r,...n]}yield ie(e)}function*Us(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let r=ie(e.slice(0,t)),n=pd(e.slice(t));return yield*[r,...n]}yield ie(e)}function Di(e){return[...Us(e)]}var qi="(true|false)",Ho="(0|[1-9][0-9]*)",Gi="(.*)";var _r="^(0|[1-9][0-9]*)$",Or="^(.*)$",Hi="^(?!.*)$";class zi extends se{}function ld(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vi(e,t){return xt(e)?e.pattern.slice(1,e.pattern.length-1):ee(e)?`(${e.anyOf.map((r)=>Vi(r,t)).join("|")})`:jt(e)?`${t}${Ho}`:Mt(e)?`${t}${Ho}`:qr(e)?`${t}${Ho}`:sr(e)?`${t}${Gi}`:gt(e)?`${t}${ld(e.const.toString())}`:or(e)?`${t}${qi}`:(()=>{throw new zi(`Unexpected Kind '${e[I]}'`)})()}function Ls(e){return`^${e.map((t)=>Vi(t,"")).join("")}$`}function Jr(e){let r=qo(e).map((n)=>ie(n));return Zt(r)}function zo(e,t){let r=he(e)?Ls(Di(e)):Ls(e);return g({[I]:"TemplateLiteral",type:"string",pattern:r},t)}function yd(e){return qo(e).map((r)=>r.toString())}function gd(e){let t=[];for(let r of e)t.push(...ut(r));return t}function hd(e){return[e.toString()]}function ut(e){return[...new Set(xt(e)?yd(e):ee(e)?gd(e.anyOf):gt(e)?hd(e.const):jt(e)?["[number]"]:Mt(e)?["[number]"]:[])]}function xd(e,t,r){let n={};for(let o of Object.getOwnPropertyNames(t))n[o]=wr(e,ut(t[o]),r);return n}function Id(e,t,r){return xd(e,t.properties,r)}function Ji(e,t,r){let n=Id(e,t,r);return te(n)}function Xi(e,t){return e.map((r)=>Yi(r,t))}function bd(e){return e.filter((t)=>!Rr(t))}function Rd(e,t){return Do(bd(Xi(e,t)))}function _d(e){return e.some((t)=>Rr(t))?[]:e}function Od(e,t){return Zt(_d(Xi(e,t)))}function wd(e,t){return t in e?e[t]:t==="[number]"?Zt(e):q()}function $d(e,t){return t==="[number]"?e:q()}function Sd(e,t){return t in e?e[t]:q()}function Yi(e,t){return Ae(e)?Rd(e.allOf,t):ee(e)?Od(e.anyOf,t):It(e)?wd(e.items??[],t):At(e)?$d(e.items,t):Ee(e)?Sd(e.properties,t):q()}function so(e,t){return t.map((r)=>Yi(e,r))}function Wi(e,t){return Zt(so(e,t))}function wr(e,t,r){if(Me(e)||Me(t)){if(!$e(e)||!$e(t))throw new se("Index types using Ref parameters require both Type and Key to be of TSchema");return Ie("Index",[e,t])}if(_e(t))return Ji(e,t,r);if(ht(t))return Qi(e,t,r);return g($e(t)?Wi(e,ut(t)):Wi(e,t),r)}function Pd(e,t,r){return{[t]:wr(e,[t],Re(r))}}function kd(e,t,r){return t.reduce((n,o)=>({...n,...Pd(e,o,r)}),{})}function Cd(e,t,r){return kd(e,t.keys,r)}function Qi(e,t,r){let n=Cd(e,t,r);return te(n)}function Rn(e,t){return g({[I]:"Iterator",type:"Iterator",items:e},t)}function Ad(e){return globalThis.Object.keys(e).filter((t)=>!ct(e[t]))}function Td(e,t){let r=Ad(e),n=r.length>0?{[I]:"Object",type:"object",required:r,properties:e}:{[I]:"Object",type:"object",properties:e};return g(n,t)}var ue=Td;function Vo(e,t){return g({[I]:"Promise",type:"Promise",item:e},t)}function Fd(e){return g(Ce(e,[Xt]))}function Nd(e){return g({...e,[Xt]:"Readonly"})}function Md(e,t){return t===!1?Fd(e):Nd(e)}function dt(e,t){let r=t??!0;return _e(e)?Zi(e,r):Md(e,r)}function jd(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=dt(e[n],t);return r}function Ed(e,t){return jd(e.properties,t)}function Zi(e,t){let r=Ed(e,t);return te(r)}function Ot(e,t){return g(e.length>0?{[I]:"Tuple",type:"array",items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[I]:"Tuple",type:"array",minItems:e.length,maxItems:e.length},t)}function ea(e,t){return e.includes(t)}function ta(e){return[...new Set(e)]}function Ud(e,t){return e.filter((r)=>t.includes(r))}function Ld(e,t){return e.reduce((r,n)=>Ud(r,n),t)}function ra(e){return e.length===1?e[0]:e.length>1?Ld(e.slice(1),e[0]):[]}function na(e){let t=[];for(let r of e)t.push(...r);return t}function oa(e,t){return e in t?wt(e,t[e]):te(t)}function Kd(e){return{[e]:ie(e)}}function Bd(e){let t={};for(let r of e)t[r]=ie(r);return t}function vd(e,t){return ea(t,e)?Kd(e):Bd(t)}function Dd(e,t){let r=vd(e,t);return oa(e,r)}function io(e,t){return t.map((r)=>wt(e,r))}function qd(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(t))r[n]=wt(e,t[n]);return r}function wt(e,t){let r={...t};return ct(t)?Qe(wt(e,Ce(t,[Ve]))):hn(t)?dt(wt(e,Ce(t,[Xt]))):_e(t)?oa(e,t.properties):ht(t)?Dd(e,t.keys):Ft(t)?gn(io(e,t.parameters),wt(e,t.returns),r):Nt(t)?Qt(io(e,t.parameters),wt(e,t.returns),r):Dr(t)?yn(wt(e,t.items),r):Gr(t)?Rn(wt(e,t.items),r):Ae(t)?Ze(io(e,t.allOf),r):ee(t)?ce(io(e,t.anyOf),r):It(t)?Ot(io(e,t.items??[]),r):Ee(t)?ue(qd(e,t.properties),r):At(t)?ln(wt(e,t.items),r):Hr(t)?Vo(wt(e,t.item),r):t}function Gd(e,t){let r={};for(let n of e)r[n]=wt(n,t);return r}function sa(e,t,r){let n=$e(e)?ut(e):e,o=t({[I]:"MappedKey",keys:n}),s=Gd(n,o);return ue(s,r)}function $t(...e){let[t,r]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new se("Ref: $ref must be a string");return g({[I]:"Ref",$ref:t},r)}function ia(e){let t=[];for(let r of e)t.push(St(r));return t}function Hd(e){let t=ia(e);return na(t)}function zd(e){let t=ia(e);return ra(t)}function Vd(e){return e.map((t,r)=>r.toString())}function Jd(e){return["[number]"]}function Wd(e){return globalThis.Object.getOwnPropertyNames(e)}function Xd(e){if(!Ks)return[];return globalThis.Object.getOwnPropertyNames(e).map((r)=>r[0]==="^"&&r[r.length-1]==="$"?r.slice(1,r.length-1):r)}function St(e){return Ae(e)?Hd(e.allOf):ee(e)?zd(e.anyOf):It(e)?Vd(e.items??[]):At(e)?Jd(e.items):Ee(e)?Wd(e.properties):zr(e)?Xd(e.patternProperties):[]}var Ks=!1;function ur(e){Ks=!0;let t=St(e);return Ks=!1,`^(${t.map((n)=>`(${n})`).join("|")})$`}function Yd(e,t){return Ie("KeyOf",[Ie(e,t)])}function Qd(e){return Ie("KeyOf",[$t(e)])}function Zd(e,t){let r=St(e),n=ef(r),o=Zt(n);return g(o,t)}function ef(e){return e.map((t)=>t==="[number]"?_t():ie(t))}function _n(e,t){return Tt(e)?Yd(e.target,e.parameters):Me(e)?Qd(e.$ref):_e(e)?aa(e,t):Zd(e,t)}function tf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=_n(e[n],Re(t));return r}function rf(e,t){return tf(e.properties,t)}function aa(e,t){let r=rf(e,t);return te(r)}function Jo(e){let t=St(e),r=so(e,t);return t.map((n,o)=>[t[o],r[o]])}function nf(e){return e.allOf.every((t)=>dr(t))}function of(e){return e.anyOf.some((t)=>dr(t))}function sf(e){return!dr(e.not)}function dr(e){return e[I]==="Intersect"?nf(e):e[I]==="Union"?of(e):e[I]==="Not"?sf(e):e[I]==="Undefined"?!0:!1}function af(e){switch(e.errorType){case l.ArrayContains:return"Expected array to contain at least one matching value";case l.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case l.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case l.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case l.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case l.ArrayUniqueItems:return"Expected array elements to be unique";case l.Array:return"Expected array";case l.AsyncIterator:return"Expected AsyncIterator";case l.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case l.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case l.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case l.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case l.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case l.BigInt:return"Expected bigint";case l.Boolean:return"Expected boolean";case l.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case l.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case l.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case l.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case l.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case l.Date:return"Expected Date";case l.Function:return"Expected function";case l.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case l.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case l.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case l.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case l.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case l.Integer:return"Expected integer";case l.IntersectUnevaluatedProperties:return"Unexpected property";case l.Intersect:return"Expected all values to match";case l.Iterator:return"Expected Iterator";case l.Literal:return`Expected ${typeof e.schema.const==="string"?`'${e.schema.const}'`:e.schema.const}`;case l.Never:return"Never";case l.Not:return"Value should not match";case l.Null:return"Expected null";case l.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case l.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case l.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case l.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case l.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case l.Number:return"Expected number";case l.Object:return"Expected object";case l.ObjectAdditionalProperties:return"Unexpected property";case l.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case l.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case l.ObjectRequiredProperty:return"Expected required property";case l.Promise:return"Expected Promise";case l.RegExp:return"Expected string to match regular expression";case l.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case l.StringFormat:return`Expected string to match '${e.schema.format}' format`;case l.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case l.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case l.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case l.String:return"Expected string";case l.Symbol:return"Expected symbol";case l.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case l.Tuple:return"Expected tuple";case l.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case l.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case l.Uint8Array:return"Expected Uint8Array";case l.Undefined:return"Expected undefined";case l.Union:return"Expected union value";case l.Void:return"Expected void";case l.Kind:return`Expected kind '${e.schema[I]}'`;default:return"Unknown error type"}}var cf=af;function ca(){return cf}class ua extends se{constructor(e){super(`Unable to dereference schema with $id '${e.$ref}'`);this.schema=e}}function uf(e,t){let r=t.find((n)=>n.$id===e.$ref);if(r===void 0)throw new ua(e);return Ge(r,t)}function $r(e,t){if(!qe(e.$id)||t.some((r)=>r.$id===e.$id))return t;return t.push(e),t}function Ge(e,t){return e[I]==="This"||e[I]==="Ref"?uf(e,t):e}class da extends se{constructor(e){super("Unable to hash value");this.value=e}}var bt;(function(e){e[e.Undefined=0]="Undefined",e[e.Null=1]="Null",e[e.Boolean=2]="Boolean",e[e.Number=3]="Number",e[e.String=4]="String",e[e.Object=5]="Object",e[e.Array=6]="Array",e[e.Date=7]="Date",e[e.Uint8Array=8]="Uint8Array",e[e.Symbol=9]="Symbol",e[e.BigInt=10]="BigInt"})(bt||(bt={}));var On=BigInt("14695981039346656037"),[df,ff]=[BigInt("1099511628211"),BigInt("18446744073709551616")],mf=Array.from({length:256}).map((e,t)=>BigInt(t)),fa=new Float64Array(1),ma=new DataView(fa.buffer),pa=new Uint8Array(fa.buffer);function*pf(e){let t=e===0?1:Math.ceil(Math.floor(Math.log2(e)+1)/8);for(let r=0;r<t;r++)yield e>>8*(t-1-r)&255}function lf(e){et(bt.Array);for(let t of e)wn(t)}function yf(e){et(bt.Boolean),et(e?1:0)}function gf(e){et(bt.BigInt),ma.setBigInt64(0,e);for(let t of pa)et(t)}function hf(e){et(bt.Date),wn(e.getTime())}function xf(e){et(bt.Null)}function If(e){et(bt.Number),ma.setFloat64(0,e);for(let t of pa)et(t)}function bf(e){et(bt.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())wn(t),wn(e[t])}function Rf(e){et(bt.String);for(let t=0;t<e.length;t++)for(let r of pf(e.charCodeAt(t)))et(r)}function _f(e){et(bt.Symbol),wn(e.description)}function Of(e){et(bt.Uint8Array);for(let t=0;t<e.length;t++)et(e[t])}function wf(e){return et(bt.Undefined)}function wn(e){if(Le(e))return lf(e);if(Kr(e))return yf(e);if(lt(e))return gf(e);if(fn(e))return hf(e);if(Lr(e))return xf(e);if(B(e))return If(e);if(at(e))return bf(e);if(qe(e))return Rf(e);if(Br(e))return _f(e);if(mn(e))return Of(e);if(nt(e))return wf(e);throw new da(e)}function et(e){On=On^mf[e],On=On*df%ff}function $n(e){return On=BigInt("14695981039346656037"),wn(e),On}function Sr(e){return g({[I]:"Any"},e)}function Pr(e){return g({[I]:"Unknown"},e)}var $f=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function la(e){try{return new RegExp(e),!0}catch{return!1}}function Bs(e){if(!he(e))return!1;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=7&&r<=13||r===27||r===127)return!1}return!0}function ya(e){return vs(e)||Se(e)}function ao(e){return xe(e)||Lo(e)}function le(e){return xe(e)||yt(e)}function vs(e){return xe(e)||Ir(e)}function de(e){return xe(e)||he(e)}function Sf(e){return xe(e)||he(e)&&Bs(e)&&la(e)}function Pf(e){return xe(e)||he(e)&&Bs(e)}function ga(e){return xe(e)||Se(e)}function Wo(e){return be(e)&&e[Ve]==="Optional"}function Ut(e){return Z(e,"Any")&&de(e.$id)}function kf(e){return Z(e,"Argument")&&yt(e.index)}function Wr(e){return Z(e,"Array")&&e.type==="array"&&de(e.$id)&&Se(e.items)&&le(e.minItems)&&le(e.maxItems)&&vs(e.uniqueItems)&&ga(e.contains)&&le(e.minContains)&&le(e.maxContains)}function Ds(e){return Z(e,"AsyncIterator")&&e.type==="AsyncIterator"&&de(e.$id)&&Se(e.items)}function Xo(e){return Z(e,"BigInt")&&e.type==="bigint"&&de(e.$id)&&ao(e.exclusiveMaximum)&&ao(e.exclusiveMinimum)&&ao(e.maximum)&&ao(e.minimum)&&ao(e.multipleOf)}function Xr(e){return Z(e,"Boolean")&&e.type==="boolean"&&de(e.$id)}function Cf(e){return Z(e,"Computed")&&he(e.target)&&Ke(e.parameters)&&e.parameters.every((t)=>Se(t))}function Yo(e){return Z(e,"Constructor")&&e.type==="Constructor"&&de(e.$id)&&Ke(e.parameters)&&e.parameters.every((t)=>Se(t))&&Se(e.returns)}function Qo(e){return Z(e,"Date")&&e.type==="Date"&&de(e.$id)&&le(e.exclusiveMaximumTimestamp)&&le(e.exclusiveMinimumTimestamp)&&le(e.maximumTimestamp)&&le(e.minimumTimestamp)&&le(e.multipleOfTimestamp)}function Zo(e){return Z(e,"Function")&&e.type==="Function"&&de(e.$id)&&Ke(e.parameters)&&e.parameters.every((t)=>Se(t))&&Se(e.returns)}function fr(e){return Z(e,"Integer")&&e.type==="integer"&&de(e.$id)&&le(e.exclusiveMaximum)&&le(e.exclusiveMinimum)&&le(e.maximum)&&le(e.minimum)&&le(e.multipleOf)}function ha(e){return be(e)&&Object.entries(e).every(([t,r])=>Bs(t)&&Se(r))}function Yr(e){return Z(e,"Intersect")&&(he(e.type)&&e.type!=="object"?!1:!0)&&Ke(e.allOf)&&e.allOf.every((t)=>Se(t)&&!jf(t))&&de(e.type)&&(vs(e.unevaluatedProperties)||ga(e.unevaluatedProperties))&&de(e.$id)}function qs(e){return Z(e,"Iterator")&&e.type==="Iterator"&&de(e.$id)&&Se(e.items)}function Z(e,t){return be(e)&&I in e&&e[I]===t}function xa(e){return kr(e)&&he(e.const)}function Ia(e){return kr(e)&&yt(e.const)}function ba(e){return kr(e)&&Ir(e.const)}function kr(e){return Z(e,"Literal")&&de(e.$id)&&Af(e.const)}function Af(e){return Ir(e)||yt(e)||he(e)}function Tf(e){return Z(e,"MappedKey")&&Ke(e.keys)&&e.keys.every((t)=>yt(t)||he(t))}function Ff(e){return Z(e,"MappedResult")&&ha(e.properties)}function Cr(e){return Z(e,"Never")&&be(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function Sn(e){return Z(e,"Not")&&Se(e.not)}function Gs(e){return Z(e,"Null")&&e.type==="null"&&de(e.$id)}function ft(e){return Z(e,"Number")&&e.type==="number"&&de(e.$id)&&le(e.exclusiveMaximum)&&le(e.exclusiveMinimum)&&le(e.maximum)&&le(e.minimum)&&le(e.multipleOf)}function Te(e){return Z(e,"Object")&&e.type==="object"&&de(e.$id)&&ha(e.properties)&&ya(e.additionalProperties)&&le(e.minProperties)&&le(e.maxProperties)}function Hs(e){return Z(e,"Promise")&&e.type==="Promise"&&de(e.$id)&&Se(e.item)}function Je(e){return Z(e,"Record")&&e.type==="object"&&de(e.$id)&&ya(e.additionalProperties)&&be(e.patternProperties)&&((t)=>{let r=Object.getOwnPropertyNames(t.patternProperties);return r.length===1&&la(r[0])&&be(t.patternProperties)&&Se(t.patternProperties[r[0]])})(e)}function Nf(e){return Z(e,"Ref")&&de(e.$id)&&he(e.$ref)}function co(e){return Z(e,"RegExp")&&de(e.$id)&&he(e.source)&&he(e.flags)&&le(e.maxLength)&&le(e.minLength)}function Lt(e){return Z(e,"String")&&e.type==="string"&&de(e.$id)&&le(e.minLength)&&le(e.maxLength)&&Sf(e.pattern)&&Pf(e.format)}function uo(e){return Z(e,"Symbol")&&e.type==="symbol"&&de(e.$id)}function fo(e){return Z(e,"TemplateLiteral")&&e.type==="string"&&he(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function Mf(e){return Z(e,"This")&&de(e.$id)&&he(e.$ref)}function jf(e){return be(e)&&we in e}function es(e){return Z(e,"Tuple")&&e.type==="array"&&de(e.$id)&&yt(e.minItems)&&yt(e.maxItems)&&e.minItems===e.maxItems&&(xe(e.items)&&xe(e.additionalItems)&&e.minItems===0||Ke(e.items)&&e.items.every((t)=>Se(t)))}function Qr(e){return Z(e,"Undefined")&&e.type==="undefined"&&de(e.$id)}function mr(e){return Z(e,"Union")&&de(e.$id)&&be(e)&&Ke(e.anyOf)&&e.anyOf.every((t)=>Se(t))}function mo(e){return Z(e,"Uint8Array")&&e.type==="Uint8Array"&&de(e.$id)&&le(e.minByteLength)&&le(e.maxByteLength)}function Kt(e){return Z(e,"Unknown")&&de(e.$id)}function Ef(e){return Z(e,"Unsafe")}function ts(e){return Z(e,"Void")&&e.type==="void"&&de(e.$id)}function Uf(e){return be(e)&&I in e&&he(e[I])&&!$f.includes(e[I])}function Se(e){return be(e)&&(Ut(e)||kf(e)||Wr(e)||Xr(e)||Xo(e)||Ds(e)||Cf(e)||Yo(e)||Qo(e)||Zo(e)||fr(e)||Yr(e)||qs(e)||kr(e)||Tf(e)||Ff(e)||Cr(e)||Sn(e)||Gs(e)||ft(e)||Te(e)||Hs(e)||Je(e)||Nf(e)||co(e)||Lt(e)||uo(e)||fo(e)||Mf(e)||es(e)||Qr(e)||mr(e)||mo(e)||Kt(e)||Ef(e)||ts(e)||Uf(e))}class Sa extends se{}var h;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(h||(h={}));function Pt(e){return e===h.False?e:h.True}function Pn(e){throw new Sa(e)}function Be(e){return Cr(e)||Yr(e)||mr(e)||Kt(e)||Ut(e)}function ve(e,t){return Cr(t)?Ca(e,t):Yr(t)?rs(e,t):mr(t)?Xs(e,t):Kt(t)?Na(e,t):Ut(t)?Ws(e,t):Pn("StructuralRight")}function Ws(e,t){return h.True}function Lf(e,t){return Yr(t)?rs(e,t):mr(t)&&t.anyOf.some((r)=>Ut(r)||Kt(r))?h.True:mr(t)?h.Union:Kt(t)?h.True:Ut(t)?h.True:h.Union}function Kf(e,t){return Kt(e)?h.False:Ut(e)?h.Union:Cr(e)?h.True:h.False}function Bf(e,t){return Te(t)&&ns(t)?h.True:Be(t)?ve(e,t):!Wr(t)?h.False:Pt(fe(e.items,t.items))}function vf(e,t){return Be(t)?ve(e,t):!Ds(t)?h.False:Pt(fe(e.items,t.items))}function Df(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):Xo(t)?h.True:h.False}function Pa(e,t){return ba(e)?h.True:Xr(e)?h.True:h.False}function qf(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):Xr(t)?h.True:h.False}function Gf(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):!Yo(t)?h.False:e.parameters.length>t.parameters.length?h.False:!e.parameters.every((r,n)=>Pt(fe(t.parameters[n],r))===h.True)?h.False:Pt(fe(e.returns,t.returns))}function Hf(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):Qo(t)?h.True:h.False}function zf(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):!Zo(t)?h.False:e.parameters.length>t.parameters.length?h.False:!e.parameters.every((r,n)=>Pt(fe(t.parameters[n],r))===h.True)?h.False:Pt(fe(e.returns,t.returns))}function ka(e,t){return kr(e)&&yt(e.const)?h.True:ft(e)||fr(e)?h.True:h.False}function Vf(e,t){return fr(t)||ft(t)?h.True:Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):h.False}function rs(e,t){return t.allOf.every((r)=>fe(e,r)===h.True)?h.True:h.False}function Jf(e,t){return e.allOf.some((r)=>fe(r,t)===h.True)?h.True:h.False}function Wf(e,t){return Be(t)?ve(e,t):!qs(t)?h.False:Pt(fe(e.items,t.items))}function Xf(e,t){return kr(t)&&t.const===e.const?h.True:Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):Lt(t)?Fa(e,t):ft(t)?Aa(e,t):fr(t)?ka(e,t):Xr(t)?Pa(e,t):h.False}function Ca(e,t){return h.False}function Yf(e,t){return h.True}function _a(e){let[t,r]=[e,0];while(!0){if(!Sn(t))break;t=t.not,r+=1}return r%2===0?t:Pr()}function Qf(e,t){return Sn(e)?fe(_a(e),t):Sn(t)?fe(e,_a(t)):Pn("Invalid fallthrough for Not")}function Zf(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):Gs(t)?h.True:h.False}function Aa(e,t){return Ia(e)?h.True:ft(e)||fr(e)?h.True:h.False}function em(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):fr(t)||ft(t)?h.True:h.False}function mt(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function Oa(e){return ns(e)}function wa(e){return mt(e,0)||mt(e,1)&&"description"in e.properties&&mr(e.properties.description)&&e.properties.description.anyOf.length===2&&(Lt(e.properties.description.anyOf[0])&&Qr(e.properties.description.anyOf[1])||Lt(e.properties.description.anyOf[1])&&Qr(e.properties.description.anyOf[0]))}function zs(e){return mt(e,0)}function $a(e){return mt(e,0)}function tm(e){return mt(e,0)}function rm(e){return mt(e,0)}function nm(e){return ns(e)}function om(e){let t=_t();return mt(e,0)||mt(e,1)&&"length"in e.properties&&Pt(fe(e.properties.length,t))===h.True}function sm(e){return mt(e,0)}function ns(e){let t=_t();return mt(e,0)||mt(e,1)&&"length"in e.properties&&Pt(fe(e.properties.length,t))===h.True}function im(e){let t=Qt([Sr()],Sr());return mt(e,0)||mt(e,1)&&"then"in e.properties&&Pt(fe(e.properties.then,t))===h.True}function Ta(e,t){return fe(e,t)===h.False?h.False:Wo(e)&&!Wo(t)?h.False:h.True}function tt(e,t){return Kt(e)?h.False:Ut(e)?h.Union:Cr(e)||xa(e)&&Oa(t)||Ia(e)&&zs(t)||ba(e)&&$a(t)||uo(e)&&wa(t)||Xo(e)&&tm(t)||Lt(e)&&Oa(t)||uo(e)&&wa(t)||ft(e)&&zs(t)||fr(e)&&zs(t)||Xr(e)&&$a(t)||mo(e)&&nm(t)||Qo(e)&&rm(t)||Yo(e)&&sm(t)||Zo(e)&&om(t)?h.True:Je(e)&&Lt(Vs(e))?(()=>t[Yt]==="Record"?h.True:h.False)():Je(e)&&ft(Vs(e))?(()=>mt(t,0)?h.True:h.False)():h.False}function am(e,t){return Be(t)?ve(e,t):Je(t)?kt(e,t):!Te(t)?h.False:(()=>{for(let r of Object.getOwnPropertyNames(t.properties)){if(!(r in e.properties)&&!Wo(t.properties[r]))return h.False;if(Wo(t.properties[r]))return h.True;if(Ta(e.properties[r],t.properties[r])===h.False)return h.False}return h.True})()}function cm(e,t){return Be(t)?ve(e,t):Te(t)&&im(t)?h.True:!Hs(t)?h.False:Pt(fe(e.item,t.item))}function Vs(e){return _r in e.patternProperties?_t():(Or in e.patternProperties)?Et():Pn("Unknown record key pattern")}function Js(e){return _r in e.patternProperties?e.patternProperties[_r]:(Or in e.patternProperties)?e.patternProperties[Or]:Pn("Unable to get record value schema")}function kt(e,t){let[r,n]=[Vs(t),Js(t)];return xa(e)&&ft(r)&&Pt(fe(e,n))===h.True?h.True:mo(e)&&ft(r)?fe(e,n):Lt(e)&&ft(r)?fe(e,n):Wr(e)&&ft(r)?fe(e,n):Te(e)?(()=>{for(let o of Object.getOwnPropertyNames(e.properties))if(Ta(n,e.properties[o])===h.False)return h.False;return h.True})():h.False}function um(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):!Je(t)?h.False:fe(Js(e),Js(t))}function dm(e,t){let r=co(e)?Et():e,n=co(t)?Et():t;return fe(r,n)}function Fa(e,t){return kr(e)&&he(e.const)?h.True:Lt(e)?h.True:h.False}function fm(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):Lt(t)?h.True:h.False}function mm(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):uo(t)?h.True:h.False}function pm(e,t){return fo(e)?fe(Jr(e),t):fo(t)?fe(e,Jr(t)):Pn("Invalid fallthrough for TemplateLiteral")}function lm(e,t){return Wr(t)&&e.items!==void 0&&e.items.every((r)=>fe(r,t.items)===h.True)}function ym(e,t){return Cr(e)?h.True:Kt(e)?h.False:Ut(e)?h.Union:h.False}function gm(e,t){return Be(t)?ve(e,t):Te(t)&&ns(t)?h.True:Wr(t)&&lm(e,t)?h.True:!es(t)?h.False:xe(e.items)&&!xe(t.items)||!xe(e.items)&&xe(t.items)?h.False:xe(e.items)&&!xe(t.items)?h.True:e.items.every((r,n)=>fe(r,t.items[n])===h.True)?h.True:h.False}function hm(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):mo(t)?h.True:h.False}function xm(e,t){return Be(t)?ve(e,t):Te(t)?tt(e,t):Je(t)?kt(e,t):ts(t)?Rm(e,t):Qr(t)?h.True:h.False}function Xs(e,t){return t.anyOf.some((r)=>fe(e,r)===h.True)?h.True:h.False}function Im(e,t){return e.anyOf.every((r)=>fe(r,t)===h.True)?h.True:h.False}function Na(e,t){return h.True}function bm(e,t){return Cr(t)?Ca(e,t):Yr(t)?rs(e,t):mr(t)?Xs(e,t):Ut(t)?Ws(e,t):Lt(t)?Fa(e,t):ft(t)?Aa(e,t):fr(t)?ka(e,t):Xr(t)?Pa(e,t):Wr(t)?Kf(e,t):es(t)?ym(e,t):Te(t)?tt(e,t):Kt(t)?h.True:h.False}function Rm(e,t){return Qr(e)?h.True:Qr(e)?h.True:h.False}function _m(e,t){return Yr(t)?rs(e,t):mr(t)?Xs(e,t):Kt(t)?Na(e,t):Ut(t)?Ws(e,t):Te(t)?tt(e,t):ts(t)?h.True:h.False}function fe(e,t){return fo(e)||fo(t)?pm(e,t):co(e)||co(t)?dm(e,t):Sn(e)||Sn(t)?Qf(e,t):Ut(e)?Lf(e,t):Wr(e)?Bf(e,t):Xo(e)?Df(e,t):Xr(e)?qf(e,t):Ds(e)?vf(e,t):Yo(e)?Gf(e,t):Qo(e)?Hf(e,t):Zo(e)?zf(e,t):fr(e)?Vf(e,t):Yr(e)?Jf(e,t):qs(e)?Wf(e,t):kr(e)?Xf(e,t):Cr(e)?Yf(e,t):Gs(e)?Zf(e,t):ft(e)?em(e,t):Te(e)?am(e,t):Je(e)?um(e,t):Lt(e)?fm(e,t):uo(e)?mm(e,t):es(e)?gm(e,t):Hs(e)?cm(e,t):mo(e)?hm(e,t):Qr(e)?xm(e,t):mr(e)?Im(e,t):Kt(e)?bm(e,t):ts(e)?_m(e,t):Pn(`Unknown left type operand '${e[I]}'`)}function Ar(e,t){return fe(e,t)}function Om(e,t,r,n,o){let s={};for(let i of globalThis.Object.getOwnPropertyNames(e))s[i]=kn(e[i],t,r,n,Re(o));return s}function wm(e,t,r,n,o){return Om(e.properties,t,r,n,o)}function Ma(e,t,r,n,o){let s=wm(e,t,r,n,o);return te(s)}function $m(e,t,r,n){let o=Ar(e,t);return o===h.Union?ce([r,n]):o===h.True?r:n}function kn(e,t,r,n,o){return _e(e)?Ma(e,t,r,n,o):ht(e)?g(ja(e,t,r,n,o)):g($m(e,t,r,n),o)}function Sm(e,t,r,n,o){return{[e]:kn(ie(e),t,r,n,Re(o))}}function Pm(e,t,r,n,o){return e.reduce((s,i)=>({...s,...Sm(i,t,r,n,o)}),{})}function km(e,t,r,n,o){return Pm(e.keys,t,r,n,o)}function ja(e,t,r,n,o){let s=km(e,t,r,n,o);return te(s)}class Ea extends se{constructor(e){super("Unknown type");this.schema=e}}function Cm(e){return e[I]==="Any"||e[I]==="Unknown"}function J(e){return e!==void 0}function Am(e,t,r){return!0}function Tm(e,t,r){return!0}function Fm(e,t,r){if(!Le(r))return!1;if(J(e.minItems)&&!(r.length>=e.minItems))return!1;if(J(e.maxItems)&&!(r.length<=e.maxItems))return!1;if(!r.every((s)=>He(e.items,t,s)))return!1;if(e.uniqueItems===!0&&!function(){let s=new Set;for(let i of r){let a=$n(i);if(s.has(a))return!1;else s.add(a)}return!0}())return!1;if(!(J(e.contains)||B(e.minContains)||B(e.maxContains)))return!0;let n=J(e.contains)?e.contains:q(),o=r.reduce((s,i)=>He(n,t,i)?s+1:s,0);if(o===0)return!1;if(B(e.minContains)&&o<e.minContains)return!1;if(B(e.maxContains)&&o>e.maxContains)return!1;return!0}function Nm(e,t,r){return Co(r)}function Mm(e,t,r){if(!lt(r))return!1;if(J(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(J(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(J(e.maximum)&&!(r<=e.maximum))return!1;if(J(e.minimum)&&!(r>=e.minimum))return!1;if(J(e.multipleOf)&&r%e.multipleOf!==BigInt(0))return!1;return!0}function jm(e,t,r){return Kr(r)}function Em(e,t,r){return He(e.returns,t,r.prototype)}function Um(e,t,r){if(!fn(r))return!1;if(J(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp))return!1;if(J(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp))return!1;if(J(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp))return!1;if(J(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp))return!1;if(J(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0)return!1;return!0}function Lm(e,t,r){return Mo(r)}function Km(e,t,r){let n=globalThis.Object.values(e.$defs),o=e.$defs[e.$ref];return He(o,[...t,...n],r)}function Bm(e,t,r){if(!No(r))return!1;if(J(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(J(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(J(e.maximum)&&!(r<=e.maximum))return!1;if(J(e.minimum)&&!(r>=e.minimum))return!1;if(J(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function vm(e,t,r){let n=e.allOf.every((o)=>He(o,t,r));if(e.unevaluatedProperties===!1){let o=new RegExp(ur(e)),s=Object.getOwnPropertyNames(r).every((i)=>o.test(i));return n&&s}else if($e(e.unevaluatedProperties)){let o=new RegExp(ur(e)),s=Object.getOwnPropertyNames(r).every((i)=>o.test(i)||He(e.unevaluatedProperties,t,r[i]));return n&&s}else return n}function Dm(e,t,r){return Ao(r)}function qm(e,t,r){return r===e.const}function Gm(e,t,r){return!1}function Hm(e,t,r){return!He(e.not,t,r)}function zm(e,t,r){return Lr(r)}function Vm(e,t,r){if(!ge.IsNumberLike(r))return!1;if(J(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(J(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(J(e.minimum)&&!(r>=e.minimum))return!1;if(J(e.maximum)&&!(r<=e.maximum))return!1;if(J(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Jm(e,t,r){if(!ge.IsObjectLike(r))return!1;if(J(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(J(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let n=Object.getOwnPropertyNames(e.properties);for(let o of n){let s=e.properties[o];if(e.required&&e.required.includes(o)){if(!He(s,t,r[o]))return!1;if((dr(s)||Cm(s))&&!(o in r))return!1}else if(ge.IsExactOptionalProperty(r,o)&&!He(s,t,r[o]))return!1}if(e.additionalProperties===!1){let o=Object.getOwnPropertyNames(r);if(e.required&&e.required.length===n.length&&o.length===n.length)return!0;else return o.every((s)=>n.includes(s))}else if(typeof e.additionalProperties==="object")return Object.getOwnPropertyNames(r).every((s)=>n.includes(s)||He(e.additionalProperties,t,r[s]));else return!0}function Wm(e,t,r){return To(r)}function Xm(e,t,r){if(!ge.IsRecordLike(r))return!1;if(J(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(J(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let[n,o]=Object.entries(e.patternProperties)[0],s=new RegExp(n),i=Object.entries(r).every(([c,d])=>s.test(c)?He(o,t,d):!0),a=typeof e.additionalProperties==="object"?Object.entries(r).every(([c,d])=>!s.test(c)?He(e.additionalProperties,t,d):!0):!0,u=e.additionalProperties===!1?Object.getOwnPropertyNames(r).every((c)=>s.test(c)):!0;return i&&a&&u}function Ym(e,t,r){return He(Ge(e,t),t,r)}function Qm(e,t,r){let n=new RegExp(e.source,e.flags);if(J(e.minLength)){if(!(r.length>=e.minLength))return!1}if(J(e.maxLength)){if(!(r.length<=e.maxLength))return!1}return n.test(r)}function Zm(e,t,r){if(!qe(r))return!1;if(J(e.minLength)){if(!(r.length>=e.minLength))return!1}if(J(e.maxLength)){if(!(r.length<=e.maxLength))return!1}if(J(e.pattern)){if(!new RegExp(e.pattern).test(r))return!1}if(J(e.format)){if(!Cs(e.format))return!1;return As(e.format)(r)}return!0}function ep(e,t,r){return Br(r)}function tp(e,t,r){return qe(r)&&new RegExp(e.pattern).test(r)}function rp(e,t,r){return He(Ge(e,t),t,r)}function np(e,t,r){if(!Le(r))return!1;if(e.items===void 0&&r.length!==0)return!1;if(r.length!==e.maxItems)return!1;if(!e.items)return!0;for(let n=0;n<e.items.length;n++)if(!He(e.items[n],t,r[n]))return!1;return!0}function op(e,t,r){return nt(r)}function sp(e,t,r){return e.anyOf.some((n)=>He(n,t,r))}function ip(e,t,r){if(!mn(r))return!1;if(J(e.maxByteLength)&&!(r.length<=e.maxByteLength))return!1;if(J(e.minByteLength)&&!(r.length>=e.minByteLength))return!1;return!0}function ap(e,t,r){return!0}function cp(e,t,r){return ge.IsVoidLike(r)}function up(e,t,r){if(!Yn(e[I]))return!1;return Ts(e[I])(e,r)}function He(e,t,r){let n=J(e.$id)?$r(e,t):t,o=e;switch(o[I]){case"Any":return Am(o,n,r);case"Argument":return Tm(o,n,r);case"Array":return Fm(o,n,r);case"AsyncIterator":return Nm(o,n,r);case"BigInt":return Mm(o,n,r);case"Boolean":return jm(o,n,r);case"Constructor":return Em(o,n,r);case"Date":return Um(o,n,r);case"Function":return Lm(o,n,r);case"Import":return Km(o,n,r);case"Integer":return Bm(o,n,r);case"Intersect":return vm(o,n,r);case"Iterator":return Dm(o,n,r);case"Literal":return qm(o,n,r);case"Never":return Gm(o,n,r);case"Not":return Hm(o,n,r);case"Null":return zm(o,n,r);case"Number":return Vm(o,n,r);case"Object":return Jm(o,n,r);case"Promise":return Wm(o,n,r);case"Record":return Xm(o,n,r);case"Ref":return Ym(o,n,r);case"RegExp":return Qm(o,n,r);case"String":return Zm(o,n,r);case"Symbol":return ep(o,n,r);case"TemplateLiteral":return tp(o,n,r);case"This":return rp(o,n,r);case"Tuple":return np(o,n,r);case"Undefined":return op(o,n,r);case"Union":return sp(o,n,r);case"Uint8Array":return ip(o,n,r);case"Unknown":return ap(o,n,r);case"Void":return cp(o,n,r);default:if(!Yn(o[I]))throw new Ea(o);return up(o,n,r)}}function Zr(...e){return e.length===3?He(e[0],e[1],e[2]):He(e[0],[],e[1])}var l;(function(e){e[e.ArrayContains=0]="ArrayContains",e[e.ArrayMaxContains=1]="ArrayMaxContains",e[e.ArrayMaxItems=2]="ArrayMaxItems",e[e.ArrayMinContains=3]="ArrayMinContains",e[e.ArrayMinItems=4]="ArrayMinItems",e[e.ArrayUniqueItems=5]="ArrayUniqueItems",e[e.Array=6]="Array",e[e.AsyncIterator=7]="AsyncIterator",e[e.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",e[e.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",e[e.BigIntMaximum=10]="BigIntMaximum",e[e.BigIntMinimum=11]="BigIntMinimum",e[e.BigIntMultipleOf=12]="BigIntMultipleOf",e[e.BigInt=13]="BigInt",e[e.Boolean=14]="Boolean",e[e.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",e[e.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",e[e.DateMaximumTimestamp=17]="DateMaximumTimestamp",e[e.DateMinimumTimestamp=18]="DateMinimumTimestamp",e[e.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",e[e.Date=20]="Date",e[e.Function=21]="Function",e[e.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",e[e.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",e[e.IntegerMaximum=24]="IntegerMaximum",e[e.IntegerMinimum=25]="IntegerMinimum",e[e.IntegerMultipleOf=26]="IntegerMultipleOf",e[e.Integer=27]="Integer",e[e.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",e[e.Intersect=29]="Intersect",e[e.Iterator=30]="Iterator",e[e.Kind=31]="Kind",e[e.Literal=32]="Literal",e[e.Never=33]="Never",e[e.Not=34]="Not",e[e.Null=35]="Null",e[e.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",e[e.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",e[e.NumberMaximum=38]="NumberMaximum",e[e.NumberMinimum=39]="NumberMinimum",e[e.NumberMultipleOf=40]="NumberMultipleOf",e[e.Number=41]="Number",e[e.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",e[e.ObjectMaxProperties=43]="ObjectMaxProperties",e[e.ObjectMinProperties=44]="ObjectMinProperties",e[e.ObjectRequiredProperty=45]="ObjectRequiredProperty",e[e.Object=46]="Object",e[e.Promise=47]="Promise",e[e.RegExp=48]="RegExp",e[e.StringFormatUnknown=49]="StringFormatUnknown",e[e.StringFormat=50]="StringFormat",e[e.StringMaxLength=51]="StringMaxLength",e[e.StringMinLength=52]="StringMinLength",e[e.StringPattern=53]="StringPattern",e[e.String=54]="String",e[e.Symbol=55]="Symbol",e[e.TupleLength=56]="TupleLength",e[e.Tuple=57]="Tuple",e[e.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",e[e.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",e[e.Uint8Array=60]="Uint8Array",e[e.Undefined=61]="Undefined",e[e.Union=62]="Union",e[e.Void=63]="Void"})(l||(l={}));class Ua extends se{constructor(e){super("Unknown type");this.schema=e}}function pr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function W(e){return e!==void 0}class Ys{constructor(e){this.iterator=e}[Symbol.iterator](){return this.iterator}First(){let e=this.iterator.next();return e.done?void 0:e.value}}function O(e,t,r,n,o=[]){return{type:e,schema:t,path:r,value:n,message:ca()({errorType:e,path:r,schema:t,value:n,errors:o}),errors:o}}function*dp(e,t,r,n){}function*fp(e,t,r,n){}function*mp(e,t,r,n){if(!Le(n))return yield O(l.Array,e,r,n);if(W(e.minItems)&&!(n.length>=e.minItems))yield O(l.ArrayMinItems,e,r,n);if(W(e.maxItems)&&!(n.length<=e.maxItems))yield O(l.ArrayMaxItems,e,r,n);for(let i=0;i<n.length;i++)yield*ze(e.items,t,`${r}/${i}`,n[i]);if(e.uniqueItems===!0&&!function(){let i=new Set;for(let a of n){let u=$n(a);if(i.has(u))return!1;else i.add(u)}return!0}())yield O(l.ArrayUniqueItems,e,r,n);if(!(W(e.contains)||W(e.minContains)||W(e.maxContains)))return;let o=W(e.contains)?e.contains:q(),s=n.reduce((i,a,u)=>ze(o,t,`${r}${u}`,a).next().done===!0?i+1:i,0);if(s===0)yield O(l.ArrayContains,e,r,n);if(B(e.minContains)&&s<e.minContains)yield O(l.ArrayMinContains,e,r,n);if(B(e.maxContains)&&s>e.maxContains)yield O(l.ArrayMaxContains,e,r,n)}function*pp(e,t,r,n){if(!Co(n))yield O(l.AsyncIterator,e,r,n)}function*lp(e,t,r,n){if(!lt(n))return yield O(l.BigInt,e,r,n);if(W(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield O(l.BigIntExclusiveMaximum,e,r,n);if(W(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield O(l.BigIntExclusiveMinimum,e,r,n);if(W(e.maximum)&&!(n<=e.maximum))yield O(l.BigIntMaximum,e,r,n);if(W(e.minimum)&&!(n>=e.minimum))yield O(l.BigIntMinimum,e,r,n);if(W(e.multipleOf)&&n%e.multipleOf!==BigInt(0))yield O(l.BigIntMultipleOf,e,r,n)}function*yp(e,t,r,n){if(!Kr(n))yield O(l.Boolean,e,r,n)}function*gp(e,t,r,n){yield*ze(e.returns,t,r,n.prototype)}function*hp(e,t,r,n){if(!fn(n))return yield O(l.Date,e,r,n);if(W(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp))yield O(l.DateExclusiveMaximumTimestamp,e,r,n);if(W(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp))yield O(l.DateExclusiveMinimumTimestamp,e,r,n);if(W(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp))yield O(l.DateMaximumTimestamp,e,r,n);if(W(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp))yield O(l.DateMinimumTimestamp,e,r,n);if(W(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)yield O(l.DateMultipleOfTimestamp,e,r,n)}function*xp(e,t,r,n){if(!Mo(n))yield O(l.Function,e,r,n)}function*Ip(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref];yield*ze(s,[...t,...o],r,n)}function*bp(e,t,r,n){if(!No(n))return yield O(l.Integer,e,r,n);if(W(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield O(l.IntegerExclusiveMaximum,e,r,n);if(W(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield O(l.IntegerExclusiveMinimum,e,r,n);if(W(e.maximum)&&!(n<=e.maximum))yield O(l.IntegerMaximum,e,r,n);if(W(e.minimum)&&!(n>=e.minimum))yield O(l.IntegerMinimum,e,r,n);if(W(e.multipleOf)&&n%e.multipleOf!==0)yield O(l.IntegerMultipleOf,e,r,n)}function*Rp(e,t,r,n){let o=!1;for(let s of e.allOf)for(let i of ze(s,t,r,n))o=!0,yield i;if(o)return yield O(l.Intersect,e,r,n);if(e.unevaluatedProperties===!1){let s=new RegExp(ur(e));for(let i of Object.getOwnPropertyNames(n))if(!s.test(i))yield O(l.IntersectUnevaluatedProperties,e,`${r}/${i}`,n)}if(typeof e.unevaluatedProperties==="object"){let s=new RegExp(ur(e));for(let i of Object.getOwnPropertyNames(n))if(!s.test(i)){let a=ze(e.unevaluatedProperties,t,`${r}/${i}`,n[i]).next();if(!a.done)yield a.value}}}function*_p(e,t,r,n){if(!Ao(n))yield O(l.Iterator,e,r,n)}function*Op(e,t,r,n){if(n!==e.const)yield O(l.Literal,e,r,n)}function*wp(e,t,r,n){yield O(l.Never,e,r,n)}function*$p(e,t,r,n){if(ze(e.not,t,r,n).next().done===!0)yield O(l.Not,e,r,n)}function*Sp(e,t,r,n){if(!Lr(n))yield O(l.Null,e,r,n)}function*Pp(e,t,r,n){if(!ge.IsNumberLike(n))return yield O(l.Number,e,r,n);if(W(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield O(l.NumberExclusiveMaximum,e,r,n);if(W(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield O(l.NumberExclusiveMinimum,e,r,n);if(W(e.maximum)&&!(n<=e.maximum))yield O(l.NumberMaximum,e,r,n);if(W(e.minimum)&&!(n>=e.minimum))yield O(l.NumberMinimum,e,r,n);if(W(e.multipleOf)&&n%e.multipleOf!==0)yield O(l.NumberMultipleOf,e,r,n)}function*kp(e,t,r,n){if(!ge.IsObjectLike(n))return yield O(l.Object,e,r,n);if(W(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield O(l.ObjectMinProperties,e,r,n);if(W(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield O(l.ObjectMaxProperties,e,r,n);let o=Array.isArray(e.required)?e.required:[],s=Object.getOwnPropertyNames(e.properties),i=Object.getOwnPropertyNames(n);for(let a of o){if(i.includes(a))continue;yield O(l.ObjectRequiredProperty,e.properties[a],`${r}/${pr(a)}`,void 0)}if(e.additionalProperties===!1){for(let a of i)if(!s.includes(a))yield O(l.ObjectAdditionalProperties,e,`${r}/${pr(a)}`,n[a])}if(typeof e.additionalProperties==="object")for(let a of i){if(s.includes(a))continue;yield*ze(e.additionalProperties,t,`${r}/${pr(a)}`,n[a])}for(let a of s){let u=e.properties[a];if(e.required&&e.required.includes(a)){if(yield*ze(u,t,`${r}/${pr(a)}`,n[a]),dr(e)&&!(a in n))yield O(l.ObjectRequiredProperty,u,`${r}/${pr(a)}`,void 0)}else if(ge.IsExactOptionalProperty(n,a))yield*ze(u,t,`${r}/${pr(a)}`,n[a])}}function*Cp(e,t,r,n){if(!To(n))yield O(l.Promise,e,r,n)}function*Ap(e,t,r,n){if(!ge.IsRecordLike(n))return yield O(l.Object,e,r,n);if(W(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield O(l.ObjectMinProperties,e,r,n);if(W(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield O(l.ObjectMaxProperties,e,r,n);let[o,s]=Object.entries(e.patternProperties)[0],i=new RegExp(o);for(let[a,u]of Object.entries(n))if(i.test(a))yield*ze(s,t,`${r}/${pr(a)}`,u);if(typeof e.additionalProperties==="object"){for(let[a,u]of Object.entries(n))if(!i.test(a))yield*ze(e.additionalProperties,t,`${r}/${pr(a)}`,u)}if(e.additionalProperties===!1)for(let[a,u]of Object.entries(n)){if(i.test(a))continue;return yield O(l.ObjectAdditionalProperties,e,`${r}/${pr(a)}`,u)}}function*Tp(e,t,r,n){yield*ze(Ge(e,t),t,r,n)}function*Fp(e,t,r,n){if(!qe(n))return yield O(l.String,e,r,n);if(W(e.minLength)&&!(n.length>=e.minLength))yield O(l.StringMinLength,e,r,n);if(W(e.maxLength)&&!(n.length<=e.maxLength))yield O(l.StringMaxLength,e,r,n);if(!new RegExp(e.source,e.flags).test(n))return yield O(l.RegExp,e,r,n)}function*Np(e,t,r,n){if(!qe(n))return yield O(l.String,e,r,n);if(W(e.minLength)&&!(n.length>=e.minLength))yield O(l.StringMinLength,e,r,n);if(W(e.maxLength)&&!(n.length<=e.maxLength))yield O(l.StringMaxLength,e,r,n);if(qe(e.pattern)){if(!new RegExp(e.pattern).test(n))yield O(l.StringPattern,e,r,n)}if(qe(e.format)){if(!Cs(e.format))yield O(l.StringFormatUnknown,e,r,n);else if(!As(e.format)(n))yield O(l.StringFormat,e,r,n)}}function*Mp(e,t,r,n){if(!Br(n))yield O(l.Symbol,e,r,n)}function*jp(e,t,r,n){if(!qe(n))return yield O(l.String,e,r,n);if(!new RegExp(e.pattern).test(n))yield O(l.StringPattern,e,r,n)}function*Ep(e,t,r,n){yield*ze(Ge(e,t),t,r,n)}function*Up(e,t,r,n){if(!Le(n))return yield O(l.Tuple,e,r,n);if(e.items===void 0&&n.length!==0)return yield O(l.TupleLength,e,r,n);if(n.length!==e.maxItems)return yield O(l.TupleLength,e,r,n);if(!e.items)return;for(let o=0;o<e.items.length;o++)yield*ze(e.items[o],t,`${r}/${o}`,n[o])}function*Lp(e,t,r,n){if(!nt(n))yield O(l.Undefined,e,r,n)}function*Kp(e,t,r,n){if(Zr(e,t,n))return;let o=e.anyOf.map((s)=>new Ys(ze(s,t,r,n)));yield O(l.Union,e,r,n,o)}function*Bp(e,t,r,n){if(!mn(n))return yield O(l.Uint8Array,e,r,n);if(W(e.maxByteLength)&&!(n.length<=e.maxByteLength))yield O(l.Uint8ArrayMaxByteLength,e,r,n);if(W(e.minByteLength)&&!(n.length>=e.minByteLength))yield O(l.Uint8ArrayMinByteLength,e,r,n)}function*vp(e,t,r,n){}function*Dp(e,t,r,n){if(!ge.IsVoidLike(n))yield O(l.Void,e,r,n)}function*qp(e,t,r,n){if(!Ts(e[I])(e,n))yield O(l.Kind,e,r,n)}function*ze(e,t,r,n){let o=W(e.$id)?[...t,e]:t,s=e;switch(s[I]){case"Any":return yield*dp(s,o,r,n);case"Argument":return yield*fp(s,o,r,n);case"Array":return yield*mp(s,o,r,n);case"AsyncIterator":return yield*pp(s,o,r,n);case"BigInt":return yield*lp(s,o,r,n);case"Boolean":return yield*yp(s,o,r,n);case"Constructor":return yield*gp(s,o,r,n);case"Date":return yield*hp(s,o,r,n);case"Function":return yield*xp(s,o,r,n);case"Import":return yield*Ip(s,o,r,n);case"Integer":return yield*bp(s,o,r,n);case"Intersect":return yield*Rp(s,o,r,n);case"Iterator":return yield*_p(s,o,r,n);case"Literal":return yield*Op(s,o,r,n);case"Never":return yield*wp(s,o,r,n);case"Not":return yield*$p(s,o,r,n);case"Null":return yield*Sp(s,o,r,n);case"Number":return yield*Pp(s,o,r,n);case"Object":return yield*kp(s,o,r,n);case"Promise":return yield*Cp(s,o,r,n);case"Record":return yield*Ap(s,o,r,n);case"Ref":return yield*Tp(s,o,r,n);case"RegExp":return yield*Fp(s,o,r,n);case"String":return yield*Np(s,o,r,n);case"Symbol":return yield*Mp(s,o,r,n);case"TemplateLiteral":return yield*jp(s,o,r,n);case"This":return yield*Ep(s,o,r,n);case"Tuple":return yield*Up(s,o,r,n);case"Undefined":return yield*Lp(s,o,r,n);case"Union":return yield*Kp(s,o,r,n);case"Uint8Array":return yield*Bp(s,o,r,n);case"Unknown":return yield*vp(s,o,r,n);case"Void":return yield*Dp(s,o,r,n);default:if(!Yn(s[I]))throw new Ua(e);return yield*qp(s,o,r,n)}}function La(...e){let t=e.length===3?ze(e[0],e[1],"",e[2]):ze(e[0],[],"",e[1]);return new Ys(t)}class Qs extends se{constructor(e,t,r){super("Unable to decode value as it does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class Ka extends se{constructor(e,t,r,n){super(n instanceof Error?n.message:"Unknown error");this.schema=e,this.path=t,this.value=r,this.error=n}}function Pe(e,t,r){try{return ne(e)?e[we].Decode(r):r}catch(n){throw new Ka(e,t,r,n)}}function Gp(e,t,r,n){return Le(n)?Pe(e,r,n.map((o,s)=>Bt(e.items,t,`${r}/${s}`,o))):Pe(e,r,n)}function Hp(e,t,r,n){if(!at(n)||jo(n))return Pe(e,r,n);let o=Jo(e),s=o.map((d)=>d[0]),i={...n};for(let[d,m]of o)if(d in i)i[d]=Bt(m,t,`${r}/${d}`,i[d]);if(!ne(e.unevaluatedProperties))return Pe(e,r,i);let a=Object.getOwnPropertyNames(i),u=e.unevaluatedProperties,c={...i};for(let d of a)if(!s.includes(d))c[d]=Pe(u,`${r}/${d}`,c[d]);return Pe(e,r,c)}function zp(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],i=Bt(s,[...t,...o],r,n);return Pe(e,r,i)}function Vp(e,t,r,n){return Pe(e,r,Bt(e.not,t,r,n))}function Jp(e,t,r,n){if(!at(n))return Pe(e,r,n);let o=St(e),s={...n};for(let c of o){if(!Fo(s,c))continue;if(nt(s[c])&&(!ir(e.properties[c])||ge.IsExactOptionalProperty(s,c)))continue;s[c]=Bt(e.properties[c],t,`${r}/${c}`,s[c])}if(!$e(e.additionalProperties))return Pe(e,r,s);let i=Object.getOwnPropertyNames(s),a=e.additionalProperties,u={...s};for(let c of i)if(!o.includes(c))u[c]=Pe(a,`${r}/${c}`,u[c]);return Pe(e,r,u)}function Wp(e,t,r,n){if(!at(n))return Pe(e,r,n);let o=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(o),i={...n};for(let d of Object.getOwnPropertyNames(n))if(s.test(d))i[d]=Bt(e.patternProperties[o],t,`${r}/${d}`,i[d]);if(!$e(e.additionalProperties))return Pe(e,r,i);let a=Object.getOwnPropertyNames(i),u=e.additionalProperties,c={...i};for(let d of a)if(!s.test(d))c[d]=Pe(u,`${r}/${d}`,c[d]);return Pe(e,r,c)}function Xp(e,t,r,n){let o=Ge(e,t);return Pe(e,r,Bt(o,t,r,n))}function Yp(e,t,r,n){let o=Ge(e,t);return Pe(e,r,Bt(o,t,r,n))}function Qp(e,t,r,n){return Le(n)&&Le(e.items)?Pe(e,r,e.items.map((o,s)=>Bt(o,t,`${r}/${s}`,n[s]))):Pe(e,r,n)}function Zp(e,t,r,n){for(let o of e.anyOf){if(!Zr(o,t,n))continue;let s=Bt(o,t,r,n);return Pe(e,r,s)}return Pe(e,r,n)}function Bt(e,t,r,n){let o=$r(e,t),s=e;switch(e[I]){case"Array":return Gp(s,o,r,n);case"Import":return zp(s,o,r,n);case"Intersect":return Hp(s,o,r,n);case"Not":return Vp(s,o,r,n);case"Object":return Jp(s,o,r,n);case"Record":return Wp(s,o,r,n);case"Ref":return Xp(s,o,r,n);case"Symbol":return Pe(s,r,n);case"This":return Yp(s,o,r,n);case"Tuple":return Qp(s,o,r,n);case"Union":return Zp(s,o,r,n);default:return Pe(s,r,n)}}function Ba(e,t,r){return Bt(e,t,"",r)}class Zs extends se{constructor(e,t,r){super("The encoded value does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class va extends se{constructor(e,t,r,n){super(`${n instanceof Error?n.message:"Unknown error"}`);this.schema=e,this.path=t,this.value=r,this.error=n}}function We(e,t,r){try{return ne(e)?e[we].Encode(r):r}catch(n){throw new va(e,t,r,n)}}function el(e,t,r,n){let o=We(e,r,n);return Le(o)?o.map((s,i)=>vt(e.items,t,`${r}/${i}`,s)):o}function tl(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],i=We(e,r,n);return vt(s,[...t,...o],r,i)}function rl(e,t,r,n){let o=We(e,r,n);if(!at(n)||jo(n))return o;let s=Jo(e),i=s.map((m)=>m[0]),a={...o};for(let[m,x]of s)if(m in a)a[m]=vt(x,t,`${r}/${m}`,a[m]);if(!ne(e.unevaluatedProperties))return a;let u=Object.getOwnPropertyNames(a),c=e.unevaluatedProperties,d={...a};for(let m of u)if(!i.includes(m))d[m]=We(c,`${r}/${m}`,d[m]);return d}function nl(e,t,r,n){return We(e.not,r,We(e,r,n))}function ol(e,t,r,n){let o=We(e,r,n);if(!at(o))return o;let s=St(e),i={...o};for(let d of s){if(!Fo(i,d))continue;if(nt(i[d])&&(!ir(e.properties[d])||ge.IsExactOptionalProperty(i,d)))continue;i[d]=vt(e.properties[d],t,`${r}/${d}`,i[d])}if(!$e(e.additionalProperties))return i;let a=Object.getOwnPropertyNames(i),u=e.additionalProperties,c={...i};for(let d of a)if(!s.includes(d))c[d]=We(u,`${r}/${d}`,c[d]);return c}function sl(e,t,r,n){let o=We(e,r,n);if(!at(n))return o;let s=Object.getOwnPropertyNames(e.patternProperties)[0],i=new RegExp(s),a={...o};for(let m of Object.getOwnPropertyNames(n))if(i.test(m))a[m]=vt(e.patternProperties[s],t,`${r}/${m}`,a[m]);if(!$e(e.additionalProperties))return a;let u=Object.getOwnPropertyNames(a),c=e.additionalProperties,d={...a};for(let m of u)if(!i.test(m))d[m]=We(c,`${r}/${m}`,d[m]);return d}function il(e,t,r,n){let o=Ge(e,t),s=vt(o,t,r,n);return We(e,r,s)}function al(e,t,r,n){let o=Ge(e,t),s=vt(o,t,r,n);return We(e,r,s)}function cl(e,t,r,n){let o=We(e,r,n);return Le(e.items)?e.items.map((s,i)=>vt(s,t,`${r}/${i}`,o[i])):[]}function ul(e,t,r,n){for(let o of e.anyOf){if(!Zr(o,t,n))continue;let s=vt(o,t,r,n);return We(e,r,s)}for(let o of e.anyOf){let s=vt(o,t,r,n);if(!Zr(e,t,s))continue;return We(e,r,s)}return We(e,r,n)}function vt(e,t,r,n){let o=$r(e,t),s=e;switch(e[I]){case"Array":return el(s,o,r,n);case"Import":return tl(s,o,r,n);case"Intersect":return rl(s,o,r,n);case"Not":return nl(s,o,r,n);case"Object":return ol(s,o,r,n);case"Record":return sl(s,o,r,n);case"Ref":return il(s,o,r,n);case"This":return al(s,o,r,n);case"Tuple":return cl(s,o,r,n);case"Union":return ul(s,o,r,n);default:return We(s,r,n)}}function Da(e,t,r){return vt(e,t,"",r)}function dl(e,t){return ne(e)||De(e.items,t)}function fl(e,t){return ne(e)||De(e.items,t)}function ml(e,t){return ne(e)||De(e.returns,t)||e.parameters.some((r)=>De(r,t))}function pl(e,t){return ne(e)||De(e.returns,t)||e.parameters.some((r)=>De(r,t))}function ll(e,t){return ne(e)||ne(e.unevaluatedProperties)||e.allOf.some((r)=>De(r,t))}function yl(e,t){let r=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((o,s)=>[...o,e.$defs[s]],[]),n=e.$defs[e.$ref];return ne(e)||De(n,[...r,...t])}function gl(e,t){return ne(e)||De(e.items,t)}function hl(e,t){return ne(e)||De(e.not,t)}function xl(e,t){return ne(e)||Object.values(e.properties).some((r)=>De(r,t))||$e(e.additionalProperties)&&De(e.additionalProperties,t)}function Il(e,t){return ne(e)||De(e.item,t)}function bl(e,t){let r=Object.getOwnPropertyNames(e.patternProperties)[0],n=e.patternProperties[r];return ne(e)||De(n,t)||$e(e.additionalProperties)&&ne(e.additionalProperties)}function Rl(e,t){if(ne(e))return!0;return De(Ge(e,t),t)}function _l(e,t){if(ne(e))return!0;return De(Ge(e,t),t)}function Ol(e,t){return ne(e)||!nt(e.items)&&e.items.some((r)=>De(r,t))}function wl(e,t){return ne(e)||e.anyOf.some((r)=>De(r,t))}function De(e,t){let r=$r(e,t),n=e;if(e.$id&&ei.has(e.$id))return!1;if(e.$id)ei.add(e.$id);switch(e[I]){case"Array":return dl(n,r);case"AsyncIterator":return fl(n,r);case"Constructor":return ml(n,r);case"Function":return pl(n,r);case"Import":return yl(n,r);case"Intersect":return ll(n,r);case"Iterator":return gl(n,r);case"Not":return hl(n,r);case"Object":return xl(n,r);case"Promise":return Il(n,r);case"Record":return bl(n,r);case"Ref":return Rl(n,r);case"This":return _l(n,r);case"Tuple":return Ol(n,r);case"Union":return wl(n,r);default:return ne(e)}}var ei=new Set;function qa(e,t){return ei.clear(),De(e,t)}class Ga{constructor(e,t,r,n){this.schema=e,this.references=t,this.checkFunc=r,this.code=n,this.hasTransform=qa(e,t)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(e){return La(this.schema,this.references,e)}Check(e){return this.checkFunc(e)}Decode(e){if(!this.checkFunc(e))throw new Qs(this.schema,e,this.Errors(e).First());return this.hasTransform?Ba(this.schema,this.references,e):e}Encode(e){let t=this.hasTransform?Da(this.schema,this.references,e):e;if(!this.checkFunc(t))throw new Zs(this.schema,e,this.Errors(e).First());return t}}var lr;(function(e){function t(s){return s===36}e.DollarSign=t;function r(s){return s===95}e.IsUnderscore=r;function n(s){return s>=65&&s<=90||s>=97&&s<=122}e.IsAlpha=n;function o(s){return s>=48&&s<=57}e.IsNumeric=o})(lr||(lr={}));var os;(function(e){function t(s){if(s.length===0)return!1;return lr.IsNumeric(s.charCodeAt(0))}function r(s){if(t(s))return!1;for(let i=0;i<s.length;i++){let a=s.charCodeAt(i);if(!(lr.IsAlpha(a)||lr.IsNumeric(a)||lr.DollarSign(a)||lr.IsUnderscore(a)))return!1}return!0}function n(s){return s.replace(/'/g,"\\'")}function o(s,i){return r(i)?`${s}.${i}`:`${s}['${n(i)}']`}e.Encode=o})(os||(os={}));var ti;(function(e){function t(r){let n=[];for(let o=0;o<r.length;o++){let s=r.charCodeAt(o);if(lr.IsNumeric(s)||lr.IsAlpha(s))n.push(r.charAt(o));else n.push(`_${s}_`)}return n.join("").replace(/__/g,"_")}e.Encode=t})(ti||(ti={}));var ri;(function(e){function t(r){return r.replace(/'/g,"\\'")}e.Escape=t})(ri||(ri={}));class Ha extends se{constructor(e){super("Unknown type");this.schema=e}}class ni extends se{constructor(e){super("Preflight validation check failed to guard for the given schema");this.schema=e}}var en;(function(e){function t(i,a,u){return ge.ExactOptionalPropertyTypes?`('${a}' in ${i} ? ${u} : true)`:`(${os.Encode(i,a)} !== undefined ? ${u} : true)`}e.IsExactOptionalProperty=t;function r(i){return!ge.AllowArrayObject?`(typeof ${i} === 'object' && ${i} !== null && !Array.isArray(${i}))`:`(typeof ${i} === 'object' && ${i} !== null)`}e.IsObjectLike=r;function n(i){return!ge.AllowArrayObject?`(typeof ${i} === 'object' && ${i} !== null && !Array.isArray(${i}) && !(${i} instanceof Date) && !(${i} instanceof Uint8Array))`:`(typeof ${i} === 'object' && ${i} !== null && !(${i} instanceof Date) && !(${i} instanceof Uint8Array))`}e.IsRecordLike=n;function o(i){return ge.AllowNaN?`typeof ${i} === 'number'`:`Number.isFinite(${i})`}e.IsNumberLike=o;function s(i){return ge.AllowNullVoid?`(${i} === undefined || ${i} === null)`:`${i} === undefined`}e.IsVoidLike=s})(en||(en={}));var po;(function(e){function t(f){return f[I]==="Any"||f[I]==="Unknown"}function*r(f,w,p){yield"true"}function*n(f,w,p){yield"true"}function*o(f,w,p){yield`Array.isArray(${p})`;let[K,k]=[Po("value","any"),Po("acc","number")];if(B(f.maxItems))yield`${p}.length <= ${f.maxItems}`;if(B(f.minItems))yield`${p}.length >= ${f.minItems}`;let T=st(f.items,w,"value");if(yield`${p}.every((${K}) => ${T})`,Se(f.contains)||B(f.minContains)||B(f.maxContains)){let ye=Se(f.contains)?f.contains:q(),it=st(ye,w,"value"),nr=B(f.minContains)?[`(count >= ${f.minContains})`]:[],Ct=B(f.maxContains)?[`(count <= ${f.maxContains})`]:[],Wt=`const count = value.reduce((${k}, ${K}) => ${it} ? acc + 1 : acc, 0)`,ko=["(count > 0)",...nr,...Ct].join(" && ");yield`((${K}) => { ${Wt}; return ${ko}})(${p})`}if(f.uniqueItems===!0)yield`((${K}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${p})`}function*s(f,w,p){yield`(typeof value === 'object' && Symbol.asyncIterator in ${p})`}function*i(f,w,p){if(yield`(typeof ${p} === 'bigint')`,lt(f.exclusiveMaximum))yield`${p} < BigInt(${f.exclusiveMaximum})`;if(lt(f.exclusiveMinimum))yield`${p} > BigInt(${f.exclusiveMinimum})`;if(lt(f.maximum))yield`${p} <= BigInt(${f.maximum})`;if(lt(f.minimum))yield`${p} >= BigInt(${f.minimum})`;if(lt(f.multipleOf))yield`(${p} % BigInt(${f.multipleOf})) === 0`}function*a(f,w,p){yield`(typeof ${p} === 'boolean')`}function*u(f,w,p){yield*Ye(f.returns,w,`${p}.prototype`)}function*c(f,w,p){if(yield`(${p} instanceof Date) && Number.isFinite(${p}.getTime())`,B(f.exclusiveMaximumTimestamp))yield`${p}.getTime() < ${f.exclusiveMaximumTimestamp}`;if(B(f.exclusiveMinimumTimestamp))yield`${p}.getTime() > ${f.exclusiveMinimumTimestamp}`;if(B(f.maximumTimestamp))yield`${p}.getTime() <= ${f.maximumTimestamp}`;if(B(f.minimumTimestamp))yield`${p}.getTime() >= ${f.minimumTimestamp}`;if(B(f.multipleOfTimestamp))yield`(${p}.getTime() % ${f.multipleOfTimestamp}) === 0`}function*d(f,w,p){yield`(typeof ${p} === 'function')`}function*m(f,w,p){let K=globalThis.Object.getOwnPropertyNames(f.$defs).reduce((k,T)=>[...k,f.$defs[T]],[]);yield*Ye($t(f.$ref),[...w,...K],p)}function*x(f,w,p){if(yield`Number.isInteger(${p})`,B(f.exclusiveMaximum))yield`${p} < ${f.exclusiveMaximum}`;if(B(f.exclusiveMinimum))yield`${p} > ${f.exclusiveMinimum}`;if(B(f.maximum))yield`${p} <= ${f.maximum}`;if(B(f.minimum))yield`${p} >= ${f.minimum}`;if(B(f.multipleOf))yield`(${p} % ${f.multipleOf}) === 0`}function*y(f,w,p){let K=f.allOf.map((k)=>st(k,w,p)).join(" && ");if(f.unevaluatedProperties===!1){let k=dn(`${new RegExp(ur(f))};`),T=`Object.getOwnPropertyNames(${p}).every(key => ${k}.test(key))`;yield`(${K} && ${T})`}else if(Se(f.unevaluatedProperties)){let k=dn(`${new RegExp(ur(f))};`),T=`Object.getOwnPropertyNames(${p}).every(key => ${k}.test(key) || ${st(f.unevaluatedProperties,w,`${p}[key]`)})`;yield`(${K} && ${T})`}else yield`(${K})`}function*R(f,w,p){yield`(typeof value === 'object' && Symbol.iterator in ${p})`}function*C(f,w,p){if(typeof f.const==="number"||typeof f.const==="boolean")yield`(${p} === ${f.const})`;else yield`(${p} === '${ri.Escape(f.const)}')`}function*G(f,w,p){yield"false"}function*A(f,w,p){yield`(!${st(f.not,w,p)})`}function*M(f,w,p){yield`(${p} === null)`}function*V(f,w,p){if(yield en.IsNumberLike(p),B(f.exclusiveMaximum))yield`${p} < ${f.exclusiveMaximum}`;if(B(f.exclusiveMinimum))yield`${p} > ${f.exclusiveMinimum}`;if(B(f.maximum))yield`${p} <= ${f.maximum}`;if(B(f.minimum))yield`${p} >= ${f.minimum}`;if(B(f.multipleOf))yield`(${p} % ${f.multipleOf}) === 0`}function*H(f,w,p){if(yield en.IsObjectLike(p),B(f.minProperties))yield`Object.getOwnPropertyNames(${p}).length >= ${f.minProperties}`;if(B(f.maxProperties))yield`Object.getOwnPropertyNames(${p}).length <= ${f.maxProperties}`;let K=Object.getOwnPropertyNames(f.properties);for(let k of K){let T=os.Encode(p,k),ye=f.properties[k];if(f.required&&f.required.includes(k)){if(yield*Ye(ye,w,T),dr(ye)||t(ye))yield`('${k}' in ${p})`}else{let it=st(ye,w,T);yield en.IsExactOptionalProperty(p,k,it)}}if(f.additionalProperties===!1)if(f.required&&f.required.length===K.length)yield`Object.getOwnPropertyNames(${p}).length === ${K.length}`;else{let k=`[${K.map((T)=>`'${T}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${p}).every(key => ${k}.includes(key))`}if(typeof f.additionalProperties==="object"){let k=st(f.additionalProperties,w,`${p}[key]`),T=`[${K.map((ye)=>`'${ye}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${p}).every(key => ${T}.includes(key) || ${k}))`}}function*L(f,w,p){yield`${p} instanceof Promise`}function*v(f,w,p){if(yield en.IsRecordLike(p),B(f.minProperties))yield`Object.getOwnPropertyNames(${p}).length >= ${f.minProperties}`;if(B(f.maxProperties))yield`Object.getOwnPropertyNames(${p}).length <= ${f.maxProperties}`;let[K,k]=Object.entries(f.patternProperties)[0],T=dn(`${new RegExp(K)}`),ye=st(k,w,"value"),it=Se(f.additionalProperties)?st(f.additionalProperties,w,p):f.additionalProperties===!1?"false":"true",nr=`(${T}.test(key) ? ${ye} : ${it})`;yield`(Object.entries(${p}).every(([key, value]) => ${nr}))`}function*Y(f,w,p){let K=Ge(f,w);if(je.functions.has(f.$ref))return yield`${So(f.$ref)}(${p})`;yield*Ye(K,w,p)}function*Ne(f,w,p){let K=dn(`${new RegExp(f.source,f.flags)};`);if(yield`(typeof ${p} === 'string')`,B(f.maxLength))yield`${p}.length <= ${f.maxLength}`;if(B(f.minLength))yield`${p}.length >= ${f.minLength}`;yield`${K}.test(${p})`}function*P(f,w,p){if(yield`(typeof ${p} === 'string')`,B(f.maxLength))yield`${p}.length <= ${f.maxLength}`;if(B(f.minLength))yield`${p}.length >= ${f.minLength}`;if(f.pattern!==void 0)yield`${dn(`${new RegExp(f.pattern)};`)}.test(${p})`;if(f.format!==void 0)yield`format('${f.format}', ${p})`}function*ae(f,w,p){yield`(typeof ${p} === 'symbol')`}function*me(f,w,p){yield`(typeof ${p} === 'string')`,yield`${dn(`${new RegExp(f.pattern)};`)}.test(${p})`}function*E(f,w,p){yield`${So(f.$ref)}(${p})`}function*pe(f,w,p){if(yield`Array.isArray(${p})`,f.items===void 0)return yield`${p}.length === 0`;yield`(${p}.length === ${f.maxItems})`;for(let K=0;K<f.items.length;K++)yield`${st(f.items[K],w,`${p}[${K}]`)}`}function*oe(f,w,p){yield`${p} === undefined`}function*Oe(f,w,p){yield`(${f.anyOf.map((k)=>st(k,w,p)).join(" || ")})`}function*Ue(f,w,p){if(yield`${p} instanceof Uint8Array`,B(f.maxByteLength))yield`(${p}.length <= ${f.maxByteLength})`;if(B(f.minByteLength))yield`(${p}.length >= ${f.minByteLength})`}function*N(f,w,p){yield"true"}function*re(f,w,p){yield en.IsVoidLike(p)}function*ke(f,w,p){let K=je.instances.size;je.instances.set(K,f),yield`kind('${f[I]}', ${K}, ${p})`}function*Ye(f,w,p,K=!0){let k=qe(f.$id)?[...w,f]:w,T=f;if(K&&qe(f.$id)){let ye=So(f.$id);if(je.functions.has(ye))return yield`${ye}(${p})`;else{je.functions.set(ye,"<deferred>");let it=_i(ye,f,w,"value",!1);return je.functions.set(ye,it),yield`${ye}(${p})`}}switch(T[I]){case"Any":return yield*r(T,k,p);case"Argument":return yield*n(T,k,p);case"Array":return yield*o(T,k,p);case"AsyncIterator":return yield*s(T,k,p);case"BigInt":return yield*i(T,k,p);case"Boolean":return yield*a(T,k,p);case"Constructor":return yield*u(T,k,p);case"Date":return yield*c(T,k,p);case"Function":return yield*d(T,k,p);case"Import":return yield*m(T,k,p);case"Integer":return yield*x(T,k,p);case"Intersect":return yield*y(T,k,p);case"Iterator":return yield*R(T,k,p);case"Literal":return yield*C(T,k,p);case"Never":return yield*G(T,k,p);case"Not":return yield*A(T,k,p);case"Null":return yield*M(T,k,p);case"Number":return yield*V(T,k,p);case"Object":return yield*H(T,k,p);case"Promise":return yield*L(T,k,p);case"Record":return yield*v(T,k,p);case"Ref":return yield*Y(T,k,p);case"RegExp":return yield*Ne(T,k,p);case"String":return yield*P(T,k,p);case"Symbol":return yield*ae(T,k,p);case"TemplateLiteral":return yield*me(T,k,p);case"This":return yield*E(T,k,p);case"Tuple":return yield*pe(T,k,p);case"Undefined":return yield*oe(T,k,p);case"Union":return yield*Oe(T,k,p);case"Uint8Array":return yield*Ue(T,k,p);case"Unknown":return yield*N(T,k,p);case"Void":return yield*re(T,k,p);default:if(!Yn(T[I]))throw new Ha(f);return yield*ke(T,k,p)}}let je={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function st(f,w,p,K=!0){return`(${[...Ye(f,w,p,K)].join(" && ")})`}function So(f){return`check_${ti.Encode(f)}`}function dn(f){let w=`local_${je.variables.size}`;return je.variables.set(w,`const ${w} = ${f}`),w}function _i(f,w,p,K,k=!0){let[T,ye]=[`
3
+ `,(Wt)=>"".padStart(Wt," ")],it=Po("value","any"),nr=Oi("boolean"),Ct=[...Ye(w,p,K,k)].map((Wt)=>`${ye(4)}${Wt}`).join(` &&${T}`);return`function ${f}(${it})${nr} {${T}${ye(2)}return (${T}${Ct}${T}${ye(2)})
4
+ }`}function Po(f,w){let p=je.language==="typescript"?`: ${w}`:"";return`${f}${p}`}function Oi(f){return je.language==="typescript"?`: ${f}`:""}function fu(f,w,p){let K=_i("check",f,w,"value"),k=Po("value","any"),T=Oi("boolean"),ye=[...je.functions.values()],it=[...je.variables.values()],nr=qe(f.$id)?`return function check(${k})${T} {
5
+ return ${So(f.$id)}(value)
6
+ }`:`return ${K}`;return[...it,...ye,nr].join(`
7
+ `)}function wi(...f){let w={language:"javascript"},[p,K,k]=f.length===2&&Le(f[1])?[f[0],f[1],w]:f.length===2&&!Le(f[1])?[f[0],[],f[1]]:f.length===3?[f[0],f[1],f[2]]:f.length===1?[f[0],[],w]:[null,[],w];if(je.language=k.language,je.variables.clear(),je.functions.clear(),je.instances.clear(),!Se(p))throw new ni(p);for(let T of K)if(!Se(T))throw new ni(T);return fu(p,K,k)}e.Code=wi;function mu(f,w=[]){let p=wi(f,w,{language:"javascript"}),K=globalThis.Function("kind","format","hash",p),k=new Map(je.instances);function T(Ct,Wt,ko){if(!Yn(Ct)||!k.has(Wt))return!1;let pu=Ts(Ct),lu=k.get(Wt);return pu(lu,ko)}function ye(Ct,Wt){if(!Cs(Ct))return!1;return As(Ct)(Wt)}function it(Ct){return $n(Ct)}let nr=K(T,ye,it);return new Ga(f,w,nr,p)}e.Compile=mu})(po||(po={}));var X;(function(e){e.assertEqual=(o)=>{};function t(o){}e.assertIs=t;function r(o){throw Error()}e.assertNever=r,e.arrayToEnum=(o)=>{let s={};for(let i of o)s[i]=i;return s},e.getValidEnumValues=(o)=>{let s=e.objectKeys(o).filter((a)=>typeof o[o[a]]!=="number"),i={};for(let a of s)i[a]=o[a];return e.objectValues(i)},e.objectValues=(o)=>e.objectKeys(o).map(function(s){return o[s]}),e.objectKeys=typeof Object.keys==="function"?(o)=>Object.keys(o):(o)=>{let s=[];for(let i in o)if(Object.prototype.hasOwnProperty.call(o,i))s.push(i);return s},e.find=(o,s)=>{for(let i of o)if(s(i))return i;return},e.isInteger=typeof Number.isInteger==="function"?(o)=>Number.isInteger(o):(o)=>typeof o==="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map((i)=>typeof i==="string"?`'${i}'`:i).join(s)}e.joinValues=n,e.jsonStringifyReplacer=(o,s)=>{if(typeof s==="bigint")return s.toString();return s}})(X||(X={}));var oi;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(oi||(oi={}));var S=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),er=(e)=>{switch(typeof e){case"undefined":return S.undefined;case"string":return S.string;case"number":return Number.isNaN(e)?S.nan:S.number;case"boolean":return S.boolean;case"function":return S.function;case"bigint":return S.bigint;case"symbol":return S.symbol;case"object":if(Array.isArray(e))return S.array;if(e===null)return S.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return S.promise;if(typeof Map<"u"&&e instanceof Map)return S.map;if(typeof Set<"u"&&e instanceof Set)return S.set;if(typeof Date<"u"&&e instanceof Date)return S.date;return S.object;default:return S.unknown}};var b=X.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),$l=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class pt extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(r)=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(o){return o.message},r={_errors:[]},n=(o)=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)r._errors.push(t(s));else{let i=r,a=0;while(a<s.path.length){let u=s.path[a];if(a!==s.path.length-1)i[u]=i[u]||{_errors:[]};else i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(s));i=i[u],a++}}};return n(this),r}static assert(e){if(!(e instanceof pt))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,X.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(t)=>t.message){let t={},r=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];t[o]=t[o]||[],t[o].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}pt.create=(e)=>new pt(e);var Sl=(e,t)=>{let r;switch(e.code){case b.invalid_type:if(e.received===S.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case b.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,X.jsonStringifyReplacer)}`;break;case b.unrecognized_keys:r=`Unrecognized key(s) in object: ${X.joinValues(e.keys,", ")}`;break;case b.invalid_union:r="Invalid input";break;case b.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${X.joinValues(e.options)}`;break;case b.invalid_enum_value:r=`Invalid enum value. Expected ${X.joinValues(e.options)}, received '${e.received}'`;break;case b.invalid_arguments:r="Invalid function arguments";break;case b.invalid_return_type:r="Invalid function return type";break;case b.invalid_date:r="Invalid date";break;case b.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")r=`${r} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)r=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)r=`Invalid input: must end with "${e.validation.endsWith}"`;else X.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case b.too_small:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else r="Invalid input";break;case b.too_big:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else r="Invalid input";break;case b.custom:r="Invalid input";break;case b.invalid_intersection_types:r="Intersection results could not be merged";break;case b.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case b.not_finite:r="Number must be finite";break;default:r=t.defaultError,X.assertNever(e)}return{message:r}},yr=Sl;var za=yr;function Pl(e){za=e}function Cn(){return za}var lo=(e)=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",u=n.filter((c)=>!!c).slice().reverse();for(let c of u)a=c(i,{data:t,defaultError:a}).message;return{...o,path:s,message:a}},kl=[];function _(e,t){let r=Cn(),n=lo({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===yr?void 0:yr].filter((o)=>!!o)});e.common.issues.push(n)}class Xe{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,t){let r=[];for(let n of t){if(n.status==="aborted")return j;if(n.status==="dirty")e.dirty();r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let n of t){let o=await n.key,s=await n.value;r.push({key:o,value:s})}return Xe.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:o,value:s}=n;if(o.status==="aborted")return j;if(s.status==="aborted")return j;if(o.status==="dirty")e.dirty();if(s.status==="dirty")e.dirty();if(o.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet))r[o.value]=s.value}return{status:e.value,value:r}}}var j=Object.freeze({status:"aborted"}),tn=(e)=>({status:"dirty",value:e}),rt=(e)=>({status:"valid",value:e}),ss=(e)=>e.status==="aborted",is=(e)=>e.status==="dirty",Tr=(e)=>e.status==="valid",An=(e)=>typeof Promise<"u"&&e instanceof Promise;var F;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(F||(F={}));class Ht{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var Va=(e,t)=>{if(Tr(t))return{success:!0,data:t.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new pt(e.common.issues);return this._error=r,this._error}}}};function D(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:o};return{errorMap:(i,a)=>{let{message:u}=e;if(i.code==="invalid_enum_value")return{message:u??a.defaultError};if(typeof a.data>"u")return{message:u??n??a.defaultError};if(i.code!=="invalid_type")return{message:a.defaultError};return{message:u??r??a.defaultError}},description:o}}class z{get description(){return this._def.description}_getType(e){return er(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:er(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Xe,ctx:{common:e.parent.common,data:e.data,parsedType:er(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(An(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:er(e)},n=this._parseSync({data:e,path:r.path,parent:r});return Va(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:er(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return Tr(r)?{value:r.value}:{issues:t.common.issues}}catch(r){if(r?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((r)=>Tr(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:er(e)},n=this._parse({data:e,path:r.path,parent:r}),o=await(An(n)?n:Promise.resolve(n));return Va(r,o)}refine(e,t){let r=(n)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(n);else return t};return this._refinement((n,o)=>{let s=e(n),i=()=>o.addIssue({code:b.custom,...r(n)});if(typeof Promise<"u"&&s instanceof Promise)return s.then((a)=>{if(!a)return i(),!1;else return!0});if(!s)return i(),!1;else return!0})}refinement(e,t){return this._refinement((r,n)=>{if(!e(r))return n.addIssue(typeof t==="function"?t(r,n):t),!1;else return!0})}_refinement(e){return new zt({schema:this,typeName:U.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(t)=>this["~validate"](t)}}optional(){return Gt.create(this,this._def)}nullable(){return hr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qt.create(this)}promise(){return sn.create(this,this._def)}or(e){return En.create([this,e],this._def)}and(e){return Un.create(this,e,this._def)}transform(e){return new zt({...D(this._def),schema:this,typeName:U.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new vn({...D(this._def),innerType:this,defaultValue:t,typeName:U.ZodDefault})}brand(){return new cs({typeName:U.ZodBranded,type:this,...D(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new Dn({...D(this._def),innerType:this,catchValue:t,typeName:U.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return bo.create(this,e)}readonly(){return qn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var Cl=/^c[^\s-]{8,}$/i,Al=/^[0-9a-z]+$/,Tl=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Fl=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Nl=/^[a-z0-9_-]{21}$/i,Ml=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,jl=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,El=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ul="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",si,Ll=/^(?:(?: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])$/,Kl=/^(?:(?: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])$/,Bl=/^(([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]))$/,vl=/^(([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])$/,Dl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ql=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Wa="((\\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])))",Gl=new RegExp(`^${Wa}$`);function Xa(e){let t="[0-5]\\d";if(e.precision)t=`${t}\\.\\d{${e.precision}}`;else if(e.precision==null)t=`${t}(\\.\\d+)?`;let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Hl(e){return new RegExp(`^${Xa(e)}$`)}function Ya(e){let t=`${Wa}T${Xa(e)}`,r=[];if(r.push(e.local?"Z?":"Z"),e.offset)r.push("([+-]\\d{2}:?\\d{2})");return t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function zl(e,t){if((t==="v4"||!t)&&Ll.test(e))return!0;if((t==="v6"||!t)&&Bl.test(e))return!0;return!1}function Vl(e,t){if(!Ml.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));if(typeof o!=="object"||o===null)return!1;if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&o.alg!==t)return!1;return!0}catch{return!1}}function Jl(e,t){if((t==="v4"||!t)&&Kl.test(e))return!0;if((t==="v6"||!t)&&vl.test(e))return!0;return!1}class Dt extends z{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==S.string){let o=this._getOrReturnCtx(e);return _(o,{code:b.invalid_type,expected:S.string,received:o.parsedType}),j}let r=new Xe,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.length<o.value)n=this._getOrReturnCtx(e,n),_(n,{code:b.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="max"){if(e.data.length>o.value)n=this._getOrReturnCtx(e,n),_(n,{code:b.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="length"){let s=e.data.length>o.value,i=e.data.length<o.value;if(s||i){if(n=this._getOrReturnCtx(e,n),s)_(n,{code:b.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});else if(i)_(n,{code:b.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});r.dirty()}}else if(o.kind==="email"){if(!El.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"email",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="emoji"){if(!si)si=new RegExp(Ul,"u");if(!si.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"emoji",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="uuid"){if(!Fl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"uuid",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="nanoid"){if(!Nl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"nanoid",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid"){if(!Cl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"cuid",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid2"){if(!Al.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"cuid2",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ulid"){if(!Tl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"ulid",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),_(n,{validation:"url",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="regex"){if(o.regex.lastIndex=0,!o.regex.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"regex",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="trim")e.data=e.data.trim();else if(o.kind==="includes"){if(!e.data.includes(o.value,o.position))n=this._getOrReturnCtx(e,n),_(n,{code:b.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()}else if(o.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(o.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(o.kind==="startsWith"){if(!e.data.startsWith(o.value))n=this._getOrReturnCtx(e,n),_(n,{code:b.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="endsWith"){if(!e.data.endsWith(o.value))n=this._getOrReturnCtx(e,n),_(n,{code:b.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="datetime"){if(!Ya(o).test(e.data))n=this._getOrReturnCtx(e,n),_(n,{code:b.invalid_string,validation:"datetime",message:o.message}),r.dirty()}else if(o.kind==="date"){if(!Gl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{code:b.invalid_string,validation:"date",message:o.message}),r.dirty()}else if(o.kind==="time"){if(!Hl(o).test(e.data))n=this._getOrReturnCtx(e,n),_(n,{code:b.invalid_string,validation:"time",message:o.message}),r.dirty()}else if(o.kind==="duration"){if(!jl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"duration",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ip"){if(!zl(e.data,o.version))n=this._getOrReturnCtx(e,n),_(n,{validation:"ip",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="jwt"){if(!Vl(e.data,o.alg))n=this._getOrReturnCtx(e,n),_(n,{validation:"jwt",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cidr"){if(!Jl(e.data,o.version))n=this._getOrReturnCtx(e,n),_(n,{validation:"cidr",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64"){if(!Dl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"base64",code:b.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64url"){if(!ql.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"base64url",code:b.invalid_string,message:o.message}),r.dirty()}else X.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:b.invalid_string,...F.errToObj(r)})}_addCheck(e){return new Dt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...F.errToObj(e)})}url(e){return this._addCheck({kind:"url",...F.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...F.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...F.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...F.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...F.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...F.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...F.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...F.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...F.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...F.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...F.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...F.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...F.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...F.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...F.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...F.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...F.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...F.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...F.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...F.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...F.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...F.errToObj(t)})}nonempty(e){return this.min(1,F.errToObj(e))}trim(){return new Dt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Dt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Dt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxLength(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}Dt.create=(e)=>new Dt({checks:[],typeName:U.ZodString,coerce:e?.coerce??!1,...D(e)});function Wl(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}class Nr extends z{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce)e.data=Number(e.data);if(this._getType(e)!==S.number){let o=this._getOrReturnCtx(e);return _(o,{code:b.invalid_type,expected:S.number,received:o.parsedType}),j}let r=void 0,n=new Xe;for(let o of this._def.checks)if(o.kind==="int"){if(!X.isInteger(e.data))r=this._getOrReturnCtx(e,r),_(r,{code:b.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty()}else if(o.kind==="min"){if(o.inclusive?e.data<o.value:e.data<=o.value)r=this._getOrReturnCtx(e,r),_(r,{code:b.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="max"){if(o.inclusive?e.data>o.value:e.data>=o.value)r=this._getOrReturnCtx(e,r),_(r,{code:b.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(Wl(e.data,o.value)!==0)r=this._getOrReturnCtx(e,r),_(r,{code:b.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else if(o.kind==="finite"){if(!Number.isFinite(e.data))r=this._getOrReturnCtx(e,r),_(r,{code:b.not_finite,message:o.message}),n.dirty()}else X.assertNever(o);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,F.toString(t))}gt(e,t){return this.setLimit("min",e,!1,F.toString(t))}lte(e,t){return this.setLimit("max",e,!0,F.toString(t))}lt(e,t){return this.setLimit("max",e,!1,F.toString(t))}setLimit(e,t,r,n){return new Nr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:F.toString(n)}]})}_addCheck(e){return new Nr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:F.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:F.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:F.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:F.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:F.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:F.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:F.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:F.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:F.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&X.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;else if(r.kind==="min"){if(t===null||r.value>t)t=r.value}else if(r.kind==="max"){if(e===null||r.value<e)e=r.value}return Number.isFinite(t)&&Number.isFinite(e)}}Nr.create=(e)=>new Nr({checks:[],typeName:U.ZodNumber,coerce:e?.coerce||!1,...D(e)});class Mr extends z{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==S.bigint)return this._getInvalidInput(e);let r=void 0,n=new Xe;for(let o of this._def.checks)if(o.kind==="min"){if(o.inclusive?e.data<o.value:e.data<=o.value)r=this._getOrReturnCtx(e,r),_(r,{code:b.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()}else if(o.kind==="max"){if(o.inclusive?e.data>o.value:e.data>=o.value)r=this._getOrReturnCtx(e,r),_(r,{code:b.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(e.data%o.value!==BigInt(0))r=this._getOrReturnCtx(e,r),_(r,{code:b.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else X.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return _(t,{code:b.invalid_type,expected:S.bigint,received:t.parsedType}),j}gte(e,t){return this.setLimit("min",e,!0,F.toString(t))}gt(e,t){return this.setLimit("min",e,!1,F.toString(t))}lte(e,t){return this.setLimit("max",e,!0,F.toString(t))}lt(e,t){return this.setLimit("max",e,!1,F.toString(t))}setLimit(e,t,r,n){return new Mr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:F.toString(n)}]})}_addCheck(e){return new Mr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:F.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:F.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:F.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:F.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:F.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}Mr.create=(e)=>new Mr({checks:[],typeName:U.ZodBigInt,coerce:e?.coerce??!1,...D(e)});class Nn extends z{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==S.boolean){let r=this._getOrReturnCtx(e);return _(r,{code:b.invalid_type,expected:S.boolean,received:r.parsedType}),j}return rt(e.data)}}Nn.create=(e)=>new Nn({typeName:U.ZodBoolean,coerce:e?.coerce||!1,...D(e)});class rn extends z{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==S.date){let o=this._getOrReturnCtx(e);return _(o,{code:b.invalid_type,expected:S.date,received:o.parsedType}),j}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return _(o,{code:b.invalid_date}),j}let r=new Xe,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.getTime()<o.value)n=this._getOrReturnCtx(e,n),_(n,{code:b.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()}else if(o.kind==="max"){if(e.data.getTime()>o.value)n=this._getOrReturnCtx(e,n),_(n,{code:b.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()}else X.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new rn({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:F.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:F.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e!=null?new Date(e):null}}rn.create=(e)=>new rn({checks:[],coerce:e?.coerce||!1,typeName:U.ZodDate,...D(e)});class yo extends z{_parse(e){if(this._getType(e)!==S.symbol){let r=this._getOrReturnCtx(e);return _(r,{code:b.invalid_type,expected:S.symbol,received:r.parsedType}),j}return rt(e.data)}}yo.create=(e)=>new yo({typeName:U.ZodSymbol,...D(e)});class Mn extends z{_parse(e){if(this._getType(e)!==S.undefined){let r=this._getOrReturnCtx(e);return _(r,{code:b.invalid_type,expected:S.undefined,received:r.parsedType}),j}return rt(e.data)}}Mn.create=(e)=>new Mn({typeName:U.ZodUndefined,...D(e)});class jn extends z{_parse(e){if(this._getType(e)!==S.null){let r=this._getOrReturnCtx(e);return _(r,{code:b.invalid_type,expected:S.null,received:r.parsedType}),j}return rt(e.data)}}jn.create=(e)=>new jn({typeName:U.ZodNull,...D(e)});class nn extends z{constructor(){super(...arguments);this._any=!0}_parse(e){return rt(e.data)}}nn.create=(e)=>new nn({typeName:U.ZodAny,...D(e)});class Fr extends z{constructor(){super(...arguments);this._unknown=!0}_parse(e){return rt(e.data)}}Fr.create=(e)=>new Fr({typeName:U.ZodUnknown,...D(e)});class tr extends z{_parse(e){let t=this._getOrReturnCtx(e);return _(t,{code:b.invalid_type,expected:S.never,received:t.parsedType}),j}}tr.create=(e)=>new tr({typeName:U.ZodNever,...D(e)});class go extends z{_parse(e){if(this._getType(e)!==S.undefined){let r=this._getOrReturnCtx(e);return _(r,{code:b.invalid_type,expected:S.void,received:r.parsedType}),j}return rt(e.data)}}go.create=(e)=>new go({typeName:U.ZodVoid,...D(e)});class qt extends z{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==S.array)return _(t,{code:b.invalid_type,expected:S.array,received:t.parsedType}),j;if(n.exactLength!==null){let s=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;if(s||i)_(t,{code:s?b.too_big:b.too_small,minimum:i?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty()}if(n.minLength!==null){if(t.data.length<n.minLength.value)_(t,{code:b.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()}if(n.maxLength!==null){if(t.data.length>n.maxLength.value)_(t,{code:b.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()}if(t.common.async)return Promise.all([...t.data].map((s,i)=>n.type._parseAsync(new Ht(t,s,t.path,i)))).then((s)=>Xe.mergeArray(r,s));let o=[...t.data].map((s,i)=>n.type._parseSync(new Ht(t,s,t.path,i)));return Xe.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new qt({...this._def,minLength:{value:e,message:F.toString(t)}})}max(e,t){return new qt({...this._def,maxLength:{value:e,message:F.toString(t)}})}length(e,t){return new qt({...this._def,exactLength:{value:e,message:F.toString(t)}})}nonempty(e){return this.min(1,e)}}qt.create=(e,t)=>new qt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:U.ZodArray,...D(t)});function Tn(e){if(e instanceof Fe){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Gt.create(Tn(n))}return new Fe({...e._def,shape:()=>t})}else if(e instanceof qt)return new qt({...e._def,type:Tn(e.element)});else if(e instanceof Gt)return Gt.create(Tn(e.unwrap()));else if(e instanceof hr)return hr.create(Tn(e.unwrap()));else if(e instanceof rr)return rr.create(e.items.map((t)=>Tn(t)));else return e}class Fe extends z{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=X.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==S.object){let u=this._getOrReturnCtx(e);return _(u,{code:b.invalid_type,expected:S.object,received:u.parsedType}),j}let{status:r,ctx:n}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof tr&&this._def.unknownKeys==="strip")){for(let u in n.data)if(!s.includes(u))i.push(u)}let a=[];for(let u of s){let c=o[u],d=n.data[u];a.push({key:{status:"valid",value:u},value:c._parse(new Ht(n,d,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof tr){let u=this._def.unknownKeys;if(u==="passthrough")for(let c of i)a.push({key:{status:"valid",value:c},value:{status:"valid",value:n.data[c]}});else if(u==="strict"){if(i.length>0)_(n,{code:b.unrecognized_keys,keys:i}),r.dirty()}else if(u==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let c of i){let d=n.data[c];a.push({key:{status:"valid",value:c},value:u._parse(new Ht(n,d,n.path,c)),alwaysSet:c in n.data})}}if(n.common.async)return Promise.resolve().then(async()=>{let u=[];for(let c of a){let d=await c.key,m=await c.value;u.push({key:d,value:m,alwaysSet:c.alwaysSet})}return u}).then((u)=>Xe.mergeObjectSync(r,u));else return Xe.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return F.errToObj,new Fe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{let n=this._def.errorMap?.(t,r).message??r.defaultError;if(t.code==="unrecognized_keys")return{message:F.errToObj(e).message??n};return{message:n}}}:{}})}strip(){return new Fe({...this._def,unknownKeys:"strip"})}passthrough(){return new Fe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Fe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Fe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:U.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Fe({...this._def,catchall:e})}pick(e){let t={};for(let r of X.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new Fe({...this._def,shape:()=>t})}omit(e){let t={};for(let r of X.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new Fe({...this._def,shape:()=>t})}deepPartial(){return Tn(this)}partial(e){let t={};for(let r of X.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new Fe({...this._def,shape:()=>t})}required(e){let t={};for(let r of X.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];while(o instanceof Gt)o=o._def.innerType;t[r]=o}return new Fe({...this._def,shape:()=>t})}keyof(){return Qa(X.objectKeys(this.shape))}}Fe.create=(e,t)=>new Fe({shape:()=>e,unknownKeys:"strip",catchall:tr.create(),typeName:U.ZodObject,...D(t)});Fe.strictCreate=(e,t)=>new Fe({shape:()=>e,unknownKeys:"strict",catchall:tr.create(),typeName:U.ZodObject,...D(t)});Fe.lazycreate=(e,t)=>new Fe({shape:e,unknownKeys:"strip",catchall:tr.create(),typeName:U.ZodObject,...D(t)});class En extends z{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function n(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map((i)=>new pt(i.ctx.common.issues));return _(t,{code:b.invalid_union,unionErrors:s}),j}if(t.common.async)return Promise.all(r.map(async(o)=>{let s={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(n);else{let o=void 0,s=[];for(let a of r){let u={...t,common:{...t.common,issues:[]},parent:null},c=a._parseSync({data:t.data,path:t.path,parent:u});if(c.status==="valid")return c;else if(c.status==="dirty"&&!o)o={result:c,ctx:u};if(u.common.issues.length)s.push(u.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let i=s.map((a)=>new pt(a));return _(t,{code:b.invalid_union,unionErrors:i}),j}}get options(){return this._def.options}}En.create=(e,t)=>new En({options:e,typeName:U.ZodUnion,...D(t)});var gr=(e)=>{if(e instanceof Ln)return gr(e.schema);else if(e instanceof zt)return gr(e.innerType());else if(e instanceof Kn)return[e.value];else if(e instanceof jr)return e.options;else if(e instanceof Bn)return X.objectValues(e.enum);else if(e instanceof vn)return gr(e._def.innerType);else if(e instanceof Mn)return[void 0];else if(e instanceof jn)return[null];else if(e instanceof Gt)return[void 0,...gr(e.unwrap())];else if(e instanceof hr)return[null,...gr(e.unwrap())];else if(e instanceof cs)return gr(e.unwrap());else if(e instanceof qn)return gr(e.unwrap());else if(e instanceof Dn)return gr(e._def.innerType);else return[]};class as extends z{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==S.object)return _(t,{code:b.invalid_type,expected:S.object,received:t.parsedType}),j;let r=this.discriminator,n=t.data[r],o=this.optionsMap.get(n);if(!o)return _(t,{code:b.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),j;if(t.common.async)return o._parseAsync({data:t.data,path:t.path,parent:t});else return o._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let o of t){let s=gr(o.shape[e]);if(!s.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of s){if(n.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,o)}}return new as({typeName:U.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...D(r)})}}function ii(e,t){let r=er(e),n=er(t);if(e===t)return{valid:!0,data:e};else if(r===S.object&&n===S.object){let o=X.objectKeys(t),s=X.objectKeys(e).filter((a)=>o.indexOf(a)!==-1),i={...e,...t};for(let a of s){let u=ii(e[a],t[a]);if(!u.valid)return{valid:!1};i[a]=u.data}return{valid:!0,data:i}}else if(r===S.array&&n===S.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let s=0;s<e.length;s++){let i=e[s],a=t[s],u=ii(i,a);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else if(r===S.date&&n===S.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class Un extends z{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(o,s)=>{if(ss(o)||ss(s))return j;let i=ii(o.value,s.value);if(!i.valid)return _(r,{code:b.invalid_intersection_types}),j;if(is(o)||is(s))t.dirty();return{status:t.value,value:i.data}};if(r.common.async)return Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,s])=>n(o,s));else return n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Un.create=(e,t,r)=>new Un({left:e,right:t,typeName:U.ZodIntersection,...D(r)});class rr extends z{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==S.array)return _(r,{code:b.invalid_type,expected:S.array,received:r.parsedType}),j;if(r.data.length<this._def.items.length)return _(r,{code:b.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;if(!this._def.rest&&r.data.length>this._def.items.length)_(r,{code:b.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let o=[...r.data].map((s,i)=>{let a=this._def.items[i]||this._def.rest;if(!a)return null;return a._parse(new Ht(r,s,r.path,i))}).filter((s)=>!!s);if(r.common.async)return Promise.all(o).then((s)=>Xe.mergeArray(t,s));else return Xe.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new rr({...this._def,rest:e})}}rr.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new rr({items:e,typeName:U.ZodTuple,rest:null,...D(t)})};class ho extends z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==S.object)return _(r,{code:b.invalid_type,expected:S.object,received:r.parsedType}),j;let n=[],o=this._def.keyType,s=this._def.valueType;for(let i in r.data)n.push({key:o._parse(new Ht(r,i,r.path,i)),value:s._parse(new Ht(r,r.data[i],r.path,i)),alwaysSet:i in r.data});if(r.common.async)return Xe.mergeObjectAsync(t,n);else return Xe.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){if(t instanceof z)return new ho({keyType:e,valueType:t,typeName:U.ZodRecord,...D(r)});return new ho({keyType:Dt.create(),valueType:e,typeName:U.ZodRecord,...D(t)})}}class xo extends z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==S.map)return _(r,{code:b.invalid_type,expected:S.map,received:r.parsedType}),j;let n=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([i,a],u)=>({key:n._parse(new Ht(r,i,r.path,[u,"key"])),value:o._parse(new Ht(r,a,r.path,[u,"value"]))}));if(r.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let a of s){let u=await a.key,c=await a.value;if(u.status==="aborted"||c.status==="aborted")return j;if(u.status==="dirty"||c.status==="dirty")t.dirty();i.set(u.value,c.value)}return{status:t.value,value:i}})}else{let i=new Map;for(let a of s){let{key:u,value:c}=a;if(u.status==="aborted"||c.status==="aborted")return j;if(u.status==="dirty"||c.status==="dirty")t.dirty();i.set(u.value,c.value)}return{status:t.value,value:i}}}}xo.create=(e,t,r)=>new xo({valueType:t,keyType:e,typeName:U.ZodMap,...D(r)});class on extends z{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==S.set)return _(r,{code:b.invalid_type,expected:S.set,received:r.parsedType}),j;let n=this._def;if(n.minSize!==null){if(r.data.size<n.minSize.value)_(r,{code:b.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()}if(n.maxSize!==null){if(r.data.size>n.maxSize.value)_(r,{code:b.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty()}let o=this._def.valueType;function s(a){let u=new Set;for(let c of a){if(c.status==="aborted")return j;if(c.status==="dirty")t.dirty();u.add(c.value)}return{status:t.value,value:u}}let i=[...r.data.values()].map((a,u)=>o._parse(new Ht(r,a,r.path,u)));if(r.common.async)return Promise.all(i).then((a)=>s(a));else return s(i)}min(e,t){return new on({...this._def,minSize:{value:e,message:F.toString(t)}})}max(e,t){return new on({...this._def,maxSize:{value:e,message:F.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}on.create=(e,t)=>new on({valueType:e,minSize:null,maxSize:null,typeName:U.ZodSet,...D(t)});class Fn extends z{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==S.function)return _(t,{code:b.invalid_type,expected:S.function,received:t.parsedType}),j;function r(i,a){return lo({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Cn(),yr].filter((u)=>!!u),issueData:{code:b.invalid_arguments,argumentsError:a}})}function n(i,a){return lo({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Cn(),yr].filter((u)=>!!u),issueData:{code:b.invalid_return_type,returnTypeError:a}})}let o={errorMap:t.common.contextualErrorMap},s=t.data;if(this._def.returns instanceof sn){let i=this;return rt(async function(...a){let u=new pt([]),c=await i._def.args.parseAsync(a,o).catch((x)=>{throw u.addIssue(r(a,x)),u}),d=await Reflect.apply(s,this,c);return await i._def.returns._def.type.parseAsync(d,o).catch((x)=>{throw u.addIssue(n(d,x)),u})})}else{let i=this;return rt(function(...a){let u=i._def.args.safeParse(a,o);if(!u.success)throw new pt([r(a,u.error)]);let c=Reflect.apply(s,this,u.data),d=i._def.returns.safeParse(c,o);if(!d.success)throw new pt([n(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Fn({...this._def,args:rr.create(e).rest(Fr.create())})}returns(e){return new Fn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Fn({args:e?e:rr.create([]).rest(Fr.create()),returns:t||Fr.create(),typeName:U.ZodFunction,...D(r)})}}class Ln extends z{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ln.create=(e,t)=>new Ln({getter:e,typeName:U.ZodLazy,...D(t)});class Kn extends z{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:b.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:e.data}}get value(){return this._def.value}}Kn.create=(e,t)=>new Kn({value:e,typeName:U.ZodLiteral,...D(t)});function Qa(e,t){return new jr({values:e,typeName:U.ZodEnum,...D(t)})}class jr extends z{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{expected:X.joinValues(r),received:t.parsedType,code:b.invalid_type}),j}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{received:t.data,code:b.invalid_enum_value,options:r}),j}return rt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return jr.create(e,{...this._def,...t})}exclude(e,t=this._def){return jr.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}}jr.create=Qa;class Bn extends z{_parse(e){let t=X.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==S.string&&r.parsedType!==S.number){let n=X.objectValues(t);return _(r,{expected:X.joinValues(n),received:r.parsedType,code:b.invalid_type}),j}if(!this._cache)this._cache=new Set(X.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=X.objectValues(t);return _(r,{received:r.data,code:b.invalid_enum_value,options:n}),j}return rt(e.data)}get enum(){return this._def.values}}Bn.create=(e,t)=>new Bn({values:e,typeName:U.ZodNativeEnum,...D(t)});class sn extends z{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==S.promise&&t.common.async===!1)return _(t,{code:b.invalid_type,expected:S.promise,received:t.parsedType}),j;let r=t.parsedType===S.promise?t.data:Promise.resolve(t.data);return rt(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}sn.create=(e,t)=>new sn({type:e,typeName:U.ZodPromise,...D(t)});class zt extends z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===U.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:(s)=>{if(_(r,s),s.fatal)t.abort();else t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let s=n.transform(r.data,o);if(r.common.async)return Promise.resolve(s).then(async(i)=>{if(t.value==="aborted")return j;let a=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});if(a.status==="aborted")return j;if(a.status==="dirty")return tn(a.value);if(t.value==="dirty")return tn(a.value);return a});else{if(t.value==="aborted")return j;let i=this._def.schema._parseSync({data:s,path:r.path,parent:r});if(i.status==="aborted")return j;if(i.status==="dirty")return tn(i.value);if(t.value==="dirty")return tn(i.value);return i}}if(n.type==="refinement"){let s=(i)=>{let a=n.refinement(i,o);if(r.common.async)return Promise.resolve(a);if(a instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(i.status==="aborted")return j;if(i.status==="dirty")t.dirty();return s(i.value),{status:t.value,value:i.value}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((i)=>{if(i.status==="aborted")return j;if(i.status==="dirty")t.dirty();return s(i.value).then(()=>({status:t.value,value:i.value}))})}if(n.type==="transform")if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Tr(s))return j;let i=n.transform(s.value,o);if(i instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((s)=>{if(!Tr(s))return j;return Promise.resolve(n.transform(s.value,o)).then((i)=>({status:t.value,value:i}))});X.assertNever(n)}}zt.create=(e,t,r)=>new zt({schema:e,typeName:U.ZodEffects,effect:t,...D(r)});zt.createWithPreprocess=(e,t,r)=>new zt({schema:t,effect:{type:"preprocess",transform:e},typeName:U.ZodEffects,...D(r)});class Gt extends z{_parse(e){if(this._getType(e)===S.undefined)return rt(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Gt.create=(e,t)=>new Gt({innerType:e,typeName:U.ZodOptional,...D(t)});class hr extends z{_parse(e){if(this._getType(e)===S.null)return rt(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}hr.create=(e,t)=>new hr({innerType:e,typeName:U.ZodNullable,...D(t)});class vn extends z{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;if(t.parsedType===S.undefined)r=this._def.defaultValue();return this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}vn.create=(e,t)=>new vn({innerType:e,typeName:U.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...D(t)});class Dn extends z{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});if(An(n))return n.then((o)=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new pt(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new pt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Dn.create=(e,t)=>new Dn({innerType:e,typeName:U.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...D(t)});class Io extends z{_parse(e){if(this._getType(e)!==S.nan){let r=this._getOrReturnCtx(e);return _(r,{code:b.invalid_type,expected:S.nan,received:r.parsedType}),j}return{status:"valid",value:e.data}}}Io.create=(e)=>new Io({typeName:U.ZodNaN,...D(e)});var Xl=Symbol("zod_brand");class cs extends z{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class bo extends z{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});if(o.status==="aborted")return j;if(o.status==="dirty")return t.dirty(),tn(o.value);else return this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();else{let n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});if(n.status==="aborted")return j;if(n.status==="dirty")return t.dirty(),{status:"dirty",value:n.value};else return this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new bo({in:e,out:t,typeName:U.ZodPipeline})}}class qn extends z{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(Tr(n))n.value=Object.freeze(n.value);return n};return An(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}}qn.create=(e,t)=>new qn({innerType:e,typeName:U.ZodReadonly,...D(t)});function Ja(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function Za(e,t={},r){if(e)return nn.create().superRefine((n,o)=>{let s=e(n);if(s instanceof Promise)return s.then((i)=>{if(!i){let a=Ja(t,n),u=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:u})}});if(!s){let i=Ja(t,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}return});return nn.create()}var Yl={object:Fe.lazycreate},U;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(U||(U={}));var Ql=(e,t={message:`Input not instance of ${e.name}`})=>Za((r)=>r instanceof e,t),ec=Dt.create,tc=Nr.create,Zl=Io.create,ey=Mr.create,rc=Nn.create,ty=rn.create,ry=yo.create,ny=Mn.create,oy=jn.create,sy=nn.create,iy=Fr.create,ay=tr.create,cy=go.create,uy=qt.create,{create:dy,strictCreate:fy}=Fe,my=En.create,py=as.create,ly=Un.create,yy=rr.create,gy=ho.create,hy=xo.create,xy=on.create,Iy=Fn.create,by=Ln.create,Ry=Kn.create,_y=jr.create,Oy=Bn.create,wy=sn.create,$y=zt.create,Sy=Gt.create,Py=hr.create,ky=zt.createWithPreprocess,Cy=bo.create,Ay=()=>ec().optional(),Ty=()=>tc().optional(),Fy=()=>rc().optional(),Ny={string:(e)=>Dt.create({...e,coerce:!0}),number:(e)=>Nr.create({...e,coerce:!0}),boolean:(e)=>Nn.create({...e,coerce:!0}),bigint:(e)=>Mr.create({...e,coerce:!0}),date:(e)=>rn.create({...e,coerce:!0})};var My=j;var jy=us,ot=(e,t=400)=>Response.json(e,{status:t,headers:{"Content-Type":"application/json"}}),oc=(e)=>{let t=po.Compile(e),r=async(n,o)=>{try{let s=n instanceof Object&&"req"in n,i=s?await n.jsonBody():await n.json();if(!t.Check(i)){let a=t.Errors(i).First();return ot({status:"error",code:"VALIDATION_FAILED",message:a?.message||"Invalid input",path:a?.path||"body"})}if(s)n.body=i;return o?o():void 0}catch{return ot({status:"error",message:"Malformed JSON payload"})}};return r.__schema=e,r},sc=(e)=>{let t=e.properties||{},r=Object.keys(t),n=r.length,o=Array.isArray(e.required)?new Set(e.required):null,s=async(i,a)=>{try{let u=i instanceof Object&&"req"in i,c=u?await i.jsonBody():await i.json();if(!c||typeof c!=="object"||Array.isArray(c))return ot({status:"error",message:"Invalid JSON object payload"});for(let d=0;d<n;d++){let m=r[d];if(!(Object.hasOwn(c,m)&&c[m]!==void 0)){if(!o||o.has(m))return ot({status:"error",code:"TYPE_MISMATCH",message:`Field '${m}' must be of type ${t[m]?.type}`,field:m});continue}if(typeof c[m]!==t[m]?.type)return ot({status:"error",code:"TYPE_MISMATCH",message:`Field '${m}' must be of type ${t[m]?.type}`,field:m})}if(u)i.body=c;return a?a():void 0}catch{return ot({status:"error",message:"Invalid JSON payload"})}};return s.__schema=e,s},ic=(e)=>{let t=async(r,n)=>{try{let o=r instanceof Object&&"req"in r,s=o?await r.jsonBody():await r.json(),i=await e.safeParseAsync(s);if(!i.success)return ot({status:"error",code:"ZOD_ERROR",errors:i.error.flatten()});if(o)r.body=i.data;return n?n():void 0}catch{return ot({status:"error",message:"Invalid JSON payload"})}};return t.__schema=e,t},Ey=(e)=>{if(e&&"_def"in e)return ic(e);if(e&&(e.kind||e.type||e[Symbol.for("TypeBox.Kind")]))return oc(e);return sc(e)};var Ro=(e)=>{if(e&&"_def"in e)return(r)=>{let n=e.safeParse(r);return n.success?{ok:!0,data:n.data}:{ok:!1,error:n.error.flatten()}};let t=po.Compile(e);return(r)=>{if(t.Check(r))return{ok:!0,data:r};let n=t.Errors(r).First();return{ok:!1,error:{message:n?.message||"Invalid input",path:n?.path}}}},ai=(e,t)=>{let r=e?.properties;if(!r||typeof r!=="object")return null;let n=[];for(let[o,s]of Object.entries(r)){let i=JSON.stringify(o),a=`${t}[${i}]`,u=ai(s,a);if(u)n.push(`${i}: (${a} && typeof ${a} === 'object' && !Array.isArray(${a})) ? ${u} : ${a}`);else n.push(`${i}: ${a}`)}return`{ ${n.join(", ")} }`},ac=(e)=>{if(!e||"_def"in e)return null;if(e.type==="array"&&e.items){let r=ai(e.items,"item");if(!r)return null;return Function(`return function(arr) {
8
8
  if (!Array.isArray(arr)) return arr;
9
9
  const len = arr.length;
10
10
  const out = new Array(len);
@@ -13,55 +13,55 @@ var{defineProperty:Oi,getOwnPropertyNames:su,getOwnPropertyDescriptor:au}=Object
13
13
  out[i] = (item && typeof item === 'object' && !Array.isArray(item)) ? ${r} : item;
14
14
  }
15
15
  return out;
16
- }`)()}let t=rs(e,"o");if(!t)return null;return Function(`return function(o) {
16
+ }`)()}let t=ai(e,"o");if(!t)return null;return Function(`return function(o) {
17
17
  if (!o || typeof o !== 'object' || Array.isArray(o)) return o;
18
18
  return ${t};
19
- }`)()},tc=(e)=>{let t=ho(e),r=ky(e);return(n)=>{if(n instanceof Response)return n;let o=r?r(n):n,i=t(o);if(!i.ok)return He({status:"error",code:"RESPONSE_VALIDATION_FAILED",error:i.error},500);return i.data}},Xa=(e,t)=>{let r=t?.properties||(t?._def?.shape?typeof t._def.shape==="function"?t._def.shape():t._def.shape:null);if(!r)return e;let n={...e};for(let[o,i]of Object.entries(r)){if(!Object.hasOwn(n,o))continue;let s=n[o];if(typeof s!=="string")continue;let a=i?.type||i?._def?.typeName;if(a==="number"||a==="integer"||a==="ZodNumber"){if(s.trim()!==""){let c=Number(s);if(!Number.isNaN(c))n[o]=c}}else if(a==="boolean"||a==="ZodBoolean"){if(s==="true")n[o]=!0;else if(s==="false")n[o]=!1}}return n},ns=(e)=>{let t=e.body?ho(e.body):null,r=e.query?ho(e.query):null,n=e.params?ho(e.params):null,o=e.headers?ho(e.headers):null,i=e.response?tc(e.response):null,s=e.maxBodySize??1048576,a=(u)=>{if(n){let m=Xa(u.params,e.params),g=n(m);if(!g.ok)return He({status:"error",code:"PARAMS_INVALID",error:g.error});u.params=g.data}if(r){let m=Xa(u.query,e.query),g=r(m);if(!g.ok)return He({status:"error",code:"QUERY_INVALID",error:g.error});u._query=g.data}if(o){let m={};u.req.headers.forEach((I,O)=>{m[O.toLowerCase()]=I});let g=o(m);if(!g.ok)return He({status:"error",code:"HEADERS_INVALID",error:g.error})}return};if(!t){let u=(m,g)=>{let I=a(m);if(I)return I;return g?g():void 0};if(u.__routeSchemas=e,i)u.__responseFilter=i;return u}let c=async(u,m)=>{let g=a(u);if(g)return g;let I;try{I=await u.jsonBody(s)}catch(T){if(T?.status===413)return He({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return He({status:"error",message:"Malformed JSON payload"})}let O=t(I);if(!O.ok)return He({status:"error",code:"VALIDATION_FAILED",error:O.error});return u.body=O.data,m?m():void 0};if(c.__schema=e.body,c.__routeSchemas=e,i)c.__responseFilter=i;return c};class Ln{prefix;groupMiddleware;routes=[];constructor(e="",t=[]){this.prefix=e;this.groupMiddleware=t}_add(e,t,r){let n=(this.prefix+"/"+t).replace(/\/+/g,"/");if(n.endsWith("/"))n=n.slice(0,-1);let o=[];for(let i=0;i<r.length;i++){let s=r[i];if(typeof s==="function")o.push(s);else if(s&&typeof s==="object")o.push(ns(s))}return this.routes.push({method:e.toUpperCase(),path:n||"",handlers:[...this.groupMiddleware,...o]}),this}get=(e,...t)=>this._add("GET",e,t);post=(e,...t)=>this._add("POST",e,t);put=(e,...t)=>this._add("PUT",e,t);patch=(e,...t)=>this._add("PATCH",e,t);delete=(e,...t)=>this._add("DELETE",e,t);options=(e,...t)=>this._add("OPTIONS",e,t);group=(e,...t)=>{let r=t.pop(),n=t,o=(this.prefix+"/"+e).replace(/\/+/g,"/"),i=new Ln(o,[...this.groupMiddleware,...n]);return r(i),this.routes.push(...i.routes),this};use(e){if(e instanceof Ln||e&&e.routes)this.routes.push(...e.routes);else if(e&&typeof e.install==="function")e.install(this);else this.groupMiddleware.push(e);return this}}class Zr{children={};staticKeys=[];paramNode=null;paramName=null;wildcardNode=null;handlers={};insert(e,t,r){let n=this,o=e.split("/").filter(Boolean);for(let i of o)if(i==="*"){if(!n.wildcardNode)n.wildcardNode=new Zr;n=n.wildcardNode;break}else if(i.startsWith(":")){if(!n.paramNode)n.paramNode=new Zr;n.paramName=i.slice(1),n=n.paramNode}else{if(!n.children[i])n.children[i]=new Zr,n.staticKeys.push(i);n=n.children[i]}n.handlers[t]=r}lookup(e,t,r,n){let o=this,i=r===-1?0:r,s=t.length;if(t[i]==="/")i++;for(let a in n.params)delete n.params[a];while(i<s){let a=t.indexOf("/",i);if(a===-1)a=s;let c=a-i,u=!1,m=o.staticKeys,g=m.length;if(g===1){let I=m[0];if(I.length===c){let O=!0;for(let T=0;T<c;T++)if(I[T]!==t[i+T]){O=!1;break}if(O)o=o.children[I],u=!0}}else for(let I=0;I<g;I++){let O=m[I];if(O.length===c){let T=!0;for(let C=0;C<c;C++)if(O[C]!==t[i+C]){T=!1;break}if(T){o=o.children[O],u=!0;break}}}if(!u)if(o.paramNode)n.params[o.paramName]=t.slice(i,a),o=o.paramNode;else if(o.wildcardNode)return n.params["*"]=t.slice(i),o.wildcardNode.handlers[e]||null;else return null;i=a+1}return o.handlers[e]||null}jitCompile(e,t=0,r="url",n="s",o=[]){let i="",s=" ".repeat(t);if(Object.keys(this.handlers).length>0){if(i+=`${s}if (${n} >= urlLen) {
20
- `,o.length>0){let a=o.map((c)=>`${JSON.stringify(c.name)}: ${c.varName}`).join(", ");i+=`${s} ctx.params = { ${a} };
21
- `}i+=`${s} switch(method) {
22
- `;for(let[a,c]of Object.entries(this.handlers)){let u=e(c);i+=`${s} case ${JSON.stringify(a)}: return ${u}(ctx);
23
- `}i+=`${s} }
24
- `,i+=`${s}}
25
- `}if(this.staticKeys.length>0)if(this.staticKeys.length===1){let a=this.staticKeys[0],c=a.length,u=`nextIdxL${t}`;i+=`${s}if (${r}.startsWith(${JSON.stringify(a)}, ${n})) {
26
- `,i+=`${s} const ${u} = ${n} + ${c};
27
- `,i+=`${s} if (${u} === urlLen || ${r}.charCodeAt(${u}) === 47) {
28
- `;let m=this.children[a],g=`newIdxL${t}`;i+=`${s} const ${g} = ${u} === urlLen ? urlLen : (${u} + 1);
29
- `,i+=m.jitCompile(e,t+1,r,g,o),i+=`${s} }
30
- `,i+=`${s}}
31
- `}else if(this.staticKeys.length>4){i+=`${s}let slash${t} = ${r}.indexOf('/', ${n});
32
- `,i+=`${s}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
33
- `,i+=`${s}switch (${r}.slice(${n}, slash${t})) {
34
- `;for(let a of this.staticKeys){i+=`${s} case ${JSON.stringify(a)}: {
35
- `;let c=this.children[a];i+=c.jitCompile(e,t+1,r,`slash${t} + 1`,o),i+=`${s} break;
36
- `,i+=`${s} }
37
- `}i+=`${s}}
38
- `}else{i+=`${s}let slash${t} = ${r}.indexOf('/', ${n});
39
- `,i+=`${s}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
40
- `,i+=`${s}const len${t} = slash${t} - (${n});
19
+ }`)()},cc=(e)=>{let t=Ro(e),r=ac(e);return(n)=>{if(n instanceof Response)return n;let o=r?r(n):n,s=t(o);if(!s.ok)return ot({status:"error",code:"RESPONSE_VALIDATION_FAILED",error:s.error},500);return s.data}},nc=(e,t)=>{let r=t?.properties||(t?._def?.shape?typeof t._def.shape==="function"?t._def.shape():t._def.shape:null);if(!r)return e;let n={...e};for(let[o,s]of Object.entries(r)){if(!Object.hasOwn(n,o))continue;let i=n[o];if(typeof i!=="string")continue;let a=s?.type||s?._def?.typeName;if(a==="number"||a==="integer"||a==="ZodNumber"){if(i.trim()!==""){let u=Number(i);if(!Number.isNaN(u))n[o]=u}}else if(a==="boolean"||a==="ZodBoolean"){if(i==="true")n[o]=!0;else if(i==="false")n[o]=!1}}return n},ci=(e)=>{let t=e.body?Ro(e.body):null,r=e.query?Ro(e.query):null,n=e.params?Ro(e.params):null,o=e.headers?Ro(e.headers):null,s=e.stripUnknown&&e.body?ac(e.body):null,i=e.response?cc(e.response):null,a=e.maxBodySize??1048576,u=Boolean(n||r||o),c=(m)=>{if(n){let x=nc(m.params,e.params),y=n(x);if(!y.ok)return ot({status:"error",code:"PARAMS_INVALID",error:y.error});m.params=y.data}if(r){let x=nc(m.query,e.query),y=r(x);if(!y.ok)return ot({status:"error",code:"QUERY_INVALID",error:y.error});m._query=y.data}if(o){let x={};m.req.headers.forEach((R,C)=>{x[C.toLowerCase()]=R});let y=o(x);if(!y.ok)return ot({status:"error",code:"HEADERS_INVALID",error:y.error})}return};if(!t){let m=(x,y)=>{if(u){let R=c(x);if(R)return R}return y?y():void 0};if(m.__routeSchemas=e,i)m.__responseFilter=i;return m}let d=async(m,x)=>{if(u){let C=c(m);if(C)return C}let y;try{y=await m.jsonBody(a)}catch(C){if(C?.status===413)return ot({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return ot({status:"error",message:"Malformed JSON payload"})}let R=t(y);if(!R.ok)return ot({status:"error",code:"VALIDATION_FAILED",error:R.error});return m.body=s?s(R.data):R.data,x?x():void 0};if(d.__schema=e.body,d.__routeSchemas=e,i)d.__responseFilter=i;return d};class an{prefix;groupMiddleware;routes=[];constructor(e="",t=[]){this.prefix=e;this.groupMiddleware=t}_add(e,t,r){let n=(this.prefix+"/"+t).replace(/\/+/g,"/");if(n.endsWith("/"))n=n.slice(0,-1);let o=[];for(let s=0;s<r.length;s++){let i=r[s];if(typeof i==="function")o.push(i);else if(i&&typeof i==="object")o.push(ci(i))}return this.routes.push({method:e.toUpperCase(),path:n||"",handlers:[...this.groupMiddleware,...o]}),this}get=(e,...t)=>this._add("GET",e,t);post=(e,...t)=>this._add("POST",e,t);put=(e,...t)=>this._add("PUT",e,t);patch=(e,...t)=>this._add("PATCH",e,t);delete=(e,...t)=>this._add("DELETE",e,t);options=(e,...t)=>this._add("OPTIONS",e,t);head=(e,...t)=>this._add("HEAD",e,t);all=(e,...t)=>{for(let r of["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"])this._add(r,e,t);return this};group=(e,...t)=>{let r=t.pop(),n=t,o=(this.prefix+"/"+e).replace(/\/+/g,"/"),s=new an(o,[...this.groupMiddleware,...n]);return r(s),this.routes.push(...s.routes),this};_mountRouter(e,t){let r=(this.prefix+"/"+e).replace(/\/+/g,"/").replace(/\/$/,"");for(let n of t.routes){let o=(r+"/"+n.path).replace(/\/+/g,"/");if(o.endsWith("/"))o=o.slice(0,-1);this.routes.push({method:n.method,path:o||"",handlers:[...this.groupMiddleware,...n.handlers]})}}route(e,t){return this._mountRouter(e,t),this}use(e,t){if(typeof e==="string"&&(t instanceof an||t&&t.routes))this._mountRouter(e,t);else if(e instanceof an||e&&e.routes)this._mountRouter("",e);else if(e&&typeof e.install==="function")e.install(this);else this.groupMiddleware.push(e);return this}}class cn{children={};staticKeys=[];paramNode=null;paramName=null;wildcardNode=null;handlers={};insert(e,t,r){let n=this,o=e.split("/").filter(Boolean);for(let s of o)if(s==="*"){if(!n.wildcardNode)n.wildcardNode=new cn;n=n.wildcardNode;break}else if(s.startsWith(":")){if(!n.paramNode)n.paramNode=new cn;n.paramName=s.slice(1),n=n.paramNode}else{if(!n.children[s])n.children[s]=new cn,n.staticKeys.push(s);n=n.children[s]}n.handlers[t]=r}lookup(e,t,r,n){let o=this,s=r===-1?0:r,i=t.length;if(t[s]==="/")s++;for(let a in n.params)delete n.params[a];while(s<i){let a=t.indexOf("/",s);if(a===-1)a=i;let u=a-s,c=!1,d=o.staticKeys,m=d.length;if(m===1){let x=d[0];if(x.length===u){let y=!0;for(let R=0;R<u;R++)if(x[R]!==t[s+R]){y=!1;break}if(y)o=o.children[x],c=!0}}else for(let x=0;x<m;x++){let y=d[x];if(y.length===u){let R=!0;for(let C=0;C<u;C++)if(y[C]!==t[s+C]){R=!1;break}if(R){o=o.children[y],c=!0;break}}}if(!c)if(o.paramNode)n.params[o.paramName]=t.slice(s,a),o=o.paramNode;else if(o.wildcardNode)return n.params["*"]=t.slice(s),o.wildcardNode.handlers[e]||null;else return null;s=a+1}return o.handlers[e]||null}jitCompile(e,t=0,r="url",n="s",o=[]){let s="",i=" ".repeat(t);if(Object.keys(this.handlers).length>0){if(s+=`${i}if (${n} >= urlLen) {
20
+ `,o.length>0){let a=o.map((u)=>`${JSON.stringify(u.name)}: ${u.varName}`).join(", ");s+=`${i} ctx.params = { ${a} };
21
+ `}s+=`${i} switch(method) {
22
+ `;for(let[a,u]of Object.entries(this.handlers)){let c=e(u);s+=`${i} case ${JSON.stringify(a)}: return ${c}(ctx);
23
+ `}s+=`${i} }
24
+ `,s+=`${i}}
25
+ `}if(this.staticKeys.length>0)if(this.staticKeys.length===1){let a=this.staticKeys[0],u=a.length,c=`nextIdxL${t}`;s+=`${i}if (${r}.startsWith(${JSON.stringify(a)}, ${n})) {
26
+ `,s+=`${i} const ${c} = ${n} + ${u};
27
+ `,s+=`${i} if (${c} === urlLen || ${r}.charCodeAt(${c}) === 47) {
28
+ `;let d=this.children[a],m=`newIdxL${t}`;s+=`${i} const ${m} = ${c} === urlLen ? urlLen : (${c} + 1);
29
+ `,s+=d.jitCompile(e,t+1,r,m,o),s+=`${i} }
30
+ `,s+=`${i}}
31
+ `}else if(this.staticKeys.length>4){s+=`${i}let slash${t} = ${r}.indexOf('/', ${n});
32
+ `,s+=`${i}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
33
+ `,s+=`${i}switch (${r}.slice(${n}, slash${t})) {
34
+ `;for(let a of this.staticKeys){s+=`${i} case ${JSON.stringify(a)}: {
35
+ `;let u=this.children[a];s+=u.jitCompile(e,t+1,r,`slash${t} + 1`,o),s+=`${i} break;
36
+ `,s+=`${i} }
37
+ `}s+=`${i}}
38
+ `}else{s+=`${i}let slash${t} = ${r}.indexOf('/', ${n});
39
+ `,s+=`${i}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
40
+ `,s+=`${i}const len${t} = slash${t} - (${n});
41
41
 
42
- `;let a=new Map;for(let c of this.staticKeys){let u=a.get(c.length);if(!u)u=[],a.set(c.length,u);u.push(c)}i+=`${s}switch(len${t}) {
43
- `;for(let[c,u]of a){i+=`${s} case ${c}:
44
- `;for(let m of u){if(c===1)i+=`${s} if (${r}.charCodeAt(${n}) === ${m.charCodeAt(0)}) {
45
- `;else i+=`${s} if (${r}.startsWith(${JSON.stringify(m)}, ${n})) {
46
- `;let g=this.children[m];i+=g.jitCompile(e,t+1,r,`slash${t} + 1`,o),i+=`${s} }
47
- `}i+=`${s} break;
48
- `}i+=`${s}}
49
- `}if(this.paramNode){let a=this.paramNode;if(this.staticKeys.length<=1)i+=`${s}let slash${t} = ${r}.indexOf('/', ${n});
50
- `,i+=`${s}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
51
- `;let c=`pL${t}`;i+=`${s}const ${c} = ${r}.slice(${n}, slash${t});
52
- `;let u=[...o,{name:this.paramName,varName:c}];i+=a.jitCompile(e,t+1,r,`slash${t} + 1`,u)}if(this.wildcardNode&&Object.keys(this.wildcardNode.handlers).length>0){let a=`wL${t}`;i+=`${s}const ${a} = ${r}.slice(${n}, urlLen);
53
- `;let u=[...o,{name:"*",varName:a}].map((m)=>`${JSON.stringify(m.name)}: ${m.varName}`).join(", ");i+=`${s}ctx.params = { ${u} };
54
- `,i+=`${s}switch(method) {
55
- `;for(let[m,g]of Object.entries(this.wildcardNode.handlers)){let I=e(g);i+=`${s} case ${JSON.stringify(m)}: return ${I}(ctx);
56
- `}i+=`${s}}
57
- `}return i}id=Math.random().toString(36).slice(2)}import{createHmac as rc,timingSafeEqual as Cy}from"crypto";class Io{req;params={};_status=200;_headers=void 0;store=new Map;body=void 0;_query=void 0;_cookies=void 0;_setCookies=void 0;_requestId=void 0;constructor(){}get query(){if(this._query!==void 0)return this._query;let e={},t=this.req?.url;if(t){let r=t.indexOf("?");if(r!==-1){let n=r+1,o=t.length;while(n<o){let i=t.indexOf("&",n);if(i===-1)i=o;if(i>n){let s=t.indexOf("=",n),a,c;if(s!==-1&&s<i)a=t.slice(n,s),c=t.slice(s+1,i);else a=t.slice(n,i),c="";if(a.indexOf("+")!==-1)a=a.replaceAll("+"," ");if(a.indexOf("%")!==-1)try{a=decodeURIComponent(a)}catch{}if(c.indexOf("+")!==-1)c=c.replaceAll("+"," ");if(c.indexOf("%")!==-1)try{c=decodeURIComponent(c)}catch{}if(a!=="__proto__"&&a!=="constructor"&&a!=="prototype")e[a]=c}n=i+1}}}return this._query=e,e}getQuery(e){return this.query[e]}get cookies(){if(this._cookies!==void 0)return this._cookies;let e={},t=this.req?.headers?.get("cookie");if(t){let r=0,n=t.length;while(r<n){let o=t.indexOf(";",r);if(o===-1)o=n;let i=t.indexOf("=",r);if(i!==-1&&i<o){let s=t.slice(r,i).trim(),a=t.slice(i+1,o).trim();try{a=decodeURIComponent(a)}catch{}if(s&&s!=="__proto__"&&s!=="constructor"&&s!=="prototype")e[s]=a}r=o+1}}return this._cookies=e,e}setCookie(e,t,r={}){let n=t;if(r.secret){let i=rc("sha256",r.secret).update(t).digest("base64url");n=`${t}.${i}`}let o=`${e}=${encodeURIComponent(n)}`;if(o+=`; Path=${r.path??"/"}`,r.domain)o+=`; Domain=${r.domain}`;if(r.maxAge!==void 0)o+=`; Max-Age=${Math.floor(r.maxAge)}`;if(r.expires)o+=`; Expires=${r.expires.toUTCString()}`;if(r.httpOnly!==!1)o+="; HttpOnly";if(r.secure)o+="; Secure";if(o+=`; SameSite=${r.sameSite??"Lax"}`,!this._setCookies)this._setCookies=[];return this._setCookies.push(o),this}getSignedCookie(e,t){let r=this.cookies[e];if(!r)return null;let n=r.lastIndexOf(".");if(n<=0)return null;let o=r.slice(0,n),i=r.slice(n+1),s=rc("sha256",t).update(o).digest(),a=Buffer.from(i,"base64url");if(a.length!==s.length||!Cy(a,s))return null;return o}deleteCookie(e,t={}){return this.setCookie(e,"",{...t,maxAge:0,expires:new Date(0)})}async jsonBody(e=1048576){if(this.body!==void 0)return this.body;let t=this.req.headers.get("content-type");if(t&&t.includes("application/json")){let r=this.req.headers.get("content-length");if(r!==null){if(Number(r)>e){let o=Error("Payload Too Large");throw o.status=413,o}try{return this.body=await this.req.json()}catch{return this.body=null}}try{let n=await this.req.text();if(Buffer.byteLength(n,"utf-8")>e){let o=Error("Payload Too Large");throw o.status=413,o}return this.body=JSON.parse(n)}catch(n){if(n?.status===413)throw n;return this.body=null}}return this.body=null}reset(e){if(this.req=e,this._status=200,this._headers=void 0,this.store.size>0)this.store.clear();return this.params={},this._query=void 0,this._cookies=void 0,this._setCookies=void 0,this.body=void 0,this}status(e){return this._status=e,this}json(e){let t=this._status||200,r;if(!this._headers)r=Response.json(e,{status:t});else{if(this._headers["content-type"]===void 0)this._headers["content-type"]="application/json";r=Response.json(e,{status:t,headers:this._headers})}if(this._setCookies)for(let n=0;n<this._setCookies.length;n++)r.headers.append("Set-Cookie",this._setCookies[n]);return r}set(e,t){return this.store.set(e,t),this}get(e){return this.store.get(e)}setHeader(e,t){if(!this._headers)this._headers={};else if(Object.isFrozen(this._headers))this._headers={...this._headers};return this._headers[e.toLowerCase()]=t,this}get user(){return this.store.get("user")}send(e,t={}){let r=this._status>=400;return this.json({status:r?"error":"success",msg:e,...t})}html(e,t){let r={"content-type":"text/html; charset=utf-8",...this._headers||{}};return new Response(e,{status:t??this._status,headers:r})}text(e,t){let r={"content-type":"text/plain; charset=utf-8",...this._headers||{}};return new Response(e,{status:t??this._status,headers:r})}redirect(e,t=302){let r={location:e,...this._headers||{}};return new Response(null,{status:t,headers:r})}sse(e){let t=new TextEncoder,r=(i)=>{if(typeof i==="string")return t.encode(`data: ${i}
42
+ `;let a=new Map;for(let u of this.staticKeys){let c=a.get(u.length);if(!c)c=[],a.set(u.length,c);c.push(u)}s+=`${i}switch(len${t}) {
43
+ `;for(let[u,c]of a){s+=`${i} case ${u}:
44
+ `;for(let d of c){if(u===1)s+=`${i} if (${r}.charCodeAt(${n}) === ${d.charCodeAt(0)}) {
45
+ `;else s+=`${i} if (${r}.startsWith(${JSON.stringify(d)}, ${n})) {
46
+ `;let m=this.children[d];s+=m.jitCompile(e,t+1,r,`slash${t} + 1`,o),s+=`${i} }
47
+ `}s+=`${i} break;
48
+ `}s+=`${i}}
49
+ `}if(this.paramNode){let a=this.paramNode;if(this.staticKeys.length<=1)s+=`${i}let slash${t} = ${r}.indexOf('/', ${n});
50
+ `,s+=`${i}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
51
+ `;let u=`pL${t}`;s+=`${i}const ${u} = ${r}.slice(${n}, slash${t});
52
+ `;let c=[...o,{name:this.paramName,varName:u}];s+=a.jitCompile(e,t+1,r,`slash${t} + 1`,c)}if(this.wildcardNode&&Object.keys(this.wildcardNode.handlers).length>0){let a=`wL${t}`;s+=`${i}const ${a} = ${r}.slice(${n}, urlLen);
53
+ `;let c=[...o,{name:"*",varName:a}].map((d)=>`${JSON.stringify(d.name)}: ${d.varName}`).join(", ");s+=`${i}ctx.params = { ${c} };
54
+ `,s+=`${i}switch(method) {
55
+ `;for(let[d,m]of Object.entries(this.wildcardNode.handlers)){let x=e(m);s+=`${i} case ${JSON.stringify(d)}: return ${x}(ctx);
56
+ `}s+=`${i}}
57
+ `}return s}id=Math.random().toString(36).slice(2)}import{createHmac as uc,timingSafeEqual as Uy}from"crypto";class _o{req;params={};_status=200;_headers=void 0;store=new Map;body=void 0;_query=void 0;_cookies=void 0;_setCookies=void 0;_requestId=void 0;_peerIp=void 0;_trustProxy=!0;constructor(e=!0){this._trustProxy=e}get query(){if(this._query!==void 0)return this._query;let e={},t=this.req?.url;if(t){let r=t.indexOf("?");if(r!==-1){let n=r+1,o=t.length,s=t.indexOf("+",n)!==-1,i=t.indexOf("%",n)!==-1;while(n<o){let a=t.indexOf("&",n);if(a===-1)a=o;if(a>n){let u=t.indexOf("=",n),c,d;if(u!==-1&&u<a)c=t.slice(n,u),d=t.slice(u+1,a);else c=t.slice(n,a),d="";if(s){if(c.indexOf("+")!==-1)c=c.replaceAll("+"," ");if(d.indexOf("+")!==-1)d=d.replaceAll("+"," ")}if(i){if(c.indexOf("%")!==-1)try{c=decodeURIComponent(c)}catch{}if(d.indexOf("%")!==-1)try{d=decodeURIComponent(d)}catch{}}if(c!=="__proto__"&&c!=="constructor"&&c!=="prototype")e[c]=d}n=a+1}}}return this._query=e,e}getQuery(e){return this.query[e]}get cookies(){if(this._cookies!==void 0)return this._cookies;let e={},t=this.req?.headers?.get("cookie");if(t){let r=0,n=t.length;while(r<n){let o=t.indexOf(";",r);if(o===-1)o=n;let s=t.indexOf("=",r);if(s!==-1&&s<o){let i=t.slice(r,s).trim(),a=t.slice(s+1,o).trim();try{a=decodeURIComponent(a)}catch{}if(i&&i!=="__proto__"&&i!=="constructor"&&i!=="prototype")e[i]=a}r=o+1}}return this._cookies=e,e}setCookie(e,t,r={}){let n=t;if(r.secret){let s=uc("sha256",r.secret).update(t).digest("base64url");n=`${t}.${s}`}let o=`${e}=${encodeURIComponent(n)}`;if(o+=`; Path=${r.path??"/"}`,r.domain)o+=`; Domain=${r.domain}`;if(r.maxAge!==void 0)o+=`; Max-Age=${Math.floor(r.maxAge)}`;if(r.expires)o+=`; Expires=${r.expires.toUTCString()}`;if(r.httpOnly!==!1)o+="; HttpOnly";if(r.secure)o+="; Secure";if(o+=`; SameSite=${r.sameSite??"Lax"}`,!this._setCookies)this._setCookies=[];return this._setCookies.push(o),this}getSignedCookie(e,t){let r=this.cookies[e];if(!r)return null;let n=r.lastIndexOf(".");if(n<=0)return null;let o=r.slice(0,n),s=r.slice(n+1),i=uc("sha256",t).update(o).digest(),a=Buffer.from(s,"base64url");if(a.length!==i.length||!Uy(a,i))return null;return o}deleteCookie(e,t={}){return this.setCookie(e,"",{...t,maxAge:0,expires:new Date(0)})}async jsonBody(e=1048576){if(this.body!==void 0)return this.body;let t=this.req.headers.get("content-type");if(t&&t.includes("application/json")){let r=this.req.headers.get("content-length");if(r!==null){if(Number(r)>e){let o=Error("Payload Too Large");throw o.status=413,o}try{return this.body=await this.req.json()}catch{return this.body=null}}try{let n=await this.req.text();if(Buffer.byteLength(n,"utf-8")>e){let o=Error("Payload Too Large");throw o.status=413,o}return this.body=JSON.parse(n)}catch(n){if(n?.status===413)throw n;return this.body=null}}return this.body=null}reset(e){if(this.req=e,this._status=200,this._headers=void 0,this.store.size>0)this.store.clear();return this.params={},this._query=void 0,this._cookies=void 0,this._setCookies=void 0,this.body=void 0,this._peerIp=void 0,this}status(e){return this._status=e,this}json(e){let t=this._status||200,r;if(!this._headers)r=t===200?Response.json(e):Response.json(e,{status:t});else{let n=this._headers;if(n["content-type"]===void 0){if(Object.isFrozen(n))n={...n},this._headers=n;n["content-type"]="application/json"}r=Response.json(e,{status:t,headers:n})}if(this._setCookies)for(let n=0;n<this._setCookies.length;n++)r.headers.append("Set-Cookie",this._setCookies[n]);return r}set(e,t){return this.store.set(e,t),this}get(e){return this.store.get(e)}setHeader(e,t){if(!this._headers)this._headers={};else if(Object.isFrozen(this._headers))this._headers={...this._headers};return this._headers[e.toLowerCase()]=t,this}get user(){return this.store.get("user")}send(e,t={}){let r=this._status>=400;return this.json({status:r?"error":"success",msg:e,...t})}html(e,t){let r={"content-type":"text/html; charset=utf-8",...this._headers||{}};return new Response(e,{status:t??this._status,headers:r})}text(e,t){let r={"content-type":"text/plain; charset=utf-8",...this._headers||{}};return new Response(e,{status:t??this._status,headers:r})}redirect(e,t=302){let r={location:e,...this._headers||{}};return new Response(null,{status:t,headers:r})}sse(e){let t=new TextEncoder,r=(s)=>{if(typeof s==="string")return t.encode(`data: ${s}
58
58
 
59
- `);let s="";if(i.id!==void 0)s+=`id: ${i.id}
60
- `;if(i.event!==void 0)s+=`event: ${i.event}
61
- `;if(i.retry!==void 0)s+=`retry: ${i.retry}
62
- `;let a=typeof i.data==="string"?i.data:JSON.stringify(i.data);return s+=`data: ${a}
59
+ `);let i="";if(s.id!==void 0)i+=`id: ${s.id}
60
+ `;if(s.event!==void 0)i+=`event: ${s.event}
61
+ `;if(s.retry!==void 0)i+=`retry: ${s.retry}
62
+ `;let a=typeof s.data==="string"?s.data:JSON.stringify(s.data);return i+=`data: ${a}
63
63
 
64
- `,t.encode(s)},n=new ReadableStream({async start(i){try{if(typeof e==="function"){let s=!1,a=(u,m,g)=>{if(!s)i.enqueue(r({data:u,event:m,id:g}))},c=()=>{if(!s)s=!0,i.close()};await e(a,c),c()}else{for await(let s of e)i.enqueue(r(s));i.close()}}catch(s){i.error(s)}}}),o={"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache, no-transform",connection:"keep-alive",...this._headers||{}};return new Response(n,{status:this._status||200,headers:o})}get requestId(){if(this._requestId!==void 0)return this._requestId;let e=this.req?.headers?.get("x-request-id");return this._requestId=e&&e.length>0&&e.length<=128?e:crypto.randomUUID(),this._requestId}get ip(){let e=this.req?.headers?.get("x-forwarded-for");if(e)return e.split(",")[0].trim();return this.req?.headers?.get("x-real-ip")||this.req?.headers?.get("cf-connecting-ip")||"127.0.0.1"}async upload(e={}){let t=e.maxFileSize??5242880,r=e.maxFiles??10,n=e.allowedTypes?new Set(e.allowedTypes):null;if(!(this.req?.headers?.get("content-type")||"").includes("multipart/form-data"))throw Object.assign(Error("Expected multipart/form-data"),{status:400});if(Number(this.req?.headers?.get("content-length")||0)>t*r+65536)throw Object.assign(Error("Payload Too Large"),{status:413});let s=await this.req.formData(),a={},c=[];for(let[u,m]of s.entries()){if(typeof m==="string"){if(u!=="__proto__"&&u!=="constructor"&&u!=="prototype")a[u]=m;continue}let g=m;if(c.length>=r)throw Object.assign(Error(`Too many files (max ${r})`),{status:413});if(g.size>t)throw Object.assign(Error(`File exceeds max size of ${t} bytes`),{status:413});let I=(g.type||"").split(";")[0].trim().toLowerCase();if(n&&!n.has(I))throw Object.assign(Error(`Unsupported file type: ${g.type||"unknown"}`),{status:415});let O=g.name||"file",C=(O.split(/[\\/]/).pop()||"file").replace(/[^a-zA-Z0-9._-]/g,"_").replace(/^\.+/,"")||"file";c.push({fieldName:u,filename:O,safeName:C,type:g.type,size:g.size,file:g})}return{fields:a,files:c}}}function Kn(e,t){return t===void 0?ce(e):ce({...t,...e})}function nc(e){return l({[x]:"Argument",index:e})}function Ty(e,t){return se("Awaited",[se(e,t)])}function Py(e){return se("Awaited",[lt(e)])}function Ny(e){return Ke(oc(e))}function Sy(e){return J(oc(e))}function jy(e){return Bn(e)}function oc(e){return e.map((t)=>Bn(t))}function Bn(e,t){return l($t(e)?Ty(e.target,e.parameters):ge(e)?Ny(e.allOf):v(e)?Sy(e.anyOf):Lr(e)?jy(e.item):Ie(e)?Py(e.$ref):e,t)}function My(e){let t=[];for(let r of e)t.push(...yt(r));return Js(t)}function Uy(e){return e.filter((t)=>!lr(t))}function Ey(e,t){let r=[];for(let n of e)r.push(...ro(n,[t]));return Uy(r)}function Ly(e,t){let r={};for(let n of t)r[n]=Bo(Ey(e,n));return r}function ic(e,t){let r=My(e),n=Ly(e,r);return X(n,t)}function ci(e){return l({[x]:"Date",type:"Date"},e)}function ui(e){return l({[x]:"Null",type:"null"},e)}function fi(e){return l({[x]:"Symbol",type:"symbol"},e)}function di(e){return l({[x]:"Undefined",type:"undefined"},e)}function mi(e){return l({[x]:"Uint8Array",type:"Uint8Array"},e)}function Ky(e){return e.map((t)=>os(t,!1))}function By(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ye(os(e[r],!1));return t}function pi(e,t){return t===!0?e:Ye(e)}function os(e,t){return Os(e)?pi(Ir(),t):ws(e)?pi(Ir(),t):Oe(e)?Ye(mt(Ky(e))):pr(e)?mi():an(e)?ci():ae(e)?pi(X(By(e)),t):$s(e)?pi(vt([],br()),t):ie(e)?di():Rs(e)?ui():Fs(e)?fi():Uo(e)?ln():ot(e)?W(e):mr(e)?W(e):oe(e)?W(e):X({})}function sc(e,t){return l(os(e,!0),t)}function ac(e,t){return wt(e)?mt(e.parameters,t):E(t)}function cc(e,t){if(ie(e))throw Error("Enum undefined or empty");let r=globalThis.Object.getOwnPropertyNames(e).filter((i)=>isNaN(i)).map((i)=>e[i]),o=[...new Set(r)].map((i)=>W(i));return J(o,{...t,[qt]:"Enum"})}function uc(e,t){return Dn(Dr(e),t)}function Dy(e,t){let r=e.filter((n)=>$r(n,t)===y.False);return r.length===1?r[0]:J(r)}function Dn(e,t,r={}){if(at(e))return l(uc(e,t),r);if(ue(e))return l(fc(e,t),r);return l(v(e)?Dy(e.anyOf,t):$r(e,t)!==y.False?E():e,r)}function Gy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Dn(e[n],t);return r}function qy(e,t){return Gy(e.properties,t)}function fc(e,t){let r=qy(e,t);return H(r)}function dc(e,t){return Gn(Dr(e),t)}function vy(e,t){let r=e.filter((n)=>$r(n,t)!==y.False);return r.length===1?r[0]:J(r)}function Gn(e,t,r){if(at(e))return l(dc(e,t),r);if(ue(e))return l(mc(e,t),r);return l(v(e)?vy(e.anyOf,t):$r(e,t)!==y.False?e:E(),r)}function Hy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Gn(e[n],t);return r}function Vy(e,t){return Hy(e.properties,t)}function mc(e,t){let r=Vy(e,t);return H(r)}function pc(e,t){return wt(e)?l(e.returns,t):E(t)}function li(e){return Ye(Le(e))}function en(e,t,r){return l({[x]:"Record",type:"object",patternProperties:{[e]:t}},r)}function is(e,t,r){let n={};for(let o of e)n[o]=t;return X(n,{...r,[qt]:"Record"})}function zy(e,t,r){return Ss(e)?is(Je(e),t,r):en(e.pattern,t,r)}function Wy(e,t,r){return is(Je(J(e)),t,r)}function Jy(e,t,r){return is([e.toString()],t,r)}function Yy(e,t,r){return en(e.source,t,r)}function Xy(e,t,r){let n=ie(e.pattern)?gr:e.pattern;return en(n,t,r)}function Qy(e,t,r){return en(gr,t,r)}function Zy(e,t,r){return en(Ks,t,r)}function eg(e,t,r){return X({true:t,false:t},r)}function tg(e,t,r){return en(yr,t,r)}function rg(e,t,r){return en(yr,t,r)}function yi(e,t,r={}){return v(e)?Wy(e.anyOf,t,r):at(e)?zy(e,t,r):it(e)?Jy(e.const,t,r):Xt(e)?eg(e,t,r):Ft(e)?tg(e,t,r):At(e)?rg(e,t,r):Ci(e)?Yy(e,t,r):Qt(e)?Xy(e,t,r):Ai(e)?Qy(e,t,r):lr(e)?Zy(e,t,r):E(r)}function gi(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function lc(e){let t=gi(e);return t===gr?kt():t===yr?dt():kt({pattern:t})}function xi(e){return e.patternProperties[gi(e)]}function ng(e,t){return t.parameters=bo(e,t.parameters),t.returns=Kt(e,t.returns),t}function og(e,t){return t.parameters=bo(e,t.parameters),t.returns=Kt(e,t.returns),t}function ig(e,t){return t.allOf=bo(e,t.allOf),t}function sg(e,t){return t.anyOf=bo(e,t.anyOf),t}function ag(e,t){if(ie(t.items))return t;return t.items=bo(e,t.items),t}function cg(e,t){return t.items=Kt(e,t.items),t}function ug(e,t){return t.items=Kt(e,t.items),t}function fg(e,t){return t.items=Kt(e,t.items),t}function dg(e,t){return t.item=Kt(e,t.item),t}function mg(e,t){let r=gg(e,t.properties);return{...t,...X(r)}}function pg(e,t){let r=Kt(e,lc(t)),n=Kt(e,xi(t)),o=yi(r,n);return{...t,...o}}function lg(e,t){return t.index in e?e[t.index]:br()}function yg(e,t){let r=dn(t),n=We(t),o=Kt(e,t);return r&&n?li(o):r&&!n?Ye(o):!r&&n?Le(o):o}function gg(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,n)=>({...r,[n]:yg(e,t[n])}),{})}function bo(e,t){return t.map((r)=>Kt(e,r))}function Kt(e,t){return wt(t)?ng(e,t):Rt(t)?og(e,t):ge(t)?ig(e,t):v(t)?sg(e,t):ct(t)?ag(e,t):Ot(t)?cg(e,t):Mr(t)?ug(e,t):Er(t)?fg(e,t):Lr(t)?dg(e,t):be(t)?mg(e,t):Kr(t)?pg(e,t):ki(t)?lg(e,t):t}function yc(e,t){return Kt(t,Kn(e))}function gc(e){return l({[x]:"Integer",type:"integer"},e)}function xg(e,t,r){return{[e]:Bt(W(e),t,ce(r))}}function hg(e,t,r){return e.reduce((o,i)=>({...o,...xg(i,t,r)}),{})}function Ig(e,t,r){return hg(e.keys,t,r)}function xc(e,t,r){let n=Ig(e,t,r);return H(n)}function bg(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),r].join("")}function _g(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),r].join("")}function Og(e){return e.toUpperCase()}function $g(e){return e.toLowerCase()}function wg(e,t,r){let n=pn(e.pattern);if(!Br(n))return{...e,pattern:hc(e.pattern,t)};let s=[...to(n)].map((u)=>W(u)),a=Ic(s,t),c=J(a);return vo([c],r)}function hc(e,t){return typeof e==="string"?t==="Uncapitalize"?bg(e):t==="Capitalize"?_g(e):t==="Uppercase"?Og(e):t==="Lowercase"?$g(e):e:e.toString()}function Ic(e,t){return e.map((r)=>Bt(r,t))}function Bt(e,t,r={}){return st(e)?xc(e,t,r):at(e)?wg(e,t,r):v(e)?J(Ic(e.anyOf,t),r):it(e)?W(hc(e.const,t),r):l(e,r)}function bc(e,t={}){return Bt(e,"Capitalize",t)}function _c(e,t={}){return Bt(e,"Lowercase",t)}function Oc(e,t={}){return Bt(e,"Uncapitalize",t)}function $c(e,t={}){return Bt(e,"Uppercase",t)}function Rg(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Cr(e[o],t,ce(r));return n}function Fg(e,t,r){return Rg(e.properties,t,r)}function wc(e,t,r){let n=Fg(e,t,r);return H(n)}function Ag(e,t){return e.map((r)=>ss(r,t))}function kg(e,t){return e.map((r)=>ss(r,t))}function Cg(e,t){let{[t]:r,...n}=e;return n}function Tg(e,t){return t.reduce((r,n)=>Cg(r,n),e)}function Pg(e,t,r){let n=ye(e,[de,"$id","required","properties"]),o=Tg(r,t);return X(o,n)}function Ng(e){let t=e.reduce((r,n)=>Ko(n)?[...r,W(n)]:r,[]);return J(t)}function ss(e,t){return ge(e)?Ke(Ag(e.allOf,t)):v(e)?J(kg(e.anyOf,t)):be(e)?Pg(e,t,e.properties):X({})}function Cr(e,t,r){let n=Oe(t)?Ng(t):t,o=me(t)?Je(t):t,i=Ie(e),s=Ie(t);return ue(e)?wc(e,o,r):st(t)?Rc(e,t,r):i&&s?se("Omit",[e,n],r):!i&&s?se("Omit",[e,n],r):i&&!s?se("Omit",[e,n],r):l({...ss(e,o),...r})}function Sg(e,t,r){return{[t]:Cr(e,[t],ce(r))}}function jg(e,t,r){return t.reduce((n,o)=>({...n,...Sg(e,o,r)}),{})}function Mg(e,t,r){return jg(e,t.keys,r)}function Rc(e,t,r){let n=Mg(e,t,r);return H(n)}function Ug(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Tr(e[o],t,ce(r));return n}function Eg(e,t,r){return Ug(e.properties,t,r)}function Fc(e,t,r){let n=Eg(e,t,r);return H(n)}function Lg(e,t){return e.map((r)=>as(r,t))}function Kg(e,t){return e.map((r)=>as(r,t))}function Bg(e,t){let r={};for(let n of t)if(n in e)r[n]=e[n];return r}function Dg(e,t,r){let n=ye(e,[de,"$id","required","properties"]),o=Bg(r,t);return X(o,n)}function Gg(e){let t=e.reduce((r,n)=>Ko(n)?[...r,W(n)]:r,[]);return J(t)}function as(e,t){return ge(e)?Ke(Lg(e.allOf,t)):v(e)?J(Kg(e.anyOf,t)):be(e)?Dg(e,t,e.properties):X({})}function Tr(e,t,r){let n=Oe(t)?Gg(t):t,o=me(t)?Je(t):t,i=Ie(e),s=Ie(t);return ue(e)?Fc(e,o,r):st(t)?Ac(e,t,r):i&&s?se("Pick",[e,n],r):!i&&s?se("Pick",[e,n],r):i&&!s?se("Pick",[e,n],r):l({...as(e,o),...r})}function qg(e,t,r){return{[t]:Tr(e,[t],ce(r))}}function vg(e,t,r){return t.reduce((n,o)=>({...n,...qg(e,o,r)}),{})}function Hg(e,t,r){return vg(e,t.keys,r)}function Ac(e,t,r){let n=Hg(e,t,r);return H(n)}function Vg(e,t){return se("Partial",[se(e,t)])}function zg(e){return se("Partial",[lt(e)])}function Wg(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Le(e[r]);return t}function Jg(e,t){let r=ye(e,[de,"$id","required","properties"]),n=Wg(t);return X(n,r)}function kc(e){return e.map((t)=>Cc(t))}function Cc(e){return $t(e)?Vg(e.target,e.parameters):Ie(e)?zg(e.$ref):ge(e)?Ke(kc(e.allOf)):v(e)?J(kc(e.anyOf)):be(e)?Jg(e,e.properties):Ur(e)?e:Xt(e)?e:Ft(e)?e:it(e)?e:Yn(e)?e:At(e)?e:Qt(e)?e:Xn(e)?e:Zt(e)?e:X({})}function qn(e,t){if(ue(e))return Tc(e,t);else return l({...Cc(e),...t})}function Yg(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=qn(e[n],ce(t));return r}function Xg(e,t){return Yg(e.properties,t)}function Tc(e,t){let r=Xg(e,t);return H(r)}function Qg(e,t){return se("Required",[se(e,t)])}function Zg(e){return se("Required",[lt(e)])}function ex(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=ye(e[r],[Se]);return t}function tx(e,t){let r=ye(e,[de,"$id","required","properties"]),n=ex(t);return X(n,r)}function Pc(e){return e.map((t)=>Nc(t))}function Nc(e){return $t(e)?Qg(e.target,e.parameters):Ie(e)?Zg(e.$ref):ge(e)?Ke(Pc(e.allOf)):v(e)?J(Pc(e.anyOf)):be(e)?tx(e,e.properties):Ur(e)?e:Xt(e)?e:Ft(e)?e:it(e)?e:Yn(e)?e:At(e)?e:Qt(e)?e:Xn(e)?e:Zt(e)?e:X({})}function vn(e,t){if(ue(e))return Sc(e,t);else return l({...Nc(e),...t})}function rx(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=vn(e[n],t);return r}function nx(e,t){return rx(e.properties,t)}function Sc(e,t){let r=nx(e,t);return H(r)}function ox(e,t){return t.map((r)=>Ie(r)?cs(e,r.$ref):ft(e,r))}function cs(e,t){return t in e?Ie(e[t])?cs(e,e[t].$ref):ft(e,e[t]):E()}function ix(e){return Bn(e[0])}function sx(e){return xr(e[0],e[1])}function ax(e){return gn(e[0])}function cx(e){return qn(e[0])}function ux(e){return Cr(e[0],e[1])}function fx(e){return Tr(e[0],e[1])}function dx(e){return vn(e[0])}function mx(e,t,r){let n=ox(e,r);return t==="Awaited"?ix(n):t==="Index"?sx(n):t==="KeyOf"?ax(n):t==="Partial"?cx(n):t==="Omit"?ux(n):t==="Pick"?fx(n):t==="Required"?dx(n):E()}function px(e,t){return cn(ft(e,t))}function lx(e,t){return un(ft(e,t))}function yx(e,t,r){return fn(_o(e,t),ft(e,r))}function gx(e,t,r){return vt(_o(e,t),ft(e,r))}function xx(e,t){return Ke(_o(e,t))}function hx(e,t){return yn(ft(e,t))}function Ix(e,t){return X(globalThis.Object.keys(t).reduce((r,n)=>({...r,[n]:ft(e,t[n])}),{}))}function bx(e,t){let[r,n]=[ft(e,xi(t)),gi(t)],o=Kn(t);return o.patternProperties[n]=r,o}function _x(e,t){return Ie(t)?{...cs(e,t.$ref),[de]:t[de]}:t}function Ox(e,t){return mt(_o(e,t))}function $x(e,t){return J(_o(e,t))}function _o(e,t){return t.map((r)=>ft(e,r))}function ft(e,t){return We(t)?l(ft(e,ye(t,[Se])),t):dn(t)?l(ft(e,ye(t,[Gt])),t):V(t)?l(_x(e,t),t):Ot(t)?l(px(e,t.items),t):Mr(t)?l(lx(e,t.items),t):$t(t)?l(mx(e,t.target,t.parameters)):wt(t)?l(yx(e,t.parameters,t.returns),t):Rt(t)?l(gx(e,t.parameters,t.returns),t):ge(t)?l(xx(e,t.allOf),t):Er(t)?l(hx(e,t.items),t):be(t)?l(Ix(e,t.properties),t):Kr(t)?l(bx(e,t)):ct(t)?l(Ox(e,t.items||[]),t):v(t)?l($x(e,t.anyOf),t):t}function wx(e,t){return t in e?ft(e,e[t]):E()}function jc(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:wx(e,r)}),{})}class Mc{constructor(e){let t=jc(e),r=this.WithIdentifiers(t);this.$defs=r}Import(e,t){let r={...this.$defs,[e]:l(this.$defs[e],t)};return l({[x]:"Import",$defs:r,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:{...e[r],$id:r}}),{})}}function Uc(e){return new Mc(e)}function Ec(e,t){return l({[x]:"Not",not:e},t)}function Lc(e,t){return Rt(e)?mt(e.parameters,t):E()}var Rx=0;function Kc(e,t={}){if(ie(t.$id))t.$id=`T${Rx++}`;let r=Kn(e({[x]:"This",$ref:`${t.$id}`}));return r.$id=t.$id,l({[qt]:"Recursive",...r},t)}function Bc(e,t){let r=oe(e)?new globalThis.RegExp(e):e;return l({[x]:"RegExp",type:"RegExp",source:r.source,flags:r.flags},t)}function Fx(e){return ge(e)?e.allOf:v(e)?e.anyOf:ct(e)?e.items??[]:[]}function Dc(e){return Fx(e)}function Gc(e,t){return Rt(e)?l(e.returns,t):E(t)}class qc{constructor(e){this.schema=e}Decode(e){return new vc(this.schema,e)}}class vc{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let o={Encode:(i)=>t[de].Encode(e(i)),Decode:(i)=>this.decode(t[de].Decode(i))};return{...t,[de]:o}}EncodeSchema(e,t){let r={Decode:this.decode,Encode:e};return{...t,[de]:r}}Encode(e){return V(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}}function Hc(e){return new qc(e)}function Vc(e){return l({[x]:"Void",type:"void"},e)}var Ax=us;import{join as Cx}from"path";import{readFileSync as Tx}from"fs";Ii();import{join as kx}from"path";async function Wc(){let e=kx(process.cwd(),"bare.config.ts");try{let t=await import(e);return hi(t.default)}catch{return hi()}}var bi=(e)=>{if(!e||!e._def)return{type:"object"};let t=e._def,r=t.typeName;if(r==="ZodObject"){let n=typeof t.shape==="function"?t.shape():t.shape,o={},i=[];for(let[s,a]of Object.entries(n||{})){let c=a;if(o[s]=bi(c),c?._def?.typeName!=="ZodOptional"&&c?._def?.typeName!=="ZodDefault")i.push(s)}return{type:"object",properties:o,...i.length?{required:i}:{}}}if(r==="ZodString")return{type:"string"};if(r==="ZodNumber")return{type:"number"};if(r==="ZodBoolean")return{type:"boolean"};if(r==="ZodArray")return{type:"array",items:bi(t.type)};if(r==="ZodOptional"||r==="ZodDefault")return bi(t.innerType);if(r==="ZodEnum")return{type:"string",enum:t.values};return{type:"object"}},Oo=(e)=>{if(!e)return{type:"object"};if("_def"in e)return bi(e);return JSON.parse(JSON.stringify(e))},ds=(e,t={})=>{let r={};for(let n of e){if(n.path==="/docs"||n.path==="/docs/json")continue;let o=("/"+n.path).replace(/\/+/g,"/").replace(/:([a-zA-Z0-9_]+)/g,"{$1}");if(!r[o])r[o]={};let i=n.method.toLowerCase(),s=[],a=void 0,c=void 0,u=void 0,m=null;for(let I of n.handlers){if(!I)continue;let O=I.__routeSchemas;if(O){if(O.detail)u=O.detail;if(O.params)m=Oo(O.params);if(O.query){let T=Oo(O.query),C=new Set(T.required||[]);for(let[Y,fe]of Object.entries(T.properties||{}))s.push({name:Y,in:"query",required:C.has(Y),schema:fe})}if(O.headers){let T=Oo(O.headers),C=new Set(T.required||[]);for(let[Y,fe]of Object.entries(T.properties||{}))s.push({name:Y,in:"header",required:C.has(Y),schema:fe})}if(O.response)c=Oo(O.response)}if(I.__schema&&!a)a={required:!0,content:{"application/json":{schema:Oo(I.__schema)}}}}let g=n.path.matchAll(/:([a-zA-Z0-9_]+)/g);for(let I of g){let O=I[1],T=m?.properties?.[O]||{type:"string"};s.unshift({name:O,in:"path",required:!0,schema:T})}r[o][i]={summary:u?.summary||`${n.method} ${o}`,...u?.description?{description:u.description}:{},...u?.tags?{tags:u.tags}:{},...s.length?{parameters:s}:{},...a?{requestBody:a}:{},responses:{"200":{description:"Success",...c?{content:{"application/json":{schema:c}}}:{}}}}}return{openapi:"3.1.0",info:{title:t.title||"BareJS API",version:t.version||"1.0.0",...t.description?{description:t.description}:{}},paths:r}},ms=(e,t="BareJS API Docs")=>{let r=t.replace(/[<>&"]/g,""),n=JSON.stringify(e);return`<!doctype html>
64
+ `,t.encode(i)},n=new ReadableStream({async start(s){try{if(typeof e==="function"){let i=!1,a=(c,d,m)=>{if(!i)s.enqueue(r({data:c,event:d,id:m}))},u=()=>{if(!i)i=!0,s.close()};await e(a,u),u()}else{for await(let i of e)s.enqueue(r(i));s.close()}}catch(i){s.error(i)}}}),o={"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache, no-transform",connection:"keep-alive",...this._headers||{}};return new Response(n,{status:this._status||200,headers:o})}get requestId(){if(this._requestId!==void 0)return this._requestId;let e=this.req?.headers?.get("x-request-id");return this._requestId=e&&e.length>0&&e.length<=128?e:crypto.randomUUID(),this._requestId}get ip(){if(this._trustProxy){let e=this.req?.headers?.get("x-forwarded-for");if(e)return e.split(",")[0].trim();let t=this.req?.headers?.get("x-real-ip")||this.req?.headers?.get("cf-connecting-ip");if(t)return t}return this._peerIp||"127.0.0.1"}async upload(e={}){let t=e.maxFileSize??5242880,r=e.maxFiles??10,n=e.allowedTypes?new Set(e.allowedTypes):null;if(!(this.req?.headers?.get("content-type")||"").includes("multipart/form-data"))throw Object.assign(Error("Expected multipart/form-data"),{status:400});if(Number(this.req?.headers?.get("content-length")||0)>t*r+65536)throw Object.assign(Error("Payload Too Large"),{status:413});let i=await this.req.formData(),a={},u=[];for(let[c,d]of i.entries()){if(typeof d==="string"){if(c!=="__proto__"&&c!=="constructor"&&c!=="prototype")a[c]=d;continue}let m=d;if(u.length>=r)throw Object.assign(Error(`Too many files (max ${r})`),{status:413});if(m.size>t)throw Object.assign(Error(`File exceeds max size of ${t} bytes`),{status:413});let x=(m.type||"").split(";")[0].trim().toLowerCase();if(n&&!n.has(x))throw Object.assign(Error(`Unsupported file type: ${m.type||"unknown"}`),{status:415});let y=m.name||"file",C=(y.split(/[\\/]/).pop()||"file").replace(/[^a-zA-Z0-9._-]/g,"_").replace(/^\.+/,"")||"file";u.push({fieldName:c,filename:y,safeName:C,type:m.type,size:m.size,file:m})}return{fields:a,files:u}}}function Gn(e,t){return t===void 0?Re(e):Re({...t,...e})}function dc(e){return g({[I]:"Argument",index:e})}function Ly(e,t){return Ie("Awaited",[Ie(e,t)])}function Ky(e){return Ie("Awaited",[$t(e)])}function By(e){return Ze(fc(e))}function vy(e){return ce(fc(e))}function Dy(e){return Hn(e)}function fc(e){return e.map((t)=>Hn(t))}function Hn(e,t){return g(Tt(e)?Ly(e.target,e.parameters):Ae(e)?By(e.allOf):ee(e)?vy(e.anyOf):Hr(e)?Dy(e.item):Me(e)?Ky(e.$ref):e,t)}function qy(e){let t=[];for(let r of e)t.push(...St(r));return ta(t)}function Gy(e){return e.filter((t)=>!Rr(t))}function Hy(e,t){let r=[];for(let n of e)r.push(...so(n,[t]));return Gy(r)}function zy(e,t){let r={};for(let n of t)r[n]=Do(Hy(e,n));return r}function mc(e,t){let r=qy(e),n=zy(e,r);return ue(n,t)}function ds(e){return g({[I]:"Date",type:"Date"},e)}function fs(e){return g({[I]:"Null",type:"null"},e)}function ms(e){return g({[I]:"Symbol",type:"symbol"},e)}function ps(e){return g({[I]:"Undefined",type:"undefined"},e)}function ls(e){return g({[I]:"Uint8Array",type:"Uint8Array"},e)}function Vy(e){return e.map((t)=>ui(t,!1))}function Jy(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=dt(ui(e[r],!1));return t}function ys(e,t){return t===!0?e:dt(e)}function ui(e,t){return ki(e)?ys(Sr(),t):Ai(e)?ys(Sr(),t):Ke(e)?dt(Ot(Vy(e))):br(e)?ls():pn(e)?ds():be(e)?ys(ue(Jy(e)),t):Ci(e)?ys(Qt([],Pr()),t):xe(e)?ps():Ti(e)?fs():Fi(e)?ms():Lo(e)?bn():yt(e)?ie(e):Ir(e)?ie(e):he(e)?ie(e):ue({})}function pc(e,t){return g(ui(e,!0),t)}function lc(e,t){return Ft(e)?Ot(e.parameters,t):q(t)}function yc(e,t){if(xe(e))throw Error("Enum undefined or empty");let r=globalThis.Object.getOwnPropertyNames(e).filter((s)=>isNaN(s)).map((s)=>e[s]),o=[...new Set(r)].map((s)=>ie(s));return ce(o,{...t,[Yt]:"Enum"})}function gc(e,t){return zn(Jr(e),t)}function Wy(e,t){let r=e.filter((n)=>Ar(n,t)===h.False);return r.length===1?r[0]:ce(r)}function zn(e,t,r={}){if(xt(e))return g(gc(e,t),r);if(_e(e))return g(hc(e,t),r);return g(ee(e)?Wy(e.anyOf,t):Ar(e,t)!==h.False?q():e,r)}function Xy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=zn(e[n],t);return r}function Yy(e,t){return Xy(e.properties,t)}function hc(e,t){let r=Yy(e,t);return te(r)}function xc(e,t){return Vn(Jr(e),t)}function Qy(e,t){let r=e.filter((n)=>Ar(n,t)!==h.False);return r.length===1?r[0]:ce(r)}function Vn(e,t,r){if(xt(e))return g(xc(e,t),r);if(_e(e))return g(Ic(e,t),r);return g(ee(e)?Qy(e.anyOf,t):Ar(e,t)!==h.False?e:q(),r)}function Zy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Vn(e[n],t);return r}function eg(e,t){return Zy(e.properties,t)}function Ic(e,t){let r=eg(e,t);return te(r)}function bc(e,t){return Ft(e)?g(e.returns,t):q(t)}function gs(e){return dt(Qe(e))}function un(e,t,r){return g({[I]:"Record",type:"object",patternProperties:{[e]:t}},r)}function di(e,t,r){let n={};for(let o of e)n[o]=t;return ue(n,{...r,[Yt]:"Record"})}function tg(e,t,r){return Ki(e)?di(ut(e),t,r):un(e.pattern,t,r)}function rg(e,t,r){return di(ut(ce(e)),t,r)}function ng(e,t,r){return di([e.toString()],t,r)}function og(e,t,r){return un(e.source,t,r)}function sg(e,t,r){let n=xe(e.pattern)?Or:e.pattern;return un(n,t,r)}function ig(e,t,r){return un(Or,t,r)}function ag(e,t,r){return un(Hi,t,r)}function cg(e,t,r){return ue({true:t,false:t},r)}function ug(e,t,r){return un(_r,t,r)}function dg(e,t,r){return un(_r,t,r)}function hs(e,t,r={}){return ee(e)?rg(e.anyOf,t,r):xt(e)?tg(e,t,r):gt(e)?ng(e.const,t,r):or(e)?cg(e,t,r):Mt(e)?ug(e,t,r):jt(e)?dg(e,t,r):Ms(e)?og(e,t,r):sr(e)?sg(e,t,r):Fs(e)?ig(e,t,r):Rr(e)?ag(e,t,r):q(r)}function xs(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function Rc(e){let t=xs(e);return t===Or?Et():t===_r?_t():Et({pattern:t})}function Is(e){return e.patternProperties[xs(e)]}function fg(e,t){return t.parameters=Oo(e,t.parameters),t.returns=Vt(e,t.returns),t}function mg(e,t){return t.parameters=Oo(e,t.parameters),t.returns=Vt(e,t.returns),t}function pg(e,t){return t.allOf=Oo(e,t.allOf),t}function lg(e,t){return t.anyOf=Oo(e,t.anyOf),t}function yg(e,t){if(xe(t.items))return t;return t.items=Oo(e,t.items),t}function gg(e,t){return t.items=Vt(e,t.items),t}function hg(e,t){return t.items=Vt(e,t.items),t}function xg(e,t){return t.items=Vt(e,t.items),t}function Ig(e,t){return t.item=Vt(e,t.item),t}function bg(e,t){let r=wg(e,t.properties);return{...t,...ue(r)}}function Rg(e,t){let r=Vt(e,Rc(t)),n=Vt(e,Is(t)),o=hs(r,n);return{...t,...o}}function _g(e,t){return t.index in e?e[t.index]:Pr()}function Og(e,t){let r=hn(t),n=ct(t),o=Vt(e,t);return r&&n?gs(o):r&&!n?dt(o):!r&&n?Qe(o):o}function wg(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,n)=>({...r,[n]:Og(e,t[n])}),{})}function Oo(e,t){return t.map((r)=>Vt(e,r))}function Vt(e,t){return Ft(t)?fg(e,t):Nt(t)?mg(e,t):Ae(t)?pg(e,t):ee(t)?lg(e,t):It(t)?yg(e,t):At(t)?gg(e,t):Dr(t)?hg(e,t):Gr(t)?xg(e,t):Hr(t)?Ig(e,t):Ee(t)?bg(e,t):zr(t)?Rg(e,t):Ns(t)?_g(e,t):t}function _c(e,t){return Vt(t,Gn(e))}function Oc(e){return g({[I]:"Integer",type:"integer"},e)}function $g(e,t,r){return{[e]:Jt(ie(e),t,Re(r))}}function Sg(e,t,r){return e.reduce((o,s)=>({...o,...$g(s,t,r)}),{})}function Pg(e,t,r){return Sg(e.keys,t,r)}function wc(e,t,r){let n=Pg(e,t,r);return te(n)}function kg(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),r].join("")}function Cg(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),r].join("")}function Ag(e){return e.toUpperCase()}function Tg(e){return e.toLowerCase()}function Fg(e,t,r){let n=In(e.pattern);if(!Vr(n))return{...e,pattern:$c(e.pattern,t)};let i=[...oo(n)].map((c)=>ie(c)),a=Sc(i,t),u=ce(a);return zo([u],r)}function $c(e,t){return typeof e==="string"?t==="Uncapitalize"?kg(e):t==="Capitalize"?Cg(e):t==="Uppercase"?Ag(e):t==="Lowercase"?Tg(e):e:e.toString()}function Sc(e,t){return e.map((r)=>Jt(r,t))}function Jt(e,t,r={}){return ht(e)?wc(e,t,r):xt(e)?Fg(e,t,r):ee(e)?ce(Sc(e.anyOf,t),r):gt(e)?ie($c(e.const,t),r):g(e,r)}function Pc(e,t={}){return Jt(e,"Capitalize",t)}function kc(e,t={}){return Jt(e,"Lowercase",t)}function Cc(e,t={}){return Jt(e,"Uncapitalize",t)}function Ac(e,t={}){return Jt(e,"Uppercase",t)}function Ng(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Er(e[o],t,Re(r));return n}function Mg(e,t,r){return Ng(e.properties,t,r)}function Tc(e,t,r){let n=Mg(e,t,r);return te(n)}function jg(e,t){return e.map((r)=>fi(r,t))}function Eg(e,t){return e.map((r)=>fi(r,t))}function Ug(e,t){let{[t]:r,...n}=e;return n}function Lg(e,t){return t.reduce((r,n)=>Ug(r,n),e)}function Kg(e,t,r){let n=Ce(e,[we,"$id","required","properties"]),o=Lg(r,t);return ue(o,n)}function Bg(e){let t=e.reduce((r,n)=>vo(n)?[...r,ie(n)]:r,[]);return ce(t)}function fi(e,t){return Ae(e)?Ze(jg(e.allOf,t)):ee(e)?ce(Eg(e.anyOf,t)):Ee(e)?Kg(e,t,e.properties):ue({})}function Er(e,t,r){let n=Ke(t)?Bg(t):t,o=$e(t)?ut(t):t,s=Me(e),i=Me(t);return _e(e)?Tc(e,o,r):ht(t)?Fc(e,t,r):s&&i?Ie("Omit",[e,n],r):!s&&i?Ie("Omit",[e,n],r):s&&!i?Ie("Omit",[e,n],r):g({...fi(e,o),...r})}function vg(e,t,r){return{[t]:Er(e,[t],Re(r))}}function Dg(e,t,r){return t.reduce((n,o)=>({...n,...vg(e,o,r)}),{})}function qg(e,t,r){return Dg(e,t.keys,r)}function Fc(e,t,r){let n=qg(e,t,r);return te(n)}function Gg(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Ur(e[o],t,Re(r));return n}function Hg(e,t,r){return Gg(e.properties,t,r)}function Nc(e,t,r){let n=Hg(e,t,r);return te(n)}function zg(e,t){return e.map((r)=>mi(r,t))}function Vg(e,t){return e.map((r)=>mi(r,t))}function Jg(e,t){let r={};for(let n of t)if(n in e)r[n]=e[n];return r}function Wg(e,t,r){let n=Ce(e,[we,"$id","required","properties"]),o=Jg(r,t);return ue(o,n)}function Xg(e){let t=e.reduce((r,n)=>vo(n)?[...r,ie(n)]:r,[]);return ce(t)}function mi(e,t){return Ae(e)?Ze(zg(e.allOf,t)):ee(e)?ce(Vg(e.anyOf,t)):Ee(e)?Wg(e,t,e.properties):ue({})}function Ur(e,t,r){let n=Ke(t)?Xg(t):t,o=$e(t)?ut(t):t,s=Me(e),i=Me(t);return _e(e)?Nc(e,o,r):ht(t)?Mc(e,t,r):s&&i?Ie("Pick",[e,n],r):!s&&i?Ie("Pick",[e,n],r):s&&!i?Ie("Pick",[e,n],r):g({...mi(e,o),...r})}function Yg(e,t,r){return{[t]:Ur(e,[t],Re(r))}}function Qg(e,t,r){return t.reduce((n,o)=>({...n,...Yg(e,o,r)}),{})}function Zg(e,t,r){return Qg(e,t.keys,r)}function Mc(e,t,r){let n=Zg(e,t,r);return te(n)}function eh(e,t){return Ie("Partial",[Ie(e,t)])}function th(e){return Ie("Partial",[$t(e)])}function rh(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Qe(e[r]);return t}function nh(e,t){let r=Ce(e,[we,"$id","required","properties"]),n=rh(t);return ue(n,r)}function jc(e){return e.map((t)=>Ec(t))}function Ec(e){return Tt(e)?eh(e.target,e.parameters):Me(e)?th(e.$ref):Ae(e)?Ze(jc(e.allOf)):ee(e)?ce(jc(e.anyOf)):Ee(e)?nh(e,e.properties):qr(e)?e:or(e)?e:Mt(e)?e:gt(e)?e:Zn(e)?e:jt(e)?e:sr(e)?e:eo(e)?e:ir(e)?e:ue({})}function Jn(e,t){if(_e(e))return Uc(e,t);else return g({...Ec(e),...t})}function oh(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Jn(e[n],Re(t));return r}function sh(e,t){return oh(e.properties,t)}function Uc(e,t){let r=sh(e,t);return te(r)}function ih(e,t){return Ie("Required",[Ie(e,t)])}function ah(e){return Ie("Required",[$t(e)])}function ch(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ce(e[r],[Ve]);return t}function uh(e,t){let r=Ce(e,[we,"$id","required","properties"]),n=ch(t);return ue(n,r)}function Lc(e){return e.map((t)=>Kc(t))}function Kc(e){return Tt(e)?ih(e.target,e.parameters):Me(e)?ah(e.$ref):Ae(e)?Ze(Lc(e.allOf)):ee(e)?ce(Lc(e.anyOf)):Ee(e)?uh(e,e.properties):qr(e)?e:or(e)?e:Mt(e)?e:gt(e)?e:Zn(e)?e:jt(e)?e:sr(e)?e:eo(e)?e:ir(e)?e:ue({})}function Wn(e,t){if(_e(e))return Bc(e,t);else return g({...Kc(e),...t})}function dh(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Wn(e[n],t);return r}function fh(e,t){return dh(e.properties,t)}function Bc(e,t){let r=fh(e,t);return te(r)}function mh(e,t){return t.map((r)=>Me(r)?pi(e,r.$ref):Rt(e,r))}function pi(e,t){return t in e?Me(e[t])?pi(e,e[t].$ref):Rt(e,e[t]):q()}function ph(e){return Hn(e[0])}function lh(e){return wr(e[0],e[1])}function yh(e){return _n(e[0])}function gh(e){return Jn(e[0])}function hh(e){return Er(e[0],e[1])}function xh(e){return Ur(e[0],e[1])}function Ih(e){return Wn(e[0])}function bh(e,t,r){let n=mh(e,r);return t==="Awaited"?ph(n):t==="Index"?lh(n):t==="KeyOf"?yh(n):t==="Partial"?gh(n):t==="Omit"?hh(n):t==="Pick"?xh(n):t==="Required"?Ih(n):q()}function Rh(e,t){return ln(Rt(e,t))}function _h(e,t){return yn(Rt(e,t))}function Oh(e,t,r){return gn(wo(e,t),Rt(e,r))}function wh(e,t,r){return Qt(wo(e,t),Rt(e,r))}function $h(e,t){return Ze(wo(e,t))}function Sh(e,t){return Rn(Rt(e,t))}function Ph(e,t){return ue(globalThis.Object.keys(t).reduce((r,n)=>({...r,[n]:Rt(e,t[n])}),{}))}function kh(e,t){let[r,n]=[Rt(e,Is(t)),xs(t)],o=Gn(t);return o.patternProperties[n]=r,o}function Ch(e,t){return Me(t)?{...pi(e,t.$ref),[we]:t[we]}:t}function Ah(e,t){return Ot(wo(e,t))}function Th(e,t){return ce(wo(e,t))}function wo(e,t){return t.map((r)=>Rt(e,r))}function Rt(e,t){return ct(t)?g(Rt(e,Ce(t,[Ve])),t):hn(t)?g(Rt(e,Ce(t,[Xt])),t):ne(t)?g(Ch(e,t),t):At(t)?g(Rh(e,t.items),t):Dr(t)?g(_h(e,t.items),t):Tt(t)?g(bh(e,t.target,t.parameters)):Ft(t)?g(Oh(e,t.parameters,t.returns),t):Nt(t)?g(wh(e,t.parameters,t.returns),t):Ae(t)?g($h(e,t.allOf),t):Gr(t)?g(Sh(e,t.items),t):Ee(t)?g(Ph(e,t.properties),t):zr(t)?g(kh(e,t)):It(t)?g(Ah(e,t.items||[]),t):ee(t)?g(Th(e,t.anyOf),t):t}function Fh(e,t){return t in e?Rt(e,e[t]):q()}function vc(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:Fh(e,r)}),{})}class Dc{constructor(e){let t=vc(e),r=this.WithIdentifiers(t);this.$defs=r}Import(e,t){let r={...this.$defs,[e]:g(this.$defs[e],t)};return g({[I]:"Import",$defs:r,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:{...e[r],$id:r}}),{})}}function qc(e){return new Dc(e)}function Gc(e,t){return g({[I]:"Not",not:e},t)}function Hc(e,t){return Nt(e)?Ot(e.parameters,t):q()}var Nh=0;function zc(e,t={}){if(xe(t.$id))t.$id=`T${Nh++}`;let r=Gn(e({[I]:"This",$ref:`${t.$id}`}));return r.$id=t.$id,g({[Yt]:"Recursive",...r},t)}function Vc(e,t){let r=he(e)?new globalThis.RegExp(e):e;return g({[I]:"RegExp",type:"RegExp",source:r.source,flags:r.flags},t)}function Mh(e){return Ae(e)?e.allOf:ee(e)?e.anyOf:It(e)?e.items??[]:[]}function Jc(e){return Mh(e)}function Wc(e,t){return Nt(e)?g(e.returns,t):q(t)}class Xc{constructor(e){this.schema=e}Decode(e){return new Yc(this.schema,e)}}class Yc{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let o={Encode:(s)=>t[we].Encode(e(s)),Decode:(s)=>this.decode(t[we].Decode(s))};return{...t,[we]:o}}EncodeSchema(e,t){let r={Decode:this.decode,Encode:e};return{...t,[we]:r}}Encode(e){return ne(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}}function Qc(e){return new Xc(e)}function Zc(e){return g({[I]:"Void",type:"void"},e)}var jh=li;import{join as Uh}from"path";import{readFileSync as Lh}from"fs";Rs();import{join as Eh}from"path";async function tu(){let e=Eh(process.cwd(),"bare.config.ts");try{let t=await import(e);return bs(t.default)}catch{return bs()}}var _s=(e)=>{if(!e||!e._def)return{type:"object"};let t=e._def,r=t.typeName;if(r==="ZodObject"){let n=typeof t.shape==="function"?t.shape():t.shape,o={},s=[];for(let[i,a]of Object.entries(n||{})){let u=a;if(o[i]=_s(u),u?._def?.typeName!=="ZodOptional"&&u?._def?.typeName!=="ZodDefault")s.push(i)}return{type:"object",properties:o,...s.length?{required:s}:{}}}if(r==="ZodString")return{type:"string"};if(r==="ZodNumber")return{type:"number"};if(r==="ZodBoolean")return{type:"boolean"};if(r==="ZodArray")return{type:"array",items:_s(t.type)};if(r==="ZodOptional"||r==="ZodDefault")return _s(t.innerType);if(r==="ZodEnum")return{type:"string",enum:t.values};return{type:"object"}},$o=(e)=>{if(!e)return{type:"object"};if("_def"in e)return _s(e);return JSON.parse(JSON.stringify(e))},gi=(e,t={})=>{let r={};for(let n of e){if(n.path==="/docs"||n.path==="/docs/json")continue;let o=("/"+n.path).replace(/\/+/g,"/").replace(/:([a-zA-Z0-9_]+)/g,"{$1}");if(!r[o])r[o]={};let s=n.method.toLowerCase(),i=[],a=void 0,u=void 0,c=void 0,d=null;for(let x of n.handlers){if(!x)continue;let y=x.__routeSchemas;if(y){if(y.detail)c=y.detail;if(y.params)d=$o(y.params);if(y.query){let R=$o(y.query),C=new Set(R.required||[]);for(let[G,A]of Object.entries(R.properties||{}))i.push({name:G,in:"query",required:C.has(G),schema:A})}if(y.headers){let R=$o(y.headers),C=new Set(R.required||[]);for(let[G,A]of Object.entries(R.properties||{}))i.push({name:G,in:"header",required:C.has(G),schema:A})}if(y.response)u=$o(y.response)}if(x.__schema&&!a)a={required:!0,content:{"application/json":{schema:$o(x.__schema)}}}}let m=n.path.matchAll(/:([a-zA-Z0-9_]+)/g);for(let x of m){let y=x[1],R=d?.properties?.[y]||{type:"string"};i.unshift({name:y,in:"path",required:!0,schema:R})}r[o][s]={summary:c?.summary||`${n.method} ${o}`,...c?.description?{description:c.description}:{},...c?.tags?{tags:c.tags}:{},...i.length?{parameters:i}:{},...a?{requestBody:a}:{},responses:{"200":{description:"Success",...u?{content:{"application/json":{schema:u}}}:{}}}}}return{openapi:"3.1.0",info:{title:t.title||"BareJS API",version:t.version||"1.0.0",...t.description?{description:t.description}:{}},...t.servers?.length?{servers:t.servers}:{},...t.tags?.length?{tags:t.tags}:{},...t.securitySchemes?{components:{securitySchemes:t.securitySchemes}}:{},...t.security?.length?{security:t.security}:{},paths:r}},hi=(e,t="BareJS API Docs")=>{let r=t.replace(/[<>&"]/g,""),n=JSON.stringify(e);return`<!doctype html>
65
65
  <html>
66
66
  <head>
67
67
  <title>${r}</title>
@@ -72,9 +72,10 @@ var{defineProperty:Oi,getOwnPropertyNames:su,getOwnPropertyDescriptor:au}=Object
72
72
  <script id="api-reference" data-url=${n}></script>
73
73
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
74
74
  </body>
75
- </html>`};class Jc extends Ln{tree=new Zr;pool=[];hotFetch;compiled=!1;poolMask;_useLog=!1;errorHandler;wsRoutes=new Map;startHooks=[];stopHooks=[];server;shutdownHandler;wsAdapter={open(e){e.data?.open?.(e)},message(e,t){e.data?.message?.(e,t)},close(e,t,r){e.data?.close?.(e,t,r)},drain(e){e.data?.drain?.(e)}};useLog(e=!0){return this._useLog=e,this}onStart(e){return this.startHooks.push(e),this}onStop(e){return this.stopHooks.push(e),this}async stop(e=!1){if(this.shutdownHandler)process.off("SIGINT",this.shutdownHandler),process.off("SIGTERM",this.shutdownHandler),this.shutdownHandler=void 0;if(this.server)this.server.stop(e),this.server=void 0;for(let t of this.stopHooks)await t()}constructor(e=1024){super();Wc();let t=Math.pow(2,Math.ceil(Math.log2(e)));this.poolMask=t-1;for(let r=0;r<t;r++)this.pool.push(new Io);try{let r=Cx(process.cwd(),"package.json"),n=JSON.parse(Tx(r,"utf-8"));if(n.name)this.name=n.name.split(/[-_]/).map((o)=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}catch{this.name="App"}}notFoundHandler=()=>({status:404,message:"Route not found"});setNotFound(e){this.notFoundHandler=e}onError(e){return this.errorHandler=e,this}ws(e,t){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/";return this.wsRoutes.set(r,t),this}docs(e="/docs",t={}){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/docs",n=`${r}/json`,o=null,i=ms(n,t.title||`${this.name} API Docs`);return this.get(n,()=>{if(!o)o=JSON.stringify(ds(this.routes,{title:this.name,...t}));return new Response(o,{status:200,headers:{"content-type":"application/json"}})}),this.get(r,()=>new Response(i,{status:200,headers:{"content-type":"text/html; charset=utf-8"}})),this}rpc(e,t){let r=async(n,o)=>{if(!n||n.jsonrpc!=="2.0"||typeof n.method!=="string")return{jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:n?.id??null};let i=Object.hasOwn(t,n.method)?t[n.method]:void 0;if(!i)return{jsonrpc:"2.0",error:{code:-32601,message:"Method not found"},id:n.id??null};try{let s=await i(n.params,o);if(n.id===void 0)return null;return{jsonrpc:"2.0",result:s,id:n.id}}catch(s){return{jsonrpc:"2.0",error:{code:-32603,message:s?.message||"Internal error"},id:n.id??null}}};return this.post(e,async(n)=>{let o=await n.jsonBody();if(!o)return n.status(400).json({jsonrpc:"2.0",error:{code:-32700,message:"Parse error"},id:null});if(Array.isArray(o)){if(o.length===0)return n.status(400).json({jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:null});let s=(await Promise.all(o.map((a)=>r(a,n)))).filter(Boolean);return s.length>0?s:new Response(null,{status:204})}let i=await r(o,n);return i===null?new Response(null,{status:204}):i}),this}_hasDerive=!1;derive(e){return this._hasDerive=!0,this.use(async(t,r)=>{let n=await e(t);if(n&&typeof n==="object"){let o=Object.keys(n);if(!t._derivedKeys)t._derivedKeys=[];for(let i=0;i<o.length;i++){let s=o[i];if(s!=="__proto__"&&s!=="constructor"&&s!=="prototype")t[s]=n[s],t._derivedKeys.push(s)}}return r()}),this}compileHandler(e,t){let r=e.find((j)=>j?.__timeout);if(r){let{ms:j,status:Ae,message:ht}=r.__timeout,Re=e.filter((qe)=>!qe?.__timeout),et=this.compileHandler(Re,t);return async(qe,tt)=>{let dr=et(qe,tt);if(!dr||!dr.then)return dr;let tn;try{let Vn=new Promise((ee)=>{tn=setTimeout(()=>{ee(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:ht},{status:Ae}))},j)});return await Promise.race([dr,Vn])}finally{if(tn!==void 0)clearTimeout(tn)}}}let n=e.length,i=e.find((j)=>j?.__responseFilter)?.__responseFilter,a=e.find((j)=>j?.__idempotencyCommit)?.__idempotencyCommit,c={status:200,headers:{"content-type":"application/json"}},u={status:200,headers:{"content-type":"text/plain"}},I=`
76
- ${i?"res = rFilter(res);":""}
75
+ </html>`};class ru extends an{tree=new cn;pool=[];hotFetch;compiled=!1;poolMask;_useLog=!1;_trustProxy=!0;errorHandler;wsRoutes=new Map;startHooks=[];stopHooks=[];crons=[];server;shutdownHandler;wsAdapter={open(e){e.data?.open?.(e)},message(e,t){e.data?.message?.(e,t)},close(e,t,r){e.data?.close?.(e,t,r)},drain(e){e.data?.drain?.(e)}};useLog(e=!0){return this._useLog=e,this}onStart(e){return this.startHooks.push(e),this}onStop(e){return this.stopHooks.push(e),this}cron(e,t,r,n={}){let o=!1,s=async()=>{if(o)return;o=!0;try{await r()}catch(a){n.onError?.(a)}finally{o=!1}},i=setInterval(s,t);if(this.crons.push({name:e,timer:i}),n.runOnStart)s();return this}async stop(e=!1){for(let t of this.crons)clearInterval(t.timer);if(this.crons.length=0,this.shutdownHandler)process.off("SIGINT",this.shutdownHandler),process.off("SIGTERM",this.shutdownHandler),this.shutdownHandler=void 0;if(this.server)this.server.stop(e),this.server=void 0;for(let t of this.stopHooks)await t()}constructor(e=1024){super();tu();let t=Math.pow(2,Math.ceil(Math.log2(e)));this.poolMask=t-1;for(let r=0;r<t;r++)this.pool.push(new _o);try{let r=Uh(process.cwd(),"package.json"),n=JSON.parse(Lh(r,"utf-8"));if(n.name)this.name=n.name.split(/[-_]/).map((o)=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}catch{this.name="App"}}notFoundHandler=()=>({status:404,message:"Route not found"});setNotFound(e){this.notFoundHandler=e}onError(e){return this.errorHandler=e,this}ws(e,t){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/";return this.wsRoutes.set(r,t),this}docs(e="/docs",t={}){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/docs",n=`${r}/json`,o=null,s=hi(n,t.title||`${this.name} API Docs`);return this.get(n,()=>{if(!o)o=JSON.stringify(gi(this.routes,{title:this.name,...t}));return new Response(o,{status:200,headers:{"content-type":"application/json"}})}),this.get(r,()=>new Response(s,{status:200,headers:{"content-type":"text/html; charset=utf-8"}})),this}rpc(e,t){let r=async(n,o)=>{if(!n||n.jsonrpc!=="2.0"||typeof n.method!=="string")return{jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:n?.id??null};let s=Object.hasOwn(t,n.method)?t[n.method]:void 0;if(!s)return{jsonrpc:"2.0",error:{code:-32601,message:"Method not found"},id:n.id??null};try{let i=await s(n.params,o);if(n.id===void 0)return null;return{jsonrpc:"2.0",result:i,id:n.id}}catch(i){return{jsonrpc:"2.0",error:{code:-32603,message:i?.message||"Internal error"},id:n.id??null}}};return this.post(e,async(n)=>{let o=await n.jsonBody();if(!o)return n.status(400).json({jsonrpc:"2.0",error:{code:-32700,message:"Parse error"},id:null});if(Array.isArray(o)){if(o.length===0)return n.status(400).json({jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:null});let i=(await Promise.all(o.map((a)=>r(a,n)))).filter(Boolean);return i.length>0?i:new Response(null,{status:204})}let s=await r(o,n);return s===null?new Response(null,{status:204}):s}),this}_hasDerive=!1;derive(e){return this._hasDerive=!0,this.use(async(t,r)=>{let n=await e(t);if(n&&typeof n==="object"){let o=Object.keys(n);if(!t._derivedKeys)t._derivedKeys=[];for(let s=0;s<o.length;s++){let i=o[s];if(i!=="__proto__"&&i!=="constructor"&&i!=="prototype")t[i]=n[i],t._derivedKeys.push(i)}}return r()}),this}compileHandler(e,t){let r=e.find((P)=>P?.__timeout);if(r){let{ms:P,status:ae,message:me}=r.__timeout,E=e.filter((oe)=>!oe?.__timeout),pe=this.compileHandler(E,t);return async(oe,Oe)=>{let Ue=pe(oe,Oe);if(!Ue||!Ue.then)return Ue;let N;try{let re=new Promise((ke)=>{N=setTimeout(()=>{ke(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:me},{status:ae}))},P)});return await Promise.race([Ue,re])}finally{if(N!==void 0)clearTimeout(N)}}}let n=e.find((P)=>P?.__circuitBreaker);if(n){let P=n.__circuitBreaker,ae=e.filter((E)=>!E?.__circuitBreaker),me=this.compileHandler(ae,t);return(E,pe)=>P(()=>me(E,pe))}let o=e.find((P)=>P?.__compress);if(o){let P=o.__compress,ae=e.filter((E)=>!E?.__compress),me=this.compileHandler(ae,t);return async(E,pe)=>{let oe=await me(E,pe);return P(E,oe)}}let s=e.length,a=e.find((P)=>P?.__responseFilter)?.__responseFilter,u=e.find((P)=>P?.__idempotencyCommit),c=u?.__idempotencyCommit,d=u?.__idempotencyRelease,m={status:200,headers:{"content-type":"application/json"}},x={status:200,headers:{"content-type":"text/plain"}},C=`
76
+ ${a?"res = rFilter(res);":""}
77
77
  if (res instanceof Response) {
78
+ ${c?"idemCommit(ctx, res, res.status);":""}
78
79
  if (ctx._headers) {
79
80
  for (const k in ctx._headers) {
80
81
  if (!res.headers.has(k)) res.headers.set(k, ctx._headers[k]);
@@ -88,7 +89,7 @@ var{defineProperty:Oi,getOwnPropertyNames:su,getOwnPropertyDescriptor:au}=Object
88
89
  }
89
90
 
90
91
  const finalStatus = ctx._status || 200;
91
- ${a?"idemCommit(ctx, res, finalStatus);":""}
92
+ ${c?"idemCommit(ctx, res, finalStatus);":""}
92
93
  ${t?"doLog(finalStatus);":""}
93
94
 
94
95
  let outRes;
@@ -102,44 +103,49 @@ var{defineProperty:Oi,getOwnPropertyNames:su,getOwnPropertyDescriptor:au}=Object
102
103
  });
103
104
  }
104
105
  } else if (finalStatus === 200 && !ctx._headers) {
105
- outRes = Response.json(res ?? null, json200);
106
+ outRes = Response.json(res ?? null);
107
+ } else if (finalStatus === 200 && ctx._headers === lastHdrs) {
108
+ outRes = Response.json(res ?? null, lastInit200);
106
109
  } else {
107
- outRes = Response.json(res ?? null, {
108
- status: finalStatus,
109
- headers: ctx._headers || json200.headers
110
- });
110
+ const hdrs = ctx._headers || json200.headers;
111
+ const init = { status: finalStatus, headers: hdrs };
112
+ if (finalStatus === 200 && Object.isFrozen(hdrs)) {
113
+ lastHdrs = hdrs;
114
+ lastInit200 = init;
115
+ }
116
+ outRes = Response.json(res ?? null, init);
111
117
  }
112
118
 
113
119
  if (ctx._setCookies) {
114
120
  for (let i = 0; i < ctx._setCookies.length; i++) outRes.headers.append('Set-Cookie', ctx._setCookies[i]);
115
121
  }
116
122
  return outRes;
117
- `,O=t?"ctx, doLog":"ctx";if(n===1){let j=e[0];if(j.constructor.name==="AsyncFunction")return Function("fn0","json200","text200",`return async function(${O}) {
118
- const res = await fn0(ctx);
119
- ${I}
120
- }`)(j,c,u);return Function("fn0","json200","text200",`return function(${O}) {
121
- const res = fn0(ctx);
122
- if (res && res.then) return res.then(v => { const res = v; ${I} });
123
- ${I}
124
- }`)(j,c,u)}let T=e.some((j)=>j.constructor.name==="AsyncFunction"),C="",Y=e.map((j,Ae)=>`fn${Ae}`);if(T){for(let j=0;j<n-1;j++)C+=`let r${j} = fn${j}(ctx, noop);
125
- `,C+=`if (r${j}) {
126
- `,C+=` if (r${j}.then) r${j} = await r${j};
127
- `,C+=` if (r${j} instanceof Response) { ${t?"doLog(r"+j+".status);":""} return r${j}; }
128
- `,C+=`}
129
- `;C+=`
130
- let res = fn${n-1}(ctx);
123
+ `,G=t?"ctx, doLog":"ctx",A=[...a?["rFilter"]:[],...c?["idemCommit"]:[],...d?["idemRelease"]:[]],M=[...a?[a]:[],...c?[c]:[],...d?[d]:[]],V=(P)=>{if(!d)return P;return(ae,me)=>{try{let E=P(ae,me);if(E&&typeof E.then==="function")return E.then((pe)=>pe,(pe)=>{throw d(ae),pe});return E}catch(E){throw d(ae),E}}};if(s===1){let P=e[0];if(P.constructor.name==="AsyncFunction")return V(Function("fn0","json200","text200",...A,`let lastHdrs = null, lastInit200 = null; return async function(${G}) {
124
+ const res = await fn0(ctx);
125
+ ${C}
126
+ }`)(P,m,x,...M));return V(Function("fn0","json200","text200",...A,`let lastHdrs = null, lastInit200 = null; return function(${G}) {
127
+ const res = fn0(ctx);
128
+ if (res && res.then) return res.then(v => { const res = v; ${C} });
129
+ ${C}
130
+ }`)(P,m,x,...M))}let H=e.some((P)=>P.constructor.name==="AsyncFunction"),L="",v=e.map((P,ae)=>`fn${ae}`);if(H){for(let P=0;P<s-1;P++)L+=`let r${P} = fn${P}(ctx, noop);
131
+ `,L+=`if (r${P}) {
132
+ `,L+=` if (r${P}.then) r${P} = await r${P};
133
+ `,L+=` if (r${P} instanceof Response) { ${t?"doLog(r"+P+".status);":""} return r${P}; }
134
+ `,L+=`}
135
+ `;L+=`
136
+ let res = fn${s-1}(ctx);
131
137
  if (res && res.then) res = await res;
132
- ${I}
133
- `}else{for(let j=0;j<n-1;j++)C+=`const r${j} = fn${j}(ctx, noop);
134
- `,C+=`if (r${j} && r${j} instanceof Response) { ${t?"doLog(r"+j+".status);":""} return r${j}; }
135
- `;C+=`
136
- let res = fn${n-1}(ctx);
137
- if (res && res.then) return res.then(v => { let res = v; ${I} });
138
- ${I}
139
- `}let fe=()=>{},Ee=T?`return async function(${O})`:`return function(${O})`;return Function(...Y,"noop","json200","text200",...i?["rFilter"]:[],...a?["idemCommit"]:[],`${Ee} { ${C} }`)(...e,fe,c,u,...i?[i]:[],...a?[a]:[])}compile(){let e=this._useLog;this.tree=new Zr;for(let ee of this.routes)this.tree.insert(ee.path,ee.method,this.compileHandler(ee.handlers,e));let t=this.tree,r=this.pool,n=r.length,o=this.notFoundHandler,i=this.errorHandler,s=(ee,rt)=>{if(i){let It=i(ee,rt);if(It instanceof Response)return It;let Jt=rt._status>=400?rt._status:500;if(typeof It==="string")return new Response(It,{status:Jt});return Response.json(It??null,{status:Jt})}if(ee?.status>=400&&ee?.status<500)return Response.json({status:ee.status,message:ee.message||"Bad Request"},{status:ee.status});return Response.json({status:500,message:ee?.message||"Internal Server Error",stack:ee?.stack},{status:500})},a=[],c=(ee)=>{let rt=`h${a.length}`;return a.push(ee),rt},u=t.jitCompile(c),m=Object.freeze({}),g=a.map((ee,rt)=>`h${rt}`),I=this.routes.some((ee)=>ee.handlers.some((rt)=>rt?.__idempotencyCommit)),C=`
138
+ ${C}
139
+ `}else{for(let P=0;P<s-1;P++)L+=`const r${P} = fn${P}(ctx, noop);
140
+ `,L+=`if (r${P} && r${P} instanceof Response) { ${t?"doLog(r"+P+".status);":""} return r${P}; }
141
+ `;L+=`
142
+ let res = fn${s-1}(ctx);
143
+ if (res && res.then) return res.then(v => { let res = v; ${C} });
144
+ ${C}
145
+ `}let Y=()=>{},Ne=H?`let lastHdrs = null, lastInit200 = null; return async function(${G})`:`let lastHdrs = null, lastInit200 = null; return function(${G})`;return V(Function(...v,"noop","json200","text200",...A,`${Ne} { ${L} }`)(...e,Y,m,x,...M))}compile(){let e=this._useLog;this.tree=new cn;for(let N of this.routes)this.tree.insert(N.path,N.method,this.compileHandler(N.handlers,e));let t=this.tree,r=this.pool,n=r.length,o=this.notFoundHandler,s=this.errorHandler,i=(N,re)=>{if(re._headers)for(let ke in re._headers){let Ye=re._headers[ke];if(Ye!==void 0&&!N.headers.has(ke))try{N.headers.set(ke,Ye)}catch{}}if(re._setCookies)for(let ke=0;ke<re._setCookies.length;ke++)try{N.headers.append("Set-Cookie",re._setCookies[ke])}catch{}return N},a=(N,re)=>{if(N instanceof Response)return i(N,re);let ke=re._status>=400?re._status:500;if(typeof N==="string")return i(new Response(N,{status:ke}),re);return i(Response.json(N??null,{status:ke}),re)},u=(N,re)=>{if(s){let ke=s(N,re);if(ke&&typeof ke.then==="function")return ke.then((Ye)=>a(Ye,re));return a(ke,re)}if(N?.status>=400&&N?.status<500)return i(Response.json({status:N.status,message:N.message||"Bad Request"},{status:N.status}),re);return i(Response.json({status:500,message:N?.message||"Internal Server Error",stack:N?.stack},{status:500}),re)},c=[],d=(N)=>{let re=`h${c.length}`;return c.push(N),re},m=t.jitCompile(d),x=Object.freeze({}),y=c.map((N,re)=>`h${re}`),R=this.routes.some((N)=>N.handlers.some((re)=>re?.__idempotencyCommit)),A=`
140
146
  if (ctx.store.size > 0) ctx.store.clear();
141
147
  ${this._hasDerive?"if (ctx._derivedKeys) { for (let i = 0; i < ctx._derivedKeys.length; i++) delete ctx[ctx._derivedKeys[i]]; ctx._derivedKeys = undefined; }":""}
142
- ${I?"if (ctx._idempotencyKey) { ctx._idemInFlight.delete(ctx._idempotencyKey); ctx._idempotencyKey = undefined; ctx._idemInFlight = undefined; }":""}
148
+ ${R?"if (ctx._idempotencyKey) { ctx._idemInFlight.delete(ctx._idempotencyKey); ctx._idempotencyKey = undefined; ctx._idemInFlight = undefined; }":""}
143
149
  ctx.req = undefined;
144
150
  ctx._status = 200;
145
151
  ctx.body = undefined;
@@ -148,36 +154,39 @@ var{defineProperty:Oi,getOwnPropertyNames:su,getOwnPropertyDescriptor:au}=Object
148
154
  ctx._setCookies = undefined;
149
155
  ctx._headers = undefined;
150
156
  ctx._requestId = undefined;
157
+ ctx._peerIp = undefined;
151
158
  ctx.params = EMPTY_PARAMS;
152
159
  if (poolTop < maxPool) pool[poolTop++] = ctx;
153
- `,Y=e?"(ctx, doLog)":"(ctx)",fe=u.replace(/return (h\d+)\(ctx\);/g,`out = $1${Y};
154
- if (out && out.then) return out.then((v) => { ${C} return v; }, (e) => { const errRes = hError(e, ctx); ${C} ${e?"doLog(errRes.status || 500);":""} return errRes; });
155
- ${C}
156
- return out;`),Ee=this.groupMiddleware.length>0,j=Ee?this.compileHandler(this.groupMiddleware,e):void 0,Ae=Ee?`if (method === 'OPTIONS') {
157
- out = hOptions${Y};
158
- if (out && out.then) return out.then((v) => { ${C} return v; }, (e) => { const errRes = hError(e, ctx); ${C} ${e?"doLog(errRes.status || 500);":""} return errRes; });
159
- ${C}
160
+ `,M=`const errRes = hError(e, ctx);
161
+ if (errRes && errRes.then) return errRes.then((r) => { ${e?"doLog(r.status || 500);":""} ${A} return r; });
162
+ ${e?"doLog(errRes.status || 500);":""}
163
+ ${A}
164
+ return errRes;`,V=e?"(ctx, doLog)":"(ctx)",H=m.replace(/return (h\d+)\(ctx\);/g,`out = $1${V};
165
+ if (out && out.then) return out.then((v) => { ${A} return v; }, (e) => { ${M} });
166
+ ${A}
167
+ return out;`),L=this.groupMiddleware.length>0,v=L?this.compileHandler(this.groupMiddleware,e):void 0,Y=L?`if (method === 'OPTIONS') {
168
+ out = hOptions${V};
169
+ if (out && out.then) return out.then((v) => { ${A} return v; }, (e) => { ${M} });
170
+ ${A}
160
171
  return out;
161
- }`:"",ht=this.groupMiddleware.filter((ee)=>ee.__isStatic),Re=ht.length>0,et=Re?async(ee)=>{let rt=()=>{};for(let It=0;It<ht.length;It++){let Jt=await ht[It](ee,rt);if(Jt instanceof Response){if(ee._headers)for(let zn in ee._headers){let $o=ee._headers[zn];if($o!==void 0&&!Jt.headers.has(zn))Jt.headers.set(zn,$o)}return Jt}}return}:void 0,qe=Re?`if (method === 'GET' || method === 'HEAD') {
172
+ }`:"",Ne=this.groupMiddleware.filter((N)=>N.__isStatic),P=Ne.length>0,ae=P?async(N)=>{let re=()=>{};for(let ke=0;ke<Ne.length;ke++){let Ye=await Ne[ke](N,re);if(Ye instanceof Response){if(N._headers)for(let je in N._headers){let st=N._headers[je];if(st!==void 0&&!Ye.headers.has(je))Ye.headers.set(je,st)}return Ye}}return}:void 0,me=P?`if (method === 'GET' || method === 'HEAD') {
162
173
  out = runStatic(ctx);
163
174
  if (out && out.then) {
164
175
  return out.then((v) => {
165
- if (v instanceof Response) { ${e?"doLog(v.status);":""} ${C} return v; }
176
+ if (v instanceof Response) { ${e?"doLog(v.status);":""} ${A} return v; }
166
177
  const errorBody = hNotFound();
167
178
  const status = errorBody.status || 404;
179
+ const nfRes = applyCtxHeaders(Response.json(errorBody, { status }), ctx);
168
180
  ${e?"doLog(status);":""}
169
- ${C}
170
- return Response.json(errorBody, { status });
181
+ ${A}
182
+ return nfRes;
171
183
  }, (e) => {
172
- const errRes = hError(e, ctx);
173
- ${C}
174
- ${e?"doLog(errRes.status || 500);":""}
175
- return errRes;
184
+ ${M}
176
185
  });
177
186
  }
178
- }`:"",tt=["pool","maxPool","Context","hNotFound","hError","EMPTY_PARAMS",...Ee?["hOptions"]:[],...Re?["runStatic"]:[],...g],dr=[r,n,Io,o,s,m,...Ee?[j]:[],...Re?[et]:[],...a],Vn=`
187
+ }`:"",E=this._trustProxy,pe=["pool","maxPool","Context","hNotFound","hError","applyCtxHeaders","EMPTY_PARAMS","trustProxyVal",...L?["hOptions"]:[],...P?["runStatic"]:[],...y],oe=[r,n,_o,o,u,i,x,E,...L?[v]:[],...P?[ae]:[],...c],Ue=`
179
188
  let poolTop = maxPool;
180
- return function(req) {
189
+ return function(req, peerIp) {
181
190
  const url = req.url;
182
191
  let s = url.indexOf('/', 8);
183
192
  const q = s === -1 ? -1 : url.indexOf('?', s);
@@ -186,33 +195,32 @@ var{defineProperty:Oi,getOwnPropertyNames:su,getOwnPropertyDescriptor:au}=Object
186
195
  else s = urlLen;
187
196
 
188
197
  const method = req.method;
189
- const ctx = poolTop > 0 ? pool[--poolTop] : new Context();
198
+ const ctx = poolTop > 0 ? pool[--poolTop] : new Context(trustProxyVal);
190
199
  let out;
191
200
  ${e?"\n const start = performance.now();\n const doLog = (status) => {\n const duration = (performance.now() - start).toFixed(3);\n console.log(\n ` \\x1b[90m${new Date().toLocaleTimeString()}\\x1b[0m ` +\n `\\x1b[1m\\x1b[38;5;117m${method.padEnd(7)}\\x1b[0m ` +\n `\\x1b[38;5;250m${url.substring(url.indexOf('/', 8))}\\x1b[0m ` +\n `${status >= 400 ? '\\x1b[33m' : '\\x1b[32m'}${status}\\x1b[0m ` +\n `\\x1b[90m(${duration}ms)\\x1b[0m`\n );\n };":""}
192
201
 
193
202
  try {
194
203
  ctx.req = req;
204
+ ctx._peerIp = peerIp;
195
205
 
196
- ${fe}
206
+ ${H}
197
207
 
198
- ${Ae}
208
+ ${Y}
199
209
 
200
- ${qe}
210
+ ${me}
201
211
 
202
212
  const errorBody = hNotFound();
203
213
  const status = errorBody.status || 404;
214
+ const nfRes = applyCtxHeaders(Response.json(errorBody, { status }), ctx);
204
215
  ${e?"doLog(status);":""}
205
- ${C}
206
- return Response.json(errorBody, { status });
216
+ ${A}
217
+ return nfRes;
207
218
 
208
219
  } catch (e) {
209
- const errRes = hError(e, ctx);
210
- ${e?"doLog(errRes.status || 500);":""}
211
- ${C}
212
- return errRes;
220
+ ${M}
213
221
  }
214
222
  }
215
- `;this.hotFetch=Function(...tt,Vn)(...dr),this.compiled=!0,this.fetch=this.hotFetch}fetch=(e)=>{if(!this.compiled)return this.compile(),this.hotFetch(e);return this.hotFetch(e)};name="App";listen(e,t="0.0.0.0",r=!0){if(!this.compiled)this.compile();let{BARE_CONFIG:n}=(Ii(),fu(zc)),o=e||n.port||3000;if(!0)console.log(`
223
+ `;this.hotFetch=Function(...pe,Ue)(...oe),this.compiled=!0,this.fetch=this.hotFetch}fetch=(e,t)=>{if(!this.compiled)return this.compile(),this.hotFetch(e,t);return this.hotFetch(e,t)};async request(e,t){let r;if(e.startsWith("http://")||e.startsWith("https://"))r=e;else r=`http://localhost${e.startsWith("/")?e:`/${e}`}`;return this.fetch(new Request(r,t))}name="App";trustProxy(e=!0){this._trustProxy=e;for(let t=0;t<this.pool.length;t++)this.pool[t]._trustProxy=e;return this}listen(e,t="0.0.0.0",r=!0,n={}){if(!this.compiled)this.compile();if(n.trustProxy!==void 0)this.trustProxy(n.trustProxy);let o=n.maxRequestBodySize??10485760,{BARE_CONFIG:s}=(Rs(),Iu(eu)),i=e||s.port||3000;if(!0)console.log(`
216
224
  \x1B[33m ____ _ _____ \x1B[0m
217
225
  \x1B[33m | __ ) __ _ _ __ ___ | | ____|\x1B[0m
218
226
  \x1B[33m | _ \\ / _\` | '__/ _ \\ _ | | _| \x1B[0m
@@ -220,9 +228,9 @@ var{defineProperty:Oi,getOwnPropertyNames:su,getOwnPropertyDescriptor:au}=Object
220
228
  \x1B[33m |____/ \\__,_|_| \\___| \\___/|_____|\x1B[0m
221
229
 
222
230
  \x1B[32m\uD83D\uDE80 ${this.name} is running in development mode\x1B[0m
223
- \x1B[90m\u2699\uFE0F Pool Size: ${this.pool.length} | JIT: Enabled | Port: ${o}\x1B[0m
224
- \x1B[36m\uD83D\uDEE1\uFE0F Hash: ${n.hash.algorithm} (${n.hash.memoryCost/1024}MB) | Iterations: ${n.hash.timeCost}\x1B[0m
225
- `);let s=this.wsRoutes,a=this.fetch,u=s.size>0?Bun.serve({port:o,hostname:t,reusePort:r,fetch(g,I){if(g.headers.get("upgrade")==="websocket"){let O=g.url,T=O.indexOf("/",8),C=T===-1?-1:O.indexOf("?",T),Y=T===-1?"/":C===-1?O.slice(T):O.slice(T,C),fe=Y.length>1&&Y.endsWith("/")?Y.slice(0,-1):Y,Ee=s.get(fe);if(Ee&&I.upgrade(g,{data:Ee}))return}return a(g)},websocket:this.wsAdapter}):Bun.serve({port:o,hostname:t,reusePort:r,fetch:a});this.server=u;for(let g of this.startHooks)Promise.resolve(g()).catch((I)=>console.error(`[${this.name}] onStart error:`,I));let m=async()=>{let I=this.name,O=process.stdout.isTTY;{let T=O?"\uD83D\uDED1":"!",C=O?"\u2705":"v";process.stdout.write(`
226
- \x1B[31m${T} Stopping ${I}...\x1B[0m
227
- `),await this.stop(!1),process.stdout.write(`\x1B[32m${C} ${I} has been stopped.\x1B[0m
228
- `)}process.exit(0)};return this.shutdownHandler=m,process.on("SIGINT",m),process.on("SIGTERM",m),u}}var Px=(e={})=>{let t=e.origin||"*",r=e.methods||"GET,POST,PUT,PATCH,DELETE,OPTIONS",n=Array.isArray(e.allowedHeaders)?e.allowedHeaders.join(", "):e.allowedHeaders||"Content-Type, Authorization",o=Array.isArray(e.exposedHeaders)?e.exposedHeaders.join(", "):e.exposedHeaders,i=e.credentials===!0;if(typeof t==="string"){let u={"Access-Control-Allow-Origin":t,"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n};if(t!=="*")u.Vary="Origin";if(i)u["Access-Control-Allow-Credentials"]="true";let m={status:204,headers:u};return(I,O)=>{if(I.req.method==="OPTIONS")return new Response(null,m);if(I.setHeader("Access-Control-Allow-Origin",t),I.setHeader("Access-Control-Allow-Methods",r),t!=="*")I.setHeader("Vary","Origin");if(i)I.setHeader("Access-Control-Allow-Credentials","true");if(o)I.setHeader("Access-Control-Expose-Headers",o);let T=O?.();if(T&&typeof T.then==="function")return T.then((C)=>{if(C instanceof Response){if(C.headers.set("Access-Control-Allow-Origin",t),C.headers.set("Access-Control-Allow-Methods",r),t!=="*")C.headers.set("Vary","Origin");if(i)C.headers.set("Access-Control-Allow-Credentials","true");if(o)C.headers.set("Access-Control-Expose-Headers",o)}return C});if(T instanceof Response){if(T.headers.set("Access-Control-Allow-Origin",t),T.headers.set("Access-Control-Allow-Methods",r),t!=="*")T.headers.set("Vary","Origin");if(i)T.headers.set("Access-Control-Allow-Credentials","true");if(o)T.headers.set("Access-Control-Expose-Headers",o)}return T}}let s=Array.isArray(t)?new Set(t):null,a=(u)=>{if(!u)return null;if(s)return s.has(u)?u:null;return t(u)?u:null};return(u,m)=>{let g=a(u.req.headers.get("origin"));if(u.req.method==="OPTIONS"){let I={"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n,Vary:"Origin"};if(g)I["Access-Control-Allow-Origin"]=g;if(i&&g)I["Access-Control-Allow-Credentials"]="true";return new Response(null,{status:204,headers:I})}if(u.setHeader("Vary","Origin"),u.setHeader("Access-Control-Allow-Methods",r),g){if(u.setHeader("Access-Control-Allow-Origin",g),i)u.setHeader("Access-Control-Allow-Credentials","true")}if(o)u.setHeader("Access-Control-Expose-Headers",o);return m?.()}};var Nx=new Set(["GET","HEAD","OPTIONS"]),Sx=(e={})=>{let t=e.ignoreMethods?new Set(e.ignoreMethods.map((s)=>s.toUpperCase())):Nx,r=e.allowedOrigins?new Set(e.allowedOrigins):null,n=e.cookieName||"csrf_token",o=(e.headerName||"x-csrf-token").toLowerCase(),i=e.requireToken===!0;return(s,a)=>{let c=s.req.method.toUpperCase();if(t.has(c))return a();let u=s.req.headers.get("sec-fetch-site"),m=s.req.headers.get("origin"),g=s.req.headers.get("referer");if(u==="cross-site"){if(!r||!m||!r.has(m))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Cross-site request blocked"},{status:403})}let I=m;if(!I&&g)try{I=new URL(g).origin}catch{return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Invalid Referer header"},{status:403})}if(I){let O;try{O=new URL(s.req.url).origin}catch{O=""}if(!(I===O||r!==null&&r.has(I)))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Origin mismatch"},{status:403})}if(i){let O=s.cookies[n],T=s.req.headers.get(o);if(!O||!T||O!==T)return Response.json({status:"error",code:"CSRF_TOKEN_INVALID",message:"Invalid or missing CSRF token"},{status:403})}return a()}};var jx=(e=1e4,t={})=>{let r=t.status??408,n=t.message??"Request Timeout",o=async(i,s)=>{let a;try{let c=new Promise((u)=>{a=setTimeout(()=>{u(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:n},{status:r}))},e)});return await Promise.race([Promise.resolve(s()),c])}finally{if(a!==void 0)clearTimeout(a)}};return o.__timeout={ms:e,status:r,message:n},o};var Mx=(e={})=>{let t=e.windowMs??60000,r=e.max??100,n=e.message??"Too many requests, please try again later.",o=e.maxEntries??1e4,i=e.keyGenerator??((a)=>a.req.headers.get("x-forwarded-for")?.split(",")[0]?.trim()||a.req.headers.get("x-real-ip")||"global"),s=new Map;return(a,c)=>{let u=Date.now(),m=i(a),g=s.get(m);if(!g||u>=g.resetAt){if(s.size>=o){for(let[O,T]of s){if(u>=T.resetAt)s.delete(O);if(s.size<o)break}if(s.size>=o){let O=s.keys().next().value;if(O!==void 0)s.delete(O)}}g={count:1,resetAt:u+t},s.set(m,g)}else g.count++;let I=Math.max(0,r-g.count);if(a.setHeader("X-RateLimit-Limit",String(r)),a.setHeader("X-RateLimit-Remaining",String(I)),a.setHeader("X-RateLimit-Reset",String(Math.ceil(g.resetAt/1000))),g.count>r){let O=Math.max(1,Math.ceil((g.resetAt-u)/1000));return Response.json({status:"error",code:"RATE_LIMITED",message:n},{status:429,headers:{"Retry-After":String(O),"X-RateLimit-Limit":String(r),"X-RateLimit-Remaining":"0","X-RateLimit-Reset":String(Math.ceil(g.resetAt/1000))}})}return c?.()}};var Ux=(e={})=>{let t=(e.headerName||"idempotency-key").toLowerCase(),r=e.ttlMs??300000,n=e.maxKeys??1e4,o=new Map,i=new Set,s=(a)=>{let c=a.req.headers.get(t);if(!c)return;let u=Date.now(),m=o.get(c);if(m){if(u<m.expiresAt)return Response.json(m.body,{status:m.status,headers:{"X-Idempotent-Replayed":"true"}});o.delete(c)}if(i.has(c))return Response.json({status:"error",code:"IDEMPOTENT_IN_FLIGHT",message:"Duplicate request is currently in flight"},{status:409});i.add(c),a._idempotencyKey=c,a._idemInFlight=i;return};return s.__idempotencyCommit=(a,c,u)=>{let m=a._idempotencyKey;if(!m)return;if(i.delete(m),u>=200&&u<300&&!(c instanceof Response)){if(o.size>=n){let g=o.keys().next().value;if(g!==void 0)o.delete(g)}o.set(m,{status:u,body:c,expiresAt:Date.now()+r})}},s},Ex=()=>{let e=new Map;return async(t,r)=>{let n=e.get(t);if(n)return{data:await n,shared:!0};let o=r().finally(()=>{e.delete(t)});return e.set(t,o),{data:await o,shared:!1}}};var Lx=(e={})=>{let t=[];if(e.noSniff!==!1)t.push(["X-Content-Type-Options","nosniff"]);if(e.frameOptions!==!1)t.push(["X-Frame-Options",e.frameOptions??"DENY"]);if(e.referrerPolicy!==!1)t.push(["Referrer-Policy",e.referrerPolicy??"strict-origin-when-cross-origin"]);if(e.hsts!==!1)t.push(["Strict-Transport-Security",e.hsts??"max-age=31536000; includeSubDomains"]);if(e.contentSecurityPolicy)t.push(["Content-Security-Policy",e.contentSecurityPolicy]);t.push(["X-XSS-Protection","0"]);let r=t.length,n=Object.freeze((()=>{let o={};for(let i=0;i<r;i++){let s=t[i];o[s[0].toLowerCase()]=s[1]}return o})());return(o,i)=>{if(!o._headers)o._headers=n;else o._headers={...o._headers,...n};let s=i?.();if(s&&typeof s.then==="function")return s.then((a)=>{if(a instanceof Response)for(let c=0;c<r;c++){let u=t[c];if(!a.headers.has(u[0]))a.headers.set(u[0],u[1])}return a});if(s instanceof Response)for(let a=0;a<r;a++){let c=t[a];if(!s.headers.has(c[0]))s.headers.set(c[0],c[1])}return s}};import{resolve as Yc,sep as Xc}from"path";import{stat as Kx}from"fs/promises";var Bx=(e="public",t={})=>{let r=Yc(process.cwd(),e),n=r.endsWith(Xc)?r:r+Xc,o=t.maxAge??3600,i=t.etag!==!1,s=async(a,c)=>{let u=a.req.method;if(u!=="GET"&&u!=="HEAD")return c();let m=a.req.url,g=m.indexOf("/",8),I=g===-1?-1:m.indexOf("?",g),O=g===-1?"":I===-1?m.slice(g):m.slice(g,I),T;try{T=decodeURIComponent(O)}catch{return a.status(400).send("Bad Request")}if(T.includes("\x00"))return a.status(400).send("Bad Request");let C=T.replace(/^\/+/,""),Y=Yc(r,C);if(Y!==r&&!Y.startsWith(n))return a.status(403).send("Forbidden");let fe=0,Ee=0;try{let Re=await Kx(Y);if(Re.isDirectory())return c();fe=Re.size,Ee=Math.floor(Re.mtimeMs)}catch{return c()}let j=Bun.file(Y),Ae={"Cache-Control":`public, max-age=${o}`,"Accept-Ranges":"bytes"};if(i){let Re=`W/"${fe.toString(16)}-${Ee.toString(16)}"`;Ae.ETag=Re;let et=a.req.headers?.get?.("if-none-match");if(et&&et===Re)return new Response(null,{status:304,headers:Ae})}let ht=a.req.headers?.get?.("range");if(ht&&ht.startsWith("bytes=")&&fe>0){let[Re,et]=ht.slice(6).split("-"),qe=Re?Number(Re):0,tt=et?Number(et):fe-1;if(!Re&&et)qe=Math.max(0,fe-Number(et)),tt=fe-1;if(!Number.isInteger(qe)||!Number.isInteger(tt)||qe<0||tt>=fe||qe>tt)return new Response(null,{status:416,headers:{...Ae,"Content-Range":`bytes */${fe}`}});if(Ae["Content-Range"]=`bytes ${qe}-${tt}/${fe}`,Ae["Content-Length"]=String(tt-qe+1),j.type)Ae["Content-Type"]=j.type;return new Response(u==="HEAD"?null:j.slice(qe,tt+1),{status:206,headers:Ae})}if(j.type)Ae["Content-Type"]=j.type;return Ae["Content-Length"]=String(fe),new Response(u==="HEAD"?null:j,{status:200,headers:Ae})};return s.__isStatic=!0,s};import{createHash as Dx,createHmac as Gx,timingSafeEqual as ys}from"crypto";var Zc=new TextEncoder,ps=(e)=>typeof e==="string"?Buffer.from(e).toString("base64url"):Buffer.from(e).toString("base64url"),Qc=(e)=>Buffer.from(e,"base64url").toString("utf-8"),ls=new Map,qx=async(e)=>{if(ls.has(e))return ls.get(e);let t=await crypto.subtle.importKey("raw",Zc.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);return ls.set(e,t),t},vx=async(e,t)=>{let r=JSON.stringify({alg:"HS256",typ:"JWT"}),n=JSON.stringify(e),o=ps(r),i=ps(n),s=`${o}.${i}`,a=await qx(t),c=await crypto.subtle.sign("HMAC",a,Zc.encode(s)),u=ps(new Uint8Array(c));return`${s}.${u}`},Hx=(e)=>{let t=typeof e==="string"?e:e.secret;return(r,n)=>{let o=r.req.headers.get("Authorization");if(!o?.startsWith("Bearer "))return r.status(401).send("Bearer token required");let i=o.slice(7),s=i.indexOf("."),a=s===-1?-1:i.indexOf(".",s+1);if(s===-1||a===-1||i.indexOf(".",a+1)!==-1)return r.status(401).send("Malformed JWT token");let c=i.slice(0,s),u=i.slice(s+1,a),m=i.slice(a+1),g=i.slice(0,a);try{let I=Gx("sha256",t).update(g).digest(),O=Buffer.from(m,"base64url");if(O.length!==I.length||!ys(O,I))return r.status(401).send("Invalid signature");let T=JSON.parse(Qc(c));if(!T||T.alg!=="HS256")return r.status(401).send("Unsupported token algorithm");let C=JSON.parse(Qc(u)),Y=Date.now()*0.001;if(typeof C.exp==="number"&&Y>=C.exp)return r.status(401).send("Token expired");if(typeof C.nbf==="number"&&Y<C.nbf)return r.status(401).send("Token not active");if(r.set("user",C),Array.isArray(n)){if(n.length===0)return;let[fe,...Ee]=n;return fe(r,Ee)}if(typeof n==="function")return n();return}catch{return r.status(401).send("Token verification failed")}}},_i=(e)=>Dx("sha256").update(e).digest(),Vx=(e)=>{let t=_i(e.user),r=_i(e.pass);return async(n,o)=>{let i=n.req.headers.get("Authorization");if(!i?.startsWith("Basic "))return n.status(401).json({status:"error",message:"Basic Auth required"});let s=i.slice(6).trim();if(!s)return n.status(401).json({status:"error",message:"Missing credentials"});let a=Buffer.from(s,"base64").toString("utf-8"),c=a.indexOf(":");if(c===-1)return n.status(401).json({status:"error",message:"Invalid credentials"});let u=a.slice(0,c),m=a.slice(c+1),g=ys(_i(u),t),I=ys(_i(m),r);if(g&&I)return o();return n.status(401).json({status:"error",message:"Invalid credentials"})}},zx=(e)=>async(t,r)=>{let n=t.get("user");if(!n||n.role!==e)return t.status(403).json({status:"error",message:`Required role: ${e}`});return r()};Ii();var eu={make:(e)=>Bun.password.hash(e,Hn.hash),verify:(e,t)=>Bun.password.verify(e,t),needsRehash:(e)=>{let{algorithm:t,memoryCost:r,timeCost:n}=Hn.hash;if(t==="bcrypt"){if(!/^\$2[aby]\$/.test(e))return!0;let s=e.match(/^\$2[aby]\$(\d+)\$/);return!s||Number(s[1])!==n}if(!e.startsWith(`$${t}$`))return!0;let o=e.match(/(?:^|[,$])m=(\d+)(?:[,$]|$)/),i=e.match(/(?:^|[,$])t=(\d+)(?:[,$]|$)/);return!o||Number(o[1])!==r||!i||Number(i[1])!==n}};var Wx=(e,t,r)=>{let n=t;if(r?.params)for(let[a,c]of Object.entries(r.params))n=n.replace(`:${a}`,encodeURIComponent(String(c)));let o=e.endsWith("/")?e.slice(0,-1):e,i=n.startsWith("/")?n:`/${n}`,s=`${o}${i}`;if(r?.query){let a=new URLSearchParams;for(let[u,m]of Object.entries(r.query))if(m!==void 0)a.set(u,String(m));let c=a.toString();if(c)s+=`?${c}`}return s},Jx=(e,t={})=>{let r=typeof e==="object"&&e!==null&&typeof e.fetch==="function",n=r?"http://localhost":e,o=t.fetch??(r?(a,c)=>e.fetch(new Request(String(a),c)):fetch),i=t.headers??{},s=async(a,c,u)=>{let m=Wx(n,c,u),g={...i,...u?.headers??{}},I={method:a,headers:g};if(u?.body!==void 0&&a!=="GET"&&a!=="HEAD"){if(!g["Content-Type"]&&!g["content-type"])g["Content-Type"]="application/json";I.body=typeof u.body==="string"?u.body:JSON.stringify(u.body)}let O=await o(m,I),C=(O.headers.get("content-type")||"").includes("application/json")?await O.json():await O.text();if(!O.ok){let Y=Error(`HTTP ${O.status}`);throw Y.status=O.status,Y.data=C,Y}return C};return{get:(a,c)=>s("GET",a,c),post:(a,c)=>s("POST",a,c),put:(a,c)=>s("PUT",a,c),patch:(a,c)=>s("PATCH",a,c),delete:(a,c)=>s("DELETE",a,c)}};export{Jc as BareJS,Ln as BareRouter,Io as Context,eu as Hash,eu as Password,Ax as T,Ax as Type,Ax as TypeBox,Fy as Z,Fy as Zod,Hx as bareAuth,Jx as bareClient,Vx as basicAuth,Px as cors,tc as createResponseFilter,Ex as createSingleflight,vx as createToken,Sx as csrf,ds as generateOpenAPISpec,zx as hasRole,Ux as idempotency,Za as n,Za as native,Mx as rateLimit,ms as renderDocsHTML,ns as schemaValidator,Lx as securityHeaders,Bx as staticFile,Qa as t,jx as timeout,Qa as typebox,Ay as v,Ay as validate,ec as z,ec as zod};
231
+ \x1B[90m\u2699\uFE0F Pool Size: ${this.pool.length} | JIT: Enabled | Port: ${i}\x1B[0m
232
+ \x1B[36m\uD83D\uDEE1\uFE0F Hash: ${s.hash.algorithm} (${s.hash.memoryCost/1024}MB) | Iterations: ${s.hash.timeCost}\x1B[0m
233
+ `);let u=this.wsRoutes,c=this.fetch,m=u.size>0?Bun.serve({port:i,hostname:t,reusePort:r,maxRequestBodySize:o,fetch(y,R){if(y.headers.get("upgrade")?.toLowerCase()==="websocket"){let C=y.url,G=C.indexOf("/",8),A=G===-1?-1:C.indexOf("?",G),M=G===-1?"/":A===-1?C.slice(G):C.slice(G,A),V=M.length>1&&M.endsWith("/")?M.slice(0,-1):M,H=u.get(V),L;if(!H){let v=V.split("/").filter(Boolean);for(let[Y,Ne]of u){if(!Y.includes(":")&&!Y.includes("*"))continue;let P=Y.split("/").filter(Boolean),ae={},me=!0;for(let E=0;E<P.length;E++){let pe=P[E];if(pe==="*"){ae["*"]=v.slice(E).join("/");break}if(E>=v.length){me=!1;break}if(pe.startsWith(":"))ae[pe.slice(1)]=v[E];else if(pe!==v[E]){me=!1;break}}if(me&&(P.includes("*")||P.length===v.length)){H=Ne,L=ae;break}}}if(H&&R.upgrade(y,{data:L?{...H,params:L}:H}))return}return c(y,R?.requestIP?.(y)?.address)},websocket:this.wsAdapter}):Bun.serve({port:i,hostname:t,reusePort:r,maxRequestBodySize:o,fetch(y,R){return c(y,R?.requestIP?.(y)?.address)}});this.server=m;for(let y of this.startHooks)Promise.resolve(y()).catch((R)=>console.error(`[${this.name}] onStart error:`,R));let x=async()=>{let R=this.name,C=process.stdout.isTTY;{let G=C?"\uD83D\uDED1":"!",A=C?"\u2705":"v";process.stdout.write(`
234
+ \x1B[31m${G} Stopping ${R}...\x1B[0m
235
+ `),await this.stop(!1),process.stdout.write(`\x1B[32m${A} ${R} has been stopped.\x1B[0m
236
+ `)}process.exit(0)};return this.shutdownHandler=x,process.on("SIGINT",x),process.on("SIGTERM",x),m}}var Kh=(e)=>{let t=e.indexOf("/",8);if(t===-1)return"/";let r=e.indexOf("?",t);return r===-1?e.slice(t):e.slice(t,r)},Bh=(e={})=>{let t=e.format??"pretty",r=e.requestId??!0,{skip:n,onLog:o}=e;return(s,i)=>{let a=Kh(s.req.url);if(n?.(s,a))return i();let u=r?s.requestId:void 0;if(u)s.setHeader("x-request-id",u);let c={timestamp:new Date().toISOString(),method:s.req.method,path:a,...u?{requestId:u}:{},ip:s.ip};if(o)o(c);else if(t==="json")console.log(JSON.stringify(c));else{let d=u?` [${u.slice(0,8)}]`:"";console.log(`[${c.timestamp}] ${c.method} ${c.path}${d}`)}return i()}};var vh=(e={})=>{let t=e.path??"/health",{readyPath:r,checks:n}=e,o=Date.now(),s=async()=>{let i={},a=!0;if(n){let c=Object.entries(n);await Promise.all(c.map(async([d,m])=>{try{let x=await m();if(i[d]=x?"ok":"fail",!x)a=!1}catch{i[d]="fail",a=!1}}))}let u={status:a?"ok":"degraded",uptimeMs:Date.now()-o,timestamp:new Date().toISOString()};if(e.version)u.version=e.version;if(n)u.checks=i;return Response.json(u,{status:a?200:503})};return{install(i){if(i.get(t,s),r&&r!==t)i.get(r,s)}}};var Dh=(e={})=>{let t=e.origin||"*",r=e.methods||"GET,POST,PUT,PATCH,DELETE,OPTIONS",n=Array.isArray(e.allowedHeaders)?e.allowedHeaders.join(", "):e.allowedHeaders||"Content-Type, Authorization",o=Array.isArray(e.exposedHeaders)?e.exposedHeaders.join(", "):e.exposedHeaders,s=e.credentials===!0;if(typeof t==="string"){let c={"Access-Control-Allow-Origin":t,"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n};if(t!=="*")c.Vary="Origin";if(s)c["Access-Control-Allow-Credentials"]="true";let d={status:204,headers:c};return(x,y)=>{if(x.req.method==="OPTIONS")return new Response(null,d);if(x.setHeader("Access-Control-Allow-Origin",t),x.setHeader("Access-Control-Allow-Methods",r),t!=="*")x.setHeader("Vary","Origin");if(s)x.setHeader("Access-Control-Allow-Credentials","true");if(o)x.setHeader("Access-Control-Expose-Headers",o);let R=y?.();if(R&&typeof R.then==="function")return R.then((C)=>{if(C instanceof Response){if(C.headers.set("Access-Control-Allow-Origin",t),C.headers.set("Access-Control-Allow-Methods",r),t!=="*")C.headers.set("Vary","Origin");if(s)C.headers.set("Access-Control-Allow-Credentials","true");if(o)C.headers.set("Access-Control-Expose-Headers",o)}return C});if(R instanceof Response){if(R.headers.set("Access-Control-Allow-Origin",t),R.headers.set("Access-Control-Allow-Methods",r),t!=="*")R.headers.set("Vary","Origin");if(s)R.headers.set("Access-Control-Allow-Credentials","true");if(o)R.headers.set("Access-Control-Expose-Headers",o)}return R}}let i=Array.isArray(t)?new Set(t):null,a=(c)=>{if(!c)return null;if(i)return i.has(c)?c:null;return t(c)?c:null};return(c,d)=>{let m=a(c.req.headers.get("origin"));if(c.req.method==="OPTIONS"){let x={"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n,Vary:"Origin"};if(m)x["Access-Control-Allow-Origin"]=m;if(s&&m)x["Access-Control-Allow-Credentials"]="true";return new Response(null,{status:204,headers:x})}if(c.setHeader("Vary","Origin"),c.setHeader("Access-Control-Allow-Methods",r),m){if(c.setHeader("Access-Control-Allow-Origin",m),s)c.setHeader("Access-Control-Allow-Credentials","true")}if(o)c.setHeader("Access-Control-Expose-Headers",o);return d?.()}};var qh=new Set(["GET","HEAD","OPTIONS"]),Gh=(e={})=>{let t=e.ignoreMethods?new Set(e.ignoreMethods.map((i)=>i.toUpperCase())):qh,r=e.allowedOrigins?new Set(e.allowedOrigins):null,n=e.cookieName||"csrf_token",o=(e.headerName||"x-csrf-token").toLowerCase(),s=e.requireToken===!0;return(i,a)=>{let u=i.req.method.toUpperCase();if(t.has(u))return a();let c=i.req.headers.get("sec-fetch-site"),d=i.req.headers.get("origin"),m=i.req.headers.get("referer");if(c==="cross-site"){if(!r||!d||!r.has(d))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Cross-site request blocked"},{status:403})}let x=d;if(!x&&m)try{x=new URL(m).origin}catch{return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Invalid Referer header"},{status:403})}if(x){let y;try{y=new URL(i.req.url).origin}catch{y=""}if(!(x===y||r!==null&&r.has(x)))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Origin mismatch"},{status:403})}if(s){let y=i.cookies[n],R=i.req.headers.get(o);if(!y||!R||y!==R)return Response.json({status:"error",code:"CSRF_TOKEN_INVALID",message:"Invalid or missing CSRF token"},{status:403})}return a()}};var Hh=(e=1e4,t={})=>{let r=t.status??408,n=t.message??"Request Timeout",o=async(s,i)=>{let a;try{let u=new Promise((c)=>{a=setTimeout(()=>{c(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:n},{status:r}))},e)});return await Promise.race([Promise.resolve(i()),u])}finally{if(a!==void 0)clearTimeout(a)}};return o.__timeout={ms:e,status:r,message:n},o};var zh=(e={})=>{let t=e.windowMs??60000,r=e.max??100,n=e.message??"Too many requests, please try again later.",o=e.maxEntries??1e4,s=e.keyGenerator??((c)=>c.ip),i=e.store,a=(c,d,m,x,y)=>{let R=Math.max(0,r-d),C=String(Math.ceil(m/1000));if(c.setHeader("X-RateLimit-Limit",String(r)),c.setHeader("X-RateLimit-Remaining",String(R)),c.setHeader("X-RateLimit-Reset",C),d>r){let G=Math.max(1,Math.ceil((m-x)/1000));return Response.json({status:"error",code:"RATE_LIMITED",message:n},{status:429,headers:{"Retry-After":String(G),"X-RateLimit-Limit":String(r),"X-RateLimit-Remaining":"0","X-RateLimit-Reset":C}})}return y?.()};if(i)return async(c,d)=>{let m=Date.now(),x=s(c),{count:y,resetAt:R}=await i.increment(x,t);return a(c,y,R,m,d)};let u=new Map;return(c,d)=>{let m=Date.now(),x=s(c),y=u.get(x);if(!y||m>=y.resetAt){if(u.size>=o){for(let[R,C]of u){if(m>=C.resetAt)u.delete(R);if(u.size<o)break}if(u.size>=o){let R=u.keys().next().value;if(R!==void 0)u.delete(R)}}y={count:1,resetAt:m+t},u.set(x,y)}else y.count++;return a(c,y.count,y.resetAt,m,d)}};var nu=(e)=>{if(e.rawBody!==void 0)return new Response(e.rawBody,{status:e.status,headers:{"content-type":e.contentType||"application/json","X-Idempotent-Replayed":"true"}});return Response.json(e.body,{status:e.status,headers:{"X-Idempotent-Replayed":"true"}})},ou=(e,t)=>{let r=e.req.headers.get(t);if(!r)return;let n=e.req.url,o=n.indexOf("/",8),s=o===-1?-1:n.indexOf("?",o),i=o===-1?"/":s===-1?n.slice(o):n.slice(o,s);return`${e.req.method}:${i}:${r}`},Vh=(e={})=>{let t=(e.headerName||"idempotency-key").toLowerCase(),r=e.ttlMs??300000,n=e.maxKeys??1e4,o=e.store;if(o){let c={delete:(m)=>{o.release(m)}},d=async(m)=>{let x=ou(m,t);if(!x){m._idempotencyKey=void 0;return}let y=await o.get(x);if(y&&Date.now()<y.expiresAt)return m._idempotencyKey=void 0,nu(y);if(!await o.acquire(x,r))return m._idempotencyKey=void 0,Response.json({status:"error",code:"IDEMPOTENT_IN_FLIGHT",message:"Duplicate request is currently in flight"},{status:409});m._idempotencyKey=x,m._idemInFlight=c;return};return d.__idempotencyCommit=(m,x,y)=>{let R=m._idempotencyKey;if(!R)return;if(m._idempotencyKey=void 0,m._idemInFlight=void 0,o.release(R),y>=200&&y<300)if(x instanceof Response){let C=x.headers.get("content-type")||"application/json";x.clone().arrayBuffer().then((G)=>o.set(R,{status:y,rawBody:G,contentType:C,expiresAt:Date.now()+r},r)).catch(()=>{})}else o.set(R,{status:y,body:x,expiresAt:Date.now()+r},r)},d.__idempotencyRelease=(m)=>{let x=m._idempotencyKey;if(x)m._idempotencyKey=void 0,m._idemInFlight=void 0,o.release(x)},d}let s=new Map,i=new Set,a=()=>{if(s.size>=n){let c=s.keys().next().value;if(c!==void 0)s.delete(c)}},u=(c)=>{let d=ou(c,t);if(!d){c._idempotencyKey=void 0;return}let m=Date.now(),x=s.get(d);if(x){if(m<x.expiresAt)return c._idempotencyKey=void 0,nu(x);s.delete(d)}if(i.has(d))return c._idempotencyKey=void 0,Response.json({status:"error",code:"IDEMPOTENT_IN_FLIGHT",message:"Duplicate request is currently in flight"},{status:409});i.add(d),c._idempotencyKey=d,c._idemInFlight=i;return};return u.__idempotencyCommit=(c,d,m)=>{let x=c._idempotencyKey;if(!x)return;if(c._idempotencyKey=void 0,c._idemInFlight=void 0,i.delete(x),m>=200&&m<300)if(d instanceof Response){let y=d.headers.get("content-type")||"application/json";d.clone().arrayBuffer().then((R)=>{a(),s.set(x,{status:m,rawBody:R,contentType:y,expiresAt:Date.now()+r})}).catch(()=>{})}else a(),s.set(x,{status:m,body:d,expiresAt:Date.now()+r})},u.__idempotencyRelease=(c)=>{let d=c._idempotencyKey;if(d)c._idempotencyKey=void 0,c._idemInFlight=void 0,i.delete(d)},u},Jh=()=>{let e=new Map;return async(t,r)=>{let n=e.get(t);if(n)return{data:await n,shared:!0};let o=r().finally(()=>{e.delete(t)});return e.set(t,o),{data:await o,shared:!1}}};var Wh=(e,t={})=>{let r=t.prefix??"barejs:",n=typeof e.send==="function",o=(u)=>n?e.send("GET",[u]):e.get(u),s=(u)=>n?e.send("DEL",[u]):e.del(u),i=(u)=>n?e.send("INCR",[u]):e.incr(u),a=async(u,c,d)=>{if(n){await e.send("SET",[u,c,"PX",String(d)]);return}try{await e.set(u,c,"PX",d)}catch{if(await e.set(u,c),typeof e.pexpire==="function")await e.pexpire(u,d);else if(typeof e.expire==="function")await e.expire(u,Math.max(1,Math.ceil(d/1000)))}};return{async increment(u,c){let d=`${r}rl:${u}`,m=Number(await i(d));if(m===1){if(n)await e.send("PEXPIRE",[d,String(c)]);else if(typeof e.pexpire==="function")await e.pexpire(d,c);else if(typeof e.expire==="function")await e.expire(d,Math.max(1,Math.ceil(c/1000)))}let x=c;if(n){let y=Number(await e.send("PTTL",[d]));if(Number.isFinite(y)&&y>0)x=y}else if(typeof e.pttl==="function"){let y=Number(await e.pttl(d));if(Number.isFinite(y)&&y>0)x=y}else if(typeof e.ttl==="function"){let y=Number(await e.ttl(d));if(Number.isFinite(y)&&y>0)x=y*1000}return{count:m,resetAt:Date.now()+x}},async get(u){let c=await o(`${r}idem:${u}`);if(!c)return;try{let d=JSON.parse(typeof c==="string"?c:String(c));if(d.rawBodyBase64){let m=Buffer.from(d.rawBodyBase64,"base64");return{status:d.status,rawBody:m.buffer.slice(m.byteOffset,m.byteOffset+m.byteLength),contentType:d.contentType,expiresAt:d.expiresAt}}return d}catch{return}},async set(u,c,d){let m={status:c.status,expiresAt:c.expiresAt};if(c.rawBody!==void 0)m.rawBodyBase64=Buffer.from(c.rawBody).toString("base64"),m.contentType=c.contentType;else m.body=c.body;await a(`${r}idem:${u}`,JSON.stringify(m),d)},async acquire(u,c=30000){let d=`${r}idem:lock:${u}`;if(n){let x=await e.send("SET",[d,"1","PX",String(c),"NX"]);return x==="OK"||x===!0}let m=await e.set(d,"1","PX",c,"NX");return m==="OK"||m===!0||m===1},async release(u){await s(`${r}idem:lock:${u}`)},async revoke(u,c){await a(`${r}rev:${u}`,"1",c)},async isRevoked(u){let c=await o(`${r}rev:${u}`);return c!==null&&c!==void 0}}};var Xh=(e={})=>{let t=e.failureThreshold??5,r=e.resetTimeoutMs??30000,n=e.isFailure??((m,x)=>Boolean(x)||m instanceof Response&&m.status>=500),o="CLOSED",s=0,i=0,a=!1,u=(m)=>{if(o!==m){let x=o;o=m,e.onStateChange?.(x,m)}},c=async(m)=>{if(o==="OPEN"){let y=Date.now()-i;if(y<r){let R=Math.max(1,Math.ceil((r-y)/1000));return Response.json({status:"error",code:"CIRCUIT_OPEN",message:"Service temporarily unavailable"},{status:503,headers:{"Retry-After":String(R)}})}u("HALF_OPEN")}let x=!1;if(o==="HALF_OPEN"){if(a)return Response.json({status:"error",code:"CIRCUIT_OPEN",message:"Service temporarily unavailable"},{status:503,headers:{"Retry-After":"1"}});a=!0,x=!0}try{let y=await m();if(n(y)){if(s++,x||s>=t)i=Date.now(),u("OPEN")}else if(s=0,x)u("CLOSED");return y}catch(y){if(s++,x||s>=t)i=Date.now(),u("OPEN");throw y}finally{if(x)a=!1}},d=(m,x)=>c(()=>x?x():void 0);return d.__circuitBreaker=c,d};var Yh=(e={})=>{let t=[];if(e.noSniff!==!1)t.push(["X-Content-Type-Options","nosniff"]);if(e.frameOptions!==!1)t.push(["X-Frame-Options",e.frameOptions??"DENY"]);if(e.referrerPolicy!==!1)t.push(["Referrer-Policy",e.referrerPolicy??"strict-origin-when-cross-origin"]);if(e.hsts!==!1)t.push(["Strict-Transport-Security",e.hsts??"max-age=31536000; includeSubDomains"]);if(e.contentSecurityPolicy)t.push(["Content-Security-Policy",e.contentSecurityPolicy]);t.push(["X-XSS-Protection","0"]);let r=t.length,n=Object.freeze((()=>{let o={};for(let s=0;s<r;s++){let i=t[s];o[i[0].toLowerCase()]=i[1]}return o})());return(o,s)=>{if(!o._headers)o._headers=n;else o._headers={...o._headers,...n};let i=s?.();if(i&&typeof i.then==="function")return i.then((a)=>{if(a instanceof Response)for(let u=0;u<r;u++){let c=t[u];if(!a.headers.has(c[0]))a.headers.set(c[0],c[1])}return a});if(i instanceof Response)for(let a=0;a<r;a++){let u=t[a];if(!i.headers.has(u[0]))i.headers.set(u[0],u[1])}return i}};import{resolve as su,sep as Os}from"path";import{stat as Qh,realpath as iu}from"fs/promises";var Zh=(e="public",t={})=>{let r=su(process.cwd(),e),n=r.endsWith(Os)?r:r+Os,o=null,s=t.maxAge??3600,i=t.etag!==!1,a=t.cacheMetadata,u=Boolean(a),c=typeof a==="object"?a.maxEntries??1000:1000,d=typeof a==="object"?a.ttlMs??30000:30000,m=u?new Map:null,x=async(y,R)=>{let C=y.req.method;if(C!=="GET"&&C!=="HEAD")return R();let G=y.req.url,A=G.indexOf("/",8),M=A===-1?-1:G.indexOf("?",A),V=A===-1?"":M===-1?G.slice(A):G.slice(A,M),H;try{H=decodeURIComponent(V)}catch{return y.status(400).send("Bad Request")}if(H.includes("\x00"))return y.status(400).send("Bad Request");let L=H.replace(/^\/+/,""),v=su(r,L);if(v!==r&&!v.startsWith(n))return y.status(403).send("Forbidden");let Y=0,Ne=0,P="",ae=m?.get(v);if(ae&&Date.now()<ae.expiresAt)m.delete(v),m.set(v,ae),Y=ae.fileSize,Ne=ae.mtimeMs,P=ae.etag;else try{let[oe,Oe]=await Promise.all([o??=iu(r),iu(v)]),Ue=oe.endsWith(Os)?oe:oe+Os;if(Oe!==oe&&!Oe.startsWith(Ue))return y.status(403).send("Forbidden");let N=await Qh(Oe);if(N.isDirectory())return R();if(Y=N.size,Ne=Math.floor(N.mtimeMs),P=i?`W/"${Y.toString(16)}-${Ne.toString(16)}"`:"",m){if(m.size>=c){let re=m.keys().next().value;if(re!==void 0)m.delete(re)}m.set(v,{realFile:Oe,fileSize:Y,mtimeMs:Ne,etag:P,expiresAt:Date.now()+d})}}catch{return R()}let me=Bun.file(v),E={"Cache-Control":`public, max-age=${s}`,"Accept-Ranges":"bytes"};if(i){E.ETag=P;let oe=y.req.headers?.get?.("if-none-match");if(oe&&oe===P)return new Response(null,{status:304,headers:E})}let pe=y.req.headers?.get?.("range");if(pe&&pe.startsWith("bytes=")&&Y>0){let[oe,Oe]=pe.slice(6).split("-"),Ue=oe?Number(oe):0,N=Oe?Number(Oe):Y-1;if(!oe&&Oe)Ue=Math.max(0,Y-Number(Oe)),N=Y-1;if(!Number.isInteger(Ue)||!Number.isInteger(N)||Ue<0||N>=Y||Ue>N)return new Response(null,{status:416,headers:{...E,"Content-Range":`bytes */${Y}`}});if(E["Content-Range"]=`bytes ${Ue}-${N}/${Y}`,E["Content-Length"]=String(N-Ue+1),me.type)E["Content-Type"]=me.type;return new Response(C==="HEAD"?null:me.slice(Ue,N+1),{status:206,headers:E})}if(me.type)E["Content-Type"]=me.type;return E["Content-Length"]=String(Y),new Response(C==="HEAD"?null:me,{status:200,headers:E})};return x.__isStatic=!0,x};import{brotliCompressSync as ex,constants as tx}from"zlib";var rx=(e={})=>{let t=e.minSize??1024,r=e.level??6,n=e.encodings??["zstd","br","gzip"],o=typeof Bun.zstdCompressSync==="function",s=(u)=>{let c=u.toLowerCase();for(let d=0;d<n.length;d++){let m=n[d];if(m==="zstd"&&o&&c.includes("zstd"))return"zstd";if(m==="br"&&c.includes("br"))return"br";if(m==="gzip"&&c.includes("gzip"))return"gzip"}return null},i=async(u,c)=>{if(u.req.method==="HEAD")return c;let d=u.req.headers.get("accept-encoding");if(!d)return c;let m=s(d);if(!m)return c;if(!(c instanceof Response))return c;if(c.status===204||c.status===304)return c;if(c.headers.has("content-encoding"))return c;if((c.headers.get("content-type")||"").includes("text/event-stream"))return c;let y=await c.arrayBuffer();if(y.byteLength<t)return new Response(y,{status:c.status,headers:c.headers});let R=new Uint8Array(y),C;if(m==="zstd")C=Bun.zstdCompressSync(R);else if(m==="br")C=ex(R,{params:{[tx.BROTLI_PARAM_QUALITY]:Math.min(11,Math.max(1,r))}});else C=Bun.gzipSync(R,{level:r});let G=new Headers(c.headers);return G.set("Content-Encoding",m),G.set("Vary","Accept-Encoding"),G.delete("Content-Length"),new Response(C,{status:c.status,headers:G})},a=async(u,c)=>{let d=await(c?c():void 0);return i(u,d)};return a.__compress=i,a};import{createHash as nx,createHmac as au,timingSafeEqual as Ss}from"crypto";var Ri=new TextEncoder,xi=(e)=>Buffer.from(e).toString("base64url"),ws=(e)=>Buffer.from(e,"base64url").toString("utf-8"),Ii=new Map,ox=async(e)=>{if(Ii.has(e))return Ii.get(e);let t=await crypto.subtle.importKey("raw",Ri.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);return Ii.set(e,t),t},sx=async(e,t)=>{let r=JSON.stringify({alg:"HS256",typ:"JWT"}),n=JSON.stringify(e),o=xi(r),s=xi(n),i=`${o}.${s}`,a=await ox(t),u=await crypto.subtle.sign("HMAC",a,Ri.encode(i)),c=xi(new Uint8Array(u));return`${i}.${c}`},xr=new Map;function ix(e,t=3600000,r){if(r)return r.revoke(e,t);if(xr.size>=1e4){let n=Date.now();for(let[o,s]of xr)if(n>=s)xr.delete(o);if(xr.size>=1e4){let o=xr.keys().next().value;if(o!==void 0)xr.delete(o)}}xr.set(e,Date.now()+t)}function bi(e,t){if(t)return t.isRevoked(e);let r=xr.get(e);if(r===void 0)return!1;if(Date.now()>=r)return xr.delete(e),!1;return!0}var cu=new Map,uu=(e)=>e==="RS256"?{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"}:{name:"ECDSA",namedCurve:"P-256"},ax=(e)=>e==="RS256"?{name:"RSASSA-PKCS1-v1_5"}:{name:"ECDSA",hash:"SHA-256"},cx=(e)=>{let t=e.replace(/-----BEGIN [A-Z0-9 ]+-----/g,"").replace(/-----END [A-Z0-9 ]+-----/g,"").replace(/\s+/g,""),r=Buffer.from(t,"base64");return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)},ux=async(e,t)=>{if(typeof e!=="string")return e;let r=`${t}:${e}`,n=cu.get(r);if(n)return n;let o=await crypto.subtle.importKey("spki",cx(e),uu(t),!1,["verify"]);return cu.set(r,o),o},dx=(e)=>{let t=typeof e==="string"?{secret:e}:e,r=t.secret??"",{isRevoked:n,revocationStore:o,publicKey:s,jwksUri:i}=t,a=t.jwksCacheTtlMs??300000,u=t.algorithms??(s||i?["RS256","ES256"]:["HS256"]),c=(A,M,V)=>{if(A.set("user",M),Array.isArray(V)){if(V.length===0)return;let[H,...L]=V;return H(A,L)}if(typeof V==="function")return V();return},d=(A,M,V,H)=>{let L=Date.now()*0.001;if(typeof M.exp==="number"&&L>=M.exp)return A.status(401).send("Token expired");if(typeof M.nbf==="number"&&L<M.nbf)return A.status(401).send("Token not active");if(bi(V)||M?.jti&&bi(String(M.jti)))return A.status(401).send("Token revoked");if(o)return(async()=>{if(await o.isRevoked(V))return A.status(401).send("Token revoked");if(M?.jti&&await o.isRevoked(String(M.jti)))return A.status(401).send("Token revoked");if(n){if(await n(M,V))return A.status(401).send("Token revoked")}return c(A,M,H)})();if(n){let v=n(M,V);if(v&&typeof v.then==="function")return v.then((Y)=>Y?A.status(401).send("Token revoked"):c(A,M,H));if(v)return A.status(401).send("Token revoked")}return c(A,M,H)};if(!s&&!i&&u.length===1&&u[0]==="HS256"){let A=(M,V)=>{let H=M.req.headers.get("Authorization");if(!H?.startsWith("Bearer "))return M.status(401).send("Bearer token required");let L=H.slice(7),v=L.indexOf("."),Y=v===-1?-1:L.indexOf(".",v+1);if(v===-1||Y===-1||L.indexOf(".",Y+1)!==-1)return M.status(401).send("Malformed JWT token");let Ne=L.slice(0,v),P=L.slice(v+1,Y),ae=L.slice(Y+1),me=L.slice(0,Y);try{let E=au("sha256",r).update(me).digest(),pe=Buffer.from(ae,"base64url");if(pe.length!==E.length||!Ss(pe,E))return M.status(401).send("Invalid signature");let oe=JSON.parse(ws(Ne));if(!oe||oe.alg!=="HS256")return M.status(401).send("Unsupported token algorithm");let Oe=JSON.parse(ws(P));return d(M,Oe,L,V)}catch{return M.status(401).send("Token verification failed")}};if(n||o)return async(M,V)=>A(M,V);return A}let x=0,y=[],R=new Map,C=async(A=!1)=>{let M=Date.now();if(!A&&y.length>0&&M-x<a)return y;let V=await fetch(i);if(!V.ok)throw Error(`JWKS fetch failed: ${V.status}`);let H=await V.json();if(y=Array.isArray(H?.keys)?H.keys:[],x=M,A)R.clear();return y},G=async(A,M)=>{let V=`${M}:${A??"__default__"}`,H=R.get(V);if(H&&Date.now()-x<a)return H;let L=await C(!1),v=A?L.find((Ne)=>Ne.kid===A):L[0];if(!v&&A)L=await C(!0),v=L.find((Ne)=>Ne.kid===A);if(!v)return null;let Y=await crypto.subtle.importKey("jwk",v,uu(M),!1,["verify"]);return R.set(V,Y),Y};return async(A,M)=>{let V=A.req.headers.get("Authorization");if(!V?.startsWith("Bearer "))return A.status(401).send("Bearer token required");let H=V.slice(7),L=H.indexOf("."),v=L===-1?-1:H.indexOf(".",L+1);if(L===-1||v===-1||H.indexOf(".",v+1)!==-1)return A.status(401).send("Malformed JWT token");let Y=H.slice(0,L),Ne=H.slice(L+1,v),P=H.slice(v+1),ae=H.slice(0,v);try{let me=JSON.parse(ws(Y)),E=me?.alg;if(!E||!u.includes(E))return A.status(401).send("Unsupported token algorithm");if(E==="HS256"){if(!r)return A.status(401).send("Unsupported token algorithm");let oe=au("sha256",r).update(ae).digest(),Oe=Buffer.from(P,"base64url");if(Oe.length!==oe.length||!Ss(Oe,oe))return A.status(401).send("Invalid signature")}else{let oe=null;if(i)oe=await G(me?.kid,E);else if(s)oe=await ux(s,E);if(!oe)return A.status(401).send("Invalid signature");let Oe=Buffer.from(P,"base64url"),Ue=Oe.buffer.slice(Oe.byteOffset,Oe.byteOffset+Oe.byteLength);if(!await crypto.subtle.verify(ax(E),oe,Ue,Ri.encode(ae)))return A.status(401).send("Invalid signature")}let pe=JSON.parse(ws(Ne));return d(A,pe,H,M)}catch{return A.status(401).send("Token verification failed")}}},$s=(e)=>nx("sha256").update(e).digest(),fx=(e)=>{let t=$s(e.user),r=$s(e.pass);return async(n,o)=>{let s=n.req.headers.get("Authorization");if(!s?.startsWith("Basic "))return n.status(401).json({status:"error",message:"Basic Auth required"});let i=s.slice(6).trim();if(!i)return n.status(401).json({status:"error",message:"Missing credentials"});let a=Buffer.from(i,"base64").toString("utf-8"),u=a.indexOf(":");if(u===-1)return n.status(401).json({status:"error",message:"Invalid credentials"});let c=a.slice(0,u),d=a.slice(u+1),m=Ss($s(c),t),x=Ss($s(d),r);if(m&&x)return o();return n.status(401).json({status:"error",message:"Invalid credentials"})}},mx=(e)=>async(t,r)=>{let n=t.get("user");if(!n||n.role!==e)return t.status(403).json({status:"error",message:`Required role: ${e}`});return r()};Rs();var du={make:(e)=>Bun.password.hash(e,Xn.hash),verify:async(e,t)=>{if(!t||typeof t!=="string")return!1;try{return await Bun.password.verify(e,t)}catch{return!1}},needsRehash:(e)=>{let{algorithm:t,memoryCost:r,timeCost:n}=Xn.hash;if(t==="bcrypt"){if(!/^\$2[aby]\$/.test(e))return!0;let i=e.match(/^\$2[aby]\$(\d+)\$/);return!i||Number(i[1])!==n}if(!e.startsWith(`$${t}$`))return!0;let o=e.match(/(?:^|[,$])m=(\d+)(?:[,$]|$)/),s=e.match(/(?:^|[,$])t=(\d+)(?:[,$]|$)/);return!o||Number(o[1])!==r||!s||Number(s[1])!==n}};var px=(e,t,r)=>{let n=t;if(r?.params)for(let[a,u]of Object.entries(r.params))n=n.replaceAll(`:${a}`,encodeURIComponent(String(u)));let o=e.endsWith("/")?e.slice(0,-1):e,s=n.startsWith("/")?n:`/${n}`,i=`${o}${s}`;if(r?.query){let a=new URLSearchParams;for(let[c,d]of Object.entries(r.query))if(d!==void 0)a.set(c,String(d));let u=a.toString();if(u)i+=`?${u}`}return i},lx=(e,t={})=>{let r=typeof e==="object"&&e!==null&&typeof e.fetch==="function",n=r?"http://localhost":e,o=t.fetch??(r?(a,u)=>e.fetch(new Request(String(a),u)):fetch),s=t.headers??{},i=async(a,u,c)=>{let d=px(n,u,c),m={...s,...c?.headers??{}},x={method:a,headers:m};if(c?.body!==void 0&&a!=="GET"&&a!=="HEAD"){if(!m["Content-Type"]&&!m["content-type"])m["Content-Type"]="application/json";x.body=typeof c.body==="string"?c.body:JSON.stringify(c.body)}let y=await o(d,x),R=null;if(y.status!==204&&y.status!==205&&y.status!==304)if((y.headers.get("content-type")||"").includes("application/json")){let G=await y.text();R=G?JSON.parse(G):null}else R=await y.text();if(!y.ok){let C=Error(`HTTP ${y.status}`);throw C.status=y.status,C.data=R,C}return R};return{get:(a,u)=>i("GET",a,u),post:(a,u)=>i("POST",a,u),put:(a,u)=>i("PUT",a,u),patch:(a,u)=>i("PATCH",a,u),delete:(a,u)=>i("DELETE",a,u)}};export{ru as BareJS,an as BareRouter,_o as Context,du as Hash,du as Password,jh as T,jh as Type,jh as TypeBox,jy as Z,jy as Zod,dx as bareAuth,lx as bareClient,fx as basicAuth,Xh as circuitBreaker,rx as compress,Dh as cors,cc as createResponseFilter,Jh as createSingleflight,sx as createToken,Gh as csrf,gi as generateOpenAPISpec,mx as hasRole,vh as healthcheck,Vh as idempotency,bi as isTokenRevoked,Bh as logger,sc as n,sc as native,zh as rateLimit,Wh as redisStore,hi as renderDocsHTML,ix as revokeToken,ci as schemaValidator,Yh as securityHeaders,Zh as staticFile,oc as t,Hh as timeout,oc as typebox,Ey as v,Ey as validate,ic as z,ic as zod};