veloce-ts 0.4.18 → 1.0.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/CHANGELOG.md +94 -1
- package/MIGRATION.md +109 -0
- package/README.md +10 -1
- package/dist/cjs/src/adapters/hono.js +2 -2
- package/dist/cjs/src/adapters/hono.js.map +3 -3
- package/dist/cjs/src/auth/index.js +3 -16
- package/dist/cjs/src/auth/index.js.map +11 -15
- package/dist/cjs/src/graphql/index.js +13 -26
- package/dist/cjs/src/graphql/index.js.map +5 -6
- package/dist/cjs/src/index.js +49 -62
- package/dist/cjs/src/index.js.map +37 -56
- package/dist/cjs/src/middleware/index.js +8 -8
- package/dist/cjs/src/middleware/index.js.map +4 -4
- package/dist/cjs/src/plugins/index.js +35 -48
- package/dist/cjs/src/plugins/index.js.map +6 -7
- package/dist/cjs/src/testing/index.js +32 -45
- package/dist/cjs/src/testing/index.js.map +11 -37
- package/dist/cjs/src/validation/index.js +2 -2
- package/dist/cjs/src/validation/index.js.map +3 -3
- package/dist/cjs/src/websocket/index.js +2 -15
- package/dist/cjs/src/websocket/index.js.map +5 -6
- package/dist/esm/src/adapters/express.js +3 -3
- package/dist/esm/src/adapters/express.js.map +2 -2
- package/dist/esm/src/adapters/hono.js +2 -2
- package/dist/esm/src/adapters/hono.js.map +3 -3
- package/dist/esm/src/auth/index.js +3 -16
- package/dist/esm/src/auth/index.js.map +11 -15
- package/dist/esm/src/cli/index.js +32 -32
- package/dist/esm/src/cli/index.js.map +2 -2
- package/dist/esm/src/docs/index.js +3 -3
- package/dist/esm/src/docs/index.js.map +2 -2
- package/dist/esm/src/errors/index.js +7 -7
- package/dist/esm/src/errors/index.js.map +2 -2
- package/dist/esm/src/graphql/index.js +14 -27
- package/dist/esm/src/graphql/index.js.map +5 -6
- package/dist/esm/src/index.js +49 -62
- package/dist/esm/src/index.js.map +37 -56
- package/dist/esm/src/middleware/index.js +8 -8
- package/dist/esm/src/middleware/index.js.map +4 -4
- package/dist/esm/src/plugins/index.js +35 -48
- package/dist/esm/src/plugins/index.js.map +6 -7
- package/dist/esm/src/testing/index.js +32 -45
- package/dist/esm/src/testing/index.js.map +11 -37
- package/dist/esm/src/types/index.js +2 -2
- package/dist/esm/src/types/index.js.map +2 -2
- package/dist/esm/src/validation/index.js +2 -2
- package/dist/esm/src/validation/index.js.map +3 -3
- package/dist/esm/src/websocket/index.js +2 -15
- package/dist/esm/src/websocket/index.js.map +5 -6
- package/dist/types/auth/auth-plugin.d.ts.map +1 -1
- package/dist/types/auth/auth-service.d.ts.map +1 -1
- package/dist/types/auth/jwt-provider.d.ts +4 -4
- package/dist/types/auth/jwt-provider.d.ts.map +1 -1
- package/dist/types/auth/oauth-plugin.d.ts +2 -0
- package/dist/types/auth/oauth-plugin.d.ts.map +1 -1
- package/dist/types/auth/permission-plugin.d.ts.map +1 -1
- package/dist/types/auth/permissions.d.ts +12 -12
- package/dist/types/auth/rbac-plugin.d.ts.map +1 -1
- package/dist/types/auth/session.d.ts +2 -0
- package/dist/types/auth/session.d.ts.map +1 -1
- package/dist/types/cache/manager.d.ts +4 -0
- package/dist/types/cache/manager.d.ts.map +1 -1
- package/dist/types/core/application.d.ts.map +1 -1
- package/dist/types/core/compiled-metadata.d.ts.map +1 -1
- package/dist/types/core/metadata.d.ts.map +1 -1
- package/dist/types/core/router-compiler.d.ts +0 -1
- package/dist/types/core/router-compiler.d.ts.map +1 -1
- package/dist/types/dependencies/prisma.d.ts +40 -0
- package/dist/types/dependencies/prisma.d.ts.map +1 -0
- package/dist/types/dependencies/typeorm.d.ts +41 -0
- package/dist/types/dependencies/typeorm.d.ts.map +1 -0
- package/dist/types/graphql/plugin.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/middleware/rate-limit.d.ts.map +1 -1
- package/dist/types/orm/base-repository.d.ts.map +1 -1
- package/dist/types/orm/drizzle/plugin.d.ts +0 -22
- package/dist/types/orm/drizzle/plugin.d.ts.map +1 -1
- package/dist/types/orm/drizzle/repository.d.ts.map +1 -1
- package/dist/types/orm/drizzle/transaction-manager.d.ts.map +1 -1
- package/dist/types/orm/prisma/plugin.d.ts +1 -1
- package/dist/types/orm/prisma/repository.d.ts.map +1 -1
- package/dist/types/orm/prisma/types.d.ts +3 -0
- package/dist/types/orm/prisma/types.d.ts.map +1 -1
- package/dist/types/orm/transaction-plugin.d.ts +1 -1
- package/dist/types/orm/typeorm/decorators.d.ts +1 -1
- package/dist/types/orm/typeorm/plugin.d.ts +1 -1
- package/dist/types/orm/typeorm/repository.d.ts.map +1 -1
- package/dist/types/orm/typeorm/transaction-manager.d.ts.map +1 -1
- package/dist/types/validation/validator.d.ts.map +1 -1
- package/dist/types/websocket/plugin.d.ts +0 -4
- package/dist/types/websocket/plugin.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
var
|
|
1
|
+
var sq=Object.create;var{getPrototypeOf:tq,defineProperty:Q6,getOwnPropertyNames:g8,getOwnPropertyDescriptor:eq}=Object,y8=Object.prototype.hasOwnProperty;function m8($){return this[$]}var $Q,qQ,QQ=($,q,Q)=>{var J=$!=null&&typeof $==="object";if(J){var W=q?$Q??=new WeakMap:qQ??=new WeakMap,X=W.get($);if(X)return X}Q=$!=null?sq(tq($)):{};let H=q||!$||!$.__esModule?Q6(Q,"default",{value:$,enumerable:!0}):Q;for(let Y of g8($))if(!y8.call(H,Y))Q6(H,Y,{get:m8.bind($,Y),enumerable:!0});if(J)W.set($,H);return H},JQ=($)=>{var q=(h8??=new WeakMap).get($),Q;if(q)return q;if(q=Q6({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var J of g8($))if(!y8.call(q,J))Q6(q,J,{get:m8.bind($,J),enumerable:!(Q=eq($,J))||Q.enumerable})}return h8.set($,q),q},h8,z=($,q)=>()=>(q||$((q={exports:{}}).exports,q),q.exports);var WQ=($)=>$;function XQ($,q){this[$]=WQ.bind(null,q)}var M0=($,q)=>{for(var Q in q)Q6($,Q,{get:q[Q],enumerable:!0,configurable:!0,set:XQ.bind(q,Q)})};var E0=($,q)=>()=>($&&(q=$($=0)),q);var P$=z((A0,u8)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var f6=require("buffer"),Q$=f6.Buffer;function l8($,q){for(var Q in $)q[Q]=$[Q]}if(Q$.from&&Q$.alloc&&Q$.allocUnsafe&&Q$.allocUnsafeSlow)u8.exports=f6;else l8(f6,A0),A0.Buffer=N$;function N$($,q,Q){return Q$($,q,Q)}N$.prototype=Object.create(Q$.prototype);l8(Q$,N$);N$.from=function($,q,Q){if(typeof $==="number")throw TypeError("Argument must not be a number");return Q$($,q,Q)};N$.alloc=function($,q,Q){if(typeof $!=="number")throw TypeError("Argument must be a number");var J=Q$($);if(q!==void 0)if(typeof Q==="string")J.fill(q,Q);else J.fill(q);else J.fill(0);return J};N$.allocUnsafe=function($){if(typeof $!=="number")throw TypeError("Argument must be a number");return Q$($)};N$.allocUnsafeSlow=function($){if(typeof $!=="number")throw TypeError("Argument must be a number");return f6.SlowBuffer($)}});var C0=z((xH,c8)=>{var T6=P$().Buffer,HQ=require("stream"),YQ=require("util");function x6($){if(this.buffer=null,this.writable=!0,this.readable=!0,!$)return this.buffer=T6.alloc(0),this;if(typeof $.pipe==="function")return this.buffer=T6.alloc(0),$.pipe(this),this;if($.length||typeof $==="object")return this.buffer=$,this.writable=!1,process.nextTick(function(){this.emit("end",$),this.readable=!1,this.emit("close")}.bind(this)),this;throw TypeError("Unexpected data type ("+typeof $+")")}YQ.inherits(x6,HQ);x6.prototype.write=function(q){this.buffer=T6.concat([this.buffer,T6.from(q)]),this.emit("data",q)};x6.prototype.end=function(q){if(q)this.write(q);this.emit("end",q),this.emit("close"),this.writable=!1,this.readable=!1};c8.exports=x6});var p8=z((vH,d8)=>{function K0($){var q=($/8|0)+($%8===0?0:1);return q}var GQ={ES256:K0(256),ES384:K0(384),ES512:K0(521)};function BQ($){var q=GQ[$];if(q)return q;throw Error('Unknown algorithm "'+$+'"')}d8.exports=BQ});var t8=z((hH,s8)=>{var v6=P$().Buffer,i8=p8(),h6=128,r8=0,wQ=32,VQ=16,FQ=2,o8=VQ|wQ|r8<<6,g6=FQ|r8<<6;function UQ($){return $.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function a8($){if(v6.isBuffer($))return $;else if(typeof $==="string")return v6.from($,"base64");throw TypeError("ECDSA signature must be a Base64 string or a Buffer")}function _Q($,q){$=a8($);var Q=i8(q),J=Q+1,W=$.length,X=0;if($[X++]!==o8)throw Error('Could not find expected "seq"');var H=$[X++];if(H===(h6|1))H=$[X++];if(W-X<H)throw Error('"seq" specified length of "'+H+'", only "'+(W-X)+'" remaining');if($[X++]!==g6)throw Error('Could not find expected "int" for "r"');var Y=$[X++];if(W-X-2<Y)throw Error('"r" specified length of "'+Y+'", only "'+(W-X-2)+'" available');if(J<Y)throw Error('"r" specified length of "'+Y+'", max of "'+J+'" is acceptable');var G=X;if(X+=Y,$[X++]!==g6)throw Error('Could not find expected "int" for "s"');var w=$[X++];if(W-X!==w)throw Error('"s" specified length of "'+w+'", expected "'+(W-X)+'"');if(J<w)throw Error('"s" specified length of "'+w+'", max of "'+J+'" is acceptable');var V=X;if(X+=w,X!==W)throw Error('Expected to consume entire buffer, but "'+(W-X)+'" bytes remain');var U=Q-Y,M=Q-w,O=v6.allocUnsafe(U+Y+M+w);for(X=0;X<U;++X)O[X]=0;$.copy(O,X,G+Math.max(-U,0),G+Y),X=Q;for(var P=X;X<P+M;++X)O[X]=0;return $.copy(O,X,V+Math.max(-M,0),V+w),O=O.toString("base64"),O=UQ(O),O}function n8($,q,Q){var J=0;while(q+J<Q&&$[q+J]===0)++J;var W=$[q+J]>=h6;if(W)--J;return J}function DQ($,q){$=a8($);var Q=i8(q),J=$.length;if(J!==Q*2)throw TypeError('"'+q+'" signatures must be "'+Q*2+'" bytes, saw "'+J+'"');var W=n8($,0,Q),X=n8($,Q,$.length),H=Q-W,Y=Q-X,G=2+H+1+1+Y,w=G<h6,V=v6.allocUnsafe((w?2:3)+G),U=0;if(V[U++]=o8,w)V[U++]=G;else V[U++]=h6|1,V[U++]=G&255;if(V[U++]=g6,V[U++]=H,W<0)V[U++]=0,U+=$.copy(V,U,0,Q);else U+=$.copy(V,U,W,Q);if(V[U++]=g6,V[U++]=Y,X<0)V[U++]=0,$.copy(V,U,Q);else $.copy(V,U,Q+X);return V}s8.exports={derToJose:_Q,joseToDer:DQ}});var $1=z((gH,e8)=>{var J6=require("buffer").Buffer,I0=require("buffer").SlowBuffer;e8.exports=y6;function y6($,q){if(!J6.isBuffer($)||!J6.isBuffer(q))return!1;if($.length!==q.length)return!1;var Q=0;for(var J=0;J<$.length;J++)Q|=$[J]^q[J];return Q===0}y6.install=function(){J6.prototype.equal=I0.prototype.equal=function(q){return y6(this,q)}};var zQ=J6.prototype.equal,LQ=I0.prototype.equal;y6.restore=function(){J6.prototype.equal=zQ,I0.prototype.equal=LQ}});var Z0=z((yH,B1)=>{var b$=P$().Buffer,p=require("crypto"),Q1=t8(),q1=require("util"),jQ=`"%s" is not a valid algorithm.
|
|
2
2
|
Supported algorithms are:
|
|
3
|
-
"HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".`,K1="secret must be a string or buffer",t$="key must be a string or a buffer",n2="key must be a string, a buffer or an object",G6=typeof G$.createPublicKey==="function";if(G6)t$+=" or a KeyObject",K1+="or a KeyObject";function $q($){if(e$.isBuffer($))return;if(typeof $==="string")return;if(!G6)throw F$(t$);if(typeof $!=="object")throw F$(t$);if(typeof $.type!=="string")throw F$(t$);if(typeof $.asymmetricKeyType!=="string")throw F$(t$);if(typeof $.export!=="function")throw F$(t$)}function qq($){if(e$.isBuffer($))return;if(typeof $==="string")return;if(typeof $==="object")return;throw F$(n2)}function p2($){if(e$.isBuffer($))return;if(typeof $==="string")return $;if(!G6)throw F$(K1);if(typeof $!=="object")throw F$(K1);if($.type!=="secret")throw F$(K1);if(typeof $.export!=="function")throw F$(K1)}function w6($){return $.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Qq($){$=$.toString();var q=4-$.length%4;if(q!==4)for(var Q=0;Q<q;++Q)$+="=";return $.replace(/\-/g,"+").replace(/_/g,"/")}function F$($){var q=[].slice.call(arguments,1),Q=t4.format.bind(t4,$).apply(null,q);return TypeError(Q)}function i2($){return e$.isBuffer($)||typeof $==="string"}function k1($){if(!i2($))$=JSON.stringify($);return $}function Jq($){return function(Q,J){p2(J),Q=k1(Q);var W=G$.createHmac("sha"+$,J),X=(W.update(Q),W.digest("base64"));return w6(X)}}var Y6,o2="timingSafeEqual"in G$?function(q,Q){if(q.byteLength!==Q.byteLength)return!1;return G$.timingSafeEqual(q,Q)}:function(q,Q){if(!Y6)Y6=a4();return Y6(q,Q)};function s2($){return function(Q,J,W){var X=Jq($)(Q,W);return o2(e$.from(J),e$.from(X))}}function Wq($){return function(Q,J){qq(J),Q=k1(Q);var W=G$.createSign("RSA-SHA"+$),X=(W.update(Q),W.sign(J,"base64"));return w6(X)}}function Xq($){return function(Q,J,W){$q(W),Q=k1(Q),J=Qq(J);var X=G$.createVerify("RSA-SHA"+$);return X.update(Q),X.verify(W,J,"base64")}}function r2($){return function(Q,J){qq(J),Q=k1(Q);var W=G$.createSign("RSA-SHA"+$),X=(W.update(Q),W.sign({key:J,padding:G$.constants.RSA_PKCS1_PSS_PADDING,saltLength:G$.constants.RSA_PSS_SALTLEN_DIGEST},"base64"));return w6(X)}}function a2($){return function(Q,J,W){$q(W),Q=k1(Q),J=Qq(J);var X=G$.createVerify("RSA-SHA"+$);return X.update(Q),X.verify({key:W,padding:G$.constants.RSA_PKCS1_PSS_PADDING,saltLength:G$.constants.RSA_PSS_SALTLEN_DIGEST},J,"base64")}}function t2($){var q=Wq($);return function(){var J=q.apply(null,arguments);return J=e4.derToJose(J,"ES"+$),J}}function e2($){var q=Xq($);return function(J,W,X){W=e4.joseToDer(W,"ES"+$).toString("base64");var H=q(J,W,X);return H}}function $5(){return function(){return""}}function q5(){return function(q,Q){return Q===""}}Hq.exports=function(q){var Q={hs:Jq,rs:Wq,ps:r2,es:t2,none:$5},J={hs:s2,rs:Xq,ps:a2,es:e2,none:q5},W=q.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!W)throw F$(d2,q);var X=(W[1]||W[3]).toLowerCase(),H=W[2];return{sign:Q[X](H),verify:J[X](H)}}});var V6=N((RG,Yq)=>{var Q5=require("buffer").Buffer;Yq.exports=function(q){if(typeof q==="string")return q;if(typeof q==="number"||Q5.isBuffer(q))return q.toString();return JSON.stringify(q)}});var _q=N((EG,Fq)=>{var J5=a$().Buffer,Gq=W6(),W5=B6(),X5=require("stream"),wq=V6(),F6=require("util");function Bq($,q){return J5.from($,q).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function H5($,q,Q){Q=Q||"utf8";var J=Bq(wq($),"binary"),W=Bq(wq(q),Q);return F6.format("%s.%s",J,W)}function Vq($){var{header:q,payload:Q}=$,J=$.secret||$.privateKey,W=$.encoding,X=W5(q.alg),H=H5(q,Q,W),Y=X.sign(H,J);return F6.format("%s.%s",H,Y)}function V0($){var q=$.secret;if(q=q==null?$.privateKey:q,q=q==null?$.key:q,/^hs/i.test($.header.alg)===!0&&q==null)throw TypeError("secret must be a string or buffer or a KeyObject");var Q=new Gq(q);this.readable=!0,this.header=$.header,this.encoding=$.encoding,this.secret=this.privateKey=this.key=Q,this.payload=new Gq($.payload),this.secret.once("close",function(){if(!this.payload.writable&&this.readable)this.sign()}.bind(this)),this.payload.once("close",function(){if(!this.secret.writable&&this.readable)this.sign()}.bind(this))}F6.inherits(V0,X5);V0.prototype.sign=function(){try{var q=Vq({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",q),this.emit("data",q),this.emit("end"),this.readable=!1,q}catch(Q){this.readable=!1,this.emit("error",Q),this.emit("close")}};V0.sign=Vq;Fq.exports=V0});var Aq=N((SG,Sq)=>{var Uq=a$().Buffer,Dq=W6(),Y5=B6(),G5=require("stream"),zq=V6(),w5=require("util"),B5=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function V5($){return Object.prototype.toString.call($)==="[object Object]"}function F5($){if(V5($))return $;try{return JSON.parse($)}catch(q){return}}function Lq($){var q=$.split(".",1)[0];return F5(Uq.from(q,"base64").toString("binary"))}function _5($){return $.split(".",2).join(".")}function jq($){return $.split(".")[2]}function D5($,q){q=q||"utf8";var Q=$.split(".")[1];return Uq.from(Q,"base64").toString(q)}function Nq($){return B5.test($)&&!!Lq($)}function Rq($,q,Q){if(!q){var J=Error("Missing algorithm parameter for jws.verify");throw J.code="MISSING_ALGORITHM",J}$=zq($);var W=jq($),X=_5($),H=Y5(q);return H.verify(X,W,Q)}function Eq($,q){if(q=q||{},$=zq($),!Nq($))return null;var Q=Lq($);if(!Q)return null;var J=D5($);if(Q.typ==="JWT"||q.json)J=JSON.parse(J,q.encoding);return{header:Q,payload:J,signature:jq($)}}function $1($){$=$||{};var q=$.secret;if(q=q==null?$.publicKey:q,q=q==null?$.key:q,/^hs/i.test($.algorithm)===!0&&q==null)throw TypeError("secret must be a string or buffer or a KeyObject");var Q=new Dq(q);this.readable=!0,this.algorithm=$.algorithm,this.encoding=$.encoding,this.secret=this.publicKey=this.key=Q,this.signature=new Dq($.signature),this.secret.once("close",function(){if(!this.signature.writable&&this.readable)this.verify()}.bind(this)),this.signature.once("close",function(){if(!this.secret.writable&&this.readable)this.verify()}.bind(this))}w5.inherits($1,G5);$1.prototype.verify=function(){try{var q=Rq(this.signature.buffer,this.algorithm,this.key.buffer),Q=Eq(this.signature.buffer,this.encoding);return this.emit("done",q,Q),this.emit("data",q),this.emit("end"),this.readable=!1,q}catch(J){this.readable=!1,this.emit("error",J),this.emit("close")}};$1.decode=Eq;$1.isValid=Nq;$1.verify=Rq;Sq.exports=$1});var _0=N((I$)=>{var Cq=_q(),F0=Aq(),U5=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"];I$.ALGORITHMS=U5;I$.sign=Cq.sign;I$.verify=F0.verify;I$.decode=F0.decode;I$.isValid=F0.isValid;I$.createSign=function(q){return new Cq(q)};I$.createVerify=function(q){return new F0(q)}});var _6=N((CG,Oq)=>{var z5=_0();Oq.exports=function($,q){q=q||{};var Q=z5.decode($,q);if(!Q)return null;var J=Q.payload;if(typeof J==="string")try{var W=JSON.parse(J);if(W!==null&&typeof W==="object")J=W}catch(X){}if(q.complete===!0)return{header:Q.header,payload:J,signature:Q.signature};return J}});var I1=N((OG,Mq)=>{var D0=function($,q){if(Error.call(this,$),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);if(this.name="JsonWebTokenError",this.message=$,q)this.inner=q};D0.prototype=Object.create(Error.prototype);D0.prototype.constructor=D0;Mq.exports=D0});var D6=N((MG,kq)=>{var Kq=I1(),U0=function($,q){Kq.call(this,$),this.name="NotBeforeError",this.date=q};U0.prototype=Object.create(Kq.prototype);U0.prototype.constructor=U0;kq.exports=U0});var U6=N((KG,bq)=>{var Iq=I1(),z0=function($,q){Iq.call(this,$),this.name="TokenExpiredError",this.expiredAt=q};z0.prototype=Object.create(Iq.prototype);z0.prototype.constructor=z0;bq.exports=z0});var Zq=N((kG,Pq)=>{var q1=1000,Q1=q1*60,J1=Q1*60,y$=J1*24,L5=y$*7,j5=y$*365.25;Pq.exports=function($,q){q=q||{};var Q=typeof $;if(Q==="string"&&$.length>0)return N5($);else if(Q==="number"&&isFinite($))return q.long?E5($):R5($);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify($))};function N5($){if($=String($),$.length>100)return;var q=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec($);if(!q)return;var Q=parseFloat(q[1]),J=(q[2]||"ms").toLowerCase();switch(J){case"years":case"year":case"yrs":case"yr":case"y":return Q*j5;case"weeks":case"week":case"w":return Q*L5;case"days":case"day":case"d":return Q*y$;case"hours":case"hour":case"hrs":case"hr":case"h":return Q*J1;case"minutes":case"minute":case"mins":case"min":case"m":return Q*Q1;case"seconds":case"second":case"secs":case"sec":case"s":return Q*q1;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return Q;default:return}}function R5($){var q=Math.abs($);if(q>=y$)return Math.round($/y$)+"d";if(q>=J1)return Math.round($/J1)+"h";if(q>=Q1)return Math.round($/Q1)+"m";if(q>=q1)return Math.round($/q1)+"s";return $+"ms"}function E5($){var q=Math.abs($);if(q>=y$)return L0($,q,y$,"day");if(q>=J1)return L0($,q,J1,"hour");if(q>=Q1)return L0($,q,Q1,"minute");if(q>=q1)return L0($,q,q1,"second");return $+" ms"}function L0($,q,Q,J){var W=q>=Q*1.5;return Math.round($/Q)+" "+J+(W?"s":"")}});var z6=N((IG,fq)=>{var S5=Zq();fq.exports=function($,q){var Q=q||Math.floor(Date.now()/1000);if(typeof $==="string"){var J=S5($);if(typeof J>"u")return;return Math.floor(Q+J/1000)}else if(typeof $==="number")return Q+$;else return}});var b1=N((bG,xq)=>{var A5=Number.MAX_SAFE_INTEGER||9007199254740991,C5=["major","premajor","minor","preminor","patch","prepatch","prerelease"];xq.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:A5,RELEASE_TYPES:C5,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var P1=N((PG,Tq)=>{var O5=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...$)=>console.error("SEMVER",...$):()=>{};Tq.exports=O5});var W1=N((S$,hq)=>{var{MAX_SAFE_COMPONENT_LENGTH:L6,MAX_SAFE_BUILD_LENGTH:M5,MAX_LENGTH:K5}=b1(),k5=P1();S$=hq.exports={};var I5=S$.re=[],b5=S$.safeRe=[],S=S$.src=[],P5=S$.safeSrc=[],A=S$.t={},Z5=0,j6="[a-zA-Z0-9-]",f5=[["\\s",1],["\\d",K5],[j6,M5]],x5=($)=>{for(let[q,Q]of f5)$=$.split(`${q}*`).join(`${q}{0,${Q}}`).split(`${q}+`).join(`${q}{1,${Q}}`);return $},x=($,q,Q)=>{let J=x5(q),W=Z5++;k5($,W,q),A[$]=W,S[W]=q,P5[W]=J,I5[W]=new RegExp(q,Q?"g":void 0),b5[W]=new RegExp(J,Q?"g":void 0)};x("NUMERICIDENTIFIER","0|[1-9]\\d*");x("NUMERICIDENTIFIERLOOSE","\\d+");x("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${j6}*`);x("MAINVERSION",`(${S[A.NUMERICIDENTIFIER]})\\.(${S[A.NUMERICIDENTIFIER]})\\.(${S[A.NUMERICIDENTIFIER]})`);x("MAINVERSIONLOOSE",`(${S[A.NUMERICIDENTIFIERLOOSE]})\\.(${S[A.NUMERICIDENTIFIERLOOSE]})\\.(${S[A.NUMERICIDENTIFIERLOOSE]})`);x("PRERELEASEIDENTIFIER",`(?:${S[A.NONNUMERICIDENTIFIER]}|${S[A.NUMERICIDENTIFIER]})`);x("PRERELEASEIDENTIFIERLOOSE",`(?:${S[A.NONNUMERICIDENTIFIER]}|${S[A.NUMERICIDENTIFIERLOOSE]})`);x("PRERELEASE",`(?:-(${S[A.PRERELEASEIDENTIFIER]}(?:\\.${S[A.PRERELEASEIDENTIFIER]})*))`);x("PRERELEASELOOSE",`(?:-?(${S[A.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${S[A.PRERELEASEIDENTIFIERLOOSE]})*))`);x("BUILDIDENTIFIER",`${j6}+`);x("BUILD",`(?:\\+(${S[A.BUILDIDENTIFIER]}(?:\\.${S[A.BUILDIDENTIFIER]})*))`);x("FULLPLAIN",`v?${S[A.MAINVERSION]}${S[A.PRERELEASE]}?${S[A.BUILD]}?`);x("FULL",`^${S[A.FULLPLAIN]}$`);x("LOOSEPLAIN",`[v=\\s]*${S[A.MAINVERSIONLOOSE]}${S[A.PRERELEASELOOSE]}?${S[A.BUILD]}?`);x("LOOSE",`^${S[A.LOOSEPLAIN]}$`);x("GTLT","((?:<|>)?=?)");x("XRANGEIDENTIFIERLOOSE",`${S[A.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);x("XRANGEIDENTIFIER",`${S[A.NUMERICIDENTIFIER]}|x|X|\\*`);x("XRANGEPLAIN",`[v=\\s]*(${S[A.XRANGEIDENTIFIER]})(?:\\.(${S[A.XRANGEIDENTIFIER]})(?:\\.(${S[A.XRANGEIDENTIFIER]})(?:${S[A.PRERELEASE]})?${S[A.BUILD]}?)?)?`);x("XRANGEPLAINLOOSE",`[v=\\s]*(${S[A.XRANGEIDENTIFIERLOOSE]})(?:\\.(${S[A.XRANGEIDENTIFIERLOOSE]})(?:\\.(${S[A.XRANGEIDENTIFIERLOOSE]})(?:${S[A.PRERELEASELOOSE]})?${S[A.BUILD]}?)?)?`);x("XRANGE",`^${S[A.GTLT]}\\s*${S[A.XRANGEPLAIN]}$`);x("XRANGELOOSE",`^${S[A.GTLT]}\\s*${S[A.XRANGEPLAINLOOSE]}$`);x("COERCEPLAIN",`(^|[^\\d])(\\d{1,${L6}})(?:\\.(\\d{1,${L6}}))?(?:\\.(\\d{1,${L6}}))?`);x("COERCE",`${S[A.COERCEPLAIN]}(?:$|[^\\d])`);x("COERCEFULL",S[A.COERCEPLAIN]+`(?:${S[A.PRERELEASE]})?(?:${S[A.BUILD]})?(?:$|[^\\d])`);x("COERCERTL",S[A.COERCE],!0);x("COERCERTLFULL",S[A.COERCEFULL],!0);x("LONETILDE","(?:~>?)");x("TILDETRIM",`(\\s*)${S[A.LONETILDE]}\\s+`,!0);S$.tildeTrimReplace="$1~";x("TILDE",`^${S[A.LONETILDE]}${S[A.XRANGEPLAIN]}$`);x("TILDELOOSE",`^${S[A.LONETILDE]}${S[A.XRANGEPLAINLOOSE]}$`);x("LONECARET","(?:\\^)");x("CARETTRIM",`(\\s*)${S[A.LONECARET]}\\s+`,!0);S$.caretTrimReplace="$1^";x("CARET",`^${S[A.LONECARET]}${S[A.XRANGEPLAIN]}$`);x("CARETLOOSE",`^${S[A.LONECARET]}${S[A.XRANGEPLAINLOOSE]}$`);x("COMPARATORLOOSE",`^${S[A.GTLT]}\\s*(${S[A.LOOSEPLAIN]})$|^$`);x("COMPARATOR",`^${S[A.GTLT]}\\s*(${S[A.FULLPLAIN]})$|^$`);x("COMPARATORTRIM",`(\\s*)${S[A.GTLT]}\\s*(${S[A.LOOSEPLAIN]}|${S[A.XRANGEPLAIN]})`,!0);S$.comparatorTrimReplace="$1$2$3";x("HYPHENRANGE",`^\\s*(${S[A.XRANGEPLAIN]})\\s+-\\s+(${S[A.XRANGEPLAIN]})\\s*$`);x("HYPHENRANGELOOSE",`^\\s*(${S[A.XRANGEPLAINLOOSE]})\\s+-\\s+(${S[A.XRANGEPLAINLOOSE]})\\s*$`);x("STAR","(<|>)?=?\\s*\\*");x("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");x("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var j0=N((ZG,vq)=>{var T5=Object.freeze({loose:!0}),h5=Object.freeze({}),v5=($)=>{if(!$)return h5;if(typeof $!=="object")return T5;return $};vq.exports=v5});var N6=N((fG,yq)=>{var gq=/^[0-9]+$/,mq=($,q)=>{if(typeof $==="number"&&typeof q==="number")return $===q?0:$<q?-1:1;let Q=gq.test($),J=gq.test(q);if(Q&&J)$=+$,q=+q;return $===q?0:Q&&!J?-1:J&&!Q?1:$<q?-1:1},g5=($,q)=>mq(q,$);yq.exports={compareIdentifiers:mq,rcompareIdentifiers:g5}});var q$=N((xG,uq)=>{var N0=P1(),{MAX_LENGTH:lq,MAX_SAFE_INTEGER:R0}=b1(),{safeRe:E0,t:S0}=W1(),m5=j0(),{compareIdentifiers:R6}=N6();class _${constructor($,q){if(q=m5(q),$ instanceof _$)if($.loose===!!q.loose&&$.includePrerelease===!!q.includePrerelease)return $;else $=$.version;else if(typeof $!=="string")throw TypeError(`Invalid version. Must be a string. Got type "${typeof $}".`);if($.length>lq)throw TypeError(`version is longer than ${lq} characters`);N0("SemVer",$,q),this.options=q,this.loose=!!q.loose,this.includePrerelease=!!q.includePrerelease;let Q=$.trim().match(q.loose?E0[S0.LOOSE]:E0[S0.FULL]);if(!Q)throw TypeError(`Invalid Version: ${$}`);if(this.raw=$,this.major=+Q[1],this.minor=+Q[2],this.patch=+Q[3],this.major>R0||this.major<0)throw TypeError("Invalid major version");if(this.minor>R0||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>R0||this.patch<0)throw TypeError("Invalid patch version");if(!Q[4])this.prerelease=[];else this.prerelease=Q[4].split(".").map((J)=>{if(/^[0-9]+$/.test(J)){let W=+J;if(W>=0&&W<R0)return W}return J});this.build=Q[5]?Q[5].split("."):[],this.format()}format(){if(this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length)this.version+=`-${this.prerelease.join(".")}`;return this.version}toString(){return this.version}compare($){if(N0("SemVer.compare",this.version,this.options,$),!($ instanceof _$)){if(typeof $==="string"&&$===this.version)return 0;$=new _$($,this.options)}if($.version===this.version)return 0;return this.compareMain($)||this.comparePre($)}compareMain($){if(!($ instanceof _$))$=new _$($,this.options);if(this.major<$.major)return-1;if(this.major>$.major)return 1;if(this.minor<$.minor)return-1;if(this.minor>$.minor)return 1;if(this.patch<$.patch)return-1;if(this.patch>$.patch)return 1;return 0}comparePre($){if(!($ instanceof _$))$=new _$($,this.options);if(this.prerelease.length&&!$.prerelease.length)return-1;else if(!this.prerelease.length&&$.prerelease.length)return 1;else if(!this.prerelease.length&&!$.prerelease.length)return 0;let q=0;do{let Q=this.prerelease[q],J=$.prerelease[q];if(N0("prerelease compare",q,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return R6(Q,J)}while(++q)}compareBuild($){if(!($ instanceof _$))$=new _$($,this.options);let q=0;do{let Q=this.build[q],J=$.build[q];if(N0("build compare",q,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return R6(Q,J)}while(++q)}inc($,q,Q){if($.startsWith("pre")){if(!q&&Q===!1)throw Error("invalid increment argument: identifier is empty");if(q){let J=`-${q}`.match(this.options.loose?E0[S0.PRERELEASELOOSE]:E0[S0.PRERELEASE]);if(!J||J[1]!==q)throw Error(`invalid identifier: ${q}`)}}switch($){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",q,Q);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",q,Q);break;case"prepatch":this.prerelease.length=0,this.inc("patch",q,Q),this.inc("pre",q,Q);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",q,Q);this.inc("pre",q,Q);break;case"release":if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0)this.major++;this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0)this.minor++;this.patch=0,this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":{let J=Number(Q)?1:0;if(this.prerelease.length===0)this.prerelease=[J];else{let W=this.prerelease.length;while(--W>=0)if(typeof this.prerelease[W]==="number")this.prerelease[W]++,W=-2;if(W===-1){if(q===this.prerelease.join(".")&&Q===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(J)}}if(q){let W=[q,J];if(Q===!1)W=[q];if(R6(this.prerelease[0],q)===0){if(isNaN(this.prerelease[1]))this.prerelease=W}else this.prerelease=W}break}default:throw Error(`invalid increment argument: ${$}`)}if(this.raw=this.format(),this.build.length)this.raw+=`+${this.build.join(".")}`;return this}}uq.exports=_$});var l$=N((TG,dq)=>{var cq=q$(),y5=($,q,Q=!1)=>{if($ instanceof cq)return $;try{return new cq($,q)}catch(J){if(!Q)return null;throw J}};dq.exports=y5});var pq=N((hG,nq)=>{var l5=l$(),u5=($,q)=>{let Q=l5($,q);return Q?Q.version:null};nq.exports=u5});var oq=N((vG,iq)=>{var c5=l$(),d5=($,q)=>{let Q=c5($.trim().replace(/^[=v]+/,""),q);return Q?Q.version:null};iq.exports=d5});var aq=N((gG,rq)=>{var sq=q$(),n5=($,q,Q,J,W)=>{if(typeof Q==="string")W=J,J=Q,Q=void 0;try{return new sq($ instanceof sq?$.version:$,Q).inc(q,J,W).version}catch(X){return null}};rq.exports=n5});var $8=N((mG,eq)=>{var tq=l$(),p5=($,q)=>{let Q=tq($,null,!0),J=tq(q,null,!0),W=Q.compare(J);if(W===0)return null;let X=W>0,H=X?Q:J,Y=X?J:Q,G=!!H.prerelease.length;if(!!Y.prerelease.length&&!G){if(!Y.patch&&!Y.minor)return"major";if(Y.compareMain(H)===0){if(Y.minor&&!Y.patch)return"minor";return"patch"}}let D=G?"pre":"";if(Q.major!==J.major)return D+"major";if(Q.minor!==J.minor)return D+"minor";if(Q.patch!==J.patch)return D+"patch";return"prerelease"};eq.exports=p5});var Q8=N((yG,q8)=>{var i5=q$(),o5=($,q)=>new i5($,q).major;q8.exports=o5});var W8=N((lG,J8)=>{var s5=q$(),r5=($,q)=>new s5($,q).minor;J8.exports=r5});var H8=N((uG,X8)=>{var a5=q$(),t5=($,q)=>new a5($,q).patch;X8.exports=t5});var G8=N((cG,Y8)=>{var e5=l$(),$J=($,q)=>{let Q=e5($,q);return Q&&Q.prerelease.length?Q.prerelease:null};Y8.exports=$J});var w$=N((dG,B8)=>{var w8=q$(),qJ=($,q,Q)=>new w8($,Q).compare(new w8(q,Q));B8.exports=qJ});var F8=N((nG,V8)=>{var QJ=w$(),JJ=($,q,Q)=>QJ(q,$,Q);V8.exports=JJ});var D8=N((pG,_8)=>{var WJ=w$(),XJ=($,q)=>WJ($,q,!0);_8.exports=XJ});var A0=N((iG,z8)=>{var U8=q$(),HJ=($,q,Q)=>{let J=new U8($,Q),W=new U8(q,Q);return J.compare(W)||J.compareBuild(W)};z8.exports=HJ});var j8=N((oG,L8)=>{var YJ=A0(),GJ=($,q)=>$.sort((Q,J)=>YJ(Q,J,q));L8.exports=GJ});var R8=N((sG,N8)=>{var wJ=A0(),BJ=($,q)=>$.sort((Q,J)=>wJ(J,Q,q));N8.exports=BJ});var Z1=N((rG,E8)=>{var VJ=w$(),FJ=($,q,Q)=>VJ($,q,Q)>0;E8.exports=FJ});var C0=N((aG,S8)=>{var _J=w$(),DJ=($,q,Q)=>_J($,q,Q)<0;S8.exports=DJ});var E6=N((tG,A8)=>{var UJ=w$(),zJ=($,q,Q)=>UJ($,q,Q)===0;A8.exports=zJ});var S6=N((eG,C8)=>{var LJ=w$(),jJ=($,q,Q)=>LJ($,q,Q)!==0;C8.exports=jJ});var O0=N(($w,O8)=>{var NJ=w$(),RJ=($,q,Q)=>NJ($,q,Q)>=0;O8.exports=RJ});var M0=N((qw,M8)=>{var EJ=w$(),SJ=($,q,Q)=>EJ($,q,Q)<=0;M8.exports=SJ});var A6=N((Qw,K8)=>{var AJ=E6(),CJ=S6(),OJ=Z1(),MJ=O0(),KJ=C0(),kJ=M0(),IJ=($,q,Q,J)=>{switch(q){case"===":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $===Q;case"!==":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $!==Q;case"":case"=":case"==":return AJ($,Q,J);case"!=":return CJ($,Q,J);case">":return OJ($,Q,J);case">=":return MJ($,Q,J);case"<":return KJ($,Q,J);case"<=":return kJ($,Q,J);default:throw TypeError(`Invalid operator: ${q}`)}};K8.exports=IJ});var I8=N((Jw,k8)=>{var bJ=q$(),PJ=l$(),{safeRe:K0,t:k0}=W1(),ZJ=($,q)=>{if($ instanceof bJ)return $;if(typeof $==="number")$=String($);if(typeof $!=="string")return null;q=q||{};let Q=null;if(!q.rtl)Q=$.match(q.includePrerelease?K0[k0.COERCEFULL]:K0[k0.COERCE]);else{let G=q.includePrerelease?K0[k0.COERCERTLFULL]:K0[k0.COERCERTL],V;while((V=G.exec($))&&(!Q||Q.index+Q[0].length!==$.length)){if(!Q||V.index+V[0].length!==Q.index+Q[0].length)Q=V;G.lastIndex=V.index+V[1].length+V[2].length}G.lastIndex=-1}if(Q===null)return null;let J=Q[2],W=Q[3]||"0",X=Q[4]||"0",H=q.includePrerelease&&Q[5]?`-${Q[5]}`:"",Y=q.includePrerelease&&Q[6]?`+${Q[6]}`:"";return PJ(`${J}.${W}.${X}${H}${Y}`,q)};k8.exports=ZJ});var Z8=N((Ww,P8)=>{class b8{constructor(){this.max=1000,this.map=new Map}get($){let q=this.map.get($);if(q===void 0)return;else return this.map.delete($),this.map.set($,q),q}delete($){return this.map.delete($)}set($,q){if(!this.delete($)&&q!==void 0){if(this.map.size>=this.max){let J=this.map.keys().next().value;this.delete(J)}this.map.set($,q)}return this}}P8.exports=b8});var B$=N((Xw,h8)=>{var fJ=/\s+/g;class f1{constructor($,q){if(q=TJ(q),$ instanceof f1)if($.loose===!!q.loose&&$.includePrerelease===!!q.includePrerelease)return $;else return new f1($.raw,q);if($ instanceof C6)return this.raw=$.value,this.set=[[$]],this.formatted=void 0,this;if(this.options=q,this.loose=!!q.loose,this.includePrerelease=!!q.includePrerelease,this.raw=$.trim().replace(fJ," "),this.set=this.raw.split("||").map((Q)=>this.parseRange(Q.trim())).filter((Q)=>Q.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let Q=this.set[0];if(this.set=this.set.filter((J)=>!x8(J[0])),this.set.length===0)this.set=[Q];else if(this.set.length>1){for(let J of this.set)if(J.length===1&&uJ(J[0])){this.set=[J];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let $=0;$<this.set.length;$++){if($>0)this.formatted+="||";let q=this.set[$];for(let Q=0;Q<q.length;Q++){if(Q>0)this.formatted+=" ";this.formatted+=q[Q].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange($){let Q=((this.options.includePrerelease&&yJ)|(this.options.loose&&lJ))+":"+$,J=f8.get(Q);if(J)return J;let W=this.options.loose,X=W?W$[Q$.HYPHENRANGELOOSE]:W$[Q$.HYPHENRANGE];$=$.replace(X,tJ(this.options.includePrerelease)),c("hyphen replace",$),$=$.replace(W$[Q$.COMPARATORTRIM],vJ),c("comparator trim",$),$=$.replace(W$[Q$.TILDETRIM],gJ),c("tilde trim",$),$=$.replace(W$[Q$.CARETTRIM],mJ),c("caret trim",$);let H=$.split(" ").map((D)=>cJ(D,this.options)).join(" ").split(/\s+/).map((D)=>aJ(D,this.options));if(W)H=H.filter((D)=>{return c("loose invalid filter",D,this.options),!!D.match(W$[Q$.COMPARATORLOOSE])});c("range list",H);let Y=new Map,G=H.map((D)=>new C6(D,this.options));for(let D of G){if(x8(D))return[D];Y.set(D.value,D)}if(Y.size>1&&Y.has(""))Y.delete("");let V=[...Y.values()];return f8.set(Q,V),V}intersects($,q){if(!($ instanceof f1))throw TypeError("a Range is required");return this.set.some((Q)=>{return T8(Q,q)&&$.set.some((J)=>{return T8(J,q)&&Q.every((W)=>{return J.every((X)=>{return W.intersects(X,q)})})})})}test($){if(!$)return!1;if(typeof $==="string")try{$=new hJ($,this.options)}catch(q){return!1}for(let q=0;q<this.set.length;q++)if(eJ(this.set[q],$,this.options))return!0;return!1}}h8.exports=f1;var xJ=Z8(),f8=new xJ,TJ=j0(),C6=x1(),c=P1(),hJ=q$(),{safeRe:W$,t:Q$,comparatorTrimReplace:vJ,tildeTrimReplace:gJ,caretTrimReplace:mJ}=W1(),{FLAG_INCLUDE_PRERELEASE:yJ,FLAG_LOOSE:lJ}=b1(),x8=($)=>$.value==="<0.0.0-0",uJ=($)=>$.value==="",T8=($,q)=>{let Q=!0,J=$.slice(),W=J.pop();while(Q&&J.length)Q=J.every((X)=>{return W.intersects(X,q)}),W=J.pop();return Q},cJ=($,q)=>{return $=$.replace(W$[Q$.BUILD],""),c("comp",$,q),$=pJ($,q),c("caret",$),$=dJ($,q),c("tildes",$),$=oJ($,q),c("xrange",$),$=rJ($,q),c("stars",$),$},X$=($)=>!$||$.toLowerCase()==="x"||$==="*",dJ=($,q)=>{return $.trim().split(/\s+/).map((Q)=>nJ(Q,q)).join(" ")},nJ=($,q)=>{let Q=q.loose?W$[Q$.TILDELOOSE]:W$[Q$.TILDE];return $.replace(Q,(J,W,X,H,Y)=>{c("tilde",$,J,W,X,H,Y);let G;if(X$(W))G="";else if(X$(X))G=`>=${W}.0.0 <${+W+1}.0.0-0`;else if(X$(H))G=`>=${W}.${X}.0 <${W}.${+X+1}.0-0`;else if(Y)c("replaceTilde pr",Y),G=`>=${W}.${X}.${H}-${Y} <${W}.${+X+1}.0-0`;else G=`>=${W}.${X}.${H} <${W}.${+X+1}.0-0`;return c("tilde return",G),G})},pJ=($,q)=>{return $.trim().split(/\s+/).map((Q)=>iJ(Q,q)).join(" ")},iJ=($,q)=>{c("caret",$,q);let Q=q.loose?W$[Q$.CARETLOOSE]:W$[Q$.CARET],J=q.includePrerelease?"-0":"";return $.replace(Q,(W,X,H,Y,G)=>{c("caret",$,W,X,H,Y,G);let V;if(X$(X))V="";else if(X$(H))V=`>=${X}.0.0${J} <${+X+1}.0.0-0`;else if(X$(Y))if(X==="0")V=`>=${X}.${H}.0${J} <${X}.${+H+1}.0-0`;else V=`>=${X}.${H}.0${J} <${+X+1}.0.0-0`;else if(G)if(c("replaceCaret pr",G),X==="0")if(H==="0")V=`>=${X}.${H}.${Y}-${G} <${X}.${H}.${+Y+1}-0`;else V=`>=${X}.${H}.${Y}-${G} <${X}.${+H+1}.0-0`;else V=`>=${X}.${H}.${Y}-${G} <${+X+1}.0.0-0`;else if(c("no pr"),X==="0")if(H==="0")V=`>=${X}.${H}.${Y}${J} <${X}.${H}.${+Y+1}-0`;else V=`>=${X}.${H}.${Y}${J} <${X}.${+H+1}.0-0`;else V=`>=${X}.${H}.${Y} <${+X+1}.0.0-0`;return c("caret return",V),V})},oJ=($,q)=>{return c("replaceXRanges",$,q),$.split(/\s+/).map((Q)=>sJ(Q,q)).join(" ")},sJ=($,q)=>{$=$.trim();let Q=q.loose?W$[Q$.XRANGELOOSE]:W$[Q$.XRANGE];return $.replace(Q,(J,W,X,H,Y,G)=>{c("xRange",$,J,W,X,H,Y,G);let V=X$(X),D=V||X$(H),z=D||X$(Y),Z=z;if(W==="="&&Z)W="";if(G=q.includePrerelease?"-0":"",V)if(W===">"||W==="<")J="<0.0.0-0";else J="*";else if(W&&Z){if(D)H=0;if(Y=0,W===">")if(W=">=",D)X=+X+1,H=0,Y=0;else H=+H+1,Y=0;else if(W==="<=")if(W="<",D)X=+X+1;else H=+H+1;if(W==="<")G="-0";J=`${W+X}.${H}.${Y}${G}`}else if(D)J=`>=${X}.0.0${G} <${+X+1}.0.0-0`;else if(z)J=`>=${X}.${H}.0${G} <${X}.${+H+1}.0-0`;return c("xRange return",J),J})},rJ=($,q)=>{return c("replaceStars",$,q),$.trim().replace(W$[Q$.STAR],"")},aJ=($,q)=>{return c("replaceGTE0",$,q),$.trim().replace(W$[q.includePrerelease?Q$.GTE0PRE:Q$.GTE0],"")},tJ=($)=>(q,Q,J,W,X,H,Y,G,V,D,z,Z)=>{if(X$(J))Q="";else if(X$(W))Q=`>=${J}.0.0${$?"-0":""}`;else if(X$(X))Q=`>=${J}.${W}.0${$?"-0":""}`;else if(H)Q=`>=${Q}`;else Q=`>=${Q}${$?"-0":""}`;if(X$(V))G="";else if(X$(D))G=`<${+V+1}.0.0-0`;else if(X$(z))G=`<${V}.${+D+1}.0-0`;else if(Z)G=`<=${V}.${D}.${z}-${Z}`;else if($)G=`<${V}.${D}.${+z+1}-0`;else G=`<=${G}`;return`${Q} ${G}`.trim()},eJ=($,q,Q)=>{for(let J=0;J<$.length;J++)if(!$[J].test(q))return!1;if(q.prerelease.length&&!Q.includePrerelease){for(let J=0;J<$.length;J++){if(c($[J].semver),$[J].semver===C6.ANY)continue;if($[J].semver.prerelease.length>0){let W=$[J].semver;if(W.major===q.major&&W.minor===q.minor&&W.patch===q.patch)return!0}}return!1}return!0}});var x1=N((Hw,u8)=>{var T1=Symbol("SemVer ANY");class I0{static get ANY(){return T1}constructor($,q){if(q=v8(q),$ instanceof I0)if($.loose===!!q.loose)return $;else $=$.value;if($=$.trim().split(/\s+/).join(" "),M6("comparator",$,q),this.options=q,this.loose=!!q.loose,this.parse($),this.semver===T1)this.value="";else this.value=this.operator+this.semver.version;M6("comp",this)}parse($){let q=this.options.loose?g8[m8.COMPARATORLOOSE]:g8[m8.COMPARATOR],Q=$.match(q);if(!Q)throw TypeError(`Invalid comparator: ${$}`);if(this.operator=Q[1]!==void 0?Q[1]:"",this.operator==="=")this.operator="";if(!Q[2])this.semver=T1;else this.semver=new y8(Q[2],this.options.loose)}toString(){return this.value}test($){if(M6("Comparator.test",$,this.options.loose),this.semver===T1||$===T1)return!0;if(typeof $==="string")try{$=new y8($,this.options)}catch(q){return!1}return O6($,this.operator,this.semver,this.options)}intersects($,q){if(!($ instanceof I0))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new l8($.value,q).test(this.value)}else if($.operator===""){if($.value==="")return!0;return new l8(this.value,q).test($.semver)}if(q=v8(q),q.includePrerelease&&(this.value==="<0.0.0-0"||$.value==="<0.0.0-0"))return!1;if(!q.includePrerelease&&(this.value.startsWith("<0.0.0")||$.value.startsWith("<0.0.0")))return!1;if(this.operator.startsWith(">")&&$.operator.startsWith(">"))return!0;if(this.operator.startsWith("<")&&$.operator.startsWith("<"))return!0;if(this.semver.version===$.semver.version&&this.operator.includes("=")&&$.operator.includes("="))return!0;if(O6(this.semver,"<",$.semver,q)&&this.operator.startsWith(">")&&$.operator.startsWith("<"))return!0;if(O6(this.semver,">",$.semver,q)&&this.operator.startsWith("<")&&$.operator.startsWith(">"))return!0;return!1}}u8.exports=I0;var v8=j0(),{safeRe:g8,t:m8}=W1(),O6=A6(),M6=P1(),y8=q$(),l8=B$()});var h1=N((Yw,c8)=>{var $7=B$(),q7=($,q,Q)=>{try{q=new $7(q,Q)}catch(J){return!1}return q.test($)};c8.exports=q7});var n8=N((Gw,d8)=>{var Q7=B$(),J7=($,q)=>new Q7($,q).set.map((Q)=>Q.map((J)=>J.value).join(" ").trim().split(" "));d8.exports=J7});var i8=N((ww,p8)=>{var W7=q$(),X7=B$(),H7=($,q,Q)=>{let J=null,W=null,X=null;try{X=new X7(q,Q)}catch(H){return null}return $.forEach((H)=>{if(X.test(H)){if(!J||W.compare(H)===-1)J=H,W=new W7(J,Q)}}),J};p8.exports=H7});var s8=N((Bw,o8)=>{var Y7=q$(),G7=B$(),w7=($,q,Q)=>{let J=null,W=null,X=null;try{X=new G7(q,Q)}catch(H){return null}return $.forEach((H)=>{if(X.test(H)){if(!J||W.compare(H)===1)J=H,W=new Y7(J,Q)}}),J};o8.exports=w7});var t8=N((Vw,a8)=>{var K6=q$(),B7=B$(),r8=Z1(),V7=($,q)=>{$=new B7($,q);let Q=new K6("0.0.0");if($.test(Q))return Q;if(Q=new K6("0.0.0-0"),$.test(Q))return Q;Q=null;for(let J=0;J<$.set.length;++J){let W=$.set[J],X=null;if(W.forEach((H)=>{let Y=new K6(H.semver.version);switch(H.operator){case">":if(Y.prerelease.length===0)Y.patch++;else Y.prerelease.push(0);Y.raw=Y.format();case"":case">=":if(!X||r8(Y,X))X=Y;break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${H.operator}`)}}),X&&(!Q||r8(Q,X)))Q=X}if(Q&&$.test(Q))return Q;return null};a8.exports=V7});var $9=N((Fw,e8)=>{var F7=B$(),_7=($,q)=>{try{return new F7($,q).range||"*"}catch(Q){return null}};e8.exports=_7});var b0=N((_w,W9)=>{var D7=q$(),J9=x1(),{ANY:U7}=J9,z7=B$(),L7=h1(),q9=Z1(),Q9=C0(),j7=M0(),N7=O0(),R7=($,q,Q,J)=>{$=new D7($,J),q=new z7(q,J);let W,X,H,Y,G;switch(Q){case">":W=q9,X=j7,H=Q9,Y=">",G=">=";break;case"<":W=Q9,X=N7,H=q9,Y="<",G="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(L7($,q,J))return!1;for(let V=0;V<q.set.length;++V){let D=q.set[V],z=null,Z=null;if(D.forEach((C)=>{if(C.semver===U7)C=new J9(">=0.0.0");if(z=z||C,Z=Z||C,W(C.semver,z.semver,J))z=C;else if(H(C.semver,Z.semver,J))Z=C}),z.operator===Y||z.operator===G)return!1;if((!Z.operator||Z.operator===Y)&&X($,Z.semver))return!1;else if(Z.operator===G&&H($,Z.semver))return!1}return!0};W9.exports=R7});var H9=N((Dw,X9)=>{var E7=b0(),S7=($,q,Q)=>E7($,q,">",Q);X9.exports=S7});var G9=N((Uw,Y9)=>{var A7=b0(),C7=($,q,Q)=>A7($,q,"<",Q);Y9.exports=C7});var V9=N((zw,B9)=>{var w9=B$(),O7=($,q,Q)=>{return $=new w9($,Q),q=new w9(q,Q),$.intersects(q,Q)};B9.exports=O7});var _9=N((Lw,F9)=>{var M7=h1(),K7=w$();F9.exports=($,q,Q)=>{let J=[],W=null,X=null,H=$.sort((D,z)=>K7(D,z,Q));for(let D of H)if(M7(D,q,Q)){if(X=D,!W)W=D}else{if(X)J.push([W,X]);X=null,W=null}if(W)J.push([W,null]);let Y=[];for(let[D,z]of J)if(D===z)Y.push(D);else if(!z&&D===H[0])Y.push("*");else if(!z)Y.push(`>=${D}`);else if(D===H[0])Y.push(`<=${z}`);else Y.push(`${D} - ${z}`);let G=Y.join(" || "),V=typeof q.raw==="string"?q.raw:String(q);return G.length<V.length?G:q}});var N9=N((jw,j9)=>{var D9=B$(),I6=x1(),{ANY:k6}=I6,v1=h1(),b6=w$(),k7=($,q,Q={})=>{if($===q)return!0;$=new D9($,Q),q=new D9(q,Q);let J=!1;$:for(let W of $.set){for(let X of q.set){let H=b7(W,X,Q);if(J=J||H!==null,H)continue $}if(J)return!1}return!0},I7=[new I6(">=0.0.0-0")],U9=[new I6(">=0.0.0")],b7=($,q,Q)=>{if($===q)return!0;if($.length===1&&$[0].semver===k6)if(q.length===1&&q[0].semver===k6)return!0;else if(Q.includePrerelease)$=I7;else $=U9;if(q.length===1&&q[0].semver===k6)if(Q.includePrerelease)return!0;else q=U9;let J=new Set,W,X;for(let C of $)if(C.operator===">"||C.operator===">=")W=z9(W,C,Q);else if(C.operator==="<"||C.operator==="<=")X=L9(X,C,Q);else J.add(C.semver);if(J.size>1)return null;let H;if(W&&X){if(H=b6(W.semver,X.semver,Q),H>0)return null;else if(H===0&&(W.operator!==">="||X.operator!=="<="))return null}for(let C of J){if(W&&!v1(C,String(W),Q))return null;if(X&&!v1(C,String(X),Q))return null;for(let y of q)if(!v1(C,String(y),Q))return!1;return!0}let Y,G,V,D,z=X&&!Q.includePrerelease&&X.semver.prerelease.length?X.semver:!1,Z=W&&!Q.includePrerelease&&W.semver.prerelease.length?W.semver:!1;if(z&&z.prerelease.length===1&&X.operator==="<"&&z.prerelease[0]===0)z=!1;for(let C of q){if(D=D||C.operator===">"||C.operator===">=",V=V||C.operator==="<"||C.operator==="<=",W){if(Z){if(C.semver.prerelease&&C.semver.prerelease.length&&C.semver.major===Z.major&&C.semver.minor===Z.minor&&C.semver.patch===Z.patch)Z=!1}if(C.operator===">"||C.operator===">="){if(Y=z9(W,C,Q),Y===C&&Y!==W)return!1}else if(W.operator===">="&&!v1(W.semver,String(C),Q))return!1}if(X){if(z){if(C.semver.prerelease&&C.semver.prerelease.length&&C.semver.major===z.major&&C.semver.minor===z.minor&&C.semver.patch===z.patch)z=!1}if(C.operator==="<"||C.operator==="<="){if(G=L9(X,C,Q),G===C&&G!==X)return!1}else if(X.operator==="<="&&!v1(X.semver,String(C),Q))return!1}if(!C.operator&&(X||W)&&H!==0)return!1}if(W&&V&&!X&&H!==0)return!1;if(X&&D&&!W&&H!==0)return!1;if(Z||z)return!1;return!0},z9=($,q,Q)=>{if(!$)return q;let J=b6($.semver,q.semver,Q);return J>0?$:J<0?q:q.operator===">"&&$.operator===">="?q:$},L9=($,q,Q)=>{if(!$)return q;let J=b6($.semver,q.semver,Q);return J<0?$:J>0?q:q.operator==="<"&&$.operator==="<="?q:$};j9.exports=k7});var P0=N((Nw,S9)=>{var P6=W1(),R9=b1(),P7=q$(),E9=N6(),Z7=l$(),f7=pq(),x7=oq(),T7=aq(),h7=$8(),v7=Q8(),g7=W8(),m7=H8(),y7=G8(),l7=w$(),u7=F8(),c7=D8(),d7=A0(),n7=j8(),p7=R8(),i7=Z1(),o7=C0(),s7=E6(),r7=S6(),a7=O0(),t7=M0(),e7=A6(),$3=I8(),q3=x1(),Q3=B$(),J3=h1(),W3=n8(),X3=i8(),H3=s8(),Y3=t8(),G3=$9(),w3=b0(),B3=H9(),V3=G9(),F3=V9(),_3=_9(),D3=N9();S9.exports={parse:Z7,valid:f7,clean:x7,inc:T7,diff:h7,major:v7,minor:g7,patch:m7,prerelease:y7,compare:l7,rcompare:u7,compareLoose:c7,compareBuild:d7,sort:n7,rsort:p7,gt:i7,lt:o7,eq:s7,neq:r7,gte:a7,lte:t7,cmp:e7,coerce:$3,Comparator:q3,Range:Q3,satisfies:J3,toComparators:W3,maxSatisfying:X3,minSatisfying:H3,minVersion:Y3,validRange:G3,outside:w3,gtr:B3,ltr:V3,intersects:F3,simplifyRange:_3,subset:D3,SemVer:P7,re:P6.re,src:P6.src,tokens:P6.t,SEMVER_SPEC_VERSION:R9.SEMVER_SPEC_VERSION,RELEASE_TYPES:R9.RELEASE_TYPES,compareIdentifiers:E9.compareIdentifiers,rcompareIdentifiers:E9.rcompareIdentifiers}});var C9=N((Rw,A9)=>{var U3=P0();A9.exports=U3.satisfies(process.version,">=15.7.0")});var M9=N((Ew,O9)=>{var z3=P0();O9.exports=z3.satisfies(process.version,">=16.9.0")});var Z6=N((Sw,K9)=>{var L3=C9(),j3=M9(),N3={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},R3={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};K9.exports=function($,q){if(!$||!q)return;let Q=q.asymmetricKeyType;if(!Q)return;let J=N3[Q];if(!J)throw Error(`Unknown key type "${Q}".`);if(!J.includes($))throw Error(`"alg" parameter for "${Q}" key type must be one of: ${J.join(", ")}.`);if(L3)switch(Q){case"ec":let W=q.asymmetricKeyDetails.namedCurve,X=R3[$];if(W!==X)throw Error(`"alg" parameter "${$}" requires curve "${X}".`);break;case"rsa-pss":if(j3){let H=parseInt($.slice(-3),10),{hashAlgorithm:Y,mgf1HashAlgorithm:G,saltLength:V}=q.asymmetricKeyDetails;if(Y!==`sha${H}`||G!==Y)throw Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${$}.`);if(V!==void 0&&V>H>>3)throw Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${$}.`)}break}}});var f6=N((Aw,k9)=>{var E3=P0();k9.exports=E3.satisfies(process.version,"^6.12.0 || >=8.0.0")});var P9=N((Cw,b9)=>{var l=I1(),S3=D6(),I9=U6(),A3=_6(),C3=z6(),O3=Z6(),M3=f6(),K3=_0(),{KeyObject:k3,createSecretKey:I3,createPublicKey:b3}=require("crypto"),x6=["RS256","RS384","RS512"],P3=["ES256","ES384","ES512"],T6=["RS256","RS384","RS512"],Z3=["HS256","HS384","HS512"];if(M3)x6.splice(x6.length,0,"PS256","PS384","PS512"),T6.splice(T6.length,0,"PS256","PS384","PS512");b9.exports=function($,q,Q,J){if(typeof Q==="function"&&!J)J=Q,Q={};if(!Q)Q={};Q=Object.assign({},Q);let W;if(J)W=J;else W=function(D,z){if(D)throw D;return z};if(Q.clockTimestamp&&typeof Q.clockTimestamp!=="number")return W(new l("clockTimestamp must be a number"));if(Q.nonce!==void 0&&(typeof Q.nonce!=="string"||Q.nonce.trim()===""))return W(new l("nonce must be a non-empty string"));if(Q.allowInvalidAsymmetricKeyTypes!==void 0&&typeof Q.allowInvalidAsymmetricKeyTypes!=="boolean")return W(new l("allowInvalidAsymmetricKeyTypes must be a boolean"));let X=Q.clockTimestamp||Math.floor(Date.now()/1000);if(!$)return W(new l("jwt must be provided"));if(typeof $!=="string")return W(new l("jwt must be a string"));let H=$.split(".");if(H.length!==3)return W(new l("jwt malformed"));let Y;try{Y=A3($,{complete:!0})}catch(D){return W(D)}if(!Y)return W(new l("invalid token"));let G=Y.header,V;if(typeof q==="function"){if(!J)return W(new l("verify must be called asynchronous if secret or public key is provided as a callback"));V=q}else V=function(D,z){return z(null,q)};return V(G,function(D,z){if(D)return W(new l("error in secret or public key callback: "+D.message));let Z=H[2].trim()!=="";if(!Z&&z)return W(new l("jwt signature is required"));if(Z&&!z)return W(new l("secret or public key must be provided"));if(!Z&&!Q.algorithms)return W(new l('please specify "none" in "algorithms" to verify unsigned tokens'));if(z!=null&&!(z instanceof k3))try{z=b3(z)}catch(p){try{z=I3(typeof z==="string"?Buffer.from(z):z)}catch(o$){return W(new l("secretOrPublicKey is not valid key material"))}}if(!Q.algorithms)if(z.type==="secret")Q.algorithms=Z3;else if(["rsa","rsa-pss"].includes(z.asymmetricKeyType))Q.algorithms=T6;else if(z.asymmetricKeyType==="ec")Q.algorithms=P3;else Q.algorithms=x6;if(Q.algorithms.indexOf(Y.header.alg)===-1)return W(new l("invalid algorithm"));if(G.alg.startsWith("HS")&&z.type!=="secret")return W(new l(`secretOrPublicKey must be a symmetric key when using ${G.alg}`));else if(/^(?:RS|PS|ES)/.test(G.alg)&&z.type!=="public")return W(new l(`secretOrPublicKey must be an asymmetric key when using ${G.alg}`));if(!Q.allowInvalidAsymmetricKeyTypes)try{O3(G.alg,z)}catch(p){return W(p)}let C;try{C=K3.verify($,Y.header.alg,z)}catch(p){return W(p)}if(!C)return W(new l("invalid signature"));let y=Y.payload;if(typeof y.nbf<"u"&&!Q.ignoreNotBefore){if(typeof y.nbf!=="number")return W(new l("invalid nbf value"));if(y.nbf>X+(Q.clockTolerance||0))return W(new S3("jwt not active",new Date(y.nbf*1000)))}if(typeof y.exp<"u"&&!Q.ignoreExpiration){if(typeof y.exp!=="number")return W(new l("invalid exp value"));if(X>=y.exp+(Q.clockTolerance||0))return W(new I9("jwt expired",new Date(y.exp*1000)))}if(Q.audience){let p=Array.isArray(Q.audience)?Q.audience:[Q.audience];if(!(Array.isArray(y.aud)?y.aud:[y.aud]).some(function(Q0){return p.some(function(A1){return A1 instanceof RegExp?A1.test(Q0):A1===Q0})}))return W(new l("jwt audience invalid. expected: "+p.join(" or ")))}if(Q.issuer){if(typeof Q.issuer==="string"&&y.iss!==Q.issuer||Array.isArray(Q.issuer)&&Q.issuer.indexOf(y.iss)===-1)return W(new l("jwt issuer invalid. expected: "+Q.issuer))}if(Q.subject){if(y.sub!==Q.subject)return W(new l("jwt subject invalid. expected: "+Q.subject))}if(Q.jwtid){if(y.jti!==Q.jwtid)return W(new l("jwt jwtid invalid. expected: "+Q.jwtid))}if(Q.nonce){if(y.nonce!==Q.nonce)return W(new l("jwt nonce invalid. expected: "+Q.nonce))}if(Q.maxAge){if(typeof y.iat!=="number")return W(new l("iat required when maxAge is specified"));let p=C3(Q.maxAge,y.iat);if(typeof p>"u")return W(new l('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(X>=p+(Q.clockTolerance||0))return W(new I9("maxAge exceeded",new Date(p*1000)))}if(Q.complete===!0){let p=Y.signature;return W(null,{header:G,payload:y,signature:p})}return W(null,y)})}});var v9=N((Ow,h9)=>{var Z9=1/0,x9=9007199254740991,f3=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,f9=NaN,x3="[object Arguments]",T3="[object Function]",h3="[object GeneratorFunction]",v3="[object String]",g3="[object Symbol]",m3=/^\s+|\s+$/g,y3=/^[-+]0x[0-9a-f]+$/i,l3=/^0b[01]+$/i,u3=/^0o[0-7]+$/i,c3=/^(?:0|[1-9]\d*)$/,d3=parseInt;function n3($,q){var Q=-1,J=$?$.length:0,W=Array(J);while(++Q<J)W[Q]=q($[Q],Q,$);return W}function p3($,q,Q,J){var W=$.length,X=Q+(J?1:-1);while(J?X--:++X<W)if(q($[X],X,$))return X;return-1}function i3($,q,Q){if(q!==q)return p3($,o3,Q);var J=Q-1,W=$.length;while(++J<W)if($[J]===q)return J;return-1}function o3($){return $!==$}function s3($,q){var Q=-1,J=Array($);while(++Q<$)J[Q]=q(Q);return J}function r3($,q){return n3(q,function(Q){return $[Q]})}function a3($,q){return function(Q){return $(q(Q))}}var Z0=Object.prototype,v6=Z0.hasOwnProperty,f0=Z0.toString,t3=Z0.propertyIsEnumerable,e3=a3(Object.keys,Object),$W=Math.max;function qW($,q){var Q=T9($)||HW($)?s3($.length,String):[],J=Q.length,W=!!J;for(var X in $)if((q||v6.call($,X))&&!(W&&(X=="length"||JW(X,J))))Q.push(X);return Q}function QW($){if(!WW($))return e3($);var q=[];for(var Q in Object($))if(v6.call($,Q)&&Q!="constructor")q.push(Q);return q}function JW($,q){return q=q==null?x9:q,!!q&&(typeof $=="number"||c3.test($))&&($>-1&&$%1==0&&$<q)}function WW($){var q=$&&$.constructor,Q=typeof q=="function"&&q.prototype||Z0;return $===Q}function XW($,q,Q,J){$=g6($)?$:zW($),Q=Q&&!J?_W(Q):0;var W=$.length;if(Q<0)Q=$W(W+Q,0);return BW($)?Q<=W&&$.indexOf(q,Q)>-1:!!W&&i3($,q,Q)>-1}function HW($){return YW($)&&v6.call($,"callee")&&(!t3.call($,"callee")||f0.call($)==x3)}var T9=Array.isArray;function g6($){return $!=null&&wW($.length)&&!GW($)}function YW($){return m6($)&&g6($)}function GW($){var q=h6($)?f0.call($):"";return q==T3||q==h3}function wW($){return typeof $=="number"&&$>-1&&$%1==0&&$<=x9}function h6($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function m6($){return!!$&&typeof $=="object"}function BW($){return typeof $=="string"||!T9($)&&m6($)&&f0.call($)==v3}function VW($){return typeof $=="symbol"||m6($)&&f0.call($)==g3}function FW($){if(!$)return $===0?$:0;if($=DW($),$===Z9||$===-Z9){var q=$<0?-1:1;return q*f3}return $===$?$:0}function _W($){var q=FW($),Q=q%1;return q===q?Q?q-Q:q:0}function DW($){if(typeof $=="number")return $;if(VW($))return f9;if(h6($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=h6(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(m3,"");var Q=l3.test($);return Q||u3.test($)?d3($.slice(2),Q?2:8):y3.test($)?f9:+$}function UW($){return g6($)?qW($):QW($)}function zW($){return $?r3($,UW($)):[]}h9.exports=XW});var m9=N((Mw,g9)=>{var LW="[object Boolean]",jW=Object.prototype,NW=jW.toString;function RW($){return $===!0||$===!1||EW($)&&NW.call($)==LW}function EW($){return!!$&&typeof $=="object"}g9.exports=RW});var d9=N((Kw,c9)=>{var y9=1/0,SW=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,l9=NaN,AW="[object Symbol]",CW=/^\s+|\s+$/g,OW=/^[-+]0x[0-9a-f]+$/i,MW=/^0b[01]+$/i,KW=/^0o[0-7]+$/i,kW=parseInt,IW=Object.prototype,bW=IW.toString;function PW($){return typeof $=="number"&&$==TW($)}function u9($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function ZW($){return!!$&&typeof $=="object"}function fW($){return typeof $=="symbol"||ZW($)&&bW.call($)==AW}function xW($){if(!$)return $===0?$:0;if($=hW($),$===y9||$===-y9){var q=$<0?-1:1;return q*SW}return $===$?$:0}function TW($){var q=xW($),Q=q%1;return q===q?Q?q-Q:q:0}function hW($){if(typeof $=="number")return $;if(fW($))return l9;if(u9($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=u9(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(CW,"");var Q=MW.test($);return Q||KW.test($)?kW($.slice(2),Q?2:8):OW.test($)?l9:+$}c9.exports=PW});var p9=N((kw,n9)=>{var vW="[object Number]",gW=Object.prototype,mW=gW.toString;function yW($){return!!$&&typeof $=="object"}function lW($){return typeof $=="number"||yW($)&&mW.call($)==vW}n9.exports=lW});var r9=N((Iw,s9)=>{var uW="[object Object]";function cW($){var q=!1;if($!=null&&typeof $.toString!="function")try{q=!!($+"")}catch(Q){}return q}function dW($,q){return function(Q){return $(q(Q))}}var nW=Function.prototype,i9=Object.prototype,o9=nW.toString,pW=i9.hasOwnProperty,iW=o9.call(Object),oW=i9.toString,sW=dW(Object.getPrototypeOf,Object);function rW($){return!!$&&typeof $=="object"}function aW($){if(!rW($)||oW.call($)!=uW||cW($))return!1;var q=sW($);if(q===null)return!0;var Q=pW.call(q,"constructor")&&q.constructor;return typeof Q=="function"&&Q instanceof Q&&o9.call(Q)==iW}s9.exports=aW});var t9=N((bw,a9)=>{var tW="[object String]",eW=Object.prototype,$X=eW.toString,qX=Array.isArray;function QX($){return!!$&&typeof $=="object"}function JX($){return typeof $=="string"||!qX($)&&QX($)&&$X.call($)==tW}a9.exports=JX});var JQ=N((Pw,QQ)=>{var WX="Expected a function",e9=1/0,XX=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,$Q=NaN,HX="[object Symbol]",YX=/^\s+|\s+$/g,GX=/^[-+]0x[0-9a-f]+$/i,wX=/^0b[01]+$/i,BX=/^0o[0-7]+$/i,VX=parseInt,FX=Object.prototype,_X=FX.toString;function DX($,q){var Q;if(typeof q!="function")throw TypeError(WX);return $=NX($),function(){if(--$>0)Q=q.apply(this,arguments);if($<=1)q=void 0;return Q}}function UX($){return DX(2,$)}function qQ($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function zX($){return!!$&&typeof $=="object"}function LX($){return typeof $=="symbol"||zX($)&&_X.call($)==HX}function jX($){if(!$)return $===0?$:0;if($=RX($),$===e9||$===-e9){var q=$<0?-1:1;return q*XX}return $===$?$:0}function NX($){var q=jX($),Q=q%1;return q===q?Q?q-Q:q:0}function RX($){if(typeof $=="number")return $;if(LX($))return $Q;if(qQ($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=qQ(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(YX,"");var Q=wX.test($);return Q||BX.test($)?VX($.slice(2),Q?2:8):GX.test($)?$Q:+$}QQ.exports=UX});var FQ=N((Zw,VQ)=>{var WQ=z6(),EX=f6(),SX=Z6(),XQ=_0(),AX=v9(),x0=m9(),HQ=d9(),y6=p9(),GQ=r9(),b$=t9(),CX=JQ(),{KeyObject:OX,createSecretKey:MX,createPrivateKey:KX}=require("crypto"),wQ=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];if(EX)wQ.splice(3,0,"PS256","PS384","PS512");var kX={expiresIn:{isValid:function($){return HQ($)||b$($)&&$},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function($){return HQ($)||b$($)&&$},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function($){return b$($)||Array.isArray($)},message:'"audience" must be a string or array'},algorithm:{isValid:AX.bind(null,wQ),message:'"algorithm" must be a valid string enum value'},header:{isValid:GQ,message:'"header" must be an object'},encoding:{isValid:b$,message:'"encoding" must be a string'},issuer:{isValid:b$,message:'"issuer" must be a string'},subject:{isValid:b$,message:'"subject" must be a string'},jwtid:{isValid:b$,message:'"jwtid" must be a string'},noTimestamp:{isValid:x0,message:'"noTimestamp" must be a boolean'},keyid:{isValid:b$,message:'"keyid" must be a string'},mutatePayload:{isValid:x0,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:x0,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:x0,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},IX={iat:{isValid:y6,message:'"iat" should be a number of seconds'},exp:{isValid:y6,message:'"exp" should be a number of seconds'},nbf:{isValid:y6,message:'"nbf" should be a number of seconds'}};function BQ($,q,Q,J){if(!GQ(Q))throw Error('Expected "'+J+'" to be a plain object.');Object.keys(Q).forEach(function(W){let X=$[W];if(!X){if(!q)throw Error('"'+W+'" is not allowed in "'+J+'"');return}if(!X.isValid(Q[W]))throw Error(X.message)})}function bX($){return BQ(kX,!1,$,"options")}function PX($){return BQ(IX,!0,$,"payload")}var YQ={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},ZX=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];VQ.exports=function($,q,Q,J){if(typeof Q==="function")J=Q,Q={};else Q=Q||{};let W=typeof $==="object"&&!Buffer.isBuffer($),X=Object.assign({alg:Q.algorithm||"HS256",typ:W?"JWT":void 0,kid:Q.keyid},Q.header);function H(V){if(J)return J(V);throw V}if(!q&&Q.algorithm!=="none")return H(Error("secretOrPrivateKey must have a value"));if(q!=null&&!(q instanceof OX))try{q=KX(q)}catch(V){try{q=MX(typeof q==="string"?Buffer.from(q):q)}catch(D){return H(Error("secretOrPrivateKey is not valid key material"))}}if(X.alg.startsWith("HS")&&q.type!=="secret")return H(Error(`secretOrPrivateKey must be a symmetric key when using ${X.alg}`));else if(/^(?:RS|PS|ES)/.test(X.alg)){if(q.type!=="private")return H(Error(`secretOrPrivateKey must be an asymmetric key when using ${X.alg}`));if(!Q.allowInsecureKeySizes&&!X.alg.startsWith("ES")&&q.asymmetricKeyDetails!==void 0&&q.asymmetricKeyDetails.modulusLength<2048)return H(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`))}if(typeof $>"u")return H(Error("payload is required"));else if(W){try{PX($)}catch(V){return H(V)}if(!Q.mutatePayload)$=Object.assign({},$)}else{let V=ZX.filter(function(D){return typeof Q[D]<"u"});if(V.length>0)return H(Error("invalid "+V.join(",")+" option for "+typeof $+" payload"))}if(typeof $.exp<"u"&&typeof Q.expiresIn<"u")return H(Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(typeof $.nbf<"u"&&typeof Q.notBefore<"u")return H(Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{bX(Q)}catch(V){return H(V)}if(!Q.allowInvalidAsymmetricKeyTypes)try{SX(X.alg,q)}catch(V){return H(V)}let Y=$.iat||Math.floor(Date.now()/1000);if(Q.noTimestamp)delete $.iat;else if(W)$.iat=Y;if(typeof Q.notBefore<"u"){try{$.nbf=WQ(Q.notBefore,Y)}catch(V){return H(V)}if(typeof $.nbf>"u")return H(Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(typeof Q.expiresIn<"u"&&typeof $==="object"){try{$.exp=WQ(Q.expiresIn,Y)}catch(V){return H(V)}if(typeof $.exp>"u")return H(Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(YQ).forEach(function(V){let D=YQ[V];if(typeof Q[V]<"u"){if(typeof $[D]<"u")return H(Error('Bad "options.'+V+'" option. The payload already has an "'+D+'" property.'));$[D]=Q[V]}});let G=Q.encoding||"utf8";if(typeof J==="function")J=J&&CX(J),XQ.createSign({header:X,privateKey:q,payload:$,encoding:G}).once("error",J).once("done",function(V){if(!Q.allowInsecureKeySizes&&/^(?:RS|PS)/.test(X.alg)&&V.length<256)return J(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`));J(null,V)});else{let V=XQ.sign({header:X,payload:$,secret:q,encoding:G});if(!Q.allowInsecureKeySizes&&/^(?:RS|PS)/.test(X.alg)&&V.length<256)throw Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`);return V}}});var DQ=N((fw,_Q)=>{_Q.exports={decode:_6(),verify:P9(),sign:FQ(),JsonWebTokenError:I1(),NotBeforeError:D6(),TokenExpiredError:U6()}});function y0($){return`https://veloce-ts.com/problems/${$}`}function MQ($,q){if(q)return q;let Q=pH[$]??"unknown-error";return y0(Q)}function KQ($,q,Q){if(Q)return Q;return iH[$]??q}function oH($){try{return new URL($.req.url).href}catch{return $.req.path}}function sH($){let q=$.statusCode??$.status,J={error:(typeof $.error==="string"?$.error:null)??(typeof $.detail==="string"?$.detail:"Error"),statusCode:q};if($.details!==void 0)J.details=$.details;else if($.violations!==void 0)J.details=$.violations;return J}function BB($,q,Q,J){let W=oH($),X={...q,instance:W};if(J==="legacy")return $.json(sH(X),Q);return new Response(JSON.stringify(X),{status:Q,headers:{"Content-Type":"application/problem+json"}})}var GB="application/problem+json",wB="https://veloce-ts.com/problems",pH,iH;var d6=J0(()=>{pH={400:"bad-request",401:"unauthorized",403:"forbidden",404:"not-found",409:"conflict",410:"gone",413:"payload-too-large",422:"unprocessable-entity",429:"too-many-requests",500:"internal-server-error",503:"service-unavailable"},iH={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",409:"Conflict",410:"Gone",413:"Payload Too Large",422:"Unprocessable Entity",429:"Too Many Requests",500:"Internal Server Error",503:"Service Unavailable"}});var Y$,rH,aH,tH,eH,$Y,qY,QY,JY,WY,XY;var kQ=J0(()=>{d6();Y$=class Y$ extends Error{statusCode;details;problemType;title;constructor($,q,Q,J){super(q);this.statusCode=$;this.details=Q;if(this.name="HTTPException",this.problemType=J?.problemType,this.title=J?.title,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){let $=this.statusCode,q=MQ($,this.problemType),Q=KQ($,this.message,this.title);return{type:q,title:Q,status:$,detail:this.message,...this.details!==void 0?{details:this.details}:{},error:this.message,statusCode:$}}};rH=class rH extends Y${constructor($="Not Found",q){super(404,$,q,{title:"Not Found"});this.name="NotFoundException"}};aH=class aH extends Y${constructor($="Unauthorized",q){super(401,$,q,{title:"Unauthorized"});this.name="UnauthorizedException"}};tH=class tH extends Y${constructor($="Forbidden",q){super(403,$,q,{title:"Forbidden"});this.name="ForbiddenException"}};eH=class eH extends Y${constructor($="Bad Request",q){super(400,$,q,{title:"Bad Request"});this.name="BadRequestException"}};$Y=class $Y extends Y${constructor($="Conflict",q){super(409,$,q,{title:"Conflict"});this.name="ConflictException"}};qY=class qY extends Y${constructor($="Gone",q){super(410,$,q,{title:"Gone"});this.name="GoneException"}};QY=class QY extends Y${constructor($="Payload Too Large",q){super(413,$,q,{title:"Payload Too Large"});this.name="PayloadTooLargeException"}};JY=class JY extends Y${constructor($="Unprocessable Entity",q){super(422,$,q,{title:"Unprocessable Entity"});this.name="UnprocessableEntityException"}};WY=class WY extends Y${constructor($="Too Many Requests",q){super(429,$,q,{title:"Too Many Requests"});this.name="TooManyRequestsException"}};XY=class XY extends Y${constructor($="Service Unavailable",q){super(503,$,q,{title:"Service Unavailable"});this.name="ServiceUnavailableException"}}});var HY={};Q6(HY,{TokenRevokedException:()=>n6,TokenExpiredException:()=>n1,InvalidTokenException:()=>i$,AuthorizationException:()=>t,AuthenticationException:()=>a});var a,t,n1,i$,n6;var v$=J0(()=>{kQ();d6();a=class a extends Y${constructor($="Authentication required"){super(401,$,void 0,{title:"Authentication Error",problemType:y0("authentication-error")});this.name="AuthenticationException"}};t=class t extends Y${constructor($="Insufficient permissions"){super(403,$,void 0,{title:"Authorization Error",problemType:y0("authorization-error")});this.name="AuthorizationException"}};n1=class n1 extends a{constructor($="Token has expired"){super($);this.name="TokenExpiredException"}};i$=class i$ extends a{constructor($="Invalid token"){super($);this.name="InvalidTokenException"}};n6=class n6 extends a{constructor($="Token has been revoked"){super($);this.name="TokenRevokedException"}}});var PQ=N(()=>{/*! *****************************************************************************
|
|
4
|
-
Copyright (C) Microsoft. All rights reserved.
|
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
6
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
7
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
3
|
+
"HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".`,W6="secret must be a string or buffer",k$="key must be a string or a buffer",OQ="key must be a string, a buffer or an object",k0=typeof p.createPublicKey==="function";if(k0)k$+=" or a KeyObject",W6+="or a KeyObject";function J1($){if(b$.isBuffer($))return;if(typeof $==="string")return;if(!k0)throw r(k$);if(typeof $!=="object")throw r(k$);if(typeof $.type!=="string")throw r(k$);if(typeof $.asymmetricKeyType!=="string")throw r(k$);if(typeof $.export!=="function")throw r(k$)}function W1($){if(b$.isBuffer($))return;if(typeof $==="string")return;if(typeof $==="object")return;throw r(OQ)}function NQ($){if(b$.isBuffer($))return;if(typeof $==="string")return $;if(!k0)throw r(W6);if(typeof $!=="object")throw r(W6);if($.type!=="secret")throw r(W6);if(typeof $.export!=="function")throw r(W6)}function b0($){return $.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function X1($){$=$.toString();var q=4-$.length%4;if(q!==4)for(var Q=0;Q<q;++Q)$+="=";return $.replace(/\-/g,"+").replace(/_/g,"/")}function r($){var q=[].slice.call(arguments,1),Q=q1.format.bind(q1,$).apply(null,q);return TypeError(Q)}function RQ($){return b$.isBuffer($)||typeof $==="string"}function X6($){if(!RQ($))$=JSON.stringify($);return $}function H1($){return function(Q,J){NQ(J),Q=X6(Q);var W=p.createHmac("sha"+$,J),X=(W.update(Q),W.digest("base64"));return b0(X)}}var P0,SQ="timingSafeEqual"in p?function(q,Q){if(q.byteLength!==Q.byteLength)return!1;return p.timingSafeEqual(q,Q)}:function(q,Q){if(!P0)P0=$1();return P0(q,Q)};function MQ($){return function(Q,J,W){var X=H1($)(Q,W);return SQ(b$.from(J),b$.from(X))}}function Y1($){return function(Q,J){W1(J),Q=X6(Q);var W=p.createSign("RSA-SHA"+$),X=(W.update(Q),W.sign(J,"base64"));return b0(X)}}function G1($){return function(Q,J,W){J1(W),Q=X6(Q),J=X1(J);var X=p.createVerify("RSA-SHA"+$);return X.update(Q),X.verify(W,J,"base64")}}function EQ($){return function(Q,J){W1(J),Q=X6(Q);var W=p.createSign("RSA-SHA"+$),X=(W.update(Q),W.sign({key:J,padding:p.constants.RSA_PKCS1_PSS_PADDING,saltLength:p.constants.RSA_PSS_SALTLEN_DIGEST},"base64"));return b0(X)}}function AQ($){return function(Q,J,W){J1(W),Q=X6(Q),J=X1(J);var X=p.createVerify("RSA-SHA"+$);return X.update(Q),X.verify({key:W,padding:p.constants.RSA_PKCS1_PSS_PADDING,saltLength:p.constants.RSA_PSS_SALTLEN_DIGEST},J,"base64")}}function CQ($){var q=Y1($);return function(){var J=q.apply(null,arguments);return J=Q1.derToJose(J,"ES"+$),J}}function KQ($){var q=G1($);return function(J,W,X){W=Q1.joseToDer(W,"ES"+$).toString("base64");var H=q(J,W,X);return H}}function IQ(){return function(){return""}}function PQ(){return function(q,Q){return Q===""}}B1.exports=function(q){var Q={hs:H1,rs:Y1,ps:EQ,es:CQ,none:IQ},J={hs:MQ,rs:G1,ps:AQ,es:KQ,none:PQ},W=q.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!W)throw r(jQ,q);var X=(W[1]||W[3]).toLowerCase(),H=W[2];return{sign:Q[X](H),verify:J[X](H)}}});var f0=z((mH,w1)=>{var kQ=require("buffer").Buffer;w1.exports=function(q){if(typeof q==="string")return q;if(typeof q==="number"||kQ.isBuffer(q))return q.toString();return JSON.stringify(q)}});var z1=z((lH,D1)=>{var bQ=P$().Buffer,V1=C0(),ZQ=Z0(),fQ=require("stream"),F1=f0(),T0=require("util");function U1($,q){return bQ.from($,q).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function TQ($,q,Q){Q=Q||"utf8";var J=U1(F1($),"binary"),W=U1(F1(q),Q);return T0.format("%s.%s",J,W)}function _1($){var{header:q,payload:Q}=$,J=$.secret||$.privateKey,W=$.encoding,X=ZQ(q.alg),H=TQ(q,Q,W),Y=X.sign(H,J);return T0.format("%s.%s",H,Y)}function m6($){var q=$.secret;if(q=q==null?$.privateKey:q,q=q==null?$.key:q,/^hs/i.test($.header.alg)===!0&&q==null)throw TypeError("secret must be a string or buffer or a KeyObject");var Q=new V1(q);this.readable=!0,this.header=$.header,this.encoding=$.encoding,this.secret=this.privateKey=this.key=Q,this.payload=new V1($.payload),this.secret.once("close",function(){if(!this.payload.writable&&this.readable)this.sign()}.bind(this)),this.payload.once("close",function(){if(!this.secret.writable&&this.readable)this.sign()}.bind(this))}T0.inherits(m6,fQ);m6.prototype.sign=function(){try{var q=_1({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",q),this.emit("data",q),this.emit("end"),this.readable=!1,q}catch(Q){this.readable=!1,this.emit("error",Q),this.emit("close")}};m6.sign=_1;D1.exports=m6});var C1=z((uH,A1)=>{var j1=P$().Buffer,L1=C0(),xQ=Z0(),vQ=require("stream"),O1=f0(),hQ=require("util"),gQ=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function yQ($){return Object.prototype.toString.call($)==="[object Object]"}function mQ($){if(yQ($))return $;try{return JSON.parse($)}catch(q){return}}function N1($){var q=$.split(".",1)[0];return mQ(j1.from(q,"base64").toString("binary"))}function lQ($){return $.split(".",2).join(".")}function R1($){return $.split(".")[2]}function uQ($,q){q=q||"utf8";var Q=$.split(".")[1];return j1.from(Q,"base64").toString(q)}function S1($){return gQ.test($)&&!!N1($)}function M1($,q,Q){if(!q){var J=Error("Missing algorithm parameter for jws.verify");throw J.code="MISSING_ALGORITHM",J}$=O1($);var W=R1($),X=lQ($),H=xQ(q);return H.verify(X,W,Q)}function E1($,q){if(q=q||{},$=O1($),!S1($))return null;var Q=N1($);if(!Q)return null;var J=uQ($);if(Q.typ==="JWT"||q.json)J=JSON.parse(J,q.encoding);return{header:Q,payload:J,signature:R1($)}}function Z$($){$=$||{};var q=$.secret;if(q=q==null?$.publicKey:q,q=q==null?$.key:q,/^hs/i.test($.algorithm)===!0&&q==null)throw TypeError("secret must be a string or buffer or a KeyObject");var Q=new L1(q);this.readable=!0,this.algorithm=$.algorithm,this.encoding=$.encoding,this.secret=this.publicKey=this.key=Q,this.signature=new L1($.signature),this.secret.once("close",function(){if(!this.signature.writable&&this.readable)this.verify()}.bind(this)),this.signature.once("close",function(){if(!this.secret.writable&&this.readable)this.verify()}.bind(this))}hQ.inherits(Z$,vQ);Z$.prototype.verify=function(){try{var q=M1(this.signature.buffer,this.algorithm,this.key.buffer),Q=E1(this.signature.buffer,this.encoding);return this.emit("done",q,Q),this.emit("data",q),this.emit("end"),this.readable=!1,q}catch(J){this.readable=!1,this.emit("error",J),this.emit("close")}};Z$.decode=E1;Z$.isValid=S1;Z$.verify=M1;A1.exports=Z$});var u6=z((V$)=>{var K1=z1(),l6=C1(),cQ=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"];V$.ALGORITHMS=cQ;V$.sign=K1.sign;V$.verify=l6.verify;V$.decode=l6.decode;V$.isValid=l6.isValid;V$.createSign=function(q){return new K1(q)};V$.createVerify=function(q){return new l6(q)}});var x0=z((dH,I1)=>{var dQ=u6();I1.exports=function($,q){q=q||{};var Q=dQ.decode($,q);if(!Q)return null;var J=Q.payload;if(typeof J==="string")try{var W=JSON.parse(J);if(W!==null&&typeof W==="object")J=W}catch(X){}if(q.complete===!0)return{header:Q.header,payload:J,signature:Q.signature};return J}});var H6=z((pH,P1)=>{var c6=function($,q){if(Error.call(this,$),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);if(this.name="JsonWebTokenError",this.message=$,q)this.inner=q};c6.prototype=Object.create(Error.prototype);c6.prototype.constructor=c6;P1.exports=c6});var v0=z((nH,b1)=>{var k1=H6(),d6=function($,q){k1.call(this,$),this.name="NotBeforeError",this.date=q};d6.prototype=Object.create(k1.prototype);d6.prototype.constructor=d6;b1.exports=d6});var h0=z((iH,f1)=>{var Z1=H6(),p6=function($,q){Z1.call(this,$),this.name="TokenExpiredError",this.expiredAt=q};p6.prototype=Object.create(Z1.prototype);p6.prototype.constructor=p6;f1.exports=p6});var x1=z((rH,T1)=>{var f$=1000,T$=f$*60,x$=T$*60,R$=x$*24,pQ=R$*7,nQ=R$*365.25;T1.exports=function($,q){q=q||{};var Q=typeof $;if(Q==="string"&&$.length>0)return iQ($);else if(Q==="number"&&isFinite($))return q.long?oQ($):rQ($);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify($))};function iQ($){if($=String($),$.length>100)return;var q=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec($);if(!q)return;var Q=parseFloat(q[1]),J=(q[2]||"ms").toLowerCase();switch(J){case"years":case"year":case"yrs":case"yr":case"y":return Q*nQ;case"weeks":case"week":case"w":return Q*pQ;case"days":case"day":case"d":return Q*R$;case"hours":case"hour":case"hrs":case"hr":case"h":return Q*x$;case"minutes":case"minute":case"mins":case"min":case"m":return Q*T$;case"seconds":case"second":case"secs":case"sec":case"s":return Q*f$;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return Q;default:return}}function rQ($){var q=Math.abs($);if(q>=R$)return Math.round($/R$)+"d";if(q>=x$)return Math.round($/x$)+"h";if(q>=T$)return Math.round($/T$)+"m";if(q>=f$)return Math.round($/f$)+"s";return $+"ms"}function oQ($){var q=Math.abs($);if(q>=R$)return n6($,q,R$,"day");if(q>=x$)return n6($,q,x$,"hour");if(q>=T$)return n6($,q,T$,"minute");if(q>=f$)return n6($,q,f$,"second");return $+" ms"}function n6($,q,Q,J){var W=q>=Q*1.5;return Math.round($/Q)+" "+J+(W?"s":"")}});var g0=z((oH,v1)=>{var aQ=x1();v1.exports=function($,q){var Q=q||Math.floor(Date.now()/1000);if(typeof $==="string"){var J=aQ($);if(typeof J>"u")return;return Math.floor(Q+J/1000)}else if(typeof $==="number")return Q+$;else return}});var Y6=z((aH,h1)=>{var sQ=Number.MAX_SAFE_INTEGER||9007199254740991,tQ=["major","premajor","minor","preminor","patch","prepatch","prerelease"];h1.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:sQ,RELEASE_TYPES:tQ,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var G6=z((sH,g1)=>{var eQ=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...$)=>console.error("SEMVER",...$):()=>{};g1.exports=eQ});var v$=z((J$,y1)=>{var{MAX_SAFE_COMPONENT_LENGTH:y0,MAX_SAFE_BUILD_LENGTH:$J,MAX_LENGTH:qJ}=Y6(),QJ=G6();J$=y1.exports={};var JJ=J$.re=[],WJ=J$.safeRe=[],L=J$.src=[],XJ=J$.safeSrc=[],j=J$.t={},HJ=0,m0="[a-zA-Z0-9-]",YJ=[["\\s",1],["\\d",qJ],[m0,$J]],GJ=($)=>{for(let[q,Q]of YJ)$=$.split(`${q}*`).join(`${q}{0,${Q}}`).split(`${q}+`).join(`${q}{1,${Q}}`);return $},E=($,q,Q)=>{let J=GJ(q),W=HJ++;QJ($,W,q),j[$]=W,L[W]=q,XJ[W]=J,JJ[W]=new RegExp(q,Q?"g":void 0),WJ[W]=new RegExp(J,Q?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*");E("NUMERICIDENTIFIERLOOSE","\\d+");E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m0}*`);E("MAINVERSION",`(${L[j.NUMERICIDENTIFIER]})\\.(${L[j.NUMERICIDENTIFIER]})\\.(${L[j.NUMERICIDENTIFIER]})`);E("MAINVERSIONLOOSE",`(${L[j.NUMERICIDENTIFIERLOOSE]})\\.(${L[j.NUMERICIDENTIFIERLOOSE]})\\.(${L[j.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASEIDENTIFIER",`(?:${L[j.NONNUMERICIDENTIFIER]}|${L[j.NUMERICIDENTIFIER]})`);E("PRERELEASEIDENTIFIERLOOSE",`(?:${L[j.NONNUMERICIDENTIFIER]}|${L[j.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASE",`(?:-(${L[j.PRERELEASEIDENTIFIER]}(?:\\.${L[j.PRERELEASEIDENTIFIER]})*))`);E("PRERELEASELOOSE",`(?:-?(${L[j.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${L[j.PRERELEASEIDENTIFIERLOOSE]})*))`);E("BUILDIDENTIFIER",`${m0}+`);E("BUILD",`(?:\\+(${L[j.BUILDIDENTIFIER]}(?:\\.${L[j.BUILDIDENTIFIER]})*))`);E("FULLPLAIN",`v?${L[j.MAINVERSION]}${L[j.PRERELEASE]}?${L[j.BUILD]}?`);E("FULL",`^${L[j.FULLPLAIN]}$`);E("LOOSEPLAIN",`[v=\\s]*${L[j.MAINVERSIONLOOSE]}${L[j.PRERELEASELOOSE]}?${L[j.BUILD]}?`);E("LOOSE",`^${L[j.LOOSEPLAIN]}$`);E("GTLT","((?:<|>)?=?)");E("XRANGEIDENTIFIERLOOSE",`${L[j.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);E("XRANGEIDENTIFIER",`${L[j.NUMERICIDENTIFIER]}|x|X|\\*`);E("XRANGEPLAIN",`[v=\\s]*(${L[j.XRANGEIDENTIFIER]})(?:\\.(${L[j.XRANGEIDENTIFIER]})(?:\\.(${L[j.XRANGEIDENTIFIER]})(?:${L[j.PRERELEASE]})?${L[j.BUILD]}?)?)?`);E("XRANGEPLAINLOOSE",`[v=\\s]*(${L[j.XRANGEIDENTIFIERLOOSE]})(?:\\.(${L[j.XRANGEIDENTIFIERLOOSE]})(?:\\.(${L[j.XRANGEIDENTIFIERLOOSE]})(?:${L[j.PRERELEASELOOSE]})?${L[j.BUILD]}?)?)?`);E("XRANGE",`^${L[j.GTLT]}\\s*${L[j.XRANGEPLAIN]}$`);E("XRANGELOOSE",`^${L[j.GTLT]}\\s*${L[j.XRANGEPLAINLOOSE]}$`);E("COERCEPLAIN",`(^|[^\\d])(\\d{1,${y0}})(?:\\.(\\d{1,${y0}}))?(?:\\.(\\d{1,${y0}}))?`);E("COERCE",`${L[j.COERCEPLAIN]}(?:$|[^\\d])`);E("COERCEFULL",L[j.COERCEPLAIN]+`(?:${L[j.PRERELEASE]})?(?:${L[j.BUILD]})?(?:$|[^\\d])`);E("COERCERTL",L[j.COERCE],!0);E("COERCERTLFULL",L[j.COERCEFULL],!0);E("LONETILDE","(?:~>?)");E("TILDETRIM",`(\\s*)${L[j.LONETILDE]}\\s+`,!0);J$.tildeTrimReplace="$1~";E("TILDE",`^${L[j.LONETILDE]}${L[j.XRANGEPLAIN]}$`);E("TILDELOOSE",`^${L[j.LONETILDE]}${L[j.XRANGEPLAINLOOSE]}$`);E("LONECARET","(?:\\^)");E("CARETTRIM",`(\\s*)${L[j.LONECARET]}\\s+`,!0);J$.caretTrimReplace="$1^";E("CARET",`^${L[j.LONECARET]}${L[j.XRANGEPLAIN]}$`);E("CARETLOOSE",`^${L[j.LONECARET]}${L[j.XRANGEPLAINLOOSE]}$`);E("COMPARATORLOOSE",`^${L[j.GTLT]}\\s*(${L[j.LOOSEPLAIN]})$|^$`);E("COMPARATOR",`^${L[j.GTLT]}\\s*(${L[j.FULLPLAIN]})$|^$`);E("COMPARATORTRIM",`(\\s*)${L[j.GTLT]}\\s*(${L[j.LOOSEPLAIN]}|${L[j.XRANGEPLAIN]})`,!0);J$.comparatorTrimReplace="$1$2$3";E("HYPHENRANGE",`^\\s*(${L[j.XRANGEPLAIN]})\\s+-\\s+(${L[j.XRANGEPLAIN]})\\s*$`);E("HYPHENRANGELOOSE",`^\\s*(${L[j.XRANGEPLAINLOOSE]})\\s+-\\s+(${L[j.XRANGEPLAINLOOSE]})\\s*$`);E("STAR","(<|>)?=?\\s*\\*");E("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");E("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var i6=z((tH,m1)=>{var BJ=Object.freeze({loose:!0}),wJ=Object.freeze({}),VJ=($)=>{if(!$)return wJ;if(typeof $!=="object")return BJ;return $};m1.exports=VJ});var l0=z((eH,c1)=>{var l1=/^[0-9]+$/,u1=($,q)=>{if(typeof $==="number"&&typeof q==="number")return $===q?0:$<q?-1:1;let Q=l1.test($),J=l1.test(q);if(Q&&J)$=+$,q=+q;return $===q?0:Q&&!J?-1:J&&!Q?1:$<q?-1:1},FJ=($,q)=>u1(q,$);c1.exports={compareIdentifiers:u1,rcompareIdentifiers:FJ}});var h=z(($Y,p1)=>{var r6=G6(),{MAX_LENGTH:d1,MAX_SAFE_INTEGER:o6}=Y6(),{safeRe:a6,t:s6}=v$(),UJ=i6(),{compareIdentifiers:u0}=l0();class o{constructor($,q){if(q=UJ(q),$ instanceof o)if($.loose===!!q.loose&&$.includePrerelease===!!q.includePrerelease)return $;else $=$.version;else if(typeof $!=="string")throw TypeError(`Invalid version. Must be a string. Got type "${typeof $}".`);if($.length>d1)throw TypeError(`version is longer than ${d1} characters`);r6("SemVer",$,q),this.options=q,this.loose=!!q.loose,this.includePrerelease=!!q.includePrerelease;let Q=$.trim().match(q.loose?a6[s6.LOOSE]:a6[s6.FULL]);if(!Q)throw TypeError(`Invalid Version: ${$}`);if(this.raw=$,this.major=+Q[1],this.minor=+Q[2],this.patch=+Q[3],this.major>o6||this.major<0)throw TypeError("Invalid major version");if(this.minor>o6||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>o6||this.patch<0)throw TypeError("Invalid patch version");if(!Q[4])this.prerelease=[];else this.prerelease=Q[4].split(".").map((J)=>{if(/^[0-9]+$/.test(J)){let W=+J;if(W>=0&&W<o6)return W}return J});this.build=Q[5]?Q[5].split("."):[],this.format()}format(){if(this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length)this.version+=`-${this.prerelease.join(".")}`;return this.version}toString(){return this.version}compare($){if(r6("SemVer.compare",this.version,this.options,$),!($ instanceof o)){if(typeof $==="string"&&$===this.version)return 0;$=new o($,this.options)}if($.version===this.version)return 0;return this.compareMain($)||this.comparePre($)}compareMain($){if(!($ instanceof o))$=new o($,this.options);if(this.major<$.major)return-1;if(this.major>$.major)return 1;if(this.minor<$.minor)return-1;if(this.minor>$.minor)return 1;if(this.patch<$.patch)return-1;if(this.patch>$.patch)return 1;return 0}comparePre($){if(!($ instanceof o))$=new o($,this.options);if(this.prerelease.length&&!$.prerelease.length)return-1;else if(!this.prerelease.length&&$.prerelease.length)return 1;else if(!this.prerelease.length&&!$.prerelease.length)return 0;let q=0;do{let Q=this.prerelease[q],J=$.prerelease[q];if(r6("prerelease compare",q,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return u0(Q,J)}while(++q)}compareBuild($){if(!($ instanceof o))$=new o($,this.options);let q=0;do{let Q=this.build[q],J=$.build[q];if(r6("build compare",q,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return u0(Q,J)}while(++q)}inc($,q,Q){if($.startsWith("pre")){if(!q&&Q===!1)throw Error("invalid increment argument: identifier is empty");if(q){let J=`-${q}`.match(this.options.loose?a6[s6.PRERELEASELOOSE]:a6[s6.PRERELEASE]);if(!J||J[1]!==q)throw Error(`invalid identifier: ${q}`)}}switch($){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",q,Q);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",q,Q);break;case"prepatch":this.prerelease.length=0,this.inc("patch",q,Q),this.inc("pre",q,Q);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",q,Q);this.inc("pre",q,Q);break;case"release":if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0)this.major++;this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0)this.minor++;this.patch=0,this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":{let J=Number(Q)?1:0;if(this.prerelease.length===0)this.prerelease=[J];else{let W=this.prerelease.length;while(--W>=0)if(typeof this.prerelease[W]==="number")this.prerelease[W]++,W=-2;if(W===-1){if(q===this.prerelease.join(".")&&Q===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(J)}}if(q){let W=[q,J];if(Q===!1)W=[q];if(u0(this.prerelease[0],q)===0){if(isNaN(this.prerelease[1]))this.prerelease=W}else this.prerelease=W}break}default:throw Error(`invalid increment argument: ${$}`)}if(this.raw=this.format(),this.build.length)this.raw+=`+${this.build.join(".")}`;return this}}p1.exports=o});var S$=z((qY,i1)=>{var n1=h(),_J=($,q,Q=!1)=>{if($ instanceof n1)return $;try{return new n1($,q)}catch(J){if(!Q)return null;throw J}};i1.exports=_J});var o1=z((QY,r1)=>{var DJ=S$(),zJ=($,q)=>{let Q=DJ($,q);return Q?Q.version:null};r1.exports=zJ});var s1=z((JY,a1)=>{var LJ=S$(),jJ=($,q)=>{let Q=LJ($.trim().replace(/^[=v]+/,""),q);return Q?Q.version:null};a1.exports=jJ});var $4=z((WY,e1)=>{var t1=h(),OJ=($,q,Q,J,W)=>{if(typeof Q==="string")W=J,J=Q,Q=void 0;try{return new t1($ instanceof t1?$.version:$,Q).inc(q,J,W).version}catch(X){return null}};e1.exports=OJ});var J4=z((XY,Q4)=>{var q4=S$(),NJ=($,q)=>{let Q=q4($,null,!0),J=q4(q,null,!0),W=Q.compare(J);if(W===0)return null;let X=W>0,H=X?Q:J,Y=X?J:Q,G=!!H.prerelease.length;if(!!Y.prerelease.length&&!G){if(!Y.patch&&!Y.minor)return"major";if(Y.compareMain(H)===0){if(Y.minor&&!Y.patch)return"minor";return"patch"}}let V=G?"pre":"";if(Q.major!==J.major)return V+"major";if(Q.minor!==J.minor)return V+"minor";if(Q.patch!==J.patch)return V+"patch";return"prerelease"};Q4.exports=NJ});var X4=z((HY,W4)=>{var RJ=h(),SJ=($,q)=>new RJ($,q).major;W4.exports=SJ});var Y4=z((YY,H4)=>{var MJ=h(),EJ=($,q)=>new MJ($,q).minor;H4.exports=EJ});var B4=z((GY,G4)=>{var AJ=h(),CJ=($,q)=>new AJ($,q).patch;G4.exports=CJ});var V4=z((BY,w4)=>{var KJ=S$(),IJ=($,q)=>{let Q=KJ($,q);return Q&&Q.prerelease.length?Q.prerelease:null};w4.exports=IJ});var n=z((wY,U4)=>{var F4=h(),PJ=($,q,Q)=>new F4($,Q).compare(new F4(q,Q));U4.exports=PJ});var D4=z((VY,_4)=>{var kJ=n(),bJ=($,q,Q)=>kJ(q,$,Q);_4.exports=bJ});var L4=z((FY,z4)=>{var ZJ=n(),fJ=($,q)=>ZJ($,q,!0);z4.exports=fJ});var t6=z((UY,O4)=>{var j4=h(),TJ=($,q,Q)=>{let J=new j4($,Q),W=new j4(q,Q);return J.compare(W)||J.compareBuild(W)};O4.exports=TJ});var R4=z((_Y,N4)=>{var xJ=t6(),vJ=($,q)=>$.sort((Q,J)=>xJ(Q,J,q));N4.exports=vJ});var M4=z((DY,S4)=>{var hJ=t6(),gJ=($,q)=>$.sort((Q,J)=>hJ(J,Q,q));S4.exports=gJ});var B6=z((zY,E4)=>{var yJ=n(),mJ=($,q,Q)=>yJ($,q,Q)>0;E4.exports=mJ});var e6=z((LY,A4)=>{var lJ=n(),uJ=($,q,Q)=>lJ($,q,Q)<0;A4.exports=uJ});var c0=z((jY,C4)=>{var cJ=n(),dJ=($,q,Q)=>cJ($,q,Q)===0;C4.exports=dJ});var d0=z((OY,K4)=>{var pJ=n(),nJ=($,q,Q)=>pJ($,q,Q)!==0;K4.exports=nJ});var $0=z((NY,I4)=>{var iJ=n(),rJ=($,q,Q)=>iJ($,q,Q)>=0;I4.exports=rJ});var q0=z((RY,P4)=>{var oJ=n(),aJ=($,q,Q)=>oJ($,q,Q)<=0;P4.exports=aJ});var p0=z((SY,k4)=>{var sJ=c0(),tJ=d0(),eJ=B6(),$5=$0(),q5=e6(),Q5=q0(),J5=($,q,Q,J)=>{switch(q){case"===":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $===Q;case"!==":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $!==Q;case"":case"=":case"==":return sJ($,Q,J);case"!=":return tJ($,Q,J);case">":return eJ($,Q,J);case">=":return $5($,Q,J);case"<":return q5($,Q,J);case"<=":return Q5($,Q,J);default:throw TypeError(`Invalid operator: ${q}`)}};k4.exports=J5});var Z4=z((MY,b4)=>{var W5=h(),X5=S$(),{safeRe:Q0,t:J0}=v$(),H5=($,q)=>{if($ instanceof W5)return $;if(typeof $==="number")$=String($);if(typeof $!=="string")return null;q=q||{};let Q=null;if(!q.rtl)Q=$.match(q.includePrerelease?Q0[J0.COERCEFULL]:Q0[J0.COERCE]);else{let G=q.includePrerelease?Q0[J0.COERCERTLFULL]:Q0[J0.COERCERTL],w;while((w=G.exec($))&&(!Q||Q.index+Q[0].length!==$.length)){if(!Q||w.index+w[0].length!==Q.index+Q[0].length)Q=w;G.lastIndex=w.index+w[1].length+w[2].length}G.lastIndex=-1}if(Q===null)return null;let J=Q[2],W=Q[3]||"0",X=Q[4]||"0",H=q.includePrerelease&&Q[5]?`-${Q[5]}`:"",Y=q.includePrerelease&&Q[6]?`+${Q[6]}`:"";return X5(`${J}.${W}.${X}${H}${Y}`,q)};b4.exports=H5});var x4=z((EY,T4)=>{class f4{constructor(){this.max=1000,this.map=new Map}get($){let q=this.map.get($);if(q===void 0)return;else return this.map.delete($),this.map.set($,q),q}delete($){return this.map.delete($)}set($,q){if(!this.delete($)&&q!==void 0){if(this.map.size>=this.max){let J=this.map.keys().next().value;this.delete(J)}this.map.set($,q)}return this}}T4.exports=f4});var i=z((AY,y4)=>{var Y5=/\s+/g;class w6{constructor($,q){if(q=B5(q),$ instanceof w6)if($.loose===!!q.loose&&$.includePrerelease===!!q.includePrerelease)return $;else return new w6($.raw,q);if($ instanceof n0)return this.raw=$.value,this.set=[[$]],this.formatted=void 0,this;if(this.options=q,this.loose=!!q.loose,this.includePrerelease=!!q.includePrerelease,this.raw=$.trim().replace(Y5," "),this.set=this.raw.split("||").map((Q)=>this.parseRange(Q.trim())).filter((Q)=>Q.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let Q=this.set[0];if(this.set=this.set.filter((J)=>!h4(J[0])),this.set.length===0)this.set=[Q];else if(this.set.length>1){for(let J of this.set)if(J.length===1&&z5(J[0])){this.set=[J];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let $=0;$<this.set.length;$++){if($>0)this.formatted+="||";let q=this.set[$];for(let Q=0;Q<q.length;Q++){if(Q>0)this.formatted+=" ";this.formatted+=q[Q].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange($){let Q=((this.options.includePrerelease&&_5)|(this.options.loose&&D5))+":"+$,J=v4.get(Q);if(J)return J;let W=this.options.loose,X=W?m[g.HYPHENRANGELOOSE]:m[g.HYPHENRANGE];$=$.replace(X,C5(this.options.includePrerelease)),k("hyphen replace",$),$=$.replace(m[g.COMPARATORTRIM],V5),k("comparator trim",$),$=$.replace(m[g.TILDETRIM],F5),k("tilde trim",$),$=$.replace(m[g.CARETTRIM],U5),k("caret trim",$);let H=$.split(" ").map((V)=>L5(V,this.options)).join(" ").split(/\s+/).map((V)=>A5(V,this.options));if(W)H=H.filter((V)=>{return k("loose invalid filter",V,this.options),!!V.match(m[g.COMPARATORLOOSE])});k("range list",H);let Y=new Map,G=H.map((V)=>new n0(V,this.options));for(let V of G){if(h4(V))return[V];Y.set(V.value,V)}if(Y.size>1&&Y.has(""))Y.delete("");let w=[...Y.values()];return v4.set(Q,w),w}intersects($,q){if(!($ instanceof w6))throw TypeError("a Range is required");return this.set.some((Q)=>{return g4(Q,q)&&$.set.some((J)=>{return g4(J,q)&&Q.every((W)=>{return J.every((X)=>{return W.intersects(X,q)})})})})}test($){if(!$)return!1;if(typeof $==="string")try{$=new w5($,this.options)}catch(q){return!1}for(let q=0;q<this.set.length;q++)if(K5(this.set[q],$,this.options))return!0;return!1}}y4.exports=w6;var G5=x4(),v4=new G5,B5=i6(),n0=V6(),k=G6(),w5=h(),{safeRe:m,t:g,comparatorTrimReplace:V5,tildeTrimReplace:F5,caretTrimReplace:U5}=v$(),{FLAG_INCLUDE_PRERELEASE:_5,FLAG_LOOSE:D5}=Y6(),h4=($)=>$.value==="<0.0.0-0",z5=($)=>$.value==="",g4=($,q)=>{let Q=!0,J=$.slice(),W=J.pop();while(Q&&J.length)Q=J.every((X)=>{return W.intersects(X,q)}),W=J.pop();return Q},L5=($,q)=>{return $=$.replace(m[g.BUILD],""),k("comp",$,q),$=N5($,q),k("caret",$),$=j5($,q),k("tildes",$),$=S5($,q),k("xrange",$),$=E5($,q),k("stars",$),$},l=($)=>!$||$.toLowerCase()==="x"||$==="*",j5=($,q)=>{return $.trim().split(/\s+/).map((Q)=>O5(Q,q)).join(" ")},O5=($,q)=>{let Q=q.loose?m[g.TILDELOOSE]:m[g.TILDE];return $.replace(Q,(J,W,X,H,Y)=>{k("tilde",$,J,W,X,H,Y);let G;if(l(W))G="";else if(l(X))G=`>=${W}.0.0 <${+W+1}.0.0-0`;else if(l(H))G=`>=${W}.${X}.0 <${W}.${+X+1}.0-0`;else if(Y)k("replaceTilde pr",Y),G=`>=${W}.${X}.${H}-${Y} <${W}.${+X+1}.0-0`;else G=`>=${W}.${X}.${H} <${W}.${+X+1}.0-0`;return k("tilde return",G),G})},N5=($,q)=>{return $.trim().split(/\s+/).map((Q)=>R5(Q,q)).join(" ")},R5=($,q)=>{k("caret",$,q);let Q=q.loose?m[g.CARETLOOSE]:m[g.CARET],J=q.includePrerelease?"-0":"";return $.replace(Q,(W,X,H,Y,G)=>{k("caret",$,W,X,H,Y,G);let w;if(l(X))w="";else if(l(H))w=`>=${X}.0.0${J} <${+X+1}.0.0-0`;else if(l(Y))if(X==="0")w=`>=${X}.${H}.0${J} <${X}.${+H+1}.0-0`;else w=`>=${X}.${H}.0${J} <${+X+1}.0.0-0`;else if(G)if(k("replaceCaret pr",G),X==="0")if(H==="0")w=`>=${X}.${H}.${Y}-${G} <${X}.${H}.${+Y+1}-0`;else w=`>=${X}.${H}.${Y}-${G} <${X}.${+H+1}.0-0`;else w=`>=${X}.${H}.${Y}-${G} <${+X+1}.0.0-0`;else if(k("no pr"),X==="0")if(H==="0")w=`>=${X}.${H}.${Y}${J} <${X}.${H}.${+Y+1}-0`;else w=`>=${X}.${H}.${Y}${J} <${X}.${+H+1}.0-0`;else w=`>=${X}.${H}.${Y} <${+X+1}.0.0-0`;return k("caret return",w),w})},S5=($,q)=>{return k("replaceXRanges",$,q),$.split(/\s+/).map((Q)=>M5(Q,q)).join(" ")},M5=($,q)=>{$=$.trim();let Q=q.loose?m[g.XRANGELOOSE]:m[g.XRANGE];return $.replace(Q,(J,W,X,H,Y,G)=>{k("xRange",$,J,W,X,H,Y,G);let w=l(X),V=w||l(H),U=V||l(Y),M=U;if(W==="="&&M)W="";if(G=q.includePrerelease?"-0":"",w)if(W===">"||W==="<")J="<0.0.0-0";else J="*";else if(W&&M){if(V)H=0;if(Y=0,W===">")if(W=">=",V)X=+X+1,H=0,Y=0;else H=+H+1,Y=0;else if(W==="<=")if(W="<",V)X=+X+1;else H=+H+1;if(W==="<")G="-0";J=`${W+X}.${H}.${Y}${G}`}else if(V)J=`>=${X}.0.0${G} <${+X+1}.0.0-0`;else if(U)J=`>=${X}.${H}.0${G} <${X}.${+H+1}.0-0`;return k("xRange return",J),J})},E5=($,q)=>{return k("replaceStars",$,q),$.trim().replace(m[g.STAR],"")},A5=($,q)=>{return k("replaceGTE0",$,q),$.trim().replace(m[q.includePrerelease?g.GTE0PRE:g.GTE0],"")},C5=($)=>(q,Q,J,W,X,H,Y,G,w,V,U,M)=>{if(l(J))Q="";else if(l(W))Q=`>=${J}.0.0${$?"-0":""}`;else if(l(X))Q=`>=${J}.${W}.0${$?"-0":""}`;else if(H)Q=`>=${Q}`;else Q=`>=${Q}${$?"-0":""}`;if(l(w))G="";else if(l(V))G=`<${+w+1}.0.0-0`;else if(l(U))G=`<${w}.${+V+1}.0-0`;else if(M)G=`<=${w}.${V}.${U}-${M}`;else if($)G=`<${w}.${V}.${+U+1}-0`;else G=`<=${G}`;return`${Q} ${G}`.trim()},K5=($,q,Q)=>{for(let J=0;J<$.length;J++)if(!$[J].test(q))return!1;if(q.prerelease.length&&!Q.includePrerelease){for(let J=0;J<$.length;J++){if(k($[J].semver),$[J].semver===n0.ANY)continue;if($[J].semver.prerelease.length>0){let W=$[J].semver;if(W.major===q.major&&W.minor===q.minor&&W.patch===q.patch)return!0}}return!1}return!0}});var V6=z((CY,p4)=>{var F6=Symbol("SemVer ANY");class W0{static get ANY(){return F6}constructor($,q){if(q=m4(q),$ instanceof W0)if($.loose===!!q.loose)return $;else $=$.value;if($=$.trim().split(/\s+/).join(" "),r0("comparator",$,q),this.options=q,this.loose=!!q.loose,this.parse($),this.semver===F6)this.value="";else this.value=this.operator+this.semver.version;r0("comp",this)}parse($){let q=this.options.loose?l4[u4.COMPARATORLOOSE]:l4[u4.COMPARATOR],Q=$.match(q);if(!Q)throw TypeError(`Invalid comparator: ${$}`);if(this.operator=Q[1]!==void 0?Q[1]:"",this.operator==="=")this.operator="";if(!Q[2])this.semver=F6;else this.semver=new c4(Q[2],this.options.loose)}toString(){return this.value}test($){if(r0("Comparator.test",$,this.options.loose),this.semver===F6||$===F6)return!0;if(typeof $==="string")try{$=new c4($,this.options)}catch(q){return!1}return i0($,this.operator,this.semver,this.options)}intersects($,q){if(!($ instanceof W0))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new d4($.value,q).test(this.value)}else if($.operator===""){if($.value==="")return!0;return new d4(this.value,q).test($.semver)}if(q=m4(q),q.includePrerelease&&(this.value==="<0.0.0-0"||$.value==="<0.0.0-0"))return!1;if(!q.includePrerelease&&(this.value.startsWith("<0.0.0")||$.value.startsWith("<0.0.0")))return!1;if(this.operator.startsWith(">")&&$.operator.startsWith(">"))return!0;if(this.operator.startsWith("<")&&$.operator.startsWith("<"))return!0;if(this.semver.version===$.semver.version&&this.operator.includes("=")&&$.operator.includes("="))return!0;if(i0(this.semver,"<",$.semver,q)&&this.operator.startsWith(">")&&$.operator.startsWith("<"))return!0;if(i0(this.semver,">",$.semver,q)&&this.operator.startsWith("<")&&$.operator.startsWith(">"))return!0;return!1}}p4.exports=W0;var m4=i6(),{safeRe:l4,t:u4}=v$(),i0=p0(),r0=G6(),c4=h(),d4=i()});var U6=z((KY,n4)=>{var I5=i(),P5=($,q,Q)=>{try{q=new I5(q,Q)}catch(J){return!1}return q.test($)};n4.exports=P5});var r4=z((IY,i4)=>{var k5=i(),b5=($,q)=>new k5($,q).set.map((Q)=>Q.map((J)=>J.value).join(" ").trim().split(" "));i4.exports=b5});var a4=z((PY,o4)=>{var Z5=h(),f5=i(),T5=($,q,Q)=>{let J=null,W=null,X=null;try{X=new f5(q,Q)}catch(H){return null}return $.forEach((H)=>{if(X.test(H)){if(!J||W.compare(H)===-1)J=H,W=new Z5(J,Q)}}),J};o4.exports=T5});var t4=z((kY,s4)=>{var x5=h(),v5=i(),h5=($,q,Q)=>{let J=null,W=null,X=null;try{X=new v5(q,Q)}catch(H){return null}return $.forEach((H)=>{if(X.test(H)){if(!J||W.compare(H)===1)J=H,W=new x5(J,Q)}}),J};s4.exports=h5});var q9=z((bY,$9)=>{var o0=h(),g5=i(),e4=B6(),y5=($,q)=>{$=new g5($,q);let Q=new o0("0.0.0");if($.test(Q))return Q;if(Q=new o0("0.0.0-0"),$.test(Q))return Q;Q=null;for(let J=0;J<$.set.length;++J){let W=$.set[J],X=null;if(W.forEach((H)=>{let Y=new o0(H.semver.version);switch(H.operator){case">":if(Y.prerelease.length===0)Y.patch++;else Y.prerelease.push(0);Y.raw=Y.format();case"":case">=":if(!X||e4(Y,X))X=Y;break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${H.operator}`)}}),X&&(!Q||e4(Q,X)))Q=X}if(Q&&$.test(Q))return Q;return null};$9.exports=y5});var J9=z((ZY,Q9)=>{var m5=i(),l5=($,q)=>{try{return new m5($,q).range||"*"}catch(Q){return null}};Q9.exports=l5});var X0=z((fY,Y9)=>{var u5=h(),H9=V6(),{ANY:c5}=H9,d5=i(),p5=U6(),W9=B6(),X9=e6(),n5=q0(),i5=$0(),r5=($,q,Q,J)=>{$=new u5($,J),q=new d5(q,J);let W,X,H,Y,G;switch(Q){case">":W=W9,X=n5,H=X9,Y=">",G=">=";break;case"<":W=X9,X=i5,H=W9,Y="<",G="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(p5($,q,J))return!1;for(let w=0;w<q.set.length;++w){let V=q.set[w],U=null,M=null;if(V.forEach((O)=>{if(O.semver===c5)O=new H9(">=0.0.0");if(U=U||O,M=M||O,W(O.semver,U.semver,J))U=O;else if(H(O.semver,M.semver,J))M=O}),U.operator===Y||U.operator===G)return!1;if((!M.operator||M.operator===Y)&&X($,M.semver))return!1;else if(M.operator===G&&H($,M.semver))return!1}return!0};Y9.exports=r5});var B9=z((TY,G9)=>{var o5=X0(),a5=($,q,Q)=>o5($,q,">",Q);G9.exports=a5});var V9=z((xY,w9)=>{var s5=X0(),t5=($,q,Q)=>s5($,q,"<",Q);w9.exports=t5});var _9=z((vY,U9)=>{var F9=i(),e5=($,q,Q)=>{return $=new F9($,Q),q=new F9(q,Q),$.intersects(q,Q)};U9.exports=e5});var z9=z((hY,D9)=>{var $2=U6(),q2=n();D9.exports=($,q,Q)=>{let J=[],W=null,X=null,H=$.sort((V,U)=>q2(V,U,Q));for(let V of H)if($2(V,q,Q)){if(X=V,!W)W=V}else{if(X)J.push([W,X]);X=null,W=null}if(W)J.push([W,null]);let Y=[];for(let[V,U]of J)if(V===U)Y.push(V);else if(!U&&V===H[0])Y.push("*");else if(!U)Y.push(`>=${V}`);else if(V===H[0])Y.push(`<=${U}`);else Y.push(`${V} - ${U}`);let G=Y.join(" || "),w=typeof q.raw==="string"?q.raw:String(q);return G.length<w.length?G:q}});var S9=z((gY,R9)=>{var L9=i(),s0=V6(),{ANY:a0}=s0,_6=U6(),t0=n(),Q2=($,q,Q={})=>{if($===q)return!0;$=new L9($,Q),q=new L9(q,Q);let J=!1;$:for(let W of $.set){for(let X of q.set){let H=W2(W,X,Q);if(J=J||H!==null,H)continue $}if(J)return!1}return!0},J2=[new s0(">=0.0.0-0")],j9=[new s0(">=0.0.0")],W2=($,q,Q)=>{if($===q)return!0;if($.length===1&&$[0].semver===a0)if(q.length===1&&q[0].semver===a0)return!0;else if(Q.includePrerelease)$=J2;else $=j9;if(q.length===1&&q[0].semver===a0)if(Q.includePrerelease)return!0;else q=j9;let J=new Set,W,X;for(let O of $)if(O.operator===">"||O.operator===">=")W=O9(W,O,Q);else if(O.operator==="<"||O.operator==="<=")X=N9(X,O,Q);else J.add(O.semver);if(J.size>1)return null;let H;if(W&&X){if(H=t0(W.semver,X.semver,Q),H>0)return null;else if(H===0&&(W.operator!==">="||X.operator!=="<="))return null}for(let O of J){if(W&&!_6(O,String(W),Q))return null;if(X&&!_6(O,String(X),Q))return null;for(let P of q)if(!_6(O,String(P),Q))return!1;return!0}let Y,G,w,V,U=X&&!Q.includePrerelease&&X.semver.prerelease.length?X.semver:!1,M=W&&!Q.includePrerelease&&W.semver.prerelease.length?W.semver:!1;if(U&&U.prerelease.length===1&&X.operator==="<"&&U.prerelease[0]===0)U=!1;for(let O of q){if(V=V||O.operator===">"||O.operator===">=",w=w||O.operator==="<"||O.operator==="<=",W){if(M){if(O.semver.prerelease&&O.semver.prerelease.length&&O.semver.major===M.major&&O.semver.minor===M.minor&&O.semver.patch===M.patch)M=!1}if(O.operator===">"||O.operator===">="){if(Y=O9(W,O,Q),Y===O&&Y!==W)return!1}else if(W.operator===">="&&!_6(W.semver,String(O),Q))return!1}if(X){if(U){if(O.semver.prerelease&&O.semver.prerelease.length&&O.semver.major===U.major&&O.semver.minor===U.minor&&O.semver.patch===U.patch)U=!1}if(O.operator==="<"||O.operator==="<="){if(G=N9(X,O,Q),G===O&&G!==X)return!1}else if(X.operator==="<="&&!_6(X.semver,String(O),Q))return!1}if(!O.operator&&(X||W)&&H!==0)return!1}if(W&&w&&!X&&H!==0)return!1;if(X&&V&&!W&&H!==0)return!1;if(M||U)return!1;return!0},O9=($,q,Q)=>{if(!$)return q;let J=t0($.semver,q.semver,Q);return J>0?$:J<0?q:q.operator===">"&&$.operator===">="?q:$},N9=($,q,Q)=>{if(!$)return q;let J=t0($.semver,q.semver,Q);return J<0?$:J>0?q:q.operator==="<"&&$.operator==="<="?q:$};R9.exports=Q2});var H0=z((yY,A9)=>{var e0=v$(),M9=Y6(),X2=h(),E9=l0(),H2=S$(),Y2=o1(),G2=s1(),B2=$4(),w2=J4(),V2=X4(),F2=Y4(),U2=B4(),_2=V4(),D2=n(),z2=D4(),L2=L4(),j2=t6(),O2=R4(),N2=M4(),R2=B6(),S2=e6(),M2=c0(),E2=d0(),A2=$0(),C2=q0(),K2=p0(),I2=Z4(),P2=V6(),k2=i(),b2=U6(),Z2=r4(),f2=a4(),T2=t4(),x2=q9(),v2=J9(),h2=X0(),g2=B9(),y2=V9(),m2=_9(),l2=z9(),u2=S9();A9.exports={parse:H2,valid:Y2,clean:G2,inc:B2,diff:w2,major:V2,minor:F2,patch:U2,prerelease:_2,compare:D2,rcompare:z2,compareLoose:L2,compareBuild:j2,sort:O2,rsort:N2,gt:R2,lt:S2,eq:M2,neq:E2,gte:A2,lte:C2,cmp:K2,coerce:I2,Comparator:P2,Range:k2,satisfies:b2,toComparators:Z2,maxSatisfying:f2,minSatisfying:T2,minVersion:x2,validRange:v2,outside:h2,gtr:g2,ltr:y2,intersects:m2,simplifyRange:l2,subset:u2,SemVer:X2,re:e0.re,src:e0.src,tokens:e0.t,SEMVER_SPEC_VERSION:M9.SEMVER_SPEC_VERSION,RELEASE_TYPES:M9.RELEASE_TYPES,compareIdentifiers:E9.compareIdentifiers,rcompareIdentifiers:E9.rcompareIdentifiers}});var K9=z((mY,C9)=>{var c2=H0();C9.exports=c2.satisfies(process.version,">=15.7.0")});var P9=z((lY,I9)=>{var d2=H0();I9.exports=d2.satisfies(process.version,">=16.9.0")});var $8=z((uY,k9)=>{var p2=K9(),n2=P9(),i2={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},r2={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};k9.exports=function($,q){if(!$||!q)return;let Q=q.asymmetricKeyType;if(!Q)return;let J=i2[Q];if(!J)throw Error(`Unknown key type "${Q}".`);if(!J.includes($))throw Error(`"alg" parameter for "${Q}" key type must be one of: ${J.join(", ")}.`);if(p2)switch(Q){case"ec":let W=q.asymmetricKeyDetails.namedCurve,X=r2[$];if(W!==X)throw Error(`"alg" parameter "${$}" requires curve "${X}".`);break;case"rsa-pss":if(n2){let H=parseInt($.slice(-3),10),{hashAlgorithm:Y,mgf1HashAlgorithm:G,saltLength:w}=q.asymmetricKeyDetails;if(Y!==`sha${H}`||G!==Y)throw Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${$}.`);if(w!==void 0&&w>H>>3)throw Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${$}.`)}break}}});var q8=z((cY,b9)=>{var o2=H0();b9.exports=o2.satisfies(process.version,"^6.12.0 || >=8.0.0")});var T9=z((dY,f9)=>{var I=H6(),a2=v0(),Z9=h0(),s2=x0(),t2=g0(),e2=$8(),$W=q8(),qW=u6(),{KeyObject:QW,createSecretKey:JW,createPublicKey:WW}=require("crypto"),Q8=["RS256","RS384","RS512"],XW=["ES256","ES384","ES512"],J8=["RS256","RS384","RS512"],HW=["HS256","HS384","HS512"];if($W)Q8.splice(Q8.length,0,"PS256","PS384","PS512"),J8.splice(J8.length,0,"PS256","PS384","PS512");f9.exports=function($,q,Q,J){if(typeof Q==="function"&&!J)J=Q,Q={};if(!Q)Q={};Q=Object.assign({},Q);let W;if(J)W=J;else W=function(V,U){if(V)throw V;return U};if(Q.clockTimestamp&&typeof Q.clockTimestamp!=="number")return W(new I("clockTimestamp must be a number"));if(Q.nonce!==void 0&&(typeof Q.nonce!=="string"||Q.nonce.trim()===""))return W(new I("nonce must be a non-empty string"));if(Q.allowInvalidAsymmetricKeyTypes!==void 0&&typeof Q.allowInvalidAsymmetricKeyTypes!=="boolean")return W(new I("allowInvalidAsymmetricKeyTypes must be a boolean"));let X=Q.clockTimestamp||Math.floor(Date.now()/1000);if(!$)return W(new I("jwt must be provided"));if(typeof $!=="string")return W(new I("jwt must be a string"));let H=$.split(".");if(H.length!==3)return W(new I("jwt malformed"));let Y;try{Y=s2($,{complete:!0})}catch(V){return W(V)}if(!Y)return W(new I("invalid token"));let G=Y.header,w;if(typeof q==="function"){if(!J)return W(new I("verify must be called asynchronous if secret or public key is provided as a callback"));w=q}else w=function(V,U){return U(null,q)};return w(G,function(V,U){if(V)return W(new I("error in secret or public key callback: "+V.message));let M=H[2].trim()!=="";if(!M&&U)return W(new I("jwt signature is required"));if(M&&!U)return W(new I("secret or public key must be provided"));if(!M&&!Q.algorithms)return W(new I('please specify "none" in "algorithms" to verify unsigned tokens'));if(U!=null&&!(U instanceof QW))try{U=WW(U)}catch(u){try{U=JW(typeof U==="string"?Buffer.from(U):U)}catch(aq){return W(new I("secretOrPublicKey is not valid key material"))}}if(!Q.algorithms)if(U.type==="secret")Q.algorithms=HW;else if(["rsa","rsa-pss"].includes(U.asymmetricKeyType))Q.algorithms=J8;else if(U.asymmetricKeyType==="ec")Q.algorithms=XW;else Q.algorithms=Q8;if(Q.algorithms.indexOf(Y.header.alg)===-1)return W(new I("invalid algorithm"));if(G.alg.startsWith("HS")&&U.type!=="secret")return W(new I(`secretOrPublicKey must be a symmetric key when using ${G.alg}`));else if(/^(?:RS|PS|ES)/.test(G.alg)&&U.type!=="public")return W(new I(`secretOrPublicKey must be an asymmetric key when using ${G.alg}`));if(!Q.allowInvalidAsymmetricKeyTypes)try{e2(G.alg,U)}catch(u){return W(u)}let O;try{O=qW.verify($,Y.header.alg,U)}catch(u){return W(u)}if(!O)return W(new I("invalid signature"));let P=Y.payload;if(typeof P.nbf<"u"&&!Q.ignoreNotBefore){if(typeof P.nbf!=="number")return W(new I("invalid nbf value"));if(P.nbf>X+(Q.clockTolerance||0))return W(new a2("jwt not active",new Date(P.nbf*1000)))}if(typeof P.exp<"u"&&!Q.ignoreExpiration){if(typeof P.exp!=="number")return W(new I("invalid exp value"));if(X>=P.exp+(Q.clockTolerance||0))return W(new Z9("jwt expired",new Date(P.exp*1000)))}if(Q.audience){let u=Array.isArray(Q.audience)?Q.audience:[Q.audience];if(!(Array.isArray(P.aud)?P.aud:[P.aud]).some(function(v8){return u.some(function(S0){return S0 instanceof RegExp?S0.test(v8):S0===v8})}))return W(new I("jwt audience invalid. expected: "+u.join(" or ")))}if(Q.issuer){if(typeof Q.issuer==="string"&&P.iss!==Q.issuer||Array.isArray(Q.issuer)&&Q.issuer.indexOf(P.iss)===-1)return W(new I("jwt issuer invalid. expected: "+Q.issuer))}if(Q.subject){if(P.sub!==Q.subject)return W(new I("jwt subject invalid. expected: "+Q.subject))}if(Q.jwtid){if(P.jti!==Q.jwtid)return W(new I("jwt jwtid invalid. expected: "+Q.jwtid))}if(Q.nonce){if(P.nonce!==Q.nonce)return W(new I("jwt nonce invalid. expected: "+Q.nonce))}if(Q.maxAge){if(typeof P.iat!=="number")return W(new I("iat required when maxAge is specified"));let u=t2(Q.maxAge,P.iat);if(typeof u>"u")return W(new I('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(X>=u+(Q.clockTolerance||0))return W(new Z9("maxAge exceeded",new Date(u*1000)))}if(Q.complete===!0){let u=Y.signature;return W(null,{header:G,payload:P,signature:u})}return W(null,P)})}});var m9=z((pY,y9)=>{var x9=1/0,h9=9007199254740991,YW=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,v9=NaN,GW="[object Arguments]",BW="[object Function]",wW="[object GeneratorFunction]",VW="[object String]",FW="[object Symbol]",UW=/^\s+|\s+$/g,_W=/^[-+]0x[0-9a-f]+$/i,DW=/^0b[01]+$/i,zW=/^0o[0-7]+$/i,LW=/^(?:0|[1-9]\d*)$/,jW=parseInt;function OW($,q){var Q=-1,J=$?$.length:0,W=Array(J);while(++Q<J)W[Q]=q($[Q],Q,$);return W}function NW($,q,Q,J){var W=$.length,X=Q+(J?1:-1);while(J?X--:++X<W)if(q($[X],X,$))return X;return-1}function RW($,q,Q){if(q!==q)return NW($,SW,Q);var J=Q-1,W=$.length;while(++J<W)if($[J]===q)return J;return-1}function SW($){return $!==$}function MW($,q){var Q=-1,J=Array($);while(++Q<$)J[Q]=q(Q);return J}function EW($,q){return OW(q,function(Q){return $[Q]})}function AW($,q){return function(Q){return $(q(Q))}}var Y0=Object.prototype,X8=Y0.hasOwnProperty,G0=Y0.toString,CW=Y0.propertyIsEnumerable,KW=AW(Object.keys,Object),IW=Math.max;function PW($,q){var Q=g9($)||TW($)?MW($.length,String):[],J=Q.length,W=!!J;for(var X in $)if((q||X8.call($,X))&&!(W&&(X=="length"||bW(X,J))))Q.push(X);return Q}function kW($){if(!ZW($))return KW($);var q=[];for(var Q in Object($))if(X8.call($,Q)&&Q!="constructor")q.push(Q);return q}function bW($,q){return q=q==null?h9:q,!!q&&(typeof $=="number"||LW.test($))&&($>-1&&$%1==0&&$<q)}function ZW($){var q=$&&$.constructor,Q=typeof q=="function"&&q.prototype||Y0;return $===Q}function fW($,q,Q,J){$=H8($)?$:dW($),Q=Q&&!J?lW(Q):0;var W=$.length;if(Q<0)Q=IW(W+Q,0);return gW($)?Q<=W&&$.indexOf(q,Q)>-1:!!W&&RW($,q,Q)>-1}function TW($){return xW($)&&X8.call($,"callee")&&(!CW.call($,"callee")||G0.call($)==GW)}var g9=Array.isArray;function H8($){return $!=null&&hW($.length)&&!vW($)}function xW($){return Y8($)&&H8($)}function vW($){var q=W8($)?G0.call($):"";return q==BW||q==wW}function hW($){return typeof $=="number"&&$>-1&&$%1==0&&$<=h9}function W8($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function Y8($){return!!$&&typeof $=="object"}function gW($){return typeof $=="string"||!g9($)&&Y8($)&&G0.call($)==VW}function yW($){return typeof $=="symbol"||Y8($)&&G0.call($)==FW}function mW($){if(!$)return $===0?$:0;if($=uW($),$===x9||$===-x9){var q=$<0?-1:1;return q*YW}return $===$?$:0}function lW($){var q=mW($),Q=q%1;return q===q?Q?q-Q:q:0}function uW($){if(typeof $=="number")return $;if(yW($))return v9;if(W8($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=W8(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(UW,"");var Q=DW.test($);return Q||zW.test($)?jW($.slice(2),Q?2:8):_W.test($)?v9:+$}function cW($){return H8($)?PW($):kW($)}function dW($){return $?EW($,cW($)):[]}y9.exports=fW});var u9=z((nY,l9)=>{var pW="[object Boolean]",nW=Object.prototype,iW=nW.toString;function rW($){return $===!0||$===!1||oW($)&&iW.call($)==pW}function oW($){return!!$&&typeof $=="object"}l9.exports=rW});var i9=z((iY,n9)=>{var c9=1/0,aW=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,d9=NaN,sW="[object Symbol]",tW=/^\s+|\s+$/g,eW=/^[-+]0x[0-9a-f]+$/i,$7=/^0b[01]+$/i,q7=/^0o[0-7]+$/i,Q7=parseInt,J7=Object.prototype,W7=J7.toString;function X7($){return typeof $=="number"&&$==B7($)}function p9($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function H7($){return!!$&&typeof $=="object"}function Y7($){return typeof $=="symbol"||H7($)&&W7.call($)==sW}function G7($){if(!$)return $===0?$:0;if($=w7($),$===c9||$===-c9){var q=$<0?-1:1;return q*aW}return $===$?$:0}function B7($){var q=G7($),Q=q%1;return q===q?Q?q-Q:q:0}function w7($){if(typeof $=="number")return $;if(Y7($))return d9;if(p9($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=p9(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(tW,"");var Q=$7.test($);return Q||q7.test($)?Q7($.slice(2),Q?2:8):eW.test($)?d9:+$}n9.exports=X7});var o9=z((rY,r9)=>{var V7="[object Number]",F7=Object.prototype,U7=F7.toString;function _7($){return!!$&&typeof $=="object"}function D7($){return typeof $=="number"||_7($)&&U7.call($)==V7}r9.exports=D7});var e9=z((oY,t9)=>{var z7="[object Object]";function L7($){var q=!1;if($!=null&&typeof $.toString!="function")try{q=!!($+"")}catch(Q){}return q}function j7($,q){return function(Q){return $(q(Q))}}var O7=Function.prototype,a9=Object.prototype,s9=O7.toString,N7=a9.hasOwnProperty,R7=s9.call(Object),S7=a9.toString,M7=j7(Object.getPrototypeOf,Object);function E7($){return!!$&&typeof $=="object"}function A7($){if(!E7($)||S7.call($)!=z7||L7($))return!1;var q=M7($);if(q===null)return!0;var Q=N7.call(q,"constructor")&&q.constructor;return typeof Q=="function"&&Q instanceof Q&&s9.call(Q)==R7}t9.exports=A7});var qq=z((aY,$q)=>{var C7="[object String]",K7=Object.prototype,I7=K7.toString,P7=Array.isArray;function k7($){return!!$&&typeof $=="object"}function b7($){return typeof $=="string"||!P7($)&&k7($)&&I7.call($)==C7}$q.exports=b7});var Hq=z((sY,Xq)=>{var Z7="Expected a function",Qq=1/0,f7=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,Jq=NaN,T7="[object Symbol]",x7=/^\s+|\s+$/g,v7=/^[-+]0x[0-9a-f]+$/i,h7=/^0b[01]+$/i,g7=/^0o[0-7]+$/i,y7=parseInt,m7=Object.prototype,l7=m7.toString;function u7($,q){var Q;if(typeof q!="function")throw TypeError(Z7);return $=i7($),function(){if(--$>0)Q=q.apply(this,arguments);if($<=1)q=void 0;return Q}}function c7($){return u7(2,$)}function Wq($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function d7($){return!!$&&typeof $=="object"}function p7($){return typeof $=="symbol"||d7($)&&l7.call($)==T7}function n7($){if(!$)return $===0?$:0;if($=r7($),$===Qq||$===-Qq){var q=$<0?-1:1;return q*f7}return $===$?$:0}function i7($){var q=n7($),Q=q%1;return q===q?Q?q-Q:q:0}function r7($){if(typeof $=="number")return $;if(p7($))return Jq;if(Wq($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=Wq(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(x7,"");var Q=h7.test($);return Q||g7.test($)?y7($.slice(2),Q?2:8):v7.test($)?Jq:+$}Xq.exports=c7});var Dq=z((tY,_q)=>{var Yq=g0(),o7=q8(),a7=$8(),Gq=u6(),s7=m9(),B0=u9(),Bq=i9(),G8=o9(),Vq=e9(),F$=qq(),t7=Hq(),{KeyObject:e7,createSecretKey:$3,createPrivateKey:q3}=require("crypto"),Fq=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];if(o7)Fq.splice(3,0,"PS256","PS384","PS512");var Q3={expiresIn:{isValid:function($){return Bq($)||F$($)&&$},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function($){return Bq($)||F$($)&&$},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function($){return F$($)||Array.isArray($)},message:'"audience" must be a string or array'},algorithm:{isValid:s7.bind(null,Fq),message:'"algorithm" must be a valid string enum value'},header:{isValid:Vq,message:'"header" must be an object'},encoding:{isValid:F$,message:'"encoding" must be a string'},issuer:{isValid:F$,message:'"issuer" must be a string'},subject:{isValid:F$,message:'"subject" must be a string'},jwtid:{isValid:F$,message:'"jwtid" must be a string'},noTimestamp:{isValid:B0,message:'"noTimestamp" must be a boolean'},keyid:{isValid:F$,message:'"keyid" must be a string'},mutatePayload:{isValid:B0,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:B0,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:B0,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},J3={iat:{isValid:G8,message:'"iat" should be a number of seconds'},exp:{isValid:G8,message:'"exp" should be a number of seconds'},nbf:{isValid:G8,message:'"nbf" should be a number of seconds'}};function Uq($,q,Q,J){if(!Vq(Q))throw Error('Expected "'+J+'" to be a plain object.');Object.keys(Q).forEach(function(W){let X=$[W];if(!X){if(!q)throw Error('"'+W+'" is not allowed in "'+J+'"');return}if(!X.isValid(Q[W]))throw Error(X.message)})}function W3($){return Uq(Q3,!1,$,"options")}function X3($){return Uq(J3,!0,$,"payload")}var wq={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},H3=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];_q.exports=function($,q,Q,J){if(typeof Q==="function")J=Q,Q={};else Q=Q||{};let W=typeof $==="object"&&!Buffer.isBuffer($),X=Object.assign({alg:Q.algorithm||"HS256",typ:W?"JWT":void 0,kid:Q.keyid},Q.header);function H(w){if(J)return J(w);throw w}if(!q&&Q.algorithm!=="none")return H(Error("secretOrPrivateKey must have a value"));if(q!=null&&!(q instanceof e7))try{q=q3(q)}catch(w){try{q=$3(typeof q==="string"?Buffer.from(q):q)}catch(V){return H(Error("secretOrPrivateKey is not valid key material"))}}if(X.alg.startsWith("HS")&&q.type!=="secret")return H(Error(`secretOrPrivateKey must be a symmetric key when using ${X.alg}`));else if(/^(?:RS|PS|ES)/.test(X.alg)){if(q.type!=="private")return H(Error(`secretOrPrivateKey must be an asymmetric key when using ${X.alg}`));if(!Q.allowInsecureKeySizes&&!X.alg.startsWith("ES")&&q.asymmetricKeyDetails!==void 0&&q.asymmetricKeyDetails.modulusLength<2048)return H(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`))}if(typeof $>"u")return H(Error("payload is required"));else if(W){try{X3($)}catch(w){return H(w)}if(!Q.mutatePayload)$=Object.assign({},$)}else{let w=H3.filter(function(V){return typeof Q[V]<"u"});if(w.length>0)return H(Error("invalid "+w.join(",")+" option for "+typeof $+" payload"))}if(typeof $.exp<"u"&&typeof Q.expiresIn<"u")return H(Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(typeof $.nbf<"u"&&typeof Q.notBefore<"u")return H(Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{W3(Q)}catch(w){return H(w)}if(!Q.allowInvalidAsymmetricKeyTypes)try{a7(X.alg,q)}catch(w){return H(w)}let Y=$.iat||Math.floor(Date.now()/1000);if(Q.noTimestamp)delete $.iat;else if(W)$.iat=Y;if(typeof Q.notBefore<"u"){try{$.nbf=Yq(Q.notBefore,Y)}catch(w){return H(w)}if(typeof $.nbf>"u")return H(Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(typeof Q.expiresIn<"u"&&typeof $==="object"){try{$.exp=Yq(Q.expiresIn,Y)}catch(w){return H(w)}if(typeof $.exp>"u")return H(Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(wq).forEach(function(w){let V=wq[w];if(typeof Q[w]<"u"){if(typeof $[V]<"u")return H(Error('Bad "options.'+w+'" option. The payload already has an "'+V+'" property.'));$[V]=Q[w]}});let G=Q.encoding||"utf8";if(typeof J==="function")J=J&&t7(J),Gq.createSign({header:X,privateKey:q,payload:$,encoding:G}).once("error",J).once("done",function(w){if(!Q.allowInsecureKeySizes&&/^(?:RS|PS)/.test(X.alg)&&w.length<256)return J(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`));J(null,w)});else{let w=Gq.sign({header:X,payload:$,secret:q,encoding:G});if(!Q.allowInsecureKeySizes&&/^(?:RS|PS)/.test(X.alg)&&w.length<256)throw Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`);return w}}});var Lq=z((eY,zq)=>{zq.exports={decode:x0(),verify:T9(),sign:Dq(),JsonWebTokenError:H6(),NotBeforeError:v0(),TokenExpiredError:h0()}});function D0($){return`https://veloce-ts.com/problems/${$}`}function Pq($,q){if(q)return q;let Q=NX[$]??"unknown-error";return D0(Q)}function kq($,q,Q){if(Q)return Q;return RX[$]??q}function SX($){try{return new URL($.req.url).href}catch{return $.req.path}}function MX($){let q=$.statusCode??$.status,J={error:(typeof $.error==="string"?$.error:null)??(typeof $.detail==="string"?$.detail:"Error"),statusCode:q};if($.details!==void 0)J.details=$.details;else if($.violations!==void 0)J.details=$.violations;return J}function kG($,q,Q,J){let W=SX($),X={...q,instance:W};if(J==="legacy")return $.json(MX(X),Q);return new Response(JSON.stringify(X),{status:Q,headers:{"Content-Type":"application/problem+json"}})}var IG="application/problem+json",PG="https://veloce-ts.com/problems",NX,RX;var F8=E0(()=>{NX={400:"bad-request",401:"unauthorized",403:"forbidden",404:"not-found",409:"conflict",410:"gone",413:"payload-too-large",422:"unprocessable-entity",429:"too-many-requests",500:"internal-server-error",503:"service-unavailable"},RX={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",409:"Conflict",410:"Gone",413:"Payload Too Large",422:"Unprocessable Entity",429:"Too Many Requests",500:"Internal Server Error",503:"Service Unavailable"}});var d,EX,AX,CX,KX,IX,PX,kX,bX,ZX,fX;var bq=E0(()=>{F8();d=class d extends Error{statusCode;details;problemType;title;constructor($,q,Q,J){super(q);this.statusCode=$;this.details=Q;if(this.name="HTTPException",this.problemType=J?.problemType,this.title=J?.title,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){let $=this.statusCode,q=Pq($,this.problemType),Q=kq($,this.message,this.title);return{type:q,title:Q,status:$,detail:this.message,...this.details!==void 0?{details:this.details}:{},error:this.message,statusCode:$}}};EX=class EX extends d{constructor($="Not Found",q){super(404,$,q,{title:"Not Found"});this.name="NotFoundException"}};AX=class AX extends d{constructor($="Unauthorized",q){super(401,$,q,{title:"Unauthorized"});this.name="UnauthorizedException"}};CX=class CX extends d{constructor($="Forbidden",q){super(403,$,q,{title:"Forbidden"});this.name="ForbiddenException"}};KX=class KX extends d{constructor($="Bad Request",q){super(400,$,q,{title:"Bad Request"});this.name="BadRequestException"}};IX=class IX extends d{constructor($="Conflict",q){super(409,$,q,{title:"Conflict"});this.name="ConflictException"}};PX=class PX extends d{constructor($="Gone",q){super(410,$,q,{title:"Gone"});this.name="GoneException"}};kX=class kX extends d{constructor($="Payload Too Large",q){super(413,$,q,{title:"Payload Too Large"});this.name="PayloadTooLargeException"}};bX=class bX extends d{constructor($="Unprocessable Entity",q){super(422,$,q,{title:"Unprocessable Entity"});this.name="UnprocessableEntityException"}};ZX=class ZX extends d{constructor($="Too Many Requests",q){super(429,$,q,{title:"Too Many Requests"});this.name="TooManyRequestsException"}};fX=class fX extends d{constructor($="Service Unavailable",q){super(503,$,q,{title:"Service Unavailable"});this.name="ServiceUnavailableException"}}});var TX={};M0(TX,{TokenRevokedException:()=>U8,TokenExpiredException:()=>S6,InvalidTokenException:()=>I$,AuthorizationException:()=>x,AuthenticationException:()=>f});var f,x,S6,I$,U8;var w$=E0(()=>{bq();F8();f=class f extends d{constructor($="Authentication required"){super(401,$,void 0,{title:"Authentication Error",problemType:D0("authentication-error")});this.name="AuthenticationException"}};x=class x extends d{constructor($="Insufficient permissions"){super(403,$,void 0,{title:"Authorization Error",problemType:D0("authorization-error")});this.name="AuthorizationException"}};S6=class S6 extends f{constructor($="Token has expired"){super($);this.name="TokenExpiredException"}};I$=class I$ extends f{constructor($="Invalid token"){super($);this.name="InvalidTokenException"}};U8=class U8 extends f{constructor($="Token has been revoked"){super($);this.name="TokenRevokedException"}}});var ZH={};M0(ZH,{setSessionData:()=>kH,removeSessionData:()=>bH,isSessionAuthenticated:()=>IH,isOAuthAuthenticated:()=>iX,isAuthenticated:()=>gX,getUserRoles:()=>Z8,getUserResourcePermissions:()=>DH,getUserPermissions:()=>dq,getToken:()=>K8,getSessionUserId:()=>PH,getSessionManager:()=>b6,getSessionData:()=>KH,getRBACManager:()=>cq,getPermissionManager:()=>T8,getOAuthUser:()=>pX,getOAuthToken:()=>nX,getOAuthProvider:()=>rX,getCurrentUser:()=>T,getCurrentSession:()=>q$,getCSRFProtection:()=>CH,getAuthError:()=>yX,createSessionMiddleware:()=>x8,createRBACMiddleware:()=>b8,createPermissionMiddleware:()=>f8,createDefaultRBAC:()=>P8,createAuthMiddleware:()=>C8,checkUserRole:()=>QH,checkUserPermission:()=>JH,checkResourceAccess:()=>iq,canUserAccess:()=>zH,UpdateSessionSchema:()=>NH,TokenRevokedException:()=>U8,TokenPayloadSchema:()=>LX,TokenExpiredException:()=>S6,Token:()=>hX,TeamOnly:()=>VH,TeamMembershipPolicy:()=>O0,SuperAdminOnly:()=>$H,SessionPlugin:()=>oq,SessionManager:()=>P6,SessionGuard:()=>Z6,SessionDataSchema:()=>LH,SessionData:()=>MH,SessionConfigSchema:()=>jH,Session:()=>RH,Roles:()=>lq,RoleSchema:()=>oX,RoleAssignmentSchema:()=>aX,ResourcePermissionSchema:()=>WH,ResourcePermissionCheckSchema:()=>XH,RequireRole:()=>k8,RequirePermission:()=>tX,RequireCSRF:()=>AH,RefreshRequestSchema:()=>OX,RedisSessionStore:()=>R0,RBACPlugin:()=>pq,RBACManager:()=>t$,RBACGuard:()=>C6,PublicResourcePolicy:()=>N0,PublicRead:()=>FH,Permissions:()=>uq,PermissionSchema:()=>nq,PermissionPlugin:()=>rq,PermissionMatcher:()=>e$,PermissionManager:()=>K6,PermissionGuard:()=>I6,PermissionCheckSchema:()=>sX,PKCEUtils:()=>z0,OwnershipPolicy:()=>j0,OwnerOnly:()=>wH,OAuthUserSchema:()=>lX,OAuthUser:()=>cX,OAuthTokensSchema:()=>mX,OAuthToken:()=>dX,OAuthStateManager:()=>L0,OAuthPlugin:()=>mq,OAuthCallbackSchema:()=>I8,OAuth:()=>uX,MinimumRole:()=>qH,MicrosoftOAuthProvider:()=>yq,MemorySessionStore:()=>$6,LoginRequestSchema:()=>jX,JWTProvider:()=>_0,InvalidTokenException:()=>I$,InMemoryUserProvider:()=>Zq,GoogleOAuthProvider:()=>hq,GitHubOAuthProvider:()=>gq,FilteredResource:()=>UH,FilteredAttributes:()=>_H,CurrentUser:()=>vX,CurrentSession:()=>SH,CreateSessionSchema:()=>OH,CanWrite:()=>YH,CanUpdate:()=>GH,CanRead:()=>HH,CanDelete:()=>BH,CanAccess:()=>O$,CSRFToken:()=>EH,CSRFProtection:()=>k6,BaseOAuthProvider:()=>A6,AuthorizationException:()=>x,AuthenticationException:()=>f,AuthService:()=>M6,AuthPlugin:()=>vq,Auth:()=>xX,AdminOnly:()=>eX});module.exports=JQ(ZH);var j$=QQ(Lq(),1);var B={};M0(B,{void:()=>d3,util:()=>K,unknown:()=>u3,union:()=>r3,undefined:()=>y3,tuple:()=>s3,transformer:()=>YX,symbol:()=>g3,string:()=>Cq,strictObject:()=>i3,setErrorMap:()=>B3,set:()=>$X,record:()=>t3,quotelessJson:()=>Y3,promise:()=>HX,preprocess:()=>wX,pipeline:()=>VX,ostring:()=>FX,optional:()=>GX,onumber:()=>UX,oboolean:()=>_X,objectUtil:()=>B8,object:()=>n3,number:()=>Kq,nullable:()=>BX,null:()=>m3,never:()=>c3,nativeEnum:()=>XX,nan:()=>x3,map:()=>e3,makeIssue:()=>D6,literal:()=>JX,lazy:()=>QX,late:()=>f3,isValid:()=>U$,isDirty:()=>V0,isAsync:()=>g$,isAborted:()=>w0,intersection:()=>a3,instanceof:()=>T3,getParsedType:()=>W$,getErrorMap:()=>h$,function:()=>qX,enum:()=>WX,effect:()=>YX,discriminatedUnion:()=>o3,defaultErrorMap:()=>Y$,datetimeRegex:()=>Mq,date:()=>h3,custom:()=>Aq,coerce:()=>DX,boolean:()=>Iq,bigint:()=>v3,array:()=>p3,any:()=>l3,addIssueToContext:()=>D,ZodVoid:()=>L6,ZodUnknown:()=>_$,ZodUnion:()=>d$,ZodUndefined:()=>u$,ZodType:()=>C,ZodTuple:()=>H$,ZodTransformer:()=>$$,ZodSymbol:()=>z6,ZodString:()=>a,ZodSet:()=>C$,ZodSchema:()=>C,ZodRecord:()=>j6,ZodReadonly:()=>s$,ZodPromise:()=>K$,ZodPipeline:()=>R6,ZodParsedType:()=>_,ZodOptional:()=>t,ZodObject:()=>Z,ZodNumber:()=>D$,ZodNullable:()=>B$,ZodNull:()=>c$,ZodNever:()=>X$,ZodNativeEnum:()=>r$,ZodNaN:()=>N6,ZodMap:()=>O6,ZodLiteral:()=>i$,ZodLazy:()=>n$,ZodIssueCode:()=>F,ZodIntersection:()=>p$,ZodFunction:()=>m$,ZodFirstPartyTypeKind:()=>S,ZodError:()=>c,ZodEnum:()=>L$,ZodEffects:()=>$$,ZodDiscriminatedUnion:()=>F0,ZodDefault:()=>o$,ZodDate:()=>E$,ZodCatch:()=>a$,ZodBranded:()=>U0,ZodBoolean:()=>l$,ZodBigInt:()=>z$,ZodArray:()=>s,ZodAny:()=>A$,Schema:()=>C,ParseStatus:()=>v,OK:()=>y,NEVER:()=>zX,INVALID:()=>R,EMPTY_PATH:()=>w3,DIRTY:()=>M$,BRAND:()=>Z3});var K;(function($){$.assertEqual=(W)=>{};function q(W){}$.assertIs=q;function Q(W){throw Error()}$.assertNever=Q,$.arrayToEnum=(W)=>{let X={};for(let H of W)X[H]=H;return X},$.getValidEnumValues=(W)=>{let X=$.objectKeys(W).filter((Y)=>typeof W[W[Y]]!=="number"),H={};for(let Y of X)H[Y]=W[Y];return $.objectValues(H)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(X){return W[X]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let X=[];for(let H in W)if(Object.prototype.hasOwnProperty.call(W,H))X.push(H);return X},$.find=(W,X)=>{for(let H of W)if(X(H))return H;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function J(W,X=" | "){return W.map((H)=>typeof H==="string"?`'${H}'`:H).join(X)}$.joinValues=J,$.jsonStringifyReplacer=(W,X)=>{if(typeof X==="bigint")return X.toString();return X}})(K||(K={}));var B8;(function($){$.mergeShapes=(q,Q)=>{return{...q,...Q}}})(B8||(B8={}));var _=K.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),W$=($)=>{switch(typeof $){case"undefined":return _.undefined;case"string":return _.string;case"number":return Number.isNaN($)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":if(Array.isArray($))return _.array;if($===null)return _.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return _.promise;if(typeof Map<"u"&&$ instanceof Map)return _.map;if(typeof Set<"u"&&$ instanceof Set)return _.set;if(typeof Date<"u"&&$ instanceof Date)return _.date;return _.object;default:return _.unknown}};var F=K.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Y3=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class c extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,q);else this.__proto__=q;this.name="ZodError",this.issues=$}format($){let q=$||function(W){return W.message},Q={_errors:[]},J=(W)=>{for(let X of W.issues)if(X.code==="invalid_union")X.unionErrors.map(J);else if(X.code==="invalid_return_type")J(X.returnTypeError);else if(X.code==="invalid_arguments")J(X.argumentsError);else if(X.path.length===0)Q._errors.push(q(X));else{let H=Q,Y=0;while(Y<X.path.length){let G=X.path[Y];if(Y!==X.path.length-1)H[G]=H[G]||{_errors:[]};else H[G]=H[G]||{_errors:[]},H[G]._errors.push(q(X));H=H[G],Y++}}};return J(this),Q}static assert($){if(!($ instanceof c))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,K.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(q)=>q.message){let q={},Q=[];for(let J of this.issues)if(J.path.length>0){let W=J.path[0];q[W]=q[W]||[],q[W].push($(J))}else Q.push($(J));return{formErrors:Q,fieldErrors:q}}get formErrors(){return this.flatten()}}c.create=($)=>{return new c($)};var G3=($,q)=>{let Q;switch($.code){case F.invalid_type:if($.received===_.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case F.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,K.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:Q=`Unrecognized key(s) in object: ${K.joinValues($.keys,", ")}`;break;case F.invalid_union:Q="Invalid input";break;case F.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${K.joinValues($.options)}`;break;case F.invalid_enum_value:Q=`Invalid enum value. Expected ${K.joinValues($.options)}, received '${$.received}'`;break;case F.invalid_arguments:Q="Invalid function arguments";break;case F.invalid_return_type:Q="Invalid function return type";break;case F.invalid_date:Q="Invalid date";break;case F.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else K.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case F.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case F.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case F.custom:Q="Invalid input";break;case F.invalid_intersection_types:Q="Intersection results could not be merged";break;case F.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case F.not_finite:Q="Number must be finite";break;default:Q=q.defaultError,K.assertNever($)}return{message:Q}},Y$=G3;var jq=Y$;function B3($){jq=$}function h$(){return jq}var D6=($)=>{let{data:q,path:Q,errorMaps:J,issueData:W}=$,X=[...Q,...W.path||[]],H={...W,path:X};if(W.message!==void 0)return{...W,path:X,message:W.message};let Y="",G=J.filter((w)=>!!w).slice().reverse();for(let w of G)Y=w(H,{data:q,defaultError:Y}).message;return{...W,path:X,message:Y}},w3=[];function D($,q){let Q=h$(),J=D6({issueData:q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===Y$?void 0:Y$].filter((W)=>!!W)});$.common.issues.push(J)}class v{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,q){let Q=[];for(let J of q){if(J.status==="aborted")return R;if(J.status==="dirty")$.dirty();Q.push(J.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,q){let Q=[];for(let J of q){let W=await J.key,X=await J.value;Q.push({key:W,value:X})}return v.mergeObjectSync($,Q)}static mergeObjectSync($,q){let Q={};for(let J of q){let{key:W,value:X}=J;if(W.status==="aborted")return R;if(X.status==="aborted")return R;if(W.status==="dirty")$.dirty();if(X.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof X.value<"u"||J.alwaysSet))Q[W.value]=X.value}return{status:$.value,value:Q}}}var R=Object.freeze({status:"aborted"}),M$=($)=>({status:"dirty",value:$}),y=($)=>({status:"valid",value:$}),w0=($)=>$.status==="aborted",V0=($)=>$.status==="dirty",U$=($)=>$.status==="valid",g$=($)=>typeof Promise<"u"&&$ instanceof Promise;var N;(function($){$.errToObj=(q)=>typeof q==="string"?{message:q}:q||{},$.toString=(q)=>typeof q==="string"?q:q?.message})(N||(N={}));class e{constructor($,q,Q,J){this._cachedPath=[],this.parent=$,this.data=q,this._path=Q,this._key=J}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var Oq=($,q)=>{if(U$(q))return{success:!0,data:q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new c($.common.issues);return this._error=Q,this._error}}}};function A($){if(!$)return{};let{errorMap:q,invalid_type_error:Q,required_error:J,description:W}=$;if(q&&(Q||J))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(q)return{errorMap:q,description:W};return{errorMap:(H,Y)=>{let{message:G}=$;if(H.code==="invalid_enum_value")return{message:G??Y.defaultError};if(typeof Y.data>"u")return{message:G??J??Y.defaultError};if(H.code!=="invalid_type")return{message:Y.defaultError};return{message:G??Q??Y.defaultError}},description:W}}class C{get description(){return this._def.description}_getType($){return W$($.data)}_getOrReturnCtx($,q){return q||{common:$.parent.common,data:$.data,parsedType:W$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new v,ctx:{common:$.parent.common,data:$.data,parsedType:W$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let q=this._parse($);if(g$(q))throw Error("Synchronous parse encountered promise.");return q}_parseAsync($){let q=this._parse($);return Promise.resolve(q)}parse($,q){let Q=this.safeParse($,q);if(Q.success)return Q.data;throw Q.error}safeParse($,q){let Q={common:{issues:[],async:q?.async??!1,contextualErrorMap:q?.errorMap},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:W$($)},J=this._parseSync({data:$,path:Q.path,parent:Q});return Oq(Q,J)}"~validate"($){let q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:W$($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:q});return U$(Q)?{value:Q.value}:{issues:q.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:q}).then((Q)=>U$(Q)?{value:Q.value}:{issues:q.common.issues})}async parseAsync($,q){let Q=await this.safeParseAsync($,q);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,q){let Q={common:{issues:[],contextualErrorMap:q?.errorMap,async:!0},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:W$($)},J=this._parse({data:$,path:Q.path,parent:Q}),W=await(g$(J)?J:Promise.resolve(J));return Oq(Q,W)}refine($,q){let Q=(J)=>{if(typeof q==="string"||typeof q>"u")return{message:q};else if(typeof q==="function")return q(J);else return q};return this._refinement((J,W)=>{let X=$(J),H=()=>W.addIssue({code:F.custom,...Q(J)});if(typeof Promise<"u"&&X instanceof Promise)return X.then((Y)=>{if(!Y)return H(),!1;else return!0});if(!X)return H(),!1;else return!0})}refinement($,q){return this._refinement((Q,J)=>{if(!$(Q))return J.addIssue(typeof q==="function"?q(Q,J):q),!1;else return!0})}_refinement($){return new $$({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(q)=>this["~validate"](q)}}optional(){return t.create(this,this._def)}nullable(){return B$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return s.create(this)}promise(){return K$.create(this,this._def)}or($){return d$.create([this,$],this._def)}and($){return p$.create(this,$,this._def)}transform($){return new $$({...A(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:$}})}default($){let q=typeof $==="function"?$:()=>$;return new o$({...A(this._def),innerType:this,defaultValue:q,typeName:S.ZodDefault})}brand(){return new U0({typeName:S.ZodBranded,type:this,...A(this._def)})}catch($){let q=typeof $==="function"?$:()=>$;return new a$({...A(this._def),innerType:this,catchValue:q,typeName:S.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return R6.create(this,$)}readonly(){return s$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var V3=/^c[^\s-]{8,}$/i,F3=/^[0-9a-z]+$/,U3=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_3=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,D3=/^[a-z0-9_-]{21}$/i,z3=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,L3=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,j3=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,O3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",w8,N3=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,R3=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,S3=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,M3=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,E3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,A3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Rq="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",C3=new RegExp(`^${Rq}$`);function Sq($){let q="[0-5]\\d";if($.precision)q=`${q}\\.\\d{${$.precision}}`;else if($.precision==null)q=`${q}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${q})${Q}`}function K3($){return new RegExp(`^${Sq($)}$`)}function Mq($){let q=`${Rq}T${Sq($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return q=`${q}(${Q.join("|")})`,new RegExp(`^${q}$`)}function I3($,q){if((q==="v4"||!q)&&N3.test($))return!0;if((q==="v6"||!q)&&S3.test($))return!0;return!1}function P3($,q){if(!z3.test($))return!1;try{let[Q]=$.split(".");if(!Q)return!1;let J=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),W=JSON.parse(atob(J));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(q&&W.alg!==q)return!1;return!0}catch{return!1}}function k3($,q){if((q==="v4"||!q)&&R3.test($))return!0;if((q==="v6"||!q)&&M3.test($))return!0;return!1}class a extends C{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==_.string){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_type,expected:_.string,received:W.parsedType}),R}let Q=new v,J=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="max"){if($.data.length>W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="length"){let X=$.data.length>W.value,H=$.data.length<W.value;if(X||H){if(J=this._getOrReturnCtx($,J),X)D(J,{code:F.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(H)D(J,{code:F.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});Q.dirty()}}else if(W.kind==="email"){if(!j3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"email",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="emoji"){if(!w8)w8=new RegExp(O3,"u");if(!w8.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"emoji",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="uuid"){if(!_3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"uuid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="nanoid"){if(!D3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"nanoid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid"){if(!V3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"cuid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid2"){if(!F3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"cuid2",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ulid"){if(!U3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"ulid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{J=this._getOrReturnCtx($,J),D(J,{validation:"url",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"regex",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),Q.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:{startsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:{endsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="datetime"){if(!Mq(W).test($.data))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:"datetime",message:W.message}),Q.dirty()}else if(W.kind==="date"){if(!C3.test($.data))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:"date",message:W.message}),Q.dirty()}else if(W.kind==="time"){if(!K3(W).test($.data))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:"time",message:W.message}),Q.dirty()}else if(W.kind==="duration"){if(!L3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"duration",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ip"){if(!I3($.data,W.version))J=this._getOrReturnCtx($,J),D(J,{validation:"ip",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="jwt"){if(!P3($.data,W.alg))J=this._getOrReturnCtx($,J),D(J,{validation:"jwt",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cidr"){if(!k3($.data,W.version))J=this._getOrReturnCtx($,J),D(J,{validation:"cidr",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64"){if(!E3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"base64",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64url"){if(!A3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"base64url",code:F.invalid_string,message:W.message}),Q.dirty()}else K.assertNever(W);return{status:Q.value,value:$.data}}_regex($,q,Q){return this.refinement((J)=>$.test(J),{validation:q,code:F.invalid_string,...N.errToObj(Q)})}_addCheck($){return new a({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...N.errToObj($)})}url($){return this._addCheck({kind:"url",...N.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...N.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...N.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...N.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...N.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...N.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...N.errToObj($)})}base64($){return this._addCheck({kind:"base64",...N.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...N.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...N.errToObj($)})}ip($){return this._addCheck({kind:"ip",...N.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...N.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...N.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...N.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...N.errToObj($)})}regex($,q){return this._addCheck({kind:"regex",regex:$,...N.errToObj(q)})}includes($,q){return this._addCheck({kind:"includes",value:$,position:q?.position,...N.errToObj(q?.message)})}startsWith($,q){return this._addCheck({kind:"startsWith",value:$,...N.errToObj(q)})}endsWith($,q){return this._addCheck({kind:"endsWith",value:$,...N.errToObj(q)})}min($,q){return this._addCheck({kind:"min",value:$,...N.errToObj(q)})}max($,q){return this._addCheck({kind:"max",value:$,...N.errToObj(q)})}length($,q){return this._addCheck({kind:"length",value:$,...N.errToObj(q)})}nonempty($){return this.min(1,N.errToObj($))}trim(){return new a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxLength(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}a.create=($)=>{return new a({checks:[],typeName:S.ZodString,coerce:$?.coerce??!1,...A($)})};function b3($,q){let Q=($.toString().split(".")[1]||"").length,J=(q.toString().split(".")[1]||"").length,W=Q>J?Q:J,X=Number.parseInt($.toFixed(W).replace(".","")),H=Number.parseInt(q.toFixed(W).replace(".",""));return X%H/10**W}class D$ extends C{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==_.number){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_type,expected:_.number,received:W.parsedType}),R}let Q=void 0,J=new v;for(let W of this._def.checks)if(W.kind==="int"){if(!K.isInteger($.data))Q=this._getOrReturnCtx($,Q),D(Q,{code:F.invalid_type,expected:"integer",received:"float",message:W.message}),J.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="multipleOf"){if(b3($.data,W.value)!==0)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.not_multiple_of,multipleOf:W.value,message:W.message}),J.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),D(Q,{code:F.not_finite,message:W.message}),J.dirty()}else K.assertNever(W);return{status:J.value,value:$.data}}gte($,q){return this.setLimit("min",$,!0,N.toString(q))}gt($,q){return this.setLimit("min",$,!1,N.toString(q))}lte($,q){return this.setLimit("max",$,!0,N.toString(q))}lt($,q){return this.setLimit("max",$,!1,N.toString(q))}setLimit($,q,Q,J){return new D$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:N.toString(J)}]})}_addCheck($){return new D$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:N.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:N.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:N.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:N.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:N.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:N.toString(q)})}finite($){return this._addCheck({kind:"finite",message:N.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:N.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:N.toString($)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&K.isInteger($.value))}get isFinite(){let $=null,q=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(q===null||Q.value>q)q=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(q)&&Number.isFinite($)}}D$.create=($)=>{return new D$({checks:[],typeName:S.ZodNumber,coerce:$?.coerce||!1,...A($)})};class z$ extends C{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==_.bigint)return this._getInvalidInput($);let Q=void 0,J=new v;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),J.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),J.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),D(Q,{code:F.not_multiple_of,multipleOf:W.value,message:W.message}),J.dirty()}else K.assertNever(W);return{status:J.value,value:$.data}}_getInvalidInput($){let q=this._getOrReturnCtx($);return D(q,{code:F.invalid_type,expected:_.bigint,received:q.parsedType}),R}gte($,q){return this.setLimit("min",$,!0,N.toString(q))}gt($,q){return this.setLimit("min",$,!1,N.toString(q))}lte($,q){return this.setLimit("max",$,!0,N.toString(q))}lt($,q){return this.setLimit("max",$,!1,N.toString(q))}setLimit($,q,Q,J){return new z$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:N.toString(J)}]})}_addCheck($){return new z$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:N.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:N.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:N.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:N.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:N.toString(q)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}z$.create=($)=>{return new z$({checks:[],typeName:S.ZodBigInt,coerce:$?.coerce??!1,...A($)})};class l$ extends C{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==_.boolean){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.boolean,received:Q.parsedType}),R}return y($.data)}}l$.create=($)=>{return new l$({typeName:S.ZodBoolean,coerce:$?.coerce||!1,...A($)})};class E$ extends C{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==_.date){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_type,expected:_.date,received:W.parsedType}),R}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_date}),R}let Q=new v,J=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),Q.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),Q.dirty()}else K.assertNever(W);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new E$({...this._def,checks:[...this._def.checks,$]})}min($,q){return this._addCheck({kind:"min",value:$.getTime(),message:N.toString(q)})}max($,q){return this._addCheck({kind:"max",value:$.getTime(),message:N.toString(q)})}get minDate(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $!=null?new Date($):null}}E$.create=($)=>{return new E$({checks:[],coerce:$?.coerce||!1,typeName:S.ZodDate,...A($)})};class z6 extends C{_parse($){if(this._getType($)!==_.symbol){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.symbol,received:Q.parsedType}),R}return y($.data)}}z6.create=($)=>{return new z6({typeName:S.ZodSymbol,...A($)})};class u$ extends C{_parse($){if(this._getType($)!==_.undefined){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.undefined,received:Q.parsedType}),R}return y($.data)}}u$.create=($)=>{return new u$({typeName:S.ZodUndefined,...A($)})};class c$ extends C{_parse($){if(this._getType($)!==_.null){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.null,received:Q.parsedType}),R}return y($.data)}}c$.create=($)=>{return new c$({typeName:S.ZodNull,...A($)})};class A$ extends C{constructor(){super(...arguments);this._any=!0}_parse($){return y($.data)}}A$.create=($)=>{return new A$({typeName:S.ZodAny,...A($)})};class _$ extends C{constructor(){super(...arguments);this._unknown=!0}_parse($){return y($.data)}}_$.create=($)=>{return new _$({typeName:S.ZodUnknown,...A($)})};class X$ extends C{_parse($){let q=this._getOrReturnCtx($);return D(q,{code:F.invalid_type,expected:_.never,received:q.parsedType}),R}}X$.create=($)=>{return new X$({typeName:S.ZodNever,...A($)})};class L6 extends C{_parse($){if(this._getType($)!==_.undefined){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.void,received:Q.parsedType}),R}return y($.data)}}L6.create=($)=>{return new L6({typeName:S.ZodVoid,...A($)})};class s extends C{_parse($){let{ctx:q,status:Q}=this._processInputParams($),J=this._def;if(q.parsedType!==_.array)return D(q,{code:F.invalid_type,expected:_.array,received:q.parsedType}),R;if(J.exactLength!==null){let X=q.data.length>J.exactLength.value,H=q.data.length<J.exactLength.value;if(X||H)D(q,{code:X?F.too_big:F.too_small,minimum:H?J.exactLength.value:void 0,maximum:X?J.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:J.exactLength.message}),Q.dirty()}if(J.minLength!==null){if(q.data.length<J.minLength.value)D(q,{code:F.too_small,minimum:J.minLength.value,type:"array",inclusive:!0,exact:!1,message:J.minLength.message}),Q.dirty()}if(J.maxLength!==null){if(q.data.length>J.maxLength.value)D(q,{code:F.too_big,maximum:J.maxLength.value,type:"array",inclusive:!0,exact:!1,message:J.maxLength.message}),Q.dirty()}if(q.common.async)return Promise.all([...q.data].map((X,H)=>{return J.type._parseAsync(new e(q,X,q.path,H))})).then((X)=>{return v.mergeArray(Q,X)});let W=[...q.data].map((X,H)=>{return J.type._parseSync(new e(q,X,q.path,H))});return v.mergeArray(Q,W)}get element(){return this._def.type}min($,q){return new s({...this._def,minLength:{value:$,message:N.toString(q)}})}max($,q){return new s({...this._def,maxLength:{value:$,message:N.toString(q)}})}length($,q){return new s({...this._def,exactLength:{value:$,message:N.toString(q)}})}nonempty($){return this.min(1,$)}}s.create=($,q)=>{return new s({type:$,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...A(q)})};function y$($){if($ instanceof Z){let q={};for(let Q in $.shape){let J=$.shape[Q];q[Q]=t.create(y$(J))}return new Z({...$._def,shape:()=>q})}else if($ instanceof s)return new s({...$._def,type:y$($.element)});else if($ instanceof t)return t.create(y$($.unwrap()));else if($ instanceof B$)return B$.create(y$($.unwrap()));else if($ instanceof H$)return H$.create($.items.map((q)=>y$(q)));else return $}class Z extends C{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),q=K.objectKeys($);return this._cached={shape:$,keys:q},this._cached}_parse($){if(this._getType($)!==_.object){let G=this._getOrReturnCtx($);return D(G,{code:F.invalid_type,expected:_.object,received:G.parsedType}),R}let{status:Q,ctx:J}=this._processInputParams($),{shape:W,keys:X}=this._getCached(),H=[];if(!(this._def.catchall instanceof X$&&this._def.unknownKeys==="strip")){for(let G in J.data)if(!X.includes(G))H.push(G)}let Y=[];for(let G of X){let w=W[G],V=J.data[G];Y.push({key:{status:"valid",value:G},value:w._parse(new e(J,V,J.path,G)),alwaysSet:G in J.data})}if(this._def.catchall instanceof X$){let G=this._def.unknownKeys;if(G==="passthrough")for(let w of H)Y.push({key:{status:"valid",value:w},value:{status:"valid",value:J.data[w]}});else if(G==="strict"){if(H.length>0)D(J,{code:F.unrecognized_keys,keys:H}),Q.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let w of H){let V=J.data[w];Y.push({key:{status:"valid",value:w},value:G._parse(new e(J,V,J.path,w)),alwaysSet:w in J.data})}}if(J.common.async)return Promise.resolve().then(async()=>{let G=[];for(let w of Y){let V=await w.key,U=await w.value;G.push({key:V,value:U,alwaysSet:w.alwaysSet})}return G}).then((G)=>{return v.mergeObjectSync(Q,G)});else return v.mergeObjectSync(Q,Y)}get shape(){return this._def.shape()}strict($){return N.errToObj,new Z({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(q,Q)=>{let J=this._def.errorMap?.(q,Q).message??Q.defaultError;if(q.code==="unrecognized_keys")return{message:N.errToObj($).message??J};return{message:J}}}:{}})}strip(){return new Z({...this._def,unknownKeys:"strip"})}passthrough(){return new Z({...this._def,unknownKeys:"passthrough"})}extend($){return new Z({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new Z({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:S.ZodObject})}setKey($,q){return this.augment({[$]:q})}catchall($){return new Z({...this._def,catchall:$})}pick($){let q={};for(let Q of K.objectKeys($))if($[Q]&&this.shape[Q])q[Q]=this.shape[Q];return new Z({...this._def,shape:()=>q})}omit($){let q={};for(let Q of K.objectKeys(this.shape))if(!$[Q])q[Q]=this.shape[Q];return new Z({...this._def,shape:()=>q})}deepPartial(){return y$(this)}partial($){let q={};for(let Q of K.objectKeys(this.shape)){let J=this.shape[Q];if($&&!$[Q])q[Q]=J;else q[Q]=J.optional()}return new Z({...this._def,shape:()=>q})}required($){let q={};for(let Q of K.objectKeys(this.shape))if($&&!$[Q])q[Q]=this.shape[Q];else{let W=this.shape[Q];while(W instanceof t)W=W._def.innerType;q[Q]=W}return new Z({...this._def,shape:()=>q})}keyof(){return Eq(K.objectKeys(this.shape))}}Z.create=($,q)=>{return new Z({shape:()=>$,unknownKeys:"strip",catchall:X$.create(),typeName:S.ZodObject,...A(q)})};Z.strictCreate=($,q)=>{return new Z({shape:()=>$,unknownKeys:"strict",catchall:X$.create(),typeName:S.ZodObject,...A(q)})};Z.lazycreate=($,q)=>{return new Z({shape:$,unknownKeys:"strip",catchall:X$.create(),typeName:S.ZodObject,...A(q)})};class d$ extends C{_parse($){let{ctx:q}=this._processInputParams($),Q=this._def.options;function J(W){for(let H of W)if(H.result.status==="valid")return H.result;for(let H of W)if(H.result.status==="dirty")return q.common.issues.push(...H.ctx.common.issues),H.result;let X=W.map((H)=>new c(H.ctx.common.issues));return D(q,{code:F.invalid_union,unionErrors:X}),R}if(q.common.async)return Promise.all(Q.map(async(W)=>{let X={...q,common:{...q.common,issues:[]},parent:null};return{result:await W._parseAsync({data:q.data,path:q.path,parent:X}),ctx:X}})).then(J);else{let W=void 0,X=[];for(let Y of Q){let G={...q,common:{...q.common,issues:[]},parent:null},w=Y._parseSync({data:q.data,path:q.path,parent:G});if(w.status==="valid")return w;else if(w.status==="dirty"&&!W)W={result:w,ctx:G};if(G.common.issues.length)X.push(G.common.issues)}if(W)return q.common.issues.push(...W.ctx.common.issues),W.result;let H=X.map((Y)=>new c(Y));return D(q,{code:F.invalid_union,unionErrors:H}),R}}get options(){return this._def.options}}d$.create=($,q)=>{return new d$({options:$,typeName:S.ZodUnion,...A(q)})};var G$=($)=>{if($ instanceof n$)return G$($.schema);else if($ instanceof $$)return G$($.innerType());else if($ instanceof i$)return[$.value];else if($ instanceof L$)return $.options;else if($ instanceof r$)return K.objectValues($.enum);else if($ instanceof o$)return G$($._def.innerType);else if($ instanceof u$)return[void 0];else if($ instanceof c$)return[null];else if($ instanceof t)return[void 0,...G$($.unwrap())];else if($ instanceof B$)return[null,...G$($.unwrap())];else if($ instanceof U0)return G$($.unwrap());else if($ instanceof s$)return G$($.unwrap());else if($ instanceof a$)return G$($._def.innerType);else return[]};class F0 extends C{_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==_.object)return D(q,{code:F.invalid_type,expected:_.object,received:q.parsedType}),R;let Q=this.discriminator,J=q.data[Q],W=this.optionsMap.get(J);if(!W)return D(q,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),R;if(q.common.async)return W._parseAsync({data:q.data,path:q.path,parent:q});else return W._parseSync({data:q.data,path:q.path,parent:q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,q,Q){let J=new Map;for(let W of q){let X=G$(W.shape[$]);if(!X.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let H of X){if(J.has(H))throw Error(`Discriminator property ${String($)} has duplicate value ${String(H)}`);J.set(H,W)}}return new F0({typeName:S.ZodDiscriminatedUnion,discriminator:$,options:q,optionsMap:J,...A(Q)})}}function V8($,q){let Q=W$($),J=W$(q);if($===q)return{valid:!0,data:$};else if(Q===_.object&&J===_.object){let W=K.objectKeys(q),X=K.objectKeys($).filter((Y)=>W.indexOf(Y)!==-1),H={...$,...q};for(let Y of X){let G=V8($[Y],q[Y]);if(!G.valid)return{valid:!1};H[Y]=G.data}return{valid:!0,data:H}}else if(Q===_.array&&J===_.array){if($.length!==q.length)return{valid:!1};let W=[];for(let X=0;X<$.length;X++){let H=$[X],Y=q[X],G=V8(H,Y);if(!G.valid)return{valid:!1};W.push(G.data)}return{valid:!0,data:W}}else if(Q===_.date&&J===_.date&&+$===+q)return{valid:!0,data:$};else return{valid:!1}}class p$ extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($),J=(W,X)=>{if(w0(W)||w0(X))return R;let H=V8(W.value,X.value);if(!H.valid)return D(Q,{code:F.invalid_intersection_types}),R;if(V0(W)||V0(X))q.dirty();return{status:q.value,value:H.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([W,X])=>J(W,X));else return J(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}p$.create=($,q,Q)=>{return new p$({left:$,right:q,typeName:S.ZodIntersection,...A(Q)})};class H$ extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.array)return D(Q,{code:F.invalid_type,expected:_.array,received:Q.parsedType}),R;if(Q.data.length<this._def.items.length)return D(Q,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),R;if(!this._def.rest&&Q.data.length>this._def.items.length)D(Q,{code:F.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q.dirty();let W=[...Q.data].map((X,H)=>{let Y=this._def.items[H]||this._def.rest;if(!Y)return null;return Y._parse(new e(Q,X,Q.path,H))}).filter((X)=>!!X);if(Q.common.async)return Promise.all(W).then((X)=>{return v.mergeArray(q,X)});else return v.mergeArray(q,W)}get items(){return this._def.items}rest($){return new H$({...this._def,rest:$})}}H$.create=($,q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new H$({items:$,typeName:S.ZodTuple,rest:null,...A(q)})};class j6 extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.object)return D(Q,{code:F.invalid_type,expected:_.object,received:Q.parsedType}),R;let J=[],W=this._def.keyType,X=this._def.valueType;for(let H in Q.data)J.push({key:W._parse(new e(Q,H,Q.path,H)),value:X._parse(new e(Q,Q.data[H],Q.path,H)),alwaysSet:H in Q.data});if(Q.common.async)return v.mergeObjectAsync(q,J);else return v.mergeObjectSync(q,J)}get element(){return this._def.valueType}static create($,q,Q){if(q instanceof C)return new j6({keyType:$,valueType:q,typeName:S.ZodRecord,...A(Q)});return new j6({keyType:a.create(),valueType:$,typeName:S.ZodRecord,...A(q)})}}class O6 extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.map)return D(Q,{code:F.invalid_type,expected:_.map,received:Q.parsedType}),R;let J=this._def.keyType,W=this._def.valueType,X=[...Q.data.entries()].map(([H,Y],G)=>{return{key:J._parse(new e(Q,H,Q.path,[G,"key"])),value:W._parse(new e(Q,Y,Q.path,[G,"value"]))}});if(Q.common.async){let H=new Map;return Promise.resolve().then(async()=>{for(let Y of X){let G=await Y.key,w=await Y.value;if(G.status==="aborted"||w.status==="aborted")return R;if(G.status==="dirty"||w.status==="dirty")q.dirty();H.set(G.value,w.value)}return{status:q.value,value:H}})}else{let H=new Map;for(let Y of X){let{key:G,value:w}=Y;if(G.status==="aborted"||w.status==="aborted")return R;if(G.status==="dirty"||w.status==="dirty")q.dirty();H.set(G.value,w.value)}return{status:q.value,value:H}}}}O6.create=($,q,Q)=>{return new O6({valueType:q,keyType:$,typeName:S.ZodMap,...A(Q)})};class C$ extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.set)return D(Q,{code:F.invalid_type,expected:_.set,received:Q.parsedType}),R;let J=this._def;if(J.minSize!==null){if(Q.data.size<J.minSize.value)D(Q,{code:F.too_small,minimum:J.minSize.value,type:"set",inclusive:!0,exact:!1,message:J.minSize.message}),q.dirty()}if(J.maxSize!==null){if(Q.data.size>J.maxSize.value)D(Q,{code:F.too_big,maximum:J.maxSize.value,type:"set",inclusive:!0,exact:!1,message:J.maxSize.message}),q.dirty()}let W=this._def.valueType;function X(Y){let G=new Set;for(let w of Y){if(w.status==="aborted")return R;if(w.status==="dirty")q.dirty();G.add(w.value)}return{status:q.value,value:G}}let H=[...Q.data.values()].map((Y,G)=>W._parse(new e(Q,Y,Q.path,G)));if(Q.common.async)return Promise.all(H).then((Y)=>X(Y));else return X(H)}min($,q){return new C$({...this._def,minSize:{value:$,message:N.toString(q)}})}max($,q){return new C$({...this._def,maxSize:{value:$,message:N.toString(q)}})}size($,q){return this.min($,q).max($,q)}nonempty($){return this.min(1,$)}}C$.create=($,q)=>{return new C$({valueType:$,minSize:null,maxSize:null,typeName:S.ZodSet,...A(q)})};class m$ extends C{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==_.function)return D(q,{code:F.invalid_type,expected:_.function,received:q.parsedType}),R;function Q(H,Y){return D6({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,h$(),Y$].filter((G)=>!!G),issueData:{code:F.invalid_arguments,argumentsError:Y}})}function J(H,Y){return D6({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,h$(),Y$].filter((G)=>!!G),issueData:{code:F.invalid_return_type,returnTypeError:Y}})}let W={errorMap:q.common.contextualErrorMap},X=q.data;if(this._def.returns instanceof K$){let H=this;return y(async function(...Y){let G=new c([]),w=await H._def.args.parseAsync(Y,W).catch((M)=>{throw G.addIssue(Q(Y,M)),G}),V=await Reflect.apply(X,this,w);return await H._def.returns._def.type.parseAsync(V,W).catch((M)=>{throw G.addIssue(J(V,M)),G})})}else{let H=this;return y(function(...Y){let G=H._def.args.safeParse(Y,W);if(!G.success)throw new c([Q(Y,G.error)]);let w=Reflect.apply(X,this,G.data),V=H._def.returns.safeParse(w,W);if(!V.success)throw new c([J(w,V.error)]);return V.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new m$({...this._def,args:H$.create($).rest(_$.create())})}returns($){return new m$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,q,Q){return new m$({args:$?$:H$.create([]).rest(_$.create()),returns:q||_$.create(),typeName:S.ZodFunction,...A(Q)})}}class n$ extends C{get schema(){return this._def.getter()}_parse($){let{ctx:q}=this._processInputParams($);return this._def.getter()._parse({data:q.data,path:q.path,parent:q})}}n$.create=($,q)=>{return new n$({getter:$,typeName:S.ZodLazy,...A(q)})};class i$ extends C{_parse($){if($.data!==this._def.value){let q=this._getOrReturnCtx($);return D(q,{received:q.data,code:F.invalid_literal,expected:this._def.value}),R}return{status:"valid",value:$.data}}get value(){return this._def.value}}i$.create=($,q)=>{return new i$({value:$,typeName:S.ZodLiteral,...A(q)})};function Eq($,q){return new L$({values:$,typeName:S.ZodEnum,...A(q)})}class L$ extends C{_parse($){if(typeof $.data!=="string"){let q=this._getOrReturnCtx($),Q=this._def.values;return D(q,{expected:K.joinValues(Q),received:q.parsedType,code:F.invalid_type}),R}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let q=this._getOrReturnCtx($),Q=this._def.values;return D(q,{received:q.data,code:F.invalid_enum_value,options:Q}),R}return y($.data)}get options(){return this._def.values}get enum(){let $={};for(let q of this._def.values)$[q]=q;return $}get Values(){let $={};for(let q of this._def.values)$[q]=q;return $}get Enum(){let $={};for(let q of this._def.values)$[q]=q;return $}extract($,q=this._def){return L$.create($,{...this._def,...q})}exclude($,q=this._def){return L$.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...q})}}L$.create=Eq;class r$ extends C{_parse($){let q=K.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==_.string&&Q.parsedType!==_.number){let J=K.objectValues(q);return D(Q,{expected:K.joinValues(J),received:Q.parsedType,code:F.invalid_type}),R}if(!this._cache)this._cache=new Set(K.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let J=K.objectValues(q);return D(Q,{received:Q.data,code:F.invalid_enum_value,options:J}),R}return y($.data)}get enum(){return this._def.values}}r$.create=($,q)=>{return new r$({values:$,typeName:S.ZodNativeEnum,...A(q)})};class K$ extends C{unwrap(){return this._def.type}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==_.promise&&q.common.async===!1)return D(q,{code:F.invalid_type,expected:_.promise,received:q.parsedType}),R;let Q=q.parsedType===_.promise?q.data:Promise.resolve(q.data);return y(Q.then((J)=>{return this._def.type.parseAsync(J,{path:q.path,errorMap:q.common.contextualErrorMap})}))}}K$.create=($,q)=>{return new K$({type:$,typeName:S.ZodPromise,...A(q)})};class $$ extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:q,ctx:Q}=this._processInputParams($),J=this._def.effect||null,W={addIssue:(X)=>{if(D(Q,X),X.fatal)q.abort();else q.dirty()},get path(){return Q.path}};if(W.addIssue=W.addIssue.bind(W),J.type==="preprocess"){let X=J.transform(Q.data,W);if(Q.common.async)return Promise.resolve(X).then(async(H)=>{if(q.value==="aborted")return R;let Y=await this._def.schema._parseAsync({data:H,path:Q.path,parent:Q});if(Y.status==="aborted")return R;if(Y.status==="dirty")return M$(Y.value);if(q.value==="dirty")return M$(Y.value);return Y});else{if(q.value==="aborted")return R;let H=this._def.schema._parseSync({data:X,path:Q.path,parent:Q});if(H.status==="aborted")return R;if(H.status==="dirty")return M$(H.value);if(q.value==="dirty")return M$(H.value);return H}}if(J.type==="refinement"){let X=(H)=>{let Y=J.refinement(H,W);if(Q.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return H};if(Q.common.async===!1){let H=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(H.status==="aborted")return R;if(H.status==="dirty")q.dirty();return X(H.value),{status:q.value,value:H.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((H)=>{if(H.status==="aborted")return R;if(H.status==="dirty")q.dirty();return X(H.value).then(()=>{return{status:q.value,value:H.value}})})}if(J.type==="transform")if(Q.common.async===!1){let X=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!U$(X))return R;let H=J.transform(X.value,W);if(H instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:q.value,value:H}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((X)=>{if(!U$(X))return R;return Promise.resolve(J.transform(X.value,W)).then((H)=>({status:q.value,value:H}))});K.assertNever(J)}}$$.create=($,q,Q)=>{return new $$({schema:$,typeName:S.ZodEffects,effect:q,...A(Q)})};$$.createWithPreprocess=($,q,Q)=>{return new $$({schema:q,effect:{type:"preprocess",transform:$},typeName:S.ZodEffects,...A(Q)})};class t extends C{_parse($){if(this._getType($)===_.undefined)return y(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}t.create=($,q)=>{return new t({innerType:$,typeName:S.ZodOptional,...A(q)})};class B$ extends C{_parse($){if(this._getType($)===_.null)return y(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}B$.create=($,q)=>{return new B$({innerType:$,typeName:S.ZodNullable,...A(q)})};class o$ extends C{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;if(q.parsedType===_.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:q.path,parent:q})}removeDefault(){return this._def.innerType}}o$.create=($,q)=>{return new o$({innerType:$,typeName:S.ZodDefault,defaultValue:typeof q.default==="function"?q.default:()=>q.default,...A(q)})};class a$ extends C{_parse($){let{ctx:q}=this._processInputParams($),Q={...q,common:{...q.common,issues:[]}},J=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(g$(J))return J.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new c(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new c(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}a$.create=($,q)=>{return new a$({innerType:$,typeName:S.ZodCatch,catchValue:typeof q.catch==="function"?q.catch:()=>q.catch,...A(q)})};class N6 extends C{_parse($){if(this._getType($)!==_.nan){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.nan,received:Q.parsedType}),R}return{status:"valid",value:$.data}}}N6.create=($)=>{return new N6({typeName:S.ZodNaN,...A($)})};var Z3=Symbol("zod_brand");class U0 extends C{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;return this._def.type._parse({data:Q,path:q.path,parent:q})}unwrap(){return this._def.type}}class R6 extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(W.status==="aborted")return R;if(W.status==="dirty")return q.dirty(),M$(W.value);else return this._def.out._parseAsync({data:W.value,path:Q.path,parent:Q})})();else{let J=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(J.status==="aborted")return R;if(J.status==="dirty")return q.dirty(),{status:"dirty",value:J.value};else return this._def.out._parseSync({data:J.value,path:Q.path,parent:Q})}}static create($,q){return new R6({in:$,out:q,typeName:S.ZodPipeline})}}class s$ extends C{_parse($){let q=this._def.innerType._parse($),Q=(J)=>{if(U$(J))J.value=Object.freeze(J.value);return J};return g$(q)?q.then((J)=>Q(J)):Q(q)}unwrap(){return this._def.innerType}}s$.create=($,q)=>{return new s$({innerType:$,typeName:S.ZodReadonly,...A(q)})};function Nq($,q){let Q=typeof $==="function"?$(q):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function Aq($,q={},Q){if($)return A$.create().superRefine((J,W)=>{let X=$(J);if(X instanceof Promise)return X.then((H)=>{if(!H){let Y=Nq(q,J),G=Y.fatal??Q??!0;W.addIssue({code:"custom",...Y,fatal:G})}});if(!X){let H=Nq(q,J),Y=H.fatal??Q??!0;W.addIssue({code:"custom",...H,fatal:Y})}return});return A$.create()}var f3={object:Z.lazycreate},S;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(S||(S={}));var T3=($,q={message:`Input not instance of ${$.name}`})=>Aq((Q)=>Q instanceof $,q),Cq=a.create,Kq=D$.create,x3=N6.create,v3=z$.create,Iq=l$.create,h3=E$.create,g3=z6.create,y3=u$.create,m3=c$.create,l3=A$.create,u3=_$.create,c3=X$.create,d3=L6.create,p3=s.create,n3=Z.create,i3=Z.strictCreate,r3=d$.create,o3=F0.create,a3=p$.create,s3=H$.create,t3=j6.create,e3=O6.create,$X=C$.create,qX=m$.create,QX=n$.create,JX=i$.create,WX=L$.create,XX=r$.create,HX=K$.create,YX=$$.create,GX=t.create,BX=B$.create,wX=$$.createWithPreprocess,VX=R6.create,FX=()=>Cq().optional(),UX=()=>Kq().optional(),_X=()=>Iq().optional(),DX={string:($)=>a.create({...$,coerce:!0}),number:($)=>D$.create({...$,coerce:!0}),boolean:($)=>l$.create({...$,coerce:!0}),bigint:($)=>z$.create({...$,coerce:!0}),date:($)=>E$.create({...$,coerce:!0})};var zX=R;class _0{config;blacklistedTokens=new Map;constructor($){this.config=$;if(!$.secret)throw Error("JWT secret is required")}generateTokens($){let q=Math.floor(Date.now()/1000),Q=this.parseExpiration(this.config.expiresIn||"1h"),J={sub:$.sub,...$,iat:q,exp:q+Q,iss:this.config.issuer,aud:this.config.audience},W=j$.sign(J,this.config.secret,{algorithm:this.config.algorithm||"HS256"}),X={sub:$.sub,type:"refresh",iat:q,exp:q+this.parseExpiration(this.config.refreshExpiresIn||"7d"),iss:this.config.issuer,aud:this.config.audience},H=j$.sign(X,this.config.refreshSecret||this.config.secret,{algorithm:this.config.algorithm||"HS256"});return{accessToken:W,refreshToken:H,expiresIn:Q}}verifyAccessToken($){if(this.isBlacklisted($))throw Error("Token has been revoked");try{return j$.verify($,this.config.secret,{algorithms:[this.config.algorithm||"HS256"],issuer:this.config.issuer,audience:this.config.audience})}catch(q){if(q instanceof Error)throw Error(`Invalid token: ${q.message}`);throw Error("Invalid token")}}verifyRefreshToken($){if(this.isBlacklisted($))throw Error("Refresh token has been revoked");try{let q=j$.verify($,this.config.refreshSecret||this.config.secret,{algorithms:[this.config.algorithm||"HS256"],issuer:this.config.issuer,audience:this.config.audience});if(q.type!=="refresh")throw Error("Invalid refresh token type");return q}catch(q){if(q instanceof Error)throw Error(`Invalid refresh token: ${q.message}`);throw Error("Invalid refresh token")}}refreshAccessToken($){let q=this.verifyRefreshToken($);return this.blacklistToken($),this.generateTokens({sub:q.sub,...Object.fromEntries(Object.entries(q).filter(([Q])=>!["iat","exp","iss","aud","type"].includes(Q)))})}decodeToken($){try{return j$.decode($)}catch{return null}}blacklistToken($){let Q=this.decodeToken($)?.exp??Math.floor(Date.now()/1000)+3600;this.blacklistedTokens.set($,Q)}isBlacklisted($){let q=this.blacklistedTokens.get($);if(q===void 0)return!1;if(q<Math.floor(Date.now()/1000))return this.blacklistedTokens.delete($),!1;return!0}cleanupBlacklist(){let $=Math.floor(Date.now()/1000);for(let[q,Q]of this.blacklistedTokens)if(Q<$)this.blacklistedTokens.delete(q)}parseExpiration($){if(typeof $==="number")return $;let q={s:1,m:60,h:3600,d:86400,w:604800},Q=$.match(/^(\d+)([smhdw])$/);if(!Q)throw Error(`Invalid expiration format: ${$}`);let[,J,W]=Q;return parseInt(J)*q[W]}}var LX=B.object({sub:B.string(),iat:B.number().optional(),exp:B.number().optional(),iss:B.string().optional(),aud:B.string().optional()}).passthrough(),jX=B.object({username:B.string().min(1),password:B.string().min(1)}),OX=B.object({refreshToken:B.string().min(1)});w$();class M6{config;userProvider;jwtProvider;constructor($,q){this.config=$;this.userProvider=q;this.jwtProvider=new _0($)}async login($,q){let Q=await this.userProvider.findByCredentials($,q);if(!Q)throw new f("Invalid credentials");let J=this.jwtProvider.generateTokens({sub:Q.id,username:Q.username,email:Q.email,roles:Q.roles||[],permissions:Q.permissions||[]});return{user:Q,tokens:J}}async refresh($){try{return this.jwtProvider.refreshAccessToken($)}catch(q){throw new I$(q instanceof Error?q.message:"Invalid refresh token")}}async logout($,q){if(this.jwtProvider.blacklistToken($),q)this.jwtProvider.blacklistToken(q)}async verifyToken($){try{let q=this.jwtProvider.verifyAccessToken($),Q=await this.userProvider.findById(q.sub);if(!Q)throw new f("User not found");return Q}catch(q){if(q instanceof Error){if(q.message.includes("expired"))throw new S6;throw new I$(q.message)}throw new I$("Token verification failed")}}getUserFromToken($){return this.jwtProvider.verifyAccessToken($)}hasRoles($,q){let Q=$.roles||[];return q.every((J)=>Q.includes(J))}hasPermissions($,q){let Q=$.permissions||[];return q.every((J)=>Q.includes(J))}async register($){if(!this.userProvider.createUser)throw Error("UserProvider does not support user creation");let q=await this.userProvider.createUser($),Q=this.jwtProvider.generateTokens({sub:q.id,username:q.username,email:q.email,roles:q.roles||[],permissions:q.permissions||[]});return{user:q,tokens:Q}}cleanup(){this.jwtProvider.cleanupBlacklist()}getJWTProvider(){return this.jwtProvider}}class Zq{users=new Map;async findByCredentials($,q){for(let[Q,J]of this.users)if(J.username===$){if(await this.verifyPassword(q,J.passwordHash)){let{passwordHash:X,...H}=J;return H}}return null}async findById($){let q=this.users.get($);if(q){let{passwordHash:Q,...J}=q;return J}return null}async hashPassword($){return Buffer.from($).toString("base64")}async verifyPassword($,q){return await this.hashPassword($)===q}async createUser($){let q=crypto.randomUUID(),Q=await this.hashPassword($.password),J={id:q,username:$.username,email:$.email,roles:$.roles||["user"],passwordHash:Q};this.users.set(q,J);let{passwordHash:W,...X}=J;return X}}var uG=require("reflect-metadata"),_8=Symbol("route:metadata"),D8=Symbol("controller:metadata"),fq=Symbol("parameter:metadata"),Tq=Symbol("dependency:metadata"),z8=Symbol("websocket:metadata"),xq=Symbol("websocket:handler:metadata"),L8=Symbol("graphql:resolver"),E6=Symbol("graphql:field"),j8=Symbol("auth:metadata"),O8=Symbol("oauth:metadata"),N8=Symbol("roles:metadata"),R8=Symbol("permissions:metadata"),S8=Symbol("minimum-role:metadata"),M8=Symbol("resource-permission:metadata"),E8=Symbol("session:metadata"),A8=Symbol("csrf:metadata");class b{routes=new Map;controllers=new Map;routesByController=new Map;websockets=new Map;graphqlResolvers=new Map;graphqlFields=new Map;registerRoute($){let q=this.getRouteKey($.target,$.propertyKey);if(this.routes.set(q,$),!this.routesByController.has($.target))this.routesByController.set($.target,[]);this.routesByController.get($.target).push($)}registerController($,q){this.controllers.set($,q)}getRoutes(){return Array.from(this.routes.values())}getRoute($,q){let Q=this.getRouteKey($,q);return this.routes.get(Q)}getRoutesByController($){return this.routesByController.get($)||[]}getController($){return this.controllers.get($)}getControllers(){return new Map(this.controllers)}registerWebSocket($){this.websockets.set($.target,$)}getWebSockets(){return Array.from(this.websockets.values())}getWebSocket($){return this.websockets.get($)}registerGraphQLResolver($){this.graphqlResolvers.set($.target,$)}registerGraphQLField($){let q=this.getRouteKey($.target,$.propertyKey);this.graphqlFields.set(q,$)}getGraphQLResolvers(){return Array.from(this.graphqlResolvers.values())}getGraphQLResolver($){return this.graphqlResolvers.get($)}getGraphQLFields(){return Array.from(this.graphqlFields.values())}getGraphQLFieldsByResolver($){return Array.from(this.graphqlFields.values()).filter((q)=>q.target===$)}clear(){this.routes.clear(),this.controllers.clear(),this.routesByController.clear(),this.websockets.clear(),this.graphqlResolvers.clear(),this.graphqlFields.clear()}getRouteKey($,q){return`${$.name}:${q}`}static defineRoute($,q,Q){let J=this.getRouteMetadata($,q),W={...J,...Q,target:$.constructor,propertyKey:q,middleware:[...J?.middleware||[],...Q.middleware||[]],parameters:Q.parameters||J?.parameters||[],dependencies:Q.dependencies||J?.dependencies||[],responses:Q.responses||J?.responses||[],auth:Q.auth||J?.auth,oauth:Q.oauth||J?.oauth,roles:Q.roles||J?.roles,permissions:Q.permissions||J?.permissions,minimumRole:Q.minimumRole||J?.minimumRole,resourcePermission:Q.resourcePermission||J?.resourcePermission,session:Q.session||J?.session,csrf:Q.csrf||J?.csrf};Reflect.defineMetadata(_8,W,$,q)}static defineParameter($,q,Q,J){let W=this.getParameterMetadata($,q)||[];W[Q]=J,Reflect.defineMetadata(fq,W,$,q);let X=this.getRouteMetadata($,q);this.defineRoute($,q,{...X,parameters:W})}static defineDependency($,q,Q,J){let W=this.getDependencyMetadata($,q)||[];W[Q]=J,Reflect.defineMetadata(Tq,W,$,q);let X=this.getRouteMetadata($,q);this.defineRoute($,q,{...X,dependencies:W})}static defineController($,q){Reflect.defineMetadata(D8,q,$)}static getRouteMetadata($,q){return Reflect.getMetadata(_8,$,q)}static getParameterMetadata($,q){return Reflect.getMetadata(fq,$,q)}static getDependencyMetadata($,q){return Reflect.getMetadata(Tq,$,q)}static getControllerMetadata($){return Reflect.getMetadata(D8,$)}static hasControllerMetadata($){return Reflect.hasMetadata(D8,$)}static hasRouteMetadata($,q){return Reflect.hasMetadata(_8,$,q)}static getRouteMethods($){let q=new Set,Q=[],J=$.prototype;while(J&&J!==Object.prototype){for(let W of Object.getOwnPropertyNames(J)){if(W==="constructor"||q.has(W))continue;if(q.add(W),this.hasRouteMetadata(J,W))Q.push(W)}J=Object.getPrototypeOf(J)}return Q}static defineWebSocket($,q){let J={...this.getWebSocketMetadata($),...q,target:$};Reflect.defineMetadata(z8,J,$)}static defineWebSocketHandler($,q,Q){let J=this.getWebSocketMetadata($.constructor)||{};switch(Q.type){case"connect":J.onConnect=q;break;case"message":J.onMessage=q,J.messageSchema=Q.schema;break;case"disconnect":J.onDisconnect=q;break}this.defineWebSocket($.constructor,J),Reflect.defineMetadata(xq,Q,$,q)}static getWebSocketMetadata($){return Reflect.getMetadata(z8,$)}static getWebSocketHandlerMetadata($,q){return Reflect.getMetadata(xq,$,q)}static hasWebSocketMetadata($){return Reflect.hasMetadata(z8,$)}static defineGraphQLResolver($,q){Reflect.defineMetadata(L8,q,$)}static defineGraphQLField($,q,Q){Reflect.defineMetadata(E6,Q,$,q);let J=this.getGraphQLFieldsMetadata($.constructor)||[];J.push(Q),Reflect.defineMetadata(E6,J,$.constructor)}static getGraphQLResolverMetadata($){return Reflect.getMetadata(L8,$)}static getGraphQLFieldsMetadata($){return Reflect.getMetadata(E6,$)||[]}static getGraphQLFieldMetadata($,q){return Reflect.getMetadata(E6,$,q)}static hasGraphQLResolverMetadata($){return Reflect.hasMetadata(L8,$)}static hasGraphQLFieldMetadata($,q){return Reflect.hasMetadata(E6,$,q)}static defineAuth($,q,Q){Reflect.defineMetadata(j8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,auth:Q})}static getAuthMetadata($,q){return Reflect.getMetadata(j8,$,q)}static hasAuthMetadata($,q){return Reflect.hasMetadata(j8,$,q)}static defineOAuth($,q,Q){Reflect.defineMetadata(O8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,oauth:Q})}static getOAuthMetadata($,q){return Reflect.getMetadata(O8,$,q)}static hasOAuthMetadata($,q){return Reflect.hasMetadata(O8,$,q)}static defineRoles($,q,Q){Reflect.defineMetadata(N8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,roles:Q})}static definePermissions($,q,Q){Reflect.defineMetadata(R8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,permissions:Q})}static defineMinimumRole($,q,Q){Reflect.defineMetadata(S8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,minimumRole:Q})}static getRolesMetadata($,q){return Reflect.getMetadata(N8,$,q)}static getPermissionsMetadata($,q){return Reflect.getMetadata(R8,$,q)}static getMinimumRoleMetadata($,q){return Reflect.getMetadata(S8,$,q)}static hasRolesMetadata($,q){return Reflect.hasMetadata(N8,$,q)}static hasPermissionsMetadata($,q){return Reflect.hasMetadata(R8,$,q)}static hasMinimumRoleMetadata($,q){return Reflect.hasMetadata(S8,$,q)}static defineResourcePermission($,q,Q){Reflect.defineMetadata(M8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,resourcePermission:Q})}static getResourcePermissionMetadata($,q){return Reflect.getMetadata(M8,$,q)}static hasResourcePermissionMetadata($,q){return Reflect.hasMetadata(M8,$,q)}static defineSession($,q,Q){Reflect.defineMetadata(E8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,session:Q})}static defineCSRF($,q,Q){Reflect.defineMetadata(A8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,csrf:Q})}static getSessionMetadata($,q){return Reflect.getMetadata(E8,$,q)}static getCSRFMetadata($,q){return Reflect.getMetadata(A8,$,q)}static hasSessionMetadata($,q){return Reflect.hasMetadata(E8,$,q)}static hasCSRFMetadata($,q){return Reflect.hasMetadata(A8,$,q)}}function xX($){return(q,Q)=>{let J={required:!$?.optional,config:$};b.defineAuth(q,Q,J)}}function vX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"current-user",required:!1})}}function hX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"token",required:!1})}}function C8($){return async(q,Q)=>{let J=q.req.header("Authorization");if(!J||!J.startsWith("Bearer "))q.set("auth.error","Missing or invalid Authorization header"),q.set("auth.authenticated",!1);else{let W=J.substring(7);try{let X=$.verifyAccessToken(W);q.set("auth.user",X),q.set("auth.token",W),q.set("auth.authenticated",!0)}catch(X){q.set("auth.error",X instanceof Error?X.message:"Authentication failed"),q.set("auth.authenticated",!1)}}await Q()}}function T($){return $.get("auth.user")||null}function K8($){return $.get("auth.token")||null}function gX($){return $.get("auth.authenticated")===!0}function yX($){return $.get("auth.error")||null}w$();w$();class vq{config;name="auth";version="1.0.0";authService;compileExtended=!1;constructor($){this.config=$;this.authService=new M6($.jwt,$.userProvider)}async install($){let q=C8(this.authService.getJWTProvider());if($.use(q),$.getContainer().register(M6,{factory:()=>this.authService,scope:"singleton"}),this.config.enableDefaultRoutes!==!1)this.addDefaultRoutes($);this.extendRouterCompiler($)}extendRouterCompiler($){if(this.compileExtended)return;this.compileExtended=!0,$.use(async(Q,J)=>{Q.set("authService",this.authService),await J()});let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getHono(),J=$.getMetadata().getRoutes();for(let W of J){let X=b.getAuthMetadata(W.target.prototype,W.propertyKey);if(W.auth?.required||X?.required){let Y=W.auth?.config||X?.config;Q.use(W.path,async(G,w)=>{if(G.req.method!==W.method)return w();let V=G.get("auth.user"),U=G.get("auth.error");if(!V)throw new f(U||"Authentication required");if(Y?.roles?.length){if(!this.authService.hasRoles(V,Y.roles))throw new x(`Required roles: ${Y.roles.join(", ")}`)}if(Y?.permissions?.length){if(!this.authService.hasPermissions(V,Y.permissions))throw new x(`Required permissions: ${Y.permissions.join(", ")}`)}await w()})}}}}buildPath($){return $.path}pathMatches($,q){let Q=$.replace(/:([^/]+)/g,"([^/]+)");return new RegExp(`^${Q}$`).test(q)}addDefaultRoutes($){let q=this.config.routes||{};if($.post(q.login||"/auth/login",{handler:async(Q)=>{let J=await Q.req.json(),{username:W,password:X}=J;try{let H=await this.authService.login(W,X);return{success:!0,user:H.user,tokens:H.tokens}}catch(H){throw new f(H instanceof Error?H.message:"Login failed")}},schema:{body:B.object({username:B.string().min(1),password:B.string().min(1)})}}),$.post(q.refresh||"/auth/refresh",{handler:async(Q)=>{let J=await Q.req.json(),{refreshToken:W}=J;try{return{success:!0,tokens:await this.authService.refresh(W)}}catch(X){throw new f(X instanceof Error?X.message:"Token refresh failed")}},schema:{body:B.object({refreshToken:B.string().min(1)})}}),$.post(q.logout||"/auth/logout",{handler:async(Q)=>{let J=K8(Q),W=await Q.req.json(),{refreshToken:X}=W;if(J)await this.authService.logout(J,X);return{success:!0,message:"Logged out successfully"}},schema:{body:B.object({refreshToken:B.string().optional()})}}),"createUser"in this.config.userProvider)$.post(q.register||"/auth/register",{handler:async(Q)=>{let J=await Q.req.json(),{username:W,password:X,email:H}=J;try{let Y=await this.authService.register({username:W,password:X,email:H});return{success:!0,user:Y.user,tokens:Y.tokens}}catch(Y){throw new f(Y instanceof Error?Y.message:"Registration failed")}},schema:{body:B.object({username:B.string().min(1),password:B.string().min(6),email:B.string().email().optional()})}});$.get("/auth/me",{handler:async(Q)=>{let J=T(Q);if(!J)throw new f("Not authenticated");return{success:!0,user:J}}})}getAuthService(){return this.authService}}class A6{name;config;constructor($,q){this.name=$;this.config=q}getAuthUrl($,q){let Q=new URLSearchParams({client_id:this.config.clientId,redirect_uri:this.config.redirectUri,response_type:"code",state:$,scope:this.config.scopes?.join(" ")||""});if(q&&this.config.pkce)Q.set("code_challenge",q),Q.set("code_challenge_method","S256");return`${this.config.authUrl}?${Q.toString()}`}async exchangeCodeForTokens($,q){let Q=new URLSearchParams({client_id:this.config.clientId,client_secret:this.config.clientSecret,code:$,grant_type:"authorization_code",redirect_uri:this.config.redirectUri});if(q&&this.config.pkce)Q.set("code_verifier",q);let J=await fetch(this.config.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:Q.toString()});if(!J.ok){let X=await J.text();throw Error(`Token exchange failed: ${X}`)}let W=await J.json();return{accessToken:W.access_token,refreshToken:W.refresh_token,expiresIn:W.expires_in,tokenType:W.token_type||"Bearer",scope:W.scope}}async getUserInfo($){let q=await fetch(this.config.userInfoUrl,{headers:{Authorization:`Bearer ${$}`,Accept:"application/json"}});if(!q.ok){let J=await q.text();throw Error(`Failed to get user info: ${J}`)}let Q=await q.json();return this.mapUserInfo(Q)}mapUserInfo($){return{id:$.id||$.sub,email:$.email,name:$.name,username:$.login||$.preferred_username,avatar:$.avatar_url||$.picture,provider:this.name,...$}}}class hq extends A6{constructor($,q,Q){super("google",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["openid","profile","email"],authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",userInfoUrl:"https://www.googleapis.com/oauth2/v2/userinfo",pkce:!0})}mapUserInfo($){return{id:$.id,email:$.email,name:$.name,username:$.email,avatar:$.picture,provider:"google",verified:$.verified_email,locale:$.locale,raw:$}}}class gq extends A6{constructor($,q,Q){super("github",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["user:email"],authUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",userInfoUrl:"https://api.github.com/user",pkce:!1})}mapUserInfo($){return{id:$.id.toString(),email:$.email,name:$.name,username:$.login,avatar:$.avatar_url,provider:"github",company:$.company,location:$.location,bio:$.bio,raw:$}}async getUserInfo($){let q=await fetch(this.config.userInfoUrl,{headers:{Authorization:`Bearer ${$}`,Accept:"application/vnd.github.v3+json","User-Agent":"VeloceTS-OAuth"}});if(!q.ok)throw Error(`Failed to get user info: ${await q.text()}`);let Q=await q.json();if(!Q.email)try{let J=await fetch("https://api.github.com/user/emails",{headers:{Authorization:`Bearer ${$}`,Accept:"application/vnd.github.v3+json","User-Agent":"VeloceTS-OAuth"}});if(J.ok){let X=(await J.json()).find((H)=>H.primary);if(X)Q.email=X.email}}catch(J){}return this.mapUserInfo(Q)}}class yq extends A6{constructor($,q,Q,J="common"){super("microsoft",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["openid","profile","email"],authUrl:`https://login.microsoftonline.com/${J}/oauth2/v2.0/authorize`,tokenUrl:`https://login.microsoftonline.com/${J}/oauth2/v2.0/token`,userInfoUrl:"https://graph.microsoft.com/v1.0/me",pkce:!0})}mapUserInfo($){return{id:$.id,email:$.mail||$.userPrincipalName,name:$.displayName,username:$.userPrincipalName,avatar:void 0,provider:"microsoft",jobTitle:$.jobTitle,department:$.department,officeLocation:$.officeLocation,raw:$}}}class z0{static generateCodeVerifier(){let $=new Uint8Array(32);return crypto.getRandomValues($),this.base64URLEncode($)}static async generateCodeChallenge($){let Q=new TextEncoder().encode($),J=await crypto.subtle.digest("SHA-256",Q);return this.base64URLEncode(new Uint8Array(J))}static async generatePKCEChallenge(){let $=this.generateCodeVerifier(),q=await this.generateCodeChallenge($);return{codeVerifier:$,codeChallenge:q,codeChallengeMethod:"S256"}}static base64URLEncode($){return btoa(String.fromCharCode(...$)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}}class L0{states=new Map;ttl=600000;generateState($){let q=crypto.randomUUID();return this.states.set(q,{timestamp:Date.now(),data:$}),this.cleanup(),q}validateState($){let q=this.states.get($);if(!q)return{valid:!1};if(Date.now()-q.timestamp>this.ttl)return this.states.delete($),{valid:!1};return this.states.delete($),{valid:!0,data:q.data}}cleanup(){let $=Date.now();for(let[q,Q]of this.states.entries())if($-Q.timestamp>this.ttl)this.states.delete(q)}}var I8=B.object({code:B.string(),state:B.string(),error:B.string().optional(),error_description:B.string().optional()}),mX=B.object({accessToken:B.string(),refreshToken:B.string().optional(),expiresIn:B.number().optional(),tokenType:B.string(),scope:B.string().optional()}),lX=B.object({id:B.string(),email:B.string().optional(),name:B.string().optional(),username:B.string().optional(),avatar:B.string().optional(),provider:B.string()}).passthrough();function uX($){return(q,Q)=>{let J={provider:$.provider,config:$};b.defineOAuth(q,Q,J)}}function cX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"oauth-user",required:!0})}}function dX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"oauth-token",required:!0})}}function pX($){return $.get("oauth.user")||null}function nX($){return $.get("oauth.token")||null}function iX($){return $.get("oauth.authenticated")===!0}function rX($){return $.get("oauth.provider")||null}class mq{config;name="oauth";version="1.0.0";dependencies=["auth"];stateManager=new L0;pkceStore=new Map;pkceStoreTTLMs=600000;constructor($){this.config=$}async install($){this.addOAuthRoutes($),this.extendRouterCompiler($)}addOAuthRoutes($){let q=this.config.routes||{};$.get(q.login||"/auth/oauth/:provider",{handler:async(Q)=>{let J=Q.req.param("provider"),W=this.config.providers[J];if(!W)return Q.json({error:"Unknown OAuth provider"},400);let X=this.stateManager.generateState({provider:J}),H;if(this.cleanupPkceStore(),W.config.pkce){let Y=await z0.generatePKCEChallenge();this.pkceStore.set(X,{challenge:Y,expiresAt:Date.now()+this.pkceStoreTTLMs}),H=W.getAuthUrl(X,Y.codeChallenge)}else H=W.getAuthUrl(X);return Q.json({authUrl:H,state:X,provider:J})}}),$.get(q.callback||"/auth/oauth/:provider/callback",{handler:async(Q)=>{let J=Q.req.param("provider"),W=Q.req.query(),X=I8.parse(W);if(X.error)return Q.json({error:"OAuth error",description:X.error_description||X.error},400);let H=this.stateManager.validateState(X.state);if(!H.valid||H.data?.provider!==J)return Q.json({error:"Invalid state parameter"},400);let Y=this.config.providers[J];if(!Y)return Q.json({error:"Unknown OAuth provider"},400);try{let w=this.pkceStore.get(X.state)?.challenge.codeVerifier,V=await Y.exchangeCodeForTokens(X.code,w),U=await Y.getUserInfo(V.accessToken);this.pkceStore.delete(X.state);let M=null;if(this.config.userProvider)M=await this.findOrCreateUser(U);if(this.config.onUserLogin)await this.config.onUserLogin(U,M);let O=null;if(this.config.authService&&M)O=this.config.authService.getJWTProvider().generateTokens({sub:String(M.id??M.username??U.id),username:M.username,email:M.email});return Q.json({success:!0,user:M||U,oauthTokens:V,jwtTokens:O,provider:J})}catch(G){return console.error("OAuth callback error:",G),Q.json({error:"OAuth authentication failed",message:G instanceof Error?G.message:"Unknown error"},500)}}}),$.get("/auth/oauth/:provider/user",{handler:async(Q)=>{let J=Q.req.param("provider"),W=Q.req.header("Authorization");if(!W||!W.startsWith("Bearer "))return Q.json({error:"Missing OAuth access token"},401);let X=W.substring(7),H=this.config.providers[J];if(!H)return Q.json({error:"Unknown OAuth provider"},400);try{let Y=await H.getUserInfo(X);return Q.json({user:Y})}catch(Y){return Q.json({error:"Failed to get user info",message:Y instanceof Error?Y.message:"Unknown error"},400)}}})}cleanupPkceStore(){let $=Date.now();for(let[q,Q]of this.pkceStore)if(Q.expiresAt<$)this.pkceStore.delete(q)}async findOrCreateUser($){if(!this.config.userProvider)return null;let q=await this.findUserByOAuthId($.id,$.provider);if(!q&&$.email)q=await this.findUserByEmail($.email);if(!q){if(q=await this.createUserFromOAuth($),this.config.onUserCreated)await this.config.onUserCreated($)}return q}async findUserByOAuthId($,q){return null}async findUserByEmail($){return null}async createUserFromOAuth($){if(!this.config.userProvider||!("createUser"in this.config.userProvider))throw Error("User provider does not support user creation");let q={username:$.username||$.email||`${$.provider}_${$.id}`,email:$.email,password:crypto.randomUUID(),roles:["user"],oauthId:$.id,oauthProvider:$.provider,name:$.name,avatar:$.avatar};return await this.config.userProvider.createUser(q)}extendRouterCompiler($){}getProvider($){return this.config.providers[$]}getProviders(){return{...this.config.providers}}}class t${roles=new Map;hierarchy=new Map;compiledPermissions=new Map;defineRole($){if(this.roles.set($.name,$),$.inherits&&$.inherits.length>0)this.hierarchy.set($.name,$.inherits);this.compiledPermissions.clear()}defineRoles($){for(let q of $)this.defineRole(q)}getRolePermissions($){if(this.compiledPermissions.has($))return Array.from(this.compiledPermissions.get($));let q=new Set;return this.collectPermissions($,q,new Set),this.compiledPermissions.set($,q),Array.from(q)}roleHasPermission($,q){return this.getRolePermissions($).includes(q)}userHasPermission($,q){for(let Q of $)if(this.roleHasPermission(Q,q))return!0;return!1}userHasRoles($,q){return q.every((Q)=>$.includes(Q))}userHasAnyRole($,q){return q.some((Q)=>$.includes(Q))}getRolesWithPermission($){let q=[];for(let Q of this.roles.keys())if(this.roleHasPermission(Q,$))q.push(Q);return q}getRoleHierarchy($){let q=[];return this.collectParentRoles($,q,new Set),q}roleInheritsFrom($,q){return this.getRoleHierarchy($).includes(q)}getAllRoles(){return Array.from(this.roles.values())}getRole($){return this.roles.get($)}roleExists($){return this.roles.has($)}validateRoles($){let q=[],Q=[];for(let J of $)if(this.roleExists(J))q.push(J);else Q.push(J);return{valid:q,invalid:Q}}getEffectiveRoles($){let q=new Set;for(let Q of $)q.add(Q),this.getRoleHierarchy(Q).forEach((W)=>q.add(W));return Array.from(q)}compareRoleLevels($,q){let Q=this.getRole($),J=this.getRole(q),W=Q?.level??0,X=J?.level??0;return W-X}getHighestRoleLevel($){let q=0;for(let Q of $){let J=this.getRole(Q);if(J&&J.level&&J.level>q)q=J.level}return q}collectPermissions($,q,Q){if(Q.has($))throw Error(`Circular role inheritance detected: ${$}`);Q.add($);let J=this.roles.get($);if(!J)throw Error(`Role not found: ${$}`);J.permissions.forEach((X)=>q.add(X));let W=this.hierarchy.get($)||[];for(let X of W)this.collectPermissions(X,q,new Set(Q))}collectParentRoles($,q,Q){if(Q.has($))return;Q.add($);let J=this.hierarchy.get($)||[];for(let W of J)q.push(W),this.collectParentRoles(W,q,Q)}}function P8(){let $=new t$;return $.defineRoles([{name:"guest",description:"Guest user with minimal permissions",permissions:["read:public"],level:1},{name:"user",description:"Regular authenticated user",permissions:["read:own","write:own","read:public"],inherits:["guest"],level:10},{name:"moderator",description:"Moderator with content management permissions",permissions:["read:all","write:all","moderate:content"],inherits:["user"],level:50},{name:"admin",description:"Administrator with full system access",permissions:["*"],inherits:["moderator"],level:100},{name:"super-admin",description:"Super administrator with unrestricted access",permissions:["*","system:*"],inherits:["admin"],level:1000}]),$}var oX=B.object({name:B.string().min(1),description:B.string().optional(),permissions:B.array(B.string()),inherits:B.array(B.string()).optional(),level:B.number().optional()}),aX=B.object({userId:B.string(),roles:B.array(B.string())}),sX=B.object({userId:B.string(),permission:B.string()});class e${static matches($,q){if(q==="*")return!0;if(q.endsWith("*")){let Q=q.slice(0,-1);return $.startsWith(Q)}return $===q}static hasPermission($,q){return $.some((Q)=>this.matches(q,Q))}static filterByPattern($,q){return $.filter((Q)=>this.matches(Q,q))}}w$();function lq($){return(q,Q)=>{let W={config:Array.isArray($)?{roles:$,requireAll:!1,allowInherited:!0}:{requireAll:!1,allowInherited:!0,...$}};b.defineRoles(q,Q,W)}}function uq($){return(q,Q)=>{let W={config:Array.isArray($)?{permissions:$,requireAll:!1}:{requireAll:!1,...$}};b.definePermissions(q,Q,W)}}function k8($){return lq([$])}function tX($){return uq([$])}function eX(){return k8("admin")}function $H(){return k8("super-admin")}function qH($){return(q,Q)=>{b.defineMinimumRole(q,Q,{roleName:$})}}function b8($){return async(q,Q)=>{q.set("rbac",$),await Q()}}class C6{rbac;constructor($){this.rbac=$}checkRoles($,q){let Q=T($);if(!Q)throw new x("Authentication required for role check");let J=Q.roles||[],W=q.allowInherited?this.rbac.getEffectiveRoles(J):J,X;if(q.requireAll)X=q.roles.every((H)=>W.includes(H));else X=q.roles.some((H)=>W.includes(H));if(!X){let H=q.requireAll?"all":"any";throw new x(`Access denied. Required ${H} of roles: ${q.roles.join(", ")}`)}}checkPermissions($,q){let Q=T($);if(!Q)throw new x("Authentication required for permission check");let J=Q.roles||[],W=new Set;for(let Y of J)this.rbac.getRolePermissions(Y).forEach((w)=>W.add(w));let X=Array.from(W),H;if(q.requireAll)H=q.permissions.every((Y)=>e$.hasPermission(X,Y));else H=q.permissions.some((Y)=>e$.hasPermission(X,Y));if(!H){let Y=q.requireAll?"all":"any";throw new x(`Access denied. Required ${Y} of permissions: ${q.permissions.join(", ")}`)}}checkMinimumRole($,q){let Q=T($);if(!Q)throw new x("Authentication required for role level check");let J=Q.roles||[],W=this.rbac.getHighestRoleLevel(J),X=this.rbac.getRole(q);if(!X)throw Error(`Required role not found: ${q}`);let H=X.level||0;if(W<H)throw new x(`Access denied. Minimum role level required: ${q} (level ${H})`)}}function cq($){return $.get("rbac")||null}function Z8($){return T($)?.roles||[]}function dq($){let q=cq($),Q=Z8($);if(!q)return[];let J=new Set;for(let W of Q)q.getRolePermissions(W).forEach((H)=>J.add(H));return Array.from(J)}function QH($,q){return Z8($).includes(q)}function JH($,q){let Q=dq($);return e$.hasPermission(Q,q)}w$();class pq{config;name="rbac";version="1.0.0";dependencies=["auth"];rbac;guard;constructor($={}){this.config=$;if($.rbac)this.rbac=$.rbac;else if($.useDefaults!==!1)this.rbac=P8();else this.rbac=new t$;if($.roles)this.rbac.defineRoles($.roles);this.guard=new C6(this.rbac)}async install($){let q=b8(this.rbac);if($.use(q),$.getContainer().register(t$,{factory:()=>this.rbac,scope:"singleton"}),$.getContainer().register(C6,{factory:()=>this.guard,scope:"singleton"}),this.injectRouteGuards($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($)}injectRouteGuards($){let q=$.getMetadata();for(let Q of q.getRoutes())if(Q.roles||Q.permissions||Q.minimumRole){let J=this.buildRBACMiddleware(Q);q.registerRoute({...Q,middleware:[J,...Q.middleware||[]]})}}buildRBACMiddleware($){let q=this.guard,Q=$.roles?.config,J=$.permissions?.config,W=$.minimumRole;return async(X,H)=>{if(!T(X))throw new f("Authentication required");if(Q)q.checkRoles(X,Q);if(J)q.checkPermissions(X,J);if(W)q.checkMinimumRole(X,W.roleName);await H()}}addManagementRoutes($){let q=this.config.routes||{},Q=async(J,W)=>{if(!T(J))throw new f("Authentication required");await W()};$.get(q.roles||"/rbac/roles",{middleware:[Q],handler:(J)=>{let W=this.rbac.getAllRoles();return J.json({success:!0,roles:W.map((X)=>({name:X.name,description:X.description,permissions:X.permissions,inherits:X.inherits,level:X.level}))})}}),$.get("/rbac/roles/:roleName",{middleware:[Q],handler:(J)=>{let W=J.req.param("roleName"),X=this.rbac.getRole(W);if(!X)return J.json({error:"Role not found"},404);let H=this.rbac.getRolePermissions(W),Y=this.rbac.getRoleHierarchy(W);return J.json({success:!0,role:{...X,effectivePermissions:H,hierarchy:Y}})}}),$.get("/rbac/roles/:roleName/permissions",{middleware:[Q],handler:(J)=>{let W=J.req.param("roleName");if(!this.rbac.roleExists(W))return J.json({error:"Role not found"},404);let X=this.rbac.getRolePermissions(W);return J.json({success:!0,role:W,permissions:X})}}),$.post("/rbac/check-permission",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{roles:X,permission:H}=W;if(!Array.isArray(X)||!H)return J.json({error:"Invalid request body"},400);let Y=this.rbac.userHasPermission(X,H);return J.json({success:!0,hasPermission:Y,roles:X,permission:H})}}),$.post("/rbac/check-roles",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userRoles:X,requiredRoles:H,requireAll:Y=!1}=W;if(!Array.isArray(X)||!Array.isArray(H))return J.json({error:"Invalid request body"},400);let G=Y?this.rbac.userHasRoles(X,H):this.rbac.userHasAnyRole(X,H);return J.json({success:!0,hasRoles:G,userRoles:X,requiredRoles:H,requireAll:Y})}}),$.post("/rbac/effective-roles",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{roles:X}=W;if(!Array.isArray(X))return J.json({error:"Invalid request body"},400);let H=this.rbac.getEffectiveRoles(X);return J.json({success:!0,inputRoles:X,effectiveRoles:H})}}),$.post("/rbac/user-permissions",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{roles:X}=W;if(!Array.isArray(X))return J.json({error:"Invalid request body"},400);let H=new Set;for(let Y of X)if(this.rbac.roleExists(Y))this.rbac.getRolePermissions(Y).forEach((w)=>H.add(w));return J.json({success:!0,roles:X,permissions:Array.from(H)})}})}getRBACManager(){return this.rbac}getGuard(){return this.guard}}class K6{resourcePermissions=new Map;permissionPolicies=new Map;grantPermission($){let q=this.getPermissionKey($.userId,$.resource);if(!this.resourcePermissions.has(q))this.resourcePermissions.set(q,[]);this.resourcePermissions.get(q).push($)}revokePermission($,q,Q){let J=this.getPermissionKey($,q),X=(this.resourcePermissions.get(J)||[]).filter((H)=>Q?H.resourceId!==Q:!0);if(X.length===0)this.resourcePermissions.delete(J);else this.resourcePermissions.set(J,X)}hasPermission($){let{user:q,resource:Q,action:J,attributes:W}=$;if(this.checkRoleBasedPermission(q,J,Q))return!0;let X=this.getPermissionKey(q.id,Q?.constructor?.name||"unknown"),H=this.resourcePermissions.get(X)||[];for(let Y of H){if(Y.expiresAt&&Y.expiresAt<new Date)continue;if(Y.resourceId&&Q?.id!==Y.resourceId)continue;for(let G of Y.permissions)if(this.matchesPermission(G,J,Q,W)){if(G.conditions&&!this.evaluateConditions(G.conditions,$))continue;return!0}}return this.checkPermissionPolicies($)}getUserPermissions($,q,Q){let J=this.getPermissionKey($,q),W=this.resourcePermissions.get(J)||[],X=[];for(let H of W){if(H.expiresAt&&H.expiresAt<new Date)continue;if(Q&&H.resourceId&&H.resourceId!==Q)continue;X.push(...H.permissions)}return X}getUserResources($){let q=new Set;for(let[Q,J]of this.resourcePermissions.entries())if(Q.startsWith(`${$}:`)){let W=Q.substring($.length+1);q.add(W)}return Array.from(q)}definePolicy($,q){this.permissionPolicies.set($,q)}filterResources($,q,Q,J=(W)=>W.constructor.name){return $.filter((W)=>{let X={user:q,resource:W,action:Q};return this.hasPermission(X)})}filterAttributes($,q,Q,J){let W={user:q,resource:$,action:Q,attributes:J};if(!this.hasPermission(W))return[];let X=$?.constructor?.name||"unknown",H=this.getUserPermissions(q.id,X,$?.id),Y=new Set;for(let G of H)if(G.action===Q||G.action==="*")if(G.attributes)G.attributes.forEach((w)=>Y.add(w));else J.forEach((w)=>Y.add(w));return Array.from(Y)}getPermissionKey($,q){return`${$}:${q}`}checkRoleBasedPermission($,q,Q){return!1}matchesPermission($,q,Q,J){if($.action!=="*"&&$.action!==q)return!1;let W=Q?.constructor?.name||"unknown";if($.resource!=="*"&&$.resource!==W)return!1;if(J&&$.attributes){if(!J.some((H)=>$.attributes.includes(H)||$.attributes.includes("*")))return!1}return!0}evaluateConditions($,q){return $.every((Q)=>this.evaluateCondition(Q,q))}evaluateCondition($,q){let Q=this.getFieldValue($.field,q);switch($.operator){case"eq":return Q===$.value;case"ne":return Q!==$.value;case"in":return Array.isArray($.value)&&$.value.includes(Q);case"nin":return Array.isArray($.value)&&!$.value.includes(Q);case"gt":return Q>$.value;case"gte":return Q>=$.value;case"lt":return Q<$.value;case"lte":return Q<=$.value;case"contains":return String(Q).includes(String($.value));case"startsWith":return String(Q).startsWith(String($.value));case"endsWith":return String(Q).endsWith(String($.value));default:return!1}}getFieldValue($,q){let Q=$.split("."),J=q;for(let W of Q)if(J&&typeof J==="object")J=J[W];else return;return J}checkPermissionPolicies($){for(let q of this.permissionPolicies.values())if(q.evaluate($))return!0;return!1}}class j0{name="ownership";description="User can access resources they own";evaluate($){let{user:q,resource:Q}=$;if(!Q||!q)return!1;return Q.userId===q.id||Q.ownerId===q.id||Q.createdBy===q.id||Q.owner===q.id}}class O0{name="team-membership";description="User can access resources belonging to their team";evaluate($){let{user:q,resource:Q}=$;if(!Q||!q||!q.teamId)return!1;return Q.teamId===q.teamId}}class N0{name="public-resource";description="Anyone can read public resources";evaluate($){let{resource:q,action:Q}=$;if(!q||Q!=="read")return!1;return q.isPublic===!0||q.visibility==="public"}}var nq=B.object({action:B.string(),resource:B.string(),conditions:B.array(B.object({field:B.string(),operator:B.enum(["eq","ne","in","nin","gt","gte","lt","lte","contains","startsWith","endsWith"]),value:B.any()})).optional(),attributes:B.array(B.string()).optional()}),WH=B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional(),permissions:B.array(nq),grantedBy:B.string().optional(),grantedAt:B.date().optional(),expiresAt:B.date().optional()}),XH=B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()});w$();function O$($){return(q,Q)=>{let J={config:$};b.defineResourcePermission(q,Q,J)}}function HH($,q){return O$({action:"read",resource:$,attributes:q})}function YH($,q){return O$({action:"write",resource:$,attributes:q})}function GH($,q){return O$({action:"update",resource:$,attributes:q})}function BH($){return O$({action:"delete",resource:$})}function wH($="access"){return O$({action:$,conditions:[{field:"resource.userId",operator:"eq",value:"{{user.id}}"}]})}function VH($="access"){return O$({action:$,conditions:[{field:"resource.teamId",operator:"eq",value:"{{user.teamId}}"}]})}function FH(){return O$({action:"read",conditions:[{field:"resource.isPublic",operator:"eq",value:!0}]})}function UH($="read"){return(q,Q,J)=>{if(Q)b.defineParameter(q,Q,J,{index:J,type:"filtered-resource",required:!0,metadata:{action:$}})}}function _H($="read"){return(q,Q,J)=>{if(Q)b.defineParameter(q,Q,J,{index:J,type:"filtered-attributes",required:!0,metadata:{action:$}})}}function f8($){return async(q,Q)=>{q.set("permissionManager",$),await Q()}}class I6{permissionManager;constructor($){this.permissionManager=$}checkResourcePermission($,q,Q){let J=T($);if(!J)throw new x("Authentication required for permission check");let W={user:J,resource:Q,action:q.action,attributes:q.attributes};if(q.conditions)W.conditions=q.conditions.map((H)=>({...H,value:this.resolveTemplateValue(H.value,W)}));if(!this.permissionManager.hasPermission(W))throw new x(`Access denied. Required permission: ${q.action} on ${q.resource||"resource"}`)}filterResource($,q,Q){let J=T($);if(!J)return null;let W={user:J,resource:q,action:Q};return this.permissionManager.hasPermission(W)?q:null}filterResources($,q,Q){let J=T($);if(!J)return[];return this.permissionManager.filterResources(q,J,Q)}filterAttributes($,q,Q,J){let W=T($);if(!W)return[];return this.permissionManager.filterAttributes(q,W,Q,J)}resolveTemplateValue($,q){if(typeof $==="string"&&$.startsWith("{{")&&$.endsWith("}}")){let Q=$.slice(2,-2);return this.getNestedValue(q,Q)}return $}getNestedValue($,q){return q.split(".").reduce((Q,J)=>Q?.[J],$)}}function T8($){return $.get("permissionManager")||null}function iq($,q,Q,J){let W=T8($),X=T($);if(!W||!X)return!1;let H={user:X,resource:q,action:Q,attributes:J};return W.hasPermission(H)}function DH($,q,Q){let J=T8($),W=T($);if(!J||!W)return[];return J.getUserPermissions(W.id,q,Q).map((H)=>H.action)}function zH($,q,Q){return iq($,q,Q)}w$();class rq{config;name="permissions";version="1.0.0";dependencies=["auth"];permissionManager;guard;constructor($={}){this.config=$;if(this.permissionManager=$.permissionManager||new K6,$.enableDefaultPolicies!==!1)this.permissionManager.definePolicy("ownership",new j0),this.permissionManager.definePolicy("team-membership",new O0),this.permissionManager.definePolicy("public-resource",new N0);this.guard=new I6(this.permissionManager)}async install($){let q=f8(this.permissionManager);if($.use(q),$.getContainer().register(K6,{factory:()=>this.permissionManager,scope:"singleton"}),$.getContainer().register(I6,{factory:()=>this.guard,scope:"singleton"}),this.extendRouterCompiler($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($)}extendRouterCompiler($){let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getMetadata().getRoutes();for(let J of Q)if(J.resourcePermission)this.addPermissionGuards($,J)}}addPermissionGuards($,q){}addManagementRoutes($){let q=this.config.routes||{},Q=async(J,W)=>{if(!T(J))throw new f("Authentication required");await W()};$.post(q.grant||"/permissions/grant",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,resource:H,resourceId:Y,permissions:G,expiresAt:w}=W,V={userId:X,resource:H,resourceId:Y,permissions:G,grantedBy:"system",grantedAt:new Date,expiresAt:w?new Date(w):void 0};return this.permissionManager.grantPermission(V),J.json({success:!0,message:"Permission granted successfully",permission:V})},schema:{body:B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional(),permissions:B.array(B.object({action:B.string(),resource:B.string(),conditions:B.array(B.any()).optional(),attributes:B.array(B.string()).optional()})),expiresAt:B.string().optional()})}}),$.delete(q.revoke||"/permissions/revoke",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,resource:H,resourceId:Y}=W;return this.permissionManager.revokePermission(X,H,Y),J.json({success:!0,message:"Permission revoked successfully"})},schema:{body:B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional()})}}),$.post(q.check||"/permissions/check",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,action:H,resource:Y,resourceId:G,attributes:w}=W,V={user:{id:X},resource:G?{id:G}:void 0,action:H,attributes:w},U=this.permissionManager.hasPermission(V);return J.json({success:!0,hasPermission:U,context:{userId:X,action:H,resource:Y,resourceId:G,attributes:w}})},schema:{body:B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()})}}),$.get("/permissions/user/:userId/resource/:resource",{middleware:[Q],handler:(J)=>{let W=J.req.param("userId"),X=J.req.param("resource"),H=J.req.query("resourceId"),Y=this.permissionManager.getUserPermissions(W,X,H);return J.json({success:!0,userId:W,resource:X,resourceId:H,permissions:Y})}}),$.get("/permissions/user/:userId/resources",{middleware:[Q],handler:(J)=>{let W=J.req.param("userId"),X=this.permissionManager.getUserResources(W);return J.json({success:!0,userId:W,resources:X})}}),$.post("/permissions/bulk-check",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{checks:X}=W,H=X.map((Y)=>{let G={user:{id:Y.userId},resource:Y.resourceId?{id:Y.resourceId}:void 0,action:Y.action,attributes:Y.attributes},w=this.permissionManager.hasPermission(G);return{...Y,hasPermission:w}});return J.json({success:!0,results:H})},schema:{body:B.object({checks:B.array(B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()}))})}}),$.post("/permissions/filter-resources",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,action:H,resources:Y}=W,G={id:X},w=this.permissionManager.filterResources(Y,G,H);return J.json({success:!0,userId:X,action:H,totalResources:Y.length,filteredResources:w.length,resources:w})},schema:{body:B.object({userId:B.string(),action:B.string(),resources:B.array(B.any())})}})}getPermissionManager(){return this.permissionManager}getGuard(){return this.guard}}class $6{sessions=new Map;cleanupTimer;constructor($=60000){if(this.cleanupTimer=setInterval(()=>this.cleanup(),$),typeof process<"u"&&process.on){let q=()=>clearInterval(this.cleanupTimer);process.on("exit",q),process.on("SIGTERM",q),process.on("SIGINT",q)}}async get($){let q=this.sessions.get($);if(!q)return null;if(q.expiresAt&&q.expiresAt<new Date)return this.sessions.delete($),null;return q}async set($,q){this.sessions.set($,q)}async destroy($){this.sessions.delete($)}async touch($){let q=this.sessions.get($);if(q)q.updatedAt=new Date,this.sessions.set($,q)}async clear(){this.sessions.clear()}async length(){return this.sessions.size}async all(){return Array.from(this.sessions.values())}cleanup(){let $=new Date;for(let[q,Q]of this.sessions.entries())if(Q.expiresAt&&Q.expiresAt<$)this.sessions.delete(q)}}class R0{redis;prefix="sess:";constructor($,q){this.redis=$;if(q)this.prefix=q}async get($){let q=this.prefix+$,Q=await this.redis.get(q);if(!Q)return null;try{let J=JSON.parse(Q);if(J.createdAt=new Date(J.createdAt),J.updatedAt=new Date(J.updatedAt),J.expiresAt)J.expiresAt=new Date(J.expiresAt);return J}catch(J){return null}}async set($,q){let Q=this.prefix+$,J=JSON.stringify(q);if(q.expiresAt){let W=Math.floor((q.expiresAt.getTime()-Date.now())/1000);if(W>0)await this.redis.setex(Q,W,J)}else await this.redis.set(Q,J)}async destroy($){let q=this.prefix+$;await this.redis.del(q)}async touch($){let q=await this.get($);if(q)q.updatedAt=new Date,await this.set($,q)}async clear(){let $=await this.redis.keys(this.prefix+"*");if($.length>0)await this.redis.del(...$)}async length(){return(await this.redis.keys(this.prefix+"*")).length}async all(){let $=await this.redis.keys(this.prefix+"*"),q=[];for(let Q of $){let J=await this.redis.get(Q);if(J)try{let W=JSON.parse(J);if(W.createdAt=new Date(W.createdAt),W.updatedAt=new Date(W.updatedAt),W.expiresAt)W.expiresAt=new Date(W.expiresAt);q.push(W)}catch(W){}}return q}}class P6{store;config;constructor($,q){this.store=$;this.config={name:"sessionId",maxAge:86400000,secure:!1,httpOnly:!0,sameSite:"lax",path:"/",rolling:!1,genid:()=>crypto.randomUUID(),...q,domain:q.domain}}async createSession($,q={},Q){let J=this.config.genid(),W=new Date,X=Q?.maxAge||this.config.maxAge,H={id:J,userId:$,data:q,createdAt:W,updatedAt:W,expiresAt:new Date(W.getTime()+X),ipAddress:Q?.ipAddress,userAgent:Q?.userAgent,csrfToken:this.generateCSRFToken()};return await this.store.set(J,H),H}async getSession($){return await this.store.get($)}async updateSession($,q){let Q=await this.store.get($);if(!Q)return null;if(Q.data={...Q.data,...q},Q.updatedAt=new Date,this.config.rolling)Q.expiresAt=new Date(Date.now()+this.config.maxAge);return await this.store.set($,Q),Q}async touchSession($){if(this.config.rolling){let q=await this.store.get($);if(q)q.updatedAt=new Date,q.expiresAt=new Date(Date.now()+this.config.maxAge),await this.store.set($,q)}else await this.store.touch($)}async destroySession($){await this.store.destroy($)}async regenerateSession($){let q=await this.store.get($);if(!q)return null;let Q=this.config.genid(),J={...q,id:Q,updatedAt:new Date,csrfToken:this.generateCSRFToken()};return await this.store.set(Q,J),await this.store.destroy($),J}async getUserSessions($){return(await this.store.all()).filter((Q)=>Q.userId===$)}async destroyUserSessions($){let q=await this.getUserSessions($);for(let Q of q)await this.store.destroy(Q.id)}validateCSRFToken($,q){return $.csrfToken===q}generateCSRFToken(){return crypto.randomUUID()}getCookieOptions(){let $={maxAge:this.config.maxAge,secure:this.config.secure,httpOnly:this.config.httpOnly,sameSite:this.config.sameSite,path:this.config.path};if(this.config.domain)$.domain=this.config.domain;return $}getConfig(){return{...this.config}}getStore(){return this.store}}class k6{tokenStore=new Map;tokenTTL=3600000;generateToken($){let q=crypto.randomUUID(),Q=new Date(Date.now()+this.tokenTTL);return this.tokenStore.set($,{token:q,expiresAt:Q}),this.cleanup(),q}validateToken($,q){let Q=this.tokenStore.get($);if(!Q)return!1;if(Q.expiresAt<new Date)return this.tokenStore.delete($),!1;return Q.token===q}removeToken($){this.tokenStore.delete($)}cleanup(){let $=new Date;for(let[q,Q]of this.tokenStore.entries())if(Q.expiresAt<$)this.tokenStore.delete(q)}}var LH=B.object({id:B.string(),userId:B.string(),data:B.record(B.any()),createdAt:B.date(),updatedAt:B.date(),expiresAt:B.date().optional(),ipAddress:B.string().optional(),userAgent:B.string().optional(),csrfToken:B.string().optional()}),jH=B.object({name:B.string().optional(),secret:B.string(),maxAge:B.number().optional(),secure:B.boolean().optional(),httpOnly:B.boolean().optional(),sameSite:B.enum(["strict","lax","none"]).optional(),domain:B.string().optional(),path:B.string().optional(),rolling:B.boolean().optional()}),OH=B.object({userId:B.string(),data:B.record(B.any()).optional(),maxAge:B.number().optional(),ipAddress:B.string().optional(),userAgent:B.string().optional()}),NH=B.object({data:B.record(B.any())});w$();var q6=require("hono/cookie");function RH($={}){return(q,Q)=>{let J={config:$};b.defineSession(q,Q,J)}}function SH(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"current-session",required:!0})}}function MH($){return(q,Q,J)=>{if(Q)b.defineParameter(q,Q,J,{index:J,type:"session-data",required:!1,metadata:{key:$}})}}function EH(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"csrf-token",required:!0})}}function AH(){return($,q)=>{b.defineCSRF($,q,{required:!0})}}function x8($,q){return async(Q,J)=>{let W=$.getConfig(),X=q6.getCookie(Q,W.name),H=null;if(X){if(H=await $.getSession(X),H)await $.touchSession(X)}Q.set("session",H),Q.set("sessionManager",$),Q.set("csrfProtection",q),await J()}}class Z6{sessionManager;csrfProtection;constructor($,q){this.sessionManager=$;this.csrfProtection=q}checkSession($,q){let Q=q$($);if(q.required&&!Q)throw new f("Session required");if(Q&&q.csrf)this.checkCSRF($,Q)}checkCSRF($,q){if(!this.csrfProtection)throw Error("CSRF protection not configured");let Q=$.req.header("X-CSRF-Token")||$.req.query("_csrf");if(!Q)throw new x("CSRF token required");if(!this.csrfProtection.validateToken(q.id,Q))throw new x("Invalid CSRF token")}async createSession($,q,Q={}){let J=b6($);if(!J)throw Error("Session manager not available");let W=$.req.header("X-Forwarded-For")||$.req.header("X-Real-IP")||"unknown",X=$.req.header("User-Agent")||"unknown",H=await J.createSession(q,Q,{ipAddress:W,userAgent:X}),Y=J.getCookieOptions();return q6.setCookie($,J.getConfig().name,H.id,Y),$.set("session",H),H}async updateSession($,q){let Q=q$($),J=b6($);if(!Q||!J)return null;let W=await J.updateSession(Q.id,q);if(W)$.set("session",W);return W}async destroySession($){let q=q$($),Q=b6($);if(!q||!Q)return;await Q.destroySession(q.id);let J=Q.getConfig();if(q6.setCookie($,J.name,"",{...Q.getCookieOptions(),maxAge:0}),$.set("session",null),this.csrfProtection)this.csrfProtection.removeToken(q.id)}async regenerateSession($){let q=q$($),Q=b6($);if(!q||!Q)return null;let J=await Q.regenerateSession(q.id);if(J){let W=Q.getCookieOptions();if(q6.setCookie($,Q.getConfig().name,J.id,W),$.set("session",J),this.csrfProtection)this.csrfProtection.removeToken(q.id),this.csrfProtection.generateToken(J.id)}return J}generateCSRFToken($){let q=q$($);if(!q||!this.csrfProtection)return null;return this.csrfProtection.generateToken(q.id)}}function q$($){return $.get("session")||null}function b6($){return $.get("sessionManager")||null}function CH($){return $.get("csrfProtection")||null}function KH($,q){let Q=q$($);if(!Q)return null;if(q)return Q.data[q];return Q.data}function IH($){return q$($)!==null}function PH($){return q$($)?.userId||null}function kH($,q,Q){let J=q$($);if(J)J.data[q]=Q,$.set("session",J)}function bH($,q){let Q=q$($);if(Q&&q in Q.data)delete Q.data[q],$.set("session",Q)}class oq{config;name="session";version="1.0.0";sessionManager;csrfProtection;guard;compileExtended=!1;cleanupIntervalId;constructor($){this.config=$;let q;if($.store)q=$.store;else if($.storeType==="redis"&&$.redis)q=new R0($.redis);else q=new $6;if(this.sessionManager=new P6(q,$.session),$.csrf?.enabled!==!1)this.csrfProtection=new k6;this.guard=new Z6(this.sessionManager,this.csrfProtection)}async install($){let q=x8(this.sessionManager,this.csrfProtection);if($.use(q),$.getContainer().register(P6,{factory:()=>this.sessionManager,scope:"singleton"}),$.getContainer().register(Z6,{factory:()=>this.guard,scope:"singleton"}),this.csrfProtection)$.getContainer().register(k6,{factory:()=>this.csrfProtection,scope:"singleton"});if(this.extendRouterCompiler($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($);if(this.sessionManager.getStore()instanceof $6)this.setupCleanup()}extendRouterCompiler($){if(this.compileExtended)return;this.compileExtended=!0;let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getMetadata().getRoutes();for(let J of Q)if(J.session||J.csrf)this.addSessionGuards($,J)}}addSessionGuards($,q){}addManagementRoutes($){let q=this.config.routes||{};if($.post(q.create||"/session/create",{handler:async(Q)=>{let J=await Q.req.json(),{userId:W,data:X}=J,H=await this.guard.createSession(Q,W,X);return Q.json({success:!0,message:"Session created successfully",session:{id:H.id,userId:H.userId,data:H.data,createdAt:H.createdAt,expiresAt:H.expiresAt}})},schema:{body:B.object({userId:B.string(),data:B.record(B.any()).optional()})}}),$.post(q.destroy||"/session/destroy",{handler:async(Q)=>{return await this.guard.destroySession(Q),Q.json({success:!0,message:"Session destroyed successfully"})}}),$.post(q.regenerate||"/session/regenerate",{handler:async(Q)=>{let J=await this.guard.regenerateSession(Q);if(!J)return Q.json({error:"No active session to regenerate"},400);return Q.json({success:!0,message:"Session regenerated successfully",session:{id:J.id,userId:J.userId,data:J.data,createdAt:J.createdAt,expiresAt:J.expiresAt}})}}),$.get(q.data||"/session/data",{handler:(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);return Q.json({success:!0,data:J.data})}}),$.put(q.data||"/session/data",{handler:async(Q)=>{let J=await Q.req.json(),{data:W}=J,X=await this.guard.updateSession(Q,W);if(!X)return Q.json({error:"No active session to update"},400);return Q.json({success:!0,message:"Session data updated successfully",data:X.data})},schema:{body:B.object({data:B.record(B.any())})}}),this.csrfProtection)$.get(q.csrf||"/session/csrf-token",{handler:(Q)=>{let J=this.guard.generateCSRFToken(Q);if(!J)return Q.json({error:"No active session or CSRF not enabled"},400);return Q.json({success:!0,csrfToken:J})}});$.get("/session/info",{handler:(Q)=>{let J=Q.get("session");if(!J)return Q.json({success:!0,authenticated:!1,session:null});return Q.json({success:!0,authenticated:!0,session:{id:J.id,userId:J.userId,createdAt:J.createdAt,updatedAt:J.updatedAt,expiresAt:J.expiresAt,ipAddress:J.ipAddress,userAgent:J.userAgent}})}}),$.get("/session/all",{handler:async(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);let W=await this.sessionManager.getUserSessions(J.userId);return Q.json({success:!0,sessions:W.map((X)=>({id:X.id,createdAt:X.createdAt,updatedAt:X.updatedAt,expiresAt:X.expiresAt,ipAddress:X.ipAddress,userAgent:X.userAgent,current:X.id===J.id}))})}}),$.post("/session/destroy-all",{handler:async(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);return await this.sessionManager.destroyUserSessions(J.userId),Q.json({success:!0,message:"All sessions destroyed successfully"})}}),$.get("/session/stats",{handler:async(Q)=>{if(!Q.get("session"))return Q.json({error:"Authentication required"},401);let W=this.sessionManager.getStore(),X=await W.length(),H=await W.all(),Y={totalSessions:X,activeSessions:H.filter((G)=>!G.expiresAt||G.expiresAt>new Date).length,expiredSessions:H.filter((G)=>G.expiresAt&&G.expiresAt<=new Date).length,uniqueUsers:new Set(H.map((G)=>G.userId)).size};return Q.json({success:!0,stats:Y})}})}setupCleanup(){if(this.cleanupIntervalId)return;let $=900000;if(this.cleanupIntervalId=setInterval(()=>{let q=this.sessionManager.getStore();if(q instanceof $6)q.cleanup()},$),typeof process<"u"&&process.on)process.on("exit",()=>{if(this.cleanupIntervalId)clearInterval(this.cleanupIntervalId)})}getSessionManager(){return this.sessionManager}getCSRFProtection(){return this.csrfProtection}getGuard(){return this.guard}}
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
11
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
12
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
13
|
-
|
|
14
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
15
|
-
and limitations under the License.
|
|
16
|
-
***************************************************************************** */var bQ;(function($){(function(q){var Q=typeof globalThis==="object"?globalThis:typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:Y(),J=W($);if(typeof Q.Reflect<"u")J=W(Q.Reflect,J);if(q(J,Q),typeof Q.Reflect>"u")Q.Reflect=$;function W(G,V){return function(D,z){if(Object.defineProperty(G,D,{configurable:!0,writable:!0,value:z}),V)V(D,z)}}function X(){try{return Function("return this;")()}catch(G){}}function H(){try{return(0,eval)("(function() { return this; })()")}catch(G){}}function Y(){return X()||H()}})(function(q,Q){var J=Object.prototype.hasOwnProperty,W=typeof Symbol==="function",X=W&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",H=W&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",Y=typeof Object.create==="function",G={__proto__:[]}instanceof Array,V=!Y&&!G,D={create:Y?function(){return q6(Object.create(null))}:G?function(){return q6({__proto__:null})}:function(){return q6({})},has:V?function(w,F){return J.call(w,F)}:function(w,F){return F in w},get:V?function(w,F){return J.call(w,F)?w[F]:void 0}:function(w,F){return w[F]}},z=Object.getPrototypeOf(Function),Z=typeof Map==="function"&&typeof Map.prototype.entries==="function"?Map:N2(),C=typeof Set==="function"&&typeof Set.prototype.entries==="function"?Set:R2(),y=typeof WeakMap==="function"?WeakMap:E2(),p=W?Symbol.for("@reflect-metadata:registry"):void 0,o$=z2(),a0=L2(o$);function Q0(w,F,_,j){if(!f(_)){if(!O4(w))throw TypeError();if(!i(F))throw TypeError();if(!i(j)&&!f(j)&&!s$(j))throw TypeError();if(s$(j))j=void 0;return _=R$(_),w2(w,F,_,j)}else{if(!O4(w))throw TypeError();if(!M4(F))throw TypeError();return G2(w,F)}}q("decorate",Q0);function A1(w,F){function _(j,I){if(!i(j))throw TypeError();if(!f(I)&&!D2(I))throw TypeError();R4(w,F,j,I)}return _}q("metadata",A1);function $2(w,F,_,j){if(!i(_))throw TypeError();if(!f(j))j=R$(j);return R4(w,F,_,j)}q("defineMetadata",$2);function q2(w,F,_){if(!i(F))throw TypeError();if(!f(_))_=R$(_);return L4(w,F,_)}q("hasMetadata",q2);function Q2(w,F,_){if(!i(F))throw TypeError();if(!f(_))_=R$(_);return t0(w,F,_)}q("hasOwnMetadata",Q2);function J2(w,F,_){if(!i(F))throw TypeError();if(!f(_))_=R$(_);return j4(w,F,_)}q("getMetadata",J2);function W2(w,F,_){if(!i(F))throw TypeError();if(!f(_))_=R$(_);return N4(w,F,_)}q("getOwnMetadata",W2);function X2(w,F){if(!i(w))throw TypeError();if(!f(F))F=R$(F);return E4(w,F)}q("getMetadataKeys",X2);function H2(w,F){if(!i(w))throw TypeError();if(!f(F))F=R$(F);return S4(w,F)}q("getOwnMetadataKeys",H2);function Y2(w,F,_){if(!i(F))throw TypeError();if(!f(_))_=R$(_);if(!i(F))throw TypeError();if(!f(_))_=R$(_);var j=C1(F,_,!1);if(f(j))return!1;return j.OrdinaryDeleteMetadata(w,F,_)}q("deleteMetadata",Y2);function G2(w,F){for(var _=w.length-1;_>=0;--_){var j=w[_],I=j(F);if(!f(I)&&!s$(I)){if(!M4(I))throw TypeError();F=I}}return F}function w2(w,F,_,j){for(var I=w.length-1;I>=0;--I){var o=w[I],r=o(F,_,j);if(!f(r)&&!s$(r)){if(!i(r))throw TypeError();j=r}}return j}function L4(w,F,_){var j=t0(w,F,_);if(j)return!0;var I=$6(F);if(!s$(I))return L4(w,I,_);return!1}function t0(w,F,_){var j=C1(F,_,!1);if(f(j))return!1;return C4(j.OrdinaryHasOwnMetadata(w,F,_))}function j4(w,F,_){var j=t0(w,F,_);if(j)return N4(w,F,_);var I=$6(F);if(!s$(I))return j4(w,I,_);return}function N4(w,F,_){var j=C1(F,_,!1);if(f(j))return;return j.OrdinaryGetOwnMetadata(w,F,_)}function R4(w,F,_,j){var I=C1(_,j,!0);I.OrdinaryDefineOwnMetadata(w,F,_,j)}function E4(w,F){var _=S4(w,F),j=$6(w);if(j===null)return _;var I=E4(j,F);if(I.length<=0)return _;if(_.length<=0)return I;var o=new C,r=[];for(var v=0,E=_;v<E.length;v++){var O=E[v],M=o.has(O);if(!M)o.add(O),r.push(O)}for(var k=0,m=I;k<m.length;k++){var O=m[k],M=o.has(O);if(!M)o.add(O),r.push(O)}return r}function S4(w,F){var _=C1(w,F,!1);if(!_)return[];return _.OrdinaryOwnMetadataKeys(w,F)}function A4(w){if(w===null)return 1;switch(typeof w){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return w===null?1:6;default:return 6}}function f(w){return w===void 0}function s$(w){return w===null}function B2(w){return typeof w==="symbol"}function i(w){return typeof w==="object"?w!==null:typeof w==="function"}function V2(w,F){switch(A4(w)){case 0:return w;case 1:return w;case 2:return w;case 3:return w;case 4:return w;case 5:return w}var _=F===3?"string":F===5?"number":"default",j=K4(w,X);if(j!==void 0){var I=j.call(w,_);if(i(I))throw TypeError();return I}return F2(w,_==="default"?"number":_)}function F2(w,F){if(F==="string"){var _=w.toString;if(r$(_)){var j=_.call(w);if(!i(j))return j}var I=w.valueOf;if(r$(I)){var j=I.call(w);if(!i(j))return j}}else{var I=w.valueOf;if(r$(I)){var j=I.call(w);if(!i(j))return j}var o=w.toString;if(r$(o)){var j=o.call(w);if(!i(j))return j}}throw TypeError()}function C4(w){return!!w}function _2(w){return""+w}function R$(w){var F=V2(w,3);if(B2(F))return F;return _2(F)}function O4(w){return Array.isArray?Array.isArray(w):w instanceof Object?w instanceof Array:Object.prototype.toString.call(w)==="[object Array]"}function r$(w){return typeof w==="function"}function M4(w){return typeof w==="function"}function D2(w){switch(A4(w)){case 3:return!0;case 4:return!0;default:return!1}}function e0(w,F){return w===F||w!==w&&F!==F}function K4(w,F){var _=w[F];if(_===void 0||_===null)return;if(!r$(_))throw TypeError();return _}function k4(w){var F=K4(w,H);if(!r$(F))throw TypeError();var _=F.call(w);if(!i(_))throw TypeError();return _}function I4(w){return w.value}function b4(w){var F=w.next();return F.done?!1:F}function P4(w){var F=w.return;if(F)F.call(w)}function $6(w){var F=Object.getPrototypeOf(w);if(typeof w!=="function"||w===z)return F;if(F!==z)return F;var _=w.prototype,j=_&&Object.getPrototypeOf(_);if(j==null||j===Object.prototype)return F;var I=j.constructor;if(typeof I!=="function")return F;if(I===w)return F;return I}function U2(){var w;if(!f(p)&&typeof Q.Reflect<"u"&&!(p in Q.Reflect)&&typeof Q.Reflect.defineMetadata==="function")w=j2(Q.Reflect);var F,_,j,I=new y,o={registerProvider:r,getProvider:E,setProvider:M};return o;function r(k){if(!Object.isExtensible(o))throw Error("Cannot add provider to a frozen registry.");switch(!0){case w===k:break;case f(F):F=k;break;case F===k:break;case f(_):_=k;break;case _===k:break;default:if(j===void 0)j=new C;j.add(k);break}}function v(k,m){if(!f(F)){if(F.isProviderFor(k,m))return F;if(!f(_)){if(_.isProviderFor(k,m))return F;if(!f(j)){var u=k4(j);while(!0){var s=b4(u);if(!s)return;var V$=I4(s);if(V$.isProviderFor(k,m))return P4(u),V$}}}}if(!f(w)&&w.isProviderFor(k,m))return w;return}function E(k,m){var u=I.get(k),s;if(!f(u))s=u.get(m);if(!f(s))return s;if(s=v(k,m),!f(s)){if(f(u))u=new Z,I.set(k,u);u.set(m,s)}return s}function O(k){if(f(k))throw TypeError();return F===k||_===k||!f(j)&&j.has(k)}function M(k,m,u){if(!O(u))throw Error("Metadata provider not registered.");var s=E(k,m);if(s!==u){if(!f(s))return!1;var V$=I.get(k);if(f(V$))V$=new Z,I.set(k,V$);V$.set(m,u)}return!0}}function z2(){var w;if(!f(p)&&i(Q.Reflect)&&Object.isExtensible(Q.Reflect))w=Q.Reflect[p];if(f(w))w=U2();if(!f(p)&&i(Q.Reflect)&&Object.isExtensible(Q.Reflect))Object.defineProperty(Q.Reflect,p,{enumerable:!1,configurable:!1,writable:!1,value:w});return w}function L2(w){var F=new y,_={isProviderFor:function(O,M){var k=F.get(O);if(f(k))return!1;return k.has(M)},OrdinaryDefineOwnMetadata:r,OrdinaryHasOwnMetadata:I,OrdinaryGetOwnMetadata:o,OrdinaryOwnMetadataKeys:v,OrdinaryDeleteMetadata:E};return o$.registerProvider(_),_;function j(O,M,k){var m=F.get(O),u=!1;if(f(m)){if(!k)return;m=new Z,F.set(O,m),u=!0}var s=m.get(M);if(f(s)){if(!k)return;if(s=new Z,m.set(M,s),!w.setProvider(O,M,_)){if(m.delete(M),u)F.delete(O);throw Error("Wrong provider for target.")}}return s}function I(O,M,k){var m=j(M,k,!1);if(f(m))return!1;return C4(m.has(O))}function o(O,M,k){var m=j(M,k,!1);if(f(m))return;return m.get(O)}function r(O,M,k,m){var u=j(k,m,!0);u.set(O,M)}function v(O,M){var k=[],m=j(O,M,!1);if(f(m))return k;var u=m.keys(),s=k4(u),V$=0;while(!0){var Z4=b4(s);if(!Z4)return k.length=V$,k;var S2=I4(Z4);try{k[V$]=S2}catch(A2){try{P4(s)}finally{throw A2}}V$++}}function E(O,M,k){var m=j(M,k,!1);if(f(m))return!1;if(!m.delete(O))return!1;if(m.size===0){var u=F.get(M);if(!f(u)){if(u.delete(k),u.size===0)F.delete(u)}}return!0}}function j2(w){var{defineMetadata:F,hasOwnMetadata:_,getOwnMetadata:j,getOwnMetadataKeys:I,deleteMetadata:o}=w,r=new y,v={isProviderFor:function(E,O){var M=r.get(E);if(!f(M)&&M.has(O))return!0;if(I(E,O).length){if(f(M))M=new C,r.set(E,M);return M.add(O),!0}return!1},OrdinaryDefineOwnMetadata:F,OrdinaryHasOwnMetadata:_,OrdinaryGetOwnMetadata:j,OrdinaryOwnMetadataKeys:I,OrdinaryDeleteMetadata:o};return v}function C1(w,F,_){var j=o$.getProvider(w,F);if(!f(j))return j;if(_){if(o$.setProvider(w,F,a0))return a0;throw Error("Illegal state.")}return}function N2(){var w={},F=[],_=function(){function v(E,O,M){this._index=0,this._keys=E,this._values=O,this._selector=M}return v.prototype["@@iterator"]=function(){return this},v.prototype[H]=function(){return this},v.prototype.next=function(){var E=this._index;if(E>=0&&E<this._keys.length){var O=this._selector(this._keys[E],this._values[E]);if(E+1>=this._keys.length)this._index=-1,this._keys=F,this._values=F;else this._index++;return{value:O,done:!1}}return{value:void 0,done:!0}},v.prototype.throw=function(E){if(this._index>=0)this._index=-1,this._keys=F,this._values=F;throw E},v.prototype.return=function(E){if(this._index>=0)this._index=-1,this._keys=F,this._values=F;return{value:E,done:!0}},v}(),j=function(){function v(){this._keys=[],this._values=[],this._cacheKey=w,this._cacheIndex=-2}return Object.defineProperty(v.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),v.prototype.has=function(E){return this._find(E,!1)>=0},v.prototype.get=function(E){var O=this._find(E,!1);return O>=0?this._values[O]:void 0},v.prototype.set=function(E,O){var M=this._find(E,!0);return this._values[M]=O,this},v.prototype.delete=function(E){var O=this._find(E,!1);if(O>=0){var M=this._keys.length;for(var k=O+1;k<M;k++)this._keys[k-1]=this._keys[k],this._values[k-1]=this._values[k];if(this._keys.length--,this._values.length--,e0(E,this._cacheKey))this._cacheKey=w,this._cacheIndex=-2;return!0}return!1},v.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=w,this._cacheIndex=-2},v.prototype.keys=function(){return new _(this._keys,this._values,I)},v.prototype.values=function(){return new _(this._keys,this._values,o)},v.prototype.entries=function(){return new _(this._keys,this._values,r)},v.prototype["@@iterator"]=function(){return this.entries()},v.prototype[H]=function(){return this.entries()},v.prototype._find=function(E,O){if(!e0(this._cacheKey,E)){this._cacheIndex=-1;for(var M=0;M<this._keys.length;M++)if(e0(this._keys[M],E)){this._cacheIndex=M;break}}if(this._cacheIndex<0&&O)this._cacheIndex=this._keys.length,this._keys.push(E),this._values.push(void 0);return this._cacheIndex},v}();return j;function I(v,E){return v}function o(v,E){return E}function r(v,E){return[v,E]}}function R2(){var w=function(){function F(){this._map=new Z}return Object.defineProperty(F.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),F.prototype.has=function(_){return this._map.has(_)},F.prototype.add=function(_){return this._map.set(_,_),this},F.prototype.delete=function(_){return this._map.delete(_)},F.prototype.clear=function(){this._map.clear()},F.prototype.keys=function(){return this._map.keys()},F.prototype.values=function(){return this._map.keys()},F.prototype.entries=function(){return this._map.entries()},F.prototype["@@iterator"]=function(){return this.keys()},F.prototype[H]=function(){return this.keys()},F}();return w}function E2(){var w=16,F=D.create(),_=j();return function(){function E(){this._key=j()}return E.prototype.has=function(O){var M=I(O,!1);return M!==void 0?D.has(M,this._key):!1},E.prototype.get=function(O){var M=I(O,!1);return M!==void 0?D.get(M,this._key):void 0},E.prototype.set=function(O,M){var k=I(O,!0);return k[this._key]=M,this},E.prototype.delete=function(O){var M=I(O,!1);return M!==void 0?delete M[this._key]:!1},E.prototype.clear=function(){this._key=j()},E}();function j(){var E;do E="@@WeakMap@@"+v();while(D.has(F,E));return F[E]=!0,E}function I(E,O){if(!J.call(E,_)){if(!O)return;Object.defineProperty(E,_,{value:D.create()})}return E[_]}function o(E,O){for(var M=0;M<O;++M)E[M]=Math.random()*255|0;return E}function r(E){if(typeof Uint8Array==="function"){var O=new Uint8Array(E);if(typeof crypto<"u")crypto.getRandomValues(O);else if(typeof msCrypto<"u")msCrypto.getRandomValues(O);else o(O,E);return O}return o(Array(E),E)}function v(){var E=r(w);E[6]=E[6]&79|64,E[8]=E[8]&191|128;var O="";for(var M=0;M<w;++M){var k=E[M];if(M===4||M===6||M===8)O+="-";if(k<16)O+="0";O+=k.toString(16).toLowerCase()}return O}}function q6(w){return w.__=void 0,delete w.__,w}})})(bQ||(bQ={}))});var iY=($)=>{let q=$.split("/");if(q[0]==="")q.shift();return q},RV=($)=>{let{groups:q,path:Q}=oY($),J=iY(Q);return sY(J,q)},oY=($)=>{let q=[];return $=$.replace(/\{[^}]+\}/g,(Q,J)=>{let W=`@${J}`;return q.push([W,Q]),W}),{groups:q,path:$}},sY=($,q)=>{for(let Q=q.length-1;Q>=0;Q--){let[J]=q[Q];for(let W=$.length-1;W>=0;W--)if($[W].includes(J)){$[W]=$[W].replace(J,q[Q][1]);break}}return $},i0,EV=($,q)=>{if($==="*")return"*";let Q=$.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(Q){let J=`${$}#${q}`;if(!i0[J])if(Q[2])i0[J]=q&&q[0]!==":"&&q[0]!=="*"?[J,Q[1],new RegExp(`^${Q[2]}(?=/${q})`)]:[$,Q[1],new RegExp(`^${Q[2]}$`)];else i0[J]=[$,Q[1],!0];return i0[J]}return null},o0=($,q)=>{try{return q($)}catch{return $.replace(/(?:%[0-9A-Fa-f]{2})+/g,(Q)=>{try{return q(Q)}catch{return Q}})}},rY=($)=>o0($,decodeURI),aY=($)=>{let q=$.url,Q=q.indexOf("/",q.indexOf(":")+4),J=Q;for(;J<q.length;J++){let W=q.charCodeAt(J);if(W===37){let X=q.indexOf("?",J),H=q.indexOf("#",J),Y=X===-1?H===-1?void 0:H:H===-1?X:Math.min(X,H),G=q.slice(Q,Y);return rY(G.includes("%25")?G.replace(/%25/g,"%2525"):G)}else if(W===63||W===35)break}return q.slice(Q,J)},SV=($)=>{let q=aY($);return q.length>1&&q.at(-1)==="/"?q.slice(0,-1):q},tY=($,q,...Q)=>{if(Q.length)q=tY(q,...Q);return`${$?.[0]==="/"?"":"/"}${$}${q==="/"?"":`${$?.at(-1)==="/"?"":"/"}${q?.[0]==="/"?q.slice(1):q}`}`},AV=($)=>{if($.charCodeAt($.length-1)!==63||!$.includes(":"))return null;let q=$.split("/"),Q=[],J="";return q.forEach((W)=>{if(W!==""&&!/\:/.test(W))J+="/"+W;else if(/\:/.test(W))if(/\?/.test(W)){if(Q.length===0&&J==="")Q.push("/");else Q.push(J);let X=W.replace("?","");J+="/"+X,Q.push(J)}else J+="/"+W}),Q.filter((W,X,H)=>H.indexOf(W)===X)},_4=($)=>{if(!/[%+]/.test($))return $;if($.indexOf("+")!==-1)$=$.replace(/\+/g," ");return $.indexOf("%")!==-1?o0($,D4):$},oQ=($,q,Q)=>{let J;if(!Q&&q&&!/[%+]/.test(q)){let H=$.indexOf("?",8);if(H===-1)return;if(!$.startsWith(q,H+1))H=$.indexOf(`&${q}`,H+1);while(H!==-1){let Y=$.charCodeAt(H+q.length+1);if(Y===61){let G=H+q.length+2,V=$.indexOf("&",G);return _4($.slice(G,V===-1?void 0:V))}else if(Y==38||isNaN(Y))return"";H=$.indexOf(`&${q}`,H+1)}if(J=/[%+]/.test($),!J)return}let W={};J??=/[%+]/.test($);let X=$.indexOf("?",8);while(X!==-1){let H=$.indexOf("&",X+1),Y=$.indexOf("=",X);if(Y>H&&H!==-1)Y=-1;let G=$.slice(X+1,Y===-1?H===-1?void 0:H:Y);if(J)G=_4(G);if(X=H,G==="")continue;let V;if(Y===-1)V="";else if(V=$.slice(Y+1,H===-1?void 0:H),J)V=_4(V);if(Q){if(!(W[G]&&Array.isArray(W[G])))W[G]=[];W[G].push(V)}else W[G]??=V}return q?W[q]:W},CV,OV=($,q)=>{return oQ($,q,!0)},D4;var sQ=J0(()=>{i0={},CV=oQ,D4=decodeURIComponent});var _G={};Q6(_G,{setSessionData:()=>VG,removeSessionData:()=>FG,isSessionAuthenticated:()=>wG,isOAuthAuthenticated:()=>NY,isAuthenticated:()=>BY,getUserRoles:()=>B4,getUserResourcePermissions:()=>lY,getUserPermissions:()=>cQ,getToken:()=>X4,getSessionUserId:()=>BG,getSessionManager:()=>$0,getSessionData:()=>GG,getRBACManager:()=>uQ,getPermissionManager:()=>F4,getOAuthUser:()=>LY,getOAuthToken:()=>jY,getOAuthProvider:()=>RY,getCurrentUser:()=>$$,getCurrentSession:()=>N$,getCSRFProtection:()=>YG,getAuthError:()=>VY,createSessionMiddleware:()=>z4,createRBACMiddleware:()=>w4,createPermissionMiddleware:()=>V4,createDefaultRBAC:()=>Y4,createAuthMiddleware:()=>W4,checkUserRole:()=>kY,checkUserPermission:()=>IY,checkResourceAccess:()=>pQ,canUserAccess:()=>uY,UpdateSessionSchema:()=>pY,TokenRevokedException:()=>n6,TokenPayloadSchema:()=>cH,TokenExpiredException:()=>n1,Token:()=>wY,TeamOnly:()=>vY,TeamMembershipPolicy:()=>d0,SuperAdminOnly:()=>MY,SessionPlugin:()=>eQ,SessionManager:()=>t1,SessionGuard:()=>q0,SessionDataSchema:()=>cY,SessionData:()=>WG,SessionConfigSchema:()=>dY,Session:()=>QG,Roles:()=>yQ,RoleSchema:()=>EY,RoleAssignmentSchema:()=>SY,ResourcePermissionSchema:()=>bY,ResourcePermissionCheckSchema:()=>PY,RequireRole:()=>G4,RequirePermission:()=>CY,RequireCSRF:()=>HG,RefreshRequestSchema:()=>nH,RedisSessionStore:()=>p0,RBACPlugin:()=>dQ,RBACManager:()=>R1,RBACGuard:()=>s1,PublicResourcePolicy:()=>n0,PublicRead:()=>gY,Permissions:()=>lQ,PermissionSchema:()=>nQ,PermissionPlugin:()=>iQ,PermissionMatcher:()=>E1,PermissionManager:()=>r1,PermissionGuard:()=>a1,PermissionCheckSchema:()=>AY,PKCEUtils:()=>l0,OwnershipPolicy:()=>c0,OwnerOnly:()=>hY,OAuthUserSchema:()=>_Y,OAuthUser:()=>UY,OAuthTokensSchema:()=>FY,OAuthToken:()=>zY,OAuthStateManager:()=>u0,OAuthPlugin:()=>mQ,OAuthCallbackSchema:()=>H4,OAuth:()=>DY,MinimumRole:()=>KY,MicrosoftOAuthProvider:()=>gQ,MemorySessionStore:()=>S1,LoginRequestSchema:()=>dH,JWTProvider:()=>m0,InvalidTokenException:()=>i$,InMemoryUserProvider:()=>IQ,GoogleOAuthProvider:()=>hQ,GitHubOAuthProvider:()=>vQ,FilteredResource:()=>mY,FilteredAttributes:()=>yY,CurrentUser:()=>GY,CurrentSession:()=>JG,CreateSessionSchema:()=>nY,CanWrite:()=>fY,CanUpdate:()=>xY,CanRead:()=>ZY,CanDelete:()=>TY,CanAccess:()=>g$,CSRFToken:()=>XG,CSRFProtection:()=>e1,BaseOAuthProvider:()=>o1,AuthorizationException:()=>t,AuthenticationException:()=>a,AuthService:()=>p1,AuthPlugin:()=>TQ,Auth:()=>YY,AdminOnly:()=>OY});module.exports=I2(_G);var h$=v4(DQ(),1);var B={};Q6(B,{void:()=>zH,util:()=>g,unknown:()=>DH,union:()=>RH,undefined:()=>VH,tuple:()=>AH,transformer:()=>fH,symbol:()=>BH,string:()=>AQ,strictObject:()=>NH,setErrorMap:()=>TX,set:()=>MH,record:()=>CH,quotelessJson:()=>fX,promise:()=>ZH,preprocess:()=>hH,pipeline:()=>vH,ostring:()=>gH,optional:()=>xH,onumber:()=>mH,oboolean:()=>yH,objectUtil:()=>l6,object:()=>jH,number:()=>CQ,nullable:()=>TH,null:()=>FH,never:()=>UH,nativeEnum:()=>PH,nan:()=>YH,map:()=>OH,makeIssue:()=>g1,literal:()=>IH,lazy:()=>kH,late:()=>XH,isValid:()=>P$,isDirty:()=>h0,isAsync:()=>H1,isAborted:()=>T0,intersection:()=>SH,instanceof:()=>HH,getParsedType:()=>A$,getErrorMap:()=>X1,function:()=>KH,enum:()=>bH,effect:()=>fH,discriminatedUnion:()=>EH,defaultErrorMap:()=>M$,datetimeRegex:()=>RQ,date:()=>wH,custom:()=>SQ,coerce:()=>lH,boolean:()=>OQ,bigint:()=>GH,array:()=>LH,any:()=>_H,addIssueToContext:()=>R,ZodVoid:()=>y1,ZodUnknown:()=>Z$,ZodUnion:()=>F1,ZodUndefined:()=>B1,ZodType:()=>h,ZodTuple:()=>O$,ZodTransformer:()=>j$,ZodSymbol:()=>m1,ZodString:()=>D$,ZodSet:()=>n$,ZodSchema:()=>h,ZodRecord:()=>l1,ZodReadonly:()=>N1,ZodPromise:()=>p$,ZodPipeline:()=>d1,ZodParsedType:()=>L,ZodOptional:()=>z$,ZodObject:()=>n,ZodNumber:()=>f$,ZodNullable:()=>k$,ZodNull:()=>V1,ZodNever:()=>C$,ZodNativeEnum:()=>z1,ZodNaN:()=>c1,ZodMap:()=>u1,ZodLiteral:()=>U1,ZodLazy:()=>D1,ZodIssueCode:()=>U,ZodIntersection:()=>_1,ZodFunction:()=>G1,ZodFirstPartyTypeKind:()=>P,ZodError:()=>H$,ZodEnum:()=>T$,ZodEffects:()=>j$,ZodDiscriminatedUnion:()=>v0,ZodDefault:()=>L1,ZodDate:()=>c$,ZodCatch:()=>j1,ZodBranded:()=>g0,ZodBoolean:()=>w1,ZodBigInt:()=>x$,ZodArray:()=>U$,ZodAny:()=>d$,Schema:()=>h,ParseStatus:()=>e,OK:()=>J$,NEVER:()=>uH,INVALID:()=>b,EMPTY_PATH:()=>hX,DIRTY:()=>u$,BRAND:()=>WH});var g;(function($){$.assertEqual=(W)=>{};function q(W){}$.assertIs=q;function Q(W){throw Error()}$.assertNever=Q,$.arrayToEnum=(W)=>{let X={};for(let H of W)X[H]=H;return X},$.getValidEnumValues=(W)=>{let X=$.objectKeys(W).filter((Y)=>typeof W[W[Y]]!=="number"),H={};for(let Y of X)H[Y]=W[Y];return $.objectValues(H)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(X){return W[X]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let X=[];for(let H in W)if(Object.prototype.hasOwnProperty.call(W,H))X.push(H);return X},$.find=(W,X)=>{for(let H of W)if(X(H))return H;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function J(W,X=" | "){return W.map((H)=>typeof H==="string"?`'${H}'`:H).join(X)}$.joinValues=J,$.jsonStringifyReplacer=(W,X)=>{if(typeof X==="bigint")return X.toString();return X}})(g||(g={}));var l6;(function($){$.mergeShapes=(q,Q)=>{return{...q,...Q}}})(l6||(l6={}));var L=g.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),A$=($)=>{switch(typeof $){case"undefined":return L.undefined;case"string":return L.string;case"number":return Number.isNaN($)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":if(Array.isArray($))return L.array;if($===null)return L.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return L.promise;if(typeof Map<"u"&&$ instanceof Map)return L.map;if(typeof Set<"u"&&$ instanceof Set)return L.set;if(typeof Date<"u"&&$ instanceof Date)return L.date;return L.object;default:return L.unknown}};var U=g.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),fX=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class H$ extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,q);else this.__proto__=q;this.name="ZodError",this.issues=$}format($){let q=$||function(W){return W.message},Q={_errors:[]},J=(W)=>{for(let X of W.issues)if(X.code==="invalid_union")X.unionErrors.map(J);else if(X.code==="invalid_return_type")J(X.returnTypeError);else if(X.code==="invalid_arguments")J(X.argumentsError);else if(X.path.length===0)Q._errors.push(q(X));else{let H=Q,Y=0;while(Y<X.path.length){let G=X.path[Y];if(Y!==X.path.length-1)H[G]=H[G]||{_errors:[]};else H[G]=H[G]||{_errors:[]},H[G]._errors.push(q(X));H=H[G],Y++}}};return J(this),Q}static assert($){if(!($ instanceof H$))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,g.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(q)=>q.message){let q={},Q=[];for(let J of this.issues)if(J.path.length>0){let W=J.path[0];q[W]=q[W]||[],q[W].push($(J))}else Q.push($(J));return{formErrors:Q,fieldErrors:q}}get formErrors(){return this.flatten()}}H$.create=($)=>{return new H$($)};var xX=($,q)=>{let Q;switch($.code){case U.invalid_type:if($.received===L.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case U.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,g.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:Q=`Unrecognized key(s) in object: ${g.joinValues($.keys,", ")}`;break;case U.invalid_union:Q="Invalid input";break;case U.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${g.joinValues($.options)}`;break;case U.invalid_enum_value:Q=`Invalid enum value. Expected ${g.joinValues($.options)}, received '${$.received}'`;break;case U.invalid_arguments:Q="Invalid function arguments";break;case U.invalid_return_type:Q="Invalid function return type";break;case U.invalid_date:Q="Invalid date";break;case U.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else g.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case U.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case U.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case U.custom:Q="Invalid input";break;case U.invalid_intersection_types:Q="Intersection results could not be merged";break;case U.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case U.not_finite:Q="Number must be finite";break;default:Q=q.defaultError,g.assertNever($)}return{message:Q}},M$=xX;var UQ=M$;function TX($){UQ=$}function X1(){return UQ}var g1=($)=>{let{data:q,path:Q,errorMaps:J,issueData:W}=$,X=[...Q,...W.path||[]],H={...W,path:X};if(W.message!==void 0)return{...W,path:X,message:W.message};let Y="",G=J.filter((V)=>!!V).slice().reverse();for(let V of G)Y=V(H,{data:q,defaultError:Y}).message;return{...W,path:X,message:Y}},hX=[];function R($,q){let Q=X1(),J=g1({issueData:q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===M$?void 0:M$].filter((W)=>!!W)});$.common.issues.push(J)}class e{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,q){let Q=[];for(let J of q){if(J.status==="aborted")return b;if(J.status==="dirty")$.dirty();Q.push(J.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,q){let Q=[];for(let J of q){let W=await J.key,X=await J.value;Q.push({key:W,value:X})}return e.mergeObjectSync($,Q)}static mergeObjectSync($,q){let Q={};for(let J of q){let{key:W,value:X}=J;if(W.status==="aborted")return b;if(X.status==="aborted")return b;if(W.status==="dirty")$.dirty();if(X.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof X.value<"u"||J.alwaysSet))Q[W.value]=X.value}return{status:$.value,value:Q}}}var b=Object.freeze({status:"aborted"}),u$=($)=>({status:"dirty",value:$}),J$=($)=>({status:"valid",value:$}),T0=($)=>$.status==="aborted",h0=($)=>$.status==="dirty",P$=($)=>$.status==="valid",H1=($)=>typeof Promise<"u"&&$ instanceof Promise;var K;(function($){$.errToObj=(q)=>typeof q==="string"?{message:q}:q||{},$.toString=(q)=>typeof q==="string"?q:q?.message})(K||(K={}));class L${constructor($,q,Q,J){this._cachedPath=[],this.parent=$,this.data=q,this._path=Q,this._key=J}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var zQ=($,q)=>{if(P$(q))return{success:!0,data:q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new H$($.common.issues);return this._error=Q,this._error}}}};function T($){if(!$)return{};let{errorMap:q,invalid_type_error:Q,required_error:J,description:W}=$;if(q&&(Q||J))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(q)return{errorMap:q,description:W};return{errorMap:(H,Y)=>{let{message:G}=$;if(H.code==="invalid_enum_value")return{message:G??Y.defaultError};if(typeof Y.data>"u")return{message:G??J??Y.defaultError};if(H.code!=="invalid_type")return{message:Y.defaultError};return{message:G??Q??Y.defaultError}},description:W}}class h{get description(){return this._def.description}_getType($){return A$($.data)}_getOrReturnCtx($,q){return q||{common:$.parent.common,data:$.data,parsedType:A$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new e,ctx:{common:$.parent.common,data:$.data,parsedType:A$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let q=this._parse($);if(H1(q))throw Error("Synchronous parse encountered promise.");return q}_parseAsync($){let q=this._parse($);return Promise.resolve(q)}parse($,q){let Q=this.safeParse($,q);if(Q.success)return Q.data;throw Q.error}safeParse($,q){let Q={common:{issues:[],async:q?.async??!1,contextualErrorMap:q?.errorMap},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:A$($)},J=this._parseSync({data:$,path:Q.path,parent:Q});return zQ(Q,J)}"~validate"($){let q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:A$($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:q});return P$(Q)?{value:Q.value}:{issues:q.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:q}).then((Q)=>P$(Q)?{value:Q.value}:{issues:q.common.issues})}async parseAsync($,q){let Q=await this.safeParseAsync($,q);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,q){let Q={common:{issues:[],contextualErrorMap:q?.errorMap,async:!0},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:A$($)},J=this._parse({data:$,path:Q.path,parent:Q}),W=await(H1(J)?J:Promise.resolve(J));return zQ(Q,W)}refine($,q){let Q=(J)=>{if(typeof q==="string"||typeof q>"u")return{message:q};else if(typeof q==="function")return q(J);else return q};return this._refinement((J,W)=>{let X=$(J),H=()=>W.addIssue({code:U.custom,...Q(J)});if(typeof Promise<"u"&&X instanceof Promise)return X.then((Y)=>{if(!Y)return H(),!1;else return!0});if(!X)return H(),!1;else return!0})}refinement($,q){return this._refinement((Q,J)=>{if(!$(Q))return J.addIssue(typeof q==="function"?q(Q,J):q),!1;else return!0})}_refinement($){return new j$({schema:this,typeName:P.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(q)=>this["~validate"](q)}}optional(){return z$.create(this,this._def)}nullable(){return k$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return U$.create(this)}promise(){return p$.create(this,this._def)}or($){return F1.create([this,$],this._def)}and($){return _1.create(this,$,this._def)}transform($){return new j$({...T(this._def),schema:this,typeName:P.ZodEffects,effect:{type:"transform",transform:$}})}default($){let q=typeof $==="function"?$:()=>$;return new L1({...T(this._def),innerType:this,defaultValue:q,typeName:P.ZodDefault})}brand(){return new g0({typeName:P.ZodBranded,type:this,...T(this._def)})}catch($){let q=typeof $==="function"?$:()=>$;return new j1({...T(this._def),innerType:this,catchValue:q,typeName:P.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return d1.create(this,$)}readonly(){return N1.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var vX=/^c[^\s-]{8,}$/i,gX=/^[0-9a-z]+$/,mX=/^[0-9A-HJKMNP-TV-Z]{26}$/i,yX=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,lX=/^[a-z0-9_-]{21}$/i,uX=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,cX=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,dX=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,nX="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",u6,pX=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,iX=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,oX=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,sX=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,rX=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,aX=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jQ="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",tX=new RegExp(`^${jQ}$`);function NQ($){let q="[0-5]\\d";if($.precision)q=`${q}\\.\\d{${$.precision}}`;else if($.precision==null)q=`${q}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${q})${Q}`}function eX($){return new RegExp(`^${NQ($)}$`)}function RQ($){let q=`${jQ}T${NQ($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return q=`${q}(${Q.join("|")})`,new RegExp(`^${q}$`)}function $H($,q){if((q==="v4"||!q)&&pX.test($))return!0;if((q==="v6"||!q)&&oX.test($))return!0;return!1}function qH($,q){if(!uX.test($))return!1;try{let[Q]=$.split(".");if(!Q)return!1;let J=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),W=JSON.parse(atob(J));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(q&&W.alg!==q)return!1;return!0}catch{return!1}}function QH($,q){if((q==="v4"||!q)&&iX.test($))return!0;if((q==="v6"||!q)&&sX.test($))return!0;return!1}class D$ extends h{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==L.string){let W=this._getOrReturnCtx($);return R(W,{code:U.invalid_type,expected:L.string,received:W.parsedType}),b}let Q=new e,J=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)J=this._getOrReturnCtx($,J),R(J,{code:U.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="max"){if($.data.length>W.value)J=this._getOrReturnCtx($,J),R(J,{code:U.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="length"){let X=$.data.length>W.value,H=$.data.length<W.value;if(X||H){if(J=this._getOrReturnCtx($,J),X)R(J,{code:U.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(H)R(J,{code:U.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});Q.dirty()}}else if(W.kind==="email"){if(!dX.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"email",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="emoji"){if(!u6)u6=new RegExp(nX,"u");if(!u6.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"emoji",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="uuid"){if(!yX.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"uuid",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="nanoid"){if(!lX.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"nanoid",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid"){if(!vX.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"cuid",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid2"){if(!gX.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"cuid2",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ulid"){if(!mX.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"ulid",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{J=this._getOrReturnCtx($,J),R(J,{validation:"url",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"regex",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))J=this._getOrReturnCtx($,J),R(J,{code:U.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),Q.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))J=this._getOrReturnCtx($,J),R(J,{code:U.invalid_string,validation:{startsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))J=this._getOrReturnCtx($,J),R(J,{code:U.invalid_string,validation:{endsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="datetime"){if(!RQ(W).test($.data))J=this._getOrReturnCtx($,J),R(J,{code:U.invalid_string,validation:"datetime",message:W.message}),Q.dirty()}else if(W.kind==="date"){if(!tX.test($.data))J=this._getOrReturnCtx($,J),R(J,{code:U.invalid_string,validation:"date",message:W.message}),Q.dirty()}else if(W.kind==="time"){if(!eX(W).test($.data))J=this._getOrReturnCtx($,J),R(J,{code:U.invalid_string,validation:"time",message:W.message}),Q.dirty()}else if(W.kind==="duration"){if(!cX.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"duration",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ip"){if(!$H($.data,W.version))J=this._getOrReturnCtx($,J),R(J,{validation:"ip",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="jwt"){if(!qH($.data,W.alg))J=this._getOrReturnCtx($,J),R(J,{validation:"jwt",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cidr"){if(!QH($.data,W.version))J=this._getOrReturnCtx($,J),R(J,{validation:"cidr",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64"){if(!rX.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"base64",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64url"){if(!aX.test($.data))J=this._getOrReturnCtx($,J),R(J,{validation:"base64url",code:U.invalid_string,message:W.message}),Q.dirty()}else g.assertNever(W);return{status:Q.value,value:$.data}}_regex($,q,Q){return this.refinement((J)=>$.test(J),{validation:q,code:U.invalid_string,...K.errToObj(Q)})}_addCheck($){return new D$({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...K.errToObj($)})}url($){return this._addCheck({kind:"url",...K.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...K.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...K.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...K.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...K.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...K.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...K.errToObj($)})}base64($){return this._addCheck({kind:"base64",...K.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...K.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...K.errToObj($)})}ip($){return this._addCheck({kind:"ip",...K.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...K.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...K.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...K.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...K.errToObj($)})}regex($,q){return this._addCheck({kind:"regex",regex:$,...K.errToObj(q)})}includes($,q){return this._addCheck({kind:"includes",value:$,position:q?.position,...K.errToObj(q?.message)})}startsWith($,q){return this._addCheck({kind:"startsWith",value:$,...K.errToObj(q)})}endsWith($,q){return this._addCheck({kind:"endsWith",value:$,...K.errToObj(q)})}min($,q){return this._addCheck({kind:"min",value:$,...K.errToObj(q)})}max($,q){return this._addCheck({kind:"max",value:$,...K.errToObj(q)})}length($,q){return this._addCheck({kind:"length",value:$,...K.errToObj(q)})}nonempty($){return this.min(1,K.errToObj($))}trim(){return new D$({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new D$({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new D$({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxLength(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}D$.create=($)=>{return new D$({checks:[],typeName:P.ZodString,coerce:$?.coerce??!1,...T($)})};function JH($,q){let Q=($.toString().split(".")[1]||"").length,J=(q.toString().split(".")[1]||"").length,W=Q>J?Q:J,X=Number.parseInt($.toFixed(W).replace(".","")),H=Number.parseInt(q.toFixed(W).replace(".",""));return X%H/10**W}class f$ extends h{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==L.number){let W=this._getOrReturnCtx($);return R(W,{code:U.invalid_type,expected:L.number,received:W.parsedType}),b}let Q=void 0,J=new e;for(let W of this._def.checks)if(W.kind==="int"){if(!g.isInteger($.data))Q=this._getOrReturnCtx($,Q),R(Q,{code:U.invalid_type,expected:"integer",received:"float",message:W.message}),J.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),R(Q,{code:U.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),R(Q,{code:U.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="multipleOf"){if(JH($.data,W.value)!==0)Q=this._getOrReturnCtx($,Q),R(Q,{code:U.not_multiple_of,multipleOf:W.value,message:W.message}),J.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),R(Q,{code:U.not_finite,message:W.message}),J.dirty()}else g.assertNever(W);return{status:J.value,value:$.data}}gte($,q){return this.setLimit("min",$,!0,K.toString(q))}gt($,q){return this.setLimit("min",$,!1,K.toString(q))}lte($,q){return this.setLimit("max",$,!0,K.toString(q))}lt($,q){return this.setLimit("max",$,!1,K.toString(q))}setLimit($,q,Q,J){return new f$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:K.toString(J)}]})}_addCheck($){return new f$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:K.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:K.toString(q)})}finite($){return this._addCheck({kind:"finite",message:K.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.toString($)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&g.isInteger($.value))}get isFinite(){let $=null,q=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(q===null||Q.value>q)q=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(q)&&Number.isFinite($)}}f$.create=($)=>{return new f$({checks:[],typeName:P.ZodNumber,coerce:$?.coerce||!1,...T($)})};class x$ extends h{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==L.bigint)return this._getInvalidInput($);let Q=void 0,J=new e;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),R(Q,{code:U.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),J.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),R(Q,{code:U.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),J.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),R(Q,{code:U.not_multiple_of,multipleOf:W.value,message:W.message}),J.dirty()}else g.assertNever(W);return{status:J.value,value:$.data}}_getInvalidInput($){let q=this._getOrReturnCtx($);return R(q,{code:U.invalid_type,expected:L.bigint,received:q.parsedType}),b}gte($,q){return this.setLimit("min",$,!0,K.toString(q))}gt($,q){return this.setLimit("min",$,!1,K.toString(q))}lte($,q){return this.setLimit("max",$,!0,K.toString(q))}lt($,q){return this.setLimit("max",$,!1,K.toString(q))}setLimit($,q,Q,J){return new x$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:K.toString(J)}]})}_addCheck($){return new x$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:K.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:K.toString(q)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}x$.create=($)=>{return new x$({checks:[],typeName:P.ZodBigInt,coerce:$?.coerce??!1,...T($)})};class w1 extends h{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==L.boolean){let Q=this._getOrReturnCtx($);return R(Q,{code:U.invalid_type,expected:L.boolean,received:Q.parsedType}),b}return J$($.data)}}w1.create=($)=>{return new w1({typeName:P.ZodBoolean,coerce:$?.coerce||!1,...T($)})};class c$ extends h{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==L.date){let W=this._getOrReturnCtx($);return R(W,{code:U.invalid_type,expected:L.date,received:W.parsedType}),b}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return R(W,{code:U.invalid_date}),b}let Q=new e,J=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)J=this._getOrReturnCtx($,J),R(J,{code:U.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),Q.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)J=this._getOrReturnCtx($,J),R(J,{code:U.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),Q.dirty()}else g.assertNever(W);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new c$({...this._def,checks:[...this._def.checks,$]})}min($,q){return this._addCheck({kind:"min",value:$.getTime(),message:K.toString(q)})}max($,q){return this._addCheck({kind:"max",value:$.getTime(),message:K.toString(q)})}get minDate(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $!=null?new Date($):null}}c$.create=($)=>{return new c$({checks:[],coerce:$?.coerce||!1,typeName:P.ZodDate,...T($)})};class m1 extends h{_parse($){if(this._getType($)!==L.symbol){let Q=this._getOrReturnCtx($);return R(Q,{code:U.invalid_type,expected:L.symbol,received:Q.parsedType}),b}return J$($.data)}}m1.create=($)=>{return new m1({typeName:P.ZodSymbol,...T($)})};class B1 extends h{_parse($){if(this._getType($)!==L.undefined){let Q=this._getOrReturnCtx($);return R(Q,{code:U.invalid_type,expected:L.undefined,received:Q.parsedType}),b}return J$($.data)}}B1.create=($)=>{return new B1({typeName:P.ZodUndefined,...T($)})};class V1 extends h{_parse($){if(this._getType($)!==L.null){let Q=this._getOrReturnCtx($);return R(Q,{code:U.invalid_type,expected:L.null,received:Q.parsedType}),b}return J$($.data)}}V1.create=($)=>{return new V1({typeName:P.ZodNull,...T($)})};class d$ extends h{constructor(){super(...arguments);this._any=!0}_parse($){return J$($.data)}}d$.create=($)=>{return new d$({typeName:P.ZodAny,...T($)})};class Z$ extends h{constructor(){super(...arguments);this._unknown=!0}_parse($){return J$($.data)}}Z$.create=($)=>{return new Z$({typeName:P.ZodUnknown,...T($)})};class C$ extends h{_parse($){let q=this._getOrReturnCtx($);return R(q,{code:U.invalid_type,expected:L.never,received:q.parsedType}),b}}C$.create=($)=>{return new C$({typeName:P.ZodNever,...T($)})};class y1 extends h{_parse($){if(this._getType($)!==L.undefined){let Q=this._getOrReturnCtx($);return R(Q,{code:U.invalid_type,expected:L.void,received:Q.parsedType}),b}return J$($.data)}}y1.create=($)=>{return new y1({typeName:P.ZodVoid,...T($)})};class U$ extends h{_parse($){let{ctx:q,status:Q}=this._processInputParams($),J=this._def;if(q.parsedType!==L.array)return R(q,{code:U.invalid_type,expected:L.array,received:q.parsedType}),b;if(J.exactLength!==null){let X=q.data.length>J.exactLength.value,H=q.data.length<J.exactLength.value;if(X||H)R(q,{code:X?U.too_big:U.too_small,minimum:H?J.exactLength.value:void 0,maximum:X?J.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:J.exactLength.message}),Q.dirty()}if(J.minLength!==null){if(q.data.length<J.minLength.value)R(q,{code:U.too_small,minimum:J.minLength.value,type:"array",inclusive:!0,exact:!1,message:J.minLength.message}),Q.dirty()}if(J.maxLength!==null){if(q.data.length>J.maxLength.value)R(q,{code:U.too_big,maximum:J.maxLength.value,type:"array",inclusive:!0,exact:!1,message:J.maxLength.message}),Q.dirty()}if(q.common.async)return Promise.all([...q.data].map((X,H)=>{return J.type._parseAsync(new L$(q,X,q.path,H))})).then((X)=>{return e.mergeArray(Q,X)});let W=[...q.data].map((X,H)=>{return J.type._parseSync(new L$(q,X,q.path,H))});return e.mergeArray(Q,W)}get element(){return this._def.type}min($,q){return new U$({...this._def,minLength:{value:$,message:K.toString(q)}})}max($,q){return new U$({...this._def,maxLength:{value:$,message:K.toString(q)}})}length($,q){return new U$({...this._def,exactLength:{value:$,message:K.toString(q)}})}nonempty($){return this.min(1,$)}}U$.create=($,q)=>{return new U$({type:$,minLength:null,maxLength:null,exactLength:null,typeName:P.ZodArray,...T(q)})};function Y1($){if($ instanceof n){let q={};for(let Q in $.shape){let J=$.shape[Q];q[Q]=z$.create(Y1(J))}return new n({...$._def,shape:()=>q})}else if($ instanceof U$)return new U$({...$._def,type:Y1($.element)});else if($ instanceof z$)return z$.create(Y1($.unwrap()));else if($ instanceof k$)return k$.create(Y1($.unwrap()));else if($ instanceof O$)return O$.create($.items.map((q)=>Y1(q)));else return $}class n extends h{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),q=g.objectKeys($);return this._cached={shape:$,keys:q},this._cached}_parse($){if(this._getType($)!==L.object){let G=this._getOrReturnCtx($);return R(G,{code:U.invalid_type,expected:L.object,received:G.parsedType}),b}let{status:Q,ctx:J}=this._processInputParams($),{shape:W,keys:X}=this._getCached(),H=[];if(!(this._def.catchall instanceof C$&&this._def.unknownKeys==="strip")){for(let G in J.data)if(!X.includes(G))H.push(G)}let Y=[];for(let G of X){let V=W[G],D=J.data[G];Y.push({key:{status:"valid",value:G},value:V._parse(new L$(J,D,J.path,G)),alwaysSet:G in J.data})}if(this._def.catchall instanceof C$){let G=this._def.unknownKeys;if(G==="passthrough")for(let V of H)Y.push({key:{status:"valid",value:V},value:{status:"valid",value:J.data[V]}});else if(G==="strict"){if(H.length>0)R(J,{code:U.unrecognized_keys,keys:H}),Q.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let V of H){let D=J.data[V];Y.push({key:{status:"valid",value:V},value:G._parse(new L$(J,D,J.path,V)),alwaysSet:V in J.data})}}if(J.common.async)return Promise.resolve().then(async()=>{let G=[];for(let V of Y){let D=await V.key,z=await V.value;G.push({key:D,value:z,alwaysSet:V.alwaysSet})}return G}).then((G)=>{return e.mergeObjectSync(Q,G)});else return e.mergeObjectSync(Q,Y)}get shape(){return this._def.shape()}strict($){return K.errToObj,new n({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(q,Q)=>{let J=this._def.errorMap?.(q,Q).message??Q.defaultError;if(q.code==="unrecognized_keys")return{message:K.errToObj($).message??J};return{message:J}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend($){return new n({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new n({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:P.ZodObject})}setKey($,q){return this.augment({[$]:q})}catchall($){return new n({...this._def,catchall:$})}pick($){let q={};for(let Q of g.objectKeys($))if($[Q]&&this.shape[Q])q[Q]=this.shape[Q];return new n({...this._def,shape:()=>q})}omit($){let q={};for(let Q of g.objectKeys(this.shape))if(!$[Q])q[Q]=this.shape[Q];return new n({...this._def,shape:()=>q})}deepPartial(){return Y1(this)}partial($){let q={};for(let Q of g.objectKeys(this.shape)){let J=this.shape[Q];if($&&!$[Q])q[Q]=J;else q[Q]=J.optional()}return new n({...this._def,shape:()=>q})}required($){let q={};for(let Q of g.objectKeys(this.shape))if($&&!$[Q])q[Q]=this.shape[Q];else{let W=this.shape[Q];while(W instanceof z$)W=W._def.innerType;q[Q]=W}return new n({...this._def,shape:()=>q})}keyof(){return EQ(g.objectKeys(this.shape))}}n.create=($,q)=>{return new n({shape:()=>$,unknownKeys:"strip",catchall:C$.create(),typeName:P.ZodObject,...T(q)})};n.strictCreate=($,q)=>{return new n({shape:()=>$,unknownKeys:"strict",catchall:C$.create(),typeName:P.ZodObject,...T(q)})};n.lazycreate=($,q)=>{return new n({shape:$,unknownKeys:"strip",catchall:C$.create(),typeName:P.ZodObject,...T(q)})};class F1 extends h{_parse($){let{ctx:q}=this._processInputParams($),Q=this._def.options;function J(W){for(let H of W)if(H.result.status==="valid")return H.result;for(let H of W)if(H.result.status==="dirty")return q.common.issues.push(...H.ctx.common.issues),H.result;let X=W.map((H)=>new H$(H.ctx.common.issues));return R(q,{code:U.invalid_union,unionErrors:X}),b}if(q.common.async)return Promise.all(Q.map(async(W)=>{let X={...q,common:{...q.common,issues:[]},parent:null};return{result:await W._parseAsync({data:q.data,path:q.path,parent:X}),ctx:X}})).then(J);else{let W=void 0,X=[];for(let Y of Q){let G={...q,common:{...q.common,issues:[]},parent:null},V=Y._parseSync({data:q.data,path:q.path,parent:G});if(V.status==="valid")return V;else if(V.status==="dirty"&&!W)W={result:V,ctx:G};if(G.common.issues.length)X.push(G.common.issues)}if(W)return q.common.issues.push(...W.ctx.common.issues),W.result;let H=X.map((Y)=>new H$(Y));return R(q,{code:U.invalid_union,unionErrors:H}),b}}get options(){return this._def.options}}F1.create=($,q)=>{return new F1({options:$,typeName:P.ZodUnion,...T(q)})};var K$=($)=>{if($ instanceof D1)return K$($.schema);else if($ instanceof j$)return K$($.innerType());else if($ instanceof U1)return[$.value];else if($ instanceof T$)return $.options;else if($ instanceof z1)return g.objectValues($.enum);else if($ instanceof L1)return K$($._def.innerType);else if($ instanceof B1)return[void 0];else if($ instanceof V1)return[null];else if($ instanceof z$)return[void 0,...K$($.unwrap())];else if($ instanceof k$)return[null,...K$($.unwrap())];else if($ instanceof g0)return K$($.unwrap());else if($ instanceof N1)return K$($.unwrap());else if($ instanceof j1)return K$($._def.innerType);else return[]};class v0 extends h{_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==L.object)return R(q,{code:U.invalid_type,expected:L.object,received:q.parsedType}),b;let Q=this.discriminator,J=q.data[Q],W=this.optionsMap.get(J);if(!W)return R(q,{code:U.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),b;if(q.common.async)return W._parseAsync({data:q.data,path:q.path,parent:q});else return W._parseSync({data:q.data,path:q.path,parent:q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,q,Q){let J=new Map;for(let W of q){let X=K$(W.shape[$]);if(!X.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let H of X){if(J.has(H))throw Error(`Discriminator property ${String($)} has duplicate value ${String(H)}`);J.set(H,W)}}return new v0({typeName:P.ZodDiscriminatedUnion,discriminator:$,options:q,optionsMap:J,...T(Q)})}}function c6($,q){let Q=A$($),J=A$(q);if($===q)return{valid:!0,data:$};else if(Q===L.object&&J===L.object){let W=g.objectKeys(q),X=g.objectKeys($).filter((Y)=>W.indexOf(Y)!==-1),H={...$,...q};for(let Y of X){let G=c6($[Y],q[Y]);if(!G.valid)return{valid:!1};H[Y]=G.data}return{valid:!0,data:H}}else if(Q===L.array&&J===L.array){if($.length!==q.length)return{valid:!1};let W=[];for(let X=0;X<$.length;X++){let H=$[X],Y=q[X],G=c6(H,Y);if(!G.valid)return{valid:!1};W.push(G.data)}return{valid:!0,data:W}}else if(Q===L.date&&J===L.date&&+$===+q)return{valid:!0,data:$};else return{valid:!1}}class _1 extends h{_parse($){let{status:q,ctx:Q}=this._processInputParams($),J=(W,X)=>{if(T0(W)||T0(X))return b;let H=c6(W.value,X.value);if(!H.valid)return R(Q,{code:U.invalid_intersection_types}),b;if(h0(W)||h0(X))q.dirty();return{status:q.value,value:H.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([W,X])=>J(W,X));else return J(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}_1.create=($,q,Q)=>{return new _1({left:$,right:q,typeName:P.ZodIntersection,...T(Q)})};class O$ extends h{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.array)return R(Q,{code:U.invalid_type,expected:L.array,received:Q.parsedType}),b;if(Q.data.length<this._def.items.length)return R(Q,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;if(!this._def.rest&&Q.data.length>this._def.items.length)R(Q,{code:U.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q.dirty();let W=[...Q.data].map((X,H)=>{let Y=this._def.items[H]||this._def.rest;if(!Y)return null;return Y._parse(new L$(Q,X,Q.path,H))}).filter((X)=>!!X);if(Q.common.async)return Promise.all(W).then((X)=>{return e.mergeArray(q,X)});else return e.mergeArray(q,W)}get items(){return this._def.items}rest($){return new O$({...this._def,rest:$})}}O$.create=($,q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new O$({items:$,typeName:P.ZodTuple,rest:null,...T(q)})};class l1 extends h{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.object)return R(Q,{code:U.invalid_type,expected:L.object,received:Q.parsedType}),b;let J=[],W=this._def.keyType,X=this._def.valueType;for(let H in Q.data)J.push({key:W._parse(new L$(Q,H,Q.path,H)),value:X._parse(new L$(Q,Q.data[H],Q.path,H)),alwaysSet:H in Q.data});if(Q.common.async)return e.mergeObjectAsync(q,J);else return e.mergeObjectSync(q,J)}get element(){return this._def.valueType}static create($,q,Q){if(q instanceof h)return new l1({keyType:$,valueType:q,typeName:P.ZodRecord,...T(Q)});return new l1({keyType:D$.create(),valueType:$,typeName:P.ZodRecord,...T(q)})}}class u1 extends h{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.map)return R(Q,{code:U.invalid_type,expected:L.map,received:Q.parsedType}),b;let J=this._def.keyType,W=this._def.valueType,X=[...Q.data.entries()].map(([H,Y],G)=>{return{key:J._parse(new L$(Q,H,Q.path,[G,"key"])),value:W._parse(new L$(Q,Y,Q.path,[G,"value"]))}});if(Q.common.async){let H=new Map;return Promise.resolve().then(async()=>{for(let Y of X){let G=await Y.key,V=await Y.value;if(G.status==="aborted"||V.status==="aborted")return b;if(G.status==="dirty"||V.status==="dirty")q.dirty();H.set(G.value,V.value)}return{status:q.value,value:H}})}else{let H=new Map;for(let Y of X){let{key:G,value:V}=Y;if(G.status==="aborted"||V.status==="aborted")return b;if(G.status==="dirty"||V.status==="dirty")q.dirty();H.set(G.value,V.value)}return{status:q.value,value:H}}}}u1.create=($,q,Q)=>{return new u1({valueType:q,keyType:$,typeName:P.ZodMap,...T(Q)})};class n$ extends h{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.set)return R(Q,{code:U.invalid_type,expected:L.set,received:Q.parsedType}),b;let J=this._def;if(J.minSize!==null){if(Q.data.size<J.minSize.value)R(Q,{code:U.too_small,minimum:J.minSize.value,type:"set",inclusive:!0,exact:!1,message:J.minSize.message}),q.dirty()}if(J.maxSize!==null){if(Q.data.size>J.maxSize.value)R(Q,{code:U.too_big,maximum:J.maxSize.value,type:"set",inclusive:!0,exact:!1,message:J.maxSize.message}),q.dirty()}let W=this._def.valueType;function X(Y){let G=new Set;for(let V of Y){if(V.status==="aborted")return b;if(V.status==="dirty")q.dirty();G.add(V.value)}return{status:q.value,value:G}}let H=[...Q.data.values()].map((Y,G)=>W._parse(new L$(Q,Y,Q.path,G)));if(Q.common.async)return Promise.all(H).then((Y)=>X(Y));else return X(H)}min($,q){return new n$({...this._def,minSize:{value:$,message:K.toString(q)}})}max($,q){return new n$({...this._def,maxSize:{value:$,message:K.toString(q)}})}size($,q){return this.min($,q).max($,q)}nonempty($){return this.min(1,$)}}n$.create=($,q)=>{return new n$({valueType:$,minSize:null,maxSize:null,typeName:P.ZodSet,...T(q)})};class G1 extends h{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==L.function)return R(q,{code:U.invalid_type,expected:L.function,received:q.parsedType}),b;function Q(H,Y){return g1({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,X1(),M$].filter((G)=>!!G),issueData:{code:U.invalid_arguments,argumentsError:Y}})}function J(H,Y){return g1({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,X1(),M$].filter((G)=>!!G),issueData:{code:U.invalid_return_type,returnTypeError:Y}})}let W={errorMap:q.common.contextualErrorMap},X=q.data;if(this._def.returns instanceof p$){let H=this;return J$(async function(...Y){let G=new H$([]),V=await H._def.args.parseAsync(Y,W).catch((Z)=>{throw G.addIssue(Q(Y,Z)),G}),D=await Reflect.apply(X,this,V);return await H._def.returns._def.type.parseAsync(D,W).catch((Z)=>{throw G.addIssue(J(D,Z)),G})})}else{let H=this;return J$(function(...Y){let G=H._def.args.safeParse(Y,W);if(!G.success)throw new H$([Q(Y,G.error)]);let V=Reflect.apply(X,this,G.data),D=H._def.returns.safeParse(V,W);if(!D.success)throw new H$([J(V,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new G1({...this._def,args:O$.create($).rest(Z$.create())})}returns($){return new G1({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,q,Q){return new G1({args:$?$:O$.create([]).rest(Z$.create()),returns:q||Z$.create(),typeName:P.ZodFunction,...T(Q)})}}class D1 extends h{get schema(){return this._def.getter()}_parse($){let{ctx:q}=this._processInputParams($);return this._def.getter()._parse({data:q.data,path:q.path,parent:q})}}D1.create=($,q)=>{return new D1({getter:$,typeName:P.ZodLazy,...T(q)})};class U1 extends h{_parse($){if($.data!==this._def.value){let q=this._getOrReturnCtx($);return R(q,{received:q.data,code:U.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:$.data}}get value(){return this._def.value}}U1.create=($,q)=>{return new U1({value:$,typeName:P.ZodLiteral,...T(q)})};function EQ($,q){return new T$({values:$,typeName:P.ZodEnum,...T(q)})}class T$ extends h{_parse($){if(typeof $.data!=="string"){let q=this._getOrReturnCtx($),Q=this._def.values;return R(q,{expected:g.joinValues(Q),received:q.parsedType,code:U.invalid_type}),b}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let q=this._getOrReturnCtx($),Q=this._def.values;return R(q,{received:q.data,code:U.invalid_enum_value,options:Q}),b}return J$($.data)}get options(){return this._def.values}get enum(){let $={};for(let q of this._def.values)$[q]=q;return $}get Values(){let $={};for(let q of this._def.values)$[q]=q;return $}get Enum(){let $={};for(let q of this._def.values)$[q]=q;return $}extract($,q=this._def){return T$.create($,{...this._def,...q})}exclude($,q=this._def){return T$.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...q})}}T$.create=EQ;class z1 extends h{_parse($){let q=g.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==L.string&&Q.parsedType!==L.number){let J=g.objectValues(q);return R(Q,{expected:g.joinValues(J),received:Q.parsedType,code:U.invalid_type}),b}if(!this._cache)this._cache=new Set(g.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let J=g.objectValues(q);return R(Q,{received:Q.data,code:U.invalid_enum_value,options:J}),b}return J$($.data)}get enum(){return this._def.values}}z1.create=($,q)=>{return new z1({values:$,typeName:P.ZodNativeEnum,...T(q)})};class p$ extends h{unwrap(){return this._def.type}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==L.promise&&q.common.async===!1)return R(q,{code:U.invalid_type,expected:L.promise,received:q.parsedType}),b;let Q=q.parsedType===L.promise?q.data:Promise.resolve(q.data);return J$(Q.then((J)=>{return this._def.type.parseAsync(J,{path:q.path,errorMap:q.common.contextualErrorMap})}))}}p$.create=($,q)=>{return new p$({type:$,typeName:P.ZodPromise,...T(q)})};class j$ extends h{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===P.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:q,ctx:Q}=this._processInputParams($),J=this._def.effect||null,W={addIssue:(X)=>{if(R(Q,X),X.fatal)q.abort();else q.dirty()},get path(){return Q.path}};if(W.addIssue=W.addIssue.bind(W),J.type==="preprocess"){let X=J.transform(Q.data,W);if(Q.common.async)return Promise.resolve(X).then(async(H)=>{if(q.value==="aborted")return b;let Y=await this._def.schema._parseAsync({data:H,path:Q.path,parent:Q});if(Y.status==="aborted")return b;if(Y.status==="dirty")return u$(Y.value);if(q.value==="dirty")return u$(Y.value);return Y});else{if(q.value==="aborted")return b;let H=this._def.schema._parseSync({data:X,path:Q.path,parent:Q});if(H.status==="aborted")return b;if(H.status==="dirty")return u$(H.value);if(q.value==="dirty")return u$(H.value);return H}}if(J.type==="refinement"){let X=(H)=>{let Y=J.refinement(H,W);if(Q.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return H};if(Q.common.async===!1){let H=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(H.status==="aborted")return b;if(H.status==="dirty")q.dirty();return X(H.value),{status:q.value,value:H.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((H)=>{if(H.status==="aborted")return b;if(H.status==="dirty")q.dirty();return X(H.value).then(()=>{return{status:q.value,value:H.value}})})}if(J.type==="transform")if(Q.common.async===!1){let X=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!P$(X))return b;let H=J.transform(X.value,W);if(H instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:q.value,value:H}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((X)=>{if(!P$(X))return b;return Promise.resolve(J.transform(X.value,W)).then((H)=>({status:q.value,value:H}))});g.assertNever(J)}}j$.create=($,q,Q)=>{return new j$({schema:$,typeName:P.ZodEffects,effect:q,...T(Q)})};j$.createWithPreprocess=($,q,Q)=>{return new j$({schema:q,effect:{type:"preprocess",transform:$},typeName:P.ZodEffects,...T(Q)})};class z$ extends h{_parse($){if(this._getType($)===L.undefined)return J$(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}z$.create=($,q)=>{return new z$({innerType:$,typeName:P.ZodOptional,...T(q)})};class k$ extends h{_parse($){if(this._getType($)===L.null)return J$(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}k$.create=($,q)=>{return new k$({innerType:$,typeName:P.ZodNullable,...T(q)})};class L1 extends h{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;if(q.parsedType===L.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:q.path,parent:q})}removeDefault(){return this._def.innerType}}L1.create=($,q)=>{return new L1({innerType:$,typeName:P.ZodDefault,defaultValue:typeof q.default==="function"?q.default:()=>q.default,...T(q)})};class j1 extends h{_parse($){let{ctx:q}=this._processInputParams($),Q={...q,common:{...q.common,issues:[]}},J=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(H1(J))return J.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new H$(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new H$(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}j1.create=($,q)=>{return new j1({innerType:$,typeName:P.ZodCatch,catchValue:typeof q.catch==="function"?q.catch:()=>q.catch,...T(q)})};class c1 extends h{_parse($){if(this._getType($)!==L.nan){let Q=this._getOrReturnCtx($);return R(Q,{code:U.invalid_type,expected:L.nan,received:Q.parsedType}),b}return{status:"valid",value:$.data}}}c1.create=($)=>{return new c1({typeName:P.ZodNaN,...T($)})};var WH=Symbol("zod_brand");class g0 extends h{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;return this._def.type._parse({data:Q,path:q.path,parent:q})}unwrap(){return this._def.type}}class d1 extends h{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(W.status==="aborted")return b;if(W.status==="dirty")return q.dirty(),u$(W.value);else return this._def.out._parseAsync({data:W.value,path:Q.path,parent:Q})})();else{let J=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(J.status==="aborted")return b;if(J.status==="dirty")return q.dirty(),{status:"dirty",value:J.value};else return this._def.out._parseSync({data:J.value,path:Q.path,parent:Q})}}static create($,q){return new d1({in:$,out:q,typeName:P.ZodPipeline})}}class N1 extends h{_parse($){let q=this._def.innerType._parse($),Q=(J)=>{if(P$(J))J.value=Object.freeze(J.value);return J};return H1(q)?q.then((J)=>Q(J)):Q(q)}unwrap(){return this._def.innerType}}N1.create=($,q)=>{return new N1({innerType:$,typeName:P.ZodReadonly,...T(q)})};function LQ($,q){let Q=typeof $==="function"?$(q):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function SQ($,q={},Q){if($)return d$.create().superRefine((J,W)=>{let X=$(J);if(X instanceof Promise)return X.then((H)=>{if(!H){let Y=LQ(q,J),G=Y.fatal??Q??!0;W.addIssue({code:"custom",...Y,fatal:G})}});if(!X){let H=LQ(q,J),Y=H.fatal??Q??!0;W.addIssue({code:"custom",...H,fatal:Y})}return});return d$.create()}var XH={object:n.lazycreate},P;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(P||(P={}));var HH=($,q={message:`Input not instance of ${$.name}`})=>SQ((Q)=>Q instanceof $,q),AQ=D$.create,CQ=f$.create,YH=c1.create,GH=x$.create,OQ=w1.create,wH=c$.create,BH=m1.create,VH=B1.create,FH=V1.create,_H=d$.create,DH=Z$.create,UH=C$.create,zH=y1.create,LH=U$.create,jH=n.create,NH=n.strictCreate,RH=F1.create,EH=v0.create,SH=_1.create,AH=O$.create,CH=l1.create,OH=u1.create,MH=n$.create,KH=G1.create,kH=D1.create,IH=U1.create,bH=T$.create,PH=z1.create,ZH=p$.create,fH=j$.create,xH=z$.create,TH=k$.create,hH=j$.createWithPreprocess,vH=d1.create,gH=()=>AQ().optional(),mH=()=>CQ().optional(),yH=()=>OQ().optional(),lH={string:($)=>D$.create({...$,coerce:!0}),number:($)=>f$.create({...$,coerce:!0}),boolean:($)=>w1.create({...$,coerce:!0}),bigint:($)=>x$.create({...$,coerce:!0}),date:($)=>c$.create({...$,coerce:!0})};var uH=b;class m0{config;blacklistedTokens=new Set;constructor($){this.config=$;if(!$.secret)throw Error("JWT secret is required")}generateTokens($){let q=Math.floor(Date.now()/1000),Q=this.parseExpiration(this.config.expiresIn||"1h"),J={sub:$.sub,...$,iat:q,exp:q+Q,iss:this.config.issuer,aud:this.config.audience},W=h$.sign(J,this.config.secret,{algorithm:this.config.algorithm||"HS256"}),X={sub:$.sub,type:"refresh",iat:q,exp:q+this.parseExpiration(this.config.refreshExpiresIn||"7d"),iss:this.config.issuer,aud:this.config.audience},H=h$.sign(X,this.config.refreshSecret||this.config.secret,{algorithm:this.config.algorithm||"HS256"});return{accessToken:W,refreshToken:H,expiresIn:Q}}verifyAccessToken($){if(this.isBlacklisted($))throw Error("Token has been revoked");try{return h$.verify($,this.config.secret,{algorithms:[this.config.algorithm||"HS256"],issuer:this.config.issuer,audience:this.config.audience})}catch(q){if(q instanceof Error)throw Error(`Invalid token: ${q.message}`);throw Error("Invalid token")}}verifyRefreshToken($){if(this.isBlacklisted($))throw Error("Refresh token has been revoked");try{let q=h$.verify($,this.config.refreshSecret||this.config.secret,{algorithms:[this.config.algorithm||"HS256"],issuer:this.config.issuer,audience:this.config.audience});if(q.type!=="refresh")throw Error("Invalid refresh token type");return q}catch(q){if(q instanceof Error)throw Error(`Invalid refresh token: ${q.message}`);throw Error("Invalid refresh token")}}refreshAccessToken($){let q=this.verifyRefreshToken($);return this.blacklistToken($),this.generateTokens({sub:q.sub,...Object.fromEntries(Object.entries(q).filter(([Q])=>!["iat","exp","iss","aud","type"].includes(Q)))})}decodeToken($){try{return h$.decode($)}catch{return null}}blacklistToken($){this.blacklistedTokens.add($),this.cleanupBlacklist()}isBlacklisted($){return this.blacklistedTokens.has($)}cleanupBlacklist(){let $=Math.floor(Date.now()/1000);for(let q of this.blacklistedTokens){let Q=this.decodeToken(q);if(Q&&Q.exp&&Q.exp<$)this.blacklistedTokens.delete(q)}}parseExpiration($){if(typeof $==="number")return $;let q={s:1,m:60,h:3600,d:86400,w:604800},Q=$.match(/^(\d+)([smhdw])$/);if(!Q)throw Error(`Invalid expiration format: ${$}`);let[,J,W]=Q;return parseInt(J)*q[W]}}var cH=B.object({sub:B.string(),iat:B.number().optional(),exp:B.number().optional(),iss:B.string().optional(),aud:B.string().optional()}).passthrough(),dH=B.object({username:B.string().min(1),password:B.string().min(1)}),nH=B.object({refreshToken:B.string().min(1)});v$();class p1{config;userProvider;jwtProvider;constructor($,q){this.config=$;this.userProvider=q;this.jwtProvider=new m0($)}async login($,q){let Q=await this.userProvider.findByCredentials($,q);if(!Q)throw new a("Invalid credentials");let J=this.jwtProvider.generateTokens({sub:Q.id,username:Q.username,email:Q.email,roles:Q.roles||[],permissions:Q.permissions||[]});return{user:Q,tokens:J}}async refresh($){try{return this.jwtProvider.refreshAccessToken($)}catch(q){throw new i$(q instanceof Error?q.message:"Invalid refresh token")}}async logout($,q){if(this.jwtProvider.blacklistToken($),q)this.jwtProvider.blacklistToken(q)}async verifyToken($){try{let q=this.jwtProvider.verifyAccessToken($),Q=await this.userProvider.findById(q.sub);if(!Q)throw new a("User not found");return Q}catch(q){if(q instanceof Error){if(q.message.includes("expired"))throw new n1;throw new i$(q.message)}throw new i$("Token verification failed")}}getUserFromToken($){return this.jwtProvider.verifyAccessToken($)}hasRoles($,q){let Q=$.roles||[];return q.every((J)=>Q.includes(J))}hasPermissions($,q){let Q=$.permissions||[];return q.every((J)=>Q.includes(J))}async register($){if(!this.userProvider.createUser)throw Error("UserProvider does not support user creation");let q=await this.userProvider.createUser($),Q=this.jwtProvider.generateTokens({sub:q.id,username:q.username,email:q.email,roles:q.roles||[],permissions:q.permissions||[]});return{user:q,tokens:Q}}cleanup(){this.jwtProvider.cleanupBlacklist()}getJWTProvider(){return this.jwtProvider}}class IQ{users=new Map;async findByCredentials($,q){for(let[Q,J]of this.users)if(J.username===$){if(await this.verifyPassword(q,J.passwordHash)){let{passwordHash:X,...H}=J;return H}}return null}async findById($){let q=this.users.get($);if(q){let{passwordHash:Q,...J}=q;return J}return null}async hashPassword($){return Buffer.from($).toString("base64")}async verifyPassword($,q){return await this.hashPassword($)===q}async createUser($){let q=crypto.randomUUID(),Q=await this.hashPassword($.password),J={id:q,username:$.username,email:$.email,roles:$.roles||["user"],passwordHash:Q};this.users.set(q,J);let{passwordHash:W,...X}=J;return X}}var CB=v4(PQ(),1),p6=Symbol("route:metadata"),i6=Symbol("controller:metadata"),ZQ=Symbol("parameter:metadata"),fQ=Symbol("dependency:metadata"),o6=Symbol("websocket:metadata"),xQ=Symbol("websocket:handler:metadata"),s6=Symbol("graphql:resolver"),i1=Symbol("graphql:field"),r6=Symbol("auth:metadata"),a6=Symbol("oauth:metadata"),t6=Symbol("roles:metadata"),e6=Symbol("permissions:metadata"),$4=Symbol("minimum-role:metadata"),q4=Symbol("resource-permission:metadata"),Q4=Symbol("session:metadata"),J4=Symbol("csrf:metadata");class d{routes=new Map;controllers=new Map;routesByController=new Map;websockets=new Map;graphqlResolvers=new Map;graphqlFields=new Map;registerRoute($){let q=this.getRouteKey($.target,$.propertyKey);if(this.routes.set(q,$),!this.routesByController.has($.target))this.routesByController.set($.target,[]);this.routesByController.get($.target).push($)}registerController($,q){this.controllers.set($,q)}getRoutes(){return Array.from(this.routes.values())}getRoute($,q){let Q=this.getRouteKey($,q);return this.routes.get(Q)}getRoutesByController($){return this.routesByController.get($)||[]}getController($){return this.controllers.get($)}getControllers(){return new Map(this.controllers)}registerWebSocket($){this.websockets.set($.target,$)}getWebSockets(){return Array.from(this.websockets.values())}getWebSocket($){return this.websockets.get($)}registerGraphQLResolver($){this.graphqlResolvers.set($.target,$)}registerGraphQLField($){let q=this.getRouteKey($.target,$.propertyKey);this.graphqlFields.set(q,$)}getGraphQLResolvers(){return Array.from(this.graphqlResolvers.values())}getGraphQLResolver($){return this.graphqlResolvers.get($)}getGraphQLFields(){return Array.from(this.graphqlFields.values())}getGraphQLFieldsByResolver($){return Array.from(this.graphqlFields.values()).filter((q)=>q.target===$)}clear(){this.routes.clear(),this.controllers.clear(),this.routesByController.clear(),this.websockets.clear(),this.graphqlResolvers.clear(),this.graphqlFields.clear()}getRouteKey($,q){return`${$.name}:${q}`}static defineRoute($,q,Q){let J=this.getRouteMetadata($,q),W={...J,...Q,target:$.constructor,propertyKey:q,middleware:[...J?.middleware||[],...Q.middleware||[]],parameters:Q.parameters||J?.parameters||[],dependencies:Q.dependencies||J?.dependencies||[],responses:Q.responses||J?.responses||[],auth:Q.auth||J?.auth,oauth:Q.oauth||J?.oauth,roles:Q.roles||J?.roles,permissions:Q.permissions||J?.permissions,minimumRole:Q.minimumRole||J?.minimumRole,resourcePermission:Q.resourcePermission||J?.resourcePermission,session:Q.session||J?.session,csrf:Q.csrf||J?.csrf};Reflect.defineMetadata(p6,W,$,q)}static defineParameter($,q,Q,J){let W=this.getParameterMetadata($,q)||[];W[Q]=J,Reflect.defineMetadata(ZQ,W,$,q);let X=this.getRouteMetadata($,q);this.defineRoute($,q,{...X,parameters:W})}static defineDependency($,q,Q,J){let W=this.getDependencyMetadata($,q)||[];W[Q]=J,Reflect.defineMetadata(fQ,W,$,q);let X=this.getRouteMetadata($,q);this.defineRoute($,q,{...X,dependencies:W})}static defineController($,q){Reflect.defineMetadata(i6,q,$)}static getRouteMetadata($,q){return Reflect.getMetadata(p6,$,q)}static getParameterMetadata($,q){return Reflect.getMetadata(ZQ,$,q)}static getDependencyMetadata($,q){return Reflect.getMetadata(fQ,$,q)}static getControllerMetadata($){return Reflect.getMetadata(i6,$)}static hasControllerMetadata($){return Reflect.hasMetadata(i6,$)}static hasRouteMetadata($,q){return Reflect.hasMetadata(p6,$,q)}static getRouteMethods($){let q=$.prototype,Q=[],J=Object.getOwnPropertyNames(q);for(let W of J){if(W==="constructor")continue;if(this.hasRouteMetadata(q,W))Q.push(W)}return Q}static defineWebSocket($,q){let J={...this.getWebSocketMetadata($),...q,target:$};Reflect.defineMetadata(o6,J,$)}static defineWebSocketHandler($,q,Q){let J=this.getWebSocketMetadata($.constructor)||{};switch(Q.type){case"connect":J.onConnect=q;break;case"message":J.onMessage=q,J.messageSchema=Q.schema;break;case"disconnect":J.onDisconnect=q;break}this.defineWebSocket($.constructor,J),Reflect.defineMetadata(xQ,Q,$,q)}static getWebSocketMetadata($){return Reflect.getMetadata(o6,$)}static getWebSocketHandlerMetadata($,q){return Reflect.getMetadata(xQ,$,q)}static hasWebSocketMetadata($){return Reflect.hasMetadata(o6,$)}static defineGraphQLResolver($,q){Reflect.defineMetadata(s6,q,$)}static defineGraphQLField($,q,Q){Reflect.defineMetadata(i1,Q,$,q);let J=this.getGraphQLFieldsMetadata($.constructor)||[];J.push(Q),Reflect.defineMetadata(i1,J,$.constructor)}static getGraphQLResolverMetadata($){return Reflect.getMetadata(s6,$)}static getGraphQLFieldsMetadata($){return Reflect.getMetadata(i1,$)||[]}static getGraphQLFieldMetadata($,q){return Reflect.getMetadata(i1,$,q)}static hasGraphQLResolverMetadata($){return Reflect.hasMetadata(s6,$)}static hasGraphQLFieldMetadata($,q){return Reflect.hasMetadata(i1,$,q)}static defineAuth($,q,Q){Reflect.defineMetadata(r6,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,auth:Q})}static getAuthMetadata($,q){return Reflect.getMetadata(r6,$,q)}static hasAuthMetadata($,q){return Reflect.hasMetadata(r6,$,q)}static defineOAuth($,q,Q){Reflect.defineMetadata(a6,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,oauth:Q})}static getOAuthMetadata($,q){return Reflect.getMetadata(a6,$,q)}static hasOAuthMetadata($,q){return Reflect.hasMetadata(a6,$,q)}static defineRoles($,q,Q){Reflect.defineMetadata(t6,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,roles:Q})}static definePermissions($,q,Q){Reflect.defineMetadata(e6,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,permissions:Q})}static defineMinimumRole($,q,Q){Reflect.defineMetadata($4,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,minimumRole:Q})}static getRolesMetadata($,q){return Reflect.getMetadata(t6,$,q)}static getPermissionsMetadata($,q){return Reflect.getMetadata(e6,$,q)}static getMinimumRoleMetadata($,q){return Reflect.getMetadata($4,$,q)}static hasRolesMetadata($,q){return Reflect.hasMetadata(t6,$,q)}static hasPermissionsMetadata($,q){return Reflect.hasMetadata(e6,$,q)}static hasMinimumRoleMetadata($,q){return Reflect.hasMetadata($4,$,q)}static defineResourcePermission($,q,Q){Reflect.defineMetadata(q4,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,resourcePermission:Q})}static getResourcePermissionMetadata($,q){return Reflect.getMetadata(q4,$,q)}static hasResourcePermissionMetadata($,q){return Reflect.hasMetadata(q4,$,q)}static defineSession($,q,Q){Reflect.defineMetadata(Q4,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,session:Q})}static defineCSRF($,q,Q){Reflect.defineMetadata(J4,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,csrf:Q})}static getSessionMetadata($,q){return Reflect.getMetadata(Q4,$,q)}static getCSRFMetadata($,q){return Reflect.getMetadata(J4,$,q)}static hasSessionMetadata($,q){return Reflect.hasMetadata(Q4,$,q)}static hasCSRFMetadata($,q){return Reflect.hasMetadata(J4,$,q)}}function YY($){return(q,Q)=>{let J={required:!$?.optional,config:$};d.defineAuth(q,Q,J)}}function GY(){return($,q,Q)=>{if(q)d.defineParameter($,q,Q,{index:Q,type:"current-user",required:!1})}}function wY(){return($,q,Q)=>{if(q)d.defineParameter($,q,Q,{index:Q,type:"token",required:!1})}}function W4($){return async(q,Q)=>{let J=q.req.header("Authorization");if(!J||!J.startsWith("Bearer "))q.set("auth.error","Missing or invalid Authorization header"),q.set("auth.authenticated",!1);else{let W=J.substring(7);try{let X=$.verifyAccessToken(W);q.set("auth.user",X),q.set("auth.token",W),q.set("auth.authenticated",!0)}catch(X){q.set("auth.error",X instanceof Error?X.message:"Authentication failed"),q.set("auth.authenticated",!1)}}await Q()}}function $$($){return $.get("auth.user")||null}function X4($){return $.get("auth.token")||null}function BY($){return $.get("auth.authenticated")===!0}function VY($){return $.get("auth.error")||null}v$();v$();class TQ{config;name="auth";version="1.0.0";authService;compileExtended=!1;constructor($){this.config=$;this.authService=new p1($.jwt,$.userProvider)}async install($){let q=W4(this.authService.getJWTProvider());if($.use(q),$.getContainer().register(p1,{factory:()=>this.authService,scope:"singleton"}),this.config.enableDefaultRoutes!==!1)this.addDefaultRoutes($);this.extendRouterCompiler($)}extendRouterCompiler($){if(this.compileExtended)return;this.compileExtended=!0,$.use(async(Q,J)=>{Q.set("authService",this.authService),await J()});let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getHono(),J=$.getMetadata().getRoutes();for(let W of J){let X=d.getAuthMetadata(W.target.prototype,W.propertyKey);if(W.auth?.required||X?.required){console.log("Adding auth middleware for route:",W.path,W.method);let Y=W.auth?.config||X?.config;Q.use(W.path,async(G,V)=>{if(console.log("Auth middleware executing for:",G.req.path,G.req.method,"target:",W.path,W.method),G.req.method!==W.method)return console.log("Method mismatch, skipping auth check"),V();console.log("Checking authentication...");let D=G.get("auth.user"),z=G.get("auth.error");if(!D){let Z=z||"Authentication required";throw console.log("No user found, throwing auth exception"),new a(Z)}if(Y?.roles?.length){if(!this.authService.hasRoles(D,Y.roles))throw new t(`Required roles: ${Y.roles.join(", ")}`)}if(Y?.permissions?.length){if(!this.authService.hasPermissions(D,Y.permissions))throw new t(`Required permissions: ${Y.permissions.join(", ")}`)}await V()})}}}}buildPath($){return $.path}pathMatches($,q){let Q=$.replace(/:([^/]+)/g,"([^/]+)");return new RegExp(`^${Q}$`).test(q)}addDefaultRoutes($){let q=this.config.routes||{};if($.post(q.login||"/auth/login",{handler:async(Q)=>{let J=await Q.req.json(),{username:W,password:X}=J;try{let H=await this.authService.login(W,X);return{success:!0,user:H.user,tokens:H.tokens}}catch(H){throw new a(H instanceof Error?H.message:"Login failed")}},schema:{body:B.object({username:B.string().min(1),password:B.string().min(1)})}}),$.post(q.refresh||"/auth/refresh",{handler:async(Q)=>{let J=await Q.req.json(),{refreshToken:W}=J;try{return{success:!0,tokens:await this.authService.refresh(W)}}catch(X){throw new a(X instanceof Error?X.message:"Token refresh failed")}},schema:{body:B.object({refreshToken:B.string().min(1)})}}),$.post(q.logout||"/auth/logout",{handler:async(Q)=>{let J=X4(Q),W=await Q.req.json(),{refreshToken:X}=W;if(J)await this.authService.logout(J,X);return{success:!0,message:"Logged out successfully"}},schema:{body:B.object({refreshToken:B.string().optional()})}}),"createUser"in this.config.userProvider)$.post(q.register||"/auth/register",{handler:async(Q)=>{let J=await Q.req.json(),{username:W,password:X,email:H}=J;try{let Y=await this.authService.register({username:W,password:X,email:H});return{success:!0,user:Y.user,tokens:Y.tokens}}catch(Y){throw new a(Y instanceof Error?Y.message:"Registration failed")}},schema:{body:B.object({username:B.string().min(1),password:B.string().min(6),email:B.string().email().optional()})}});$.get("/auth/me",{handler:async(Q)=>{let J=$$(Q);if(!J)throw new a("Not authenticated");return{success:!0,user:J}}})}getAuthService(){return this.authService}}class o1{name;config;constructor($,q){this.name=$;this.config=q}getAuthUrl($,q){let Q=new URLSearchParams({client_id:this.config.clientId,redirect_uri:this.config.redirectUri,response_type:"code",state:$,scope:this.config.scopes?.join(" ")||""});if(q&&this.config.pkce)Q.set("code_challenge",q),Q.set("code_challenge_method","S256");return`${this.config.authUrl}?${Q.toString()}`}async exchangeCodeForTokens($,q){let Q=new URLSearchParams({client_id:this.config.clientId,client_secret:this.config.clientSecret,code:$,grant_type:"authorization_code",redirect_uri:this.config.redirectUri});if(q&&this.config.pkce)Q.set("code_verifier",q);let J=await fetch(this.config.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:Q.toString()});if(!J.ok){let X=await J.text();throw Error(`Token exchange failed: ${X}`)}let W=await J.json();return{accessToken:W.access_token,refreshToken:W.refresh_token,expiresIn:W.expires_in,tokenType:W.token_type||"Bearer",scope:W.scope}}async getUserInfo($){let q=await fetch(this.config.userInfoUrl,{headers:{Authorization:`Bearer ${$}`,Accept:"application/json"}});if(!q.ok){let J=await q.text();throw Error(`Failed to get user info: ${J}`)}let Q=await q.json();return this.mapUserInfo(Q)}mapUserInfo($){return{id:$.id||$.sub,email:$.email,name:$.name,username:$.login||$.preferred_username,avatar:$.avatar_url||$.picture,provider:this.name,...$}}}class hQ extends o1{constructor($,q,Q){super("google",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["openid","profile","email"],authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",userInfoUrl:"https://www.googleapis.com/oauth2/v2/userinfo",pkce:!0})}mapUserInfo($){return{id:$.id,email:$.email,name:$.name,username:$.email,avatar:$.picture,provider:"google",verified:$.verified_email,locale:$.locale,raw:$}}}class vQ extends o1{constructor($,q,Q){super("github",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["user:email"],authUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",userInfoUrl:"https://api.github.com/user",pkce:!1})}mapUserInfo($){return{id:$.id.toString(),email:$.email,name:$.name,username:$.login,avatar:$.avatar_url,provider:"github",company:$.company,location:$.location,bio:$.bio,raw:$}}async getUserInfo($){let q=await fetch(this.config.userInfoUrl,{headers:{Authorization:`Bearer ${$}`,Accept:"application/vnd.github.v3+json","User-Agent":"VeloceTS-OAuth"}});if(!q.ok)throw Error(`Failed to get user info: ${await q.text()}`);let Q=await q.json();if(!Q.email)try{let J=await fetch("https://api.github.com/user/emails",{headers:{Authorization:`Bearer ${$}`,Accept:"application/vnd.github.v3+json","User-Agent":"VeloceTS-OAuth"}});if(J.ok){let X=(await J.json()).find((H)=>H.primary);if(X)Q.email=X.email}}catch(J){}return this.mapUserInfo(Q)}}class gQ extends o1{constructor($,q,Q,J="common"){super("microsoft",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["openid","profile","email"],authUrl:`https://login.microsoftonline.com/${J}/oauth2/v2.0/authorize`,tokenUrl:`https://login.microsoftonline.com/${J}/oauth2/v2.0/token`,userInfoUrl:"https://graph.microsoft.com/v1.0/me",pkce:!0})}mapUserInfo($){return{id:$.id,email:$.mail||$.userPrincipalName,name:$.displayName,username:$.userPrincipalName,avatar:void 0,provider:"microsoft",jobTitle:$.jobTitle,department:$.department,officeLocation:$.officeLocation,raw:$}}}class l0{static generateCodeVerifier(){let $=new Uint8Array(32);return crypto.getRandomValues($),this.base64URLEncode($)}static async generateCodeChallenge($){let Q=new TextEncoder().encode($),J=await crypto.subtle.digest("SHA-256",Q);return this.base64URLEncode(new Uint8Array(J))}static async generatePKCEChallenge(){let $=this.generateCodeVerifier(),q=await this.generateCodeChallenge($);return{codeVerifier:$,codeChallenge:q,codeChallengeMethod:"S256"}}static base64URLEncode($){return btoa(String.fromCharCode(...$)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}}class u0{states=new Map;ttl=600000;generateState($){let q=crypto.randomUUID();return this.states.set(q,{timestamp:Date.now(),data:$}),this.cleanup(),q}validateState($){let q=this.states.get($);if(!q)return{valid:!1};if(Date.now()-q.timestamp>this.ttl)return this.states.delete($),{valid:!1};return this.states.delete($),{valid:!0,data:q.data}}cleanup(){let $=Date.now();for(let[q,Q]of this.states.entries())if($-Q.timestamp>this.ttl)this.states.delete(q)}}var H4=B.object({code:B.string(),state:B.string(),error:B.string().optional(),error_description:B.string().optional()}),FY=B.object({accessToken:B.string(),refreshToken:B.string().optional(),expiresIn:B.number().optional(),tokenType:B.string(),scope:B.string().optional()}),_Y=B.object({id:B.string(),email:B.string().optional(),name:B.string().optional(),username:B.string().optional(),avatar:B.string().optional(),provider:B.string()}).passthrough();function DY($){return(q,Q)=>{let J={provider:$.provider,config:$};d.defineOAuth(q,Q,J)}}function UY(){return($,q,Q)=>{if(q)d.defineParameter($,q,Q,{index:Q,type:"oauth-user",required:!0})}}function zY(){return($,q,Q)=>{if(q)d.defineParameter($,q,Q,{index:Q,type:"oauth-token",required:!0})}}function LY($){return $.get("oauth.user")||null}function jY($){return $.get("oauth.token")||null}function NY($){return $.get("oauth.authenticated")===!0}function RY($){return $.get("oauth.provider")||null}class mQ{config;name="oauth";version="1.0.0";dependencies=["auth"];stateManager=new u0;pkceStore=new Map;constructor($){this.config=$}async install($){this.addOAuthRoutes($),this.extendRouterCompiler($)}addOAuthRoutes($){let q=this.config.routes||{};$.get(q.login||"/auth/oauth/:provider",{handler:async(Q)=>{let J=Q.req.param("provider"),W=this.config.providers[J];if(!W)return Q.json({error:"Unknown OAuth provider"},400);let X=this.stateManager.generateState({provider:J}),H;if(W.config.pkce){let Y=await l0.generatePKCEChallenge();this.pkceStore.set(X,Y),H=W.getAuthUrl(X,Y.codeChallenge)}else H=W.getAuthUrl(X);return Q.json({authUrl:H,state:X,provider:J})}}),$.get(q.callback||"/auth/oauth/:provider/callback",{handler:async(Q)=>{let J=Q.req.param("provider"),W=Q.req.query(),X=H4.parse(W);if(X.error)return Q.json({error:"OAuth error",description:X.error_description||X.error},400);let H=this.stateManager.validateState(X.state);if(!H.valid||H.data?.provider!==J)return Q.json({error:"Invalid state parameter"},400);let Y=this.config.providers[J];if(!Y)return Q.json({error:"Unknown OAuth provider"},400);try{let G=this.pkceStore.get(X.state),V=G?.codeVerifier,D=await Y.exchangeCodeForTokens(X.code,V),z=await Y.getUserInfo(D.accessToken);if(G)this.pkceStore.delete(X.state);let Z=null;if(this.config.userProvider)Z=await this.findOrCreateUser(z);if(this.config.onUserLogin)await this.config.onUserLogin(z,Z);let C=null;if(this.config.authService&&Z)C=(await this.config.authService.login(Z.username,"")).tokens;return Q.json({success:!0,user:Z||z,oauthTokens:D,jwtTokens:C,provider:J})}catch(G){return console.error("OAuth callback error:",G),Q.json({error:"OAuth authentication failed",message:G instanceof Error?G.message:"Unknown error"},500)}}}),$.get("/auth/oauth/:provider/user",{handler:async(Q)=>{let J=Q.req.param("provider"),W=Q.req.header("Authorization");if(!W||!W.startsWith("Bearer "))return Q.json({error:"Missing OAuth access token"},401);let X=W.substring(7),H=this.config.providers[J];if(!H)return Q.json({error:"Unknown OAuth provider"},400);try{let Y=await H.getUserInfo(X);return Q.json({user:Y})}catch(Y){return Q.json({error:"Failed to get user info",message:Y instanceof Error?Y.message:"Unknown error"},400)}}})}async findOrCreateUser($){if(!this.config.userProvider)return null;let q=await this.findUserByOAuthId($.id,$.provider);if(!q&&$.email)q=await this.findUserByEmail($.email);if(!q){if(q=await this.createUserFromOAuth($),this.config.onUserCreated)await this.config.onUserCreated($)}return q}async findUserByOAuthId($,q){return null}async findUserByEmail($){return null}async createUserFromOAuth($){if(!this.config.userProvider||!("createUser"in this.config.userProvider))throw Error("User provider does not support user creation");let q={username:$.username||$.email||`${$.provider}_${$.id}`,email:$.email,password:crypto.randomUUID(),roles:["user"],oauthId:$.id,oauthProvider:$.provider,name:$.name,avatar:$.avatar};return await this.config.userProvider.createUser(q)}extendRouterCompiler($){}getProvider($){return this.config.providers[$]}getProviders(){return{...this.config.providers}}}class R1{roles=new Map;hierarchy=new Map;compiledPermissions=new Map;defineRole($){if(this.roles.set($.name,$),$.inherits&&$.inherits.length>0)this.hierarchy.set($.name,$.inherits);this.compiledPermissions.clear()}defineRoles($){for(let q of $)this.defineRole(q)}getRolePermissions($){if(this.compiledPermissions.has($))return Array.from(this.compiledPermissions.get($));let q=new Set;return this.collectPermissions($,q,new Set),this.compiledPermissions.set($,q),Array.from(q)}roleHasPermission($,q){return this.getRolePermissions($).includes(q)}userHasPermission($,q){for(let Q of $)if(this.roleHasPermission(Q,q))return!0;return!1}userHasRoles($,q){return q.every((Q)=>$.includes(Q))}userHasAnyRole($,q){return q.some((Q)=>$.includes(Q))}getRolesWithPermission($){let q=[];for(let Q of this.roles.keys())if(this.roleHasPermission(Q,$))q.push(Q);return q}getRoleHierarchy($){let q=[];return this.collectParentRoles($,q,new Set),q}roleInheritsFrom($,q){return this.getRoleHierarchy($).includes(q)}getAllRoles(){return Array.from(this.roles.values())}getRole($){return this.roles.get($)}roleExists($){return this.roles.has($)}validateRoles($){let q=[],Q=[];for(let J of $)if(this.roleExists(J))q.push(J);else Q.push(J);return{valid:q,invalid:Q}}getEffectiveRoles($){let q=new Set;for(let Q of $)q.add(Q),this.getRoleHierarchy(Q).forEach((W)=>q.add(W));return Array.from(q)}compareRoleLevels($,q){let Q=this.getRole($),J=this.getRole(q),W=Q?.level??0,X=J?.level??0;return W-X}getHighestRoleLevel($){let q=0;for(let Q of $){let J=this.getRole(Q);if(J&&J.level&&J.level>q)q=J.level}return q}collectPermissions($,q,Q){if(Q.has($))throw Error(`Circular role inheritance detected: ${$}`);Q.add($);let J=this.roles.get($);if(!J)throw Error(`Role not found: ${$}`);J.permissions.forEach((X)=>q.add(X));let W=this.hierarchy.get($)||[];for(let X of W)this.collectPermissions(X,q,new Set(Q))}collectParentRoles($,q,Q){if(Q.has($))return;Q.add($);let J=this.hierarchy.get($)||[];for(let W of J)q.push(W),this.collectParentRoles(W,q,Q)}}function Y4(){let $=new R1;return $.defineRoles([{name:"guest",description:"Guest user with minimal permissions",permissions:["read:public"],level:1},{name:"user",description:"Regular authenticated user",permissions:["read:own","write:own","read:public"],inherits:["guest"],level:10},{name:"moderator",description:"Moderator with content management permissions",permissions:["read:all","write:all","moderate:content"],inherits:["user"],level:50},{name:"admin",description:"Administrator with full system access",permissions:["*"],inherits:["moderator"],level:100},{name:"super-admin",description:"Super administrator with unrestricted access",permissions:["*","system:*"],inherits:["admin"],level:1000}]),$}var EY=B.object({name:B.string().min(1),description:B.string().optional(),permissions:B.array(B.string()),inherits:B.array(B.string()).optional(),level:B.number().optional()}),SY=B.object({userId:B.string(),roles:B.array(B.string())}),AY=B.object({userId:B.string(),permission:B.string()});class E1{static matches($,q){if(q==="*")return!0;if(q.endsWith("*")){let Q=q.slice(0,-1);return $.startsWith(Q)}return $===q}static hasPermission($,q){return $.some((Q)=>this.matches(q,Q))}static filterByPattern($,q){return $.filter((Q)=>this.matches(Q,q))}}v$();function yQ($){return(q,Q)=>{let W={config:Array.isArray($)?{roles:$,requireAll:!1,allowInherited:!0}:{requireAll:!1,allowInherited:!0,...$}};d.defineRoles(q,Q,W)}}function lQ($){return(q,Q)=>{let W={config:Array.isArray($)?{permissions:$,requireAll:!1}:{requireAll:!1,...$}};d.definePermissions(q,Q,W)}}function G4($){return yQ([$])}function CY($){return lQ([$])}function OY(){return G4("admin")}function MY(){return G4("super-admin")}function KY($){return(q,Q)=>{d.defineMinimumRole(q,Q,{roleName:$})}}function w4($){return async(q,Q)=>{q.set("rbac",$),await Q()}}class s1{rbac;constructor($){this.rbac=$}checkRoles($,q){let Q=$$($);if(!Q)throw new t("Authentication required for role check");let J=Q.roles||[],W=q.allowInherited?this.rbac.getEffectiveRoles(J):J,X;if(q.requireAll)X=q.roles.every((H)=>W.includes(H));else X=q.roles.some((H)=>W.includes(H));if(!X){let H=q.requireAll?"all":"any";throw new t(`Access denied. Required ${H} of roles: ${q.roles.join(", ")}`)}}checkPermissions($,q){let Q=$$($);if(!Q)throw new t("Authentication required for permission check");let J=Q.roles||[],W=new Set;for(let Y of J)this.rbac.getRolePermissions(Y).forEach((V)=>W.add(V));let X=Array.from(W),H;if(q.requireAll)H=q.permissions.every((Y)=>E1.hasPermission(X,Y));else H=q.permissions.some((Y)=>E1.hasPermission(X,Y));if(!H){let Y=q.requireAll?"all":"any";throw new t(`Access denied. Required ${Y} of permissions: ${q.permissions.join(", ")}`)}}checkMinimumRole($,q){let Q=$$($);if(!Q)throw new t("Authentication required for role level check");let J=Q.roles||[],W=this.rbac.getHighestRoleLevel(J),X=this.rbac.getRole(q);if(!X)throw Error(`Required role not found: ${q}`);let H=X.level||0;if(W<H)throw new t(`Access denied. Minimum role level required: ${q} (level ${H})`)}}function uQ($){return $.get("rbac")||null}function B4($){return $$($)?.roles||[]}function cQ($){let q=uQ($),Q=B4($);if(!q)return[];let J=new Set;for(let W of Q)q.getRolePermissions(W).forEach((H)=>J.add(H));return Array.from(J)}function kY($,q){return B4($).includes(q)}function IY($,q){let Q=cQ($);return E1.hasPermission(Q,q)}v$();class dQ{config;name="rbac";version="1.0.0";dependencies=["auth"];rbac;guard;constructor($={}){this.config=$;if($.rbac)this.rbac=$.rbac;else if($.useDefaults!==!1)this.rbac=Y4();else this.rbac=new R1;if($.roles)this.rbac.defineRoles($.roles);this.guard=new s1(this.rbac)}async install($){let q=w4(this.rbac);if($.use(q),$.getContainer().register(R1,{factory:()=>this.rbac,scope:"singleton"}),$.getContainer().register(s1,{factory:()=>this.guard,scope:"singleton"}),this.injectRouteGuards($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($)}injectRouteGuards($){let q=$.getMetadata();for(let Q of q.getRoutes())if(Q.roles||Q.permissions||Q.minimumRole){let J=this.buildRBACMiddleware(Q);q.registerRoute({...Q,middleware:[J,...Q.middleware||[]]})}}buildRBACMiddleware($){let q=this.guard,Q=$.roles?.config,J=$.permissions?.config,W=$.minimumRole;return async(X,H)=>{if(!$$(X))throw new a("Authentication required");if(Q)q.checkRoles(X,Q);if(J)q.checkPermissions(X,J);if(W)q.checkMinimumRole(X,W.roleName);await H()}}addManagementRoutes($){let q=this.config.routes||{};$.get(q.roles||"/rbac/roles",{handler:(Q)=>{let J=this.rbac.getAllRoles();return Q.json({success:!0,roles:J.map((W)=>({name:W.name,description:W.description,permissions:W.permissions,inherits:W.inherits,level:W.level}))})}}),$.get("/rbac/roles/:roleName",{handler:(Q)=>{let J=Q.req.param("roleName"),W=this.rbac.getRole(J);if(!W)return Q.json({error:"Role not found"},404);let X=this.rbac.getRolePermissions(J),H=this.rbac.getRoleHierarchy(J);return Q.json({success:!0,role:{...W,effectivePermissions:X,hierarchy:H}})}}),$.get("/rbac/roles/:roleName/permissions",{handler:(Q)=>{let J=Q.req.param("roleName");if(!this.rbac.roleExists(J))return Q.json({error:"Role not found"},404);let W=this.rbac.getRolePermissions(J);return Q.json({success:!0,role:J,permissions:W})}}),$.post("/rbac/check-permission",{handler:async(Q)=>{let J=await Q.req.json(),{roles:W,permission:X}=J;if(!Array.isArray(W)||!X)return Q.json({error:"Invalid request body"},400);let H=this.rbac.userHasPermission(W,X);return Q.json({success:!0,hasPermission:H,roles:W,permission:X})}}),$.post("/rbac/check-roles",{handler:async(Q)=>{let J=await Q.req.json(),{userRoles:W,requiredRoles:X,requireAll:H=!1}=J;if(!Array.isArray(W)||!Array.isArray(X))return Q.json({error:"Invalid request body"},400);let Y=H?this.rbac.userHasRoles(W,X):this.rbac.userHasAnyRole(W,X);return Q.json({success:!0,hasRoles:Y,userRoles:W,requiredRoles:X,requireAll:H})}}),$.post("/rbac/effective-roles",{handler:async(Q)=>{let J=await Q.req.json(),{roles:W}=J;if(!Array.isArray(W))return Q.json({error:"Invalid request body"},400);let X=this.rbac.getEffectiveRoles(W);return Q.json({success:!0,inputRoles:W,effectiveRoles:X})}}),$.post("/rbac/user-permissions",{handler:async(Q)=>{let J=await Q.req.json(),{roles:W}=J;if(!Array.isArray(W))return Q.json({error:"Invalid request body"},400);let X=new Set;for(let H of W)if(this.rbac.roleExists(H))this.rbac.getRolePermissions(H).forEach((G)=>X.add(G));return Q.json({success:!0,roles:W,permissions:Array.from(X)})}})}getRBACManager(){return this.rbac}getGuard(){return this.guard}}class r1{resourcePermissions=new Map;permissionPolicies=new Map;grantPermission($){let q=this.getPermissionKey($.userId,$.resource);if(!this.resourcePermissions.has(q))this.resourcePermissions.set(q,[]);this.resourcePermissions.get(q).push($)}revokePermission($,q,Q){let J=this.getPermissionKey($,q),X=(this.resourcePermissions.get(J)||[]).filter((H)=>Q?H.resourceId!==Q:!0);if(X.length===0)this.resourcePermissions.delete(J);else this.resourcePermissions.set(J,X)}hasPermission($){let{user:q,resource:Q,action:J,attributes:W}=$;if(this.checkRoleBasedPermission(q,J,Q))return!0;let X=this.getPermissionKey(q.id,Q?.constructor?.name||"unknown"),H=this.resourcePermissions.get(X)||[];for(let Y of H){if(Y.expiresAt&&Y.expiresAt<new Date)continue;if(Y.resourceId&&Q?.id!==Y.resourceId)continue;for(let G of Y.permissions)if(this.matchesPermission(G,J,Q,W)){if(G.conditions&&!this.evaluateConditions(G.conditions,$))continue;return!0}}return this.checkPermissionPolicies($)}getUserPermissions($,q,Q){let J=this.getPermissionKey($,q),W=this.resourcePermissions.get(J)||[],X=[];for(let H of W){if(H.expiresAt&&H.expiresAt<new Date)continue;if(Q&&H.resourceId&&H.resourceId!==Q)continue;X.push(...H.permissions)}return X}getUserResources($){let q=new Set;for(let[Q,J]of this.resourcePermissions.entries())if(Q.startsWith(`${$}:`)){let W=Q.substring($.length+1);q.add(W)}return Array.from(q)}definePolicy($,q){this.permissionPolicies.set($,q)}filterResources($,q,Q,J=(W)=>W.constructor.name){return $.filter((W)=>{let X={user:q,resource:W,action:Q};return this.hasPermission(X)})}filterAttributes($,q,Q,J){let W={user:q,resource:$,action:Q,attributes:J};if(!this.hasPermission(W))return[];let X=$?.constructor?.name||"unknown",H=this.getUserPermissions(q.id,X,$?.id),Y=new Set;for(let G of H)if(G.action===Q||G.action==="*")if(G.attributes)G.attributes.forEach((V)=>Y.add(V));else J.forEach((V)=>Y.add(V));return Array.from(Y)}getPermissionKey($,q){return`${$}:${q}`}checkRoleBasedPermission($,q,Q){return!1}matchesPermission($,q,Q,J){if($.action!=="*"&&$.action!==q)return!1;let W=Q?.constructor?.name||"unknown";if($.resource!=="*"&&$.resource!==W)return!1;if(J&&$.attributes){if(!J.some((H)=>$.attributes.includes(H)||$.attributes.includes("*")))return!1}return!0}evaluateConditions($,q){return $.every((Q)=>this.evaluateCondition(Q,q))}evaluateCondition($,q){let Q=this.getFieldValue($.field,q);switch($.operator){case"eq":return Q===$.value;case"ne":return Q!==$.value;case"in":return Array.isArray($.value)&&$.value.includes(Q);case"nin":return Array.isArray($.value)&&!$.value.includes(Q);case"gt":return Q>$.value;case"gte":return Q>=$.value;case"lt":return Q<$.value;case"lte":return Q<=$.value;case"contains":return String(Q).includes(String($.value));case"startsWith":return String(Q).startsWith(String($.value));case"endsWith":return String(Q).endsWith(String($.value));default:return!1}}getFieldValue($,q){let Q=$.split("."),J=q;for(let W of Q)if(J&&typeof J==="object")J=J[W];else return;return J}checkPermissionPolicies($){for(let q of this.permissionPolicies.values())if(q.evaluate($))return!0;return!1}}class c0{name="ownership";description="User can access resources they own";evaluate($){let{user:q,resource:Q}=$;if(!Q||!q)return!1;return Q.userId===q.id||Q.ownerId===q.id||Q.createdBy===q.id||Q.owner===q.id}}class d0{name="team-membership";description="User can access resources belonging to their team";evaluate($){let{user:q,resource:Q}=$;if(!Q||!q||!q.teamId)return!1;return Q.teamId===q.teamId}}class n0{name="public-resource";description="Anyone can read public resources";evaluate($){let{resource:q,action:Q}=$;if(!q||Q!=="read")return!1;return q.isPublic===!0||q.visibility==="public"}}var nQ=B.object({action:B.string(),resource:B.string(),conditions:B.array(B.object({field:B.string(),operator:B.enum(["eq","ne","in","nin","gt","gte","lt","lte","contains","startsWith","endsWith"]),value:B.any()})).optional(),attributes:B.array(B.string()).optional()}),bY=B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional(),permissions:B.array(nQ),grantedBy:B.string().optional(),grantedAt:B.date().optional(),expiresAt:B.date().optional()}),PY=B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()});v$();function g$($){return(q,Q)=>{let J={config:$};d.defineResourcePermission(q,Q,J)}}function ZY($,q){return g$({action:"read",resource:$,attributes:q})}function fY($,q){return g$({action:"write",resource:$,attributes:q})}function xY($,q){return g$({action:"update",resource:$,attributes:q})}function TY($){return g$({action:"delete",resource:$})}function hY($="access"){return g$({action:$,conditions:[{field:"resource.userId",operator:"eq",value:"{{user.id}}"}]})}function vY($="access"){return g$({action:$,conditions:[{field:"resource.teamId",operator:"eq",value:"{{user.teamId}}"}]})}function gY(){return g$({action:"read",conditions:[{field:"resource.isPublic",operator:"eq",value:!0}]})}function mY($="read"){return(q,Q,J)=>{if(Q)d.defineParameter(q,Q,J,{index:J,type:"filtered-resource",required:!0,metadata:{action:$}})}}function yY($="read"){return(q,Q,J)=>{if(Q)d.defineParameter(q,Q,J,{index:J,type:"filtered-attributes",required:!0,metadata:{action:$}})}}function V4($){return async(q,Q)=>{q.set("permissionManager",$),await Q()}}class a1{permissionManager;constructor($){this.permissionManager=$}checkResourcePermission($,q,Q){let J=$$($);if(!J)throw new t("Authentication required for permission check");let W={user:J,resource:Q,action:q.action,attributes:q.attributes};if(q.conditions)W.conditions=q.conditions.map((H)=>({...H,value:this.resolveTemplateValue(H.value,W)}));if(!this.permissionManager.hasPermission(W))throw new t(`Access denied. Required permission: ${q.action} on ${q.resource||"resource"}`)}filterResource($,q,Q){let J=$$($);if(!J)return null;let W={user:J,resource:q,action:Q};return this.permissionManager.hasPermission(W)?q:null}filterResources($,q,Q){let J=$$($);if(!J)return[];return this.permissionManager.filterResources(q,J,Q)}filterAttributes($,q,Q,J){let W=$$($);if(!W)return[];return this.permissionManager.filterAttributes(q,W,Q,J)}resolveTemplateValue($,q){if(typeof $==="string"&&$.startsWith("{{")&&$.endsWith("}}")){let Q=$.slice(2,-2);return this.getNestedValue(q,Q)}return $}getNestedValue($,q){return q.split(".").reduce((Q,J)=>Q?.[J],$)}}function F4($){return $.get("permissionManager")||null}function pQ($,q,Q,J){let W=F4($),X=$$($);if(!W||!X)return!1;let H={user:X,resource:q,action:Q,attributes:J};return W.hasPermission(H)}function lY($,q,Q){let J=F4($),W=$$($);if(!J||!W)return[];return J.getUserPermissions(W.id,q,Q).map((H)=>H.action)}function uY($,q,Q){return pQ($,q,Q)}class iQ{config;name="permissions";version="1.0.0";dependencies=["auth"];permissionManager;guard;constructor($={}){this.config=$;if(this.permissionManager=$.permissionManager||new r1,$.enableDefaultPolicies!==!1)this.permissionManager.definePolicy("ownership",new c0),this.permissionManager.definePolicy("team-membership",new d0),this.permissionManager.definePolicy("public-resource",new n0);this.guard=new a1(this.permissionManager)}async install($){let q=V4(this.permissionManager);if($.use(q),$.getContainer().register(r1,{factory:()=>this.permissionManager,scope:"singleton"}),$.getContainer().register(a1,{factory:()=>this.guard,scope:"singleton"}),this.extendRouterCompiler($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($)}extendRouterCompiler($){let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getMetadata().getRoutes();for(let J of Q)if(J.resourcePermission)this.addPermissionGuards($,J)}}addPermissionGuards($,q){}addManagementRoutes($){let q=this.config.routes||{};$.post(q.grant||"/permissions/grant",{handler:async(Q)=>{let J=await Q.req.json(),{userId:W,resource:X,resourceId:H,permissions:Y,expiresAt:G}=J,V={userId:W,resource:X,resourceId:H,permissions:Y,grantedBy:"system",grantedAt:new Date,expiresAt:G?new Date(G):void 0};return this.permissionManager.grantPermission(V),Q.json({success:!0,message:"Permission granted successfully",permission:V})},schema:{body:B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional(),permissions:B.array(B.object({action:B.string(),resource:B.string(),conditions:B.array(B.any()).optional(),attributes:B.array(B.string()).optional()})),expiresAt:B.string().optional()})}}),$.delete(q.revoke||"/permissions/revoke",{handler:async(Q)=>{let J=await Q.req.json(),{userId:W,resource:X,resourceId:H}=J;return this.permissionManager.revokePermission(W,X,H),Q.json({success:!0,message:"Permission revoked successfully"})},schema:{body:B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional()})}}),$.post(q.check||"/permissions/check",{handler:async(Q)=>{let J=await Q.req.json(),{userId:W,action:X,resource:H,resourceId:Y,attributes:G}=J,V={user:{id:W},resource:Y?{id:Y}:void 0,action:X,attributes:G},D=this.permissionManager.hasPermission(V);return Q.json({success:!0,hasPermission:D,context:{userId:W,action:X,resource:H,resourceId:Y,attributes:G}})},schema:{body:B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()})}}),$.get("/permissions/user/:userId/resource/:resource",{handler:(Q)=>{let J=Q.req.param("userId"),W=Q.req.param("resource"),X=Q.req.query("resourceId"),H=this.permissionManager.getUserPermissions(J,W,X);return Q.json({success:!0,userId:J,resource:W,resourceId:X,permissions:H})}}),$.get("/permissions/user/:userId/resources",{handler:(Q)=>{let J=Q.req.param("userId"),W=this.permissionManager.getUserResources(J);return Q.json({success:!0,userId:J,resources:W})}}),$.post("/permissions/bulk-check",{handler:async(Q)=>{let J=await Q.req.json(),{checks:W}=J,X=W.map((H)=>{let Y={user:{id:H.userId},resource:H.resourceId?{id:H.resourceId}:void 0,action:H.action,attributes:H.attributes},G=this.permissionManager.hasPermission(Y);return{...H,hasPermission:G}});return Q.json({success:!0,results:X})},schema:{body:B.object({checks:B.array(B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()}))})}}),$.post("/permissions/filter-resources",{handler:async(Q)=>{let J=await Q.req.json(),{userId:W,action:X,resources:H}=J,Y={id:W},G=this.permissionManager.filterResources(H,Y,X);return Q.json({success:!0,userId:W,action:X,totalResources:H.length,filteredResources:G.length,resources:G})},schema:{body:B.object({userId:B.string(),action:B.string(),resources:B.array(B.any())})}})}getPermissionManager(){return this.permissionManager}getGuard(){return this.guard}}class S1{sessions=new Map;async get($){let q=this.sessions.get($);if(!q)return null;if(q.expiresAt&&q.expiresAt<new Date)return this.sessions.delete($),null;return q}async set($,q){this.sessions.set($,q)}async destroy($){this.sessions.delete($)}async touch($){let q=this.sessions.get($);if(q)q.updatedAt=new Date,this.sessions.set($,q)}async clear(){this.sessions.clear()}async length(){return this.sessions.size}async all(){return Array.from(this.sessions.values())}cleanup(){let $=new Date;for(let[q,Q]of this.sessions.entries())if(Q.expiresAt&&Q.expiresAt<$)this.sessions.delete(q)}}class p0{redis;prefix="sess:";constructor($,q){this.redis=$;if(q)this.prefix=q}async get($){let q=this.prefix+$,Q=await this.redis.get(q);if(!Q)return null;try{let J=JSON.parse(Q);if(J.createdAt=new Date(J.createdAt),J.updatedAt=new Date(J.updatedAt),J.expiresAt)J.expiresAt=new Date(J.expiresAt);return J}catch(J){return null}}async set($,q){let Q=this.prefix+$,J=JSON.stringify(q);if(q.expiresAt){let W=Math.floor((q.expiresAt.getTime()-Date.now())/1000);if(W>0)await this.redis.setex(Q,W,J)}else await this.redis.set(Q,J)}async destroy($){let q=this.prefix+$;await this.redis.del(q)}async touch($){let q=await this.get($);if(q)q.updatedAt=new Date,await this.set($,q)}async clear(){let $=await this.redis.keys(this.prefix+"*");if($.length>0)await this.redis.del(...$)}async length(){return(await this.redis.keys(this.prefix+"*")).length}async all(){let $=await this.redis.keys(this.prefix+"*"),q=[];for(let Q of $){let J=await this.redis.get(Q);if(J)try{let W=JSON.parse(J);if(W.createdAt=new Date(W.createdAt),W.updatedAt=new Date(W.updatedAt),W.expiresAt)W.expiresAt=new Date(W.expiresAt);q.push(W)}catch(W){}}return q}}class t1{store;config;constructor($,q){this.store=$;this.config={name:"sessionId",maxAge:86400000,secure:!1,httpOnly:!0,sameSite:"lax",path:"/",rolling:!1,genid:()=>crypto.randomUUID(),...q,domain:q.domain}}async createSession($,q={},Q){let J=this.config.genid(),W=new Date,X=Q?.maxAge||this.config.maxAge,H={id:J,userId:$,data:q,createdAt:W,updatedAt:W,expiresAt:new Date(W.getTime()+X),ipAddress:Q?.ipAddress,userAgent:Q?.userAgent,csrfToken:this.generateCSRFToken()};return await this.store.set(J,H),H}async getSession($){return await this.store.get($)}async updateSession($,q){let Q=await this.store.get($);if(!Q)return null;if(Q.data={...Q.data,...q},Q.updatedAt=new Date,this.config.rolling)Q.expiresAt=new Date(Date.now()+this.config.maxAge);return await this.store.set($,Q),Q}async touchSession($){if(this.config.rolling){let q=await this.store.get($);if(q)q.updatedAt=new Date,q.expiresAt=new Date(Date.now()+this.config.maxAge),await this.store.set($,q)}else await this.store.touch($)}async destroySession($){await this.store.destroy($)}async regenerateSession($){let q=await this.store.get($);if(!q)return null;let Q=this.config.genid(),J={...q,id:Q,updatedAt:new Date,csrfToken:this.generateCSRFToken()};return await this.store.set(Q,J),await this.store.destroy($),J}async getUserSessions($){return(await this.store.all()).filter((Q)=>Q.userId===$)}async destroyUserSessions($){let q=await this.getUserSessions($);for(let Q of q)await this.store.destroy(Q.id)}validateCSRFToken($,q){return $.csrfToken===q}generateCSRFToken(){return crypto.randomUUID()}getCookieOptions(){let $={maxAge:this.config.maxAge,secure:this.config.secure,httpOnly:this.config.httpOnly,sameSite:this.config.sameSite,path:this.config.path};if(this.config.domain)$.domain=this.config.domain;return $}getConfig(){return{...this.config}}getStore(){return this.store}}class e1{tokenStore=new Map;tokenTTL=3600000;generateToken($){let q=crypto.randomUUID(),Q=new Date(Date.now()+this.tokenTTL);return this.tokenStore.set($,{token:q,expiresAt:Q}),this.cleanup(),q}validateToken($,q){let Q=this.tokenStore.get($);if(!Q)return!1;if(Q.expiresAt<new Date)return this.tokenStore.delete($),!1;return Q.token===q}removeToken($){this.tokenStore.delete($)}cleanup(){let $=new Date;for(let[q,Q]of this.tokenStore.entries())if(Q.expiresAt<$)this.tokenStore.delete(q)}}var cY=B.object({id:B.string(),userId:B.string(),data:B.record(B.any()),createdAt:B.date(),updatedAt:B.date(),expiresAt:B.date().optional(),ipAddress:B.string().optional(),userAgent:B.string().optional(),csrfToken:B.string().optional()}),dY=B.object({name:B.string().optional(),secret:B.string(),maxAge:B.number().optional(),secure:B.boolean().optional(),httpOnly:B.boolean().optional(),sameSite:B.enum(["strict","lax","none"]).optional(),domain:B.string().optional(),path:B.string().optional(),rolling:B.boolean().optional()}),nY=B.object({userId:B.string(),data:B.record(B.any()).optional(),maxAge:B.number().optional(),ipAddress:B.string().optional(),userAgent:B.string().optional()}),pY=B.object({data:B.record(B.any())});sQ();var aQ=/^[\w!#$%&'*.^`|~+-]+$/,eY=/^[ !#-:<-[\]-~]*$/,rQ=($)=>{let q=0,Q=$.length;while(q<Q){let J=$.charCodeAt(q);if(J!==32&&J!==9)break;q++}while(Q>q){let J=$.charCodeAt(Q-1);if(J!==32&&J!==9)break;Q--}return q===0&&Q===$.length?$:$.slice(q,Q)},U4=($,q)=>{if(q&&$.indexOf(q)===-1)return{};let Q=$.split(";"),J={};for(let W of Q){let X=W.indexOf("=");if(X===-1)continue;let H=rQ(W.substring(0,X));if(q&&q!==H||!aQ.test(H))continue;let Y=rQ(W.substring(X+1));if(Y.startsWith('"')&&Y.endsWith('"'))Y=Y.slice(1,-1);if(eY.test(Y)){if(J[H]=Y.indexOf("%")!==-1?o0(Y,D4):Y,q)break}}return J};var $G=($,q,Q={})=>{if(!aQ.test($))throw Error("Invalid cookie name");let J=`${$}=${q}`;if($.startsWith("__Secure-")&&!Q.secure)throw Error("__Secure- Cookie must have Secure attributes");if($.startsWith("__Host-")){if(!Q.secure)throw Error("__Host- Cookie must have Secure attributes");if(Q.path!=="/")throw Error('__Host- Cookie must have Path attributes with "/"');if(Q.domain)throw Error("__Host- Cookie must not have Domain attributes")}for(let W of["domain","path"])if(Q[W]&&/[;\r\n]/.test(Q[W]))throw Error(`${W} must not contain ";", "\\r", or "\\n"`);if(Q&&typeof Q.maxAge==="number"&&Q.maxAge>=0){if(Q.maxAge>34560000)throw Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");J+=`; Max-Age=${Q.maxAge|0}`}if(Q.domain&&Q.prefix!=="host")J+=`; Domain=${Q.domain}`;if(Q.path)J+=`; Path=${Q.path}`;if(Q.expires){if(Q.expires.getTime()-Date.now()>34560000000)throw Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");J+=`; Expires=${Q.expires.toUTCString()}`}if(Q.httpOnly)J+="; HttpOnly";if(Q.secure)J+="; Secure";if(Q.sameSite)J+=`; SameSite=${Q.sameSite.charAt(0).toUpperCase()+Q.sameSite.slice(1)}`;if(Q.priority)J+=`; Priority=${Q.priority.charAt(0).toUpperCase()+Q.priority.slice(1)}`;if(Q.partitioned){if(!Q.secure)throw Error("Partitioned Cookie must have Secure attributes");J+="; Partitioned"}return J},s0=($,q,Q)=>{return q=encodeURIComponent(q),$G($,q,Q)};var tQ=($,q,Q)=>{let J=$.req.raw.headers.get("Cookie");if(typeof q==="string"){if(!J)return;let X=q;if(Q==="secure")X="__Secure-"+q;else if(Q==="host")X="__Host-"+q;return U4(J,X)[X]}if(!J)return{};return U4(J)};var qG=($,q,Q)=>{let J;if(Q?.prefix==="secure")J=s0("__Secure-"+$,q,{path:"/",...Q,secure:!0});else if(Q?.prefix==="host")J=s0("__Host-"+$,q,{...Q,path:"/",secure:!0,domain:void 0});else J=s0($,q,{path:"/",...Q});return J},r0=($,q,Q,J)=>{let W=qG(q,Q,J);$.header("Set-Cookie",W,{append:!0})};v$();function QG($={}){return(q,Q)=>{let J={config:$};d.defineSession(q,Q,J)}}function JG(){return($,q,Q)=>{if(q)d.defineParameter($,q,Q,{index:Q,type:"current-session",required:!0})}}function WG($){return(q,Q,J)=>{if(Q)d.defineParameter(q,Q,J,{index:J,type:"session-data",required:!1,metadata:{key:$}})}}function XG(){return($,q,Q)=>{if(q)d.defineParameter($,q,Q,{index:Q,type:"csrf-token",required:!0})}}function HG(){return($,q)=>{d.defineCSRF($,q,{required:!0})}}function z4($,q){return async(Q,J)=>{let W=$.getConfig(),X=tQ(Q,W.name),H=null;if(X){if(H=await $.getSession(X),H)await $.touchSession(X)}Q.set("session",H),Q.set("sessionManager",$),Q.set("csrfProtection",q),await J()}}class q0{sessionManager;csrfProtection;constructor($,q){this.sessionManager=$;this.csrfProtection=q}checkSession($,q){let Q=N$($);if(q.required&&!Q)throw new a("Session required");if(Q&&q.csrf)this.checkCSRF($,Q)}checkCSRF($,q){if(!this.csrfProtection)throw Error("CSRF protection not configured");let Q=$.req.header("X-CSRF-Token")||$.req.query("_csrf");if(!Q)throw new t("CSRF token required");if(!this.csrfProtection.validateToken(q.id,Q))throw new t("Invalid CSRF token")}async createSession($,q,Q={}){let J=$0($);if(!J)throw Error("Session manager not available");let W=$.req.header("X-Forwarded-For")||$.req.header("X-Real-IP")||"unknown",X=$.req.header("User-Agent")||"unknown",H=await J.createSession(q,Q,{ipAddress:W,userAgent:X}),Y=J.getCookieOptions();return r0($,J.getConfig().name,H.id,Y),$.set("session",H),H}async updateSession($,q){let Q=N$($),J=$0($);if(!Q||!J)return null;let W=await J.updateSession(Q.id,q);if(W)$.set("session",W);return W}async destroySession($){let q=N$($),Q=$0($);if(!q||!Q)return;await Q.destroySession(q.id);let J=Q.getConfig();if(r0($,J.name,"",{...Q.getCookieOptions(),maxAge:0}),$.set("session",null),this.csrfProtection)this.csrfProtection.removeToken(q.id)}async regenerateSession($){let q=N$($),Q=$0($);if(!q||!Q)return null;let J=await Q.regenerateSession(q.id);if(J){let W=Q.getCookieOptions();if(r0($,Q.getConfig().name,J.id,W),$.set("session",J),this.csrfProtection)this.csrfProtection.removeToken(q.id),this.csrfProtection.generateToken(J.id)}return J}generateCSRFToken($){let q=N$($);if(!q||!this.csrfProtection)return null;return this.csrfProtection.generateToken(q.id)}}function N$($){return $.get("session")||null}function $0($){return $.get("sessionManager")||null}function YG($){return $.get("csrfProtection")||null}function GG($,q){let Q=N$($);if(!Q)return null;if(q)return Q.data[q];return Q.data}function wG($){return N$($)!==null}function BG($){return N$($)?.userId||null}function VG($,q,Q){let J=N$($);if(J)J.data[q]=Q,$.set("session",J)}function FG($,q){let Q=N$($);if(Q&&q in Q.data)delete Q.data[q],$.set("session",Q)}class eQ{config;name="session";version="1.0.0";sessionManager;csrfProtection;guard;compileExtended=!1;cleanupIntervalId;constructor($){this.config=$;let q;if($.store)q=$.store;else if($.storeType==="redis"&&$.redis)q=new p0($.redis);else q=new S1;if(this.sessionManager=new t1(q,$.session),$.csrf?.enabled!==!1)this.csrfProtection=new e1;this.guard=new q0(this.sessionManager,this.csrfProtection)}async install($){let q=z4(this.sessionManager,this.csrfProtection);if($.use(q),$.getContainer().register(t1,{factory:()=>this.sessionManager,scope:"singleton"}),$.getContainer().register(q0,{factory:()=>this.guard,scope:"singleton"}),this.csrfProtection)$.getContainer().register(e1,{factory:()=>this.csrfProtection,scope:"singleton"});if(this.extendRouterCompiler($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($);if(this.sessionManager.getStore()instanceof S1)this.setupCleanup()}extendRouterCompiler($){if(this.compileExtended)return;this.compileExtended=!0;let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getMetadata().getRoutes();for(let J of Q)if(J.session||J.csrf)this.addSessionGuards($,J)}}addSessionGuards($,q){}addManagementRoutes($){let q=this.config.routes||{};if($.post(q.create||"/session/create",{handler:async(Q)=>{let J=await Q.req.json(),{userId:W,data:X}=J,H=await this.guard.createSession(Q,W,X);return Q.json({success:!0,message:"Session created successfully",session:{id:H.id,userId:H.userId,data:H.data,createdAt:H.createdAt,expiresAt:H.expiresAt}})},schema:{body:B.object({userId:B.string(),data:B.record(B.any()).optional()})}}),$.post(q.destroy||"/session/destroy",{handler:async(Q)=>{return await this.guard.destroySession(Q),Q.json({success:!0,message:"Session destroyed successfully"})}}),$.post(q.regenerate||"/session/regenerate",{handler:async(Q)=>{let J=await this.guard.regenerateSession(Q);if(!J)return Q.json({error:"No active session to regenerate"},400);return Q.json({success:!0,message:"Session regenerated successfully",session:{id:J.id,userId:J.userId,data:J.data,createdAt:J.createdAt,expiresAt:J.expiresAt}})}}),$.get(q.data||"/session/data",{handler:(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);return Q.json({success:!0,data:J.data})}}),$.put(q.data||"/session/data",{handler:async(Q)=>{let J=await Q.req.json(),{data:W}=J,X=await this.guard.updateSession(Q,W);if(!X)return Q.json({error:"No active session to update"},400);return Q.json({success:!0,message:"Session data updated successfully",data:X.data})},schema:{body:B.object({data:B.record(B.any())})}}),this.csrfProtection)$.get(q.csrf||"/session/csrf-token",{handler:(Q)=>{let J=this.guard.generateCSRFToken(Q);if(!J)return Q.json({error:"No active session or CSRF not enabled"},400);return Q.json({success:!0,csrfToken:J})}});$.get("/session/info",{handler:(Q)=>{let J=Q.get("session");if(!J)return Q.json({success:!0,authenticated:!1,session:null});return Q.json({success:!0,authenticated:!0,session:{id:J.id,userId:J.userId,createdAt:J.createdAt,updatedAt:J.updatedAt,expiresAt:J.expiresAt,ipAddress:J.ipAddress,userAgent:J.userAgent}})}}),$.get("/session/all",{handler:async(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);let W=await this.sessionManager.getUserSessions(J.userId);return Q.json({success:!0,sessions:W.map((X)=>({id:X.id,createdAt:X.createdAt,updatedAt:X.updatedAt,expiresAt:X.expiresAt,ipAddress:X.ipAddress,userAgent:X.userAgent,current:X.id===J.id}))})}}),$.post("/session/destroy-all",{handler:async(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);return await this.sessionManager.destroyUserSessions(J.userId),Q.json({success:!0,message:"All sessions destroyed successfully"})}}),$.get("/session/stats",{handler:async(Q)=>{if(!Q.get("session"))return Q.json({error:"Authentication required"},401);let W=this.sessionManager.getStore(),X=await W.length(),H=await W.all(),Y={totalSessions:X,activeSessions:H.filter((G)=>!G.expiresAt||G.expiresAt>new Date).length,expiredSessions:H.filter((G)=>G.expiresAt&&G.expiresAt<=new Date).length,uniqueUsers:new Set(H.map((G)=>G.userId)).size};return Q.json({success:!0,stats:Y})}})}setupCleanup(){if(this.cleanupIntervalId)return;let $=900000;if(this.cleanupIntervalId=setInterval(()=>{let q=this.sessionManager.getStore();if(q instanceof S1)q.cleanup()},$),typeof process<"u"&&process.on)process.on("exit",()=>{if(this.cleanupIntervalId)clearInterval(this.cleanupIntervalId)})}getSessionManager(){return this.sessionManager}getCSRFProtection(){return this.csrfProtection}getGuard(){return this.guard}}
|
|
17
|
-
|
|
18
|
-
//# debugId=10F73B0917DD3E9D64756E2164756E21
|
|
5
|
+
//# debugId=1D465B4B4A87599D64756E2164756E21
|