@absolutejs/auth 0.0.2 → 0.1.0

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,154 +1,161 @@
1
1
  // @bun
2
- var $A=Object.create;var{getPrototypeOf:QA,defineProperty:f5,getOwnPropertyNames:YA}=Object;var JA=Object.prototype.hasOwnProperty;var n4=(w,z,U)=>{U=w!=null?$A(QA(w)):{};let W=z||!w||!w.__esModule?f5(U,"default",{value:w,enumerable:!0}):U;for(let A of YA(w))if(!JA.call(W,A))f5(W,A,{get:()=>w[A],enumerable:!0});return W};var aw=(w,z)=>()=>(z||w((z={exports:{}}).exports,z),z.exports);var J6=(w,z)=>{for(var U in z)f5(w,U,{get:z[U],enumerable:!0,configurable:!0,set:(W)=>z[U]=()=>W})};var ZU=aw((XU)=>{Object.defineProperty(XU,"__esModule",{value:!0});XU.parse=Tq;XU.serialize=gq;var jq=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,Eq=/^[\u0021-\u003A\u003C-\u007E]*$/,Iq=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,xq=/^[\u0020-\u003A\u003D-\u007E]*$/,Vq=Object.prototype.toString,kq=(()=>{let w=function(){};return w.prototype=Object.create(null),w})();function Tq(w,z){let U=new kq,W=w.length;if(W<2)return U;let A=z?.decode||fq,X=0;do{let Z=w.indexOf("=",X);if(Z===-1)break;let $=w.indexOf(";",X),Q=$===-1?W:$;if(Z>Q){X=w.lastIndexOf(";",Z-1)+1;continue}let Y=WU(w,X,Z),B=AU(w,Z,Y),G=w.slice(Y,B);if(U[G]===void 0){let _=WU(w,Z+1,Q),H=AU(w,Q,_),F=A(w.slice(_,H));U[G]=F}X=Q+1}while(X<W);return U}function WU(w,z,U){do{let W=w.charCodeAt(z);if(W!==32&&W!==9)return z}while(++z<U);return U}function AU(w,z,U){while(z>U){let W=w.charCodeAt(--z);if(W!==32&&W!==9)return z+1}return U}function gq(w,z,U){let W=U?.encode||encodeURIComponent;if(!jq.test(w))throw new TypeError(`argument name is invalid: ${w}`);let A=W(z);if(!Eq.test(A))throw new TypeError(`argument val is invalid: ${z}`);let X=w+"="+A;if(!U)return X;if(U.maxAge!==void 0){if(!Number.isInteger(U.maxAge))throw new TypeError(`option maxAge is invalid: ${U.maxAge}`);X+="; Max-Age="+U.maxAge}if(U.domain){if(!Iq.test(U.domain))throw new TypeError(`option domain is invalid: ${U.domain}`);X+="; Domain="+U.domain}if(U.path){if(!xq.test(U.path))throw new TypeError(`option path is invalid: ${U.path}`);X+="; Path="+U.path}if(U.expires){if(!dq(U.expires)||!Number.isFinite(U.expires.valueOf()))throw new TypeError(`option expires is invalid: ${U.expires}`);X+="; Expires="+U.expires.toUTCString()}if(U.httpOnly)X+="; HttpOnly";if(U.secure)X+="; Secure";if(U.partitioned)X+="; Partitioned";if(U.priority)switch(typeof U.priority==="string"?U.priority.toLowerCase():void 0){case"low":X+="; Priority=Low";break;case"medium":X+="; Priority=Medium";break;case"high":X+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${U.priority}`)}if(U.sameSite)switch(typeof U.sameSite==="string"?U.sameSite.toLowerCase():U.sameSite){case!0:case"strict":X+="; SameSite=Strict";break;case"lax":X+="; SameSite=Lax";break;case"none":X+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${U.sameSite}`)}return X}function fq(w){if(w.indexOf("%")===-1)return w;try{return decodeURIComponent(w)}catch(z){return w}}function dq(w){return Vq.call(w)==="[object Date]"}});var F8=aw((JE,YU)=>{var $U=12,cq=0,jw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function iq(w){var z=w.indexOf("%");if(z===-1)return w;var U=w.length,W="",A=0,X=0,Z=z,$=$U;while(z>-1&&z<U){var Q=QU(w[z+1],4),Y=QU(w[z+2],0),B=Q|Y,G=jw[B];if($=jw[256+$+G],X=X<<6|B&jw[364+G],$===$U)W+=w.slice(A,Z),W+=X<=65535?String.fromCharCode(X):String.fromCharCode(55232+(X>>10),56320+(X&1023)),X=0,A=z+3,z=Z=w.indexOf("%",A);else if($===cq)return null;else{if(z+=3,z<U&&w.charCodeAt(z)===37)continue;return null}}return W+w.slice(A)}var vq={"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function QU(w,z){var U=vq[w];return U===void 0?255:U<<z}YU.exports=iq});var F6=(w,z)=>{let U=z?.length?{}:null;if(U)for(let W of z)U[W.part.charCodeAt(0)]=W;return{part:w,store:null,inert:U,params:null,wildcardStore:null}},ew=(w,z)=>({...w,part:z}),wz=(w)=>({name:w,store:null,inert:null});class u1{root={};history=[];static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};add(w,z,U,{ignoreError:W=!1,ignoreHistory:A=!1}={}){if(typeof z!=="string")throw new TypeError("Route path must be a string");if(z==="")z="/";else if(z[0]!=="/")z=`/${z}`;let X=z[z.length-1]==="*",Z=z.match(u1.regex.optionalParams);if(Z){let G=z.replaceAll("?","");this.add(w,G,U,{ignoreError:W});for(let _=0;_<Z.length;_++){let H=z.replace("/"+Z[_],"");this.add(w,H,U,{ignoreError:!0})}return U}if(Z)z=z.replaceAll("?","");if(this.history.find(([G,_,H])=>G===w&&_===z))return U;if(X||Z&&z.charCodeAt(z.length-1)===63)z=z.slice(0,-1);if(!A)this.history.push([w,z,U]);let $=z.split(u1.regex.static),Q=z.match(u1.regex.params)||[];if($[$.length-1]==="")$.pop();let Y;if(!this.root[w])Y=this.root[w]=F6("/");else Y=this.root[w];let B=0;for(let G=0;G<$.length;++G){let _=$[G];if(G>0){let H=Q[B++].slice(1);if(Y.params===null)Y.params=wz(H);else if(Y.params.name!==H)if(W)return U;else throw new Error(`Cannot create route "${z}" with parameter "${H}" because a route already exists with a different parameter name ("${Y.params.name}") in the same location`);let F=Y.params;if(F.inert===null){Y=F.inert=F6(_);continue}Y=F.inert}for(let H=0;;){if(H===_.length){if(H<Y.part.length){let F=ew(Y,Y.part.slice(H));Object.assign(Y,F6(_,[F]))}break}if(H===Y.part.length){if(Y.inert===null)Y.inert={};let F=Y.inert[_.charCodeAt(H)];if(F){Y=F,_=_.slice(H),H=0;continue}let R=F6(_.slice(H));Y.inert[_.charCodeAt(H)]=R,Y=R;break}if(_[H]!==Y.part[H]){let F=ew(Y,Y.part.slice(H)),R=F6(_.slice(H));Object.assign(Y,F6(Y.part.slice(0,H),[F,R])),Y=R;break}++H}}if(B<Q.length){let G=Q[B].slice(1);if(Y.params===null)Y.params=wz(G);else if(Y.params.name!==G)if(W)return U;else throw new Error(`Cannot create route "${z}" with parameter "${G}" because a route already exists with a different parameter name ("${Y.params.name}") in the same location`);if(Y.params.store===null)Y.params.store=U;return Y.params.store}if(X){if(Y.wildcardStore===null)Y.wildcardStore=U;return Y.wildcardStore}if(Y.store===null)Y.store=U;return Y.store}find(w,z){let U=this.root[w];if(!U)return null;return d5(z,z.length,U,0)}}var d5=(w,z,U,W)=>{let A=U.part,X=A.length,Z=W+X;if(X>1){if(Z>z)return null;if(X<15){for(let $=1,Q=W+1;$<X;++$,++Q)if(A.charCodeAt($)!==w.charCodeAt(Q))return null}else if(w.slice(W,Z)!==A)return null}if(Z===z){if(U.store!==null)return{store:U.store,params:{}};if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":""}};return null}if(U.inert!==null){let $=U.inert[w.charCodeAt(Z)];if($!==void 0){let Q=d5(w,z,$,Z);if(Q!==null)return Q}}if(U.params!==null){let{store:$,name:Q,inert:Y}=U.params,B=w.indexOf("/",Z);if(B!==Z){if(B===-1||B>=z){if($!==null){let G={};return G[Q]=w.substring(Z,z),{store:$,params:G}}}else if(Y!==null){let G=d5(w,z,Y,B);if(G!==null)return G.params[Q]=w.substring(Z,B),G}}}if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":w.substring(Z,z)}};return null};var H2={};J6(H2,{IsUndefined:()=>s0,IsUint8Array:()=>C1,IsSymbol:()=>v5,IsString:()=>E0,IsRegExp:()=>$4,IsObject:()=>P0,IsNumber:()=>f2,IsNull:()=>i5,IsIterator:()=>c5,IsFunction:()=>y5,IsDate:()=>B6,IsBoolean:()=>R1,IsBigInt:()=>Z4,IsAsyncIterator:()=>h5,IsArray:()=>u0,HasPropertyKey:()=>u4});function u4(w,z){return z in w}function h5(w){return P0(w)&&!u0(w)&&!C1(w)&&Symbol.asyncIterator in w}function u0(w){return Array.isArray(w)}function Z4(w){return typeof w==="bigint"}function R1(w){return typeof w==="boolean"}function B6(w){return w instanceof globalThis.Date}function y5(w){return typeof w==="function"}function c5(w){return P0(w)&&!u0(w)&&!C1(w)&&Symbol.iterator in w}function i5(w){return w===null}function f2(w){return typeof w==="number"}function P0(w){return typeof w==="object"&&w!==null}function $4(w){return w instanceof globalThis.RegExp}function E0(w){return typeof w==="string"}function v5(w){return typeof w==="symbol"}function C1(w){return w instanceof globalThis.Uint8Array}function s0(w){return w===void 0}function BA(w){return w.map((z)=>m4(z))}function MA(w){return new Date(w.getTime())}function qA(w){return new Uint8Array(w)}function HA(w){return new RegExp(w.source,w.flags)}function GA(w){let z={};for(let U of Object.getOwnPropertyNames(w))z[U]=m4(w[U]);for(let U of Object.getOwnPropertySymbols(w))z[U]=m4(w[U]);return z}function m4(w){return u0(w)?BA(w):B6(w)?MA(w):C1(w)?qA(w):$4(w)?HA(w):P0(w)?GA(w):w}function k0(w){return m4(w)}function zz(w,z){return z===void 0?k0(w):k0({...z,...w})}function t4(w){return s(w)&&Symbol.asyncIterator in w}function p4(w){return s(w)&&Symbol.iterator in w}function n5(w){return s(w)&&(Object.getPrototypeOf(w)===Object.prototype||Object.getPrototypeOf(w)===null)}function o4(w){return w instanceof Promise}function G2(w){return w instanceof Date&&Number.isFinite(w.getTime())}function Uz(w){return w instanceof globalThis.Map}function Wz(w){return w instanceof globalThis.Set}function d2(w){return ArrayBuffer.isView(w)}function j6(w){return w instanceof globalThis.Uint8Array}function v(w,z){return z in w}function s(w){return w!==null&&typeof w==="object"}function n(w){return Array.isArray(w)&&!ArrayBuffer.isView(w)}function T0(w){return w===void 0}function K1(w){return w===null}function G1(w){return typeof w==="boolean"}function d(w){return typeof w==="number"}function l4(w){return Number.isInteger(w)}function A2(w){return typeof w==="bigint"}function $0(w){return typeof w==="string"}function m1(w){return typeof w==="function"}function F1(w){return typeof w==="symbol"}function V2(w){return A2(w)||G1(w)||K1(w)||d(w)||$0(w)||F1(w)||T0(w)}var V0;(function(w){w.InstanceMode="default",w.ExactOptionalPropertyTypes=!1,w.AllowArrayObject=!1,w.AllowNaN=!1,w.AllowNullVoid=!1;function z(Z,$){return w.ExactOptionalPropertyTypes?$ in Z:Z[$]!==void 0}w.IsExactOptionalProperty=z;function U(Z){let $=s(Z);return w.AllowArrayObject?$:$&&!n(Z)}w.IsObjectLike=U;function W(Z){return U(Z)&&!(Z instanceof Date)&&!(Z instanceof Uint8Array)}w.IsRecordLike=W;function A(Z){return w.AllowNaN?d(Z):Number.isFinite(Z)}w.IsNumberLike=A;function X(Z){let $=T0(Z);return w.AllowNullVoid?$||Z===null:$}w.IsVoidLike=X})(V0||(V0={}));function LA(w){return globalThis.Object.freeze(w).map((z)=>Q4(z))}function NA(w){return w}function SA(w){return w}function _A(w){return w}function DA(w){let z={};for(let U of Object.getOwnPropertyNames(w))z[U]=Q4(w[U]);for(let U of Object.getOwnPropertySymbols(w))z[U]=Q4(w[U]);return globalThis.Object.freeze(z)}function Q4(w){return u0(w)?LA(w):B6(w)?NA(w):C1(w)?SA(w):$4(w)?_A(w):P0(w)?DA(w):w}function P(w,z){let U=z!==void 0?{...z,...w}:w;switch(V0.InstanceMode){case"freeze":return Q4(U);case"clone":return k0(U);default:return U}}class y extends Error{constructor(w){super(w)}}var F0=Symbol.for("TypeBox.Transform"),w1=Symbol.for("TypeBox.Readonly"),X2=Symbol.for("TypeBox.Optional"),h2=Symbol.for("TypeBox.Hint"),N=Symbol.for("TypeBox.Kind");function s4(w){return P0(w)&&w[w1]==="Readonly"}function y2(w){return P0(w)&&w[X2]==="Optional"}function u5(w){return Q0(w,"Any")}function j1(w){return Q0(w,"Array")}function Y4(w){return Q0(w,"AsyncIterator")}function m5(w){return Q0(w,"BigInt")}function t5(w){return Q0(w,"Boolean")}function S2(w){return Q0(w,"Computed")}function J4(w){return Q0(w,"Constructor")}function PA(w){return Q0(w,"Date")}function B4(w){return Q0(w,"Function")}function M6(w){return Q0(w,"Integer")}function m0(w){return Q0(w,"Intersect")}function M4(w){return Q0(w,"Iterator")}function Q0(w,z){return P0(w)&&N in w&&w[N]===z}function r4(w){return R1(w)||f2(w)||E0(w)}function E1(w){return Q0(w,"Literal")}function k2(w){return Q0(w,"MappedKey")}function g0(w){return Q0(w,"MappedResult")}function t1(w){return Q0(w,"Never")}function OA(w){return Q0(w,"Not")}function bA(w){return Q0(w,"Null")}function q6(w){return Q0(w,"Number")}function r0(w){return Q0(w,"Object")}function q4(w){return Q0(w,"Promise")}function p5(w){return Q0(w,"Record")}function h0(w){return Q0(w,"Ref")}function o5(w){return Q0(w,"RegExp")}function H4(w){return Q0(w,"String")}function RA(w){return Q0(w,"Symbol")}function T2(w){return Q0(w,"TemplateLiteral")}function CA(w){return Q0(w,"This")}function S0(w){return P0(w)&&F0 in w}function z1(w){return Q0(w,"Tuple")}function G4(w){return Q0(w,"Undefined")}function q0(w){return Q0(w,"Union")}function KA(w){return Q0(w,"Uint8Array")}function FA(w){return Q0(w,"Unknown")}function jA(w){return Q0(w,"Unsafe")}function EA(w){return Q0(w,"Void")}function p1(w){return P0(w)&&N in w&&E0(w[N])}function d0(w){return u5(w)||j1(w)||t5(w)||m5(w)||Y4(w)||S2(w)||J4(w)||PA(w)||B4(w)||M6(w)||m0(w)||M4(w)||E1(w)||k2(w)||g0(w)||t1(w)||OA(w)||bA(w)||q6(w)||r0(w)||q4(w)||p5(w)||h0(w)||o5(w)||H4(w)||RA(w)||T2(w)||CA(w)||z1(w)||G4(w)||q0(w)||KA(w)||FA(w)||jA(w)||EA(w)||p1(w)}var q={};J6(q,{TypeGuardUnknownTypeError:()=>Xz,IsVoid:()=>mz,IsUnsafe:()=>uz,IsUnknown:()=>nz,IsUnionLiteral:()=>hA,IsUnion:()=>r5,IsUndefined:()=>iz,IsUint8Array:()=>vz,IsTuple:()=>cz,IsTransform:()=>yz,IsThis:()=>hz,IsTemplateLiteral:()=>dz,IsSymbol:()=>fz,IsString:()=>gz,IsSchema:()=>f0,IsRegExp:()=>Tz,IsRef:()=>kz,IsRecursive:()=>dA,IsRecord:()=>Vz,IsReadonly:()=>kA,IsProperties:()=>a4,IsPromise:()=>xz,IsOptional:()=>TA,IsObject:()=>Iz,IsNumber:()=>Ez,IsNull:()=>jz,IsNot:()=>Fz,IsNever:()=>Kz,IsMappedResult:()=>Cz,IsMappedKey:()=>Rz,IsLiteralValue:()=>bz,IsLiteralString:()=>Pz,IsLiteralNumber:()=>Oz,IsLiteralBoolean:()=>fA,IsLiteral:()=>N4,IsKindOf:()=>w0,IsKind:()=>tz,IsIterator:()=>Dz,IsIntersect:()=>_z,IsInteger:()=>Sz,IsImport:()=>gA,IsFunction:()=>Nz,IsDate:()=>Lz,IsConstructor:()=>Gz,IsComputed:()=>Hz,IsBoolean:()=>qz,IsBigInt:()=>Mz,IsAsyncIterator:()=>Bz,IsArray:()=>Jz,IsAny:()=>Yz});class Xz extends y{}var IA=["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 Zz(w){try{return new RegExp(w),!0}catch{return!1}}function l5(w){if(!E0(w))return!1;for(let z=0;z<w.length;z++){let U=w.charCodeAt(z);if(U>=7&&U<=13||U===27||U===127)return!1}return!0}function $z(w){return s5(w)||f0(w)}function L4(w){return s0(w)||Z4(w)}function I0(w){return s0(w)||f2(w)}function s5(w){return s0(w)||R1(w)}function O0(w){return s0(w)||E0(w)}function xA(w){return s0(w)||E0(w)&&l5(w)&&Zz(w)}function VA(w){return s0(w)||E0(w)&&l5(w)}function Qz(w){return s0(w)||f0(w)}function kA(w){return P0(w)&&w[w1]==="Readonly"}function TA(w){return P0(w)&&w[X2]==="Optional"}function Yz(w){return w0(w,"Any")&&O0(w.$id)}function Jz(w){return w0(w,"Array")&&w.type==="array"&&O0(w.$id)&&f0(w.items)&&I0(w.minItems)&&I0(w.maxItems)&&s5(w.uniqueItems)&&Qz(w.contains)&&I0(w.minContains)&&I0(w.maxContains)}function Bz(w){return w0(w,"AsyncIterator")&&w.type==="AsyncIterator"&&O0(w.$id)&&f0(w.items)}function Mz(w){return w0(w,"BigInt")&&w.type==="bigint"&&O0(w.$id)&&L4(w.exclusiveMaximum)&&L4(w.exclusiveMinimum)&&L4(w.maximum)&&L4(w.minimum)&&L4(w.multipleOf)}function qz(w){return w0(w,"Boolean")&&w.type==="boolean"&&O0(w.$id)}function Hz(w){return w0(w,"Computed")&&E0(w.target)&&u0(w.parameters)&&w.parameters.every((z)=>f0(z))}function Gz(w){return w0(w,"Constructor")&&w.type==="Constructor"&&O0(w.$id)&&u0(w.parameters)&&w.parameters.every((z)=>f0(z))&&f0(w.returns)}function Lz(w){return w0(w,"Date")&&w.type==="Date"&&O0(w.$id)&&I0(w.exclusiveMaximumTimestamp)&&I0(w.exclusiveMinimumTimestamp)&&I0(w.maximumTimestamp)&&I0(w.minimumTimestamp)&&I0(w.multipleOfTimestamp)}function Nz(w){return w0(w,"Function")&&w.type==="Function"&&O0(w.$id)&&u0(w.parameters)&&w.parameters.every((z)=>f0(z))&&f0(w.returns)}function gA(w){return w0(w,"Import")&&u4(w,"$defs")&&P0(w.$defs)&&a4(w.$defs)&&u4(w,"$ref")&&E0(w.$ref)&&w.$ref in w.$defs}function Sz(w){return w0(w,"Integer")&&w.type==="integer"&&O0(w.$id)&&I0(w.exclusiveMaximum)&&I0(w.exclusiveMinimum)&&I0(w.maximum)&&I0(w.minimum)&&I0(w.multipleOf)}function a4(w){return P0(w)&&Object.entries(w).every(([z,U])=>l5(z)&&f0(U))}function _z(w){return w0(w,"Intersect")&&(E0(w.type)&&w.type!=="object"?!1:!0)&&u0(w.allOf)&&w.allOf.every((z)=>f0(z)&&!yz(z))&&O0(w.type)&&(s5(w.unevaluatedProperties)||Qz(w.unevaluatedProperties))&&O0(w.$id)}function Dz(w){return w0(w,"Iterator")&&w.type==="Iterator"&&O0(w.$id)&&f0(w.items)}function w0(w,z){return P0(w)&&N in w&&w[N]===z}function Pz(w){return N4(w)&&E0(w.const)}function Oz(w){return N4(w)&&f2(w.const)}function fA(w){return N4(w)&&R1(w.const)}function N4(w){return w0(w,"Literal")&&O0(w.$id)&&bz(w.const)}function bz(w){return R1(w)||f2(w)||E0(w)}function Rz(w){return w0(w,"MappedKey")&&u0(w.keys)&&w.keys.every((z)=>f2(z)||E0(z))}function Cz(w){return w0(w,"MappedResult")&&a4(w.properties)}function Kz(w){return w0(w,"Never")&&P0(w.not)&&Object.getOwnPropertyNames(w.not).length===0}function Fz(w){return w0(w,"Not")&&f0(w.not)}function jz(w){return w0(w,"Null")&&w.type==="null"&&O0(w.$id)}function Ez(w){return w0(w,"Number")&&w.type==="number"&&O0(w.$id)&&I0(w.exclusiveMaximum)&&I0(w.exclusiveMinimum)&&I0(w.maximum)&&I0(w.minimum)&&I0(w.multipleOf)}function Iz(w){return w0(w,"Object")&&w.type==="object"&&O0(w.$id)&&a4(w.properties)&&$z(w.additionalProperties)&&I0(w.minProperties)&&I0(w.maxProperties)}function xz(w){return w0(w,"Promise")&&w.type==="Promise"&&O0(w.$id)&&f0(w.item)}function Vz(w){return w0(w,"Record")&&w.type==="object"&&O0(w.$id)&&$z(w.additionalProperties)&&P0(w.patternProperties)&&((z)=>{let U=Object.getOwnPropertyNames(z.patternProperties);return U.length===1&&Zz(U[0])&&P0(z.patternProperties)&&f0(z.patternProperties[U[0]])})(w)}function dA(w){return P0(w)&&h2 in w&&w[h2]==="Recursive"}function kz(w){return w0(w,"Ref")&&O0(w.$id)&&E0(w.$ref)}function Tz(w){return w0(w,"RegExp")&&O0(w.$id)&&E0(w.source)&&E0(w.flags)&&I0(w.maxLength)&&I0(w.minLength)}function gz(w){return w0(w,"String")&&w.type==="string"&&O0(w.$id)&&I0(w.minLength)&&I0(w.maxLength)&&xA(w.pattern)&&VA(w.format)}function fz(w){return w0(w,"Symbol")&&w.type==="symbol"&&O0(w.$id)}function dz(w){return w0(w,"TemplateLiteral")&&w.type==="string"&&E0(w.pattern)&&w.pattern[0]==="^"&&w.pattern[w.pattern.length-1]==="$"}function hz(w){return w0(w,"This")&&O0(w.$id)&&E0(w.$ref)}function yz(w){return P0(w)&&F0 in w}function cz(w){return w0(w,"Tuple")&&w.type==="array"&&O0(w.$id)&&f2(w.minItems)&&f2(w.maxItems)&&w.minItems===w.maxItems&&(s0(w.items)&&s0(w.additionalItems)&&w.minItems===0||u0(w.items)&&w.items.every((z)=>f0(z)))}function iz(w){return w0(w,"Undefined")&&w.type==="undefined"&&O0(w.$id)}function hA(w){return r5(w)&&w.anyOf.every((z)=>Pz(z)||Oz(z))}function r5(w){return w0(w,"Union")&&O0(w.$id)&&P0(w)&&u0(w.anyOf)&&w.anyOf.every((z)=>f0(z))}function vz(w){return w0(w,"Uint8Array")&&w.type==="Uint8Array"&&O0(w.$id)&&I0(w.minByteLength)&&I0(w.maxByteLength)}function nz(w){return w0(w,"Unknown")&&O0(w.$id)}function uz(w){return w0(w,"Unsafe")}function mz(w){return w0(w,"Void")&&w.type==="void"&&O0(w.$id)}function tz(w){return P0(w)&&N in w&&E0(w[N])&&!IA.includes(w[N])}function f0(w){return P0(w)&&(Yz(w)||Jz(w)||qz(w)||Mz(w)||Bz(w)||Hz(w)||Gz(w)||Lz(w)||Nz(w)||Sz(w)||_z(w)||Dz(w)||N4(w)||Rz(w)||Cz(w)||Kz(w)||Fz(w)||jz(w)||Ez(w)||Iz(w)||xz(w)||Vz(w)||kz(w)||Tz(w)||gz(w)||fz(w)||dz(w)||hz(w)||cz(w)||iz(w)||r5(w)||vz(w)||nz(w)||uz(w)||mz(w)||tz(w))}var pz="(true|false)",e4="(0|[1-9][0-9]*)",oz="(.*)";var I1="^(0|[1-9][0-9]*)$",x1="^(.*)$",lz="^(?!.*)$";var b0={};J6(b0,{Set:()=>nA,Has:()=>vA,Get:()=>uA,Entries:()=>yA,Delete:()=>iA,Clear:()=>cA});var E6=new Map;function yA(){return new Map(E6)}function cA(){return E6.clear()}function iA(w){return E6.delete(w)}function vA(w){return E6.has(w)}function nA(w,z){E6.set(w,z)}function uA(w){return E6.get(w)}var y0={};J6(y0,{Set:()=>lA,Has:()=>oA,Get:()=>sA,Entries:()=>mA,Delete:()=>pA,Clear:()=>tA});var I6=new Map;function mA(){return new Map(I6)}function tA(){return I6.clear()}function pA(w){return I6.delete(w)}function oA(w){return I6.has(w)}function lA(w,z){I6.set(w,z)}function sA(w){return I6.get(w)}function sz(w,z){return w.includes(z)}function rz(w){return[...new Set(w)]}function rA(w,z){return w.filter((U)=>z.includes(U))}function aA(w,z){return w.reduce((U,W)=>{return rA(U,W)},z)}function az(w){return w.length===1?w[0]:w.length>1?aA(w.slice(1),w[0]):[]}function ez(w){let z=[];for(let U of w)z.push(...U);return z}function o1(w){return P({[N]:"Any"},w)}function x6(w,z){return P({[N]:"Array",type:"array",items:w},z)}function V6(w,z){return P({[N]:"AsyncIterator",type:"AsyncIterator",items:w},z)}function N0(w,z,U){return P({[N]:"Computed",target:w,parameters:z},U)}function eA(w,z){let{[z]:U,...W}=w;return W}function c0(w,z){return z.reduce((U,W)=>eA(U,W),w)}function H0(w){return P({[N]:"Never",not:{}},w)}function Y0(w){return P({[N]:"MappedResult",properties:w})}function k6(w,z,U){return P({[N]:"Constructor",type:"Constructor",parameters:w,returns:z},U)}function L1(w,z,U){return P({[N]:"Function",type:"Function",parameters:w,returns:z},U)}function S4(w,z){return P({[N]:"Union",anyOf:w},z)}function wX(w){return w.some((z)=>y2(z))}function w9(w){return w.map((z)=>y2(z)?zX(z):z)}function zX(w){return c0(w,[X2])}function UX(w,z){return wX(w)?_2(S4(w9(w),z)):S4(w9(w),z)}function N1(w,z){return w.length===1?P(w[0],z):w.length===0?H0(z):UX(w,z)}function G0(w,z){return w.length===0?H0(z):w.length===1?P(w[0],z):S4(w,z)}class a5 extends y{}function WX(w){return w.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function e5(w,z,U){return w[z]===U&&w.charCodeAt(z-1)!==92}function V1(w,z){return e5(w,z,"(")}function _4(w,z){return e5(w,z,")")}function z9(w,z){return e5(w,z,"|")}function AX(w){if(!(V1(w,0)&&_4(w,w.length-1)))return!1;let z=0;for(let U=0;U<w.length;U++){if(V1(w,U))z+=1;if(_4(w,U))z-=1;if(z===0&&U!==w.length-1)return!1}return!0}function XX(w){return w.slice(1,w.length-1)}function ZX(w){let z=0;for(let U=0;U<w.length;U++){if(V1(w,U))z+=1;if(_4(w,U))z-=1;if(z9(w,U)&&z===0)return!0}return!1}function $X(w){for(let z=0;z<w.length;z++)if(V1(w,z))return!0;return!1}function QX(w){let[z,U]=[0,0],W=[];for(let X=0;X<w.length;X++){if(V1(w,X))z+=1;if(_4(w,X))z-=1;if(z9(w,X)&&z===0){let Z=w.slice(U,X);if(Z.length>0)W.push(T6(Z));U=X+1}}let A=w.slice(U);if(A.length>0)W.push(T6(A));if(W.length===0)return{type:"const",const:""};if(W.length===1)return W[0];return{type:"or",expr:W}}function YX(w){function z(A,X){if(!V1(A,X))throw new a5("TemplateLiteralParser: Index must point to open parens");let Z=0;for(let $=X;$<A.length;$++){if(V1(A,$))Z+=1;if(_4(A,$))Z-=1;if(Z===0)return[X,$]}throw new a5("TemplateLiteralParser: Unclosed group parens in expression")}function U(A,X){for(let Z=X;Z<A.length;Z++)if(V1(A,Z))return[X,Z];return[X,A.length]}let W=[];for(let A=0;A<w.length;A++)if(V1(w,A)){let[X,Z]=z(w,A),$=w.slice(X,Z+1);W.push(T6($)),A=Z}else{let[X,Z]=U(w,A),$=w.slice(X,Z);if($.length>0)W.push(T6($));A=Z-1}return W.length===0?{type:"const",const:""}:W.length===1?W[0]:{type:"and",expr:W}}function T6(w){return AX(w)?T6(XX(w)):ZX(w)?QX(w):$X(w)?YX(w):{type:"const",const:WX(w)}}function g6(w){return T6(w.slice(1,w.length-1))}class U9 extends y{}function JX(w){return w.type==="or"&&w.expr.length===2&&w.expr[0].type==="const"&&w.expr[0].const==="0"&&w.expr[1].type==="const"&&w.expr[1].const==="[1-9][0-9]*"}function BX(w){return w.type==="or"&&w.expr.length===2&&w.expr[0].type==="const"&&w.expr[0].const==="true"&&w.expr[1].type==="const"&&w.expr[1].const==="false"}function MX(w){return w.type==="const"&&w.const===".*"}function H6(w){return JX(w)||MX(w)?!1:BX(w)?!0:w.type==="and"?w.expr.every((z)=>H6(z)):w.type==="or"?w.expr.every((z)=>H6(z)):w.type==="const"?!0:(()=>{throw new U9("Unknown expression type")})()}function w8(w){let z=g6(w.pattern);return H6(z)}class W9 extends y{}function*A9(w){if(w.length===1)return yield*w[0];for(let z of w[0])for(let U of A9(w.slice(1)))yield`${z}${U}`}function*qX(w){return yield*A9(w.expr.map((z)=>[...D4(z)]))}function*HX(w){for(let z of w.expr)yield*D4(z)}function*GX(w){return yield w.const}function*D4(w){return w.type==="and"?yield*qX(w):w.type==="or"?yield*HX(w):w.type==="const"?yield*GX(w):(()=>{throw new W9("Unknown expression")})()}function f6(w){let z=g6(w.pattern);return H6(z)?[...D4(z)]:[]}function X0(w,z){return P({[N]:"Literal",const:w,type:typeof w},z)}function z8(w){return P({[N]:"Boolean",type:"boolean"},w)}function d6(w){return P({[N]:"BigInt",type:"bigint"},w)}function S1(w){return P({[N]:"Number",type:"number"},w)}function c2(w){return P({[N]:"String",type:"string"},w)}function*LX(w){let z=w.trim().replace(/"|'/g,"");return z==="boolean"?yield z8():z==="number"?yield S1():z==="bigint"?yield d6():z==="string"?yield c2():yield(()=>{let U=z.split("|").map((W)=>X0(W.trim()));return U.length===0?H0():U.length===1?U[0]:N1(U)})()}function*NX(w){if(w[1]!=="{"){let z=X0("$"),U=ww(w.slice(1));return yield*[z,...U]}for(let z=2;z<w.length;z++)if(w[z]==="}"){let U=LX(w.slice(2,z)),W=ww(w.slice(z+1));return yield*[...U,...W]}yield X0(w)}function*ww(w){for(let z=0;z<w.length;z++)if(w[z]==="$"){let U=X0(w.slice(0,z)),W=NX(w.slice(z));return yield*[U,...W]}yield X0(w)}function X9(w){return[...ww(w)]}class Z9 extends y{}function SX(w){return w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $9(w,z){return T2(w)?w.pattern.slice(1,w.pattern.length-1):q0(w)?`(${w.anyOf.map((U)=>$9(U,z)).join("|")})`:q6(w)?`${z}${e4}`:M6(w)?`${z}${e4}`:m5(w)?`${z}${e4}`:H4(w)?`${z}${oz}`:E1(w)?`${z}${SX(w.const.toString())}`:t5(w)?`${z}${pz}`:(()=>{throw new Z9(`Unexpected Kind '${w[N]}'`)})()}function zw(w){return`^${w.map((z)=>$9(z,"")).join("")}$`}function G6(w){let U=f6(w).map((W)=>X0(W));return N1(U)}function U8(w,z){let U=E0(w)?zw(X9(w)):zw(w);return P({[N]:"TemplateLiteral",type:"string",pattern:U},z)}function _X(w){return f6(w).map((U)=>U.toString())}function DX(w){let z=[];for(let U of w)z.push(...D2(U));return z}function PX(w){return[w.toString()]}function D2(w){return[...new Set(T2(w)?_X(w):q0(w)?DX(w.anyOf):E1(w)?PX(w.const):q6(w)?["[number]"]:M6(w)?["[number]"]:[])]}function OX(w,z,U){let W={};for(let A of Object.getOwnPropertyNames(z))W[A]=l1(w,D2(z[A]),U);return W}function bX(w,z,U){return OX(w,z.properties,U)}function Q9(w,z,U){let W=bX(w,z,U);return Y0(W)}function J9(w,z){return w.map((U)=>B9(U,z))}function RX(w){return w.filter((z)=>!t1(z))}function CX(w,z){return W8(RX(J9(w,z)))}function KX(w){return w.some((z)=>t1(z))?[]:w}function FX(w,z){return N1(KX(J9(w,z)))}function jX(w,z){return z in w?w[z]:z==="[number]"?N1(w):H0()}function EX(w,z){return z==="[number]"?w:H0()}function IX(w,z){return z in w?w[z]:H0()}function B9(w,z){return m0(w)?CX(w.allOf,z):q0(w)?FX(w.anyOf,z):z1(w)?jX(w.items??[],z):j1(w)?EX(w.items,z):r0(w)?IX(w.properties,z):H0()}function P4(w,z){return z.map((U)=>B9(w,U))}function Y9(w,z){return N1(P4(w,z))}function l1(w,z,U){if(h0(w)||h0(z)){if(!d0(w)||!d0(z))throw new y("Index types using Ref parameters require both Type and Key to be of TSchema");return N0("Index",[w,z])}if(g0(z))return Q9(w,z,U);if(k2(z))return M9(w,z,U);return P(d0(z)?Y9(w,D2(z)):Y9(w,z),U)}function xX(w,z,U){return{[z]:l1(w,[z],k0(U))}}function VX(w,z,U){return z.reduce((W,A)=>{return{...W,...xX(w,A,U)}},{})}function kX(w,z,U){return VX(w,z.keys,U)}function M9(w,z,U){let W=kX(w,z,U);return Y0(W)}function h6(w,z){return P({[N]:"Iterator",type:"Iterator",items:w},z)}function TX(w){let z=[];for(let U in w)if(!y2(w[U]))z.push(U);return z}function gX(w,z){let U=TX(w),W=U.length>0?{[N]:"Object",type:"object",properties:w,required:U}:{[N]:"Object",type:"object",properties:w};return P(W,z)}var _0=gX;function A8(w,z){return P({[N]:"Promise",type:"Promise",item:w},z)}function fX(w){return P(c0(w,[w1]))}function dX(w){return P({...w,[w1]:"Readonly"})}function hX(w,z){return z===!1?fX(w):dX(w)}function i2(w,z){let U=z??!0;return g0(w)?q9(w,U):hX(w,U)}function yX(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=i2(w[W],z);return U}function cX(w,z){return yX(w.properties,z)}function q9(w,z){let U=cX(w,z);return Y0(U)}function v2(w,z){return P(w.length>0?{[N]:"Tuple",type:"array",items:w,additionalItems:!1,minItems:w.length,maxItems:w.length}:{[N]:"Tuple",type:"array",minItems:w.length,maxItems:w.length},z)}function H9(w,z){return w in z?n2(w,z[w]):Y0(z)}function iX(w){return{[w]:X0(w)}}function vX(w){let z={};for(let U of w)z[U]=X0(U);return z}function nX(w,z){return sz(z,w)?iX(w):vX(z)}function uX(w,z){let U=nX(w,z);return H9(w,U)}function O4(w,z){return z.map((U)=>n2(w,U))}function mX(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=n2(w,z[W]);return U}function n2(w,z){let U={...z};return y2(z)?_2(n2(w,c0(z,[X2]))):s4(z)?i2(n2(w,c0(z,[w1]))):g0(z)?H9(w,z.properties):k2(z)?uX(w,z.keys):J4(z)?k6(O4(w,z.parameters),n2(w,z.returns),U):B4(z)?L1(O4(w,z.parameters),n2(w,z.returns),U):Y4(z)?V6(n2(w,z.items),U):M4(z)?h6(n2(w,z.items),U):m0(z)?Z2(O4(w,z.allOf),U):q0(z)?G0(O4(w,z.anyOf),U):z1(z)?v2(O4(w,z.items??[]),U):r0(z)?_0(mX(w,z.properties),U):j1(z)?x6(n2(w,z.items),U):q4(z)?A8(n2(w,z.item),U):z}function tX(w,z){let U={};for(let W of w)U[W]=n2(W,z);return U}function G9(w,z,U){let W=d0(w)?D2(w):w,A=z({[N]:"MappedKey",keys:W}),X=tX(W,A);return _0(X,U)}function pX(w){return P(c0(w,[X2]))}function oX(w){return P({...w,[X2]:"Optional"})}function lX(w,z){return z===!1?pX(w):oX(w)}function _2(w,z){let U=z??!0;return g0(w)?L9(w,U):lX(w,U)}function sX(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=_2(w[W],z);return U}function rX(w,z){return sX(w.properties,z)}function L9(w,z){let U=rX(w,z);return Y0(U)}function b4(w,z={}){let U=w.every((A)=>r0(A)),W=d0(z.unevaluatedProperties)?{unevaluatedProperties:z.unevaluatedProperties}:{};return P(z.unevaluatedProperties===!1||d0(z.unevaluatedProperties)||U?{...W,[N]:"Intersect",type:"object",allOf:w}:{...W,[N]:"Intersect",allOf:w},z)}function aX(w){return w.every((z)=>y2(z))}function eX(w){return c0(w,[X2])}function N9(w){return w.map((z)=>y2(z)?eX(z):z)}function wZ(w,z){return aX(w)?_2(b4(N9(w),z)):b4(N9(w),z)}function W8(w,z={}){if(w.length===1)return P(w[0],z);if(w.length===0)return H0(z);if(w.some((U)=>S0(U)))throw new Error("Cannot intersect transform types");return wZ(w,z)}function Z2(w,z){if(w.length===1)return P(w[0],z);if(w.length===0)return H0(z);if(w.some((U)=>S0(U)))throw new Error("Cannot intersect transform types");return b4(w,z)}function P2(...w){let[z,U]=typeof w[0]==="string"?[w[0],w[1]]:[w[0].$id,w[1]];if(typeof z!=="string")throw new y("Ref: $ref must be a string");return P({[N]:"Ref",$ref:z},U)}function zZ(w,z){return N0("Awaited",[N0(w,z)])}function UZ(w){return N0("Awaited",[P2(w)])}function WZ(w){return Z2(S9(w))}function AZ(w){return G0(S9(w))}function XZ(w){return y6(w)}function S9(w){return w.map((z)=>y6(z))}function y6(w,z){return P(S2(w)?zZ(w.target,w.parameters):m0(w)?WZ(w.allOf):q0(w)?AZ(w.anyOf):q4(w)?XZ(w.item):h0(w)?UZ(w.$ref):w,z)}function _9(w){let z=[];for(let U of w)z.push(O2(U));return z}function ZZ(w){let z=_9(w);return ez(z)}function $Z(w){let z=_9(w);return az(z)}function QZ(w){return w.map((z,U)=>U.toString())}function YZ(w){return["[number]"]}function JZ(w){return globalThis.Object.getOwnPropertyNames(w)}function BZ(w){if(!Uw)return[];return globalThis.Object.getOwnPropertyNames(w).map((U)=>{return U[0]==="^"&&U[U.length-1]==="$"?U.slice(1,U.length-1):U})}function O2(w){return m0(w)?ZZ(w.allOf):q0(w)?$Z(w.anyOf):z1(w)?QZ(w.items??[]):j1(w)?YZ(w.items):r0(w)?JZ(w.properties):p5(w)?BZ(w.patternProperties):[]}var Uw=!1;function k1(w){Uw=!0;let z=O2(w);return Uw=!1,`^(${z.map((W)=>`(${W})`).join("|")})$`}function MZ(w,z){return N0("KeyOf",[N0(w,z)])}function qZ(w){return N0("KeyOf",[P2(w)])}function HZ(w,z){let U=O2(w),W=GZ(U),A=N1(W);return P(A,z)}function GZ(w){return w.map((z)=>z==="[number]"?S1():X0(z))}function c6(w,z){return S2(w)?MZ(w.target,w.parameters):h0(w)?qZ(w.$ref):g0(w)?D9(w,z):HZ(w,z)}function LZ(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=c6(w[W],k0(z));return U}function NZ(w,z){return LZ(w.properties,z)}function D9(w,z){let U=NZ(w,z);return Y0(U)}function X8(w){let z=O2(w),U=P4(w,z);return z.map((W,A)=>[z[A],U[A]])}function SZ(w){let z=[];for(let U of w)z.push(...O2(U));return rz(z)}function _Z(w){return w.filter((z)=>!t1(z))}function DZ(w,z){let U=[];for(let W of w)U.push(...P4(W,[z]));return _Z(U)}function PZ(w,z){let U={};for(let W of z)U[W]=W8(DZ(w,W));return U}function P9(w,z){let U=SZ(w),W=PZ(w,U);return _0(W,z)}function Z8(w){return P({[N]:"Date",type:"Date"},w)}function $8(w){return P({[N]:"Null",type:"null"},w)}function Q8(w){return P({[N]:"Symbol",type:"symbol"},w)}function Y8(w){return P({[N]:"Undefined",type:"undefined"},w)}function J8(w){return P({[N]:"Uint8Array",type:"Uint8Array"},w)}function T1(w){return P({[N]:"Unknown"},w)}function OZ(w){return w.map((z)=>Ww(z,!1))}function bZ(w){let z={};for(let U of globalThis.Object.getOwnPropertyNames(w))z[U]=i2(Ww(w[U],!1));return z}function B8(w,z){return z===!0?w:i2(w)}function Ww(w,z){return h5(w)?B8(o1(),z):c5(w)?B8(o1(),z):u0(w)?i2(v2(OZ(w))):C1(w)?J8():B6(w)?Z8():P0(w)?B8(_0(bZ(w)),z):y5(w)?B8(L1([],T1()),z):s0(w)?Y8():i5(w)?$8():v5(w)?Q8():Z4(w)?d6():f2(w)?X0(w):R1(w)?X0(w):E0(w)?X0(w):_0({})}function O9(w,z){return P(Ww(w,!0),z)}function b9(w,z){return v2(w.parameters,z)}function R9(w,z){if(s0(w))throw new Error("Enum undefined or empty");let U=globalThis.Object.getOwnPropertyNames(w).filter((X)=>isNaN(X)).map((X)=>w[X]),A=[...new Set(U)].map((X)=>X0(X));return G0(A,{...z,[h2]:"Enum"})}class E9 extends y{}var D;(function(w){w[w.Union=0]="Union",w[w.True=1]="True",w[w.False=2]="False"})(D||(D={}));function u2(w){return w===D.False?w:D.True}function i6(w){throw new E9(w)}function t0(w){return q.IsNever(w)||q.IsIntersect(w)||q.IsUnion(w)||q.IsUnknown(w)||q.IsAny(w)}function p0(w,z){return q.IsNever(z)?V9(w,z):q.IsIntersect(z)?M8(w,z):q.IsUnion(z)?Qw(w,z):q.IsUnknown(z)?f9(w,z):q.IsAny(z)?$w(w,z):i6("StructuralRight")}function $w(w,z){return D.True}function RZ(w,z){return q.IsIntersect(z)?M8(w,z):q.IsUnion(z)&&z.anyOf.some((U)=>q.IsAny(U)||q.IsUnknown(U))?D.True:q.IsUnion(z)?D.Union:q.IsUnknown(z)?D.True:q.IsAny(z)?D.True:D.Union}function CZ(w,z){return q.IsUnknown(w)?D.False:q.IsAny(w)?D.Union:q.IsNever(w)?D.True:D.False}function KZ(w,z){return q.IsObject(z)&&q8(z)?D.True:t0(z)?p0(w,z):!q.IsArray(z)?D.False:u2(R0(w.items,z.items))}function FZ(w,z){return t0(z)?p0(w,z):!q.IsAsyncIterator(z)?D.False:u2(R0(w.items,z.items))}function jZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsBigInt(z)?D.True:D.False}function I9(w,z){return q.IsLiteralBoolean(w)?D.True:q.IsBoolean(w)?D.True:D.False}function EZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsBoolean(z)?D.True:D.False}function IZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):!q.IsConstructor(z)?D.False:w.parameters.length>z.parameters.length?D.False:!w.parameters.every((U,W)=>u2(R0(z.parameters[W],U))===D.True)?D.False:u2(R0(w.returns,z.returns))}function xZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsDate(z)?D.True:D.False}function VZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):!q.IsFunction(z)?D.False:w.parameters.length>z.parameters.length?D.False:!w.parameters.every((U,W)=>u2(R0(z.parameters[W],U))===D.True)?D.False:u2(R0(w.returns,z.returns))}function x9(w,z){return q.IsLiteral(w)&&H2.IsNumber(w.const)?D.True:q.IsNumber(w)||q.IsInteger(w)?D.True:D.False}function kZ(w,z){return q.IsInteger(z)||q.IsNumber(z)?D.True:t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):D.False}function M8(w,z){return z.allOf.every((U)=>R0(w,U)===D.True)?D.True:D.False}function TZ(w,z){return w.allOf.some((U)=>R0(U,z)===D.True)?D.True:D.False}function gZ(w,z){return t0(z)?p0(w,z):!q.IsIterator(z)?D.False:u2(R0(w.items,z.items))}function fZ(w,z){return q.IsLiteral(z)&&z.const===w.const?D.True:t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsString(z)?g9(w,z):q.IsNumber(z)?k9(w,z):q.IsInteger(z)?x9(w,z):q.IsBoolean(z)?I9(w,z):D.False}function V9(w,z){return D.False}function dZ(w,z){return D.True}function C9(w){let[z,U]=[w,0];while(!0){if(!q.IsNot(z))break;z=z.not,U+=1}return U%2===0?z:T1()}function hZ(w,z){return q.IsNot(w)?R0(C9(w),z):q.IsNot(z)?R0(w,C9(z)):i6("Invalid fallthrough for Not")}function yZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsNull(z)?D.True:D.False}function k9(w,z){return q.IsLiteralNumber(w)?D.True:q.IsNumber(w)||q.IsInteger(w)?D.True:D.False}function cZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsInteger(z)||q.IsNumber(z)?D.True:D.False}function b2(w,z){return Object.getOwnPropertyNames(w.properties).length===z}function K9(w){return q8(w)}function F9(w){return b2(w,0)||b2(w,1)&&"description"in w.properties&&q.IsUnion(w.properties.description)&&w.properties.description.anyOf.length===2&&(q.IsString(w.properties.description.anyOf[0])&&q.IsUndefined(w.properties.description.anyOf[1])||q.IsString(w.properties.description.anyOf[1])&&q.IsUndefined(w.properties.description.anyOf[0]))}function Aw(w){return b2(w,0)}function j9(w){return b2(w,0)}function iZ(w){return b2(w,0)}function vZ(w){return b2(w,0)}function nZ(w){return q8(w)}function uZ(w){let z=S1();return b2(w,0)||b2(w,1)&&"length"in w.properties&&u2(R0(w.properties.length,z))===D.True}function mZ(w){return b2(w,0)}function q8(w){let z=S1();return b2(w,0)||b2(w,1)&&"length"in w.properties&&u2(R0(w.properties.length,z))===D.True}function tZ(w){let z=L1([o1()],o1());return b2(w,0)||b2(w,1)&&"then"in w.properties&&u2(R0(w.properties.then,z))===D.True}function T9(w,z){return R0(w,z)===D.False?D.False:q.IsOptional(w)&&!q.IsOptional(z)?D.False:D.True}function $2(w,z){return q.IsUnknown(w)?D.False:q.IsAny(w)?D.Union:q.IsNever(w)||q.IsLiteralString(w)&&K9(z)||q.IsLiteralNumber(w)&&Aw(z)||q.IsLiteralBoolean(w)&&j9(z)||q.IsSymbol(w)&&F9(z)||q.IsBigInt(w)&&iZ(z)||q.IsString(w)&&K9(z)||q.IsSymbol(w)&&F9(z)||q.IsNumber(w)&&Aw(z)||q.IsInteger(w)&&Aw(z)||q.IsBoolean(w)&&j9(z)||q.IsUint8Array(w)&&nZ(z)||q.IsDate(w)&&vZ(z)||q.IsConstructor(w)&&mZ(z)||q.IsFunction(w)&&uZ(z)?D.True:q.IsRecord(w)&&q.IsString(Xw(w))?(()=>{return z[h2]==="Record"?D.True:D.False})():q.IsRecord(w)&&q.IsNumber(Xw(w))?(()=>{return b2(z,0)?D.True:D.False})():D.False}function pZ(w,z){return t0(z)?p0(w,z):q.IsRecord(z)?m2(w,z):!q.IsObject(z)?D.False:(()=>{for(let U of Object.getOwnPropertyNames(z.properties)){if(!(U in w.properties)&&!q.IsOptional(z.properties[U]))return D.False;if(q.IsOptional(z.properties[U]))return D.True;if(T9(w.properties[U],z.properties[U])===D.False)return D.False}return D.True})()}function oZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)&&tZ(z)?D.True:!q.IsPromise(z)?D.False:u2(R0(w.item,z.item))}function Xw(w){return I1 in w.patternProperties?S1():(x1 in w.patternProperties)?c2():i6("Unknown record key pattern")}function Zw(w){return I1 in w.patternProperties?w.patternProperties[I1]:(x1 in w.patternProperties)?w.patternProperties[x1]:i6("Unable to get record value schema")}function m2(w,z){let[U,W]=[Xw(z),Zw(z)];return q.IsLiteralString(w)&&q.IsNumber(U)&&u2(R0(w,W))===D.True?D.True:q.IsUint8Array(w)&&q.IsNumber(U)?R0(w,W):q.IsString(w)&&q.IsNumber(U)?R0(w,W):q.IsArray(w)&&q.IsNumber(U)?R0(w,W):q.IsObject(w)?(()=>{for(let A of Object.getOwnPropertyNames(w.properties))if(T9(W,w.properties[A])===D.False)return D.False;return D.True})():D.False}function lZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):!q.IsRecord(z)?D.False:R0(Zw(w),Zw(z))}function sZ(w,z){let U=q.IsRegExp(w)?c2():w,W=q.IsRegExp(z)?c2():z;return R0(U,W)}function g9(w,z){return q.IsLiteral(w)&&H2.IsString(w.const)?D.True:q.IsString(w)?D.True:D.False}function rZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsString(z)?D.True:D.False}function aZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsSymbol(z)?D.True:D.False}function eZ(w,z){return q.IsTemplateLiteral(w)?R0(G6(w),z):q.IsTemplateLiteral(z)?R0(w,G6(z)):i6("Invalid fallthrough for TemplateLiteral")}function w$(w,z){return q.IsArray(z)&&w.items!==void 0&&w.items.every((U)=>R0(U,z.items)===D.True)}function z$(w,z){return q.IsNever(w)?D.True:q.IsUnknown(w)?D.False:q.IsAny(w)?D.Union:D.False}function U$(w,z){return t0(z)?p0(w,z):q.IsObject(z)&&q8(z)?D.True:q.IsArray(z)&&w$(w,z)?D.True:!q.IsTuple(z)?D.False:H2.IsUndefined(w.items)&&!H2.IsUndefined(z.items)||!H2.IsUndefined(w.items)&&H2.IsUndefined(z.items)?D.False:H2.IsUndefined(w.items)&&!H2.IsUndefined(z.items)?D.True:w.items.every((U,W)=>R0(U,z.items[W])===D.True)?D.True:D.False}function W$(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsUint8Array(z)?D.True:D.False}function A$(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsVoid(z)?$$(w,z):q.IsUndefined(z)?D.True:D.False}function Qw(w,z){return z.anyOf.some((U)=>R0(w,U)===D.True)?D.True:D.False}function X$(w,z){return w.anyOf.every((U)=>R0(U,z)===D.True)?D.True:D.False}function f9(w,z){return D.True}function Z$(w,z){return q.IsNever(z)?V9(w,z):q.IsIntersect(z)?M8(w,z):q.IsUnion(z)?Qw(w,z):q.IsAny(z)?$w(w,z):q.IsString(z)?g9(w,z):q.IsNumber(z)?k9(w,z):q.IsInteger(z)?x9(w,z):q.IsBoolean(z)?I9(w,z):q.IsArray(z)?CZ(w,z):q.IsTuple(z)?z$(w,z):q.IsObject(z)?$2(w,z):q.IsUnknown(z)?D.True:D.False}function $$(w,z){return q.IsUndefined(w)?D.True:q.IsUndefined(w)?D.True:D.False}function Q$(w,z){return q.IsIntersect(z)?M8(w,z):q.IsUnion(z)?Qw(w,z):q.IsUnknown(z)?f9(w,z):q.IsAny(z)?$w(w,z):q.IsObject(z)?$2(w,z):q.IsVoid(z)?D.True:D.False}function R0(w,z){return q.IsTemplateLiteral(w)||q.IsTemplateLiteral(z)?eZ(w,z):q.IsRegExp(w)||q.IsRegExp(z)?sZ(w,z):q.IsNot(w)||q.IsNot(z)?hZ(w,z):q.IsAny(w)?RZ(w,z):q.IsArray(w)?KZ(w,z):q.IsBigInt(w)?jZ(w,z):q.IsBoolean(w)?EZ(w,z):q.IsAsyncIterator(w)?FZ(w,z):q.IsConstructor(w)?IZ(w,z):q.IsDate(w)?xZ(w,z):q.IsFunction(w)?VZ(w,z):q.IsInteger(w)?kZ(w,z):q.IsIntersect(w)?TZ(w,z):q.IsIterator(w)?gZ(w,z):q.IsLiteral(w)?fZ(w,z):q.IsNever(w)?dZ(w,z):q.IsNull(w)?yZ(w,z):q.IsNumber(w)?cZ(w,z):q.IsObject(w)?pZ(w,z):q.IsRecord(w)?lZ(w,z):q.IsString(w)?rZ(w,z):q.IsSymbol(w)?aZ(w,z):q.IsTuple(w)?U$(w,z):q.IsPromise(w)?oZ(w,z):q.IsUint8Array(w)?W$(w,z):q.IsUndefined(w)?A$(w,z):q.IsUnion(w)?X$(w,z):q.IsUnknown(w)?Z$(w,z):q.IsVoid(w)?Q$(w,z):i6(`Unknown left type operand '${w[N]}'`)}function s1(w,z){return R0(w,z)}function Y$(w,z,U,W,A){let X={};for(let Z of globalThis.Object.getOwnPropertyNames(w))X[Z]=v6(w[Z],z,U,W,k0(A));return X}function J$(w,z,U,W,A){return Y$(w.properties,z,U,W,A)}function d9(w,z,U,W,A){let X=J$(w,z,U,W,A);return Y0(X)}function B$(w,z,U,W){let A=s1(w,z);return A===D.Union?G0([U,W]):A===D.True?U:W}function v6(w,z,U,W,A){return g0(w)?d9(w,z,U,W,A):k2(w)?P(h9(w,z,U,W,A)):P(B$(w,z,U,W),A)}function M$(w,z,U,W,A){return{[w]:v6(X0(w),z,U,W,k0(A))}}function q$(w,z,U,W,A){return w.reduce((X,Z)=>{return{...X,...M$(Z,z,U,W,A)}},{})}function H$(w,z,U,W,A){return q$(w.keys,z,U,W,A)}function h9(w,z,U,W,A){let X=H$(w,z,U,W,A);return Y0(X)}function G$(w){return w.allOf.every((z)=>g1(z))}function L$(w){return w.anyOf.some((z)=>g1(z))}function N$(w){return!g1(w.not)}function g1(w){return w[N]==="Intersect"?G$(w):w[N]==="Union"?L$(w):w[N]==="Not"?N$(w):w[N]==="Undefined"?!0:!1}function y9(w,z){return n6(G6(w),z)}function S$(w,z){let U=w.filter((W)=>s1(W,z)===D.False);return U.length===1?U[0]:G0(U)}function n6(w,z,U={}){if(T2(w))return P(y9(w,z),U);if(g0(w))return P(c9(w,z),U);return P(q0(w)?S$(w.anyOf,z):s1(w,z)!==D.False?H0():w,U)}function _$(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=n6(w[W],z);return U}function D$(w,z){return _$(w.properties,z)}function c9(w,z){let U=D$(w,z);return Y0(U)}function i9(w,z){return u6(G6(w),z)}function P$(w,z){let U=w.filter((W)=>s1(W,z)!==D.False);return U.length===1?U[0]:G0(U)}function u6(w,z,U){if(T2(w))return P(i9(w,z),U);if(g0(w))return P(v9(w,z),U);return P(q0(w)?P$(w.anyOf,z):s1(w,z)!==D.False?w:H0(),U)}function O$(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=u6(w[W],z);return U}function b$(w,z){return O$(w.properties,z)}function v9(w,z){let U=b$(w,z);return Y0(U)}function n9(w,z){return P(w.returns,z)}function u9(w){return P({[N]:"Integer",type:"integer"},w)}function R$(w,z,U){return{[w]:U1(X0(w),z,k0(U))}}function C$(w,z,U){return w.reduce((A,X)=>{return{...A,...R$(X,z,U)}},{})}function K$(w,z,U){return C$(w.keys,z,U)}function m9(w,z,U){let W=K$(w,z,U);return Y0(W)}function F$(w){let[z,U]=[w.slice(0,1),w.slice(1)];return[z.toLowerCase(),U].join("")}function j$(w){let[z,U]=[w.slice(0,1),w.slice(1)];return[z.toUpperCase(),U].join("")}function E$(w){return w.toUpperCase()}function I$(w){return w.toLowerCase()}function x$(w,z,U){let W=g6(w.pattern);if(!H6(W))return{...w,pattern:t9(w.pattern,z)};let Z=[...D4(W)].map((Y)=>X0(Y)),$=p9(Z,z),Q=G0($);return U8([Q],U)}function t9(w,z){return typeof w==="string"?z==="Uncapitalize"?F$(w):z==="Capitalize"?j$(w):z==="Uppercase"?E$(w):z==="Lowercase"?I$(w):w:w.toString()}function p9(w,z){return w.map((U)=>U1(U,z))}function U1(w,z,U={}){return k2(w)?m9(w,z,U):T2(w)?x$(w,z,U):q0(w)?G0(p9(w.anyOf,z),U):E1(w)?X0(t9(w.const,z),U):P(w,U)}function o9(w,z={}){return U1(w,"Capitalize",z)}function l9(w,z={}){return U1(w,"Lowercase",z)}function s9(w,z={}){return U1(w,"Uncapitalize",z)}function r9(w,z={}){return U1(w,"Uppercase",z)}function V$(w,z,U){let W={};for(let A of globalThis.Object.getOwnPropertyNames(w))W[A]=r1(w[A],z,k0(U));return W}function k$(w,z,U){return V$(w.properties,z,U)}function a9(w,z,U){let W=k$(w,z,U);return Y0(W)}function T$(w,z){return w.map((U)=>Yw(U,z))}function g$(w,z){return w.map((U)=>Yw(U,z))}function f$(w,z){let{[z]:U,...W}=w;return W}function d$(w,z){return z.reduce((U,W)=>f$(U,W),w)}function h$(w,z){let U=c0(w,[F0,"$id","required","properties"]),W=d$(w.properties,z);return _0(W,U)}function y$(w){let z=w.reduce((U,W)=>r4(W)?[...U,X0(W)]:U,[]);return G0(z)}function Yw(w,z){return m0(w)?Z2(T$(w.allOf,z)):q0(w)?G0(g$(w.anyOf,z)):r0(w)?h$(w,z):_0({})}function r1(w,z,U){let W=u0(z)?y$(z):z,A=d0(z)?D2(z):z,X=h0(w),Z=h0(z);return g0(w)?a9(w,A,U):k2(z)?e9(w,z,U):X&&Z?N0("Omit",[w,W],U):!X&&Z?N0("Omit",[w,W],U):X&&!Z?N0("Omit",[w,W],U):P({...Yw(w,A),...U})}function c$(w,z,U){return{[z]:r1(w,[z],k0(U))}}function i$(w,z,U){return z.reduce((W,A)=>{return{...W,...c$(w,A,U)}},{})}function v$(w,z,U){return i$(w,z.keys,U)}function e9(w,z,U){let W=v$(w,z,U);return Y0(W)}function n$(w,z,U){let W={};for(let A of globalThis.Object.getOwnPropertyNames(w))W[A]=a1(w[A],z,k0(U));return W}function u$(w,z,U){return n$(w.properties,z,U)}function w7(w,z,U){let W=u$(w,z,U);return Y0(W)}function m$(w,z){return w.map((U)=>Jw(U,z))}function t$(w,z){return w.map((U)=>Jw(U,z))}function p$(w,z){let U={};for(let W of z)if(W in w)U[W]=w[W];return U}function o$(w,z){let U=c0(w,[F0,"$id","required","properties"]),W=p$(w.properties,z);return _0(W,U)}function l$(w){let z=w.reduce((U,W)=>r4(W)?[...U,X0(W)]:U,[]);return G0(z)}function Jw(w,z){return m0(w)?Z2(m$(w.allOf,z)):q0(w)?G0(t$(w.anyOf,z)):r0(w)?o$(w,z):_0({})}function a1(w,z,U){let W=u0(z)?l$(z):z,A=d0(z)?D2(z):z,X=h0(w),Z=h0(z);return g0(w)?w7(w,A,U):k2(z)?z7(w,z,U):X&&Z?N0("Pick",[w,W],U):!X&&Z?N0("Pick",[w,W],U):X&&!Z?N0("Pick",[w,W],U):P({...Jw(w,A),...U})}function s$(w,z,U){return{[z]:a1(w,[z],k0(U))}}function r$(w,z,U){return z.reduce((W,A)=>{return{...W,...s$(w,A,U)}},{})}function a$(w,z,U){return r$(w,z.keys,U)}function z7(w,z,U){let W=a$(w,z,U);return Y0(W)}function e$(w,z){return N0("Partial",[N0(w,z)])}function wQ(w){return N0("Partial",[P2(w)])}function zQ(w){let z={};for(let U of globalThis.Object.getOwnPropertyNames(w))z[U]=_2(w[U]);return z}function UQ(w){let z=c0(w,[F0,"$id","required","properties"]),U=zQ(w.properties);return _0(U,z)}function U7(w){return w.map((z)=>W7(z))}function W7(w){return S2(w)?e$(w.target,w.parameters):h0(w)?wQ(w.$ref):m0(w)?Z2(U7(w.allOf)):q0(w)?G0(U7(w.anyOf)):r0(w)?UQ(w):_0({})}function m6(w,z){if(g0(w))return A7(w,z);else return P({...W7(w),...z})}function WQ(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=m6(w[W],k0(z));return U}function AQ(w,z){return WQ(w.properties,z)}function A7(w,z){let U=AQ(w,z);return Y0(U)}function L6(w,z,U){return P({[N]:"Record",type:"object",patternProperties:{[w]:z}},U)}function Bw(w,z,U){let W={};for(let A of w)W[A]=z;return _0(W,{...U,[h2]:"Record"})}function XQ(w,z,U){return w8(w)?Bw(D2(w),z,U):L6(w.pattern,z,U)}function ZQ(w,z,U){return Bw(D2(G0(w)),z,U)}function $Q(w,z,U){return Bw([w.toString()],z,U)}function QQ(w,z,U){return L6(w.source,z,U)}function YQ(w,z,U){let W=s0(w.pattern)?x1:w.pattern;return L6(W,z,U)}function JQ(w,z,U){return L6(x1,z,U)}function BQ(w,z,U){return L6(lz,z,U)}function MQ(w,z,U){return L6(I1,z,U)}function qQ(w,z,U){return L6(I1,z,U)}function H8(w,z,U={}){return S2(z)?N0("Record",[w,N0(z.target,z.parameters)],U):S2(w)?N0("Record",[N0(z.target,z.parameters),z],U):h0(w)?N0("Record",[P2(w.$ref),z]):q0(w)?ZQ(w.anyOf,z,U):T2(w)?XQ(w,z,U):E1(w)?$Q(w.const,z,U):M6(w)?MQ(w,z,U):q6(w)?qQ(w,z,U):o5(w)?QQ(w,z,U):H4(w)?YQ(w,z,U):u5(w)?JQ(w,z,U):t1(w)?BQ(w,z,U):H0(U)}function HQ(w,z){return N0("Required",[N0(w,z)])}function GQ(w){return N0("Required",[P2(w)])}function LQ(w){let z={};for(let U of globalThis.Object.getOwnPropertyNames(w))z[U]=c0(w[U],[X2]);return z}function NQ(w){let z=c0(w,[F0,"$id","required","properties"]),U=LQ(w.properties);return _0(U,z)}function X7(w){return w.map((z)=>Z7(z))}function Z7(w){return S2(w)?HQ(w.target,w.parameters):h0(w)?GQ(w.$ref):m0(w)?Z2(X7(w.allOf)):q0(w)?G0(X7(w.anyOf)):r0(w)?NQ(w):_0({})}function t6(w,z){if(g0(w))return $7(w,z);else return P({...Z7(w),...z})}function SQ(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=t6(w[W],z);return U}function _Q(w,z){return SQ(w.properties,z)}function $7(w,z){let U=_Q(w,z);return Y0(U)}function DQ(w,z){return z.map((U)=>{return h0(U)?Q7(w,U.$ref):t2(w,U)})}function Q7(w,z){return z in w?h0(w[z])?Q7(w,w[z].$ref):t2(w,w[z]):H0()}function PQ(w){return y6(w[0])}function OQ(w){return l1(w[0],w[1])}function bQ(w){return c6(w[0])}function RQ(w){return m6(w[0])}function CQ(w){return r1(w[0],w[1])}function KQ(w){return a1(w[0],w[1])}function FQ(w){return H8(w[0],w[1])}function jQ(w){return t6(w[0])}function EQ(w,z,U){let W=DQ(w,U);return z==="Awaited"?PQ(W):z==="Index"?OQ(W):z==="KeyOf"?bQ(W):z==="Partial"?RQ(W):z==="Omit"?CQ(W):z==="Pick"?KQ(W):z==="Record"?FQ(W):z==="Required"?jQ(W):H0()}function IQ(w,z){return _0(globalThis.Object.keys(z).reduce((U,W)=>{return{...U,[W]:t2(w,z[W])}},{}))}function xQ(w,z,U){return k6(R4(w,z),t2(w,U))}function VQ(w,z,U){return L1(R4(w,z),t2(w,U))}function kQ(w,z){return v2(R4(w,z))}function TQ(w,z){return Z2(R4(w,z))}function gQ(w,z){return G0(R4(w,z))}function fQ(w,z){return x6(t2(w,z))}function dQ(w,z){return V6(t2(w,z))}function hQ(w,z){return h6(t2(w,z))}function R4(w,z){return z.map((U)=>t2(w,U))}function t2(w,z){return y2(z)?P(t2(w,c0(z,[X2])),z):s4(z)?P(t2(w,c0(z,[w1])),z):j1(z)?P(fQ(w,z.items),z):Y4(z)?P(dQ(w,z.items),z):S2(z)?P(EQ(w,z.target,z.parameters)):J4(z)?P(xQ(w,z.parameters,z.returns),z):B4(z)?P(VQ(w,z.parameters,z.returns),z):m0(z)?P(TQ(w,z.allOf),z):M4(z)?P(hQ(w,z.items),z):r0(z)?P(IQ(w,z.properties),z):z1(z)?P(kQ(w,z.items||[]),z):q0(z)?P(gQ(w,z.anyOf),z):z}function yQ(w,z){return z in w?t2(w,w[z]):H0()}function Y7(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,U)=>{return{...z,[U]:yQ(w,U)}},{})}class J7{constructor(w){let z=Y7(w),U=this.WithIdentifiers(z);this.$defs=U}Import(w,z){let U={...this.$defs,[w]:P(this.$defs[w],z)};return P({[N]:"Import",$defs:U,$ref:w})}WithIdentifiers(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,U)=>{return{...z,[U]:{...w[U],$id:U}}},{})}}function B7(w){return new J7(w)}function M7(w,z){return P({[N]:"Not",not:w},z)}function q7(w,z){return v2(w.parameters,z)}function H7(w){return i2(_2(w))}var cQ=0;function G7(w,z={}){if(s0(z.$id))z.$id=`T${cQ++}`;let U=zz(w({[N]:"This",$ref:`${z.$id}`}));return U.$id=z.$id,P({[h2]:"Recursive",...U},z)}function L7(w,z){let U=E0(w)?new globalThis.RegExp(w):w;return P({[N]:"RegExp",type:"RegExp",source:U.source,flags:U.flags},z)}function iQ(w){return m0(w)?w.allOf:q0(w)?w.anyOf:z1(w)?w.items??[]:[]}function N7(w){return iQ(w)}function S7(w,z){return P(w.returns,z)}class _7{constructor(w){this.schema=w}Decode(w){return new D7(this.schema,w)}}class D7{constructor(w,z){this.schema=w,this.decode=z}EncodeTransform(w,z){let A={Encode:(X)=>z[F0].Encode(w(X)),Decode:(X)=>this.decode(z[F0].Decode(X))};return{...z,[F0]:A}}EncodeSchema(w,z){let U={Decode:this.decode,Encode:w};return{...z,[F0]:U}}Encode(w){return S0(this.schema)?this.EncodeTransform(w,this.schema):this.EncodeSchema(w,this.schema)}}function P7(w){return new _7(w)}function G8(w={}){return P({[N]:w[N]??"Unsafe"},w)}function O7(w){return P({[N]:"Void",type:"void"},w)}var Mw={};J6(Mw,{Void:()=>O7,Uppercase:()=>r9,Unsafe:()=>G8,Unknown:()=>T1,Union:()=>G0,Undefined:()=>Y8,Uncapitalize:()=>s9,Uint8Array:()=>J8,Tuple:()=>v2,Transform:()=>P7,TemplateLiteral:()=>U8,Symbol:()=>Q8,String:()=>c2,ReturnType:()=>S7,Rest:()=>N7,Required:()=>t6,RegExp:()=>L7,Ref:()=>P2,Recursive:()=>G7,Record:()=>H8,ReadonlyOptional:()=>H7,Readonly:()=>i2,Promise:()=>A8,Pick:()=>a1,Partial:()=>m6,Parameters:()=>q7,Optional:()=>_2,Omit:()=>r1,Object:()=>_0,Number:()=>S1,Null:()=>$8,Not:()=>M7,Never:()=>H0,Module:()=>B7,Mapped:()=>G9,Lowercase:()=>l9,Literal:()=>X0,KeyOf:()=>c6,Iterator:()=>h6,Intersect:()=>Z2,Integer:()=>u9,InstanceType:()=>n9,Index:()=>l1,Function:()=>L1,Extract:()=>u6,Extends:()=>v6,Exclude:()=>n6,Enum:()=>R9,Date:()=>Z8,ConstructorParameters:()=>b9,Constructor:()=>k6,Const:()=>O9,Composite:()=>P9,Capitalize:()=>o9,Boolean:()=>z8,BigInt:()=>d6,Awaited:()=>y6,AsyncIterator:()=>V6,Array:()=>x6,Any:()=>o1});var N6=Mw;class b7 extends y{constructor(w){super(`Duplicate type kind '${w}' detected`)}}class R7 extends y{constructor(w){super(`Duplicate string format '${w}' detected`)}}var f1;(function(w){function z(W,A){if(y0.Has(W))throw new b7(W);return y0.Set(W,A),(X={})=>G8({...X,[N]:W})}w.Type=z;function U(W,A){if(b0.Has(W))throw new R7(W);return b0.Set(W,A),W}w.Format=U})(f1||(f1={}));function vQ(w){switch(w.errorType){case S.ArrayContains:return"Expected array to contain at least one matching value";case S.ArrayMaxContains:return`Expected array to contain no more than ${w.schema.maxContains} matching values`;case S.ArrayMinContains:return`Expected array to contain at least ${w.schema.minContains} matching values`;case S.ArrayMaxItems:return`Expected array length to be less or equal to ${w.schema.maxItems}`;case S.ArrayMinItems:return`Expected array length to be greater or equal to ${w.schema.minItems}`;case S.ArrayUniqueItems:return"Expected array elements to be unique";case S.Array:return"Expected array";case S.AsyncIterator:return"Expected AsyncIterator";case S.BigIntExclusiveMaximum:return`Expected bigint to be less than ${w.schema.exclusiveMaximum}`;case S.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${w.schema.exclusiveMinimum}`;case S.BigIntMaximum:return`Expected bigint to be less or equal to ${w.schema.maximum}`;case S.BigIntMinimum:return`Expected bigint to be greater or equal to ${w.schema.minimum}`;case S.BigIntMultipleOf:return`Expected bigint to be a multiple of ${w.schema.multipleOf}`;case S.BigInt:return"Expected bigint";case S.Boolean:return"Expected boolean";case S.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${w.schema.exclusiveMinimumTimestamp}`;case S.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${w.schema.exclusiveMaximumTimestamp}`;case S.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${w.schema.minimumTimestamp}`;case S.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${w.schema.maximumTimestamp}`;case S.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${w.schema.multipleOfTimestamp}`;case S.Date:return"Expected Date";case S.Function:return"Expected function";case S.IntegerExclusiveMaximum:return`Expected integer to be less than ${w.schema.exclusiveMaximum}`;case S.IntegerExclusiveMinimum:return`Expected integer to be greater than ${w.schema.exclusiveMinimum}`;case S.IntegerMaximum:return`Expected integer to be less or equal to ${w.schema.maximum}`;case S.IntegerMinimum:return`Expected integer to be greater or equal to ${w.schema.minimum}`;case S.IntegerMultipleOf:return`Expected integer to be a multiple of ${w.schema.multipleOf}`;case S.Integer:return"Expected integer";case S.IntersectUnevaluatedProperties:return"Unexpected property";case S.Intersect:return"Expected all values to match";case S.Iterator:return"Expected Iterator";case S.Literal:return`Expected ${typeof w.schema.const==="string"?`'${w.schema.const}'`:w.schema.const}`;case S.Never:return"Never";case S.Not:return"Value should not match";case S.Null:return"Expected null";case S.NumberExclusiveMaximum:return`Expected number to be less than ${w.schema.exclusiveMaximum}`;case S.NumberExclusiveMinimum:return`Expected number to be greater than ${w.schema.exclusiveMinimum}`;case S.NumberMaximum:return`Expected number to be less or equal to ${w.schema.maximum}`;case S.NumberMinimum:return`Expected number to be greater or equal to ${w.schema.minimum}`;case S.NumberMultipleOf:return`Expected number to be a multiple of ${w.schema.multipleOf}`;case S.Number:return"Expected number";case S.Object:return"Expected object";case S.ObjectAdditionalProperties:return"Unexpected property";case S.ObjectMaxProperties:return`Expected object to have no more than ${w.schema.maxProperties} properties`;case S.ObjectMinProperties:return`Expected object to have at least ${w.schema.minProperties} properties`;case S.ObjectRequiredProperty:return"Expected required property";case S.Promise:return"Expected Promise";case S.RegExp:return"Expected string to match regular expression";case S.StringFormatUnknown:return`Unknown format '${w.schema.format}'`;case S.StringFormat:return`Expected string to match '${w.schema.format}' format`;case S.StringMaxLength:return`Expected string length less or equal to ${w.schema.maxLength}`;case S.StringMinLength:return`Expected string length greater or equal to ${w.schema.minLength}`;case S.StringPattern:return`Expected string to match '${w.schema.pattern}'`;case S.String:return"Expected string";case S.Symbol:return"Expected symbol";case S.TupleLength:return`Expected tuple to have ${w.schema.maxItems||0} elements`;case S.Tuple:return"Expected tuple";case S.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${w.schema.maxByteLength}`;case S.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${w.schema.minByteLength}`;case S.Uint8Array:return"Expected Uint8Array";case S.Undefined:return"Expected undefined";case S.Union:return"Expected union value";case S.Void:return"Expected void";case S.Kind:return`Expected kind '${w.schema[N]}'`;default:return"Unknown error type"}}var nQ=vQ;function C7(){return nQ}class K7 extends y{constructor(w){super(`Unable to dereference schema with $id '${w.$ref}'`);this.schema=w}}function uQ(w,z){let U=z.find((W)=>W.$id===w.$ref);if(U===void 0)throw new K7(w);return J0(U,z)}function e0(w,z){if(!$0(w.$id)||z.some((U)=>U.$id===w.$id))return z;return z.push(w),z}function J0(w,z){return w[N]==="This"||w[N]==="Ref"?uQ(w,z):w}class F7 extends y{constructor(w){super("Unable to hash value");this.value=w}}var g2;(function(w){w[w.Undefined=0]="Undefined",w[w.Null=1]="Null",w[w.Boolean=2]="Boolean",w[w.Number=3]="Number",w[w.String=4]="String",w[w.Object=5]="Object",w[w.Array=6]="Array",w[w.Date=7]="Date",w[w.Uint8Array=8]="Uint8Array",w[w.Symbol=9]="Symbol",w[w.BigInt=10]="BigInt"})(g2||(g2={}));var p6=BigInt("14695981039346656037"),[mQ,tQ]=[BigInt("1099511628211"),BigInt("18446744073709551616")],pQ=Array.from({length:256}).map((w,z)=>BigInt(z)),j7=new Float64Array(1),E7=new DataView(j7.buffer),I7=new Uint8Array(j7.buffer);function*oQ(w){let z=w===0?1:Math.ceil(Math.floor(Math.log2(w)+1)/8);for(let U=0;U<z;U++)yield w>>8*(z-1-U)&255}function lQ(w){Q2(g2.Array);for(let z of w)o6(z)}function sQ(w){Q2(g2.Boolean),Q2(w?1:0)}function rQ(w){Q2(g2.BigInt),E7.setBigInt64(0,w);for(let z of I7)Q2(z)}function aQ(w){Q2(g2.Date),o6(w.getTime())}function eQ(w){Q2(g2.Null)}function wY(w){Q2(g2.Number),E7.setFloat64(0,w);for(let z of I7)Q2(z)}function zY(w){Q2(g2.Object);for(let z of globalThis.Object.getOwnPropertyNames(w).sort())o6(z),o6(w[z])}function UY(w){Q2(g2.String);for(let z=0;z<w.length;z++)for(let U of oQ(w.charCodeAt(z)))Q2(U)}function WY(w){Q2(g2.Symbol),o6(w.description)}function AY(w){Q2(g2.Uint8Array);for(let z=0;z<w.length;z++)Q2(w[z])}function XY(w){return Q2(g2.Undefined)}function o6(w){if(n(w))return lQ(w);if(G1(w))return sQ(w);if(A2(w))return rQ(w);if(G2(w))return aQ(w);if(K1(w))return eQ(w);if(d(w))return wY(w);if(s(w))return zY(w);if($0(w))return UY(w);if(F1(w))return WY(w);if(j6(w))return AY(w);if(T0(w))return XY(w);throw new F7(w)}function Q2(w){p6=p6^pQ[w],p6=p6*mQ%tQ}function e1(w){return p6=BigInt("14695981039346656037"),o6(w),p6}class x7 extends y{constructor(w){super("Unknown type");this.schema=w}}function ZY(w){return w[N]==="Any"||w[N]==="Unknown"}function z0(w){return w!==void 0}function $Y(w,z,U){return!0}function QY(w,z,U){if(!n(U))return!1;if(z0(w.minItems)&&!(U.length>=w.minItems))return!1;if(z0(w.maxItems)&&!(U.length<=w.maxItems))return!1;if(!U.every((X)=>w2(w.items,z,X)))return!1;if(w.uniqueItems===!0&&!function(){let X=new Set;for(let Z of U){let $=e1(Z);if(X.has($))return!1;else X.add($)}return!0}())return!1;if(!(z0(w.contains)||d(w.minContains)||d(w.maxContains)))return!0;let W=z0(w.contains)?w.contains:H0(),A=U.reduce((X,Z)=>w2(W,z,Z)?X+1:X,0);if(A===0)return!1;if(d(w.minContains)&&A<w.minContains)return!1;if(d(w.maxContains)&&A>w.maxContains)return!1;return!0}function YY(w,z,U){return t4(U)}function JY(w,z,U){if(!A2(U))return!1;if(z0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(U<=w.maximum))return!1;if(z0(w.minimum)&&!(U>=w.minimum))return!1;if(z0(w.multipleOf)&&U%w.multipleOf!==BigInt(0))return!1;return!0}function BY(w,z,U){return G1(U)}function MY(w,z,U){return w2(w.returns,z,U.prototype)}function qY(w,z,U){if(!G2(U))return!1;if(z0(w.exclusiveMaximumTimestamp)&&!(U.getTime()<w.exclusiveMaximumTimestamp))return!1;if(z0(w.exclusiveMinimumTimestamp)&&!(U.getTime()>w.exclusiveMinimumTimestamp))return!1;if(z0(w.maximumTimestamp)&&!(U.getTime()<=w.maximumTimestamp))return!1;if(z0(w.minimumTimestamp)&&!(U.getTime()>=w.minimumTimestamp))return!1;if(z0(w.multipleOfTimestamp)&&U.getTime()%w.multipleOfTimestamp!==0)return!1;return!0}function HY(w,z,U){return m1(U)}function GY(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return w2(A,[...z,...W],U)}function LY(w,z,U){if(!l4(U))return!1;if(z0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(U<=w.maximum))return!1;if(z0(w.minimum)&&!(U>=w.minimum))return!1;if(z0(w.multipleOf)&&U%w.multipleOf!==0)return!1;return!0}function NY(w,z,U){let W=w.allOf.every((A)=>w2(A,z,U));if(w.unevaluatedProperties===!1){let A=new RegExp(k1(w)),X=Object.getOwnPropertyNames(U).every((Z)=>A.test(Z));return W&&X}else if(d0(w.unevaluatedProperties)){let A=new RegExp(k1(w)),X=Object.getOwnPropertyNames(U).every((Z)=>A.test(Z)||w2(w.unevaluatedProperties,z,U[Z]));return W&&X}else return W}function SY(w,z,U){return p4(U)}function _Y(w,z,U){return U===w.const}function DY(w,z,U){return!1}function PY(w,z,U){return!w2(w.not,z,U)}function OY(w,z,U){return K1(U)}function bY(w,z,U){if(!V0.IsNumberLike(U))return!1;if(z0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))return!1;if(z0(w.minimum)&&!(U>=w.minimum))return!1;if(z0(w.maximum)&&!(U<=w.maximum))return!1;if(z0(w.multipleOf)&&U%w.multipleOf!==0)return!1;return!0}function RY(w,z,U){if(!V0.IsObjectLike(U))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))return!1;let W=Object.getOwnPropertyNames(w.properties);for(let A of W){let X=w.properties[A];if(w.required&&w.required.includes(A)){if(!w2(X,z,U[A]))return!1;if((g1(X)||ZY(X))&&!(A in U))return!1}else if(V0.IsExactOptionalProperty(U,A)&&!w2(X,z,U[A]))return!1}if(w.additionalProperties===!1){let A=Object.getOwnPropertyNames(U);if(w.required&&w.required.length===W.length&&A.length===W.length)return!0;else return A.every((X)=>W.includes(X))}else if(typeof w.additionalProperties==="object")return Object.getOwnPropertyNames(U).every((X)=>W.includes(X)||w2(w.additionalProperties,z,U[X]));else return!0}function CY(w,z,U){return o4(U)}function KY(w,z,U){if(!V0.IsRecordLike(U))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))return!1;let[W,A]=Object.entries(w.patternProperties)[0],X=new RegExp(W),Z=Object.entries(U).every(([Y,B])=>{return X.test(Y)?w2(A,z,B):!0}),$=typeof w.additionalProperties==="object"?Object.entries(U).every(([Y,B])=>{return!X.test(Y)?w2(w.additionalProperties,z,B):!0}):!0,Q=w.additionalProperties===!1?Object.getOwnPropertyNames(U).every((Y)=>{return X.test(Y)}):!0;return Z&&$&&Q}function FY(w,z,U){return w2(J0(w,z),z,U)}function jY(w,z,U){let W=new RegExp(w.source,w.flags);if(z0(w.minLength)){if(!(U.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(U.length<=w.maxLength))return!1}return W.test(U)}function EY(w,z,U){if(!$0(U))return!1;if(z0(w.minLength)){if(!(U.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(U.length<=w.maxLength))return!1}if(z0(w.pattern)){if(!new RegExp(w.pattern).test(U))return!1}if(z0(w.format)){if(!b0.Has(w.format))return!1;return b0.Get(w.format)(U)}return!0}function IY(w,z,U){return F1(U)}function xY(w,z,U){return $0(U)&&new RegExp(w.pattern).test(U)}function VY(w,z,U){return w2(J0(w,z),z,U)}function kY(w,z,U){if(!n(U))return!1;if(w.items===void 0&&U.length!==0)return!1;if(U.length!==w.maxItems)return!1;if(!w.items)return!0;for(let W=0;W<w.items.length;W++)if(!w2(w.items[W],z,U[W]))return!1;return!0}function TY(w,z,U){return T0(U)}function gY(w,z,U){return w.anyOf.some((W)=>w2(W,z,U))}function fY(w,z,U){if(!j6(U))return!1;if(z0(w.maxByteLength)&&!(U.length<=w.maxByteLength))return!1;if(z0(w.minByteLength)&&!(U.length>=w.minByteLength))return!1;return!0}function dY(w,z,U){return!0}function hY(w,z,U){return V0.IsVoidLike(U)}function yY(w,z,U){if(!y0.Has(w[N]))return!1;return y0.Get(w[N])(w,U)}function w2(w,z,U){let W=z0(w.$id)?e0(w,z):z,A=w;switch(A[N]){case"Any":return $Y(A,W,U);case"Array":return QY(A,W,U);case"AsyncIterator":return YY(A,W,U);case"BigInt":return JY(A,W,U);case"Boolean":return BY(A,W,U);case"Constructor":return MY(A,W,U);case"Date":return qY(A,W,U);case"Function":return HY(A,W,U);case"Import":return GY(A,W,U);case"Integer":return LY(A,W,U);case"Intersect":return NY(A,W,U);case"Iterator":return SY(A,W,U);case"Literal":return _Y(A,W,U);case"Never":return DY(A,W,U);case"Not":return PY(A,W,U);case"Null":return OY(A,W,U);case"Number":return bY(A,W,U);case"Object":return RY(A,W,U);case"Promise":return CY(A,W,U);case"Record":return KY(A,W,U);case"Ref":return FY(A,W,U);case"RegExp":return jY(A,W,U);case"String":return EY(A,W,U);case"Symbol":return IY(A,W,U);case"TemplateLiteral":return xY(A,W,U);case"This":return VY(A,W,U);case"Tuple":return kY(A,W,U);case"Undefined":return TY(A,W,U);case"Union":return gY(A,W,U);case"Uint8Array":return fY(A,W,U);case"Unknown":return dY(A,W,U);case"Void":return hY(A,W,U);default:if(!y0.Has(A[N]))throw new x7(A);return yY(A,W,U)}}function r(...w){return w.length===3?w2(w[0],w[1],w[2]):w2(w[0],[],w[1])}var S;(function(w){w[w.ArrayContains=0]="ArrayContains",w[w.ArrayMaxContains=1]="ArrayMaxContains",w[w.ArrayMaxItems=2]="ArrayMaxItems",w[w.ArrayMinContains=3]="ArrayMinContains",w[w.ArrayMinItems=4]="ArrayMinItems",w[w.ArrayUniqueItems=5]="ArrayUniqueItems",w[w.Array=6]="Array",w[w.AsyncIterator=7]="AsyncIterator",w[w.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",w[w.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",w[w.BigIntMaximum=10]="BigIntMaximum",w[w.BigIntMinimum=11]="BigIntMinimum",w[w.BigIntMultipleOf=12]="BigIntMultipleOf",w[w.BigInt=13]="BigInt",w[w.Boolean=14]="Boolean",w[w.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",w[w.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",w[w.DateMaximumTimestamp=17]="DateMaximumTimestamp",w[w.DateMinimumTimestamp=18]="DateMinimumTimestamp",w[w.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",w[w.Date=20]="Date",w[w.Function=21]="Function",w[w.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",w[w.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",w[w.IntegerMaximum=24]="IntegerMaximum",w[w.IntegerMinimum=25]="IntegerMinimum",w[w.IntegerMultipleOf=26]="IntegerMultipleOf",w[w.Integer=27]="Integer",w[w.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",w[w.Intersect=29]="Intersect",w[w.Iterator=30]="Iterator",w[w.Kind=31]="Kind",w[w.Literal=32]="Literal",w[w.Never=33]="Never",w[w.Not=34]="Not",w[w.Null=35]="Null",w[w.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",w[w.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",w[w.NumberMaximum=38]="NumberMaximum",w[w.NumberMinimum=39]="NumberMinimum",w[w.NumberMultipleOf=40]="NumberMultipleOf",w[w.Number=41]="Number",w[w.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",w[w.ObjectMaxProperties=43]="ObjectMaxProperties",w[w.ObjectMinProperties=44]="ObjectMinProperties",w[w.ObjectRequiredProperty=45]="ObjectRequiredProperty",w[w.Object=46]="Object",w[w.Promise=47]="Promise",w[w.RegExp=48]="RegExp",w[w.StringFormatUnknown=49]="StringFormatUnknown",w[w.StringFormat=50]="StringFormat",w[w.StringMaxLength=51]="StringMaxLength",w[w.StringMinLength=52]="StringMinLength",w[w.StringPattern=53]="StringPattern",w[w.String=54]="String",w[w.Symbol=55]="Symbol",w[w.TupleLength=56]="TupleLength",w[w.Tuple=57]="Tuple",w[w.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",w[w.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",w[w.Uint8Array=60]="Uint8Array",w[w.Undefined=61]="Undefined",w[w.Union=62]="Union",w[w.Void=63]="Void"})(S||(S={}));class V7 extends y{constructor(w){super("Unknown type");this.schema=w}}function d1(w){return w.replace(/~/g,"~0").replace(/\//g,"~1")}function U0(w){return w!==void 0}class S6{constructor(w){this.iterator=w}[Symbol.iterator](){return this.iterator}First(){let w=this.iterator.next();return w.done?void 0:w.value}}function E(w,z,U,W,A=[]){return{type:w,schema:z,path:U,value:W,message:C7()({errorType:w,path:U,schema:z,value:W,errors:A}),errors:A}}function*cY(w,z,U,W){}function*iY(w,z,U,W){if(!n(W))return yield E(S.Array,w,U,W);if(U0(w.minItems)&&!(W.length>=w.minItems))yield E(S.ArrayMinItems,w,U,W);if(U0(w.maxItems)&&!(W.length<=w.maxItems))yield E(S.ArrayMaxItems,w,U,W);for(let Z=0;Z<W.length;Z++)yield*z2(w.items,z,`${U}/${Z}`,W[Z]);if(w.uniqueItems===!0&&!function(){let Z=new Set;for(let $ of W){let Q=e1($);if(Z.has(Q))return!1;else Z.add(Q)}return!0}())yield E(S.ArrayUniqueItems,w,U,W);if(!(U0(w.contains)||U0(w.minContains)||U0(w.maxContains)))return;let A=U0(w.contains)?w.contains:H0(),X=W.reduce((Z,$,Q)=>z2(A,z,`${U}${Q}`,$).next().done===!0?Z+1:Z,0);if(X===0)yield E(S.ArrayContains,w,U,W);if(d(w.minContains)&&X<w.minContains)yield E(S.ArrayMinContains,w,U,W);if(d(w.maxContains)&&X>w.maxContains)yield E(S.ArrayMaxContains,w,U,W)}function*vY(w,z,U,W){if(!t4(W))yield E(S.AsyncIterator,w,U,W)}function*nY(w,z,U,W){if(!A2(W))return yield E(S.BigInt,w,U,W);if(U0(w.exclusiveMaximum)&&!(W<w.exclusiveMaximum))yield E(S.BigIntExclusiveMaximum,w,U,W);if(U0(w.exclusiveMinimum)&&!(W>w.exclusiveMinimum))yield E(S.BigIntExclusiveMinimum,w,U,W);if(U0(w.maximum)&&!(W<=w.maximum))yield E(S.BigIntMaximum,w,U,W);if(U0(w.minimum)&&!(W>=w.minimum))yield E(S.BigIntMinimum,w,U,W);if(U0(w.multipleOf)&&W%w.multipleOf!==BigInt(0))yield E(S.BigIntMultipleOf,w,U,W)}function*uY(w,z,U,W){if(!G1(W))yield E(S.Boolean,w,U,W)}function*mY(w,z,U,W){yield*z2(w.returns,z,U,W.prototype)}function*tY(w,z,U,W){if(!G2(W))return yield E(S.Date,w,U,W);if(U0(w.exclusiveMaximumTimestamp)&&!(W.getTime()<w.exclusiveMaximumTimestamp))yield E(S.DateExclusiveMaximumTimestamp,w,U,W);if(U0(w.exclusiveMinimumTimestamp)&&!(W.getTime()>w.exclusiveMinimumTimestamp))yield E(S.DateExclusiveMinimumTimestamp,w,U,W);if(U0(w.maximumTimestamp)&&!(W.getTime()<=w.maximumTimestamp))yield E(S.DateMaximumTimestamp,w,U,W);if(U0(w.minimumTimestamp)&&!(W.getTime()>=w.minimumTimestamp))yield E(S.DateMinimumTimestamp,w,U,W);if(U0(w.multipleOfTimestamp)&&W.getTime()%w.multipleOfTimestamp!==0)yield E(S.DateMultipleOfTimestamp,w,U,W)}function*pY(w,z,U,W){if(!m1(W))yield E(S.Function,w,U,W)}function*oY(w,z,U,W){let A=globalThis.Object.values(w.$defs),X=w.$defs[w.$ref];yield*z2(X,[...z,...A],U,W)}function*lY(w,z,U,W){if(!l4(W))return yield E(S.Integer,w,U,W);if(U0(w.exclusiveMaximum)&&!(W<w.exclusiveMaximum))yield E(S.IntegerExclusiveMaximum,w,U,W);if(U0(w.exclusiveMinimum)&&!(W>w.exclusiveMinimum))yield E(S.IntegerExclusiveMinimum,w,U,W);if(U0(w.maximum)&&!(W<=w.maximum))yield E(S.IntegerMaximum,w,U,W);if(U0(w.minimum)&&!(W>=w.minimum))yield E(S.IntegerMinimum,w,U,W);if(U0(w.multipleOf)&&W%w.multipleOf!==0)yield E(S.IntegerMultipleOf,w,U,W)}function*sY(w,z,U,W){let A=!1;for(let X of w.allOf)for(let Z of z2(X,z,U,W))A=!0,yield Z;if(A)return yield E(S.Intersect,w,U,W);if(w.unevaluatedProperties===!1){let X=new RegExp(k1(w));for(let Z of Object.getOwnPropertyNames(W))if(!X.test(Z))yield E(S.IntersectUnevaluatedProperties,w,`${U}/${Z}`,W)}if(typeof w.unevaluatedProperties==="object"){let X=new RegExp(k1(w));for(let Z of Object.getOwnPropertyNames(W))if(!X.test(Z)){let $=z2(w.unevaluatedProperties,z,`${U}/${Z}`,W[Z]).next();if(!$.done)yield $.value}}}function*rY(w,z,U,W){if(!p4(W))yield E(S.Iterator,w,U,W)}function*aY(w,z,U,W){if(W!==w.const)yield E(S.Literal,w,U,W)}function*eY(w,z,U,W){yield E(S.Never,w,U,W)}function*wJ(w,z,U,W){if(z2(w.not,z,U,W).next().done===!0)yield E(S.Not,w,U,W)}function*zJ(w,z,U,W){if(!K1(W))yield E(S.Null,w,U,W)}function*UJ(w,z,U,W){if(!V0.IsNumberLike(W))return yield E(S.Number,w,U,W);if(U0(w.exclusiveMaximum)&&!(W<w.exclusiveMaximum))yield E(S.NumberExclusiveMaximum,w,U,W);if(U0(w.exclusiveMinimum)&&!(W>w.exclusiveMinimum))yield E(S.NumberExclusiveMinimum,w,U,W);if(U0(w.maximum)&&!(W<=w.maximum))yield E(S.NumberMaximum,w,U,W);if(U0(w.minimum)&&!(W>=w.minimum))yield E(S.NumberMinimum,w,U,W);if(U0(w.multipleOf)&&W%w.multipleOf!==0)yield E(S.NumberMultipleOf,w,U,W)}function*WJ(w,z,U,W){if(!V0.IsObjectLike(W))return yield E(S.Object,w,U,W);if(U0(w.minProperties)&&!(Object.getOwnPropertyNames(W).length>=w.minProperties))yield E(S.ObjectMinProperties,w,U,W);if(U0(w.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=w.maxProperties))yield E(S.ObjectMaxProperties,w,U,W);let A=Array.isArray(w.required)?w.required:[],X=Object.getOwnPropertyNames(w.properties),Z=Object.getOwnPropertyNames(W);for(let $ of A){if(Z.includes($))continue;yield E(S.ObjectRequiredProperty,w.properties[$],`${U}/${d1($)}`,void 0)}if(w.additionalProperties===!1){for(let $ of Z)if(!X.includes($))yield E(S.ObjectAdditionalProperties,w,`${U}/${d1($)}`,W[$])}if(typeof w.additionalProperties==="object")for(let $ of Z){if(X.includes($))continue;yield*z2(w.additionalProperties,z,`${U}/${d1($)}`,W[$])}for(let $ of X){let Q=w.properties[$];if(w.required&&w.required.includes($)){if(yield*z2(Q,z,`${U}/${d1($)}`,W[$]),g1(w)&&!($ in W))yield E(S.ObjectRequiredProperty,Q,`${U}/${d1($)}`,void 0)}else if(V0.IsExactOptionalProperty(W,$))yield*z2(Q,z,`${U}/${d1($)}`,W[$])}}function*AJ(w,z,U,W){if(!o4(W))yield E(S.Promise,w,U,W)}function*XJ(w,z,U,W){if(!V0.IsRecordLike(W))return yield E(S.Object,w,U,W);if(U0(w.minProperties)&&!(Object.getOwnPropertyNames(W).length>=w.minProperties))yield E(S.ObjectMinProperties,w,U,W);if(U0(w.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=w.maxProperties))yield E(S.ObjectMaxProperties,w,U,W);let[A,X]=Object.entries(w.patternProperties)[0],Z=new RegExp(A);for(let[$,Q]of Object.entries(W))if(Z.test($))yield*z2(X,z,`${U}/${d1($)}`,Q);if(typeof w.additionalProperties==="object"){for(let[$,Q]of Object.entries(W))if(!Z.test($))yield*z2(w.additionalProperties,z,`${U}/${d1($)}`,Q)}if(w.additionalProperties===!1)for(let[$,Q]of Object.entries(W)){if(Z.test($))continue;return yield E(S.ObjectAdditionalProperties,w,`${U}/${d1($)}`,Q)}}function*ZJ(w,z,U,W){yield*z2(J0(w,z),z,U,W)}function*$J(w,z,U,W){if(!$0(W))return yield E(S.String,w,U,W);if(U0(w.minLength)&&!(W.length>=w.minLength))yield E(S.StringMinLength,w,U,W);if(U0(w.maxLength)&&!(W.length<=w.maxLength))yield E(S.StringMaxLength,w,U,W);if(!new RegExp(w.source,w.flags).test(W))return yield E(S.RegExp,w,U,W)}function*QJ(w,z,U,W){if(!$0(W))return yield E(S.String,w,U,W);if(U0(w.minLength)&&!(W.length>=w.minLength))yield E(S.StringMinLength,w,U,W);if(U0(w.maxLength)&&!(W.length<=w.maxLength))yield E(S.StringMaxLength,w,U,W);if($0(w.pattern)){if(!new RegExp(w.pattern).test(W))yield E(S.StringPattern,w,U,W)}if($0(w.format)){if(!b0.Has(w.format))yield E(S.StringFormatUnknown,w,U,W);else if(!b0.Get(w.format)(W))yield E(S.StringFormat,w,U,W)}}function*YJ(w,z,U,W){if(!F1(W))yield E(S.Symbol,w,U,W)}function*JJ(w,z,U,W){if(!$0(W))return yield E(S.String,w,U,W);if(!new RegExp(w.pattern).test(W))yield E(S.StringPattern,w,U,W)}function*BJ(w,z,U,W){yield*z2(J0(w,z),z,U,W)}function*MJ(w,z,U,W){if(!n(W))return yield E(S.Tuple,w,U,W);if(w.items===void 0&&W.length!==0)return yield E(S.TupleLength,w,U,W);if(W.length!==w.maxItems)return yield E(S.TupleLength,w,U,W);if(!w.items)return;for(let A=0;A<w.items.length;A++)yield*z2(w.items[A],z,`${U}/${A}`,W[A])}function*qJ(w,z,U,W){if(!T0(W))yield E(S.Undefined,w,U,W)}function*HJ(w,z,U,W){if(r(w,z,W))return;let A=w.anyOf.map((X)=>new S6(z2(X,z,U,W)));yield E(S.Union,w,U,W,A)}function*GJ(w,z,U,W){if(!j6(W))return yield E(S.Uint8Array,w,U,W);if(U0(w.maxByteLength)&&!(W.length<=w.maxByteLength))yield E(S.Uint8ArrayMaxByteLength,w,U,W);if(U0(w.minByteLength)&&!(W.length>=w.minByteLength))yield E(S.Uint8ArrayMinByteLength,w,U,W)}function*LJ(w,z,U,W){}function*NJ(w,z,U,W){if(!V0.IsVoidLike(W))yield E(S.Void,w,U,W)}function*SJ(w,z,U,W){if(!y0.Get(w[N])(w,W))yield E(S.Kind,w,U,W)}function*z2(w,z,U,W){let A=U0(w.$id)?[...z,w]:z,X=w;switch(X[N]){case"Any":return yield*cY(X,A,U,W);case"Array":return yield*iY(X,A,U,W);case"AsyncIterator":return yield*vY(X,A,U,W);case"BigInt":return yield*nY(X,A,U,W);case"Boolean":return yield*uY(X,A,U,W);case"Constructor":return yield*mY(X,A,U,W);case"Date":return yield*tY(X,A,U,W);case"Function":return yield*pY(X,A,U,W);case"Import":return yield*oY(X,A,U,W);case"Integer":return yield*lY(X,A,U,W);case"Intersect":return yield*sY(X,A,U,W);case"Iterator":return yield*rY(X,A,U,W);case"Literal":return yield*aY(X,A,U,W);case"Never":return yield*eY(X,A,U,W);case"Not":return yield*wJ(X,A,U,W);case"Null":return yield*zJ(X,A,U,W);case"Number":return yield*UJ(X,A,U,W);case"Object":return yield*WJ(X,A,U,W);case"Promise":return yield*AJ(X,A,U,W);case"Record":return yield*XJ(X,A,U,W);case"Ref":return yield*ZJ(X,A,U,W);case"RegExp":return yield*$J(X,A,U,W);case"String":return yield*QJ(X,A,U,W);case"Symbol":return yield*YJ(X,A,U,W);case"TemplateLiteral":return yield*JJ(X,A,U,W);case"This":return yield*BJ(X,A,U,W);case"Tuple":return yield*MJ(X,A,U,W);case"Undefined":return yield*qJ(X,A,U,W);case"Union":return yield*HJ(X,A,U,W);case"Uint8Array":return yield*GJ(X,A,U,W);case"Unknown":return yield*LJ(X,A,U,W);case"Void":return yield*NJ(X,A,U,W);default:if(!y0.Has(X[N]))throw new V7(w);return yield*SJ(X,A,U,W)}}function _1(...w){let z=w.length===3?z2(w[0],w[1],"",w[2]):z2(w[0],[],"",w[1]);return new S6(z)}class C4 extends y{constructor(w,z,U){super("Unable to decode value as it does not match the expected schema");this.schema=w,this.value=z,this.error=U}}class L8 extends y{constructor(w,z,U,W){super(W instanceof Error?W.message:"Unknown error");this.schema=w,this.path=z,this.value=U,this.error=W}}function i0(w,z,U){try{return S0(w)?w[F0].Decode(U):U}catch(W){throw new L8(w,z,U,W)}}function _J(w,z,U,W){return n(W)?i0(w,U,W.map((A,X)=>W1(w.items,z,`${U}/${X}`,A))):i0(w,U,W)}function DJ(w,z,U,W){if(!s(W)||V2(W))return i0(w,U,W);let A=X8(w),X=A.map((B)=>B[0]),Z={...W};for(let[B,G]of A)if(B in Z)Z[B]=W1(G,z,`${U}/${B}`,Z[B]);if(!S0(w.unevaluatedProperties))return i0(w,U,Z);let $=Object.getOwnPropertyNames(Z),Q=w.unevaluatedProperties,Y={...Z};for(let B of $)if(!X.includes(B))Y[B]=i0(Q,`${U}/${B}`,Y[B]);return i0(w,U,Y)}function PJ(w,z,U,W){let A=globalThis.Object.values(w.$defs),X=w.$defs[w.$ref],Z=w[F0],$={[F0]:Z,...X};return W1($,[...z,...A],U,W)}function OJ(w,z,U,W){return i0(w,U,W1(w.not,z,U,W))}function bJ(w,z,U,W){if(!s(W))return i0(w,U,W);let A=O2(w),X={...W};for(let Y of A){if(!v(X,Y))continue;if(T0(X[Y])&&(!G4(w.properties[Y])||V0.IsExactOptionalProperty(X,Y)))continue;X[Y]=W1(w.properties[Y],z,`${U}/${Y}`,X[Y])}if(!d0(w.additionalProperties))return i0(w,U,X);let Z=Object.getOwnPropertyNames(X),$=w.additionalProperties,Q={...X};for(let Y of Z)if(!A.includes(Y))Q[Y]=i0($,`${U}/${Y}`,Q[Y]);return i0(w,U,Q)}function RJ(w,z,U,W){if(!s(W))return i0(w,U,W);let A=Object.getOwnPropertyNames(w.patternProperties)[0],X=new RegExp(A),Z={...W};for(let B of Object.getOwnPropertyNames(W))if(X.test(B))Z[B]=W1(w.patternProperties[A],z,`${U}/${B}`,Z[B]);if(!d0(w.additionalProperties))return i0(w,U,Z);let $=Object.getOwnPropertyNames(Z),Q=w.additionalProperties,Y={...Z};for(let B of $)if(!X.test(B))Y[B]=i0(Q,`${U}/${B}`,Y[B]);return i0(w,U,Y)}function CJ(w,z,U,W){let A=J0(w,z);return i0(w,U,W1(A,z,U,W))}function KJ(w,z,U,W){let A=J0(w,z);return i0(w,U,W1(A,z,U,W))}function FJ(w,z,U,W){return n(W)&&n(w.items)?i0(w,U,w.items.map((A,X)=>W1(A,z,`${U}/${X}`,W[X]))):i0(w,U,W)}function jJ(w,z,U,W){for(let A of w.anyOf){if(!r(A,z,W))continue;let X=W1(A,z,U,W);return i0(w,U,X)}return i0(w,U,W)}function W1(w,z,U,W){let A=e0(w,z),X=w;switch(w[N]){case"Array":return _J(X,A,U,W);case"Import":return PJ(X,A,U,W);case"Intersect":return DJ(X,A,U,W);case"Not":return OJ(X,A,U,W);case"Object":return bJ(X,A,U,W);case"Record":return RJ(X,A,U,W);case"Ref":return CJ(X,A,U,W);case"Symbol":return i0(X,U,W);case"This":return KJ(X,A,U,W);case"Tuple":return FJ(X,A,U,W);case"Union":return jJ(X,A,U,W);default:return i0(X,U,W)}}function l6(w,z,U){return W1(w,z,"",U)}class K4 extends y{constructor(w,z,U){super("The encoded value does not match the expected schema");this.schema=w,this.value=z,this.error=U}}class k7 extends y{constructor(w,z,U,W){super(`${W instanceof Error?W.message:"Unknown error"}`);this.schema=w,this.path=z,this.value=U,this.error=W}}function Y2(w,z,U){try{return S0(w)?w[F0].Encode(U):U}catch(W){throw new k7(w,z,U,W)}}function EJ(w,z,U,W){let A=Y2(w,U,W);return n(A)?A.map((X,Z)=>A1(w.items,z,`${U}/${Z}`,X)):A}function IJ(w,z,U,W){let A=globalThis.Object.values(w.$defs),X=w.$defs[w.$ref],Z=w[F0],$={[F0]:Z,...X};return A1($,[...z,...A],U,W)}function xJ(w,z,U,W){let A=Y2(w,U,W);if(!s(W)||V2(W))return A;let X=X8(w),Z=X.map((G)=>G[0]),$={...A};for(let[G,_]of X)if(G in $)$[G]=A1(_,z,`${U}/${G}`,$[G]);if(!S0(w.unevaluatedProperties))return $;let Q=Object.getOwnPropertyNames($),Y=w.unevaluatedProperties,B={...$};for(let G of Q)if(!Z.includes(G))B[G]=Y2(Y,`${U}/${G}`,B[G]);return B}function VJ(w,z,U,W){return Y2(w.not,U,Y2(w,U,W))}function kJ(w,z,U,W){let A=Y2(w,U,W);if(!s(A))return A;let X=O2(w),Z={...A};for(let B of X){if(!v(Z,B))continue;if(T0(Z[B])&&(!G4(w.properties[B])||V0.IsExactOptionalProperty(Z,B)))continue;Z[B]=A1(w.properties[B],z,`${U}/${B}`,Z[B])}if(!d0(w.additionalProperties))return Z;let $=Object.getOwnPropertyNames(Z),Q=w.additionalProperties,Y={...Z};for(let B of $)if(!X.includes(B))Y[B]=Y2(Q,`${U}/${B}`,Y[B]);return Y}function TJ(w,z,U,W){let A=Y2(w,U,W);if(!s(W))return A;let X=Object.getOwnPropertyNames(w.patternProperties)[0],Z=new RegExp(X),$={...A};for(let G of Object.getOwnPropertyNames(W))if(Z.test(G))$[G]=A1(w.patternProperties[X],z,`${U}/${G}`,$[G]);if(!d0(w.additionalProperties))return $;let Q=Object.getOwnPropertyNames($),Y=w.additionalProperties,B={...$};for(let G of Q)if(!Z.test(G))B[G]=Y2(Y,`${U}/${G}`,B[G]);return B}function gJ(w,z,U,W){let A=J0(w,z),X=A1(A,z,U,W);return Y2(w,U,X)}function fJ(w,z,U,W){let A=J0(w,z),X=A1(A,z,U,W);return Y2(w,U,X)}function dJ(w,z,U,W){let A=Y2(w,U,W);return n(w.items)?w.items.map((X,Z)=>A1(X,z,`${U}/${Z}`,A[Z])):[]}function hJ(w,z,U,W){for(let A of w.anyOf){if(!r(A,z,W))continue;let X=A1(A,z,U,W);return Y2(w,U,X)}for(let A of w.anyOf){let X=A1(A,z,U,W);if(!r(w,z,X))continue;return Y2(w,U,X)}return Y2(w,U,W)}function A1(w,z,U,W){let A=e0(w,z),X=w;switch(w[N]){case"Array":return EJ(X,A,U,W);case"Import":return IJ(X,A,U,W);case"Intersect":return xJ(X,A,U,W);case"Not":return VJ(X,A,U,W);case"Object":return kJ(X,A,U,W);case"Record":return TJ(X,A,U,W);case"Ref":return gJ(X,A,U,W);case"This":return fJ(X,A,U,W);case"Tuple":return dJ(X,A,U,W);case"Union":return hJ(X,A,U,W);default:return Y2(X,U,W)}}function s6(w,z,U){return A1(w,z,"",U)}function yJ(w,z){return S0(w)||U2(w.items,z)}function cJ(w,z){return S0(w)||U2(w.items,z)}function iJ(w,z){return S0(w)||U2(w.returns,z)||w.parameters.some((U)=>U2(U,z))}function vJ(w,z){return S0(w)||U2(w.returns,z)||w.parameters.some((U)=>U2(U,z))}function nJ(w,z){return S0(w)||S0(w.unevaluatedProperties)||w.allOf.some((U)=>U2(U,z))}function uJ(w,z){return S0(w)||U2(w.items,z)}function mJ(w,z){return S0(w)||U2(w.not,z)}function tJ(w,z){return S0(w)||Object.values(w.properties).some((U)=>U2(U,z))||d0(w.additionalProperties)&&U2(w.additionalProperties,z)}function pJ(w,z){return S0(w)||U2(w.item,z)}function oJ(w,z){let U=Object.getOwnPropertyNames(w.patternProperties)[0],W=w.patternProperties[U];return S0(w)||U2(W,z)||d0(w.additionalProperties)&&S0(w.additionalProperties)}function lJ(w,z){if(S0(w))return!0;return U2(J0(w,z),z)}function sJ(w,z){if(S0(w))return!0;return U2(J0(w,z),z)}function rJ(w,z){return S0(w)||!T0(w.items)&&w.items.some((U)=>U2(U,z))}function aJ(w,z){return S0(w)||w.anyOf.some((U)=>U2(U,z))}function U2(w,z){let U=e0(w,z),W=w;if(w.$id&&qw.has(w.$id))return!1;if(w.$id)qw.add(w.$id);switch(w[N]){case"Array":return yJ(W,U);case"AsyncIterator":return cJ(W,U);case"Constructor":return iJ(W,U);case"Function":return vJ(W,U);case"Intersect":return nJ(W,U);case"Iterator":return uJ(W,U);case"Not":return mJ(W,U);case"Object":return tJ(W,U);case"Promise":return pJ(W,U);case"Record":return oJ(W,U);case"Ref":return lJ(W,U);case"This":return sJ(W,U);case"Tuple":return rJ(W,U);case"Union":return aJ(W,U);default:return S0(w)}}var qw=new Set;function h1(w,z){return qw.clear(),U2(w,z)}class T7{constructor(w,z,U,W){this.schema=w,this.references=z,this.checkFunc=U,this.code=W,this.hasTransform=h1(w,z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(w){return _1(this.schema,this.references,w)}Check(w){return this.checkFunc(w)}Decode(w){if(!this.checkFunc(w))throw new C4(this.schema,w,this.Errors(w).First());return this.hasTransform?l6(this.schema,this.references,w):w}Encode(w){let z=this.hasTransform?s6(this.schema,this.references,w):w;if(!this.checkFunc(z))throw new K4(this.schema,w,this.Errors(w).First());return z}}var y1;(function(w){function z(X){return X===36}w.DollarSign=z;function U(X){return X===95}w.IsUnderscore=U;function W(X){return X>=65&&X<=90||X>=97&&X<=122}w.IsAlpha=W;function A(X){return X>=48&&X<=57}w.IsNumeric=A})(y1||(y1={}));var N8;(function(w){function z(X){if(X.length===0)return!1;return y1.IsNumeric(X.charCodeAt(0))}function U(X){if(z(X))return!1;for(let Z=0;Z<X.length;Z++){let $=X.charCodeAt(Z);if(!(y1.IsAlpha($)||y1.IsNumeric($)||y1.DollarSign($)||y1.IsUnderscore($)))return!1}return!0}function W(X){return X.replace(/'/g,"\\'")}function A(X,Z){return U(Z)?`${X}.${Z}`:`${X}['${W(Z)}']`}w.Encode=A})(N8||(N8={}));var Hw;(function(w){function z(U){let W=[];for(let A=0;A<U.length;A++){let X=U.charCodeAt(A);if(y1.IsNumeric(X)||y1.IsAlpha(X))W.push(U.charAt(A));else W.push(`_${X}_`)}return W.join("").replace(/__/g,"_")}w.Encode=z})(Hw||(Hw={}));var Gw;(function(w){function z(U){return U.replace(/'/g,"\\'")}w.Escape=z})(Gw||(Gw={}));class g7 extends y{constructor(w){super("Unknown type");this.schema=w}}class Lw extends y{constructor(w){super("Preflight validation check failed to guard for the given schema");this.schema=w}}var _6;(function(w){function z(Z,$,Q){return V0.ExactOptionalPropertyTypes?`('${$}' in ${Z} ? ${Q} : true)`:`(${N8.Encode(Z,$)} !== undefined ? ${Q} : true)`}w.IsExactOptionalProperty=z;function U(Z){return!V0.AllowArrayObject?`(typeof ${Z} === 'object' && ${Z} !== null && !Array.isArray(${Z}))`:`(typeof ${Z} === 'object' && ${Z} !== null)`}w.IsObjectLike=U;function W(Z){return!V0.AllowArrayObject?`(typeof ${Z} === 'object' && ${Z} !== null && !Array.isArray(${Z}) && !(${Z} instanceof Date) && !(${Z} instanceof Uint8Array))`:`(typeof ${Z} === 'object' && ${Z} !== null && !(${Z} instanceof Date) && !(${Z} instanceof Uint8Array))`}w.IsRecordLike=W;function A(Z){return V0.AllowNaN?`typeof ${Z} === 'number'`:`Number.isFinite(${Z})`}w.IsNumberLike=A;function X(Z){return V0.AllowNullVoid?`(${Z} === undefined || ${Z} === null)`:`${Z} === undefined`}w.IsVoidLike=X})(_6||(_6={}));var w6;(function(w){function z(M){return M[N]==="Any"||M[N]==="Unknown"}function*U(M,C,L){yield"true"}function*W(M,C,L){yield`Array.isArray(${L})`;let[u,V]=[b("value","any"),b("acc","number")];if(d(M.maxItems))yield`${L}.length <= ${M.maxItems}`;if(d(M.minItems))yield`${L}.length >= ${M.minItems}`;let k=q2(M.items,C,"value");if(yield`${L}.every((${u}) => ${k})`,f0(M.contains)||d(M.minContains)||d(M.maxContains)){let x0=f0(M.contains)?M.contains:H0(),N2=q2(x0,C,"value"),b1=d(M.minContains)?[`(count >= ${M.minContains})`]:[],e2=d(M.maxContains)?[`(count <= ${M.maxContains})`]:[],H1=`const count = value.reduce((${V}, ${u}) => ${N2} ? acc + 1 : acc, 0)`,v4=["(count > 0)",...b1,...e2].join(" && ");yield`((${u}) => { ${H1}; return ${v4}})(${L})`}if(M.uniqueItems===!0)yield`((${u}) => { 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 } )(${L})`}function*A(M,C,L){yield`(typeof value === 'object' && Symbol.asyncIterator in ${L})`}function*X(M,C,L){if(yield`(typeof ${L} === 'bigint')`,A2(M.exclusiveMaximum))yield`${L} < BigInt(${M.exclusiveMaximum})`;if(A2(M.exclusiveMinimum))yield`${L} > BigInt(${M.exclusiveMinimum})`;if(A2(M.maximum))yield`${L} <= BigInt(${M.maximum})`;if(A2(M.minimum))yield`${L} >= BigInt(${M.minimum})`;if(A2(M.multipleOf))yield`(${L} % BigInt(${M.multipleOf})) === 0`}function*Z(M,C,L){yield`(typeof ${L} === 'boolean')`}function*$(M,C,L){yield*o0(M.returns,C,`${L}.prototype`)}function*Q(M,C,L){if(yield`(${L} instanceof Date) && Number.isFinite(${L}.getTime())`,d(M.exclusiveMaximumTimestamp))yield`${L}.getTime() < ${M.exclusiveMaximumTimestamp}`;if(d(M.exclusiveMinimumTimestamp))yield`${L}.getTime() > ${M.exclusiveMinimumTimestamp}`;if(d(M.maximumTimestamp))yield`${L}.getTime() <= ${M.maximumTimestamp}`;if(d(M.minimumTimestamp))yield`${L}.getTime() >= ${M.minimumTimestamp}`;if(d(M.multipleOfTimestamp))yield`(${L}.getTime() % ${M.multipleOfTimestamp}) === 0`}function*Y(M,C,L){yield`(typeof ${L} === 'function')`}function*B(M,C,L){let u=globalThis.Object.getOwnPropertyNames(M.$defs).reduce((V,k)=>{return[...V,M.$defs[k]]},[]);yield*o0(P2(M.$ref),[...C,...u],L)}function*G(M,C,L){if(yield`Number.isInteger(${L})`,d(M.exclusiveMaximum))yield`${L} < ${M.exclusiveMaximum}`;if(d(M.exclusiveMinimum))yield`${L} > ${M.exclusiveMinimum}`;if(d(M.maximum))yield`${L} <= ${M.maximum}`;if(d(M.minimum))yield`${L} >= ${M.minimum}`;if(d(M.multipleOf))yield`(${L} % ${M.multipleOf}) === 0`}function*_(M,C,L){let u=M.allOf.map((V)=>q2(V,C,L)).join(" && ");if(M.unevaluatedProperties===!1){let V=j(`${new RegExp(k1(M))};`),k=`Object.getOwnPropertyNames(${L}).every(key => ${V}.test(key))`;yield`(${u} && ${k})`}else if(f0(M.unevaluatedProperties)){let V=j(`${new RegExp(k1(M))};`),k=`Object.getOwnPropertyNames(${L}).every(key => ${V}.test(key) || ${q2(M.unevaluatedProperties,C,`${L}[key]`)})`;yield`(${u} && ${k})`}else yield`(${u})`}function*H(M,C,L){yield`(typeof value === 'object' && Symbol.iterator in ${L})`}function*F(M,C,L){if(typeof M.const==="number"||typeof M.const==="boolean")yield`(${L} === ${M.const})`;else yield`(${L} === '${Gw.Escape(M.const)}')`}function*R(M,C,L){yield"false"}function*J(M,C,L){yield`(!${q2(M.not,C,L)})`}function*m(M,C,L){yield`(${L} === null)`}function*A0(M,C,L){if(yield _6.IsNumberLike(L),d(M.exclusiveMaximum))yield`${L} < ${M.exclusiveMaximum}`;if(d(M.exclusiveMinimum))yield`${L} > ${M.exclusiveMinimum}`;if(d(M.maximum))yield`${L} <= ${M.maximum}`;if(d(M.minimum))yield`${L} >= ${M.minimum}`;if(d(M.multipleOf))yield`(${L} % ${M.multipleOf}) === 0`}function*L0(M,C,L){if(yield _6.IsObjectLike(L),d(M.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${M.minProperties}`;if(d(M.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${M.maxProperties}`;let u=Object.getOwnPropertyNames(M.properties);for(let V of u){let k=N8.Encode(L,V),x0=M.properties[V];if(M.required&&M.required.includes(V)){if(yield*o0(x0,C,k),g1(x0)||z(x0))yield`('${V}' in ${L})`}else{let N2=q2(x0,C,k);yield _6.IsExactOptionalProperty(L,V,N2)}}if(M.additionalProperties===!1)if(M.required&&M.required.length===u.length)yield`Object.getOwnPropertyNames(${L}).length === ${u.length}`;else{let V=`[${u.map((k)=>`'${k}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${L}).every(key => ${V}.includes(key))`}if(typeof M.additionalProperties==="object"){let V=q2(M.additionalProperties,C,`${L}[key]`),k=`[${u.map((x0)=>`'${x0}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${L}).every(key => ${k}.includes(key) || ${V}))`}}function*h(M,C,L){yield`(typeof value === 'object' && typeof ${L}.then === 'function')`}function*a(M,C,L){if(yield _6.IsRecordLike(L),d(M.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${M.minProperties}`;if(d(M.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${M.maxProperties}`;let[u,V]=Object.entries(M.patternProperties)[0],k=j(`${new RegExp(u)}`),x0=q2(V,C,"value"),N2=f0(M.additionalProperties)?q2(M.additionalProperties,C,L):M.additionalProperties===!1?"false":"true",b1=`(${k}.test(key) ? ${x0} : ${N2})`;yield`(Object.entries(${L}).every(([key, value]) => ${b1}))`}function*x(M,C,L){let u=J0(M,C);if(l0.functions.has(M.$ref))return yield`${x2(M.$ref)}(${L})`;yield*o0(u,C,L)}function*i(M,C,L){let u=j(`${new RegExp(M.source,M.flags)};`);if(yield`(typeof ${L} === 'string')`,d(M.maxLength))yield`${L}.length <= ${M.maxLength}`;if(d(M.minLength))yield`${L}.length >= ${M.minLength}`;yield`${u}.test(${L})`}function*K(M,C,L){if(yield`(typeof ${L} === 'string')`,d(M.maxLength))yield`${L}.length <= ${M.maxLength}`;if(d(M.minLength))yield`${L}.length >= ${M.minLength}`;if(M.pattern!==void 0)yield`${j(`${new RegExp(M.pattern)};`)}.test(${L})`;if(M.format!==void 0)yield`format('${M.format}', ${L})`}function*o(M,C,L){yield`(typeof ${L} === 'symbol')`}function*D0(M,C,L){yield`(typeof ${L} === 'string')`,yield`${j(`${new RegExp(M.pattern)};`)}.test(${L})`}function*l(M,C,L){yield`${x2(M.$ref)}(${L})`}function*O1(M,C,L){if(yield`Array.isArray(${L})`,M.items===void 0)return yield`${L}.length === 0`;yield`(${L}.length === ${M.maxItems})`;for(let u=0;u<M.items.length;u++)yield`${q2(M.items[u],C,`${L}[${u}]`)}`}function*C0(M,C,L){yield`${L} === undefined`}function*n1(M,C,L){yield`(${M.anyOf.map((V)=>q2(V,C,L)).join(" || ")})`}function*I2(M,C,L){if(yield`${L} instanceof Uint8Array`,d(M.maxByteLength))yield`(${L}.length <= ${M.maxByteLength})`;if(d(M.minByteLength))yield`(${L}.length >= ${M.minByteLength})`}function*Y6(M,C,L){yield"true"}function*g5(M,C,L){yield _6.IsVoidLike(L)}function*K6(M,C,L){let u=l0.instances.size;l0.instances.set(u,M),yield`kind('${M[N]}', ${u}, ${L})`}function*o0(M,C,L,u=!0){let V=$0(M.$id)?[...C,M]:C,k=M;if(u&&$0(M.$id)){let x0=x2(M.$id);if(l0.functions.has(x0))return yield`${x0}(${L})`;else{l0.functions.set(x0,"<deferred>");let N2=O(x0,M,C,"value",!1);return l0.functions.set(x0,N2),yield`${x0}(${L})`}}switch(k[N]){case"Any":return yield*U(k,V,L);case"Array":return yield*W(k,V,L);case"AsyncIterator":return yield*A(k,V,L);case"BigInt":return yield*X(k,V,L);case"Boolean":return yield*Z(k,V,L);case"Constructor":return yield*$(k,V,L);case"Date":return yield*Q(k,V,L);case"Function":return yield*Y(k,V,L);case"Import":return yield*B(k,V,L);case"Integer":return yield*G(k,V,L);case"Intersect":return yield*_(k,V,L);case"Iterator":return yield*H(k,V,L);case"Literal":return yield*F(k,V,L);case"Never":return yield*R(k,V,L);case"Not":return yield*J(k,V,L);case"Null":return yield*m(k,V,L);case"Number":return yield*A0(k,V,L);case"Object":return yield*L0(k,V,L);case"Promise":return yield*h(k,V,L);case"Record":return yield*a(k,V,L);case"Ref":return yield*x(k,V,L);case"RegExp":return yield*i(k,V,L);case"String":return yield*K(k,V,L);case"Symbol":return yield*o(k,V,L);case"TemplateLiteral":return yield*D0(k,V,L);case"This":return yield*l(k,V,L);case"Tuple":return yield*O1(k,V,L);case"Undefined":return yield*C0(k,V,L);case"Union":return yield*n1(k,V,L);case"Uint8Array":return yield*I2(k,V,L);case"Unknown":return yield*Y6(k,V,L);case"Void":return yield*g5(k,V,L);default:if(!y0.Has(k[N]))throw new g7(M);return yield*K6(k,V,L)}}let l0={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function q2(M,C,L,u=!0){return`(${[...o0(M,C,L,u)].join(" && ")})`}function x2(M){return`check_${Hw.Encode(M)}`}function j(M){let C=`local_${l0.variables.size}`;return l0.variables.set(C,`const ${C} = ${M}`),C}function O(M,C,L,u,V=!0){let[k,x0]=[`
3
- `,(H1)=>"".padStart(H1," ")],N2=b("value","any"),b1=T("boolean"),e2=[...o0(C,L,u,V)].map((H1)=>`${x0(4)}${H1}`).join(` &&${k}`);return`function ${M}(${N2})${b1} {${k}${x0(2)}return (${k}${e2}${k}${x0(2)})
4
- }`}function b(M,C){let L=l0.language==="typescript"?`: ${C}`:"";return`${M}${L}`}function T(M){return l0.language==="typescript"?`: ${M}`:""}function t(M,C,L){let u=O("check",M,C,"value"),V=b("value","any"),k=T("boolean"),x0=[...l0.functions.values()],N2=[...l0.variables.values()],b1=$0(M.$id)?`return function check(${V})${k} {
5
- return ${x2(M.$id)}(value)
6
- }`:`return ${u}`;return[...N2,...x0,b1].join(`
7
- `)}function e(...M){let C={language:"javascript"},[L,u,V]=M.length===2&&n(M[1])?[M[0],M[1],C]:M.length===2&&!n(M[1])?[M[0],[],M[1]]:M.length===3?[M[0],M[1],M[2]]:M.length===1?[M[0],[],C]:[null,[],C];if(l0.language=V.language,l0.variables.clear(),l0.functions.clear(),l0.instances.clear(),!f0(L))throw new Lw(L);for(let k of u)if(!f0(k))throw new Lw(k);return t(L,u,V)}w.Code=e;function K0(M,C=[]){let L=e(M,C,{language:"javascript"}),u=globalThis.Function("kind","format","hash",L),V=new Map(l0.instances);function k(e2,H1,v4){if(!y0.Has(e2)||!V.has(H1))return!1;let XA=y0.Get(e2),ZA=V.get(H1);return XA(ZA,v4)}function x0(e2,H1){if(!b0.Has(e2))return!1;return b0.Get(e2)(H1)}function N2(e2){return e1(e2)}let b1=u(k,x0,N2);return new T7(M,C,b1,L)}w.Compile=K0})(w6||(w6={}));var eJ=function(w,z,U,W,A){if(W==="m")throw new TypeError("Private method is not writable");if(W==="a"&&!A)throw new TypeError("Private accessor was defined without a setter");if(typeof z==="function"?w!==z||!A:!z.has(w))throw new TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?A.call(w,U):A?A.value=U:z.set(w,U),U},d7=function(w,z,U,W){if(U==="a"&&!W)throw new TypeError("Private accessor was defined without a getter");if(typeof z==="function"?w!==z||!W:!z.has(w))throw new TypeError("Cannot read private member from an object whose class did not declare it");return U==="m"?W:U==="a"?W.call(w):W?W.value:z.get(w)},Nw,S8,h7;class y7 extends y{constructor(w){let z=w.First();super(z===void 0?"Invalid Value":z.message);Nw.add(this),S8.set(this,void 0),eJ(this,S8,w,"f"),this.error=z}Errors(){return new S6(d7(this,Nw,"m",h7).call(this))}}S8=new WeakMap,Nw=new WeakSet,h7=function*w(){if(this.error)yield this.error;yield*d7(this,S8,"f")};function f7(w,z,U){if(r(w,z,U))return;throw new y7(_1(w,z,U))}function _8(...w){return w.length===3?f7(w[0],w[1],w[2]):f7(w[0],[],w[1])}function wB(w){let z={};for(let U of Object.getOwnPropertyNames(w))z[U]=B0(w[U]);for(let U of Object.getOwnPropertySymbols(w))z[U]=B0(w[U]);return z}function zB(w){return w.map((z)=>B0(z))}function UB(w){return w.slice()}function WB(w){return new Map(B0([...w.entries()]))}function AB(w){return new Set(B0([...w.entries()]))}function XB(w){return new Date(w.toISOString())}function ZB(w){return w}function B0(w){if(n(w))return zB(w);if(G2(w))return XB(w);if(d2(w))return UB(w);if(Uz(w))return WB(w);if(Wz(w))return AB(w);if(s(w))return wB(w);if(V2(w))return ZB(w);throw new Error("ValueClone: Unable to clone value")}class p2 extends y{constructor(w,z){super(z);this.schema=w}}function M0(w){return m1(w)?w():B0(w)}function $B(w,z){if(v(w,"default"))return M0(w.default);else return{}}function QB(w,z){if(w.uniqueItems===!0&&!v(w,"default"))throw new p2(w,"Array with the uniqueItems constraint requires a default value");else if("contains"in w&&!v(w,"default"))throw new p2(w,"Array with the contains constraint requires a default value");else if("default"in w)return M0(w.default);else if(w.minItems!==void 0)return Array.from({length:w.minItems}).map((U)=>{return R2(w.items,z)});else return[]}function YB(w,z){if(v(w,"default"))return M0(w.default);else return async function*(){}()}function JB(w,z){if(v(w,"default"))return M0(w.default);else return BigInt(0)}function BB(w,z){if(v(w,"default"))return M0(w.default);else return!1}function MB(w,z){if(v(w,"default"))return M0(w.default);else{let U=R2(w.returns,z);if(typeof U==="object"&&!Array.isArray(U))return class{constructor(){for(let[W,A]of Object.entries(U)){let X=this;X[W]=A}}};else return class{}}}function qB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minimumTimestamp!==void 0)return new Date(w.minimumTimestamp);else return new Date}function HB(w,z){if(v(w,"default"))return M0(w.default);else return()=>R2(w.returns,z)}function GB(w,z){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return R2(W,[...z,...U])}function LB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function NB(w,z){if(v(w,"default"))return M0(w.default);else{let U=w.allOf.reduce((W,A)=>{let X=R2(A,z);return typeof X==="object"?{...W,...X}:X},{});if(!r(w,z,U))throw new p2(w,"Intersect produced invalid value. Consider using a default value.");return U}}function SB(w,z){if(v(w,"default"))return M0(w.default);else return function*(){}()}function _B(w,z){if(v(w,"default"))return M0(w.default);else return w.const}function DB(w,z){if(v(w,"default"))return M0(w.default);else throw new p2(w,"Never types cannot be created. Consider using a default value.")}function PB(w,z){if(v(w,"default"))return M0(w.default);else throw new p2(w,"Not types must have a default value")}function OB(w,z){if(v(w,"default"))return M0(w.default);else return null}function bB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function RB(w,z){if(v(w,"default"))return M0(w.default);else{let U=new Set(w.required),W={};for(let[A,X]of Object.entries(w.properties)){if(!U.has(A))continue;W[A]=R2(X,z)}return W}}function CB(w,z){if(v(w,"default"))return M0(w.default);else return Promise.resolve(R2(w.item,z))}function KB(w,z){let[U,W]=Object.entries(w.patternProperties)[0];if(v(w,"default"))return M0(w.default);else if(!(U===x1||U===I1)){let A=U.slice(1,U.length-1).split("|"),X={};for(let Z of A)X[Z]=R2(W,z);return X}else return{}}function FB(w,z){if(v(w,"default"))return M0(w.default);else return R2(J0(w,z),z)}function jB(w,z){if(v(w,"default"))return M0(w.default);else throw new p2(w,"RegExp types cannot be created. Consider using a default value.")}function EB(w,z){if(w.pattern!==void 0)if(!v(w,"default"))throw new p2(w,"String types with patterns must specify a default value");else return M0(w.default);else if(w.format!==void 0)if(!v(w,"default"))throw new p2(w,"String types with formats must specify a default value");else return M0(w.default);else if(v(w,"default"))return M0(w.default);else if(w.minLength!==void 0)return Array.from({length:w.minLength}).map(()=>" ").join("");else return""}function IB(w,z){if(v(w,"default"))return M0(w.default);else if("value"in w)return Symbol.for(w.value);else return Symbol()}function xB(w,z){if(v(w,"default"))return M0(w.default);if(!w8(w))throw new p2(w,"Can only create template literals that produce a finite variants. Consider using a default value.");return f6(w)[0]}function VB(w,z){if(c7++>cB)throw new p2(w,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(v(w,"default"))return M0(w.default);else return R2(J0(w,z),z)}function kB(w,z){if(v(w,"default"))return M0(w.default);if(w.items===void 0)return[];else return Array.from({length:w.minItems}).map((U,W)=>R2(w.items[W],z))}function TB(w,z){if(v(w,"default"))return M0(w.default);else return}function gB(w,z){if(v(w,"default"))return M0(w.default);else if(w.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return R2(w.anyOf[0],z)}function fB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minByteLength!==void 0)return new Uint8Array(w.minByteLength);else return new Uint8Array(0)}function dB(w,z){if(v(w,"default"))return M0(w.default);else return{}}function hB(w,z){if(v(w,"default"))return M0(w.default);else return}function yB(w,z){if(v(w,"default"))return M0(w.default);else throw new Error("User defined types must specify a default value")}function R2(w,z){let U=e0(w,z),W=w;switch(W[N]){case"Any":return $B(W,U);case"Array":return QB(W,U);case"AsyncIterator":return YB(W,U);case"BigInt":return JB(W,U);case"Boolean":return BB(W,U);case"Constructor":return MB(W,U);case"Date":return qB(W,U);case"Function":return HB(W,U);case"Import":return GB(W,U);case"Integer":return LB(W,U);case"Intersect":return NB(W,U);case"Iterator":return SB(W,U);case"Literal":return _B(W,U);case"Never":return DB(W,U);case"Not":return PB(W,U);case"Null":return OB(W,U);case"Number":return bB(W,U);case"Object":return RB(W,U);case"Promise":return CB(W,U);case"Record":return KB(W,U);case"Ref":return FB(W,U);case"RegExp":return jB(W,U);case"String":return EB(W,U);case"Symbol":return IB(W,U);case"TemplateLiteral":return xB(W,U);case"This":return VB(W,U);case"Tuple":return kB(W,U);case"Undefined":return TB(W,U);case"Union":return gB(W,U);case"Uint8Array":return fB(W,U);case"Unknown":return dB(W,U);case"Void":return hB(W,U);default:if(!y0.Has(W[N]))throw new p2(W,"Unknown type");return yB(W,U)}}var cB=512,c7=0;function o2(...w){return c7=0,w.length===2?R2(w[0],w[1]):R2(w[0],[])}class Sw extends y{constructor(w,z){super(z);this.schema=w}}function iB(w,z,U){if(w[N]==="Object"&&typeof U==="object"&&!K1(U)){let W=w,A=Object.getOwnPropertyNames(U),X=Object.entries(W.properties),[Z,$]=[1/X.length,X.length];return X.reduce((Q,[Y,B])=>{let G=B[N]==="Literal"&&B.const===U[Y]?$:0,_=r(B,z,U[Y])?Z:0,H=A.includes(Y)?Z:0;return Q+(G+_+H)},0)}else return r(w,z,U)?1:0}function vB(w,z,U){let W=w.anyOf.map((Z)=>J0(Z,z)),[A,X]=[W[0],0];for(let Z of W){let $=iB(Z,z,U);if($>X)A=Z,X=$}return A}function nB(w,z,U){if("default"in w)return typeof U==="function"?w.default:B0(w.default);else{let W=vB(w,z,U);return _w(W,z,U)}}function uB(w,z,U){return r(w,z,U)?B0(U):o2(w,z)}function mB(w,z,U){return r(w,z,U)?U:o2(w,z)}function tB(w,z,U){if(r(w,z,U))return B0(U);let W=n(U)?B0(U):o2(w,z),A=d(w.minItems)&&W.length<w.minItems?[...W,...Array.from({length:w.minItems-W.length},()=>null)]:W,Z=(d(w.maxItems)&&A.length>w.maxItems?A.slice(0,w.maxItems):A).map((Q)=>X1(w.items,z,Q));if(w.uniqueItems!==!0)return Z;let $=[...new Set(Z)];if(!r(w,z,$))throw new Sw(w,"Array cast produced invalid data due to uniqueItems constraint");return $}function pB(w,z,U){if(r(w,z,U))return o2(w,z);let W=new Set(w.returns.required||[]),A=function(){};for(let[X,Z]of Object.entries(w.returns.properties)){if(!W.has(X)&&U.prototype[X]===void 0)continue;A.prototype[X]=X1(Z,z,U.prototype[X])}return A}function oB(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return X1(A,[...z,...W],U)}function lB(w,z,U){let W=o2(w,z),A=s(W)&&s(U)?{...W,...U}:U;return r(w,z,A)?A:o2(w,z)}function sB(w,z,U){throw new Sw(w,"Never types cannot be cast")}function rB(w,z,U){if(r(w,z,U))return U;if(U===null||typeof U!=="object")return o2(w,z);let W=new Set(w.required||[]),A={};for(let[X,Z]of Object.entries(w.properties)){if(!W.has(X)&&U[X]===void 0)continue;A[X]=X1(Z,z,U[X])}if(typeof w.additionalProperties==="object"){let X=Object.getOwnPropertyNames(w.properties);for(let Z of Object.getOwnPropertyNames(U)){if(X.includes(Z))continue;A[Z]=X1(w.additionalProperties,z,U[Z])}}return A}function aB(w,z,U){if(r(w,z,U))return B0(U);if(U===null||typeof U!=="object"||Array.isArray(U)||U instanceof Date)return o2(w,z);let W=Object.getOwnPropertyNames(w.patternProperties)[0],A=w.patternProperties[W],X={};for(let[Z,$]of Object.entries(U))X[Z]=X1(A,z,$);return X}function eB(w,z,U){return X1(J0(w,z),z,U)}function wM(w,z,U){return X1(J0(w,z),z,U)}function zM(w,z,U){if(r(w,z,U))return B0(U);if(!n(U))return o2(w,z);if(w.items===void 0)return[];return w.items.map((W,A)=>X1(W,z,U[A]))}function UM(w,z,U){return r(w,z,U)?B0(U):nB(w,z,U)}function X1(w,z,U){let W=$0(w.$id)?e0(w,z):z,A=w;switch(w[N]){case"Array":return tB(A,W,U);case"Constructor":return pB(A,W,U);case"Import":return oB(A,W,U);case"Intersect":return lB(A,W,U);case"Never":return sB(A,W,U);case"Object":return rB(A,W,U);case"Record":return aB(A,W,U);case"Ref":return eB(A,W,U);case"This":return wM(A,W,U);case"Tuple":return zM(A,W,U);case"Union":return UM(A,W,U);case"Date":case"Symbol":case"Uint8Array":return uB(w,z,U);default:return mB(A,W,U)}}function _w(...w){return w.length===3?X1(w[0],w[1],w[2]):X1(w[0],[],w[1])}function WM(w){return p1(w)&&w[N]!=="Unsafe"}function AM(w,z,U){if(!n(U))return U;return U.map((W)=>C2(w.items,z,W))}function XM(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return C2(A,[...z,...W],U)}function ZM(w,z,U){let W=w.unevaluatedProperties,X=w.allOf.map(($)=>C2($,z,B0(U))).reduce(($,Q)=>s(Q)?{...$,...Q}:Q,{});if(!s(U)||!s(X)||!p1(W))return X;let Z=O2(w);for(let $ of Object.getOwnPropertyNames(U)){if(Z.includes($))continue;if(r(W,z,U[$]))X[$]=C2(W,z,U[$])}return X}function $M(w,z,U){if(!s(U)||n(U))return U;let W=w.additionalProperties;for(let A of Object.getOwnPropertyNames(U)){if(v(w.properties,A)){U[A]=C2(w.properties[A],z,U[A]);continue}if(p1(W)&&r(W,z,U[A])){U[A]=C2(W,z,U[A]);continue}delete U[A]}return U}function QM(w,z,U){if(!s(U))return U;let W=w.additionalProperties,A=Object.getOwnPropertyNames(U),[X,Z]=Object.entries(w.patternProperties)[0],$=new RegExp(X);for(let Q of A){if($.test(Q)){U[Q]=C2(Z,z,U[Q]);continue}if(p1(W)&&r(W,z,U[Q])){U[Q]=C2(W,z,U[Q]);continue}delete U[Q]}return U}function YM(w,z,U){return C2(J0(w,z),z,U)}function JM(w,z,U){return C2(J0(w,z),z,U)}function BM(w,z,U){if(!n(U))return U;if(T0(w.items))return[];let W=Math.min(U.length,w.items.length);for(let A=0;A<W;A++)U[A]=C2(w.items[A],z,U[A]);return U.length>W?U.slice(0,W):U}function MM(w,z,U){for(let W of w.anyOf)if(WM(W)&&r(W,z,U))return C2(W,z,U);return U}function C2(w,z,U){let W=$0(w.$id)?e0(w,z):z,A=w;switch(A[N]){case"Array":return AM(A,W,U);case"Import":return XM(A,W,U);case"Intersect":return ZM(A,W,U);case"Object":return $M(A,W,U);case"Record":return QM(A,W,U);case"Ref":return YM(A,W,U);case"This":return JM(A,W,U);case"Tuple":return BM(A,W,U);case"Union":return MM(A,W,U);default:return U}}function D8(...w){return w.length===3?C2(w[0],w[1],w[2]):C2(w[0],[],w[1])}function P8(w){return $0(w)&&!isNaN(w)&&!isNaN(parseFloat(w))}function qM(w){return A2(w)||G1(w)||d(w)}function F4(w){return w===!0||d(w)&&w===1||A2(w)&&w===BigInt("1")||$0(w)&&(w.toLowerCase()==="true"||w==="1")}function j4(w){return w===!1||d(w)&&(w===0||Object.is(w,-0))||A2(w)&&w===BigInt("0")||$0(w)&&(w.toLowerCase()==="false"||w==="0"||w==="-0")}function HM(w){return $0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(w)}function GM(w){return $0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(w)}function LM(w){return $0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(w)}function NM(w){return $0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(w)}function SM(w){return $0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(w)}function _M(w,z){let U=v7(w);return U===z?U:w}function DM(w,z){let U=n7(w);return U===z?U:w}function PM(w,z){let U=i7(w);return U===z?U:w}function OM(w,z){return $0(w.const)?_M(z,w.const):d(w.const)?DM(z,w.const):G1(w.const)?PM(z,w.const):z}function i7(w){return F4(w)?!0:j4(w)?!1:w}function bM(w){let z=(U)=>U.split(".")[0];return P8(w)?BigInt(z(w)):d(w)?BigInt(Math.trunc(w)):j4(w)?BigInt(0):F4(w)?BigInt(1):w}function v7(w){return F1(w)&&w.description!==void 0?w.description.toString():qM(w)?w.toString():w}function n7(w){return P8(w)?parseFloat(w):F4(w)?1:j4(w)?0:w}function RM(w){return P8(w)?parseInt(w):d(w)?w|0:F4(w)?1:j4(w)?0:w}function CM(w){return $0(w)&&w.toLowerCase()==="null"?null:w}function KM(w){return $0(w)&&w==="undefined"?void 0:w}function FM(w){return G2(w)?w:d(w)?new Date(w):F4(w)?new Date(1):j4(w)?new Date(0):P8(w)?new Date(parseInt(w)):GM(w)?new Date(`1970-01-01T${w}.000Z`):HM(w)?new Date(`1970-01-01T${w}`):NM(w)?new Date(`${w}.000Z`):LM(w)?new Date(w):SM(w)?new Date(`${w}T00:00:00.000Z`):w}function jM(w){return w}function EM(w,z,U){return(n(U)?U:[U]).map((A)=>Z1(w.items,z,A))}function IM(w,z,U){return bM(U)}function xM(w,z,U){return i7(U)}function VM(w,z,U){return FM(U)}function kM(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return Z1(A,[...z,...W],U)}function TM(w,z,U){return RM(U)}function gM(w,z,U){return w.allOf.reduce((W,A)=>Z1(A,z,W),U)}function fM(w,z,U){return OM(w,U)}function dM(w,z,U){return CM(U)}function hM(w,z,U){return n7(U)}function yM(w,z,U){if(!s(U))return U;for(let W of Object.getOwnPropertyNames(w.properties)){if(!v(U,W))continue;U[W]=Z1(w.properties[W],z,U[W])}return U}function cM(w,z,U){if(!s(U))return U;let A=Object.getOwnPropertyNames(w.patternProperties)[0],X=w.patternProperties[A];for(let[Z,$]of Object.entries(U))U[Z]=Z1(X,z,$);return U}function iM(w,z,U){return Z1(J0(w,z),z,U)}function vM(w,z,U){return v7(U)}function nM(w,z,U){return $0(U)||d(U)?Symbol(U):U}function uM(w,z,U){return Z1(J0(w,z),z,U)}function mM(w,z,U){if(!(n(U)&&!T0(w.items)))return U;return U.map((A,X)=>{return X<w.items.length?Z1(w.items[X],z,A):A})}function tM(w,z,U){return KM(U)}function pM(w,z,U){for(let W of w.anyOf){let A=Z1(W,z,B0(U));if(!r(W,z,A))continue;return A}return U}function Z1(w,z,U){let W=e0(w,z),A=w;switch(w[N]){case"Array":return EM(A,W,U);case"BigInt":return IM(A,W,U);case"Boolean":return xM(A,W,U);case"Date":return VM(A,W,U);case"Import":return kM(A,W,U);case"Integer":return TM(A,W,U);case"Intersect":return gM(A,W,U);case"Literal":return fM(A,W,U);case"Null":return dM(A,W,U);case"Number":return hM(A,W,U);case"Object":return yM(A,W,U);case"Record":return cM(A,W,U);case"Ref":return iM(A,W,U);case"String":return vM(A,W,U);case"Symbol":return nM(A,W,U);case"This":return uM(A,W,U);case"Tuple":return mM(A,W,U);case"Undefined":return tM(A,W,U);case"Union":return pM(A,W,U);default:return jM(U)}}function O8(...w){return w.length===3?Z1(w[0],w[1],w[2]):Z1(w[0],[],w[1])}function u7(...w){let[z,U,W]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]];if(!r(z,U,W))throw new C4(z,W,_1(z,U,W).First());return h1(z,U)?l6(z,U,W):W}function c1(w,z){let U=v(w,"default")?w.default:void 0,W=m1(U)?U():B0(U);return T0(z)?W:s(z)&&s(W)?Object.assign(W,z):z}function Dw(w){return p1(w)&&"default"in w}function oM(w,z,U){if(n(U)){for(let A=0;A<U.length;A++)U[A]=L2(w.items,z,U[A]);return U}let W=c1(w,U);if(!n(W))return W;for(let A=0;A<W.length;A++)W[A]=L2(w.items,z,W[A]);return W}function lM(w,z,U){return G2(U)?U:c1(w,U)}function sM(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return L2(A,[...z,...W],U)}function rM(w,z,U){let W=c1(w,U);return w.allOf.reduce((A,X)=>{let Z=L2(X,z,W);return s(Z)?{...A,...Z}:Z},{})}function aM(w,z,U){let W=c1(w,U);if(!s(W))return W;let A=Object.getOwnPropertyNames(w.properties);for(let X of A){let Z=L2(w.properties[X],z,W[X]);if(T0(Z))continue;W[X]=L2(w.properties[X],z,W[X])}if(!Dw(w.additionalProperties))return W;for(let X of Object.getOwnPropertyNames(W)){if(A.includes(X))continue;W[X]=L2(w.additionalProperties,z,W[X])}return W}function eM(w,z,U){let W=c1(w,U);if(!s(W))return W;let A=w.additionalProperties,[X,Z]=Object.entries(w.patternProperties)[0],$=new RegExp(X);for(let Q of Object.getOwnPropertyNames(W)){if(!($.test(Q)&&Dw(Z)))continue;W[Q]=L2(Z,z,W[Q])}if(!Dw(A))return W;for(let Q of Object.getOwnPropertyNames(W)){if($.test(Q))continue;W[Q]=L2(A,z,W[Q])}return W}function wq(w,z,U){return L2(J0(w,z),z,c1(w,U))}function zq(w,z,U){return L2(J0(w,z),z,U)}function Uq(w,z,U){let W=c1(w,U);if(!n(W)||T0(w.items))return W;let[A,X]=[w.items,Math.max(w.items.length,W.length)];for(let Z=0;Z<X;Z++)if(Z<A.length)W[Z]=L2(A[Z],z,W[Z]);return W}function Wq(w,z,U){let W=c1(w,U);for(let A of w.anyOf){let X=L2(A,z,B0(W));if(r(A,z,X))return X}return W}function L2(w,z,U){let W=e0(w,z),A=w;switch(A[N]){case"Array":return oM(A,W,U);case"Date":return lM(A,W,U);case"Import":return sM(A,W,U);case"Intersect":return rM(A,W,U);case"Object":return aM(A,W,U);case"Record":return eM(A,W,U);case"Ref":return wq(A,W,U);case"This":return zq(A,W,U);case"Tuple":return Uq(A,W,U);case"Union":return Wq(A,W,U);default:return c1(A,U)}}function b8(...w){return w.length===3?L2(w[0],w[1],w[2]):L2(w[0],[],w[1])}var $1={};J6($1,{ValuePointerRootSetError:()=>Pw,ValuePointerRootDeleteError:()=>Ow,Set:()=>Aq,Has:()=>Zq,Get:()=>$q,Format:()=>E4,Delete:()=>Xq});class Pw extends y{constructor(w,z,U){super("Cannot set root value");this.value=w,this.path=z,this.update=U}}class Ow extends y{constructor(w,z){super("Cannot delete root value");this.value=w,this.path=z}}function m7(w){return w.indexOf("~")===-1?w:w.replace(/~1/g,"/").replace(/~0/g,"~")}function*E4(w){if(w==="")return;let[z,U]=[0,0];for(let W=0;W<w.length;W++)if(w.charAt(W)==="/")if(W===0)z=W+1;else U=W,yield m7(w.slice(z,U)),z=W+1;else U=W;yield m7(w.slice(z))}function Aq(w,z,U){if(z==="")throw new Pw(w,z,U);let[W,A,X]=[null,w,""];for(let Z of E4(z)){if(A[Z]===void 0)A[Z]={};W=A,A=A[Z],X=Z}W[X]=U}function Xq(w,z){if(z==="")throw new Ow(w,z);let[U,W,A]=[null,w,""];for(let X of E4(z)){if(W[X]===void 0||W[X]===null)return;U=W,W=W[X],A=X}if(Array.isArray(U)){let X=parseInt(A);U.splice(X,1)}else delete U[A]}function Zq(w,z){if(z==="")return!0;let[U,W,A]=[null,w,""];for(let X of E4(z)){if(W[X]===void 0)return!1;U=W,W=W[X],A=X}return Object.getOwnPropertyNames(U).includes(A)}function $q(w,z){if(z==="")return w;let U=w;for(let W of E4(z)){if(U[W]===void 0)return;U=U[W]}return U}function Qq(w,z){if(!s(z))return!1;let U=[...Object.keys(w),...Object.getOwnPropertySymbols(w)],W=[...Object.keys(z),...Object.getOwnPropertySymbols(z)];if(U.length!==W.length)return!1;return U.every((A)=>D6(w[A],z[A]))}function Yq(w,z){return G2(z)&&w.getTime()===z.getTime()}function Jq(w,z){if(!n(z)||w.length!==z.length)return!1;return w.every((U,W)=>D6(U,z[W]))}function Bq(w,z){if(!d2(z)||w.length!==z.length||Object.getPrototypeOf(w).constructor.name!==Object.getPrototypeOf(z).constructor.name)return!1;return w.every((U,W)=>D6(U,z[W]))}function Mq(w,z){return w===z}function D6(w,z){if(G2(w))return Yq(w,z);if(d2(w))return Bq(w,z);if(n(w))return Jq(w,z);if(s(w))return Qq(w,z);if(V2(w))return Mq(w,z);throw new Error("ValueEquals: Unable to compare value")}var qq=_0({type:X0("insert"),path:c2(),value:T1()}),Hq=_0({type:X0("update"),path:c2(),value:T1()}),Gq=_0({type:X0("delete"),path:c2()}),p7=G0([qq,Hq,Gq]);class bw extends y{constructor(w,z){super(z);this.value=w}}function R8(w,z){return{type:"update",path:w,value:z}}function o7(w,z){return{type:"insert",path:w,value:z}}function l7(w){return{type:"delete",path:w}}function t7(w){if(globalThis.Object.getOwnPropertySymbols(w).length>0)throw new bw(w,"Cannot diff objects with symbols")}function*Lq(w,z,U){if(t7(z),t7(U),!n5(U))return yield R8(w,U);let W=globalThis.Object.getOwnPropertyNames(z),A=globalThis.Object.getOwnPropertyNames(U);for(let X of A){if(v(z,X))continue;yield o7(`${w}/${X}`,U[X])}for(let X of W){if(!v(U,X))continue;if(D6(z,U))continue;yield*C8(`${w}/${X}`,z[X],U[X])}for(let X of W){if(v(U,X))continue;yield l7(`${w}/${X}`)}}function*Nq(w,z,U){if(!n(U))return yield R8(w,U);for(let W=0;W<Math.min(z.length,U.length);W++)yield*C8(`${w}/${W}`,z[W],U[W]);for(let W=0;W<U.length;W++){if(W<z.length)continue;yield o7(`${w}/${W}`,U[W])}for(let W=z.length-1;W>=0;W--){if(W<U.length)continue;yield l7(`${w}/${W}`)}}function*Sq(w,z,U){if(!d2(U)||z.length!==U.length||globalThis.Object.getPrototypeOf(z).constructor.name!==globalThis.Object.getPrototypeOf(U).constructor.name)return yield R8(w,U);for(let W=0;W<Math.min(z.length,U.length);W++)yield*C8(`${w}/${W}`,z[W],U[W])}function*_q(w,z,U){if(z===U)return;yield R8(w,U)}function*C8(w,z,U){if(n5(z))return yield*Lq(w,z,U);if(n(z))return yield*Nq(w,z,U);if(d2(z))return yield*Sq(w,z,U);if(V2(z))return yield*_q(w,z,U);throw new bw(z,"Unable to diff value")}function s7(w,z){return[...C8("",w,z)]}function Dq(w){return w.length>0&&w[0].path===""&&w[0].type==="update"}function Pq(w){return w.length===0}function r7(w,z){if(Dq(z))return B0(z[0].value);if(Pq(z))return B0(w);let U=B0(w);for(let W of z)switch(W.type){case"insert":{$1.Set(U,W.path,W.value);break}case"update":{$1.Set(U,W.path,W.value);break}case"delete":{$1.Delete(U,W.path);break}}return U}function a7(...w){let[z,U,W]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]],A=h1(z,U)?s6(z,U,W):W;if(!r(z,U,A))throw new K4(z,A,_1(z,U,A).First());return A}function K8(w){return s(w)&&!n(w)}class Rw extends y{constructor(w){super(w)}}function Oq(w,z,U,W){if(!K8(U))$1.Set(w,z,B0(W));else{let A=Object.getOwnPropertyNames(U),X=Object.getOwnPropertyNames(W);for(let Z of A)if(!X.includes(Z))delete U[Z];for(let Z of X)if(!A.includes(Z))U[Z]=null;for(let Z of X)Cw(w,`${z}/${Z}`,U[Z],W[Z])}}function bq(w,z,U,W){if(!n(U))$1.Set(w,z,B0(W));else{for(let A=0;A<W.length;A++)Cw(w,`${z}/${A}`,U[A],W[A]);U.splice(W.length)}}function Rq(w,z,U,W){if(d2(U)&&U.length===W.length)for(let A=0;A<U.length;A++)U[A]=W[A];else $1.Set(w,z,B0(W))}function Cq(w,z,U,W){if(U===W)return;$1.Set(w,z,W)}function Cw(w,z,U,W){if(n(W))return bq(w,z,U,W);if(d2(W))return Rq(w,z,U,W);if(K8(W))return Oq(w,z,U,W);if(V2(W))return Cq(w,z,U,W)}function e7(w){return d2(w)||V2(w)}function Kq(w,z){return K8(w)&&n(z)||n(w)&&K8(z)}function wU(w,z){if(e7(w)||e7(z))throw new Rw("Only object and array types can be mutated at the root level");if(Kq(w,z))throw new Rw("Cannot assign due type mismatch of assignable values");Cw(w,"",w,z)}class Fw extends y{constructor(w){super(w)}}var Kw;(function(w){let z=new Map([["Clone",(X,Z,$)=>B0($)],["Clean",(X,Z,$)=>D8(X,Z,$)],["Default",(X,Z,$)=>b8(X,Z,$)],["Convert",(X,Z,$)=>O8(X,Z,$)],["Assert",(X,Z,$)=>{return _8(X,Z,$),$}],["Decode",(X,Z,$)=>h1(X,Z)?l6(X,Z,$):$],["Encode",(X,Z,$)=>h1(X,Z)?s6(X,Z,$):$]]);function U(X){z.delete(X)}w.Delete=U;function W(X,Z){z.set(X,Z)}w.Set=W;function A(X){return z.get(X)}w.Get=A})(Kw||(Kw={}));var zU=["Clone","Clean","Default","Convert","Assert","Decode"];function Fq(w,z,U,W){return w.reduce((A,X)=>{let Z=Kw.Get(X);if(T0(Z))throw new Fw(`Unable to find Parse operation '${X}'`);return Z(z,U,A)},W)}function UU(...w){let[z,U,W,A]=w.length===4?[w[0],w[1],w[2],w[3]]:w.length===3?n(w[0])?[w[0],w[1],[],w[2]]:[zU,w[0],w[1],w[2]]:w.length===2?[zU,w[0],[],w[1]]:(()=>{throw new Fw("Invalid Arguments")})();return Fq(z,U,W,A)}var p={};J6(p,{ValueErrorIterator:()=>S6,Patch:()=>r7,Parse:()=>UU,Mutate:()=>wU,Hash:()=>e1,Errors:()=>_1,Equal:()=>D6,Encode:()=>a7,Edit:()=>p7,Diff:()=>s7,Default:()=>b8,Decode:()=>u7,Create:()=>o2,Convert:()=>O8,Clone:()=>B0,Clean:()=>D8,Check:()=>r,Cast:()=>_w,Assert:()=>_8});var y8=n4(ZU(),1),mU=n4(F8(),1);var b6=n4(F8(),1),sU=n4(F8(),1);var cw={date:EU,time:fw(!0),"date-time":JU(!0),"iso-time":fw(!1),"iso-date-time":JU(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:sq,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:WH,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:rq,int32:{type:"number",validate:wH},int64:{type:"number",validate:zH},float:{type:"number",validate:MU},double:{type:"number",validate:MU},password:!0,binary:!0};function nq(w){return w%4===0&&(w%100!==0||w%400===0)}var uq=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,mq=[0,31,28,31,30,31,30,31,31,30,31,30,31];function EU(w){let z=uq.exec(w);if(!z)return!1;let U=+z[1],W=+z[2],A=+z[3];return W>=1&&W<=12&&A>=1&&A<=(W===2&&nq(U)?29:mq[W])}var tq=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function fw(w){return function z(U){let W=tq.exec(U);if(!W)return!1;let A=+W[1],X=+W[2],Z=+W[3],$=W[4],Q=W[5]==="-"?-1:1,Y=+(W[6]||0),B=+(W[7]||0);if(Y>23||B>59||w&&!$)return!1;if(A<=23&&X<=59&&Z<60)return!0;let G=X-B*Q,_=A-Y*Q-(G<0?1:0);return(_===23||_===-1)&&(G===59||G===-1)&&Z<61}}var pq=/t|\s/i;function JU(w){let z=fw(w);return function U(W){let A=W.split(pq);return A.length===2&&EU(A[0])&&z(A[1])}}var oq=/\/|:/,lq=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function sq(w){return oq.test(w)&&lq.test(w)}var BU=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function rq(w){return BU.lastIndex=0,BU.test(w)}var aq=-2147483648,eq=2147483647;function wH(w){return Number.isInteger(w)&&w<=eq&&w>=aq}function zH(w){return Number.isInteger(w)}function MU(){return!0}var UH=/[^\\]\\Z/;function WH(w){if(UH.test(w))return!1;try{return new RegExp(w),!0}catch(z){return!1}}var IU="toJSON"in new Headers,j8=(w,z)=>{let U=new URL(w);return U.pathname=z,U.toString()},AH=(w)=>typeof w==="function"&&/^\s*class\s+/.test(w.toString())||w.toString().startsWith("[object ")&&w.toString()!=="[object Object]"||s2(Object.getPrototypeOf(w)),Ew=(w)=>w&&typeof w==="object"&&!Array.isArray(w),F2=(w,z,{skipKeys:U,override:W=!0}={})=>{if(!Ew(w)||!Ew(z))return w;for(let[A,X]of Object.entries(z)){if(U?.includes(A))continue;if(!Ew(X)||!(A in w)||AH(X)){if(W||!(A in w))w[A]=X;continue}w[A]=F2(w[A],X,{skipKeys:U,override:W})}return w},XH=(w,z)=>{let{properties:U,...W}=w??{},{properties:A,...X}=z??{};return F2(W,X)},v0=(w=[],z=[])=>{if(!w)return[];if(!z)return w;let U=[],W=[];if(!Array.isArray(w))w=[w];if(!Array.isArray(z))z=[z];for(let A of w)if(U.push(A),A.checksum)W.push(A.checksum);for(let A of z)if(!W.includes(A.checksum))U.push(A);return U},ZH=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],$H=ZH.reduce((w,z)=>(w[z]=!0,w),{}),xU=(w,z)=>{let U=(W)=>typeof W==="object"&&Object.keys(W).every(iw);if(U(w)&&U(z))return{...w,...z};else if(w&&!U(w)&&U(z))return{200:w,...z};return z??w},I4=(w,z)=>{return{body:z?.body??w?.body,headers:z?.headers??w?.headers,params:z?.params??w?.params,query:z?.query??w?.query,cookie:z?.cookie??w?.cookie,response:xU(w?.response,z?.response)}},D1=(w,z)=>{let{resolve:U,...W}=w??{},{resolve:A,...X}=z??{};return{...W,...X,body:z?.body??w?.body,headers:z?.headers??w?.headers,params:z?.params??w?.params,query:z?.query??w?.query,cookie:z?.cookie??w?.cookie,response:xU(w?.response,z?.response),type:w?.type||z?.type,detail:F2(z?.detail??{},w?.detail??{}),parse:v0(w?.parse,z?.parse),transform:v0(w?.transform,z?.transform),beforeHandle:v0(v0(W2(U,"resolve"),w?.beforeHandle),v0(W2(A,"resolve"),z?.beforeHandle)),afterHandle:v0(w?.afterHandle,z?.afterHandle),mapResponse:v0(w?.mapResponse,z?.mapResponse),afterResponse:v0(w?.afterResponse,z?.afterResponse),trace:v0(w?.trace,z?.trace),error:v0(w?.error,z?.error)}},dw=(w,z,U=!0)=>{if(!Array.isArray(z))return B2(w,z,U);for(let W of z)w=B2(w,W,U);return w},B2=(w,z,U=!0)=>{if(!w)return w;if(z.untilObjectFound&&!U&&w.type==="object")return w;let W=z.from[N];if(w.oneOf){for(let Z=0;Z<w.oneOf.length;Z++)w.oneOf[Z]=B2(w.oneOf[Z],z,U);return w}if(w.anyOf){for(let Z=0;Z<w.anyOf.length;Z++)w.anyOf[Z]=B2(w.anyOf[Z],z,U);return w}if(w.allOf){for(let Z=0;Z<w.allOf.length;Z++)w.allOf[Z]=B2(w.allOf[Z],z,U);return w}if(w.not){for(let Z=0;Z<w.not.length;Z++)w.not[Z]=B2(w.not[Z],z,U);return w}let A=U&&!!z.excludeRoot;if(w[N]===W){let{anyOf:Z,oneOf:$,allOf:Q,not:Y,properties:B,items:G,..._}=w,H=z.to(_),F,R=(J)=>{if(B&&J.type==="object"){let A0={};for(let[L0,h]of Object.entries(B))A0[L0]=B2(h,z,!1);return{..._,...J,properties:A0}}if(G&&J.type==="array")return{..._,...J,items:B2(G,z,!1)};let m={..._,...J};if(delete m.required,B&&J.type==="string"&&J.format==="ObjectString"&&J.default==="{}")F=I.ObjectString(B,_),m.default=JSON.stringify(p.Create(I.Object(B))),m.properties=B;if(G&&J.type==="string"&&J.format==="ArrayString"&&J.default==="[]")F=I.ArrayString(G,_),m.default=JSON.stringify(p.Create(I.Array(G))),m.items=G;return m};if(A){if(B){let J={};for(let[m,A0]of Object.entries(B))J[m]=B2(A0,z,!1);return{..._,properties:J}}else if(G?.map)return{..._,items:G.map((J)=>B2(J,z,!1))};return _}if(H.anyOf)for(let J=0;J<H.anyOf.length;J++)H.anyOf[J]=R(H.anyOf[J]);else if(H.oneOf)for(let J=0;J<H.oneOf.length;J++)H.oneOf[J]=R(H.oneOf[J]);else if(H.allOf)for(let J=0;J<H.allOf.length;J++)H.allOf[J]=R(H.allOf[J]);else if(H.not)for(let J=0;J<H.not.length;J++)H.not[J]=R(H.not[J]);if(F)H[F0]=F[F0];if(H.anyOf||H.oneOf||H.allOf||H.not)return H;if(B){let J={};for(let[m,A0]of Object.entries(B))J[m]=B2(A0,z,!1);return{..._,...H,properties:J}}else if(G?.map)return{..._,...H,items:G.map((J)=>B2(J,z,!1))};return{..._,...H}}let X=w?.properties;if(X&&U&&z.rootOnly!==!0)for(let[Z,$]of Object.entries(X))switch($[N]){case W:let{anyOf:Q,oneOf:Y,allOf:B,not:G,type:_,...H}=$,F=z.to(H);if(F.anyOf)for(let R=0;R<F.anyOf.length;R++)F.anyOf[R]={...H,...F.anyOf[R]};else if(F.oneOf)for(let R=0;R<F.oneOf.length;R++)F.oneOf[R]={...H,...F.oneOf[R]};else if(F.allOf)for(let R=0;R<F.allOf.length;R++)F.allOf[R]={...H,...F.allOf[R]};else if(F.not)for(let R=0;R<F.not.length;R++)F.not[R]={...H,...F.not[R]};X[Z]={...H,...B2(H,z,!1)};break;case"Object":case"Union":X[Z]=B2($,z,!1);break;default:if($.items)for(let R=0;R<$.items.length;R++)$.items[R]=B2($.items[R],z,!1);else if($.anyOf||$.oneOf||$.allOf||$.not)X[Z]=B2($,z,!1);break}return w},k4=(w)=>(z)=>{if(typeof z==="object")try{return p.Clean(w,structuredClone(z))}catch{try{return p.Clean(w,z)}catch{return z}}return z},j2=(w,{models:z={},dynamic:U=!1,modules:W,normalize:A=!1,additionalProperties:X=!1,coerce:Z=!1,additionalCoerce:$=[]}={modules:I.Module({})})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let Q=typeof w==="string"?W.Import(w)??z[w]:w;if(Z||$)if(Z)Q=dw(Q,[{from:I.Ref(""),to:(B)=>W.Import(B.$ref)},{from:I.Number(),to:(B)=>I.Numeric(B),untilObjectFound:!0},{from:I.Boolean(),to:(B)=>I.BooleanString(B),untilObjectFound:!0},...Array.isArray($)?$:[$]]);else Q=dw(Q,[{from:I.Ref(""),to:(B)=>W.Import(B.$ref)},...Array.isArray($)?$:[$]]);if(Q.type==="object"&&"additionalProperties"in Q===!1)Q.additionalProperties=X;if(U){let B={schema:Q,references:"",checkFunc:()=>{},code:"",Check:(G)=>p.Check(Q,G),Errors:(G)=>p.Errors(Q,G),Code:()=>"",Clean:k4(Q),Decode:(G)=>p.Decode(Q,G),Encode:(G)=>p.Encode(Q,G)};if(A&&Q.additionalProperties===!1)B.Clean=k4(Q);if(Q.config){if(B.config=Q.config,B?.schema?.config)delete B.schema.config}return B.parse=(G)=>{try{return B.Decode(G)}catch(_){throw[...B.Errors(G)].map(J1)}},B.safeParse=(G)=>{try{return{success:!0,data:B.Decode(G),error:null}}catch(_){let H=[...Y.Errors(G)].map(J1);return{success:!1,data:null,error:H[0]?.summary,errors:H}}},B}let Y=w6.Compile(Q,Object.values(z));if(Y.Clean=k4(Q),Q.config){if(Y.config=Q.config,Y?.schema?.config)delete Y.schema.config}return Y.parse=(B)=>{try{return Y.Decode(B)}catch(G){throw[...Y.Errors(B)].map(J1)}},Y.safeParse=(B)=>{try{return{success:!0,data:Y.Decode(B),error:null}}catch(G){let _=[...Y.Errors(B)].map(J1);return{success:!1,data:null,error:_[0]?.summary,errors:_}}},Y},qU=(w,{models:z={},modules:U,dynamic:W=!1,normalize:A=!1,additionalProperties:X=!1})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let Z=typeof w==="string"?U.Import(w)??z[w]:w,$=(Y,B)=>{if(W)return{schema:Y,references:"",checkFunc:()=>{},code:"",Check:(_)=>p.Check(Y,_),Errors:(_)=>p.Errors(Y,_),Code:()=>"",Clean:k4(Y),Decode:(_)=>p.Decode(Y,_),Encode:(_)=>p.Encode(Y,_)};let G=w6.Compile(Y,B);if(A&&Y.additionalProperties===!1)G.Clean=k4(Y);return G};if(N in Z){if("additionalProperties"in Z===!1)Z.additionalProperties=X;return{200:$(Z,Object.values(z))}}let Q={};return Object.keys(Z).forEach((Y)=>{let B=Z[+Y];if(typeof B==="string"){if(B in z){let G=z[B];G.type==="object"&&"additionalProperties"in G,Q[+Y]=N in G?$(G,Object.values(z)):G}return}if(B.type==="object"&&"additionalProperties"in B===!1)B.additionalProperties=X;Q[+Y]=N in B?$(B,Object.values(z)):B}),Q},QH=typeof Bun!=="undefined",YH=QH&&typeof Bun.hash==="function",x4=(w)=>{if(YH)return Bun.hash(w);let z=9;for(let U=0;U<w.length;)z=Math.imul(z^w.charCodeAt(U++),387420489);return z=z^z>>>9},Iw,P6=()=>{if(!Iw)Iw=[{from:I.Object({}),to:()=>I.ObjectString({}),excludeRoot:!0},{from:I.Array(I.Any()),to:()=>I.ArrayString(I.Any())}];return Iw},xw,HU=()=>{if(!xw)xw=[{from:I.Number(),to:(w)=>I.Numeric(w),rootOnly:!0},{from:I.Boolean(),to:(w)=>I.BooleanString(w),rootOnly:!0}];return xw},VU=({validator:w,modules:z,defaultConfig:U={},config:W,dynamic:A,models:X})=>{let Z=j2(w,{modules:z,dynamic:A,models:X,additionalProperties:!0,coerce:!0,additionalCoerce:P6()});if(s2(U))if(Z)Z.config=XH(Z.config,W);else Z=j2(I.Cookie({}),{modules:z,dynamic:A,models:X,additionalProperties:!0}),Z.config=U;return Z},Q1=(w,z)=>{if(!z)return;if(!Array.isArray(z)){let W=z;if(w&&!W.checksum)W.checksum=w;if(W.scope==="scoped")W.scope="local";return W}let U=[...z];for(let W of U){if(w&&!W.checksum)W.checksum=w;if(W.scope==="scoped")W.scope="local"}return U},GU=(w,z,U)=>{return{start:v0(w.start,Q1(U,z?.start)),request:v0(w.request,Q1(U,z?.request)),parse:v0(w.parse,Q1(U,z?.parse)),transform:v0(w.transform,Q1(U,z?.transform)),beforeHandle:v0(v0(W2(w.resolve,"resolve"),w.beforeHandle),Q1(U,v0(W2(z?.resolve,"resolve"),z?.beforeHandle))),afterHandle:v0(w.afterHandle,Q1(U,z?.afterHandle)),mapResponse:v0(w.mapResponse,Q1(U,z?.mapResponse)),afterResponse:v0(w.afterResponse,Q1(U,z?.afterResponse)),trace:v0(w.trace,Q1(U,z?.trace)),error:v0(w.error,Q1(U,z?.error)),stop:v0(w.stop,Q1(U,z?.stop))}},JH=(w,z,{skipIfHasType:U=!1}={})=>{if(!w)return w;if(!Array.isArray(w)){if(U)w.scope??=z;else w.scope=z;return w}for(let W of w)if(U)W.scope??=z;else W.scope=z;return w},z6=(w)=>{if(!w)return w;if(!Array.isArray(w))switch(w.scope){case"global":case"scoped":return{...w};default:return{fn:w}}let z=[];for(let U of w)switch(U.scope){case"global":case"scoped":z.push({...U});break}return z},LU=(w)=>{return{...w,type:w?.type,detail:w?.detail,parse:z6(w?.parse),transform:z6(w?.transform),beforeHandle:z6(w?.beforeHandle),afterHandle:z6(w?.afterHandle),mapResponse:z6(w?.mapResponse),afterResponse:z6(w?.afterResponse),error:z6(w?.error),trace:z6(w?.trace)}},f8={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},NU=Object.fromEntries(Object.entries(f8).map(([w,z])=>[z,w]));function BH(w){let z=w;while(z.endsWith("="))z=z.slice(0,-1);return z}var SU=new TextEncoder,V8=async(w,z)=>{if(typeof w!=="string")throw new TypeError("Cookie value must be provided as a string.");if(z===null)throw new TypeError("Secret key must be provided.");let U=await crypto.subtle.importKey("raw",SU.encode(z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),W=await crypto.subtle.sign("HMAC",U,SU.encode(w));return w+"."+BH(Buffer.from(W).toString("base64"))},_U=async(w,z)=>{if(typeof w!=="string")throw new TypeError("Signed cookie string must be provided.");if(z===null)throw new TypeError("Secret key must be provided.");let U=w.slice(0,w.lastIndexOf("."));return await V8(U,z)===w?U:!1},MH=(w,z,U)=>{if(!w||typeof w!=="object"||!z)return;for(let[W,A]of Object.entries(z)){if(W in $H||!(W in w))continue;let X=w[W];if(typeof X==="function"){let Z=X(A);if(typeof Z==="object")for(let[$,Q]of Object.entries(Z))U($)({fn:Q});delete z[W]}}},qH=({globalHook:w,localHook:z})=>(U)=>(W,A)=>{if(typeof W==="function")W={fn:W};if(U==="resolve")W={...W,subType:"resolve"};if("fn"in W||Array.isArray(W)){if(!z[U])z[U]=[];if(typeof z[U]==="function")z[U]=[z[U]];if(Array.isArray(W))z[U]=z[U].concat(W);else z[U].push(W);return}let{insert:X="after",stack:Z="local"}=W;if(typeof A==="function")A={fn:A};if(Z==="global")if(!Array.isArray(A))if(X==="before")w[U].unshift(A);else w[U].push(A);else if(X==="before")w[U]=A.concat(w[U]);else w[U]=w[U].concat(A);else{if(!z[U])z[U]=[];if(typeof z[U]==="function")z[U]=[z[U]];if(!Array.isArray(A))if(X==="before")z[U].unshift(A);else z[U].push(A);else if(X==="before")z[U]=A.concat(z[U]);else z[U]=z[U].concat(A)}},HH=(w)=>{if(typeof w==="number")return w;if(w.length<16){if(w.trim().length===0)return null;let z=Number(w);if(Number.isNaN(z))return null;return z}if(w.length===16){if(w.trim().length===0)return null;let z=Number(w);if(Number.isNaN(z)||z.toString()!==w)return null;return z}return null},iw=(w)=>HH(w)!==null;class kU{onError;root=null;promises=[];constructor(w=console.error){this.onError=w}get size(){return this.promises.length}add(w){return this.promises.push(w),this.root||=this.drain(),w}async drain(){while(this.promises.length>0){try{await this.promises[0]}catch(w){this.onError(w)}this.promises.shift()}this.root=null}then(w,z){return(this.root??Promise.resolve()).then(w,z)}}var W2=(w,z)=>{if(!w)return w;if(!Array.isArray(w)){if(typeof w==="function"||typeof w==="string")return z?{fn:w,subType:z}:{fn:w};else if("fn"in w)return w}let U=[];for(let W of w)if(typeof W==="function"||typeof W==="string")U.push(z?{fn:W,subType:z}:{fn:W});else if("fn"in W)U.push(W);return U},GH=(w)=>{return{...w,start:W2(w?.start),request:W2(w?.request),parse:W2(w?.parse),transform:W2(w?.transform),beforeHandle:W2(w?.beforeHandle),afterHandle:W2(w?.afterHandle),mapResponse:W2(w?.mapResponse),afterResponse:W2(w?.afterResponse),trace:W2(w?.trace),error:W2(w?.error),stop:W2(w?.stop)}},DU=(w)=>{return{...w,start:w.start?.map((z)=>z.fn),request:w.request?.map((z)=>z.fn),parse:w.parse?.map((z)=>z.fn),transform:w.transform?.map((z)=>z.fn),beforeHandle:w.beforeHandle?.map((z)=>z.fn),afterHandle:w.afterHandle?.map((z)=>z.fn),afterResponse:w.afterResponse?.map((z)=>z.fn),mapResponse:w.mapResponse?.map((z)=>z.fn),trace:w.trace?.map((z)=>z.fn),error:w.error?.map((z)=>z.fn),stop:w.stop?.map((z)=>z.fn)}},Vw=(w)=>({body:w.body,cookie:w.cookie,headers:w.headers,query:w.query,set:w.set,server:w.server,request:w.request,route:w.route}),TU=(w,z=302)=>Response.redirect(w,z),PE=Symbol("ElysiaFormData"),d8=Symbol("ElysiaRequestId");var gU=()=>{let w=crypto.randomUUID();return w.slice(0,8)+w.slice(24,32)},PU=(w)=>{let z=[];for(let U=0;U<w.length;U++){let W=w[U];if(W.checksum){if(z.includes(W.checksum))w.splice(U,1),U--;z.push(W.checksum)}}return w},J2=(w,z="scoped")=>{if(z==="scoped"){for(let U of w)if("scope"in U&&U.scope==="local")U.scope="scoped";return}for(let U of w)if("scope"in U)U.scope="global"},r6=(w)=>{if(w.charCodeAt(w.length-1)===47)return w.slice(0,w.length-1);return w+"/"},s2=(w)=>{if(!w)return!1;for(let z in w)return!0;return!1},OU=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,k8=Symbol("ElysiaErrorCode"),T8=(OU?.NODE_ENV??OU?.ENV)==="production";class M1{code;response;constructor(w,z){let U=z??(w in NU?NU[w]:w);this.code=f8[w]??w,this.response=U}}var LH=(w,z)=>new M1(w,z);class fU extends Error{code="INTERNAL_SERVER_ERROR";status=500;constructor(w){super(w??"INTERNAL_SERVER_ERROR")}}class h8 extends Error{code="NOT_FOUND";status=404;constructor(w){super(w??"NOT_FOUND")}}class dU extends Error{code="PARSE";status=400;constructor(){super("Bad Request")}}class hw extends Error{key;code="INVALID_COOKIE_SIGNATURE";status=400;constructor(w,z){super(z??`"${w}" has invalid cookie signature`);this.key=w}}var J1=(w)=>{if(!w)return{summary:void 0};let{message:z,path:U,value:W,type:A}=w,X=U.slice(1).replaceAll("/","."),Z=U==="";switch(A){case 42:return{...w,summary:Z?"Value should not be provided":`Property '${X}' should not be provided`};case 45:return{...w,summary:Z?"Value is missing":`Property '${X}' is missing`};case 50:let $=z.indexOf("'"),Q=z.slice($+1,z.indexOf("'",$+1));return{...w,summary:Z?"Value should be an email":`Property '${X}' should be ${Q}`};case 54:return{...w,summary:`${z.slice(0,9)} property '${X}' to be ${z.slice(8)} but found: ${W}`};case 62:let Y=w.schema.anyOf.map((B)=>`'${B?.format??B.type}'`).join(", ");return{...w,summary:Z?`Value should be one of ${Y}`:`Property '${X}' should be one of: ${Y}`};default:return{summary:z,...w}}};class Z0 extends Error{type;validator;value;code="VALIDATION";status=422;constructor(w,z,U){if(U&&typeof U==="object"&&U instanceof M1)U=U.response;let W=T8?void 0:("Errors"in z)?z.Errors(U).First():p.Errors(z,U).First(),A=W.schema.message||W?.schema.error!==void 0?typeof W.schema.error==="function"?W.schema.error({type:w,validator:z,value:U,get errors(){return[...z.Errors(U)].map(J1)}}):W.schema.error:void 0,X=W?.path||"root",Z="";if(A!==void 0)Z=typeof A==="object"?JSON.stringify(A):A+"";else if(T8)Z=JSON.stringify({type:"validation",on:w,summary:J1(W).summary,message:W?.message,found:U});else{let $=z?.schema??z,Q="Errors"in z?[...z.Errors(U)].map(J1):[...p.Errors(z,U)].map(J1),Y;try{Y=p.Create($)}catch(B){Y={type:"Could not create expected value",message:B?.message,error:B}}Z=JSON.stringify({type:"validation",on:w,summary:J1(W).summary,property:X,message:W?.message,expected:Y,found:U,errors:Q},null,2)}super(Z);this.type=w,this.validator=z,this.value=U,Object.setPrototypeOf(this,Z0.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(J1):[...p.Errors(this.validator,this.value)].map(J1)}static simplifyModel(w){let z="schema"in w?w.schema:w;try{return p.Create(z)}catch{return z}}get model(){return Z0.simplifyModel(this.validator)}toResponse(w){return new Response(this.message,{status:400,headers:{...w,"content-type":"application/json"}})}}var hU=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,yU=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,cU=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,NH=cw.date,SH=cw["date-time"];if(!b0.Has("date"))f1.Format("date",(w)=>{let z=w.replace(/"/g,"");if(hU.test(z)||yU.test(z)||cU.test(z)||NH(z)){let U=new Date(z);if(!Number.isNaN(U.getTime()))return!0}return!1});if(!b0.Has("date-time"))f1.Format("date-time",(w)=>{let z=w.replace(/"/g,"");if(hU.test(z)||yU.test(z)||cU.test(z)||SH(z)){let U=new Date(z);if(!Number.isNaN(U.getTime()))return!0}return!1});Object.entries(cw).forEach((w)=>{let[z,U]=w;if(!b0.Has(z)){if(U instanceof RegExp)f1.Format(z,(W)=>U.test(W));else if(typeof U==="function")f1.Format(z,U)}});var I=Object.assign({},N6),bU=(w)=>{if(typeof w==="string")switch(w.slice(-1)){case"k":return+w.slice(0,w.length-1)*1024;case"m":return+w.slice(0,w.length-1)*1048576;default:return+w}return w},yw=(w,z)=>{if(!(z instanceof Blob))return!1;if(w.minSize&&z.size<bU(w.minSize))return!1;if(w.maxSize&&z.size>bU(w.maxSize))return!1;if(w.extension)if(typeof w.extension==="string"){if(!z.type.startsWith(w.extension))return!1}else{for(let U=0;U<w.extension.length;U++)if(z.type.startsWith(w.extension[U]))return!0;return!1}return!0},_H=y0.Get("Files")??f1.Type("File",yw),DH=y0.Get("Files")??f1.Type("Files",(w,z)=>{if(!Array.isArray(z))return yw(w,z);if(w.minItems&&z.length<w.minItems)return!1;if(w.maxItems&&z.length>w.maxItems)return!1;for(let U=0;U<z.length;U++)if(!yw(w,z[U]))return!1;return!0});if(!b0.Has("numeric"))b0.Set("numeric",(w)=>!!w&&!isNaN(+w));if(!b0.Has("integer"))b0.Set("integer",(w)=>!!w&&Number.isInteger(+w));if(!b0.Has("boolean"))b0.Set("boolean",(w)=>w==="true"||w==="false");if(!b0.Has("ObjectString"))b0.Set("ObjectString",(w)=>{let z=w.charCodeAt(0);if(z===9||z===10||z===32)z=w.trimStart().charCodeAt(0);if(z!==123&&z!==91)return!1;try{return JSON.parse(w),!0}catch{return!1}});if(!b0.Has("ArrayString"))b0.Set("ArrayString",(w)=>{let z=w.charCodeAt(0);if(z===9||z===10||z===32)z=w.trimStart().charCodeAt(0);if(z!==123&&z!==91)return!1;try{return JSON.parse(w),!0}catch{return!1}});y0.Set("UnionEnum",(w,z)=>{return(typeof z==="number"||typeof z==="string"||z===null)&&w.enum.includes(z)});var r2={Numeric:(w)=>{let z=N6.Number(w);return I.Transform(I.Union([I.String({format:"numeric",default:0}),I.Number(w)],w)).Decode((U)=>{let W=+U;if(isNaN(W))return U;if(w&&!p.Check(z,W))throw new Z0("property",z,W);return W}).Encode((U)=>U)},Integer:(w)=>{let z=N6.Integer(w);return I.Transform(I.Union([I.String({format:"integer",default:0}),I.Number(w)],w)).Decode((U)=>{let W=+U;if(!p.Check(z,W))throw new Z0("property",z,W);return W}).Encode((U)=>U)},Date:(w)=>{let z=N6.Date(w);return I.Transform(I.Union([N6.Date(w),I.String({format:"date",default:new Date().toISOString()}),I.String({format:"date-time",default:new Date().toISOString()}),I.Number()],w)).Decode((U)=>{if(typeof U==="number"){let A=new Date(U);if(!p.Check(z,A))throw new Z0("property",z,A);return A}if(U instanceof Date)return U;let W=new Date(U);if(!p.Check(z,W))throw new Z0("property",z,W);return W}).Encode((U)=>{if(typeof U==="string")return new Date(U);return U})},BooleanString:(w)=>{let z=N6.Boolean(w);return I.Transform(I.Union([I.Boolean(w),I.String({format:"boolean",default:!1})],w)).Decode((U)=>{if(typeof U==="string")return U==="true";if(U!==void 0&&!p.Check(z,U))throw new Z0("property",z,U);return U}).Encode((U)=>U)},ObjectString:(w,z)=>{let U=I.Object(w,z),W=JSON.stringify(p.Create(U)),A;try{A=w6.Compile(U)}catch{}return I.Transform(I.Union([I.String({format:"ObjectString",default:W}),U])).Decode((X)=>{if(typeof X==="string"){if(X.charCodeAt(0)!==123)throw new Z0("property",U,X);try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(A){if(!A.Check(X))throw new Z0("property",U,X);return A.Decode(X)}if(!p.Check(U,X))throw new Z0("property",U,X);return p.Decode(U,X)}return X}).Encode((X)=>{if(typeof X==="string")try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(!p.Check(U,X))throw new Z0("property",U,X);return JSON.stringify(X)})},ArrayString:(w={},z)=>{let U=I.Array(w,z),W=JSON.stringify(p.Create(U)),A;try{A=w6.Compile(U)}catch{}return I.Transform(I.Union([I.String({format:"ArrayString",default:W}),U])).Decode((X)=>{if(typeof X==="string"){if(X.charCodeAt(0)!==91)throw new Z0("property",U,X);try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(A){if(!A.Check(X))throw new Z0("property",U,X);return A.Decode(X)}if(!p.Check(U,X))throw new Z0("property",U,X);return p.Decode(U,X)}return X}).Encode((X)=>{if(typeof X==="string")try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(!p.Check(U,X))throw new Z0("property",U,X);return JSON.stringify(X)})},File:_H,Files:(w={})=>I.Transform(DH(w)).Decode((z)=>{if(Array.isArray(z))return z;return[z]}).Encode((z)=>z),Nullable:(w)=>I.Union([w,I.Null()]),MaybeEmpty:(w)=>I.Union([w,I.Null(),I.Undefined()]),Cookie:(w,{domain:z,expires:U,httpOnly:W,maxAge:A,path:X,priority:Z,sameSite:$,secure:Q,secrets:Y,sign:B,...G}={})=>{let _=I.Object(w,G);return _.config={domain:z,expires:U,httpOnly:W,maxAge:A,path:X,priority:Z,sameSite:$,secure:Q,secrets:Y,sign:B},_},UnionEnum:(w,z={})=>{let U=w.every((W)=>typeof W==="string")?{type:"string"}:w.every((W)=>typeof W==="number")?{type:"number"}:w.every((W)=>W===null)?{type:"null"}:{};if(w.some((W)=>typeof W==="object"&&W!==null))throw new Error("This type does not support objects or arrays");return{default:w[0],...z,[N]:"UnionEnum",...U,enum:w}}};I.BooleanString=r2.BooleanString;I.ObjectString=r2.ObjectString;I.ArrayString=r2.ArrayString;I.Numeric=r2.Numeric;I.Integer=r2.Integer;I.File=(w={})=>r2.File({default:"File",...w,extension:w?.type,type:"string",format:"binary"});I.Files=(w={})=>r2.Files({...w,elysiaMeta:"Files",default:"Files",extension:w?.type,type:"array",items:{...w,default:"Files",type:"string",format:"binary"}});I.Nullable=(w)=>r2.Nullable(w);I.MaybeEmpty=r2.MaybeEmpty;I.Cookie=r2.Cookie;I.Date=r2.Date;I.UnionEnum=r2.UnionEnum;var T4=(w)=>{let z=typeof w==="object"?w.fn.toString():typeof w==="string"?w.toString():w,U=z.indexOf(")");if(z.charCodeAt(U+2)===61&&z.charCodeAt(U+5)!==123)return!0;return z.includes("return")},PH=(w)=>{if(w.startsWith("async"))w=w.slice(5);w=w.trimStart();let z=-1;if(w.charCodeAt(0)===40){if(z=w.indexOf("=>",w.indexOf(")")),z!==-1){let A=z;while(A>0)if(w.charCodeAt(--A)===41)break;let X=w.slice(z+2);if(X.charCodeAt(0)===32)X=X.trimStart();return[w.slice(1,A),X,{isArrowReturn:X.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(w)){if(z=w.indexOf("=>"),z!==-1){let A=w.slice(z+2);if(A.charCodeAt(0)===32)A=A.trimStart();return[w.slice(0,z),A,{isArrowReturn:A.charCodeAt(0)!==123}]}}if(w.startsWith("function")){z=w.indexOf("(");let A=w.indexOf(")");return[w.slice(z+1,A),w.slice(A+2),{isArrowReturn:!1}]}let U=w.indexOf("(");if(U!==-1){let A=w.indexOf(`
8
- `,2),X=w.slice(0,A),Z=X.lastIndexOf(")")+1,$=w.slice(A+1);return[X.slice(U,Z),"{"+$,{isArrowReturn:!1}]}let W=w.split(`
9
- `,2);return[W[0],W[1],{isArrowReturn:!1}]},OH=(w)=>{let z=w.indexOf("{");if(z===-1)return[-1,0];let U=z+1,W=1;for(;U<w.length;U++){let A=w.charCodeAt(U);if(A===123)W++;else if(A===125)W--;if(W===0)break}if(W!==0)return[0,w.length];return[z,U+1]},bH=(w)=>{let z=w.lastIndexOf("}");if(z===-1)return[-1,0];let U=z-1,W=1;for(;U>=0;U--){let A=w.charCodeAt(U);if(A===125)W++;else if(A===123)W--;if(W===0)break}if(W!==0)return[-1,0];return[U,z+1]},iU=(w)=>{while(!0){let z=w.indexOf(":");if(z===-1)break;let U=w.indexOf(",",z);if(U===-1)U=w.indexOf("}",z)-1;if(U===-2)U=w.length;w=w.slice(0,z)+w.slice(U)}return w},vU=(w)=>{let z=!1;if(w.charCodeAt(0)===40)w=w.slice(1,-1);if(w.charCodeAt(0)===123)z=!0,w=w.slice(1,-1);w=w.replace(/( |\t|\n)/g,"").trim();let U=[];while(!0){let[A,X]=OH(w);if(A===-1)break;if(U.push(w.slice(0,A-1)),w.charCodeAt(X)===44)X++;w=w.slice(X)}if(w=iU(w),w)U=U.concat(w.split(","));let W=[];for(let A of U){if(A.indexOf(",")===-1){W.push(A);continue}for(let X of A.split(","))W.push(X.trim())}return U=W,{hasParenthesis:z,parameters:U}},RH=(w,z)=>{let{parameters:U,hasParenthesis:W}=vU(w);if(!z.query&&U.includes("query"))z.query=!0;if(!z.headers&&U.includes("headers"))z.headers=!0;if(!z.body&&U.includes("body"))z.body=!0;if(!z.cookie&&U.includes("cookie"))z.cookie=!0;if(!z.set&&U.includes("set"))z.set=!0;if(!z.server&&U.includes("server"))z.server=!0;if(!z.request&&U.includes("request"))z.request=!0;if(!z.route&&U.includes("route"))z.route=!0;if(W)return`{ ${U.join(", ")} }`;return U.join(", ")},RU=(w,z,U)=>{let W=z.indexOf(w+`
10
- `,U),A=z.indexOf(w+"\t",U),X=z.indexOf(w+",",U),Z=z.indexOf(w+";",U),$=z.indexOf(w+" ",U);return[W,A,X,Z,$].filter((Q)=>Q>0).sort((Q,Y)=>Q-Y)[0]||-1},nU=(w,z,U=0)=>{if(U>5)return[];let W=[],A=z;while(!0){let X=RU(" = "+w,A);if(X===-1)X=RU("="+w,A);if(X===-1){let Y=A.indexOf(" = "+w);if(Y===-1)Y=A.indexOf("="+w);if(Y+3+w.length!==A.length)break;X=Y}let Z=A.slice(0,X),$=Z.lastIndexOf(" "),Q=Z.slice($!==-1?$+1:-1);if(Q==="}"){let[Y,B]=bH(Z);W.push(iU(A.slice(Y,B))),A=A.slice(X+3+w.length);continue}while(Q.charCodeAt(0)===44)Q=Q.slice(1);while(Q.charCodeAt(0)===9)Q=Q.slice(1);if(!Q.includes("("))W.push(Q);A=A.slice(X+3+w.length)}for(let X of W){if(X.charCodeAt(0)===123)continue;let Z=nU(X,z);if(Z.length>0)W.push(...Z)}return W},CH=(w)=>{if(!w)return;if(w.charCodeAt(0)!==123)return w;if(w=w.slice(2,-2),!w.includes(",")){if(w.includes("..."))return w.slice(w.indexOf("...")+3);return}let z=w.indexOf("...");if(z===-1)return;return w.slice(z+3).trimEnd()},KH=(w,z,U)=>{let W=(A,X)=>w.includes(X+"."+A)||w.includes(X+'["'+A+'"]')||w.includes(X+"['"+A+"']");for(let A of z){if(!A)continue;if(A.charCodeAt(0)===123){let X=vU(A).parameters;if(!U.query&&X.includes("query"))U.query=!0;if(!U.headers&&X.includes("headers"))U.headers=!0;if(!U.body&&X.includes("body"))U.body=!0;if(!U.cookie&&X.includes("cookie"))U.cookie=!0;if(!U.set&&X.includes("set"))U.set=!0;if(!U.query&&X.includes("server"))U.server=!0;if(!U.request&&X.includes("request"))U.request=!0;if(!U.route&&X.includes("route"))U.route=!0;continue}if(!U.query&&W("query",A))U.query=!0;if(w.includes("return "+A)||w.includes("return "+A+".query"))U.query=!0;if(!U.headers&&W("headers",A))U.headers=!0;if(!U.body&&W("body",A))U.body=!0;if(!U.cookie&&W("cookie",A))U.cookie=!0;if(!U.set&&W("set",A))U.set=!0;if(!U.server&&W("server",A))U.server=!0;if(U.query&&U.headers&&U.body&&U.cookie&&U.set&&U.server&&U.server&&U.route)break}return z},FH=(w,z,U)=>{try{let W=new RegExp(`(?:\\w)\\((?:.*)?${w}`,"gs");W.test(z);let A=z.charCodeAt(W.lastIndex);if(A===41||A===44)return U.query=!0,U.headers=!0,U.body=!0,U.cookie=!0,U.set=!0,U.server=!0,U.route=!0,U.request=!0,!0;return!1}catch(W){return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"),console.log("--- body ---"),console.log(z),console.log("--- context ---"),console.log(w),!0}},uU=(w,z={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let U=[];if(w.handler&&typeof w.handler==="function")U.push(w.handler);if(w.request?.length)U.push(...w.request);if(w.beforeHandle?.length)U.push(...w.beforeHandle);if(w.parse?.length)U.push(...w.parse);if(w.error?.length)U.push(...w.error);if(w.transform?.length)U.push(...w.transform);if(w.afterHandle?.length)U.push(...w.afterHandle);if(w.mapResponse?.length)U.push(...w.mapResponse);if(w.afterResponse?.length)U.push(...w.afterResponse);for(let W of U){if(!W)continue;let A="fn"in W?W.fn:W;if(typeof A!=="function")continue;let[X,Z,{isArrowReturn:$}]=PH(A.toString()),Q=RH(X,z),Y=CH(Q);if(Y){let B=nU(Y,Z);if(B.splice(0,-1,Y),!FH(Y,Z,z))KH(Z,B,z);if(!z.query&&Z.includes("return "+Y+".query"))z.query=!0}if(z.query&&z.headers&&z.body&&z.cookie&&z.set&&z.server&&z.request&&z.route)break}return z};class z4{name;jar;initial;constructor(w,z,U={}){this.name=w,this.jar=z,this.initial=U}get cookie(){return this.jar[this.name]??this.initial}set cookie(w){if(!(this.name in this.jar))this.jar[this.name]=this.initial;this.jar[this.name]=w}get setCookie(){if(!(this.name in this.jar))this.jar[this.name]=this.initial;return this.jar[this.name]}set setCookie(w){this.cookie=w}get value(){return this.cookie.value}set value(w){this.setCookie.value=w}get expires(){return this.cookie.expires}set expires(w){this.setCookie.expires=w}get maxAge(){return this.cookie.maxAge}set maxAge(w){this.setCookie.maxAge=w}get domain(){return this.cookie.domain}set domain(w){this.setCookie.domain=w}get path(){return this.cookie.path}set path(w){this.setCookie.path=w}get secure(){return this.cookie.secure}set secure(w){this.setCookie.secure=w}get httpOnly(){return this.cookie.httpOnly}set httpOnly(w){this.setCookie.httpOnly=w}get sameSite(){return this.cookie.sameSite}set sameSite(w){this.setCookie.sameSite=w}get priority(){return this.cookie.priority}set priority(w){this.setCookie.priority=w}get partitioned(){return this.cookie.partitioned}set partitioned(w){this.setCookie.partitioned=w}get secrets(){return this.cookie.secrets}set secrets(w){this.setCookie.secrets=w}update(w){return this.setCookie=Object.assign(this.cookie,typeof w==="function"?w(this.cookie):w),this}set(w){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof w==="function"?w(this.cookie):w),this}remove(){if(this.value===void 0)return;return this.set({expires:new Date(0),maxAge:0,value:""}),this}toString(){return typeof this.value==="object"?JSON.stringify(this.value):this.value?.toString()??""}}var CU=(w,z,U)=>{if(!w.cookie)w.cookie={};return new Proxy(z,{get(W,A){if(A in z)return new z4(A,w.cookie,Object.assign({},U??{},z[A]));return new z4(A,w.cookie,Object.assign({},U))}})},tU=async(w,z,{secrets:U,sign:W,...A}={})=>{if(!z)return CU(w,{},A);let X=typeof U==="string";if(W&&W!==!0&&!Array.isArray(W))W=[W];let Z={},$=y8.parse(z);for(let[Q,Y]of Object.entries($)){let B=mU.default(Y);if(W===!0||W?.includes(Q)){if(!U)throw new Error("No secret is provided to cookie plugin");if(X){let G=await _U(B,U);if(G===!1)throw new hw(Q);B=G}else{let G=!0;for(let _=0;_<U.length;_++){let H=await _U(B,U[_]);if(H!==!1){G=!0,B=H;break}}if(!G)throw new hw(Q)}}Z[Q]={value:B}}return CU(w,Z,A)},pU=(w)=>{if(!w||!s2(w))return;let z=[];for(let[U,W]of Object.entries(w)){if(!U||!W)continue;let A=W.value;if(A===void 0||A===null)continue;z.push(y8.serialize(U,typeof A==="object"?JSON.stringify(A):A+"",W))}if(z.length===0)return;if(z.length===1)return z[0];return z},W6=(w,z)=>{let U=w.size;if(!z&&U||U&&z&&z.status!==206&&z.status!==304&&z.status!==412&&z.status!==416){if(z){if(z.headers instanceof Headers){let W={"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"};if(IU)W=z.headers.toJSON();else{W={};for(let[A,X]of z.headers.entries())if(A in z.headers)W[A]=X}return new Response(w,{status:z.status,headers:W})}if(s2(z.headers))return new Response(w,{status:z.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"},z.headers)})}return new Response(w,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"}})}return new Response(w)},oU=(w,z)=>{if(!w)return w;w.delete("set-cookie");for(let U=0;U<z.length;U++){let W=z[U].indexOf("=");w.append("set-cookie",`${z[U].slice(0,W)}=${z[U].slice(W+1)||""}`)}return w},B1=async(w,z,U)=>{let W=w.next();if(W instanceof Promise)W=await W;if(W.done){if(z)return E2(W.value,z,U);return A6(W.value,U)}return new Response(new ReadableStream({async start(A){let X=!1;if(U?.signal?.addEventListener("abort",()=>{X=!0;try{A.close()}catch{}}),W.value!==void 0&&W.value!==null)if(typeof W.value==="object")try{A.enqueue(Buffer.from(JSON.stringify(W.value)))}catch{A.enqueue(Buffer.from(W.value.toString()))}else A.enqueue(Buffer.from(W.value.toString()));for await(let Z of w){if(X)break;if(Z===void 0||Z===null)continue;if(typeof Z==="object")try{A.enqueue(Buffer.from(JSON.stringify(Z)))}catch{A.enqueue(Buffer.from(Z.toString()))}else A.enqueue(Buffer.from(Z.toString()));await new Promise(($)=>setTimeout(()=>$(),0))}try{A.close()}catch{}}}),{...z,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...z?.headers}})};async function*w4(w){let z=w.body;if(!z)return;let U=z.getReader(),W=new TextDecoder;try{while(!0){let{done:A,value:X}=await U.read();if(A)break;yield W.decode(X)}}finally{U.releaseLock()}}var lU=(w)=>{if(typeof w.status==="string")w.status=f8[w.status];if(w.cookie&&s2(w.cookie)){let z=pU(w.cookie);if(z)w.headers["set-cookie"]=z}if(w.headers["set-cookie"]&&Array.isArray(w.headers["set-cookie"]))w.headers=oU(new Headers(w.headers),w.headers["set-cookie"])},g8=(w,z)=>{if(w.status!==z.status&&z.status!==200&&(w.status<=300||w.status>400))w=new Response(w.body,{headers:w.headers,status:z.status});let U=!1;if(z.headers instanceof Headers)for(let W of z.headers.keys())if(W==="set-cookie"){if(U)continue;U=!0;for(let A of z.headers.getSetCookie())w.headers.append("set-cookie",A)}else w.headers.append(W,z.headers?.get(W)??"");else for(let W in z.headers)w.headers.append(W,z.headers[W]);return w},E2=(w,z,U)=>{if(s2(z.headers)||z.status!==200||z.cookie)switch(lU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,E2(w.response,z,U);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,z);case void 0:if(!w)return new Response("",z);return Response.json(w,z);case"Response":if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w;case"Error":return X6(w,z);case"Promise":return w.then((W)=>E2(W,z,U));case"Function":return E2(w(),z,U);case"Number":case"Boolean":return new Response(w.toString(),z);case"Cookie":if(w instanceof z4)return new Response(w.value,z);return new Response(w?.toString(),z);case"FormData":return new Response(w,z);default:if(w instanceof Response){if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w}if(w instanceof Promise)return w.then((W)=>E2(W,z));if(w instanceof Error)return X6(w,z);if(w instanceof M1)return z.status=w.code,E2(w.response,z,U);if(typeof w?.next==="function")return B1(w,z,U);if(typeof w?.then==="function")return w.then((W)=>E2(W,z));if(typeof w?.toResponse==="function")return E2(w.toResponse(),z);if("charCodeAt"in w){let W=w.charCodeAt(0);if(W===123||W===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w,z)}if(typeof w?.next==="function"||w instanceof ReadableStream||w instanceof Response&&w.headers.get("transfer-encoding")==="chunked")return B1(w,z,U);return A6(w,U)},K2=(w,z,U)=>{if(w===void 0||w===null)return;if(s2(z.headers)||z.status!==200||z.cookie)switch(lU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,K2(w.response,z,U);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,z);case void 0:if(!w)return;return Response.json(w,z);case"Response":if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w;case"Promise":return w.then((W)=>K2(W,z));case"Error":return X6(w,z);case"Function":return K2(w(),z);case"Number":case"Boolean":return new Response(w.toString(),z);case"FormData":return new Response(w);case"Cookie":if(w instanceof z4)return new Response(w.value,z);return new Response(w?.toString(),z);default:if(w instanceof Response){if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w}if(w instanceof Promise)return w.then((W)=>K2(W,z));if(w instanceof Error)return X6(w,z);if(w instanceof M1)return z.status=w.code,K2(w.response,z,U);if(typeof w?.next==="function")return B1(w,z,U);if(typeof w?.then==="function")return w.then((W)=>K2(W,z));if(typeof w?.toResponse==="function")return K2(w.toResponse(),z);if("charCodeAt"in w){let W=w.charCodeAt(0);if(W===123||W===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w,z)}else switch(w?.constructor?.name){case"String":return new Response(w);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,K2(w.response,z,U);case"ReadableStream":return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!w)return new Response("");return new Response(JSON.stringify(w),{headers:{"content-type":"application/json"}});case"Response":if(w.headers.get("transfer-encoding")==="chunked")return B1(w4(w));return w;case"Promise":return w.then((W)=>{let A=K2(W,z);if(A!==void 0)return A});case"Error":return X6(w,z);case"Function":return A6(w(),U);case"Number":case"Boolean":return new Response(w.toString());case"Cookie":if(w instanceof z4)return new Response(w.value,z);return new Response(w?.toString(),z);case"FormData":return new Response(w);default:if(w instanceof Response)return w;if(w instanceof Promise)return w.then((W)=>K2(W,z));if(w instanceof Error)return X6(w,z);if(w instanceof M1)return z.status=w.code,K2(w.response,z,U);if(typeof w?.next==="function")return B1(w,z,U);if(typeof w?.then==="function")return w.then((W)=>K2(W,z));if(typeof w?.toResponse==="function")return K2(w.toResponse(),z);if("charCodeAt"in w){let W=w.charCodeAt(0);if(W===123||W===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w)}},A6=(w,z)=>{switch(w?.constructor?.name){case"String":return new Response(w);case"Object":case"Array":return Response.json(w);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w);case"ElysiaCustomStatusResponse":return E2(w.response,{status:w.code,headers:{}});case"ReadableStream":return z?.signal?.addEventListener("abort",{handleEvent(){if(z?.signal&&!z?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!w)return new Response("");return new Response(JSON.stringify(w),{headers:{"content-type":"application/json"}});case"Response":if(w.headers.get("transfer-encoding")==="chunked")return B1(w4(w));return w;case"Error":return X6(w);case"Promise":return w.then((U)=>A6(U,z));case"Function":return A6(w(),z);case"Number":case"Boolean":return new Response(w.toString());case"FormData":return new Response(w);default:if(w instanceof Response)return w;if(w instanceof Promise)return w.then((U)=>A6(U,z));if(w instanceof Error)return X6(w);if(w instanceof M1)return E2(w.response,{status:w.code,headers:{}});if(typeof w?.next==="function")return B1(w,void 0,z);if(typeof w?.then==="function")return w.then((U)=>E2(U,set));if(typeof w?.toResponse==="function")return A6(w.toResponse());if("charCodeAt"in w){let U=w.charCodeAt(0);if(U===123||U===91)return new Response(JSON.stringify(w),{headers:{"Content-Type":"application/json"}})}return new Response(w)}},X6=(w,z)=>new Response(JSON.stringify({name:w?.name,message:w?.message,cause:w?.cause}),{status:z?.status!==200?z?.status??500:500,headers:z?.headers}),jH=(w,z,U={})=>{if(typeof w==="function")return;let W=E2(w,{headers:U});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0)return W.clone.bind(W)},I8={name:"web-standard",isWebStandard:!0,handler:{mapResponse:E2,mapEarlyResponse:K2,mapCompactResponse:A6,createStaticHandler:jH},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {}
2
+ var _X=Object.create;var{getPrototypeOf:SX,defineProperty:e5,getOwnPropertyNames:DX}=Object;var PX=Object.prototype.hasOwnProperty;var OX=(z,w,U)=>{U=z!=null?_X(SX(z)):{};let W=w||!z||!z.__esModule?e5(U,"default",{value:z,enumerable:!0}):U;for(let X of DX(z))if(!PX.call(W,X))e5(W,X,{get:()=>z[X],enumerable:!0});return W};var RX=(z,w)=>()=>(w||z((w={exports:{}}).exports,w),w.exports);var K6=(z,w)=>{for(var U in w)e5(z,U,{get:w[U],enumerable:!0,configurable:!0,set:(W)=>w[U]=()=>W})};var MW=RX((BW)=>{Object.defineProperty(BW,"__esModule",{value:!0});BW.parse=jN;BW.serialize=EN;var ON=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,RN=/^[\u0021-\u003A\u003C-\u007E]*$/,CN=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,bN=/^[\u0020-\u003A\u003D-\u007E]*$/,KN=Object.prototype.toString,FN=(()=>{let z=function(){};return z.prototype=Object.create(null),z})();function jN(z,w){let U=new FN,W=z.length;if(W<2)return U;let X=w?.decode||IN,A=0;do{let Z=z.indexOf("=",A);if(Z===-1)break;let $=z.indexOf(";",A),Y=$===-1?W:$;if(Z>Y){A=z.lastIndexOf(";",Z-1)+1;continue}let Q=QW(z,A,Z),J=JW(z,Z,Q),N=z.slice(Q,J);if(U[N]===void 0){let S=QW(z,Z+1,Y),G=JW(z,Y,S),O=X(z.slice(S,G));U[N]=O}A=Y+1}while(A<W);return U}function QW(z,w,U){do{let W=z.charCodeAt(w);if(W!==32&&W!==9)return w}while(++w<U);return U}function JW(z,w,U){while(w>U){let W=z.charCodeAt(--w);if(W!==32&&W!==9)return w+1}return U}function EN(z,w,U){let W=U?.encode||encodeURIComponent;if(!ON.test(z))throw new TypeError(`argument name is invalid: ${z}`);let X=W(w);if(!RN.test(X))throw new TypeError(`argument val is invalid: ${w}`);let A=z+"="+X;if(!U)return A;if(U.maxAge!==void 0){if(!Number.isInteger(U.maxAge))throw new TypeError(`option maxAge is invalid: ${U.maxAge}`);A+="; Max-Age="+U.maxAge}if(U.domain){if(!CN.test(U.domain))throw new TypeError(`option domain is invalid: ${U.domain}`);A+="; Domain="+U.domain}if(U.path){if(!bN.test(U.path))throw new TypeError(`option path is invalid: ${U.path}`);A+="; Path="+U.path}if(U.expires){if(!xN(U.expires)||!Number.isFinite(U.expires.valueOf()))throw new TypeError(`option expires is invalid: ${U.expires}`);A+="; Expires="+U.expires.toUTCString()}if(U.httpOnly)A+="; HttpOnly";if(U.secure)A+="; Secure";if(U.partitioned)A+="; Partitioned";if(U.priority)switch(typeof U.priority==="string"?U.priority.toLowerCase():void 0){case"low":A+="; Priority=Low";break;case"medium":A+="; Priority=Medium";break;case"high":A+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${U.priority}`)}if(U.sameSite)switch(typeof U.sameSite==="string"?U.sameSite.toLowerCase():U.sameSite){case!0:case"strict":A+="; SameSite=Strict";break;case"lax":A+="; SameSite=Lax";break;case"none":A+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${U.sameSite}`)}return A}function IN(z){if(z.indexOf("%")===-1)return z;try{return decodeURIComponent(z)}catch(w){return z}}function xN(z){return KN.call(z)==="[object Date]"}});var Mw;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(Mw||(Mw={}));var qw;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(qw||(qw={}));function zz(z){return Nw(z,CX,b4.Include)}function K4(z){return Nw(z,bX,b4.None)}function Nw(z,w,U){let W="";for(let X=0;X<z.byteLength;X+=3){let A=0,Z=0;for(let $=0;$<3&&X+$<z.byteLength;$++)A=A<<8|z[X+$],Z+=8;for(let $=0;$<4;$++)if(Z>=6)W+=w[A>>Z-6&63],Z-=6;else if(Z>0)W+=w[A<<6-Z&63],Z=0;else if(U===b4.Include)W+="="}return W}var CX="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bX="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var b4;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(b4||(b4={}));var Lw;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(Lw||(Lw={}));class Hw{uint8(z,w){if(z.byteLength<w+1)throw new TypeError("Insufficient bytes");return z[w]}uint16(z,w){if(z.byteLength<w+2)throw new TypeError("Insufficient bytes");return z[w]<<8|z[w+1]}uint32(z,w){if(z.byteLength<w+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=z[w+W]<<24-W*8;return U}uint64(z,w){if(z.byteLength<w+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(z[w+W])<<BigInt(56-W*8);return U}putUint8(z,w,U){if(z.length<U+1)throw new TypeError("Not enough space");if(w<0||w>255)throw new TypeError("Invalid uint8 value");z[U]=w}putUint16(z,w,U){if(z.length<U+2)throw new TypeError("Not enough space");if(w<0||w>65535)throw new TypeError("Invalid uint16 value");z[U]=w>>8,z[U+1]=w&255}putUint32(z,w,U){if(z.length<U+4)throw new TypeError("Not enough space");if(w<0||w>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)z[U+W]=w>>(3-W)*8&255}putUint64(z,w,U){if(z.length<U+8)throw new TypeError("Not enough space");if(w<0||w>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)z[U+W]=Number(w>>BigInt((7-W)*8)&0xffn)}}class _w{uint8(z,w){if(z.byteLength<w+1)throw new TypeError("Insufficient bytes");return z[w]}uint16(z,w){if(z.byteLength<w+2)throw new TypeError("Insufficient bytes");return z[w]|z[w+1]<<8}uint32(z,w){if(z.byteLength<w+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=z[w+W]<<W*8;return U}uint64(z,w){if(z.byteLength<w+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(z[w+W])<<BigInt(W*8);return U}putUint8(z,w,U){if(z.length<1+U)throw new TypeError("Insufficient space");if(w<0||w>255)throw new TypeError("Invalid uint8 value");z[U]=w}putUint16(z,w,U){if(z.length<2+U)throw new TypeError("Insufficient space");if(w<0||w>65535)throw new TypeError("Invalid uint16 value");z[U+1]=w>>8,z[U]=w&255}putUint32(z,w,U){if(z.length<4+U)throw new TypeError("Insufficient space");if(w<0||w>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)z[U+W]=w>>W*8&255}putUint64(z,w,U){if(z.length<8+U)throw new TypeError("Insufficient space");if(w<0||w>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)z[U+W]=Number(w>>BigInt(W*8)&0xffn)}}var j1=new Hw,KX=new _w;function c0(z,w){return(z<<32-w|z>>>w)>>>0}function v2(z,w){return(z<<BigInt(64-w)|z>>BigInt(w))&0xffffffffffffffffn}class Sw{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);l=0n;w=new Uint32Array(64);update(z){if(this.l+=BigInt(z.byteLength)*8n,this.currentBlockSize+z.byteLength<64){this.blocks.set(z,this.currentBlockSize),this.currentBlockSize+=z.byteLength;return}let w=0;if(this.currentBlockSize>0){let U=z.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),w+=U.byteLength,this.currentBlockSize=0}while(w+64<=z.byteLength){let U=z.slice(w,w+64);this.blocks.set(U),this.process(),w+=64}if(z.byteLength-w>0){let U=z.slice(w);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),j1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let z=new Uint8Array(28);for(let w=0;w<7;w++)j1.putUint32(z,this.H[w],w*4);return z}process(){for(let Y=0;Y<16;Y++)this.w[Y]=(this.blocks[Y*4]<<24|this.blocks[Y*4+1]<<16|this.blocks[Y*4+2]<<8|this.blocks[Y*4+3])>>>0;for(let Y=16;Y<64;Y++){let Q=(c0(this.w[Y-2],17)^c0(this.w[Y-2],19)^this.w[Y-2]>>>10)>>>0,J=(c0(this.w[Y-15],7)^c0(this.w[Y-15],18)^this.w[Y-15]>>>3)>>>0;this.w[Y]=Q+this.w[Y-7]+J+this.w[Y-16]|0}let z=this.H[0],w=this.H[1],U=this.H[2],W=this.H[3],X=this.H[4],A=this.H[5],Z=this.H[6],$=this.H[7];for(let Y=0;Y<64;Y++){let Q=(c0(X,6)^c0(X,11)^c0(X,25))>>>0,J=(X&A^~X&Z)>>>0,N=$+Q+J+FX[Y]+this.w[Y]|0,S=(c0(z,2)^c0(z,13)^c0(z,22))>>>0,G=(z&w^z&U^w&U)>>>0,O=S+G|0;$=Z,Z=A,A=X,X=W+N|0,W=U,U=w,w=z,z=N+O|0}this.H[0]=z+this.H[0]|0,this.H[1]=w+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=X+this.H[4]|0,this.H[5]=A+this.H[5]|0,this.H[6]=Z+this.H[6]|0,this.H[7]=$+this.H[7]|0}}var FX=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function wz(z){let w=new Uz;return w.update(z),w.digest()}class Uz{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);l=0n;w=new Uint32Array(64);update(z){if(this.l+=BigInt(z.byteLength)*8n,this.currentBlockSize+z.byteLength<64){this.blocks.set(z,this.currentBlockSize),this.currentBlockSize+=z.byteLength;return}let w=0;if(this.currentBlockSize>0){let U=z.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),w+=U.byteLength,this.currentBlockSize=0}while(w+64<=z.byteLength){let U=z.slice(w,w+64);this.blocks.set(U),this.process(),w+=64}if(z.byteLength-w>0){let U=z.slice(w);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),j1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let z=new Uint8Array(32);for(let w=0;w<8;w++)j1.putUint32(z,this.H[w],w*4);return z}process(){for(let Y=0;Y<16;Y++)this.w[Y]=(this.blocks[Y*4]<<24|this.blocks[Y*4+1]<<16|this.blocks[Y*4+2]<<8|this.blocks[Y*4+3])>>>0;for(let Y=16;Y<64;Y++){let Q=(c0(this.w[Y-2],17)^c0(this.w[Y-2],19)^this.w[Y-2]>>>10)>>>0,J=(c0(this.w[Y-15],7)^c0(this.w[Y-15],18)^this.w[Y-15]>>>3)>>>0;this.w[Y]=Q+this.w[Y-7]+J+this.w[Y-16]|0}let z=this.H[0],w=this.H[1],U=this.H[2],W=this.H[3],X=this.H[4],A=this.H[5],Z=this.H[6],$=this.H[7];for(let Y=0;Y<64;Y++){let Q=(c0(X,6)^c0(X,11)^c0(X,25))>>>0,J=(X&A^~X&Z)>>>0,N=$+Q+J+jX[Y]+this.w[Y]|0,S=(c0(z,2)^c0(z,13)^c0(z,22))>>>0,G=(z&w^z&U^w&U)>>>0,O=S+G|0;$=Z,Z=A,A=X,X=W+N|0,W=U,U=w,w=z,z=N+O|0}this.H[0]=z+this.H[0]|0,this.H[1]=w+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=X+this.H[4]|0,this.H[5]=A+this.H[5]|0,this.H[6]=Z+this.H[6]|0,this.H[7]=$+this.H[7]|0}}var jX=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);class Z6{blockSize=128;size=64;blocks=new Uint8Array(128);currentBlockSize=0;l=0n;w=new BigUint64Array(80);H;constructor(z){if(z.byteLength!==64)throw new TypeError;this.H=z}update(z){if(this.l+=BigInt(z.byteLength)*8n,this.currentBlockSize+z.byteLength<128){this.blocks.set(z,this.currentBlockSize),this.currentBlockSize+=z.byteLength;return}let w=0;if(this.currentBlockSize>0){let U=z.slice(0,128-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),w+=U.byteLength,this.currentBlockSize=0}while(w+128<=z.byteLength){let U=z.slice(w,w+128);this.blocks.set(U),this.process(),w+=128,this.currentBlockSize=0}if(z.byteLength-w>0){let U=z.slice(w);this.blocks.set(U),this.currentBlockSize=U.byteLength}}putDigest(z){if(z.byteLength>64||z.byteLength%8!==0)throw new TypeError;if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,128-this.currentBlockSize<16)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),j1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();for(let w=0;w<z.byteLength/8;w++)j1.putUint64(z,this.H[w],w*8)}process(){for(let Y=0;Y<16;Y++)this.w[Y]=BigInt(this.blocks[Y*8])<<56n|BigInt(this.blocks[Y*8+1])<<48n|BigInt(this.blocks[Y*8+2])<<40n|BigInt(this.blocks[Y*8+3])<<32n|BigInt(this.blocks[Y*8+4])<<24n|BigInt(this.blocks[Y*8+5])<<16n|BigInt(this.blocks[Y*8+6])<<8n|BigInt(this.blocks[Y*8+7]);for(let Y=16;Y<80;Y++){let Q=(v2(this.w[Y-2],19)^v2(this.w[Y-2],61)^this.w[Y-2]>>6n)&0xffffffffffffffffn,J=(v2(this.w[Y-15],1)^v2(this.w[Y-15],8)^this.w[Y-15]>>7n)&0xffffffffffffffffn;this.w[Y]=Q+this.w[Y-7]+J+this.w[Y-16]&0xffffffffffffffffn}let z=this.H[0],w=this.H[1],U=this.H[2],W=this.H[3],X=this.H[4],A=this.H[5],Z=this.H[6],$=this.H[7];for(let Y=0;Y<80;Y++){let Q=(v2(X,14)^v2(X,18)^v2(X,41))&0xffffffffffffffffn,J=(X&A^~X&Z)&0xffffffffffffffffn,N=$+Q+J+EX[Y]+this.w[Y]&0xffffffffffffffffn,S=(v2(z,28)^v2(z,34)^v2(z,39))&0xffffffffffffffffn,G=(z&w^z&U^w&U)&0xffffffffffffffffn,O=S+G&0xffffffffffffffffn;$=Z,Z=A,A=X,X=W+N&0xffffffffffffffffn,W=U,U=w,w=z,z=N+O&0xffffffffffffffffn}this.H[0]=z+this.H[0]&0xffffffffffffffffn,this.H[1]=w+this.H[1]&0xffffffffffffffffn,this.H[2]=U+this.H[2]&0xffffffffffffffffn,this.H[3]=W+this.H[3]&0xffffffffffffffffn,this.H[4]=X+this.H[4]&0xffffffffffffffffn,this.H[5]=A+this.H[5]&0xffffffffffffffffn,this.H[6]=Z+this.H[6]&0xffffffffffffffffn,this.H[7]=$+this.H[7]&0xffffffffffffffffn}}class Dw{blockSize=128;size=64;sha512=new Z6(new BigUint64Array([0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(64);return this.sha512.putDigest(z),z}}var EX=new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class Pw{blockSize=128;size=48;sha512=new Z6(new BigUint64Array([0xcbbb9d5dc1059ed8n,0x629a292a367cd507n,0x9159015a3070dd17n,0x152fecd8f70e5939n,0x67332667ffc00b31n,0x8eb44a8768581511n,0xdb0c2e0d64f98fa7n,0x47b5481dbefa4fa4n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(48);return this.sha512.putDigest(z),z}}class Ow{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x8c3d37c819544da2n,0x73e1996689dcd4d6n,0x1dfab7ae32ff9c82n,0x679dd514582f9fcfn,0x0f6d2b697bd44da8n,0x77e36f7304c48942n,0x3f9d85a86a1d36c8n,0x1112e6ad91d692a1n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(32);return this.sha512.putDigest(z),z.slice(0,28)}}class Rw{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x22312194fc2bf72cn,0x9f555fa3c84c64c2n,0x2393b86b6f53b151n,0x963877195940eabdn,0x96283ee2a88effe3n,0xbe5e1e2553863992n,0x2b0199fc2c85b8aan,0x0eb72ddc81c52ca2n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(32);return this.sha512.putDigest(z),z}}class o6{data;constructor(z){this.data=z}tokenType(){if("token_type"in this.data&&typeof this.data.token_type==="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token==="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in==="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1000)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token==="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token==="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope==="string"}scopes(){if("scope"in this.data&&typeof this.data.scope==="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token==="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function V2(z){let w=wz(new TextEncoder().encode(z));return K4(w)}function Wz(){let z=new Uint8Array(32);return crypto.getRandomValues(z),K4(z)}function Xz(){let z=new Uint8Array(32);return crypto.getRandomValues(z),K4(z)}function Cw(z,w){if(w.length!==1)throw new TypeError("Invalid character string");let U=0;while(U<z.length&&z[U]===w)U++;return z.slice(U)}function Az(z,w){if(w.length!==1)throw new TypeError("Invalid character string");let U=z.length;while(U>0&&z[U-1]===w)U--;return z.slice(0,U)}function r0(z,...w){let U=Az(z,"/");for(let W of w)U=Az(U,"/")+"/"+Cw(W,"/");return U}function g(z,w){let U=new TextEncoder().encode(w.toString()),W=new Request(z,{method:"POST",body:U});return W.headers.set("Content-Type","application/x-www-form-urlencoded"),W.headers.set("Accept","application/json"),W.headers.set("User-Agent","arctic"),W.headers.set("Content-Length",U.byteLength.toString()),W}function E1(z,w){let U=new TextEncoder().encode(`${z}:${w}`);return zz(U)}async function i(z){let w;try{w=await fetch(z)}catch(U){throw new $6(U)}if(w.status===400||w.status===401){let U;try{U=await w.json()}catch{throw new d1(w.status)}if(typeof U!=="object"||U===null)throw new Z1(w.status,U);let W;try{W=A8(U)}catch{throw new Z1(w.status,U)}throw W}if(w.status===200){let U;try{U=await w.json()}catch{throw new d1(w.status)}if(typeof U!=="object"||U===null)throw new Z1(w.status,U);return new o6(U)}if(w.body!==null)await w.body.cancel();throw new d1(w.status)}async function h1(z){let w;try{w=await fetch(z)}catch(U){throw new $6(U)}if(w.status===400||w.status===401){let U;try{U=await w.json()}catch{throw new Z1(w.status,null)}if(typeof U!=="object"||U===null)throw new Z1(w.status,U);let W;try{W=A8(U)}catch{throw new Z1(w.status,U)}throw W}if(w.status===200){if(w.body!==null)await w.body.cancel();return}if(w.body!==null)await w.body.cancel();throw new d1(w.status)}function A8(z){let w;if("error"in z&&typeof z.error==="string")w=z.error;else throw new Error("Invalid error response");let U=null,W=null,X=null;if("error_description"in z){if(typeof z.error_description!=="string")throw new Error("Invalid data");U=z.error_description}if("error_uri"in z){if(typeof z.error_uri!=="string")throw new Error("Invalid data");W=z.error_uri}if("state"in z){if(typeof z.state!=="string")throw new Error("Invalid data");X=z.state}return new F4(w,U,W,X)}class $6 extends Error{constructor(z){super("Failed to send request",{cause:z})}}class F4 extends Error{code;description;uri;state;constructor(z,w,U,W){super(`OAuth request error: ${z}`);this.code=z,this.description=w,this.uri=U,this.state=W}}class d1 extends Error{status;constructor(z){super("Unexpected error response");this.status=z}}class Z1 extends Error{status;data;constructor(z,w){super("Unexpected error response body");this.status=z,this.data=w}}class y{clientId;clientPassword;redirectURI;constructor(z,w,U){this.clientId=z,this.clientPassword=w,this.redirectURI=U}createAuthorizationURL(z,w,U){let W=new URL(z);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),this.redirectURI!==null)W.searchParams.set("redirect_uri",this.redirectURI);if(W.searchParams.set("state",w),U.length>0)W.searchParams.set("scope",U.join(" "));return W}createAuthorizationURLWithPKCE(z,w,U,W,X){let A=new URL(z);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),this.redirectURI!==null)A.searchParams.set("redirect_uri",this.redirectURI);if(A.searchParams.set("state",w),U===e.S256){let Z=V2(W);A.searchParams.set("code_challenge_method","S256"),A.searchParams.set("code_challenge",Z)}else if(U===e.Plain)A.searchParams.set("code_challenge_method","plain"),A.searchParams.set("code_challenge",W);if(X.length>0)A.searchParams.set("scope",X.join(" "));return A}async validateAuthorizationCode(z,w,U){let W=new URLSearchParams;if(W.set("grant_type","authorization_code"),W.set("code",w),this.redirectURI!==null)W.set("redirect_uri",this.redirectURI);if(U!==null)W.set("code_verifier",U);if(this.clientPassword===null)W.set("client_id",this.clientId);let X=g(z,W);if(this.clientPassword!==null){let Z=E1(this.clientId,this.clientPassword);X.headers.set("Authorization",`Basic ${Z}`)}return await i(X)}async refreshAccessToken(z,w,U){let W=new URLSearchParams;if(W.set("grant_type","refresh_token"),W.set("refresh_token",w),this.clientPassword===null)W.set("client_id",this.clientId);if(U.length>0)W.set("scope",U.join(" "));let X=g(z,W);if(this.clientPassword!==null){let Z=E1(this.clientId,this.clientPassword);X.headers.set("Authorization",`Basic ${Z}`)}return await i(X)}async revokeToken(z,w){let U=new URLSearchParams;if(U.set("token",w),this.clientPassword===null)U.set("client_id",this.clientId);let W=g(z,U);if(this.clientPassword!==null){let X=E1(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${X}`)}await h1(W)}}var e;(function(z){z[z.S256=0]="S256",z[z.Plain=1]="Plain"})(e||(e={}));class Z8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=`https://${z}/oauth2/authorize`,this.tokenEndpoint=`https://${z}/oauth2/token`,this.tokenRevocationEndpoint=`https://${z}/oauth2/revoke`,this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z,w){return await this.client.refreshAccessToken(this.tokenEndpoint,z,w)}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var xX="https://anilist.co/api/v2/oauth/authorize",VX="https://anilist.co/api/v2/oauth/token";class $8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z){return this.client.createAuthorizationURL(xX,z,[])}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(VX,z,null)}}var bw;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(bw||(bw={}));var Kw;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(Kw||(Kw={}));function F6(z){return kX(z,TX,Y8.None)}function kX(z,w,U){let W="";for(let X=0;X<z.byteLength;X+=3){let A=0,Z=0;for(let $=0;$<3&&X+$<z.byteLength;$++)A=A<<8|z[X+$],Z+=8;for(let $=0;$<4;$++)if(Z>=6)W+=w[A>>Z-6&63],Z-=6;else if(Z>0)W+=w[A<<6-Z&63],Z=0;else if(U===Y8.Include)W+="="}return W}var TX="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function Zz(z){return gX(z,fX,j4.Ignore)}function gX(z,w,U){let W=new Uint8Array(Math.ceil(z.length/4)*3),X=0;for(let A=0;A<z.length;A+=4){let Z=0,$=0;for(let Q=0;Q<4;Q++){if(U===j4.Required&&z[A+Q]==="=")continue;if(U===j4.Ignore&&(A+Q>=z.length||z[A+Q]==="="))continue;if(Q>0&&z[A+Q-1]==="=")throw new Error("Invalid padding");if(!(z[A+Q]in w))throw new Error("Invalid character");Z|=w[z[A+Q]]<<(3-Q)*6,$+=6}if($<24){let Q;if($===12)Q=Z&65535;else if($===18)Q=Z&255;else throw new Error("Invalid padding");if(Q!==0)throw new Error("Invalid padding")}let Y=Math.floor($/8);for(let Q=0;Q<Y;Q++)W[X]=Z>>16-Q*8&255,X++}return W.slice(0,X)}var Y8;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(Y8||(Y8={}));var j4;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(j4||(j4={}));var fX={"0":52,"1":53,"2":54,"3":55,"4":56,"5":57,"6":58,"7":59,"8":60,"9":61,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,"-":62,_:63};function Fw(z){let w=z.split(".");if(w.length!==3)throw new Error("Invalid JWT");let U;try{U=new TextDecoder().decode(Zz(w[1]))}catch{throw new Error("Invalid JWT: Invalid base64url encoding")}let W;try{W=JSON.parse(U)}catch{throw new Error("Invalid JWT: Invalid JSON encoding")}if(typeof W!=="object"||W===null)throw new Error("Invalid JWT: Invalid payload");return W}function jw(z,w,U){let W=F6(new TextEncoder().encode(z)),X=F6(new TextEncoder().encode(w)),A=F6(U);return W+"."+X+"."+A}function Ew(z,w){let U=F6(new TextEncoder().encode(z)),W=F6(new TextEncoder().encode(w)),X=U+"."+W;return new TextEncoder().encode(X)}var hX="https://appleid.apple.com/auth/authorize",cX="https://appleid.apple.com/auth/token";class Q8{clientId;teamId;keyId;pkcs8PrivateKey;redirectURI;constructor(z,w,U,W,X){this.clientId=z,this.teamId=w,this.keyId=U,this.pkcs8PrivateKey=W,this.redirectURI=X}createAuthorizationURL(z,w){let U=new URL(hX);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId);let U=await this.createClientSecret();w.set("client_secret",U);let W=g(cX,w);return await i(W)}async createClientSecret(){let z=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),w=Math.floor(Date.now()/1000),U=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),W=JSON.stringify({iss:this.teamId,exp:w+300,aud:["https://appleid.apple.com"],sub:this.clientId,iat:w}),X=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},z,Ew(U,W)));return jw(U,W,X)}}var iX="https://auth.atlassian.com/authorize",xw="https://auth.atlassian.com/oauth/token";class J8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(iX);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U.searchParams.set("audience","api.atlassian.com"),U.searchParams.set("prompt","consent"),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(xw,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(xw,w);return await i(U)}}class B8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=`https://${z}/authorize`,this.tokenEndpoint=`https://${z}/oauth/token`,this.tokenRevocationEndpoint=`https://${z}/oauth/revoke`,this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){let W;if(w!==null)W=this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,e.S256,w,U);else W=this.client.createAuthorizationURL(this.authorizationEndpoint,z,U);return W}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}class M8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=r0(z,"/application/o/authorize/"),this.tokenEndpoint=r0(z,"/application/o/token/"),this.tokenRevocationEndpoint=r0(z,"/application/o/revoke/"),this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var yX="https://bitbucket.org/site/oauth2/authorize",Vw="https://bitbucket.org/site/oauth2/access_token";class q8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z){return this.client.createAuthorizationURL(yX,z,[])}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(Vw,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(Vw,z,[])}}var vX="https://account.box.com/api/oauth2/authorize",kw="https://api.box.com/oauth2/token",nX="https://api.box.com/oauth2/revoke";class L8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(vX);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(kw,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(kw,w);return await i(U)}async revokeToken(z){let w=new URLSearchParams;w.set("token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(nX,w);await h1(U)}}var uX="https://www.coinbase.com/oauth/authorize",Tw="https://www.coinbase.com/oauth/token",mX="https://api.coinbase.com/oauth/revoke";class N8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(uX);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(Tw,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(Tw,w);return await i(U)}async revokeToken(z){let w=new URLSearchParams;w.set("token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(mX,w);await h1(U)}}var gw="https://discord.com/oauth2/authorize",fw="https://discord.com/api/oauth2/token",tX="https://discord.com/api/oauth2/token/revoke";class G8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){let W;if(w!==null)W=this.client.createAuthorizationURLWithPKCE(gw,z,e.S256,w,U);else W=this.client.createAuthorizationURL(gw,z,U);return W}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(fw,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(fw,z,[])}async revokeToken(z){await this.client.revokeToken(tX,z)}}var oX="https://dribbble.com/oauth/authorize",pX="https://dribbble.com/oauth/token";class H8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(oX);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(pX,w);return await i(U)}}var lX="https://www.dropbox.com/oauth2/authorize",dw="https://api.dropboxapi.com/oauth2/token",sX="https://api.dropboxapi.com/2/auth/token/revoke";class _8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(lX,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(dw,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(dw,z,[])}async revokeToken(z){await this.client.revokeToken(sX,z)}}var rX="https://www.facebook.com/v16.0/dialog/oauth",aX="https://graph.facebook.com/v16.0/oauth/access_token";class S8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(rX);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(aX,w);return await i(U)}}var eX="https://www.figma.com/oauth",zA="https://api.figma.com/v1/oauth/token",wA="https://api.figma.com/v1/oauth/refresh";class D8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(eX,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(zA,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(wA,z,[])}}var UA="https://github.com/login/oauth/authorize",hw="https://github.com/login/oauth/access_token";class P8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(UA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(z){let w=new URLSearchParams;if(w.set("grant_type","authorization_code"),w.set("code",z),this.redirectURI!==null)w.set("redirect_uri",this.redirectURI);let U=g(hw,w),W=E1(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await cw(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z);let U=g(hw,w),W=E1(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await cw(U)}}async function cw(z){let w;try{w=await fetch(z)}catch(X){throw new $6(X)}if(w.status!==200){if(w.body!==null)await w.body.cancel();throw new d1(w.status)}let U;try{U=await w.json()}catch{throw new d1(w.status)}if(typeof U!=="object"||U===null)throw new Z1(w.status,U);if("error"in U&&typeof U.error==="string"){let X;try{X=A8(U)}catch{throw new Z1(w.status,U)}throw X}return new o6(U)}class O8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=r0(z,"/oauth/authorize"),this.tokenEndpoint=r0(z,"/oauth/token"),this.tokenRevocationEndpoint=r0(z,"/oauth/revoke"),this.client=new y(w,U,W)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(this.authorizationEndpoint,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var WA="https://accounts.google.com/o/oauth2/v2/auth",iw="https://oauth2.googleapis.com/token",XA="https://oauth2.googleapis.com/revoke";class R8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(WA,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(iw,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(iw,z,[])}async revokeToken(z){await this.client.revokeToken(XA,z)}}var AA="https://appcenter.intuit.com/connect/oauth2",yw="https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",ZA="https://developer.API.intuit.com/v2/oauth2/tokens/revoke";class C8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(AA,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(yw,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(yw,z,[])}async revokeToken(z){await this.client.revokeToken(ZA,z)}}var $A="https://kauth.kakao.com/oauth/authorize",vw="https://kauth.kakao.com/oauth/token";class b8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL($A);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(vw,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(vw,w);return await i(U)}}class K8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=z+"/protocol/openid-connect/auth",this.tokenEndpoint=z+"/protocol/openid-connect/token",this.tokenRevocationEndpoint=z+"/protocol/openid-connect/revoke",this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var YA="https://lichess.org/oauth",QA="https://lichess.org/api/token";class F8{client;constructor(z,w){this.client=new y(z,null,w)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(YA,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(QA,z,w)}}var JA="https://access.line.me/oauth2/v2.1/authorize",nw="https://api.line.me/oauth2/v2.1/token";class j8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w,U){let W=new URL(JA);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),W.searchParams.set("state",z),U.length>0)W.searchParams.set("scope",U.join(" "));W.searchParams.set("redirect_uri",this.redirectURI);let X=V2(w);return W.searchParams.set("code_challenge_method","S256"),W.searchParams.set("code_challenge",X),W}async validateAuthorizationCode(z,w){let U=new URLSearchParams;U.set("grant_type","authorization_code"),U.set("code",z),U.set("code_verifier",w),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),U.set("client_secret",this.clientSecret);let W=g(nw,U);return await i(W)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(nw,w);return await i(U)}}var BA="https://linear.app/oauth/authorize",MA="https://api.linear.app/oauth/token";class E8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(BA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(MA,w);return await i(U)}}var qA="https://www.linkedin.com/oauth/v2/authorization",uw="https://www.linkedin.com/oauth/v2/accessToken";class I8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(qA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(uw,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(uw,w);return await i(U)}}class x8{authorizationEndpoint;tokenEndpoint;clientId;clientSecret;redirectURI;constructor(z,w,U,W){this.authorizationEndpoint=r0("https://login.microsoftonline.com",z,"/oauth2/v2.0/authorize"),this.tokenEndpoint=r0("https://login.microsoftonline.com",z,"/oauth2/v2.0/token"),this.clientId=w,this.clientSecret=U,this.redirectURI=W}createAuthorizationURL(z,w,U){let W=new URL(this.authorizationEndpoint);W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),W.searchParams.set("redirect_uri",this.redirectURI),W.searchParams.set("state",z);let X=V2(w);if(W.searchParams.set("code_challenge_method","S256"),W.searchParams.set("code_challenge",X),U.length>0)W.searchParams.set("scope",U.join(" "));return W}async validateAuthorizationCode(z,w){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",z),U.set("redirect_uri",this.redirectURI),U.set("code_verifier",w),this.clientSecret===null)U.set("client_id",this.clientId);let W=g(this.tokenEndpoint,U);if(this.clientSecret!==null){let A=E1(this.clientId,this.clientSecret);W.headers.set("Authorization",`Basic ${A}`)}else W.headers.set("Origin","arctic");return await i(W)}async refreshAccessToken(z,w){let U=new URLSearchParams;if(U.set("grant_type","refresh_token"),U.set("refresh_token",z),this.clientSecret===null)U.set("client_id",this.clientId);if(w.length>0)U.set("scope",w.join(" "));let W=g(this.tokenEndpoint,U);if(this.clientSecret!==null){let A=E1(this.clientId,this.clientSecret);W.headers.set("Authorization",`Basic ${A}`)}else W.headers.set("Origin","arctic");return await i(W)}}var LA="https://myanimelist.net/v1/oauth2/authorize",mw="https://myanimelist.net/v1/oauth2/token";class V8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURLWithPKCE(LA,z,e.Plain,w,[])}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(mw,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(mw,z,[])}}var NA="https://api.notion.com/v1/oauth/authorize",GA="https://api.notion.com/v1/oauth/token";class k8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z){let w=this.client.createAuthorizationURL(NA,z,[]);return w.searchParams.set("owner","user"),w}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(GA,z,null)}}class T8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W,X){let A=`https://${z}/oauth2`;if(w!==null)A=r0(A,w);this.authorizationEndpoint=r0(A,"/v1/authorize"),this.tokenEndpoint=r0(A,"/v1/token"),this.tokenRevocationEndpoint=r0(A,"/v1/revoke"),this.client=new y(U,W,X)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z,w){return await this.client.refreshAccessToken(this.tokenEndpoint,z,w)}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var HA="https://osu.ppy.sh/oauth/authorize",tw="https://osu.ppy.sh/oauth/token";class g8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(HA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(z){let w=new URLSearchParams;if(w.set("grant_type","authorization_code"),w.set("code",z),this.redirectURI!==null)w.set("redirect_uri",this.redirectURI);w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(tw,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(tw,w);return await i(U)}}var _A="https://www.patreon.com/oauth2/authorize",ow="https://www.patreon.com/api/oauth2/token";class f8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(_A);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(ow,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(ow,w);return await i(U)}}var SA="https://www.reddit.com/api/v1/authorize",pw="https://www.reddit.com/api/v1/access_token";class d8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(SA,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(pw,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(pw,z,[])}}var DA="https://apis.roblox.com/oauth/v1/authorize",lw="https://apis.roblox.com/oauth/v1/token",PA="https://apis.roblox.com/oauth/v1/token/revoke";class h8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(DA,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(lw,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(lw,z,[])}async revokeToken(z){await this.client.revokeToken(PA,z)}}class c8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=`https://${z}/services/oauth2/authorize`,this.tokenEndpoint=`https://${z}/services/oauth2/token`,this.tokenRevocationEndpoint=`https://${z}/services/oauth2/revoke`,this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var OA="https://shikimori.one/oauth/authorize",sw="https://shikimori.one/oauth/token";class i8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z){let w=new URL(OA);return w.searchParams.set("response_type","code"),w.searchParams.set("client_id",this.clientId),w.searchParams.set("state",z),w.searchParams.set("redirect_uri",this.redirectURI),w}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(sw,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(sw,w);return await i(U)}}var RA="https://slack.com/openid/connect/authorize",CA="https://slack.com/api/openid.connect.token";class y8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(RA,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(CA,z,null)}}var rw="https://accounts.spotify.com/authorize",aw="https://accounts.spotify.com/api/token";class v8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){let W;if(w!==null)W=this.client.createAuthorizationURLWithPKCE(rw,z,e.S256,w,U);else W=this.client.createAuthorizationURL(rw,z,U);return W}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(aw,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(aw,z,[])}}var bA="https://www.strava.com/oauth/authorize",ew="https://www.strava.com/api/v3/oauth/token";class n8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(bA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(","));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(ew,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(ew,w);return await i(U)}}var KA="https://v5api.tiltify.com/oauth/authorizeze",z9="https://v5api.tiltify.com/oauth/token";class u8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(KA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(z9,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(z9,w);return await i(U)}}var FA="https://www.tumblr.com/oauth2/authorize",w9="https://api.tumblr.com/v2/oauth2/token";class m8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(FA,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(w9,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(w9,z,[])}}var jA="https://id.twitch.tv/oauth2/authorize",U9="https://id.twitch.tv/oauth2/token";class t8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(jA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(U9,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(U9,w);return await i(U)}}var EA="https://twitter.com/i/oauth2/authorize",W9="https://api.twitter.com/2/oauth2/token",IA="https://api.twitter.com/2/oauth2/revoke";class o8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(EA,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(W9,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(W9,z,[])}async revokeToken(z){await this.client.revokeToken(IA,z)}}var xA="https://oauth.vk.com/authorize",VA="https://oauth.vk.com/access_token";class p8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(xA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(VA,w);return await i(U)}}var kA="https://api.workos.com/sso/authorize",TA="https://api.workos.com/sso/token";class l8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(kA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),U.searchParams.set("redirect_uri",this.redirectURI),w!==null){let W=V2(w);U.searchParams.set("code_challenge_method","S256"),U.searchParams.set("code_challenge",W)}return U}async validateAuthorizationCode(z,w){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",z),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),this.clientSecret!==null)U.set("client_secret",this.clientSecret);if(w!==null)U.set("code_verifier",w);let W=g(TA,U);return await i(W)}}var gA="https://api.login.yahoo.com/oauth2/request_auth",X9="https://api.login.yahoo.com/oauth2/get_token";class s8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(gA,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(X9,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(X9,z,[])}}var fA="https://oauth.yandex.com/authorize",A9="https://oauth.yandex.com/token";class r8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(fA,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(A9,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(A9,z,[])}}var dA="https://zoom.us/oauth/authorize",Z9="https://zoom.us/oauth/token",hA="https://zoom.us/oauth/revoke";class a8{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(dA,z,e.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(Z9,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(Z9,z,[])}async revokeToken(z){await this.client.revokeToken(hA,z)}}var cA="https://api.intra.42.fr/oauth/authorize",iA="https://api.intra.42.fr/oauth/token";class e8{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(cA);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=g(iA,w);return await i(U)}}function $z(z){try{return Fw(z)}catch(w){throw new Error("Invalid ID token",{cause:w})}}var p6=(z,w)=>{let U=w?.length?{}:null;if(U)for(let W of w)U[W.part.charCodeAt(0)]=W;return{part:z,store:null,inert:U,params:null,wildcardStore:null}},$9=(z,w)=>({...z,part:w}),Y9=(z)=>({name:z,store:null,inert:null});class j6{config;root={};history=[];deferred=[];constructor(z={}){if(this.config=z,z.lazy)this.find=this.lazyFind}static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};lazyFind=(z,w)=>{if(!this.config.lazy)return this.find;return this.build(),this.find(z,w)};build(){if(!this.config.lazy)return;for(let[z,w,U]of this.deferred)this.add(z,w,U,{lazy:!1,ignoreHistory:!0});this.deferred=[],this.find=(z,w)=>{let U=this.root[z];if(!U)return null;return z5(w,w.length,U,0)}}add(z,w,U,{ignoreError:W=!1,ignoreHistory:X=!1,lazy:A=this.config.lazy}={}){if(A)return this.find=this.lazyFind,this.deferred.push([z,w,U]),U;if(typeof w!=="string")throw new TypeError("Route path must be a string");if(w==="")w="/";else if(w[0]!=="/")w=`/${w}`;let Z=w[w.length-1]==="*",$=w.match(j6.regex.optionalParams);if($){let S=w.replaceAll("?","");this.add(z,S,U,{ignoreError:W,ignoreHistory:X,lazy:A});for(let G=0;G<$.length;G++){let O=w.replace("/"+$[G],"");this.add(z,O,U,{ignoreError:!0,ignoreHistory:X,lazy:A})}return U}if($)w=w.replaceAll("?","");if(this.history.find(([S,G,O])=>S===z&&G===w))return U;if(Z||$&&w.charCodeAt(w.length-1)===63)w=w.slice(0,-1);if(!X)this.history.push([z,w,U]);let Y=w.split(j6.regex.static),Q=w.match(j6.regex.params)||[];if(Y[Y.length-1]==="")Y.pop();let J;if(!this.root[z])J=this.root[z]=p6("/");else J=this.root[z];let N=0;for(let S=0;S<Y.length;++S){let G=Y[S];if(S>0){let O=Q[N++].slice(1);if(J.params===null)J.params=Y9(O);else if(J.params.name!==O)if(W)return U;else throw new Error(`Cannot create route "${w}" with parameter "${O}" because a route already exists with a different parameter name ("${J.params.name}") in the same location`);let M=J.params;if(M.inert===null){J=M.inert=p6(G);continue}J=M.inert}for(let O=0;;){if(O===G.length){if(O<J.part.length){let M=$9(J,J.part.slice(O));Object.assign(J,p6(G,[M]))}break}if(O===J.part.length){if(J.inert===null)J.inert={};let M=J.inert[G.charCodeAt(O)];if(M){J=M,G=G.slice(O),O=0;continue}let C=p6(G.slice(O));J.inert[G.charCodeAt(O)]=C,J=C;break}if(G[O]!==J.part[O]){let M=$9(J,J.part.slice(O)),C=p6(G.slice(O));Object.assign(J,p6(J.part.slice(0,O),[M,C])),J=C;break}++O}}if(N<Q.length){let S=Q[N].slice(1);if(J.params===null)J.params=Y9(S);else if(J.params.name!==S)if(W)return U;else throw new Error(`Cannot create route "${w}" with parameter "${S}" because a route already exists with a different parameter name ("${J.params.name}") in the same location`);if(J.params.store===null)J.params.store=U;return J.params.store}if(Z){if(J.wildcardStore===null)J.wildcardStore=U;return J.wildcardStore}if(J.store===null)J.store=U;return J.store}find(z,w){let U=this.root[z];if(!U)return null;return z5(w,w.length,U,0)}}var z5=(z,w,U,W)=>{let X=U.part,A=X.length,Z=W+A;if(A>1){if(Z>w)return null;if(A<15){for(let $=1,Y=W+1;$<A;++$,++Y)if(X.charCodeAt($)!==z.charCodeAt(Y))return null}else if(z.slice(W,Z)!==X)return null}if(Z===w){if(U.store!==null)return{store:U.store,params:{}};if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":""}};return null}if(U.inert!==null){let $=U.inert[z.charCodeAt(Z)];if($!==void 0){let Y=z5(z,w,$,Z);if(Y!==null)return Y}}if(U.params!==null){let{store:$,name:Y,inert:Q}=U.params,J=z.indexOf("/",Z);if(J!==Z){if(J===-1||J>=w){if($!==null){let N={};return N[Y]=z.substring(Z,w),{store:$,params:N}}}else if(Q!==null){let N=z5(z,w,Q,J);if(N!==null)return N.params[Y]=z.substring(Z,J),N}}}if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":z.substring(Z,w)}};return null};var Q2={};K6(Q2,{IsUndefined:()=>t0,IsUint8Array:()=>i1,IsSymbol:()=>Mz,IsString:()=>F0,IsRegExp:()=>I4,IsObject:()=>P0,IsNumber:()=>k2,IsNull:()=>Bz,IsIterator:()=>Jz,IsFunction:()=>Qz,IsDate:()=>E6,IsBoolean:()=>c1,IsBigInt:()=>E4,IsAsyncIterator:()=>Yz,IsArray:()=>m0,HasPropertyKey:()=>w5});function w5(z,w){return w in z}function Yz(z){return P0(z)&&!m0(z)&&!i1(z)&&Symbol.asyncIterator in z}function m0(z){return Array.isArray(z)}function E4(z){return typeof z==="bigint"}function c1(z){return typeof z==="boolean"}function E6(z){return z instanceof globalThis.Date}function Qz(z){return typeof z==="function"}function Jz(z){return P0(z)&&!m0(z)&&!i1(z)&&Symbol.iterator in z}function Bz(z){return z===null}function k2(z){return typeof z==="number"}function P0(z){return typeof z==="object"&&z!==null}function I4(z){return z instanceof globalThis.RegExp}function F0(z){return typeof z==="string"}function Mz(z){return typeof z==="symbol"}function i1(z){return z instanceof globalThis.Uint8Array}function t0(z){return z===void 0}function yA(z){return z.map((w)=>U5(w))}function vA(z){return new Date(z.getTime())}function nA(z){return new Uint8Array(z)}function uA(z){return new RegExp(z.source,z.flags)}function mA(z){let w={};for(let U of Object.getOwnPropertyNames(z))w[U]=U5(z[U]);for(let U of Object.getOwnPropertySymbols(z))w[U]=U5(z[U]);return w}function U5(z){return m0(z)?yA(z):E6(z)?vA(z):i1(z)?nA(z):I4(z)?uA(z):P0(z)?mA(z):z}function V0(z){return U5(z)}function l6(z,w){return w===void 0?V0(z):V0({...w,...z})}function W5(z){return l(z)&&globalThis.Symbol.asyncIterator in z}function X5(z){return l(z)&&globalThis.Symbol.iterator in z}function qz(z){return l(z)&&(globalThis.Object.getPrototypeOf(z)===Object.prototype||globalThis.Object.getPrototypeOf(z)===null)}function A5(z){return z instanceof globalThis.Promise}function N2(z){return z instanceof Date&&globalThis.Number.isFinite(z.getTime())}function Q9(z){return z instanceof globalThis.Map}function J9(z){return z instanceof globalThis.Set}function n2(z){return globalThis.ArrayBuffer.isView(z)}function s6(z){return z instanceof globalThis.Uint8Array}function u(z,w){return w in z}function l(z){return z!==null&&typeof z==="object"}function m(z){return globalThis.Array.isArray(z)&&!globalThis.ArrayBuffer.isView(z)}function k0(z){return z===void 0}function y1(z){return z===null}function I1(z){return typeof z==="boolean"}function v(z){return typeof z==="number"}function Z5(z){return globalThis.Number.isInteger(z)}function X2(z){return typeof z==="bigint"}function $0(z){return typeof z==="string"}function Y6(z){return typeof z==="function"}function v1(z){return typeof z==="symbol"}function T2(z){return X2(z)||I1(z)||y1(z)||v(z)||$0(z)||v1(z)||k0(z)}var I0;(function(z){z.InstanceMode="default",z.ExactOptionalPropertyTypes=!1,z.AllowArrayObject=!1,z.AllowNaN=!1,z.AllowNullVoid=!1;function w(Z,$){return z.ExactOptionalPropertyTypes?$ in Z:Z[$]!==void 0}z.IsExactOptionalProperty=w;function U(Z){let $=l(Z);return z.AllowArrayObject?$:$&&!m(Z)}z.IsObjectLike=U;function W(Z){return U(Z)&&!(Z instanceof Date)&&!(Z instanceof Uint8Array)}z.IsRecordLike=W;function X(Z){return z.AllowNaN?v(Z):Number.isFinite(Z)}z.IsNumberLike=X;function A(Z){let $=k0(Z);return z.AllowNullVoid?$||Z===null:$}z.IsVoidLike=A})(I0||(I0={}));function tA(z){return globalThis.Object.freeze(z).map((w)=>x4(w))}function oA(z){return z}function pA(z){return z}function lA(z){return z}function sA(z){let w={};for(let U of Object.getOwnPropertyNames(z))w[U]=x4(z[U]);for(let U of Object.getOwnPropertySymbols(z))w[U]=x4(z[U]);return globalThis.Object.freeze(w)}function x4(z){return m0(z)?tA(z):E6(z)?oA(z):i1(z)?pA(z):I4(z)?lA(z):P0(z)?sA(z):z}function D(z,w){let U=w!==void 0?{...w,...z}:z;switch(I0.InstanceMode){case"freeze":return x4(U);case"clone":return V0(U);default:return U}}class n extends Error{constructor(z){super(z)}}var j0=Symbol.for("TypeBox.Transform"),$1=Symbol.for("TypeBox.Readonly"),A2=Symbol.for("TypeBox.Optional"),u2=Symbol.for("TypeBox.Hint"),H=Symbol.for("TypeBox.Kind");function r6(z){return P0(z)&&z[$1]==="Readonly"}function S2(z){return P0(z)&&z[A2]==="Optional"}function Lz(z){return X0(z,"Any")}function Nz(z){return X0(z,"Argument")}function Y1(z){return X0(z,"Array")}function I6(z){return X0(z,"AsyncIterator")}function x6(z){return X0(z,"BigInt")}function n1(z){return X0(z,"Boolean")}function Q1(z){return X0(z,"Computed")}function J1(z){return X0(z,"Constructor")}function rA(z){return X0(z,"Date")}function B1(z){return X0(z,"Function")}function M1(z){return X0(z,"Integer")}function i0(z){return X0(z,"Intersect")}function V6(z){return X0(z,"Iterator")}function X0(z,w){return P0(z)&&H in z&&z[H]===w}function $5(z){return c1(z)||k2(z)||F0(z)}function g2(z){return X0(z,"Literal")}function f2(z){return X0(z,"MappedKey")}function T0(z){return X0(z,"MappedResult")}function Q6(z){return X0(z,"Never")}function aA(z){return X0(z,"Not")}function V4(z){return X0(z,"Null")}function q1(z){return X0(z,"Number")}function o0(z){return X0(z,"Object")}function k6(z){return X0(z,"Promise")}function T6(z){return X0(z,"Record")}function u0(z){return X0(z,"Ref")}function Gz(z){return X0(z,"RegExp")}function u1(z){return X0(z,"String")}function k4(z){return X0(z,"Symbol")}function d2(z){return X0(z,"TemplateLiteral")}function eA(z){return X0(z,"This")}function L0(z){return P0(z)&&j0 in z}function h2(z){return X0(z,"Tuple")}function m1(z){return X0(z,"Undefined")}function Y0(z){return X0(z,"Union")}function zZ(z){return X0(z,"Uint8Array")}function wZ(z){return X0(z,"Unknown")}function UZ(z){return X0(z,"Unsafe")}function WZ(z){return X0(z,"Void")}function J6(z){return P0(z)&&H in z&&F0(z[H])}function f0(z){return Lz(z)||Nz(z)||Y1(z)||n1(z)||x6(z)||I6(z)||Q1(z)||J1(z)||rA(z)||B1(z)||M1(z)||i0(z)||V6(z)||g2(z)||f2(z)||T0(z)||Q6(z)||aA(z)||V4(z)||q1(z)||o0(z)||k6(z)||T6(z)||u0(z)||Gz(z)||u1(z)||k4(z)||d2(z)||eA(z)||h2(z)||m1(z)||Y0(z)||zZ(z)||wZ(z)||UZ(z)||WZ(z)||J6(z)}var q={};K6(q,{TypeGuardUnknownTypeError:()=>B9,IsVoid:()=>a9,IsUnsafe:()=>r9,IsUnknown:()=>s9,IsUnionLiteral:()=>MZ,IsUnion:()=>Sz,IsUndefined:()=>p9,IsUint8Array:()=>l9,IsTuple:()=>o9,IsTransform:()=>t9,IsThis:()=>m9,IsTemplateLiteral:()=>u9,IsSymbol:()=>n9,IsString:()=>v9,IsSchema:()=>g0,IsRegExp:()=>y9,IsRef:()=>i9,IsRecursive:()=>BZ,IsRecord:()=>c9,IsReadonly:()=>$Z,IsProperties:()=>Y5,IsPromise:()=>h9,IsOptional:()=>YZ,IsObject:()=>d9,IsNumber:()=>f9,IsNull:()=>g9,IsNot:()=>T9,IsNever:()=>k9,IsMappedResult:()=>V9,IsMappedKey:()=>x9,IsLiteralValue:()=>I9,IsLiteralString:()=>j9,IsLiteralNumber:()=>E9,IsLiteralBoolean:()=>JZ,IsLiteral:()=>g4,IsKindOf:()=>z0,IsKind:()=>e9,IsIterator:()=>F9,IsIntersect:()=>K9,IsInteger:()=>b9,IsImport:()=>QZ,IsFunction:()=>C9,IsDate:()=>R9,IsConstructor:()=>O9,IsComputed:()=>P9,IsBoolean:()=>D9,IsBigInt:()=>S9,IsAsyncIterator:()=>_9,IsArray:()=>H9,IsArgument:()=>G9,IsAny:()=>N9});class B9 extends n{}var XZ=["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 M9(z){try{return new RegExp(z),!0}catch{return!1}}function Hz(z){if(!F0(z))return!1;for(let w=0;w<z.length;w++){let U=z.charCodeAt(w);if(U>=7&&U<=13||U===27||U===127)return!1}return!0}function q9(z){return _z(z)||g0(z)}function T4(z){return t0(z)||E4(z)}function E0(z){return t0(z)||k2(z)}function _z(z){return t0(z)||c1(z)}function O0(z){return t0(z)||F0(z)}function AZ(z){return t0(z)||F0(z)&&Hz(z)&&M9(z)}function ZZ(z){return t0(z)||F0(z)&&Hz(z)}function L9(z){return t0(z)||g0(z)}function $Z(z){return P0(z)&&z[$1]==="Readonly"}function YZ(z){return P0(z)&&z[A2]==="Optional"}function N9(z){return z0(z,"Any")&&O0(z.$id)}function G9(z){return z0(z,"Argument")&&k2(z.index)}function H9(z){return z0(z,"Array")&&z.type==="array"&&O0(z.$id)&&g0(z.items)&&E0(z.minItems)&&E0(z.maxItems)&&_z(z.uniqueItems)&&L9(z.contains)&&E0(z.minContains)&&E0(z.maxContains)}function _9(z){return z0(z,"AsyncIterator")&&z.type==="AsyncIterator"&&O0(z.$id)&&g0(z.items)}function S9(z){return z0(z,"BigInt")&&z.type==="bigint"&&O0(z.$id)&&T4(z.exclusiveMaximum)&&T4(z.exclusiveMinimum)&&T4(z.maximum)&&T4(z.minimum)&&T4(z.multipleOf)}function D9(z){return z0(z,"Boolean")&&z.type==="boolean"&&O0(z.$id)}function P9(z){return z0(z,"Computed")&&F0(z.target)&&m0(z.parameters)&&z.parameters.every((w)=>g0(w))}function O9(z){return z0(z,"Constructor")&&z.type==="Constructor"&&O0(z.$id)&&m0(z.parameters)&&z.parameters.every((w)=>g0(w))&&g0(z.returns)}function R9(z){return z0(z,"Date")&&z.type==="Date"&&O0(z.$id)&&E0(z.exclusiveMaximumTimestamp)&&E0(z.exclusiveMinimumTimestamp)&&E0(z.maximumTimestamp)&&E0(z.minimumTimestamp)&&E0(z.multipleOfTimestamp)}function C9(z){return z0(z,"Function")&&z.type==="Function"&&O0(z.$id)&&m0(z.parameters)&&z.parameters.every((w)=>g0(w))&&g0(z.returns)}function QZ(z){return z0(z,"Import")&&w5(z,"$defs")&&P0(z.$defs)&&Y5(z.$defs)&&w5(z,"$ref")&&F0(z.$ref)&&z.$ref in z.$defs}function b9(z){return z0(z,"Integer")&&z.type==="integer"&&O0(z.$id)&&E0(z.exclusiveMaximum)&&E0(z.exclusiveMinimum)&&E0(z.maximum)&&E0(z.minimum)&&E0(z.multipleOf)}function Y5(z){return P0(z)&&Object.entries(z).every(([w,U])=>Hz(w)&&g0(U))}function K9(z){return z0(z,"Intersect")&&(F0(z.type)&&z.type!=="object"?!1:!0)&&m0(z.allOf)&&z.allOf.every((w)=>g0(w)&&!t9(w))&&O0(z.type)&&(_z(z.unevaluatedProperties)||L9(z.unevaluatedProperties))&&O0(z.$id)}function F9(z){return z0(z,"Iterator")&&z.type==="Iterator"&&O0(z.$id)&&g0(z.items)}function z0(z,w){return P0(z)&&H in z&&z[H]===w}function j9(z){return g4(z)&&F0(z.const)}function E9(z){return g4(z)&&k2(z.const)}function JZ(z){return g4(z)&&c1(z.const)}function g4(z){return z0(z,"Literal")&&O0(z.$id)&&I9(z.const)}function I9(z){return c1(z)||k2(z)||F0(z)}function x9(z){return z0(z,"MappedKey")&&m0(z.keys)&&z.keys.every((w)=>k2(w)||F0(w))}function V9(z){return z0(z,"MappedResult")&&Y5(z.properties)}function k9(z){return z0(z,"Never")&&P0(z.not)&&Object.getOwnPropertyNames(z.not).length===0}function T9(z){return z0(z,"Not")&&g0(z.not)}function g9(z){return z0(z,"Null")&&z.type==="null"&&O0(z.$id)}function f9(z){return z0(z,"Number")&&z.type==="number"&&O0(z.$id)&&E0(z.exclusiveMaximum)&&E0(z.exclusiveMinimum)&&E0(z.maximum)&&E0(z.minimum)&&E0(z.multipleOf)}function d9(z){return z0(z,"Object")&&z.type==="object"&&O0(z.$id)&&Y5(z.properties)&&q9(z.additionalProperties)&&E0(z.minProperties)&&E0(z.maxProperties)}function h9(z){return z0(z,"Promise")&&z.type==="Promise"&&O0(z.$id)&&g0(z.item)}function c9(z){return z0(z,"Record")&&z.type==="object"&&O0(z.$id)&&q9(z.additionalProperties)&&P0(z.patternProperties)&&((w)=>{let U=Object.getOwnPropertyNames(w.patternProperties);return U.length===1&&M9(U[0])&&P0(w.patternProperties)&&g0(w.patternProperties[U[0]])})(z)}function BZ(z){return P0(z)&&u2 in z&&z[u2]==="Recursive"}function i9(z){return z0(z,"Ref")&&O0(z.$id)&&F0(z.$ref)}function y9(z){return z0(z,"RegExp")&&O0(z.$id)&&F0(z.source)&&F0(z.flags)&&E0(z.maxLength)&&E0(z.minLength)}function v9(z){return z0(z,"String")&&z.type==="string"&&O0(z.$id)&&E0(z.minLength)&&E0(z.maxLength)&&AZ(z.pattern)&&ZZ(z.format)}function n9(z){return z0(z,"Symbol")&&z.type==="symbol"&&O0(z.$id)}function u9(z){return z0(z,"TemplateLiteral")&&z.type==="string"&&F0(z.pattern)&&z.pattern[0]==="^"&&z.pattern[z.pattern.length-1]==="$"}function m9(z){return z0(z,"This")&&O0(z.$id)&&F0(z.$ref)}function t9(z){return P0(z)&&j0 in z}function o9(z){return z0(z,"Tuple")&&z.type==="array"&&O0(z.$id)&&k2(z.minItems)&&k2(z.maxItems)&&z.minItems===z.maxItems&&(t0(z.items)&&t0(z.additionalItems)&&z.minItems===0||m0(z.items)&&z.items.every((w)=>g0(w)))}function p9(z){return z0(z,"Undefined")&&z.type==="undefined"&&O0(z.$id)}function MZ(z){return Sz(z)&&z.anyOf.every((w)=>j9(w)||E9(w))}function Sz(z){return z0(z,"Union")&&O0(z.$id)&&P0(z)&&m0(z.anyOf)&&z.anyOf.every((w)=>g0(w))}function l9(z){return z0(z,"Uint8Array")&&z.type==="Uint8Array"&&O0(z.$id)&&E0(z.minByteLength)&&E0(z.maxByteLength)}function s9(z){return z0(z,"Unknown")&&O0(z.$id)}function r9(z){return z0(z,"Unsafe")}function a9(z){return z0(z,"Void")&&z.type==="void"&&O0(z.$id)}function e9(z){return P0(z)&&H in z&&F0(z[H])&&!XZ.includes(z[H])}function g0(z){return P0(z)&&(N9(z)||G9(z)||H9(z)||D9(z)||S9(z)||_9(z)||P9(z)||O9(z)||R9(z)||C9(z)||b9(z)||K9(z)||F9(z)||g4(z)||x9(z)||V9(z)||k9(z)||T9(z)||g9(z)||f9(z)||d9(z)||h9(z)||c9(z)||i9(z)||y9(z)||v9(z)||n9(z)||u9(z)||m9(z)||o9(z)||p9(z)||Sz(z)||l9(z)||s9(z)||r9(z)||a9(z)||e9(z))}var z7="(true|false)",Q5="(0|[1-9][0-9]*)",w7="(.*)";var x1="^(0|[1-9][0-9]*)$",V1="^(.*)$",U7="^(?!.*)$";var D0={};K6(D0,{Set:()=>HZ,Has:()=>GZ,Get:()=>_Z,Entries:()=>qZ,Delete:()=>NZ,Clear:()=>LZ});var a6=new Map;function qZ(){return new Map(a6)}function LZ(){return a6.clear()}function NZ(z){return a6.delete(z)}function GZ(z){return a6.has(z)}function HZ(z,w){a6.set(z,w)}function _Z(z){return a6.get(z)}var p0={};K6(p0,{Set:()=>RZ,Has:()=>OZ,Get:()=>CZ,Entries:()=>SZ,Delete:()=>PZ,Clear:()=>DZ});var e6=new Map;function SZ(){return new Map(e6)}function DZ(){return e6.clear()}function PZ(z){return e6.delete(z)}function OZ(z){return e6.has(z)}function RZ(z,w){e6.set(z,w)}function CZ(z){return e6.get(z)}function W7(z,w){return z.includes(w)}function X7(z){return[...new Set(z)]}function bZ(z,w){return z.filter((U)=>w.includes(U))}function KZ(z,w){return z.reduce((U,W)=>{return bZ(U,W)},w)}function A7(z){return z.length===1?z[0]:z.length>1?KZ(z.slice(1),z[0]):[]}function Z7(z){let w=[];for(let U of z)w.push(...U);return w}function B6(z){return D({[H]:"Any"},z)}function z4(z,w){return D({[H]:"Array",type:"array",items:z},w)}function $7(z){return D({[H]:"Argument",index:z})}function w4(z,w){return D({[H]:"AsyncIterator",type:"AsyncIterator",items:z},w)}function x0(z,w,U){return D({[H]:"Computed",target:z,parameters:w},U)}function FZ(z,w){let{[w]:U,...W}=z;return W}function y0(z,w){return w.reduce((U,W)=>FZ(U,W),z)}function p(z){return D({[H]:"Never",not:{}},z)}function Q0(z){return D({[H]:"MappedResult",properties:z})}function U4(z,w,U){return D({[H]:"Constructor",type:"Constructor",parameters:z,returns:w},U)}function k1(z,w,U){return D({[H]:"Function",type:"Function",parameters:z,returns:w},U)}function f4(z,w){return D({[H]:"Union",anyOf:z},w)}function jZ(z){return z.some((w)=>S2(w))}function Y7(z){return z.map((w)=>S2(w)?EZ(w):w)}function EZ(z){return y0(z,[A2])}function IZ(z,w){return jZ(z)?J2(f4(Y7(z),w)):f4(Y7(z),w)}function T1(z,w){return z.length===1?D(z[0],w):z.length===0?p(w):IZ(z,w)}function N0(z,w){return z.length===0?p(w):z.length===1?D(z[0],w):f4(z,w)}class Dz extends n{}function xZ(z){return z.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Pz(z,w,U){return z[w]===U&&z.charCodeAt(w-1)!==92}function o1(z,w){return Pz(z,w,"(")}function d4(z,w){return Pz(z,w,")")}function Q7(z,w){return Pz(z,w,"|")}function VZ(z){if(!(o1(z,0)&&d4(z,z.length-1)))return!1;let w=0;for(let U=0;U<z.length;U++){if(o1(z,U))w+=1;if(d4(z,U))w-=1;if(w===0&&U!==z.length-1)return!1}return!0}function kZ(z){return z.slice(1,z.length-1)}function TZ(z){let w=0;for(let U=0;U<z.length;U++){if(o1(z,U))w+=1;if(d4(z,U))w-=1;if(Q7(z,U)&&w===0)return!0}return!1}function gZ(z){for(let w=0;w<z.length;w++)if(o1(z,w))return!0;return!1}function fZ(z){let[w,U]=[0,0],W=[];for(let A=0;A<z.length;A++){if(o1(z,A))w+=1;if(d4(z,A))w-=1;if(Q7(z,A)&&w===0){let Z=z.slice(U,A);if(Z.length>0)W.push(W4(Z));U=A+1}}let X=z.slice(U);if(X.length>0)W.push(W4(X));if(W.length===0)return{type:"const",const:""};if(W.length===1)return W[0];return{type:"or",expr:W}}function dZ(z){function w(X,A){if(!o1(X,A))throw new Dz("TemplateLiteralParser: Index must point to open parens");let Z=0;for(let $=A;$<X.length;$++){if(o1(X,$))Z+=1;if(d4(X,$))Z-=1;if(Z===0)return[A,$]}throw new Dz("TemplateLiteralParser: Unclosed group parens in expression")}function U(X,A){for(let Z=A;Z<X.length;Z++)if(o1(X,Z))return[A,Z];return[A,X.length]}let W=[];for(let X=0;X<z.length;X++)if(o1(z,X)){let[A,Z]=w(z,X),$=z.slice(A,Z+1);W.push(W4($)),X=Z}else{let[A,Z]=U(z,X),$=z.slice(A,Z);if($.length>0)W.push(W4($));X=Z-1}return W.length===0?{type:"const",const:""}:W.length===1?W[0]:{type:"and",expr:W}}function W4(z){return VZ(z)?W4(kZ(z)):TZ(z)?fZ(z):gZ(z)?dZ(z):{type:"const",const:xZ(z)}}function X4(z){return W4(z.slice(1,z.length-1))}class J7 extends n{}function hZ(z){return z.type==="or"&&z.expr.length===2&&z.expr[0].type==="const"&&z.expr[0].const==="0"&&z.expr[1].type==="const"&&z.expr[1].const==="[1-9][0-9]*"}function cZ(z){return z.type==="or"&&z.expr.length===2&&z.expr[0].type==="const"&&z.expr[0].const==="true"&&z.expr[1].type==="const"&&z.expr[1].const==="false"}function iZ(z){return z.type==="const"&&z.const===".*"}function g6(z){return hZ(z)||iZ(z)?!1:cZ(z)?!0:z.type==="and"?z.expr.every((w)=>g6(w)):z.type==="or"?z.expr.every((w)=>g6(w)):z.type==="const"?!0:(()=>{throw new J7("Unknown expression type")})()}function J5(z){let w=X4(z.pattern);return g6(w)}class B7 extends n{}function*M7(z){if(z.length===1)return yield*z[0];for(let w of z[0])for(let U of M7(z.slice(1)))yield`${w}${U}`}function*yZ(z){return yield*M7(z.expr.map((w)=>[...h4(w)]))}function*vZ(z){for(let w of z.expr)yield*h4(w)}function*nZ(z){return yield z.const}function*h4(z){return z.type==="and"?yield*yZ(z):z.type==="or"?yield*vZ(z):z.type==="const"?yield*nZ(z):(()=>{throw new B7("Unknown expression")})()}function A4(z){let w=X4(z.pattern);return g6(w)?[...h4(w)]:[]}function A0(z,w){return D({[H]:"Literal",const:z,type:typeof z},w)}function B5(z){return D({[H]:"Boolean",type:"boolean"},z)}function Z4(z){return D({[H]:"BigInt",type:"bigint"},z)}function m2(z){return D({[H]:"Number",type:"number"},z)}function G2(z){return D({[H]:"String",type:"string"},z)}function*uZ(z){let w=z.trim().replace(/"|'/g,"");return w==="boolean"?yield B5():w==="number"?yield m2():w==="bigint"?yield Z4():w==="string"?yield G2():yield(()=>{let U=w.split("|").map((W)=>A0(W.trim()));return U.length===0?p():U.length===1?U[0]:T1(U)})()}function*mZ(z){if(z[1]!=="{"){let w=A0("$"),U=Oz(z.slice(1));return yield*[w,...U]}for(let w=2;w<z.length;w++)if(z[w]==="}"){let U=uZ(z.slice(2,w)),W=Oz(z.slice(w+1));return yield*[...U,...W]}yield A0(z)}function*Oz(z){for(let w=0;w<z.length;w++)if(z[w]==="$"){let U=A0(z.slice(0,w)),W=mZ(z.slice(w));return yield*[U,...W]}yield A0(z)}function q7(z){return[...Oz(z)]}class L7 extends n{}function tZ(z){return z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N7(z,w){return d2(z)?z.pattern.slice(1,z.pattern.length-1):Y0(z)?`(${z.anyOf.map((U)=>N7(U,w)).join("|")})`:q1(z)?`${w}${Q5}`:M1(z)?`${w}${Q5}`:x6(z)?`${w}${Q5}`:u1(z)?`${w}${w7}`:g2(z)?`${w}${tZ(z.const.toString())}`:n1(z)?`${w}${z7}`:(()=>{throw new L7(`Unexpected Kind '${z[H]}'`)})()}function Rz(z){return`^${z.map((w)=>N7(w,"")).join("")}$`}function f6(z){let U=A4(z).map((W)=>A0(W));return T1(U)}function M5(z,w){let U=F0(z)?Rz(q7(z)):Rz(z);return D({[H]:"TemplateLiteral",type:"string",pattern:U},w)}function oZ(z){return A4(z).map((U)=>U.toString())}function pZ(z){let w=[];for(let U of z)w.push(...D2(U));return w}function lZ(z){return[z.toString()]}function D2(z){return[...new Set(d2(z)?oZ(z):Y0(z)?pZ(z.anyOf):g2(z)?lZ(z.const):q1(z)?["[number]"]:M1(z)?["[number]"]:[])]}function sZ(z,w,U){let W={};for(let X of Object.getOwnPropertyNames(w))W[X]=M6(z,D2(w[X]),U);return W}function rZ(z,w,U){return sZ(z,w.properties,U)}function G7(z,w,U){let W=rZ(z,w,U);return Q0(W)}function _7(z,w){return z.map((U)=>S7(U,w))}function aZ(z){return z.filter((w)=>!Q6(w))}function eZ(z,w){return q5(aZ(_7(z,w)))}function z$(z){return z.some((w)=>Q6(w))?[]:z}function w$(z,w){return T1(z$(_7(z,w)))}function U$(z,w){return w in z?z[w]:w==="[number]"?T1(z):p()}function W$(z,w){return w==="[number]"?z:p()}function X$(z,w){return w in z?z[w]:p()}function S7(z,w){return i0(z)?eZ(z.allOf,w):Y0(z)?w$(z.anyOf,w):h2(z)?U$(z.items??[],w):Y1(z)?W$(z.items,w):o0(z)?X$(z.properties,w):p()}function c4(z,w){return w.map((U)=>S7(z,U))}function H7(z,w){return T1(c4(z,w))}function M6(z,w,U){if(u0(z)||u0(w)){if(!f0(z)||!f0(w))throw new n("Index types using Ref parameters require both Type and Key to be of TSchema");return x0("Index",[z,w])}if(T0(w))return G7(z,w,U);if(f2(w))return D7(z,w,U);return D(f0(w)?H7(z,D2(w)):H7(z,w),U)}function A$(z,w,U){return{[w]:M6(z,[w],V0(U))}}function Z$(z,w,U){return w.reduce((W,X)=>{return{...W,...A$(z,X,U)}},{})}function $$(z,w,U){return Z$(z,w.keys,U)}function D7(z,w,U){let W=$$(z,w,U);return Q0(W)}function $4(z,w){return D({[H]:"Iterator",type:"Iterator",items:z},w)}function Y$(z){let w=[];for(let U in z)if(!S2(z[U]))w.push(U);return w}function Q$(z,w){let U=Y$(z),W=U.length>0?{[H]:"Object",type:"object",properties:z,required:U}:{[H]:"Object",type:"object",properties:z};return D(W,w)}var G0=Q$;function L5(z,w){return D({[H]:"Promise",type:"Promise",item:z},w)}function J$(z){return D(y0(z,[$1]))}function B$(z){return D({...z,[$1]:"Readonly"})}function M$(z,w){return w===!1?J$(z):B$(z)}function P2(z,w){let U=w??!0;return T0(z)?P7(z,U):M$(z,U)}function q$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=P2(z[W],w);return U}function L$(z,w){return q$(z.properties,w)}function P7(z,w){let U=L$(z,w);return Q0(U)}function t2(z,w){return D(z.length>0?{[H]:"Tuple",type:"array",items:z,additionalItems:!1,minItems:z.length,maxItems:z.length}:{[H]:"Tuple",type:"array",minItems:z.length,maxItems:z.length},w)}function O7(z,w){return z in w?o2(z,w[z]):Q0(w)}function N$(z){return{[z]:A0(z)}}function G$(z){let w={};for(let U of z)w[U]=A0(U);return w}function H$(z,w){return W7(w,z)?N$(z):G$(w)}function _$(z,w){let U=H$(z,w);return O7(z,U)}function i4(z,w){return w.map((U)=>o2(z,U))}function S$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=o2(z,w[W]);return U}function o2(z,w){let U={...w};return S2(w)?J2(o2(z,y0(w,[A2]))):r6(w)?P2(o2(z,y0(w,[$1]))):T0(w)?O7(z,w.properties):f2(w)?_$(z,w.keys):J1(w)?U4(i4(z,w.parameters),o2(z,w.returns),U):B1(w)?k1(i4(z,w.parameters),o2(z,w.returns),U):I6(w)?w4(o2(z,w.items),U):V6(w)?$4(o2(z,w.items),U):i0(w)?B2(i4(z,w.allOf),U):Y0(w)?N0(i4(z,w.anyOf),U):h2(w)?t2(i4(z,w.items??[]),U):o0(w)?G0(S$(z,w.properties),U):Y1(w)?z4(o2(z,w.items),U):k6(w)?L5(o2(z,w.item),U):w}function D$(z,w){let U={};for(let W of z)U[W]=o2(W,w);return U}function R7(z,w,U){let W=f0(z)?D2(z):z,X=w({[H]:"MappedKey",keys:W}),A=D$(W,X);return G0(A,U)}function P$(z){return D(y0(z,[A2]))}function O$(z){return D({...z,[A2]:"Optional"})}function R$(z,w){return w===!1?P$(z):O$(z)}function J2(z,w){let U=w??!0;return T0(z)?C7(z,U):R$(z,U)}function C$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=J2(z[W],w);return U}function b$(z,w){return C$(z.properties,w)}function C7(z,w){let U=b$(z,w);return Q0(U)}function y4(z,w={}){let U=z.every((X)=>o0(X)),W=f0(w.unevaluatedProperties)?{unevaluatedProperties:w.unevaluatedProperties}:{};return D(w.unevaluatedProperties===!1||f0(w.unevaluatedProperties)||U?{...W,[H]:"Intersect",type:"object",allOf:z}:{...W,[H]:"Intersect",allOf:z},w)}function K$(z){return z.every((w)=>S2(w))}function F$(z){return y0(z,[A2])}function b7(z){return z.map((w)=>S2(w)?F$(w):w)}function j$(z,w){return K$(z)?J2(y4(b7(z),w)):y4(b7(z),w)}function q5(z,w={}){if(z.length===1)return D(z[0],w);if(z.length===0)return p(w);if(z.some((U)=>L0(U)))throw new Error("Cannot intersect transform types");return j$(z,w)}function B2(z,w){if(z.length===1)return D(z[0],w);if(z.length===0)return p(w);if(z.some((U)=>L0(U)))throw new Error("Cannot intersect transform types");return y4(z,w)}function p2(...z){let[w,U]=typeof z[0]==="string"?[z[0],z[1]]:[z[0].$id,z[1]];if(typeof w!=="string")throw new n("Ref: $ref must be a string");return D({[H]:"Ref",$ref:w},U)}function E$(z,w){return x0("Awaited",[x0(z,w)])}function I$(z){return x0("Awaited",[p2(z)])}function x$(z){return B2(K7(z))}function V$(z){return N0(K7(z))}function k$(z){return Y4(z)}function K7(z){return z.map((w)=>Y4(w))}function Y4(z,w){return D(Q1(z)?E$(z.target,z.parameters):i0(z)?x$(z.allOf):Y0(z)?V$(z.anyOf):k6(z)?k$(z.item):u0(z)?I$(z.$ref):z,w)}function F7(z){let w=[];for(let U of z)w.push(O2(U));return w}function T$(z){let w=F7(z);return Z7(w)}function g$(z){let w=F7(z);return A7(w)}function f$(z){return z.map((w,U)=>U.toString())}function d$(z){return["[number]"]}function h$(z){return globalThis.Object.getOwnPropertyNames(z)}function c$(z){if(!Cz)return[];return globalThis.Object.getOwnPropertyNames(z).map((U)=>{return U[0]==="^"&&U[U.length-1]==="$"?U.slice(1,U.length-1):U})}function O2(z){return i0(z)?T$(z.allOf):Y0(z)?g$(z.anyOf):h2(z)?f$(z.items??[]):Y1(z)?d$(z.items):o0(z)?h$(z.properties):T6(z)?c$(z.patternProperties):[]}var Cz=!1;function p1(z){Cz=!0;let w=O2(z);return Cz=!1,`^(${w.map((W)=>`(${W})`).join("|")})$`}function i$(z,w){return x0("KeyOf",[x0(z,w)])}function y$(z){return x0("KeyOf",[p2(z)])}function v$(z,w){let U=O2(z),W=n$(U),X=T1(W);return D(X,w)}function n$(z){return z.map((w)=>w==="[number]"?m2():A0(w))}function Q4(z,w){return Q1(z)?i$(z.target,z.parameters):u0(z)?y$(z.$ref):T0(z)?j7(z,w):v$(z,w)}function u$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=Q4(z[W],V0(w));return U}function m$(z,w){return u$(z.properties,w)}function j7(z,w){let U=m$(z,w);return Q0(U)}function N5(z){let w=O2(z),U=c4(z,w);return w.map((W,X)=>[w[X],U[X]])}function t$(z){let w=[];for(let U of z)w.push(...O2(U));return X7(w)}function o$(z){return z.filter((w)=>!Q6(w))}function p$(z,w){let U=[];for(let W of z)U.push(...c4(W,[w]));return o$(U)}function l$(z,w){let U={};for(let W of w)U[W]=q5(p$(z,W));return U}function E7(z,w){let U=t$(z),W=l$(z,U);return G0(W,w)}function G5(z){return D({[H]:"Date",type:"Date"},z)}function H5(z){return D({[H]:"Null",type:"null"},z)}function _5(z){return D({[H]:"Symbol",type:"symbol"},z)}function S5(z){return D({[H]:"Undefined",type:"undefined"},z)}function D5(z){return D({[H]:"Uint8Array",type:"Uint8Array"},z)}function L1(z){return D({[H]:"Unknown"},z)}function s$(z){return z.map((w)=>bz(w,!1))}function r$(z){let w={};for(let U of globalThis.Object.getOwnPropertyNames(z))w[U]=P2(bz(z[U],!1));return w}function P5(z,w){return w===!0?z:P2(z)}function bz(z,w){return Yz(z)?P5(B6(),w):Jz(z)?P5(B6(),w):m0(z)?P2(t2(s$(z))):i1(z)?D5():E6(z)?G5():P0(z)?P5(G0(r$(z)),w):Qz(z)?P5(k1([],L1()),w):t0(z)?S5():Bz(z)?H5():Mz(z)?_5():E4(z)?Z4():k2(z)?A0(z):c1(z)?A0(z):F0(z)?A0(z):G0({})}function I7(z,w){return D(bz(z,!0),w)}function x7(z,w){return J1(z)?t2(z.parameters,w):p(w)}function V7(z,w){if(t0(z))throw new Error("Enum undefined or empty");let U=globalThis.Object.getOwnPropertyNames(z).filter((A)=>isNaN(A)).map((A)=>z[A]),X=[...new Set(U)].map((A)=>A0(A));return N0(X,{...w,[u2]:"Enum"})}class d7 extends n{}var P;(function(z){z[z.Union=0]="Union",z[z.True=1]="True",z[z.False=2]="False"})(P||(P={}));function l2(z){return z===P.False?z:P.True}function J4(z){throw new d7(z)}function l0(z){return q.IsNever(z)||q.IsIntersect(z)||q.IsUnion(z)||q.IsUnknown(z)||q.IsAny(z)}function s0(z,w){return q.IsNever(w)?i7(z,w):q.IsIntersect(w)?O5(z,w):q.IsUnion(w)?Iz(z,w):q.IsUnknown(w)?u7(z,w):q.IsAny(w)?Ez(z,w):J4("StructuralRight")}function Ez(z,w){return P.True}function a$(z,w){return q.IsIntersect(w)?O5(z,w):q.IsUnion(w)&&w.anyOf.some((U)=>q.IsAny(U)||q.IsUnknown(U))?P.True:q.IsUnion(w)?P.Union:q.IsUnknown(w)?P.True:q.IsAny(w)?P.True:P.Union}function e$(z,w){return q.IsUnknown(z)?P.False:q.IsAny(z)?P.Union:q.IsNever(z)?P.True:P.False}function zY(z,w){return q.IsObject(w)&&R5(w)?P.True:l0(w)?s0(z,w):!q.IsArray(w)?P.False:l2(R0(z.items,w.items))}function wY(z,w){return l0(w)?s0(z,w):!q.IsAsyncIterator(w)?P.False:l2(R0(z.items,w.items))}function UY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsBigInt(w)?P.True:P.False}function h7(z,w){return q.IsLiteralBoolean(z)?P.True:q.IsBoolean(z)?P.True:P.False}function WY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsBoolean(w)?P.True:P.False}function XY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):!q.IsConstructor(w)?P.False:z.parameters.length>w.parameters.length?P.False:!z.parameters.every((U,W)=>l2(R0(w.parameters[W],U))===P.True)?P.False:l2(R0(z.returns,w.returns))}function AY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsDate(w)?P.True:P.False}function ZY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):!q.IsFunction(w)?P.False:z.parameters.length>w.parameters.length?P.False:!z.parameters.every((U,W)=>l2(R0(w.parameters[W],U))===P.True)?P.False:l2(R0(z.returns,w.returns))}function c7(z,w){return q.IsLiteral(z)&&Q2.IsNumber(z.const)?P.True:q.IsNumber(z)||q.IsInteger(z)?P.True:P.False}function $Y(z,w){return q.IsInteger(w)||q.IsNumber(w)?P.True:l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):P.False}function O5(z,w){return w.allOf.every((U)=>R0(z,U)===P.True)?P.True:P.False}function YY(z,w){return z.allOf.some((U)=>R0(U,w)===P.True)?P.True:P.False}function QY(z,w){return l0(w)?s0(z,w):!q.IsIterator(w)?P.False:l2(R0(z.items,w.items))}function JY(z,w){return q.IsLiteral(w)&&w.const===z.const?P.True:l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsString(w)?n7(z,w):q.IsNumber(w)?y7(z,w):q.IsInteger(w)?c7(z,w):q.IsBoolean(w)?h7(z,w):P.False}function i7(z,w){return P.False}function BY(z,w){return P.True}function k7(z){let[w,U]=[z,0];while(!0){if(!q.IsNot(w))break;w=w.not,U+=1}return U%2===0?w:L1()}function MY(z,w){return q.IsNot(z)?R0(k7(z),w):q.IsNot(w)?R0(z,k7(w)):J4("Invalid fallthrough for Not")}function qY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsNull(w)?P.True:P.False}function y7(z,w){return q.IsLiteralNumber(z)?P.True:q.IsNumber(z)||q.IsInteger(z)?P.True:P.False}function LY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsInteger(w)||q.IsNumber(w)?P.True:P.False}function R2(z,w){return Object.getOwnPropertyNames(z.properties).length===w}function T7(z){return R5(z)}function g7(z){return R2(z,0)||R2(z,1)&&"description"in z.properties&&q.IsUnion(z.properties.description)&&z.properties.description.anyOf.length===2&&(q.IsString(z.properties.description.anyOf[0])&&q.IsUndefined(z.properties.description.anyOf[1])||q.IsString(z.properties.description.anyOf[1])&&q.IsUndefined(z.properties.description.anyOf[0]))}function Kz(z){return R2(z,0)}function f7(z){return R2(z,0)}function NY(z){return R2(z,0)}function GY(z){return R2(z,0)}function HY(z){return R5(z)}function _Y(z){let w=m2();return R2(z,0)||R2(z,1)&&"length"in z.properties&&l2(R0(z.properties.length,w))===P.True}function SY(z){return R2(z,0)}function R5(z){let w=m2();return R2(z,0)||R2(z,1)&&"length"in z.properties&&l2(R0(z.properties.length,w))===P.True}function DY(z){let w=k1([B6()],B6());return R2(z,0)||R2(z,1)&&"then"in z.properties&&l2(R0(z.properties.then,w))===P.True}function v7(z,w){return R0(z,w)===P.False?P.False:q.IsOptional(z)&&!q.IsOptional(w)?P.False:P.True}function M2(z,w){return q.IsUnknown(z)?P.False:q.IsAny(z)?P.Union:q.IsNever(z)||q.IsLiteralString(z)&&T7(w)||q.IsLiteralNumber(z)&&Kz(w)||q.IsLiteralBoolean(z)&&f7(w)||q.IsSymbol(z)&&g7(w)||q.IsBigInt(z)&&NY(w)||q.IsString(z)&&T7(w)||q.IsSymbol(z)&&g7(w)||q.IsNumber(z)&&Kz(w)||q.IsInteger(z)&&Kz(w)||q.IsBoolean(z)&&f7(w)||q.IsUint8Array(z)&&HY(w)||q.IsDate(z)&&GY(w)||q.IsConstructor(z)&&SY(w)||q.IsFunction(z)&&_Y(w)?P.True:q.IsRecord(z)&&q.IsString(Fz(z))?(()=>{return w[u2]==="Record"?P.True:P.False})():q.IsRecord(z)&&q.IsNumber(Fz(z))?(()=>{return R2(w,0)?P.True:P.False})():P.False}function PY(z,w){return l0(w)?s0(z,w):q.IsRecord(w)?s2(z,w):!q.IsObject(w)?P.False:(()=>{for(let U of Object.getOwnPropertyNames(w.properties)){if(!(U in z.properties)&&!q.IsOptional(w.properties[U]))return P.False;if(q.IsOptional(w.properties[U]))return P.True;if(v7(z.properties[U],w.properties[U])===P.False)return P.False}return P.True})()}function OY(z,w){return l0(w)?s0(z,w):q.IsObject(w)&&DY(w)?P.True:!q.IsPromise(w)?P.False:l2(R0(z.item,w.item))}function Fz(z){return x1 in z.patternProperties?m2():(V1 in z.patternProperties)?G2():J4("Unknown record key pattern")}function jz(z){return x1 in z.patternProperties?z.patternProperties[x1]:(V1 in z.patternProperties)?z.patternProperties[V1]:J4("Unable to get record value schema")}function s2(z,w){let[U,W]=[Fz(w),jz(w)];return q.IsLiteralString(z)&&q.IsNumber(U)&&l2(R0(z,W))===P.True?P.True:q.IsUint8Array(z)&&q.IsNumber(U)?R0(z,W):q.IsString(z)&&q.IsNumber(U)?R0(z,W):q.IsArray(z)&&q.IsNumber(U)?R0(z,W):q.IsObject(z)?(()=>{for(let X of Object.getOwnPropertyNames(z.properties))if(v7(W,z.properties[X])===P.False)return P.False;return P.True})():P.False}function RY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):!q.IsRecord(w)?P.False:R0(jz(z),jz(w))}function CY(z,w){let U=q.IsRegExp(z)?G2():z,W=q.IsRegExp(w)?G2():w;return R0(U,W)}function n7(z,w){return q.IsLiteral(z)&&Q2.IsString(z.const)?P.True:q.IsString(z)?P.True:P.False}function bY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsString(w)?P.True:P.False}function KY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsSymbol(w)?P.True:P.False}function FY(z,w){return q.IsTemplateLiteral(z)?R0(f6(z),w):q.IsTemplateLiteral(w)?R0(z,f6(w)):J4("Invalid fallthrough for TemplateLiteral")}function jY(z,w){return q.IsArray(w)&&z.items!==void 0&&z.items.every((U)=>R0(U,w.items)===P.True)}function EY(z,w){return q.IsNever(z)?P.True:q.IsUnknown(z)?P.False:q.IsAny(z)?P.Union:P.False}function IY(z,w){return l0(w)?s0(z,w):q.IsObject(w)&&R5(w)?P.True:q.IsArray(w)&&jY(z,w)?P.True:!q.IsTuple(w)?P.False:Q2.IsUndefined(z.items)&&!Q2.IsUndefined(w.items)||!Q2.IsUndefined(z.items)&&Q2.IsUndefined(w.items)?P.False:Q2.IsUndefined(z.items)&&!Q2.IsUndefined(w.items)?P.True:z.items.every((U,W)=>R0(U,w.items[W])===P.True)?P.True:P.False}function xY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsUint8Array(w)?P.True:P.False}function VY(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?s2(z,w):q.IsVoid(w)?gY(z,w):q.IsUndefined(w)?P.True:P.False}function Iz(z,w){return w.anyOf.some((U)=>R0(z,U)===P.True)?P.True:P.False}function kY(z,w){return z.anyOf.every((U)=>R0(U,w)===P.True)?P.True:P.False}function u7(z,w){return P.True}function TY(z,w){return q.IsNever(w)?i7(z,w):q.IsIntersect(w)?O5(z,w):q.IsUnion(w)?Iz(z,w):q.IsAny(w)?Ez(z,w):q.IsString(w)?n7(z,w):q.IsNumber(w)?y7(z,w):q.IsInteger(w)?c7(z,w):q.IsBoolean(w)?h7(z,w):q.IsArray(w)?e$(z,w):q.IsTuple(w)?EY(z,w):q.IsObject(w)?M2(z,w):q.IsUnknown(w)?P.True:P.False}function gY(z,w){return q.IsUndefined(z)?P.True:q.IsUndefined(z)?P.True:P.False}function fY(z,w){return q.IsIntersect(w)?O5(z,w):q.IsUnion(w)?Iz(z,w):q.IsUnknown(w)?u7(z,w):q.IsAny(w)?Ez(z,w):q.IsObject(w)?M2(z,w):q.IsVoid(w)?P.True:P.False}function R0(z,w){return q.IsTemplateLiteral(z)||q.IsTemplateLiteral(w)?FY(z,w):q.IsRegExp(z)||q.IsRegExp(w)?CY(z,w):q.IsNot(z)||q.IsNot(w)?MY(z,w):q.IsAny(z)?a$(z,w):q.IsArray(z)?zY(z,w):q.IsBigInt(z)?UY(z,w):q.IsBoolean(z)?WY(z,w):q.IsAsyncIterator(z)?wY(z,w):q.IsConstructor(z)?XY(z,w):q.IsDate(z)?AY(z,w):q.IsFunction(z)?ZY(z,w):q.IsInteger(z)?$Y(z,w):q.IsIntersect(z)?YY(z,w):q.IsIterator(z)?QY(z,w):q.IsLiteral(z)?JY(z,w):q.IsNever(z)?BY(z,w):q.IsNull(z)?qY(z,w):q.IsNumber(z)?LY(z,w):q.IsObject(z)?PY(z,w):q.IsRecord(z)?RY(z,w):q.IsString(z)?bY(z,w):q.IsSymbol(z)?KY(z,w):q.IsTuple(z)?IY(z,w):q.IsPromise(z)?OY(z,w):q.IsUint8Array(z)?xY(z,w):q.IsUndefined(z)?VY(z,w):q.IsUnion(z)?kY(z,w):q.IsUnknown(z)?TY(z,w):q.IsVoid(z)?fY(z,w):J4(`Unknown left type operand '${z[H]}'`)}function q6(z,w){return R0(z,w)}function dY(z,w,U,W,X){let A={};for(let Z of globalThis.Object.getOwnPropertyNames(z))A[Z]=B4(z[Z],w,U,W,V0(X));return A}function hY(z,w,U,W,X){return dY(z.properties,w,U,W,X)}function m7(z,w,U,W,X){let A=hY(z,w,U,W,X);return Q0(A)}function cY(z,w,U,W){let X=q6(z,w);return X===P.Union?N0([U,W]):X===P.True?U:W}function B4(z,w,U,W,X){return T0(z)?m7(z,w,U,W,X):f2(z)?D(t7(z,w,U,W,X)):D(cY(z,w,U,W),X)}function iY(z,w,U,W,X){return{[z]:B4(A0(z),w,U,W,V0(X))}}function yY(z,w,U,W,X){return z.reduce((A,Z)=>{return{...A,...iY(Z,w,U,W,X)}},{})}function vY(z,w,U,W,X){return yY(z.keys,w,U,W,X)}function t7(z,w,U,W,X){let A=vY(z,w,U,W,X);return Q0(A)}function nY(z){return z.allOf.every((w)=>l1(w))}function uY(z){return z.anyOf.some((w)=>l1(w))}function mY(z){return!l1(z.not)}function l1(z){return z[H]==="Intersect"?nY(z):z[H]==="Union"?uY(z):z[H]==="Not"?mY(z):z[H]==="Undefined"?!0:!1}function o7(z,w){return M4(f6(z),w)}function tY(z,w){let U=z.filter((W)=>q6(W,w)===P.False);return U.length===1?U[0]:N0(U)}function M4(z,w,U={}){if(d2(z))return D(o7(z,w),U);if(T0(z))return D(p7(z,w),U);return D(Y0(z)?tY(z.anyOf,w):q6(z,w)!==P.False?p():z,U)}function oY(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=M4(z[W],w);return U}function pY(z,w){return oY(z.properties,w)}function p7(z,w){let U=pY(z,w);return Q0(U)}function l7(z,w){return q4(f6(z),w)}function lY(z,w){let U=z.filter((W)=>q6(W,w)!==P.False);return U.length===1?U[0]:N0(U)}function q4(z,w,U){if(d2(z))return D(l7(z,w),U);if(T0(z))return D(s7(z,w),U);return D(Y0(z)?lY(z.anyOf,w):q6(z,w)!==P.False?z:p(),U)}function sY(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=q4(z[W],w);return U}function rY(z,w){return sY(z.properties,w)}function s7(z,w){let U=rY(z,w);return Q0(U)}function r7(z,w){return J1(z)?D(z.returns,w):p(w)}function C5(z){return P2(J2(z))}function d6(z,w,U){return D({[H]:"Record",type:"object",patternProperties:{[z]:w}},U)}function xz(z,w,U){let W={};for(let X of z)W[X]=w;return G0(W,{...U,[u2]:"Record"})}function aY(z,w,U){return J5(z)?xz(D2(z),w,U):d6(z.pattern,w,U)}function eY(z,w,U){return xz(D2(N0(z)),w,U)}function zQ(z,w,U){return xz([z.toString()],w,U)}function wQ(z,w,U){return d6(z.source,w,U)}function UQ(z,w,U){let W=t0(z.pattern)?V1:z.pattern;return d6(W,w,U)}function WQ(z,w,U){return d6(V1,w,U)}function XQ(z,w,U){return d6(U7,w,U)}function AQ(z,w,U){return G0({true:w,false:w},U)}function ZQ(z,w,U){return d6(x1,w,U)}function $Q(z,w,U){return d6(x1,w,U)}function b5(z,w,U={}){return Y0(z)?eY(z.anyOf,w,U):d2(z)?aY(z,w,U):g2(z)?zQ(z.const,w,U):n1(z)?AQ(z,w,U):M1(z)?ZQ(z,w,U):q1(z)?$Q(z,w,U):Gz(z)?wQ(z,w,U):u1(z)?UQ(z,w,U):Lz(z)?WQ(z,w,U):Q6(z)?XQ(z,w,U):p(U)}function K5(z){return globalThis.Object.getOwnPropertyNames(z.patternProperties)[0]}function a7(z){let w=K5(z);return w===V1?G2():w===x1?m2():G2({pattern:w})}function F5(z){return z.patternProperties[K5(z)]}function YQ(z,w){return w.parameters=v4(z,w.parameters),w.returns=N1(z,w.returns),w}function QQ(z,w){return w.parameters=v4(z,w.parameters),w.returns=N1(z,w.returns),w}function JQ(z,w){return w.allOf=v4(z,w.allOf),w}function BQ(z,w){return w.anyOf=v4(z,w.anyOf),w}function MQ(z,w){if(t0(w.items))return w;return w.items=v4(z,w.items),w}function qQ(z,w){return w.items=N1(z,w.items),w}function LQ(z,w){return w.items=N1(z,w.items),w}function NQ(z,w){return w.items=N1(z,w.items),w}function GQ(z,w){return w.item=N1(z,w.item),w}function HQ(z,w){let U=PQ(z,w.properties);return{...w,...G0(U)}}function _Q(z,w){let U=N1(z,a7(w)),W=N1(z,F5(w)),X=b5(U,W);return{...w,...X}}function SQ(z,w){return w.index in z?z[w.index]:L1()}function DQ(z,w){let U=r6(w),W=S2(w),X=N1(z,w);return U&&W?C5(X):U&&!W?P2(X):!U&&W?J2(X):X}function PQ(z,w){return globalThis.Object.getOwnPropertyNames(w).reduce((U,W)=>{return{...U,[W]:DQ(z,w[W])}},{})}function v4(z,w){return w.map((U)=>N1(z,U))}function N1(z,w){return J1(w)?YQ(z,w):B1(w)?QQ(z,w):i0(w)?JQ(z,w):Y0(w)?BQ(z,w):h2(w)?MQ(z,w):Y1(w)?qQ(z,w):I6(w)?LQ(z,w):V6(w)?NQ(z,w):k6(w)?GQ(z,w):o0(w)?HQ(z,w):T6(w)?_Q(z,w):Nz(w)?SQ(z,w):w}function e7(z,w){return N1(w,l6(z))}function zU(z){return D({[H]:"Integer",type:"integer"},z)}function OQ(z,w,U){return{[z]:G1(A0(z),w,V0(U))}}function RQ(z,w,U){return z.reduce((X,A)=>{return{...X,...OQ(A,w,U)}},{})}function CQ(z,w,U){return RQ(z.keys,w,U)}function wU(z,w,U){let W=CQ(z,w,U);return Q0(W)}function bQ(z){let[w,U]=[z.slice(0,1),z.slice(1)];return[w.toLowerCase(),U].join("")}function KQ(z){let[w,U]=[z.slice(0,1),z.slice(1)];return[w.toUpperCase(),U].join("")}function FQ(z){return z.toUpperCase()}function jQ(z){return z.toLowerCase()}function EQ(z,w,U){let W=X4(z.pattern);if(!g6(W))return{...z,pattern:UU(z.pattern,w)};let Z=[...h4(W)].map((Q)=>A0(Q)),$=WU(Z,w),Y=N0($);return M5([Y],U)}function UU(z,w){return typeof z==="string"?w==="Uncapitalize"?bQ(z):w==="Capitalize"?KQ(z):w==="Uppercase"?FQ(z):w==="Lowercase"?jQ(z):z:z.toString()}function WU(z,w){return z.map((U)=>G1(U,w))}function G1(z,w,U={}){return f2(z)?wU(z,w,U):d2(z)?EQ(z,w,U):Y0(z)?N0(WU(z.anyOf,w),U):g2(z)?A0(UU(z.const,w),U):D(z,U)}function XU(z,w={}){return G1(z,"Capitalize",w)}function AU(z,w={}){return G1(z,"Lowercase",w)}function ZU(z,w={}){return G1(z,"Uncapitalize",w)}function $U(z,w={}){return G1(z,"Uppercase",w)}function IQ(z,w,U){let W={};for(let X of globalThis.Object.getOwnPropertyNames(z))W[X]=L6(z[X],w,V0(U));return W}function xQ(z,w,U){return IQ(z.properties,w,U)}function YU(z,w,U){let W=xQ(z,w,U);return Q0(W)}function VQ(z,w){return z.map((U)=>Vz(U,w))}function kQ(z,w){return z.map((U)=>Vz(U,w))}function TQ(z,w){let{[w]:U,...W}=z;return W}function gQ(z,w){return w.reduce((U,W)=>TQ(U,W),z)}function fQ(z,w){let U=y0(z,[j0,"$id","required","properties"]),W=gQ(z.properties,w);return G0(W,U)}function dQ(z){let w=z.reduce((U,W)=>$5(W)?[...U,A0(W)]:U,[]);return N0(w)}function Vz(z,w){return i0(z)?B2(VQ(z.allOf,w)):Y0(z)?N0(kQ(z.anyOf,w)):o0(z)?fQ(z,w):G0({})}function L6(z,w,U){let W=m0(w)?dQ(w):w,X=f0(w)?D2(w):w,A=u0(z),Z=u0(w);return T0(z)?YU(z,X,U):f2(w)?QU(z,w,U):A&&Z?x0("Omit",[z,W],U):!A&&Z?x0("Omit",[z,W],U):A&&!Z?x0("Omit",[z,W],U):D({...Vz(z,X),...U})}function hQ(z,w,U){return{[w]:L6(z,[w],V0(U))}}function cQ(z,w,U){return w.reduce((W,X)=>{return{...W,...hQ(z,X,U)}},{})}function iQ(z,w,U){return cQ(z,w.keys,U)}function QU(z,w,U){let W=iQ(z,w,U);return Q0(W)}function yQ(z,w,U){let W={};for(let X of globalThis.Object.getOwnPropertyNames(z))W[X]=N6(z[X],w,V0(U));return W}function vQ(z,w,U){return yQ(z.properties,w,U)}function JU(z,w,U){let W=vQ(z,w,U);return Q0(W)}function nQ(z,w){return z.map((U)=>kz(U,w))}function uQ(z,w){return z.map((U)=>kz(U,w))}function mQ(z,w){let U={};for(let W of w)if(W in z)U[W]=z[W];return U}function tQ(z,w){let U=y0(z,[j0,"$id","required","properties"]),W=mQ(z.properties,w);return G0(W,U)}function oQ(z){let w=z.reduce((U,W)=>$5(W)?[...U,A0(W)]:U,[]);return N0(w)}function kz(z,w){return i0(z)?B2(nQ(z.allOf,w)):Y0(z)?N0(uQ(z.anyOf,w)):o0(z)?tQ(z,w):G0({})}function N6(z,w,U){let W=m0(w)?oQ(w):w,X=f0(w)?D2(w):w,A=u0(z),Z=u0(w);return T0(z)?JU(z,X,U):f2(w)?BU(z,w,U):A&&Z?x0("Pick",[z,W],U):!A&&Z?x0("Pick",[z,W],U):A&&!Z?x0("Pick",[z,W],U):D({...kz(z,X),...U})}function pQ(z,w,U){return{[w]:N6(z,[w],V0(U))}}function lQ(z,w,U){return w.reduce((W,X)=>{return{...W,...pQ(z,X,U)}},{})}function sQ(z,w,U){return lQ(z,w.keys,U)}function BU(z,w,U){let W=sQ(z,w,U);return Q0(W)}function rQ(z,w){return x0("Partial",[x0(z,w)])}function aQ(z){return x0("Partial",[p2(z)])}function eQ(z){let w={};for(let U of globalThis.Object.getOwnPropertyNames(z))w[U]=J2(z[U]);return w}function zJ(z){let w=y0(z,[j0,"$id","required","properties"]),U=eQ(z.properties);return G0(U,w)}function MU(z){return z.map((w)=>qU(w))}function qU(z){return Q1(z)?rQ(z.target,z.parameters):u0(z)?aQ(z.$ref):i0(z)?B2(MU(z.allOf)):Y0(z)?N0(MU(z.anyOf)):o0(z)?zJ(z):x6(z)?z:n1(z)?z:M1(z)?z:g2(z)?z:V4(z)?z:q1(z)?z:u1(z)?z:k4(z)?z:m1(z)?z:G0({})}function L4(z,w){if(T0(z))return LU(z,w);else return D({...qU(z),...w})}function wJ(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=L4(z[W],V0(w));return U}function UJ(z,w){return wJ(z.properties,w)}function LU(z,w){let U=UJ(z,w);return Q0(U)}function WJ(z,w){return x0("Required",[x0(z,w)])}function XJ(z){return x0("Required",[p2(z)])}function AJ(z){let w={};for(let U of globalThis.Object.getOwnPropertyNames(z))w[U]=y0(z[U],[A2]);return w}function ZJ(z){let w=y0(z,[j0,"$id","required","properties"]),U=AJ(z.properties);return G0(U,w)}function NU(z){return z.map((w)=>GU(w))}function GU(z){return Q1(z)?WJ(z.target,z.parameters):u0(z)?XJ(z.$ref):i0(z)?B2(NU(z.allOf)):Y0(z)?N0(NU(z.anyOf)):o0(z)?ZJ(z):x6(z)?z:n1(z)?z:M1(z)?z:g2(z)?z:V4(z)?z:q1(z)?z:u1(z)?z:k4(z)?z:m1(z)?z:G0({})}function N4(z,w){if(T0(z))return HU(z,w);else return D({...GU(z),...w})}function $J(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=N4(z[W],w);return U}function YJ(z,w){return $J(z.properties,w)}function HU(z,w){let U=YJ(z,w);return Q0(U)}function QJ(z,w){return w.map((U)=>{return u0(U)?Tz(z,U.$ref):c2(z,U)})}function Tz(z,w){return w in z?u0(z[w])?Tz(z,z[w].$ref):c2(z,z[w]):p()}function JJ(z){return Y4(z[0])}function BJ(z){return M6(z[0],z[1])}function MJ(z){return Q4(z[0])}function qJ(z){return L4(z[0])}function LJ(z){return L6(z[0],z[1])}function NJ(z){return N6(z[0],z[1])}function GJ(z){return N4(z[0])}function HJ(z,w,U){let W=QJ(z,U);return w==="Awaited"?JJ(W):w==="Index"?BJ(W):w==="KeyOf"?MJ(W):w==="Partial"?qJ(W):w==="Omit"?LJ(W):w==="Pick"?NJ(W):w==="Required"?GJ(W):p()}function _J(z,w){return z4(c2(z,w))}function SJ(z,w){return w4(c2(z,w))}function DJ(z,w,U){return U4(n4(z,w),c2(z,U))}function PJ(z,w,U){return k1(n4(z,w),c2(z,U))}function OJ(z,w){return B2(n4(z,w))}function RJ(z,w){return $4(c2(z,w))}function CJ(z,w){return G0(globalThis.Object.keys(w).reduce((U,W)=>{return{...U,[W]:c2(z,w[W])}},{}))}function bJ(z,w){let[U,W]=[c2(z,F5(w)),K5(w)],X=l6(w);return X.patternProperties[W]=U,X}function KJ(z,w){return u0(w)?{...Tz(z,w.$ref),[j0]:w[j0]}:w}function FJ(z,w){return t2(n4(z,w))}function jJ(z,w){return N0(n4(z,w))}function n4(z,w){return w.map((U)=>c2(z,U))}function c2(z,w){return S2(w)?D(c2(z,y0(w,[A2])),w):r6(w)?D(c2(z,y0(w,[$1])),w):L0(w)?D(KJ(z,w),w):Y1(w)?D(_J(z,w.items),w):I6(w)?D(SJ(z,w.items),w):Q1(w)?D(HJ(z,w.target,w.parameters)):J1(w)?D(DJ(z,w.parameters,w.returns),w):B1(w)?D(PJ(z,w.parameters,w.returns),w):i0(w)?D(OJ(z,w.allOf),w):V6(w)?D(RJ(z,w.items),w):o0(w)?D(CJ(z,w.properties),w):T6(w)?D(bJ(z,w)):h2(w)?D(FJ(z,w.items||[]),w):Y0(w)?D(jJ(z,w.anyOf),w):w}function EJ(z,w){return w in z?c2(z,z[w]):p()}function _U(z){return globalThis.Object.getOwnPropertyNames(z).reduce((w,U)=>{return{...w,[U]:EJ(z,U)}},{})}class SU{constructor(z){let w=_U(z),U=this.WithIdentifiers(w);this.$defs=U}Import(z,w){let U={...this.$defs,[z]:D(this.$defs[z],w)};return D({[H]:"Import",$defs:U,$ref:z})}WithIdentifiers(z){return globalThis.Object.getOwnPropertyNames(z).reduce((w,U)=>{return{...w,[U]:{...z[U],$id:U}}},{})}}function DU(z){return new SU(z)}function PU(z,w){return D({[H]:"Not",not:z},w)}function OU(z,w){return B1(z)?t2(z.parameters,w):p()}var IJ=0;function RU(z,w={}){if(t0(w.$id))w.$id=`T${IJ++}`;let U=l6(z({[H]:"This",$ref:`${w.$id}`}));return U.$id=w.$id,D({[u2]:"Recursive",...U},w)}function CU(z,w){let U=F0(z)?new globalThis.RegExp(z):z;return D({[H]:"RegExp",type:"RegExp",source:U.source,flags:U.flags},w)}function xJ(z){return i0(z)?z.allOf:Y0(z)?z.anyOf:h2(z)?z.items??[]:[]}function bU(z){return xJ(z)}function KU(z,w){return B1(z)?D(z.returns,w):p(w)}class FU{constructor(z){this.schema=z}Decode(z){return new jU(this.schema,z)}}class jU{constructor(z,w){this.schema=z,this.decode=w}EncodeTransform(z,w){let X={Encode:(A)=>w[j0].Encode(z(A)),Decode:(A)=>this.decode(w[j0].Decode(A))};return{...w,[j0]:X}}EncodeSchema(z,w){let U={Decode:this.decode,Encode:z};return{...w,[j0]:U}}Encode(z){return L0(this.schema)?this.EncodeTransform(z,this.schema):this.EncodeSchema(z,this.schema)}}function EU(z){return new FU(z)}function j5(z={}){return D({[H]:z[H]??"Unsafe"},z)}function IU(z){return D({[H]:"Void",type:"void"},z)}var gz={};K6(gz,{Void:()=>IU,Uppercase:()=>$U,Unsafe:()=>j5,Unknown:()=>L1,Union:()=>N0,Undefined:()=>S5,Uncapitalize:()=>ZU,Uint8Array:()=>D5,Tuple:()=>t2,Transform:()=>EU,TemplateLiteral:()=>M5,Symbol:()=>_5,String:()=>G2,ReturnType:()=>KU,Rest:()=>bU,Required:()=>N4,RegExp:()=>CU,Ref:()=>p2,Recursive:()=>RU,Record:()=>b5,ReadonlyOptional:()=>C5,Readonly:()=>P2,Promise:()=>L5,Pick:()=>N6,Partial:()=>L4,Parameters:()=>OU,Optional:()=>J2,Omit:()=>L6,Object:()=>G0,Number:()=>m2,Null:()=>H5,Not:()=>PU,Never:()=>p,Module:()=>DU,Mapped:()=>R7,Lowercase:()=>AU,Literal:()=>A0,KeyOf:()=>Q4,Iterator:()=>$4,Intersect:()=>B2,Integer:()=>zU,Instantiate:()=>e7,InstanceType:()=>r7,Index:()=>M6,Function:()=>k1,Extract:()=>q4,Extends:()=>B4,Exclude:()=>M4,Enum:()=>V7,Date:()=>G5,ConstructorParameters:()=>x7,Constructor:()=>U4,Const:()=>I7,Composite:()=>E7,Capitalize:()=>XU,Boolean:()=>B5,BigInt:()=>Z4,Awaited:()=>Y4,AsyncIterator:()=>w4,Array:()=>z4,Argument:()=>$7,Any:()=>B6});var G6=gz;function VJ(z){switch(z.errorType){case _.ArrayContains:return"Expected array to contain at least one matching value";case _.ArrayMaxContains:return`Expected array to contain no more than ${z.schema.maxContains} matching values`;case _.ArrayMinContains:return`Expected array to contain at least ${z.schema.minContains} matching values`;case _.ArrayMaxItems:return`Expected array length to be less or equal to ${z.schema.maxItems}`;case _.ArrayMinItems:return`Expected array length to be greater or equal to ${z.schema.minItems}`;case _.ArrayUniqueItems:return"Expected array elements to be unique";case _.Array:return"Expected array";case _.AsyncIterator:return"Expected AsyncIterator";case _.BigIntExclusiveMaximum:return`Expected bigint to be less than ${z.schema.exclusiveMaximum}`;case _.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${z.schema.exclusiveMinimum}`;case _.BigIntMaximum:return`Expected bigint to be less or equal to ${z.schema.maximum}`;case _.BigIntMinimum:return`Expected bigint to be greater or equal to ${z.schema.minimum}`;case _.BigIntMultipleOf:return`Expected bigint to be a multiple of ${z.schema.multipleOf}`;case _.BigInt:return"Expected bigint";case _.Boolean:return"Expected boolean";case _.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${z.schema.exclusiveMinimumTimestamp}`;case _.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${z.schema.exclusiveMaximumTimestamp}`;case _.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${z.schema.minimumTimestamp}`;case _.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${z.schema.maximumTimestamp}`;case _.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${z.schema.multipleOfTimestamp}`;case _.Date:return"Expected Date";case _.Function:return"Expected function";case _.IntegerExclusiveMaximum:return`Expected integer to be less than ${z.schema.exclusiveMaximum}`;case _.IntegerExclusiveMinimum:return`Expected integer to be greater than ${z.schema.exclusiveMinimum}`;case _.IntegerMaximum:return`Expected integer to be less or equal to ${z.schema.maximum}`;case _.IntegerMinimum:return`Expected integer to be greater or equal to ${z.schema.minimum}`;case _.IntegerMultipleOf:return`Expected integer to be a multiple of ${z.schema.multipleOf}`;case _.Integer:return"Expected integer";case _.IntersectUnevaluatedProperties:return"Unexpected property";case _.Intersect:return"Expected all values to match";case _.Iterator:return"Expected Iterator";case _.Literal:return`Expected ${typeof z.schema.const==="string"?`'${z.schema.const}'`:z.schema.const}`;case _.Never:return"Never";case _.Not:return"Value should not match";case _.Null:return"Expected null";case _.NumberExclusiveMaximum:return`Expected number to be less than ${z.schema.exclusiveMaximum}`;case _.NumberExclusiveMinimum:return`Expected number to be greater than ${z.schema.exclusiveMinimum}`;case _.NumberMaximum:return`Expected number to be less or equal to ${z.schema.maximum}`;case _.NumberMinimum:return`Expected number to be greater or equal to ${z.schema.minimum}`;case _.NumberMultipleOf:return`Expected number to be a multiple of ${z.schema.multipleOf}`;case _.Number:return"Expected number";case _.Object:return"Expected object";case _.ObjectAdditionalProperties:return"Unexpected property";case _.ObjectMaxProperties:return`Expected object to have no more than ${z.schema.maxProperties} properties`;case _.ObjectMinProperties:return`Expected object to have at least ${z.schema.minProperties} properties`;case _.ObjectRequiredProperty:return"Expected required property";case _.Promise:return"Expected Promise";case _.RegExp:return"Expected string to match regular expression";case _.StringFormatUnknown:return`Unknown format '${z.schema.format}'`;case _.StringFormat:return`Expected string to match '${z.schema.format}' format`;case _.StringMaxLength:return`Expected string length less or equal to ${z.schema.maxLength}`;case _.StringMinLength:return`Expected string length greater or equal to ${z.schema.minLength}`;case _.StringPattern:return`Expected string to match '${z.schema.pattern}'`;case _.String:return"Expected string";case _.Symbol:return"Expected symbol";case _.TupleLength:return`Expected tuple to have ${z.schema.maxItems||0} elements`;case _.Tuple:return"Expected tuple";case _.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${z.schema.maxByteLength}`;case _.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${z.schema.minByteLength}`;case _.Uint8Array:return"Expected Uint8Array";case _.Undefined:return"Expected undefined";case _.Union:return"Expected union value";case _.Void:return"Expected void";case _.Kind:return`Expected kind '${z.schema[H]}'`;default:return"Unknown error type"}}var kJ=VJ;function xU(){return kJ}class VU extends n{constructor(z){super(`Unable to dereference schema with $id '${z.$ref}'`);this.schema=z}}function TJ(z,w){let U=w.find((W)=>W.$id===z.$ref);if(U===void 0)throw new VU(z);return J0(U,w)}function z2(z,w){if(!$0(z.$id)||w.some((U)=>U.$id===z.$id))return w;return w.push(z),w}function J0(z,w){return z[H]==="This"||z[H]==="Ref"?TJ(z,w):z}class kU extends n{constructor(z){super("Unable to hash value");this.value=z}}var i2;(function(z){z[z.Undefined=0]="Undefined",z[z.Null=1]="Null",z[z.Boolean=2]="Boolean",z[z.Number=3]="Number",z[z.String=4]="String",z[z.Object=5]="Object",z[z.Array=6]="Array",z[z.Date=7]="Date",z[z.Uint8Array=8]="Uint8Array",z[z.Symbol=9]="Symbol",z[z.BigInt=10]="BigInt"})(i2||(i2={}));var G4=BigInt("14695981039346656037"),[gJ,fJ]=[BigInt("1099511628211"),BigInt("18446744073709551616")],dJ=Array.from({length:256}).map((z,w)=>BigInt(w)),TU=new Float64Array(1),gU=new DataView(TU.buffer),fU=new Uint8Array(TU.buffer);function*hJ(z){let w=z===0?1:Math.ceil(Math.floor(Math.log2(z)+1)/8);for(let U=0;U<w;U++)yield z>>8*(w-1-U)&255}function cJ(z){q2(i2.Array);for(let w of z)H4(w)}function iJ(z){q2(i2.Boolean),q2(z?1:0)}function yJ(z){q2(i2.BigInt),gU.setBigInt64(0,z);for(let w of fU)q2(w)}function vJ(z){q2(i2.Date),H4(z.getTime())}function nJ(z){q2(i2.Null)}function uJ(z){q2(i2.Number),gU.setFloat64(0,z);for(let w of fU)q2(w)}function mJ(z){q2(i2.Object);for(let w of globalThis.Object.getOwnPropertyNames(z).sort())H4(w),H4(z[w])}function tJ(z){q2(i2.String);for(let w=0;w<z.length;w++)for(let U of hJ(z.charCodeAt(w)))q2(U)}function oJ(z){q2(i2.Symbol),H4(z.description)}function pJ(z){q2(i2.Uint8Array);for(let w=0;w<z.length;w++)q2(z[w])}function lJ(z){return q2(i2.Undefined)}function H4(z){if(m(z))return cJ(z);if(I1(z))return iJ(z);if(X2(z))return yJ(z);if(N2(z))return vJ(z);if(y1(z))return nJ(z);if(v(z))return uJ(z);if(l(z))return mJ(z);if($0(z))return tJ(z);if(v1(z))return oJ(z);if(s6(z))return pJ(z);if(k0(z))return lJ(z);throw new kU(z)}function q2(z){G4=G4^dJ[z],G4=G4*gJ%fJ}function H6(z){return G4=BigInt("14695981039346656037"),H4(z),G4}class dU extends n{constructor(z){super("Unknown type");this.schema=z}}function sJ(z){return z[H]==="Any"||z[H]==="Unknown"}function U0(z){return z!==void 0}function rJ(z,w,U){return!0}function aJ(z,w,U){return!0}function eJ(z,w,U){if(!m(U))return!1;if(U0(z.minItems)&&!(U.length>=z.minItems))return!1;if(U0(z.maxItems)&&!(U.length<=z.maxItems))return!1;if(!U.every((A)=>w2(z.items,w,A)))return!1;if(z.uniqueItems===!0&&!function(){let A=new Set;for(let Z of U){let $=H6(Z);if(A.has($))return!1;else A.add($)}return!0}())return!1;if(!(U0(z.contains)||v(z.minContains)||v(z.maxContains)))return!0;let W=U0(z.contains)?z.contains:p(),X=U.reduce((A,Z)=>w2(W,w,Z)?A+1:A,0);if(X===0)return!1;if(v(z.minContains)&&X<z.minContains)return!1;if(v(z.maxContains)&&X>z.maxContains)return!1;return!0}function zB(z,w,U){return W5(U)}function wB(z,w,U){if(!X2(U))return!1;if(U0(z.exclusiveMaximum)&&!(U<z.exclusiveMaximum))return!1;if(U0(z.exclusiveMinimum)&&!(U>z.exclusiveMinimum))return!1;if(U0(z.maximum)&&!(U<=z.maximum))return!1;if(U0(z.minimum)&&!(U>=z.minimum))return!1;if(U0(z.multipleOf)&&U%z.multipleOf!==BigInt(0))return!1;return!0}function UB(z,w,U){return I1(U)}function WB(z,w,U){return w2(z.returns,w,U.prototype)}function XB(z,w,U){if(!N2(U))return!1;if(U0(z.exclusiveMaximumTimestamp)&&!(U.getTime()<z.exclusiveMaximumTimestamp))return!1;if(U0(z.exclusiveMinimumTimestamp)&&!(U.getTime()>z.exclusiveMinimumTimestamp))return!1;if(U0(z.maximumTimestamp)&&!(U.getTime()<=z.maximumTimestamp))return!1;if(U0(z.minimumTimestamp)&&!(U.getTime()>=z.minimumTimestamp))return!1;if(U0(z.multipleOfTimestamp)&&U.getTime()%z.multipleOfTimestamp!==0)return!1;return!0}function AB(z,w,U){return Y6(U)}function ZB(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return w2(X,[...w,...W],U)}function $B(z,w,U){if(!Z5(U))return!1;if(U0(z.exclusiveMaximum)&&!(U<z.exclusiveMaximum))return!1;if(U0(z.exclusiveMinimum)&&!(U>z.exclusiveMinimum))return!1;if(U0(z.maximum)&&!(U<=z.maximum))return!1;if(U0(z.minimum)&&!(U>=z.minimum))return!1;if(U0(z.multipleOf)&&U%z.multipleOf!==0)return!1;return!0}function YB(z,w,U){let W=z.allOf.every((X)=>w2(X,w,U));if(z.unevaluatedProperties===!1){let X=new RegExp(p1(z)),A=Object.getOwnPropertyNames(U).every((Z)=>X.test(Z));return W&&A}else if(f0(z.unevaluatedProperties)){let X=new RegExp(p1(z)),A=Object.getOwnPropertyNames(U).every((Z)=>X.test(Z)||w2(z.unevaluatedProperties,w,U[Z]));return W&&A}else return W}function QB(z,w,U){return X5(U)}function JB(z,w,U){return U===z.const}function BB(z,w,U){return!1}function MB(z,w,U){return!w2(z.not,w,U)}function qB(z,w,U){return y1(U)}function LB(z,w,U){if(!I0.IsNumberLike(U))return!1;if(U0(z.exclusiveMaximum)&&!(U<z.exclusiveMaximum))return!1;if(U0(z.exclusiveMinimum)&&!(U>z.exclusiveMinimum))return!1;if(U0(z.minimum)&&!(U>=z.minimum))return!1;if(U0(z.maximum)&&!(U<=z.maximum))return!1;if(U0(z.multipleOf)&&U%z.multipleOf!==0)return!1;return!0}function NB(z,w,U){if(!I0.IsObjectLike(U))return!1;if(U0(z.minProperties)&&!(Object.getOwnPropertyNames(U).length>=z.minProperties))return!1;if(U0(z.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=z.maxProperties))return!1;let W=Object.getOwnPropertyNames(z.properties);for(let X of W){let A=z.properties[X];if(z.required&&z.required.includes(X)){if(!w2(A,w,U[X]))return!1;if((l1(A)||sJ(A))&&!(X in U))return!1}else if(I0.IsExactOptionalProperty(U,X)&&!w2(A,w,U[X]))return!1}if(z.additionalProperties===!1){let X=Object.getOwnPropertyNames(U);if(z.required&&z.required.length===W.length&&X.length===W.length)return!0;else return X.every((A)=>W.includes(A))}else if(typeof z.additionalProperties==="object")return Object.getOwnPropertyNames(U).every((A)=>W.includes(A)||w2(z.additionalProperties,w,U[A]));else return!0}function GB(z,w,U){return A5(U)}function HB(z,w,U){if(!I0.IsRecordLike(U))return!1;if(U0(z.minProperties)&&!(Object.getOwnPropertyNames(U).length>=z.minProperties))return!1;if(U0(z.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=z.maxProperties))return!1;let[W,X]=Object.entries(z.patternProperties)[0],A=new RegExp(W),Z=Object.entries(U).every(([Q,J])=>{return A.test(Q)?w2(X,w,J):!0}),$=typeof z.additionalProperties==="object"?Object.entries(U).every(([Q,J])=>{return!A.test(Q)?w2(z.additionalProperties,w,J):!0}):!0,Y=z.additionalProperties===!1?Object.getOwnPropertyNames(U).every((Q)=>{return A.test(Q)}):!0;return Z&&$&&Y}function _B(z,w,U){return w2(J0(z,w),w,U)}function SB(z,w,U){let W=new RegExp(z.source,z.flags);if(U0(z.minLength)){if(!(U.length>=z.minLength))return!1}if(U0(z.maxLength)){if(!(U.length<=z.maxLength))return!1}return W.test(U)}function DB(z,w,U){if(!$0(U))return!1;if(U0(z.minLength)){if(!(U.length>=z.minLength))return!1}if(U0(z.maxLength)){if(!(U.length<=z.maxLength))return!1}if(U0(z.pattern)){if(!new RegExp(z.pattern).test(U))return!1}if(U0(z.format)){if(!D0.Has(z.format))return!1;return D0.Get(z.format)(U)}return!0}function PB(z,w,U){return v1(U)}function OB(z,w,U){return $0(U)&&new RegExp(z.pattern).test(U)}function RB(z,w,U){return w2(J0(z,w),w,U)}function CB(z,w,U){if(!m(U))return!1;if(z.items===void 0&&U.length!==0)return!1;if(U.length!==z.maxItems)return!1;if(!z.items)return!0;for(let W=0;W<z.items.length;W++)if(!w2(z.items[W],w,U[W]))return!1;return!0}function bB(z,w,U){return k0(U)}function KB(z,w,U){return z.anyOf.some((W)=>w2(W,w,U))}function FB(z,w,U){if(!s6(U))return!1;if(U0(z.maxByteLength)&&!(U.length<=z.maxByteLength))return!1;if(U0(z.minByteLength)&&!(U.length>=z.minByteLength))return!1;return!0}function jB(z,w,U){return!0}function EB(z,w,U){return I0.IsVoidLike(U)}function IB(z,w,U){if(!p0.Has(z[H]))return!1;return p0.Get(z[H])(z,U)}function w2(z,w,U){let W=U0(z.$id)?z2(z,w):w,X=z;switch(X[H]){case"Any":return rJ(X,W,U);case"Argument":return aJ(X,W,U);case"Array":return eJ(X,W,U);case"AsyncIterator":return zB(X,W,U);case"BigInt":return wB(X,W,U);case"Boolean":return UB(X,W,U);case"Constructor":return WB(X,W,U);case"Date":return XB(X,W,U);case"Function":return AB(X,W,U);case"Import":return ZB(X,W,U);case"Integer":return $B(X,W,U);case"Intersect":return YB(X,W,U);case"Iterator":return QB(X,W,U);case"Literal":return JB(X,W,U);case"Never":return BB(X,W,U);case"Not":return MB(X,W,U);case"Null":return qB(X,W,U);case"Number":return LB(X,W,U);case"Object":return NB(X,W,U);case"Promise":return GB(X,W,U);case"Record":return HB(X,W,U);case"Ref":return _B(X,W,U);case"RegExp":return SB(X,W,U);case"String":return DB(X,W,U);case"Symbol":return PB(X,W,U);case"TemplateLiteral":return OB(X,W,U);case"This":return RB(X,W,U);case"Tuple":return CB(X,W,U);case"Undefined":return bB(X,W,U);case"Union":return KB(X,W,U);case"Uint8Array":return FB(X,W,U);case"Unknown":return jB(X,W,U);case"Void":return EB(X,W,U);default:if(!p0.Has(X[H]))throw new dU(X);return IB(X,W,U)}}function s(...z){return z.length===3?w2(z[0],z[1],z[2]):w2(z[0],[],z[1])}var _;(function(z){z[z.ArrayContains=0]="ArrayContains",z[z.ArrayMaxContains=1]="ArrayMaxContains",z[z.ArrayMaxItems=2]="ArrayMaxItems",z[z.ArrayMinContains=3]="ArrayMinContains",z[z.ArrayMinItems=4]="ArrayMinItems",z[z.ArrayUniqueItems=5]="ArrayUniqueItems",z[z.Array=6]="Array",z[z.AsyncIterator=7]="AsyncIterator",z[z.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",z[z.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",z[z.BigIntMaximum=10]="BigIntMaximum",z[z.BigIntMinimum=11]="BigIntMinimum",z[z.BigIntMultipleOf=12]="BigIntMultipleOf",z[z.BigInt=13]="BigInt",z[z.Boolean=14]="Boolean",z[z.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",z[z.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",z[z.DateMaximumTimestamp=17]="DateMaximumTimestamp",z[z.DateMinimumTimestamp=18]="DateMinimumTimestamp",z[z.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",z[z.Date=20]="Date",z[z.Function=21]="Function",z[z.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",z[z.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",z[z.IntegerMaximum=24]="IntegerMaximum",z[z.IntegerMinimum=25]="IntegerMinimum",z[z.IntegerMultipleOf=26]="IntegerMultipleOf",z[z.Integer=27]="Integer",z[z.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",z[z.Intersect=29]="Intersect",z[z.Iterator=30]="Iterator",z[z.Kind=31]="Kind",z[z.Literal=32]="Literal",z[z.Never=33]="Never",z[z.Not=34]="Not",z[z.Null=35]="Null",z[z.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",z[z.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",z[z.NumberMaximum=38]="NumberMaximum",z[z.NumberMinimum=39]="NumberMinimum",z[z.NumberMultipleOf=40]="NumberMultipleOf",z[z.Number=41]="Number",z[z.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",z[z.ObjectMaxProperties=43]="ObjectMaxProperties",z[z.ObjectMinProperties=44]="ObjectMinProperties",z[z.ObjectRequiredProperty=45]="ObjectRequiredProperty",z[z.Object=46]="Object",z[z.Promise=47]="Promise",z[z.RegExp=48]="RegExp",z[z.StringFormatUnknown=49]="StringFormatUnknown",z[z.StringFormat=50]="StringFormat",z[z.StringMaxLength=51]="StringMaxLength",z[z.StringMinLength=52]="StringMinLength",z[z.StringPattern=53]="StringPattern",z[z.String=54]="String",z[z.Symbol=55]="Symbol",z[z.TupleLength=56]="TupleLength",z[z.Tuple=57]="Tuple",z[z.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",z[z.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",z[z.Uint8Array=60]="Uint8Array",z[z.Undefined=61]="Undefined",z[z.Union=62]="Union",z[z.Void=63]="Void"})(_||(_={}));class hU extends n{constructor(z){super("Unknown type");this.schema=z}}function s1(z){return z.replace(/~/g,"~0").replace(/\//g,"~1")}function W0(z){return z!==void 0}class h6{constructor(z){this.iterator=z}[Symbol.iterator](){return this.iterator}First(){let z=this.iterator.next();return z.done?void 0:z.value}}function V(z,w,U,W,X=[]){return{type:z,schema:w,path:U,value:W,message:xU()({errorType:z,path:U,schema:w,value:W,errors:X}),errors:X}}function*xB(z,w,U,W){}function*VB(z,w,U,W){}function*kB(z,w,U,W){if(!m(W))return yield V(_.Array,z,U,W);if(W0(z.minItems)&&!(W.length>=z.minItems))yield V(_.ArrayMinItems,z,U,W);if(W0(z.maxItems)&&!(W.length<=z.maxItems))yield V(_.ArrayMaxItems,z,U,W);for(let Z=0;Z<W.length;Z++)yield*U2(z.items,w,`${U}/${Z}`,W[Z]);if(z.uniqueItems===!0&&!function(){let Z=new Set;for(let $ of W){let Y=H6($);if(Z.has(Y))return!1;else Z.add(Y)}return!0}())yield V(_.ArrayUniqueItems,z,U,W);if(!(W0(z.contains)||W0(z.minContains)||W0(z.maxContains)))return;let X=W0(z.contains)?z.contains:p(),A=W.reduce((Z,$,Y)=>U2(X,w,`${U}${Y}`,$).next().done===!0?Z+1:Z,0);if(A===0)yield V(_.ArrayContains,z,U,W);if(v(z.minContains)&&A<z.minContains)yield V(_.ArrayMinContains,z,U,W);if(v(z.maxContains)&&A>z.maxContains)yield V(_.ArrayMaxContains,z,U,W)}function*TB(z,w,U,W){if(!W5(W))yield V(_.AsyncIterator,z,U,W)}function*gB(z,w,U,W){if(!X2(W))return yield V(_.BigInt,z,U,W);if(W0(z.exclusiveMaximum)&&!(W<z.exclusiveMaximum))yield V(_.BigIntExclusiveMaximum,z,U,W);if(W0(z.exclusiveMinimum)&&!(W>z.exclusiveMinimum))yield V(_.BigIntExclusiveMinimum,z,U,W);if(W0(z.maximum)&&!(W<=z.maximum))yield V(_.BigIntMaximum,z,U,W);if(W0(z.minimum)&&!(W>=z.minimum))yield V(_.BigIntMinimum,z,U,W);if(W0(z.multipleOf)&&W%z.multipleOf!==BigInt(0))yield V(_.BigIntMultipleOf,z,U,W)}function*fB(z,w,U,W){if(!I1(W))yield V(_.Boolean,z,U,W)}function*dB(z,w,U,W){yield*U2(z.returns,w,U,W.prototype)}function*hB(z,w,U,W){if(!N2(W))return yield V(_.Date,z,U,W);if(W0(z.exclusiveMaximumTimestamp)&&!(W.getTime()<z.exclusiveMaximumTimestamp))yield V(_.DateExclusiveMaximumTimestamp,z,U,W);if(W0(z.exclusiveMinimumTimestamp)&&!(W.getTime()>z.exclusiveMinimumTimestamp))yield V(_.DateExclusiveMinimumTimestamp,z,U,W);if(W0(z.maximumTimestamp)&&!(W.getTime()<=z.maximumTimestamp))yield V(_.DateMaximumTimestamp,z,U,W);if(W0(z.minimumTimestamp)&&!(W.getTime()>=z.minimumTimestamp))yield V(_.DateMinimumTimestamp,z,U,W);if(W0(z.multipleOfTimestamp)&&W.getTime()%z.multipleOfTimestamp!==0)yield V(_.DateMultipleOfTimestamp,z,U,W)}function*cB(z,w,U,W){if(!Y6(W))yield V(_.Function,z,U,W)}function*iB(z,w,U,W){let X=globalThis.Object.values(z.$defs),A=z.$defs[z.$ref];yield*U2(A,[...w,...X],U,W)}function*yB(z,w,U,W){if(!Z5(W))return yield V(_.Integer,z,U,W);if(W0(z.exclusiveMaximum)&&!(W<z.exclusiveMaximum))yield V(_.IntegerExclusiveMaximum,z,U,W);if(W0(z.exclusiveMinimum)&&!(W>z.exclusiveMinimum))yield V(_.IntegerExclusiveMinimum,z,U,W);if(W0(z.maximum)&&!(W<=z.maximum))yield V(_.IntegerMaximum,z,U,W);if(W0(z.minimum)&&!(W>=z.minimum))yield V(_.IntegerMinimum,z,U,W);if(W0(z.multipleOf)&&W%z.multipleOf!==0)yield V(_.IntegerMultipleOf,z,U,W)}function*vB(z,w,U,W){let X=!1;for(let A of z.allOf)for(let Z of U2(A,w,U,W))X=!0,yield Z;if(X)return yield V(_.Intersect,z,U,W);if(z.unevaluatedProperties===!1){let A=new RegExp(p1(z));for(let Z of Object.getOwnPropertyNames(W))if(!A.test(Z))yield V(_.IntersectUnevaluatedProperties,z,`${U}/${Z}`,W)}if(typeof z.unevaluatedProperties==="object"){let A=new RegExp(p1(z));for(let Z of Object.getOwnPropertyNames(W))if(!A.test(Z)){let $=U2(z.unevaluatedProperties,w,`${U}/${Z}`,W[Z]).next();if(!$.done)yield $.value}}}function*nB(z,w,U,W){if(!X5(W))yield V(_.Iterator,z,U,W)}function*uB(z,w,U,W){if(W!==z.const)yield V(_.Literal,z,U,W)}function*mB(z,w,U,W){yield V(_.Never,z,U,W)}function*tB(z,w,U,W){if(U2(z.not,w,U,W).next().done===!0)yield V(_.Not,z,U,W)}function*oB(z,w,U,W){if(!y1(W))yield V(_.Null,z,U,W)}function*pB(z,w,U,W){if(!I0.IsNumberLike(W))return yield V(_.Number,z,U,W);if(W0(z.exclusiveMaximum)&&!(W<z.exclusiveMaximum))yield V(_.NumberExclusiveMaximum,z,U,W);if(W0(z.exclusiveMinimum)&&!(W>z.exclusiveMinimum))yield V(_.NumberExclusiveMinimum,z,U,W);if(W0(z.maximum)&&!(W<=z.maximum))yield V(_.NumberMaximum,z,U,W);if(W0(z.minimum)&&!(W>=z.minimum))yield V(_.NumberMinimum,z,U,W);if(W0(z.multipleOf)&&W%z.multipleOf!==0)yield V(_.NumberMultipleOf,z,U,W)}function*lB(z,w,U,W){if(!I0.IsObjectLike(W))return yield V(_.Object,z,U,W);if(W0(z.minProperties)&&!(Object.getOwnPropertyNames(W).length>=z.minProperties))yield V(_.ObjectMinProperties,z,U,W);if(W0(z.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=z.maxProperties))yield V(_.ObjectMaxProperties,z,U,W);let X=Array.isArray(z.required)?z.required:[],A=Object.getOwnPropertyNames(z.properties),Z=Object.getOwnPropertyNames(W);for(let $ of X){if(Z.includes($))continue;yield V(_.ObjectRequiredProperty,z.properties[$],`${U}/${s1($)}`,void 0)}if(z.additionalProperties===!1){for(let $ of Z)if(!A.includes($))yield V(_.ObjectAdditionalProperties,z,`${U}/${s1($)}`,W[$])}if(typeof z.additionalProperties==="object")for(let $ of Z){if(A.includes($))continue;yield*U2(z.additionalProperties,w,`${U}/${s1($)}`,W[$])}for(let $ of A){let Y=z.properties[$];if(z.required&&z.required.includes($)){if(yield*U2(Y,w,`${U}/${s1($)}`,W[$]),l1(z)&&!($ in W))yield V(_.ObjectRequiredProperty,Y,`${U}/${s1($)}`,void 0)}else if(I0.IsExactOptionalProperty(W,$))yield*U2(Y,w,`${U}/${s1($)}`,W[$])}}function*sB(z,w,U,W){if(!A5(W))yield V(_.Promise,z,U,W)}function*rB(z,w,U,W){if(!I0.IsRecordLike(W))return yield V(_.Object,z,U,W);if(W0(z.minProperties)&&!(Object.getOwnPropertyNames(W).length>=z.minProperties))yield V(_.ObjectMinProperties,z,U,W);if(W0(z.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=z.maxProperties))yield V(_.ObjectMaxProperties,z,U,W);let[X,A]=Object.entries(z.patternProperties)[0],Z=new RegExp(X);for(let[$,Y]of Object.entries(W))if(Z.test($))yield*U2(A,w,`${U}/${s1($)}`,Y);if(typeof z.additionalProperties==="object"){for(let[$,Y]of Object.entries(W))if(!Z.test($))yield*U2(z.additionalProperties,w,`${U}/${s1($)}`,Y)}if(z.additionalProperties===!1)for(let[$,Y]of Object.entries(W)){if(Z.test($))continue;return yield V(_.ObjectAdditionalProperties,z,`${U}/${s1($)}`,Y)}}function*aB(z,w,U,W){yield*U2(J0(z,w),w,U,W)}function*eB(z,w,U,W){if(!$0(W))return yield V(_.String,z,U,W);if(W0(z.minLength)&&!(W.length>=z.minLength))yield V(_.StringMinLength,z,U,W);if(W0(z.maxLength)&&!(W.length<=z.maxLength))yield V(_.StringMaxLength,z,U,W);if(!new RegExp(z.source,z.flags).test(W))return yield V(_.RegExp,z,U,W)}function*zM(z,w,U,W){if(!$0(W))return yield V(_.String,z,U,W);if(W0(z.minLength)&&!(W.length>=z.minLength))yield V(_.StringMinLength,z,U,W);if(W0(z.maxLength)&&!(W.length<=z.maxLength))yield V(_.StringMaxLength,z,U,W);if($0(z.pattern)){if(!new RegExp(z.pattern).test(W))yield V(_.StringPattern,z,U,W)}if($0(z.format)){if(!D0.Has(z.format))yield V(_.StringFormatUnknown,z,U,W);else if(!D0.Get(z.format)(W))yield V(_.StringFormat,z,U,W)}}function*wM(z,w,U,W){if(!v1(W))yield V(_.Symbol,z,U,W)}function*UM(z,w,U,W){if(!$0(W))return yield V(_.String,z,U,W);if(!new RegExp(z.pattern).test(W))yield V(_.StringPattern,z,U,W)}function*WM(z,w,U,W){yield*U2(J0(z,w),w,U,W)}function*XM(z,w,U,W){if(!m(W))return yield V(_.Tuple,z,U,W);if(z.items===void 0&&W.length!==0)return yield V(_.TupleLength,z,U,W);if(W.length!==z.maxItems)return yield V(_.TupleLength,z,U,W);if(!z.items)return;for(let X=0;X<z.items.length;X++)yield*U2(z.items[X],w,`${U}/${X}`,W[X])}function*AM(z,w,U,W){if(!k0(W))yield V(_.Undefined,z,U,W)}function*ZM(z,w,U,W){if(s(z,w,W))return;let X=z.anyOf.map((A)=>new h6(U2(A,w,U,W)));yield V(_.Union,z,U,W,X)}function*$M(z,w,U,W){if(!s6(W))return yield V(_.Uint8Array,z,U,W);if(W0(z.maxByteLength)&&!(W.length<=z.maxByteLength))yield V(_.Uint8ArrayMaxByteLength,z,U,W);if(W0(z.minByteLength)&&!(W.length>=z.minByteLength))yield V(_.Uint8ArrayMinByteLength,z,U,W)}function*YM(z,w,U,W){}function*QM(z,w,U,W){if(!I0.IsVoidLike(W))yield V(_.Void,z,U,W)}function*JM(z,w,U,W){if(!p0.Get(z[H])(z,W))yield V(_.Kind,z,U,W)}function*U2(z,w,U,W){let X=W0(z.$id)?[...w,z]:w,A=z;switch(A[H]){case"Any":return yield*xB(A,X,U,W);case"Argument":return yield*VB(A,X,U,W);case"Array":return yield*kB(A,X,U,W);case"AsyncIterator":return yield*TB(A,X,U,W);case"BigInt":return yield*gB(A,X,U,W);case"Boolean":return yield*fB(A,X,U,W);case"Constructor":return yield*dB(A,X,U,W);case"Date":return yield*hB(A,X,U,W);case"Function":return yield*cB(A,X,U,W);case"Import":return yield*iB(A,X,U,W);case"Integer":return yield*yB(A,X,U,W);case"Intersect":return yield*vB(A,X,U,W);case"Iterator":return yield*nB(A,X,U,W);case"Literal":return yield*uB(A,X,U,W);case"Never":return yield*mB(A,X,U,W);case"Not":return yield*tB(A,X,U,W);case"Null":return yield*oB(A,X,U,W);case"Number":return yield*pB(A,X,U,W);case"Object":return yield*lB(A,X,U,W);case"Promise":return yield*sB(A,X,U,W);case"Record":return yield*rB(A,X,U,W);case"Ref":return yield*aB(A,X,U,W);case"RegExp":return yield*eB(A,X,U,W);case"String":return yield*zM(A,X,U,W);case"Symbol":return yield*wM(A,X,U,W);case"TemplateLiteral":return yield*UM(A,X,U,W);case"This":return yield*WM(A,X,U,W);case"Tuple":return yield*XM(A,X,U,W);case"Undefined":return yield*AM(A,X,U,W);case"Union":return yield*ZM(A,X,U,W);case"Uint8Array":return yield*$M(A,X,U,W);case"Unknown":return yield*YM(A,X,U,W);case"Void":return yield*QM(A,X,U,W);default:if(!p0.Has(A[H]))throw new hU(z);return yield*JM(A,X,U,W)}}function g1(...z){let w=z.length===3?U2(z[0],z[1],"",z[2]):U2(z[0],[],"",z[1]);return new h6(w)}class u4 extends n{constructor(z,w,U){super("Unable to decode value as it does not match the expected schema");this.schema=z,this.value=w,this.error=U}}class E5 extends n{constructor(z,w,U,W){super(W instanceof Error?W.message:"Unknown error");this.schema=z,this.path=w,this.value=U,this.error=W}}function d0(z,w,U){try{return L0(z)?z[j0].Decode(U):U}catch(W){throw new E5(z,w,U,W)}}function BM(z,w,U,W){return m(W)?d0(z,U,W.map((X,A)=>H1(z.items,w,`${U}/${A}`,X))):d0(z,U,W)}function MM(z,w,U,W){if(!l(W)||T2(W))return d0(z,U,W);let X=N5(z),A=X.map((J)=>J[0]),Z={...W};for(let[J,N]of X)if(J in Z)Z[J]=H1(N,w,`${U}/${J}`,Z[J]);if(!L0(z.unevaluatedProperties))return d0(z,U,Z);let $=Object.getOwnPropertyNames(Z),Y=z.unevaluatedProperties,Q={...Z};for(let J of $)if(!A.includes(J))Q[J]=d0(Y,`${U}/${J}`,Q[J]);return d0(z,U,Q)}function qM(z,w,U,W){let X=globalThis.Object.values(z.$defs),A=z.$defs[z.$ref],Z=H1(A,[...w,...X],U,W);return d0(z,U,Z)}function LM(z,w,U,W){return d0(z,U,H1(z.not,w,U,W))}function NM(z,w,U,W){if(!l(W))return d0(z,U,W);let X=O2(z),A={...W};for(let Q of X){if(!u(A,Q))continue;if(k0(A[Q])&&(!m1(z.properties[Q])||I0.IsExactOptionalProperty(A,Q)))continue;A[Q]=H1(z.properties[Q],w,`${U}/${Q}`,A[Q])}if(!f0(z.additionalProperties))return d0(z,U,A);let Z=Object.getOwnPropertyNames(A),$=z.additionalProperties,Y={...A};for(let Q of Z)if(!X.includes(Q))Y[Q]=d0($,`${U}/${Q}`,Y[Q]);return d0(z,U,Y)}function GM(z,w,U,W){if(!l(W))return d0(z,U,W);let X=Object.getOwnPropertyNames(z.patternProperties)[0],A=new RegExp(X),Z={...W};for(let J of Object.getOwnPropertyNames(W))if(A.test(J))Z[J]=H1(z.patternProperties[X],w,`${U}/${J}`,Z[J]);if(!f0(z.additionalProperties))return d0(z,U,Z);let $=Object.getOwnPropertyNames(Z),Y=z.additionalProperties,Q={...Z};for(let J of $)if(!A.test(J))Q[J]=d0(Y,`${U}/${J}`,Q[J]);return d0(z,U,Q)}function HM(z,w,U,W){let X=J0(z,w);return d0(z,U,H1(X,w,U,W))}function _M(z,w,U,W){let X=J0(z,w);return d0(z,U,H1(X,w,U,W))}function SM(z,w,U,W){return m(W)&&m(z.items)?d0(z,U,z.items.map((X,A)=>H1(X,w,`${U}/${A}`,W[A]))):d0(z,U,W)}function DM(z,w,U,W){for(let X of z.anyOf){if(!s(X,w,W))continue;let A=H1(X,w,U,W);return d0(z,U,A)}return d0(z,U,W)}function H1(z,w,U,W){let X=z2(z,w),A=z;switch(z[H]){case"Array":return BM(A,X,U,W);case"Import":return qM(A,X,U,W);case"Intersect":return MM(A,X,U,W);case"Not":return LM(A,X,U,W);case"Object":return NM(A,X,U,W);case"Record":return GM(A,X,U,W);case"Ref":return HM(A,X,U,W);case"Symbol":return d0(A,U,W);case"This":return _M(A,X,U,W);case"Tuple":return SM(A,X,U,W);case"Union":return DM(A,X,U,W);default:return d0(A,U,W)}}function _4(z,w,U){return H1(z,w,"",U)}class m4 extends n{constructor(z,w,U){super("The encoded value does not match the expected schema");this.schema=z,this.value=w,this.error=U}}class cU extends n{constructor(z,w,U,W){super(`${W instanceof Error?W.message:"Unknown error"}`);this.schema=z,this.path=w,this.value=U,this.error=W}}function Z2(z,w,U){try{return L0(z)?z[j0].Encode(U):U}catch(W){throw new cU(z,w,U,W)}}function PM(z,w,U,W){let X=Z2(z,U,W);return m(X)?X.map((A,Z)=>_1(z.items,w,`${U}/${Z}`,A)):X}function OM(z,w,U,W){let X=globalThis.Object.values(z.$defs),A=z.$defs[z.$ref],Z=Z2(z,U,W);return _1(A,[...w,...X],U,Z)}function RM(z,w,U,W){let X=Z2(z,U,W);if(!l(W)||T2(W))return X;let A=N5(z),Z=A.map((N)=>N[0]),$={...X};for(let[N,S]of A)if(N in $)$[N]=_1(S,w,`${U}/${N}`,$[N]);if(!L0(z.unevaluatedProperties))return $;let Y=Object.getOwnPropertyNames($),Q=z.unevaluatedProperties,J={...$};for(let N of Y)if(!Z.includes(N))J[N]=Z2(Q,`${U}/${N}`,J[N]);return J}function CM(z,w,U,W){return Z2(z.not,U,Z2(z,U,W))}function bM(z,w,U,W){let X=Z2(z,U,W);if(!l(X))return X;let A=O2(z),Z={...X};for(let J of A){if(!u(Z,J))continue;if(k0(Z[J])&&(!m1(z.properties[J])||I0.IsExactOptionalProperty(Z,J)))continue;Z[J]=_1(z.properties[J],w,`${U}/${J}`,Z[J])}if(!f0(z.additionalProperties))return Z;let $=Object.getOwnPropertyNames(Z),Y=z.additionalProperties,Q={...Z};for(let J of $)if(!A.includes(J))Q[J]=Z2(Y,`${U}/${J}`,Q[J]);return Q}function KM(z,w,U,W){let X=Z2(z,U,W);if(!l(W))return X;let A=Object.getOwnPropertyNames(z.patternProperties)[0],Z=new RegExp(A),$={...X};for(let N of Object.getOwnPropertyNames(W))if(Z.test(N))$[N]=_1(z.patternProperties[A],w,`${U}/${N}`,$[N]);if(!f0(z.additionalProperties))return $;let Y=Object.getOwnPropertyNames($),Q=z.additionalProperties,J={...$};for(let N of Y)if(!Z.test(N))J[N]=Z2(Q,`${U}/${N}`,J[N]);return J}function FM(z,w,U,W){let X=J0(z,w),A=_1(X,w,U,W);return Z2(z,U,A)}function jM(z,w,U,W){let X=J0(z,w),A=_1(X,w,U,W);return Z2(z,U,A)}function EM(z,w,U,W){let X=Z2(z,U,W);return m(z.items)?z.items.map((A,Z)=>_1(A,w,`${U}/${Z}`,X[Z])):[]}function IM(z,w,U,W){for(let X of z.anyOf){if(!s(X,w,W))continue;let A=_1(X,w,U,W);return Z2(z,U,A)}for(let X of z.anyOf){let A=_1(X,w,U,W);if(!s(z,w,A))continue;return Z2(z,U,A)}return Z2(z,U,W)}function _1(z,w,U,W){let X=z2(z,w),A=z;switch(z[H]){case"Array":return PM(A,X,U,W);case"Import":return OM(A,X,U,W);case"Intersect":return RM(A,X,U,W);case"Not":return CM(A,X,U,W);case"Object":return bM(A,X,U,W);case"Record":return KM(A,X,U,W);case"Ref":return FM(A,X,U,W);case"This":return jM(A,X,U,W);case"Tuple":return EM(A,X,U,W);case"Union":return IM(A,X,U,W);default:return Z2(A,U,W)}}function S4(z,w,U){return _1(z,w,"",U)}function xM(z,w){return L0(z)||a0(z.items,w)}function VM(z,w){return L0(z)||a0(z.items,w)}function kM(z,w){return L0(z)||a0(z.returns,w)||z.parameters.some((U)=>a0(U,w))}function TM(z,w){return L0(z)||a0(z.returns,w)||z.parameters.some((U)=>a0(U,w))}function gM(z,w){return L0(z)||L0(z.unevaluatedProperties)||z.allOf.some((U)=>a0(U,w))}function fM(z,w){let U=globalThis.Object.getOwnPropertyNames(z.$defs).reduce((X,A)=>[...X,z.$defs[A]],[]),W=z.$defs[z.$ref];return L0(z)||a0(W,[...U,...w])}function dM(z,w){return L0(z)||a0(z.items,w)}function hM(z,w){return L0(z)||a0(z.not,w)}function cM(z,w){return L0(z)||Object.values(z.properties).some((U)=>a0(U,w))||f0(z.additionalProperties)&&a0(z.additionalProperties,w)}function iM(z,w){return L0(z)||a0(z.item,w)}function yM(z,w){let U=Object.getOwnPropertyNames(z.patternProperties)[0],W=z.patternProperties[U];return L0(z)||a0(W,w)||f0(z.additionalProperties)&&L0(z.additionalProperties)}function vM(z,w){if(L0(z))return!0;return a0(J0(z,w),w)}function nM(z,w){if(L0(z))return!0;return a0(J0(z,w),w)}function uM(z,w){return L0(z)||!k0(z.items)&&z.items.some((U)=>a0(U,w))}function mM(z,w){return L0(z)||z.anyOf.some((U)=>a0(U,w))}function a0(z,w){let U=z2(z,w),W=z;if(z.$id&&fz.has(z.$id))return!1;if(z.$id)fz.add(z.$id);switch(z[H]){case"Array":return xM(W,U);case"AsyncIterator":return VM(W,U);case"Constructor":return kM(W,U);case"Function":return TM(W,U);case"Import":return fM(W,U);case"Intersect":return gM(W,U);case"Iterator":return dM(W,U);case"Not":return hM(W,U);case"Object":return cM(W,U);case"Promise":return iM(W,U);case"Record":return yM(W,U);case"Ref":return vM(W,U);case"This":return nM(W,U);case"Tuple":return uM(W,U);case"Union":return mM(W,U);default:return L0(z)}}var fz=new Set;function r1(z,w){return fz.clear(),a0(z,w)}class iU{constructor(z,w,U,W){this.schema=z,this.references=w,this.checkFunc=U,this.code=W,this.hasTransform=r1(z,w)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(z){return g1(this.schema,this.references,z)}Check(z){return this.checkFunc(z)}Decode(z){if(!this.checkFunc(z))throw new u4(this.schema,z,this.Errors(z).First());return this.hasTransform?_4(this.schema,this.references,z):z}Encode(z){let w=this.hasTransform?S4(this.schema,this.references,z):z;if(!this.checkFunc(w))throw new m4(this.schema,z,this.Errors(z).First());return w}}var a1;(function(z){function w(A){return A===36}z.DollarSign=w;function U(A){return A===95}z.IsUnderscore=U;function W(A){return A>=65&&A<=90||A>=97&&A<=122}z.IsAlpha=W;function X(A){return A>=48&&A<=57}z.IsNumeric=X})(a1||(a1={}));var I5;(function(z){function w(A){if(A.length===0)return!1;return a1.IsNumeric(A.charCodeAt(0))}function U(A){if(w(A))return!1;for(let Z=0;Z<A.length;Z++){let $=A.charCodeAt(Z);if(!(a1.IsAlpha($)||a1.IsNumeric($)||a1.DollarSign($)||a1.IsUnderscore($)))return!1}return!0}function W(A){return A.replace(/'/g,"\\'")}function X(A,Z){return U(Z)?`${A}.${Z}`:`${A}['${W(Z)}']`}z.Encode=X})(I5||(I5={}));var dz;(function(z){function w(U){let W=[];for(let X=0;X<U.length;X++){let A=U.charCodeAt(X);if(a1.IsNumeric(A)||a1.IsAlpha(A))W.push(U.charAt(X));else W.push(`_${A}_`)}return W.join("").replace(/__/g,"_")}z.Encode=w})(dz||(dz={}));var hz;(function(z){function w(U){return U.replace(/'/g,"\\'")}z.Escape=w})(hz||(hz={}));class yU extends n{constructor(z){super("Unknown type");this.schema=z}}class cz extends n{constructor(z){super("Preflight validation check failed to guard for the given schema");this.schema=z}}var c6;(function(z){function w(Z,$,Y){return I0.ExactOptionalPropertyTypes?`('${$}' in ${Z} ? ${Y} : true)`:`(${I5.Encode(Z,$)} !== undefined ? ${Y} : true)`}z.IsExactOptionalProperty=w;function U(Z){return!I0.AllowArrayObject?`(typeof ${Z} === 'object' && ${Z} !== null && !Array.isArray(${Z}))`:`(typeof ${Z} === 'object' && ${Z} !== null)`}z.IsObjectLike=U;function W(Z){return!I0.AllowArrayObject?`(typeof ${Z} === 'object' && ${Z} !== null && !Array.isArray(${Z}) && !(${Z} instanceof Date) && !(${Z} instanceof Uint8Array))`:`(typeof ${Z} === 'object' && ${Z} !== null && !(${Z} instanceof Date) && !(${Z} instanceof Uint8Array))`}z.IsRecordLike=W;function X(Z){return I0.AllowNaN?`typeof ${Z} === 'number'`:`Number.isFinite(${Z})`}z.IsNumberLike=X;function A(Z){return I0.AllowNullVoid?`(${Z} === undefined || ${Z} === null)`:`${Z} === undefined`}z.IsVoidLike=A})(c6||(c6={}));var _6;(function(z){function w(B){return B[H]==="Any"||B[H]==="Unknown"}function*U(B,K,L){yield"true"}function*W(B,K,L){yield"true"}function*X(B,K,L){yield`Array.isArray(${L})`;let[d,x]=[j("value","any"),j("acc","number")];if(v(B.maxItems))yield`${L}.length <= ${B.maxItems}`;if(v(B.minItems))yield`${L}.length >= ${B.minItems}`;let h=x2(B.items,K,"value");if(yield`${L}.every((${d}) => ${h})`,g0(B.contains)||v(B.minContains)||v(B.maxContains)){let b0=g0(B.contains)?B.contains:p(),_2=x2(b0,K,"value"),f1=v(B.minContains)?[`(count >= ${B.minContains})`]:[],A1=v(B.maxContains)?[`(count <= ${B.maxContains})`]:[],F1=`const count = value.reduce((${x}, ${d}) => ${_2} ? acc + 1 : acc, 0)`,X8=["(count > 0)",...f1,...A1].join(" && ");yield`((${d}) => { ${F1}; return ${X8}})(${L})`}if(B.uniqueItems===!0)yield`((${d}) => { 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 } )(${L})`}function*A(B,K,L){yield`(typeof value === 'object' && Symbol.asyncIterator in ${L})`}function*Z(B,K,L){if(yield`(typeof ${L} === 'bigint')`,X2(B.exclusiveMaximum))yield`${L} < BigInt(${B.exclusiveMaximum})`;if(X2(B.exclusiveMinimum))yield`${L} > BigInt(${B.exclusiveMinimum})`;if(X2(B.maximum))yield`${L} <= BigInt(${B.maximum})`;if(X2(B.minimum))yield`${L} >= BigInt(${B.minimum})`;if(X2(B.multipleOf))yield`(${L} % BigInt(${B.multipleOf})) === 0`}function*$(B,K,L){yield`(typeof ${L} === 'boolean')`}function*Y(B,K,L){yield*W1(B.returns,K,`${L}.prototype`)}function*Q(B,K,L){if(yield`(${L} instanceof Date) && Number.isFinite(${L}.getTime())`,v(B.exclusiveMaximumTimestamp))yield`${L}.getTime() < ${B.exclusiveMaximumTimestamp}`;if(v(B.exclusiveMinimumTimestamp))yield`${L}.getTime() > ${B.exclusiveMinimumTimestamp}`;if(v(B.maximumTimestamp))yield`${L}.getTime() <= ${B.maximumTimestamp}`;if(v(B.minimumTimestamp))yield`${L}.getTime() >= ${B.minimumTimestamp}`;if(v(B.multipleOfTimestamp))yield`(${L}.getTime() % ${B.multipleOfTimestamp}) === 0`}function*J(B,K,L){yield`(typeof ${L} === 'function')`}function*N(B,K,L){let d=globalThis.Object.getOwnPropertyNames(B.$defs).reduce((x,h)=>{return[...x,B.$defs[h]]},[]);yield*W1(p2(B.$ref),[...K,...d],L)}function*S(B,K,L){if(yield`Number.isInteger(${L})`,v(B.exclusiveMaximum))yield`${L} < ${B.exclusiveMaximum}`;if(v(B.exclusiveMinimum))yield`${L} > ${B.exclusiveMinimum}`;if(v(B.maximum))yield`${L} <= ${B.maximum}`;if(v(B.minimum))yield`${L} >= ${B.minimum}`;if(v(B.multipleOf))yield`(${L} % ${B.multipleOf}) === 0`}function*G(B,K,L){let d=B.allOf.map((x)=>x2(x,K,L)).join(" && ");if(B.unevaluatedProperties===!1){let x=A6(`${new RegExp(p1(B))};`),h=`Object.getOwnPropertyNames(${L}).every(key => ${x}.test(key))`;yield`(${d} && ${h})`}else if(g0(B.unevaluatedProperties)){let x=A6(`${new RegExp(p1(B))};`),h=`Object.getOwnPropertyNames(${L}).every(key => ${x}.test(key) || ${x2(B.unevaluatedProperties,K,`${L}[key]`)})`;yield`(${d} && ${h})`}else yield`(${d})`}function*O(B,K,L){yield`(typeof value === 'object' && Symbol.iterator in ${L})`}function*M(B,K,L){if(typeof B.const==="number"||typeof B.const==="boolean")yield`(${L} === ${B.const})`;else yield`(${L} === '${hz.Escape(B.const)}')`}function*C(B,K,L){yield"false"}function*k(B,K,L){yield`(!${x2(B.not,K,L)})`}function*q0(B,K,L){yield`(${L} === null)`}function*w0(B,K,L){if(yield c6.IsNumberLike(L),v(B.exclusiveMaximum))yield`${L} < ${B.exclusiveMaximum}`;if(v(B.exclusiveMinimum))yield`${L} > ${B.exclusiveMinimum}`;if(v(B.maximum))yield`${L} <= ${B.maximum}`;if(v(B.minimum))yield`${L} >= ${B.minimum}`;if(v(B.multipleOf))yield`(${L} % ${B.multipleOf}) === 0`}function*_0(B,K,L){if(yield c6.IsObjectLike(L),v(B.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${B.minProperties}`;if(v(B.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${B.maxProperties}`;let d=Object.getOwnPropertyNames(B.properties);for(let x of d){let h=I5.Encode(L,x),b0=B.properties[x];if(B.required&&B.required.includes(x)){if(yield*W1(b0,K,h),l1(b0)||w(b0))yield`('${x}' in ${L})`}else{let _2=x2(b0,K,h);yield c6.IsExactOptionalProperty(L,x,_2)}}if(B.additionalProperties===!1)if(B.required&&B.required.length===d.length)yield`Object.getOwnPropertyNames(${L}).length === ${d.length}`;else{let x=`[${d.map((h)=>`'${h}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${L}).every(key => ${x}.includes(key))`}if(typeof B.additionalProperties==="object"){let x=x2(B.additionalProperties,K,`${L}[key]`),h=`[${d.map((b0)=>`'${b0}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${L}).every(key => ${h}.includes(key) || ${x}))`}}function*C0(B,K,L){yield`${L} instanceof Promise`}function*f(B,K,L){if(yield c6.IsRecordLike(L),v(B.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${B.minProperties}`;if(v(B.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${B.maxProperties}`;let[d,x]=Object.entries(B.patternProperties)[0],h=A6(`${new RegExp(d)}`),b0=x2(x,K,"value"),_2=g0(B.additionalProperties)?x2(B.additionalProperties,K,L):B.additionalProperties===!1?"false":"true",f1=`(${h}.test(key) ? ${b0} : ${_2})`;yield`(Object.entries(${L}).every(([key, value]) => ${f1}))`}function*E(B,K,L){let d=J0(B,K);if(S0.functions.has(B.$ref))return yield`${X6(B.$ref)}(${L})`;yield*W1(d,K,L)}function*T(B,K,L){let d=A6(`${new RegExp(B.source,B.flags)};`);if(yield`(typeof ${L} === 'string')`,v(B.maxLength))yield`${L}.length <= ${B.maxLength}`;if(v(B.minLength))yield`${L}.length >= ${B.minLength}`;yield`${d}.test(${L})`}function*F(B,K,L){if(yield`(typeof ${L} === 'string')`,v(B.maxLength))yield`${L}.length <= ${B.maxLength}`;if(v(B.minLength))yield`${L}.length >= ${B.minLength}`;if(B.pattern!==void 0)yield`${A6(`${new RegExp(B.pattern)};`)}.test(${L})`;if(B.format!==void 0)yield`format('${B.format}', ${L})`}function*a(B,K,L){yield`(typeof ${L} === 'symbol')`}function*Z0(B,K,L){yield`(typeof ${L} === 'string')`,yield`${A6(`${new RegExp(B.pattern)};`)}.test(${L})`}function*H0(B,K,L){yield`${X6(B.$ref)}(${L})`}function*h0(B,K,L){if(yield`Array.isArray(${L})`,B.items===void 0)return yield`${L}.length === 0`;yield`(${L}.length === ${B.maxItems})`;for(let d=0;d<B.items.length;d++)yield`${x2(B.items[d],K,`${L}[${d}]`)}`}function*U6(B,K,L){yield`${L} === undefined`}function*n0(B,K,L){yield`(${B.anyOf.map((x)=>x2(x,K,L)).join(" || ")})`}function*W6(B,K,L){if(yield`${L} instanceof Uint8Array`,v(B.maxByteLength))yield`(${L}.length <= ${B.maxByteLength})`;if(v(B.minByteLength))yield`(${L}.length >= ${B.minByteLength})`}function*I2(B,K,L){yield"true"}function*b6(B,K,L){yield c6.IsVoidLike(L)}function*a5(B,K,L){let d=S0.instances.size;S0.instances.set(d,B),yield`kind('${B[H]}', ${d}, ${L})`}function*W1(B,K,L,d=!0){let x=$0(B.$id)?[...K,B]:K,h=B;if(d&&$0(B.$id)){let b0=X6(B.$id);if(S0.functions.has(b0))return yield`${b0}(${L})`;else{S0.functions.set(b0,"<deferred>");let _2=X1(b0,B,K,"value",!1);return S0.functions.set(b0,_2),yield`${b0}(${L})`}}switch(h[H]){case"Any":return yield*U(h,x,L);case"Argument":return yield*W(h,x,L);case"Array":return yield*X(h,x,L);case"AsyncIterator":return yield*A(h,x,L);case"BigInt":return yield*Z(h,x,L);case"Boolean":return yield*$(h,x,L);case"Constructor":return yield*Y(h,x,L);case"Date":return yield*Q(h,x,L);case"Function":return yield*J(h,x,L);case"Import":return yield*N(h,x,L);case"Integer":return yield*S(h,x,L);case"Intersect":return yield*G(h,x,L);case"Iterator":return yield*O(h,x,L);case"Literal":return yield*M(h,x,L);case"Never":return yield*C(h,x,L);case"Not":return yield*k(h,x,L);case"Null":return yield*q0(h,x,L);case"Number":return yield*w0(h,x,L);case"Object":return yield*_0(h,x,L);case"Promise":return yield*C0(h,x,L);case"Record":return yield*f(h,x,L);case"Ref":return yield*E(h,x,L);case"RegExp":return yield*T(h,x,L);case"String":return yield*F(h,x,L);case"Symbol":return yield*a(h,x,L);case"TemplateLiteral":return yield*Z0(h,x,L);case"This":return yield*H0(h,x,L);case"Tuple":return yield*h0(h,x,L);case"Undefined":return yield*U6(h,x,L);case"Union":return yield*n0(h,x,L);case"Uint8Array":return yield*W6(h,x,L);case"Unknown":return yield*I2(h,x,L);case"Void":return yield*b6(h,x,L);default:if(!p0.Has(h[H]))throw new yU(B);return yield*a5(h,x,L)}}let S0={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function x2(B,K,L,d=!0){return`(${[...W1(B,K,L,d)].join(" && ")})`}function X6(B){return`check_${dz.Encode(B)}`}function A6(B){let K=`local_${S0.variables.size}`;return S0.variables.set(K,`const ${K} = ${B}`),K}function X1(B,K,L,d,x=!0){let[h,b0]=[`
3
+ `,(F1)=>"".padStart(F1," ")],_2=j("value","any"),f1=R("boolean"),A1=[...W1(K,L,d,x)].map((F1)=>`${b0(4)}${F1}`).join(` &&${h}`);return`function ${B}(${_2})${f1} {${h}${b0(2)}return (${h}${A1}${h}${b0(2)})
4
+ }`}function j(B,K){let L=S0.language==="typescript"?`: ${K}`:"";return`${B}${L}`}function R(B){return S0.language==="typescript"?`: ${B}`:""}function b(B,K,L){let d=X1("check",B,K,"value"),x=j("value","any"),h=R("boolean"),b0=[...S0.functions.values()],_2=[...S0.variables.values()],f1=$0(B.$id)?`return function check(${x})${h} {
5
+ return ${X6(B.$id)}(value)
6
+ }`:`return ${d}`;return[..._2,...b0,f1].join(`
7
+ `)}function c(...B){let K={language:"javascript"},[L,d,x]=B.length===2&&m(B[1])?[B[0],B[1],K]:B.length===2&&!m(B[1])?[B[0],[],B[1]]:B.length===3?[B[0],B[1],B[2]]:B.length===1?[B[0],[],K]:[null,[],K];if(S0.language=x.language,S0.variables.clear(),S0.functions.clear(),S0.instances.clear(),!g0(L))throw new cz(L);for(let h of d)if(!g0(h))throw new cz(h);return b(L,d,x)}z.Code=c;function t(B,K=[]){let L=c(B,K,{language:"javascript"}),d=globalThis.Function("kind","format","hash",L),x=new Map(S0.instances);function h(A1,F1,X8){if(!p0.Has(A1)||!x.has(F1))return!1;let GX=p0.Get(A1),HX=x.get(F1);return GX(HX,X8)}function b0(A1,F1){if(!D0.Has(A1))return!1;return D0.Get(A1)(F1)}function _2(A1){return H6(A1)}let f1=d(h,b0,_2);return new iU(B,K,f1,L)}z.Compile=t})(_6||(_6={}));var tM=function(z,w,U,W,X){if(W==="m")throw new TypeError("Private method is not writable");if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof w==="function"?z!==w||!X:!w.has(z))throw new TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?X.call(z,U):X?X.value=U:w.set(z,U),U},nU=function(z,w,U,W){if(U==="a"&&!W)throw new TypeError("Private accessor was defined without a getter");if(typeof w==="function"?z!==w||!W:!w.has(z))throw new TypeError("Cannot read private member from an object whose class did not declare it");return U==="m"?W:U==="a"?W.call(z):W?W.value:w.get(z)},iz,x5,uU;class mU extends n{constructor(z){let w=z.First();super(w===void 0?"Invalid Value":w.message);iz.add(this),x5.set(this,void 0),tM(this,x5,z,"f"),this.error=w}Errors(){return new h6(nU(this,iz,"m",uU).call(this))}}x5=new WeakMap,iz=new WeakSet,uU=function*z(){if(this.error)yield this.error;yield*nU(this,x5,"f")};function vU(z,w,U){if(s(z,w,U))return;throw new mU(g1(z,w,U))}function V5(...z){return z.length===3?vU(z[0],z[1],z[2]):vU(z[0],[],z[1])}function oM(z){let w={};for(let U of Object.getOwnPropertyNames(z))w[U]=B0(z[U]);for(let U of Object.getOwnPropertySymbols(z))w[U]=B0(z[U]);return w}function pM(z){return z.map((w)=>B0(w))}function lM(z){return z.slice()}function sM(z){return new Map(B0([...z.entries()]))}function rM(z){return new Set(B0([...z.entries()]))}function aM(z){return new Date(z.toISOString())}function eM(z){return z}function B0(z){if(m(z))return pM(z);if(N2(z))return aM(z);if(n2(z))return lM(z);if(Q9(z))return sM(z);if(J9(z))return rM(z);if(l(z))return oM(z);if(T2(z))return eM(z);throw new Error("ValueClone: Unable to clone value")}class r2 extends n{constructor(z,w){super(w);this.schema=z}}function M0(z){return Y6(z)?z():B0(z)}function zq(z,w){if(u(z,"default"))return M0(z.default);else return{}}function wq(z,w){return{}}function Uq(z,w){if(z.uniqueItems===!0&&!u(z,"default"))throw new r2(z,"Array with the uniqueItems constraint requires a default value");else if("contains"in z&&!u(z,"default"))throw new r2(z,"Array with the contains constraint requires a default value");else if("default"in z)return M0(z.default);else if(z.minItems!==void 0)return Array.from({length:z.minItems}).map((U)=>{return C2(z.items,w)});else return[]}function Wq(z,w){if(u(z,"default"))return M0(z.default);else return async function*(){}()}function Xq(z,w){if(u(z,"default"))return M0(z.default);else return BigInt(0)}function Aq(z,w){if(u(z,"default"))return M0(z.default);else return!1}function Zq(z,w){if(u(z,"default"))return M0(z.default);else{let U=C2(z.returns,w);if(typeof U==="object"&&!Array.isArray(U))return class{constructor(){for(let[W,X]of Object.entries(U)){let A=this;A[W]=X}}};else return class{}}}function $q(z,w){if(u(z,"default"))return M0(z.default);else if(z.minimumTimestamp!==void 0)return new Date(z.minimumTimestamp);else return new Date}function Yq(z,w){if(u(z,"default"))return M0(z.default);else return()=>C2(z.returns,w)}function Qq(z,w){let U=globalThis.Object.values(z.$defs),W=z.$defs[z.$ref];return C2(W,[...w,...U])}function Jq(z,w){if(u(z,"default"))return M0(z.default);else if(z.minimum!==void 0)return z.minimum;else return 0}function Bq(z,w){if(u(z,"default"))return M0(z.default);else{let U=z.allOf.reduce((W,X)=>{let A=C2(X,w);return typeof A==="object"?{...W,...A}:A},{});if(!s(z,w,U))throw new r2(z,"Intersect produced invalid value. Consider using a default value.");return U}}function Mq(z,w){if(u(z,"default"))return M0(z.default);else return function*(){}()}function qq(z,w){if(u(z,"default"))return M0(z.default);else return z.const}function Lq(z,w){if(u(z,"default"))return M0(z.default);else throw new r2(z,"Never types cannot be created. Consider using a default value.")}function Nq(z,w){if(u(z,"default"))return M0(z.default);else throw new r2(z,"Not types must have a default value")}function Gq(z,w){if(u(z,"default"))return M0(z.default);else return null}function Hq(z,w){if(u(z,"default"))return M0(z.default);else if(z.minimum!==void 0)return z.minimum;else return 0}function _q(z,w){if(u(z,"default"))return M0(z.default);else{let U=new Set(z.required),W={};for(let[X,A]of Object.entries(z.properties)){if(!U.has(X))continue;W[X]=C2(A,w)}return W}}function Sq(z,w){if(u(z,"default"))return M0(z.default);else return Promise.resolve(C2(z.item,w))}function Dq(z,w){let[U,W]=Object.entries(z.patternProperties)[0];if(u(z,"default"))return M0(z.default);else if(!(U===V1||U===x1)){let X=U.slice(1,U.length-1).split("|"),A={};for(let Z of X)A[Z]=C2(W,w);return A}else return{}}function Pq(z,w){if(u(z,"default"))return M0(z.default);else return C2(J0(z,w),w)}function Oq(z,w){if(u(z,"default"))return M0(z.default);else throw new r2(z,"RegExp types cannot be created. Consider using a default value.")}function Rq(z,w){if(z.pattern!==void 0)if(!u(z,"default"))throw new r2(z,"String types with patterns must specify a default value");else return M0(z.default);else if(z.format!==void 0)if(!u(z,"default"))throw new r2(z,"String types with formats must specify a default value");else return M0(z.default);else if(u(z,"default"))return M0(z.default);else if(z.minLength!==void 0)return Array.from({length:z.minLength}).map(()=>" ").join("");else return""}function Cq(z,w){if(u(z,"default"))return M0(z.default);else if("value"in z)return Symbol.for(z.value);else return Symbol()}function bq(z,w){if(u(z,"default"))return M0(z.default);if(!J5(z))throw new r2(z,"Can only create template literals that produce a finite variants. Consider using a default value.");return A4(z)[0]}function Kq(z,w){if(tU++>Tq)throw new r2(z,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(u(z,"default"))return M0(z.default);else return C2(J0(z,w),w)}function Fq(z,w){if(u(z,"default"))return M0(z.default);if(z.items===void 0)return[];else return Array.from({length:z.minItems}).map((U,W)=>C2(z.items[W],w))}function jq(z,w){if(u(z,"default"))return M0(z.default);else return}function Eq(z,w){if(u(z,"default"))return M0(z.default);else if(z.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return C2(z.anyOf[0],w)}function Iq(z,w){if(u(z,"default"))return M0(z.default);else if(z.minByteLength!==void 0)return new Uint8Array(z.minByteLength);else return new Uint8Array(0)}function xq(z,w){if(u(z,"default"))return M0(z.default);else return{}}function Vq(z,w){if(u(z,"default"))return M0(z.default);else return}function kq(z,w){if(u(z,"default"))return M0(z.default);else throw new Error("User defined types must specify a default value")}function C2(z,w){let U=z2(z,w),W=z;switch(W[H]){case"Any":return zq(W,U);case"Argument":return wq(W,U);case"Array":return Uq(W,U);case"AsyncIterator":return Wq(W,U);case"BigInt":return Xq(W,U);case"Boolean":return Aq(W,U);case"Constructor":return Zq(W,U);case"Date":return $q(W,U);case"Function":return Yq(W,U);case"Import":return Qq(W,U);case"Integer":return Jq(W,U);case"Intersect":return Bq(W,U);case"Iterator":return Mq(W,U);case"Literal":return qq(W,U);case"Never":return Lq(W,U);case"Not":return Nq(W,U);case"Null":return Gq(W,U);case"Number":return Hq(W,U);case"Object":return _q(W,U);case"Promise":return Sq(W,U);case"Record":return Dq(W,U);case"Ref":return Pq(W,U);case"RegExp":return Oq(W,U);case"String":return Rq(W,U);case"Symbol":return Cq(W,U);case"TemplateLiteral":return bq(W,U);case"This":return Kq(W,U);case"Tuple":return Fq(W,U);case"Undefined":return jq(W,U);case"Union":return Eq(W,U);case"Uint8Array":return Iq(W,U);case"Unknown":return xq(W,U);case"Void":return Vq(W,U);default:if(!p0.Has(W[H]))throw new r2(W,"Unknown type");return kq(W,U)}}var Tq=512,tU=0;function a2(...z){return tU=0,z.length===2?C2(z[0],z[1]):C2(z[0],[])}class yz extends n{constructor(z,w){super(w);this.schema=z}}function gq(z,w,U){if(z[H]==="Object"&&typeof U==="object"&&!y1(U)){let W=z,X=Object.getOwnPropertyNames(U),A=Object.entries(W.properties),[Z,$]=[1/A.length,A.length];return A.reduce((Y,[Q,J])=>{let N=J[H]==="Literal"&&J.const===U[Q]?$:0,S=s(J,w,U[Q])?Z:0,G=X.includes(Q)?Z:0;return Y+(N+S+G)},0)}else return s(z,w,U)?1:0}function fq(z,w,U){let W=z.anyOf.map((Z)=>J0(Z,w)),[X,A]=[W[0],0];for(let Z of W){let $=gq(Z,w,U);if($>A)X=Z,A=$}return X}function dq(z,w,U){if("default"in z)return typeof U==="function"?z.default:B0(z.default);else{let W=fq(z,w,U);return t4(W,w,U)}}function hq(z,w,U){return s(z,w,U)?B0(U):a2(z,w)}function cq(z,w,U){return s(z,w,U)?U:a2(z,w)}function iq(z,w,U){if(s(z,w,U))return B0(U);let W=m(U)?B0(U):a2(z,w),X=v(z.minItems)&&W.length<z.minItems?[...W,...Array.from({length:z.minItems-W.length},()=>null)]:W,Z=(v(z.maxItems)&&X.length>z.maxItems?X.slice(0,z.maxItems):X).map((Y)=>S1(z.items,w,Y));if(z.uniqueItems!==!0)return Z;let $=[...new Set(Z)];if(!s(z,w,$))throw new yz(z,"Array cast produced invalid data due to uniqueItems constraint");return $}function yq(z,w,U){if(s(z,w,U))return a2(z,w);let W=new Set(z.returns.required||[]),X=function(){};for(let[A,Z]of Object.entries(z.returns.properties)){if(!W.has(A)&&U.prototype[A]===void 0)continue;X.prototype[A]=S1(Z,w,U.prototype[A])}return X}function vq(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return S1(X,[...w,...W],U)}function nq(z,w,U){let W=a2(z,w),X=l(W)&&l(U)?{...W,...U}:U;return s(z,w,X)?X:a2(z,w)}function uq(z,w,U){throw new yz(z,"Never types cannot be cast")}function mq(z,w,U){if(s(z,w,U))return U;if(U===null||typeof U!=="object")return a2(z,w);let W=new Set(z.required||[]),X={};for(let[A,Z]of Object.entries(z.properties)){if(!W.has(A)&&U[A]===void 0)continue;X[A]=S1(Z,w,U[A])}if(typeof z.additionalProperties==="object"){let A=Object.getOwnPropertyNames(z.properties);for(let Z of Object.getOwnPropertyNames(U)){if(A.includes(Z))continue;X[Z]=S1(z.additionalProperties,w,U[Z])}}return X}function tq(z,w,U){if(s(z,w,U))return B0(U);if(U===null||typeof U!=="object"||Array.isArray(U)||U instanceof Date)return a2(z,w);let W=Object.getOwnPropertyNames(z.patternProperties)[0],X=z.patternProperties[W],A={};for(let[Z,$]of Object.entries(U))A[Z]=S1(X,w,$);return A}function oq(z,w,U){return S1(J0(z,w),w,U)}function pq(z,w,U){return S1(J0(z,w),w,U)}function lq(z,w,U){if(s(z,w,U))return B0(U);if(!m(U))return a2(z,w);if(z.items===void 0)return[];return z.items.map((W,X)=>S1(W,w,U[X]))}function sq(z,w,U){return s(z,w,U)?B0(U):dq(z,w,U)}function S1(z,w,U){let W=$0(z.$id)?z2(z,w):w,X=z;switch(z[H]){case"Array":return iq(X,W,U);case"Constructor":return yq(X,W,U);case"Import":return vq(X,W,U);case"Intersect":return nq(X,W,U);case"Never":return uq(X,W,U);case"Object":return mq(X,W,U);case"Record":return tq(X,W,U);case"Ref":return oq(X,W,U);case"This":return pq(X,W,U);case"Tuple":return lq(X,W,U);case"Union":return sq(X,W,U);case"Date":case"Symbol":case"Uint8Array":return hq(z,w,U);default:return cq(X,W,U)}}function t4(...z){return z.length===3?S1(z[0],z[1],z[2]):S1(z[0],[],z[1])}function rq(z){return J6(z)&&z[H]!=="Unsafe"}function aq(z,w,U){if(!m(U))return U;return U.map((W)=>b2(z.items,w,W))}function eq(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return b2(X,[...w,...W],U)}function zL(z,w,U){let W=z.unevaluatedProperties,A=z.allOf.map(($)=>b2($,w,B0(U))).reduce(($,Y)=>l(Y)?{...$,...Y}:Y,{});if(!l(U)||!l(A)||!J6(W))return A;let Z=O2(z);for(let $ of Object.getOwnPropertyNames(U)){if(Z.includes($))continue;if(s(W,w,U[$]))A[$]=b2(W,w,U[$])}return A}function wL(z,w,U){if(!l(U)||m(U))return U;let W=z.additionalProperties;for(let X of Object.getOwnPropertyNames(U)){if(u(z.properties,X)){U[X]=b2(z.properties[X],w,U[X]);continue}if(J6(W)&&s(W,w,U[X])){U[X]=b2(W,w,U[X]);continue}delete U[X]}return U}function UL(z,w,U){if(!l(U))return U;let W=z.additionalProperties,X=Object.getOwnPropertyNames(U),[A,Z]=Object.entries(z.patternProperties)[0],$=new RegExp(A);for(let Y of X){if($.test(Y)){U[Y]=b2(Z,w,U[Y]);continue}if(J6(W)&&s(W,w,U[Y])){U[Y]=b2(W,w,U[Y]);continue}delete U[Y]}return U}function WL(z,w,U){return b2(J0(z,w),w,U)}function XL(z,w,U){return b2(J0(z,w),w,U)}function AL(z,w,U){if(!m(U))return U;if(k0(z.items))return[];let W=Math.min(U.length,z.items.length);for(let X=0;X<W;X++)U[X]=b2(z.items[X],w,U[X]);return U.length>W?U.slice(0,W):U}function ZL(z,w,U){for(let W of z.anyOf)if(rq(W)&&s(W,w,U))return b2(W,w,U);return U}function b2(z,w,U){let W=$0(z.$id)?z2(z,w):w,X=z;switch(X[H]){case"Array":return aq(X,W,U);case"Import":return eq(X,W,U);case"Intersect":return zL(X,W,U);case"Object":return wL(X,W,U);case"Record":return UL(X,W,U);case"Ref":return WL(X,W,U);case"This":return XL(X,W,U);case"Tuple":return AL(X,W,U);case"Union":return ZL(X,W,U);default:return U}}function k5(...z){return z.length===3?b2(z[0],z[1],z[2]):b2(z[0],[],z[1])}function T5(z){return $0(z)&&!isNaN(z)&&!isNaN(parseFloat(z))}function $L(z){return X2(z)||I1(z)||v(z)}function o4(z){return z===!0||v(z)&&z===1||X2(z)&&z===BigInt("1")||$0(z)&&(z.toLowerCase()==="true"||z==="1")}function p4(z){return z===!1||v(z)&&(z===0||Object.is(z,-0))||X2(z)&&z===BigInt("0")||$0(z)&&(z.toLowerCase()==="false"||z==="0"||z==="-0")}function YL(z){return $0(z)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(z)}function QL(z){return $0(z)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(z)}function JL(z){return $0(z)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(z)}function BL(z){return $0(z)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(z)}function ML(z){return $0(z)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(z)}function qL(z,w){let U=pU(z);return U===w?U:z}function LL(z,w){let U=lU(z);return U===w?U:z}function NL(z,w){let U=oU(z);return U===w?U:z}function GL(z,w){return $0(z.const)?qL(w,z.const):v(z.const)?LL(w,z.const):I1(z.const)?NL(w,z.const):w}function oU(z){return o4(z)?!0:p4(z)?!1:z}function HL(z){let w=(U)=>U.split(".")[0];return T5(z)?BigInt(w(z)):v(z)?BigInt(Math.trunc(z)):p4(z)?BigInt(0):o4(z)?BigInt(1):z}function pU(z){return v1(z)&&z.description!==void 0?z.description.toString():$L(z)?z.toString():z}function lU(z){return T5(z)?parseFloat(z):o4(z)?1:p4(z)?0:z}function _L(z){return T5(z)?parseInt(z):v(z)?Math.trunc(z):o4(z)?1:p4(z)?0:z}function SL(z){return $0(z)&&z.toLowerCase()==="null"?null:z}function DL(z){return $0(z)&&z==="undefined"?void 0:z}function PL(z){return N2(z)?z:v(z)?new Date(z):o4(z)?new Date(1):p4(z)?new Date(0):T5(z)?new Date(parseInt(z)):QL(z)?new Date(`1970-01-01T${z}.000Z`):YL(z)?new Date(`1970-01-01T${z}`):BL(z)?new Date(`${z}.000Z`):JL(z)?new Date(z):ML(z)?new Date(`${z}T00:00:00.000Z`):z}function OL(z){return z}function RL(z,w,U){return(m(U)?U:[U]).map((X)=>D1(z.items,w,X))}function CL(z,w,U){return HL(U)}function bL(z,w,U){return oU(U)}function KL(z,w,U){return PL(U)}function FL(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return D1(X,[...w,...W],U)}function jL(z,w,U){return _L(U)}function EL(z,w,U){return z.allOf.reduce((W,X)=>D1(X,w,W),U)}function IL(z,w,U){return GL(z,U)}function xL(z,w,U){return SL(U)}function VL(z,w,U){return lU(U)}function kL(z,w,U){if(!l(U))return U;for(let W of Object.getOwnPropertyNames(z.properties)){if(!u(U,W))continue;U[W]=D1(z.properties[W],w,U[W])}return U}function TL(z,w,U){if(!l(U))return U;let X=Object.getOwnPropertyNames(z.patternProperties)[0],A=z.patternProperties[X];for(let[Z,$]of Object.entries(U))U[Z]=D1(A,w,$);return U}function gL(z,w,U){return D1(J0(z,w),w,U)}function fL(z,w,U){return pU(U)}function dL(z,w,U){return $0(U)||v(U)?Symbol(U):U}function hL(z,w,U){return D1(J0(z,w),w,U)}function cL(z,w,U){if(!(m(U)&&!k0(z.items)))return U;return U.map((X,A)=>{return A<z.items.length?D1(z.items[A],w,X):X})}function iL(z,w,U){return DL(U)}function yL(z,w,U){for(let W of z.anyOf){let X=D1(W,w,B0(U));if(!s(W,w,X))continue;return X}return U}function D1(z,w,U){let W=z2(z,w),X=z;switch(z[H]){case"Array":return RL(X,W,U);case"BigInt":return CL(X,W,U);case"Boolean":return bL(X,W,U);case"Date":return KL(X,W,U);case"Import":return FL(X,W,U);case"Integer":return jL(X,W,U);case"Intersect":return EL(X,W,U);case"Literal":return IL(X,W,U);case"Null":return xL(X,W,U);case"Number":return VL(X,W,U);case"Object":return kL(X,W,U);case"Record":return TL(X,W,U);case"Ref":return gL(X,W,U);case"String":return fL(X,W,U);case"Symbol":return dL(X,W,U);case"This":return hL(X,W,U);case"Tuple":return cL(X,W,U);case"Undefined":return iL(X,W,U);case"Union":return yL(X,W,U);default:return OL(U)}}function g5(...z){return z.length===3?D1(z[0],z[1],z[2]):D1(z[0],[],z[1])}function sU(...z){let[w,U,W]=z.length===3?[z[0],z[1],z[2]]:[z[0],[],z[1]];if(!s(w,U,W))throw new u4(w,W,g1(w,U,W).First());return r1(w,U)?_4(w,U,W):W}function e1(z,w){let U=u(z,"default")?z.default:void 0,W=Y6(U)?U():B0(U);return k0(w)?W:l(w)&&l(W)?Object.assign(W,w):w}function vz(z){return J6(z)&&"default"in z}function vL(z,w,U){if(m(U)){for(let X=0;X<U.length;X++)U[X]=H2(z.items,w,U[X]);return U}let W=e1(z,U);if(!m(W))return W;for(let X=0;X<W.length;X++)W[X]=H2(z.items,w,W[X]);return W}function nL(z,w,U){return N2(U)?U:e1(z,U)}function uL(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return H2(X,[...w,...W],U)}function mL(z,w,U){let W=e1(z,U);return z.allOf.reduce((X,A)=>{let Z=H2(A,w,W);return l(Z)?{...X,...Z}:Z},{})}function tL(z,w,U){let W=e1(z,U);if(!l(W))return W;let X=Object.getOwnPropertyNames(z.properties);for(let A of X){let Z=H2(z.properties[A],w,W[A]);if(k0(Z))continue;W[A]=H2(z.properties[A],w,W[A])}if(!vz(z.additionalProperties))return W;for(let A of Object.getOwnPropertyNames(W)){if(X.includes(A))continue;W[A]=H2(z.additionalProperties,w,W[A])}return W}function oL(z,w,U){let W=e1(z,U);if(!l(W))return W;let X=z.additionalProperties,[A,Z]=Object.entries(z.patternProperties)[0],$=new RegExp(A);for(let Y of Object.getOwnPropertyNames(W)){if(!($.test(Y)&&vz(Z)))continue;W[Y]=H2(Z,w,W[Y])}if(!vz(X))return W;for(let Y of Object.getOwnPropertyNames(W)){if($.test(Y))continue;W[Y]=H2(X,w,W[Y])}return W}function pL(z,w,U){return H2(J0(z,w),w,e1(z,U))}function lL(z,w,U){return H2(J0(z,w),w,U)}function sL(z,w,U){let W=e1(z,U);if(!m(W)||k0(z.items))return W;let[X,A]=[z.items,Math.max(z.items.length,W.length)];for(let Z=0;Z<A;Z++)if(Z<X.length)W[Z]=H2(X[Z],w,W[Z]);return W}function rL(z,w,U){let W=e1(z,U);for(let X of z.anyOf){let A=H2(X,w,B0(W));if(s(X,w,A))return A}return W}function H2(z,w,U){let W=z2(z,w),X=z;switch(X[H]){case"Array":return vL(X,W,U);case"Date":return nL(X,W,U);case"Import":return uL(X,W,U);case"Intersect":return mL(X,W,U);case"Object":return tL(X,W,U);case"Record":return oL(X,W,U);case"Ref":return pL(X,W,U);case"This":return lL(X,W,U);case"Tuple":return sL(X,W,U);case"Union":return rL(X,W,U);default:return e1(X,U)}}function f5(...z){return z.length===3?H2(z[0],z[1],z[2]):H2(z[0],[],z[1])}var P1={};K6(P1,{ValuePointerRootSetError:()=>nz,ValuePointerRootDeleteError:()=>uz,Set:()=>aL,Has:()=>zN,Get:()=>wN,Format:()=>l4,Delete:()=>eL});class nz extends n{constructor(z,w,U){super("Cannot set root value");this.value=z,this.path=w,this.update=U}}class uz extends n{constructor(z,w){super("Cannot delete root value");this.value=z,this.path=w}}function rU(z){return z.indexOf("~")===-1?z:z.replace(/~1/g,"/").replace(/~0/g,"~")}function*l4(z){if(z==="")return;let[w,U]=[0,0];for(let W=0;W<z.length;W++)if(z.charAt(W)==="/")if(W===0)w=W+1;else U=W,yield rU(z.slice(w,U)),w=W+1;else U=W;yield rU(z.slice(w))}function aL(z,w,U){if(w==="")throw new nz(z,w,U);let[W,X,A]=[null,z,""];for(let Z of l4(w)){if(X[Z]===void 0)X[Z]={};W=X,X=X[Z],A=Z}W[A]=U}function eL(z,w){if(w==="")throw new uz(z,w);let[U,W,X]=[null,z,""];for(let A of l4(w)){if(W[A]===void 0||W[A]===null)return;U=W,W=W[A],X=A}if(Array.isArray(U)){let A=parseInt(X);U.splice(A,1)}else delete U[X]}function zN(z,w){if(w==="")return!0;let[U,W,X]=[null,z,""];for(let A of l4(w)){if(W[A]===void 0)return!1;U=W,W=W[A],X=A}return Object.getOwnPropertyNames(U).includes(X)}function wN(z,w){if(w==="")return z;let U=z;for(let W of l4(w)){if(U[W]===void 0)return;U=U[W]}return U}function UN(z,w){if(!l(w))return!1;let U=[...Object.keys(z),...Object.getOwnPropertySymbols(z)],W=[...Object.keys(w),...Object.getOwnPropertySymbols(w)];if(U.length!==W.length)return!1;return U.every((X)=>i6(z[X],w[X]))}function WN(z,w){return N2(w)&&z.getTime()===w.getTime()}function XN(z,w){if(!m(w)||z.length!==w.length)return!1;return z.every((U,W)=>i6(U,w[W]))}function AN(z,w){if(!n2(w)||z.length!==w.length||Object.getPrototypeOf(z).constructor.name!==Object.getPrototypeOf(w).constructor.name)return!1;return z.every((U,W)=>i6(U,w[W]))}function ZN(z,w){return z===w}function i6(z,w){if(N2(z))return WN(z,w);if(n2(z))return AN(z,w);if(m(z))return XN(z,w);if(l(z))return UN(z,w);if(T2(z))return ZN(z,w);throw new Error("ValueEquals: Unable to compare value")}var $N=G0({type:A0("insert"),path:G2(),value:L1()}),YN=G0({type:A0("update"),path:G2(),value:L1()}),QN=G0({type:A0("delete"),path:G2()}),eU=N0([$N,YN,QN]);class mz extends n{constructor(z,w){super(w);this.value=z}}function d5(z,w){return{type:"update",path:z,value:w}}function zW(z,w){return{type:"insert",path:z,value:w}}function wW(z){return{type:"delete",path:z}}function aU(z){if(globalThis.Object.getOwnPropertySymbols(z).length>0)throw new mz(z,"Cannot diff objects with symbols")}function*JN(z,w,U){if(aU(w),aU(U),!qz(U))return yield d5(z,U);let W=globalThis.Object.getOwnPropertyNames(w),X=globalThis.Object.getOwnPropertyNames(U);for(let A of X){if(u(w,A))continue;yield zW(`${z}/${A}`,U[A])}for(let A of W){if(!u(U,A))continue;if(i6(w,U))continue;yield*h5(`${z}/${A}`,w[A],U[A])}for(let A of W){if(u(U,A))continue;yield wW(`${z}/${A}`)}}function*BN(z,w,U){if(!m(U))return yield d5(z,U);for(let W=0;W<Math.min(w.length,U.length);W++)yield*h5(`${z}/${W}`,w[W],U[W]);for(let W=0;W<U.length;W++){if(W<w.length)continue;yield zW(`${z}/${W}`,U[W])}for(let W=w.length-1;W>=0;W--){if(W<U.length)continue;yield wW(`${z}/${W}`)}}function*MN(z,w,U){if(!n2(U)||w.length!==U.length||globalThis.Object.getPrototypeOf(w).constructor.name!==globalThis.Object.getPrototypeOf(U).constructor.name)return yield d5(z,U);for(let W=0;W<Math.min(w.length,U.length);W++)yield*h5(`${z}/${W}`,w[W],U[W])}function*qN(z,w,U){if(w===U)return;yield d5(z,U)}function*h5(z,w,U){if(qz(w))return yield*JN(z,w,U);if(m(w))return yield*BN(z,w,U);if(n2(w))return yield*MN(z,w,U);if(T2(w))return yield*qN(z,w,U);throw new mz(w,"Unable to diff value")}function UW(z,w){return[...h5("",z,w)]}function LN(z){return z.length>0&&z[0].path===""&&z[0].type==="update"}function NN(z){return z.length===0}function WW(z,w){if(LN(w))return B0(w[0].value);if(NN(w))return B0(z);let U=B0(z);for(let W of w)switch(W.type){case"insert":{P1.Set(U,W.path,W.value);break}case"update":{P1.Set(U,W.path,W.value);break}case"delete":{P1.Delete(U,W.path);break}}return U}function XW(...z){let[w,U,W]=z.length===3?[z[0],z[1],z[2]]:[z[0],[],z[1]],X=r1(w,U)?S4(w,U,W):W;if(!s(w,U,X))throw new m4(w,X,g1(w,U,X).First());return X}function c5(z){return l(z)&&!m(z)}class tz extends n{constructor(z){super(z)}}function GN(z,w,U,W){if(!c5(U))P1.Set(z,w,B0(W));else{let X=Object.getOwnPropertyNames(U),A=Object.getOwnPropertyNames(W);for(let Z of X)if(!A.includes(Z))delete U[Z];for(let Z of A)if(!X.includes(Z))U[Z]=null;for(let Z of A)oz(z,`${w}/${Z}`,U[Z],W[Z])}}function HN(z,w,U,W){if(!m(U))P1.Set(z,w,B0(W));else{for(let X=0;X<W.length;X++)oz(z,`${w}/${X}`,U[X],W[X]);U.splice(W.length)}}function _N(z,w,U,W){if(n2(U)&&U.length===W.length)for(let X=0;X<U.length;X++)U[X]=W[X];else P1.Set(z,w,B0(W))}function SN(z,w,U,W){if(U===W)return;P1.Set(z,w,W)}function oz(z,w,U,W){if(m(W))return HN(z,w,U,W);if(n2(W))return _N(z,w,U,W);if(c5(W))return GN(z,w,U,W);if(T2(W))return SN(z,w,U,W)}function AW(z){return n2(z)||T2(z)}function DN(z,w){return c5(z)&&m(w)||m(z)&&c5(w)}function ZW(z,w){if(AW(z)||AW(w))throw new tz("Only object and array types can be mutated at the root level");if(DN(z,w))throw new tz("Cannot assign due type mismatch of assignable values");oz(z,"",z,w)}class lz extends n{constructor(z){super(z)}}var pz;(function(z){let w=new Map([["Assert",(A,Z,$)=>{return V5(A,Z,$),$}],["Cast",(A,Z,$)=>t4(A,Z,$)],["Clean",(A,Z,$)=>k5(A,Z,$)],["Clone",(A,Z,$)=>B0($)],["Convert",(A,Z,$)=>g5(A,Z,$)],["Decode",(A,Z,$)=>r1(A,Z)?_4(A,Z,$):$],["Default",(A,Z,$)=>f5(A,Z,$)],["Encode",(A,Z,$)=>r1(A,Z)?S4(A,Z,$):$]]);function U(A){w.delete(A)}z.Delete=U;function W(A,Z){w.set(A,Z)}z.Set=W;function X(A){return w.get(A)}z.Get=X})(pz||(pz={}));var $W=["Clone","Clean","Default","Convert","Assert","Decode"];function PN(z,w,U,W){return z.reduce((X,A)=>{let Z=pz.Get(A);if(k0(Z))throw new lz(`Unable to find Parse operation '${A}'`);return Z(w,U,X)},W)}function YW(...z){let[w,U,W,X]=z.length===4?[z[0],z[1],z[2],z[3]]:z.length===3?m(z[0])?[z[0],z[1],[],z[2]]:[$W,z[0],z[1],z[2]]:z.length===2?[$W,z[0],[],z[1]]:(()=>{throw new lz("Invalid Arguments")})();return PN(w,U,W,X)}var o={};K6(o,{ValueErrorIterator:()=>h6,Patch:()=>WW,Parse:()=>YW,Mutate:()=>ZW,Hash:()=>H6,Errors:()=>g1,Equal:()=>i6,Encode:()=>XW,Edit:()=>eU,Diff:()=>UW,Default:()=>f5,Decode:()=>sU,Create:()=>a2,Convert:()=>g5,Clone:()=>B0,Clean:()=>k5,Check:()=>s,Cast:()=>t4,Assert:()=>V5});var s5=OX(MW(),1);var $w={date:gW,time:Ww(!0),"date-time":qW(!0),"iso-time":Ww(!1),"iso-date-time":qW(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:yN,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:pN,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:vN,int32:{type:"number",validate:mN},int64:{type:"number",validate:tN},float:{type:"number",validate:NW},double:{type:"number",validate:NW},password:!0,binary:!0};function TN(z){return z%4===0&&(z%100!==0||z%400===0)}var gN=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,fN=[0,31,28,31,30,31,30,31,31,30,31,30,31];function gW(z){let w=gN.exec(z);if(!w)return!1;let U=+w[1],W=+w[2],X=+w[3];return W>=1&&W<=12&&X>=1&&X<=(W===2&&TN(U)?29:fN[W])}var dN=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Ww(z){return function w(U){let W=dN.exec(U);if(!W)return!1;let X=+W[1],A=+W[2],Z=+W[3],$=W[4],Y=W[5]==="-"?-1:1,Q=+(W[6]||0),J=+(W[7]||0);if(Q>23||J>59||z&&!$)return!1;if(X<=23&&A<=59&&Z<60)return!0;let N=A-J*Y,S=X-Q*Y-(N<0?1:0);return(S===23||S===-1)&&(N===59||N===-1)&&Z<61}}var hN=/t|\s/i;function qW(z){let w=Ww(z);return function U(W){let X=W.split(hN);return X.length===2&&gW(X[0])&&w(X[1])}}var cN=/\/|:/,iN=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function yN(z){return cN.test(z)&&iN.test(z)}var LW=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function vN(z){return LW.lastIndex=0,LW.test(z)}var nN=-2147483648,uN=2147483647;function mN(z){return Number.isInteger(z)&&z<=uN&&z>=nN}function tN(z){return Number.isInteger(z)}function NW(){return!0}var oN=/[^\\]\\Z/;function pN(z){if(oN.test(z))return!1;try{return new RegExp(z),!0}catch(w){return!1}}var n5="toJSON"in new Headers,GW=(z,w)=>{let U=new URL(z);return U.pathname=w,U.toString()},lN=(z)=>typeof z==="function"&&/^\s*class\s+/.test(z.toString())||z.toString&&z.toString().startsWith("[object ")&&z.toString()!=="[object Object]"||w1(Object.getPrototypeOf(z)),sz=(z)=>z&&typeof z==="object"&&!Array.isArray(z),F2=(z,w,{skipKeys:U,override:W=!0}={})=>{if(!sz(z)||!sz(w))return z;for(let[X,A]of Object.entries(w)){if(U?.includes(X))continue;if(!sz(A)||!(X in z)||lN(A)){if(W||!(X in z))z[X]=A;continue}z[X]=F2(z[X],A,{skipKeys:U,override:W})}return z},sN=(z,w)=>{let U=F2(Object.assign({},z),w,{skipKeys:["properties"]});if("properties"in U)delete U.properties;return U},v0=(z=[],w=[])=>{if(!z)return;if(!w)return z;let U=[],W=[];if(!Array.isArray(z))z=[z];if(!Array.isArray(w))w=[w];for(let X of z)if(U.push(X),X.checksum)W.push(X.checksum);for(let X of w)if(!W.includes(X.checksum))U.push(X);return U},rN=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],aN=rN.reduce((z,w)=>(z[w]=!0,z),{}),fW=(z,w)=>{let U=(W)=>typeof W==="object"&&Object.keys(W).every(Yw);if(U(z)&&U(w))return Object.assign(z,w);else if(z&&!U(z)&&U(w))return Object.assign({200:z},w);return w??z},s4=(z,w)=>{return{body:w?.body??z?.body,headers:w?.headers??z?.headers,params:w?.params??z?.params,query:w?.query??z?.query,cookie:w?.cookie??z?.cookie,response:fW(z?.response,w?.response)}},z6=(z,w)=>{let{resolve:U,...W}=z??{},{resolve:X,...A}=w??{};return{...W,...A,body:w?.body??z?.body,headers:w?.headers??z?.headers,params:w?.params??z?.params,query:w?.query??z?.query,cookie:w?.cookie??z?.cookie,response:fW(z?.response,w?.response),type:z?.type||w?.type,detail:F2(w?.detail??{},z?.detail??{}),parse:v0(z?.parse,w?.parse),transform:v0(z?.transform,w?.transform),beforeHandle:v0(v0(W2(U,"resolve"),z?.beforeHandle),v0(W2(X,"resolve"),w?.beforeHandle)),afterHandle:v0(z?.afterHandle,w?.afterHandle),mapResponse:v0(z?.mapResponse,w?.mapResponse),afterResponse:v0(z?.afterResponse,w?.afterResponse),trace:v0(z?.trace,w?.trace),error:v0(z?.error,w?.error)}},Xw=(z,w,U=!0)=>{if(!Array.isArray(w))return w.original=z,$2(z,w,U);for(let W of w)W.original=z,z=$2(z,W,U);return z},$2=(z,w,U=!0)=>{if(!z)return z;if(w.untilObjectFound&&!U&&z.type==="object")return z;let W=w.from[H];if(z.oneOf){for(let Z=0;Z<z.oneOf.length;Z++)z.oneOf[Z]=$2(z.oneOf[Z],w,U);return z}if(z.anyOf){for(let Z=0;Z<z.anyOf.length;Z++)z.anyOf[Z]=$2(z.anyOf[Z],w,U);return z}if(z.allOf){for(let Z=0;Z<z.allOf.length;Z++)z.allOf[Z]=$2(z.allOf[Z],w,U);return z}if(z.not)return $2(z.not,w,U);let X=U&&!!w.excludeRoot;if(z[H]===W){let{anyOf:Z,oneOf:$,allOf:Y,not:Q,properties:J,items:N,...S}=z,G=w.to(S);if(!G)return z;let O,M=(C)=>{if(J&&C.type==="object"){let q0={};for(let[w0,_0]of Object.entries(J))q0[w0]=$2(_0,w,!1);return{...S,...C,properties:q0}}if(N&&C.type==="array")return{...S,...C,items:$2(N,w,!1)};let k={...S,...C};if(delete k.required,J&&C.type==="string"&&C.format==="ObjectString"&&C.default==="{}")O=I.ObjectString(J,S),k.default=JSON.stringify(o.Create(I.Object(J))),k.properties=J;if(N&&C.type==="string"&&C.format==="ArrayString"&&C.default==="[]")O=I.ArrayString(N,S),k.default=JSON.stringify(o.Create(I.Array(N))),k.items=N;return k};if(X){if(J){let C={};for(let[k,q0]of Object.entries(J))C[k]=$2(q0,w,!1);return{...S,properties:C}}else if(N?.map)return{...S,items:N.map((C)=>$2(C,w,!1))};return S}if(G.anyOf)for(let C=0;C<G.anyOf.length;C++)G.anyOf[C]=M(G.anyOf[C]);else if(G.oneOf)for(let C=0;C<G.oneOf.length;C++)G.oneOf[C]=M(G.oneOf[C]);else if(G.allOf)for(let C=0;C<G.allOf.length;C++)G.allOf[C]=M(G.allOf[C]);else if(G.not)G.not=M(G.not);if(O)G[j0]=O[j0];if(G.anyOf||G.oneOf||G.allOf||G.not)return G;if(J){let C={};for(let[k,q0]of Object.entries(J))C[k]=$2(q0,w,!1);return{...S,...G,properties:C}}else if(N?.map)return{...S,...G,items:N.map((C)=>$2(C,w,!1))};return{...S,...G}}let A=z?.properties;if(A&&U&&w.rootOnly!==!0)for(let[Z,$]of Object.entries(A))switch($[H]){case W:let{anyOf:Y,oneOf:Q,allOf:J,not:N,type:S,...G}=$,O=w.to(G);if(!O)return z;if(O.anyOf)for(let M=0;M<O.anyOf.length;M++)O.anyOf[M]={...G,...O.anyOf[M]};else if(O.oneOf)for(let M=0;M<O.oneOf.length;M++)O.oneOf[M]={...G,...O.oneOf[M]};else if(O.allOf)for(let M=0;M<O.allOf.length;M++)O.allOf[M]={...G,...O.allOf[M]};else if(O.not)O.not={...G,...O.not};A[Z]={...G,...$2(G,w,!1)};break;case"Object":case"Union":A[Z]=$2($,w,!1);break;default:if(Array.isArray($.items))for(let M=0;M<$.items.length;M++)$.items[M]=$2($.items[M],w,!1);else if($.anyOf||$.oneOf||$.allOf||$.not)A[Z]=$2($,w,!1);else if($.type==="array")$.items=$2($.items,w,!1);break}return z},z8=(z)=>(w)=>{if(typeof w==="object")try{return o.Clean(z,structuredClone(w))}catch{try{return o.Clean(z,w)}catch{return w}}return w},j2=(z,{models:w={},dynamic:U=!1,modules:W,normalize:X=!1,additionalProperties:A=!1,coerce:Z=!1,additionalCoerce:$=[]}={modules:I.Module({})})=>{if(!z)return;let Y;if(typeof z!=="string")Y=z;else{let J=z.endsWith("[]"),N=J?z.substring(0,z.length-2):z;if(Y=W.Import(N)??w[N],J)Y=I.Array(Y)}if(!Y)return;if(Z||$)if(Z)Y=Xw(Y,[{from:I.Ref(""),to:(J)=>W.Import(J.$ref)},{from:I.Number(),to:(J)=>I.Numeric(J),untilObjectFound:!0},{from:I.Boolean(),to:(J)=>I.BooleanString(J),untilObjectFound:!0},...Array.isArray($)?$:[$]]);else Y=Xw(Y,[{from:I.Ref(""),to:(J)=>W.Import(J.$ref)},...Array.isArray($)?$:[$]]);if(Y.type==="object"&&"additionalProperties"in Y===!1)Y.additionalProperties=A;if(U){let J={schema:Y,references:"",checkFunc:()=>{},code:"",Check:(N)=>o.Check(Y,N),Errors:(N)=>o.Errors(Y,N),Code:()=>"",Clean:z8(Y),Decode:(N)=>o.Decode(Y,N),Encode:(N)=>o.Encode(Y,N)};if(X&&Y.additionalProperties===!1)J.Clean=z8(Y);if(Y.config){if(J.config=Y.config,J?.schema?.config)delete J.schema.config}return J.parse=(N)=>{try{return J.Decode(N)}catch(S){throw[...J.Errors(N)].map(b1)}},J.safeParse=(N)=>{try{return{success:!0,data:J.Decode(N),error:null}}catch(S){let G=[...Q.Errors(N)].map(b1);return{success:!1,data:null,error:G[0]?.summary,errors:G}}},J}let Q=_6.Compile(Y,Object.values(w));if(Q.Clean=z8(Y),Y.config){if(Q.config=Y.config,Q?.schema?.config)delete Q.schema.config}return Q.parse=(J)=>{try{return Q.Decode(J)}catch(N){throw[...Q.Errors(J)].map(b1)}},Q.safeParse=(J)=>{try{return{success:!0,data:Q.Decode(J),error:null}}catch(N){let S=[...Q.Errors(J)].map(b1);return{success:!1,data:null,error:S[0]?.summary,errors:S}}},Q},HW=(z,{models:w={},modules:U,dynamic:W=!1,normalize:X=!1,additionalProperties:A=!1})=>{if(!z)return;let Z;if(typeof z!=="string")Z=z;else{let J=z.endsWith("[]"),N=J?z.substring(0,z.length-2):z;if(Z=U.Import(N)??w[N],J)Z=I.Array(Z)}if(!Z)return;let $=(J,N)=>{if(W)return{schema:J,references:"",checkFunc:()=>{},code:"",Check:(G)=>o.Check(J,G),Errors:(G)=>o.Errors(J,G),Code:()=>"",Clean:z8(J),Decode:(G)=>o.Decode(J,G),Encode:(G)=>o.Encode(J,G)};let S=_6.Compile(J,N);if(X&&J.additionalProperties===!1)S.Clean=z8(J);return S},Y=Object.values(w);if(H in Z){if("additionalProperties"in Z===!1)Z.additionalProperties=A;return{200:$(Z,Y)}}let Q={};return Object.keys(Z).forEach((J)=>{let N=Z[+J];if(typeof N==="string"){if(N in w){let S=w[N];S.type==="object"&&"additionalProperties"in S,Q[+J]=H in S?$(S,Y):S}return}if(N.type==="object"&&"additionalProperties"in N===!1)N.additionalProperties=A;Q[+J]=H in N?$(N,Y):N}),Q},eN=typeof Bun!=="undefined",zG=eN&&typeof Bun.hash==="function",r4=(z)=>{if(zG)return Bun.hash(z);let w=9;for(let U=0;U<z.length;)w=Math.imul(w^z.charCodeAt(U++),387420489);return w=w^w>>>9},rz,y6=()=>{if(!rz)rz=[{from:I.Object({}),to:()=>I.ObjectString({}),excludeRoot:!0},{from:I.Array(I.Any()),to:()=>I.ArrayString(I.Any())}];return rz},az,_W=()=>{if(!az)az=[{from:I.Number(),to:(z)=>I.Numeric(z),rootOnly:!0},{from:I.Boolean(),to:(z)=>I.BooleanString(z),rootOnly:!0}];return az},dW=({validator:z,modules:w,defaultConfig:U={},config:W,dynamic:X,models:A})=>{let Z=j2(z,{modules:w,dynamic:X,models:A,additionalProperties:!0,coerce:!0,additionalCoerce:y6()});if(w1(U))if(Z)Z.config=sN(Z.config,W);else Z=j2(I.Cookie({}),{modules:w,dynamic:X,models:A,additionalProperties:!0}),Z.config=U;return Z},O1=(z,w)=>{if(!w)return;if(!Array.isArray(w)){let W=w;if(z&&!W.checksum)W.checksum=z;if(W.scope==="scoped")W.scope="local";return W}let U=[...w];for(let W of U){if(z&&!W.checksum)W.checksum=z;if(W.scope==="scoped")W.scope="local"}return U},SW=(z,w,U)=>{return{start:v0(z.start,O1(U,w?.start)),request:v0(z.request,O1(U,w?.request)),parse:v0(z.parse,O1(U,w?.parse)),transform:v0(z.transform,O1(U,w?.transform)),beforeHandle:v0(v0(W2(z.resolve,"resolve"),z.beforeHandle),O1(U,v0(W2(w?.resolve,"resolve"),w?.beforeHandle))),afterHandle:v0(z.afterHandle,O1(U,w?.afterHandle)),mapResponse:v0(z.mapResponse,O1(U,w?.mapResponse)),afterResponse:v0(z.afterResponse,O1(U,w?.afterResponse)),trace:v0(z.trace,O1(U,w?.trace)),error:v0(z.error,O1(U,w?.error)),stop:v0(z.stop,O1(U,w?.stop))}},wG=(z,w,{skipIfHasType:U=!1}={})=>{if(!z)return z;if(!Array.isArray(z)){if(U)z.scope??=w;else z.scope=w;return z}for(let W of z)if(U)W.scope??=w;else W.scope=w;return z},S6=(z)=>{if(!z)return z;if(!Array.isArray(z))switch(z.scope){case"global":case"scoped":return{...z};default:return{fn:z}}let w=[];for(let U of z)switch(U.scope){case"global":case"scoped":w.push({...U});break}return w},DW=(z)=>{return{...z,type:z?.type,detail:z?.detail,parse:S6(z?.parse),transform:S6(z?.transform),beforeHandle:S6(z?.beforeHandle),afterHandle:S6(z?.afterHandle),mapResponse:S6(z?.mapResponse),afterResponse:S6(z?.afterResponse),error:S6(z?.error),trace:S6(z?.trace)}},p5={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},PW=Object.fromEntries(Object.entries(p5).map(([z,w])=>[w,z]));function UG(z){let w=z;while(w.endsWith("="))w=w.slice(0,-1);return w}var OW=new TextEncoder,u5=async(z,w)=>{if(typeof z!=="string")throw new TypeError("Cookie value must be provided as a string.");if(w===null)throw new TypeError("Secret key must be provided.");let U=await crypto.subtle.importKey("raw",OW.encode(w),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),W=await crypto.subtle.sign("HMAC",U,OW.encode(z));return z+"."+UG(Buffer.from(W).toString("base64"))},RW=async(z,w)=>{if(typeof z!=="string")throw new TypeError("Signed cookie string must be provided.");if(w===null)throw new TypeError("Secret key must be provided.");let U=z.slice(0,z.lastIndexOf("."));return await u5(U,w)===z?U:!1},WG=(z,w,U)=>{if(!z||typeof z!=="object"||!w)return;for(let[W,X]of Object.entries(w)){if(W in aN||!(W in z))continue;let A=z[W];if(typeof A==="function"){let Z=A(X);if(typeof Z==="object")for(let[$,Y]of Object.entries(Z))U($)({fn:Y})}delete w[W]}},XG=({globalHook:z,localHook:w})=>(U)=>(W,X)=>{if(typeof W==="function")W={fn:W};if(U==="resolve")W={...W,subType:"resolve"};if("fn"in W||Array.isArray(W)){if(!w[U])w[U]=[];if(typeof w[U]==="function")w[U]=[w[U]];if(Array.isArray(W))w[U]=w[U].concat(W);else w[U].push(W);return}let{insert:A="after",stack:Z="local"}=W;if(typeof X==="function")X={fn:X};if(Z==="global")if(!Array.isArray(X))if(A==="before")z[U].unshift(X);else z[U].push(X);else if(A==="before")z[U]=X.concat(z[U]);else z[U]=z[U].concat(X);else{if(!w[U])w[U]=[];if(typeof w[U]==="function")w[U]=[w[U]];if(!Array.isArray(X))if(A==="before")w[U].unshift(X);else w[U].push(X);else if(A==="before")w[U]=X.concat(w[U]);else w[U]=w[U].concat(X)}},AG=(z)=>{if(typeof z==="number")return z;if(z.length<16){if(z.trim().length===0)return null;let w=Number(z);if(Number.isNaN(w))return null;return w}if(z.length===16){if(z.trim().length===0)return null;let w=Number(z);if(Number.isNaN(w)||w.toString()!==z)return null;return w}return null},Yw=(z)=>AG(z)!==null;class hW{onError;root=null;promises=[];constructor(z=console.error){this.onError=z}get size(){return this.promises.length}add(z){return this.promises.push(z),this.root||=this.drain(),z}async drain(){while(this.promises.length>0){try{await this.promises[0]}catch(z){this.onError(z)}this.promises.shift()}this.root=null}then(z,w){return(this.root??Promise.resolve()).then(z,w)}}var W2=(z,w)=>{if(!z)return z;if(!Array.isArray(z)){if(typeof z==="function"||typeof z==="string")return w?{fn:z,subType:w}:{fn:z};else if("fn"in z)return z}let U=[];for(let W of z)if(typeof W==="function"||typeof W==="string")U.push(w?{fn:W,subType:w}:{fn:W});else if("fn"in W)U.push(W);return U},ZG=(z)=>{return{...z,start:W2(z?.start),request:W2(z?.request),parse:W2(z?.parse),transform:W2(z?.transform),beforeHandle:W2(z?.beforeHandle),afterHandle:W2(z?.afterHandle),mapResponse:W2(z?.mapResponse),afterResponse:W2(z?.afterResponse),trace:W2(z?.trace),error:W2(z?.error),stop:W2(z?.stop)}},CW=(z)=>{let w={};if(z.start?.map)w.start=z.start.map((U)=>U.fn);if(z.request?.map)w.request=z.request.map((U)=>U.fn);if(z.parse?.map)w.parse=z.parse.map((U)=>U.fn);if(z.transform?.map)w.transform=z.transform.map((U)=>U.fn);if(z.beforeHandle?.map)w.beforeHandle=z.beforeHandle.map((U)=>U.fn);if(z.afterHandle?.map)w.afterHandle=z.afterHandle.map((U)=>U.fn);if(z.mapResponse?.map)w.mapResponse=z.mapResponse.map((U)=>U.fn);if(z.afterResponse?.map)w.afterResponse=z.afterResponse.map((U)=>U.fn);if(z.trace?.map)w.trace=z.trace.map((U)=>U.fn);if(z.error?.map)w.error=z.error.map((U)=>U.fn);if(z.stop?.map)w.stop=z.stop.map((U)=>U.fn);return w},ez=(z)=>({body:z.body,cookie:z.cookie,headers:z.headers,query:z.query,set:z.set,server:z.server,request:z.request,route:z.route}),cW=(z,w=302)=>Response.redirect(z,w),Wf=Symbol("ElysiaFormData"),l5=Symbol("ElysiaRequestId");var iW=()=>{let z=crypto.randomUUID();return z.slice(0,8)+z.slice(24,32)},bW=(z)=>{let w=[];for(let U=0;U<z.length;U++){let W=z[U];if(W.checksum){if(w.includes(W.checksum))z.splice(U,1),U--;w.push(W.checksum)}}return z},L2=(z,w="scoped")=>{if(!z)return;if(w==="scoped"){for(let U of z)if("scope"in U&&U.scope==="local")U.scope="scoped";return}for(let U of z)if("scope"in U)U.scope="global"},D4=(z)=>{if(z.charCodeAt(z.length-1)===47)return z.slice(0,z.length-1);return z+"/"},w1=(z)=>{if(!z)return!1;for(let w in z)return!0;return!1},R1=(z)=>{if(Array.isArray(z))return z.length===0;return!z},zw=(z)=>{let w={...z};if(R1(z.afterHandle))delete w.afterHandle;if(R1(z.afterResponse))delete w.afterResponse;if(R1(z.beforeHandle))delete w.beforeHandle;if(R1(z.error))delete w.error;if(R1(z.mapResponse))delete w.mapResponse;if(R1(z.parse))delete w.parse;if(R1(z.request))delete w.request;if(R1(z.start))delete w.start;if(R1(z.stop))delete w.stop;if(R1(z.trace))delete w.trace;if(R1(z.transform))delete w.transform;if(!w.type)delete w.type;if(w.detail&&!Object.keys(w.detail).length)delete w.detail;if(!w.body)delete w.body;if(!w.cookie)delete w.cookie;if(!w.headers)delete w.headers;if(!w.query)delete w.query;if(!w.params)delete w.params;if(!w.response)delete w.response;return w},a4=(z,{dynamic:w=!1}={})=>{let U=encodeURIComponent(z).replace(/%2F/g,"/");if(w)U=U.replace(/%3A/g,":").replace(/%3F/g,"?");return U},KW=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,m5=Symbol("ElysiaErrorCode"),t5=(KW?.NODE_ENV??KW?.ENV)==="production";class K1{code;response;constructor(z,w){let U=w??(z in PW?PW[z]:z);this.code=p5[z]??z,this.response=U}}var yW=(z,w)=>new K1(z,w);class vW extends Error{code="INTERNAL_SERVER_ERROR";status=500;constructor(z){super(z??"INTERNAL_SERVER_ERROR")}}class Qw extends Error{code="NOT_FOUND";status=404;constructor(z){super(z??"NOT_FOUND")}}class nW extends Error{code="PARSE";status=400;constructor(){super("Bad Request")}}class Aw extends Error{key;code="INVALID_COOKIE_SIGNATURE";status=400;constructor(z,w){super(w??`"${z}" has invalid cookie signature`);this.key=z}}var b1=(z)=>{if(!z)return{summary:void 0};let{message:w,path:U,value:W,type:X}=z,A=U.slice(1).replaceAll("/","."),Z=U==="";switch(X){case 42:return{...z,summary:Z?"Value should not be provided":`Property '${A}' should not be provided`};case 45:return{...z,summary:Z?"Value is missing":`Property '${A}' is missing`};case 50:let $=w.indexOf("'"),Y=w.slice($+1,w.indexOf("'",$+1));return{...z,summary:Z?"Value should be an email":`Property '${A}' should be ${Y}`};case 54:return{...z,summary:`${w.slice(0,9)} property '${A}' to be ${w.slice(8)} but found: ${W}`};case 62:let Q=z.schema.anyOf.map((J)=>`'${J?.format??J.type}'`).join(", ");return{...z,summary:Z?`Value should be one of ${Q}`:`Property '${A}' should be one of: ${Q}`};default:return{summary:w,...z}}};class r extends Error{type;validator;value;code="VALIDATION";status=422;constructor(z,w,U){if(U&&typeof U==="object"&&U instanceof K1)U=U.response;let W=t5?void 0:("Errors"in w)?w.Errors(U).First():o.Errors(w,U).First(),X=W?.schema?.message||W?.schema?.error!==void 0?typeof W.schema.error==="function"?W.schema.error({type:z,validator:w,value:U,get errors(){return[...w.Errors(U)].map(b1)}}):W.schema.error:void 0,A=W?.path||"root",Z="";if(X!==void 0)Z=typeof X==="object"?JSON.stringify(X):X+"";else if(t5)Z=JSON.stringify({type:"validation",on:z,summary:b1(W).summary,message:W?.message,found:U});else{let $=w?.schema??w,Y="Errors"in w?[...w.Errors(U)].map(b1):[...o.Errors(w,U)].map(b1),Q;try{Q=o.Create($)}catch(J){Q={type:"Could not create expected value",message:J?.message,error:J}}Z=JSON.stringify({type:"validation",on:z,summary:b1(W).summary,property:A,message:W?.message,expected:Q,found:U,errors:Y},null,2)}super(Z);this.type=z,this.validator=w,this.value=U,Object.setPrototypeOf(this,r.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(b1):[...o.Errors(this.validator,this.value)].map(b1)}static simplifyModel(z){let w="schema"in z?z.schema:z;try{return o.Create(w)}catch{return w}}get model(){return r.simplifyModel(this.validator)}toResponse(z){return new Response(this.message,{status:400,headers:{...z,"content-type":"application/json"}})}}var uW=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,mW=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,tW=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,$G=$w.date,YG=$w["date-time"];if(!D0.Has("date"))D0.Set("date",(z)=>{let w=z.replace(/"/g,"");if(uW.test(w)||mW.test(w)||tW.test(w)||$G(w)){let U=new Date(w);if(!Number.isNaN(U.getTime()))return!0}return!1});if(!D0.Has("date-time"))D0.Set("date-time",(z)=>{let w=z.replace(/"/g,"");if(uW.test(w)||mW.test(w)||tW.test(w)||YG(w)){let U=new Date(w);if(!Number.isNaN(U.getTime()))return!0}return!1});Object.entries($w).forEach((z)=>{let[w,U]=z;if(!D0.Has(w)){if(U instanceof RegExp)D0.Set(w,(W)=>U.test(W));else if(typeof U==="function")D0.Set(w,U)}});var I=Object.assign({},G6),FW=(z)=>{if(typeof z==="string")switch(z.slice(-1)){case"k":return+z.slice(0,z.length-1)*1024;case"m":return+z.slice(0,z.length-1)*1048576;default:return+z}return z},jW=(z,w)=>{if(z.startsWith(w))return!0;return w.charCodeAt(w.length-1)===42&&w.charCodeAt(w.length-2)===47&&z.startsWith(w.slice(0,-1))},Zw=(z,w)=>{if(!(w instanceof Blob))return!1;if(z.minSize&&w.size<FW(z.minSize))return!1;if(z.maxSize&&w.size>FW(z.maxSize))return!1;if(z.extension){if(typeof z.extension==="string")return jW(w.type,z.extension);for(let U=0;U<z.extension.length;U++)if(jW(w.type,z.extension[U]))return!0;return!1}return!0},QG=oW("File",Zw),JG=oW("Files",(z,w)=>{if(!Array.isArray(w))return Zw(z,w);if(z.minItems&&w.length<z.minItems)return!1;if(z.maxItems&&w.length>z.maxItems)return!1;for(let U=0;U<w.length;U++)if(!Zw(z,w[U]))return!1;return!0});if(!D0.Has("numeric"))D0.Set("numeric",(z)=>!!z&&!isNaN(+z));if(!D0.Has("integer"))D0.Set("integer",(z)=>!!z&&Number.isInteger(+z));if(!D0.Has("boolean"))D0.Set("boolean",(z)=>z==="true"||z==="false");if(!D0.Has("ObjectString"))D0.Set("ObjectString",(z)=>{let w=z.charCodeAt(0);if(w===9||w===10||w===32)w=z.trimStart().charCodeAt(0);if(w!==123&&w!==91)return!1;try{return JSON.parse(z),!0}catch{return!1}});if(!D0.Has("ArrayString"))D0.Set("ArrayString",(z)=>{let w=z.charCodeAt(0);if(w===9||w===10||w===32)w=z.trimStart().charCodeAt(0);if(w!==123&&w!==91)return!1;try{return JSON.parse(z),!0}catch{return!1}});if(!p0.Has("UnionEnum"))p0.Set("UnionEnum",(z,w)=>{return(typeof w==="number"||typeof w==="string"||w===null)&&z.enum.includes(w)});var U1={Numeric:(z)=>{let w=G6.Number(z);return I.Transform(I.Union([I.String({format:"numeric",default:0}),I.Number(z)],z)).Decode((U)=>{let W=+U;if(isNaN(W))return U;if(z&&!o.Check(w,W))throw new r("property",w,W);return W}).Encode((U)=>U)},Integer:(z)=>{let w=G6.Integer(z);return I.Transform(I.Union([I.String({format:"integer",default:0}),G6.Integer(z)],z)).Decode((U)=>{let W=+U;if(!o.Check(w,W))throw new r("property",w,W);return W}).Encode((U)=>U)},Date:(z)=>{let w=G6.Date(z),U=z?.default?new Date(z.default):void 0;return I.Transform(I.Union([G6.Date(z),I.String({format:"date",default:U?.toISOString()}),I.String({format:"date-time",default:U?.toISOString()}),I.Number({default:U?.getTime()})],z)).Decode((W)=>{if(typeof W==="number"){let A=new Date(W);if(!o.Check(w,A))throw new r("property",w,A);return A}if(W instanceof Date)return W;let X=new Date(W);if(!X||isNaN(X.getTime()))throw new r("property",w,X);if(!o.Check(w,X))throw new r("property",w,X);return X}).Encode((W)=>W.toISOString())},BooleanString:(z)=>{let w=G6.Boolean(z);return I.Transform(I.Union([I.Boolean(z),I.String({format:"boolean",default:!1})],z)).Decode((U)=>{if(typeof U==="string")return U==="true";if(U!==void 0&&!o.Check(w,U))throw new r("property",w,U);return U}).Encode((U)=>U)},ObjectString:(z,w)=>{let U=I.Object(z,w),W=JSON.stringify(o.Create(U)),X;try{X=_6.Compile(U)}catch{}return I.Transform(I.Union([I.String({format:"ObjectString",default:W}),U])).Decode((A)=>{if(typeof A==="string"){if(A.charCodeAt(0)!==123)throw new r("property",U,A);try{A=JSON.parse(A)}catch{throw new r("property",U,A)}if(X){if(!X.Check(A))throw new r("property",U,A);return X.Decode(A)}if(!o.Check(U,A))throw new r("property",U,A);return o.Decode(U,A)}return A}).Encode((A)=>{if(typeof A==="string")try{A=JSON.parse(A)}catch{throw new r("property",U,A)}if(!o.Check(U,A))throw new r("property",U,A);return JSON.stringify(A)})},ArrayString:(z=I.String(),w)=>{let U=I.Array(z,w),W;try{W=_6.Compile(U)}catch{}let X=(A,Z=!1)=>{if(A.charCodeAt(0)===91){try{A=JSON.parse(A)}catch{throw new r("property",U,A)}if(W){if(!W.Check(A))throw new r("property",U,A);return W.Decode(A)}if(!o.Check(U,A))throw new r("property",U,A);return o.Decode(U,A)}if(A.indexOf(",")!==-1){let $=A.split(",").map((Y)=>Y.trim());if(W){if(!W.Check($))throw new r("property",U,A);return W.Decode($)}if(!o.Check(U,$))throw new r("property",U,$);return o.Decode(U,$)}if(Z)return A;throw new r("property",U,A)};return I.Transform(I.Union([I.String({format:"ArrayString",default:w?.default}),U])).Decode((A)=>{if(Array.isArray(A)){let Z=[];for(let $=0;$<A.length;$++){let Y=A[$];if(typeof Y==="string"){let Q=X(Y,!0);if(Array.isArray(Q))Z=Z.concat(Q);else Z.push(Q);continue}Z.push(Y)}return Z}if(typeof A==="string")return X(A);return A}).Encode((A)=>{if(typeof A==="string")try{A=JSON.parse(A)}catch{throw new r("property",U,A)}if(!o.Check(U,A))throw new r("property",U,A);return JSON.stringify(A)})},File:QG,Files:(z={})=>I.Transform(JG(z)).Decode((w)=>{if(Array.isArray(w))return w;return[w]}).Encode((w)=>w),Nullable:(z,w)=>I.Union([z,I.Null()],w),MaybeEmpty:(z,w)=>I.Union([z,I.Null(),I.Undefined()],w),Cookie:(z,{domain:w,expires:U,httpOnly:W,maxAge:X,path:A,priority:Z,sameSite:$,secure:Y,secrets:Q,sign:J,...N}={})=>{let S=I.Object(z,N);return S.config={domain:w,expires:U,httpOnly:W,maxAge:X,path:A,priority:Z,sameSite:$,secure:Y,secrets:Q,sign:J},S},UnionEnum:(z,w={})=>{let U=z.every((W)=>typeof W==="string")?{type:"string"}:z.every((W)=>typeof W==="number")?{type:"number"}:z.every((W)=>W===null)?{type:"null"}:{};if(z.some((W)=>typeof W==="object"&&W!==null))throw new Error("This type does not support objects or arrays");return{default:z[0],...w,[H]:"UnionEnum",...U,enum:z}}};I.BooleanString=U1.BooleanString;I.ObjectString=U1.ObjectString;I.ArrayString=U1.ArrayString;I.Numeric=U1.Numeric;I.Integer=U1.Integer;I.File=(z={})=>U1.File({default:"File",...z,extension:z?.type,type:"string",format:"binary"});I.Files=(z={})=>U1.Files({...z,elysiaMeta:"Files",default:"Files",extension:z?.type,type:"array",items:{...z,default:"Files",type:"string",format:"binary"}});I.Nullable=(z)=>U1.Nullable(z);I.MaybeEmpty=U1.MaybeEmpty;I.Cookie=U1.Cookie;I.Date=U1.Date;I.UnionEnum=U1.UnionEnum;function oW(z,w){if(!p0.Has(z))p0.Set(z,w);return(U={})=>j5({...U,[H]:z})}var w8=(z)=>{let w=typeof z==="object"?z.fn.toString():typeof z==="string"?z.toString():z,U=w.indexOf(")");if(w.charCodeAt(U+2)===61&&w.charCodeAt(U+5)!==123)return!0;return w.includes("return")},BG=(z)=>{if(z.startsWith("async"))z=z.slice(5);z=z.trimStart();let w=-1;if(z.charCodeAt(0)===40){if(w=z.indexOf("=>",z.indexOf(")")),w!==-1){let X=w;while(X>0)if(z.charCodeAt(--X)===41)break;let A=z.slice(w+2);if(A.charCodeAt(0)===32)A=A.trimStart();return[z.slice(1,X),A,{isArrowReturn:A.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(z)){if(w=z.indexOf("=>"),w!==-1){let X=z.slice(w+2);if(X.charCodeAt(0)===32)X=X.trimStart();return[z.slice(0,w),X,{isArrowReturn:X.charCodeAt(0)!==123}]}}if(z.startsWith("function")){w=z.indexOf("(");let X=z.indexOf(")");return[z.slice(w+1,X),z.slice(X+2),{isArrowReturn:!1}]}let U=z.indexOf("(");if(U!==-1){let X=z.indexOf(`
8
+ `,2),A=z.slice(0,X),Z=A.lastIndexOf(")")+1,$=z.slice(X+1);return[A.slice(U,Z),"{"+$,{isArrowReturn:!1}]}let W=z.split(`
9
+ `,2);return[W[0],W[1],{isArrowReturn:!1}]},MG=(z)=>{let w=z.indexOf("{");if(w===-1)return[-1,0];let U=w+1,W=1;for(;U<z.length;U++){let X=z.charCodeAt(U);if(X===123)W++;else if(X===125)W--;if(W===0)break}if(W!==0)return[0,z.length];return[w,U+1]},qG=(z)=>{let w=z.lastIndexOf("}");if(w===-1)return[-1,0];let U=w-1,W=1;for(;U>=0;U--){let X=z.charCodeAt(U);if(X===125)W++;else if(X===123)W--;if(W===0)break}if(W!==0)return[-1,0];return[U,w+1]},pW=(z)=>{while(!0){let w=z.indexOf(":");if(w===-1)break;let U=z.indexOf(",",w);if(U===-1)U=z.indexOf("}",w)-1;if(U===-2)U=z.length;z=z.slice(0,w)+z.slice(U)}return z},lW=(z)=>{let w=!1;if(z.charCodeAt(0)===40)z=z.slice(1,-1);if(z.charCodeAt(0)===123)w=!0,z=z.slice(1,-1);z=z.replace(/( |\t|\n)/g,"").trim();let U=[];while(!0){let[X,A]=MG(z);if(X===-1)break;if(U.push(z.slice(0,X-1)),z.charCodeAt(A)===44)A++;z=z.slice(A)}if(z=pW(z),z)U=U.concat(z.split(","));let W=[];for(let X of U){if(X.indexOf(",")===-1){W.push(X);continue}for(let A of X.split(","))W.push(A.trim())}return U=W,{hasParenthesis:w,parameters:U}},LG=(z,w)=>{let{parameters:U,hasParenthesis:W}=lW(z);if(!w.query&&U.includes("query"))w.query=!0;if(!w.headers&&U.includes("headers"))w.headers=!0;if(!w.body&&U.includes("body"))w.body=!0;if(!w.cookie&&U.includes("cookie"))w.cookie=!0;if(!w.set&&U.includes("set"))w.set=!0;if(!w.server&&U.includes("server"))w.server=!0;if(!w.request&&U.includes("request"))w.request=!0;if(!w.route&&U.includes("route"))w.route=!0;if(W)return`{ ${U.join(", ")} }`;return U.join(", ")},EW=(z,w,U)=>{let W=w.indexOf(z+`
10
+ `,U),X=w.indexOf(z+"\t",U),A=w.indexOf(z+",",U),Z=w.indexOf(z+";",U),$=w.indexOf(z+" ",U);return[W,X,A,Z,$].filter((Y)=>Y>0).sort((Y,Q)=>Y-Q)[0]||-1},sW=(z,w,U=0)=>{if(U>5)return[];let W=[],X=w;while(!0){let A=EW(" = "+z,X);if(A===-1)A=EW("="+z,X);if(A===-1){let Q=X.indexOf(" = "+z);if(Q===-1)Q=X.indexOf("="+z);if(Q+3+z.length!==X.length)break;A=Q}let Z=X.slice(0,A),$=Z.lastIndexOf(" "),Y=Z.slice($!==-1?$+1:-1);if(Y==="}"){let[Q,J]=qG(Z);W.push(pW(X.slice(Q,J))),X=X.slice(A+3+z.length);continue}while(Y.charCodeAt(0)===44)Y=Y.slice(1);while(Y.charCodeAt(0)===9)Y=Y.slice(1);if(!Y.includes("("))W.push(Y);X=X.slice(A+3+z.length)}for(let A of W){if(A.charCodeAt(0)===123)continue;let Z=sW(A,w);if(Z.length>0)W.push(...Z)}return W},NG=(z)=>{if(!z)return;if(z.charCodeAt(0)!==123)return z;if(z=z.slice(2,-2),!z.includes(",")){if(z.includes("..."))return z.slice(z.indexOf("...")+3);return}let w=z.indexOf("...");if(w===-1)return;return z.slice(w+3).trimEnd()},GG=(z,w,U)=>{let W=(X,A)=>z.includes(A+"."+X)||z.includes(A+'["'+X+'"]')||z.includes(A+"['"+X+"']");for(let X of w){if(!X)continue;if(X.charCodeAt(0)===123){let A=lW(X).parameters;if(!U.query&&A.includes("query"))U.query=!0;if(!U.headers&&A.includes("headers"))U.headers=!0;if(!U.body&&A.includes("body"))U.body=!0;if(!U.cookie&&A.includes("cookie"))U.cookie=!0;if(!U.set&&A.includes("set"))U.set=!0;if(!U.query&&A.includes("server"))U.server=!0;if(!U.request&&A.includes("request"))U.request=!0;if(!U.route&&A.includes("route"))U.route=!0;continue}if(!U.query&&W("query",X))U.query=!0;if(z.includes("return "+X)||z.includes("return "+X+".query"))U.query=!0;if(!U.headers&&W("headers",X))U.headers=!0;if(!U.body&&W("body",X))U.body=!0;if(!U.cookie&&W("cookie",X))U.cookie=!0;if(!U.set&&W("set",X))U.set=!0;if(!U.server&&W("server",X))U.server=!0;if(U.query&&U.headers&&U.body&&U.cookie&&U.set&&U.server&&U.server&&U.route)break}return w},HG=(z,w,U)=>{try{let W=new RegExp(`(?:\\w)\\((?:.*)?${z}`,"gs");W.test(w);let X=w.charCodeAt(W.lastIndex);if(X===41||X===44)return U.query=!0,U.headers=!0,U.body=!0,U.cookie=!0,U.set=!0,U.server=!0,U.route=!0,U.request=!0,!0;return!1}catch(W){return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"),console.log("--- body ---"),console.log(w),console.log("--- context ---"),console.log(z),!0}},rW=(z,w={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let U=[];if(z.handler&&typeof z.handler==="function")U.push(z.handler);if(z.request?.length)U.push(...z.request);if(z.beforeHandle?.length)U.push(...z.beforeHandle);if(z.parse?.length)U.push(...z.parse);if(z.error?.length)U.push(...z.error);if(z.transform?.length)U.push(...z.transform);if(z.afterHandle?.length)U.push(...z.afterHandle);if(z.mapResponse?.length)U.push(...z.mapResponse);if(z.afterResponse?.length)U.push(...z.afterResponse);for(let W of U){if(!W)continue;let X="fn"in W?W.fn:W;if(typeof X!=="function")continue;let[A,Z,{isArrowReturn:$}]=BG(X.toString()),Y=LG(A,w),Q=NG(Y);if(Q){let J=sW(Q,Z.slice(1,-1));J.splice(0,-1,Q);let N=Z;if(N.charCodeAt(0)===123&&N.charCodeAt(Z.length-1)===125)N=N.slice(1,-1);if(!HG(Q,N,w))GG(N,J,w);if(!w.query&&N.includes("return "+Q+".query"))w.query=!0}if(w.query&&w.headers&&w.body&&w.cookie&&w.set&&w.server&&w.request&&w.route)break}return w},v6=[];for(let z=48;z<58;z++)v6[z]=z-48;for(let z=0;z<6;z++)v6[z+65]=v6[z+97]=z+10;var _G=(z,w)=>{if(z in v6&&w in v6)return v6[z]<<4|v6[w];return 255},aW=[...new Array(128).fill(0),...new Array(16).fill(1),...new Array(16).fill(2),...new Array(32).fill(3),4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4],SG=[0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0],IW=aW.map((z)=>[127,63,63,63,0,31,15,15,15,7,7,7][z]),P6=(z)=>{let w=z.indexOf("%");if(w===-1)return z;let U=z.length-3;if(w>U)return null;let W="",X=0,A=0,Z=w,$=12,Y;for(;;){if(Y=_G(z.charCodeAt(w+1),z.charCodeAt(w+2)),$=SG[$+aW[Y]],$===0)return null;if($===12){if(W+=z.substring(X,Z),A=A<<6|Y&IW[Y],A>65535)W+=String.fromCharCode(55232+(A>>10),56320+(A&1023));else W+=String.fromCharCode(A);if(X=w+3,w=z.indexOf("%",X),w===-1)return W+z.substring(X);if(w>U)return null;Z=w,A=0}else{if(w+=3,w>U||z.charCodeAt(w)!==37)return null;A=A<<6|Y&IW[Y]}}};class R4{name;jar;initial;constructor(z,w,U={}){this.name=z,this.jar=w,this.initial=U}get cookie(){return this.jar[this.name]??this.initial}set cookie(z){if(!(this.name in this.jar))this.jar[this.name]=this.initial;this.jar[this.name]=z}get setCookie(){if(!(this.name in this.jar))this.jar[this.name]=this.initial;return this.jar[this.name]}set setCookie(z){this.cookie=z}get value(){return this.cookie.value}set value(z){this.setCookie.value=z}get expires(){return this.cookie.expires}set expires(z){this.setCookie.expires=z}get maxAge(){return this.cookie.maxAge}set maxAge(z){this.setCookie.maxAge=z}get domain(){return this.cookie.domain}set domain(z){this.setCookie.domain=z}get path(){return this.cookie.path}set path(z){this.setCookie.path=z}get secure(){return this.cookie.secure}set secure(z){this.setCookie.secure=z}get httpOnly(){return this.cookie.httpOnly}set httpOnly(z){this.setCookie.httpOnly=z}get sameSite(){return this.cookie.sameSite}set sameSite(z){this.setCookie.sameSite=z}get priority(){return this.cookie.priority}set priority(z){this.setCookie.priority=z}get partitioned(){return this.cookie.partitioned}set partitioned(z){this.setCookie.partitioned=z}get secrets(){return this.cookie.secrets}set secrets(z){this.setCookie.secrets=z}update(z){return this.setCookie=Object.assign(this.cookie,typeof z==="function"?z(this.cookie):z),this}set(z){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof z==="function"?z(this.cookie):z),this}remove(){if(this.value===void 0)return;return this.set({expires:new Date(0),maxAge:0,value:""}),this}toString(){return typeof this.value==="object"?JSON.stringify(this.value):this.value?.toString()??""}}var xW=(z,w,U)=>{if(!z.cookie)z.cookie={};return new Proxy(w,{get(W,X){if(X in w)return new R4(X,z.cookie,Object.assign({},U??{},w[X]));return new R4(X,z.cookie,Object.assign({},U))}})},eW=async(z,w,{secrets:U,sign:W,...X}={})=>{if(!w)return xW(z,{},X);let A=typeof U==="string";if(W&&W!==!0&&!Array.isArray(W))W=[W];let Z={},$=s5.parse(w);for(let[Y,Q]of Object.entries($)){if(Q===void 0)continue;let J=P6(Q);if(W===!0||W?.includes(Y)){if(!U)throw new Error("No secret is provided to cookie plugin");if(A){let N=await RW(J,U);if(N===!1)throw new Aw(Y);J=N}else{let N=!0;for(let S=0;S<U.length;S++){let G=await RW(J,U[S]);if(G!==!1){N=!0,J=G;break}}if(!N)throw new Aw(Y)}}Z[Y]={value:J}}return xW(z,Z,X)},zX=(z)=>{if(!z||!w1(z))return;let w=[];for(let[U,W]of Object.entries(z)){if(!U||!W)continue;let X=W.value;if(X===void 0||X===null)continue;w.push(s5.serialize(U,typeof X==="object"?JSON.stringify(X):X+"",W))}if(w.length===0)return;if(w.length===1)return w[0];return w},O6=(z,w)=>{let U=z.size;if(!w&&U||U&&w&&w.status!==206&&w.status!==304&&w.status!==412&&w.status!==416){if(w){if(w.headers instanceof Headers){let W={"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"};if(n5)W=w.headers.toJSON();else{W={};for(let[X,A]of w.headers.entries())if(X in w.headers)W[X]=A}return new Response(z,{status:w.status,headers:W})}if(w1(w.headers))return new Response(z,{status:w.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"},w.headers)})}return new Response(z,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"}})}return new Response(z)},wX=(z,w)=>{if(!z)return z;z.delete("set-cookie");for(let U=0;U<w.length;U++){let W=w[U].indexOf("=");z.append("set-cookie",`${w[U].slice(0,W)}=${w[U].slice(W+1)||""}`)}return z},n6=(z,w)=>{if(w?.headers){if(z){if(n5)Object.assign(w.headers,z.headers.toJSON());else for(let[U,W]of z.headers.entries())if(U in w.headers)w.headers[U]=W}if(w.status===200)w.status=z.status;if(w.headers["content-encoding"])delete w.headers["content-encoding"];return w}if(!z)return{headers:{},status:w?.status??200};if(n5){if(w={headers:z.headers.toJSON(),status:w?.status??200},w.headers["content-encoding"])delete w.headers["content-encoding"];return w}w={headers:{},status:w?.status??200};for(let[U,W]of z.headers.entries()){if(U==="content-encoding")continue;if(U in w.headers)w.headers[U]=W}return w},z1=async(z,w,U)=>{let W=z.next();if(W instanceof Promise)W=await W;if(W.done){if(w)return E2(W.value,w,U);return R6(W.value,U)}if(w?.headers){if(!w.headers["transfer-encoding"])w.headers["transfer-encoding"]="chunked";if(!w.headers["content-type"])w.headers["content-type"]="text/event-stream; charset=utf-8"}else w={status:200,headers:{"content-type":"text/event-stream; charset=utf-8","transfer-encoding":"chunked"}};return new Response(new ReadableStream({async start(X){let A=!1;if(U?.signal?.addEventListener("abort",()=>{A=!0;try{X.close()}catch{}}),W.value!==void 0&&W.value!==null)if(typeof W.value==="object")try{X.enqueue(Buffer.from(JSON.stringify(W.value)))}catch{X.enqueue(Buffer.from(W.value.toString()))}else X.enqueue(Buffer.from(W.value.toString()));for await(let Z of z){if(A)break;if(Z===void 0||Z===null)continue;if(typeof Z==="object")try{X.enqueue(Buffer.from(JSON.stringify(Z)))}catch{X.enqueue(Buffer.from(Z.toString()))}else X.enqueue(Buffer.from(Z.toString()));await new Promise(($)=>setTimeout(()=>$(),0))}try{X.close()}catch{}}}),w)};async function*u6(z){let w=z.body;if(!w)return;let U=w.getReader(),W=new TextDecoder;try{while(!0){let{done:X,value:A}=await U.read();if(X)break;yield W.decode(A)}}finally{U.releaseLock()}}var UX=(z)=>{if(typeof z.status==="string")z.status=p5[z.status];if(z.cookie&&w1(z.cookie)){let w=zX(z.cookie);if(w)z.headers["set-cookie"]=w}if(z.headers["set-cookie"]&&Array.isArray(z.headers["set-cookie"]))z.headers=wX(new Headers(z.headers),z.headers["set-cookie"])},o5=(z,w)=>{if(z.status!==w.status&&w.status!==200&&(z.status<=300||z.status>400))z=new Response(z.body,{headers:z.headers,status:w.status});let U=!1;if(w.headers instanceof Headers)for(let W of w.headers.keys())if(W==="set-cookie"){if(U)continue;U=!0;for(let X of w.headers.getSetCookie())z.headers.append("set-cookie",X)}else z.headers.append(W,w.headers?.get(W)??"");else for(let W in w.headers)z.headers.append(W,w.headers[W]);return z},E2=(z,w,U)=>{if(w1(w.headers)||w.status!==200||w.cookie)switch(UX(w),z?.constructor?.name){case"String":return new Response(z,w);case"Array":case"Object":return Response.json(z,w);case"ElysiaFile":return O6(z.value);case"Blob":return O6(z,w);case"ElysiaCustomStatusResponse":return w.status=z.code,E2(z.response,w,U);case"ReadableStream":if(!w.headers["content-type"]?.startsWith("text/event-stream"))w.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,w);case void 0:if(!z)return new Response("",w);return Response.json(z,w);case"Response":if(z=o5(z,w),!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return z1(u6(z),n6(z,w),U);return z;case"Error":return C6(z,w);case"Promise":return z.then((W)=>E2(W,w,U));case"Function":return E2(z(),w,U);case"Number":case"Boolean":return new Response(z.toString(),w);case"Cookie":if(z instanceof R4)return new Response(z.value,w);return new Response(z?.toString(),w);case"FormData":return new Response(z,w);default:if(z instanceof Response){if(z=o5(z,w),z.headers.get("transfer-encoding")==="chunked")return z1(u6(z),n6(z,w),U);return z}if(z instanceof Promise)return z.then((W)=>E2(W,w));if(z instanceof Error)return C6(z,w);if(z instanceof K1)return w.status=z.code,E2(z.response,w,U);if(typeof z?.next==="function")return z1(z,w,U);if(typeof z?.then==="function")return z.then((W)=>E2(W,w));if(typeof z?.toResponse==="function")return E2(z.toResponse(),w);if("charCodeAt"in z){let W=z.charCodeAt(0);if(W===123||W===91){if(!w.headers["Content-Type"])w.headers["Content-Type"]="application/json";return new Response(JSON.stringify(z),w)}}return new Response(z,w)}if(z instanceof Response&&!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return z1(u6(z),n6(z,w),U);if(typeof z?.next==="function"||z instanceof ReadableStream)return z1(z,w,U);return R6(z,U)},K2=(z,w,U)=>{if(z===void 0||z===null)return;if(w1(w.headers)||w.status!==200||w.cookie)switch(UX(w),z?.constructor?.name){case"String":return new Response(z,w);case"Array":case"Object":return Response.json(z,w);case"ElysiaFile":return O6(z.value);case"Blob":return O6(z,w);case"ElysiaCustomStatusResponse":return w.status=z.code,K2(z.response,w,U);case"ReadableStream":if(!w.headers["content-type"]?.startsWith("text/event-stream"))w.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,w);case void 0:if(!z)return;return Response.json(z,w);case"Response":if(z=o5(z,w),!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return z1(u6(z),n6(z,w),U);return z;case"Promise":return z.then((W)=>K2(W,w));case"Error":return C6(z,w);case"Function":return K2(z(),w);case"Number":case"Boolean":return new Response(z.toString(),w);case"FormData":return new Response(z);case"Cookie":if(z instanceof R4)return new Response(z.value,w);return new Response(z?.toString(),w);default:if(z instanceof Response){if(z=o5(z,w),z.headers.get("transfer-encoding")==="chunked")return z1(u6(z),n6(z,w),U);return z}if(z instanceof Promise)return z.then((W)=>K2(W,w));if(z instanceof Error)return C6(z,w);if(z instanceof K1)return w.status=z.code,K2(z.response,w,U);if(typeof z?.next==="function")return z1(z,w,U);if(typeof z?.then==="function")return z.then((W)=>K2(W,w));if(typeof z?.toResponse==="function")return K2(z.toResponse(),w);if("charCodeAt"in z){let W=z.charCodeAt(0);if(W===123||W===91){if(!w.headers["Content-Type"])w.headers["Content-Type"]="application/json";return new Response(JSON.stringify(z),w)}}return new Response(z,w)}else switch(z?.constructor?.name){case"String":return new Response(z);case"Array":case"Object":return Response.json(z,w);case"ElysiaFile":return O6(z.value);case"Blob":return O6(z,w);case"ElysiaCustomStatusResponse":return w.status=z.code,K2(z.response,w,U);case"ReadableStream":return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!z)return new Response("");return new Response(JSON.stringify(z),{headers:{"content-type":"application/json"}});case"Response":if(!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return z1(u6(z),n6(z),U);return z;case"Promise":return z.then((W)=>{let X=K2(W,w);if(X!==void 0)return X});case"Error":return C6(z,w);case"Function":return R6(z(),U);case"Number":case"Boolean":return new Response(z.toString());case"Cookie":if(z instanceof R4)return new Response(z.value,w);return new Response(z?.toString(),w);case"FormData":return new Response(z);default:if(z instanceof Response)return z;if(z instanceof Promise)return z.then((W)=>K2(W,w));if(z instanceof Error)return C6(z,w);if(z instanceof K1)return w.status=z.code,K2(z.response,w,U);if(typeof z?.next==="function")return z1(z,w,U);if(typeof z?.then==="function")return z.then((W)=>K2(W,w));if(typeof z?.toResponse==="function")return K2(z.toResponse(),w);if("charCodeAt"in z){let W=z.charCodeAt(0);if(W===123||W===91){if(!w.headers["Content-Type"])w.headers["Content-Type"]="application/json";return new Response(JSON.stringify(z),w)}}return new Response(z)}},R6=(z,w)=>{switch(z?.constructor?.name){case"String":return new Response(z);case"Object":case"Array":return Response.json(z);case"ElysiaFile":return O6(z.value);case"Blob":return O6(z);case"ElysiaCustomStatusResponse":return E2(z.response,{status:z.code,headers:{}});case"ReadableStream":return w?.signal?.addEventListener("abort",{handleEvent(){if(w?.signal&&!w?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!z)return new Response("");return new Response(JSON.stringify(z),{headers:{"content-type":"application/json"}});case"Response":if(z.headers.get("transfer-encoding")==="chunked")return z1(u6(z),n6(z),w);return z;case"Error":return C6(z);case"Promise":return z.then((U)=>R6(U,w));case"Function":return R6(z(),w);case"Number":case"Boolean":return new Response(z.toString());case"FormData":return new Response(z);default:if(z instanceof Response)return z;if(z instanceof Promise)return z.then((U)=>R6(U,w));if(z instanceof Error)return C6(z);if(z instanceof K1)return E2(z.response,{status:z.code,headers:{}});if(typeof z?.next==="function")return z1(z,void 0,w);if(typeof z?.then==="function")return z.then((U)=>E2(U,set));if(typeof z?.toResponse==="function")return R6(z.toResponse());if("charCodeAt"in z){let U=z.charCodeAt(0);if(U===123||U===91)return new Response(JSON.stringify(z),{headers:{"Content-Type":"application/json"}})}return new Response(z)}},C6=(z,w)=>new Response(JSON.stringify({name:z?.name,message:z?.message,cause:z?.cause}),{status:w?.status!==200?w?.status??500:500,headers:w?.headers}),DG=(z,w,U={})=>{if(typeof z==="function")return;let W=E2(z,{headers:U});if(!w.parse?.length&&!w.transform?.length&&!w.beforeHandle?.length&&!w.afterHandle?.length)return W.clone.bind(W)},y5={name:"web-standard",isWebStandard:!0,handler:{mapResponse:E2,mapEarlyResponse:K2,mapCompactResponse:R6,createStaticHandler:DG},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {}
11
11
  for (const [key, value] of c.request.headers.entries())c.headers[key] = value
12
- `,parser:{json(w){if(w)return`try{c.body=await c.request.json()}catch{}
12
+ `,parser:{json(z){if(z)return`try{c.body=await c.request.json()}catch{}
13
13
  `;return`c.body=await c.request.json()
14
14
  `},text(){return`c.body=await c.request.text()
15
15
  `},urlencoded(){return`c.body=parseQuery(await c.request.text())
16
16
  `},arrayBuffer(){return`c.body=await c.request.arrayBuffer()
17
- `},formData(w){let z=`
17
+ `},formData(z){let w=`
18
18
  c.body={}
19
- `;if(w)z+="let form;try{form=await c.request.formData()}catch{}";else z+=`const form=await c.request.formData()
20
- `;return z+`for(const key of form.keys()){if(c.body[key]) continue
19
+ `;if(z)w+="let form;try{form=await c.request.formData()}catch{}";else w+=`const form=await c.request.formData()
20
+ `;return w+`for(const key of form.keys()){if(c.body[key]) continue
21
21
  const value=form.getAll(key)
22
22
  if(value.length===1)c.body[key]=value[0]
23
- else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(w){let z="",U="",W=w.setHeaders;for(let Z of Object.keys(w.singleton.decorator))z+=`,${Z}: decorator['${Z}']`;let A=w.config.handler?.standardHostname??!0,X=w.event.trace.length>0;if(U+=`const u=r.url,s=u.indexOf('/',${A?11:7}),qi=u.indexOf('?', s + 1)
23
+ else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(z){let w="",U="",W=z.setHeaders;for(let Z of Object.keys(z.singleton.decorator))w+=`,${Z}: decorator['${Z}']`;let X=z.config.handler?.standardHostname??!0,A=!!z.event.trace?.length;if(U+=`const u=r.url,s=u.indexOf('/',${X?11:7}),qi=u.indexOf('?', s + 1)
24
24
  let p
25
25
  if(qi===-1)p=u.substring(s)
26
26
  else p=u.substring(s, qi)
27
- `,X)U+=`const id=randomId()
28
- `;if(U+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",U+=Object.keys(W??{}).length?"Object.assign({}, app.setHeaders)":"{}",U+=",status:200}",w.inference.server)U+=",get server(){return getServer()}";if(X)U+=",[ELYSIA_REQUEST_ID]:id";return U+=z,U+=`}
29
- `,U},websocket(w){let z="",U=w.router.static.ws,W=w.router.ws;if(Object.keys(U).length||W.history.length){z+="if(r.method==='GET'){switch(p){";for(let[A,X]of Object.entries(U))z+=`case'${A}':`+(w.config.strictPath!==!0?`case'${r6(A)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${X}].composed(c)
30
- `;z+=`default:if(r.headers.get('upgrade')==='websocket'){const route=wsRouter.find('ws',p)
27
+ `,A)U+=`const id=randomId()
28
+ `;if(U+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",U+=Object.keys(W??{}).length?"Object.assign({}, app.setHeaders)":"{}",U+=",status:200}",z.inference.server)U+=",get server(){return app.getServer()}";if(A)U+=",[ELYSIA_REQUEST_ID]:id";return U+=w,U+=`}
29
+ `,U},websocket(z){let w="",U=z.router.static.ws,W=z.router.http;if(W.build(),Object.keys(U).length||W.root.ws||W.history.find((X)=>X["0"]==="ws")){w+="if(r.method==='GET'){switch(p){";for(let[X,A]of Object.entries(U))w+=`case'${X}':`+(z.config.strictPath!==!0?`case'${D4(X)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${A}].composed(c)
30
+ `;w+=`default:if(r.headers.get('upgrade')==='websocket'){const route=router.find('ws',p)
31
31
  if(route){c.params=route.params
32
32
  if(route.store.handler)return route.store.handler(c)
33
- return (route.store.handler=route.store.compile())(c)}}break}}`}return z},error404(w,z){let U="if(route===null)return ";if(z)U+=`app.handleError(c,notFound,false,${this.parameters})`;else U+=w?"new Response(error404Message,{status:c.set.status===200?404:c.set.status,headers:c.set.headers})":"error404.clone()";return{declare:z?"":`const error404Message=notFound.message.toString()
33
+ return (route.store.handler=route.store.compile())(c)}}break}}`}return w},error404(z,w){let U="if(route===null)return ";if(w)U+=`app.handleError(c,notFound,false,${this.parameters})`;else U+=z?"new Response(error404Message,{status:c.set.status===200?404:c.set.status,headers:c.set.headers})":"error404.clone()";return{declare:w?"":`const error404Message=notFound.message.toString()
34
34
  const error404=new Response(error404Message,{status:404})
35
- `,code:U}}},composeError:{mapResponseContext:"",validationError:"return new Response(error.message,{headers:Object.assign({'content-type':'application/json'},set.headers),status:set.status})",unknownError:"return new Response(error.message,{headers:set.headers,status:error.status??set.status??500})"},listen(){return()=>{throw new Error("WebStandard does not support listen, you might want to export default Elysia.fetch instead")}}},EH=(w,z,U={})=>{if(typeof w==="function"||w instanceof Blob)return;let W=E2(w,{headers:U});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0){if(!W.headers.has("content-type"))W.headers.append("content-type","text/plain;charset=utf-8");return W.clone.bind(W)}},KU={open(w){w.data.open?.(w)},message(w,z){w.data.message?.(w,z)},drain(w){w.data.drain?.(w)},close(w,z,U){w.data.close?.(w,z,U)}};class V4{raw;data;body;validator;["~types"];get id(){return this.data.id}constructor(w,z,U=void 0){this.raw=w,this.data=z,this.body=U,this.validator=w.data?.validator,this.sendText=w.sendText.bind(w),this.sendBinary=w.sendBinary.bind(w),this.close=w.close.bind(w),this.terminate=w.terminate.bind(w),this.publishText=w.publishText.bind(w),this.publishBinary=w.publishBinary.bind(w),this.subscribe=w.subscribe.bind(w),this.unsubscribe=w.unsubscribe.bind(w),this.isSubscribed=w.isSubscribed.bind(w),this.cork=w.cork.bind(w),this.remoteAddress=w.remoteAddress,this.binaryType=w.binaryType,this.data=w.data,this.send=this.send.bind(this),this.ping=this.ping.bind(this),this.pong=this.pong.bind(this),this.publish=this.publish.bind(this)}send(w,z){if(Buffer.isBuffer(w))return this.raw.send(w,z);if(this.validator?.Check(w)===!1)return this.raw.send(new Z0("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.send(w,z)}ping(w){if(Buffer.isBuffer(w))return this.raw.ping(w);if(this.validator?.Check(w)===!1)return this.raw.send(new Z0("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.ping(w)}pong(w){if(Buffer.isBuffer(w))return this.raw.pong(w);if(this.validator?.Check(w)===!1)return this.raw.send(new Z0("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.pong(w)}publish(w,z,U){if(Buffer.isBuffer(z))return this.raw.publish(w,z,U);if(this.validator?.Check(z)===!1)return this.raw.send(new Z0("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.publish(w,z,U)}sendText;sendBinary;close;terminate;publishText;publishBinary;subscribe;unsubscribe;isSubscribed;cork;remoteAddress;binaryType;get readyState(){return this.raw.readyState}}var IH=(w)=>{let z=typeof w==="function"?[w]:w;return async function U(W,A){if(typeof A==="string"){let X=A?.charCodeAt(0);if(X===47||X===123)try{A=JSON.parse(A)}catch{}else if(iw(A))A=+A}if(z)for(let X=0;X<z.length;X++){let Z=z[X](W,A);if(Z instanceof Promise)Z=await Z;if(Z!==void 0)return Z}return A}},xH=(w)=>{let z=(U,W)=>{if(W instanceof Promise)return W.then((Z)=>z(U,Z));if(Buffer.isBuffer(W))return U.send(W.toString());if(W===void 0)return;let A=(Z)=>{if(w?.Check(Z)===!1)return U.send(new Z0("message",w,Z).message);if(typeof Z==="object")return U.send(JSON.stringify(Z));U.send(Z)};if(typeof W?.next!=="function")return void A(W);let X=W.next();if(X instanceof Promise)return(async()=>{let Z=await X;if(w?.Check(Z)===!1)return U.send(new Z0("message",w,Z).message);if(A(Z.value),!Z.done)for await(let $ of W)A($)})();if(A(X.value),!X.done)for(let Z of W)A(Z)};return z},VH={...I8,name:"bun",handler:{...I8.handler,createNativeStaticHandler:EH},composeHandler:{...I8.composeHandler,headers:IU?`c.headers = c.request.headers.toJSON()
35
+ `,code:U}}},composeError:{mapResponseContext:"",validationError:"return new Response(error.message,{headers:Object.assign({'content-type':'application/json'},set.headers),status:set.status})",unknownError:"return new Response(error.message,{headers:set.headers,status:error.status??set.status??500})"},listen(){return()=>{throw new Error("WebStandard does not support listen, you might want to export default Elysia.fetch instead")}}},PG=(z,w,U={})=>{if(typeof z==="function"||z instanceof Blob)return;if(typeof z==="object"&&z?.toString()==="[object HTMLBundle]")return()=>z;let W=E2(z,{headers:U});if(!w.parse?.length&&!w.transform?.length&&!w.beforeHandle?.length&&!w.afterHandle?.length){if(!W.headers.has("content-type"))W.headers.append("content-type","text/plain;charset=utf-8");return W.clone.bind(W)}},VW={open(z){z.data.open?.(z)},message(z,w){z.data.message?.(z,w)},drain(z){z.data.drain?.(z)},close(z,w,U){z.data.close?.(z,w,U)}};class e4{raw;data;body;validator;["~types"];get id(){return this.data.id}constructor(z,w,U=void 0){this.raw=z,this.data=w,this.body=U,this.validator=z.data?.validator,this.sendText=z.sendText.bind(z),this.sendBinary=z.sendBinary.bind(z),this.close=z.close.bind(z),this.terminate=z.terminate.bind(z),this.publishText=z.publishText.bind(z),this.publishBinary=z.publishBinary.bind(z),this.subscribe=z.subscribe.bind(z),this.unsubscribe=z.unsubscribe.bind(z),this.isSubscribed=z.isSubscribed.bind(z),this.cork=z.cork.bind(z),this.remoteAddress=z.remoteAddress,this.binaryType=z.binaryType,this.data=z.data,this.send=this.send.bind(this),this.ping=this.ping.bind(this),this.pong=this.pong.bind(this),this.publish=this.publish.bind(this)}send(z,w){if(Buffer.isBuffer(z))return this.raw.send(z,w);if(this.validator?.Check(z)===!1)return this.raw.send(new r("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.send(z,w)}ping(z){if(Buffer.isBuffer(z))return this.raw.ping(z);if(this.validator?.Check(z)===!1)return this.raw.send(new r("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.ping(z)}pong(z){if(Buffer.isBuffer(z))return this.raw.pong(z);if(this.validator?.Check(z)===!1)return this.raw.send(new r("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.pong(z)}publish(z,w,U){if(Buffer.isBuffer(w))return this.raw.publish(z,w,U);if(this.validator?.Check(w)===!1)return this.raw.send(new r("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.publish(z,w,U)}sendText;sendBinary;close;terminate;publishText;publishBinary;subscribe;unsubscribe;isSubscribed;cork;remoteAddress;binaryType;get readyState(){return this.raw.readyState}}var OG=(z)=>{let w=typeof z==="function"?[z]:z;return async function U(W,X){if(typeof X==="string"){let A=X?.charCodeAt(0);if(A===34||A===47||A===91||A===123)try{X=JSON.parse(X)}catch{}else if(Yw(X))X=+X;else if(X==="true")X=!0;else if(X==="false")X=!1;else if(X==="null")X=null}if(w)for(let A=0;A<w.length;A++){let Z=w[A](W,X);if(Z instanceof Promise)Z=await Z;if(Z!==void 0)return Z}return X}},RG=(z)=>{let w=(U,W)=>{if(W instanceof Promise)return W.then((Z)=>w(U,Z));if(Buffer.isBuffer(W))return U.send(W.toString());if(W===void 0)return;let X=(Z)=>{if(z?.Check(Z)===!1)return U.send(new r("message",z,Z).message);if(typeof Z==="object")return U.send(JSON.stringify(Z));U.send(Z)};if(typeof W?.next!=="function")return void X(W);let A=W.next();if(A instanceof Promise)return(async()=>{let Z=await A;if(z?.Check(Z)===!1)return U.send(new r("message",z,Z).message);if(X(Z.value),!Z.done)for await(let $ of W)X($)})();if(X(A.value),!A.done)for(let Z of W)X(Z)};return w},CG={...y5,name:"bun",handler:{...y5.handler,createNativeStaticHandler:PG},composeHandler:{...y5.composeHandler,headers:n5?`c.headers = c.request.headers.toJSON()
36
36
  `:`c.headers = {}
37
37
  for (const [key, value] of c.request.headers.entries())c.headers[key] = value
38
- `},listen(w){return(z,U)=>{if(typeof Bun==="undefined")throw new Error(".listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch");if(w.compile(),typeof z==="string"){if(!iw(z))throw new Error("Port must be a numeric value");z=parseInt(z)}let W=w.fetch,A=typeof z==="object"?{development:!T8,reusePort:!0,...w.config.serve||{},...z||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...KU||{}},fetch:W,error:w.outerErrorHandler}:{development:!T8,reusePort:!0,...w.config.serve||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...KU||{}},port:z,fetch:W,error:w.outerErrorHandler};w.server=Bun?.serve(A);for(let X=0;X<w.event.start.length;X++)w.event.start[X].fn(w);if(U)U(w.server);process.on("beforeExit",()=>{if(w.server){w.server.stop(),w.server=null;for(let X=0;X<w.event.stop.length;X++)w.event.stop[X].fn(w)}}),w.promisedModules.then(()=>{Bun?.gc(!1)})}},ws(w,z,U){let{parse:W,body:A,response:X,...Z}=U,$=j2(A,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize}),Q=j2(X,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize});w.route("$INTERNALWS",z,async(Y)=>{let B=w.getServer(),{set:G,path:_,qi:H,headers:F,query:R,params:J}=Y;if(Y.validator=Q,U.upgrade){if(typeof U.upgrade==="function"){let h=U.upgrade(Y);if(h instanceof Promise)await h}else if(U.upgrade)Object.assign(G.headers,U.upgrade)}if(G.cookie&&s2(G.cookie)){let h=pU(G.cookie);if(h)G.headers["set-cookie"]=h}if(G.headers["set-cookie"]&&Array.isArray(G.headers["set-cookie"]))G.headers=oU(new Headers(G.headers),G.headers["set-cookie"]);let m=xH(Q),A0=IH(W),L0;if(B?.upgrade(Y.request,{headers:s2(G.headers)?G.headers:void 0,data:{...Y,get id(){if(L0)return L0;return L0=gU()},validator:Q,ping(h){U.ping?.(h)},pong(h){U.pong?.(h)},open(h){m(h,U.open?.(new V4(h,Y)))},message:async(h,a)=>{let x=await A0(h,a);if($?.Check(x)===!1)return void h.send(new Z0("message",$,x).message);m(h,U.message?.(new V4(h,Y,x),x))},drain(h){m(h,U.drain?.(new V4(h,Y)))},close(h,a,x){m(h,U.close?.(new V4(h,Y),a,x))}}}))return;return G.status=400,"Expected a websocket connection"},{...Z,websocket:U})}},kH=typeof Bun!=="undefined",FU=kH?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{},a6=/\+/g;function TH(w){let z={};if(typeof w!=="string")return z;let U="",W="",A=-1,X=-1,Z=0,$=w.length;for(let Q=0;Q<$;Q++)switch(w.charCodeAt(Q)){case 38:let Y=X>A;if(!Y)X=Q;if(U=w.slice(A+1,X),Y||U.length>0){if(Z&1)U=U.replace(a6," ");if(Z&2)U=b6.default(U)||U;if(!z[U]){if(Y){if(W=w.slice(X+1,Q),Z&4)W=W.replace(a6," ");if(Z&8)W=b6.default(W)||W}z[U]=W}}U="",W="",A=Q,X=Q,Z=0;break;case 61:if(X<=A)X=Q;else Z|=8;break;case 43:if(X>A)Z|=4;else Z|=1;break;case 37:if(X>A)Z|=8;else Z|=2;break}if(A<$){let Q=X>A;if(U=w.slice(A+1,Q?X:$),Q||U.length>0){if(Z&1)U=U.replace(a6," ");if(Z&2)U=b6.default(U)||U;if(!z[U]){if(Q){if(W=w.slice(X+1,$),Z&4)W=W.replace(a6," ");if(Z&8)W=b6.default(W)||W}z[U]=W}}}return z}var x8=(w)=>{let z={};if(typeof w!=="string")return z;let U=w.length,W="",A="",X=-1,Z=-1,$=!1,Q=!1,Y=!1,B=!1,G=!1,_=0;for(let H=0;H<U+1;H++){if(H!==U)_=w.charCodeAt(H);else _=38;switch(_){case 38:{if(G=Z>X,!G)Z=H;if(W=w.slice(X+1,Z),G||W.length>0){if(Y)W=W.replace(a6," ");if($)W=b6.default(W)||W;if(G){if(A=w.slice(Z+1,H),B)A=A.replace(a6," ");if(Q)A=b6.default(A)||A}let F=z[W];if(F===void 0)z[W]=A;else if(F.pop)F.push(A);else z[W]=[F,A]}A="",X=H,Z=H,$=!1,Q=!1,Y=!1,B=!1;break}case 61:if(Z<=X)Z=H;else Q=!0;break;case 43:if(Z>X)B=!0;else Y=!0;break;case 37:if(Z>X)Q=!0;else $=!0;break}}return z},vw=Symbol("ElysiaTrace"),i1=()=>{let{promise:w,resolve:z}=Promise.withResolvers(),{promise:U,resolve:W}=Promise.withResolvers(),{promise:A,resolve:X}=Promise.withResolvers(),Z=[],$=[];return[(Q)=>{if(Q)Z.push(Q);return w},(Q)=>{let Y=[],B=[],G=null;for(let H=0;H<(Q.total??0);H++){let{promise:F,resolve:R}=Promise.withResolvers(),{promise:J,resolve:m}=Promise.withResolvers(),{promise:A0,resolve:L0}=Promise.withResolvers(),h=[],a=[];Y.push((x)=>{if(x)h.push(x);return F}),B.push((x)=>{let i={...x,end:J,error:A0,index:H,onStop(K){if(K)a.push(K);return J}};R(i);for(let K=0;K<h.length;K++)h[K](i);return(K=null)=>{let o=performance.now();if(K)G=K;let D0={end:o,error:K,get elapsed(){return o-x.begin}};for(let l=0;l<a.length;l++)a[l](D0);m(o),L0(K)}})}let _={...Q,end:U,error:A,onEvent(H){for(let F=0;F<Y.length;F++)Y[F](H)},onStop(H){if(H)$.push(H);return U}};z(_);for(let H=0;H<Z.length;H++)Z[H](_);return{resolveChild:B,resolve(H=null){let F=performance.now();if(!H&&G)H=G;let R={end:F,error:H,get elapsed(){return F-Q.begin}};for(let J=0;J<$.length;J++)$[J](R);W(F),X(H)}}}]},gH=(w)=>{return(z)=>{let[U,W]=i1(),[A,X]=i1(),[Z,$]=i1(),[Q,Y]=i1(),[B,G]=i1(),[_,H]=i1(),[F,R]=i1(),[J,m]=i1(),[A0,L0]=i1();return w({id:z[d8],context:z,set:z.set,onRequest:U,onParse:A,onTransform:Z,onBeforeHandle:Q,onHandle:B,onAfterHandle:_,onMapResponse:J,onAfterResponse:A0,onError:F}),{request:W,parse:X,transform:$,beforeHandle:Y,handle:G,afterHandle:H,error:R,mapResponse:m,afterResponse:L0}}},g4={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},Y1=(w)=>{if(!w)return!1;let z=w?.schema;if(z?.[g4.kind]==="Import")return w.References().some(Y1);return!!z&&g4.optional in z},fH=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],l2=(w)=>{if(!w)return!1;let z=w?.schema??w;if(z[g4.kind]==="Import"&&w.References())return w.References().some(l2);if(z.anyOf)return z.anyOf.some(l2);if(z.someOf)return z.someOf.some(l2);if(z.allOf)return z.allOf.some(l2);if(z.not)return z.not.some(l2);if(z.type==="object"){let U=z.properties;if("additionalProperties"in z)return z.additionalProperties;if("patternProperties"in z)return!1;for(let W of Object.keys(U)){let A=U[W];if(A.type==="object"){if(l2(A))return!0}else if(A.anyOf){for(let X=0;X<A.anyOf.length;X++)if(l2(A.anyOf[X]))return!0}return A.additionalProperties}return!1}return!1},nw=({context:w="c",trace:z,addFn:U})=>{if(!z.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let W=0;W<z.length;W++)U(`let report${W}, reportChild${W}, reportErr${W}, reportErrChild${W};let trace${W} = ${w}[ELYSIA_TRACE]?.[${W}] ?? trace[${W}](${w});
39
- `);return(W,{name:A,total:X=0}={})=>{if(!A)A="anonymous";let Z=W==="error"?"reportErr":"report";for(let $=0;$<z.length;$++)U(`${Z}${$} = trace${$}.${W}({id,event:'${W}',name:'${A}',begin:performance.now(),total:${X}})
40
- `);return{resolve(){for(let $=0;$<z.length;$++)U(`${Z}${$}.resolve()
41
- `)},resolveChild($){for(let Q=0;Q<z.length;Q++)U(`${Z}Child${Q}=${Z}${Q}.resolveChild?.shift()?.({id,event:'${W}',name:'${$}',begin:performance.now()})
42
- `);return(Q)=>{for(let Y=0;Y<z.length;Y++)if(Q)U(`if(${Q} instanceof Error){${Z}Child${Y}?.(${Q}) }else{${Z}Child${Y}?.()}`);else U(`${Z}Child${Y}?.()
43
- `)}}}}},dH=({injectResponse:w="",normalize:z=!1,validator:U})=>({composeValidation:(W,A=`c.${W}`)=>`c.set.status=422;throw new ValidationError('${W}',validator.${W},${A})`,composeResponseValidation:(W="r")=>{let A=w+`
44
- `;A+=`if(${W} instanceof ElysiaCustomStatusResponse){c.set.status=${W}.code
45
- ${W}=${W}.response}const isResponse=${W} instanceof Response
46
- switch(c.set.status){`;for(let[X,Z]of Object.entries(U.response)){if(A+=`
47
- case ${X}:if(!isResponse){`,z&&"Clean"in Z&&!l2(Z))A+=`${W}=validator.response['${X}'].Clean(${W})
48
- `;A+=`if(validator.response['${X}'].Check(${W})===false){c.set.status=422
49
- throw new ValidationError('response',validator.response['${X}'],${W})}c.set.status = ${X}}break
50
- `}return A+"}"}}),RE=Symbol.for("TypeBox.Kind"),U6=(w,z)=>{if(!z)return;let U=z.schema??z;if(U[g4.kind]==="Import")return z.References().some((W)=>U6(w,W));if(U.type==="object"){let W=U.properties;if(!W)return!1;for(let A of Object.keys(W)){let X=W[A];if(w in X)return!0;if(X.type==="object"){if(U6(w,X))return!0}else if(X.anyOf){for(let Z=0;Z<X.anyOf.length;Z++)if(U6(w,X.anyOf[Z]))return!0}}return!1}return w in U},kw=Symbol.for("TypeBox.Transform"),O6=(w)=>{if(!w)return;if(w.type==="object"&&w.properties){let z=w.properties;for(let U of Object.keys(z)){let W=z[U];if(W.type==="object"){if(O6(W))return!0}else if(W.anyOf){for(let A=0;A<W.anyOf.length;A++)if(O6(W.anyOf[A]))return!0}if(kw in W)return!0}return!1}return kw in w||w.properties&&kw in w.properties},hH=/(?:return|=>) \S+\(/g,e6=(w)=>{return(w?.fn??w).constructor.name==="AsyncFunction"},a0=(w)=>{let z=w?.fn??w;if(z.constructor.name==="AsyncFunction")return!0;let U=z.toString();if(U.includes("=> response.clone("))return!1;if(U.includes("await"))return!0;if(U.includes("async"))return!0;if(U.includes("=>response.clone("))return!1;return!!U.match(hH)},E8=(w)=>{let z=w?.fn??w;return z.constructor.name==="AsyncGeneratorFunction"||z.constructor.name==="GeneratorFunction"},yH=({app:w,path:z,method:U,localHook:W,hooks:A,validator:X,handler:Z,allowMeta:$=!1,inference:Q,asManifest:Y=!1})=>{let B=w["~adapter"].composeHandler,G=w["~adapter"].handler,_=typeof Z==="function";if(!_){if(Z=G.mapResponse(Z,{headers:w.setHeaders??{}}),A.parse.length===0&&A.transform.length===0&&A.beforeHandle.length===0&&A.afterHandle.length===0){if(Z instanceof Response)return Function("a","return function(){return a.clone()}")(Z);return Function("a","return function(){return a}")(Z)}}let H=_?"handler(c)":"handler",F=A.afterResponse.length>0,R=A.trace.length>0,J="";if(Q=uU(Object.assign(W,{handler:Z}),Q),B.declare){let j=B.declare(Q);if(j)J+=j}if(Q.server)J+=`Object.defineProperty(c,'server',{get:function(){return getServer()}})
51
- `;X.createBody?.(),X.createQuery?.(),X.createHeaders?.(),X.createParams?.(),X.createCookie?.(),X.createResponse?.();let m=Q.query||!!X.query,A0=U!=="$INTERNALWS"&&U!=="GET"&&U!=="HEAD"&&(Q.body||!!X.body||A.parse.length);if(A0)J+=`let isParsing=false
52
- `;let L0=w.setHeaders,h=L0&&!!Object.keys(L0).length,a=Q.headers||X.headers||B.preferWebstandardHeaders!==!0&&Q.body,x=Q.cookie||!!X.cookie,i=x?VU({modules:w.definitions.typebox,validator:X.cookie,defaultConfig:w.config.cookie,dynamic:!!w.config.aot,config:X.cookie?.config??{},models:w.definitions.type}):void 0,K=i?.config,o="";if(K?.sign){if(!K.secrets)throw new Error(`t.Cookie required secret which is not set in (${U}) ${z}.`);let j=!K.secrets?void 0:typeof K.secrets==="string"?K.secrets:K.secrets[0];if(o+=`const _setCookie = c.set.cookie
53
- if(_setCookie){`,K.sign===!0)o+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${j}')}`;else for(let O of K.sign)o+=`if(_setCookie['${O}']?.value){c.set.cookie['${O}'].value=await signCookie(_setCookie['${O}'].value,'${j}')}`;o+=`}
54
- `}let D0=w.config.normalize,{composeValidation:l,composeResponseValidation:O1}=dH({normalize:D0,validator:X});if(a)J+=B.headers;if(R)J+=`const id=c[ELYSIA_REQUEST_ID]
55
- `;let C0=nw({trace:A.trace,addFn:(j)=>{J+=j}});if(J+="try{",x){let j=(b,T)=>{let t=K?.[b]??T;if(!t)return typeof T==="string"?`${b}:"${T}",`:`${b}:${T},`;if(typeof t==="string")return`${b}:'${t}',`;if(t instanceof Date)return`${b}: new Date(${t.getTime()}),`;return`${b}:${t},`},O=K?`{secrets:${K.secrets!==void 0?typeof K.secrets==="string"?`'${K.secrets}'`:"["+K.secrets.reduce((b,T)=>b+`'${T}',`,"")+"]":"undefined"},sign:${K.sign===!0?!0:K.sign!==void 0?"["+K.sign.reduce((b,T)=>b+`'${T}',`,"")+"]":"undefined"},`+j("domain")+j("expires")+j("httpOnly")+j("maxAge")+j("path","/")+j("priority")+j("sameSite")+j("secure")+"}":"undefined";if(a)J+=`
56
- c.cookie=await parseCookie(c.set,c.headers.cookie,${O})
57
- `;else J+=`
58
- c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${O})
59
- `}if(m){let j=[];if(X.query&&X.query.schema.type==="object"){let O=X.query.schema.properties;if(!l2(X.query))for(let[b,T]of Object.entries(O)){let t=T;if(t&&g4.optional in t&&t.type==="array"&&t.items)t=t.items;let{type:e,anyOf:K0}=t,M=e==="array"||K0?.some((C)=>C.type==="string"&&C.format==="ArrayString");j.push({key:b,isArray:M,isNestedObjectArray:M&&t.items?.type==="object"||!!t.items?.anyOf?.some((C)=>C.type==="object"||C.type==="array"),isObject:e==="object"||K0?.some((C)=>C.type==="string"&&C.format==="ArrayString"),anyOf:!!K0})}}if(!j.length)J+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{J+=`if(c.qi!==-1){let url = '&' + decodeURIComponent(c.url.slice(c.qi + 1))
60
- `;let O=0;for(let{key:b,isArray:T,isObject:t,isNestedObjectArray:e,anyOf:K0}of j){let M=(O===0?"let ":"")+`memory=url.indexOf('&${b}=')
61
- let a${O}
62
- `;if(T)if(J+=M,e)J+=`while(memory!==-1){const start=memory+${b.length+2}
38
+ `},listen(z){return(w,U)=>{if(typeof Bun==="undefined")throw new Error(".listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch");if(z.compile(),typeof w==="string"){if(!Yw(w))throw new Error("Port must be a numeric value");w=parseInt(w)}let W=z.fetch,X=typeof w==="object"?{development:!t5,reusePort:!0,...z.config.serve||{},...w||{},static:{...z.router.static.http.static,...z.config.serve?.static},websocket:{...z.config.websocket||{},...VW||{}},fetch:W,error:z.outerErrorHandler}:{development:!t5,reusePort:!0,...z.config.serve||{},static:z.router.static.http.static,websocket:{...z.config.websocket||{},...VW||{}},port:w,fetch:W,error:z.outerErrorHandler};if(z.server=Bun?.serve(X),z.event.start)for(let A=0;A<z.event.start.length;A++)z.event.start[A].fn(z);if(U)U(z.server);process.on("beforeExit",()=>{if(z.server){if(z.server.stop?.(),z.server=null,z.event.stop)for(let A=0;A<z.event.stop.length;A++)z.event.stop[A].fn(z)}}),z.promisedModules.then(()=>{Bun?.gc(!1)})}},ws(z,w,U){let{parse:W,body:X,response:A,...Z}=U,$=j2(X,{modules:z.definitions.typebox,models:z.definitions.type,normalize:z.config.normalize}),Y=j2(A,{modules:z.definitions.typebox,models:z.definitions.type,normalize:z.config.normalize});z.route("$INTERNALWS",w,async(Q)=>{let J=z.getServer(),{set:N,path:S,qi:G,headers:O,query:M,params:C}=Q;if(Q.validator=Y,U.upgrade){if(typeof U.upgrade==="function"){let f=U.upgrade(Q);if(f instanceof Promise)await f}else if(U.upgrade)Object.assign(N.headers,U.upgrade)}if(N.cookie&&w1(N.cookie)){let f=zX(N.cookie);if(f)N.headers["set-cookie"]=f}if(N.headers["set-cookie"]&&Array.isArray(N.headers["set-cookie"]))N.headers=wX(new Headers(N.headers),N.headers["set-cookie"]);let k=RG(Y),q0=OG(W),w0,_0=[...Array.isArray(U.error)?U.error:[U.error],...(z.event.error??[]).map((f)=>typeof f==="function"?f:f.fn)],C0=!_0.length?()=>{}:async(f,E)=>{for(let T of _0){let F=T(Object.assign(Q,{error:E}));if(F instanceof Promise)F=await F;if(await k(f,F),F)break}};if(J?.upgrade(Q.request,{headers:w1(N.headers)?N.headers:void 0,data:{...Q,get id(){if(w0)return w0;return w0=iW()},validator:Y,ping(f){U.ping?.(f)},pong(f){U.pong?.(f)},open(f){try{k(f,U.open?.(new e4(f,Q)))}catch(E){C0(f,E)}},message:async(f,E)=>{let T=await q0(f,E);if($?.Check(T)===!1)return void f.send(new r("message",$,T).message);try{k(f,U.message?.(new e4(f,Q,T),T))}catch(F){C0(f,F)}},drain(f){try{k(f,U.drain?.(new e4(f,Q)))}catch(E){C0(f,E)}},close(f,E,T){try{k(f,U.close?.(new e4(f,Q),E,T))}catch(F){C0(f,F)}}}}))return;return N.status=400,"Expected a websocket connection"},{...Z,websocket:U})}},bG=typeof Bun!=="undefined",kW=bG?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{},P4=/\+/g;function KG(z){let w={};if(typeof z!=="string")return w;let U="",W="",X=-1,A=-1,Z=0,$=z.length;for(let Y=0;Y<$;Y++)switch(z.charCodeAt(Y)){case 38:let Q=A>X;if(!Q)A=Y;if(U=z.slice(X+1,A),Q||U.length>0){if(Z&1)U=U.replace(P4," ");if(Z&2)U=P6(U)||U;if(!w[U]){if(Q){if(W=z.slice(A+1,Y),Z&4)W=W.replace(P4," ");if(Z&8)W=P6(W)||W}w[U]=W}}U="",W="",X=Y,A=Y,Z=0;break;case 61:if(A<=X)A=Y;else Z|=8;break;case 43:if(A>X)Z|=4;else Z|=1;break;case 37:if(A>X)Z|=8;else Z|=2;break}if(X<$){let Y=A>X;if(U=z.slice(X+1,Y?A:$),Y||U.length>0){if(Z&1)U=U.replace(P4," ");if(Z&2)U=P6(U)||U;if(!w[U]){if(Y){if(W=z.slice(A+1,$),Z&4)W=W.replace(P4," ");if(Z&8)W=P6(W)||W}w[U]=W}}}return w}var v5=(z)=>{let w={};if(typeof z!=="string")return w;let U=z.length,W="",X="",A=-1,Z=-1,$=!1,Y=!1,Q=!1,J=!1,N=!1,S=0;for(let G=0;G<U+1;G++){if(G!==U)S=z.charCodeAt(G);else S=38;switch(S){case 38:{if(N=Z>A,!N)Z=G;if(W=z.slice(A+1,Z),N||W.length>0){if(Q)W=W.replace(P4," ");if($)W=P6(W)||W;if(N){if(X=z.slice(Z+1,G),J)X=X.replace(P4," ");if(Y)X=P6(X)||X}let O=w[W];if(O===void 0)w[W]=X;else if(O.pop)O.push(X);else w[W]=[O,X]}X="",A=G,Z=G,$=!1,Y=!1,Q=!1,J=!1;break}case 61:if(Z<=A)Z=G;else Y=!0;break;case 43:if(Z>A)J=!0;else Q=!0;break;case 37:if(Z>A)Y=!0;else $=!0;break}}return w},Jw=Symbol("ElysiaTrace"),w6=()=>{let{promise:z,resolve:w}=Promise.withResolvers(),{promise:U,resolve:W}=Promise.withResolvers(),{promise:X,resolve:A}=Promise.withResolvers(),Z=[],$=[];return[(Y)=>{if(Y)Z.push(Y);return z},(Y)=>{let Q=[],J=[],N=null;for(let G=0;G<(Y.total??0);G++){let{promise:O,resolve:M}=Promise.withResolvers(),{promise:C,resolve:k}=Promise.withResolvers(),{promise:q0,resolve:w0}=Promise.withResolvers(),_0=[],C0=[];Q.push((f)=>{if(f)_0.push(f);return O}),J.push((f)=>{let E={...f,end:C,error:q0,index:G,onStop(T){if(T)C0.push(T);return C}};M(E);for(let T=0;T<_0.length;T++)_0[T](E);return(T=null)=>{let F=performance.now();if(T)N=T;let a={end:F,error:T,get elapsed(){return F-f.begin}};for(let Z0=0;Z0<C0.length;Z0++)C0[Z0](a);k(F),w0(T)}})}let S={...Y,end:U,error:X,onEvent(G){for(let O=0;O<Q.length;O++)Q[O](G)},onStop(G){if(G)$.push(G);return U}};w(S);for(let G=0;G<Z.length;G++)Z[G](S);return{resolveChild:J,resolve(G=null){let O=performance.now();if(!G&&N)G=N;let M={end:O,error:G,get elapsed(){return O-Y.begin}};for(let C=0;C<$.length;C++)$[C](M);W(O),A(G)}}}]},FG=(z)=>{return(w)=>{let[U,W]=w6(),[X,A]=w6(),[Z,$]=w6(),[Y,Q]=w6(),[J,N]=w6(),[S,G]=w6(),[O,M]=w6(),[C,k]=w6(),[q0,w0]=w6();return z({id:w[l5],context:w,set:w.set,onRequest:U,onParse:X,onTransform:Z,onBeforeHandle:Y,onHandle:J,onAfterHandle:S,onMapResponse:C,onAfterResponse:q0,onError:O}),{request:W,parse:A,transform:$,beforeHandle:Q,handle:N,afterHandle:G,error:M,mapResponse:k,afterResponse:w0}}},m6={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},C1=(z)=>{if(!z)return!1;let w=z?.schema;if(w?.[m6.kind]==="Import")return z.References().some(C1);return!!w&&m6.optional in w},Y2=(z,w)=>w?z:"",jG=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],e2=(z)=>{if(!z)return!1;let w=z?.schema??z;if(w[m6.kind]==="Import"&&z.References())return z.References().some(e2);if(w.anyOf)return w.anyOf.some(e2);if(w.someOf)return w.someOf.some(e2);if(w.allOf)return w.allOf.some(e2);if(w.not)return w.not.some(e2);if(w.type==="object"){let U=w.properties;if("additionalProperties"in w)return w.additionalProperties;if("patternProperties"in w)return!1;for(let W of Object.keys(U)){let X=U[W];if(X.type==="object"){if(e2(X))return!0}else if(X.anyOf){for(let A=0;A<X.anyOf.length;A++)if(e2(X.anyOf[A]))return!0}return X.additionalProperties}return!1}return!1},Bw=({context:z="c",trace:w=[],addFn:U})=>{if(!w.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let W=0;W<w.length;W++)U(`let report${W}, reportChild${W}, reportErr${W}, reportErrChild${W};let trace${W} = ${z}[ELYSIA_TRACE]?.[${W}] ?? trace[${W}](${z});
39
+ `);return(W,{name:X,total:A=0}={})=>{if(!X)X="anonymous";let Z=W==="error"?"reportErr":"report";for(let $=0;$<w.length;$++)U(`${Z}${$} = trace${$}.${W}({id,event:'${W}',name:'${X}',begin:performance.now(),total:${A}})
40
+ `);return{resolve(){for(let $=0;$<w.length;$++)U(`${Z}${$}.resolve()
41
+ `)},resolveChild($){for(let Y=0;Y<w.length;Y++)U(`${Z}Child${Y}=${Z}${Y}.resolveChild?.shift()?.({id,event:'${W}',name:'${$}',begin:performance.now()})
42
+ `);return(Y)=>{for(let Q=0;Q<w.length;Q++)if(Y)U(`if(${Y} instanceof Error){${Z}Child${Q}?.(${Y}) }else{${Z}Child${Q}?.()}`);else U(`${Z}Child${Q}?.()
43
+ `)}}}}},EG=({injectResponse:z="",normalize:w=!1,validator:U,encodeSchema:W=!1})=>({composeValidation:(X,A=`c.${X}`)=>`c.set.status=422;throw new ValidationError('${X}',validator.${X},${A})`,composeResponseValidation:(X="r")=>{let A=z+`
44
+ `;A+=`if(${X} instanceof ElysiaCustomStatusResponse){c.set.status=${X}.code
45
+ ${X}=${X}.response}const isResponse=${X} instanceof Response
46
+ switch(c.set.status){`;for(let[Z,$]of Object.entries(U.response)){if(A+=`
47
+ case ${Z}:if(!isResponse){`,w&&"Clean"in $&&!e2($))A+=`${X}=validator.response['${Z}'].Clean(${X})
48
+ `;if(W&&($.hasTransform||typeof $.Decode==="function"))A+=`${X}=validator.response['${Z}'].Encode(${X})
49
+ `;A+=`if(validator.response['${Z}'].Check(${X})===false){c.set.status=422
50
+ throw new ValidationError('response',validator.response['${Z}'],${X})}c.set.status = ${Z}}
51
+ `,A+=`break
52
+ `}return A+"}"}}),Zf=Symbol.for("TypeBox.Kind"),D6=(z,w)=>{if(!w)return;let U=w.schema??w;if(U[m6.kind]==="Import")return w.References().some((W)=>D6(z,W));if(U.type==="object"){let W=U.properties;if(!W)return!1;for(let X of Object.keys(W)){let A=W[X];if(z in A)return!0;if(A.type==="object"){if(D6(z,A))return!0}else if(A.anyOf){for(let Z=0;Z<A.anyOf.length;Z++)if(D6(z,A.anyOf[Z]))return!0}}return!1}return z in U},IG=Symbol.for("TypeBox.Transform"),y2=(z)=>{if(!z)return!1;if(z.$ref&&z.$defs&&z.$ref in z.$defs&&y2(z.$defs[z.$ref]))return!0;if(z.oneOf){for(let w=0;w<z.oneOf.length;w++)if(y2(z.oneOf[w]))return!0}if(z.anyOf){for(let w=0;w<z.anyOf.length;w++)if(y2(z.anyOf[w]))return!0}if(z.allOf){for(let w=0;w<z.allOf.length;w++)if(y2(z.allOf[w]))return!0}if(z.not&&y2(z.not))return!0;if(z.type==="object"&&z.properties){let w=z.properties;for(let U of Object.keys(w)){let W=w[U];if(y2(W))return!0;if(W.type==="array"&&W.items&&y2(W.items))return!0}}if(z.type==="array"&&z.items&&y2(z.items))return!0;return IG in z},xG=/(?:return|=>) \S+\(/g,O4=(z)=>{return(z?.fn??z).constructor.name==="AsyncFunction"},e0=(z)=>{let w=z?.fn??z;if(w.constructor.name==="AsyncFunction")return!0;let U=w.toString();if(U.includes("=> response.clone("))return!1;if(U.includes("await"))return!0;if(U.includes("async"))return!0;if(U.includes("=>response.clone("))return!1;return!!U.match(xG)},i5=(z)=>{let w=z?.fn??z;return w.constructor.name==="AsyncGeneratorFunction"||w.constructor.name==="GeneratorFunction"},VG=({app:z,path:w,method:U,hooks:W,validator:X,handler:A,allowMeta:Z=!1,inference:$,asManifest:Y=!1})=>{let Q=z["~adapter"].composeHandler,J=z["~adapter"].handler,N=typeof A==="function";if(!N){if(A=J.mapResponse(A,{headers:z.setHeaders??{}}),W.parse?.length&&W.transform?.length&&W.beforeHandle?.length&&W.afterHandle?.length){if(A instanceof Response)return Function("a","return function(){return a.clone()}")(A);return Function("a","return function(){return a}")(A)}}let S=N?"handler(c)":"handler",G=!!W.afterResponse?.length,O=!!W.trace?.length,M="";if($=rW(Object.assign({},W,{handler:A}),$),Q.declare){let j=Q.declare($);if(j)M+=j}if($.server)M+=`Object.defineProperty(c,'server',{get:function(){return getServer()}})
53
+ `;X.createBody?.(),X.createQuery?.(),X.createHeaders?.(),X.createParams?.(),X.createCookie?.(),X.createResponse?.();let C=X.body||X.headers||X.params||X.query||X.cookie||X.response,k=$.query||!!X.query,q0=W.parse?.length===1&&W.parse[0].fn==="none",w0=U!=="$INTERNALWS"&&U!=="GET"&&U!=="HEAD"&&($.body||!!X.body||!!W.parse?.length)&&!q0;if(w0)M+=`let isParsing=false
54
+ `;let _0=z.setHeaders,C0=_0&&!!Object.keys(_0).length,f=$.headers||X.headers||Q.preferWebstandardHeaders!==!0&&$.body,E=$.cookie||!!X.cookie,T=E?dW({modules:z.definitions.typebox,validator:X.cookie,defaultConfig:z.config.cookie,dynamic:!!z.config.aot,config:X.cookie?.config??{},models:z.definitions.type}):void 0,F=T?.config,a="";if(F?.sign){if(!F.secrets)throw new Error(`t.Cookie required secret which is not set in (${U}) ${w}.`);let j=!F.secrets?void 0:typeof F.secrets==="string"?F.secrets:F.secrets[0];if(a+=`const _setCookie = c.set.cookie
55
+ if(_setCookie){`,F.sign===!0)a+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${j}')}`;else for(let R of F.sign)a+=`if(_setCookie['${R}']?.value){c.set.cookie['${R}'].value=await signCookie(_setCookie['${R}'].value,'${j}')}`;a+=`}
56
+ `}let Z0=z.config.normalize,H0=z.config.experimental?.encodeSchema,{composeValidation:h0,composeResponseValidation:U6}=EG({normalize:Z0,validator:X,encodeSchema:H0});if(f)M+=Q.headers;if(O)M+=`const id=c[ELYSIA_REQUEST_ID]
57
+ `;let n0=Bw({trace:W.trace,addFn:(j)=>{M+=j}});if(M+="try{",E){let j=(b,c)=>{let t=F?.[b]??c;if(!t)return typeof c==="string"?`${b}:"${c}",`:`${b}:${c},`;if(typeof t==="string")return`${b}:'${t}',`;if(t instanceof Date)return`${b}: new Date(${t.getTime()}),`;return`${b}:${t},`},R=F?`{secrets:${F.secrets!==void 0?typeof F.secrets==="string"?`'${F.secrets}'`:"["+F.secrets.reduce((b,c)=>b+`'${c}',`,"")+"]":"undefined"},sign:${F.sign===!0?!0:F.sign!==void 0?"["+F.sign.reduce((b,c)=>b+`'${c}',`,"")+"]":"undefined"},`+j("domain")+j("expires")+j("httpOnly")+j("maxAge")+j("path","/")+j("priority")+j("sameSite")+j("secure")+"}":"undefined";if(f)M+=`
58
+ c.cookie=await parseCookie(c.set,c.headers.cookie,${R})
59
+ `;else M+=`
60
+ c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${R})
61
+ `}if(k){let j=[];if(X.query&&X.query.schema.type==="object"){let R=X.query.schema.properties;if(!e2(X.query))for(let[b,c]of Object.entries(R)){let t=c,B=t.type==="array"||!!t.anyOf?.some((d)=>d.type==="string"&&d.format==="ArrayString");if(t&&m6.optional in t&&t.type==="array"&&t.items)t=t.items;let{type:K,anyOf:L}=t;j.push({key:b,isArray:B,isNestedObjectArray:B&&t.items?.type==="object"||!!t.items?.anyOf?.some((d)=>d.type==="object"||d.type==="array"),isObject:K==="object"||L?.some((d)=>d.type==="string"&&d.format==="ArrayString"),anyOf:!!L})}}if(!j.length)M+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{M+=`if(c.qi!==-1){let url='&'+c.url.slice(c.qi + 1)
62
+ `;let R=0;for(let{key:b,isArray:c,isObject:t,isNestedObjectArray:B,anyOf:K}of j){let L=(R===0?"let ":"")+`memory=url.indexOf('&${b}=')
63
+ let a${R}
64
+ `;if(c)if(M+=L,B)M+=`while(memory!==-1){const start=memory+${b.length+2}
63
65
  memory=url.indexOf('&',start)
64
- if(a${O}===undefined)
65
- a${O}=''
66
+ if(a${R}===undefined)
67
+ a${R}=''
66
68
  else
67
- a${O}+=','
69
+ a${R}+=','
68
70
  let temp
69
- if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
70
- else temp=decodeURIComponent(url.slice(start, memory).replace(/\\+|%20/g,' '))
71
- const charCode = temp.charCodeAt(0)
72
- if(charCode !== 91 && charCode !== 123)
71
+ if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))
72
+ else temp=decodeURIComponent(url.slice(start, memory).replace(/\\+/g,' '))
73
+ const charCode=temp.charCodeAt(0)
74
+ if(charCode!==91&&charCode !== 123)
73
75
  temp='"'+temp+'"'
74
- a${O} += temp
75
- if(memory === -1)break
76
+ a${R}+=temp
77
+ if(memory===-1)break
76
78
  memory=url.indexOf('&${b}=',memory)
77
- if(memory === -1)break}try{if(a${O}.charCodeAt(0) === 91)a${O} = JSON.parse(a${O})
79
+ if(memory===-1)break}try{if(a${R}.charCodeAt(0)===91)a${R} = JSON.parse(a${R})
78
80
  else
79
- a${O}=JSON.parse('['+a${O}+']')}catch{}
80
- `;else J+=`while(memory!==-1){const start=memory+${b.length+2}
81
+ a${R}=JSON.parse('['+a${R}+']')}catch{}
82
+ `;else M+=`while(memory!==-1){const start=memory+${b.length+2}
81
83
  memory=url.indexOf('&',start)
82
- if(a${O}===undefined)a${O}=[]
83
- if(memory===-1){a${O}.push(decodeURIComponent(url.slice(start)).replace(/\\+|%20/g,' '))
84
- break}else a${O}.push(decodeURIComponent(url.slice(start, memory)).replace(/\\+|%20/g,' '))
85
- memory=url.indexOf('&${b}=',memory)
84
+ if(a${R}===undefined)a${R}=[]
85
+ if(memory===-1){const temp=decodeURIComponent(url.slice(start)).replace(/\\+/g,' ')
86
+ if(temp.includes(',')){a${R}=a${R}.concat(temp.split(','))}else{a${R}.push(decodeURIComponent(url.slice(start)).replace(/\\+/g,' '))}
87
+ break}else{const temp=decodeURIComponent(url.slice(start, memory)).replace(/\\+/g,' ')
88
+ if(temp.includes(',')){a${R}=a${R}.concat(temp.split(','))}else{a${R}.push(temp)}
89
+ }memory=url.indexOf('&${b}=',memory)
86
90
  if(memory===-1) break
87
- }`;else if(t)J+=M+`if(memory!==-1){const start=memory+${b.length+2}
91
+ }`;else if(t)M+=L+`if(memory!==-1){const start=memory+${b.length+2}
88
92
  memory=url.indexOf('&',start)
89
- if(memory===-1)a${O}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))else a${O}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))if(a${O}!==undefined)try{a${O}=JSON.parse(a${O})}catch{}}`;else{if(J+=M+`if(memory!==-1){const start=memory+${b.length+2}
93
+ if(memory===-1)a${R}=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))else a${R}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))if(a${R}!==undefined)try{a${R}=JSON.parse(a${R})}catch{}}`;else{if(M+=L+`if(memory!==-1){const start=memory+${b.length+2}
90
94
  memory=url.indexOf('&',start)
91
- if(memory===-1)a${O}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
92
- else{a${O}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))`,K0)J+=`
95
+ if(memory===-1)a${R}=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))
96
+ else{a${R}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))`,K)M+=`
93
97
  let deepMemory=url.indexOf('&${b}=',memory)
94
- if(deepMemory!==-1){a${O}=[a${O}]
98
+ if(deepMemory!==-1){a${R}=[a${R}]
95
99
  let first=true
96
100
  while(true){const start=deepMemory+${b.length+2}
97
101
  if(first)first=false
98
102
  else deepMemory = url.indexOf('&', start)
99
103
  let value
100
- if(deepMemory===-1)value=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
101
- else value=decodeURIComponent(url.slice(start, deepMemory).replace(/\\+|%20/g,' '))
104
+ if(deepMemory===-1)value=url.slice(start).replace(/\\+/g,' ')
105
+ else value=url.slice(start, deepMemory).replace(/\\+/g,' ')
106
+ value=decodeURIComponent(value)
107
+ if(value===null){if(deepMemory===-1){break}else{continue}}
102
108
  const vStart=value.charCodeAt(0)
103
109
  const vEnd=value.charCodeAt(value.length - 1)
104
110
  if((vStart===91&&vEnd===93)||(vStart===123&&vEnd===125))
105
- try{a${O}.push(JSON.parse(value))}catch{a${O}.push(value)}if(deepMemory===-1)break}}`;J+="}}"}O++,J+=`
106
- `}J+="c.query={"+j.map(({key:b},T)=>`'${b}':a${T}`).join(",")+"}",J+=`} else c.query = {}
107
- `}}let n1=typeof Z==="function"&&a0(Z),I2=R||A.afterResponse.length>0?"c.response= ":"",Y6=x||A0||n1||A.parse.length>0||A.afterHandle.some(a0)||A.beforeHandle.some(a0)||A.transform.some(a0)||A.mapResponse.some(a0),g5=(typeof Z==="function"?E8(Z):!1)||A.beforeHandle.some(E8)||A.afterHandle.some(E8)||A.transform.some(E8),K6=Q.cookie||Q.set||a||R||X.response||_&&h||g5,o0=B.mapResponseContext?`,${B.mapResponseContext}`:"";if(Q.route)J+=`c.route=\`${z}\`
108
- `;let l0=C0("parse",{total:A.parse.length});if(A0){let j=Y1(X.body),O=A.parse.length||Q.body||X.body;if(B.parser.declare)J+=B.parser.declare;J+=`
109
- isParsing=true`;let b=typeof A.parse==="string"?A.parse:Array.isArray(A.parse)&&A.parse.length===1?typeof A.parse[0]==="string"?A.parse[0]:typeof A.parse[0].fn==="string"?A.parse[0].fn:void 0:void 0;if(b&&b in fH){let T=C0("parse",{total:A.parse.length});switch(b){case"json":case"application/json":J+=B.parser.json(j);break;case"text":case"text/plain":J+=B.parser.text(j);break;case"urlencoded":case"application/x-www-form-urlencoded":J+=B.parser.urlencoded(j);break;case"arrayBuffer":case"application/octet-stream":J+=B.parser.arrayBuffer(j);break;case"formdata":case"multipart/form-data":J+=B.parser.formData(j);break;default:if(b[0]in w["~parser"])J+=a?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",J+=`
111
+ try{a${R}.push(JSON.parse(value))}catch{a${R}.push(value)}if(deepMemory===-1)break}}`;M+="}}"}R++,M+=`
112
+ `}M+="c.query={"+j.map(({key:b},c)=>`'${b}':a${c}`).join(",")+"}",M+=`} else c.query = {}
113
+ `}}let W6=typeof A==="function"&&e0(A),I2=O||W.afterResponse?.length?"c.response= ":"",b6=E||w0||W6||!!W.parse?.length||!!W.afterHandle?.some(e0)||!!W.beforeHandle?.some(e0)||!!W.transform?.some(e0)||!!W.mapResponse?.some(e0),a5=(typeof A==="function"?i5(A):!1)||!!W.beforeHandle?.some(i5)||!!W.afterHandle?.some(i5)||!!W.transform?.some(i5),W1=$.cookie||$.set||f||O||X.response||N&&C0||a5,S0=Q.mapResponseContext?`,${Q.mapResponseContext}`:"";if(O||$.route)M+=`c.route=\`${w}\`
114
+ `;let x2=n0("parse",{total:W.parse?.length});if(w0){let j=C1(X.body),R=!!W.parse?.length||$.body||X.body;if(Q.parser.declare)M+=Q.parser.declare;M+=`
115
+ isParsing=true
116
+ `;let b=typeof W.parse==="string"?W.parse:Array.isArray(W.parse)&&W.parse.length===1?typeof W.parse[0]==="string"?W.parse[0]:typeof W.parse[0].fn==="string"?W.parse[0].fn:void 0:void 0;if(b&&jG.includes(b)){let c=n0("parse",{total:W.parse?.length});switch(b){case"json":case"application/json":M+=Q.parser.json(j);break;case"text":case"text/plain":M+=Q.parser.text(j);break;case"urlencoded":case"application/x-www-form-urlencoded":M+=Q.parser.urlencoded(j);break;case"arrayBuffer":case"application/octet-stream":M+=Q.parser.arrayBuffer(j);break;case"formdata":case"multipart/form-data":M+=Q.parser.formData(j);break;default:if(b[0]in z["~parser"])M+=f?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",M+=`
110
117
  if(contentType){const index=contentType.indexOf(';')
111
118
  if(index!==-1)contentType=contentType.substring(0, index)}
112
119
  else{contentType=''}c.contentType=contentType
113
- `,J+=`let result=parser['${b}'](c, contentType)
120
+ `,M+=`let result=parser['${b}'](c, contentType)
114
121
  if(result instanceof Promise)result=await result
115
122
  if(result instanceof ElysiaCustomStatusResponse)throw result
116
123
  if(result!==undefined)c.body=result
117
124
  delete c.contentType
118
- `;break}T.resolve()}else if(O){if(J+=`
119
- `,J+=a?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",J+=`
125
+ `;break}c.resolve()}else if(R){if(M+=`
126
+ `,M+=f?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",M+=`
120
127
  if(contentType){const index=contentType.indexOf(';')
121
128
  if(index!==-1)contentType=contentType.substring(0, index)}
122
129
  else{contentType=''}c.contentType=contentType
123
- `,A.parse.length)J+=`let used=false
124
- `;let T=C0("parse",{total:A.parse.length}),t=!1;for(let e=0;e<A.parse.length;e++){let K0=`bo${e}`;if(e!==0)J+=`
125
- if(!used){`;if(typeof A.parse[e].fn==="string"){let M=T.resolveChild(A.parse[e].fn);switch(A.parse[e].fn){case"json":case"application/json":t=!0,J+=B.parser.json(j);break;case"text":case"text/plain":t=!0,J+=B.parser.text(j);break;case"urlencoded":case"application/x-www-form-urlencoded":t=!0,J+=B.parser.urlencoded(j);break;case"arrayBuffer":case"application/octet-stream":t=!0,J+=B.parser.arrayBuffer(j);break;case"formdata":case"multipart/form-data":t=!0,J+=B.parser.formData(j);break;default:J+=`${K0}=parser['${A.parse[e].fn}'](c,contentType)
126
- if(${K0} instanceof Promise)${K0}=await ${K0}
127
- if(${K0}!==undefined){c.body=${K0};used=true}
128
- `}M()}else{let M=T.resolveChild(A.parse[e].fn.name);J+=`let ${K0}=parse[${e}]
129
- ${K0}=${K0}(c,contentType)
130
- if(${K0} instanceof Promise)${K0}=await ${K0}
131
- if(${K0}!==undefined){c.body=${K0};used=true}`,M()}if(e!==0)J+="}";if(t)break}if(T.resolve(),!t){if(A.parse.length)J+=`
130
+ `,W.parse?.length)M+=`let used=false
131
+ `;let c=n0("parse",{total:W.parse?.length}),t=!1;if(W.parse)for(let B=0;B<W.parse.length;B++){let K=`bo${B}`;if(B!==0)M+=`
132
+ if(!used){`;if(typeof W.parse[B].fn==="string"){let L=c.resolveChild(W.parse[B].fn);switch(W.parse[B].fn){case"json":case"application/json":t=!0,M+=Q.parser.json(j);break;case"text":case"text/plain":t=!0,M+=Q.parser.text(j);break;case"urlencoded":case"application/x-www-form-urlencoded":t=!0,M+=Q.parser.urlencoded(j);break;case"arrayBuffer":case"application/octet-stream":t=!0,M+=Q.parser.arrayBuffer(j);break;case"formdata":case"multipart/form-data":t=!0,M+=Q.parser.formData(j);break;default:M+=`${K}=parser['${W.parse[B].fn}'](c,contentType)
133
+ if(${K} instanceof Promise)${K}=await ${K}
134
+ if(${K}!==undefined){c.body=${K};used=true}
135
+ `}L()}else{let L=c.resolveChild(W.parse[B].fn.name);M+=`let ${K}=e.parse[${B}]
136
+ ${K}=${K}(c,contentType)
137
+ if(${K} instanceof Promise)${K}=await ${K}
138
+ if(${K}!==undefined){c.body=${K};used=true}`,L()}if(B!==0)M+="}";if(t)break}if(c.resolve(),!t){if(W.parse?.length)M+=`
132
139
  if(!used){
133
140
  if(!contentType) throw new ParseError()
134
- `;J+="switch(contentType){",J+=`case 'application/json':
135
- `+B.parser.json(j)+`break
136
- case 'text/plain':`+B.parser.text(j)+`break
137
- case 'application/x-www-form-urlencoded':`+B.parser.urlencoded(j)+`break
138
- case 'application/octet-stream':`+B.parser.arrayBuffer(j)+`break
139
- case 'multipart/form-data':`+B.parser.formData(j)+`break
140
- `;for(let e of Object.keys(w["~parser"]))J+=`case '${e}':let bo${e}=parser['${e}'](c,contentType)
141
- if(bo${e} instanceof Promise)bo${e}=await bo${e}
142
- if(bo${e} instanceof ElysiaCustomStatusResponse)throw result
143
- if(bo${e}!==undefined)c.body=bo${e}
141
+ `;M+="switch(contentType){",M+=`case 'application/json':
142
+ `+Q.parser.json(j)+`break
143
+ case 'text/plain':`+Q.parser.text(j)+`break
144
+ case 'application/x-www-form-urlencoded':`+Q.parser.urlencoded(j)+`break
145
+ case 'application/octet-stream':`+Q.parser.arrayBuffer(j)+`break
146
+ case 'multipart/form-data':`+Q.parser.formData(j)+`break
147
+ `;for(let B of Object.keys(z["~parser"]))M+=`case '${B}':let bo${B}=parser['${B}'](c,contentType)
148
+ if(bo${B} instanceof Promise)bo${B}=await bo${B}
149
+ if(bo${B} instanceof ElysiaCustomStatusResponse)throw result
150
+ if(bo${B}!==undefined)c.body=bo${B}
144
151
  break
145
- `;if(A.parse.length)J+="}";J+="}"}}J+=`
146
- delete c.contentType`,J+=`
152
+ `;if(W.parse?.length)M+="}";M+="}"}}M+=`
153
+ delete c.contentType`,M+=`
147
154
  isParsing=false
148
- `}if(l0.resolve(),A?.transform){let j=C0("transform",{total:A.transform.length});if(A.transform.length)J+=`let transformed
149
- `;for(let O=0;O<A.transform.length;O++){let b=A.transform[O],T=j.resolveChild(b.fn.name);if(J+=a0(b)?`transformed=await transform[${O}](c)
150
- `:`transformed=transform[${O}](c)
151
- `,b.subType==="mapDerive")J+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
155
+ `}if(x2.resolve(),W?.transform){let j=n0("transform",{total:W.transform.length});if(W.transform.length)M+=`let transformed
156
+ `;for(let R=0;R<W.transform.length;R++){let b=W.transform[R],c=j.resolveChild(b.fn.name);if(M+=e0(b)?`transformed=await e.transform[${R}](c)
157
+ `:`transformed=e.transform[${R}](c)
158
+ `,b.subType==="mapDerive")M+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
152
159
  else{transformed.request=c.request
153
160
  transformed.store=c.store
154
161
  transformed.qi=c.qi
@@ -157,30 +164,30 @@ transformed.url=c.url
157
164
  transformed.redirect=c.redirect
158
165
  transformed.set=c.set
159
166
  transformed.error=c.error
160
- c=transformed}`;else J+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
167
+ c=transformed}`;else M+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
161
168
  else Object.assign(c,transformed)
162
- `;T()}j.resolve()}if(X){if(X.headers){if(D0&&"Clean"in X.headers&&!l2(X.headers))J+=`c.headers=validator.headers.Clean(c.headers);
163
- `;if(U6("default",X.headers))for(let[j,O]of Object.entries(p.Default(X.headers.schema,{}))){let b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(b!==void 0)J+=`c.headers['${j}']??=${b}
164
- `}if(Y1(X.headers))J+="if(isNotEmpty(c.headers)){";if(J+="if(validator.headers.Check(c.headers) === false){"+l("headers")+"}",O6(X.headers.schema))J+=`c.headers=validator.headers.Decode(c.headers)
165
- `;if(Y1(X.headers))J+="}"}if(X.params){if(U6("default",X.params))for(let[j,O]of Object.entries(p.Default(X.params.schema,{}))){let b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(b!==void 0)J+=`c.params['${j}']??=${b}
166
- `}if(J+="if(validator.params.Check(c.params)===false){"+l("params")+"}",O6(X.params.schema))J+=`c.params=validator.params.Decode(c.params)
167
- `}if(X.query){if(D0&&"Clean"in X.query&&!l2(X.query))J+=`c.query=validator.query.Clean(c.query)
168
- `;if(U6("default",X.query))for(let[j,O]of Object.entries(p.Default(X.query.schema,{}))){let b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(b!==void 0)J+=`if(c.query['${j}']===undefined)c.query['${j}']=${b}
169
- `}if(Y1(X.query))J+="if(isNotEmpty(c.query)){";if(J+="if(validator.query.Check(c.query)===false){"+l("query")+"}",O6(X.query.schema))J+=`c.query=validator.query.Decode(Object.assign({},c.query))
170
- `;if(Y1(X.query))J+="}"}if(X.body){if(D0&&"Clean"in X.body&&!l2(X.body))J+=`c.body=validator.body.Clean(c.body)
171
- `;let j=O6(X.body.schema);if(j||Y1(X.body))J+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&isNotEmpty(c.body))
172
- `;if(U6("default",X.body)){let O=p.Default(X.body.schema,X.body.schema.type==="object"?{}:void 0),b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(J+=`if(validator.body.Check(c.body)===false){if(typeof c.body==='object')c.body=Object.assign(${b},c.body)
173
- else c.body=${b}
174
- `,Y1(X.body))J+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+l("body")+"}";else J+="if(validator.body.Check(c.body)===false){"+l("body")+"}";J+="}"}else if(Y1(X.body))J+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+l("body")+"}";else J+="if(validator.body.Check(c.body)===false){"+l("body")+"}";if(j)J+=`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)
175
- `}if(i&&s2(i?.schema?.properties??i?.schema?.schema??{})){if(J+=`const cookieValue={}
169
+ `;c()}j.resolve()}if(X){if(X.headers){if(Z0&&"Clean"in X.headers&&!e2(X.headers))M+=`c.headers=validator.headers.Clean(c.headers);
170
+ `;if(D6("default",X.headers))for(let[j,R]of Object.entries(o.Default(X.headers.schema,{}))){let b=typeof R==="object"?JSON.stringify(R):typeof R==="string"?`'${R}'`:R;if(b!==void 0)M+=`c.headers['${j}']??=${b}
171
+ `}if(C1(X.headers))M+="if(isNotEmpty(c.headers)){";if(M+="if(validator.headers.Check(c.headers) === false){"+h0("headers")+"}",y2(X.headers.schema))M+=`c.headers=validator.headers.Decode(c.headers)
172
+ `;if(C1(X.headers))M+="}"}if(X.params){if(D6("default",X.params))for(let[j,R]of Object.entries(o.Default(X.params.schema,{}))){let b=typeof R==="object"?JSON.stringify(R):typeof R==="string"?`'${R}'`:R;if(b!==void 0)M+=`c.params['${j}']??=${b}
173
+ `}if(M+="if(validator.params.Check(c.params)===false){"+h0("params")+"}",y2(X.params.schema))M+=`c.params=validator.params.Decode(c.params)
174
+ `}if(X.query){if(Z0&&"Clean"in X.query&&!e2(X.query))M+=`c.query=validator.query.Clean(c.query)
175
+ `;if(D6("default",X.query))for(let[j,R]of Object.entries(o.Default(X.query.schema,{}))){let b=typeof R==="object"?JSON.stringify(R):typeof R==="string"?`'${R}'`:R;if(b!==void 0)M+=`if(c.query['${j}']===undefined)c.query['${j}']=${b}
176
+ `}if(C1(X.query))M+="if(isNotEmpty(c.query)){";if(M+="if(validator.query.Check(c.query)===false){"+h0("query")+"}",y2(X.query.schema))M+=`c.query=validator.query.Decode(Object.assign({},c.query))
177
+ `;if(C1(X.query))M+="}"}if(X.body){if(Z0&&"Clean"in X.body&&!e2(X.body))M+=`c.body=validator.body.Clean(c.body)
178
+ `;let j=y2(X.body.schema);if(j||C1(X.body))M+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&isNotEmpty(c.body))
179
+ `;if(D6("default",X.body)){let R=X.body.schema,b=o.Default(R,R.type==="object"||R[m6.kind]==="Import"&&R.$defs[R.$ref][m6.kind]==="Object"?{}:void 0),c=typeof b==="object"?JSON.stringify(b):typeof b==="string"?`'${b}'`:b;if(M+="if(validator.body.Check(c.body)===false){",b!==void 0&&b!==null)M+=`if(typeof c.body==='object')c.body=Object.assign(${c},c.body)
180
+ else c.body=${c}
181
+ `;if(C1(X.body))M+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+h0("body")+"}";else M+="if(validator.body.Check(c.body)===false){"+h0("body")+"}";M+="}"}else if(C1(X.body))M+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+h0("body")+"}";else M+="if(validator.body.Check(c.body)===false){"+h0("body")+"}";if(j)M+=`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)
182
+ `}if(T&&w1(T?.schema?.properties??T?.schema?.schema??{})){if(M+=`const cookieValue={}
176
183
  for(const [key,value] of Object.entries(c.cookie))cookieValue[key]=value.value
177
- `,U6("default",i))for(let[j,O]of Object.entries(p.Default(i.schema,{})))J+=`cookieValue['${j}'] = ${typeof O==="object"?JSON.stringify(O):O}
178
- `;if(Y1(X.cookie))J+="if(isNotEmpty(c.cookie)){";if(J+="if(validator.cookie.Check(cookieValue)===false){"+l("cookie","cookieValue")+"}",O6(X.cookie.schema))J+=`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))c.cookie[key].value=value
179
- `;if(Y1(X.cookie))J+="}"}}if(A?.beforeHandle){let j=C0("beforeHandle",{total:A.beforeHandle.length}),O=!1;for(let b=0;b<A.beforeHandle.length;b++){let T=A.beforeHandle[b],t=j.resolveChild(T.fn.name),e=T4(T);if(T.subType==="resolve"||T.subType==="mapResolve"){if(!O)O=!0,J+=`
184
+ `,D6("default",T))for(let[j,R]of Object.entries(o.Default(T.schema,{})))M+=`cookieValue['${j}'] = ${typeof R==="object"?JSON.stringify(R):R}
185
+ `;if(C1(X.cookie))M+="if(isNotEmpty(c.cookie)){";if(M+="if(validator.cookie.Check(cookieValue)===false){"+h0("cookie","cookieValue")+"}",y2(X.cookie.schema))M+=`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))c.cookie[key].value=value
186
+ `;if(C1(X.cookie))M+="}"}}if(W?.beforeHandle){let j=n0("beforeHandle",{total:W.beforeHandle.length}),R=!1;for(let b=0;b<W.beforeHandle.length;b++){let c=W.beforeHandle[b],t=j.resolveChild(c.fn.name),B=w8(c);if(c.subType==="resolve"||c.subType==="mapResolve"){if(!R)R=!0,M+=`
180
187
  let resolved
181
- `;if(J+=a0(T)?`resolved=await beforeHandle[${b}](c);
182
- `:`resolved=beforeHandle[${b}](c);
183
- `,T.subType==="mapResolve")J+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
188
+ `;if(M+=e0(c)?`resolved=await e.beforeHandle[${b}](c);
189
+ `:`resolved=e.beforeHandle[${b}](c);
190
+ `,c.subType==="mapResolve")M+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
184
191
  else{resolved.request = c.request
185
192
  resolved.store = c.store
186
193
  resolved.qi = c.qi
@@ -189,135 +196,135 @@ resolved.url = c.url
189
196
  resolved.redirect = c.redirect
190
197
  resolved.set = c.set
191
198
  resolved.error = c.error
192
- c = resolved}`;else J+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
199
+ c = resolved}`;else M+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
193
200
  else Object.assign(c, resolved)
194
- `}else if(!e)J+=a0(T)?`await beforeHandle[${b}](c)
195
- `:`beforeHandle[${b}](c)
196
- `,t();else{if(J+=a0(T)?`be=await beforeHandle[${b}](c)
197
- `:`be=beforeHandle[${b}](c)
198
- `,t("be"),J+="if(be!==undefined){",j.resolve(),A.afterHandle?.length){C0("handle",{name:_?Z.name:void 0}).resolve();let M=C0("afterHandle",{total:A.afterHandle.length});for(let C=0;C<A.afterHandle.length;C++){let L=A.afterHandle[C],u=T4(L),V=M.resolveChild(L.fn.name);if(J+=`c.response = be
199
- `,!u)J+=a0(L.fn)?`await afterHandle[${C}](c, be)
200
- `:`afterHandle[${C}](c, be)
201
- `;else J+=a0(L.fn)?`af = await afterHandle[${C}](c)
202
- `:`af = afterHandle[${C}](c)
203
- `,J+=`if(af!==undefined) c.response=be=af
204
- `;V("af")}M.resolve()}if(X.response)J+=O1("be");let K0=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length){J+=`c.response=be
205
- `;for(let M=0;M<A.mapResponse.length;M++){let C=A.mapResponse[M],L=K0.resolveChild(C.fn.name);J+=`if(mr===undefined){mr=${e6(C)?"await":""} onMapResponse[${M}](c)
206
- if(mr!==undefined)be=c.response=mr}`,L()}}K0.resolve(),J+=o,J+=`return mapEarlyResponse(${I2}be,c.set${o0})}
207
- `}}j.resolve()}if(A?.afterHandle.length){let j=C0("handle",{name:_?Z.name:void 0});if(A.afterHandle.length)J+=n1?`let r=c.response=await ${H}
208
- `:`let r=c.response=${H}
209
- `;else J+=n1?`let r=await ${H}
210
- `:`let r=${H}
211
- `;j.resolve();let O=C0("afterHandle",{total:A.afterHandle.length});for(let T=0;T<A.afterHandle.length;T++){let t=A.afterHandle[T],e=T4(t),K0=O.resolveChild(t.fn.name);if(!e)J+=a0(t.fn)?`await afterHandle[${T}](c)
212
- `:`afterHandle[${T}](c)
213
- `,K0();else if(J+=a0(t.fn)?`af=await afterHandle[${T}](c)
214
- `:`af=afterHandle[${T}](c)
215
- `,K0("af"),X.response)J+="if(af!==undefined){",O.resolve(),J+=O1("af"),J+="c.response=af}";else J+="if(af!==undefined){",O.resolve(),J+="c.response=af}"}if(O.resolve(),J+=`r=c.response
216
- `,X.response)J+=O1();J+=o;let b=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length)for(let T=0;T<A.mapResponse.length;T++){let t=A.mapResponse[T],e=b.resolveChild(t.fn.name);J+=`mr=${e6(t)?"await":""} onMapResponse[${T}](c)
201
+ `}else if(!B)M+=e0(c)?`await e.beforeHandle[${b}](c)
202
+ `:`e.beforeHandle[${b}](c)
203
+ `,t();else{if(M+=e0(c)?`be=await e.beforeHandle[${b}](c)
204
+ `:`be=e.beforeHandle[${b}](c)
205
+ `,t("be"),M+="if(be!==undefined){",j.resolve(),W.afterHandle?.length){n0("handle",{name:N?A.name:void 0}).resolve();let L=n0("afterHandle",{total:W.afterHandle.length});for(let d=0;d<W.afterHandle.length;d++){let x=W.afterHandle[d],h=w8(x),b0=L.resolveChild(x.fn.name);if(M+=`c.response = be
206
+ `,!h)M+=e0(x.fn)?`await e.afterHandle[${d}](c, be)
207
+ `:`e.afterHandle[${d}](c, be)
208
+ `;else M+=e0(x.fn)?`af = await e.afterHandle[${d}](c)
209
+ `:`af = e.afterHandle[${d}](c)
210
+ `,M+=`if(af!==undefined) c.response=be=af
211
+ `;b0("af")}L.resolve()}if(X.response)M+=U6("be");let K=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length){M+=`c.response=be
212
+ `;for(let L=0;L<W.mapResponse.length;L++){let d=W.mapResponse[L],x=K.resolveChild(d.fn.name);M+=`if(mr===undefined){mr=${O4(d)?"await ":""}e.mapResponse[${L}](c)
213
+ if(mr!==undefined)be=c.response=mr}`,x()}}K.resolve(),M+=a,M+=`return mapEarlyResponse(${I2}be,c.set${S0})}
214
+ `}}j.resolve()}if(W.afterHandle?.length){let j=n0("handle",{name:N?A.name:void 0});if(W.afterHandle.length)M+=W6?`let r=c.response=await ${S}
215
+ `:`let r=c.response=${S}
216
+ `;else M+=W6?`let r=await ${S}
217
+ `:`let r=${S}
218
+ `;j.resolve();let R=n0("afterHandle",{total:W.afterHandle.length});for(let c=0;c<W.afterHandle.length;c++){let t=W.afterHandle[c],B=w8(t),K=R.resolveChild(t.fn.name);if(!B)M+=e0(t.fn)?`await e.afterHandle[${c}](c)
219
+ `:`e.afterHandle[${c}](c)
220
+ `,K();else if(M+=e0(t.fn)?`af=await e.afterHandle[${c}](c)
221
+ `:`af=e.afterHandle[${c}](c)
222
+ `,K("af"),X.response)M+="if(af!==undefined){",R.resolve(),M+=U6("af"),M+="c.response=af}";else M+="if(af!==undefined){",R.resolve(),M+="c.response=af}"}if(R.resolve(),M+=`r=c.response
223
+ `,X.response)M+=U6();M+=a;let b=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length)for(let c=0;c<W.mapResponse.length;c++){let t=W.mapResponse[c],B=b.resolveChild(t.fn.name);M+=`mr=${O4(t)?"await ":""}e.mapResponse[${c}](c)
217
224
  if(mr!==undefined)r=c.response=mr
218
- `,e()}if(b.resolve(),K6)J+=`return mapResponse(${I2}r,c.set${o0})
219
- `;else J+=`return mapCompactResponse(${I2}r${o0})
220
- `}else{let j=C0("handle",{name:_?Z.name:void 0});if(X.response||A.mapResponse.length){if(J+=n1?`let r=await ${H}
221
- `:`let r=${H}
222
- `,j.resolve(),X.response)J+=O1();C0("afterHandle").resolve();let O=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length){J+=`
225
+ `,B()}if(b.resolve(),W1)M+=`return mapResponse(${I2}r,c.set${S0})
226
+ `;else M+=`return mapCompactResponse(${I2}r${S0})
227
+ `}else{let j=n0("handle",{name:N?A.name:void 0});if(X.response||W.mapResponse?.length){if(M+=W6?`let r=await ${S}
228
+ `:`let r=${S}
229
+ `,j.resolve(),X.response)M+=U6();n0("afterHandle").resolve();let R=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length){M+=`
223
230
  c.response=r
224
- `;for(let b=0;b<A.mapResponse.length;b++){let T=A.mapResponse[b],t=O.resolveChild(T.fn.name);J+=`
225
- if(mr===undefined){mr=${e6(T)?"await ":""}onMapResponse[${b}](c)
231
+ `;for(let b=0;b<W.mapResponse.length;b++){let c=W.mapResponse[b],t=R.resolveChild(c.fn.name);M+=`
232
+ if(mr===undefined){mr=${O4(c)?"await ":""}e.mapResponse[${b}](c)
226
233
  if(mr!==undefined)r=c.response=mr}
227
- `,t()}}if(O.resolve(),J+=o,Z instanceof Response)J+=Q.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${H}.clone(),c.set${o0})else return ${H}.clone()`:`return ${H}.clone()`,J+=`
228
- `;else if(K6)J+=`return mapResponse(${I2}r,c.set${o0})
229
- `;else J+=`return mapCompactResponse(${I2}r${o0})
230
- `}else if(x||R){J+=n1?`let r=await ${H}
231
- `:`let r=${H}
232
- `,j.resolve(),C0("afterHandle").resolve();let O=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length){J+=`c.response= r
233
- `;for(let b=0;b<A.mapResponse.length;b++){let T=A.mapResponse[b],t=O.resolveChild(T.fn.name);J+=`if(mr===undefined){mr=${e6(T)?"await ":""}onMapResponse[${b}](c)
234
- if(mr!==undefined)r=c.response=mr}`,t()}}if(O.resolve(),J+=o,K6)J+=`return mapResponse(${I2}r,c.set${o0})
235
- `;else J+=`return mapCompactResponse(${I2}r${o0})
236
- `}else{j.resolve();let O=n1?`await ${H}`:H;if(C0("afterHandle").resolve(),Z instanceof Response)J+=Q.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${H}.clone(),c.set${o0})
237
- else return ${H}.clone()
238
- `:`return ${H}.clone()
239
- `;else if(K6)J+=`return mapResponse(${I2}${O},c.set${o0})
240
- `;else J+=`return mapCompactResponse(${I2}${O}${o0})
241
- `}}if(J+=`
242
- }catch(error){`,A0)J+=`if(isParsing)error=new ParseError()
243
- `;if(!Y6)J+="return(async()=>{";if(J+=`const set=c.set
234
+ `,t()}}if(R.resolve(),M+=a,A instanceof Response)M+=$.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${S}.clone(),c.set${S0})else return ${S}.clone()`:`return ${S}.clone()`,M+=`
235
+ `;else if(W1)M+=`return mapResponse(${I2}r,c.set${S0})
236
+ `;else M+=`return mapCompactResponse(${I2}r${S0})
237
+ `}else if(E||O){M+=W6?`let r=await ${S}
238
+ `:`let r=${S}
239
+ `,j.resolve(),n0("afterHandle").resolve();let R=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length){M+=`c.response= r
240
+ `;for(let b=0;b<W.mapResponse.length;b++){let c=W.mapResponse[b],t=R.resolveChild(c.fn.name);M+=`if(mr===undefined){mr=${O4(c)?"await ":""}e.mapResponse[${b}](c)
241
+ if(mr!==undefined)r=c.response=mr}`,t()}}if(R.resolve(),M+=a,W1)M+=`return mapResponse(${I2}r,c.set${S0})
242
+ `;else M+=`return mapCompactResponse(${I2}r${S0})
243
+ `}else{j.resolve();let R=W6?`await ${S}`:S;if(n0("afterHandle").resolve(),A instanceof Response)M+=$.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${S}.clone(),c.set${S0})
244
+ else return ${S}.clone()
245
+ `:`return ${S}.clone()
246
+ `;else if(W1)M+=`return mapResponse(${I2}${R},c.set${S0})
247
+ `;else M+=`return mapCompactResponse(${I2}${R}${S0})
248
+ `}}if(M+=`
249
+ }catch(error){`,w0)M+=`if(isParsing)error=new ParseError()
250
+ `;if(!b6)M+="return(async()=>{";if(M+=`const set=c.set
244
251
  if(!set.status||set.status<300)set.status=error?.status||500
245
- `,R)for(let j=0;j<A.trace.length;j++)J+=`report${j}?.resolve(error);reportChild${j}?.(error)
246
- `;let q2=C0("error",{total:A.error.length});if(A.error.length){J+=`c.error=error
247
- if(error instanceof TypeBoxError){c.code="VALIDATION"
248
- c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}let er
249
- `;for(let j=0;j<A.error.length;j++){let O=q2.resolveChild(A.error[j].fn.name);if(a0(A.error[j]))J+=`er=await handleErrors[${j}](c)
250
- `;else J+=`er=handleErrors[${j}](c)
252
+ `,O&&W.trace)for(let j=0;j<W.trace.length;j++)M+=`report${j}?.resolve(error);reportChild${j}?.(error)
253
+ `;let X6=n0("error",{total:W.error?.length});if(W.error?.length){if(M+=`c.error=error
254
+ `,C)M+=`if(error instanceof TypeBoxError){c.code="VALIDATION"
255
+ c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}`;else M+=`c.code=error.code??error[ERROR_CODE]??"UNKNOWN"
256
+ `;M+=`let er
257
+ `;for(let j=0;j<W.error.length;j++){let R=X6.resolveChild(W.error[j].fn.name);if(e0(W.error[j]))M+=`er=await e.error[${j}](c)
258
+ `;else M+=`er=e.error[${j}](c)
251
259
  if(er instanceof Promise)er=await er
252
- `;O();let b=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length)for(let T=0;T<A.mapResponse.length;T++){let t=A.mapResponse[T],e=b.resolveChild(t.fn.name);J+=`c.response=er
253
- er=onMapResponse[${T}](c)
260
+ `;R();let b=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length)for(let c=0;c<W.mapResponse.length;c++){let t=W.mapResponse[c],B=b.resolveChild(t.fn.name);M+=`c.response=er
261
+ er=e.mapResponse[${c}](c)
254
262
  if(er instanceof Promise)er=await er
255
- `,e()}if(b.resolve(),J+=`er=mapEarlyResponse(er,set${o0})
256
- `,J+="if(er){",R){for(let T=0;T<A.trace.length;T++)J+=`report${T}.resolve()
257
- `;q2.resolve()}J+="return er}"}}if(q2.resolve(),J+="return handleError(c,error,true)",!Y6)J+="})()";if(J+="}",F||R){if(J+="finally{ ",!Y6)J+=";(async()=>{";let j=C0("afterResponse",{total:A.afterResponse.length});if(F)for(let O=0;O<A.afterResponse.length;O++){let b=j.resolveChild(A.afterResponse[O].fn.name);J+=`
258
- await afterResponse[${O}](c)
259
- `,b()}if(j.resolve(),!Y6)J+="})()";J+="}"}let x2="const {handler,handleError,hooks: {transform,resolve,beforeHandle,afterHandle,mapResponse: onMapResponse,parse,error: handleErrors,afterResponse,trace: _trace},validator,utils: {mapResponse,mapCompactResponse,mapEarlyResponse,parseQuery,parseQueryFromURL,isNotEmpty},error: {NotFoundError,ValidationError,InternalServerError,ParseError},schema,definitions,ERROR_CODE,parseCookie,signCookie,decodeURIComponent,ElysiaCustomStatusResponse,ELYSIA_TRACE,ELYSIA_REQUEST_ID,parser,getServer,"+(B.inject?Object.keys(B.inject).join(",")+",":"")+`TypeBoxError}=hooks
260
- const trace=_trace.map(x=>typeof x==='function'?x:x.fn)
261
- return ${Y6?"async ":""}function handle(c){`;if(A.beforeHandle.length)x2+=`let be
262
- `;if(A.afterHandle.length)x2+=`let af
263
- `;if(A.mapResponse.length)x2+=`let mr
264
- `;if($)x2+=`c.schema = schema
263
+ `,B()}if(b.resolve(),M+=`er=mapEarlyResponse(er,set${S0})
264
+ `,M+="if(er){",O&&W.trace){for(let c=0;c<W.trace.length;c++)M+=`report${c}.resolve()
265
+ `;X6.resolve()}M+="return er}"}}if(X6.resolve(),M+="return handleError(c,error,true)",!b6)M+="})()";if(M+="}",G||O){if(M+="finally{ ",!b6)M+=";(async()=>{";let j=n0("afterResponse",{total:W.afterResponse?.length});if(G&&W.afterResponse)for(let R=0;R<W.afterResponse.length;R++){let b=j.resolveChild(W.afterResponse[R].fn.name);M+=`
266
+ await e.afterResponse[${R}](c)
267
+ `,b()}if(j.resolve(),!b6)M+="})()";M+="}"}let A6=Q.inject?Object.keys(Q.inject).join(",")+",":"",X1="const {handler,handleError,hooks:e, "+Y2("validator,",C)+"mapResponse,mapCompactResponse,mapEarlyResponse,isNotEmpty,utils:{"+Y2("parseQuery,",w0)+Y2("parseQueryFromURL,",k)+"},error:{"+Y2("ValidationError,",C)+"InternalServerError,"+Y2("ParseError",w0)+"},schema,definitions,ERROR_CODE,"+Y2("parseCookie,",E)+Y2("signCookie,",E)+Y2("decodeURIComponent,",k)+"ElysiaCustomStatusResponse,"+Y2("ELYSIA_TRACE,",O)+Y2("ELYSIA_REQUEST_ID,",O)+Y2("parser,",W.parse?.length)+Y2("getServer,",$.server)+A6+Y2("TypeBoxError",C)+`}=hooks
268
+ const trace=e.trace?.map(x=>typeof x==='function'?x:x.fn)??[]
269
+ return ${b6?"async ":""}function handle(c){`;if(W.beforeHandle?.length)X1+=`let be
270
+ `;if(W.afterHandle?.length)X1+=`let af
271
+ `;if(W.mapResponse?.length)X1+=`let mr
272
+ `;if(Z)X1+=`c.schema = schema
265
273
  c.defs = definitions
266
- `;x2+=J+"}";try{if(Y)return Function("hooks",x2);return Function("hooks",x2)({handler:Z,hooks:DU(A),validator:X,handleError:w.handleError,utils:{mapResponse:G.mapResponse,mapCompactResponse:G.mapCompactResponse,mapEarlyResponse:G.mapEarlyResponse,parseQuery:x8,parseQueryFromURL:TH,isNotEmpty:s2},error:{NotFoundError:h8,ValidationError:Z0,InternalServerError:fU,ParseError:dU},schema:w.router.history,definitions:w.definitions.type,ERROR_CODE:k8,parseCookie:tU,signCookie:V8,decodeURIComponent:sU.default,ElysiaCustomStatusResponse:M1,ELYSIA_TRACE:vw,ELYSIA_REQUEST_ID:d8,getServer:()=>w.getServer(),TypeBoxError:y,parser:w["~parser"],...B.inject})}catch(j){let O=DU(A);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof Z==="function"?Z.toString():Z,instruction:x2,hooks:{...O,transform:O?.transform?.map?.((b)=>b.toString()),resolve:O?.resolve?.map?.((b)=>b.toString()),beforeHandle:O?.beforeHandle?.map?.((b)=>b.toString()),afterHandle:O?.afterHandle?.map?.((b)=>b.toString()),mapResponse:O?.mapResponse?.map?.((b)=>b.toString()),parse:O?.parse?.map?.((b)=>b.toString()),error:O?.error?.map?.((b)=>b.toString()),afterResponse:O?.afterResponse?.map?.((b)=>b.toString()),stop:O?.stop?.map?.((b)=>b.toString())},validator:X,definitions:w.definitions.type,error:j,fnLiteral:J}),console.log("---"),process.exit(1)}},Tw=(w,{asManifest:z=!1}={})=>{let U=w["~adapter"].composeGeneralHandler,W=U.error404(!!w.event.request.length,!!w.event.error.length),A="",X=w.router,Z="const route=router.find(r.method,p)";Z+=X.http.root.ALL?`??router.find("ALL",p)
274
+ `;X1+=M+"}";try{if(Y)return Function("hooks",X1);return Function("hooks",X1)({handler:A,hooks:CW(W),validator:C?X:void 0,handleError:z.handleError,mapResponse:J.mapResponse,mapCompactResponse:J.mapCompactResponse,mapEarlyResponse:J.mapEarlyResponse,isNotEmpty:w1,utils:{parseQuery:w0?v5:void 0,parseQueryFromURL:k?KG:void 0},error:{ValidationError:C?r:void 0,InternalServerError:vW,ParseError:w0?nW:void 0},schema:z.router.history,definitions:z.definitions.type,ERROR_CODE:m5,parseCookie:E?eW:void 0,signCookie:E?u5:void 0,decodeURIComponent:k?P6:void 0,ElysiaCustomStatusResponse:K1,ELYSIA_TRACE:O?Jw:void 0,ELYSIA_REQUEST_ID:O?l5:void 0,getServer:()=>z.getServer(),TypeBoxError:C?n:void 0,parser:z["~parser"],...Q.inject})}catch(j){let R=CW(W);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof A==="function"?A.toString():A,instruction:X1,hooks:{...R,transform:R?.transform?.map?.((b)=>b.toString()),resolve:R?.resolve?.map?.((b)=>b.toString()),beforeHandle:R?.beforeHandle?.map?.((b)=>b.toString()),afterHandle:R?.afterHandle?.map?.((b)=>b.toString()),mapResponse:R?.mapResponse?.map?.((b)=>b.toString()),parse:R?.parse?.map?.((b)=>b.toString()),error:R?.error?.map?.((b)=>b.toString()),afterResponse:R?.afterResponse?.map?.((b)=>b.toString()),stop:R?.stop?.map?.((b)=>b.toString())},validator:X,definitions:z.definitions.type,error:j,fnLiteral:M}),console.log("---"),process.exit(1)}},ww=(z,{asManifest:w=!1}={})=>{let U=z["~adapter"].composeGeneralHandler;z.router.http.build();let W=U.error404(!!z.event.request?.length,!!z.event.error?.length),X=z.event.trace?.length,A="",Z=z.router,$="const route=router.find(r.method,p)";$+=Z.http.root.ALL?`??router.find("ALL",p)
267
275
  `:`
268
- `,Z+=W.code,Z+=`
276
+ `,$+=W.code,$+=`
269
277
  c.params=route.params
270
278
  if(route.store.handler)return route.store.handler(c)
271
279
  return (route.store.handler=route.store.compile())(c)
272
- `;let $="";for(let[_,{code:H,all:F}]of Object.entries(X.static.http.map)){if($+=`case'${_}':`,w.config.strictPath!==!0)$+=`case'${r6(_)}':`;$+=`switch(r.method){${H}
273
- `+(F??"default: break map")+"}"}let Q=w.event.request.some(a0),Y=U.inject?Object.keys(U.inject).join(",")+",":"";if(A+=`
274
- const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,ELYSIA_TRACE,ELYSIA_REQUEST_ID,`+Y+`getServer}=data
280
+ `;let Y="";for(let[G,O]of Object.entries(Z.static.http.map)){if(Y+=`case'${G}':`,z.config.strictPath!==!0)Y+=`case'${D4(G)}':`;let M=a4(G);if(G!==M)Y+=`case'${M}':`;Y+=`switch(r.method){${O.code}
281
+ `+(O.all??"default: break map")+"}"}let Q=!!z.event.request?.some(e0),J=U.inject?Object.keys(U.inject).join(",")+",":"";if(A+=`
282
+ const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,`+Y2("ELYSIA_TRACE,",X)+Y2("ELYSIA_REQUEST_ID,",X)+J+`}=data
275
283
  const store=app.singleton.store
276
284
  const decorator=app.singleton.decorator
277
285
  const staticRouter=app.router.static.http
278
286
  const ht=app.router.history
279
- const wsRouter=app.router.ws
280
287
  const router=app.router.http
281
- const trace=app.event.trace.map(x=>typeof x==='function'?x:x.fn)
288
+ const trace=app.event.trace?.map(x=>typeof x==='function'?x:x.fn)??[]
282
289
  const notFound=new NotFoundError()
283
290
  const hoc=app.extender.higherOrderFunctions.map(x=>x.fn)
284
- `,w.event.request.length)A+=`const onRequest=app.event.request.map(x=>x.fn)
285
- `;if(A+=W.declare,w.event.trace.length)A+="const "+w.event.trace.map((_,H)=>`tr${H}=app.event.trace[${H}].fn`).join(",")+`
286
- `;if(A+=`${Q?"async ":""}function map(${U.parameters}){`,w.event.request.length)A+=`let re
287
- `;if(A+=U.createContext(w),w.event.trace.length)A+="c[ELYSIA_TRACE]=["+w.event.trace.map((_,H)=>`tr${H}(c)`).join(",")+`]
288
- `;let B=nw({trace:w.event.trace,addFn(_){A+=_}})("request",{total:w.event.request.length});if(w.event.request.length){A+="try{";for(let _=0;_<w.event.request.length;_++){let H=w.event.request[_],F=T4(H),R=a0(H),J=B.resolveChild(w.event.request[_].fn.name);if(F)A+=`re=mapEarlyResponse(${R?"await ":""}onRequest[${_}](c),c.set)
289
- `,J("re"),A+=`if(re!==undefined)return re
290
- `;else A+=`${R?"await ":""}onRequest[${_}](c)
291
- `,J()}A+="}catch(error){return app.handleError(c,error,false)}"}if(B.resolve(),A+=U.websocket(w),A+=`
291
+ `,z.event.request?.length)A+=`const onRequest=app.event.request.map(x=>x.fn)
292
+ `;if(A+=W.declare,z.event.trace?.length)A+="const "+z.event.trace.map((G,O)=>`tr${O}=app.event.trace[${O}].fn`).join(",")+`
293
+ `;if(A+=`${Q?"async ":""}function map(${U.parameters}){`,z.event.request?.length)A+=`let re
294
+ `;if(A+=U.createContext(z),z.event.trace?.length)A+="c[ELYSIA_TRACE]=["+z.event.trace.map((G,O)=>`tr${O}(c)`).join(",")+`]
295
+ `;let N=Bw({trace:z.event.trace,addFn(G){A+=G}})("request",{total:z.event.request?.length});if(z.event.request?.length){A+="try{";for(let G=0;G<z.event.request.length;G++){let O=z.event.request[G],M=w8(O),C=e0(O),k=N.resolveChild(z.event.request[G].fn.name);if(M)A+=`re=mapEarlyResponse(${C?"await ":""}onRequest[${G}](c),c.set)
296
+ `,k("re"),A+=`if(re!==undefined)return re
297
+ `;else A+=`${C?"await ":""}onRequest[${G}](c)
298
+ `,k()}A+="}catch(error){return app.handleError(c,error,false)}"}if(N.resolve(),A+=U.websocket(z),A+=`
292
299
  map:switch(p){
293
- `+$+"default:break}"+Z+`}
294
- `,w.extender.higherOrderFunctions.length){let _="map";for(let H=0;H<w.extender.higherOrderFunctions.length;H++)_=`hoc[${H}](${_},${U.parameters})`;A+=`return function hocMap(${U.parameters}){return ${_}(${U.parameters})}`}else A+="return map";let G=rU(w);return w.handleError=G,Function("data",A)({app:w,mapEarlyResponse:w["~adapter"].handler.mapEarlyResponse,NotFoundError:h8,randomId:gU,handleError:G,error:LH,redirect:TU,ELYSIA_TRACE:vw,ELYSIA_REQUEST_ID:d8,getServer:()=>w.getServer(),...U.inject})},rU=(w)=>{let z=w.event,U="",W=w["~adapter"].composeError,A=W.inject?Object.keys(W.inject).join(",")+",":"";U+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,ELYSIA_TRACE,"+A+`ELYSIA_REQUEST_ID}=inject
295
- `,U+=`const trace=_trace.map(x=>typeof x==='function'?x:x.fn)
300
+ `+Y+"default:break}"+$+`}
301
+ `,z.extender.higherOrderFunctions.length){let G="map";for(let O=0;O<z.extender.higherOrderFunctions.length;O++)G=`hoc[${O}](${G},${U.parameters})`;A+=`return function hocMap(${U.parameters}){return ${G}(${U.parameters})}`}else A+="return map";let S=WX(z);return z.handleError=S,Function("data",A)({app:z,mapEarlyResponse:z["~adapter"].handler.mapEarlyResponse,NotFoundError:Qw,randomId:iW,handleError:S,error:yW,redirect:cW,ELYSIA_TRACE:X?Jw:void 0,ELYSIA_REQUEST_ID:X?l5:void 0,...U.inject})},WX=(z)=>{let w=z.event,U="",W=z["~adapter"].composeError,X=W.inject?Object.keys(W.inject).join(",")+",":"",A=!!z.event.trace?.length;if(U+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,"+Y2("ELYSIA_TRACE,",A)+Y2("ELYSIA_REQUEST_ID,",A)+X+`}=inject
302
+ `,U+=`const trace=_trace?.map(x=>typeof x==='function'?x:x.fn)??[]
296
303
  const onMapResponse=[]
297
- for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i])
304
+ if(_onMapResponse)for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i])
298
305
  delete _onMapResponse
299
- const onError=onErrorContainer.map(x=>x.fn)
300
- const res=resContainer.map(x=>x.fn)
301
- return ${w.event.error.find(a0)||w.event.mapResponse.find(a0)?"async ":""}function(context,error,skipGlobal){`;let X=w.event.trace.length>0;if(U+="",X)U+=`const id=context[ELYSIA_REQUEST_ID]
302
- `;let Z=nw({context:"context",trace:z.trace,addFn:(Y)=>{U+=Y}});if(U+=`const set=context.set
306
+ const onError=onErrorContainer?.map(x=>x.fn)??[]
307
+ const res=resContainer?.map(x=>x.fn)??[]
308
+ return ${z.event.error?.find(e0)||z.event.mapResponse?.find(e0)?"async ":""}function(context,error,skipGlobal){`,U+="",A)U+=`const id=context[ELYSIA_REQUEST_ID]
309
+ `;let Z=Bw({context:"context",trace:w.trace,addFn:(Q)=>{U+=Q}});if(U+=`const set=context.set
303
310
  let _r
304
311
  if(!context.code)context.code=error.code??error[ERROR_CODE]
305
312
  if(!(context.error instanceof Error))context.error=error
306
313
  if(error instanceof ElysiaCustomStatusResponse){set.status=error.status=error.code
307
- error.message=error.response}`,W.declare)U+=W.declare;let $=X||z.afterResponse.length>0||z.afterResponse.length>0?"context.response = ":"";for(let Y=0;Y<w.event.error.length;Y++){let B=w.event.error[Y],G=`${a0(B)?"await ":""}onError[${Y}](context)
308
- `;if(U+="if(skipGlobal!==true){",T4(B)){U+=`_r=${G}
314
+ error.message=error.response}`,W.declare)U+=W.declare;let $=A||!!w.afterResponse?.length||!!w.afterResponse?.length?"context.response = ":"";if(z.event.error)for(let Q=0;Q<z.event.error.length;Q++){let J=z.event.error[Q],N=`${e0(J)?"await ":""}onError[${Q}](context)
315
+ `;if(U+="if(skipGlobal!==true){",w8(J)){U+=`_r=${N}
309
316
  if(_r!==undefined){if(_r instanceof Response)return mapResponse(_r,set${W.mapResponseContext})
310
317
  if(_r instanceof ElysiaCustomStatusResponse){error.status=error.code
311
318
  error.message = error.response}if(set.status===200||!set.status)set.status=error.status
312
- `;let _=Z("mapResponse",{total:z.mapResponse.length,name:"context"});if(z.mapResponse.length)for(let H=0;H<z.mapResponse.length;H++){let F=z.mapResponse[H],R=_.resolveChild(F.fn.name);U+=`context.response=_r_r=${e6(F)?"await ":""}onMapResponse[${H}](context)
313
- `,R()}_.resolve(),U+=`return mapResponse(${$}_r,set${W.mapResponseContext})}`}else U+=G;U+="}"}U+=`if(error.constructor.name==="ValidationError"||error.constructor.name==="TransformDecodeError"){if(error.error)error=error.error
319
+ `;let S=Z("mapResponse",{total:w.mapResponse?.length,name:"context"});if(w.mapResponse?.length)for(let G=0;G<w.mapResponse.length;G++){let O=w.mapResponse[G],M=S.resolveChild(O.fn.name);U+=`context.response=_r_r=${O4(O)?"await ":""}onMapResponse[${G}](context)
320
+ `,M()}S.resolve(),U+=`return mapResponse(${$}_r,set${W.mapResponseContext})}`}else U+=N;U+="}"}U+=`if(error.constructor.name==="ValidationError"||error.constructor.name==="TransformDecodeError"){if(error.error)error=error.error
314
321
  set.status=error.status??422
315
- `+W.validationError+"}",U+="if(error instanceof Error){"+W.unknownError+"}";let Q=Z("mapResponse",{total:z.mapResponse.length,name:"context"});if(U+=`
322
+ `+W.validationError+"}",U+="if(error instanceof Error){"+W.unknownError+"}";let Y=Z("mapResponse",{total:w.mapResponse?.length,name:"context"});if(U+=`
316
323
  if(!context.response)context.response=error.message??error
317
- `,z.mapResponse.length){U+=`let mr
318
- `;for(let Y=0;Y<z.mapResponse.length;Y++){let B=z.mapResponse[Y],G=Q.resolveChild(B.fn.name);U+=`if(mr===undefined){mr=${e6(B)?"await ":""}onMapResponse[${Y}](context)
319
- if(mr!==undefined)error=context.response=mr}`,G()}}return Q.resolve(),U+=`
320
- return mapResponse(${$}error,set${W.mapResponseContext})}`,Function("inject",U)({app:w,mapResponse:w["~adapter"].handler.mapResponse,ERROR_CODE:k8,ElysiaCustomStatusResponse:M1,ELYSIA_TRACE:vw,ELYSIA_REQUEST_ID:d8,...W.inject})},gw=(w,z)=>{for(let[U,W]of Object.entries(w.schema.properties))z[U]??=W.default},jU=(w)=>{let{mapResponse:z,mapEarlyResponse:U}=w["~adapter"].handler;return async(W)=>{let A=W.url,X=A.indexOf("/",11),Z=A.indexOf("?",X+1),$=Z===-1?A.substring(X):A.substring(X,Z),Q={cookie:{},status:200,headers:{}},Y=Object.assign({},w.singleton.decorator,{set:Q,store:w.singleton.store,request:W,path:$,qi:Z,redirect:TU});try{for(let x=0;x<w.event.request.length;x++){let i=w.event.request[x].fn,K=i(Y);if(K instanceof Promise)K=await K;if(K=U(K,Q),K)return Y.response=K}let B=w.router.dynamic.find(W.method,$)??w.router.dynamic.find("ALL",$);if(!B)throw new h8;let{handle:G,hooks:_,validator:H,content:F}=B.store,R;if(W.method!=="GET"&&W.method!=="HEAD")if(F)switch(F){case"application/json":R=await W.json();break;case"text/plain":R=await W.text();break;case"application/x-www-form-urlencoded":R=x8(await W.text());break;case"application/octet-stream":R=await W.arrayBuffer();break;case"multipart/form-data":R={};let x=await W.formData();for(let i of x.keys()){if(R[i])continue;let K=x.getAll(i);if(K.length===1)R[i]=K[0];else R[i]=K}break}else{let x=W.headers.get("content-type");if(x){let i=x.indexOf(";");if(i!==-1)x=x.slice(0,i);Y.contentType=x;for(let K=0;K<_.parse.length;K++){let o=_.parse[K].fn,D0=o(Y,x);if(D0 instanceof Promise)D0=await D0;if(D0){R=D0;break}}if(delete Y.contentType,R===void 0)switch(x){case"application/json":R=await W.json();break;case"text/plain":R=await W.text();break;case"application/x-www-form-urlencoded":R=x8(await W.text());break;case"application/octet-stream":R=await W.arrayBuffer();break;case"multipart/form-data":R={};let K=await W.formData();for(let o of K.keys()){if(R[o])continue;let D0=K.getAll(o);if(D0.length===1)R[o]=D0[0];else R[o]=D0}break}}}Y.body=R,Y.params=B?.params||void 0,Y.query=Z===-1?{}:x8(A.substring(Z+1)),Y.headers={};for(let[x,i]of W.headers.entries())Y.headers[x]=i;let J=Object.assign({},w.config?.cookie,H?.cookie?.config),m=W.headers.get("cookie");Y.cookie=await tU(Y.set,m,J?{secrets:J.secrets!==void 0?typeof J.secrets==="string"?J.secrets:J.secrets.join(","):void 0,sign:J.sign===!0?!0:J.sign!==void 0?typeof J.sign==="string"?J.sign:J.sign.join(","):void 0}:void 0);let A0=H?.createHeaders?.();if(A0)gw(A0,Y.headers);let L0=H?.createParams?.();if(L0)gw(L0,Y.params);let h=H?.createQuery?.();if(h)gw(h,Y.query);for(let x=0;x<_.transform.length;x++){let i=_.transform[x],K=i.fn(Y);if(i.subType==="derive")if(K instanceof Promise)Object.assign(Y,await K);else Object.assign(Y,K);else if(K instanceof Promise)await K}if(H){if(A0){let x=structuredClone(Y.headers);for(let[i,K]of W.headers)x[i]=K;if(H.headers.Check(x)===!1)throw new Z0("header",H.headers,x)}else if(H.headers?.Decode)Y.headers=H.headers.Decode(Y.headers);if(L0?.Check(Y.params)===!1)throw new Z0("params",H.params,Y.params);else if(H.params?.Decode)Y.params=H.params.Decode(Y.params);if(h?.Check(Y.query)===!1)throw new Z0("query",H.query,Y.query);else if(H.query?.Decode)Y.query=H.query.Decode(Y.query);if(H.createCookie?.()){let x={};for(let[i,K]of Object.entries(Y.cookie))x[i]=K.value;if(H.cookie.Check(x)===!1)throw new Z0("cookie",H.cookie,x);else if(H.cookie?.Decode)x=H.cookie.Decode(x)}if(H.createBody?.()?.Check(R)===!1)throw new Z0("body",H.body,R);else if(H.body?.Decode)Y.body=H.body.Decode(R)}for(let x=0;x<_.beforeHandle.length;x++){let i=_.beforeHandle[x],K=i.fn(Y);if(i.subType==="resolve"){if(K instanceof M1){let o=U(K,Y.set);if(o)return Y.response=o}if(K instanceof Promise)Object.assign(Y,await K);else Object.assign(Y,K);continue}else if(K instanceof Promise)K=await K;if(K!==void 0){Y.response=K;for(let D0=0;D0<_.afterHandle.length;D0++){let l=_.afterHandle[D0].fn(Y);if(l instanceof Promise)l=await l;if(l)K=l}let o=U(K,Y.set);if(o)return Y.response=o}}let a=typeof G==="function"?G(Y):G;if(a instanceof Promise)a=await a;if(!_.afterHandle.length){let x=a instanceof M1?a.code:Q.status?typeof Q.status==="string"?f8[Q.status]:Q.status:200,i=H?.createResponse?.()?.[x];if(i?.Check(a)===!1)throw new Z0("response",i,a);else if(i?.Decode)a=i.Decode(a)}else{Y.response=a;for(let x=0;x<_.afterHandle.length;x++){let i=_.afterHandle[x].fn(Y);if(i instanceof Promise)i=await i;let K=U(i,Y.set);if(K!==void 0){let o=H?.response?.[K.status];if(o?.Check(K)===!1)throw new Z0("response",o,K);else if(o?.Decode)a=o.Decode(a);return Y.response=K}}}if(Y.set.cookie&&J?.sign){let x=!J.secrets?void 0:typeof J.secrets==="string"?J.secrets:J.secrets[0];if(J.sign===!0)for(let[i,K]of Object.entries(Y.set.cookie))Y.set.cookie[i].value=await V8(K.value,"${secret}");else{let i=H?.cookie?.schema?.properties;for(let K of J.sign){if(!(K in i))continue;if(Y.set.cookie[K]?.value)Y.set.cookie[K].value=await V8(Y.set.cookie[K].value,x)}}}return z(Y.response=a,Y.set)}catch(B){let G=B instanceof L8&&B.error?B.error:B;return w.handleError(Y,G)}finally{for(let B of w.event.afterResponse)await B.fn(Y)}}},cH=(w)=>{let{mapResponse:z}=w["~adapter"].handler;return async(U,W)=>{let A=Object.assign(U,{error:W,code:W.code});A.set=U.set;for(let X=0;X<w.event.error.length;X++){let Z=w.event.error[X].fn(A);if(Z instanceof Promise)Z=await Z;if(Z!==void 0&&Z!==null)return U.response=z(Z,U.set)}return new Response(typeof W.cause==="string"?W.cause:W.message,{headers:U.set.headers,status:W.status??500})}};class j0{config;server=null;dependencies={};_routes={};_types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}};_ephemeral={};_volatile={};singleton={decorator:{},store:{},derive:{},resolve:{}};get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}definitions={typebox:I.Module({}),type:{},error:{}};extender={macros:[],higherOrderFunctions:[]};validator={global:null,scoped:null,local:null,getCandidate(){return I4(I4(this.global,this.scoped),this.local)}};event={start:[],request:[],parse:[],transform:[],beforeHandle:[],afterHandle:[],mapResponse:[],afterResponse:[],trace:[],error:[],stop:[]};telemetry={stack:void 0};router={http:new u1,ws:new u1,dynamic:new u1,static:{http:{static:{},map:{},all:""},ws:{}},history:[]};routeTree=new Map;get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1};getServer(){return this.server}"~parser"={};_promisedModules;get promisedModules(){if(!this._promisedModules)this._promisedModules=new kU;return this._promisedModules}constructor(w={}){if(w.tags)if(!w.detail)w.detail={tags:w.tags};else w.detail.tags=w.tags;if(w.nativeStaticResponse===void 0)w.nativeStaticResponse=!0;if(this.config={},this.applyConfig(w??{}),this["~adapter"]=w.adapter??(typeof Bun!=="undefined"?VH:I8),w?.analytic&&(w?.name||w?.seed!==void 0))this.telemetry.stack=new Error().stack}"~adapter";env(w,z=FU){if(j2(w,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0}).Check(z)===!1){let U=new Z0("env",w,z);throw new Error(U.all.map((W)=>W.summary).join(`
321
- `))}return this}wrap(w){return this.extender.higherOrderFunctions.push({checksum:x4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:w.toString()})),fn:w}),this}applyMacro(w){if(this.extender.macros.length){let z=qH({globalHook:this.event,localHook:w}),U={events:{global:this.event,local:w},get onParse(){return z("parse")},get onTransform(){return z("transform")},get onBeforeHandle(){return z("beforeHandle")},get onAfterHandle(){return z("afterHandle")},get mapResponse(){return z("mapResponse")},get onAfterResponse(){return z("afterResponse")},get onError(){return z("error")}};for(let W of this.extender.macros)MH(W.fn(U),w,z)}}applyConfig(w){return this.config={prefix:"",aot:FU.ELYSIA_AOT!=="false",normalize:!0,...w,cookie:{path:"/",...w?.cookie},experimental:w?.experimental??{},seed:w?.seed===void 0?"":w?.seed},this}get models(){let w={};for(let z of Object.keys(this.definitions.type))w[z]=j2(this.definitions.typebox.Import(z));return w.modules=this.definitions.typebox,w}add(w,z,U,W,{allowMeta:A=!1,skipPrefix:X=!1}={allowMeta:!1,skipPrefix:!1}){if(W=GH(W),z!==""&&z.charCodeAt(0)!==47)z="/"+z;if(this.config.prefix&&!X)z=this.config.prefix+z;if(W?.type)switch(W.type){case"text":W.type="text/plain";break;case"json":W.type="application/json";break;case"formdata":W.type="multipart/form-data";break;case"urlencoded":W.type="application/x-www-form-urlencoded";break;case"arrayBuffer":W.type="application/octet-stream";break;default:break}let Z=this.definitions.type,$=!this.config.aot,Q={...this.validator.getCandidate()},Y={body:W?.body??Q?.body,headers:W?.headers??Q?.headers,params:W?.params??Q?.params,query:W?.query??Q?.query,cookie:W?.cookie??Q?.cookie,response:W?.response??Q?.response},B=()=>Y.cookie?VU({modules:_,validator:Y.cookie,defaultConfig:this.config.cookie,config:Y.cookie?.config??{},dynamic:$,models:Z}):void 0,G=this.config.normalize,_=this.definitions.typebox,H=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:j2(Y.body,{modules:_,dynamic:$,models:Z,normalize:G,additionalCoerce:HU()}),headers:j2(Y.headers,{modules:_,dynamic:$,models:Z,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:P6()}),params:j2(Y.params,{modules:_,dynamic:$,models:Z,coerce:!0,additionalCoerce:P6()}),query:j2(Y.query,{modules:_,dynamic:$,models:Z,normalize:G,coerce:!0,additionalCoerce:P6()}),cookie:B(),response:qU(Y.response,{modules:_,dynamic:$,models:Z,normalize:G})}:{createBody(){if(this.body)return this.body;return this.body=j2(Y.body,{modules:_,dynamic:$,models:Z,normalize:G,additionalCoerce:HU()})},createHeaders(){if(this.headers)return this.headers;return this.headers=j2(Y.headers,{modules:_,dynamic:$,models:Z,additionalProperties:!G,coerce:!0,additionalCoerce:P6()})},createParams(){if(this.params)return this.params;return this.params=j2(Y.params,{modules:_,dynamic:$,models:Z,coerce:!0,additionalCoerce:P6()})},createQuery(){if(this.query)return this.query;return this.query=j2(Y.query,{modules:_,dynamic:$,models:Z,coerce:!0,additionalCoerce:P6()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=B()},createResponse(){if(this.response)return this.response;return this.response=qU(Y.response,{modules:_,dynamic:$,models:Z,normalize:G})}};if(W=D1(W,Q),W.tags)if(!W.detail)W.detail={tags:W.tags};else W.detail.tags=W.tags;if(s2(this.config.detail))W.detail=F2(Object.assign({},this.config.detail),W.detail);this.applyMacro(W);let F=D1(this.event,W);if(this.config.aot===!1){if(this.router.dynamic.add(w,z,{validator:H,hooks:F,content:W?.type,handle:U}),this.config.strictPath===!1)this.router.dynamic.add(w,r6(z),{validator:H,hooks:F,content:W?.type,handle:U});this.router.history.push({method:w,path:z,composed:null,handler:U,hooks:F,compile:U});return}let R=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,J=Vw(this.inference),m=this["~adapter"].handler,A0=typeof U!=="function"&&typeof m.createStaticHandler==="function"?m.createStaticHandler(U,F,this.setHeaders):void 0,L0=typeof U!=="function"?m.createNativeStaticHandler?.(U,F,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[z]=L0();let h=(l=!1)=>yH({app:this,path:z,method:w,localHook:D1(W),hooks:F,validator:H,handler:typeof U!=="function"&&typeof m.createStaticHandler!=="function"?()=>U:U,allowMeta:A,inference:J,asManifest:l});if(this.routeTree.has(w+z))for(let l=0;l<this.router.history.length;l++){let O1=this.router.history[l];if(O1.path===z&&O1.method===w){let C0=this.router.history.splice(l,1)[0];if(C0&&this.routeTree.has(C0?.method+C0?.path))this.routeTree.delete(C0.method+C0.path)}}else this.routeTree.set(w+z,this.router.history.length);let a=this.router.history,x=this.router.history.length,i=R?h():(l)=>(a[x].composed=h())(l),K=w==="$INTERNALWS";this.router.history.push({method:w,path:z,composed:i,handler:U,hooks:F,compile:()=>h(),websocket:W.websocket});let o=this.router.static.http,D0={handler:R?i:void 0,compile:h};if(K){let l=r6(z);if(z.indexOf(":")===-1&&z.indexOf("*")===-1)this.router.static.ws[z]=x;else if(this.router.ws.add("ws",z,D0),l)this.router.ws.add("ws",l,D0);return}if(z.indexOf(":")===-1&&z.indexOf("*")===-1){if(!o.map[z])o.map[z]={code:""};let l=A0?"":"c";if(w==="ALL")o.map[z].all=`default:return ht[${x}].composed(${l})
322
- `;else o.map[z].code=`case '${w}':return ht[${x}].composed(${l})
323
- ${o.map[z].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[r6(z)]=L0()}else if(this.router.http.add(w,z,D0),!this.config.strictPath){let l=r6(z);if(this.config.nativeStaticResponse===!0&&A0&&(w==="GET"||w==="ALL"))this.router.static.http.static[l]=A0();this.router.http.add(w,l,D0)}}setHeaders;headers(w){if(!w)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=F2(this.setHeaders,w),this}onStart(w){return this.on("start",w),this}onRequest(w){return this.on("request",w),this}onParse(w,z){if(!z){if(typeof w==="string")return this.on("parse",this["~parser"][w]);return this.on("parse",w)}return this.on(w,"parse",z)}parser(w,z){return this["~parser"][w]=z,this}onTransform(w,z){if(!z)return this.on("transform",w);return this.on(w,"transform",z)}resolve(w,z){if(!z)z=w,w={as:"local"};let U={subType:"resolve",fn:z};return this.onBeforeHandle(w,U)}mapResolve(w,z){if(!z)z=w,w={as:"local"};let U={subType:"mapResolve",fn:z};return this.onBeforeHandle(w,U)}onBeforeHandle(w,z){if(!z)return this.on("beforeHandle",w);return this.on(w,"beforeHandle",z)}onAfterHandle(w,z){if(!z)return this.on("afterHandle",w);return this.on(w,"afterHandle",z)}mapResponse(w,z){if(!z)return this.on("mapResponse",w);return this.on(w,"mapResponse",z)}onAfterResponse(w,z){if(!z)return this.on("afterResponse",w);return this.on(w,"afterResponse",z)}trace(w,z){if(!z)z=w,w={as:"local"};if(!Array.isArray(z))z=[z];for(let U of z)this.on(w,"trace",gH(U));return this}error(w,z){switch(typeof w){case"string":return z.prototype[k8]=w,this.definitions.error[w]=z,this;case"function":return this.definitions.error=w(this.definitions.error),this}for(let[U,W]of Object.entries(w))W.prototype[k8]=U,this.definitions.error[U]=W;return this}onError(w,z){if(!z)return this.on("error",w);return this.on(w,"error",z)}onStop(w){return this.on("stop",w),this}on(w,z,U){let W;switch(typeof w){case"string":W=w,U=z;break;case"object":if(W=z,!Array.isArray(z)&&typeof z==="object")U=z;break}if(Array.isArray(U))U=W2(U);else if(typeof U==="function")U=[{fn:U}];else U=[U];let A=U;for(let X of A)if(X.scope=typeof w==="string"?"local":w?.as??"local",W==="resolve"||W==="derive")X.subType=W;if(W!=="trace")uU({[W]:A.map((X)=>X.fn)},this.inference);for(let X of A){let Z=JH(X,"global",{skipIfHasType:!0});switch(W){case"start":this.event.start.push(Z);break;case"request":this.event.request.push(Z);break;case"parse":this.event.parse.push(Z);break;case"transform":this.event.transform.push(Z);break;case"derive":this.event.transform.push(W2(Z,"derive"));break;case"beforeHandle":this.event.beforeHandle.push(Z);break;case"resolve":this.event.beforeHandle.push(W2(Z,"resolve"));break;case"afterHandle":this.event.afterHandle.push(Z);break;case"mapResponse":this.event.mapResponse.push(Z);break;case"afterResponse":this.event.afterResponse.push(Z);break;case"trace":this.event.trace.push(Z);break;case"error":this.event.error.push(Z);break;case"stop":this.event.stop.push(Z);break}}return this}propagate(){return J2(this.event.parse),J2(this.event.transform),J2(this.event.beforeHandle),J2(this.event.afterHandle),J2(this.event.mapResponse),J2(this.event.afterResponse),J2(this.event.trace),J2(this.event.error),this}as(w){let z={plugin:"scoped",scoped:"scoped",global:"global"}[w];if(J2(this.event.parse,z),J2(this.event.transform,z),J2(this.event.beforeHandle,z),J2(this.event.afterHandle,z),J2(this.event.mapResponse,z),J2(this.event.afterResponse,z),J2(this.event.trace,z),J2(this.event.error,z),w==="plugin")this.validator.scoped=I4(this.validator.scoped,this.validator.local),this.validator.local=null;else if(w==="global")this.validator.global=I4(this.validator.global,I4(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(w,z,U){let W=new j0({...this.config,prefix:""});W.singleton={...this.singleton},W.definitions={...this.definitions},W.getServer=()=>this.getServer(),W.inference=Vw(this.inference),W.extender={...this.extender};let A=typeof z==="object",X=(A?U:z)(W);if(this.singleton=F2(this.singleton,W.singleton),this.definitions=F2(this.definitions,W.definitions),X.event.request.length)this.event.request=[...this.event.request||[],...X.event.request||[]];if(X.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...X.event.mapResponse||[]];return this.model(X.definitions.type),Object.values(W.router.history).forEach(({method:Z,path:$,handler:Q,hooks:Y})=>{if($=(A?"":this.config.prefix)+w+$,A){let B=z,G=Y;this.add(Z,$,Q,D1(B,{...G||{},error:!G.error?X.event.error:Array.isArray(G.error)?[...G.error||{},...X.event.error||{}]:[G.error,...X.event.error||{}]}))}else this.add(Z,$,Q,D1(Y,{error:X.event.error}),{skipPrefix:!0})}),this}guard(w,z){if(!z){if(typeof w==="object"){this.applyMacro(w);let A=w.as??"local";if(this.validator[A]={body:w.body??this.validator[A]?.body,headers:w.headers??this.validator[A]?.headers,params:w.params??this.validator[A]?.params,query:w.query??this.validator[A]?.query,response:w.response??this.validator[A]?.response,cookie:w.cookie??this.validator[A]?.cookie},w.parse)this.on({as:A},"parse",w.parse);if(w.transform)this.on({as:A},"transform",w.transform);if(w.derive)this.on({as:A},"derive",w.derive);if(w.beforeHandle)this.on({as:A},"beforeHandle",w.beforeHandle);if(w.resolve)this.on({as:A},"resolve",w.resolve);if(w.afterHandle)this.on({as:A},"afterHandle",w.afterHandle);if(w.mapResponse)this.on({as:A},"mapResponse",w.mapResponse);if(w.afterResponse)this.on({as:A},"afterResponse",w.afterResponse);if(w.error)this.on({as:A},"error",w.error);if(w.detail)if(this.config.detail)this.config.detail=F2(Object.assign({},this.config.detail),w.detail);else this.config.detail=w.detail;if(w?.tags)if(!this.config.detail)this.config.detail={tags:w.tags};else this.config.detail.tags=w.tags;return this}return this.guard({},w)}let U=new j0({...this.config,prefix:""});U.singleton={...this.singleton},U.definitions={...this.definitions},U.inference=Vw(this.inference),U.extender={...this.extender};let W=z(U);if(this.singleton=F2(this.singleton,U.singleton),this.definitions=F2(this.definitions,U.definitions),W.getServer=()=>this.server,W.event.request.length)this.event.request=[...this.event.request||[],...W.event.request||[]];if(W.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...W.event.mapResponse||[]];return this.model(W.definitions.type),Object.values(U.router.history).forEach(({method:A,path:X,handler:Z,hooks:$})=>{this.add(A,X,Z,D1(w,{...$||{},error:!$.error?W.event.error:Array.isArray($.error)?[...$.error||{},...W.event.error||[]]:[$.error,...W.event.error||[]]}))}),this}use(w,z){if(Array.isArray(w)){let U=this;for(let W of w)U=U.use(W);return U}if(z?.scoped)return this.guard({},(U)=>U.use(w));if(Array.isArray(w)){let U=this;for(let W of w)U=this.use(W);return U}if(w instanceof Promise)return this.promisedModules.add(w.then((U)=>{if(typeof U==="function")return U(this);if(U instanceof j0)return this._use(U).compile();if(U.constructor.name==="Elysia")return this._use(U).compile();if(typeof U.default==="function")return U.default(this);if(U.default instanceof j0)return this._use(U.default);if(U.constructor.name==="Elysia")return this._use(U.default);throw new Error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.')}).then((U)=>U.compile())),this;return this._use(w)}_use(w){if(typeof w==="function"){let A=w(this);if(A instanceof Promise)return this.promisedModules.add(A.then((X)=>{if(X instanceof j0){X.getServer=()=>this.getServer(),X.getGlobalRoutes=()=>this.getGlobalRoutes(),X.model(this.definitions.type),X.error(this.definitions.error);for(let{method:Z,path:$,handler:Q,hooks:Y}of Object.values(X.router.history))this.add(Z,$,Q,D1(Y,{error:X.event.error}));return X.compile(),X}if(typeof X==="function")return X(this);if(typeof X.default==="function")return X.default(this);return this._use(X)}).then((X)=>X.compile())),this;return A}let{name:z,seed:U}=w.config;if(w.getServer=()=>this.getServer(),w.getGlobalRoutes=()=>this.getGlobalRoutes(),w.model(this.definitions.type),w.error(this.definitions.error),this["~parser"]={...w["~parser"],...this["~parser"]},this.headers(w.setHeaders),z){if(!(z in this.dependencies))this.dependencies[z]=[];let A=U!==void 0?x4(z+JSON.stringify(U)):0;if(!this.dependencies[z].some(({checksum:X})=>A===X))this.extender.macros=this.extender.macros.concat(w.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(w.extender.higherOrderFunctions)}else this.extender.macros=this.extender.macros.concat(w.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(w.extender.higherOrderFunctions);PU(this.extender.macros),PU(this.extender.higherOrderFunctions);let W=[];for(let A=0;A<this.extender.higherOrderFunctions.length;A++){let X=this.extender.higherOrderFunctions[A];if(X.checksum){if(W.includes(X.checksum))this.extender.higherOrderFunctions.splice(A,1),A--;W.push(X.checksum)}}this.inference={body:this.inference.body||w.inference.body,cookie:this.inference.cookie||w.inference.cookie,headers:this.inference.headers||w.inference.headers,query:this.inference.query||w.inference.query,set:this.inference.set||w.inference.set,server:this.inference.server||w.inference.server,request:this.inference.request||w.inference.request,route:this.inference.route||w.inference.route},this.decorate(w.singleton.decorator),this.state(w.singleton.store),this.model(w.definitions.type),this.error(w.definitions.error),w.extender.macros=this.extender.macros.concat(w.extender.macros);for(let{method:A,path:X,handler:Z,hooks:$}of Object.values(w.router.history))this.add(A,X,Z,D1($,{error:w.event.error}));if(z){if(!(z in this.dependencies))this.dependencies[z]=[];let A=U!==void 0?x4(z+JSON.stringify(U)):0;if(this.dependencies[z].some(({checksum:X})=>A===X))return this;this.dependencies[z].push(this.config?.analytic?{name:w.config.name,seed:w.config.seed,checksum:A,dependencies:w.dependencies,stack:w.telemetry.stack,routes:w.router.history,decorators:w.singleton,store:w.singleton.store,error:w.definitions.error,derive:w.event.transform.filter((X)=>X?.subType==="derive").map((X)=>({fn:X.toString(),stack:new Error().stack??""})),resolve:w.event.transform.filter((X)=>X?.subType==="resolve").map((X)=>({fn:X.toString(),stack:new Error().stack??""}))}:{name:w.config.name,seed:w.config.seed,checksum:A,dependencies:w.dependencies}),this.event=GU(this.event,LU(w.event),A)}else this.event=GU(this.event,LU(w.event));return this.validator.global=D1(this.validator.global,{...w.validator.global}),this.validator.local=D1(this.validator.local,{...w.validator.scoped}),this}macro(w){if(typeof w==="function"){let z={checksum:x4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:w.toString()})),fn:w};this.extender.macros.push(z)}else if(typeof w==="object"){let z={checksum:x4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(w).map(([U,W])=>`${U}+${W}`).join(",")})),fn:()=>w};this.extender.macros.push(z)}return this}mount(w,z){if(w instanceof j0||typeof w==="function"||w.length===0||w==="/"){let A=typeof w==="function"?w:w instanceof j0?w.compile().fetch:z instanceof j0?z.compile().fetch:z,X=async({request:Z,path:$})=>{if(Z.method==="GET"||Z.method==="HEAD"||!Z.headers.get("content-type"))return A(new Request(j8(Z.url,$||"/"),Z));return A(new Request(j8(Z.url,$||"/"),{...Z,body:await Z.arrayBuffer()}))};return this.all("/*",X,{type:"none"}),this}let U=w.length;if(z instanceof j0)z=z.compile().fetch;let W=async({request:A,path:X})=>{if(A.method==="GET"||A.method==="HEAD"||!A.headers.get("content-type"))return z(new Request(j8(A.url,X.slice(U)||"/"),A));return z(new Request(j8(A.url,X.slice(U)||"/"),{...A,body:await A.arrayBuffer()}))};return this.all(w,W,{type:"none"}),this.all(w+(w.endsWith("/")?"*":"/*"),W,{type:"none"}),this}get(w,z,U){return this.add("GET",w,z,U),this}post(w,z,U){return this.add("POST",w,z,U),this}put(w,z,U){return this.add("PUT",w,z,U),this}patch(w,z,U){return this.add("PATCH",w,z,U),this}delete(w,z,U){return this.add("DELETE",w,z,U),this}options(w,z,U){return this.add("OPTIONS",w,z,U),this}all(w,z,U){return this.add("ALL",w,z,U),this}head(w,z,U){return this.add("HEAD",w,z,U),this}connect(w,z,U){return this.add("CONNECT",w,z,U),this}route(w,z,U,W){return this.add(w.toUpperCase(),z,U,W,W?.config),this}ws(w,z){if(this["~adapter"].ws)this["~adapter"].ws(this,w,z);else console.warn("Current adapter doesn't support WebSocket");return this}state(w,z,U){if(z===void 0)U=w,w={as:"append"},z="";else if(U===void 0){if(typeof w==="string")U=z,z=w,w={as:"append"};else if(typeof w==="object")U=z,z=""}let{as:W}=w;if(typeof z!=="string")return this;switch(typeof U){case"object":if(z){if(z in this.singleton.store)this.singleton.store[z]=F2(this.singleton.store[z],U,{override:W==="override"});else this.singleton.store[z]=U;return this}if(U===null)return this;return this.singleton.store=F2(this.singleton.store,U,{override:W==="override"}),this;case"function":if(z){if(W==="override"||!(z in this.singleton.store))this.singleton.store[z]=U}else this.singleton.store=U(this.singleton.store);return this;default:if(W==="override"||!(z in this.singleton.store))this.singleton.store[z]=U;return this}}decorate(w,z,U){if(z===void 0)U=w,w={as:"append"},z="";else if(U===void 0){if(typeof w==="string")U=z,z=w,w={as:"append"};else if(typeof w==="object")U=z,z=""}let{as:W}=w;if(typeof z!=="string")return this;switch(typeof U){case"object":if(z){if(z in this.singleton.decorator)this.singleton.decorator[z]=F2(this.singleton.decorator[z],U,{override:W==="override"});else this.singleton.decorator[z]=U;return this}if(U===null)return this;return this.singleton.decorator=F2(this.singleton.decorator,U,{override:W==="override"}),this;case"function":if(z){if(W==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=U}else this.singleton.decorator=U(this.singleton.decorator);return this;default:if(W==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=U;return this}}derive(w,z){if(!z)z=w,w={as:"local"};let U={subType:"derive",fn:z};return this.onTransform(w,U)}model(w,z){let U=(W)=>dw(W,[{from:I.Number(),to:(A)=>I.Numeric(A),untilObjectFound:!0},{from:I.Boolean(),to:(A)=>I.BooleanString(A),untilObjectFound:!0}]);switch(typeof w){case"object":let W={};return Object.entries(w).forEach(([X,Z])=>{if(!(X in this.definitions.type))W[X]=this.definitions.type[X]=U(Z)}),this.definitions.typebox=I.Module({...this.definitions.typebox.$defs,...W}),this;case"function":let A=U(w(this.definitions.type));return this.definitions.type=A,this.definitions.typebox=I.Module(A),this}return this.definitions.type[w]=z,this.definitions.typebox=I.Module({...this.definitions.typebox.$defs,[w]:z}),this}mapDerive(w,z){if(!z)z=w,w={as:"local"};let U={subType:"mapDerive",fn:z};return this.onTransform(w,U)}affix(w,z,U){if(U==="")return this;let W=["_","-"," "],A=(Q)=>Q[0].toUpperCase()+Q.slice(1),X=w==="prefix"?(Q,Y)=>W.includes(Q.at(-1)??"")?Q+Y:Q+A(Y):W.includes(U.at(-1)??"")?(Q,Y)=>Y+Q:(Q,Y)=>Y+A(Q),Z=(Q)=>{let Y={};switch(Q){case"decorator":for(let B in this.singleton.decorator)Y[X(U,B)]=this.singleton.decorator[B];this.singleton.decorator=Y;break;case"state":for(let B in this.singleton.store)Y[X(U,B)]=this.singleton.store[B];this.singleton.store=Y;break;case"model":for(let B in this.definitions.type)Y[X(U,B)]=this.definitions.type[B];this.definitions.type=Y;break;case"error":for(let B in this.definitions.error)Y[X(U,B)]=this.definitions.error[B];this.definitions.error=Y;break}},$=Array.isArray(z)?z:[z];for(let Q of $.some((Y)=>Y==="all")?["decorator","state","model","error"]:$)Z(Q);return this}prefix(w,z){return this.affix("prefix",w,z)}suffix(w,z){return this.affix("suffix",w,z)}compile(){if(this["~adapter"].isWebStandard){if(this.fetch=this.config.aot?Tw(this):jU(this),typeof this.server?.reload==="function")this.server.reload({...this.server||{},fetch:this.fetch});return this}if(typeof this.server?.reload==="function")this.server.reload(this.server||{});return this._handle=Tw(this),this}handle=async(w)=>this.fetch(w);fetch=(w)=>{return(this.fetch=this.config.aot?Tw(this):jU(this))(w)};handleError=async(w,z)=>{return(this.handleError=this.config.aot?rU(this):cH(this))(w,z)};outerErrorHandler=(w)=>new Response(w.message||w.name||"Error",{status:w?.status??500});listen=(w,z)=>{return this["~adapter"].listen(this)(w,z),this};stop=async(w)=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server){if(this.server.stop(w),this.server=null,this.event.stop.length)for(let z=0;z<this.event.stop.length;z++)this.event.stop[z].fn(this)}};get modules(){return Promise.all(this.promisedModules.promises)}}var aU;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(aU||(aU={}));var eU;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(eU||(eU={}));function uw(w){return zW(w,iH,f4.Include)}function d4(w){return zW(w,vH,f4.None)}function zW(w,z,U){let W="";for(let A=0;A<w.byteLength;A+=3){let X=0,Z=0;for(let $=0;$<3&&A+$<w.byteLength;$++)X=X<<8|w[A+$],Z+=8;for(let $=0;$<4;$++)if(Z>=6)W+=z[X>>Z-6&63],Z-=6;else if(Z>0)W+=z[X<<6-Z&63],Z=0;else if(U===f4.Include)W+="="}return W}var iH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",vH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var f4;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(f4||(f4={}));var wW;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(wW||(wW={}));class WW{uint8(w,z){if(w.byteLength<z+1)throw new TypeError("Insufficient bytes");return w[z]}uint16(w,z){if(w.byteLength<z+2)throw new TypeError("Insufficient bytes");return w[z]<<8|w[z+1]}uint32(w,z){if(w.byteLength<z+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=w[z+W]<<24-W*8;return U}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(w[z+W])<<BigInt(56-W*8);return U}putUint8(w,z,U){if(w.length<U+1)throw new TypeError("Not enough space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[U]=z}putUint16(w,z,U){if(w.length<U+2)throw new TypeError("Not enough space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[U]=z>>8,w[U+1]=z&255}putUint32(w,z,U){if(w.length<U+4)throw new TypeError("Not enough space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)w[U+W]=z>>(3-W)*8&255}putUint64(w,z,U){if(w.length<U+8)throw new TypeError("Not enough space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)w[U+W]=Number(z>>BigInt((7-W)*8)&0xffn)}}class AW{uint8(w,z){if(w.byteLength<z+1)throw new TypeError("Insufficient bytes");return w[z]}uint16(w,z){if(w.byteLength<z+2)throw new TypeError("Insufficient bytes");return w[z]|w[z+1]<<8}uint32(w,z){if(w.byteLength<z+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=w[z+W]<<W*8;return U}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(w[z+W])<<BigInt(W*8);return U}putUint8(w,z,U){if(w.length<1+U)throw new TypeError("Insufficient space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[U]=z}putUint16(w,z,U){if(w.length<2+U)throw new TypeError("Insufficient space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[U+1]=z>>8,w[U]=z&255}putUint32(w,z,U){if(w.length<4+U)throw new TypeError("Insufficient space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)w[U+W]=z>>W*8&255}putUint64(w,z,U){if(w.length<8+U)throw new TypeError("Insufficient space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)w[U+W]=Number(z>>BigInt(W*8)&0xffn)}}var P1=new WW,nH=new AW;function n0(w,z){return(w<<32-z|w>>>z)>>>0}function a2(w,z){return(w<<BigInt(64-z)|w>>BigInt(z))&0xffffffffffffffffn}class XW{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);l=0n;w=new Uint32Array(64);update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<64){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let U=w.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),z+=U.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let U=w.slice(z,z+64);this.blocks.set(U),this.process(),z+=64}if(w.byteLength-z>0){let U=w.slice(z);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),P1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(28);for(let z=0;z<7;z++)P1.putUint32(w,this.H[z],z*4);return w}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(n0(this.w[Q-2],17)^n0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,B=(n0(this.w[Q-15],7)^n0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+B+this.w[Q-16]|0}let w=this.H[0],z=this.H[1],U=this.H[2],W=this.H[3],A=this.H[4],X=this.H[5],Z=this.H[6],$=this.H[7];for(let Q=0;Q<64;Q++){let Y=(n0(A,6)^n0(A,11)^n0(A,25))>>>0,B=(A&X^~A&Z)>>>0,G=$+Y+B+uH[Q]+this.w[Q]|0,_=(n0(w,2)^n0(w,13)^n0(w,22))>>>0,H=(w&z^w&U^z&U)>>>0,F=_+H|0;$=Z,Z=X,X=A,A=W+G|0,W=U,U=z,z=w,w=G+F|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=A+this.H[4]|0,this.H[5]=X+this.H[5]|0,this.H[6]=Z+this.H[6]|0,this.H[7]=$+this.H[7]|0}}var uH=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function mw(w){let z=new tw;return z.update(w),z.digest()}class tw{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);l=0n;w=new Uint32Array(64);update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<64){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let U=w.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),z+=U.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let U=w.slice(z,z+64);this.blocks.set(U),this.process(),z+=64}if(w.byteLength-z>0){let U=w.slice(z);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),P1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(32);for(let z=0;z<8;z++)P1.putUint32(w,this.H[z],z*4);return w}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(n0(this.w[Q-2],17)^n0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,B=(n0(this.w[Q-15],7)^n0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+B+this.w[Q-16]|0}let w=this.H[0],z=this.H[1],U=this.H[2],W=this.H[3],A=this.H[4],X=this.H[5],Z=this.H[6],$=this.H[7];for(let Q=0;Q<64;Q++){let Y=(n0(A,6)^n0(A,11)^n0(A,25))>>>0,B=(A&X^~A&Z)>>>0,G=$+Y+B+mH[Q]+this.w[Q]|0,_=(n0(w,2)^n0(w,13)^n0(w,22))>>>0,H=(w&z^w&U^z&U)>>>0,F=_+H|0;$=Z,Z=X,X=A,A=W+G|0,W=U,U=z,z=w,w=G+F|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=A+this.H[4]|0,this.H[5]=X+this.H[5]|0,this.H[6]=Z+this.H[6]|0,this.H[7]=$+this.H[7]|0}}var mH=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);class Z6{blockSize=128;size=64;blocks=new Uint8Array(128);currentBlockSize=0;l=0n;w=new BigUint64Array(80);H;constructor(w){if(w.byteLength!==64)throw new TypeError;this.H=w}update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<128){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let U=w.slice(0,128-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),z+=U.byteLength,this.currentBlockSize=0}while(z+128<=w.byteLength){let U=w.slice(z,z+128);this.blocks.set(U),this.process(),z+=128,this.currentBlockSize=0}if(w.byteLength-z>0){let U=w.slice(z);this.blocks.set(U),this.currentBlockSize=U.byteLength}}putDigest(w){if(w.byteLength>64||w.byteLength%8!==0)throw new TypeError;if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,128-this.currentBlockSize<16)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),P1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();for(let z=0;z<w.byteLength/8;z++)P1.putUint64(w,this.H[z],z*8)}process(){for(let Q=0;Q<16;Q++)this.w[Q]=BigInt(this.blocks[Q*8])<<56n|BigInt(this.blocks[Q*8+1])<<48n|BigInt(this.blocks[Q*8+2])<<40n|BigInt(this.blocks[Q*8+3])<<32n|BigInt(this.blocks[Q*8+4])<<24n|BigInt(this.blocks[Q*8+5])<<16n|BigInt(this.blocks[Q*8+6])<<8n|BigInt(this.blocks[Q*8+7]);for(let Q=16;Q<80;Q++){let Y=(a2(this.w[Q-2],19)^a2(this.w[Q-2],61)^this.w[Q-2]>>6n)&0xffffffffffffffffn,B=(a2(this.w[Q-15],1)^a2(this.w[Q-15],8)^this.w[Q-15]>>7n)&0xffffffffffffffffn;this.w[Q]=Y+this.w[Q-7]+B+this.w[Q-16]&0xffffffffffffffffn}let w=this.H[0],z=this.H[1],U=this.H[2],W=this.H[3],A=this.H[4],X=this.H[5],Z=this.H[6],$=this.H[7];for(let Q=0;Q<80;Q++){let Y=(a2(A,14)^a2(A,18)^a2(A,41))&0xffffffffffffffffn,B=(A&X^~A&Z)&0xffffffffffffffffn,G=$+Y+B+tH[Q]+this.w[Q]&0xffffffffffffffffn,_=(a2(w,28)^a2(w,34)^a2(w,39))&0xffffffffffffffffn,H=(w&z^w&U^z&U)&0xffffffffffffffffn,F=_+H&0xffffffffffffffffn;$=Z,Z=X,X=A,A=W+G&0xffffffffffffffffn,W=U,U=z,z=w,w=G+F&0xffffffffffffffffn}this.H[0]=w+this.H[0]&0xffffffffffffffffn,this.H[1]=z+this.H[1]&0xffffffffffffffffn,this.H[2]=U+this.H[2]&0xffffffffffffffffn,this.H[3]=W+this.H[3]&0xffffffffffffffffn,this.H[4]=A+this.H[4]&0xffffffffffffffffn,this.H[5]=X+this.H[5]&0xffffffffffffffffn,this.H[6]=Z+this.H[6]&0xffffffffffffffffn,this.H[7]=$+this.H[7]&0xffffffffffffffffn}}class ZW{blockSize=128;size=64;sha512=new Z6(new BigUint64Array([0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(64);return this.sha512.putDigest(w),w}}var tH=new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class $W{blockSize=128;size=48;sha512=new Z6(new BigUint64Array([0xcbbb9d5dc1059ed8n,0x629a292a367cd507n,0x9159015a3070dd17n,0x152fecd8f70e5939n,0x67332667ffc00b31n,0x8eb44a8768581511n,0xdb0c2e0d64f98fa7n,0x47b5481dbefa4fa4n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(48);return this.sha512.putDigest(w),w}}class QW{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x8c3d37c819544da2n,0x73e1996689dcd4d6n,0x1dfab7ae32ff9c82n,0x679dd514582f9fcfn,0x0f6d2b697bd44da8n,0x77e36f7304c48942n,0x3f9d85a86a1d36c8n,0x1112e6ad91d692a1n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(32);return this.sha512.putDigest(w),w.slice(0,28)}}class YW{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x22312194fc2bf72cn,0x9f555fa3c84c64c2n,0x2393b86b6f53b151n,0x963877195940eabdn,0x96283ee2a88effe3n,0xbe5e1e2553863992n,0x2b0199fc2c85b8aan,0x0eb72ddc81c52ca2n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(32);return this.sha512.putDigest(w),w}}class U4{data;constructor(w){this.data=w}tokenType(){if("token_type"in this.data&&typeof this.data.token_type==="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token==="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in==="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1000)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token==="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token==="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope==="string"}scopes(){if("scope"in this.data&&typeof this.data.scope==="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token==="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function W4(w){let z=mw(new TextEncoder().encode(w));return d4(z)}function pw(){let w=new Uint8Array(32);return crypto.getRandomValues(w),d4(w)}function ow(){let w=new Uint8Array(32);return crypto.getRandomValues(w),d4(w)}function JW(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let U=0;while(U<w.length&&w[U]===z)U++;return w.slice(U)}function lw(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let U=w.length;while(U>0&&w[U-1]===z)U--;return w.slice(0,U)}function M2(w,...z){let U=lw(w,"/");for(let W of z)U+="/",U+=lw(JW(W,"/"),"/");return U}function g(w,z){let U=new TextEncoder().encode(z.toString()),W=new Request(w,{method:"POST",body:U});return W.headers.set("Content-Type","application/x-www-form-urlencoded"),W.headers.set("Accept","application/json"),W.headers.set("User-Agent","arctic"),W.headers.set("Content-Length",U.byteLength.toString()),W}function R6(w,z){let U=new TextEncoder().encode(`${w}:${z}`);return uw(U)}async function c(w){let z;try{z=await fetch(w)}catch(U){throw new $6(U)}if(z.status===400||z.status===401){let U;try{U=await z.json()}catch{throw new v1(z.status)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);let W;try{W=c8(U)}catch{throw new q1(z.status,U)}throw W}if(z.status===200){let U;try{U=await z.json()}catch{throw new v1(z.status)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);return new U4(U)}if(z.body!==null)await z.body.cancel();throw new v1(z.status)}async function A4(w){let z;try{z=await fetch(w)}catch(U){throw new $6(U)}if(z.status===400||z.status===401){let U;try{U=await z.json()}catch{throw new q1(z.status,null)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);let W;try{W=c8(U)}catch{throw new q1(z.status,U)}throw W}if(z.status===200){if(z.body!==null)await z.body.cancel();return}if(z.body!==null)await z.body.cancel();throw new v1(z.status)}function c8(w){let z;if("error"in w&&typeof w.error==="string")z=w.error;else throw new Error("Invalid error response");let U=null,W=null,A=null;if("error_description"in w){if(typeof w.error_description!=="string")throw new Error("Invalid data");U=w.error_description}if("error_uri"in w){if(typeof w.error_uri!=="string")throw new Error("Invalid data");W=w.error_uri}if("state"in w){if(typeof w.state!=="string")throw new Error("Invalid data");A=w.state}return new h4(z,U,W,A)}class $6 extends Error{constructor(w){super("Failed to send request",{cause:w})}}class h4 extends Error{code;description;uri;state;constructor(w,z,U,W){super(`OAuth request error: ${w}`);this.code=w,this.description=z,this.uri=U,this.state=W}}class v1 extends Error{status;constructor(w){super("Unexpected error response");this.status=w}}class q1 extends Error{status;data;constructor(w,z){super("Unexpected error response body");this.status=w,this.data=z}}class f{clientId;clientPassword;redirectURI;constructor(w,z,U){this.clientId=w,this.clientPassword=z,this.redirectURI=U}createAuthorizationURL(w,z,U){let W=new URL(w);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),this.redirectURI!==null)W.searchParams.set("redirect_uri",this.redirectURI);if(W.searchParams.set("state",z),U.length>0)W.searchParams.set("scope",U.join(" "));return W}createAuthorizationURLWithPKCE(w,z,U,W,A){let X=new URL(w);if(X.searchParams.set("response_type","code"),X.searchParams.set("client_id",this.clientId),this.redirectURI!==null)X.searchParams.set("redirect_uri",this.redirectURI);if(X.searchParams.set("state",z),U===W0.S256){let Z=W4(W);X.searchParams.set("code_challenge_method","S256"),X.searchParams.set("code_challenge",Z)}else if(U===W0.Plain)X.searchParams.set("code_challenge_method","plain"),X.searchParams.set("code_challenge",W);if(A.length>0)X.searchParams.set("scope",A.join(" "));return X}async validateAuthorizationCode(w,z,U){let W=new URLSearchParams;if(W.set("grant_type","authorization_code"),W.set("code",z),this.redirectURI!==null)W.set("redirect_uri",this.redirectURI);if(U!==null)W.set("code_verifier",U);if(this.clientPassword===null)W.set("client_id",this.clientId);let A=g(w,W);if(this.clientPassword!==null){let Z=R6(this.clientId,this.clientPassword);A.headers.set("Authorization",`Basic ${Z}`)}return await c(A)}async refreshAccessToken(w,z,U){let W=new URLSearchParams;if(W.set("grant_type","refresh_token"),W.set("refresh_token",z),this.clientPassword===null)W.set("client_id",this.clientId);if(U.length>0)W.set("scope",U.join(" "));let A=g(w,W);if(this.clientPassword!==null){let Z=R6(this.clientId,this.clientPassword);A.headers.set("Authorization",`Basic ${Z}`)}return await c(A)}async revokeToken(w,z){let U=new URLSearchParams;if(U.set("token",z),this.clientPassword===null)U.set("client_id",this.clientId);let W=g(w,U);if(this.clientPassword!==null){let A=R6(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${A}`)}await A4(W)}}var W0;(function(w){w[w.S256=0]="S256",w[w.Plain=1]="Plain"})(W0||(W0={}));class i8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=`https://${w}/oauth2/authorize`,this.tokenEndpoint=`https://${w}/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/oauth2/revoke`,this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var oH="https://anilist.co/api/v2/oauth/authorize",lH="https://anilist.co/api/v2/oauth/token";class v8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w){return this.client.createAuthorizationURL(oH,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(lH,w,null)}}var BW;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(BW||(BW={}));var MW;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(MW||(MW={}));function C6(w){return sH(w,rH,n8.None)}function sH(w,z,U){let W="";for(let A=0;A<w.byteLength;A+=3){let X=0,Z=0;for(let $=0;$<3&&A+$<w.byteLength;$++)X=X<<8|w[A+$],Z+=8;for(let $=0;$<4;$++)if(Z>=6)W+=z[X>>Z-6&63],Z-=6;else if(Z>0)W+=z[X<<6-Z&63],Z=0;else if(U===n8.Include)W+="="}return W}var rH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function sw(w){return aH(w,eH,y4.Ignore)}function aH(w,z,U){let W=new Uint8Array(Math.ceil(w.length/4)*3),A=0;for(let X=0;X<w.length;X+=4){let Z=0,$=0;for(let Y=0;Y<4;Y++){if(U===y4.Required&&w[X+Y]==="=")continue;if(U===y4.Ignore&&(X+Y>=w.length||w[X+Y]==="="))continue;if(Y>0&&w[X+Y-1]==="=")throw new Error("Invalid padding");if(!(w[X+Y]in z))throw new Error("Invalid character");Z|=z[w[X+Y]]<<(3-Y)*6,$+=6}if($<24){let Y;if($===12)Y=Z&65535;else if($===18)Y=Z&255;else throw new Error("Invalid padding");if(Y!==0)throw new Error("Invalid padding")}let Q=Math.floor($/8);for(let Y=0;Y<Q;Y++)W[A]=Z>>16-Y*8&255,A++}return W.slice(0,A)}var n8;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(n8||(n8={}));var y4;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(y4||(y4={}));var eH={"0":52,"1":53,"2":54,"3":55,"4":56,"5":57,"6":58,"7":59,"8":60,"9":61,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,"-":62,_:63};function qW(w){let z=w.split(".");if(z.length!==3)throw new Error("Invalid JWT");let U;try{U=new TextDecoder().decode(sw(z[1]))}catch{throw new Error("Invalid JWT: Invalid base64url encoding")}let W;try{W=JSON.parse(U)}catch{throw new Error("Invalid JWT: Invalid JSON encoding")}if(typeof W!=="object"||W===null)throw new Error("Invalid JWT: Invalid payload");return W}function HW(w,z,U){let W=C6(new TextEncoder().encode(w)),A=C6(new TextEncoder().encode(z)),X=C6(U);return W+"."+A+"."+X}function GW(w,z){let U=C6(new TextEncoder().encode(w)),W=C6(new TextEncoder().encode(z)),A=U+"."+W;return new TextEncoder().encode(A)}var zG="https://appleid.apple.com/auth/authorize",UG="https://appleid.apple.com/auth/token";class u8{clientId;teamId;keyId;pkcs8PrivateKey;redirectURI;constructor(w,z,U,W,A){this.clientId=w,this.teamId=z,this.keyId=U,this.pkcs8PrivateKey=W,this.redirectURI=A}createAuthorizationURL(w,z){let U=new URL(zG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId);let U=await this.createClientSecret();z.set("client_secret",U);let W=g(UG,z);return await c(W)}async createClientSecret(){let w=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),z=Math.floor(Date.now()/1000),U=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),W=JSON.stringify({iss:this.teamId,exp:z+300,aud:["https://appleid.apple.com"],sub:this.clientId,iat:z}),A=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},w,GW(U,W)));return HW(U,W,A)}}var WG="https://auth.atlassian.com/authorize",NW="https://auth.atlassian.com/oauth/token";class m8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(WG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U.searchParams.set("audience","api.atlassian.com"),U.searchParams.set("prompt","consent"),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(NW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(NW,z);return await c(U)}}class t8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=`https://${w}/authorize`,this.tokenEndpoint=`https://${w}/oauth/token`,this.tokenRevocationEndpoint=`https://${w}/oauth/revoke`,this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){let W;if(z!==null)W=this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U);else W=this.client.createAuthorizationURL(this.authorizationEndpoint,w,U);return W}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}class p8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=M2(w,"/application/o/authorize"),this.tokenEndpoint=M2(w,"/application/o/token"),this.tokenRevocationEndpoint=M2(w,"/application/o/revoke"),this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var AG="https://bitbucket.org/site/oauth2/authorize",SW="https://bitbucket.org/site/oauth2/access_token";class o8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w){return this.client.createAuthorizationURL(AG,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(SW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(SW,w,[])}}var XG="https://account.box.com/api/oauth2/authorize",_W="https://api.box.com/oauth2/token",ZG="https://api.box.com/oauth2/revoke";class l8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(XG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(_W,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(_W,z);return await c(U)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(ZG,z);await A4(U)}}var $G="https://www.coinbase.com/oauth/authorize",DW="https://www.coinbase.com/oauth/token",QG="https://api.coinbase.com/oauth/revoke";class s8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL($G);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(DW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(DW,z);return await c(U)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(QG,z);await A4(U)}}var PW="https://discord.com/oauth2/authorize",OW="https://discord.com/api/oauth2/token",YG="https://discord.com/api/oauth2/token/revoke";class r8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){let W;if(z!==null)W=this.client.createAuthorizationURLWithPKCE(PW,w,W0.S256,z,U);else W=this.client.createAuthorizationURL(PW,w,U);return W}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(OW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(OW,w,[])}async revokeToken(w){await this.client.revokeToken(YG,w)}}var JG="https://dribbble.com/oauth/authorize",BG="https://dribbble.com/oauth/token";class a8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(JG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(BG,z);return await c(U)}}var MG="https://www.dropbox.com/oauth2/authorize",bW="https://api.dropboxapi.com/oauth2/token",qG="https://api.dropboxapi.com/2/auth/token/revoke";class e8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(MG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(bW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(bW,w,[])}async revokeToken(w){await this.client.revokeToken(qG,w)}}var HG="https://www.facebook.com/v16.0/dialog/oauth",GG="https://graph.facebook.com/v16.0/oauth/access_token";class w5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(HG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(GG,z);return await c(U)}}var LG="https://www.figma.com/oauth",NG="https://www.figma.com/api/oauth/token";class z5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(LG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(NG,w,null)}}var SG="https://appcenter.intuit.com/connect/oauth2",RW="https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",_G="https://developer.API.intuit.com/v2/oauth2/tokens/revoke";class U5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(SG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(RW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(RW,w,[])}async revokeToken(w){await this.client.revokeToken(_G,w)}}var DG="https://github.com/login/oauth/authorize",CW="https://github.com/login/oauth/access_token";class W5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(DG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(w){let z=new URLSearchParams;if(z.set("grant_type","authorization_code"),z.set("code",w),this.redirectURI!==null)z.set("redirect_uri",this.redirectURI);let U=g(CW,z),W=R6(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await KW(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w);let U=g(CW,z),W=R6(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await KW(U)}}async function KW(w){let z;try{z=await fetch(w)}catch(A){throw new $6(A)}if(z.status!==200){if(z.body!==null)await z.body.cancel();throw new v1(z.status)}let U;try{U=await z.json()}catch{throw new v1(z.status)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);if("error"in U&&typeof U.error==="string"){let A;try{A=c8(U)}catch{throw new q1(z.status,U)}throw A}return new U4(U)}class A5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=M2(w,"/oauth/authorize"),this.tokenEndpoint=M2(w,"/oauth/token"),this.tokenRevocationEndpoint=M2(w,"/oauth/revoke"),this.client=new f(z,U,W)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(this.authorizationEndpoint,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var PG="https://accounts.google.com/o/oauth2/v2/auth",FW="https://oauth2.googleapis.com/token",OG="https://oauth2.googleapis.com/revoke";class X5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(PG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(FW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(FW,w,[])}async revokeToken(w){await this.client.revokeToken(OG,w)}}var bG="https://kauth.kakao.com/oauth/authorize",jW="https://kauth.kakao.com/oauth/token";class Z5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(bG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(jW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(jW,z);return await c(U)}}class $5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=w+"/protocol/openid-connect/auth",this.tokenEndpoint=w+"/protocol/openid-connect/token",this.tokenRevocationEndpoint=w+"/protocol/openid-connect/revoke",this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var RG="https://lichess.org/oauth",CG="https://lichess.org/api/token";class Q5{client;constructor(w,z){this.client=new f(w,null,z)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(RG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(CG,w,z)}}var KG="https://access.line.me/oauth2/v2.1/authorize",EW="https://api.line.me/oauth2/v2.1/token";class Y5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z,U){let W=new URL(KG);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),W.searchParams.set("state",w),U.length>0)W.searchParams.set("scope",U.join(" "));W.searchParams.set("redirect_uri",this.redirectURI);let A=W4(z);return W.searchParams.set("code_challenge_method","S256"),W.searchParams.set("code_challenge",A),W}async validateAuthorizationCode(w,z){let U=new URLSearchParams;U.set("grant_type","authorization_code"),U.set("code",w),U.set("code_verifier",z),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),U.set("client_secret",this.clientSecret);let W=g(EW,U);return await c(W)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(EW,z);return await c(U)}}var FG="https://linear.app/oauth/authorize",jG="https://api.linear.app/oauth/token";class J5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(FG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(jG,z);return await c(U)}}var EG="https://www.linkedin.com/oauth/v2/authorization",IW="https://www.linkedin.com/oauth/v2/accessToken";class B5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(EG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(IW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(IW,z);return await c(U)}}class M5{authorizationEndpoint;tokenEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=M2("https://login.microsoftonline.com",w,"/oauth2/v2.0/authorize"),this.tokenEndpoint=M2("https://login.microsoftonline.com",w,"/oauth2/v2.0/token"),this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}}var IG="https://myanimelist.net/v1/oauth2/authorize",xW="https://myanimelist.net/v1/oauth2/token";class q5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURLWithPKCE(IG,w,W0.Plain,z,[])}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(xW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(xW,w,[])}}var xG="https://api.notion.com/v1/oauth/authorize",VG="https://api.notion.com/v1/oauth/token";class H5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w){let z=this.client.createAuthorizationURL(xG,w,[]);return z.searchParams.set("owner","user"),z}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(VG,w,null)}}class G5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W,A){let X=`https://${w}/oauth2`;if(z!==null)X=M2(X,z);this.authorizationEndpoint=M2(X,"/v1/authorize"),this.tokenEndpoint=M2(X,"/v1/token"),this.tokenRevocationEndpoint=M2(X,"/v1/revoke"),this.client=new f(U,W,A)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var kG="https://osu.ppy.sh/oauth/authorize",VW="https://osu.ppy.sh/oauth/token";class L5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(kG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(w){let z=new URLSearchParams;if(z.set("grant_type","authorization_code"),z.set("code",w),this.redirectURI!==null)z.set("redirect_uri",this.redirectURI);z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(VW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(VW,z);return await c(U)}}var TG="https://www.patreon.com/oauth2/authorize",kW="https://www.patreon.com/api/oauth2/token";class N5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(TG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(kW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(kW,z);return await c(U)}}var gG="https://www.reddit.com/api/v1/authorize",TW="https://www.reddit.com/api/v1/access_token";class S5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(gG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(TW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(TW,w,[])}}var fG="https://apis.roblox.com/oauth/v1/authorize",gW="https://apis.roblox.com/oauth/v1/token",dG="https://apis.roblox.com/oauth/v1/token/revoke";class _5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(fG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(gW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(gW,w,[])}async revokeToken(w){await this.client.revokeToken(dG,w)}}class D5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=`https://${w}/services/oauth2/authorize`,this.tokenEndpoint=`https://${w}/services/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/services/oauth2/revoke`,this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var hG="https://shikimori.one/oauth/authorize",fW="https://shikimori.one/oauth/token";class P5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w){let z=new URL(hG);return z.searchParams.set("response_type","code"),z.searchParams.set("client_id",this.clientId),z.searchParams.set("state",w),z.searchParams.set("redirect_uri",this.redirectURI),z}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(fW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(fW,z);return await c(U)}}var yG="https://slack.com/openid/connect/authorize",cG="https://slack.com/api/openid.connect.token";class O5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(yG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(cG,w,null)}}var dW="https://accounts.spotify.com/authorize",hW="https://accounts.spotify.com/api/token";class b5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){let W;if(z!==null)W=this.client.createAuthorizationURLWithPKCE(dW,w,W0.S256,z,U);else W=this.client.createAuthorizationURL(dW,w,U);return W}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(hW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(hW,w,[])}}var iG="https://www.strava.com/oauth/authorize",vG="https://www.strava.com/oauth/token";class R5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(iG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(","));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(vG,z);return await c(U)}}var nG="https://v5api.tiltify.com/oauth/authorizeze",yW="https://v5api.tiltify.com/oauth/token";class C5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(nG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(yW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(yW,z);return await c(U)}}var uG="https://www.tumblr.com/oauth2/authorize",cW="https://api.tumblr.com/v2/oauth2/token";class K5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(uG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(cW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(cW,w,[])}}var mG="https://id.twitch.tv/oauth2/authorize",iW="https://id.twitch.tv/oauth2/token";class F5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(mG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(iW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(iW,z);return await c(U)}}var tG="https://twitter.com/i/oauth2/authorize",vW="https://api.twitter.com/2/oauth2/token",pG="https://api.twitter.com/2/oauth2/revoke";class j5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(tG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(vW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(vW,w,[])}async revokeToken(w){await this.client.revokeToken(pG,w)}}var oG="https://oauth.vk.com/authorize",lG="https://oauth.vk.com/access_token";class E5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(oG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(lG,z);return await c(U)}}var sG="https://api.workos.com/sso/authorize",rG="https://api.workos.com/sso/token";class I5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(sG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),U.searchParams.set("redirect_uri",this.redirectURI),z!==null){let W=W4(z);U.searchParams.set("code_challenge_method","S256"),U.searchParams.set("code_challenge",W)}return U}async validateAuthorizationCode(w,z){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",w),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),this.clientSecret!==null)U.set("client_secret",this.clientSecret);if(z!==null)U.set("code_verifier",z);let W=g(rG,U);return await c(W)}}var aG="https://api.login.yahoo.com/oauth2/request_auth",nW="https://api.login.yahoo.com/oauth2/get_token";class x5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(aG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(nW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(nW,w,[])}}var eG="https://oauth.yandex.com/authorize",uW="https://oauth.yandex.com/token";class V5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(eG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(uW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(uW,w,[])}}var wL="https://zoom.us/oauth/authorize",mW="https://zoom.us/oauth/token",zL="https://zoom.us/oauth/revoke";class k5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(wL,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(mW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(mW,w,[])}async revokeToken(w){await this.client.revokeToken(zL,w)}}var UL="https://api.intra.42.fr/oauth/authorize",WL="https://api.intra.42.fr/oauth/token";class T5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(UL);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(WL,z);return await c(U)}}function rw(w){try{return qW(w)}catch(z){throw new Error("Invalid ID token",{cause:z})}}var c4={AmazonCognito:i8,AniList:v8,Apple:u8,Atlassian:m8,Auth0:t8,Authentik:p8,Bitbucket:o8,Box:l8,Coinbase:s8,Discord:r8,Dribbble:a8,Dropbox:e8,Facebook:w5,Figma:z5,Intuit:U5,GitHub:W5,GitLab:A5,Google:X5,Kakao:Z5,KeyCloak:$5,Lichess:Q5,Line:Y5,Linear:J5,LinkedIn:B5,MicrosoftEntraId:M5,MyAnimeList:q5,Notion:H5,Okta:G5,Osu:L5,Patreon:N5,Reddit:S5,Roblox:_5,Salesforce:D5,Shikimori:P5,Slack:O5,Spotify:b5,Strava:R5,Tiltify:C5,Tumblr:K5,Twitch:F5,Twitter:j5,VK:E5,WorkOS:I5,Yahoo:x5,Yandex:V5,Zoom:k5,FortyTwo:T5},tW=Object.keys(c4).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),i4={AmazonCognito:"https://{region}.amazonaws.com/{userPoolId}/.well-known/openid-configuration",AniList:"https://graphql.anilist.co",Apple:"https://appleid.apple.com/auth/token",Atlassian:"https://api.atlassian.com/me",Auth0:"https://{your_domain}/userinfo",Authentik:"https://{your_domain}/api/v1/user/me",Bitbucket:"https://api.bitbucket.org/2.0/user",Box:"https://api.box.com/2.0/users/me",Coinbase:"https://api.coinbase.com/v2/user",Discord:"https://discord.com/api/users/@me",Dribbble:"https://api.dribbble.com/v2/user",Dropbox:"https://api.dropboxapi.com/2/users/get_current_account",Facebook:"https://graph.facebook.com/me",Figma:"https://api.figma.com/v1/me",Intuit:"https://accounts.platform.intuit.com/v1/openid_connect/userinfo",GitHub:"https://api.github.com/user",GitLab:"https://gitlab.com/api/v4/user",Google:"https://www.googleapis.com/userinfo/v2/me",Kakao:"https://kapi.kakao.com/v2/user/me",KeyCloak:"https://{your_domain}/auth/realms/{realm}/protocol/openid-connect/userinfo",Lichess:"https://lichess.org/api/account",Line:"https://api.line.me/v2/profile",Linear:"https://api.linear.app/v1/me",LinkedIn:"https://api.linkedin.com/v2/me",MicrosoftEntraId:"https://graph.microsoft.com/v1.0/me",MyAnimeList:"https://myanimelist.net/v1/users/@me",Notion:"https://api.notion.com/v1/users/me",Okta:"https://{yourOktaDomain}/oauth2/v1/userinfo",Osu:"https://osu.ppy.sh/api/v2/me",Patreon:"https://www.patreon.com/api/oauth2/v2/identity",Reddit:"https://oauth.reddit.com/api/v1/me",Roblox:"https://apis.roblox.com/users/v1/users/me",Salesforce:"https://login.salesforce.com/services/oauth2/userinfo",Shikimori:"https://shikimori.one/api/users/whoami",Slack:"https://slack.com/api/users.identity",Spotify:"https://api.spotify.com/v1/me",Strava:"https://www.strava.com/api/v3/athlete",Tiltify:"https://tiltify.com/api/v3/user",Tumblr:"https://api.tumblr.com/v2/user/info",Twitch:"https://api.twitch.tv/helix/users",Twitter:"https://api.twitter.com/2/users/me",VK:"https://api.vk.com/method/users.get",WorkOS:"https://api.workos.com/sso/profile",Yahoo:"https://api.login.yahoo.com/openid/v1/userinfo",Yandex:"https://login.yandex.ru/info",Zoom:"https://api.zoom.us/v2/users/me",FortyTwo:"https://api.intra.42.fr/v2/me"},pW={AmazonCognito:"https://cognito-idp.{region}.amazonaws.com/{userPoolId}",AniList:"https://anilist.co/api/v2/oauth/authorize",Apple:"https://appleid.apple.com",Atlassian:"https://auth.atlassian.com",Auth0:"https://{your_domain}.auth0.com",Authentik:"https://{your_domain}",Bitbucket:"https://bitbucket.org/site/oauth2/authorize",Box:"https://account.box.com/api/oauth2/authorize",Coinbase:"https://www.coinbase.com/oauth/authorize",Discord:"https://discord.com/api/oauth2/authorize",Dribbble:"https://dribbble.com/oauth/authorize",Dropbox:"https://www.dropbox.com/oauth2/authorize",Facebook:"https://www.facebook.com/v12.0/dialog/oauth",Figma:"https://www.figma.com/oauth",Intuit:"https://appcenter.intuit.com/connect/oauth2",GitHub:"https://github.com/login/oauth/authorize",GitLab:"https://gitlab.com/oauth/authorize",Google:"https://accounts.google.com",Kakao:"https://kauth.kakao.com/oauth/authorize",KeyCloak:"https://{your_domain}/auth",Lichess:"https://lichess.org/oauth/authorize",Line:"https://access.line.me/oauth2/v2.1/authorize",Linear:"https://linear.app/oauth/authorize",LinkedIn:"https://www.linkedin.com/oauth/v2/authorization",MicrosoftEntraId:"https://login.microsoftonline.com/{tenant}/v2.0",MyAnimeList:"https://myanimelist.net/v1/oauth2/authorize",Notion:"https://api.notion.com/v1/oauth/authorize",Okta:"https://{yourOktaDomain}/oauth2/default/v1/authorize",Osu:"https://osu.ppy.sh/oauth/authorize",Patreon:"https://www.patreon.com/oauth2/authorize",Reddit:"https://www.reddit.com/api/v1/authorize",Roblox:"https://apis.roblox.com/oauth/v1/authorize",Salesforce:"https://login.salesforce.com/services/oauth2/authorize",Shikimori:"https://shikimori.one/oauth/authorize",Slack:"https://slack.com/oauth/v2/authorize",Spotify:"https://accounts.spotify.com/authorize",Strava:"https://www.strava.com/oauth/authorize",Tiltify:"https://tiltify.com/oauth/authorize",Tumblr:"https://www.tumblr.com/oauth/authorize",Twitch:"https://id.twitch.tv/oauth2/authorize",Twitter:"https://api.twitter.com/oauth/authorize",VK:"https://oauth.vk.com/authorize",WorkOS:"https://api.workos.com/sso/authorize",Yahoo:"https://api.login.yahoo.com/oauth2/request_auth",Yandex:"https://oauth.yandex.com/authorize",Zoom:"https://zoom.us/oauth/authorize",FortyTwo:"https://api.intra.42.fr/oauth/authorize"},oW=Object.keys(i4).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),IT=Object.keys(pW).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{});var lW=({logoutRoute:w="logout",onLogout:z})=>{return new j0().post(`/${w}`,async({error:U,cookie:{user_session_id:W,auth_provider:A}})=>{if(A.value===void 0)return U(401,"No auth provider found");try{return z?.(),W.remove(),A.remove(),new Response("Succesfuly Logged Out",{status:204})}catch(X){if(X instanceof Error)console.error("Failed to refresh token:",X.message);return U(500)}})};var sW=(w)=>{return"refreshAccessToken"in w&&typeof w.refreshAccessToken==="function"};var Q6=(w)=>{return Object.keys(c4).map((z)=>z.toLowerCase()).includes(w.toLowerCase())},rW=(w)=>{return Object.keys(i4).includes(w)};var aW=(w)=>{return!0};var eW=({clientProviders:w,revokeRoute:z="revoke",onRevoke:U})=>{return new j0().post(`/${z}/access-token`,async({error:W,cookie:{user_refresh_token:A,auth_provider:X}})=>{if(A.value===void 0)return W(401,"No refresh token found");if(X.value===void 0)return W(401,"No auth provider found");if(!Q6(X.value))return W(400,"Invalid provider");let Z=X.value.toLowerCase(),{providerInstance:$}=w[Z];U?.()})};var X4=()=>{return new j0({name:"sessionStore"}).state({session:{}})};var wA=({statusRoute:w="auth-status",onStatus:z})=>{return new j0().use(X4()).get(`/${w}`,async({error:U,cookie:{user_session_id:W,auth_provider:A},store:{session:X}})=>{try{if(W.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});if(A.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let Z=X[W.value];if(Z===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let $=Z.user;return z?.(),new Response(JSON.stringify({user:$}),{headers:{"Content-Type":"application/json"}})}catch(Z){if(Z instanceof Error)console.error("Failed to get auth status: ",Z.message);return U(500)}})};var zA=({clientProviders:w,refreshRoute:z="refresh",onRefresh:U})=>{return new j0().post(`/${z}`,async({error:W,cookie:{user_refresh_token:A,auth_provider:X}})=>{if(A.value===void 0)return W(401,"No refresh token found");if(X.value===void 0)return W(401,"No auth provider found");let Z=X.value.toLowerCase(),{providerInstance:$}=w[Z];if(!sW($))return W(401,"Provider is not refreshable");try{let Q=await $.refreshAccessToken(A.value);return U?.(),new Response("Token refreshed",{status:204})}catch(Q){if(Q instanceof Error)console.error("Failed to refresh token:",Q.message);return W(500)}})};var UA=({clientProviders:w,authorizeRoute:z="authorize",onAuthorize:U})=>{return new j0().get(`/${z}/:provider`,({error:W,redirect:A,cookie:{state:X,code_verifier:Z,auth_provider:$,redirect_url:Q},params:{provider:Y},headers:B})=>{if(Y===void 0)return W(400,"Provider is required");if(!Q6(Y))return W(400,"Invalid provider");try{let G=Y.toLowerCase(),{providerInstance:_,scopes:H,searchParams:F}=w[G],R=B.referer||"/";Q.set({value:R,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),$.set({value:Y,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let J=ow();X.set({value:J,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let m,A0;if(_.createAuthorizationURL.toString().includes("codeVerifier"))A0=pw(),Z.set({value:A0,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),m=_.createAuthorizationURL(J,A0,H);else m=_.createAuthorizationURL(J,H);return F.forEach(([L0,h])=>{m.searchParams.set(L0,h)}),U?.(),A(m.toString())}catch(G){if(G instanceof Error)console.error("Failed to validate authorization code:",G.message);return W(500)}})};var WA=({clientProviders:w,callbackRoute:z="authorize/callback",onCallback:U,getUser:W,createUser:A})=>{return new j0().use(X4()).get(`/${z}`,async({error:X,redirect:Z,store:{session:$},cookie:{state:Q,code_verifier:Y,redirect_url:B,user_session_id:G,auth_provider:_},query:{code:H,state:F}})=>{if(!H||!Q.value)return X(400,"Invalid callback request");if(F!==Q.value)return X(400,"Invalid state mismatch");if(_.value===void 0)return X(401,"No auth provider found");if(!Q6(_.value))return X(400,"Invalid provider");let R=_.value.toLowerCase(),{providerInstance:J}=w[R];try{let m;if(Q.remove(),J.validateAuthorizationCode.toString().includes("codeVerifier")){if(!Y.value)return X(400,"Code verifier not found and is required");m=await J.validateAuthorizationCode(H,Y.value),Y.remove()}else m=await J.validateAuthorizationCode(H);let A0=rw(m.idToken()),L0=_.value,h=await W?.({decodedIdToken:A0,authProvider:L0});if(h===null||h===void 0)h=await A?.({decodedIdToken:A0,authProvider:L0});let a=crypto.randomUUID();if(!aW(h))return X(500,"Invalid user schema");$[a]={user:h,expiresAt:Date.now()+86400000},G.set({value:a,secure:!0,httpOnly:!0,sameSite:"lax"}),U?.();let x=B.value??"/";return Z(x)}catch(m){if(m instanceof Error)console.error("Failed to validate authorization code:",m.message);return X(500)}})};var AA=()=>{return new j0().use(X4()).derive(({store:{session:w},cookie:{user_session_id:z},error:U})=>{return{protectRoute:async(W,A)=>{if(z.value===void 0)return A?.()??U(401,"No session ID found");if(w[z.value]===void 0)return A?.()??U(401,"No session found");return W()}}}).as("plugin")};var Lg=({config:w,authorizeRoute:z,callbackRoute:U,logoutRoute:W,statusRoute:A,refreshRoute:X,revokeRoute:Z,onAuthorize:$,onCallback:Q,onStatus:Y,onRefresh:B,onLogout:G,onRevoke:_,createUser:H,getUser:F})=>{let R=Object.entries(w).reduce((J,[m,A0={}])=>{let L0=m.toLowerCase(),h=tW[L0],a=oW[L0];if(!h||!Q6(h))return console.error(`Provider ${m} is not supported`),J;let x=c4[h],i;if(rW(a))i=i4[a];let{credentials:K=[],scopes:o=[],searchParams:D0=[]}=A0,l=new x(...K);return J[L0]={providerInstance:l,scopes:o,searchParams:D0,userInfoURL:i},J},{});return new j0().error("OAUTH2_REQUEST_ERROR",h4).error("ARCTIC_FETCH_ERROR",$6).use(lW({logoutRoute:W,onLogout:G})).use(eW({clientProviders:R,revokeRoute:Z,onRevoke:_})).use(wA({statusRoute:A,onStatus:Y})).use(zA({clientProviders:R,refreshRoute:X,onRefresh:B})).use(UA({clientProviders:R,authorizeRoute:z,onAuthorize:$})).use(WA({clientProviders:R,callbackRoute:U,onCallback:Q,getUser:F,createUser:H})).use(AA()).as("plugin")};export{Lg as absoluteAuth};
324
+ `,w.mapResponse?.length){U+=`let mr
325
+ `;for(let Q=0;Q<w.mapResponse.length;Q++){let J=w.mapResponse[Q],N=Y.resolveChild(J.fn.name);U+=`if(mr===undefined){mr=${O4(J)?"await ":""}onMapResponse[${Q}](context)
326
+ if(mr!==undefined)error=context.response=mr}`,N()}}return Y.resolve(),U+=`
327
+ return mapResponse(${$}error,set${W.mapResponseContext})}`,Function("inject",U)({app:z,mapResponse:z["~adapter"].handler.mapResponse,ERROR_CODE:m5,ElysiaCustomStatusResponse:K1,ELYSIA_TRACE:A?Jw:void 0,ELYSIA_REQUEST_ID:A?l5:void 0,...W.inject})},Uw=(z,w)=>{for(let[U,W]of Object.entries(z.schema.properties))w[U]??=W.default},TW=(z)=>{let{mapResponse:w,mapEarlyResponse:U}=z["~adapter"].handler;return async(W)=>{let X=W.url,A=X.indexOf("/",11),Z=X.indexOf("?",A+1),$=Z===-1?X.substring(A):X.substring(A,Z),Y={cookie:{},status:200,headers:{}},Q=Object.assign({},z.singleton.decorator,{set:Y,store:z.singleton.store,request:W,path:$,qi:Z,error:yW,redirect:cW});try{if(z.event.request)for(let E=0;E<z.event.request.length;E++){let T=z.event.request[E].fn,F=T(Q);if(F instanceof Promise)F=await F;if(F=U(F,Y),F)return Q.response=F}let J=z.router.dynamic.find(W.method,$)??z.router.dynamic.find("ALL",$);if(!J)throw new Qw;let{handle:N,hooks:S,validator:G,content:O,route:M}=J.store,C;if(W.method!=="GET"&&W.method!=="HEAD")if(O)switch(O){case"application/json":C=await W.json();break;case"text/plain":C=await W.text();break;case"application/x-www-form-urlencoded":C=v5(await W.text());break;case"application/octet-stream":C=await W.arrayBuffer();break;case"multipart/form-data":C={};let E=await W.formData();for(let T of E.keys()){if(C[T])continue;let F=E.getAll(T);if(F.length===1)C[T]=F[0];else C[T]=F}break}else{let E=W.headers.get("content-type");if(E){let T=E.indexOf(";");if(T!==-1)E=E.slice(0,T);if(Q.contentType=E,S.parse)for(let F=0;F<S.parse.length;F++){let a=S.parse[F].fn,Z0=a(Q,E);if(Z0 instanceof Promise)Z0=await Z0;if(Z0){C=Z0;break}}if(delete Q.contentType,C===void 0)switch(E){case"application/json":C=await W.json();break;case"text/plain":C=await W.text();break;case"application/x-www-form-urlencoded":C=v5(await W.text());break;case"application/octet-stream":C=await W.arrayBuffer();break;case"multipart/form-data":C={};let F=await W.formData();for(let a of F.keys()){if(C[a])continue;let Z0=F.getAll(a);if(Z0.length===1)C[a]=Z0[0];else C[a]=Z0}break}}}Q.route=M,Q.body=C,Q.params=J?.params||void 0,Q.query=Z===-1?{}:v5(X.substring(Z+1)),Q.headers={};for(let[E,T]of W.headers.entries())Q.headers[E]=T;let k=Object.assign({},z.config?.cookie,G?.cookie?.config),q0=W.headers.get("cookie");Q.cookie=await eW(Q.set,q0,k?{secrets:k.secrets!==void 0?typeof k.secrets==="string"?k.secrets:k.secrets.join(","):void 0,sign:k.sign===!0?!0:k.sign!==void 0?typeof k.sign==="string"?k.sign:k.sign.join(","):void 0}:void 0);let w0=G?.createHeaders?.();if(w0)Uw(w0,Q.headers);let _0=G?.createParams?.();if(_0)Uw(_0,Q.params);let C0=G?.createQuery?.();if(C0)Uw(C0,Q.query);if(S.transform)for(let E=0;E<S.transform.length;E++){let T=S.transform[E],F=T.fn(Q);if(T.subType==="derive")if(F instanceof Promise)Object.assign(Q,await F);else Object.assign(Q,F);else if(F instanceof Promise)await F}if(G){if(w0){let E=structuredClone(Q.headers);for(let[T,F]of W.headers)E[T]=F;if(G.headers.Check(E)===!1)throw new r("header",G.headers,E)}else if(G.headers?.Decode)Q.headers=G.headers.Decode(Q.headers);if(_0?.Check(Q.params)===!1)throw new r("params",G.params,Q.params);else if(G.params?.Decode)Q.params=G.params.Decode(Q.params);if(C0?.Check(Q.query)===!1)throw new r("query",G.query,Q.query);else if(G.query?.Decode)Q.query=G.query.Decode(Q.query);if(G.createCookie?.()){let E={};for(let[T,F]of Object.entries(Q.cookie))E[T]=F.value;if(G.cookie.Check(E)===!1)throw new r("cookie",G.cookie,E);else if(G.cookie?.Decode)E=G.cookie.Decode(E)}if(G.createBody?.()?.Check(C)===!1)throw new r("body",G.body,C);else if(G.body?.Decode)Q.body=G.body.Decode(C)}if(S.beforeHandle)for(let E=0;E<S.beforeHandle.length;E++){let T=S.beforeHandle[E],F=T.fn(Q);if(T.subType==="resolve"){if(F instanceof K1){let a=U(F,Q.set);if(a)return Q.response=a}if(F instanceof Promise)Object.assign(Q,await F);else Object.assign(Q,F);continue}else if(F instanceof Promise)F=await F;if(F!==void 0){if(Q.response=F,S.afterHandle)for(let Z0=0;Z0<S.afterHandle.length;Z0++){let H0=S.afterHandle[Z0].fn(Q);if(H0 instanceof Promise)H0=await H0;if(H0)F=H0}let a=U(F,Q.set);if(a)return Q.response=a}}let f=typeof N==="function"?N(Q):N;if(f instanceof Promise)f=await f;if(S.afterHandle)if(!S.afterHandle.length){let E=f instanceof K1?f.code:Y.status?typeof Y.status==="string"?p5[Y.status]:Y.status:200,T=G?.createResponse?.()?.[E];if(T?.Check(f)===!1)throw new r("response",T,f);else if(T?.Decode)f=T.Decode(f)}else{Q.response=f;for(let E=0;E<S.afterHandle.length;E++){let T=S.afterHandle[E].fn(Q);if(T instanceof Promise)T=await T;let F=U(T,Q.set);if(F!==void 0){let a=G?.response?.[F.status];if(a?.Check(F)===!1)throw new r("response",a,F);else if(a?.Decode)f=a.Decode(f);return Q.response=F}}}if(Q.set.cookie&&k?.sign){let E=!k.secrets?void 0:typeof k.secrets==="string"?k.secrets:k.secrets[0];if(k.sign===!0)for(let[T,F]of Object.entries(Q.set.cookie))Q.set.cookie[T].value=await u5(F.value,"${secret}");else{let T=G?.cookie?.schema?.properties;for(let F of k.sign){if(!(F in T))continue;if(Q.set.cookie[F]?.value)Q.set.cookie[F].value=await u5(Q.set.cookie[F].value,E)}}}return w(Q.response=f,Q.set)}catch(J){let N=J instanceof E5&&J.error?J.error:J;return z.handleError(Q,N)}finally{if(z.event.afterResponse)for(let J of z.event.afterResponse)await J.fn(Q)}}},kG=(z)=>{let{mapResponse:w}=z["~adapter"].handler;return async(U,W)=>{let X=Object.assign(U,{error:W,code:W.code});if(X.set=U.set,z.event.error)for(let A=0;A<z.event.error.length;A++){let Z=z.event.error[A].fn(X);if(Z instanceof Promise)Z=await Z;if(Z!==void 0&&Z!==null)return U.response=w(Z,U.set)}return new Response(typeof W.cause==="string"?W.cause:W.message,{headers:U.set.headers,status:W.status??500})}};class K0{config;server=null;dependencies={};_routes={};_types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}};_ephemeral={};_volatile={};singleton={decorator:{},store:{},derive:{},resolve:{}};get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}definitions={typebox:I.Module({}),type:{},error:{}};extender={macros:[],higherOrderFunctions:[]};validator={global:null,scoped:null,local:null,getCandidate(){return s4(s4(this.global,this.scoped),this.local)}};event={};telemetry={stack:void 0};router={"~http":void 0,get http(){if(!this["~http"])this["~http"]=new j6({lazy:!0});return this["~http"]},"~dynamic":void 0,get dynamic(){if(!this["~dynamic"])this["~dynamic"]=new j6;return this["~dynamic"]},static:{http:{static:{},map:{},all:""},ws:{}},history:[]};routeTree=new Map;get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1};getServer(){return this.server}getParent(){return null}"~parser"={};_promisedModules;get promisedModules(){if(!this._promisedModules)this._promisedModules=new hW;return this._promisedModules}constructor(z={}){if(z.tags)if(!z.detail)z.detail={tags:z.tags};else z.detail.tags=z.tags;if(z.nativeStaticResponse===void 0)z.nativeStaticResponse=!0;if(this.config={},this.applyConfig(z??{}),this["~adapter"]=z.adapter??(typeof Bun!=="undefined"?CG:y5),z?.analytic&&(z?.name||z?.seed!==void 0))this.telemetry.stack=new Error().stack}"~adapter";env(z,w=kW){if(j2(z,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0}).Check(w)===!1){let U=new r("env",z,w);throw new Error(U.all.map((W)=>W.summary).join(`
328
+ `))}return this}wrap(z){return this.extender.higherOrderFunctions.push({checksum:r4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:z.toString()})),fn:z}),this}applyMacro(z){if(this.extender.macros.length){let w=XG({globalHook:this.event,localHook:z}),U={events:{global:this.event,local:z},get onParse(){return w("parse")},get onTransform(){return w("transform")},get onBeforeHandle(){return w("beforeHandle")},get onAfterHandle(){return w("afterHandle")},get mapResponse(){return w("mapResponse")},get onAfterResponse(){return w("afterResponse")},get onError(){return w("error")}};for(let W of this.extender.macros)WG(W.fn(U),z,w)}}applyConfig(z){return this.config={prefix:"",aot:kW.ELYSIA_AOT!=="false",normalize:!0,...z,cookie:{path:"/",...z?.cookie},experimental:z?.experimental??{},seed:z?.seed===void 0?"":z?.seed},this}get models(){let z={};for(let w of Object.keys(this.definitions.type))z[w]=j2(this.definitions.typebox.Import(w));return z.modules=this.definitions.typebox,z}add(z,w,U,W,{allowMeta:X=!1,skipPrefix:A=!1}={allowMeta:!1,skipPrefix:!1}){if(W=zw(ZG(W)),w!==""&&w.charCodeAt(0)!==47)w="/"+w;if(this.config.prefix&&!A)w=this.config.prefix+w;if(W?.type)switch(W.type){case"text":W.type="text/plain";break;case"json":W.type="application/json";break;case"formdata":W.type="multipart/form-data";break;case"urlencoded":W.type="application/x-www-form-urlencoded";break;case"arrayBuffer":W.type="application/octet-stream";break;default:break}let Z=this.definitions.type,$=!this.config.aot,Y={...this.validator.getCandidate()},Q={body:W?.body??Y?.body,headers:W?.headers??Y?.headers,params:W?.params??Y?.params,query:W?.query??Y?.query,cookie:W?.cookie??Y?.cookie,response:W?.response??Y?.response},J=()=>Q.cookie?dW({modules:S,validator:Q.cookie,defaultConfig:this.config.cookie,config:Q.cookie?.config??{},dynamic:$,models:Z}):void 0,N=this.config.normalize,S=this.definitions.typebox,G=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:j2(Q.body,{modules:S,dynamic:$,models:Z,normalize:N,additionalCoerce:_W()}),headers:j2(Q.headers,{modules:S,dynamic:$,models:Z,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:y6()}),params:j2(Q.params,{modules:S,dynamic:$,models:Z,coerce:!0,additionalCoerce:y6()}),query:j2(Q.query,{modules:S,dynamic:$,models:Z,normalize:N,coerce:!0,additionalCoerce:y6()}),cookie:J(),response:HW(Q.response,{modules:S,dynamic:$,models:Z,normalize:N})}:{createBody(){if(this.body)return this.body;return this.body=j2(Q.body,{modules:S,dynamic:$,models:Z,normalize:N,additionalCoerce:_W()})},createHeaders(){if(this.headers)return this.headers;return this.headers=j2(Q.headers,{modules:S,dynamic:$,models:Z,additionalProperties:!N,coerce:!0,additionalCoerce:y6()})},createParams(){if(this.params)return this.params;return this.params=j2(Q.params,{modules:S,dynamic:$,models:Z,coerce:!0,additionalCoerce:y6()})},createQuery(){if(this.query)return this.query;return this.query=j2(Q.query,{modules:S,dynamic:$,models:Z,coerce:!0,additionalCoerce:y6()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=J()},createResponse(){if(this.response)return this.response;return this.response=HW(Q.response,{modules:S,dynamic:$,models:Z,normalize:N})}};if(W=z6(W,zw(Y)),W.tags)if(!W.detail)W.detail={tags:W.tags};else W.detail.tags=W.tags;if(w1(this.config.detail))W.detail=F2(Object.assign({},this.config.detail),W.detail);this.applyMacro(W);let O=zw(z6(this.event,W));if(this.config.aot===!1){this.router.dynamic.add(z,w,{validator:G,hooks:O,content:W?.type,handle:U,route:w});let H0=a4(w,{dynamic:!0});if(w!==H0)this.router.dynamic.add(z,H0,{validator:G,hooks:O,content:W?.type,handle:U,route:w});if(this.config.strictPath===!1){let h0=D4(w);this.router.dynamic.add(z,h0,{validator:G,hooks:O,content:W?.type,handle:U,route:w});let U6=a4(h0);if(h0!==U6)this.router.dynamic.add(z,h0,{validator:G,hooks:O,content:W?.type,handle:U,route:w})}this.router.history.push({method:z,path:w,composed:null,handler:U,hooks:O});return}let M=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,C=ez(this.inference),k=this["~adapter"].handler,q0=typeof U!=="function"&&typeof k.createStaticHandler==="function"?k.createStaticHandler(U,O,this.setHeaders):void 0,w0=typeof U!=="function"?k.createNativeStaticHandler?.(U,O,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&w0&&(z==="GET"||z==="ALL"))this.router.static.http.static[w]=w0();let _0=(H0=!1)=>VG({app:this,path:w,method:z,hooks:O,validator:G,handler:typeof U!=="function"&&typeof k.createStaticHandler!=="function"?()=>U:U,allowMeta:X,inference:C,asManifest:H0}),C0;if(this.routeTree.has(z+w))for(let H0=0;H0<this.router.history.length;H0++){let h0=this.router.history[H0];if(h0.path===w&&h0.method===z){C0=H0;break}}else this.routeTree.set(z+w,this.router.history.length);let f=this.router.history,E=C0??this.router.history.length,T=M?_0():(H0)=>{let h0=(f[E].composed=_0())(H0);return _0=void 0,h0};if(M)_0=void 0;let F=z==="$INTERNALWS";if(C0!==void 0)this.router.history[C0]=Object.assign({method:z,path:w,composed:T,handler:U,hooks:O},W.webSocket?{websocket:W.websocket}:{});else this.router.history.push(Object.assign({method:z,path:w,composed:T,handler:U,hooks:O},W.webSocket?{websocket:W.websocket}:{}));let a=this.router.static.http,Z0={handler:M?T:void 0,compile(){return this.handler=_0()}};if(F){if(this.router.http.add("ws",w,Z0),!this.config.strictPath)this.router.http.add("ws",D4(w),Z0);let H0=a4(w,{dynamic:!0});if(H0!==w)this.router.http.add("ws",H0,Z0);return}if(w.indexOf(":")===-1&&w.indexOf("*")===-1){if(!a.map[w])a.map[w]={code:""};let H0=q0?"":"c";if(z==="ALL")a.map[w].all=`default:return ht[${E}].composed(${H0})
329
+ `;else a.map[w].code=`case '${z}':return ht[${E}].composed(${H0})
330
+ ${a.map[w].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&w0&&(z==="GET"||z==="ALL"))this.router.static.http.static[D4(w)]=w0()}else{if(this.router.http.add(z,w,Z0),!this.config.strictPath){let h0=D4(w);if(this.config.nativeStaticResponse===!0&&q0&&(z==="GET"||z==="ALL"))this.router.static.http.static[h0]=q0();this.router.http.add(z,h0,Z0)}let H0=a4(w,{dynamic:!0});if(w!==H0){if(this.router.http.add(z,H0,Z0),this.config.nativeStaticResponse===!0&&q0&&(z==="GET"||z==="ALL"))this.router.static.http.static[H0]=q0();this.router.http.add(z,H0,Z0)}}}setHeaders;headers(z){if(!z)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=F2(this.setHeaders,z),this}onStart(z){return this.on("start",z),this}onRequest(z){return this.on("request",z),this}onParse(z,w){if(!w){if(typeof z==="string")return this.on("parse",this["~parser"][z]);return this.on("parse",z)}return this.on(z,"parse",w)}parser(z,w){return this["~parser"][z]=w,this}onTransform(z,w){if(!w)return this.on("transform",z);return this.on(z,"transform",w)}resolve(z,w){if(!w)w=z,z={as:"local"};let U={subType:"resolve",fn:w};return this.onBeforeHandle(z,U)}mapResolve(z,w){if(!w)w=z,z={as:"local"};let U={subType:"mapResolve",fn:w};return this.onBeforeHandle(z,U)}onBeforeHandle(z,w){if(!w)return this.on("beforeHandle",z);return this.on(z,"beforeHandle",w)}onAfterHandle(z,w){if(!w)return this.on("afterHandle",z);return this.on(z,"afterHandle",w)}mapResponse(z,w){if(!w)return this.on("mapResponse",z);return this.on(z,"mapResponse",w)}onAfterResponse(z,w){if(!w)return this.on("afterResponse",z);return this.on(z,"afterResponse",w)}trace(z,w){if(!w)w=z,z={as:"local"};if(!Array.isArray(w))w=[w];for(let U of w)this.on(z,"trace",FG(U));return this}error(z,w){switch(typeof z){case"string":return w.prototype[m5]=z,this.definitions.error[z]=w,this;case"function":return this.definitions.error=z(this.definitions.error),this}for(let[U,W]of Object.entries(z))W.prototype[m5]=U,this.definitions.error[U]=W;return this}onError(z,w){if(!w)return this.on("error",z);return this.on(z,"error",w)}onStop(z){return this.on("stop",z),this}on(z,w,U){let W;switch(typeof z){case"string":W=z,U=w;break;case"object":if(W=w,!Array.isArray(w)&&typeof w==="object")U=w;break}if(Array.isArray(U))U=W2(U);else if(typeof U==="function")U=[{fn:U}];else U=[U];let X=U;for(let A of X)if(A.scope=typeof z==="string"?"local":z?.as??"local",W==="resolve"||W==="derive")A.subType=W;if(W!=="trace")rW({[W]:X.map((A)=>A.fn)},this.inference);for(let A of X){let Z=wG(A,"global",{skipIfHasType:!0});switch(W){case"start":this.event.start??=[],this.event.start.push(Z);break;case"request":this.event.request??=[],this.event.request.push(Z);break;case"parse":this.event.parse??=[],this.event.parse.push(Z);break;case"transform":this.event.transform??=[],this.event.transform.push(Z);break;case"derive":this.event.transform??=[],this.event.transform.push(W2(Z,"derive"));break;case"beforeHandle":this.event.beforeHandle??=[],this.event.beforeHandle.push(Z);break;case"resolve":this.event.beforeHandle??=[],this.event.beforeHandle.push(W2(Z,"resolve"));break;case"afterHandle":this.event.afterHandle??=[],this.event.afterHandle.push(Z);break;case"mapResponse":this.event.mapResponse??=[],this.event.mapResponse.push(Z);break;case"afterResponse":this.event.afterResponse??=[],this.event.afterResponse.push(Z);break;case"trace":this.event.trace??=[],this.event.trace.push(Z);break;case"error":this.event.error??=[],this.event.error.push(Z);break;case"stop":this.event.stop??=[],this.event.stop.push(Z);break}}return this}propagate(){return L2(this.event.parse),L2(this.event.transform),L2(this.event.beforeHandle),L2(this.event.afterHandle),L2(this.event.mapResponse),L2(this.event.afterResponse),L2(this.event.trace),L2(this.event.error),this}as(z){let w={plugin:"scoped",scoped:"scoped",global:"global"}[z];if(L2(this.event.parse,w),L2(this.event.transform,w),L2(this.event.beforeHandle,w),L2(this.event.afterHandle,w),L2(this.event.mapResponse,w),L2(this.event.afterResponse,w),L2(this.event.trace,w),L2(this.event.error,w),z==="plugin")this.validator.scoped=s4(this.validator.scoped,this.validator.local),this.validator.local=null;else if(z==="global")this.validator.global=s4(this.validator.global,s4(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(z,w,U){let W=new K0({...this.config,prefix:""});W.singleton={...this.singleton},W.definitions={...this.definitions},W.getServer=()=>this.getServer(),W.inference=ez(this.inference),W.extender={...this.extender};let X=typeof w==="object",A=(X?U:w)(W);if(this.singleton=F2(this.singleton,W.singleton),this.definitions=F2(this.definitions,W.definitions),A.event.request?.length)this.event.request=[...this.event.request||[],...A.event.request||[]];if(A.event.mapResponse?.length)this.event.mapResponse=[...this.event.mapResponse||[],...A.event.mapResponse||[]];return this.model(A.definitions.type),Object.values(W.router.history).forEach(({method:Z,path:$,handler:Y,hooks:Q})=>{if($=(X?"":this.config.prefix)+z+$,X){let J=w,N=Q;this.add(Z,$,Y,z6(J,{...N||{},error:!N.error?A.event.error:Array.isArray(N.error)?[...N.error||{},...A.event.error||{}]:[N.error,...A.event.error||{}]}))}else this.add(Z,$,Y,z6(Q,{error:A.event.error}),{skipPrefix:!0})}),this}guard(z,w){if(!w){if(typeof z==="object"){this.applyMacro(z);let X=z.as??"local";if(this.validator[X]={body:z.body??this.validator[X]?.body,headers:z.headers??this.validator[X]?.headers,params:z.params??this.validator[X]?.params,query:z.query??this.validator[X]?.query,response:z.response??this.validator[X]?.response,cookie:z.cookie??this.validator[X]?.cookie},z.parse)this.on({as:X},"parse",z.parse);if(z.transform)this.on({as:X},"transform",z.transform);if(z.derive)this.on({as:X},"derive",z.derive);if(z.beforeHandle)this.on({as:X},"beforeHandle",z.beforeHandle);if(z.resolve)this.on({as:X},"resolve",z.resolve);if(z.afterHandle)this.on({as:X},"afterHandle",z.afterHandle);if(z.mapResponse)this.on({as:X},"mapResponse",z.mapResponse);if(z.afterResponse)this.on({as:X},"afterResponse",z.afterResponse);if(z.error)this.on({as:X},"error",z.error);if(z.detail)if(this.config.detail)this.config.detail=F2(Object.assign({},this.config.detail),z.detail);else this.config.detail=z.detail;if(z?.tags)if(!this.config.detail)this.config.detail={tags:z.tags};else this.config.detail.tags=z.tags;return this}return this.guard({},z)}let U=new K0({...this.config,prefix:""});U.singleton={...this.singleton},U.definitions={...this.definitions},U.inference=ez(this.inference),U.extender={...this.extender};let W=w(U);if(this.singleton=F2(this.singleton,U.singleton),this.definitions=F2(this.definitions,U.definitions),W.getServer=()=>this.server,W.event.request?.length)this.event.request=[...this.event.request||[],...W.event.request||[]];if(W.event.mapResponse?.length)this.event.mapResponse=[...this.event.mapResponse||[],...W.event.mapResponse||[]];return this.model(W.definitions.type),Object.values(U.router.history).forEach(({method:X,path:A,handler:Z,hooks:$})=>{this.add(X,A,Z,z6(z,{...$||{},error:!$.error?W.event.error:Array.isArray($.error)?[...$.error||{},...W.event.error||[]]:[$.error,...W.event.error||[]]}))}),this}use(z,w){if(Array.isArray(z)){let U=this;for(let W of z)U=U.use(W);return U}if(w?.scoped)return this.guard({},(U)=>U.use(z));if(Array.isArray(z)){let U=this;for(let W of z)U=this.use(W);return U}if(z instanceof Promise)return this.promisedModules.add(z.then((U)=>{if(typeof U==="function")return U(this);if(U instanceof K0)return this._use(U).compile();if(U.constructor.name==="Elysia")return this._use(U).compile();if(typeof U.default==="function")return U.default(this);if(U.default instanceof K0)return this._use(U.default);if(U.constructor.name==="Elysia")return this._use(U.default);if(U.constructor.name==="_Elysia")return this._use(U.default);try{return this._use(U.default)}catch(W){throw console.error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.'),W}}).then((U)=>{if(U&&typeof U.compile==="function")U.compile();return U})),this;return this._use(z)}propagatePromiseModules(z){if(z.promisedModules.size<=0)return this;for(let w of z.promisedModules.promises)this.promisedModules.add(w.then((U)=>{if(!U)return;let W=this._use(U);if(W instanceof Promise)return W.then((X)=>{if(X)X.compile();else U.compile()});return U.compile()}));return this}_use(z){if(typeof z==="function"){let X=z(this);if(X instanceof Promise)return this.promisedModules.add(X.then((A)=>{if(A instanceof K0){A.getServer=()=>this.getServer(),A.getGlobalRoutes=()=>this.getGlobalRoutes(),A.model(this.definitions.type),A.error(this.definitions.error);for(let{method:Z,path:$,handler:Y,hooks:Q}of Object.values(A.router.history))this.add(Z,$,Y,z6(Q,{error:A.event.error}));if(A.compile(),A===this)return;return this.propagatePromiseModules(A),A}if(typeof A==="function")return A(this);if(typeof A.default==="function")return A.default(this);return this._use(A)}).then((A)=>{if(A&&typeof A.compile==="function")A.compile();return A})),this;return X}this.propagatePromiseModules(z);let{name:w,seed:U}=z.config;if(z.getParent=()=>this,z.getServer=()=>this.getServer(),z.getGlobalRoutes=()=>this.getGlobalRoutes(),z.model(this.definitions.type),z.error(this.definitions.error),this["~parser"]={...z["~parser"],...this["~parser"]},this.headers(z.setHeaders),w){if(!(w in this.dependencies))this.dependencies[w]=[];let X=U!==void 0?r4(w+JSON.stringify(U)):0;if(!this.dependencies[w].some(({checksum:A})=>X===A))this.extender.macros=this.extender.macros.concat(z.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(z.extender.higherOrderFunctions)}else this.extender.macros=this.extender.macros.concat(z.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(z.extender.higherOrderFunctions);bW(this.extender.macros),bW(this.extender.higherOrderFunctions);let W=[];for(let X=0;X<this.extender.higherOrderFunctions.length;X++){let A=this.extender.higherOrderFunctions[X];if(A.checksum){if(W.includes(A.checksum))this.extender.higherOrderFunctions.splice(X,1),X--;W.push(A.checksum)}}this.inference={body:this.inference.body||z.inference.body,cookie:this.inference.cookie||z.inference.cookie,headers:this.inference.headers||z.inference.headers,query:this.inference.query||z.inference.query,set:this.inference.set||z.inference.set,server:this.inference.server||z.inference.server,request:this.inference.request||z.inference.request,route:this.inference.route||z.inference.route},this.decorate(z.singleton.decorator),this.state(z.singleton.store),this.model(z.definitions.type),this.error(z.definitions.error),z.extender.macros=this.extender.macros.concat(z.extender.macros);for(let{method:X,path:A,handler:Z,hooks:$}of Object.values(z.router.history))this.add(X,A,Z,z6($,{error:z.event.error}));if(w){if(!(w in this.dependencies))this.dependencies[w]=[];let X=U!==void 0?r4(w+JSON.stringify(U)):0;if(this.dependencies[w].some(({checksum:A})=>X===A))return this;this.dependencies[w].push(this.config?.analytic?{name:z.config.name,seed:z.config.seed,checksum:X,dependencies:z.dependencies,stack:z.telemetry.stack,routes:z.router.history,decorators:z.singleton,store:z.singleton.store,error:z.definitions.error,derive:z.event.transform?.filter((A)=>A?.subType==="derive").map((A)=>({fn:A.toString(),stack:new Error().stack??""})),resolve:z.event.transform?.filter((A)=>A?.subType==="resolve").map((A)=>({fn:A.toString(),stack:new Error().stack??""}))}:{name:z.config.name,seed:z.config.seed,checksum:X,dependencies:z.dependencies}),this.event=SW(this.event,DW(z.event),X)}else this.event=SW(this.event,DW(z.event));return this.validator.global=z6(this.validator.global,{...z.validator.global}),this.validator.local=z6(this.validator.local,{...z.validator.scoped}),this}macro(z){if(typeof z==="function"){let w={checksum:r4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:z.toString()})),fn:z};this.extender.macros.push(w)}else if(typeof z==="object"){for(let U of Object.keys(z))if(typeof z[U]==="object"){let W={...z[U]};z[U]=(X)=>{if(X===!0)return W}}let w={checksum:r4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(z).map(([U,W])=>`${U}+${W}`).join(",")})),fn:()=>z};this.extender.macros.push(w)}return this}mount(z,w){if(z instanceof K0||typeof z==="function"||z.length===0||z==="/"){let X=typeof z==="function"?z:z instanceof K0?z.compile().fetch:w instanceof K0?w.compile().fetch:w,A=({request:Z,path:$})=>X(new Request(GW(Z.url,$),{method:Z.method,headers:Z.headers,signal:Z.signal,credentials:Z.credentials,referrerPolicy:Z.referrerPolicy,duplex:Z.duplex,redirect:Z.redirect,mode:Z.mode,keepalive:Z.keepalive,integrity:Z.integrity,body:Z.body}));return this.all("/*",A,{parse:"none"}),this}if(!w)return this;let U=z.length-(z.endsWith("*")?1:0);if(w instanceof K0)w=w.compile().fetch;let W=({request:X,path:A})=>w(new Request(GW(X.url,A.slice(U)||"/"),{method:X.method,headers:X.headers,signal:X.signal,credentials:X.credentials,referrerPolicy:X.referrerPolicy,duplex:X.duplex,redirect:X.redirect,mode:X.mode,keepalive:X.keepalive,integrity:X.integrity,body:X.body}));return this.all(z,W,{parse:"none"}),this.all(z+(z.endsWith("/")?"*":"/*"),W,{parse:"none"}),this}get(z,w,U){return this.add("GET",z,w,U),this}post(z,w,U){return this.add("POST",z,w,U),this}put(z,w,U){return this.add("PUT",z,w,U),this}patch(z,w,U){return this.add("PATCH",z,w,U),this}delete(z,w,U){return this.add("DELETE",z,w,U),this}options(z,w,U){return this.add("OPTIONS",z,w,U),this}all(z,w,U){return this.add("ALL",z,w,U),this}head(z,w,U){return this.add("HEAD",z,w,U),this}connect(z,w,U){return this.add("CONNECT",z,w,U),this}route(z,w,U,W){return this.add(z.toUpperCase(),w,U,W,W?.config),this}ws(z,w){if(this["~adapter"].ws)this["~adapter"].ws(this,z,w);else console.warn("Current adapter doesn't support WebSocket");return this}state(z,w,U){if(w===void 0)U=z,z={as:"append"},w="";else if(U===void 0){if(typeof z==="string")U=w,w=z,z={as:"append"};else if(typeof z==="object")U=w,w=""}let{as:W}=z;if(typeof w!=="string")return this;switch(typeof U){case"object":if(w){if(w in this.singleton.store)this.singleton.store[w]=F2(this.singleton.store[w],U,{override:W==="override"});else this.singleton.store[w]=U;return this}if(U===null)return this;return this.singleton.store=F2(this.singleton.store,U,{override:W==="override"}),this;case"function":if(w){if(W==="override"||!(w in this.singleton.store))this.singleton.store[w]=U}else this.singleton.store=U(this.singleton.store);return this;default:if(W==="override"||!(w in this.singleton.store))this.singleton.store[w]=U;return this}}decorate(z,w,U){if(w===void 0)U=z,z={as:"append"},w="";else if(U===void 0){if(typeof z==="string")U=w,w=z,z={as:"append"};else if(typeof z==="object")U=w,w=""}let{as:W}=z;if(typeof w!=="string")return this;switch(typeof U){case"object":if(w){if(w in this.singleton.decorator)this.singleton.decorator[w]=F2(this.singleton.decorator[w],U,{override:W==="override"});else this.singleton.decorator[w]=U;return this}if(U===null)return this;return this.singleton.decorator=F2(this.singleton.decorator,U,{override:W==="override"}),this;case"function":if(w){if(W==="override"||!(w in this.singleton.decorator))this.singleton.decorator[w]=U}else this.singleton.decorator=U(this.singleton.decorator);return this;default:if(W==="override"||!(w in this.singleton.decorator))this.singleton.decorator[w]=U;return this}}derive(z,w){if(!w)w=z,z={as:"local"};let U={subType:"derive",fn:w};return this.onTransform(z,U)}model(z,w){let U=(W)=>Xw(W,[{from:I.Number(),to:(X)=>I.Numeric(X),untilObjectFound:!0},{from:I.Boolean(),to:(X)=>I.BooleanString(X),untilObjectFound:!0}]);switch(typeof z){case"object":let W={},X=Object.entries(z);for(let[$,Y]of X){if($ in this.definitions.type)continue;W[$]=this.definitions.type[$]=U(Y),W[$].$id??=`#/components/schemas/${$}`}return this.definitions.typebox=I.Module({...this.definitions.typebox.$defs,...W}),this;case"function":let A=U(z(this.definitions.type));return this.definitions.type=A,this.definitions.typebox=I.Module(A),this;case"string":if(!w)break;let Z={...w,id:w.$id??`#/components/schemas/${z}`};return this.definitions.type[z]=w,this.definitions.typebox=I.Module({...this.definitions.typebox.$defs,...Z}),this}return this.definitions.type[z]=w,this.definitions.typebox=I.Module({...this.definitions.typebox.$defs,[z]:w}),this}mapDerive(z,w){if(!w)w=z,z={as:"local"};let U={subType:"mapDerive",fn:w};return this.onTransform(z,U)}affix(z,w,U){if(U==="")return this;let W=["_","-"," "],X=(Y)=>Y[0].toUpperCase()+Y.slice(1),A=z==="prefix"?(Y,Q)=>W.includes(Y.at(-1)??"")?Y+Q:Y+X(Q):W.includes(U.at(-1)??"")?(Y,Q)=>Q+Y:(Y,Q)=>Q+X(Y),Z=(Y)=>{let Q={};switch(Y){case"decorator":for(let J in this.singleton.decorator)Q[A(U,J)]=this.singleton.decorator[J];this.singleton.decorator=Q;break;case"state":for(let J in this.singleton.store)Q[A(U,J)]=this.singleton.store[J];this.singleton.store=Q;break;case"model":for(let J in this.definitions.type)Q[A(U,J)]=this.definitions.type[J];this.definitions.type=Q;break;case"error":for(let J in this.definitions.error)Q[A(U,J)]=this.definitions.error[J];this.definitions.error=Q;break}},$=Array.isArray(w)?w:[w];for(let Y of $.some((Q)=>Q==="all")?["decorator","state","model","error"]:$)Z(Y);return this}prefix(z,w){return this.affix("prefix",z,w)}suffix(z,w){return this.affix("suffix",z,w)}compile(){if(this["~adapter"].isWebStandard){if(this.fetch=this.config.aot?ww(this):TW(this),typeof this.server?.reload==="function")this.server.reload({...this.server||{},fetch:this.fetch});return this}if(typeof this.server?.reload==="function")this.server.reload(this.server||{});return this._handle=ww(this),this}handle=async(z)=>this.fetch(z);fetch=(z)=>{return(this.fetch=this.config.aot?ww(this):TW(this))(z)};handleError=async(z,w)=>{return(this.handleError=this.config.aot?WX(this):kG(this))(z,w)};outerErrorHandler=(z)=>new Response(z.message||z.name||"Error",{status:z?.status??500});listen=(z,w)=>{return this["~adapter"].listen(this)(z,w),this};stop=async(z)=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server){if(this.server.stop(z),this.server=null,this.event.stop?.length)for(let w=0;w<this.event.stop.length;w++)this.event.stop[w].fn(this)}};get modules(){return this.promisedModules}}var U8={AmazonCognito:Z8,AniList:$8,Apple:Q8,Atlassian:J8,Auth0:B8,Authentik:M8,Bitbucket:q8,Box:L8,Coinbase:N8,Discord:G8,Dribbble:H8,Dropbox:_8,Facebook:S8,Figma:D8,FortyTwo:e8,GitHub:P8,GitLab:O8,Google:R8,Intuit:C8,Kakao:b8,KeyCloak:K8,Lichess:F8,Line:j8,Linear:E8,LinkedIn:I8,MicrosoftEntraId:x8,MyAnimeList:V8,Notion:k8,Okta:T8,Osu:g8,Patreon:f8,Reddit:d8,Roblox:h8,Salesforce:c8,Shikimori:i8,Slack:y8,Spotify:v8,Strava:n8,Tiltify:u8,Tumblr:m8,Twitch:t8,Twitter:o8,VK:p8,WorkOS:l8,Yahoo:s8,Yandex:r8,Zoom:a8},XX=Object.keys(U8).reduce((z,w)=>{return z[w.toLowerCase()]=w,z},{});var r5=(z)=>("refreshAccessToken"in z)&&typeof z.refreshAccessToken==="function",AX=(z)=>("revokeAccessToken"in z)&&typeof z.revokeAccessToken==="function",t6=(z)=>Object.keys(U8).map((w)=>w.toLowerCase()).includes(z.toLowerCase()),ZX=(z)=>!0,$X=(z)=>z!==null&&z!==void 0&&z.trim()!=="";var YX=86400000;var W8=1800;var QX=({clientProviders:z,authorizeRoute:w="authorize",onAuthorize:U})=>new K0().get(`/${w}/:provider`,({error:W,redirect:X,cookie:{state:A,code_verifier:Z,auth_provider:$,redirect_url:Y},params:{provider:Q},headers:J})=>{if(Q===void 0)return W("Bad Request","Provider is required");if(!t6(Q))return W("Bad Request","Invalid provider");try{let N=Q.toLowerCase(),{providerInstance:S,scopes:G,searchParams:O}=z[N],M=J.referer??"/";Y.set({httpOnly:!0,maxAge:W8,path:"/",sameSite:"lax",secure:!0,value:M}),$.set({httpOnly:!0,maxAge:W8,path:"/",sameSite:"lax",secure:!0,value:Q});let C=Xz();A.set({httpOnly:!0,maxAge:W8,path:"/",sameSite:"lax",secure:!0,value:C});let k=S.createAuthorizationURL.toString().includes("codeVerifier"),q0=k?Wz():void 0;k&&Z.set({httpOnly:!0,maxAge:W8,path:"/",sameSite:"lax",secure:!0,value:q0??""});let w0=k?S.createAuthorizationURL(C,q0,G):S.createAuthorizationURL(C,G);return O.forEach(([_0,C0])=>{w0.searchParams.set(_0,C0)}),U?.(),X(w0.toString())}catch(N){if(N instanceof Error)return W("Internal Server Error",`Failed to authorize: ${N.message}`);return W("Internal Server Error",`Unknown error: ${N}`)}});var C4=()=>{let z={};return new K0({name:"sessionStore"}).state({session:z})};var JX=({clientProviders:z,callbackRoute:w="authorize/callback",onCallback:U,getUser:W,createUser:X})=>new K0().use(C4()).get(`/${w}`,async({error:A,redirect:Z,store:{session:$},cookie:{state:Y,code_verifier:Q,redirect_url:J,user_session_id:N,auth_provider:S},query:{code:G,state:O}})=>{if(!$X(G)||Y.value===void 0)return A("Bad Request","Invalid callback request");if(O!==Y.value)return A("Bad Request","Invalid state mismatch");if(S.value===void 0)return A("Unauthorized","No auth provider found");if(!t6(S.value))return A("Unauthorized","Invalid provider");let M=S.value.toLowerCase(),{providerInstance:C}=z[M];try{Y.remove();let k=C.validateAuthorizationCode.toString().includes("codeVerifier"),q0=Q.value;if(k&&q0===void 0)return A("Bad Request","Code verifier not found and is required");let w0=q0??"",_0=await(k?C.validateAuthorizationCode(G,w0):C.validateAuthorizationCode(G));if(k)Q.remove();let C0=Object.fromEntries(Object.entries($z(_0.idToken())).map(([a,Z0])=>[a,typeof Z0==="string"?Z0:void 0])),f=S.value,E=await W?.({authProvider:f,decodedIdToken:C0});if(E=E??await X?.({authProvider:f,decodedIdToken:C0}),!ZX(E))return A("Internal Server Error","Invalid user schema");let T=crypto.randomUUID();$[T]={expiresAt:Date.now()+YX,user:E},N.set({httpOnly:!0,sameSite:"lax",secure:!0,value:T}),U?.();let F=J.value??"/";return Z(F)}catch(k){if(k instanceof Error)return A("Internal Server Error",`${k.message} - ${k.stack??""}`);return A("Internal Server Error",`Failed to validate authorization code: Unknown error: ${k}`)}});var BX=({logoutRoute:z="logout",onLogout:w})=>new K0().post(`/${z}`,async({error:U,cookie:{user_session_id:W,auth_provider:X}})=>{if(X.value===void 0)return U("Unauthorized","No auth provider found");try{return w?.(),W.remove(),X.remove(),new Response("Succesfuly Logged Out",{status:204})}catch(A){if(A instanceof Error)return U("Internal Server Error",`Failed to logout: ${A.message}`);return U("Internal Server Error",`Failed to logout: Unknown error: ${A}`)}});var MX=()=>new K0().use(C4()).derive(({store:{session:z},cookie:{user_session_id:w},error:U})=>({protectRoute:async(W,X)=>{if(w.value===void 0)return X?.()??U("Unauthorized","No session ID found");if(z[w.value]===void 0)return X?.()??U("Unauthorized","No session found");return W()}})).as("plugin");var qX=({clientProviders:z,refreshRoute:w="refresh",onRefresh:U})=>new K0().post(`/${w}`,async({error:W,cookie:{user_refresh_token:X,auth_provider:A}})=>{if(X.value===void 0)return W("Unauthorized","No refresh token found");if(A.value===void 0)return W("Unauthorized","No auth provider found");let Z=A.value.toLowerCase(),{providerInstance:$}=z[Z];if(!r5($))return W("Not Implemented","Provider is not refreshable");try{return await $.refreshAccessToken(X.value),U?.(),new Response("Token refreshed",{status:204})}catch(Y){if(Y instanceof Error)return W("Internal Server Error",`Failed to refresh token: ${Y.message}`);return W("Internal Server Error",`Faile to refresh token: Unknown error: ${Y}`)}});var LX=({clientProviders:z,revokeRoute:w="revoke",onRevoke:U})=>new K0().post(`/${w}/access-token`,async({error:W,cookie:{user_refresh_token:X,auth_provider:A}})=>{if(X.value===void 0)return W("Unauthorized","No refresh token found");if(A.value===void 0)return W("Unauthorized","No auth provider found");let Z=A.value.toLowerCase(),{providerInstance:$}=z[Z];if(!AX($))return W("Not Implemented","Provider does not support revocation");try{return await $.revokeAccessToken(X.value),U?.(),new Response("Token revoked",{status:204})}catch(Y){if(Y instanceof Error)return W("Internal Server Error",`Failed to revoke token: ${Y.message}`);return W("Internal Server Error",`Failed to revoke token: Unknown error: ${Y}`)}});var NX=({clientProviders:z,statusRoute:w="auth-status",onStatus:U})=>new K0().use(C4()).get(`/${w}`,async({error:W,cookie:{user_session_id:X,auth_provider:A},store:{session:Z}})=>{try{if(X.value===void 0)return new Response(JSON.stringify({isLoggedIn:!1,user:null}),{headers:{"Content-Type":"application/json"}});if(A.value===void 0)return new Response(JSON.stringify({isLoggedIn:!1,user:null}),{headers:{"Content-Type":"application/json"}});let $=A.value.toLowerCase(),{providerInstance:Y}=z[$];if(!r5(Y))return W("Not Implemented","Provider is not refreshable");let Q=Z[X.value];if(Q===void 0)return new Response(JSON.stringify({isLoggedIn:!1,user:null}),{headers:{"Content-Type":"application/json"}});let{user:J}=Q;return U?.(),new Response(JSON.stringify({isLoggedIn:!0,user:J}),{headers:{"Content-Type":"application/json"}})}catch($){if($ instanceof Error)return W("Internal Server Error",`Error: ${$.message} - ${$.stack??""}`);return W("Internal Server Error",`Unknown Error: ${$}`)}});var zd=({config:z,authorizeRoute:w,callbackRoute:U,logoutRoute:W,statusRoute:X,refreshRoute:A,revokeRoute:Z,onAuthorize:$,onCallback:Y,onStatus:Q,onRefresh:J,onLogout:N,onRevoke:S,createUser:G,getUser:O})=>{let M=Object.keys(z).reduce((C,k)=>{if(!Object.prototype.hasOwnProperty.call(z,k))return C;if(!t6(k))return console.error(`Provider ${k} is not supported`),C;let q0=z[k];if(!q0)return C;let w0=k.toLowerCase(),_0=XX[w0];if(!t6(_0))return console.error(`Provider ${k} is not supported`),C;let C0=U8[_0],{credentials:f,scopes:E=[],searchParams:T=[]}=q0,F=new C0(...f);return C[w0]={providerInstance:F,scopes:E,searchParams:T},C},{});return new K0().error("OAUTH2_REQUEST_ERROR",F4).error("ARCTIC_FETCH_ERROR",$6).use(BX({logoutRoute:W,onLogout:N})).use(LX({clientProviders:M,onRevoke:S,revokeRoute:Z})).use(NX({clientProviders:M,onStatus:Q,statusRoute:X})).use(qX({clientProviders:M,onRefresh:J,refreshRoute:A})).use(QX({authorizeRoute:w,clientProviders:M,onAuthorize:$})).use(JX({callbackRoute:U,clientProviders:M,createUser:G,getUser:O,onCallback:Y})).use(MX()).as("plugin")};export{zd as absoluteAuth};