veloce-ts 0.2.2 → 0.2.4

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/src/index.js +11 -11
  3. package/dist/cjs/src/index.js.map +7 -7
  4. package/dist/cjs/src/testing/index.js +4 -4
  5. package/dist/cjs/src/testing/index.js.map +3 -3
  6. package/dist/cjs/src/websocket/index.js +15 -2
  7. package/dist/cjs/src/websocket/index.js.map +7 -4
  8. package/dist/esm/chunk-2100y16g.js +5 -0
  9. package/dist/esm/chunk-2100y16g.js.map +10 -0
  10. package/dist/esm/{chunk-9f0s1qbb.js → chunk-5q75d71c.js} +2 -2
  11. package/dist/esm/{chunk-9f0s1qbb.js.map → chunk-5q75d71c.js.map} +1 -1
  12. package/dist/esm/{chunk-09p9prja.js → chunk-8dpc6an2.js} +1 -1
  13. package/dist/esm/{chunk-r8ssy5cv.js → chunk-9v7atckx.js} +2 -2
  14. package/dist/esm/{chunk-r8ssy5cv.js.map → chunk-9v7atckx.js.map} +1 -1
  15. package/dist/esm/{chunk-dpjkne9h.js → chunk-bvstdn0t.js} +1 -1
  16. package/dist/esm/{chunk-dfhwaw13.js → chunk-ctwpr5gr.js} +1 -1
  17. package/dist/esm/{chunk-q0w1t07v.js → chunk-dfay135z.js} +3 -3
  18. package/dist/esm/{chunk-q0w1t07v.js.map → chunk-dfay135z.js.map} +1 -1
  19. package/dist/esm/{chunk-3vd5qsws.js → chunk-dtw2tbsd.js} +2 -2
  20. package/dist/esm/{chunk-3vd5qsws.js.map → chunk-dtw2tbsd.js.map} +1 -1
  21. package/dist/esm/{chunk-qg4ngg5j.js → chunk-k66rn4fj.js} +3 -3
  22. package/dist/esm/{chunk-qg4ngg5j.js.map → chunk-k66rn4fj.js.map} +1 -1
  23. package/dist/esm/{chunk-vzhqg5mb.js → chunk-mky5qqg0.js} +3 -3
  24. package/dist/esm/{chunk-vzhqg5mb.js.map → chunk-mky5qqg0.js.map} +1 -1
  25. package/dist/esm/{chunk-vkkzgaf7.js → chunk-mznkhz9c.js} +2 -2
  26. package/dist/esm/{chunk-vkkzgaf7.js.map → chunk-mznkhz9c.js.map} +1 -1
  27. package/dist/esm/{chunk-3nhrrhv9.js → chunk-s5z0wb7e.js} +3 -3
  28. package/dist/esm/{chunk-3nhrrhv9.js.map → chunk-s5z0wb7e.js.map} +1 -1
  29. package/dist/esm/{chunk-gy9nsvnk.js → chunk-vh4sxcpe.js} +3 -3
  30. package/dist/esm/{chunk-gy9nsvnk.js.map → chunk-vh4sxcpe.js.map} +1 -1
  31. package/dist/esm/{chunk-4s66h6qw.js → chunk-xa333k40.js} +1 -1
  32. package/dist/esm/{chunk-f64j5zbr.js → chunk-y262e56g.js} +2 -2
  33. package/dist/esm/{chunk-f64j5zbr.js.map → chunk-y262e56g.js.map} +1 -1
  34. package/dist/esm/{chunk-sv2c5krg.js → chunk-yq3gf9ts.js} +3 -3
  35. package/dist/esm/{chunk-sv2c5krg.js.map → chunk-yq3gf9ts.js.map} +1 -1
  36. package/dist/esm/src/cli/index.js +3 -3
  37. package/dist/esm/src/cli/index.js.map +1 -1
  38. package/dist/esm/src/docs/index.js +3 -3
  39. package/dist/esm/src/docs/index.js.map +1 -1
  40. package/dist/esm/src/errors/index.js +2 -2
  41. package/dist/esm/src/errors/index.js.map +1 -1
  42. package/dist/esm/src/graphql/index.js +2 -2
  43. package/dist/esm/src/graphql/index.js.map +1 -1
  44. package/dist/esm/src/index.js +3 -3
  45. package/dist/esm/src/index.js.map +4 -5
  46. package/dist/esm/src/middleware/index.js +2 -2
  47. package/dist/esm/src/middleware/index.js.map +1 -1
  48. package/dist/esm/src/plugins/index.js +3 -3
  49. package/dist/esm/src/plugins/index.js.map +1 -1
  50. package/dist/esm/src/testing/index.js +2 -2
  51. package/dist/esm/src/testing/index.js.map +4 -5
  52. package/dist/esm/src/types/index.js +2 -2
  53. package/dist/esm/src/types/index.js.map +1 -1
  54. package/dist/esm/src/validation/index.js +2 -2
  55. package/dist/esm/src/validation/index.js.map +1 -1
  56. package/dist/esm/src/websocket/index.js +2 -2
  57. package/dist/esm/src/websocket/index.js.map +4 -3
  58. package/dist/types/core/router-compiler.d.ts.map +1 -1
  59. package/dist/types/decorators/params.d.ts +8 -2
  60. package/dist/types/decorators/params.d.ts.map +1 -1
  61. package/dist/types/websocket/index.d.ts +1 -0
  62. package/dist/types/websocket/index.d.ts.map +1 -1
  63. package/package.json +1 -1
  64. /package/dist/esm/{chunk-09p9prja.js.map → chunk-8dpc6an2.js.map} +0 -0
  65. /package/dist/esm/{chunk-dpjkne9h.js.map → chunk-bvstdn0t.js.map} +0 -0
  66. /package/dist/esm/{chunk-dfhwaw13.js.map → chunk-ctwpr5gr.js.map} +0 -0
  67. /package/dist/esm/{chunk-4s66h6qw.js.map → chunk-xa333k40.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- var Yf=Object.create;var{getPrototypeOf:Gf,defineProperty:r0,getOwnPropertyNames:n$,getOwnPropertyDescriptor:qf}=Object,c$=Object.prototype.hasOwnProperty;var _f=($,f,H)=>{H=$!=null?Yf(Gf($)):{};let Q=f||!$||!$.__esModule?r0(H,"default",{value:$,enumerable:!0}):H;for(let X of n$($))if(!c$.call(Q,X))r0(Q,X,{get:()=>$[X],enumerable:!0});return Q},m$=new WeakMap,z1=($)=>{var f=m$.get($),H;if(f)return f;if(f=r0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")n$($).map((Q)=>!c$.call(f,Q)&&r0(f,Q,{get:()=>$[Q],enumerable:!(H=qf($,Q))||H.enumerable}));return m$.set($,f),f},Bf=($,f)=>()=>(f||$((f={exports:{}}).exports,f),f.exports);var t0=($,f)=>{for(var H in f)r0($,H,{get:f[H],enumerable:!0,configurable:!0,set:(Q)=>f[H]=()=>Q})};var u$=($,f)=>()=>($&&(f=$($=0)),f);var _2=Bf(()=>{/*! *****************************************************************************
1
+ var Gf=Object.create;var{getPrototypeOf:qf,defineProperty:r0,getOwnPropertyNames:c$,getOwnPropertyDescriptor:_f}=Object,u$=Object.prototype.hasOwnProperty;var Bf=($,f,H)=>{H=$!=null?Gf(qf($)):{};let Q=f||!$||!$.__esModule?r0(H,"default",{value:$,enumerable:!0}):H;for(let X of c$($))if(!u$.call(Q,X))r0(Q,X,{get:()=>$[X],enumerable:!0});return Q},n$=new WeakMap,w1=($)=>{var f=n$.get($),H;if(f)return f;if(f=r0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")c$($).map((Q)=>!u$.call(f,Q)&&r0(f,Q,{get:()=>$[Q],enumerable:!(H=_f($,Q))||H.enumerable}));return n$.set($,f),f},zf=($,f)=>()=>(f||$((f={exports:{}}).exports,f),f.exports);var t0=($,f)=>{for(var H in f)r0($,H,{get:f[H],enumerable:!0,configurable:!0,set:(Q)=>f[H]=()=>Q})};var y$=($,f)=>()=>($&&(f=$($=0)),f);var B2=zf(()=>{/*! *****************************************************************************
2
2
  Copyright (C) Microsoft. All rights reserved.
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
@@ -11,7 +11,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
11
11
 
12
12
  See the Apache Version 2.0 License for specific language governing permissions
13
13
  and limitations under the License.
14
- ***************************************************************************** */var q2;(function($){(function(f){var H=typeof globalThis==="object"?globalThis:typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:Y(),Q=X($);if(typeof H.Reflect<"u")Q=X(H.Reflect,Q);if(f(Q,H),typeof H.Reflect>"u")H.Reflect=$;function X(G,_){return function(S,A){if(Object.defineProperty(G,S,{configurable:!0,writable:!0,value:A}),_)_(S,A)}}function J(){try{return Function("return this;")()}catch(G){}}function W(){try{return(0,eval)("(function() { return this; })()")}catch(G){}}function Y(){return J()||W()}})(function(f,H){var Q=Object.prototype.hasOwnProperty,X=typeof Symbol==="function",J=X&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",W=X&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",Y=typeof Object.create==="function",G={__proto__:[]}instanceof Array,_=!Y&&!G,S={create:Y?function(){return k1(Object.create(null))}:G?function(){return k1({__proto__:null})}:function(){return k1({})},has:_?function(q,B){return Q.call(q,B)}:function(q,B){return B in q},get:_?function(q,B){return Q.call(q,B)?q[B]:void 0}:function(q,B){return q[B]}},A=Object.getPrototypeOf(Function),k=typeof Map==="function"&&typeof Map.prototype.entries==="function"?Map:Hf(),Z=typeof Set==="function"&&typeof Set.prototype.entries==="function"?Set:Qf(),h=typeof WeakMap==="function"?WeakMap:Xf(),T=X?Symbol.for("@reflect-metadata:registry"):void 0,m=e2(),o=$f(m);function e(q,B,z,L){if(!O(z)){if(!I$(q))throw TypeError();if(!n(B))throw TypeError();if(!n(L)&&!O(L)&&!h0(L))throw TypeError();if(h0(L))L=void 0;return z=q0(z),s2(q,B,z,L)}else{if(!I$(q))throw TypeError();if(!P$(B))throw TypeError();return i2(q,B)}}f("decorate",e);function i(q,B){function z(L,F){if(!n(L))throw TypeError();if(!O(F)&&!t2(F))throw TypeError();O$(q,B,L,F)}return z}f("metadata",i);function $0(q,B,z,L){if(!n(z))throw TypeError();if(!O(L))L=q0(L);return O$(q,B,z,L)}f("defineMetadata",$0);function s(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);return A$(q,B,z)}f("hasMetadata",s);function t(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);return v1(q,B,z)}f("hasOwnMetadata",t);function f0(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);return U$(q,B,z)}f("getMetadata",f0);function C1(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);return C$(q,B,z)}f("getOwnMetadata",C1);function G0(q,B){if(!n(q))throw TypeError();if(!O(B))B=q0(B);return v$(q,B)}f("getMetadataKeys",G0);function O1(q,B){if(!n(q))throw TypeError();if(!O(B))B=q0(B);return h$(q,B)}f("getOwnMetadataKeys",O1);function F$(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);if(!n(B))throw TypeError();if(!O(z))z=q0(z);var L=p0(B,z,!1);if(O(L))return!1;return L.OrdinaryDeleteMetadata(q,B,z)}f("deleteMetadata",F$);function i2(q,B){for(var z=q.length-1;z>=0;--z){var L=q[z],F=L(B);if(!O(F)&&!h0(F)){if(!P$(F))throw TypeError();B=F}}return B}function s2(q,B,z,L){for(var F=q.length-1;F>=0;--F){var c=q[F],y=c(B,z,L);if(!O(y)&&!h0(y)){if(!n(y))throw TypeError();L=y}}return L}function A$(q,B,z){var L=v1(q,B,z);if(L)return!0;var F=M1(B);if(!h0(F))return A$(q,F,z);return!1}function v1(q,B,z){var L=p0(B,z,!1);if(O(L))return!1;return k$(L.OrdinaryHasOwnMetadata(q,B,z))}function U$(q,B,z){var L=v1(q,B,z);if(L)return C$(q,B,z);var F=M1(B);if(!h0(F))return U$(q,F,z);return}function C$(q,B,z){var L=p0(B,z,!1);if(O(L))return;return L.OrdinaryGetOwnMetadata(q,B,z)}function O$(q,B,z,L){var F=p0(z,L,!0);F.OrdinaryDefineOwnMetadata(q,B,z,L)}function v$(q,B){var z=h$(q,B),L=M1(q);if(L===null)return z;var F=v$(L,B);if(F.length<=0)return z;if(z.length<=0)return F;var c=new Z,y=[];for(var I=0,V=z;I<V.length;I++){var R=V[I],E=c.has(R);if(!E)c.add(R),y.push(R)}for(var b=0,K=F;b<K.length;b++){var R=K[b],E=c.has(R);if(!E)c.add(R),y.push(R)}return y}function h$(q,B){var z=p0(q,B,!1);if(!z)return[];return z.OrdinaryOwnMetadataKeys(q,B)}function M$(q){if(q===null)return 1;switch(typeof q){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return q===null?1:6;default:return 6}}function O(q){return q===void 0}function h0(q){return q===null}function o2(q){return typeof q==="symbol"}function n(q){return typeof q==="object"?q!==null:typeof q==="function"}function d2(q,B){switch(M$(q)){case 0:return q;case 1:return q;case 2:return q;case 3:return q;case 4:return q;case 5:return q}var z=B===3?"string":B===5?"number":"default",L=K$(q,J);if(L!==void 0){var F=L.call(q,z);if(n(F))throw TypeError();return F}return p2(q,z==="default"?"number":z)}function p2(q,B){if(B==="string"){var z=q.toString;if(M0(z)){var L=z.call(q);if(!n(L))return L}var F=q.valueOf;if(M0(F)){var L=F.call(q);if(!n(L))return L}}else{var F=q.valueOf;if(M0(F)){var L=F.call(q);if(!n(L))return L}var c=q.toString;if(M0(c)){var L=c.call(q);if(!n(L))return L}}throw TypeError()}function k$(q){return!!q}function r2(q){return""+q}function q0(q){var B=d2(q,3);if(o2(B))return B;return r2(B)}function I$(q){return Array.isArray?Array.isArray(q):q instanceof Object?q instanceof Array:Object.prototype.toString.call(q)==="[object Array]"}function M0(q){return typeof q==="function"}function P$(q){return typeof q==="function"}function t2(q){switch(M$(q)){case 3:return!0;case 4:return!0;default:return!1}}function h1(q,B){return q===B||q!==q&&B!==B}function K$(q,B){var z=q[B];if(z===void 0||z===null)return;if(!M0(z))throw TypeError();return z}function T$(q){var B=K$(q,W);if(!M0(B))throw TypeError();var z=B.call(q);if(!n(z))throw TypeError();return z}function x$(q){return q.value}function g$(q){var B=q.next();return B.done?!1:B}function l$(q){var B=q.return;if(B)B.call(q)}function M1(q){var B=Object.getPrototypeOf(q);if(typeof q!=="function"||q===A)return B;if(B!==A)return B;var z=q.prototype,L=z&&Object.getPrototypeOf(z);if(L==null||L===Object.prototype)return B;var F=L.constructor;if(typeof F!=="function")return B;if(F===q)return B;return F}function a2(){var q;if(!O(T)&&typeof H.Reflect<"u"&&!(T in H.Reflect)&&typeof H.Reflect.defineMetadata==="function")q=ff(H.Reflect);var B,z,L,F=new h,c={registerProvider:y,getProvider:V,setProvider:E};return c;function y(b){if(!Object.isExtensible(c))throw Error("Cannot add provider to a frozen registry.");switch(!0){case q===b:break;case O(B):B=b;break;case B===b:break;case O(z):z=b;break;case z===b:break;default:if(L===void 0)L=new Z;L.add(b);break}}function I(b,K){if(!O(B)){if(B.isProviderFor(b,K))return B;if(!O(z)){if(z.isProviderFor(b,K))return B;if(!O(L)){var x=T$(L);while(!0){var u=g$(x);if(!u)return;var H0=x$(u);if(H0.isProviderFor(b,K))return l$(x),H0}}}}if(!O(q)&&q.isProviderFor(b,K))return q;return}function V(b,K){var x=F.get(b),u;if(!O(x))u=x.get(K);if(!O(u))return u;if(u=I(b,K),!O(u)){if(O(x))x=new k,F.set(b,x);x.set(K,u)}return u}function R(b){if(O(b))throw TypeError();return B===b||z===b||!O(L)&&L.has(b)}function E(b,K,x){if(!R(x))throw Error("Metadata provider not registered.");var u=V(b,K);if(u!==x){if(!O(u))return!1;var H0=F.get(b);if(O(H0))H0=new k,F.set(b,H0);H0.set(K,x)}return!0}}function e2(){var q;if(!O(T)&&n(H.Reflect)&&Object.isExtensible(H.Reflect))q=H.Reflect[T];if(O(q))q=a2();if(!O(T)&&n(H.Reflect)&&Object.isExtensible(H.Reflect))Object.defineProperty(H.Reflect,T,{enumerable:!1,configurable:!1,writable:!1,value:q});return q}function $f(q){var B=new h,z={isProviderFor:function(R,E){var b=B.get(R);if(O(b))return!1;return b.has(E)},OrdinaryDefineOwnMetadata:y,OrdinaryHasOwnMetadata:F,OrdinaryGetOwnMetadata:c,OrdinaryOwnMetadataKeys:I,OrdinaryDeleteMetadata:V};return m.registerProvider(z),z;function L(R,E,b){var K=B.get(R),x=!1;if(O(K)){if(!b)return;K=new k,B.set(R,K),x=!0}var u=K.get(E);if(O(u)){if(!b)return;if(u=new k,K.set(E,u),!q.setProvider(R,E,z)){if(K.delete(E),x)B.delete(R);throw Error("Wrong provider for target.")}}return u}function F(R,E,b){var K=L(E,b,!1);if(O(K))return!1;return k$(K.has(R))}function c(R,E,b){var K=L(E,b,!1);if(O(K))return;return K.get(R)}function y(R,E,b,K){var x=L(b,K,!0);x.set(R,E)}function I(R,E){var b=[],K=L(R,E,!1);if(O(K))return b;var x=K.keys(),u=T$(x),H0=0;while(!0){var Z$=g$(u);if(!Z$)return b.length=H0,b;var Jf=x$(Z$);try{b[H0]=Jf}catch(Wf){try{l$(u)}finally{throw Wf}}H0++}}function V(R,E,b){var K=L(E,b,!1);if(O(K))return!1;if(!K.delete(R))return!1;if(K.size===0){var x=B.get(E);if(!O(x)){if(x.delete(b),x.size===0)B.delete(x)}}return!0}}function ff(q){var{defineMetadata:B,hasOwnMetadata:z,getOwnMetadata:L,getOwnMetadataKeys:F,deleteMetadata:c}=q,y=new h,I={isProviderFor:function(V,R){var E=y.get(V);if(!O(E)&&E.has(R))return!0;if(F(V,R).length){if(O(E))E=new Z,y.set(V,E);return E.add(R),!0}return!1},OrdinaryDefineOwnMetadata:B,OrdinaryHasOwnMetadata:z,OrdinaryGetOwnMetadata:L,OrdinaryOwnMetadataKeys:F,OrdinaryDeleteMetadata:c};return I}function p0(q,B,z){var L=m.getProvider(q,B);if(!O(L))return L;if(z){if(m.setProvider(q,B,o))return o;throw Error("Illegal state.")}return}function Hf(){var q={},B=[],z=function(){function I(V,R,E){this._index=0,this._keys=V,this._values=R,this._selector=E}return I.prototype["@@iterator"]=function(){return this},I.prototype[W]=function(){return this},I.prototype.next=function(){var V=this._index;if(V>=0&&V<this._keys.length){var R=this._selector(this._keys[V],this._values[V]);if(V+1>=this._keys.length)this._index=-1,this._keys=B,this._values=B;else this._index++;return{value:R,done:!1}}return{value:void 0,done:!0}},I.prototype.throw=function(V){if(this._index>=0)this._index=-1,this._keys=B,this._values=B;throw V},I.prototype.return=function(V){if(this._index>=0)this._index=-1,this._keys=B,this._values=B;return{value:V,done:!0}},I}(),L=function(){function I(){this._keys=[],this._values=[],this._cacheKey=q,this._cacheIndex=-2}return Object.defineProperty(I.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),I.prototype.has=function(V){return this._find(V,!1)>=0},I.prototype.get=function(V){var R=this._find(V,!1);return R>=0?this._values[R]:void 0},I.prototype.set=function(V,R){var E=this._find(V,!0);return this._values[E]=R,this},I.prototype.delete=function(V){var R=this._find(V,!1);if(R>=0){var E=this._keys.length;for(var b=R+1;b<E;b++)this._keys[b-1]=this._keys[b],this._values[b-1]=this._values[b];if(this._keys.length--,this._values.length--,h1(V,this._cacheKey))this._cacheKey=q,this._cacheIndex=-2;return!0}return!1},I.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=q,this._cacheIndex=-2},I.prototype.keys=function(){return new z(this._keys,this._values,F)},I.prototype.values=function(){return new z(this._keys,this._values,c)},I.prototype.entries=function(){return new z(this._keys,this._values,y)},I.prototype["@@iterator"]=function(){return this.entries()},I.prototype[W]=function(){return this.entries()},I.prototype._find=function(V,R){if(!h1(this._cacheKey,V)){this._cacheIndex=-1;for(var E=0;E<this._keys.length;E++)if(h1(this._keys[E],V)){this._cacheIndex=E;break}}if(this._cacheIndex<0&&R)this._cacheIndex=this._keys.length,this._keys.push(V),this._values.push(void 0);return this._cacheIndex},I}();return L;function F(I,V){return I}function c(I,V){return V}function y(I,V){return[I,V]}}function Qf(){var q=function(){function B(){this._map=new k}return Object.defineProperty(B.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),B.prototype.has=function(z){return this._map.has(z)},B.prototype.add=function(z){return this._map.set(z,z),this},B.prototype.delete=function(z){return this._map.delete(z)},B.prototype.clear=function(){this._map.clear()},B.prototype.keys=function(){return this._map.keys()},B.prototype.values=function(){return this._map.keys()},B.prototype.entries=function(){return this._map.entries()},B.prototype["@@iterator"]=function(){return this.keys()},B.prototype[W]=function(){return this.keys()},B}();return q}function Xf(){var q=16,B=S.create(),z=L();return function(){function V(){this._key=L()}return V.prototype.has=function(R){var E=F(R,!1);return E!==void 0?S.has(E,this._key):!1},V.prototype.get=function(R){var E=F(R,!1);return E!==void 0?S.get(E,this._key):void 0},V.prototype.set=function(R,E){var b=F(R,!0);return b[this._key]=E,this},V.prototype.delete=function(R){var E=F(R,!1);return E!==void 0?delete E[this._key]:!1},V.prototype.clear=function(){this._key=L()},V}();function L(){var V;do V="@@WeakMap@@"+I();while(S.has(B,V));return B[V]=!0,V}function F(V,R){if(!Q.call(V,z)){if(!R)return;Object.defineProperty(V,z,{value:S.create()})}return V[z]}function c(V,R){for(var E=0;E<R;++E)V[E]=Math.random()*255|0;return V}function y(V){if(typeof Uint8Array==="function"){var R=new Uint8Array(V);if(typeof crypto<"u")crypto.getRandomValues(R);else if(typeof msCrypto<"u")msCrypto.getRandomValues(R);else c(R,V);return R}return c(Array(V),V)}function I(){var V=y(q);V[6]=V[6]&79|64,V[8]=V[8]&191|128;var R="";for(var E=0;E<q;++E){var b=V[E];if(E===4||E===6||E===8)R+="-";if(b<16)R+="0";R+=b.toString(16).toLowerCase()}return R}}function k1(q){return q.__=void 0,delete q.__,q}})})(q2||(q2={}))});var a,kf,If,Pf,Kf;var D1=u$(()=>{a=class a extends Error{statusCode;details;constructor($,f,H){super(f);this.statusCode=$;this.details=H;if(this.name="HTTPException",Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}};kf=class kf extends a{constructor($="Not Found",f){super(404,$,f);this.name="NotFoundException"}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}};If=class If extends a{constructor($="Unauthorized",f){super(401,$,f);this.name="UnauthorizedException"}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}};Pf=class Pf extends a{constructor($="Forbidden",f){super(403,$,f);this.name="ForbiddenException"}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}};Kf=class Kf extends a{constructor($="Bad Request",f){super(400,$,f);this.name="BadRequestException"}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}}});var E2={};t0(E2,{TokenRevokedException:()=>R2,TokenExpiredException:()=>N2,InvalidTokenException:()=>V2,AuthorizationException:()=>S2,AuthenticationException:()=>X1});var X1,S2,N2,V2,R2;var D2=u$(()=>{D1();X1=class X1 extends a{constructor($="Authentication required"){super(401,$);this.name="AuthenticationException"}toJSON(){return{error:"Authentication Error",message:this.message,statusCode:401}}};S2=class S2 extends a{constructor($="Insufficient permissions"){super(403,$);this.name="AuthorizationException"}toJSON(){return{error:"Authorization Error",message:this.message,statusCode:403}}};N2=class N2 extends X1{constructor($="Token has expired"){super($);this.name="TokenExpiredException"}};V2=class V2 extends X1{constructor($="Invalid token"){super($);this.name="InvalidTokenException"}};R2=class R2 extends X1{constructor($="Token has been revoked"){super($);this.name="TokenRevokedException"}}});var R$={};t0(R$,{HonoAdapter:()=>g2});class g2{hono;name="hono";runtime;constructor($){this.hono=$;this.runtime=s4()}listen($,f){switch(this.runtime){case"bun":return this.listenBun($,f);case"deno":return this.listenDeno($,f);case"node":return this.listenNode($,f);case"workerd":throw Error("Cloudflare Workers do not support listen(). Deploy using wrangler or export the handler with getHandler().");default:throw Error(`Unsupported runtime: ${this.runtime}. FastAPI-TS supports Bun, Node.js, Deno, and Cloudflare Workers.`)}}getHandler(){return this.hono.fetch}getRuntime(){return this.runtime}listenBun($,f){let H=Bun.serve({port:$,fetch:this.hono.fetch});if(f)f();return H}listenDeno($,f){let H=new AbortController;return Deno.serve({port:$,signal:H.signal,onListen:f},this.hono.fetch),{port:$,close:()=>H.abort()}}listenNode($,f){try{let{serve:H}=(()=>{throw new Error("Cannot require module "+"@hono/node-server");})();return H({fetch:this.hono.fetch,port:$},f)}catch(H){throw Error("Node.js adapter requires @hono/node-server package. Install it with: npm install @hono/node-server")}}}var s4=()=>{if(typeof Bun<"u")return"bun";if(typeof Deno<"u")return"deno";if(typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers")return"workerd";if(typeof process<"u"&&process.versions&&process.versions.node)return"node";return"unknown"};var Z2={};t0(Z2,{ExpressAdapter:()=>l2});class l2{app;name="express";express;constructor($){this.app=$;try{let f=(()=>{throw new Error("Cannot require module "+"express");})();this.express=f(),this.setupBridge()}catch(f){throw Error("Express adapter requires express package. Install it with: npm install express")}}setupBridge(){let $=this.app.getHono();this.express.use(async(f,H)=>{try{let Q=this.createWebRequest(f),X=await $.fetch(Q);await this.sendExpressResponse(H,X)}catch(Q){H.status(500).json({error:"Internal Server Error",message:Q instanceof Error?Q.message:"Unknown error"})}})}createWebRequest($){let f=$.protocol||"http",H=$.get("host")||"localhost",Q=`${f}://${H}${$.originalUrl||$.url}`,X=new Headers;for(let[W,Y]of Object.entries($.headers))if(typeof Y==="string")X.set(W,Y);else if(Array.isArray(Y))Y.forEach((G)=>X.append(W,G));let J={method:$.method,headers:X};if($.method!=="GET"&&$.method!=="HEAD"){if($.body)J.body=JSON.stringify($.body),X.set("content-type","application/json")}return new Request(Q,J)}async sendExpressResponse($,f){if($.status(f.status),f.headers.forEach((H,Q)=>{$.setHeader(Q,H)}),f.body){let H=f.headers.get("content-type")||"";if(H.includes("application/json")){let Q=await f.json();$.json(Q)}else if(H.includes("text/")){let Q=await f.text();$.send(Q)}else{let Q=await f.arrayBuffer();$.send(Buffer.from(Q))}}else $.end()}listen($,f){return this.express.listen($,f)}getHandler(){return this.express}getExpressApp(){return this.express}}var o4={};t0(o4,{setupTestApp:()=>u2,mockDependency:()=>c2,createTestClient:()=>b$,createTestApp:()=>D$,clearMocks:()=>y2,TestClient:()=>a0});module.exports=z1(o4);class a0{hono;constructor($){this.hono=$.getHono()}async get($,f){return this.request("GET",$,f)}async post($,f){return this.request("POST",$,f)}async put($,f){return this.request("PUT",$,f)}async delete($,f){return this.request("DELETE",$,f)}async patch($,f){return this.request("PATCH",$,f)}async request($,f,H){let Q=this.buildUrl(f,H?.query),X={method:$,headers:this.buildHeaders(H)};if(H?.body!==void 0)X.body=H.body;else if(H?.json!==void 0)X.body=JSON.stringify(H.json);let J=await this.hono.request(Q,X),W=await J.text(),Y;try{Y=JSON.parse(W)}catch{Y=W}return{status:J.status,headers:J.headers,body:Y,text:W,json:async()=>JSON.parse(W),ok:J.ok}}buildUrl($,f){if(!f||Object.keys(f).length===0)return $;let H=new URLSearchParams(f).toString();return`${$}?${H}`}buildHeaders($){let f={...$?.headers};if($?.json!==void 0&&!f["Content-Type"])f["Content-Type"]="application/json";return f}}var I1=($,f,H)=>{return(Q,X)=>{let J=-1;return W(0);async function W(Y){if(Y<=J)throw Error("next() called multiple times");J=Y;let G,_=!1,S;if($[Y])S=$[Y][0][0],Q.req.routeIndex=Y;else S=Y===$.length&&X||void 0;if(S)try{G=await S(Q,()=>W(Y+1))}catch(A){if(A instanceof Error&&f)Q.error=A,G=await f(A,Q),_=!0;else throw A}else if(Q.finalized===!1&&H)G=await H(Q);if(G&&(Q.finalized===!1||_))Q.res=G;return Q}}};var y$=Symbol();var i$=async($,f=Object.create(null))=>{let{all:H=!1,dot:Q=!1}=f,J=($ instanceof w1?$.raw.headers:$.headers).get("Content-Type");if(J?.startsWith("multipart/form-data")||J?.startsWith("application/x-www-form-urlencoded"))return zf($,{all:H,dot:Q});return{}};async function zf($,f){let H=await $.formData();if(H)return wf(H,f);return{}}function wf($,f){let H=Object.create(null);if($.forEach((Q,X)=>{if(!(f.all||X.endsWith("[]")))H[X]=Q;else jf(H,X,Q)}),f.dot)Object.entries(H).forEach(([Q,X])=>{if(Q.includes("."))Lf(H,Q,X),delete H[Q]});return H}var jf=($,f,H)=>{if($[f]!==void 0)if(Array.isArray($[f]))$[f].push(H);else $[f]=[$[f],H];else if(!f.endsWith("[]"))$[f]=H;else $[f]=[H]},Lf=($,f,H)=>{let Q=$,X=f.split(".");X.forEach((J,W)=>{if(W===X.length-1)Q[J]=H;else{if(!Q[J]||typeof Q[J]!=="object"||Array.isArray(Q[J])||Q[J]instanceof File)Q[J]=Object.create(null);Q=Q[J]}})};var K1=($)=>{let f=$.split("/");if(f[0]==="")f.shift();return f},s$=($)=>{let{groups:f,path:H}=Sf($),Q=K1(H);return Nf(Q,f)},Sf=($)=>{let f=[];return $=$.replace(/\{[^}]+\}/g,(H,Q)=>{let X=`@${Q}`;return f.push([X,H]),X}),{groups:f,path:$}},Nf=($,f)=>{for(let H=f.length-1;H>=0;H--){let[Q]=f[H];for(let X=$.length-1;X>=0;X--)if($[X].includes(Q)){$[X]=$[X].replace(Q,f[H][1]);break}}return $},j1={},o$=($,f)=>{if($==="*")return"*";let H=$.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(H){let Q=`${$}#${f}`;if(!j1[Q])if(H[2])j1[Q]=f&&f[0]!==":"&&f[0]!=="*"?[Q,H[1],new RegExp(`^${H[2]}(?=/${f})`)]:[$,H[1],new RegExp(`^${H[2]}$`)];else j1[Q]=[$,H[1],!0];return j1[Q]}return null},k0=($,f)=>{try{return f($)}catch{return $.replace(/(?:%[0-9A-Fa-f]{2})+/g,(H)=>{try{return f(H)}catch{return H}})}},Vf=($)=>k0($,decodeURI),T1=($)=>{let f=$.url,H=f.indexOf("/",f.indexOf(":")+4),Q=H;for(;Q<f.length;Q++){let X=f.charCodeAt(Q);if(X===37){let J=f.indexOf("?",Q),W=f.slice(H,J===-1?void 0:J);return Vf(W.includes("%25")?W.replace(/%25/g,"%2525"):W)}else if(X===63)break}return f.slice(H,Q)};var d$=($)=>{let f=T1($);return f.length>1&&f.at(-1)==="/"?f.slice(0,-1):f},b0=($,f,...H)=>{if(H.length)f=b0(f,...H);return`${$?.[0]==="/"?"":"/"}${$}${f==="/"?"":`${$?.at(-1)==="/"?"":"/"}${f?.[0]==="/"?f.slice(1):f}`}`},L1=($)=>{if($.charCodeAt($.length-1)!==63||!$.includes(":"))return null;let f=$.split("/"),H=[],Q="";return f.forEach((X)=>{if(X!==""&&!/\:/.test(X))Q+="/"+X;else if(/\:/.test(X))if(/\?/.test(X)){if(H.length===0&&Q==="")H.push("/");else H.push(Q);let J=X.replace("?","");Q+="/"+J,H.push(Q)}else Q+="/"+X}),H.filter((X,J,W)=>W.indexOf(X)===J)},P1=($)=>{if(!/[%+]/.test($))return $;if($.indexOf("+")!==-1)$=$.replace(/\+/g," ");return $.indexOf("%")!==-1?k0($,e0):$},p$=($,f,H)=>{let Q;if(!H&&f&&!/[%+]/.test(f)){let W=$.indexOf(`?${f}`,8);if(W===-1)W=$.indexOf(`&${f}`,8);while(W!==-1){let Y=$.charCodeAt(W+f.length+1);if(Y===61){let G=W+f.length+2,_=$.indexOf("&",G);return P1($.slice(G,_===-1?void 0:_))}else if(Y==38||isNaN(Y))return"";W=$.indexOf(`&${f}`,W+1)}if(Q=/[%+]/.test($),!Q)return}let X={};Q??=/[%+]/.test($);let J=$.indexOf("?",8);while(J!==-1){let W=$.indexOf("&",J+1),Y=$.indexOf("=",J);if(Y>W&&W!==-1)Y=-1;let G=$.slice(J+1,Y===-1?W===-1?void 0:W:Y);if(Q)G=P1(G);if(J=W,G==="")continue;let _;if(Y===-1)_="";else if(_=$.slice(Y+1,W===-1?void 0:W),Q)_=P1(_);if(H){if(!(X[G]&&Array.isArray(X[G])))X[G]=[];X[G].push(_)}else X[G]??=_}return f?X[f]:X},r$=p$,t$=($,f)=>{return p$($,f,!0)},e0=decodeURIComponent;var a$=($)=>k0($,e0),w1=class{raw;#f;#$;routeIndex=0;path;bodyCache={};constructor($,f="/",H=[[]]){this.raw=$,this.path=f,this.#$=H,this.#f={}}param($){return $?this.#H($):this.#J()}#H($){let f=this.#$[0][this.routeIndex][1][$],H=this.#X(f);return H&&/\%/.test(H)?a$(H):H}#J(){let $={},f=Object.keys(this.#$[0][this.routeIndex][1]);for(let H of f){let Q=this.#X(this.#$[0][this.routeIndex][1][H]);if(Q!==void 0)$[H]=/\%/.test(Q)?a$(Q):Q}return $}#X($){return this.#$[1]?this.#$[1][$]:$}query($){return r$(this.url,$)}queries($){return t$(this.url,$)}header($){if($)return this.raw.headers.get($)??void 0;let f={};return this.raw.headers.forEach((H,Q)=>{f[Q]=H}),f}async parseBody($){return this.bodyCache.parsedBody??=await i$(this,$)}#Q=($)=>{let{bodyCache:f,raw:H}=this,Q=f[$];if(Q)return Q;let X=Object.keys(f)[0];if(X)return f[X].then((J)=>{if(X==="json")J=JSON.stringify(J);return new Response(J)[$]()});return f[$]=H[$]()};json(){return this.#Q("text").then(($)=>JSON.parse($))}text(){return this.#Q("text")}arrayBuffer(){return this.#Q("arrayBuffer")}blob(){return this.#Q("blob")}formData(){return this.#Q("formData")}addValidatedData($,f){this.#f[$]=f}valid($){return this.#f[$]}get url(){return this.raw.url}get method(){return this.raw.method}get[y$](){return this.#$}get matchedRoutes(){return this.#$[0].map(([[,$]])=>$)}get routePath(){return this.#$[0].map(([[,$]])=>$)[this.routeIndex].path}};var e$={Stringify:1,BeforeStream:2,Stream:3},Rf=($,f)=>{let H=new String($);return H.isEscaped=!0,H.callbacks=f,H};var x1=async($,f,H,Q,X)=>{if(typeof $==="object"&&!($ instanceof String)){if(!($ instanceof Promise))$=$.toString();if($ instanceof Promise)$=await $}let J=$.callbacks;if(!J?.length)return Promise.resolve($);if(X)X[0]+=$;else X=[$];let W=Promise.all(J.map((Y)=>Y({phase:f,buffer:X,context:Q}))).then((Y)=>Promise.all(Y.filter(Boolean).map((G)=>x1(G,f,!1,Q,X))).then(()=>X[0]));if(H)return Rf(await W,J);else return W};var Ef="text/plain; charset=UTF-8",g1=($,f)=>{return{"Content-Type":$,...f}},$2=class{#f;#$;env={};#H;finalized=!1;error;#J;#X;#Q;#_;#G;#q;#Y;#B;#z;constructor($,f){if(this.#f=$,f)this.#X=f.executionCtx,this.env=f.env,this.#q=f.notFoundHandler,this.#z=f.path,this.#B=f.matchResult}get req(){return this.#$??=new w1(this.#f,this.#z,this.#B),this.#$}get event(){if(this.#X&&"respondWith"in this.#X)return this.#X;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#X)return this.#X;else throw Error("This context has no ExecutionContext")}get res(){return this.#Q||=new Response(null,{headers:this.#Y??=new Headers})}set res($){if(this.#Q&&$){$=new Response($.body,$);for(let[f,H]of this.#Q.headers.entries()){if(f==="content-type")continue;if(f==="set-cookie"){let Q=this.#Q.headers.getSetCookie();$.headers.delete("set-cookie");for(let X of Q)$.headers.append("set-cookie",X)}else $.headers.set(f,H)}}this.#Q=$,this.finalized=!0}render=(...$)=>{return this.#G??=(f)=>this.html(f),this.#G(...$)};setLayout=($)=>this.#_=$;getLayout=()=>this.#_;setRenderer=($)=>{this.#G=$};header=($,f,H)=>{if(this.finalized)this.#Q=new Response(this.#Q.body,this.#Q);let Q=this.#Q?this.#Q.headers:this.#Y??=new Headers;if(f===void 0)Q.delete($);else if(H?.append)Q.append($,f);else Q.set($,f)};status=($)=>{this.#J=$};set=($,f)=>{this.#H??=new Map,this.#H.set($,f)};get=($)=>{return this.#H?this.#H.get($):void 0};get var(){if(!this.#H)return{};return Object.fromEntries(this.#H)}#W($,f,H){let Q=this.#Q?new Headers(this.#Q.headers):this.#Y??new Headers;if(typeof f==="object"&&"headers"in f){let J=f.headers instanceof Headers?f.headers:new Headers(f.headers);for(let[W,Y]of J)if(W.toLowerCase()==="set-cookie")Q.append(W,Y);else Q.set(W,Y)}if(H)for(let[J,W]of Object.entries(H))if(typeof W==="string")Q.set(J,W);else{Q.delete(J);for(let Y of W)Q.append(J,Y)}let X=typeof f==="number"?f:f?.status??this.#J;return new Response($,{status:X,headers:Q})}newResponse=(...$)=>this.#W(...$);body=($,f,H)=>this.#W($,f,H);text=($,f,H)=>{return!this.#Y&&!this.#J&&!f&&!H&&!this.finalized?new Response($):this.#W($,f,g1(Ef,H))};json=($,f,H)=>{return this.#W(JSON.stringify($),f,g1("application/json",H))};html=($,f,H)=>{let Q=(X)=>this.#W(X,f,g1("text/html; charset=UTF-8",H));return typeof $==="object"?x1($,e$.Stringify,!1,{}).then(Q):Q($)};redirect=($,f)=>{let H=String($);return this.header("Location",!/[^\x00-\xFF]/.test(H)?H:encodeURI(H)),this.newResponse(null,f??302)};notFound=()=>{return this.#q??=()=>new Response,this.#q(this)}};var l="ALL",f2="all",H2=["get","post","put","delete","options","patch"],S1="Can not add a route since the matcher is already built.",N1=class extends Error{};var Q2="__COMPOSED_HANDLER";var Df=($)=>{return $.text("404 Not Found",404)},X2=($,f)=>{if("getResponse"in $){let H=$.getResponse();return f.newResponse(H.body,H)}return console.error($),f.text("Internal Server Error",500)},l1=class{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#f="/";routes=[];constructor($={}){[...H2,f2].forEach((X)=>{this[X]=(J,...W)=>{if(typeof J==="string")this.#f=J;else this.#J(X,this.#f,J);return W.forEach((Y)=>{this.#J(X,this.#f,Y)}),this}}),this.on=(X,J,...W)=>{for(let Y of[J].flat()){this.#f=Y;for(let G of[X].flat())W.map((_)=>{this.#J(G.toUpperCase(),this.#f,_)})}return this},this.use=(X,...J)=>{if(typeof X==="string")this.#f=X;else this.#f="*",J.unshift(X);return J.forEach((W)=>{this.#J(l,this.#f,W)}),this};let{strict:H,...Q}=$;Object.assign(this,Q),this.getPath=H??!0?$.getPath??T1:d$}#$(){let $=new l1({router:this.router,getPath:this.getPath});return $.errorHandler=this.errorHandler,$.#H=this.#H,$.routes=this.routes,$}#H=Df;errorHandler=X2;route($,f){let H=this.basePath($);return f.routes.map((Q)=>{let X;if(f.errorHandler===X2)X=Q.handler;else X=async(J,W)=>(await I1([],f.errorHandler)(J,()=>Q.handler(J,W))).res,X[Q2]=Q.handler;H.#J(Q.method,Q.path,X)}),this}basePath($){let f=this.#$();return f._basePath=b0(this._basePath,$),f}onError=($)=>{return this.errorHandler=$,this};notFound=($)=>{return this.#H=$,this};mount($,f,H){let Q,X;if(H)if(typeof H==="function")X=H;else if(X=H.optionHandler,H.replaceRequest===!1)Q=(Y)=>Y;else Q=H.replaceRequest;let J=X?(Y)=>{let G=X(Y);return Array.isArray(G)?G:[G]}:(Y)=>{let G=void 0;try{G=Y.executionCtx}catch{}return[Y.env,G]};Q||=(()=>{let Y=b0(this._basePath,$),G=Y==="/"?0:Y.length;return(_)=>{let S=new URL(_.url);return S.pathname=S.pathname.slice(G)||"/",new Request(S,_)}})();let W=async(Y,G)=>{let _=await f(Q(Y.req.raw),...J(Y));if(_)return _;await G()};return this.#J(l,b0($,"*"),W),this}#J($,f,H){$=$.toUpperCase(),f=b0(this._basePath,f);let Q={basePath:this._basePath,path:f,method:$,handler:H};this.router.add($,f,[H,Q]),this.routes.push(Q)}#X($,f){if($ instanceof Error)return this.errorHandler($,f);throw $}#Q($,f,H,Q){if(Q==="HEAD")return(async()=>new Response(null,await this.#Q($,f,H,"GET")))();let X=this.getPath($,{env:H}),J=this.router.match(Q,X),W=new $2($,{path:X,matchResult:J,env:H,executionCtx:f,notFoundHandler:this.#H});if(J[0].length===1){let G;try{G=J[0][0][0][0](W,async()=>{W.res=await this.#H(W)})}catch(_){return this.#X(_,W)}return G instanceof Promise?G.then((_)=>_||(W.finalized?W.res:this.#H(W))).catch((_)=>this.#X(_,W)):G??this.#H(W)}let Y=I1(J[0],this.errorHandler,this.#H);return(async()=>{try{let G=await Y(W);if(!G.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return G.res}catch(G){return this.#X(G,W)}})()}fetch=($,...f)=>{return this.#Q($,f[1],f[0],$.method)};request=($,f,H,Q)=>{if($ instanceof Request)return this.fetch(f?new Request($,f):$,H,Q);return $=$.toString(),this.fetch(new Request(/^https?:\/\//.test($)?$:`http://localhost${b0("/",$)}`,f),H,Q)};fire=()=>{addEventListener("fetch",($)=>{$.respondWith(this.#Q($.request,$,void 0,$.request.method))})}};var V1="[^/]+",$1=".*",f1="(?:|/.*)",F0=Symbol(),bf=new Set(".\\+*[^]$()");function Ff($,f){if($.length===1)return f.length===1?$<f?-1:1:-1;if(f.length===1)return 1;if($===$1||$===f1)return 1;else if(f===$1||f===f1)return-1;if($===V1)return 1;else if(f===V1)return-1;return $.length===f.length?$<f?-1:1:f.length-$.length}var R1=class{#f;#$;#H=Object.create(null);insert($,f,H,Q,X){if($.length===0){if(this.#f!==void 0)throw F0;if(X)return;this.#f=f;return}let[J,...W]=$,Y=J==="*"?W.length===0?["","",$1]:["","",V1]:J==="/*"?["","",f1]:J.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),G;if(Y){let _=Y[1],S=Y[2]||V1;if(_&&Y[2]){if(S===".*")throw F0;if(S=S.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(S))throw F0}if(G=this.#H[S],!G){if(Object.keys(this.#H).some((A)=>A!==$1&&A!==f1))throw F0;if(X)return;if(G=this.#H[S]=new R1,_!=="")G.#$=Q.varIndex++}if(!X&&_!=="")H.push([_,G.#$])}else if(G=this.#H[J],!G){if(Object.keys(this.#H).some((_)=>_.length>1&&_!==$1&&_!==f1))throw F0;if(X)return;G=this.#H[J]=new R1}G.insert(W,f,H,Q,X)}buildRegExpStr(){let f=Object.keys(this.#H).sort(Ff).map((H)=>{let Q=this.#H[H];return(typeof Q.#$==="number"?`(${H})@${Q.#$}`:bf.has(H)?`\\${H}`:H)+Q.buildRegExpStr()});if(typeof this.#f==="number")f.unshift(`#${this.#f}`);if(f.length===0)return"";if(f.length===1)return f[0];return"(?:"+f.join("|")+")"}};var J2=class{#f={varIndex:0};#$=new R1;insert($,f,H){let Q=[],X=[];for(let W=0;;){let Y=!1;if($=$.replace(/\{[^}]+\}/g,(G)=>{let _=`@\\${W}`;return X[W]=[_,G],W++,Y=!0,_}),!Y)break}let J=$.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let W=X.length-1;W>=0;W--){let[Y]=X[W];for(let G=J.length-1;G>=0;G--)if(J[G].indexOf(Y)!==-1){J[G]=J[G].replace(Y,X[W][1]);break}}return this.#$.insert(J,f,Q,this.#f,H),Q}buildRegExp(){let $=this.#$.buildRegExpStr();if($==="")return[/^$/,[],[]];let f=0,H=[],Q=[];return $=$.replace(/#(\d+)|@(\d+)|\.\*\$/g,(X,J,W)=>{if(J!==void 0)return H[++f]=Number(J),"$()";if(W!==void 0)return Q[Number(W)]=++f,"";return""}),[new RegExp(`^${$}`),H,Q]}};var W2=[],Af=[/^$/,[],Object.create(null)],Y2=Object.create(null);function G2($){return Y2[$]??=new RegExp($==="*"?"":`^${$.replace(/\/\*$|([.\\+*[^\]$()])/g,(f,H)=>H?`\\${H}`:"(?:|/.*)")}$`)}function Uf(){Y2=Object.create(null)}function Cf($){let f=new J2,H=[];if($.length===0)return Af;let Q=$.map((_)=>[!/\*|\/:/.test(_[0]),..._]).sort(([_,S],[A,k])=>_?1:A?-1:S.length-k.length),X=Object.create(null);for(let _=0,S=-1,A=Q.length;_<A;_++){let[k,Z,h]=Q[_];if(k)X[Z]=[h.map(([m])=>[m,Object.create(null)]),W2];else S++;let T;try{T=f.insert(Z,S,k)}catch(m){throw m===F0?new N1(Z):m}if(k)continue;H[S]=h.map(([m,o])=>{let e=Object.create(null);o-=1;for(;o>=0;o--){let[i,$0]=T[o];e[i]=$0}return[m,e]})}let[J,W,Y]=f.buildRegExp();for(let _=0,S=H.length;_<S;_++)for(let A=0,k=H[_].length;A<k;A++){let Z=H[_][A]?.[1];if(!Z)continue;let h=Object.keys(Z);for(let T=0,m=h.length;T<m;T++)Z[h[T]]=Y[Z[h[T]]]}let G=[];for(let _ in W)G[_]=H[W[_]];return[J,G,X]}function I0($,f){if(!$)return;for(let H of Object.keys($).sort((Q,X)=>X.length-Q.length))if(G2(H).test(f))return[...$[H]];return}var Z1=class{name="RegExpRouter";#f;#$;constructor(){this.#f={[l]:Object.create(null)},this.#$={[l]:Object.create(null)}}add($,f,H){let Q=this.#f,X=this.#$;if(!Q||!X)throw Error(S1);if(!Q[$])[Q,X].forEach((Y)=>{Y[$]=Object.create(null),Object.keys(Y[l]).forEach((G)=>{Y[$][G]=[...Y[l][G]]})});if(f==="/*")f="*";let J=(f.match(/\/:/g)||[]).length;if(/\*$/.test(f)){let Y=G2(f);if($===l)Object.keys(Q).forEach((G)=>{Q[G][f]||=I0(Q[G],f)||I0(Q[l],f)||[]});else Q[$][f]||=I0(Q[$],f)||I0(Q[l],f)||[];Object.keys(Q).forEach((G)=>{if($===l||$===G)Object.keys(Q[G]).forEach((_)=>{Y.test(_)&&Q[G][_].push([H,J])})}),Object.keys(X).forEach((G)=>{if($===l||$===G)Object.keys(X[G]).forEach((_)=>Y.test(_)&&X[G][_].push([H,J]))});return}let W=L1(f)||[f];for(let Y=0,G=W.length;Y<G;Y++){let _=W[Y];Object.keys(X).forEach((S)=>{if($===l||$===S)X[S][_]||=[...I0(Q[S],_)||I0(Q[l],_)||[]],X[S][_].push([H,J-G+Y+1])})}}match($,f){Uf();let H=this.#H();return this.match=(Q,X)=>{let J=H[Q]||H[l],W=J[2][X];if(W)return W;let Y=X.match(J[0]);if(!Y)return[[],W2];let G=Y.indexOf("",1);return[J[1][G],Y]},this.match($,f)}#H(){let $=Object.create(null);return Object.keys(this.#$).concat(Object.keys(this.#f)).forEach((f)=>{$[f]||=this.#J(f)}),this.#f=this.#$=void 0,$}#J($){let f=[],H=$===l;if([this.#f,this.#$].forEach((Q)=>{let X=Q[$]?Object.keys(Q[$]).map((J)=>[J,Q[$][J]]):[];if(X.length!==0)H||=!0,f.push(...X);else if($!==l)f.push(...Object.keys(Q[l]).map((J)=>[J,Q[l][J]]))}),!H)return null;else return Cf(f)}};var m1=class{name="SmartRouter";#f=[];#$=[];constructor($){this.#f=$.routers}add($,f,H){if(!this.#$)throw Error(S1);this.#$.push([$,f,H])}match($,f){if(!this.#$)throw Error("Fatal error");let H=this.#f,Q=this.#$,X=H.length,J=0,W;for(;J<X;J++){let Y=H[J];try{for(let G=0,_=Q.length;G<_;G++)Y.add(...Q[G]);W=Y.match($,f)}catch(G){if(G instanceof N1)continue;throw G}this.match=Y.match.bind(Y),this.#f=[Y],this.#$=void 0;break}if(J===X)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,W}get activeRouter(){if(this.#$||this.#f.length!==1)throw Error("No active router has been determined yet.");return this.#f[0]}};var H1=Object.create(null),n1=class{#f;#$;#H;#J=0;#X=H1;constructor($,f,H){if(this.#$=H||Object.create(null),this.#f=[],$&&f){let Q=Object.create(null);Q[$]={handler:f,possibleKeys:[],score:0},this.#f=[Q]}this.#H=[]}insert($,f,H){this.#J=++this.#J;let Q=this,X=s$(f),J=[];for(let W=0,Y=X.length;W<Y;W++){let G=X[W],_=X[W+1],S=o$(G,_),A=Array.isArray(S)?S[0]:G;if(A in Q.#$){if(Q=Q.#$[A],S)J.push(S[1]);continue}if(Q.#$[A]=new n1,S)Q.#H.push(S),J.push(S[1]);Q=Q.#$[A]}return Q.#f.push({[$]:{handler:H,possibleKeys:J.filter((W,Y,G)=>G.indexOf(W)===Y),score:this.#J}}),Q}#Q($,f,H,Q){let X=[];for(let J=0,W=$.#f.length;J<W;J++){let Y=$.#f[J],G=Y[f]||Y[l],_={};if(G!==void 0){if(G.params=Object.create(null),X.push(G),H!==H1||Q&&Q!==H1)for(let S=0,A=G.possibleKeys.length;S<A;S++){let k=G.possibleKeys[S],Z=_[G.score];G.params[k]=Q?.[k]&&!Z?Q[k]:H[k]??Q?.[k],_[G.score]=!0}}}return X}search($,f){let H=[];this.#X=H1;let X=[this],J=K1(f),W=[];for(let Y=0,G=J.length;Y<G;Y++){let _=J[Y],S=Y===G-1,A=[];for(let k=0,Z=X.length;k<Z;k++){let h=X[k],T=h.#$[_];if(T)if(T.#X=h.#X,S){if(T.#$["*"])H.push(...this.#Q(T.#$["*"],$,h.#X));H.push(...this.#Q(T,$,h.#X))}else A.push(T);for(let m=0,o=h.#H.length;m<o;m++){let e=h.#H[m],i=h.#X===H1?{}:{...h.#X};if(e==="*"){let G0=h.#$["*"];if(G0)H.push(...this.#Q(G0,$,h.#X)),G0.#X=i,A.push(G0);continue}let[$0,s,t]=e;if(!_&&!(t instanceof RegExp))continue;let f0=h.#$[$0],C1=J.slice(Y).join("/");if(t instanceof RegExp){let G0=t.exec(C1);if(G0){if(i[s]=G0[0],H.push(...this.#Q(f0,$,h.#X,i)),Object.keys(f0.#$).length){f0.#X=i;let O1=G0[0].match(/\//)?.length??0;(W[O1]||=[]).push(f0)}continue}}if(t===!0||t.test(_))if(i[s]=_,S){if(H.push(...this.#Q(f0,$,i,h.#X)),f0.#$["*"])H.push(...this.#Q(f0.#$["*"],$,i,h.#X))}else f0.#X=i,A.push(f0)}}X=A.concat(W.shift()??[])}if(H.length>1)H.sort((Y,G)=>{return Y.score-G.score});return[H.map(({handler:Y,params:G})=>[Y,G])]}};var c1=class{name="TrieRouter";#f;constructor(){this.#f=new n1}add($,f,H){let Q=L1(f);if(Q){for(let X=0,J=Q.length;X<J;X++)this.#f.insert($,Q[X],H);return}this.#f.insert($,f,H)}match($,f){return this.#f.search($,f)}};var u1=class extends l1{constructor($={}){super($);this.router=$.router??new m1({routers:[new Z1,new c1]})}};var J8=_f(_2()),y1=Symbol("route:metadata"),i1=Symbol("controller:metadata"),B2=Symbol("parameter:metadata"),z2=Symbol("dependency:metadata"),s1=Symbol("websocket:metadata"),w2=Symbol("websocket:handler:metadata"),o1=Symbol("graphql:resolver"),Q1=Symbol("graphql:field"),d1=Symbol("auth:metadata"),p1=Symbol("oauth:metadata"),r1=Symbol("roles:metadata"),t1=Symbol("permissions:metadata"),a1=Symbol("minimum-role:metadata"),e1=Symbol("resource-permission:metadata"),$$=Symbol("session:metadata"),f$=Symbol("csrf:metadata");class S0{routes=new Map;controllers=new Map;routesByController=new Map;websockets=new Map;graphqlResolvers=new Map;graphqlFields=new Map;registerRoute($){let f=this.getRouteKey($.target,$.propertyKey);if(this.routes.set(f,$),!this.routesByController.has($.target))this.routesByController.set($.target,[]);this.routesByController.get($.target).push($)}registerController($,f){this.controllers.set($,f)}getRoutes(){return Array.from(this.routes.values())}getRoute($,f){let H=this.getRouteKey($,f);return this.routes.get(H)}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 f=this.getRouteKey($.target,$.propertyKey);this.graphqlFields.set(f,$)}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((f)=>f.target===$)}clear(){this.routes.clear(),this.controllers.clear(),this.routesByController.clear(),this.websockets.clear(),this.graphqlResolvers.clear(),this.graphqlFields.clear()}getRouteKey($,f){return`${$.name}:${f}`}static defineRoute($,f,H){let Q=this.getRouteMetadata($,f),X={...Q,...H,target:$.constructor,propertyKey:f,middleware:[...Q?.middleware||[],...H.middleware||[]],parameters:H.parameters||Q?.parameters||[],dependencies:H.dependencies||Q?.dependencies||[],responses:H.responses||Q?.responses||[],auth:H.auth||Q?.auth,oauth:H.oauth||Q?.oauth,roles:H.roles||Q?.roles,permissions:H.permissions||Q?.permissions,minimumRole:H.minimumRole||Q?.minimumRole,resourcePermission:H.resourcePermission||Q?.resourcePermission,session:H.session||Q?.session,csrf:H.csrf||Q?.csrf};Reflect.defineMetadata(y1,X,$,f)}static defineParameter($,f,H,Q){let X=this.getParameterMetadata($,f)||[];X[H]=Q,Reflect.defineMetadata(B2,X,$,f);let J=this.getRouteMetadata($,f);this.defineRoute($,f,{...J,parameters:X})}static defineDependency($,f,H,Q){let X=this.getDependencyMetadata($,f)||[];X[H]=Q,Reflect.defineMetadata(z2,X,$,f);let J=this.getRouteMetadata($,f);this.defineRoute($,f,{...J,dependencies:X})}static defineController($,f){Reflect.defineMetadata(i1,f,$)}static getRouteMetadata($,f){return Reflect.getMetadata(y1,$,f)}static getParameterMetadata($,f){return Reflect.getMetadata(B2,$,f)}static getDependencyMetadata($,f){return Reflect.getMetadata(z2,$,f)}static getControllerMetadata($){return Reflect.getMetadata(i1,$)}static hasControllerMetadata($){return Reflect.hasMetadata(i1,$)}static hasRouteMetadata($,f){return Reflect.hasMetadata(y1,$,f)}static getRouteMethods($){let f=$.prototype,H=[],Q=Object.getOwnPropertyNames(f);for(let X of Q){if(X==="constructor")continue;if(this.hasRouteMetadata(f,X))H.push(X)}return H}static defineWebSocket($,f){let Q={...this.getWebSocketMetadata($),...f,target:$};Reflect.defineMetadata(s1,Q,$)}static defineWebSocketHandler($,f,H){let Q=this.getWebSocketMetadata($.constructor)||{};switch(H.type){case"connect":Q.onConnect=f;break;case"message":Q.onMessage=f,Q.messageSchema=H.schema;break;case"disconnect":Q.onDisconnect=f;break}this.defineWebSocket($.constructor,Q),Reflect.defineMetadata(w2,H,$,f)}static getWebSocketMetadata($){return Reflect.getMetadata(s1,$)}static getWebSocketHandlerMetadata($,f){return Reflect.getMetadata(w2,$,f)}static hasWebSocketMetadata($){return Reflect.hasMetadata(s1,$)}static defineGraphQLResolver($,f){Reflect.defineMetadata(o1,f,$)}static defineGraphQLField($,f,H){Reflect.defineMetadata(Q1,H,$,f);let Q=this.getGraphQLFieldsMetadata($.constructor)||[];Q.push(H),Reflect.defineMetadata(Q1,Q,$.constructor)}static getGraphQLResolverMetadata($){return Reflect.getMetadata(o1,$)}static getGraphQLFieldsMetadata($){return Reflect.getMetadata(Q1,$)||[]}static getGraphQLFieldMetadata($,f){return Reflect.getMetadata(Q1,$,f)}static hasGraphQLResolverMetadata($){return Reflect.hasMetadata(o1,$)}static hasGraphQLFieldMetadata($,f){return Reflect.hasMetadata(Q1,$,f)}static defineAuth($,f,H){Reflect.defineMetadata(d1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,auth:H})}static getAuthMetadata($,f){return Reflect.getMetadata(d1,$,f)}static hasAuthMetadata($,f){return Reflect.hasMetadata(d1,$,f)}static defineOAuth($,f,H){Reflect.defineMetadata(p1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,oauth:H})}static getOAuthMetadata($,f){return Reflect.getMetadata(p1,$,f)}static hasOAuthMetadata($,f){return Reflect.hasMetadata(p1,$,f)}static defineRoles($,f,H){Reflect.defineMetadata(r1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,roles:H})}static definePermissions($,f,H){Reflect.defineMetadata(t1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,permissions:H})}static defineMinimumRole($,f,H){Reflect.defineMetadata(a1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,minimumRole:H})}static getRolesMetadata($,f){return Reflect.getMetadata(r1,$,f)}static getPermissionsMetadata($,f){return Reflect.getMetadata(t1,$,f)}static getMinimumRoleMetadata($,f){return Reflect.getMetadata(a1,$,f)}static hasRolesMetadata($,f){return Reflect.hasMetadata(r1,$,f)}static hasPermissionsMetadata($,f){return Reflect.hasMetadata(t1,$,f)}static hasMinimumRoleMetadata($,f){return Reflect.hasMetadata(a1,$,f)}static defineResourcePermission($,f,H){Reflect.defineMetadata(e1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,resourcePermission:H})}static getResourcePermissionMetadata($,f){return Reflect.getMetadata(e1,$,f)}static hasResourcePermissionMetadata($,f){return Reflect.hasMetadata(e1,$,f)}static defineSession($,f,H){Reflect.defineMetadata($$,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,session:H})}static defineCSRF($,f,H){Reflect.defineMetadata(f$,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,csrf:H})}static getSessionMetadata($,f){return Reflect.getMetadata($$,$,f)}static getCSRFMetadata($,f){return Reflect.getMetadata(f$,$,f)}static hasSessionMetadata($,f){return Reflect.hasMetadata($$,$,f)}static hasCSRFMetadata($,f){return Reflect.hasMetadata(f$,$,f)}}class H${singletons=new Map;requestScoped=new WeakMap;providers=new Map;resolutionStack=new Set;providerNameCache=new WeakMap;stats={singletonHits:0,singletonMisses:0,requestHits:0,requestMisses:0,transientCreations:0};register($,f){this.providers.set($,f||{scope:"transient"})}async resolve($,f){let H=this.providers.get($)||{scope:f?.scope||"transient"},Q=f?.scope||H.scope||"transient";if(Q==="singleton"){if(this.singletons.has($))return this.stats.singletonHits++,this.singletons.get($);if(this.stats.singletonMisses++,this.resolutionStack.has($))throw Error(`Circular dependency detected: ${this.buildCircularDependencyMessage($)}`);this.resolutionStack.add($);try{let X=await this.create($,H,f?.context);return this.singletons.set($,X),X}finally{this.resolutionStack.delete($)}}if(Q==="request"&&f?.context){let X=this.requestScoped.get(f.context);if(X?.has($))return this.stats.requestHits++,X.get($);if(this.stats.requestMisses++,!X)X=new Map,this.requestScoped.set(f.context,X);if(this.resolutionStack.has($))throw Error(`Circular dependency detected: ${this.buildCircularDependencyMessage($)}`);this.resolutionStack.add($);try{let J=await this.create($,H,f.context);return X.set($,J),J}finally{this.resolutionStack.delete($)}}if(this.stats.transientCreations++,this.resolutionStack.has($))throw Error(`Circular dependency detected: ${this.buildCircularDependencyMessage($)}`);this.resolutionStack.add($);try{return await this.create($,H,f?.context)}finally{this.resolutionStack.delete($)}}buildCircularDependencyMessage($){let f=Array.from(this.resolutionStack),H=this.getProviderName($);return f.map((X)=>this.getProviderName(X)).join(" -> ")+" -> "+H}async create($,f,H){if(f.factory)return f.factory();if(typeof $==="function")if($.prototype&&$.prototype.constructor===$){let Q=new $;return await this.resolveNestedDependencies(Q,H),Q}else{let Q=$();return Q instanceof Promise?await Q:Q}throw Error("Invalid provider type")}async resolveNestedDependencies($,f){}getProviderName($){let f=this.providerNameCache.get($);if(f)return f;let H;if(typeof $==="function")if($.name)H=$.name;else H=$.toString().substring(0,50);else H=String($);return this.providerNameCache.set($,H),H}clear(){this.singletons.clear(),this.providers.clear(),this.resolutionStack.clear(),this.providerNameCache=new WeakMap,this.resetStats()}clearRequestScope($){this.requestScoped.delete($)}getStats(){let $=this.stats.singletonHits+this.stats.singletonMisses,f=$>0?this.stats.singletonHits/$*100:0,H=this.stats.requestHits+this.stats.requestMisses,Q=H>0?this.stats.requestHits/H*100:0;return{singletonHits:this.stats.singletonHits,singletonMisses:this.stats.singletonMisses,singletonHitRate:Math.round(f*100)/100,requestHits:this.stats.requestHits,requestMisses:this.stats.requestMisses,requestHitRate:Math.round(Q*100)/100,transientCreations:this.stats.transientCreations}}resetStats(){this.stats={singletonHits:0,singletonMisses:0,requestHits:0,requestMisses:0,transientCreations:0}}}var Of=/^[\w!#$%&'*.^`|~+-]+$/,vf=/^[ !#-:<-[\]-~]*$/,Q$=($,f)=>{if(f&&$.indexOf(f)===-1)return{};let H=$.trim().split(";"),Q={};for(let X of H){X=X.trim();let J=X.indexOf("=");if(J===-1)continue;let W=X.substring(0,J).trim();if(f&&f!==W||!Of.test(W))continue;let Y=X.substring(J+1).trim();if(Y.startsWith('"')&&Y.endsWith('"'))Y=Y.slice(1,-1);if(vf.test(Y)){if(Q[W]=Y.indexOf("%")!==-1?k0(Y,e0):Y,f)break}}return Q};var hf=($,f,H={})=>{let Q=`${$}=${f}`;if($.startsWith("__Secure-")&&!H.secure)throw Error("__Secure- Cookie must have Secure attributes");if($.startsWith("__Host-")){if(!H.secure)throw Error("__Host- Cookie must have Secure attributes");if(H.path!=="/")throw Error('__Host- Cookie must have Path attributes with "/"');if(H.domain)throw Error("__Host- Cookie must not have Domain attributes")}if(H&&typeof H.maxAge==="number"&&H.maxAge>=0){if(H.maxAge>34560000)throw Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");Q+=`; Max-Age=${H.maxAge|0}`}if(H.domain&&H.prefix!=="host")Q+=`; Domain=${H.domain}`;if(H.path)Q+=`; Path=${H.path}`;if(H.expires){if(H.expires.getTime()-Date.now()>34560000000)throw Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");Q+=`; Expires=${H.expires.toUTCString()}`}if(H.httpOnly)Q+="; HttpOnly";if(H.secure)Q+="; Secure";if(H.sameSite)Q+=`; SameSite=${H.sameSite.charAt(0).toUpperCase()+H.sameSite.slice(1)}`;if(H.priority)Q+=`; Priority=${H.priority.charAt(0).toUpperCase()+H.priority.slice(1)}`;if(H.partitioned){if(!H.secure)throw Error("Partitioned Cookie must have Secure attributes");Q+="; Partitioned"}return Q},E1=($,f,H)=>{return f=encodeURIComponent(f),hf($,f,H)};var j2=($,f,H)=>{let Q=$.req.raw.headers.get("Cookie");if(typeof f==="string"){if(!Q)return;let J=f;if(H==="secure")J="__Secure-"+f;else if(H==="host")J="__Host-"+f;return Q$(Q,J)[J]}if(!Q)return{};return Q$(Q)};var Mf=($,f,H)=>{let Q;if(H?.prefix==="secure")Q=E1("__Secure-"+$,f,{path:"/",...H,secure:!0});else if(H?.prefix==="host")Q=E1("__Host-"+$,f,{...H,path:"/",secure:!0,domain:void 0});else Q=E1($,f,{path:"/",...H});return Q},w8=($,f,H,Q)=>{let X=Mf(f,H,Q);$.header("Set-Cookie",X,{append:!0})};class L2{static json($,f=200,H){return new X$($,f,H)}static html($,f=200){return new J$($,f)}static file($,f){return new Y$($,f)}static stream($,f){return new G$($,f)}static redirect($,f=302){return new W$($,f)}}class X${data;status;headers;constructor($,f=200,H={}){this.data=$;this.status=f;this.headers=H}toHonoResponse($){return $.json(this.data,this.status,this.headers)}}class J${content;status;constructor($,f=200){this.content=$;this.status=f}toHonoResponse($){return $.html(this.content,this.status)}}class W${url;status;constructor($,f=302){this.url=$;this.status=f}toHonoResponse($){return $.redirect(this.url,this.status)}}class Y${path;options;constructor($,f){this.path=$;this.options=f}async toHonoResponse($){try{let f=typeof Bun<"u"?Bun.file(this.path):await this.readFileNode(this.path),Q={"Content-Type":this.options?.contentType||this.guessContentType(this.path)};if(this.options?.download||this.options?.filename){let X=this.options?.filename||this.path.split("/").pop()||"download",J=this.options?.download?"attachment":"inline";Q["Content-Disposition"]=`${J}; filename="${X}"`}if(typeof Bun<"u"&&f instanceof Blob)return $.body(f,200,Q);else return $.body(f,200,Q)}catch(f){return $.json({error:"File not found",message:f instanceof Error?f.message:"Unknown error"},404)}}async readFileNode($){throw Error("File reading in Node.js requires fs module - use Bun runtime or implement adapter")}guessContentType($){let f=$.split(".").pop()?.toLowerCase();return{html:"text/html",css:"text/css",js:"application/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",pdf:"application/pdf",txt:"text/plain",xml:"application/xml"}[f||""]||"application/octet-stream"}}class G${stream;options;constructor($,f){this.stream=$;this.options=f}toHonoResponse($){let f={"Content-Type":this.options?.contentType||"application/octet-stream",...this.options?.headers};return $.body(this.stream,200,f)}}class q${static serialize($,f){if(f===null||f===void 0)return $.body(null,204);if(f instanceof L2)return f;if(f instanceof X$)return f.toHonoResponse($);if(f instanceof J$)return f.toHonoResponse($);if(f instanceof Y$)return f.toHonoResponse($);if(f instanceof G$)return f.toHonoResponse($);if(f instanceof W$)return f.toHonoResponse($);if(f&&typeof f.toHonoResponse==="function")return f.toHonoResponse($);return $.json(f)}}class _${static compile($){let f=this.compilePathRegex($.path),H=this.resolveParameterOrder($.parameters),Q=this.resolveDependencyOrder($.dependencies),X=this.calculateMaxArgumentIndex($.parameters,$.dependencies),J=this.computeParameterFlags($.parameters);return{...$,pathRegex:f,parameterOrder:H,dependencyOrder:Q,maxArgumentIndex:X,...J}}static compilePathRegex($){let f=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return f=f.replace(/\\\{([^}]+)\\\}/g,"(?<$1>[^/]+)"),f=f.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,"(?<$1>[^/]+)"),f=`^${f}$`,new RegExp(f)}static resolveParameterOrder($){if(!$||$.length===0)return[];return $.map((f)=>f.index).filter((f)=>f!==void 0).sort((f,H)=>f-H)}static resolveDependencyOrder($){if(!$||$.length===0)return[];return $.map((f)=>f.index).filter((f)=>f!==void 0).sort((f,H)=>f-H)}static calculateMaxArgumentIndex($,f){let H=-1;if($&&$.length>0){let Q=Math.max(...$.map((X)=>X.index));H=Math.max(H,Q)}if(f&&f.length>0){let Q=Math.max(...f.map((X)=>X.index));H=Math.max(H,Q)}return H}static computeParameterFlags($){if(!$||$.length===0)return{hasBody:!1,hasQuery:!1,hasParams:!1,hasHeaders:!1,hasCookies:!1,hasDependencies:!1};return{hasBody:$.some((f)=>f.type==="body"),hasQuery:$.some((f)=>f.type==="query"),hasParams:$.some((f)=>f.type==="param"),hasHeaders:$.some((f)=>f.type==="header"),hasCookies:$.some((f)=>f.type==="cookie"),hasDependencies:!1}}static compileAll($){return $.map((f)=>this.compile(f))}}class B${app;metadata;container;validator;errorHandler;compiledRoutes=new Map;constructor($,f,H,Q,X){this.app=$;this.metadata=f;this.container=H;this.validator=Q;this.errorHandler=X}compile(){let $=this.metadata.getRoutes(),f=_$.compileAll($);for(let H of f){let Q=`${H.target.name}:${H.propertyKey}`;this.compiledRoutes.set(Q,H);let X=this.createHandler(H),J=this.normalizePath(H.path),W=H.method.toLowerCase();if(H.middleware&&H.middleware.length>0)this.app[W](J,...H.middleware,X);else this.app[W](J,X)}}normalizePath($){if(!$.startsWith("/"))$="/"+$;if($=$.replace(/\{([^}]+)\}/g,":$1"),$.length>1&&$.endsWith("/"))$=$.slice(0,-1);return $}createHandler($){return async(f)=>{try{f.set("routeMetadata",$);let H=await this.extractParameters(f,$.parameters),Q=await this.resolveDependencies(f,$.dependencies),X=this.mergeArguments(H,Q,$.parameters,$.maxArgumentIndex),J;if($.handler)J=await $.handler(f,...X);else{let W=await this.container.resolve($.target,{scope:"transient",context:f});if(typeof W[$.propertyKey]!=="function")throw Error(`Method ${$.propertyKey} not found on controller ${$.target.name}`);J=await W[$.propertyKey](...X)}return this.serializeResponse(f,J)}catch(H){return await this.handleError(f,H)}}}serializeResponse($,f){return q$.serialize($,f)}getRouteMetadataForContext($){return $.get("routeMetadata")||null}isAuthRequired($){if($.auth?.required)return!0;return $.parameters.some((f)=>f.type==="current-user")}async handleError($,f){return await this.errorHandler.handle(f,$)}async extractParameters($,f){let H=[];for(let Q of f){if(!Q)continue;let X;switch(Q.type){case"body":try{X=await $.req.json()}catch(Y){X=null}break;case"query":if(Q.name)X=$.req.query(Q.name);else X=$.req.query();break;case"param":if(Q.name)X=$.req.param(Q.name);else X=$.req.param();break;case"header":if(Q.name)X=$.req.header(Q.name);else{let Y={};$.req.raw.headers.forEach((G,_)=>{Y[_]=G}),X=Y}break;case"cookie":if(Q.name)X=j2($,Q.name);else{let Y=$.req.header("cookie");if(Y)X=Object.fromEntries(Y.split(";").map((G)=>{let[_,...S]=G.trim().split("=");return[_,S.join("=")]}));else X={}}break;case"request":X=$.req;break;case"response":case"context":X=$;break;case"current-user":X=$.get("auth.user")||null;let J=this.getRouteMetadataForContext($);if(J&&this.isAuthRequired(J)){if(!X){let Y=$.get("auth.error")||"Authentication required",{AuthenticationException:G}=await Promise.resolve().then(() => (D2(),E2));throw new G(Y)}}break;case"token":X=$.get("auth.token")||null;break;case"oauth-user":X=$.get("oauth.user")||null;break;case"oauth-token":X=$.get("oauth.token")||null;break;case"current-session":X=$.get("session")||null;break;case"session-data":let W=$.get("session");if(W&&Q.metadata?.key)X=W.data[Q.metadata.key];else if(W)X=W.data;else X=null;break;case"csrf-token":X=$.get("csrf.token")||null;break;case"filtered-resource":X=$.get("filtered.resource")||null;break;case"filtered-attributes":X=$.get("filtered.attributes")||[];break;default:X=void 0}if(Q.schema)try{X=await this.validator.validate(X,Q.schema)}catch(J){throw J}H[Q.index]=X}return H}mergeArguments($,f,H,Q){let J=H.filter((_)=>_!==void 0&&_.index!==void 0).map((_)=>_.index),W=J.length>0?Math.max(...J):-1,Y=Q!==void 0&&Q>=0?Q:Math.max(W,$.length-1,f.length-1,0);if(!Number.isFinite(Y)||Y<0)Y=0;let G=Array(Y+1);for(let _=0;_<=Y;_++)if($[_]!==void 0)G[_]=$[_];else if(f[_]!==void 0)G[_]=f[_];return G}async resolveDependencies($,f){let H=[];for(let Q of f){if(!Q)continue;try{let X=await this.container.resolve(Q.provider,{scope:Q.scope,context:$});H[Q.index]=X}catch(X){throw Error(`Failed to resolve dependency at index ${Q.index}: ${X instanceof Error?X.message:"Unknown error"}`)}}return H}}var P2={};t0(P2,{void:()=>R4,util:()=>P,unknown:()=>N4,union:()=>F4,undefined:()=>j4,tuple:()=>C4,transformer:()=>x4,symbol:()=>w4,string:()=>M2,strictObject:()=>b4,setErrorMap:()=>gf,set:()=>h4,record:()=>O4,quotelessJson:()=>Tf,promise:()=>T4,preprocess:()=>Z4,pipeline:()=>m4,ostring:()=>n4,optional:()=>g4,onumber:()=>c4,oboolean:()=>u4,objectUtil:()=>z$,object:()=>D4,number:()=>k2,nullable:()=>l4,null:()=>L4,never:()=>V4,nativeEnum:()=>K4,nan:()=>_4,map:()=>v4,makeIssue:()=>J1,literal:()=>I4,lazy:()=>k4,late:()=>G4,isValid:()=>N0,isDirty:()=>F1,isAsync:()=>K0,isAborted:()=>b1,intersection:()=>U4,instanceof:()=>q4,getParsedType:()=>_0,getErrorMap:()=>P0,function:()=>M4,enum:()=>P4,effect:()=>x4,discriminatedUnion:()=>A4,defaultErrorMap:()=>w0,datetimeRegex:()=>O2,date:()=>z4,custom:()=>h2,coerce:()=>y4,boolean:()=>I2,bigint:()=>B4,array:()=>E4,any:()=>S4,addIssueToContext:()=>N,ZodVoid:()=>Y1,ZodUnknown:()=>V0,ZodUnion:()=>m0,ZodUndefined:()=>l0,ZodType:()=>M,ZodTuple:()=>z0,ZodTransformer:()=>Y0,ZodSymbol:()=>W1,ZodString:()=>Q0,ZodSet:()=>O0,ZodSchema:()=>M,ZodRecord:()=>G1,ZodReadonly:()=>o0,ZodPromise:()=>v0,ZodPipeline:()=>B1,ZodParsedType:()=>j,ZodOptional:()=>J0,ZodObject:()=>g,ZodNumber:()=>R0,ZodNullable:()=>L0,ZodNull:()=>Z0,ZodNever:()=>B0,ZodNativeEnum:()=>y0,ZodNaN:()=>_1,ZodMap:()=>q1,ZodLiteral:()=>u0,ZodLazy:()=>c0,ZodIssueCode:()=>w,ZodIntersection:()=>n0,ZodFunction:()=>x0,ZodFirstPartyTypeKind:()=>C,ZodError:()=>d,ZodEnum:()=>D0,ZodEffects:()=>Y0,ZodDiscriminatedUnion:()=>A1,ZodDefault:()=>i0,ZodDate:()=>U0,ZodCatch:()=>s0,ZodBranded:()=>U1,ZodBoolean:()=>g0,ZodBigInt:()=>E0,ZodArray:()=>X0,ZodAny:()=>C0,Schema:()=>M,ParseStatus:()=>p,OK:()=>r,NEVER:()=>i4,INVALID:()=>U,EMPTY_PATH:()=>lf,DIRTY:()=>A0,BRAND:()=>Y4});var P;(function($){$.assertEqual=(X)=>{};function f(X){}$.assertIs=f;function H(X){throw Error()}$.assertNever=H,$.arrayToEnum=(X)=>{let J={};for(let W of X)J[W]=W;return J},$.getValidEnumValues=(X)=>{let J=$.objectKeys(X).filter((Y)=>typeof X[X[Y]]!=="number"),W={};for(let Y of J)W[Y]=X[Y];return $.objectValues(W)},$.objectValues=(X)=>{return $.objectKeys(X).map(function(J){return X[J]})},$.objectKeys=typeof Object.keys==="function"?(X)=>Object.keys(X):(X)=>{let J=[];for(let W in X)if(Object.prototype.hasOwnProperty.call(X,W))J.push(W);return J},$.find=(X,J)=>{for(let W of X)if(J(W))return W;return},$.isInteger=typeof Number.isInteger==="function"?(X)=>Number.isInteger(X):(X)=>typeof X==="number"&&Number.isFinite(X)&&Math.floor(X)===X;function Q(X,J=" | "){return X.map((W)=>typeof W==="string"?`'${W}'`:W).join(J)}$.joinValues=Q,$.jsonStringifyReplacer=(X,J)=>{if(typeof J==="bigint")return J.toString();return J}})(P||(P={}));var z$;(function($){$.mergeShapes=(f,H)=>{return{...f,...H}}})(z$||(z$={}));var j=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_0=($)=>{switch(typeof $){case"undefined":return j.undefined;case"string":return j.string;case"number":return Number.isNaN($)?j.nan:j.number;case"boolean":return j.boolean;case"function":return j.function;case"bigint":return j.bigint;case"symbol":return j.symbol;case"object":if(Array.isArray($))return j.array;if($===null)return j.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return j.promise;if(typeof Map<"u"&&$ instanceof Map)return j.map;if(typeof Set<"u"&&$ instanceof Set)return j.set;if(typeof Date<"u"&&$ instanceof Date)return j.date;return j.object;default:return j.unknown}};var w=P.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"]),Tf=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class d extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(H)=>{this.issues=[...this.issues,H]},this.addIssues=(H=[])=>{this.issues=[...this.issues,...H]};let f=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,f);else this.__proto__=f;this.name="ZodError",this.issues=$}format($){let f=$||function(X){return X.message},H={_errors:[]},Q=(X)=>{for(let J of X.issues)if(J.code==="invalid_union")J.unionErrors.map(Q);else if(J.code==="invalid_return_type")Q(J.returnTypeError);else if(J.code==="invalid_arguments")Q(J.argumentsError);else if(J.path.length===0)H._errors.push(f(J));else{let W=H,Y=0;while(Y<J.path.length){let G=J.path[Y];if(Y!==J.path.length-1)W[G]=W[G]||{_errors:[]};else W[G]=W[G]||{_errors:[]},W[G]._errors.push(f(J));W=W[G],Y++}}};return Q(this),H}static assert($){if(!($ instanceof d))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(f)=>f.message){let f={},H=[];for(let Q of this.issues)if(Q.path.length>0){let X=Q.path[0];f[X]=f[X]||[],f[X].push($(Q))}else H.push($(Q));return{formErrors:H,fieldErrors:f}}get formErrors(){return this.flatten()}}d.create=($)=>{return new d($)};var xf=($,f)=>{let H;switch($.code){case w.invalid_type:if($.received===j.undefined)H="Required";else H=`Expected ${$.expected}, received ${$.received}`;break;case w.invalid_literal:H=`Invalid literal value, expected ${JSON.stringify($.expected,P.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:H=`Unrecognized key(s) in object: ${P.joinValues($.keys,", ")}`;break;case w.invalid_union:H="Invalid input";break;case w.invalid_union_discriminator:H=`Invalid discriminator value. Expected ${P.joinValues($.options)}`;break;case w.invalid_enum_value:H=`Invalid enum value. Expected ${P.joinValues($.options)}, received '${$.received}'`;break;case w.invalid_arguments:H="Invalid function arguments";break;case w.invalid_return_type:H="Invalid function return type";break;case w.invalid_date:H="Invalid date";break;case w.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(H=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")H=`${H} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)H=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)H=`Invalid input: must end with "${$.validation.endsWith}"`;else P.assertNever($.validation);else if($.validation!=="regex")H=`Invalid ${$.validation}`;else H="Invalid";break;case w.too_small:if($.type==="array")H=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")H=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")H=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")H=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")H=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else H="Invalid input";break;case w.too_big:if($.type==="array")H=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")H=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")H=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")H=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")H=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else H="Invalid input";break;case w.custom:H="Invalid input";break;case w.invalid_intersection_types:H="Intersection results could not be merged";break;case w.not_multiple_of:H=`Number must be a multiple of ${$.multipleOf}`;break;case w.not_finite:H="Number must be finite";break;default:H=f.defaultError,P.assertNever($)}return{message:H}},w0=xf;var b2=w0;function gf($){b2=$}function P0(){return b2}var J1=($)=>{let{data:f,path:H,errorMaps:Q,issueData:X}=$,J=[...H,...X.path||[]],W={...X,path:J};if(X.message!==void 0)return{...X,path:J,message:X.message};let Y="",G=Q.filter((_)=>!!_).slice().reverse();for(let _ of G)Y=_(W,{data:f,defaultError:Y}).message;return{...X,path:J,message:Y}},lf=[];function N($,f){let H=P0(),Q=J1({issueData:f,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,H,H===w0?void 0:w0].filter((X)=>!!X)});$.common.issues.push(Q)}class p{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,f){let H=[];for(let Q of f){if(Q.status==="aborted")return U;if(Q.status==="dirty")$.dirty();H.push(Q.value)}return{status:$.value,value:H}}static async mergeObjectAsync($,f){let H=[];for(let Q of f){let X=await Q.key,J=await Q.value;H.push({key:X,value:J})}return p.mergeObjectSync($,H)}static mergeObjectSync($,f){let H={};for(let Q of f){let{key:X,value:J}=Q;if(X.status==="aborted")return U;if(J.status==="aborted")return U;if(X.status==="dirty")$.dirty();if(J.status==="dirty")$.dirty();if(X.value!=="__proto__"&&(typeof J.value<"u"||Q.alwaysSet))H[X.value]=J.value}return{status:$.value,value:H}}}var U=Object.freeze({status:"aborted"}),A0=($)=>({status:"dirty",value:$}),r=($)=>({status:"valid",value:$}),b1=($)=>$.status==="aborted",F1=($)=>$.status==="dirty",N0=($)=>$.status==="valid",K0=($)=>typeof Promise<"u"&&$ instanceof Promise;var D;(function($){$.errToObj=(f)=>typeof f==="string"?{message:f}:f||{},$.toString=(f)=>typeof f==="string"?f:f?.message})(D||(D={}));class W0{constructor($,f,H,Q){this._cachedPath=[],this.parent=$,this.data=f,this._path=H,this._key=Q}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 F2=($,f)=>{if(N0(f))return{success:!0,data:f.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 H=new d($.common.issues);return this._error=H,this._error}}}};function v($){if(!$)return{};let{errorMap:f,invalid_type_error:H,required_error:Q,description:X}=$;if(f&&(H||Q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(f)return{errorMap:f,description:X};return{errorMap:(W,Y)=>{let{message:G}=$;if(W.code==="invalid_enum_value")return{message:G??Y.defaultError};if(typeof Y.data>"u")return{message:G??Q??Y.defaultError};if(W.code!=="invalid_type")return{message:Y.defaultError};return{message:G??H??Y.defaultError}},description:X}}class M{get description(){return this._def.description}_getType($){return _0($.data)}_getOrReturnCtx($,f){return f||{common:$.parent.common,data:$.data,parsedType:_0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new p,ctx:{common:$.parent.common,data:$.data,parsedType:_0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let f=this._parse($);if(K0(f))throw Error("Synchronous parse encountered promise.");return f}_parseAsync($){let f=this._parse($);return Promise.resolve(f)}parse($,f){let H=this.safeParse($,f);if(H.success)return H.data;throw H.error}safeParse($,f){let H={common:{issues:[],async:f?.async??!1,contextualErrorMap:f?.errorMap},path:f?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:_0($)},Q=this._parseSync({data:$,path:H.path,parent:H});return F2(H,Q)}"~validate"($){let f={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:_0($)};if(!this["~standard"].async)try{let H=this._parseSync({data:$,path:[],parent:f});return N0(H)?{value:H.value}:{issues:f.common.issues}}catch(H){if(H?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;f.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:f}).then((H)=>N0(H)?{value:H.value}:{issues:f.common.issues})}async parseAsync($,f){let H=await this.safeParseAsync($,f);if(H.success)return H.data;throw H.error}async safeParseAsync($,f){let H={common:{issues:[],contextualErrorMap:f?.errorMap,async:!0},path:f?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:_0($)},Q=this._parse({data:$,path:H.path,parent:H}),X=await(K0(Q)?Q:Promise.resolve(Q));return F2(H,X)}refine($,f){let H=(Q)=>{if(typeof f==="string"||typeof f>"u")return{message:f};else if(typeof f==="function")return f(Q);else return f};return this._refinement((Q,X)=>{let J=$(Q),W=()=>X.addIssue({code:w.custom,...H(Q)});if(typeof Promise<"u"&&J instanceof Promise)return J.then((Y)=>{if(!Y)return W(),!1;else return!0});if(!J)return W(),!1;else return!0})}refinement($,f){return this._refinement((H,Q)=>{if(!$(H))return Q.addIssue(typeof f==="function"?f(H,Q):f),!1;else return!0})}_refinement($){return new Y0({schema:this,typeName:C.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:(f)=>this["~validate"](f)}}optional(){return J0.create(this,this._def)}nullable(){return L0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X0.create(this)}promise(){return v0.create(this,this._def)}or($){return m0.create([this,$],this._def)}and($){return n0.create(this,$,this._def)}transform($){return new Y0({...v(this._def),schema:this,typeName:C.ZodEffects,effect:{type:"transform",transform:$}})}default($){let f=typeof $==="function"?$:()=>$;return new i0({...v(this._def),innerType:this,defaultValue:f,typeName:C.ZodDefault})}brand(){return new U1({typeName:C.ZodBranded,type:this,...v(this._def)})}catch($){let f=typeof $==="function"?$:()=>$;return new s0({...v(this._def),innerType:this,catchValue:f,typeName:C.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return B1.create(this,$)}readonly(){return o0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var Zf=/^c[^\s-]{8,}$/i,mf=/^[0-9a-z]+$/,nf=/^[0-9A-HJKMNP-TV-Z]{26}$/i,cf=/^[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,uf=/^[a-z0-9_-]{21}$/i,yf=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,sf=/^[-+]?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)?)??$/,of=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,df="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",w$,pf=/^(?:(?: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])$/,rf=/^(?:(?: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])$/,tf=/^(([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]))$/,af=/^(([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])$/,ef=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,U2="((\\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])))",f4=new RegExp(`^${U2}$`);function C2($){let f="[0-5]\\d";if($.precision)f=`${f}\\.\\d{${$.precision}}`;else if($.precision==null)f=`${f}(\\.\\d+)?`;let H=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${f})${H}`}function H4($){return new RegExp(`^${C2($)}$`)}function O2($){let f=`${U2}T${C2($)}`,H=[];if(H.push($.local?"Z?":"Z"),$.offset)H.push("([+-]\\d{2}:?\\d{2})");return f=`${f}(${H.join("|")})`,new RegExp(`^${f}$`)}function Q4($,f){if((f==="v4"||!f)&&pf.test($))return!0;if((f==="v6"||!f)&&tf.test($))return!0;return!1}function X4($,f){if(!yf.test($))return!1;try{let[H]=$.split(".");if(!H)return!1;let Q=H.replace(/-/g,"+").replace(/_/g,"/").padEnd(H.length+(4-H.length%4)%4,"="),X=JSON.parse(atob(Q));if(typeof X!=="object"||X===null)return!1;if("typ"in X&&X?.typ!=="JWT")return!1;if(!X.alg)return!1;if(f&&X.alg!==f)return!1;return!0}catch{return!1}}function J4($,f){if((f==="v4"||!f)&&rf.test($))return!0;if((f==="v6"||!f)&&af.test($))return!0;return!1}class Q0 extends M{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==j.string){let X=this._getOrReturnCtx($);return N(X,{code:w.invalid_type,expected:j.string,received:X.parsedType}),U}let H=new p,Q=void 0;for(let X of this._def.checks)if(X.kind==="min"){if($.data.length<X.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:w.too_small,minimum:X.value,type:"string",inclusive:!0,exact:!1,message:X.message}),H.dirty()}else if(X.kind==="max"){if($.data.length>X.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:w.too_big,maximum:X.value,type:"string",inclusive:!0,exact:!1,message:X.message}),H.dirty()}else if(X.kind==="length"){let J=$.data.length>X.value,W=$.data.length<X.value;if(J||W){if(Q=this._getOrReturnCtx($,Q),J)N(Q,{code:w.too_big,maximum:X.value,type:"string",inclusive:!0,exact:!0,message:X.message});else if(W)N(Q,{code:w.too_small,minimum:X.value,type:"string",inclusive:!0,exact:!0,message:X.message});H.dirty()}}else if(X.kind==="email"){if(!of.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"email",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="emoji"){if(!w$)w$=new RegExp(df,"u");if(!w$.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"emoji",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="uuid"){if(!cf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"uuid",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="nanoid"){if(!uf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"nanoid",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="cuid"){if(!Zf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"cuid",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="cuid2"){if(!mf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"cuid2",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="ulid"){if(!nf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"ulid",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="url")try{new URL($.data)}catch{Q=this._getOrReturnCtx($,Q),N(Q,{validation:"url",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="regex"){if(X.regex.lastIndex=0,!X.regex.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"regex",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="trim")$.data=$.data.trim();else if(X.kind==="includes"){if(!$.data.includes(X.value,X.position))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:{includes:X.value,position:X.position},message:X.message}),H.dirty()}else if(X.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(X.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(X.kind==="startsWith"){if(!$.data.startsWith(X.value))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:{startsWith:X.value},message:X.message}),H.dirty()}else if(X.kind==="endsWith"){if(!$.data.endsWith(X.value))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:{endsWith:X.value},message:X.message}),H.dirty()}else if(X.kind==="datetime"){if(!O2(X).test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:"datetime",message:X.message}),H.dirty()}else if(X.kind==="date"){if(!f4.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:"date",message:X.message}),H.dirty()}else if(X.kind==="time"){if(!H4(X).test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:"time",message:X.message}),H.dirty()}else if(X.kind==="duration"){if(!sf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"duration",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="ip"){if(!Q4($.data,X.version))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"ip",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="jwt"){if(!X4($.data,X.alg))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"jwt",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="cidr"){if(!J4($.data,X.version))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"cidr",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="base64"){if(!ef.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"base64",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="base64url"){if(!$4.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"base64url",code:w.invalid_string,message:X.message}),H.dirty()}else P.assertNever(X);return{status:H.value,value:$.data}}_regex($,f,H){return this.refinement((Q)=>$.test(Q),{validation:f,code:w.invalid_string,...D.errToObj(H)})}_addCheck($){return new Q0({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...D.errToObj($)})}url($){return this._addCheck({kind:"url",...D.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...D.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...D.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...D.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...D.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...D.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...D.errToObj($)})}base64($){return this._addCheck({kind:"base64",...D.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...D.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...D.errToObj($)})}ip($){return this._addCheck({kind:"ip",...D.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...D.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,...D.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,...D.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...D.errToObj($)})}regex($,f){return this._addCheck({kind:"regex",regex:$,...D.errToObj(f)})}includes($,f){return this._addCheck({kind:"includes",value:$,position:f?.position,...D.errToObj(f?.message)})}startsWith($,f){return this._addCheck({kind:"startsWith",value:$,...D.errToObj(f)})}endsWith($,f){return this._addCheck({kind:"endsWith",value:$,...D.errToObj(f)})}min($,f){return this._addCheck({kind:"min",value:$,...D.errToObj(f)})}max($,f){return this._addCheck({kind:"max",value:$,...D.errToObj(f)})}length($,f){return this._addCheck({kind:"length",value:$,...D.errToObj(f)})}nonempty($){return this.min(1,D.errToObj($))}trim(){return new Q0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Q0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Q0({...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 f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $}get maxLength(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $}}Q0.create=($)=>{return new Q0({checks:[],typeName:C.ZodString,coerce:$?.coerce??!1,...v($)})};function W4($,f){let H=($.toString().split(".")[1]||"").length,Q=(f.toString().split(".")[1]||"").length,X=H>Q?H:Q,J=Number.parseInt($.toFixed(X).replace(".","")),W=Number.parseInt(f.toFixed(X).replace(".",""));return J%W/10**X}class R0 extends M{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($)!==j.number){let X=this._getOrReturnCtx($);return N(X,{code:w.invalid_type,expected:j.number,received:X.parsedType}),U}let H=void 0,Q=new p;for(let X of this._def.checks)if(X.kind==="int"){if(!P.isInteger($.data))H=this._getOrReturnCtx($,H),N(H,{code:w.invalid_type,expected:"integer",received:"float",message:X.message}),Q.dirty()}else if(X.kind==="min"){if(X.inclusive?$.data<X.value:$.data<=X.value)H=this._getOrReturnCtx($,H),N(H,{code:w.too_small,minimum:X.value,type:"number",inclusive:X.inclusive,exact:!1,message:X.message}),Q.dirty()}else if(X.kind==="max"){if(X.inclusive?$.data>X.value:$.data>=X.value)H=this._getOrReturnCtx($,H),N(H,{code:w.too_big,maximum:X.value,type:"number",inclusive:X.inclusive,exact:!1,message:X.message}),Q.dirty()}else if(X.kind==="multipleOf"){if(W4($.data,X.value)!==0)H=this._getOrReturnCtx($,H),N(H,{code:w.not_multiple_of,multipleOf:X.value,message:X.message}),Q.dirty()}else if(X.kind==="finite"){if(!Number.isFinite($.data))H=this._getOrReturnCtx($,H),N(H,{code:w.not_finite,message:X.message}),Q.dirty()}else P.assertNever(X);return{status:Q.value,value:$.data}}gte($,f){return this.setLimit("min",$,!0,D.toString(f))}gt($,f){return this.setLimit("min",$,!1,D.toString(f))}lte($,f){return this.setLimit("max",$,!0,D.toString(f))}lt($,f){return this.setLimit("max",$,!1,D.toString(f))}setLimit($,f,H,Q){return new R0({...this._def,checks:[...this._def.checks,{kind:$,value:f,inclusive:H,message:D.toString(Q)}]})}_addCheck($){return new R0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:D.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:D.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:D.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:D.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:D.toString($)})}multipleOf($,f){return this._addCheck({kind:"multipleOf",value:$,message:D.toString(f)})}finite($){return this._addCheck({kind:"finite",message:D.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:D.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:D.toString($)})}get minValue(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $}get maxValue(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&P.isInteger($.value))}get isFinite(){let $=null,f=null;for(let H of this._def.checks)if(H.kind==="finite"||H.kind==="int"||H.kind==="multipleOf")return!0;else if(H.kind==="min"){if(f===null||H.value>f)f=H.value}else if(H.kind==="max"){if($===null||H.value<$)$=H.value}return Number.isFinite(f)&&Number.isFinite($)}}R0.create=($)=>{return new R0({checks:[],typeName:C.ZodNumber,coerce:$?.coerce||!1,...v($)})};class E0 extends M{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($)!==j.bigint)return this._getInvalidInput($);let H=void 0,Q=new p;for(let X of this._def.checks)if(X.kind==="min"){if(X.inclusive?$.data<X.value:$.data<=X.value)H=this._getOrReturnCtx($,H),N(H,{code:w.too_small,type:"bigint",minimum:X.value,inclusive:X.inclusive,message:X.message}),Q.dirty()}else if(X.kind==="max"){if(X.inclusive?$.data>X.value:$.data>=X.value)H=this._getOrReturnCtx($,H),N(H,{code:w.too_big,type:"bigint",maximum:X.value,inclusive:X.inclusive,message:X.message}),Q.dirty()}else if(X.kind==="multipleOf"){if($.data%X.value!==BigInt(0))H=this._getOrReturnCtx($,H),N(H,{code:w.not_multiple_of,multipleOf:X.value,message:X.message}),Q.dirty()}else P.assertNever(X);return{status:Q.value,value:$.data}}_getInvalidInput($){let f=this._getOrReturnCtx($);return N(f,{code:w.invalid_type,expected:j.bigint,received:f.parsedType}),U}gte($,f){return this.setLimit("min",$,!0,D.toString(f))}gt($,f){return this.setLimit("min",$,!1,D.toString(f))}lte($,f){return this.setLimit("max",$,!0,D.toString(f))}lt($,f){return this.setLimit("max",$,!1,D.toString(f))}setLimit($,f,H,Q){return new E0({...this._def,checks:[...this._def.checks,{kind:$,value:f,inclusive:H,message:D.toString(Q)}]})}_addCheck($){return new E0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:D.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:D.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:D.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:D.toString($)})}multipleOf($,f){return this._addCheck({kind:"multipleOf",value:$,message:D.toString(f)})}get minValue(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $}get maxValue(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $}}E0.create=($)=>{return new E0({checks:[],typeName:C.ZodBigInt,coerce:$?.coerce??!1,...v($)})};class g0 extends M{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==j.boolean){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.boolean,received:H.parsedType}),U}return r($.data)}}g0.create=($)=>{return new g0({typeName:C.ZodBoolean,coerce:$?.coerce||!1,...v($)})};class U0 extends M{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==j.date){let X=this._getOrReturnCtx($);return N(X,{code:w.invalid_type,expected:j.date,received:X.parsedType}),U}if(Number.isNaN($.data.getTime())){let X=this._getOrReturnCtx($);return N(X,{code:w.invalid_date}),U}let H=new p,Q=void 0;for(let X of this._def.checks)if(X.kind==="min"){if($.data.getTime()<X.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:w.too_small,message:X.message,inclusive:!0,exact:!1,minimum:X.value,type:"date"}),H.dirty()}else if(X.kind==="max"){if($.data.getTime()>X.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:w.too_big,message:X.message,inclusive:!0,exact:!1,maximum:X.value,type:"date"}),H.dirty()}else P.assertNever(X);return{status:H.value,value:new Date($.data.getTime())}}_addCheck($){return new U0({...this._def,checks:[...this._def.checks,$]})}min($,f){return this._addCheck({kind:"min",value:$.getTime(),message:D.toString(f)})}max($,f){return this._addCheck({kind:"max",value:$.getTime(),message:D.toString(f)})}get minDate(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $!=null?new Date($):null}}U0.create=($)=>{return new U0({checks:[],coerce:$?.coerce||!1,typeName:C.ZodDate,...v($)})};class W1 extends M{_parse($){if(this._getType($)!==j.symbol){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.symbol,received:H.parsedType}),U}return r($.data)}}W1.create=($)=>{return new W1({typeName:C.ZodSymbol,...v($)})};class l0 extends M{_parse($){if(this._getType($)!==j.undefined){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.undefined,received:H.parsedType}),U}return r($.data)}}l0.create=($)=>{return new l0({typeName:C.ZodUndefined,...v($)})};class Z0 extends M{_parse($){if(this._getType($)!==j.null){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.null,received:H.parsedType}),U}return r($.data)}}Z0.create=($)=>{return new Z0({typeName:C.ZodNull,...v($)})};class C0 extends M{constructor(){super(...arguments);this._any=!0}_parse($){return r($.data)}}C0.create=($)=>{return new C0({typeName:C.ZodAny,...v($)})};class V0 extends M{constructor(){super(...arguments);this._unknown=!0}_parse($){return r($.data)}}V0.create=($)=>{return new V0({typeName:C.ZodUnknown,...v($)})};class B0 extends M{_parse($){let f=this._getOrReturnCtx($);return N(f,{code:w.invalid_type,expected:j.never,received:f.parsedType}),U}}B0.create=($)=>{return new B0({typeName:C.ZodNever,...v($)})};class Y1 extends M{_parse($){if(this._getType($)!==j.undefined){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.void,received:H.parsedType}),U}return r($.data)}}Y1.create=($)=>{return new Y1({typeName:C.ZodVoid,...v($)})};class X0 extends M{_parse($){let{ctx:f,status:H}=this._processInputParams($),Q=this._def;if(f.parsedType!==j.array)return N(f,{code:w.invalid_type,expected:j.array,received:f.parsedType}),U;if(Q.exactLength!==null){let J=f.data.length>Q.exactLength.value,W=f.data.length<Q.exactLength.value;if(J||W)N(f,{code:J?w.too_big:w.too_small,minimum:W?Q.exactLength.value:void 0,maximum:J?Q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Q.exactLength.message}),H.dirty()}if(Q.minLength!==null){if(f.data.length<Q.minLength.value)N(f,{code:w.too_small,minimum:Q.minLength.value,type:"array",inclusive:!0,exact:!1,message:Q.minLength.message}),H.dirty()}if(Q.maxLength!==null){if(f.data.length>Q.maxLength.value)N(f,{code:w.too_big,maximum:Q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Q.maxLength.message}),H.dirty()}if(f.common.async)return Promise.all([...f.data].map((J,W)=>{return Q.type._parseAsync(new W0(f,J,f.path,W))})).then((J)=>{return p.mergeArray(H,J)});let X=[...f.data].map((J,W)=>{return Q.type._parseSync(new W0(f,J,f.path,W))});return p.mergeArray(H,X)}get element(){return this._def.type}min($,f){return new X0({...this._def,minLength:{value:$,message:D.toString(f)}})}max($,f){return new X0({...this._def,maxLength:{value:$,message:D.toString(f)}})}length($,f){return new X0({...this._def,exactLength:{value:$,message:D.toString(f)}})}nonempty($){return this.min(1,$)}}X0.create=($,f)=>{return new X0({type:$,minLength:null,maxLength:null,exactLength:null,typeName:C.ZodArray,...v(f)})};function T0($){if($ instanceof g){let f={};for(let H in $.shape){let Q=$.shape[H];f[H]=J0.create(T0(Q))}return new g({...$._def,shape:()=>f})}else if($ instanceof X0)return new X0({...$._def,type:T0($.element)});else if($ instanceof J0)return J0.create(T0($.unwrap()));else if($ instanceof L0)return L0.create(T0($.unwrap()));else if($ instanceof z0)return z0.create($.items.map((f)=>T0(f)));else return $}class g extends M{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(),f=P.objectKeys($);return this._cached={shape:$,keys:f},this._cached}_parse($){if(this._getType($)!==j.object){let G=this._getOrReturnCtx($);return N(G,{code:w.invalid_type,expected:j.object,received:G.parsedType}),U}let{status:H,ctx:Q}=this._processInputParams($),{shape:X,keys:J}=this._getCached(),W=[];if(!(this._def.catchall instanceof B0&&this._def.unknownKeys==="strip")){for(let G in Q.data)if(!J.includes(G))W.push(G)}let Y=[];for(let G of J){let _=X[G],S=Q.data[G];Y.push({key:{status:"valid",value:G},value:_._parse(new W0(Q,S,Q.path,G)),alwaysSet:G in Q.data})}if(this._def.catchall instanceof B0){let G=this._def.unknownKeys;if(G==="passthrough")for(let _ of W)Y.push({key:{status:"valid",value:_},value:{status:"valid",value:Q.data[_]}});else if(G==="strict"){if(W.length>0)N(Q,{code:w.unrecognized_keys,keys:W}),H.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let _ of W){let S=Q.data[_];Y.push({key:{status:"valid",value:_},value:G._parse(new W0(Q,S,Q.path,_)),alwaysSet:_ in Q.data})}}if(Q.common.async)return Promise.resolve().then(async()=>{let G=[];for(let _ of Y){let S=await _.key,A=await _.value;G.push({key:S,value:A,alwaysSet:_.alwaysSet})}return G}).then((G)=>{return p.mergeObjectSync(H,G)});else return p.mergeObjectSync(H,Y)}get shape(){return this._def.shape()}strict($){return D.errToObj,new g({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(f,H)=>{let Q=this._def.errorMap?.(f,H).message??H.defaultError;if(f.code==="unrecognized_keys")return{message:D.errToObj($).message??Q};return{message:Q}}}:{}})}strip(){return new g({...this._def,unknownKeys:"strip"})}passthrough(){return new g({...this._def,unknownKeys:"passthrough"})}extend($){return new g({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new g({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:C.ZodObject})}setKey($,f){return this.augment({[$]:f})}catchall($){return new g({...this._def,catchall:$})}pick($){let f={};for(let H of P.objectKeys($))if($[H]&&this.shape[H])f[H]=this.shape[H];return new g({...this._def,shape:()=>f})}omit($){let f={};for(let H of P.objectKeys(this.shape))if(!$[H])f[H]=this.shape[H];return new g({...this._def,shape:()=>f})}deepPartial(){return T0(this)}partial($){let f={};for(let H of P.objectKeys(this.shape)){let Q=this.shape[H];if($&&!$[H])f[H]=Q;else f[H]=Q.optional()}return new g({...this._def,shape:()=>f})}required($){let f={};for(let H of P.objectKeys(this.shape))if($&&!$[H])f[H]=this.shape[H];else{let X=this.shape[H];while(X instanceof J0)X=X._def.innerType;f[H]=X}return new g({...this._def,shape:()=>f})}keyof(){return v2(P.objectKeys(this.shape))}}g.create=($,f)=>{return new g({shape:()=>$,unknownKeys:"strip",catchall:B0.create(),typeName:C.ZodObject,...v(f)})};g.strictCreate=($,f)=>{return new g({shape:()=>$,unknownKeys:"strict",catchall:B0.create(),typeName:C.ZodObject,...v(f)})};g.lazycreate=($,f)=>{return new g({shape:$,unknownKeys:"strip",catchall:B0.create(),typeName:C.ZodObject,...v(f)})};class m0 extends M{_parse($){let{ctx:f}=this._processInputParams($),H=this._def.options;function Q(X){for(let W of X)if(W.result.status==="valid")return W.result;for(let W of X)if(W.result.status==="dirty")return f.common.issues.push(...W.ctx.common.issues),W.result;let J=X.map((W)=>new d(W.ctx.common.issues));return N(f,{code:w.invalid_union,unionErrors:J}),U}if(f.common.async)return Promise.all(H.map(async(X)=>{let J={...f,common:{...f.common,issues:[]},parent:null};return{result:await X._parseAsync({data:f.data,path:f.path,parent:J}),ctx:J}})).then(Q);else{let X=void 0,J=[];for(let Y of H){let G={...f,common:{...f.common,issues:[]},parent:null},_=Y._parseSync({data:f.data,path:f.path,parent:G});if(_.status==="valid")return _;else if(_.status==="dirty"&&!X)X={result:_,ctx:G};if(G.common.issues.length)J.push(G.common.issues)}if(X)return f.common.issues.push(...X.ctx.common.issues),X.result;let W=J.map((Y)=>new d(Y));return N(f,{code:w.invalid_union,unionErrors:W}),U}}get options(){return this._def.options}}m0.create=($,f)=>{return new m0({options:$,typeName:C.ZodUnion,...v(f)})};var j0=($)=>{if($ instanceof c0)return j0($.schema);else if($ instanceof Y0)return j0($.innerType());else if($ instanceof u0)return[$.value];else if($ instanceof D0)return $.options;else if($ instanceof y0)return P.objectValues($.enum);else if($ instanceof i0)return j0($._def.innerType);else if($ instanceof l0)return[void 0];else if($ instanceof Z0)return[null];else if($ instanceof J0)return[void 0,...j0($.unwrap())];else if($ instanceof L0)return[null,...j0($.unwrap())];else if($ instanceof U1)return j0($.unwrap());else if($ instanceof o0)return j0($.unwrap());else if($ instanceof s0)return j0($._def.innerType);else return[]};class A1 extends M{_parse($){let{ctx:f}=this._processInputParams($);if(f.parsedType!==j.object)return N(f,{code:w.invalid_type,expected:j.object,received:f.parsedType}),U;let H=this.discriminator,Q=f.data[H],X=this.optionsMap.get(Q);if(!X)return N(f,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[H]}),U;if(f.common.async)return X._parseAsync({data:f.data,path:f.path,parent:f});else return X._parseSync({data:f.data,path:f.path,parent:f})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,f,H){let Q=new Map;for(let X of f){let J=j0(X.shape[$]);if(!J.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let W of J){if(Q.has(W))throw Error(`Discriminator property ${String($)} has duplicate value ${String(W)}`);Q.set(W,X)}}return new A1({typeName:C.ZodDiscriminatedUnion,discriminator:$,options:f,optionsMap:Q,...v(H)})}}function j$($,f){let H=_0($),Q=_0(f);if($===f)return{valid:!0,data:$};else if(H===j.object&&Q===j.object){let X=P.objectKeys(f),J=P.objectKeys($).filter((Y)=>X.indexOf(Y)!==-1),W={...$,...f};for(let Y of J){let G=j$($[Y],f[Y]);if(!G.valid)return{valid:!1};W[Y]=G.data}return{valid:!0,data:W}}else if(H===j.array&&Q===j.array){if($.length!==f.length)return{valid:!1};let X=[];for(let J=0;J<$.length;J++){let W=$[J],Y=f[J],G=j$(W,Y);if(!G.valid)return{valid:!1};X.push(G.data)}return{valid:!0,data:X}}else if(H===j.date&&Q===j.date&&+$===+f)return{valid:!0,data:$};else return{valid:!1}}class n0 extends M{_parse($){let{status:f,ctx:H}=this._processInputParams($),Q=(X,J)=>{if(b1(X)||b1(J))return U;let W=j$(X.value,J.value);if(!W.valid)return N(H,{code:w.invalid_intersection_types}),U;if(F1(X)||F1(J))f.dirty();return{status:f.value,value:W.data}};if(H.common.async)return Promise.all([this._def.left._parseAsync({data:H.data,path:H.path,parent:H}),this._def.right._parseAsync({data:H.data,path:H.path,parent:H})]).then(([X,J])=>Q(X,J));else return Q(this._def.left._parseSync({data:H.data,path:H.path,parent:H}),this._def.right._parseSync({data:H.data,path:H.path,parent:H}))}}n0.create=($,f,H)=>{return new n0({left:$,right:f,typeName:C.ZodIntersection,...v(H)})};class z0 extends M{_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.parsedType!==j.array)return N(H,{code:w.invalid_type,expected:j.array,received:H.parsedType}),U;if(H.data.length<this._def.items.length)return N(H,{code:w.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),U;if(!this._def.rest&&H.data.length>this._def.items.length)N(H,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f.dirty();let X=[...H.data].map((J,W)=>{let Y=this._def.items[W]||this._def.rest;if(!Y)return null;return Y._parse(new W0(H,J,H.path,W))}).filter((J)=>!!J);if(H.common.async)return Promise.all(X).then((J)=>{return p.mergeArray(f,J)});else return p.mergeArray(f,X)}get items(){return this._def.items}rest($){return new z0({...this._def,rest:$})}}z0.create=($,f)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new z0({items:$,typeName:C.ZodTuple,rest:null,...v(f)})};class G1 extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.parsedType!==j.object)return N(H,{code:w.invalid_type,expected:j.object,received:H.parsedType}),U;let Q=[],X=this._def.keyType,J=this._def.valueType;for(let W in H.data)Q.push({key:X._parse(new W0(H,W,H.path,W)),value:J._parse(new W0(H,H.data[W],H.path,W)),alwaysSet:W in H.data});if(H.common.async)return p.mergeObjectAsync(f,Q);else return p.mergeObjectSync(f,Q)}get element(){return this._def.valueType}static create($,f,H){if(f instanceof M)return new G1({keyType:$,valueType:f,typeName:C.ZodRecord,...v(H)});return new G1({keyType:Q0.create(),valueType:$,typeName:C.ZodRecord,...v(f)})}}class q1 extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.parsedType!==j.map)return N(H,{code:w.invalid_type,expected:j.map,received:H.parsedType}),U;let Q=this._def.keyType,X=this._def.valueType,J=[...H.data.entries()].map(([W,Y],G)=>{return{key:Q._parse(new W0(H,W,H.path,[G,"key"])),value:X._parse(new W0(H,Y,H.path,[G,"value"]))}});if(H.common.async){let W=new Map;return Promise.resolve().then(async()=>{for(let Y of J){let G=await Y.key,_=await Y.value;if(G.status==="aborted"||_.status==="aborted")return U;if(G.status==="dirty"||_.status==="dirty")f.dirty();W.set(G.value,_.value)}return{status:f.value,value:W}})}else{let W=new Map;for(let Y of J){let{key:G,value:_}=Y;if(G.status==="aborted"||_.status==="aborted")return U;if(G.status==="dirty"||_.status==="dirty")f.dirty();W.set(G.value,_.value)}return{status:f.value,value:W}}}}q1.create=($,f,H)=>{return new q1({valueType:f,keyType:$,typeName:C.ZodMap,...v(H)})};class O0 extends M{_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.parsedType!==j.set)return N(H,{code:w.invalid_type,expected:j.set,received:H.parsedType}),U;let Q=this._def;if(Q.minSize!==null){if(H.data.size<Q.minSize.value)N(H,{code:w.too_small,minimum:Q.minSize.value,type:"set",inclusive:!0,exact:!1,message:Q.minSize.message}),f.dirty()}if(Q.maxSize!==null){if(H.data.size>Q.maxSize.value)N(H,{code:w.too_big,maximum:Q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Q.maxSize.message}),f.dirty()}let X=this._def.valueType;function J(Y){let G=new Set;for(let _ of Y){if(_.status==="aborted")return U;if(_.status==="dirty")f.dirty();G.add(_.value)}return{status:f.value,value:G}}let W=[...H.data.values()].map((Y,G)=>X._parse(new W0(H,Y,H.path,G)));if(H.common.async)return Promise.all(W).then((Y)=>J(Y));else return J(W)}min($,f){return new O0({...this._def,minSize:{value:$,message:D.toString(f)}})}max($,f){return new O0({...this._def,maxSize:{value:$,message:D.toString(f)}})}size($,f){return this.min($,f).max($,f)}nonempty($){return this.min(1,$)}}O0.create=($,f)=>{return new O0({valueType:$,minSize:null,maxSize:null,typeName:C.ZodSet,...v(f)})};class x0 extends M{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:f}=this._processInputParams($);if(f.parsedType!==j.function)return N(f,{code:w.invalid_type,expected:j.function,received:f.parsedType}),U;function H(W,Y){return J1({data:W,path:f.path,errorMaps:[f.common.contextualErrorMap,f.schemaErrorMap,P0(),w0].filter((G)=>!!G),issueData:{code:w.invalid_arguments,argumentsError:Y}})}function Q(W,Y){return J1({data:W,path:f.path,errorMaps:[f.common.contextualErrorMap,f.schemaErrorMap,P0(),w0].filter((G)=>!!G),issueData:{code:w.invalid_return_type,returnTypeError:Y}})}let X={errorMap:f.common.contextualErrorMap},J=f.data;if(this._def.returns instanceof v0){let W=this;return r(async function(...Y){let G=new d([]),_=await W._def.args.parseAsync(Y,X).catch((k)=>{throw G.addIssue(H(Y,k)),G}),S=await Reflect.apply(J,this,_);return await W._def.returns._def.type.parseAsync(S,X).catch((k)=>{throw G.addIssue(Q(S,k)),G})})}else{let W=this;return r(function(...Y){let G=W._def.args.safeParse(Y,X);if(!G.success)throw new d([H(Y,G.error)]);let _=Reflect.apply(J,this,G.data),S=W._def.returns.safeParse(_,X);if(!S.success)throw new d([Q(_,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new x0({...this._def,args:z0.create($).rest(V0.create())})}returns($){return new x0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,f,H){return new x0({args:$?$:z0.create([]).rest(V0.create()),returns:f||V0.create(),typeName:C.ZodFunction,...v(H)})}}class c0 extends M{get schema(){return this._def.getter()}_parse($){let{ctx:f}=this._processInputParams($);return this._def.getter()._parse({data:f.data,path:f.path,parent:f})}}c0.create=($,f)=>{return new c0({getter:$,typeName:C.ZodLazy,...v(f)})};class u0 extends M{_parse($){if($.data!==this._def.value){let f=this._getOrReturnCtx($);return N(f,{received:f.data,code:w.invalid_literal,expected:this._def.value}),U}return{status:"valid",value:$.data}}get value(){return this._def.value}}u0.create=($,f)=>{return new u0({value:$,typeName:C.ZodLiteral,...v(f)})};function v2($,f){return new D0({values:$,typeName:C.ZodEnum,...v(f)})}class D0 extends M{_parse($){if(typeof $.data!=="string"){let f=this._getOrReturnCtx($),H=this._def.values;return N(f,{expected:P.joinValues(H),received:f.parsedType,code:w.invalid_type}),U}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let f=this._getOrReturnCtx($),H=this._def.values;return N(f,{received:f.data,code:w.invalid_enum_value,options:H}),U}return r($.data)}get options(){return this._def.values}get enum(){let $={};for(let f of this._def.values)$[f]=f;return $}get Values(){let $={};for(let f of this._def.values)$[f]=f;return $}get Enum(){let $={};for(let f of this._def.values)$[f]=f;return $}extract($,f=this._def){return D0.create($,{...this._def,...f})}exclude($,f=this._def){return D0.create(this.options.filter((H)=>!$.includes(H)),{...this._def,...f})}}D0.create=v2;class y0 extends M{_parse($){let f=P.getValidEnumValues(this._def.values),H=this._getOrReturnCtx($);if(H.parsedType!==j.string&&H.parsedType!==j.number){let Q=P.objectValues(f);return N(H,{expected:P.joinValues(Q),received:H.parsedType,code:w.invalid_type}),U}if(!this._cache)this._cache=new Set(P.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let Q=P.objectValues(f);return N(H,{received:H.data,code:w.invalid_enum_value,options:Q}),U}return r($.data)}get enum(){return this._def.values}}y0.create=($,f)=>{return new y0({values:$,typeName:C.ZodNativeEnum,...v(f)})};class v0 extends M{unwrap(){return this._def.type}_parse($){let{ctx:f}=this._processInputParams($);if(f.parsedType!==j.promise&&f.common.async===!1)return N(f,{code:w.invalid_type,expected:j.promise,received:f.parsedType}),U;let H=f.parsedType===j.promise?f.data:Promise.resolve(f.data);return r(H.then((Q)=>{return this._def.type.parseAsync(Q,{path:f.path,errorMap:f.common.contextualErrorMap})}))}}v0.create=($,f)=>{return new v0({type:$,typeName:C.ZodPromise,...v(f)})};class Y0 extends M{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===C.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:f,ctx:H}=this._processInputParams($),Q=this._def.effect||null,X={addIssue:(J)=>{if(N(H,J),J.fatal)f.abort();else f.dirty()},get path(){return H.path}};if(X.addIssue=X.addIssue.bind(X),Q.type==="preprocess"){let J=Q.transform(H.data,X);if(H.common.async)return Promise.resolve(J).then(async(W)=>{if(f.value==="aborted")return U;let Y=await this._def.schema._parseAsync({data:W,path:H.path,parent:H});if(Y.status==="aborted")return U;if(Y.status==="dirty")return A0(Y.value);if(f.value==="dirty")return A0(Y.value);return Y});else{if(f.value==="aborted")return U;let W=this._def.schema._parseSync({data:J,path:H.path,parent:H});if(W.status==="aborted")return U;if(W.status==="dirty")return A0(W.value);if(f.value==="dirty")return A0(W.value);return W}}if(Q.type==="refinement"){let J=(W)=>{let Y=Q.refinement(W,X);if(H.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return W};if(H.common.async===!1){let W=this._def.schema._parseSync({data:H.data,path:H.path,parent:H});if(W.status==="aborted")return U;if(W.status==="dirty")f.dirty();return J(W.value),{status:f.value,value:W.value}}else return this._def.schema._parseAsync({data:H.data,path:H.path,parent:H}).then((W)=>{if(W.status==="aborted")return U;if(W.status==="dirty")f.dirty();return J(W.value).then(()=>{return{status:f.value,value:W.value}})})}if(Q.type==="transform")if(H.common.async===!1){let J=this._def.schema._parseSync({data:H.data,path:H.path,parent:H});if(!N0(J))return U;let W=Q.transform(J.value,X);if(W instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:f.value,value:W}}else return this._def.schema._parseAsync({data:H.data,path:H.path,parent:H}).then((J)=>{if(!N0(J))return U;return Promise.resolve(Q.transform(J.value,X)).then((W)=>({status:f.value,value:W}))});P.assertNever(Q)}}Y0.create=($,f,H)=>{return new Y0({schema:$,typeName:C.ZodEffects,effect:f,...v(H)})};Y0.createWithPreprocess=($,f,H)=>{return new Y0({schema:f,effect:{type:"preprocess",transform:$},typeName:C.ZodEffects,...v(H)})};class J0 extends M{_parse($){if(this._getType($)===j.undefined)return r(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}J0.create=($,f)=>{return new J0({innerType:$,typeName:C.ZodOptional,...v(f)})};class L0 extends M{_parse($){if(this._getType($)===j.null)return r(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}L0.create=($,f)=>{return new L0({innerType:$,typeName:C.ZodNullable,...v(f)})};class i0 extends M{_parse($){let{ctx:f}=this._processInputParams($),H=f.data;if(f.parsedType===j.undefined)H=this._def.defaultValue();return this._def.innerType._parse({data:H,path:f.path,parent:f})}removeDefault(){return this._def.innerType}}i0.create=($,f)=>{return new i0({innerType:$,typeName:C.ZodDefault,defaultValue:typeof f.default==="function"?f.default:()=>f.default,...v(f)})};class s0 extends M{_parse($){let{ctx:f}=this._processInputParams($),H={...f,common:{...f.common,issues:[]}},Q=this._def.innerType._parse({data:H.data,path:H.path,parent:{...H}});if(K0(Q))return Q.then((X)=>{return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new d(H.common.issues)},input:H.data})}});else return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new d(H.common.issues)},input:H.data})}}removeCatch(){return this._def.innerType}}s0.create=($,f)=>{return new s0({innerType:$,typeName:C.ZodCatch,catchValue:typeof f.catch==="function"?f.catch:()=>f.catch,...v(f)})};class _1 extends M{_parse($){if(this._getType($)!==j.nan){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.nan,received:H.parsedType}),U}return{status:"valid",value:$.data}}}_1.create=($)=>{return new _1({typeName:C.ZodNaN,...v($)})};var Y4=Symbol("zod_brand");class U1 extends M{_parse($){let{ctx:f}=this._processInputParams($),H=f.data;return this._def.type._parse({data:H,path:f.path,parent:f})}unwrap(){return this._def.type}}class B1 extends M{_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.common.async)return(async()=>{let X=await this._def.in._parseAsync({data:H.data,path:H.path,parent:H});if(X.status==="aborted")return U;if(X.status==="dirty")return f.dirty(),A0(X.value);else return this._def.out._parseAsync({data:X.value,path:H.path,parent:H})})();else{let Q=this._def.in._parseSync({data:H.data,path:H.path,parent:H});if(Q.status==="aborted")return U;if(Q.status==="dirty")return f.dirty(),{status:"dirty",value:Q.value};else return this._def.out._parseSync({data:Q.value,path:H.path,parent:H})}}static create($,f){return new B1({in:$,out:f,typeName:C.ZodPipeline})}}class o0 extends M{_parse($){let f=this._def.innerType._parse($),H=(Q)=>{if(N0(Q))Q.value=Object.freeze(Q.value);return Q};return K0(f)?f.then((Q)=>H(Q)):H(f)}unwrap(){return this._def.innerType}}o0.create=($,f)=>{return new o0({innerType:$,typeName:C.ZodReadonly,...v(f)})};function A2($,f){let H=typeof $==="function"?$(f):typeof $==="string"?{message:$}:$;return typeof H==="string"?{message:H}:H}function h2($,f={},H){if($)return C0.create().superRefine((Q,X)=>{let J=$(Q);if(J instanceof Promise)return J.then((W)=>{if(!W){let Y=A2(f,Q),G=Y.fatal??H??!0;X.addIssue({code:"custom",...Y,fatal:G})}});if(!J){let W=A2(f,Q),Y=W.fatal??H??!0;X.addIssue({code:"custom",...W,fatal:Y})}return});return C0.create()}var G4={object:g.lazycreate},C;(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"})(C||(C={}));var q4=($,f={message:`Input not instance of ${$.name}`})=>h2((H)=>H instanceof $,f),M2=Q0.create,k2=R0.create,_4=_1.create,B4=E0.create,I2=g0.create,z4=U0.create,w4=W1.create,j4=l0.create,L4=Z0.create,S4=C0.create,N4=V0.create,V4=B0.create,R4=Y1.create,E4=X0.create,D4=g.create,b4=g.strictCreate,F4=m0.create,A4=A1.create,U4=n0.create,C4=z0.create,O4=G1.create,v4=q1.create,h4=O0.create,M4=x0.create,k4=c0.create,I4=u0.create,P4=D0.create,K4=y0.create,T4=v0.create,x4=Y0.create,g4=J0.create,l4=L0.create,Z4=Y0.createWithPreprocess,m4=B1.create,n4=()=>M2().optional(),c4=()=>k2().optional(),u4=()=>I2().optional(),y4={string:($)=>Q0.create({...$,coerce:!0}),number:($)=>R0.create({...$,coerce:!0}),boolean:($)=>g0.create({...$,coerce:!0}),bigint:($)=>E0.create({...$,coerce:!0}),date:($)=>U0.create({...$,coerce:!0})};var i4=U;D1();class d0 extends a{zodError;constructor($){super(422,"Validation failed");this.zodError=$;this.name="ValidationException"}toJSON(){return{error:"Validation Error",statusCode:this.statusCode,details:this.zodError.errors.map(($)=>({path:$.path.join("."),message:$.message,code:$.code}))}}}class L${schemaCache=new WeakMap;stats={hits:0,misses:0,validations:0};async validate($,f){this.stats.validations++;try{let H=this.schemaCache.get(f);if(!H)this.stats.misses++,H={schema:f,resultCache:new WeakMap},this.schemaCache.set(f,H);else this.stats.hits++;return await H.schema.parseAsync($)}catch(H){if(H instanceof d)throw new d0(H);throw H}}validateSync($,f){this.stats.validations++;try{let H=this.schemaCache.get(f);if(!H)this.stats.misses++,H={schema:f,resultCache:new WeakMap},this.schemaCache.set(f,H);else this.stats.hits++;return H.schema.parse($)}catch(H){if(H instanceof d)throw new d0(H);throw H}}getCacheStats(){let $=this.stats.validations>0?this.stats.hits/this.stats.validations*100:0;return{...this.stats,hitRate:Math.round($*100)/100}}resetStats(){this.stats={hits:0,misses:0,validations:0}}clearCache(){this.schemaCache=new WeakMap,this.resetStats()}}D1();class S${customHandler;isDevelopment;constructor($){this.customHandler=$,this.isDevelopment=!0}setCustomHandler($){this.customHandler=$}async handle($,f){if(console.log("ErrorHandler.handle called with:",$.constructor.name,$.message),this.customHandler)try{return await this.customHandler($,f)}catch(H){console.error("Custom error handler failed:",H)}if($ instanceof d0)return console.log("Handling as ValidationException"),this.handleValidationException($,f);if($ instanceof a)return console.log("Handling as HTTPException"),this.handleHTTPException($,f);return console.log("Handling as generic error"),this.handleGenericError($,f)}handleValidationException($,f){let H=$.toJSON();if(this.isDevelopment)console.error("Validation Error:",{path:f.req.path,method:f.req.method,details:H.details});return f.json(H,$.statusCode)}handleHTTPException($,f){let H=$.toJSON();if($.statusCode>=500)console.error("HTTP Exception:",{name:$.name,statusCode:$.statusCode,message:$.message,path:f.req.path,method:f.req.method,...this.isDevelopment&&$.stack?{stack:$.stack}:{}});else if(this.isDevelopment)console.warn("HTTP Exception:",{name:$.name,statusCode:$.statusCode,message:$.message,path:f.req.path,method:f.req.method});return f.json(H,$.statusCode)}handleGenericError($,f){console.error("Internal Server Error:",{name:$.name,message:$.message,path:f.req.path,method:f.req.method,stack:$.stack});let H={error:"Internal Server Error",statusCode:500};if(this.isDevelopment){if(H.message=$.message,H.name=$.name,$.stack)H.stack=$.stack.split(`
15
- `).map((Q)=>Q.trim())}else H.message="An unexpected error occurred";return f.json(H,500)}isDevelopmentMode(){return this.isDevelopment}setDevelopmentMode($){this.isDevelopment=$}}class N${plugins=new Map;installed=new Set;register($){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);this.plugins.set($.name,$)}async install($){let f=this.resolveInstallOrder();for(let H of f)await this.plugins.get(H).install($),this.installed.add(H)}isInstalled($){return this.installed.has($)}getPlugin($){return this.plugins.get($)}getPluginNames(){return Array.from(this.plugins.keys())}resolveInstallOrder(){let $=new Set,f=new Set,H=[],Q=(X,J=[])=>{if(f.has(X)){let Y=[...J,X].join(" -> ");throw Error(`Circular dependency detected in plugins: ${Y}`)}if($.has(X))return;f.add(X);let W=this.plugins.get(X);if(!W)throw Error(`Plugin "${X}" is not registered`);if(W.dependencies)for(let Y of W.dependencies){if(!this.plugins.has(Y))throw Error(`Plugin "${X}" depends on "${Y}" which is not registered`);Q(Y,[...J,X])}f.delete(X),$.add(X),H.push(X)};for(let X of this.plugins.keys())Q(X);return H}}function K2($){let{origin:f="*",methods:H=["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:Q=["Content-Type","Authorization"],exposedHeaders:X=[],credentials:J=!1,maxAge:W=86400}=$||{};return async(Y,G)=>{let _=Y.req.header("origin"),S=Y.req.method,A=null;if(typeof f==="string")A=f;else if(Array.isArray(f)){if(_&&f.includes(_))A=_}else if(typeof f==="function"){if(_&&f(_))A=_}if(A)Y.header("Access-Control-Allow-Origin",A);if(J)Y.header("Access-Control-Allow-Credentials","true");if(X.length>0)Y.header("Access-Control-Expose-Headers",X.join(", "));if(S==="OPTIONS")return Y.header("Access-Control-Allow-Methods",H.join(", ")),Y.header("Access-Control-Allow-Headers",Q.join(", ")),Y.header("Access-Control-Max-Age",W.toString()),Y.body(null,204);await G()}}function T2($){let{windowMs:f=60000,max:H=100,keyGenerator:Q=(W)=>{return W.req.header("x-forwarded-for")||W.req.header("x-real-ip")||"unknown"}}=$,X=new Map,J=setInterval(()=>{let W=Date.now();for(let[Y,G]of X.entries())if(W>G.resetTime)X.delete(Y)},f);if(typeof process<"u"&&process.on)process.on("exit",()=>clearInterval(J));return async(W,Y)=>{let G=Q(W),_=Date.now(),S=X.get(G);if(!S||_>S.resetTime)X.set(G,{count:1,resetTime:_+f}),W.header("X-RateLimit-Limit",H.toString()),W.header("X-RateLimit-Remaining",(H-1).toString()),W.header("X-RateLimit-Reset",new Date(_+f).toISOString()),await Y();else if(S.count<H)S.count++,W.header("X-RateLimit-Limit",H.toString()),W.header("X-RateLimit-Remaining",(H-S.count).toString()),W.header("X-RateLimit-Reset",new Date(S.resetTime).toISOString()),await Y();else{let A=Math.ceil((S.resetTime-_)/1000);return W.header("X-RateLimit-Limit",H.toString()),W.header("X-RateLimit-Remaining","0"),W.header("X-RateLimit-Reset",new Date(S.resetTime).toISOString()),W.header("Retry-After",A.toString()),W.json({error:"Too Many Requests",message:`Rate limit exceeded. Please try again in ${A} seconds.`,retryAfter:A},429)}}}function x2($){let{threshold:f=1024,level:H=6}=$||{};return async(Q,X)=>{await X();let J=Q.res;if(!J)return;let W=J.headers.get("content-type")||"",Y=J.headers.get("content-length"),G=Q.req.header("accept-encoding")||"";if(!["text/","application/json","application/javascript","application/xml","application/x-www-form-urlencoded"].some((h)=>W.toLowerCase().includes(h)))return;if(Y&&parseInt(Y)<f)return;if(J.headers.get("content-encoding"))return;let A=await J.arrayBuffer();if(A.byteLength<f)return;let k=null,Z=null;if(G.includes("br")&&typeof CompressionStream<"u")try{let h=new CompressionStream("deflate"),T=h.writable.getWriter();T.write(new Uint8Array(A)),T.close();let m=h.readable.getReader(),o=[];while(!0){let{done:s,value:t}=await m.read();if(s)break;o.push(t)}let e=o.reduce((s,t)=>s+t.length,0),i=new Uint8Array(e),$0=0;for(let s of o)i.set(s,$0),$0+=s.length;k=i,Z="deflate"}catch(h){k=null}if(!k&&G.includes("gzip")&&typeof CompressionStream<"u")try{let h=new CompressionStream("gzip"),T=h.writable.getWriter();T.write(new Uint8Array(A)),T.close();let m=h.readable.getReader(),o=[];while(!0){let{done:s,value:t}=await m.read();if(s)break;o.push(t)}let e=o.reduce((s,t)=>s+t.length,0),i=new Uint8Array(e),$0=0;for(let s of o)i.set(s,$0),$0+=s.length;k=i,Z="gzip"}catch(h){k=null}if(k&&Z&&k.byteLength<A.byteLength){let h=new Headers(J.headers);return h.set("content-encoding",Z),h.set("content-length",k.byteLength.toString()),h.delete("content-length"),new Response(k,{status:J.status,statusText:J.statusText,headers:h})}}}class E${hono;metadata;container;validator;errorHandler;compiler;pluginManager;config;compiled=!1;globalMiddleware=[];groupPrefix="";constructor($){if(this.config={adapter:"hono",title:"Veloce-TS API",version:"1.0.0",docs:!0,...$},this.hono=new u1,this.metadata=new S0,this.container=new H$,this.validator=new L$,this.errorHandler=new S$,this.pluginManager=new N$,this.compiler=new B$(this.hono,this.metadata,this.container,this.validator,this.errorHandler),this.config.cors)if(this.config.cors===!0)this.useCors();else this.useCors(this.config.cors)}include($){let f=S0.getControllerMetadata($);if(f)this.metadata.registerController($,f);let H=S0.getRouteMethods($);for(let Q of H){let X=S0.getRouteMetadata($.prototype,Q),J=S0.getParameterMetadata($.prototype,Q),W=S0.getDependencyMetadata($.prototype,Q);if(X&&X.method&&X.path!==void 0){let Y=f?.prefix||"",G=this.normalizePath(Y,X.path);this.metadata.registerRoute({target:$,propertyKey:Q,method:X.method,path:G,middleware:[...f?.middleware||[],...X.middleware||[]],parameters:J||X.parameters||[],dependencies:W||X.dependencies||[],responses:X.responses||[],docs:X.docs})}}}get($,f){this.registerFunctionalRoute("GET",$,f)}post($,f){this.registerFunctionalRoute("POST",$,f)}put($,f){this.registerFunctionalRoute("PUT",$,f)}delete($,f){this.registerFunctionalRoute("DELETE",$,f)}patch($,f){this.registerFunctionalRoute("PATCH",$,f)}route($){return new n2(this,$)}group($,f){let H=this.groupPrefix;this.groupPrefix=this.normalizePath(this.groupPrefix,$),f(),this.groupPrefix=H}registerFunctionalRoute($,f,H){let Q=this.normalizePath(this.groupPrefix,f),X={target:m2,propertyKey:`${$.toLowerCase()}_${Q}`,method:$,path:Q,middleware:H.middleware||[],parameters:this.extractParametersFromSchema(H.schema),dependencies:[],responses:H.responses||[],docs:H.docs,handler:H.handler};this.metadata.registerRoute(X)}extractParametersFromSchema($){let f=[],H=0;if($?.body)f.push({index:H++,type:"body",schema:$.body,required:!0});if($?.query)f.push({index:H++,type:"query",schema:$.query,required:!1});if($?.params)f.push({index:H++,type:"param",schema:$.params,required:!0});if($?.headers)f.push({index:H++,type:"header",schema:$.headers,required:!1});return f}use($){this.globalMiddleware.push($),this.hono.use("*",$)}useCors($){let f=K2($);this.use(f)}useRateLimit($){let f=T2($);this.use(f)}useCompression($){let f=x2($);this.use(f)}usePlugin($){this.pluginManager.register($)}getPluginManager(){return this.pluginManager}onError($){this.errorHandler.setCustomHandler($)}getErrorHandler(){return this.errorHandler}normalizePath(...$){let f=$.filter((H)=>H!=="").join("/").replace(/\/+/g,"/").replace(/\/$/,"");return f.startsWith("/")?f:`/${f}`}getHono(){return this.hono}getMetadata(){return this.metadata}getContainer(){return this.container}getCompiler(){return this.compiler}getConfig(){return this.config}isCompiled(){return this.compiled}markCompiled(){this.compiled=!0}async compile(){if(this.compiled){console.warn("Routes have already been compiled. Skipping compilation.");return}await this.pluginManager.install(this),this.compiler.compile(),this.compiled=!0}async listen($,f){if(!this.compiled)await this.compile();return this.createAdapter().listen($,f)}createAdapter(){let $=this.config.adapter||"hono";switch($){case"hono":{let{HonoAdapter:f}=z1(R$);return new f(this.hono)}case"express":{let{ExpressAdapter:f}=z1(Z2);return new f(this)}case"native":{let{HonoAdapter:f}=z1(R$);return new f(this.hono)}default:throw Error(`Unknown adapter type: ${$}. Supported adapters: 'hono', 'express', 'native'`)}}}class m2{}class n2{app;path;constructor($,f){this.app=$;this.path=f}get($){return this.app.get(this.path,$),this}post($){return this.app.post(this.path,$),this}put($){return this.app.put(this.path,$),this}delete($){return this.app.delete(this.path,$),this}patch($){return this.app.patch(this.path,$),this}}function D$($){let f={docs:!1,cors:!1,...$};return new E$(f)}function c2($,f,H,Q){let X=$.getContainer(),J=typeof H==="function"?H:()=>H;X.register(f,{scope:Q?.scope||"singleton",factory:J})}function b$($){return new a0($)}async function u2($,f){let H=D$(f);await $(H),await H.compile();let Q=b$(H);return{app:H,client:Q}}function y2($){$.getContainer().clear()}
14
+ ***************************************************************************** */var _2;(function($){(function(f){var H=typeof globalThis==="object"?globalThis:typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:Y(),Q=X($);if(typeof H.Reflect<"u")Q=X(H.Reflect,Q);if(f(Q,H),typeof H.Reflect>"u")H.Reflect=$;function X(G,_){return function(S,A){if(Object.defineProperty(G,S,{configurable:!0,writable:!0,value:A}),_)_(S,A)}}function J(){try{return Function("return this;")()}catch(G){}}function W(){try{return(0,eval)("(function() { return this; })()")}catch(G){}}function Y(){return J()||W()}})(function(f,H){var Q=Object.prototype.hasOwnProperty,X=typeof Symbol==="function",J=X&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",W=X&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",Y=typeof Object.create==="function",G={__proto__:[]}instanceof Array,_=!Y&&!G,S={create:Y?function(){return k1(Object.create(null))}:G?function(){return k1({__proto__:null})}:function(){return k1({})},has:_?function(q,B){return Q.call(q,B)}:function(q,B){return B in q},get:_?function(q,B){return Q.call(q,B)?q[B]:void 0}:function(q,B){return q[B]}},A=Object.getPrototypeOf(Function),k=typeof Map==="function"&&typeof Map.prototype.entries==="function"?Map:Qf(),Z=typeof Set==="function"&&typeof Set.prototype.entries==="function"?Set:Xf(),h=typeof WeakMap==="function"?WeakMap:Jf(),T=X?Symbol.for("@reflect-metadata:registry"):void 0,m=$f(),o=ff(m);function e(q,B,z,L){if(!O(z)){if(!P$(q))throw TypeError();if(!n(B))throw TypeError();if(!n(L)&&!O(L)&&!h0(L))throw TypeError();if(h0(L))L=void 0;return z=q0(z),o2(q,B,z,L)}else{if(!P$(q))throw TypeError();if(!K$(B))throw TypeError();return s2(q,B)}}f("decorate",e);function i(q,B){function z(L,F){if(!n(L))throw TypeError();if(!O(F)&&!a2(F))throw TypeError();v$(q,B,L,F)}return z}f("metadata",i);function $0(q,B,z,L){if(!n(z))throw TypeError();if(!O(L))L=q0(L);return v$(q,B,z,L)}f("defineMetadata",$0);function s(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);return U$(q,B,z)}f("hasMetadata",s);function t(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);return v1(q,B,z)}f("hasOwnMetadata",t);function f0(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);return C$(q,B,z)}f("getMetadata",f0);function C1(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);return O$(q,B,z)}f("getOwnMetadata",C1);function G0(q,B){if(!n(q))throw TypeError();if(!O(B))B=q0(B);return h$(q,B)}f("getMetadataKeys",G0);function O1(q,B){if(!n(q))throw TypeError();if(!O(B))B=q0(B);return M$(q,B)}f("getOwnMetadataKeys",O1);function A$(q,B,z){if(!n(B))throw TypeError();if(!O(z))z=q0(z);if(!n(B))throw TypeError();if(!O(z))z=q0(z);var L=p0(B,z,!1);if(O(L))return!1;return L.OrdinaryDeleteMetadata(q,B,z)}f("deleteMetadata",A$);function s2(q,B){for(var z=q.length-1;z>=0;--z){var L=q[z],F=L(B);if(!O(F)&&!h0(F)){if(!K$(F))throw TypeError();B=F}}return B}function o2(q,B,z,L){for(var F=q.length-1;F>=0;--F){var c=q[F],y=c(B,z,L);if(!O(y)&&!h0(y)){if(!n(y))throw TypeError();L=y}}return L}function U$(q,B,z){var L=v1(q,B,z);if(L)return!0;var F=M1(B);if(!h0(F))return U$(q,F,z);return!1}function v1(q,B,z){var L=p0(B,z,!1);if(O(L))return!1;return I$(L.OrdinaryHasOwnMetadata(q,B,z))}function C$(q,B,z){var L=v1(q,B,z);if(L)return O$(q,B,z);var F=M1(B);if(!h0(F))return C$(q,F,z);return}function O$(q,B,z){var L=p0(B,z,!1);if(O(L))return;return L.OrdinaryGetOwnMetadata(q,B,z)}function v$(q,B,z,L){var F=p0(z,L,!0);F.OrdinaryDefineOwnMetadata(q,B,z,L)}function h$(q,B){var z=M$(q,B),L=M1(q);if(L===null)return z;var F=h$(L,B);if(F.length<=0)return z;if(z.length<=0)return F;var c=new Z,y=[];for(var I=0,V=z;I<V.length;I++){var R=V[I],E=c.has(R);if(!E)c.add(R),y.push(R)}for(var b=0,K=F;b<K.length;b++){var R=K[b],E=c.has(R);if(!E)c.add(R),y.push(R)}return y}function M$(q,B){var z=p0(q,B,!1);if(!z)return[];return z.OrdinaryOwnMetadataKeys(q,B)}function k$(q){if(q===null)return 1;switch(typeof q){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return q===null?1:6;default:return 6}}function O(q){return q===void 0}function h0(q){return q===null}function d2(q){return typeof q==="symbol"}function n(q){return typeof q==="object"?q!==null:typeof q==="function"}function p2(q,B){switch(k$(q)){case 0:return q;case 1:return q;case 2:return q;case 3:return q;case 4:return q;case 5:return q}var z=B===3?"string":B===5?"number":"default",L=T$(q,J);if(L!==void 0){var F=L.call(q,z);if(n(F))throw TypeError();return F}return r2(q,z==="default"?"number":z)}function r2(q,B){if(B==="string"){var z=q.toString;if(M0(z)){var L=z.call(q);if(!n(L))return L}var F=q.valueOf;if(M0(F)){var L=F.call(q);if(!n(L))return L}}else{var F=q.valueOf;if(M0(F)){var L=F.call(q);if(!n(L))return L}var c=q.toString;if(M0(c)){var L=c.call(q);if(!n(L))return L}}throw TypeError()}function I$(q){return!!q}function t2(q){return""+q}function q0(q){var B=p2(q,3);if(d2(B))return B;return t2(B)}function P$(q){return Array.isArray?Array.isArray(q):q instanceof Object?q instanceof Array:Object.prototype.toString.call(q)==="[object Array]"}function M0(q){return typeof q==="function"}function K$(q){return typeof q==="function"}function a2(q){switch(k$(q)){case 3:return!0;case 4:return!0;default:return!1}}function h1(q,B){return q===B||q!==q&&B!==B}function T$(q,B){var z=q[B];if(z===void 0||z===null)return;if(!M0(z))throw TypeError();return z}function x$(q){var B=T$(q,W);if(!M0(B))throw TypeError();var z=B.call(q);if(!n(z))throw TypeError();return z}function g$(q){return q.value}function l$(q){var B=q.next();return B.done?!1:B}function Z$(q){var B=q.return;if(B)B.call(q)}function M1(q){var B=Object.getPrototypeOf(q);if(typeof q!=="function"||q===A)return B;if(B!==A)return B;var z=q.prototype,L=z&&Object.getPrototypeOf(z);if(L==null||L===Object.prototype)return B;var F=L.constructor;if(typeof F!=="function")return B;if(F===q)return B;return F}function e2(){var q;if(!O(T)&&typeof H.Reflect<"u"&&!(T in H.Reflect)&&typeof H.Reflect.defineMetadata==="function")q=Hf(H.Reflect);var B,z,L,F=new h,c={registerProvider:y,getProvider:V,setProvider:E};return c;function y(b){if(!Object.isExtensible(c))throw Error("Cannot add provider to a frozen registry.");switch(!0){case q===b:break;case O(B):B=b;break;case B===b:break;case O(z):z=b;break;case z===b:break;default:if(L===void 0)L=new Z;L.add(b);break}}function I(b,K){if(!O(B)){if(B.isProviderFor(b,K))return B;if(!O(z)){if(z.isProviderFor(b,K))return B;if(!O(L)){var x=x$(L);while(!0){var u=l$(x);if(!u)return;var H0=g$(u);if(H0.isProviderFor(b,K))return Z$(x),H0}}}}if(!O(q)&&q.isProviderFor(b,K))return q;return}function V(b,K){var x=F.get(b),u;if(!O(x))u=x.get(K);if(!O(u))return u;if(u=I(b,K),!O(u)){if(O(x))x=new k,F.set(b,x);x.set(K,u)}return u}function R(b){if(O(b))throw TypeError();return B===b||z===b||!O(L)&&L.has(b)}function E(b,K,x){if(!R(x))throw Error("Metadata provider not registered.");var u=V(b,K);if(u!==x){if(!O(u))return!1;var H0=F.get(b);if(O(H0))H0=new k,F.set(b,H0);H0.set(K,x)}return!0}}function $f(){var q;if(!O(T)&&n(H.Reflect)&&Object.isExtensible(H.Reflect))q=H.Reflect[T];if(O(q))q=e2();if(!O(T)&&n(H.Reflect)&&Object.isExtensible(H.Reflect))Object.defineProperty(H.Reflect,T,{enumerable:!1,configurable:!1,writable:!1,value:q});return q}function ff(q){var B=new h,z={isProviderFor:function(R,E){var b=B.get(R);if(O(b))return!1;return b.has(E)},OrdinaryDefineOwnMetadata:y,OrdinaryHasOwnMetadata:F,OrdinaryGetOwnMetadata:c,OrdinaryOwnMetadataKeys:I,OrdinaryDeleteMetadata:V};return m.registerProvider(z),z;function L(R,E,b){var K=B.get(R),x=!1;if(O(K)){if(!b)return;K=new k,B.set(R,K),x=!0}var u=K.get(E);if(O(u)){if(!b)return;if(u=new k,K.set(E,u),!q.setProvider(R,E,z)){if(K.delete(E),x)B.delete(R);throw Error("Wrong provider for target.")}}return u}function F(R,E,b){var K=L(E,b,!1);if(O(K))return!1;return I$(K.has(R))}function c(R,E,b){var K=L(E,b,!1);if(O(K))return;return K.get(R)}function y(R,E,b,K){var x=L(b,K,!0);x.set(R,E)}function I(R,E){var b=[],K=L(R,E,!1);if(O(K))return b;var x=K.keys(),u=x$(x),H0=0;while(!0){var m$=l$(u);if(!m$)return b.length=H0,b;var Wf=g$(m$);try{b[H0]=Wf}catch(Yf){try{Z$(u)}finally{throw Yf}}H0++}}function V(R,E,b){var K=L(E,b,!1);if(O(K))return!1;if(!K.delete(R))return!1;if(K.size===0){var x=B.get(E);if(!O(x)){if(x.delete(b),x.size===0)B.delete(x)}}return!0}}function Hf(q){var{defineMetadata:B,hasOwnMetadata:z,getOwnMetadata:L,getOwnMetadataKeys:F,deleteMetadata:c}=q,y=new h,I={isProviderFor:function(V,R){var E=y.get(V);if(!O(E)&&E.has(R))return!0;if(F(V,R).length){if(O(E))E=new Z,y.set(V,E);return E.add(R),!0}return!1},OrdinaryDefineOwnMetadata:B,OrdinaryHasOwnMetadata:z,OrdinaryGetOwnMetadata:L,OrdinaryOwnMetadataKeys:F,OrdinaryDeleteMetadata:c};return I}function p0(q,B,z){var L=m.getProvider(q,B);if(!O(L))return L;if(z){if(m.setProvider(q,B,o))return o;throw Error("Illegal state.")}return}function Qf(){var q={},B=[],z=function(){function I(V,R,E){this._index=0,this._keys=V,this._values=R,this._selector=E}return I.prototype["@@iterator"]=function(){return this},I.prototype[W]=function(){return this},I.prototype.next=function(){var V=this._index;if(V>=0&&V<this._keys.length){var R=this._selector(this._keys[V],this._values[V]);if(V+1>=this._keys.length)this._index=-1,this._keys=B,this._values=B;else this._index++;return{value:R,done:!1}}return{value:void 0,done:!0}},I.prototype.throw=function(V){if(this._index>=0)this._index=-1,this._keys=B,this._values=B;throw V},I.prototype.return=function(V){if(this._index>=0)this._index=-1,this._keys=B,this._values=B;return{value:V,done:!0}},I}(),L=function(){function I(){this._keys=[],this._values=[],this._cacheKey=q,this._cacheIndex=-2}return Object.defineProperty(I.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),I.prototype.has=function(V){return this._find(V,!1)>=0},I.prototype.get=function(V){var R=this._find(V,!1);return R>=0?this._values[R]:void 0},I.prototype.set=function(V,R){var E=this._find(V,!0);return this._values[E]=R,this},I.prototype.delete=function(V){var R=this._find(V,!1);if(R>=0){var E=this._keys.length;for(var b=R+1;b<E;b++)this._keys[b-1]=this._keys[b],this._values[b-1]=this._values[b];if(this._keys.length--,this._values.length--,h1(V,this._cacheKey))this._cacheKey=q,this._cacheIndex=-2;return!0}return!1},I.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=q,this._cacheIndex=-2},I.prototype.keys=function(){return new z(this._keys,this._values,F)},I.prototype.values=function(){return new z(this._keys,this._values,c)},I.prototype.entries=function(){return new z(this._keys,this._values,y)},I.prototype["@@iterator"]=function(){return this.entries()},I.prototype[W]=function(){return this.entries()},I.prototype._find=function(V,R){if(!h1(this._cacheKey,V)){this._cacheIndex=-1;for(var E=0;E<this._keys.length;E++)if(h1(this._keys[E],V)){this._cacheIndex=E;break}}if(this._cacheIndex<0&&R)this._cacheIndex=this._keys.length,this._keys.push(V),this._values.push(void 0);return this._cacheIndex},I}();return L;function F(I,V){return I}function c(I,V){return V}function y(I,V){return[I,V]}}function Xf(){var q=function(){function B(){this._map=new k}return Object.defineProperty(B.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),B.prototype.has=function(z){return this._map.has(z)},B.prototype.add=function(z){return this._map.set(z,z),this},B.prototype.delete=function(z){return this._map.delete(z)},B.prototype.clear=function(){this._map.clear()},B.prototype.keys=function(){return this._map.keys()},B.prototype.values=function(){return this._map.keys()},B.prototype.entries=function(){return this._map.entries()},B.prototype["@@iterator"]=function(){return this.keys()},B.prototype[W]=function(){return this.keys()},B}();return q}function Jf(){var q=16,B=S.create(),z=L();return function(){function V(){this._key=L()}return V.prototype.has=function(R){var E=F(R,!1);return E!==void 0?S.has(E,this._key):!1},V.prototype.get=function(R){var E=F(R,!1);return E!==void 0?S.get(E,this._key):void 0},V.prototype.set=function(R,E){var b=F(R,!0);return b[this._key]=E,this},V.prototype.delete=function(R){var E=F(R,!1);return E!==void 0?delete E[this._key]:!1},V.prototype.clear=function(){this._key=L()},V}();function L(){var V;do V="@@WeakMap@@"+I();while(S.has(B,V));return B[V]=!0,V}function F(V,R){if(!Q.call(V,z)){if(!R)return;Object.defineProperty(V,z,{value:S.create()})}return V[z]}function c(V,R){for(var E=0;E<R;++E)V[E]=Math.random()*255|0;return V}function y(V){if(typeof Uint8Array==="function"){var R=new Uint8Array(V);if(typeof crypto<"u")crypto.getRandomValues(R);else if(typeof msCrypto<"u")msCrypto.getRandomValues(R);else c(R,V);return R}return c(Array(V),V)}function I(){var V=y(q);V[6]=V[6]&79|64,V[8]=V[8]&191|128;var R="";for(var E=0;E<q;++E){var b=V[E];if(E===4||E===6||E===8)R+="-";if(b<16)R+="0";R+=b.toString(16).toLowerCase()}return R}}function k1(q){return q.__=void 0,delete q.__,q}})})(_2||(_2={}))});var a,If,Pf,Kf,B$;var X1=y$(()=>{a=class a extends Error{statusCode;details;constructor($,f,H){super(f);this.statusCode=$;this.details=H;if(this.name="HTTPException",Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}};If=class If extends a{constructor($="Not Found",f){super(404,$,f);this.name="NotFoundException"}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}};Pf=class Pf extends a{constructor($="Unauthorized",f){super(401,$,f);this.name="UnauthorizedException"}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}};Kf=class Kf extends a{constructor($="Forbidden",f){super(403,$,f);this.name="ForbiddenException"}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}};B$=class B$ extends a{constructor($="Bad Request",f){super(400,$,f);this.name="BadRequestException"}toJSON(){return{error:this.message,statusCode:this.statusCode,...this.details&&{details:this.details}}}}});var D2={};t0(D2,{TokenRevokedException:()=>E2,TokenExpiredException:()=>V2,InvalidTokenException:()=>R2,AuthorizationException:()=>N2,AuthenticationException:()=>J1});var J1,N2,V2,R2,E2;var b2=y$(()=>{X1();J1=class J1 extends a{constructor($="Authentication required"){super(401,$);this.name="AuthenticationException"}toJSON(){return{error:"Authentication Error",message:this.message,statusCode:401}}};N2=class N2 extends a{constructor($="Insufficient permissions"){super(403,$);this.name="AuthorizationException"}toJSON(){return{error:"Authorization Error",message:this.message,statusCode:403}}};V2=class V2 extends J1{constructor($="Token has expired"){super($);this.name="TokenExpiredException"}};R2=class R2 extends J1{constructor($="Invalid token"){super($);this.name="InvalidTokenException"}};E2=class E2 extends J1{constructor($="Token has been revoked"){super($);this.name="TokenRevokedException"}}});var E$={};t0(E$,{HonoAdapter:()=>l2});class l2{hono;name="hono";runtime;constructor($){this.hono=$;this.runtime=s4()}listen($,f){switch(this.runtime){case"bun":return this.listenBun($,f);case"deno":return this.listenDeno($,f);case"node":return this.listenNode($,f);case"workerd":throw Error("Cloudflare Workers do not support listen(). Deploy using wrangler or export the handler with getHandler().");default:throw Error(`Unsupported runtime: ${this.runtime}. FastAPI-TS supports Bun, Node.js, Deno, and Cloudflare Workers.`)}}getHandler(){return this.hono.fetch}getRuntime(){return this.runtime}listenBun($,f){let H=Bun.serve({port:$,fetch:this.hono.fetch});if(f)f();return H}listenDeno($,f){let H=new AbortController;return Deno.serve({port:$,signal:H.signal,onListen:f},this.hono.fetch),{port:$,close:()=>H.abort()}}listenNode($,f){try{let{serve:H}=(()=>{throw new Error("Cannot require module "+"@hono/node-server");})();return H({fetch:this.hono.fetch,port:$},f)}catch(H){throw Error("Node.js adapter requires @hono/node-server package. Install it with: npm install @hono/node-server")}}}var s4=()=>{if(typeof Bun<"u")return"bun";if(typeof Deno<"u")return"deno";if(typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers")return"workerd";if(typeof process<"u"&&process.versions&&process.versions.node)return"node";return"unknown"};var m2={};t0(m2,{ExpressAdapter:()=>Z2});class Z2{app;name="express";express;constructor($){this.app=$;try{let f=(()=>{throw new Error("Cannot require module "+"express");})();this.express=f(),this.setupBridge()}catch(f){throw Error("Express adapter requires express package. Install it with: npm install express")}}setupBridge(){let $=this.app.getHono();this.express.use(async(f,H)=>{try{let Q=this.createWebRequest(f),X=await $.fetch(Q);await this.sendExpressResponse(H,X)}catch(Q){H.status(500).json({error:"Internal Server Error",message:Q instanceof Error?Q.message:"Unknown error"})}})}createWebRequest($){let f=$.protocol||"http",H=$.get("host")||"localhost",Q=`${f}://${H}${$.originalUrl||$.url}`,X=new Headers;for(let[W,Y]of Object.entries($.headers))if(typeof Y==="string")X.set(W,Y);else if(Array.isArray(Y))Y.forEach((G)=>X.append(W,G));let J={method:$.method,headers:X};if($.method!=="GET"&&$.method!=="HEAD"){if($.body)J.body=JSON.stringify($.body),X.set("content-type","application/json")}return new Request(Q,J)}async sendExpressResponse($,f){if($.status(f.status),f.headers.forEach((H,Q)=>{$.setHeader(Q,H)}),f.body){let H=f.headers.get("content-type")||"";if(H.includes("application/json")){let Q=await f.json();$.json(Q)}else if(H.includes("text/")){let Q=await f.text();$.send(Q)}else{let Q=await f.arrayBuffer();$.send(Buffer.from(Q))}}else $.end()}listen($,f){return this.express.listen($,f)}getHandler(){return this.express}getExpressApp(){return this.express}}var o4={};t0(o4,{setupTestApp:()=>y2,mockDependency:()=>u2,createTestClient:()=>F$,createTestApp:()=>b$,clearMocks:()=>i2,TestClient:()=>a0});module.exports=w1(o4);class a0{hono;constructor($){this.hono=$.getHono()}async get($,f){return this.request("GET",$,f)}async post($,f){return this.request("POST",$,f)}async put($,f){return this.request("PUT",$,f)}async delete($,f){return this.request("DELETE",$,f)}async patch($,f){return this.request("PATCH",$,f)}async request($,f,H){let Q=this.buildUrl(f,H?.query),X={method:$,headers:this.buildHeaders(H)};if(H?.body!==void 0)X.body=H.body;else if(H?.json!==void 0)X.body=JSON.stringify(H.json);let J=await this.hono.request(Q,X),W=await J.text(),Y;try{Y=JSON.parse(W)}catch{Y=W}return{status:J.status,headers:J.headers,body:Y,text:W,json:async()=>JSON.parse(W),ok:J.ok}}buildUrl($,f){if(!f||Object.keys(f).length===0)return $;let H=new URLSearchParams(f).toString();return`${$}?${H}`}buildHeaders($){let f={...$?.headers};if($?.json!==void 0&&!f["Content-Type"])f["Content-Type"]="application/json";return f}}var I1=($,f,H)=>{return(Q,X)=>{let J=-1;return W(0);async function W(Y){if(Y<=J)throw Error("next() called multiple times");J=Y;let G,_=!1,S;if($[Y])S=$[Y][0][0],Q.req.routeIndex=Y;else S=Y===$.length&&X||void 0;if(S)try{G=await S(Q,()=>W(Y+1))}catch(A){if(A instanceof Error&&f)Q.error=A,G=await f(A,Q),_=!0;else throw A}else if(Q.finalized===!1&&H)G=await H(Q);if(G&&(Q.finalized===!1||_))Q.res=G;return Q}}};var i$=Symbol();var s$=async($,f=Object.create(null))=>{let{all:H=!1,dot:Q=!1}=f,J=($ instanceof j1?$.raw.headers:$.headers).get("Content-Type");if(J?.startsWith("multipart/form-data")||J?.startsWith("application/x-www-form-urlencoded"))return wf($,{all:H,dot:Q});return{}};async function wf($,f){let H=await $.formData();if(H)return jf(H,f);return{}}function jf($,f){let H=Object.create(null);if($.forEach((Q,X)=>{if(!(f.all||X.endsWith("[]")))H[X]=Q;else Lf(H,X,Q)}),f.dot)Object.entries(H).forEach(([Q,X])=>{if(Q.includes("."))Sf(H,Q,X),delete H[Q]});return H}var Lf=($,f,H)=>{if($[f]!==void 0)if(Array.isArray($[f]))$[f].push(H);else $[f]=[$[f],H];else if(!f.endsWith("[]"))$[f]=H;else $[f]=[H]},Sf=($,f,H)=>{let Q=$,X=f.split(".");X.forEach((J,W)=>{if(W===X.length-1)Q[J]=H;else{if(!Q[J]||typeof Q[J]!=="object"||Array.isArray(Q[J])||Q[J]instanceof File)Q[J]=Object.create(null);Q=Q[J]}})};var K1=($)=>{let f=$.split("/");if(f[0]==="")f.shift();return f},o$=($)=>{let{groups:f,path:H}=Nf($),Q=K1(H);return Vf(Q,f)},Nf=($)=>{let f=[];return $=$.replace(/\{[^}]+\}/g,(H,Q)=>{let X=`@${Q}`;return f.push([X,H]),X}),{groups:f,path:$}},Vf=($,f)=>{for(let H=f.length-1;H>=0;H--){let[Q]=f[H];for(let X=$.length-1;X>=0;X--)if($[X].includes(Q)){$[X]=$[X].replace(Q,f[H][1]);break}}return $},L1={},d$=($,f)=>{if($==="*")return"*";let H=$.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(H){let Q=`${$}#${f}`;if(!L1[Q])if(H[2])L1[Q]=f&&f[0]!==":"&&f[0]!=="*"?[Q,H[1],new RegExp(`^${H[2]}(?=/${f})`)]:[$,H[1],new RegExp(`^${H[2]}$`)];else L1[Q]=[$,H[1],!0];return L1[Q]}return null},k0=($,f)=>{try{return f($)}catch{return $.replace(/(?:%[0-9A-Fa-f]{2})+/g,(H)=>{try{return f(H)}catch{return H}})}},Rf=($)=>k0($,decodeURI),T1=($)=>{let f=$.url,H=f.indexOf("/",f.indexOf(":")+4),Q=H;for(;Q<f.length;Q++){let X=f.charCodeAt(Q);if(X===37){let J=f.indexOf("?",Q),W=f.slice(H,J===-1?void 0:J);return Rf(W.includes("%25")?W.replace(/%25/g,"%2525"):W)}else if(X===63)break}return f.slice(H,Q)};var p$=($)=>{let f=T1($);return f.length>1&&f.at(-1)==="/"?f.slice(0,-1):f},b0=($,f,...H)=>{if(H.length)f=b0(f,...H);return`${$?.[0]==="/"?"":"/"}${$}${f==="/"?"":`${$?.at(-1)==="/"?"":"/"}${f?.[0]==="/"?f.slice(1):f}`}`},S1=($)=>{if($.charCodeAt($.length-1)!==63||!$.includes(":"))return null;let f=$.split("/"),H=[],Q="";return f.forEach((X)=>{if(X!==""&&!/\:/.test(X))Q+="/"+X;else if(/\:/.test(X))if(/\?/.test(X)){if(H.length===0&&Q==="")H.push("/");else H.push(Q);let J=X.replace("?","");Q+="/"+J,H.push(Q)}else Q+="/"+X}),H.filter((X,J,W)=>W.indexOf(X)===J)},P1=($)=>{if(!/[%+]/.test($))return $;if($.indexOf("+")!==-1)$=$.replace(/\+/g," ");return $.indexOf("%")!==-1?k0($,e0):$},r$=($,f,H)=>{let Q;if(!H&&f&&!/[%+]/.test(f)){let W=$.indexOf(`?${f}`,8);if(W===-1)W=$.indexOf(`&${f}`,8);while(W!==-1){let Y=$.charCodeAt(W+f.length+1);if(Y===61){let G=W+f.length+2,_=$.indexOf("&",G);return P1($.slice(G,_===-1?void 0:_))}else if(Y==38||isNaN(Y))return"";W=$.indexOf(`&${f}`,W+1)}if(Q=/[%+]/.test($),!Q)return}let X={};Q??=/[%+]/.test($);let J=$.indexOf("?",8);while(J!==-1){let W=$.indexOf("&",J+1),Y=$.indexOf("=",J);if(Y>W&&W!==-1)Y=-1;let G=$.slice(J+1,Y===-1?W===-1?void 0:W:Y);if(Q)G=P1(G);if(J=W,G==="")continue;let _;if(Y===-1)_="";else if(_=$.slice(Y+1,W===-1?void 0:W),Q)_=P1(_);if(H){if(!(X[G]&&Array.isArray(X[G])))X[G]=[];X[G].push(_)}else X[G]??=_}return f?X[f]:X},t$=r$,a$=($,f)=>{return r$($,f,!0)},e0=decodeURIComponent;var e$=($)=>k0($,e0),j1=class{raw;#f;#$;routeIndex=0;path;bodyCache={};constructor($,f="/",H=[[]]){this.raw=$,this.path=f,this.#$=H,this.#f={}}param($){return $?this.#H($):this.#J()}#H($){let f=this.#$[0][this.routeIndex][1][$],H=this.#X(f);return H&&/\%/.test(H)?e$(H):H}#J(){let $={},f=Object.keys(this.#$[0][this.routeIndex][1]);for(let H of f){let Q=this.#X(this.#$[0][this.routeIndex][1][H]);if(Q!==void 0)$[H]=/\%/.test(Q)?e$(Q):Q}return $}#X($){return this.#$[1]?this.#$[1][$]:$}query($){return t$(this.url,$)}queries($){return a$(this.url,$)}header($){if($)return this.raw.headers.get($)??void 0;let f={};return this.raw.headers.forEach((H,Q)=>{f[Q]=H}),f}async parseBody($){return this.bodyCache.parsedBody??=await s$(this,$)}#Q=($)=>{let{bodyCache:f,raw:H}=this,Q=f[$];if(Q)return Q;let X=Object.keys(f)[0];if(X)return f[X].then((J)=>{if(X==="json")J=JSON.stringify(J);return new Response(J)[$]()});return f[$]=H[$]()};json(){return this.#Q("text").then(($)=>JSON.parse($))}text(){return this.#Q("text")}arrayBuffer(){return this.#Q("arrayBuffer")}blob(){return this.#Q("blob")}formData(){return this.#Q("formData")}addValidatedData($,f){this.#f[$]=f}valid($){return this.#f[$]}get url(){return this.raw.url}get method(){return this.raw.method}get[i$](){return this.#$}get matchedRoutes(){return this.#$[0].map(([[,$]])=>$)}get routePath(){return this.#$[0].map(([[,$]])=>$)[this.routeIndex].path}};var $2={Stringify:1,BeforeStream:2,Stream:3},Ef=($,f)=>{let H=new String($);return H.isEscaped=!0,H.callbacks=f,H};var x1=async($,f,H,Q,X)=>{if(typeof $==="object"&&!($ instanceof String)){if(!($ instanceof Promise))$=$.toString();if($ instanceof Promise)$=await $}let J=$.callbacks;if(!J?.length)return Promise.resolve($);if(X)X[0]+=$;else X=[$];let W=Promise.all(J.map((Y)=>Y({phase:f,buffer:X,context:Q}))).then((Y)=>Promise.all(Y.filter(Boolean).map((G)=>x1(G,f,!1,Q,X))).then(()=>X[0]));if(H)return Ef(await W,J);else return W};var Df="text/plain; charset=UTF-8",g1=($,f)=>{return{"Content-Type":$,...f}},f2=class{#f;#$;env={};#H;finalized=!1;error;#J;#X;#Q;#_;#G;#q;#Y;#B;#z;constructor($,f){if(this.#f=$,f)this.#X=f.executionCtx,this.env=f.env,this.#q=f.notFoundHandler,this.#z=f.path,this.#B=f.matchResult}get req(){return this.#$??=new j1(this.#f,this.#z,this.#B),this.#$}get event(){if(this.#X&&"respondWith"in this.#X)return this.#X;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#X)return this.#X;else throw Error("This context has no ExecutionContext")}get res(){return this.#Q||=new Response(null,{headers:this.#Y??=new Headers})}set res($){if(this.#Q&&$){$=new Response($.body,$);for(let[f,H]of this.#Q.headers.entries()){if(f==="content-type")continue;if(f==="set-cookie"){let Q=this.#Q.headers.getSetCookie();$.headers.delete("set-cookie");for(let X of Q)$.headers.append("set-cookie",X)}else $.headers.set(f,H)}}this.#Q=$,this.finalized=!0}render=(...$)=>{return this.#G??=(f)=>this.html(f),this.#G(...$)};setLayout=($)=>this.#_=$;getLayout=()=>this.#_;setRenderer=($)=>{this.#G=$};header=($,f,H)=>{if(this.finalized)this.#Q=new Response(this.#Q.body,this.#Q);let Q=this.#Q?this.#Q.headers:this.#Y??=new Headers;if(f===void 0)Q.delete($);else if(H?.append)Q.append($,f);else Q.set($,f)};status=($)=>{this.#J=$};set=($,f)=>{this.#H??=new Map,this.#H.set($,f)};get=($)=>{return this.#H?this.#H.get($):void 0};get var(){if(!this.#H)return{};return Object.fromEntries(this.#H)}#W($,f,H){let Q=this.#Q?new Headers(this.#Q.headers):this.#Y??new Headers;if(typeof f==="object"&&"headers"in f){let J=f.headers instanceof Headers?f.headers:new Headers(f.headers);for(let[W,Y]of J)if(W.toLowerCase()==="set-cookie")Q.append(W,Y);else Q.set(W,Y)}if(H)for(let[J,W]of Object.entries(H))if(typeof W==="string")Q.set(J,W);else{Q.delete(J);for(let Y of W)Q.append(J,Y)}let X=typeof f==="number"?f:f?.status??this.#J;return new Response($,{status:X,headers:Q})}newResponse=(...$)=>this.#W(...$);body=($,f,H)=>this.#W($,f,H);text=($,f,H)=>{return!this.#Y&&!this.#J&&!f&&!H&&!this.finalized?new Response($):this.#W($,f,g1(Df,H))};json=($,f,H)=>{return this.#W(JSON.stringify($),f,g1("application/json",H))};html=($,f,H)=>{let Q=(X)=>this.#W(X,f,g1("text/html; charset=UTF-8",H));return typeof $==="object"?x1($,$2.Stringify,!1,{}).then(Q):Q($)};redirect=($,f)=>{let H=String($);return this.header("Location",!/[^\x00-\xFF]/.test(H)?H:encodeURI(H)),this.newResponse(null,f??302)};notFound=()=>{return this.#q??=()=>new Response,this.#q(this)}};var l="ALL",H2="all",Q2=["get","post","put","delete","options","patch"],N1="Can not add a route since the matcher is already built.",V1=class extends Error{};var X2="__COMPOSED_HANDLER";var bf=($)=>{return $.text("404 Not Found",404)},J2=($,f)=>{if("getResponse"in $){let H=$.getResponse();return f.newResponse(H.body,H)}return console.error($),f.text("Internal Server Error",500)},l1=class{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#f="/";routes=[];constructor($={}){[...Q2,H2].forEach((X)=>{this[X]=(J,...W)=>{if(typeof J==="string")this.#f=J;else this.#J(X,this.#f,J);return W.forEach((Y)=>{this.#J(X,this.#f,Y)}),this}}),this.on=(X,J,...W)=>{for(let Y of[J].flat()){this.#f=Y;for(let G of[X].flat())W.map((_)=>{this.#J(G.toUpperCase(),this.#f,_)})}return this},this.use=(X,...J)=>{if(typeof X==="string")this.#f=X;else this.#f="*",J.unshift(X);return J.forEach((W)=>{this.#J(l,this.#f,W)}),this};let{strict:H,...Q}=$;Object.assign(this,Q),this.getPath=H??!0?$.getPath??T1:p$}#$(){let $=new l1({router:this.router,getPath:this.getPath});return $.errorHandler=this.errorHandler,$.#H=this.#H,$.routes=this.routes,$}#H=bf;errorHandler=J2;route($,f){let H=this.basePath($);return f.routes.map((Q)=>{let X;if(f.errorHandler===J2)X=Q.handler;else X=async(J,W)=>(await I1([],f.errorHandler)(J,()=>Q.handler(J,W))).res,X[X2]=Q.handler;H.#J(Q.method,Q.path,X)}),this}basePath($){let f=this.#$();return f._basePath=b0(this._basePath,$),f}onError=($)=>{return this.errorHandler=$,this};notFound=($)=>{return this.#H=$,this};mount($,f,H){let Q,X;if(H)if(typeof H==="function")X=H;else if(X=H.optionHandler,H.replaceRequest===!1)Q=(Y)=>Y;else Q=H.replaceRequest;let J=X?(Y)=>{let G=X(Y);return Array.isArray(G)?G:[G]}:(Y)=>{let G=void 0;try{G=Y.executionCtx}catch{}return[Y.env,G]};Q||=(()=>{let Y=b0(this._basePath,$),G=Y==="/"?0:Y.length;return(_)=>{let S=new URL(_.url);return S.pathname=S.pathname.slice(G)||"/",new Request(S,_)}})();let W=async(Y,G)=>{let _=await f(Q(Y.req.raw),...J(Y));if(_)return _;await G()};return this.#J(l,b0($,"*"),W),this}#J($,f,H){$=$.toUpperCase(),f=b0(this._basePath,f);let Q={basePath:this._basePath,path:f,method:$,handler:H};this.router.add($,f,[H,Q]),this.routes.push(Q)}#X($,f){if($ instanceof Error)return this.errorHandler($,f);throw $}#Q($,f,H,Q){if(Q==="HEAD")return(async()=>new Response(null,await this.#Q($,f,H,"GET")))();let X=this.getPath($,{env:H}),J=this.router.match(Q,X),W=new f2($,{path:X,matchResult:J,env:H,executionCtx:f,notFoundHandler:this.#H});if(J[0].length===1){let G;try{G=J[0][0][0][0](W,async()=>{W.res=await this.#H(W)})}catch(_){return this.#X(_,W)}return G instanceof Promise?G.then((_)=>_||(W.finalized?W.res:this.#H(W))).catch((_)=>this.#X(_,W)):G??this.#H(W)}let Y=I1(J[0],this.errorHandler,this.#H);return(async()=>{try{let G=await Y(W);if(!G.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return G.res}catch(G){return this.#X(G,W)}})()}fetch=($,...f)=>{return this.#Q($,f[1],f[0],$.method)};request=($,f,H,Q)=>{if($ instanceof Request)return this.fetch(f?new Request($,f):$,H,Q);return $=$.toString(),this.fetch(new Request(/^https?:\/\//.test($)?$:`http://localhost${b0("/",$)}`,f),H,Q)};fire=()=>{addEventListener("fetch",($)=>{$.respondWith(this.#Q($.request,$,void 0,$.request.method))})}};var R1="[^/]+",$1=".*",f1="(?:|/.*)",F0=Symbol(),Ff=new Set(".\\+*[^]$()");function Af($,f){if($.length===1)return f.length===1?$<f?-1:1:-1;if(f.length===1)return 1;if($===$1||$===f1)return 1;else if(f===$1||f===f1)return-1;if($===R1)return 1;else if(f===R1)return-1;return $.length===f.length?$<f?-1:1:f.length-$.length}var E1=class{#f;#$;#H=Object.create(null);insert($,f,H,Q,X){if($.length===0){if(this.#f!==void 0)throw F0;if(X)return;this.#f=f;return}let[J,...W]=$,Y=J==="*"?W.length===0?["","",$1]:["","",R1]:J==="/*"?["","",f1]:J.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),G;if(Y){let _=Y[1],S=Y[2]||R1;if(_&&Y[2]){if(S===".*")throw F0;if(S=S.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(S))throw F0}if(G=this.#H[S],!G){if(Object.keys(this.#H).some((A)=>A!==$1&&A!==f1))throw F0;if(X)return;if(G=this.#H[S]=new E1,_!=="")G.#$=Q.varIndex++}if(!X&&_!=="")H.push([_,G.#$])}else if(G=this.#H[J],!G){if(Object.keys(this.#H).some((_)=>_.length>1&&_!==$1&&_!==f1))throw F0;if(X)return;G=this.#H[J]=new E1}G.insert(W,f,H,Q,X)}buildRegExpStr(){let f=Object.keys(this.#H).sort(Af).map((H)=>{let Q=this.#H[H];return(typeof Q.#$==="number"?`(${H})@${Q.#$}`:Ff.has(H)?`\\${H}`:H)+Q.buildRegExpStr()});if(typeof this.#f==="number")f.unshift(`#${this.#f}`);if(f.length===0)return"";if(f.length===1)return f[0];return"(?:"+f.join("|")+")"}};var W2=class{#f={varIndex:0};#$=new E1;insert($,f,H){let Q=[],X=[];for(let W=0;;){let Y=!1;if($=$.replace(/\{[^}]+\}/g,(G)=>{let _=`@\\${W}`;return X[W]=[_,G],W++,Y=!0,_}),!Y)break}let J=$.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let W=X.length-1;W>=0;W--){let[Y]=X[W];for(let G=J.length-1;G>=0;G--)if(J[G].indexOf(Y)!==-1){J[G]=J[G].replace(Y,X[W][1]);break}}return this.#$.insert(J,f,Q,this.#f,H),Q}buildRegExp(){let $=this.#$.buildRegExpStr();if($==="")return[/^$/,[],[]];let f=0,H=[],Q=[];return $=$.replace(/#(\d+)|@(\d+)|\.\*\$/g,(X,J,W)=>{if(J!==void 0)return H[++f]=Number(J),"$()";if(W!==void 0)return Q[Number(W)]=++f,"";return""}),[new RegExp(`^${$}`),H,Q]}};var Y2=[],Uf=[/^$/,[],Object.create(null)],G2=Object.create(null);function q2($){return G2[$]??=new RegExp($==="*"?"":`^${$.replace(/\/\*$|([.\\+*[^\]$()])/g,(f,H)=>H?`\\${H}`:"(?:|/.*)")}$`)}function Cf(){G2=Object.create(null)}function Of($){let f=new W2,H=[];if($.length===0)return Uf;let Q=$.map((_)=>[!/\*|\/:/.test(_[0]),..._]).sort(([_,S],[A,k])=>_?1:A?-1:S.length-k.length),X=Object.create(null);for(let _=0,S=-1,A=Q.length;_<A;_++){let[k,Z,h]=Q[_];if(k)X[Z]=[h.map(([m])=>[m,Object.create(null)]),Y2];else S++;let T;try{T=f.insert(Z,S,k)}catch(m){throw m===F0?new V1(Z):m}if(k)continue;H[S]=h.map(([m,o])=>{let e=Object.create(null);o-=1;for(;o>=0;o--){let[i,$0]=T[o];e[i]=$0}return[m,e]})}let[J,W,Y]=f.buildRegExp();for(let _=0,S=H.length;_<S;_++)for(let A=0,k=H[_].length;A<k;A++){let Z=H[_][A]?.[1];if(!Z)continue;let h=Object.keys(Z);for(let T=0,m=h.length;T<m;T++)Z[h[T]]=Y[Z[h[T]]]}let G=[];for(let _ in W)G[_]=H[W[_]];return[J,G,X]}function I0($,f){if(!$)return;for(let H of Object.keys($).sort((Q,X)=>X.length-Q.length))if(q2(H).test(f))return[...$[H]];return}var Z1=class{name="RegExpRouter";#f;#$;constructor(){this.#f={[l]:Object.create(null)},this.#$={[l]:Object.create(null)}}add($,f,H){let Q=this.#f,X=this.#$;if(!Q||!X)throw Error(N1);if(!Q[$])[Q,X].forEach((Y)=>{Y[$]=Object.create(null),Object.keys(Y[l]).forEach((G)=>{Y[$][G]=[...Y[l][G]]})});if(f==="/*")f="*";let J=(f.match(/\/:/g)||[]).length;if(/\*$/.test(f)){let Y=q2(f);if($===l)Object.keys(Q).forEach((G)=>{Q[G][f]||=I0(Q[G],f)||I0(Q[l],f)||[]});else Q[$][f]||=I0(Q[$],f)||I0(Q[l],f)||[];Object.keys(Q).forEach((G)=>{if($===l||$===G)Object.keys(Q[G]).forEach((_)=>{Y.test(_)&&Q[G][_].push([H,J])})}),Object.keys(X).forEach((G)=>{if($===l||$===G)Object.keys(X[G]).forEach((_)=>Y.test(_)&&X[G][_].push([H,J]))});return}let W=S1(f)||[f];for(let Y=0,G=W.length;Y<G;Y++){let _=W[Y];Object.keys(X).forEach((S)=>{if($===l||$===S)X[S][_]||=[...I0(Q[S],_)||I0(Q[l],_)||[]],X[S][_].push([H,J-G+Y+1])})}}match($,f){Cf();let H=this.#H();return this.match=(Q,X)=>{let J=H[Q]||H[l],W=J[2][X];if(W)return W;let Y=X.match(J[0]);if(!Y)return[[],Y2];let G=Y.indexOf("",1);return[J[1][G],Y]},this.match($,f)}#H(){let $=Object.create(null);return Object.keys(this.#$).concat(Object.keys(this.#f)).forEach((f)=>{$[f]||=this.#J(f)}),this.#f=this.#$=void 0,$}#J($){let f=[],H=$===l;if([this.#f,this.#$].forEach((Q)=>{let X=Q[$]?Object.keys(Q[$]).map((J)=>[J,Q[$][J]]):[];if(X.length!==0)H||=!0,f.push(...X);else if($!==l)f.push(...Object.keys(Q[l]).map((J)=>[J,Q[l][J]]))}),!H)return null;else return Of(f)}};var m1=class{name="SmartRouter";#f=[];#$=[];constructor($){this.#f=$.routers}add($,f,H){if(!this.#$)throw Error(N1);this.#$.push([$,f,H])}match($,f){if(!this.#$)throw Error("Fatal error");let H=this.#f,Q=this.#$,X=H.length,J=0,W;for(;J<X;J++){let Y=H[J];try{for(let G=0,_=Q.length;G<_;G++)Y.add(...Q[G]);W=Y.match($,f)}catch(G){if(G instanceof V1)continue;throw G}this.match=Y.match.bind(Y),this.#f=[Y],this.#$=void 0;break}if(J===X)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,W}get activeRouter(){if(this.#$||this.#f.length!==1)throw Error("No active router has been determined yet.");return this.#f[0]}};var H1=Object.create(null),n1=class{#f;#$;#H;#J=0;#X=H1;constructor($,f,H){if(this.#$=H||Object.create(null),this.#f=[],$&&f){let Q=Object.create(null);Q[$]={handler:f,possibleKeys:[],score:0},this.#f=[Q]}this.#H=[]}insert($,f,H){this.#J=++this.#J;let Q=this,X=o$(f),J=[];for(let W=0,Y=X.length;W<Y;W++){let G=X[W],_=X[W+1],S=d$(G,_),A=Array.isArray(S)?S[0]:G;if(A in Q.#$){if(Q=Q.#$[A],S)J.push(S[1]);continue}if(Q.#$[A]=new n1,S)Q.#H.push(S),J.push(S[1]);Q=Q.#$[A]}return Q.#f.push({[$]:{handler:H,possibleKeys:J.filter((W,Y,G)=>G.indexOf(W)===Y),score:this.#J}}),Q}#Q($,f,H,Q){let X=[];for(let J=0,W=$.#f.length;J<W;J++){let Y=$.#f[J],G=Y[f]||Y[l],_={};if(G!==void 0){if(G.params=Object.create(null),X.push(G),H!==H1||Q&&Q!==H1)for(let S=0,A=G.possibleKeys.length;S<A;S++){let k=G.possibleKeys[S],Z=_[G.score];G.params[k]=Q?.[k]&&!Z?Q[k]:H[k]??Q?.[k],_[G.score]=!0}}}return X}search($,f){let H=[];this.#X=H1;let X=[this],J=K1(f),W=[];for(let Y=0,G=J.length;Y<G;Y++){let _=J[Y],S=Y===G-1,A=[];for(let k=0,Z=X.length;k<Z;k++){let h=X[k],T=h.#$[_];if(T)if(T.#X=h.#X,S){if(T.#$["*"])H.push(...this.#Q(T.#$["*"],$,h.#X));H.push(...this.#Q(T,$,h.#X))}else A.push(T);for(let m=0,o=h.#H.length;m<o;m++){let e=h.#H[m],i=h.#X===H1?{}:{...h.#X};if(e==="*"){let G0=h.#$["*"];if(G0)H.push(...this.#Q(G0,$,h.#X)),G0.#X=i,A.push(G0);continue}let[$0,s,t]=e;if(!_&&!(t instanceof RegExp))continue;let f0=h.#$[$0],C1=J.slice(Y).join("/");if(t instanceof RegExp){let G0=t.exec(C1);if(G0){if(i[s]=G0[0],H.push(...this.#Q(f0,$,h.#X,i)),Object.keys(f0.#$).length){f0.#X=i;let O1=G0[0].match(/\//)?.length??0;(W[O1]||=[]).push(f0)}continue}}if(t===!0||t.test(_))if(i[s]=_,S){if(H.push(...this.#Q(f0,$,i,h.#X)),f0.#$["*"])H.push(...this.#Q(f0.#$["*"],$,i,h.#X))}else f0.#X=i,A.push(f0)}}X=A.concat(W.shift()??[])}if(H.length>1)H.sort((Y,G)=>{return Y.score-G.score});return[H.map(({handler:Y,params:G})=>[Y,G])]}};var c1=class{name="TrieRouter";#f;constructor(){this.#f=new n1}add($,f,H){let Q=S1(f);if(Q){for(let X=0,J=Q.length;X<J;X++)this.#f.insert($,Q[X],H);return}this.#f.insert($,f,H)}match($,f){return this.#f.search($,f)}};var u1=class extends l1{constructor($={}){super($);this.router=$.router??new m1({routers:[new Z1,new c1]})}};var J8=Bf(B2()),y1=Symbol("route:metadata"),i1=Symbol("controller:metadata"),z2=Symbol("parameter:metadata"),w2=Symbol("dependency:metadata"),s1=Symbol("websocket:metadata"),j2=Symbol("websocket:handler:metadata"),o1=Symbol("graphql:resolver"),Q1=Symbol("graphql:field"),d1=Symbol("auth:metadata"),p1=Symbol("oauth:metadata"),r1=Symbol("roles:metadata"),t1=Symbol("permissions:metadata"),a1=Symbol("minimum-role:metadata"),e1=Symbol("resource-permission:metadata"),$$=Symbol("session:metadata"),f$=Symbol("csrf:metadata");class S0{routes=new Map;controllers=new Map;routesByController=new Map;websockets=new Map;graphqlResolvers=new Map;graphqlFields=new Map;registerRoute($){let f=this.getRouteKey($.target,$.propertyKey);if(this.routes.set(f,$),!this.routesByController.has($.target))this.routesByController.set($.target,[]);this.routesByController.get($.target).push($)}registerController($,f){this.controllers.set($,f)}getRoutes(){return Array.from(this.routes.values())}getRoute($,f){let H=this.getRouteKey($,f);return this.routes.get(H)}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 f=this.getRouteKey($.target,$.propertyKey);this.graphqlFields.set(f,$)}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((f)=>f.target===$)}clear(){this.routes.clear(),this.controllers.clear(),this.routesByController.clear(),this.websockets.clear(),this.graphqlResolvers.clear(),this.graphqlFields.clear()}getRouteKey($,f){return`${$.name}:${f}`}static defineRoute($,f,H){let Q=this.getRouteMetadata($,f),X={...Q,...H,target:$.constructor,propertyKey:f,middleware:[...Q?.middleware||[],...H.middleware||[]],parameters:H.parameters||Q?.parameters||[],dependencies:H.dependencies||Q?.dependencies||[],responses:H.responses||Q?.responses||[],auth:H.auth||Q?.auth,oauth:H.oauth||Q?.oauth,roles:H.roles||Q?.roles,permissions:H.permissions||Q?.permissions,minimumRole:H.minimumRole||Q?.minimumRole,resourcePermission:H.resourcePermission||Q?.resourcePermission,session:H.session||Q?.session,csrf:H.csrf||Q?.csrf};Reflect.defineMetadata(y1,X,$,f)}static defineParameter($,f,H,Q){let X=this.getParameterMetadata($,f)||[];X[H]=Q,Reflect.defineMetadata(z2,X,$,f);let J=this.getRouteMetadata($,f);this.defineRoute($,f,{...J,parameters:X})}static defineDependency($,f,H,Q){let X=this.getDependencyMetadata($,f)||[];X[H]=Q,Reflect.defineMetadata(w2,X,$,f);let J=this.getRouteMetadata($,f);this.defineRoute($,f,{...J,dependencies:X})}static defineController($,f){Reflect.defineMetadata(i1,f,$)}static getRouteMetadata($,f){return Reflect.getMetadata(y1,$,f)}static getParameterMetadata($,f){return Reflect.getMetadata(z2,$,f)}static getDependencyMetadata($,f){return Reflect.getMetadata(w2,$,f)}static getControllerMetadata($){return Reflect.getMetadata(i1,$)}static hasControllerMetadata($){return Reflect.hasMetadata(i1,$)}static hasRouteMetadata($,f){return Reflect.hasMetadata(y1,$,f)}static getRouteMethods($){let f=$.prototype,H=[],Q=Object.getOwnPropertyNames(f);for(let X of Q){if(X==="constructor")continue;if(this.hasRouteMetadata(f,X))H.push(X)}return H}static defineWebSocket($,f){let Q={...this.getWebSocketMetadata($),...f,target:$};Reflect.defineMetadata(s1,Q,$)}static defineWebSocketHandler($,f,H){let Q=this.getWebSocketMetadata($.constructor)||{};switch(H.type){case"connect":Q.onConnect=f;break;case"message":Q.onMessage=f,Q.messageSchema=H.schema;break;case"disconnect":Q.onDisconnect=f;break}this.defineWebSocket($.constructor,Q),Reflect.defineMetadata(j2,H,$,f)}static getWebSocketMetadata($){return Reflect.getMetadata(s1,$)}static getWebSocketHandlerMetadata($,f){return Reflect.getMetadata(j2,$,f)}static hasWebSocketMetadata($){return Reflect.hasMetadata(s1,$)}static defineGraphQLResolver($,f){Reflect.defineMetadata(o1,f,$)}static defineGraphQLField($,f,H){Reflect.defineMetadata(Q1,H,$,f);let Q=this.getGraphQLFieldsMetadata($.constructor)||[];Q.push(H),Reflect.defineMetadata(Q1,Q,$.constructor)}static getGraphQLResolverMetadata($){return Reflect.getMetadata(o1,$)}static getGraphQLFieldsMetadata($){return Reflect.getMetadata(Q1,$)||[]}static getGraphQLFieldMetadata($,f){return Reflect.getMetadata(Q1,$,f)}static hasGraphQLResolverMetadata($){return Reflect.hasMetadata(o1,$)}static hasGraphQLFieldMetadata($,f){return Reflect.hasMetadata(Q1,$,f)}static defineAuth($,f,H){Reflect.defineMetadata(d1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,auth:H})}static getAuthMetadata($,f){return Reflect.getMetadata(d1,$,f)}static hasAuthMetadata($,f){return Reflect.hasMetadata(d1,$,f)}static defineOAuth($,f,H){Reflect.defineMetadata(p1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,oauth:H})}static getOAuthMetadata($,f){return Reflect.getMetadata(p1,$,f)}static hasOAuthMetadata($,f){return Reflect.hasMetadata(p1,$,f)}static defineRoles($,f,H){Reflect.defineMetadata(r1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,roles:H})}static definePermissions($,f,H){Reflect.defineMetadata(t1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,permissions:H})}static defineMinimumRole($,f,H){Reflect.defineMetadata(a1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,minimumRole:H})}static getRolesMetadata($,f){return Reflect.getMetadata(r1,$,f)}static getPermissionsMetadata($,f){return Reflect.getMetadata(t1,$,f)}static getMinimumRoleMetadata($,f){return Reflect.getMetadata(a1,$,f)}static hasRolesMetadata($,f){return Reflect.hasMetadata(r1,$,f)}static hasPermissionsMetadata($,f){return Reflect.hasMetadata(t1,$,f)}static hasMinimumRoleMetadata($,f){return Reflect.hasMetadata(a1,$,f)}static defineResourcePermission($,f,H){Reflect.defineMetadata(e1,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,resourcePermission:H})}static getResourcePermissionMetadata($,f){return Reflect.getMetadata(e1,$,f)}static hasResourcePermissionMetadata($,f){return Reflect.hasMetadata(e1,$,f)}static defineSession($,f,H){Reflect.defineMetadata($$,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,session:H})}static defineCSRF($,f,H){Reflect.defineMetadata(f$,H,$,f);let Q=this.getRouteMetadata($,f);this.defineRoute($,f,{...Q,csrf:H})}static getSessionMetadata($,f){return Reflect.getMetadata($$,$,f)}static getCSRFMetadata($,f){return Reflect.getMetadata(f$,$,f)}static hasSessionMetadata($,f){return Reflect.hasMetadata($$,$,f)}static hasCSRFMetadata($,f){return Reflect.hasMetadata(f$,$,f)}}class H${singletons=new Map;requestScoped=new WeakMap;providers=new Map;resolutionStack=new Set;providerNameCache=new WeakMap;stats={singletonHits:0,singletonMisses:0,requestHits:0,requestMisses:0,transientCreations:0};register($,f){this.providers.set($,f||{scope:"transient"})}async resolve($,f){let H=this.providers.get($)||{scope:f?.scope||"transient"},Q=f?.scope||H.scope||"transient";if(Q==="singleton"){if(this.singletons.has($))return this.stats.singletonHits++,this.singletons.get($);if(this.stats.singletonMisses++,this.resolutionStack.has($))throw Error(`Circular dependency detected: ${this.buildCircularDependencyMessage($)}`);this.resolutionStack.add($);try{let X=await this.create($,H,f?.context);return this.singletons.set($,X),X}finally{this.resolutionStack.delete($)}}if(Q==="request"&&f?.context){let X=this.requestScoped.get(f.context);if(X?.has($))return this.stats.requestHits++,X.get($);if(this.stats.requestMisses++,!X)X=new Map,this.requestScoped.set(f.context,X);if(this.resolutionStack.has($))throw Error(`Circular dependency detected: ${this.buildCircularDependencyMessage($)}`);this.resolutionStack.add($);try{let J=await this.create($,H,f.context);return X.set($,J),J}finally{this.resolutionStack.delete($)}}if(this.stats.transientCreations++,this.resolutionStack.has($))throw Error(`Circular dependency detected: ${this.buildCircularDependencyMessage($)}`);this.resolutionStack.add($);try{return await this.create($,H,f?.context)}finally{this.resolutionStack.delete($)}}buildCircularDependencyMessage($){let f=Array.from(this.resolutionStack),H=this.getProviderName($);return f.map((X)=>this.getProviderName(X)).join(" -> ")+" -> "+H}async create($,f,H){if(f.factory)return f.factory();if(typeof $==="function")if($.prototype&&$.prototype.constructor===$){let Q=new $;return await this.resolveNestedDependencies(Q,H),Q}else{let Q=$();return Q instanceof Promise?await Q:Q}throw Error("Invalid provider type")}async resolveNestedDependencies($,f){}getProviderName($){let f=this.providerNameCache.get($);if(f)return f;let H;if(typeof $==="function")if($.name)H=$.name;else H=$.toString().substring(0,50);else H=String($);return this.providerNameCache.set($,H),H}clear(){this.singletons.clear(),this.providers.clear(),this.resolutionStack.clear(),this.providerNameCache=new WeakMap,this.resetStats()}clearRequestScope($){this.requestScoped.delete($)}getStats(){let $=this.stats.singletonHits+this.stats.singletonMisses,f=$>0?this.stats.singletonHits/$*100:0,H=this.stats.requestHits+this.stats.requestMisses,Q=H>0?this.stats.requestHits/H*100:0;return{singletonHits:this.stats.singletonHits,singletonMisses:this.stats.singletonMisses,singletonHitRate:Math.round(f*100)/100,requestHits:this.stats.requestHits,requestMisses:this.stats.requestMisses,requestHitRate:Math.round(Q*100)/100,transientCreations:this.stats.transientCreations}}resetStats(){this.stats={singletonHits:0,singletonMisses:0,requestHits:0,requestMisses:0,transientCreations:0}}}var vf=/^[\w!#$%&'*.^`|~+-]+$/,hf=/^[ !#-:<-[\]-~]*$/,Q$=($,f)=>{if(f&&$.indexOf(f)===-1)return{};let H=$.trim().split(";"),Q={};for(let X of H){X=X.trim();let J=X.indexOf("=");if(J===-1)continue;let W=X.substring(0,J).trim();if(f&&f!==W||!vf.test(W))continue;let Y=X.substring(J+1).trim();if(Y.startsWith('"')&&Y.endsWith('"'))Y=Y.slice(1,-1);if(hf.test(Y)){if(Q[W]=Y.indexOf("%")!==-1?k0(Y,e0):Y,f)break}}return Q};var Mf=($,f,H={})=>{let Q=`${$}=${f}`;if($.startsWith("__Secure-")&&!H.secure)throw Error("__Secure- Cookie must have Secure attributes");if($.startsWith("__Host-")){if(!H.secure)throw Error("__Host- Cookie must have Secure attributes");if(H.path!=="/")throw Error('__Host- Cookie must have Path attributes with "/"');if(H.domain)throw Error("__Host- Cookie must not have Domain attributes")}if(H&&typeof H.maxAge==="number"&&H.maxAge>=0){if(H.maxAge>34560000)throw Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");Q+=`; Max-Age=${H.maxAge|0}`}if(H.domain&&H.prefix!=="host")Q+=`; Domain=${H.domain}`;if(H.path)Q+=`; Path=${H.path}`;if(H.expires){if(H.expires.getTime()-Date.now()>34560000000)throw Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");Q+=`; Expires=${H.expires.toUTCString()}`}if(H.httpOnly)Q+="; HttpOnly";if(H.secure)Q+="; Secure";if(H.sameSite)Q+=`; SameSite=${H.sameSite.charAt(0).toUpperCase()+H.sameSite.slice(1)}`;if(H.priority)Q+=`; Priority=${H.priority.charAt(0).toUpperCase()+H.priority.slice(1)}`;if(H.partitioned){if(!H.secure)throw Error("Partitioned Cookie must have Secure attributes");Q+="; Partitioned"}return Q},D1=($,f,H)=>{return f=encodeURIComponent(f),Mf($,f,H)};var L2=($,f,H)=>{let Q=$.req.raw.headers.get("Cookie");if(typeof f==="string"){if(!Q)return;let J=f;if(H==="secure")J="__Secure-"+f;else if(H==="host")J="__Host-"+f;return Q$(Q,J)[J]}if(!Q)return{};return Q$(Q)};var kf=($,f,H)=>{let Q;if(H?.prefix==="secure")Q=D1("__Secure-"+$,f,{path:"/",...H,secure:!0});else if(H?.prefix==="host")Q=D1("__Host-"+$,f,{...H,path:"/",secure:!0,domain:void 0});else Q=D1($,f,{path:"/",...H});return Q},w8=($,f,H,Q)=>{let X=kf(f,H,Q);$.header("Set-Cookie",X,{append:!0})};class S2{static json($,f=200,H){return new X$($,f,H)}static html($,f=200){return new J$($,f)}static file($,f){return new Y$($,f)}static stream($,f){return new G$($,f)}static redirect($,f=302){return new W$($,f)}}class X${data;status;headers;constructor($,f=200,H={}){this.data=$;this.status=f;this.headers=H}toHonoResponse($){return $.json(this.data,this.status,this.headers)}}class J${content;status;constructor($,f=200){this.content=$;this.status=f}toHonoResponse($){return $.html(this.content,this.status)}}class W${url;status;constructor($,f=302){this.url=$;this.status=f}toHonoResponse($){return $.redirect(this.url,this.status)}}class Y${path;options;constructor($,f){this.path=$;this.options=f}async toHonoResponse($){try{let f=typeof Bun<"u"?Bun.file(this.path):await this.readFileNode(this.path),Q={"Content-Type":this.options?.contentType||this.guessContentType(this.path)};if(this.options?.download||this.options?.filename){let X=this.options?.filename||this.path.split("/").pop()||"download",J=this.options?.download?"attachment":"inline";Q["Content-Disposition"]=`${J}; filename="${X}"`}if(typeof Bun<"u"&&f instanceof Blob)return $.body(f,200,Q);else return $.body(f,200,Q)}catch(f){return $.json({error:"File not found",message:f instanceof Error?f.message:"Unknown error"},404)}}async readFileNode($){throw Error("File reading in Node.js requires fs module - use Bun runtime or implement adapter")}guessContentType($){let f=$.split(".").pop()?.toLowerCase();return{html:"text/html",css:"text/css",js:"application/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",pdf:"application/pdf",txt:"text/plain",xml:"application/xml"}[f||""]||"application/octet-stream"}}class G${stream;options;constructor($,f){this.stream=$;this.options=f}toHonoResponse($){let f={"Content-Type":this.options?.contentType||"application/octet-stream",...this.options?.headers};return $.body(this.stream,200,f)}}class q${static serialize($,f){if(f===null||f===void 0)return $.body(null,204);if(f instanceof S2)return f;if(f instanceof X$)return f.toHonoResponse($);if(f instanceof J$)return f.toHonoResponse($);if(f instanceof Y$)return f.toHonoResponse($);if(f instanceof G$)return f.toHonoResponse($);if(f instanceof W$)return f.toHonoResponse($);if(f&&typeof f.toHonoResponse==="function")return f.toHonoResponse($);return $.json(f)}}class _${static compile($){let f=this.compilePathRegex($.path),H=this.resolveParameterOrder($.parameters),Q=this.resolveDependencyOrder($.dependencies),X=this.calculateMaxArgumentIndex($.parameters,$.dependencies),J=this.computeParameterFlags($.parameters);return{...$,pathRegex:f,parameterOrder:H,dependencyOrder:Q,maxArgumentIndex:X,...J}}static compilePathRegex($){let f=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return f=f.replace(/\\\{([^}]+)\\\}/g,"(?<$1>[^/]+)"),f=f.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,"(?<$1>[^/]+)"),f=`^${f}$`,new RegExp(f)}static resolveParameterOrder($){if(!$||$.length===0)return[];return $.map((f)=>f.index).filter((f)=>f!==void 0).sort((f,H)=>f-H)}static resolveDependencyOrder($){if(!$||$.length===0)return[];return $.map((f)=>f.index).filter((f)=>f!==void 0).sort((f,H)=>f-H)}static calculateMaxArgumentIndex($,f){let H=-1;if($&&$.length>0){let Q=Math.max(...$.map((X)=>X.index));H=Math.max(H,Q)}if(f&&f.length>0){let Q=Math.max(...f.map((X)=>X.index));H=Math.max(H,Q)}return H}static computeParameterFlags($){if(!$||$.length===0)return{hasBody:!1,hasQuery:!1,hasParams:!1,hasHeaders:!1,hasCookies:!1,hasDependencies:!1};return{hasBody:$.some((f)=>f.type==="body"),hasQuery:$.some((f)=>f.type==="query"),hasParams:$.some((f)=>f.type==="param"),hasHeaders:$.some((f)=>f.type==="header"),hasCookies:$.some((f)=>f.type==="cookie"),hasDependencies:!1}}static compileAll($){return $.map((f)=>this.compile(f))}}X1();class z${app;metadata;container;validator;errorHandler;compiledRoutes=new Map;constructor($,f,H,Q,X){this.app=$;this.metadata=f;this.container=H;this.validator=Q;this.errorHandler=X}compile(){let $=this.metadata.getRoutes(),f=_$.compileAll($);for(let H of f){let Q=`${H.target.name}:${H.propertyKey}`;this.compiledRoutes.set(Q,H);let X=this.createHandler(H),J=this.normalizePath(H.path),W=H.method.toLowerCase();if(H.middleware&&H.middleware.length>0)this.app[W](J,...H.middleware,X);else this.app[W](J,X)}}normalizePath($){if(!$.startsWith("/"))$="/"+$;if($=$.replace(/\{([^}]+)\}/g,":$1"),$.length>1&&$.endsWith("/"))$=$.slice(0,-1);return $}createHandler($){return async(f)=>{try{f.set("routeMetadata",$);let H=await this.extractParameters(f,$.parameters),Q=await this.resolveDependencies(f,$.dependencies),X=this.mergeArguments(H,Q,$.parameters,$.maxArgumentIndex),J;if($.handler)J=await $.handler(f,...X);else{let W=await this.container.resolve($.target,{scope:"transient",context:f});if(typeof W[$.propertyKey]!=="function")throw Error(`Method ${$.propertyKey} not found on controller ${$.target.name}`);J=await W[$.propertyKey](...X)}return this.serializeResponse(f,J)}catch(H){return await this.handleError(f,H)}}}serializeResponse($,f){return q$.serialize($,f)}getRouteMetadataForContext($){return $.get("routeMetadata")||null}isAuthRequired($){if($.auth?.required)return!0;return $.parameters.some((f)=>f.type==="current-user")}async handleError($,f){return await this.errorHandler.handle(f,$)}async extractParameters($,f){let H=[];for(let Q of f){if(!Q)continue;let X;switch(Q.type){case"body":try{X=await $.req.json()}catch(Y){X=null}break;case"query":if(Q.name)X=$.req.query(Q.name);else X=$.req.query();if(Q.schema&&X!==void 0)try{X=Q.schema.parse(X)}catch(Y){throw new B$(`Invalid query parameter: ${Y}`)}break;case"param":if(Q.name)X=$.req.param(Q.name);else X=$.req.param();break;case"header":if(Q.name)X=$.req.header(Q.name);else{let Y={};$.req.raw.headers.forEach((G,_)=>{Y[_]=G}),X=Y}break;case"cookie":if(Q.name)X=L2($,Q.name);else{let Y=$.req.header("cookie");if(Y)X=Object.fromEntries(Y.split(";").map((G)=>{let[_,...S]=G.trim().split("=");return[_,S.join("=")]}));else X={}}break;case"request":X=$.req;break;case"response":case"context":X=$;break;case"current-user":X=$.get("auth.user")||null;let J=this.getRouteMetadataForContext($);if(J&&this.isAuthRequired(J)){if(!X){let Y=$.get("auth.error")||"Authentication required",{AuthenticationException:G}=await Promise.resolve().then(() => (b2(),D2));throw new G(Y)}}break;case"token":X=$.get("auth.token")||null;break;case"oauth-user":X=$.get("oauth.user")||null;break;case"oauth-token":X=$.get("oauth.token")||null;break;case"current-session":X=$.get("session")||null;break;case"session-data":let W=$.get("session");if(W&&Q.metadata?.key)X=W.data[Q.metadata.key];else if(W)X=W.data;else X=null;break;case"csrf-token":X=$.get("csrf.token")||null;break;case"filtered-resource":X=$.get("filtered.resource")||null;break;case"filtered-attributes":X=$.get("filtered.attributes")||[];break;default:X=void 0}if(Q.schema)try{X=await this.validator.validate(X,Q.schema)}catch(J){throw J}H[Q.index]=X}return H}mergeArguments($,f,H,Q){let J=H.filter((_)=>_!==void 0&&_.index!==void 0).map((_)=>_.index),W=J.length>0?Math.max(...J):-1,Y=Q!==void 0&&Q>=0?Q:Math.max(W,$.length-1,f.length-1,0);if(!Number.isFinite(Y)||Y<0)Y=0;let G=Array(Y+1);for(let _=0;_<=Y;_++)if($[_]!==void 0)G[_]=$[_];else if(f[_]!==void 0)G[_]=f[_];return G}async resolveDependencies($,f){let H=[];for(let Q of f){if(!Q)continue;try{let X=await this.container.resolve(Q.provider,{scope:Q.scope,context:$});H[Q.index]=X}catch(X){throw Error(`Failed to resolve dependency at index ${Q.index}: ${X instanceof Error?X.message:"Unknown error"}`)}}return H}}var K2={};t0(K2,{void:()=>R4,util:()=>P,unknown:()=>N4,union:()=>F4,undefined:()=>j4,tuple:()=>C4,transformer:()=>x4,symbol:()=>w4,string:()=>k2,strictObject:()=>b4,setErrorMap:()=>gf,set:()=>h4,record:()=>O4,quotelessJson:()=>Tf,promise:()=>T4,preprocess:()=>Z4,pipeline:()=>m4,ostring:()=>n4,optional:()=>g4,onumber:()=>c4,oboolean:()=>u4,objectUtil:()=>w$,object:()=>D4,number:()=>I2,nullable:()=>l4,null:()=>L4,never:()=>V4,nativeEnum:()=>K4,nan:()=>_4,map:()=>v4,makeIssue:()=>W1,literal:()=>I4,lazy:()=>k4,late:()=>G4,isValid:()=>N0,isDirty:()=>F1,isAsync:()=>K0,isAborted:()=>b1,intersection:()=>U4,instanceof:()=>q4,getParsedType:()=>_0,getErrorMap:()=>P0,function:()=>M4,enum:()=>P4,effect:()=>x4,discriminatedUnion:()=>A4,defaultErrorMap:()=>w0,datetimeRegex:()=>v2,date:()=>z4,custom:()=>M2,coerce:()=>y4,boolean:()=>P2,bigint:()=>B4,array:()=>E4,any:()=>S4,addIssueToContext:()=>N,ZodVoid:()=>G1,ZodUnknown:()=>V0,ZodUnion:()=>m0,ZodUndefined:()=>l0,ZodType:()=>M,ZodTuple:()=>z0,ZodTransformer:()=>Y0,ZodSymbol:()=>Y1,ZodString:()=>Q0,ZodSet:()=>O0,ZodSchema:()=>M,ZodRecord:()=>q1,ZodReadonly:()=>o0,ZodPromise:()=>v0,ZodPipeline:()=>z1,ZodParsedType:()=>j,ZodOptional:()=>J0,ZodObject:()=>g,ZodNumber:()=>R0,ZodNullable:()=>L0,ZodNull:()=>Z0,ZodNever:()=>B0,ZodNativeEnum:()=>y0,ZodNaN:()=>B1,ZodMap:()=>_1,ZodLiteral:()=>u0,ZodLazy:()=>c0,ZodIssueCode:()=>w,ZodIntersection:()=>n0,ZodFunction:()=>x0,ZodFirstPartyTypeKind:()=>C,ZodError:()=>d,ZodEnum:()=>D0,ZodEffects:()=>Y0,ZodDiscriminatedUnion:()=>A1,ZodDefault:()=>i0,ZodDate:()=>U0,ZodCatch:()=>s0,ZodBranded:()=>U1,ZodBoolean:()=>g0,ZodBigInt:()=>E0,ZodArray:()=>X0,ZodAny:()=>C0,Schema:()=>M,ParseStatus:()=>p,OK:()=>r,NEVER:()=>i4,INVALID:()=>U,EMPTY_PATH:()=>lf,DIRTY:()=>A0,BRAND:()=>Y4});var P;(function($){$.assertEqual=(X)=>{};function f(X){}$.assertIs=f;function H(X){throw Error()}$.assertNever=H,$.arrayToEnum=(X)=>{let J={};for(let W of X)J[W]=W;return J},$.getValidEnumValues=(X)=>{let J=$.objectKeys(X).filter((Y)=>typeof X[X[Y]]!=="number"),W={};for(let Y of J)W[Y]=X[Y];return $.objectValues(W)},$.objectValues=(X)=>{return $.objectKeys(X).map(function(J){return X[J]})},$.objectKeys=typeof Object.keys==="function"?(X)=>Object.keys(X):(X)=>{let J=[];for(let W in X)if(Object.prototype.hasOwnProperty.call(X,W))J.push(W);return J},$.find=(X,J)=>{for(let W of X)if(J(W))return W;return},$.isInteger=typeof Number.isInteger==="function"?(X)=>Number.isInteger(X):(X)=>typeof X==="number"&&Number.isFinite(X)&&Math.floor(X)===X;function Q(X,J=" | "){return X.map((W)=>typeof W==="string"?`'${W}'`:W).join(J)}$.joinValues=Q,$.jsonStringifyReplacer=(X,J)=>{if(typeof J==="bigint")return J.toString();return J}})(P||(P={}));var w$;(function($){$.mergeShapes=(f,H)=>{return{...f,...H}}})(w$||(w$={}));var j=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_0=($)=>{switch(typeof $){case"undefined":return j.undefined;case"string":return j.string;case"number":return Number.isNaN($)?j.nan:j.number;case"boolean":return j.boolean;case"function":return j.function;case"bigint":return j.bigint;case"symbol":return j.symbol;case"object":if(Array.isArray($))return j.array;if($===null)return j.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return j.promise;if(typeof Map<"u"&&$ instanceof Map)return j.map;if(typeof Set<"u"&&$ instanceof Set)return j.set;if(typeof Date<"u"&&$ instanceof Date)return j.date;return j.object;default:return j.unknown}};var w=P.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"]),Tf=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class d extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(H)=>{this.issues=[...this.issues,H]},this.addIssues=(H=[])=>{this.issues=[...this.issues,...H]};let f=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,f);else this.__proto__=f;this.name="ZodError",this.issues=$}format($){let f=$||function(X){return X.message},H={_errors:[]},Q=(X)=>{for(let J of X.issues)if(J.code==="invalid_union")J.unionErrors.map(Q);else if(J.code==="invalid_return_type")Q(J.returnTypeError);else if(J.code==="invalid_arguments")Q(J.argumentsError);else if(J.path.length===0)H._errors.push(f(J));else{let W=H,Y=0;while(Y<J.path.length){let G=J.path[Y];if(Y!==J.path.length-1)W[G]=W[G]||{_errors:[]};else W[G]=W[G]||{_errors:[]},W[G]._errors.push(f(J));W=W[G],Y++}}};return Q(this),H}static assert($){if(!($ instanceof d))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(f)=>f.message){let f={},H=[];for(let Q of this.issues)if(Q.path.length>0){let X=Q.path[0];f[X]=f[X]||[],f[X].push($(Q))}else H.push($(Q));return{formErrors:H,fieldErrors:f}}get formErrors(){return this.flatten()}}d.create=($)=>{return new d($)};var xf=($,f)=>{let H;switch($.code){case w.invalid_type:if($.received===j.undefined)H="Required";else H=`Expected ${$.expected}, received ${$.received}`;break;case w.invalid_literal:H=`Invalid literal value, expected ${JSON.stringify($.expected,P.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:H=`Unrecognized key(s) in object: ${P.joinValues($.keys,", ")}`;break;case w.invalid_union:H="Invalid input";break;case w.invalid_union_discriminator:H=`Invalid discriminator value. Expected ${P.joinValues($.options)}`;break;case w.invalid_enum_value:H=`Invalid enum value. Expected ${P.joinValues($.options)}, received '${$.received}'`;break;case w.invalid_arguments:H="Invalid function arguments";break;case w.invalid_return_type:H="Invalid function return type";break;case w.invalid_date:H="Invalid date";break;case w.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(H=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")H=`${H} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)H=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)H=`Invalid input: must end with "${$.validation.endsWith}"`;else P.assertNever($.validation);else if($.validation!=="regex")H=`Invalid ${$.validation}`;else H="Invalid";break;case w.too_small:if($.type==="array")H=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")H=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")H=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")H=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")H=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else H="Invalid input";break;case w.too_big:if($.type==="array")H=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")H=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")H=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")H=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")H=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else H="Invalid input";break;case w.custom:H="Invalid input";break;case w.invalid_intersection_types:H="Intersection results could not be merged";break;case w.not_multiple_of:H=`Number must be a multiple of ${$.multipleOf}`;break;case w.not_finite:H="Number must be finite";break;default:H=f.defaultError,P.assertNever($)}return{message:H}},w0=xf;var F2=w0;function gf($){F2=$}function P0(){return F2}var W1=($)=>{let{data:f,path:H,errorMaps:Q,issueData:X}=$,J=[...H,...X.path||[]],W={...X,path:J};if(X.message!==void 0)return{...X,path:J,message:X.message};let Y="",G=Q.filter((_)=>!!_).slice().reverse();for(let _ of G)Y=_(W,{data:f,defaultError:Y}).message;return{...X,path:J,message:Y}},lf=[];function N($,f){let H=P0(),Q=W1({issueData:f,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,H,H===w0?void 0:w0].filter((X)=>!!X)});$.common.issues.push(Q)}class p{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,f){let H=[];for(let Q of f){if(Q.status==="aborted")return U;if(Q.status==="dirty")$.dirty();H.push(Q.value)}return{status:$.value,value:H}}static async mergeObjectAsync($,f){let H=[];for(let Q of f){let X=await Q.key,J=await Q.value;H.push({key:X,value:J})}return p.mergeObjectSync($,H)}static mergeObjectSync($,f){let H={};for(let Q of f){let{key:X,value:J}=Q;if(X.status==="aborted")return U;if(J.status==="aborted")return U;if(X.status==="dirty")$.dirty();if(J.status==="dirty")$.dirty();if(X.value!=="__proto__"&&(typeof J.value<"u"||Q.alwaysSet))H[X.value]=J.value}return{status:$.value,value:H}}}var U=Object.freeze({status:"aborted"}),A0=($)=>({status:"dirty",value:$}),r=($)=>({status:"valid",value:$}),b1=($)=>$.status==="aborted",F1=($)=>$.status==="dirty",N0=($)=>$.status==="valid",K0=($)=>typeof Promise<"u"&&$ instanceof Promise;var D;(function($){$.errToObj=(f)=>typeof f==="string"?{message:f}:f||{},$.toString=(f)=>typeof f==="string"?f:f?.message})(D||(D={}));class W0{constructor($,f,H,Q){this._cachedPath=[],this.parent=$,this.data=f,this._path=H,this._key=Q}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 A2=($,f)=>{if(N0(f))return{success:!0,data:f.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 H=new d($.common.issues);return this._error=H,this._error}}}};function v($){if(!$)return{};let{errorMap:f,invalid_type_error:H,required_error:Q,description:X}=$;if(f&&(H||Q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(f)return{errorMap:f,description:X};return{errorMap:(W,Y)=>{let{message:G}=$;if(W.code==="invalid_enum_value")return{message:G??Y.defaultError};if(typeof Y.data>"u")return{message:G??Q??Y.defaultError};if(W.code!=="invalid_type")return{message:Y.defaultError};return{message:G??H??Y.defaultError}},description:X}}class M{get description(){return this._def.description}_getType($){return _0($.data)}_getOrReturnCtx($,f){return f||{common:$.parent.common,data:$.data,parsedType:_0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new p,ctx:{common:$.parent.common,data:$.data,parsedType:_0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let f=this._parse($);if(K0(f))throw Error("Synchronous parse encountered promise.");return f}_parseAsync($){let f=this._parse($);return Promise.resolve(f)}parse($,f){let H=this.safeParse($,f);if(H.success)return H.data;throw H.error}safeParse($,f){let H={common:{issues:[],async:f?.async??!1,contextualErrorMap:f?.errorMap},path:f?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:_0($)},Q=this._parseSync({data:$,path:H.path,parent:H});return A2(H,Q)}"~validate"($){let f={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:_0($)};if(!this["~standard"].async)try{let H=this._parseSync({data:$,path:[],parent:f});return N0(H)?{value:H.value}:{issues:f.common.issues}}catch(H){if(H?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;f.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:f}).then((H)=>N0(H)?{value:H.value}:{issues:f.common.issues})}async parseAsync($,f){let H=await this.safeParseAsync($,f);if(H.success)return H.data;throw H.error}async safeParseAsync($,f){let H={common:{issues:[],contextualErrorMap:f?.errorMap,async:!0},path:f?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:_0($)},Q=this._parse({data:$,path:H.path,parent:H}),X=await(K0(Q)?Q:Promise.resolve(Q));return A2(H,X)}refine($,f){let H=(Q)=>{if(typeof f==="string"||typeof f>"u")return{message:f};else if(typeof f==="function")return f(Q);else return f};return this._refinement((Q,X)=>{let J=$(Q),W=()=>X.addIssue({code:w.custom,...H(Q)});if(typeof Promise<"u"&&J instanceof Promise)return J.then((Y)=>{if(!Y)return W(),!1;else return!0});if(!J)return W(),!1;else return!0})}refinement($,f){return this._refinement((H,Q)=>{if(!$(H))return Q.addIssue(typeof f==="function"?f(H,Q):f),!1;else return!0})}_refinement($){return new Y0({schema:this,typeName:C.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:(f)=>this["~validate"](f)}}optional(){return J0.create(this,this._def)}nullable(){return L0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X0.create(this)}promise(){return v0.create(this,this._def)}or($){return m0.create([this,$],this._def)}and($){return n0.create(this,$,this._def)}transform($){return new Y0({...v(this._def),schema:this,typeName:C.ZodEffects,effect:{type:"transform",transform:$}})}default($){let f=typeof $==="function"?$:()=>$;return new i0({...v(this._def),innerType:this,defaultValue:f,typeName:C.ZodDefault})}brand(){return new U1({typeName:C.ZodBranded,type:this,...v(this._def)})}catch($){let f=typeof $==="function"?$:()=>$;return new s0({...v(this._def),innerType:this,catchValue:f,typeName:C.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return z1.create(this,$)}readonly(){return o0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var Zf=/^c[^\s-]{8,}$/i,mf=/^[0-9a-z]+$/,nf=/^[0-9A-HJKMNP-TV-Z]{26}$/i,cf=/^[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,uf=/^[a-z0-9_-]{21}$/i,yf=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,sf=/^[-+]?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)?)??$/,of=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,df="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",j$,pf=/^(?:(?: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])$/,rf=/^(?:(?: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])$/,tf=/^(([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]))$/,af=/^(([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])$/,ef=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,C2="((\\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])))",f4=new RegExp(`^${C2}$`);function O2($){let f="[0-5]\\d";if($.precision)f=`${f}\\.\\d{${$.precision}}`;else if($.precision==null)f=`${f}(\\.\\d+)?`;let H=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${f})${H}`}function H4($){return new RegExp(`^${O2($)}$`)}function v2($){let f=`${C2}T${O2($)}`,H=[];if(H.push($.local?"Z?":"Z"),$.offset)H.push("([+-]\\d{2}:?\\d{2})");return f=`${f}(${H.join("|")})`,new RegExp(`^${f}$`)}function Q4($,f){if((f==="v4"||!f)&&pf.test($))return!0;if((f==="v6"||!f)&&tf.test($))return!0;return!1}function X4($,f){if(!yf.test($))return!1;try{let[H]=$.split(".");if(!H)return!1;let Q=H.replace(/-/g,"+").replace(/_/g,"/").padEnd(H.length+(4-H.length%4)%4,"="),X=JSON.parse(atob(Q));if(typeof X!=="object"||X===null)return!1;if("typ"in X&&X?.typ!=="JWT")return!1;if(!X.alg)return!1;if(f&&X.alg!==f)return!1;return!0}catch{return!1}}function J4($,f){if((f==="v4"||!f)&&rf.test($))return!0;if((f==="v6"||!f)&&af.test($))return!0;return!1}class Q0 extends M{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==j.string){let X=this._getOrReturnCtx($);return N(X,{code:w.invalid_type,expected:j.string,received:X.parsedType}),U}let H=new p,Q=void 0;for(let X of this._def.checks)if(X.kind==="min"){if($.data.length<X.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:w.too_small,minimum:X.value,type:"string",inclusive:!0,exact:!1,message:X.message}),H.dirty()}else if(X.kind==="max"){if($.data.length>X.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:w.too_big,maximum:X.value,type:"string",inclusive:!0,exact:!1,message:X.message}),H.dirty()}else if(X.kind==="length"){let J=$.data.length>X.value,W=$.data.length<X.value;if(J||W){if(Q=this._getOrReturnCtx($,Q),J)N(Q,{code:w.too_big,maximum:X.value,type:"string",inclusive:!0,exact:!0,message:X.message});else if(W)N(Q,{code:w.too_small,minimum:X.value,type:"string",inclusive:!0,exact:!0,message:X.message});H.dirty()}}else if(X.kind==="email"){if(!of.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"email",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="emoji"){if(!j$)j$=new RegExp(df,"u");if(!j$.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"emoji",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="uuid"){if(!cf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"uuid",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="nanoid"){if(!uf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"nanoid",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="cuid"){if(!Zf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"cuid",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="cuid2"){if(!mf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"cuid2",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="ulid"){if(!nf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"ulid",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="url")try{new URL($.data)}catch{Q=this._getOrReturnCtx($,Q),N(Q,{validation:"url",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="regex"){if(X.regex.lastIndex=0,!X.regex.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"regex",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="trim")$.data=$.data.trim();else if(X.kind==="includes"){if(!$.data.includes(X.value,X.position))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:{includes:X.value,position:X.position},message:X.message}),H.dirty()}else if(X.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(X.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(X.kind==="startsWith"){if(!$.data.startsWith(X.value))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:{startsWith:X.value},message:X.message}),H.dirty()}else if(X.kind==="endsWith"){if(!$.data.endsWith(X.value))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:{endsWith:X.value},message:X.message}),H.dirty()}else if(X.kind==="datetime"){if(!v2(X).test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:"datetime",message:X.message}),H.dirty()}else if(X.kind==="date"){if(!f4.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:"date",message:X.message}),H.dirty()}else if(X.kind==="time"){if(!H4(X).test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:w.invalid_string,validation:"time",message:X.message}),H.dirty()}else if(X.kind==="duration"){if(!sf.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"duration",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="ip"){if(!Q4($.data,X.version))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"ip",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="jwt"){if(!X4($.data,X.alg))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"jwt",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="cidr"){if(!J4($.data,X.version))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"cidr",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="base64"){if(!ef.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"base64",code:w.invalid_string,message:X.message}),H.dirty()}else if(X.kind==="base64url"){if(!$4.test($.data))Q=this._getOrReturnCtx($,Q),N(Q,{validation:"base64url",code:w.invalid_string,message:X.message}),H.dirty()}else P.assertNever(X);return{status:H.value,value:$.data}}_regex($,f,H){return this.refinement((Q)=>$.test(Q),{validation:f,code:w.invalid_string,...D.errToObj(H)})}_addCheck($){return new Q0({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...D.errToObj($)})}url($){return this._addCheck({kind:"url",...D.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...D.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...D.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...D.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...D.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...D.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...D.errToObj($)})}base64($){return this._addCheck({kind:"base64",...D.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...D.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...D.errToObj($)})}ip($){return this._addCheck({kind:"ip",...D.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...D.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,...D.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,...D.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...D.errToObj($)})}regex($,f){return this._addCheck({kind:"regex",regex:$,...D.errToObj(f)})}includes($,f){return this._addCheck({kind:"includes",value:$,position:f?.position,...D.errToObj(f?.message)})}startsWith($,f){return this._addCheck({kind:"startsWith",value:$,...D.errToObj(f)})}endsWith($,f){return this._addCheck({kind:"endsWith",value:$,...D.errToObj(f)})}min($,f){return this._addCheck({kind:"min",value:$,...D.errToObj(f)})}max($,f){return this._addCheck({kind:"max",value:$,...D.errToObj(f)})}length($,f){return this._addCheck({kind:"length",value:$,...D.errToObj(f)})}nonempty($){return this.min(1,D.errToObj($))}trim(){return new Q0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Q0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Q0({...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 f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $}get maxLength(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $}}Q0.create=($)=>{return new Q0({checks:[],typeName:C.ZodString,coerce:$?.coerce??!1,...v($)})};function W4($,f){let H=($.toString().split(".")[1]||"").length,Q=(f.toString().split(".")[1]||"").length,X=H>Q?H:Q,J=Number.parseInt($.toFixed(X).replace(".","")),W=Number.parseInt(f.toFixed(X).replace(".",""));return J%W/10**X}class R0 extends M{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($)!==j.number){let X=this._getOrReturnCtx($);return N(X,{code:w.invalid_type,expected:j.number,received:X.parsedType}),U}let H=void 0,Q=new p;for(let X of this._def.checks)if(X.kind==="int"){if(!P.isInteger($.data))H=this._getOrReturnCtx($,H),N(H,{code:w.invalid_type,expected:"integer",received:"float",message:X.message}),Q.dirty()}else if(X.kind==="min"){if(X.inclusive?$.data<X.value:$.data<=X.value)H=this._getOrReturnCtx($,H),N(H,{code:w.too_small,minimum:X.value,type:"number",inclusive:X.inclusive,exact:!1,message:X.message}),Q.dirty()}else if(X.kind==="max"){if(X.inclusive?$.data>X.value:$.data>=X.value)H=this._getOrReturnCtx($,H),N(H,{code:w.too_big,maximum:X.value,type:"number",inclusive:X.inclusive,exact:!1,message:X.message}),Q.dirty()}else if(X.kind==="multipleOf"){if(W4($.data,X.value)!==0)H=this._getOrReturnCtx($,H),N(H,{code:w.not_multiple_of,multipleOf:X.value,message:X.message}),Q.dirty()}else if(X.kind==="finite"){if(!Number.isFinite($.data))H=this._getOrReturnCtx($,H),N(H,{code:w.not_finite,message:X.message}),Q.dirty()}else P.assertNever(X);return{status:Q.value,value:$.data}}gte($,f){return this.setLimit("min",$,!0,D.toString(f))}gt($,f){return this.setLimit("min",$,!1,D.toString(f))}lte($,f){return this.setLimit("max",$,!0,D.toString(f))}lt($,f){return this.setLimit("max",$,!1,D.toString(f))}setLimit($,f,H,Q){return new R0({...this._def,checks:[...this._def.checks,{kind:$,value:f,inclusive:H,message:D.toString(Q)}]})}_addCheck($){return new R0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:D.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:D.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:D.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:D.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:D.toString($)})}multipleOf($,f){return this._addCheck({kind:"multipleOf",value:$,message:D.toString(f)})}finite($){return this._addCheck({kind:"finite",message:D.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:D.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:D.toString($)})}get minValue(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $}get maxValue(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&P.isInteger($.value))}get isFinite(){let $=null,f=null;for(let H of this._def.checks)if(H.kind==="finite"||H.kind==="int"||H.kind==="multipleOf")return!0;else if(H.kind==="min"){if(f===null||H.value>f)f=H.value}else if(H.kind==="max"){if($===null||H.value<$)$=H.value}return Number.isFinite(f)&&Number.isFinite($)}}R0.create=($)=>{return new R0({checks:[],typeName:C.ZodNumber,coerce:$?.coerce||!1,...v($)})};class E0 extends M{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($)!==j.bigint)return this._getInvalidInput($);let H=void 0,Q=new p;for(let X of this._def.checks)if(X.kind==="min"){if(X.inclusive?$.data<X.value:$.data<=X.value)H=this._getOrReturnCtx($,H),N(H,{code:w.too_small,type:"bigint",minimum:X.value,inclusive:X.inclusive,message:X.message}),Q.dirty()}else if(X.kind==="max"){if(X.inclusive?$.data>X.value:$.data>=X.value)H=this._getOrReturnCtx($,H),N(H,{code:w.too_big,type:"bigint",maximum:X.value,inclusive:X.inclusive,message:X.message}),Q.dirty()}else if(X.kind==="multipleOf"){if($.data%X.value!==BigInt(0))H=this._getOrReturnCtx($,H),N(H,{code:w.not_multiple_of,multipleOf:X.value,message:X.message}),Q.dirty()}else P.assertNever(X);return{status:Q.value,value:$.data}}_getInvalidInput($){let f=this._getOrReturnCtx($);return N(f,{code:w.invalid_type,expected:j.bigint,received:f.parsedType}),U}gte($,f){return this.setLimit("min",$,!0,D.toString(f))}gt($,f){return this.setLimit("min",$,!1,D.toString(f))}lte($,f){return this.setLimit("max",$,!0,D.toString(f))}lt($,f){return this.setLimit("max",$,!1,D.toString(f))}setLimit($,f,H,Q){return new E0({...this._def,checks:[...this._def.checks,{kind:$,value:f,inclusive:H,message:D.toString(Q)}]})}_addCheck($){return new E0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:D.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:D.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:D.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:D.toString($)})}multipleOf($,f){return this._addCheck({kind:"multipleOf",value:$,message:D.toString(f)})}get minValue(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $}get maxValue(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $}}E0.create=($)=>{return new E0({checks:[],typeName:C.ZodBigInt,coerce:$?.coerce??!1,...v($)})};class g0 extends M{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==j.boolean){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.boolean,received:H.parsedType}),U}return r($.data)}}g0.create=($)=>{return new g0({typeName:C.ZodBoolean,coerce:$?.coerce||!1,...v($)})};class U0 extends M{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==j.date){let X=this._getOrReturnCtx($);return N(X,{code:w.invalid_type,expected:j.date,received:X.parsedType}),U}if(Number.isNaN($.data.getTime())){let X=this._getOrReturnCtx($);return N(X,{code:w.invalid_date}),U}let H=new p,Q=void 0;for(let X of this._def.checks)if(X.kind==="min"){if($.data.getTime()<X.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:w.too_small,message:X.message,inclusive:!0,exact:!1,minimum:X.value,type:"date"}),H.dirty()}else if(X.kind==="max"){if($.data.getTime()>X.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:w.too_big,message:X.message,inclusive:!0,exact:!1,maximum:X.value,type:"date"}),H.dirty()}else P.assertNever(X);return{status:H.value,value:new Date($.data.getTime())}}_addCheck($){return new U0({...this._def,checks:[...this._def.checks,$]})}min($,f){return this._addCheck({kind:"min",value:$.getTime(),message:D.toString(f)})}max($,f){return this._addCheck({kind:"max",value:$.getTime(),message:D.toString(f)})}get minDate(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $!=null?new Date($):null}}U0.create=($)=>{return new U0({checks:[],coerce:$?.coerce||!1,typeName:C.ZodDate,...v($)})};class Y1 extends M{_parse($){if(this._getType($)!==j.symbol){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.symbol,received:H.parsedType}),U}return r($.data)}}Y1.create=($)=>{return new Y1({typeName:C.ZodSymbol,...v($)})};class l0 extends M{_parse($){if(this._getType($)!==j.undefined){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.undefined,received:H.parsedType}),U}return r($.data)}}l0.create=($)=>{return new l0({typeName:C.ZodUndefined,...v($)})};class Z0 extends M{_parse($){if(this._getType($)!==j.null){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.null,received:H.parsedType}),U}return r($.data)}}Z0.create=($)=>{return new Z0({typeName:C.ZodNull,...v($)})};class C0 extends M{constructor(){super(...arguments);this._any=!0}_parse($){return r($.data)}}C0.create=($)=>{return new C0({typeName:C.ZodAny,...v($)})};class V0 extends M{constructor(){super(...arguments);this._unknown=!0}_parse($){return r($.data)}}V0.create=($)=>{return new V0({typeName:C.ZodUnknown,...v($)})};class B0 extends M{_parse($){let f=this._getOrReturnCtx($);return N(f,{code:w.invalid_type,expected:j.never,received:f.parsedType}),U}}B0.create=($)=>{return new B0({typeName:C.ZodNever,...v($)})};class G1 extends M{_parse($){if(this._getType($)!==j.undefined){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.void,received:H.parsedType}),U}return r($.data)}}G1.create=($)=>{return new G1({typeName:C.ZodVoid,...v($)})};class X0 extends M{_parse($){let{ctx:f,status:H}=this._processInputParams($),Q=this._def;if(f.parsedType!==j.array)return N(f,{code:w.invalid_type,expected:j.array,received:f.parsedType}),U;if(Q.exactLength!==null){let J=f.data.length>Q.exactLength.value,W=f.data.length<Q.exactLength.value;if(J||W)N(f,{code:J?w.too_big:w.too_small,minimum:W?Q.exactLength.value:void 0,maximum:J?Q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Q.exactLength.message}),H.dirty()}if(Q.minLength!==null){if(f.data.length<Q.minLength.value)N(f,{code:w.too_small,minimum:Q.minLength.value,type:"array",inclusive:!0,exact:!1,message:Q.minLength.message}),H.dirty()}if(Q.maxLength!==null){if(f.data.length>Q.maxLength.value)N(f,{code:w.too_big,maximum:Q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Q.maxLength.message}),H.dirty()}if(f.common.async)return Promise.all([...f.data].map((J,W)=>{return Q.type._parseAsync(new W0(f,J,f.path,W))})).then((J)=>{return p.mergeArray(H,J)});let X=[...f.data].map((J,W)=>{return Q.type._parseSync(new W0(f,J,f.path,W))});return p.mergeArray(H,X)}get element(){return this._def.type}min($,f){return new X0({...this._def,minLength:{value:$,message:D.toString(f)}})}max($,f){return new X0({...this._def,maxLength:{value:$,message:D.toString(f)}})}length($,f){return new X0({...this._def,exactLength:{value:$,message:D.toString(f)}})}nonempty($){return this.min(1,$)}}X0.create=($,f)=>{return new X0({type:$,minLength:null,maxLength:null,exactLength:null,typeName:C.ZodArray,...v(f)})};function T0($){if($ instanceof g){let f={};for(let H in $.shape){let Q=$.shape[H];f[H]=J0.create(T0(Q))}return new g({...$._def,shape:()=>f})}else if($ instanceof X0)return new X0({...$._def,type:T0($.element)});else if($ instanceof J0)return J0.create(T0($.unwrap()));else if($ instanceof L0)return L0.create(T0($.unwrap()));else if($ instanceof z0)return z0.create($.items.map((f)=>T0(f)));else return $}class g extends M{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(),f=P.objectKeys($);return this._cached={shape:$,keys:f},this._cached}_parse($){if(this._getType($)!==j.object){let G=this._getOrReturnCtx($);return N(G,{code:w.invalid_type,expected:j.object,received:G.parsedType}),U}let{status:H,ctx:Q}=this._processInputParams($),{shape:X,keys:J}=this._getCached(),W=[];if(!(this._def.catchall instanceof B0&&this._def.unknownKeys==="strip")){for(let G in Q.data)if(!J.includes(G))W.push(G)}let Y=[];for(let G of J){let _=X[G],S=Q.data[G];Y.push({key:{status:"valid",value:G},value:_._parse(new W0(Q,S,Q.path,G)),alwaysSet:G in Q.data})}if(this._def.catchall instanceof B0){let G=this._def.unknownKeys;if(G==="passthrough")for(let _ of W)Y.push({key:{status:"valid",value:_},value:{status:"valid",value:Q.data[_]}});else if(G==="strict"){if(W.length>0)N(Q,{code:w.unrecognized_keys,keys:W}),H.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let _ of W){let S=Q.data[_];Y.push({key:{status:"valid",value:_},value:G._parse(new W0(Q,S,Q.path,_)),alwaysSet:_ in Q.data})}}if(Q.common.async)return Promise.resolve().then(async()=>{let G=[];for(let _ of Y){let S=await _.key,A=await _.value;G.push({key:S,value:A,alwaysSet:_.alwaysSet})}return G}).then((G)=>{return p.mergeObjectSync(H,G)});else return p.mergeObjectSync(H,Y)}get shape(){return this._def.shape()}strict($){return D.errToObj,new g({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(f,H)=>{let Q=this._def.errorMap?.(f,H).message??H.defaultError;if(f.code==="unrecognized_keys")return{message:D.errToObj($).message??Q};return{message:Q}}}:{}})}strip(){return new g({...this._def,unknownKeys:"strip"})}passthrough(){return new g({...this._def,unknownKeys:"passthrough"})}extend($){return new g({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new g({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:C.ZodObject})}setKey($,f){return this.augment({[$]:f})}catchall($){return new g({...this._def,catchall:$})}pick($){let f={};for(let H of P.objectKeys($))if($[H]&&this.shape[H])f[H]=this.shape[H];return new g({...this._def,shape:()=>f})}omit($){let f={};for(let H of P.objectKeys(this.shape))if(!$[H])f[H]=this.shape[H];return new g({...this._def,shape:()=>f})}deepPartial(){return T0(this)}partial($){let f={};for(let H of P.objectKeys(this.shape)){let Q=this.shape[H];if($&&!$[H])f[H]=Q;else f[H]=Q.optional()}return new g({...this._def,shape:()=>f})}required($){let f={};for(let H of P.objectKeys(this.shape))if($&&!$[H])f[H]=this.shape[H];else{let X=this.shape[H];while(X instanceof J0)X=X._def.innerType;f[H]=X}return new g({...this._def,shape:()=>f})}keyof(){return h2(P.objectKeys(this.shape))}}g.create=($,f)=>{return new g({shape:()=>$,unknownKeys:"strip",catchall:B0.create(),typeName:C.ZodObject,...v(f)})};g.strictCreate=($,f)=>{return new g({shape:()=>$,unknownKeys:"strict",catchall:B0.create(),typeName:C.ZodObject,...v(f)})};g.lazycreate=($,f)=>{return new g({shape:$,unknownKeys:"strip",catchall:B0.create(),typeName:C.ZodObject,...v(f)})};class m0 extends M{_parse($){let{ctx:f}=this._processInputParams($),H=this._def.options;function Q(X){for(let W of X)if(W.result.status==="valid")return W.result;for(let W of X)if(W.result.status==="dirty")return f.common.issues.push(...W.ctx.common.issues),W.result;let J=X.map((W)=>new d(W.ctx.common.issues));return N(f,{code:w.invalid_union,unionErrors:J}),U}if(f.common.async)return Promise.all(H.map(async(X)=>{let J={...f,common:{...f.common,issues:[]},parent:null};return{result:await X._parseAsync({data:f.data,path:f.path,parent:J}),ctx:J}})).then(Q);else{let X=void 0,J=[];for(let Y of H){let G={...f,common:{...f.common,issues:[]},parent:null},_=Y._parseSync({data:f.data,path:f.path,parent:G});if(_.status==="valid")return _;else if(_.status==="dirty"&&!X)X={result:_,ctx:G};if(G.common.issues.length)J.push(G.common.issues)}if(X)return f.common.issues.push(...X.ctx.common.issues),X.result;let W=J.map((Y)=>new d(Y));return N(f,{code:w.invalid_union,unionErrors:W}),U}}get options(){return this._def.options}}m0.create=($,f)=>{return new m0({options:$,typeName:C.ZodUnion,...v(f)})};var j0=($)=>{if($ instanceof c0)return j0($.schema);else if($ instanceof Y0)return j0($.innerType());else if($ instanceof u0)return[$.value];else if($ instanceof D0)return $.options;else if($ instanceof y0)return P.objectValues($.enum);else if($ instanceof i0)return j0($._def.innerType);else if($ instanceof l0)return[void 0];else if($ instanceof Z0)return[null];else if($ instanceof J0)return[void 0,...j0($.unwrap())];else if($ instanceof L0)return[null,...j0($.unwrap())];else if($ instanceof U1)return j0($.unwrap());else if($ instanceof o0)return j0($.unwrap());else if($ instanceof s0)return j0($._def.innerType);else return[]};class A1 extends M{_parse($){let{ctx:f}=this._processInputParams($);if(f.parsedType!==j.object)return N(f,{code:w.invalid_type,expected:j.object,received:f.parsedType}),U;let H=this.discriminator,Q=f.data[H],X=this.optionsMap.get(Q);if(!X)return N(f,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[H]}),U;if(f.common.async)return X._parseAsync({data:f.data,path:f.path,parent:f});else return X._parseSync({data:f.data,path:f.path,parent:f})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,f,H){let Q=new Map;for(let X of f){let J=j0(X.shape[$]);if(!J.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let W of J){if(Q.has(W))throw Error(`Discriminator property ${String($)} has duplicate value ${String(W)}`);Q.set(W,X)}}return new A1({typeName:C.ZodDiscriminatedUnion,discriminator:$,options:f,optionsMap:Q,...v(H)})}}function L$($,f){let H=_0($),Q=_0(f);if($===f)return{valid:!0,data:$};else if(H===j.object&&Q===j.object){let X=P.objectKeys(f),J=P.objectKeys($).filter((Y)=>X.indexOf(Y)!==-1),W={...$,...f};for(let Y of J){let G=L$($[Y],f[Y]);if(!G.valid)return{valid:!1};W[Y]=G.data}return{valid:!0,data:W}}else if(H===j.array&&Q===j.array){if($.length!==f.length)return{valid:!1};let X=[];for(let J=0;J<$.length;J++){let W=$[J],Y=f[J],G=L$(W,Y);if(!G.valid)return{valid:!1};X.push(G.data)}return{valid:!0,data:X}}else if(H===j.date&&Q===j.date&&+$===+f)return{valid:!0,data:$};else return{valid:!1}}class n0 extends M{_parse($){let{status:f,ctx:H}=this._processInputParams($),Q=(X,J)=>{if(b1(X)||b1(J))return U;let W=L$(X.value,J.value);if(!W.valid)return N(H,{code:w.invalid_intersection_types}),U;if(F1(X)||F1(J))f.dirty();return{status:f.value,value:W.data}};if(H.common.async)return Promise.all([this._def.left._parseAsync({data:H.data,path:H.path,parent:H}),this._def.right._parseAsync({data:H.data,path:H.path,parent:H})]).then(([X,J])=>Q(X,J));else return Q(this._def.left._parseSync({data:H.data,path:H.path,parent:H}),this._def.right._parseSync({data:H.data,path:H.path,parent:H}))}}n0.create=($,f,H)=>{return new n0({left:$,right:f,typeName:C.ZodIntersection,...v(H)})};class z0 extends M{_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.parsedType!==j.array)return N(H,{code:w.invalid_type,expected:j.array,received:H.parsedType}),U;if(H.data.length<this._def.items.length)return N(H,{code:w.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),U;if(!this._def.rest&&H.data.length>this._def.items.length)N(H,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f.dirty();let X=[...H.data].map((J,W)=>{let Y=this._def.items[W]||this._def.rest;if(!Y)return null;return Y._parse(new W0(H,J,H.path,W))}).filter((J)=>!!J);if(H.common.async)return Promise.all(X).then((J)=>{return p.mergeArray(f,J)});else return p.mergeArray(f,X)}get items(){return this._def.items}rest($){return new z0({...this._def,rest:$})}}z0.create=($,f)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new z0({items:$,typeName:C.ZodTuple,rest:null,...v(f)})};class q1 extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.parsedType!==j.object)return N(H,{code:w.invalid_type,expected:j.object,received:H.parsedType}),U;let Q=[],X=this._def.keyType,J=this._def.valueType;for(let W in H.data)Q.push({key:X._parse(new W0(H,W,H.path,W)),value:J._parse(new W0(H,H.data[W],H.path,W)),alwaysSet:W in H.data});if(H.common.async)return p.mergeObjectAsync(f,Q);else return p.mergeObjectSync(f,Q)}get element(){return this._def.valueType}static create($,f,H){if(f instanceof M)return new q1({keyType:$,valueType:f,typeName:C.ZodRecord,...v(H)});return new q1({keyType:Q0.create(),valueType:$,typeName:C.ZodRecord,...v(f)})}}class _1 extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.parsedType!==j.map)return N(H,{code:w.invalid_type,expected:j.map,received:H.parsedType}),U;let Q=this._def.keyType,X=this._def.valueType,J=[...H.data.entries()].map(([W,Y],G)=>{return{key:Q._parse(new W0(H,W,H.path,[G,"key"])),value:X._parse(new W0(H,Y,H.path,[G,"value"]))}});if(H.common.async){let W=new Map;return Promise.resolve().then(async()=>{for(let Y of J){let G=await Y.key,_=await Y.value;if(G.status==="aborted"||_.status==="aborted")return U;if(G.status==="dirty"||_.status==="dirty")f.dirty();W.set(G.value,_.value)}return{status:f.value,value:W}})}else{let W=new Map;for(let Y of J){let{key:G,value:_}=Y;if(G.status==="aborted"||_.status==="aborted")return U;if(G.status==="dirty"||_.status==="dirty")f.dirty();W.set(G.value,_.value)}return{status:f.value,value:W}}}}_1.create=($,f,H)=>{return new _1({valueType:f,keyType:$,typeName:C.ZodMap,...v(H)})};class O0 extends M{_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.parsedType!==j.set)return N(H,{code:w.invalid_type,expected:j.set,received:H.parsedType}),U;let Q=this._def;if(Q.minSize!==null){if(H.data.size<Q.minSize.value)N(H,{code:w.too_small,minimum:Q.minSize.value,type:"set",inclusive:!0,exact:!1,message:Q.minSize.message}),f.dirty()}if(Q.maxSize!==null){if(H.data.size>Q.maxSize.value)N(H,{code:w.too_big,maximum:Q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Q.maxSize.message}),f.dirty()}let X=this._def.valueType;function J(Y){let G=new Set;for(let _ of Y){if(_.status==="aborted")return U;if(_.status==="dirty")f.dirty();G.add(_.value)}return{status:f.value,value:G}}let W=[...H.data.values()].map((Y,G)=>X._parse(new W0(H,Y,H.path,G)));if(H.common.async)return Promise.all(W).then((Y)=>J(Y));else return J(W)}min($,f){return new O0({...this._def,minSize:{value:$,message:D.toString(f)}})}max($,f){return new O0({...this._def,maxSize:{value:$,message:D.toString(f)}})}size($,f){return this.min($,f).max($,f)}nonempty($){return this.min(1,$)}}O0.create=($,f)=>{return new O0({valueType:$,minSize:null,maxSize:null,typeName:C.ZodSet,...v(f)})};class x0 extends M{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:f}=this._processInputParams($);if(f.parsedType!==j.function)return N(f,{code:w.invalid_type,expected:j.function,received:f.parsedType}),U;function H(W,Y){return W1({data:W,path:f.path,errorMaps:[f.common.contextualErrorMap,f.schemaErrorMap,P0(),w0].filter((G)=>!!G),issueData:{code:w.invalid_arguments,argumentsError:Y}})}function Q(W,Y){return W1({data:W,path:f.path,errorMaps:[f.common.contextualErrorMap,f.schemaErrorMap,P0(),w0].filter((G)=>!!G),issueData:{code:w.invalid_return_type,returnTypeError:Y}})}let X={errorMap:f.common.contextualErrorMap},J=f.data;if(this._def.returns instanceof v0){let W=this;return r(async function(...Y){let G=new d([]),_=await W._def.args.parseAsync(Y,X).catch((k)=>{throw G.addIssue(H(Y,k)),G}),S=await Reflect.apply(J,this,_);return await W._def.returns._def.type.parseAsync(S,X).catch((k)=>{throw G.addIssue(Q(S,k)),G})})}else{let W=this;return r(function(...Y){let G=W._def.args.safeParse(Y,X);if(!G.success)throw new d([H(Y,G.error)]);let _=Reflect.apply(J,this,G.data),S=W._def.returns.safeParse(_,X);if(!S.success)throw new d([Q(_,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new x0({...this._def,args:z0.create($).rest(V0.create())})}returns($){return new x0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,f,H){return new x0({args:$?$:z0.create([]).rest(V0.create()),returns:f||V0.create(),typeName:C.ZodFunction,...v(H)})}}class c0 extends M{get schema(){return this._def.getter()}_parse($){let{ctx:f}=this._processInputParams($);return this._def.getter()._parse({data:f.data,path:f.path,parent:f})}}c0.create=($,f)=>{return new c0({getter:$,typeName:C.ZodLazy,...v(f)})};class u0 extends M{_parse($){if($.data!==this._def.value){let f=this._getOrReturnCtx($);return N(f,{received:f.data,code:w.invalid_literal,expected:this._def.value}),U}return{status:"valid",value:$.data}}get value(){return this._def.value}}u0.create=($,f)=>{return new u0({value:$,typeName:C.ZodLiteral,...v(f)})};function h2($,f){return new D0({values:$,typeName:C.ZodEnum,...v(f)})}class D0 extends M{_parse($){if(typeof $.data!=="string"){let f=this._getOrReturnCtx($),H=this._def.values;return N(f,{expected:P.joinValues(H),received:f.parsedType,code:w.invalid_type}),U}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let f=this._getOrReturnCtx($),H=this._def.values;return N(f,{received:f.data,code:w.invalid_enum_value,options:H}),U}return r($.data)}get options(){return this._def.values}get enum(){let $={};for(let f of this._def.values)$[f]=f;return $}get Values(){let $={};for(let f of this._def.values)$[f]=f;return $}get Enum(){let $={};for(let f of this._def.values)$[f]=f;return $}extract($,f=this._def){return D0.create($,{...this._def,...f})}exclude($,f=this._def){return D0.create(this.options.filter((H)=>!$.includes(H)),{...this._def,...f})}}D0.create=h2;class y0 extends M{_parse($){let f=P.getValidEnumValues(this._def.values),H=this._getOrReturnCtx($);if(H.parsedType!==j.string&&H.parsedType!==j.number){let Q=P.objectValues(f);return N(H,{expected:P.joinValues(Q),received:H.parsedType,code:w.invalid_type}),U}if(!this._cache)this._cache=new Set(P.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let Q=P.objectValues(f);return N(H,{received:H.data,code:w.invalid_enum_value,options:Q}),U}return r($.data)}get enum(){return this._def.values}}y0.create=($,f)=>{return new y0({values:$,typeName:C.ZodNativeEnum,...v(f)})};class v0 extends M{unwrap(){return this._def.type}_parse($){let{ctx:f}=this._processInputParams($);if(f.parsedType!==j.promise&&f.common.async===!1)return N(f,{code:w.invalid_type,expected:j.promise,received:f.parsedType}),U;let H=f.parsedType===j.promise?f.data:Promise.resolve(f.data);return r(H.then((Q)=>{return this._def.type.parseAsync(Q,{path:f.path,errorMap:f.common.contextualErrorMap})}))}}v0.create=($,f)=>{return new v0({type:$,typeName:C.ZodPromise,...v(f)})};class Y0 extends M{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===C.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:f,ctx:H}=this._processInputParams($),Q=this._def.effect||null,X={addIssue:(J)=>{if(N(H,J),J.fatal)f.abort();else f.dirty()},get path(){return H.path}};if(X.addIssue=X.addIssue.bind(X),Q.type==="preprocess"){let J=Q.transform(H.data,X);if(H.common.async)return Promise.resolve(J).then(async(W)=>{if(f.value==="aborted")return U;let Y=await this._def.schema._parseAsync({data:W,path:H.path,parent:H});if(Y.status==="aborted")return U;if(Y.status==="dirty")return A0(Y.value);if(f.value==="dirty")return A0(Y.value);return Y});else{if(f.value==="aborted")return U;let W=this._def.schema._parseSync({data:J,path:H.path,parent:H});if(W.status==="aborted")return U;if(W.status==="dirty")return A0(W.value);if(f.value==="dirty")return A0(W.value);return W}}if(Q.type==="refinement"){let J=(W)=>{let Y=Q.refinement(W,X);if(H.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return W};if(H.common.async===!1){let W=this._def.schema._parseSync({data:H.data,path:H.path,parent:H});if(W.status==="aborted")return U;if(W.status==="dirty")f.dirty();return J(W.value),{status:f.value,value:W.value}}else return this._def.schema._parseAsync({data:H.data,path:H.path,parent:H}).then((W)=>{if(W.status==="aborted")return U;if(W.status==="dirty")f.dirty();return J(W.value).then(()=>{return{status:f.value,value:W.value}})})}if(Q.type==="transform")if(H.common.async===!1){let J=this._def.schema._parseSync({data:H.data,path:H.path,parent:H});if(!N0(J))return U;let W=Q.transform(J.value,X);if(W instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:f.value,value:W}}else return this._def.schema._parseAsync({data:H.data,path:H.path,parent:H}).then((J)=>{if(!N0(J))return U;return Promise.resolve(Q.transform(J.value,X)).then((W)=>({status:f.value,value:W}))});P.assertNever(Q)}}Y0.create=($,f,H)=>{return new Y0({schema:$,typeName:C.ZodEffects,effect:f,...v(H)})};Y0.createWithPreprocess=($,f,H)=>{return new Y0({schema:f,effect:{type:"preprocess",transform:$},typeName:C.ZodEffects,...v(H)})};class J0 extends M{_parse($){if(this._getType($)===j.undefined)return r(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}J0.create=($,f)=>{return new J0({innerType:$,typeName:C.ZodOptional,...v(f)})};class L0 extends M{_parse($){if(this._getType($)===j.null)return r(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}L0.create=($,f)=>{return new L0({innerType:$,typeName:C.ZodNullable,...v(f)})};class i0 extends M{_parse($){let{ctx:f}=this._processInputParams($),H=f.data;if(f.parsedType===j.undefined)H=this._def.defaultValue();return this._def.innerType._parse({data:H,path:f.path,parent:f})}removeDefault(){return this._def.innerType}}i0.create=($,f)=>{return new i0({innerType:$,typeName:C.ZodDefault,defaultValue:typeof f.default==="function"?f.default:()=>f.default,...v(f)})};class s0 extends M{_parse($){let{ctx:f}=this._processInputParams($),H={...f,common:{...f.common,issues:[]}},Q=this._def.innerType._parse({data:H.data,path:H.path,parent:{...H}});if(K0(Q))return Q.then((X)=>{return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new d(H.common.issues)},input:H.data})}});else return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new d(H.common.issues)},input:H.data})}}removeCatch(){return this._def.innerType}}s0.create=($,f)=>{return new s0({innerType:$,typeName:C.ZodCatch,catchValue:typeof f.catch==="function"?f.catch:()=>f.catch,...v(f)})};class B1 extends M{_parse($){if(this._getType($)!==j.nan){let H=this._getOrReturnCtx($);return N(H,{code:w.invalid_type,expected:j.nan,received:H.parsedType}),U}return{status:"valid",value:$.data}}}B1.create=($)=>{return new B1({typeName:C.ZodNaN,...v($)})};var Y4=Symbol("zod_brand");class U1 extends M{_parse($){let{ctx:f}=this._processInputParams($),H=f.data;return this._def.type._parse({data:H,path:f.path,parent:f})}unwrap(){return this._def.type}}class z1 extends M{_parse($){let{status:f,ctx:H}=this._processInputParams($);if(H.common.async)return(async()=>{let X=await this._def.in._parseAsync({data:H.data,path:H.path,parent:H});if(X.status==="aborted")return U;if(X.status==="dirty")return f.dirty(),A0(X.value);else return this._def.out._parseAsync({data:X.value,path:H.path,parent:H})})();else{let Q=this._def.in._parseSync({data:H.data,path:H.path,parent:H});if(Q.status==="aborted")return U;if(Q.status==="dirty")return f.dirty(),{status:"dirty",value:Q.value};else return this._def.out._parseSync({data:Q.value,path:H.path,parent:H})}}static create($,f){return new z1({in:$,out:f,typeName:C.ZodPipeline})}}class o0 extends M{_parse($){let f=this._def.innerType._parse($),H=(Q)=>{if(N0(Q))Q.value=Object.freeze(Q.value);return Q};return K0(f)?f.then((Q)=>H(Q)):H(f)}unwrap(){return this._def.innerType}}o0.create=($,f)=>{return new o0({innerType:$,typeName:C.ZodReadonly,...v(f)})};function U2($,f){let H=typeof $==="function"?$(f):typeof $==="string"?{message:$}:$;return typeof H==="string"?{message:H}:H}function M2($,f={},H){if($)return C0.create().superRefine((Q,X)=>{let J=$(Q);if(J instanceof Promise)return J.then((W)=>{if(!W){let Y=U2(f,Q),G=Y.fatal??H??!0;X.addIssue({code:"custom",...Y,fatal:G})}});if(!J){let W=U2(f,Q),Y=W.fatal??H??!0;X.addIssue({code:"custom",...W,fatal:Y})}return});return C0.create()}var G4={object:g.lazycreate},C;(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"})(C||(C={}));var q4=($,f={message:`Input not instance of ${$.name}`})=>M2((H)=>H instanceof $,f),k2=Q0.create,I2=R0.create,_4=B1.create,B4=E0.create,P2=g0.create,z4=U0.create,w4=Y1.create,j4=l0.create,L4=Z0.create,S4=C0.create,N4=V0.create,V4=B0.create,R4=G1.create,E4=X0.create,D4=g.create,b4=g.strictCreate,F4=m0.create,A4=A1.create,U4=n0.create,C4=z0.create,O4=q1.create,v4=_1.create,h4=O0.create,M4=x0.create,k4=c0.create,I4=u0.create,P4=D0.create,K4=y0.create,T4=v0.create,x4=Y0.create,g4=J0.create,l4=L0.create,Z4=Y0.createWithPreprocess,m4=z1.create,n4=()=>k2().optional(),c4=()=>I2().optional(),u4=()=>P2().optional(),y4={string:($)=>Q0.create({...$,coerce:!0}),number:($)=>R0.create({...$,coerce:!0}),boolean:($)=>g0.create({...$,coerce:!0}),bigint:($)=>E0.create({...$,coerce:!0}),date:($)=>U0.create({...$,coerce:!0})};var i4=U;X1();class d0 extends a{zodError;constructor($){super(422,"Validation failed");this.zodError=$;this.name="ValidationException"}toJSON(){return{error:"Validation Error",statusCode:this.statusCode,details:this.zodError.errors.map(($)=>({path:$.path.join("."),message:$.message,code:$.code}))}}}class S${schemaCache=new WeakMap;stats={hits:0,misses:0,validations:0};async validate($,f){this.stats.validations++;try{let H=this.schemaCache.get(f);if(!H)this.stats.misses++,H={schema:f,resultCache:new WeakMap},this.schemaCache.set(f,H);else this.stats.hits++;return await H.schema.parseAsync($)}catch(H){if(H instanceof d)throw new d0(H);throw H}}validateSync($,f){this.stats.validations++;try{let H=this.schemaCache.get(f);if(!H)this.stats.misses++,H={schema:f,resultCache:new WeakMap},this.schemaCache.set(f,H);else this.stats.hits++;return H.schema.parse($)}catch(H){if(H instanceof d)throw new d0(H);throw H}}getCacheStats(){let $=this.stats.validations>0?this.stats.hits/this.stats.validations*100:0;return{...this.stats,hitRate:Math.round($*100)/100}}resetStats(){this.stats={hits:0,misses:0,validations:0}}clearCache(){this.schemaCache=new WeakMap,this.resetStats()}}X1();class N${customHandler;isDevelopment;constructor($){this.customHandler=$,this.isDevelopment=!0}setCustomHandler($){this.customHandler=$}async handle($,f){if(console.log("ErrorHandler.handle called with:",$.constructor.name,$.message),this.customHandler)try{return await this.customHandler($,f)}catch(H){console.error("Custom error handler failed:",H)}if($ instanceof d0)return console.log("Handling as ValidationException"),this.handleValidationException($,f);if($ instanceof a)return console.log("Handling as HTTPException"),this.handleHTTPException($,f);return console.log("Handling as generic error"),this.handleGenericError($,f)}handleValidationException($,f){let H=$.toJSON();if(this.isDevelopment)console.error("Validation Error:",{path:f.req.path,method:f.req.method,details:H.details});return f.json(H,$.statusCode)}handleHTTPException($,f){let H=$.toJSON();if($.statusCode>=500)console.error("HTTP Exception:",{name:$.name,statusCode:$.statusCode,message:$.message,path:f.req.path,method:f.req.method,...this.isDevelopment&&$.stack?{stack:$.stack}:{}});else if(this.isDevelopment)console.warn("HTTP Exception:",{name:$.name,statusCode:$.statusCode,message:$.message,path:f.req.path,method:f.req.method});return f.json(H,$.statusCode)}handleGenericError($,f){console.error("Internal Server Error:",{name:$.name,message:$.message,path:f.req.path,method:f.req.method,stack:$.stack});let H={error:"Internal Server Error",statusCode:500};if(this.isDevelopment){if(H.message=$.message,H.name=$.name,$.stack)H.stack=$.stack.split(`
15
+ `).map((Q)=>Q.trim())}else H.message="An unexpected error occurred";return f.json(H,500)}isDevelopmentMode(){return this.isDevelopment}setDevelopmentMode($){this.isDevelopment=$}}class V${plugins=new Map;installed=new Set;register($){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);this.plugins.set($.name,$)}async install($){let f=this.resolveInstallOrder();for(let H of f)await this.plugins.get(H).install($),this.installed.add(H)}isInstalled($){return this.installed.has($)}getPlugin($){return this.plugins.get($)}getPluginNames(){return Array.from(this.plugins.keys())}resolveInstallOrder(){let $=new Set,f=new Set,H=[],Q=(X,J=[])=>{if(f.has(X)){let Y=[...J,X].join(" -> ");throw Error(`Circular dependency detected in plugins: ${Y}`)}if($.has(X))return;f.add(X);let W=this.plugins.get(X);if(!W)throw Error(`Plugin "${X}" is not registered`);if(W.dependencies)for(let Y of W.dependencies){if(!this.plugins.has(Y))throw Error(`Plugin "${X}" depends on "${Y}" which is not registered`);Q(Y,[...J,X])}f.delete(X),$.add(X),H.push(X)};for(let X of this.plugins.keys())Q(X);return H}}function T2($){let{origin:f="*",methods:H=["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:Q=["Content-Type","Authorization"],exposedHeaders:X=[],credentials:J=!1,maxAge:W=86400}=$||{};return async(Y,G)=>{let _=Y.req.header("origin"),S=Y.req.method,A=null;if(typeof f==="string")A=f;else if(Array.isArray(f)){if(_&&f.includes(_))A=_}else if(typeof f==="function"){if(_&&f(_))A=_}if(A)Y.header("Access-Control-Allow-Origin",A);if(J)Y.header("Access-Control-Allow-Credentials","true");if(X.length>0)Y.header("Access-Control-Expose-Headers",X.join(", "));if(S==="OPTIONS")return Y.header("Access-Control-Allow-Methods",H.join(", ")),Y.header("Access-Control-Allow-Headers",Q.join(", ")),Y.header("Access-Control-Max-Age",W.toString()),Y.body(null,204);await G()}}function x2($){let{windowMs:f=60000,max:H=100,keyGenerator:Q=(W)=>{return W.req.header("x-forwarded-for")||W.req.header("x-real-ip")||"unknown"}}=$,X=new Map,J=setInterval(()=>{let W=Date.now();for(let[Y,G]of X.entries())if(W>G.resetTime)X.delete(Y)},f);if(typeof process<"u"&&process.on)process.on("exit",()=>clearInterval(J));return async(W,Y)=>{let G=Q(W),_=Date.now(),S=X.get(G);if(!S||_>S.resetTime)X.set(G,{count:1,resetTime:_+f}),W.header("X-RateLimit-Limit",H.toString()),W.header("X-RateLimit-Remaining",(H-1).toString()),W.header("X-RateLimit-Reset",new Date(_+f).toISOString()),await Y();else if(S.count<H)S.count++,W.header("X-RateLimit-Limit",H.toString()),W.header("X-RateLimit-Remaining",(H-S.count).toString()),W.header("X-RateLimit-Reset",new Date(S.resetTime).toISOString()),await Y();else{let A=Math.ceil((S.resetTime-_)/1000);return W.header("X-RateLimit-Limit",H.toString()),W.header("X-RateLimit-Remaining","0"),W.header("X-RateLimit-Reset",new Date(S.resetTime).toISOString()),W.header("Retry-After",A.toString()),W.json({error:"Too Many Requests",message:`Rate limit exceeded. Please try again in ${A} seconds.`,retryAfter:A},429)}}}function g2($){let{threshold:f=1024,level:H=6}=$||{};return async(Q,X)=>{await X();let J=Q.res;if(!J)return;let W=J.headers.get("content-type")||"",Y=J.headers.get("content-length"),G=Q.req.header("accept-encoding")||"";if(!["text/","application/json","application/javascript","application/xml","application/x-www-form-urlencoded"].some((h)=>W.toLowerCase().includes(h)))return;if(Y&&parseInt(Y)<f)return;if(J.headers.get("content-encoding"))return;let A=await J.arrayBuffer();if(A.byteLength<f)return;let k=null,Z=null;if(G.includes("br")&&typeof CompressionStream<"u")try{let h=new CompressionStream("deflate"),T=h.writable.getWriter();T.write(new Uint8Array(A)),T.close();let m=h.readable.getReader(),o=[];while(!0){let{done:s,value:t}=await m.read();if(s)break;o.push(t)}let e=o.reduce((s,t)=>s+t.length,0),i=new Uint8Array(e),$0=0;for(let s of o)i.set(s,$0),$0+=s.length;k=i,Z="deflate"}catch(h){k=null}if(!k&&G.includes("gzip")&&typeof CompressionStream<"u")try{let h=new CompressionStream("gzip"),T=h.writable.getWriter();T.write(new Uint8Array(A)),T.close();let m=h.readable.getReader(),o=[];while(!0){let{done:s,value:t}=await m.read();if(s)break;o.push(t)}let e=o.reduce((s,t)=>s+t.length,0),i=new Uint8Array(e),$0=0;for(let s of o)i.set(s,$0),$0+=s.length;k=i,Z="gzip"}catch(h){k=null}if(k&&Z&&k.byteLength<A.byteLength){let h=new Headers(J.headers);return h.set("content-encoding",Z),h.set("content-length",k.byteLength.toString()),h.delete("content-length"),new Response(k,{status:J.status,statusText:J.statusText,headers:h})}}}class D${hono;metadata;container;validator;errorHandler;compiler;pluginManager;config;compiled=!1;globalMiddleware=[];groupPrefix="";constructor($){if(this.config={adapter:"hono",title:"Veloce-TS API",version:"1.0.0",docs:!0,...$},this.hono=new u1,this.metadata=new S0,this.container=new H$,this.validator=new S$,this.errorHandler=new N$,this.pluginManager=new V$,this.compiler=new z$(this.hono,this.metadata,this.container,this.validator,this.errorHandler),this.config.cors)if(this.config.cors===!0)this.useCors();else this.useCors(this.config.cors)}include($){let f=S0.getControllerMetadata($);if(f)this.metadata.registerController($,f);let H=S0.getRouteMethods($);for(let Q of H){let X=S0.getRouteMetadata($.prototype,Q),J=S0.getParameterMetadata($.prototype,Q),W=S0.getDependencyMetadata($.prototype,Q);if(X&&X.method&&X.path!==void 0){let Y=f?.prefix||"",G=this.normalizePath(Y,X.path);this.metadata.registerRoute({target:$,propertyKey:Q,method:X.method,path:G,middleware:[...f?.middleware||[],...X.middleware||[]],parameters:J||X.parameters||[],dependencies:W||X.dependencies||[],responses:X.responses||[],docs:X.docs})}}}get($,f){this.registerFunctionalRoute("GET",$,f)}post($,f){this.registerFunctionalRoute("POST",$,f)}put($,f){this.registerFunctionalRoute("PUT",$,f)}delete($,f){this.registerFunctionalRoute("DELETE",$,f)}patch($,f){this.registerFunctionalRoute("PATCH",$,f)}route($){return new c2(this,$)}group($,f){let H=this.groupPrefix;this.groupPrefix=this.normalizePath(this.groupPrefix,$),f(),this.groupPrefix=H}registerFunctionalRoute($,f,H){let Q=this.normalizePath(this.groupPrefix,f),X={target:n2,propertyKey:`${$.toLowerCase()}_${Q}`,method:$,path:Q,middleware:H.middleware||[],parameters:this.extractParametersFromSchema(H.schema),dependencies:[],responses:H.responses||[],docs:H.docs,handler:H.handler};this.metadata.registerRoute(X)}extractParametersFromSchema($){let f=[],H=0;if($?.body)f.push({index:H++,type:"body",schema:$.body,required:!0});if($?.query)f.push({index:H++,type:"query",schema:$.query,required:!1});if($?.params)f.push({index:H++,type:"param",schema:$.params,required:!0});if($?.headers)f.push({index:H++,type:"header",schema:$.headers,required:!1});return f}use($){this.globalMiddleware.push($),this.hono.use("*",$)}useCors($){let f=T2($);this.use(f)}useRateLimit($){let f=x2($);this.use(f)}useCompression($){let f=g2($);this.use(f)}usePlugin($){this.pluginManager.register($)}getPluginManager(){return this.pluginManager}onError($){this.errorHandler.setCustomHandler($)}getErrorHandler(){return this.errorHandler}normalizePath(...$){let f=$.filter((H)=>H!=="").join("/").replace(/\/+/g,"/").replace(/\/$/,"");return f.startsWith("/")?f:`/${f}`}getHono(){return this.hono}getMetadata(){return this.metadata}getContainer(){return this.container}getCompiler(){return this.compiler}getConfig(){return this.config}isCompiled(){return this.compiled}markCompiled(){this.compiled=!0}async compile(){if(this.compiled){console.warn("Routes have already been compiled. Skipping compilation.");return}await this.pluginManager.install(this),this.compiler.compile(),this.compiled=!0}async listen($,f){if(!this.compiled)await this.compile();return this.createAdapter().listen($,f)}createAdapter(){let $=this.config.adapter||"hono";switch($){case"hono":{let{HonoAdapter:f}=w1(E$);return new f(this.hono)}case"express":{let{ExpressAdapter:f}=w1(m2);return new f(this)}case"native":{let{HonoAdapter:f}=w1(E$);return new f(this.hono)}default:throw Error(`Unknown adapter type: ${$}. Supported adapters: 'hono', 'express', 'native'`)}}}class n2{}class c2{app;path;constructor($,f){this.app=$;this.path=f}get($){return this.app.get(this.path,$),this}post($){return this.app.post(this.path,$),this}put($){return this.app.put(this.path,$),this}delete($){return this.app.delete(this.path,$),this}patch($){return this.app.patch(this.path,$),this}}function b$($){let f={docs:!1,cors:!1,...$};return new D$(f)}function u2($,f,H,Q){let X=$.getContainer(),J=typeof H==="function"?H:()=>H;X.register(f,{scope:Q?.scope||"singleton",factory:J})}function F$($){return new a0($)}async function y2($,f){let H=b$(f);await $(H),await H.compile();let Q=F$(H);return{app:H,client:Q}}function i2($){$.getContainer().clear()}
16
16
 
17
- //# debugId=22E2EAB67A9B40BB64756E2164756E21
17
+ //# debugId=288216597F43BB5F64756E2164756E21