@vibecontrols/agent 2026.824.1 → 2026.1124.1

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 (183) hide show
  1. package/dist/agent-config-v9d7gcz0.js +2 -0
  2. package/dist/agent-ready-tracker-mewxehg9.js +2 -0
  3. package/dist/app-k7z7tjem.js +2 -0
  4. package/dist/autostart.cmd-ahet7b1t.js +2 -0
  5. package/dist/bootstrap-workspace-3pb8qjsh.js +2 -0
  6. package/dist/bootstrap.service-9m7m1ksa.js +2 -0
  7. package/dist/bridge-client-xvqy3n15.js +2 -0
  8. package/dist/cli.js +2 -2
  9. package/dist/daemon-profile-sg8fp50z.js +2 -0
  10. package/dist/finalize-retry-handle-registry-z9mbbjmj.js +2 -0
  11. package/dist/finalize-retry-worker-az74f2qv.js +2 -0
  12. package/dist/gateway-client-ermpz52n.js +2 -0
  13. package/dist/getMachineId-bsd-4w1wmcjv.js +2 -0
  14. package/dist/getMachineId-darwin-kejwz8w5.js +3 -0
  15. package/dist/getMachineId-linux-mpm53wat.js +2 -0
  16. package/dist/getMachineId-unsupported-54seyw5v.js +2 -0
  17. package/dist/getMachineId-win-cva7ghz9.js +2 -0
  18. package/dist/highlights-3nz7pbkh.js +2 -0
  19. package/dist/highlights-6dgztt5d.js +2 -0
  20. package/dist/highlights-jq0g1547.js +2 -0
  21. package/dist/highlights-yc7cwzcr.js +2 -0
  22. package/dist/highlights-z2sw1kpq.js +2 -0
  23. package/dist/index-01fp85ft.js +171 -0
  24. package/dist/index-06bmw4xf.js +83 -0
  25. package/dist/index-0gmhd3hs.js +4 -0
  26. package/dist/index-0qjbnyg4.js +21 -0
  27. package/dist/index-2r6cmxxz.js +9 -0
  28. package/dist/index-2vcxt38h.js +3 -0
  29. package/dist/index-3b5xejjs.js +5 -0
  30. package/dist/index-3cbesatx.js +178 -0
  31. package/dist/index-4q8y6k1e.js +26 -0
  32. package/dist/index-4z1y39jt.js +3 -0
  33. package/dist/index-5021rk8n.js +3 -0
  34. package/dist/index-652f9scs.js +4 -0
  35. package/dist/index-76m37yd8.js +22 -0
  36. package/dist/index-7f2k4g6q.js +8 -0
  37. package/dist/index-7gk1x74m.js +15 -0
  38. package/dist/index-7wben1jx.js +3 -0
  39. package/dist/index-8rbhm4g8.js +7 -0
  40. package/dist/index-9bj65n3s.js +13 -0
  41. package/dist/index-9xrhb68w.js +14 -0
  42. package/dist/index-a0vx2zyx.js +3 -0
  43. package/dist/index-aav1drxa.js +158 -0
  44. package/dist/index-akk3rxnn.js +4 -0
  45. package/dist/index-b3v08awy.js +3 -0
  46. package/dist/index-byerrz46.js +3 -0
  47. package/dist/index-c4whjk5r.js +3 -0
  48. package/dist/index-cy97asyh.js +133 -0
  49. package/dist/index-d59kp6zr.js +3 -0
  50. package/dist/index-haww9jpq.js +27 -0
  51. package/dist/index-hsrt2v87.js +2 -0
  52. package/dist/index-jmx5awkj.js +3 -0
  53. package/dist/index-jnxjjx2y.js +3 -0
  54. package/dist/index-kwhx023z.js +11 -0
  55. package/dist/index-m942hydk.js +116 -0
  56. package/dist/index-mmx2kp76.js +16 -0
  57. package/dist/index-p0bbp16g.js +11 -0
  58. package/dist/index-qe3xpt41.js +3 -0
  59. package/dist/index-qfxwk38p.js +82 -0
  60. package/dist/index-ss5gez2p.js +2 -0
  61. package/dist/index-t5cfkz1e.js +4 -0
  62. package/dist/index-t6p4szqx.js +5 -0
  63. package/dist/index-tahaxp6n.js +3 -0
  64. package/dist/index-v16qz1fa.js +3 -0
  65. package/dist/index-vtsd74g0.js +9 -0
  66. package/dist/index-w0m3jm0s.js +408 -0
  67. package/dist/index-w4jqdhc2.js +5 -0
  68. package/dist/index-wr888ydc.js +17 -0
  69. package/dist/index-xtd0j8ve.js +3 -0
  70. package/dist/index-ywnfz6nm.js +3 -0
  71. package/dist/index.js +3 -3
  72. package/dist/injections-h25c1fmk.js +2 -0
  73. package/dist/interactive-vbz68zh5.js +2 -0
  74. package/dist/key.cmd-f6rjvjy8.js +2 -0
  75. package/dist/log-shipper-0erbwn0q.js +2 -0
  76. package/dist/path-utils-r4df8d3w.js +2 -0
  77. package/dist/plugin-system-kvg955t3.js +2 -0
  78. package/dist/prereqs-runner-gca0bytz.js +2 -0
  79. package/dist/profile-mount-s4mc1x18.js +2 -0
  80. package/dist/prune-stale-shims-4nqtv0xt.js +2 -0
  81. package/dist/register-core-31wm1d8m.js +2 -0
  82. package/dist/secondary-profile-attach-95kmnrhf.js +2 -0
  83. package/dist/subprocess-4gg77skg.js +2 -0
  84. package/dist/telemetry-nmtywcba.js +2 -0
  85. package/dist/tree-sitter-javascript-rfadfcwb.js +2 -0
  86. package/dist/tree-sitter-markdown-gkyb2qez.js +2 -0
  87. package/dist/tree-sitter-markdown_inline-xzttqkvb.js +2 -0
  88. package/dist/tree-sitter-typescript-4z897028.js +2 -0
  89. package/dist/tree-sitter-zig-y6n7djp6.js +2 -0
  90. package/dist/tunnel-bootstrap-rym0b0x5.js +2 -0
  91. package/package.json +10 -9
  92. package/dist/agent-config-5b0avmy6.js +0 -2
  93. package/dist/agent-ready-tracker-ez6r9djg.js +0 -2
  94. package/dist/app-hkt10ta3.js +0 -2
  95. package/dist/autostart.cmd-fdcdqrr2.js +0 -2
  96. package/dist/bootstrap-workspace-t5fyq07m.js +0 -2
  97. package/dist/bootstrap.service-nxhkrsf1.js +0 -2
  98. package/dist/bridge-client-bgkr7bcn.js +0 -2
  99. package/dist/daemon-profile-j2wt35x8.js +0 -2
  100. package/dist/esm-n9r8p5n2.js +0 -2
  101. package/dist/finalize-retry-handle-registry-fvm4gm8s.js +0 -2
  102. package/dist/finalize-retry-worker-wb8wj1yw.js +0 -2
  103. package/dist/gateway-client-6dqagbg4.js +0 -2
  104. package/dist/getMachineId-bsd-fgatzdd7.js +0 -2
  105. package/dist/getMachineId-darwin-gt8j2jw2.js +0 -3
  106. package/dist/getMachineId-linux-bcz4rr1x.js +0 -2
  107. package/dist/getMachineId-unsupported-079qwwb4.js +0 -2
  108. package/dist/getMachineId-win-2hk4e8bg.js +0 -2
  109. package/dist/highlights-0gfz787m.js +0 -2
  110. package/dist/highlights-86sbx76f.js +0 -2
  111. package/dist/highlights-n55f5jnk.js +0 -2
  112. package/dist/highlights-tbmszdr7.js +0 -2
  113. package/dist/highlights-wm2cs773.js +0 -2
  114. package/dist/index-06es0fmw.js +0 -10
  115. package/dist/index-0d4wfjbt.js +0 -171
  116. package/dist/index-29fmptfn.js +0 -13
  117. package/dist/index-2q2jadag.js +0 -11
  118. package/dist/index-2sn36kaj.js +0 -7
  119. package/dist/index-3p4n7nwg.js +0 -83
  120. package/dist/index-3tf12pw3.js +0 -3
  121. package/dist/index-4gsn3d9r.js +0 -26
  122. package/dist/index-54mmh1eb.js +0 -4
  123. package/dist/index-6jzsthh9.js +0 -3
  124. package/dist/index-7wejfjj9.js +0 -5
  125. package/dist/index-8q19ryt2.js +0 -28
  126. package/dist/index-8xh8m2z7.js +0 -8
  127. package/dist/index-a8n6s2ae.js +0 -2
  128. package/dist/index-b16y8wyz.js +0 -15
  129. package/dist/index-bv1z3fxw.js +0 -3
  130. package/dist/index-cs78wq6y.js +0 -3
  131. package/dist/index-df19rrbe.js +0 -5
  132. package/dist/index-dx9hjdp4.js +0 -178
  133. package/dist/index-ea42kfvk.js +0 -5
  134. package/dist/index-ekr40gvh.js +0 -3
  135. package/dist/index-evnbrmdf.js +0 -4
  136. package/dist/index-ggxs7nwz.js +0 -3
  137. package/dist/index-gz5t0vvc.js +0 -4
  138. package/dist/index-hey6w5m0.js +0 -3
  139. package/dist/index-hp8jrj6j.js +0 -3
  140. package/dist/index-hrfkzecw.js +0 -3
  141. package/dist/index-hwpmdq5z.js +0 -4
  142. package/dist/index-hz5cy6vz.js +0 -11
  143. package/dist/index-jbxh0ffn.js +0 -407
  144. package/dist/index-js2r0men.js +0 -9
  145. package/dist/index-k3jkzj3k.js +0 -9
  146. package/dist/index-kteawn2b.js +0 -3
  147. package/dist/index-mbhq916m.js +0 -3
  148. package/dist/index-mxc61yr1.js +0 -3
  149. package/dist/index-pnk33bjw.js +0 -116
  150. package/dist/index-qdbxvcwr.js +0 -17
  151. package/dist/index-qqq9qyy6.js +0 -21
  152. package/dist/index-rmh8pff5.js +0 -3
  153. package/dist/index-sspydg85.js +0 -15
  154. package/dist/index-tk81f249.js +0 -3
  155. package/dist/index-vjdg5qb2.js +0 -2
  156. package/dist/index-vkrf8kzp.js +0 -158
  157. package/dist/index-vnxqna70.js +0 -16
  158. package/dist/index-w2j4ttsx.js +0 -130
  159. package/dist/index-w7gctzhm.js +0 -83
  160. package/dist/index-wj5hx7gq.js +0 -4
  161. package/dist/index-x4eaagvr.js +0 -3
  162. package/dist/index-xjr60th0.js +0 -3
  163. package/dist/index-xtbppqnv.js +0 -3
  164. package/dist/index-zr9rmjyp.js +0 -3
  165. package/dist/injections-2g0zh0bq.js +0 -2
  166. package/dist/interactive-08vyaapn.js +0 -2
  167. package/dist/key.cmd-642xcxb4.js +0 -2
  168. package/dist/log-shipper-9xfnjwr6.js +0 -2
  169. package/dist/path-utils-g449hqvm.js +0 -2
  170. package/dist/plugin-system-gpzcch00.js +0 -2
  171. package/dist/prereqs-runner-re9f51fp.js +0 -2
  172. package/dist/profile-mount-txvgkaz8.js +0 -2
  173. package/dist/prune-stale-shims-vs6a07tb.js +0 -2
  174. package/dist/register-core-e0ha52yw.js +0 -2
  175. package/dist/secondary-profile-attach-m9x9e7py.js +0 -2
  176. package/dist/subprocess-zcgpccp1.js +0 -2
  177. package/dist/telemetry-k6em3vy2.js +0 -2
  178. package/dist/tree-sitter-javascript-qh90w7td.js +0 -2
  179. package/dist/tree-sitter-markdown-favzteb6.js +0 -2
  180. package/dist/tree-sitter-markdown_inline-x2726t9j.js +0 -2
  181. package/dist/tree-sitter-typescript-m7ep8z1h.js +0 -2
  182. package/dist/tree-sitter-zig-3vsxg5wh.js +0 -2
  183. package/dist/tunnel-bootstrap-y8dczezc.js +0 -2
@@ -0,0 +1,408 @@
1
+ // @bun
2
+ import{P,a,Hi}from"./index-a0vx2zyx.js";var hi=a(function(_C,Ou){var xu=12,Fh=0,Na=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function Eh(e){var t=e.indexOf("%");if(t===-1)return e;var n=e.length,o="",i=0,s=0,c=t,f=xu;while(t>-1&&t<n){var u=Iu(e[t+1],4),l=Iu(e[t+2],0),d=u|l,y=Na[d];if(f=Na[256+f+y],s=s<<6|d&Na[364+y],f===xu)o+=e.slice(i,c),o+=s<=65535?String.fromCharCode(s):String.fromCharCode(55232+(s>>10),56320+(s&1023)),s=0,i=t+3,t=c=e.indexOf("%",i);else if(f===Fh)return null;else{if(t+=3,t<n&&e.charCodeAt(t)===37)continue;return null}}return o+e.slice(i)}var Ch={"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function Iu(e,t){var n=Ch[e];return n===void 0?255:n<<t}Ou.exports=Eh});var ud=a(function(ad){Object.defineProperty(ad,"__esModule",{value:!0});ad.parseCookie=id;ad.parse=id;ad.stringifyCookie=Dx;ad.stringifySetCookie=vs;ad.serialize=vs;ad.parseSetCookie=Bx;ad.stringifySetCookie=vs;ad.serialize=vs;var nd=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,od=/^[\u0021-\u003A\u003C-\u007E]*$/,Nx=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,Ux=/^[\u0020-\u003A\u003D-\u007E]*$/,Mx=/^-?\d+$/,Kx=Object.prototype.toString,Lx=(()=>{let e=function(){};return e.prototype=Object.create(null),e})();function id(e,t){let n=new Lx,o=e.length;if(o<2)return n;let i=t?.decode||sd,s=0;do{let c=rc(e,s,o);if(c===-1)break;let f=tc(e,s,o);if(c>f){s=e.lastIndexOf(";",c-1)+1;continue}let u=wn(e,s,c);if(n[u]===void 0)n[u]=i(wn(e,c+1,f));s=f+1}while(s<o);return n}function Dx(e,t){let n=t?.encode||encodeURIComponent,o=[];for(let i of Object.keys(e)){let s=e[i];if(s===void 0)continue;if(!nd.test(i))throw TypeError(`cookie name is invalid: ${i}`);let c=n(s);if(!od.test(c))throw TypeError(`cookie val is invalid: ${s}`);o.push(`${i}=${c}`)}return o.join("; ")}function vs(e,t,n){let o=typeof e==="object"?e:{...n,name:e,value:String(t)},s=(typeof t==="object"?t:n)?.encode||encodeURIComponent;if(!nd.test(o.name))throw TypeError(`argument name is invalid: ${o.name}`);let c=o.value?s(o.value):"";if(!od.test(c))throw TypeError(`argument val is invalid: ${o.value}`);let f=o.name+"="+c;if(o.maxAge!==void 0){if(!Number.isInteger(o.maxAge))throw TypeError(`option maxAge is invalid: ${o.maxAge}`);f+="; Max-Age="+o.maxAge}if(o.domain){if(!Nx.test(o.domain))throw TypeError(`option domain is invalid: ${o.domain}`);f+="; Domain="+o.domain}if(o.path){if(!Ux.test(o.path))throw TypeError(`option path is invalid: ${o.path}`);f+="; Path="+o.path}if(o.expires){if(!vx(o.expires)||!Number.isFinite(o.expires.valueOf()))throw TypeError(`option expires is invalid: ${o.expires}`);f+="; Expires="+o.expires.toUTCString()}if(o.httpOnly)f+="; HttpOnly";if(o.secure)f+="; Secure";if(o.partitioned)f+="; Partitioned";if(o.priority)switch(typeof o.priority==="string"?o.priority.toLowerCase():void 0){case"low":f+="; Priority=Low";break;case"medium":f+="; Priority=Medium";break;case"high":f+="; Priority=High";break;default:throw TypeError(`option priority is invalid: ${o.priority}`)}if(o.sameSite)switch(typeof o.sameSite==="string"?o.sameSite.toLowerCase():o.sameSite){case!0:case"strict":f+="; SameSite=Strict";break;case"lax":f+="; SameSite=Lax";break;case"none":f+="; SameSite=None";break;default:throw TypeError(`option sameSite is invalid: ${o.sameSite}`)}return f}function Bx(e,t){let n=t?.decode||sd,o=e.length,i=tc(e,0,o),s=rc(e,0,i),c=s===-1?{name:"",value:n(wn(e,0,i))}:{name:wn(e,0,s),value:n(wn(e,s+1,i))},f=i+1;while(f<o){let u=tc(e,f,o),l=rc(e,f,u),d=l===-1?wn(e,f,u):wn(e,f,l),y=l===-1?void 0:wn(e,l+1,u);switch(d.toLowerCase()){case"httponly":c.httpOnly=!0;break;case"secure":c.secure=!0;break;case"partitioned":c.partitioned=!0;break;case"domain":c.domain=y;break;case"path":c.path=y;break;case"max-age":if(y&&Mx.test(y))c.maxAge=Number(y);break;case"expires":if(!y)break;let b=new Date(y);if(Number.isFinite(b.valueOf()))c.expires=b;break;case"priority":if(!y)break;let p=y.toLowerCase();if(p==="low"||p==="medium"||p==="high")c.priority=p;break;case"samesite":if(!y)break;let g=y.toLowerCase();if(g==="lax"||g==="strict"||g==="none")c.sameSite=g;break}f=u+1}return c}function tc(e,t,n){let o=e.indexOf(";",t);return o===-1?n:o}function rc(e,t,n){let o=e.indexOf("=",t);return o<n?o:-1}function wn(e,t,n){let o=t,i=n;do{let s=e.charCodeAt(o);if(s!==32&&s!==9)break}while(++o<i);while(i>o){let s=e.charCodeAt(i-1);if(s!==32&&s!==9)break;i--}return e.slice(o,i)}function sd(e){if(e.indexOf("%")===-1)return e;try{return decodeURIComponent(e)}catch(t){return e}}function vx(e){return Kx.call(e)==="[object Date]"}});var ka={};Hi(ka,{Any:()=>gn,Argument:()=>Jc,Array:()=>Io,AsyncIterator:()=>Oo,Awaited:()=>Eo,BigInt:()=>So,Boolean:()=>rs,Capitalize:()=>Gf,Composite:()=>gf,Const:()=>bf,Constructor:()=>Ro,ConstructorParameters:()=>xf,Date:()=>as,Enum:()=>If,Exclude:()=>jo,Extends:()=>Po,Extract:()=>ko,Function:()=>Sr,Index:()=>bn,InstanceType:()=>Df,Instantiate:()=>vf,Integer:()=>Hf,Intersect:()=>mt,Iterator:()=>Fo,KeyOf:()=>Co,Literal:()=>de,Lowercase:()=>zf,Mapped:()=>df,Module:()=>cu,Never:()=>Z,Not:()=>fu,Null:()=>cs,Number:()=>Vt,Object:()=>he,Omit:()=>On,Optional:()=>pt,Parameters:()=>uu,Partial:()=>No,Pick:()=>Rn,Promise:()=>is,Readonly:()=>wt,ReadonlyOptional:()=>ys,Record:()=>hs,Recursive:()=>du,Ref:()=>Gt,RegExp:()=>lu,Required:()=>Uo,Rest:()=>pu,ReturnType:()=>mu,String:()=>fr,Symbol:()=>fs,TemplateLiteral:()=>ns,Transform:()=>gu,Tuple:()=>qt,Uint8Array:()=>ds,Uncapitalize:()=>Jf,Undefined:()=>us,Union:()=>le,Unknown:()=>xn,Unsafe:()=>xs,Uppercase:()=>Wf,Void:()=>bu});var lo=(e,t)=>{let n=t?.length?{}:null;if(n)for(let o of t)n[o.part.charCodeAt(0)]=o;return{part:e,store:null,inert:n,params:null,wildcardStore:null}},$c=(e,t)=>({...e,part:t}),wc=(e)=>({name:e,store:null,inert:null});class Tn{config;root={};history=[];deferred=[];constructor(e={}){if(this.config=e,e.lazy)this.find=this.lazyFind;if(e.onParam&&!Array.isArray(e.onParam))this.config.onParam=[this.config.onParam]}static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/(\/:\w+\?)/g};lazyFind=(e,t)=>{if(!this.config.lazy)return this.find;return this.build(),this.find(e,t)};build(){if(!this.config.lazy)return;for(let[e,t,n]of this.deferred)this.add(e,t,n,{lazy:!1,ignoreHistory:!0});this.deferred=[],this.find=(e,t)=>{let n=this.root[e];if(!n)return null;return Ki(t,t.length,n,0,this.config.onParam)}}add(e,t,n,{ignoreError:o=!1,ignoreHistory:i=!1,lazy:s=this.config.lazy}={}){if(s)return this.find=this.lazyFind,this.deferred.push([e,t,n]),n;if(typeof t!=="string")throw TypeError("Route path must be a string");if(t==="")t="/";else if(t[0]!=="/")t=`/${t}`;let c=t[t.length-1]==="*",f=t.match(Tn.regex.optionalParams);if(f){let b=t.replaceAll("?","");this.add(e,b,n,{ignoreError:o,ignoreHistory:i,lazy:s});for(let p=0;p<f.length;p++){let g=t.replace(f[p],"");this.add(e,g,n,{ignoreError:!0,ignoreHistory:i,lazy:s})}return n}if(f)t=t.replaceAll("?","");if(this.history.find(([b,p,g])=>b===e&&p===t))return n;if(c||f&&t.charCodeAt(t.length-1)===63)t=t.slice(0,-1);if(!i)this.history.push([e,t,n]);let u=t.split(Tn.regex.static),l=t.match(Tn.regex.params)||[];if(u[u.length-1]==="")u.pop();let d;if(!this.root[e])d=this.root[e]=lo("/");else d=this.root[e];let y=0;for(let b=0;b<u.length;++b){let p=u[b];if(b>0){let g=l[y++].slice(1);if(d.params===null)d.params=wc(g);else if(d.params.name!==g)if(o)return n;else throw Error(`Cannot create route "${t}" with parameter "${g}" because a route already exists with a different parameter name ("${d.params.name}") in the same location`);let R=d.params;if(R.inert===null){d=R.inert=lo(p);continue}d=R.inert}for(let g=0;;){if(g===p.length){if(g<d.part.length){let R=$c(d,d.part.slice(g));Object.assign(d,lo(p,[R]))}break}if(g===d.part.length){if(d.inert===null)d.inert={};let R=d.inert[p.charCodeAt(g)];if(R){d=R,p=p.slice(g),g=0;continue}let L=lo(p.slice(g));d.inert[p.charCodeAt(g)]=L,d=L;break}if(p[g]!==d.part[g]){let R=$c(d,d.part.slice(g)),L=lo(p.slice(g));Object.assign(d,lo(d.part.slice(0,g),[R,L])),d=L;break}++g}}if(y<l.length){let b=l[y].slice(1);if(d.params===null)d.params=wc(b);else if(d.params.name!==b)if(o)return n;else throw Error(`Cannot create route "${t}" with parameter "${b}" because a route already exists with a different parameter name ("${d.params.name}") in the same location`);if(d.params.store===null)d.params.store=n;return d.params.store}if(c){if(d.wildcardStore===null)d.wildcardStore=n;return d.wildcardStore}if(d.store===null)d.store=n;return d.store}find(e,t){let n=this.root[e];if(!n)return null;return Ki(t,t.length,n,0,this.config.onParam)}}var Ki=(e,t,n,o,i)=>{let s=n.part,c=s.length,f=o+c;if(c>1){if(f>t)return null;if(c<15){for(let u=1,l=o+1;u<c;++u,++l)if(s.charCodeAt(u)!==e.charCodeAt(l))return null}else if(e.slice(o,f)!==s)return null}if(f===t){if(n.store!==null)return{store:n.store,params:{}};if(n.wildcardStore!==null)return{store:n.wildcardStore,params:{"*":""}};return null}if(n.inert!==null){let u=n.inert[e.charCodeAt(f)];if(u!==void 0){let l=Ki(e,t,u,f,i);if(l!==null)return l}}if(n.params!==null){let{store:u,name:l,inert:d}=n.params,y=e.indexOf("/",f);if(y!==f){if(y===-1||y>=t){if(u!==null){let b={};if(b[l]=e.substring(f,t),i)for(let p=0;p<i.length;p++){let g=i[p](b[l],l);if(g!==void 0)b[l]=g}return{store:u,params:b}}}else if(d!==null){let b=Ki(e,t,d,y,i);if(b!==null){if(b.params[l]=e.substring(f,y),i)for(let p=0;p<i.length;p++){let g=i[p](b.params[l],l);if(g!==void 0)b.params[l]=g}return b}}}}if(n.wildcardStore!==null)return{store:n.wildcardStore,params:{"*":e.substring(f,t)}};return null};function Ac(e){return Fe(e)&&!We(e)&&!fn(e)&&Symbol.asyncIterator in e}function We(e){return Array.isArray(e)}function Li(e){return typeof e==="bigint"}function cn(e){return typeof e==="boolean"}function po(e){return e instanceof globalThis.Date}function Sc(e){return typeof e==="function"}function Fc(e){return Fe(e)&&!We(e)&&!fn(e)&&Symbol.iterator in e}function Ec(e){return e===null}function jt(e){return typeof e==="number"}function Fe(e){return typeof e==="object"&&e!==null}function Di(e){return e instanceof globalThis.RegExp}function Oe(e){return typeof e==="string"}function Cc(e){return typeof e==="symbol"}function fn(e){return e instanceof globalThis.Uint8Array}function Re(e){return e===void 0}function Vd(e){return e.map((t)=>Bi(t))}function qd(e){return new Date(e.getTime())}function _d(e){return new Uint8Array(e)}function Gd(e){return new RegExp(e.source,e.flags)}function zd(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Bi(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Bi(e[n]);return t}function Bi(e){return We(e)?Vd(e):po(e)?qd(e):fn(e)?_d(e):Di(e)?Gd(e):Fe(e)?zd(e):e}function Ee(e){return Bi(e)}function mo(e,t){return t===void 0?Ee(e):Ee({...t,...e})}function vi(e){return be(e)&&globalThis.Symbol.asyncIterator in e}function Vi(e){return be(e)&&globalThis.Symbol.iterator in e}function qi(e){return e instanceof globalThis.Promise}function $r(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function Tc(e){return e instanceof globalThis.Map}function Pc(e){return e instanceof globalThis.Set}function jc(e){return globalThis.ArrayBuffer.isView(e)}function yo(e){return e instanceof globalThis.Uint8Array}function Y(e,t){return t in e}function be(e){return e!==null&&typeof e==="object"}function pe(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function Ge(e){return e===void 0}function jn(e){return e===null}function kn(e){return typeof e==="boolean"}function Q(e){return typeof e==="number"}function _i(e){return globalThis.Number.isInteger(e)}function kt(e){return typeof e==="bigint"}function Qe(e){return typeof e==="string"}function un(e){return typeof e==="function"}function Nn(e){return typeof e==="symbol"}function ho(e){return kt(e)||kn(e)||jn(e)||Q(e)||Qe(e)||Nn(e)||Ge(e)}var $e;(function(e){e.InstanceMode="default",e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(c,f){return e.ExactOptionalPropertyTypes?f in c:c[f]!==void 0}e.IsExactOptionalProperty=t;function n(c){let f=be(c);return e.AllowArrayObject?f:f&&!pe(c)}e.IsObjectLike=n;function o(c){return n(c)&&!(c instanceof Date)&&!(c instanceof Uint8Array)}e.IsRecordLike=o;function i(c){return e.AllowNaN?Q(c):Number.isFinite(c)}e.IsNumberLike=i;function s(c){let f=Ge(c);return e.AllowNullVoid?f||c===null:f}e.IsVoidLike=s})($e||($e={}));function Jd(e){return globalThis.Object.freeze(e).map((t)=>Xo(t))}function Wd(e){return e}function Qd(e){return e}function Yd(e){return e}function Zd(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Xo(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Xo(e[n]);return globalThis.Object.freeze(t)}function Xo(e){return We(e)?Jd(e):po(e)?Wd(e):fn(e)?Qd(e):Di(e)?Yd(e):Fe(e)?Zd(e):e}function F(e,t){let n=t!==void 0?{...t,...e}:e;switch($e.InstanceMode){case"freeze":return Xo(n);case"clone":return Ee(n);default:return n}}class re extends Error{constructor(e){super(e)}}var we=Symbol.for("TypeBox.Transform"),wr=Symbol.for("TypeBox.Readonly"),tt=Symbol.for("TypeBox.Optional"),Ar=Symbol.for("TypeBox.Hint"),I=Symbol.for("TypeBox.Kind");function go(e){return Fe(e)&&e[wr]==="Readonly"}function Ot(e){return Fe(e)&&e[tt]==="Optional"}function ia(e){return ne(e,"Any")}function sa(e){return ne(e,"Argument")}function Xt(e){return ne(e,"Array")}function Un(e){return ne(e,"AsyncIterator")}function Mn(e){return ne(e,"BigInt")}function Ur(e){return ne(e,"Boolean")}function er(e){return ne(e,"Computed")}function tr(e){return ne(e,"Constructor")}function Xd(e){return ne(e,"Date")}function rr(e){return ne(e,"Function")}function nr(e){return ne(e,"Integer")}function Le(e){return ne(e,"Intersect")}function Kn(e){return ne(e,"Iterator")}function ne(e,t){return Fe(e)&&I in e&&e[I]===t}function Gi(e){return cn(e)||jt(e)||Oe(e)}function Nt(e){return ne(e,"Literal")}function Ut(e){return ne(e,"MappedKey")}function Ce(e){return ne(e,"MappedResult")}function dn(e){return ne(e,"Never")}function el(e){return ne(e,"Not")}function ei(e){return ne(e,"Null")}function or(e){return ne(e,"Number")}function ze(e){return ne(e,"Object")}function Ln(e){return ne(e,"Promise")}function Dn(e){return ne(e,"Record")}function qe(e){return ne(e,"Ref")}function aa(e){return ne(e,"RegExp")}function Mr(e){return ne(e,"String")}function ti(e){return ne(e,"Symbol")}function Mt(e){return ne(e,"TemplateLiteral")}function tl(e){return ne(e,"This")}function fe(e){return Fe(e)&&we in e}function Kt(e){return ne(e,"Tuple")}function Kr(e){return ne(e,"Undefined")}function ie(e){return ne(e,"Union")}function rl(e){return ne(e,"Uint8Array")}function nl(e){return ne(e,"Unknown")}function ol(e){return ne(e,"Unsafe")}function il(e){return ne(e,"Void")}function ln(e){return Fe(e)&&I in e&&Oe(e[I])}function Pe(e){return ia(e)||sa(e)||Xt(e)||Ur(e)||Mn(e)||Un(e)||er(e)||tr(e)||Xd(e)||rr(e)||nr(e)||Le(e)||Kn(e)||Nt(e)||Ut(e)||Ce(e)||dn(e)||el(e)||ei(e)||or(e)||ze(e)||Ln(e)||Dn(e)||qe(e)||aa(e)||Mr(e)||ti(e)||Mt(e)||tl(e)||Kt(e)||Kr(e)||ie(e)||rl(e)||nl(e)||ol(e)||il(e)||ln(e)}var sl=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function kc(e){try{return new RegExp(e),!0}catch{return!1}}function ca(e){if(!Oe(e))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=7&&n<=13||n===27||n===127)return!1}return!0}function Nc(e){return fa(e)||je(e)}function ri(e){return Re(e)||Li(e)}function xe(e){return Re(e)||jt(e)}function fa(e){return Re(e)||cn(e)}function ye(e){return Re(e)||Oe(e)}function al(e){return Re(e)||Oe(e)&&ca(e)&&kc(e)}function cl(e){return Re(e)||Oe(e)&&ca(e)}function Uc(e){return Re(e)||je(e)}function zi(e){return Fe(e)&&e[tt]==="Optional"}function ir(e){return oe(e,"Any")&&ye(e.$id)}function fl(e){return oe(e,"Argument")&&jt(e.index)}function Bn(e){return oe(e,"Array")&&e.type==="array"&&ye(e.$id)&&je(e.items)&&xe(e.minItems)&&xe(e.maxItems)&&fa(e.uniqueItems)&&Uc(e.contains)&&xe(e.minContains)&&xe(e.maxContains)}function ua(e){return oe(e,"AsyncIterator")&&e.type==="AsyncIterator"&&ye(e.$id)&&je(e.items)}function Ji(e){return oe(e,"BigInt")&&e.type==="bigint"&&ye(e.$id)&&ri(e.exclusiveMaximum)&&ri(e.exclusiveMinimum)&&ri(e.maximum)&&ri(e.minimum)&&ri(e.multipleOf)}function vn(e){return oe(e,"Boolean")&&e.type==="boolean"&&ye(e.$id)}function ul(e){return oe(e,"Computed")&&Oe(e.target)&&We(e.parameters)&&e.parameters.every((t)=>je(t))}function Wi(e){return oe(e,"Constructor")&&e.type==="Constructor"&&ye(e.$id)&&We(e.parameters)&&e.parameters.every((t)=>je(t))&&je(e.returns)}function Qi(e){return oe(e,"Date")&&e.type==="Date"&&ye(e.$id)&&xe(e.exclusiveMaximumTimestamp)&&xe(e.exclusiveMinimumTimestamp)&&xe(e.maximumTimestamp)&&xe(e.minimumTimestamp)&&xe(e.multipleOfTimestamp)}function Yi(e){return oe(e,"Function")&&e.type==="Function"&&ye(e.$id)&&We(e.parameters)&&e.parameters.every((t)=>je(t))&&je(e.returns)}function Dr(e){return oe(e,"Integer")&&e.type==="integer"&&ye(e.$id)&&xe(e.exclusiveMaximum)&&xe(e.exclusiveMinimum)&&xe(e.maximum)&&xe(e.minimum)&&xe(e.multipleOf)}function Mc(e){return Fe(e)&&Object.entries(e).every(([t,n])=>ca(t)&&je(n))}function Hn(e){return oe(e,"Intersect")&&(Oe(e.type)&&e.type!=="object"?!1:!0)&&We(e.allOf)&&e.allOf.every((t)=>je(t)&&!hl(t))&&ye(e.type)&&(fa(e.unevaluatedProperties)||Uc(e.unevaluatedProperties))&&ye(e.$id)}function da(e){return oe(e,"Iterator")&&e.type==="Iterator"&&ye(e.$id)&&je(e.items)}function oe(e,t){return Fe(e)&&I in e&&e[I]===t}function Kc(e){return pn(e)&&Oe(e.const)}function Lc(e){return pn(e)&&jt(e.const)}function Dc(e){return pn(e)&&cn(e.const)}function pn(e){return oe(e,"Literal")&&ye(e.$id)&&dl(e.const)}function dl(e){return cn(e)||jt(e)||Oe(e)}function ll(e){return oe(e,"MappedKey")&&We(e.keys)&&e.keys.every((t)=>jt(t)||Oe(t))}function pl(e){return oe(e,"MappedResult")&&Mc(e.properties)}function mn(e){return oe(e,"Never")&&Fe(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function bo(e){return oe(e,"Not")&&je(e.not)}function la(e){return oe(e,"Null")&&e.type==="null"&&ye(e.$id)}function Rt(e){return oe(e,"Number")&&e.type==="number"&&ye(e.$id)&&xe(e.exclusiveMaximum)&&xe(e.exclusiveMinimum)&&xe(e.maximum)&&xe(e.minimum)&&xe(e.multipleOf)}function De(e){return oe(e,"Object")&&e.type==="object"&&ye(e.$id)&&Mc(e.properties)&&Nc(e.additionalProperties)&&xe(e.minProperties)&&xe(e.maxProperties)}function pa(e){return oe(e,"Promise")&&e.type==="Promise"&&ye(e.$id)&&je(e.item)}function ct(e){return oe(e,"Record")&&e.type==="object"&&ye(e.$id)&&Nc(e.additionalProperties)&&Fe(e.patternProperties)&&((t)=>{let n=Object.getOwnPropertyNames(t.patternProperties);return n.length===1&&kc(n[0])&&Fe(t.patternProperties)&&je(t.patternProperties[n[0]])})(e)}function ml(e){return oe(e,"Ref")&&ye(e.$id)&&Oe(e.$ref)}function ni(e){return oe(e,"RegExp")&&ye(e.$id)&&Oe(e.source)&&Oe(e.flags)&&xe(e.maxLength)&&xe(e.minLength)}function sr(e){return oe(e,"String")&&e.type==="string"&&ye(e.$id)&&xe(e.minLength)&&xe(e.maxLength)&&al(e.pattern)&&cl(e.format)}function oi(e){return oe(e,"Symbol")&&e.type==="symbol"&&ye(e.$id)}function ii(e){return oe(e,"TemplateLiteral")&&e.type==="string"&&Oe(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function yl(e){return oe(e,"This")&&ye(e.$id)&&Oe(e.$ref)}function hl(e){return Fe(e)&&we in e}function Zi(e){return oe(e,"Tuple")&&e.type==="array"&&ye(e.$id)&&jt(e.minItems)&&jt(e.maxItems)&&e.minItems===e.maxItems&&(Re(e.items)&&Re(e.additionalItems)&&e.minItems===0||We(e.items)&&e.items.every((t)=>je(t)))}function Vn(e){return oe(e,"Undefined")&&e.type==="undefined"&&ye(e.$id)}function Br(e){return oe(e,"Union")&&ye(e.$id)&&Fe(e)&&We(e.anyOf)&&e.anyOf.every((t)=>je(t))}function si(e){return oe(e,"Uint8Array")&&e.type==="Uint8Array"&&ye(e.$id)&&xe(e.minByteLength)&&xe(e.maxByteLength)}function ar(e){return oe(e,"Unknown")&&ye(e.$id)}function gl(e){return oe(e,"Unsafe")}function Xi(e){return oe(e,"Void")&&e.type==="void"&&ye(e.$id)}function bl(e){return Fe(e)&&I in e&&Oe(e[I])&&!sl.includes(e[I])}function je(e){return Fe(e)&&(ir(e)||fl(e)||Bn(e)||vn(e)||Ji(e)||ua(e)||ul(e)||Wi(e)||Qi(e)||Yi(e)||Dr(e)||Hn(e)||da(e)||pn(e)||ll(e)||pl(e)||mn(e)||bo(e)||la(e)||Rt(e)||De(e)||pa(e)||ct(e)||ml(e)||ni(e)||sr(e)||oi(e)||ii(e)||yl(e)||Zi(e)||Vn(e)||Br(e)||si(e)||ar(e)||gl(e)||Xi(e)||bl(e))}var vc="(true|false)",es="(0|[1-9][0-9]*)",Hc="(.*)";var yn="^(0|[1-9][0-9]*)$",hn="^(.*)$",Vc="^(?!.*)$";var ma=new Map;function cr(e){return ma.has(e)}function vr(e,t){ma.set(e,t)}function ya(e){return ma.get(e)}var ha=new Map;function qn(e){return ha.has(e)}function xl(e,t){ha.set(e,t)}function ga(e){return ha.get(e)}function qc(e,t){return e.includes(t)}function _c(e){return[...new Set(e)]}function Il(e,t){return e.filter((n)=>t.includes(n))}function Ol(e,t){return e.reduce((n,o)=>Il(n,o),t)}function Gc(e){return e.length===1?e[0]:e.length>1?Ol(e.slice(1),e[0]):[]}function zc(e){let t=[];for(let n of e)t.push(...n);return t}function gn(e){return F({[I]:"Any"},e)}function Io(e,t){return F({[I]:"Array",type:"array",items:e},t)}function Jc(e){return F({[I]:"Argument",index:e})}function Oo(e,t){return F({[I]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function Ae(e,t,n){return F({[I]:"Computed",target:e,parameters:t},n)}function Rl(e,t){let{[t]:n,...o}=e;return o}function Be(e,t){return t.reduce((n,o)=>Rl(n,o),e)}function Z(e){return F({[I]:"Never",not:{}},e)}function ae(e){return F({[I]:"MappedResult",properties:e})}function Ro(e,t,n){return F({[I]:"Constructor",type:"Constructor",parameters:e,returns:t},n)}function Sr(e,t,n){return F({[I]:"Function",type:"Function",parameters:e,returns:t},n)}function ci(e,t){return F({[I]:"Union",anyOf:e},t)}function $l(e){return e.some((t)=>Ot(t))}function Wc(e){return e.map((t)=>Ot(t)?wl(t):t)}function wl(e){return Be(e,[tt])}function Al(e,t){return $l(e)?pt(ci(Wc(e),t)):ci(Wc(e),t)}function Fr(e,t){return e.length===1?F(e[0],t):e.length===0?Z(t):Al(e,t)}function le(e,t){return e.length===0?Z(t):e.length===1?F(e[0],t):ci(e,t)}class ba extends re{}function Sl(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function xa(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function Hr(e,t){return xa(e,t,"(")}function fi(e,t){return xa(e,t,")")}function Qc(e,t){return xa(e,t,"|")}function Fl(e){if(!(Hr(e,0)&&fi(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++){if(Hr(e,n))t+=1;if(fi(e,n))t-=1;if(t===0&&n!==e.length-1)return!1}return!0}function El(e){return e.slice(1,e.length-1)}function Cl(e){let t=0;for(let n=0;n<e.length;n++){if(Hr(e,n))t+=1;if(fi(e,n))t-=1;if(Qc(e,n)&&t===0)return!0}return!1}function Tl(e){for(let t=0;t<e.length;t++)if(Hr(e,t))return!0;return!1}function Pl(e){let[t,n]=[0,0],o=[];for(let s=0;s<e.length;s++){if(Hr(e,s))t+=1;if(fi(e,s))t-=1;if(Qc(e,s)&&t===0){let c=e.slice(n,s);if(c.length>0)o.push($o(c));n=s+1}}let i=e.slice(n);if(i.length>0)o.push($o(i));if(o.length===0)return{type:"const",const:""};if(o.length===1)return o[0];return{type:"or",expr:o}}function jl(e){function t(i,s){if(!Hr(i,s))throw new ba("TemplateLiteralParser: Index must point to open parens");let c=0;for(let f=s;f<i.length;f++){if(Hr(i,f))c+=1;if(fi(i,f))c-=1;if(c===0)return[s,f]}throw new ba("TemplateLiteralParser: Unclosed group parens in expression")}function n(i,s){for(let c=s;c<i.length;c++)if(Hr(i,c))return[s,c];return[s,i.length]}let o=[];for(let i=0;i<e.length;i++)if(Hr(e,i)){let[s,c]=t(e,i),f=e.slice(s,c+1);o.push($o(f)),i=c}else{let[s,c]=n(e,i),f=e.slice(s,c);if(f.length>0)o.push($o(f));i=c-1}return o.length===0?{type:"const",const:""}:o.length===1?o[0]:{type:"and",expr:o}}function $o(e){return Fl(e)?$o(El(e)):Cl(e)?Pl(e):Tl(e)?jl(e):{type:"const",const:Sl(e)}}function wo(e){return $o(e.slice(1,e.length-1))}class Yc extends re{}function kl(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="0"&&e.expr[1].type==="const"&&e.expr[1].const==="[1-9][0-9]*"}function Nl(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="true"&&e.expr[1].type==="const"&&e.expr[1].const==="false"}function Ul(e){return e.type==="const"&&e.const===".*"}function _n(e){return kl(e)||Ul(e)?!1:Nl(e)?!0:e.type==="and"?e.expr.every((t)=>_n(t)):e.type==="or"?e.expr.every((t)=>_n(t)):e.type==="const"?!0:(()=>{throw new Yc("Unknown expression type")})()}function ts(e){let t=wo(e.pattern);return _n(t)}class Zc extends re{}function*Xc(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of Xc(e.slice(1)))yield`${t}${n}`}function*Ml(e){return yield*Xc(e.expr.map((t)=>[...ui(t)]))}function*Kl(e){for(let t of e.expr)yield*ui(t)}function*Ll(e){return yield e.const}function*ui(e){return e.type==="and"?yield*Ml(e):e.type==="or"?yield*Kl(e):e.type==="const"?yield*Ll(e):(()=>{throw new Zc("Unknown expression")})()}function Ao(e){let t=wo(e.pattern);return _n(t)?[...ui(t)]:[]}function de(e,t){return F({[I]:"Literal",const:e,type:typeof e},t)}function rs(e){return F({[I]:"Boolean",type:"boolean"},e)}function So(e){return F({[I]:"BigInt",type:"bigint"},e)}function Vt(e){return F({[I]:"Number",type:"number"},e)}function fr(e){return F({[I]:"String",type:"string"},e)}function*Dl(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield rs():t==="number"?yield Vt():t==="bigint"?yield So():t==="string"?yield fr():yield(()=>{let n=t.split("|").map((o)=>de(o.trim()));return n.length===0?Z():n.length===1?n[0]:Fr(n)})()}function*Bl(e){if(e[1]!=="{"){let t=de("$"),n=Ia(e.slice(1));return yield*[t,...n]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let n=Dl(e.slice(2,t)),o=Ia(e.slice(t+1));return yield*[...n,...o]}yield de(e)}function*Ia(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let n=de(e.slice(0,t)),o=Bl(e.slice(t));return yield*[n,...o]}yield de(e)}function ef(e){return[...Ia(e)]}class tf extends re{}function vl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rf(e,t){return Mt(e)?e.pattern.slice(1,e.pattern.length-1):ie(e)?`(${e.anyOf.map((n)=>rf(n,t)).join("|")})`:or(e)?`${t}${es}`:nr(e)?`${t}${es}`:Mn(e)?`${t}${es}`:Mr(e)?`${t}${Hc}`:Nt(e)?`${t}${vl(e.const.toString())}`:Ur(e)?`${t}${vc}`:(()=>{throw new tf(`Unexpected Kind '${e[I]}'`)})()}function Oa(e){return`^${e.map((t)=>rf(t,"")).join("")}$`}function Gn(e){let n=Ao(e).map((o)=>de(o));return Fr(n)}function ns(e,t){let n=Oe(e)?Oa(ef(e)):Oa(e);return F({[I]:"TemplateLiteral",type:"string",pattern:n},t)}function Hl(e){return Ao(e).map((n)=>n.toString())}function Vl(e){let t=[];for(let n of e)t.push(...$t(n));return t}function ql(e){return[e.toString()]}function $t(e){return[...new Set(Mt(e)?Hl(e):ie(e)?Vl(e.anyOf):Nt(e)?ql(e.const):or(e)?["[number]"]:nr(e)?["[number]"]:[])]}function _l(e,t,n){let o={};for(let i of Object.getOwnPropertyNames(t))o[i]=bn(e,$t(t[i]),n);return o}function Gl(e,t,n){return _l(e,t.properties,n)}function nf(e,t,n){let o=Gl(e,t,n);return ae(o)}function sf(e,t){return e.map((n)=>af(n,t))}function zl(e){return e.filter((t)=>!dn(t))}function Jl(e,t){return os(zl(sf(e,t)))}function Wl(e){return e.some((t)=>dn(t))?[]:e}function Ql(e,t){return Fr(Wl(sf(e,t)))}function Yl(e,t){return t in e?e[t]:t==="[number]"?Fr(e):Z()}function Zl(e,t){return t==="[number]"?e:Z()}function Xl(e,t){return t in e?e[t]:Z()}function af(e,t){return Le(e)?Jl(e.allOf,t):ie(e)?Ql(e.anyOf,t):Kt(e)?Yl(e.items??[],t):Xt(e)?Zl(e.items,t):ze(e)?Xl(e.properties,t):Z()}function di(e,t){return t.map((n)=>af(e,n))}function of(e,t){return Fr(di(e,t))}function bn(e,t,n){if(qe(e)||qe(t)){if(!Pe(e)||!Pe(t))throw new re("Index types using Ref parameters require both Type and Key to be of TSchema");return Ae("Index",[e,t])}if(Ce(t))return nf(e,t,n);if(Ut(t))return cf(e,t,n);return F(Pe(t)?of(e,$t(t)):of(e,t),n)}function ep(e,t,n){return{[t]:bn(e,[t],Ee(n))}}function tp(e,t,n){return t.reduce((o,i)=>({...o,...ep(e,i,n)}),{})}function rp(e,t,n){return tp(e,t.keys,n)}function cf(e,t,n){let o=rp(e,t,n);return ae(o)}function Fo(e,t){return F({[I]:"Iterator",type:"Iterator",items:e},t)}function np(e){return globalThis.Object.keys(e).filter((t)=>!Ot(e[t]))}function op(e,t){let n=np(e),o=n.length>0?{[I]:"Object",type:"object",required:n,properties:e}:{[I]:"Object",type:"object",properties:e};return F(o,t)}var he=op;function is(e,t){return F({[I]:"Promise",type:"Promise",item:e},t)}function ip(e){return F(Be(e,[wr]))}function sp(e){return F({...e,[wr]:"Readonly"})}function ap(e,t){return t===!1?ip(e):sp(e)}function wt(e,t){let n=t??!0;return Ce(e)?ff(e,n):ap(e,n)}function cp(e,t){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=wt(e[o],t);return n}function fp(e,t){return cp(e.properties,t)}function ff(e,t){let n=fp(e,t);return ae(n)}function qt(e,t){return F(e.length>0?{[I]:"Tuple",type:"array",items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[I]:"Tuple",type:"array",minItems:e.length,maxItems:e.length},t)}function uf(e,t){return e in t?_t(e,t[e]):ae(t)}function up(e){return{[e]:de(e)}}function dp(e){let t={};for(let n of e)t[n]=de(n);return t}function lp(e,t){return qc(t,e)?up(e):dp(t)}function pp(e,t){let n=lp(e,t);return uf(e,n)}function li(e,t){return t.map((n)=>_t(e,n))}function mp(e,t){let n={};for(let o of globalThis.Object.getOwnPropertyNames(t))n[o]=_t(e,t[o]);return n}function _t(e,t){let n={...t};return Ot(t)?pt(_t(e,Be(t,[tt]))):go(t)?wt(_t(e,Be(t,[wr]))):Ce(t)?uf(e,t.properties):Ut(t)?pp(e,t.keys):tr(t)?Ro(li(e,t.parameters),_t(e,t.returns),n):rr(t)?Sr(li(e,t.parameters),_t(e,t.returns),n):Un(t)?Oo(_t(e,t.items),n):Kn(t)?Fo(_t(e,t.items),n):Le(t)?mt(li(e,t.allOf),n):ie(t)?le(li(e,t.anyOf),n):Kt(t)?qt(li(e,t.items??[]),n):ze(t)?he(mp(e,t.properties),n):Xt(t)?Io(_t(e,t.items),n):Ln(t)?is(_t(e,t.item),n):t}function yp(e,t){let n={};for(let o of e)n[o]=_t(o,t);return n}function df(e,t,n){let o=Pe(e)?$t(e):e,i=t({[I]:"MappedKey",keys:o}),s=yp(o,i);return he(s,n)}function hp(e){return F(Be(e,[tt]))}function gp(e){return F({...e,[tt]:"Optional"})}function bp(e,t){return t===!1?hp(e):gp(e)}function pt(e,t){let n=t??!0;return Ce(e)?lf(e,n):bp(e,n)}function xp(e,t){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=pt(e[o],t);return n}function Ip(e,t){return xp(e.properties,t)}function lf(e,t){let n=Ip(e,t);return ae(n)}function pi(e,t={}){let n=e.every((i)=>ze(i)),o=Pe(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return F(t.unevaluatedProperties===!1||Pe(t.unevaluatedProperties)||n?{...o,[I]:"Intersect",type:"object",allOf:e}:{...o,[I]:"Intersect",allOf:e},t)}function Op(e){return e.every((t)=>Ot(t))}function Rp(e){return Be(e,[tt])}function pf(e){return e.map((t)=>Ot(t)?Rp(t):t)}function $p(e,t){return Op(e)?pt(pi(pf(e),t)):pi(pf(e),t)}function os(e,t={}){if(e.length===1)return F(e[0],t);if(e.length===0)return Z(t);if(e.some((n)=>fe(n)))throw Error("Cannot intersect transform types");return $p(e,t)}function mt(e,t){if(e.length===1)return F(e[0],t);if(e.length===0)return Z(t);if(e.some((n)=>fe(n)))throw Error("Cannot intersect transform types");return pi(e,t)}function Gt(...e){let[t,n]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new re("Ref: $ref must be a string");return F({[I]:"Ref",$ref:t},n)}function wp(e,t){return Ae("Awaited",[Ae(e,t)])}function Ap(e){return Ae("Awaited",[Gt(e)])}function Sp(e){return mt(mf(e))}function Fp(e){return le(mf(e))}function Ep(e){return Eo(e)}function mf(e){return e.map((t)=>Eo(t))}function Eo(e,t){return F(er(e)?wp(e.target,e.parameters):Le(e)?Sp(e.allOf):ie(e)?Fp(e.anyOf):Ln(e)?Ep(e.item):qe(e)?Ap(e.$ref):e,t)}function yf(e){let t=[];for(let n of e)t.push(At(n));return t}function Cp(e){let t=yf(e);return zc(t)}function Tp(e){let t=yf(e);return Gc(t)}function Pp(e){return e.map((t,n)=>n.toString())}function jp(e){return["[number]"]}function kp(e){return globalThis.Object.getOwnPropertyNames(e)}function Np(e){if(!Ra)return[];return globalThis.Object.getOwnPropertyNames(e).map((n)=>n[0]==="^"&&n[n.length-1]==="$"?n.slice(1,n.length-1):n)}function At(e){return Le(e)?Cp(e.allOf):ie(e)?Tp(e.anyOf):Kt(e)?Pp(e.items??[]):Xt(e)?jp(e.items):ze(e)?kp(e.properties):Dn(e)?Np(e.patternProperties):[]}var Ra=!1;function Vr(e){Ra=!0;let t=At(e);return Ra=!1,`^(${t.map((o)=>`(${o})`).join("|")})$`}function Up(e,t){return Ae("KeyOf",[Ae(e,t)])}function Mp(e){return Ae("KeyOf",[Gt(e)])}function Kp(e,t){let n=At(e),o=Lp(n),i=Fr(o);return F(i,t)}function Lp(e){return e.map((t)=>t==="[number]"?Vt():de(t))}function Co(e,t){return er(e)?Up(e.target,e.parameters):qe(e)?Mp(e.$ref):Ce(e)?hf(e,t):Kp(e,t)}function Dp(e,t){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Co(e[o],Ee(t));return n}function Bp(e,t){return Dp(e.properties,t)}function hf(e,t){let n=Bp(e,t);return ae(n)}function ss(e){let t=At(e),n=di(e,t);return t.map((o,i)=>[t[i],n[i]])}function vp(e){let t=[];for(let n of e)t.push(...At(n));return _c(t)}function Hp(e){return e.filter((t)=>!dn(t))}function Vp(e,t){let n=[];for(let o of e)n.push(...di(o,[t]));return Hp(n)}function qp(e,t){let n={};for(let o of t)n[o]=os(Vp(e,o));return n}function gf(e,t){let n=vp(e),o=qp(e,n);return he(o,t)}function as(e){return F({[I]:"Date",type:"Date"},e)}function cs(e){return F({[I]:"Null",type:"null"},e)}function fs(e){return F({[I]:"Symbol",type:"symbol"},e)}function us(e){return F({[I]:"Undefined",type:"undefined"},e)}function ds(e){return F({[I]:"Uint8Array",type:"Uint8Array"},e)}function xn(e){return F({[I]:"Unknown"},e)}function _p(e){return e.map((t)=>$a(t,!1))}function Gp(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=wt($a(e[n],!1));return t}function ls(e,t){return t===!0?e:wt(e)}function $a(e,t){return Ac(e)?ls(gn(),t):Fc(e)?ls(gn(),t):We(e)?wt(qt(_p(e))):fn(e)?ds():po(e)?as():Fe(e)?ls(he(Gp(e)),t):Sc(e)?ls(Sr([],xn()),t):Re(e)?us():Ec(e)?cs():Cc(e)?fs():Li(e)?So():jt(e)?de(e):cn(e)?de(e):Oe(e)?de(e):he({})}function bf(e,t){return F($a(e,!0),t)}function xf(e,t){return tr(e)?qt(e.parameters,t):Z(t)}function If(e,t){if(Re(e))throw Error("Enum undefined or empty");let n=globalThis.Object.getOwnPropertyNames(e).filter((s)=>isNaN(s)).map((s)=>e[s]),i=[...new Set(n)].map((s)=>de(s));return le(i,{...t,[Ar]:"Enum"})}class Af extends re{}var T;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(T||(T={}));function zt(e){return e===T.False?e:T.True}function To(e){throw new Af(e)}function Ye(e){return mn(e)||Hn(e)||Br(e)||ar(e)||ir(e)}function Ze(e,t){return mn(t)?Ef(e,t):Hn(t)?ps(e,t):Br(t)?Ea(e,t):ar(t)?jf(e,t):ir(t)?Fa(e,t):To("StructuralRight")}function Fa(e,t){return T.True}function zp(e,t){return Hn(t)?ps(e,t):Br(t)&&t.anyOf.some((n)=>ir(n)||ar(n))?T.True:Br(t)?T.Union:ar(t)?T.True:ir(t)?T.True:T.Union}function Jp(e,t){return ar(e)?T.False:ir(e)?T.Union:mn(e)?T.True:T.False}function Wp(e,t){return De(t)&&ms(t)?T.True:Ye(t)?Ze(e,t):!Bn(t)?T.False:zt(ge(e.items,t.items))}function Qp(e,t){return Ye(t)?Ze(e,t):!ua(t)?T.False:zt(ge(e.items,t.items))}function Yp(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):Ji(t)?T.True:T.False}function Sf(e,t){return Dc(e)?T.True:vn(e)?T.True:T.False}function Zp(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):vn(t)?T.True:T.False}function Xp(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):!Wi(t)?T.False:e.parameters.length>t.parameters.length?T.False:!e.parameters.every((n,o)=>zt(ge(t.parameters[o],n))===T.True)?T.False:zt(ge(e.returns,t.returns))}function em(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):Qi(t)?T.True:T.False}function tm(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):!Yi(t)?T.False:e.parameters.length>t.parameters.length?T.False:!e.parameters.every((n,o)=>zt(ge(t.parameters[o],n))===T.True)?T.False:zt(ge(e.returns,t.returns))}function Ff(e,t){return pn(e)&&jt(e.const)?T.True:Rt(e)||Dr(e)?T.True:T.False}function rm(e,t){return Dr(t)||Rt(t)?T.True:Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):T.False}function ps(e,t){return t.allOf.every((n)=>ge(e,n)===T.True)?T.True:T.False}function nm(e,t){return e.allOf.some((n)=>ge(n,t)===T.True)?T.True:T.False}function om(e,t){return Ye(t)?Ze(e,t):!da(t)?T.False:zt(ge(e.items,t.items))}function im(e,t){return pn(t)&&t.const===e.const?T.True:Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):sr(t)?Pf(e,t):Rt(t)?Cf(e,t):Dr(t)?Ff(e,t):vn(t)?Sf(e,t):T.False}function Ef(e,t){return T.False}function sm(e,t){return T.True}function Of(e){let[t,n]=[e,0];while(!0){if(!bo(t))break;t=t.not,n+=1}return n%2===0?t:xn()}function am(e,t){return bo(e)?ge(Of(e),t):bo(t)?ge(e,Of(t)):To("Invalid fallthrough for Not")}function cm(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):la(t)?T.True:T.False}function Cf(e,t){return Lc(e)?T.True:Rt(e)||Dr(e)?T.True:T.False}function fm(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):Dr(t)||Rt(t)?T.True:T.False}function St(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function Rf(e){return ms(e)}function $f(e){return St(e,0)||St(e,1)&&"description"in e.properties&&Br(e.properties.description)&&e.properties.description.anyOf.length===2&&(sr(e.properties.description.anyOf[0])&&Vn(e.properties.description.anyOf[1])||sr(e.properties.description.anyOf[1])&&Vn(e.properties.description.anyOf[0]))}function wa(e){return St(e,0)}function wf(e){return St(e,0)}function um(e){return St(e,0)}function dm(e){return St(e,0)}function lm(e){return ms(e)}function pm(e){let t=Vt();return St(e,0)||St(e,1)&&"length"in e.properties&&zt(ge(e.properties.length,t))===T.True}function mm(e){return St(e,0)}function ms(e){let t=Vt();return St(e,0)||St(e,1)&&"length"in e.properties&&zt(ge(e.properties.length,t))===T.True}function ym(e){let t=Sr([gn()],gn());return St(e,0)||St(e,1)&&"then"in e.properties&&zt(ge(e.properties.then,t))===T.True}function Tf(e,t){return ge(e,t)===T.False?T.False:zi(e)&&!zi(t)?T.False:T.True}function yt(e,t){return ar(e)?T.False:ir(e)?T.Union:mn(e)||Kc(e)&&Rf(t)||Lc(e)&&wa(t)||Dc(e)&&wf(t)||oi(e)&&$f(t)||Ji(e)&&um(t)||sr(e)&&Rf(t)||oi(e)&&$f(t)||Rt(e)&&wa(t)||Dr(e)&&wa(t)||vn(e)&&wf(t)||si(e)&&lm(t)||Qi(e)&&dm(t)||Wi(e)&&mm(t)||Yi(e)&&pm(t)?T.True:ct(e)&&sr(Aa(e))?(()=>t[Ar]==="Record"?T.True:T.False)():ct(e)&&Rt(Aa(e))?(()=>St(t,0)?T.True:T.False)():T.False}function hm(e,t){return Ye(t)?Ze(e,t):ct(t)?Jt(e,t):!De(t)?T.False:(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!zi(t.properties[n]))return T.False;if(zi(t.properties[n]))return T.True;if(Tf(e.properties[n],t.properties[n])===T.False)return T.False}return T.True})()}function gm(e,t){return Ye(t)?Ze(e,t):De(t)&&ym(t)?T.True:!pa(t)?T.False:zt(ge(e.item,t.item))}function Aa(e){return yn in e.patternProperties?Vt():(hn in e.patternProperties)?fr():To("Unknown record key pattern")}function Sa(e){return yn in e.patternProperties?e.patternProperties[yn]:(hn in e.patternProperties)?e.patternProperties[hn]:To("Unable to get record value schema")}function Jt(e,t){let[n,o]=[Aa(t),Sa(t)];return Kc(e)&&Rt(n)&&zt(ge(e,o))===T.True?T.True:si(e)&&Rt(n)?ge(e,o):sr(e)&&Rt(n)?ge(e,o):Bn(e)&&Rt(n)?ge(e,o):De(e)?(()=>{for(let i of Object.getOwnPropertyNames(e.properties))if(Tf(o,e.properties[i])===T.False)return T.False;return T.True})():T.False}function bm(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):!ct(t)?T.False:ge(Sa(e),Sa(t))}function xm(e,t){let n=ni(e)?fr():e,o=ni(t)?fr():t;return ge(n,o)}function Pf(e,t){return pn(e)&&Oe(e.const)?T.True:sr(e)?T.True:T.False}function Im(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):sr(t)?T.True:T.False}function Om(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):oi(t)?T.True:T.False}function Rm(e,t){return ii(e)?ge(Gn(e),t):ii(t)?ge(e,Gn(t)):To("Invalid fallthrough for TemplateLiteral")}function $m(e,t){return Bn(t)&&e.items!==void 0&&e.items.every((n)=>ge(n,t.items)===T.True)}function wm(e,t){return mn(e)?T.True:ar(e)?T.False:ir(e)?T.Union:T.False}function Am(e,t){return Ye(t)?Ze(e,t):De(t)&&ms(t)?T.True:Bn(t)&&$m(e,t)?T.True:!Zi(t)?T.False:Re(e.items)&&!Re(t.items)||!Re(e.items)&&Re(t.items)?T.False:Re(e.items)&&!Re(t.items)?T.True:e.items.every((n,o)=>ge(n,t.items[o])===T.True)?T.True:T.False}function Sm(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):si(t)?T.True:T.False}function Fm(e,t){return Ye(t)?Ze(e,t):De(t)?yt(e,t):ct(t)?Jt(e,t):Xi(t)?Tm(e,t):Vn(t)?T.True:T.False}function Ea(e,t){return t.anyOf.some((n)=>ge(e,n)===T.True)?T.True:T.False}function Em(e,t){return e.anyOf.every((n)=>ge(n,t)===T.True)?T.True:T.False}function jf(e,t){return T.True}function Cm(e,t){return mn(t)?Ef(e,t):Hn(t)?ps(e,t):Br(t)?Ea(e,t):ir(t)?Fa(e,t):sr(t)?Pf(e,t):Rt(t)?Cf(e,t):Dr(t)?Ff(e,t):vn(t)?Sf(e,t):Bn(t)?Jp(e,t):Zi(t)?wm(e,t):De(t)?yt(e,t):ar(t)?T.True:T.False}function Tm(e,t){return Vn(e)?T.True:Vn(e)?T.True:T.False}function Pm(e,t){return Hn(t)?ps(e,t):Br(t)?Ea(e,t):ar(t)?jf(e,t):ir(t)?Fa(e,t):De(t)?yt(e,t):Xi(t)?T.True:T.False}function ge(e,t){return ii(e)||ii(t)?Rm(e,t):ni(e)||ni(t)?xm(e,t):bo(e)||bo(t)?am(e,t):ir(e)?zp(e,t):Bn(e)?Wp(e,t):Ji(e)?Yp(e,t):vn(e)?Zp(e,t):ua(e)?Qp(e,t):Wi(e)?Xp(e,t):Qi(e)?em(e,t):Yi(e)?tm(e,t):Dr(e)?rm(e,t):Hn(e)?nm(e,t):da(e)?om(e,t):pn(e)?im(e,t):mn(e)?sm(e,t):la(e)?cm(e,t):Rt(e)?fm(e,t):De(e)?hm(e,t):ct(e)?bm(e,t):sr(e)?Im(e,t):oi(e)?Om(e,t):Zi(e)?Am(e,t):pa(e)?gm(e,t):si(e)?Sm(e,t):Vn(e)?Fm(e,t):Br(e)?Em(e,t):ar(e)?Cm(e,t):Xi(e)?Pm(e,t):To(`Unknown left type operand '${e[I]}'`)}function In(e,t){return ge(e,t)}function jm(e,t,n,o,i){let s={};for(let c of globalThis.Object.getOwnPropertyNames(e))s[c]=Po(e[c],t,n,o,Ee(i));return s}function km(e,t,n,o,i){return jm(e.properties,t,n,o,i)}function kf(e,t,n,o,i){let s=km(e,t,n,o,i);return ae(s)}function Nm(e,t,n,o){let i=In(e,t);return i===T.Union?le([n,o]):i===T.True?n:o}function Po(e,t,n,o,i){return Ce(e)?kf(e,t,n,o,i):Ut(e)?F(Nf(e,t,n,o,i)):F(Nm(e,t,n,o),i)}function Um(e,t,n,o,i){return{[e]:Po(de(e),t,n,o,Ee(i))}}function Mm(e,t,n,o,i){return e.reduce((s,c)=>({...s,...Um(c,t,n,o,i)}),{})}function Km(e,t,n,o,i){return Mm(e.keys,t,n,o,i)}function Nf(e,t,n,o,i){let s=Km(e,t,n,o,i);return ae(s)}function Lm(e){return e.allOf.every((t)=>qr(t))}function Dm(e){return e.anyOf.some((t)=>qr(t))}function Bm(e){return!qr(e.not)}function qr(e){return e[I]==="Intersect"?Lm(e):e[I]==="Union"?Dm(e):e[I]==="Not"?Bm(e):e[I]==="Undefined"?!0:!1}function Uf(e,t){return jo(Gn(e),t)}function vm(e,t){let n=e.filter((o)=>In(o,t)===T.False);return n.length===1?n[0]:le(n)}function jo(e,t,n={}){if(Mt(e))return F(Uf(e,t),n);if(Ce(e))return F(Mf(e,t),n);return F(ie(e)?vm(e.anyOf,t):In(e,t)!==T.False?Z():e,n)}function Hm(e,t){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=jo(e[o],t);return n}function Vm(e,t){return Hm(e.properties,t)}function Mf(e,t){let n=Vm(e,t);return ae(n)}function Kf(e,t){return ko(Gn(e),t)}function qm(e,t){let n=e.filter((o)=>In(o,t)!==T.False);return n.length===1?n[0]:le(n)}function ko(e,t,n){if(Mt(e))return F(Kf(e,t),n);if(Ce(e))return F(Lf(e,t),n);return F(ie(e)?qm(e.anyOf,t):In(e,t)!==T.False?e:Z(),n)}function _m(e,t){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=ko(e[o],t);return n}function Gm(e,t){return _m(e.properties,t)}function Lf(e,t){let n=Gm(e,t);return ae(n)}function Df(e,t){return tr(e)?F(e.returns,t):Z(t)}function ys(e){return wt(pt(e))}function zn(e,t,n){return F({[I]:"Record",type:"object",patternProperties:{[e]:t}},n)}function Ca(e,t,n){let o={};for(let i of e)o[i]=t;return he(o,{...n,[Ar]:"Record"})}function zm(e,t,n){return ts(e)?Ca($t(e),t,n):zn(e.pattern,t,n)}function Jm(e,t,n){return Ca($t(le(e)),t,n)}function Wm(e,t,n){return Ca([e.toString()],t,n)}function Qm(e,t,n){return zn(e.source,t,n)}function Ym(e,t,n){let o=Re(e.pattern)?hn:e.pattern;return zn(o,t,n)}function Zm(e,t,n){return zn(hn,t,n)}function Xm(e,t,n){return zn(Vc,t,n)}function ey(e,t,n){return he({true:t,false:t},n)}function ty(e,t,n){return zn(yn,t,n)}function ry(e,t,n){return zn(yn,t,n)}function hs(e,t,n={}){return ie(e)?Jm(e.anyOf,t,n):Mt(e)?zm(e,t,n):Nt(e)?Wm(e.const,t,n):Ur(e)?ey(e,t,n):nr(e)?ty(e,t,n):or(e)?ry(e,t,n):aa(e)?Qm(e,t,n):Mr(e)?Ym(e,t,n):ia(e)?Zm(e,t,n):dn(e)?Xm(e,t,n):Z(n)}function gs(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function Bf(e){let t=gs(e);return t===hn?fr():t===yn?Vt():fr({pattern:t})}function bs(e){return e.patternProperties[gs(e)]}function ny(e,t){return t.parameters=mi(e,t.parameters),t.returns=ur(e,t.returns),t}function oy(e,t){return t.parameters=mi(e,t.parameters),t.returns=ur(e,t.returns),t}function iy(e,t){return t.allOf=mi(e,t.allOf),t}function sy(e,t){return t.anyOf=mi(e,t.anyOf),t}function ay(e,t){if(Re(t.items))return t;return t.items=mi(e,t.items),t}function cy(e,t){return t.items=ur(e,t.items),t}function fy(e,t){return t.items=ur(e,t.items),t}function uy(e,t){return t.items=ur(e,t.items),t}function dy(e,t){return t.item=ur(e,t.item),t}function ly(e,t){let n=hy(e,t.properties);return{...t,...he(n)}}function py(e,t){let n=ur(e,Bf(t)),o=ur(e,bs(t)),i=hs(n,o);return{...t,...i}}function my(e,t){return t.index in e?e[t.index]:xn()}function yy(e,t){let n=go(t),o=Ot(t),i=ur(e,t);return n&&o?ys(i):n&&!o?wt(i):!n&&o?pt(i):i}function hy(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,o)=>({...n,[o]:yy(e,t[o])}),{})}function mi(e,t){return t.map((n)=>ur(e,n))}function ur(e,t){return tr(t)?ny(e,t):rr(t)?oy(e,t):Le(t)?iy(e,t):ie(t)?sy(e,t):Kt(t)?ay(e,t):Xt(t)?cy(e,t):Un(t)?fy(e,t):Kn(t)?uy(e,t):Ln(t)?dy(e,t):ze(t)?ly(e,t):Dn(t)?py(e,t):sa(t)?my(e,t):t}function vf(e,t){return ur(t,mo(e))}function Hf(e){return F({[I]:"Integer",type:"integer"},e)}function gy(e,t,n){return{[e]:dr(de(e),t,Ee(n))}}function by(e,t,n){return e.reduce((i,s)=>({...i,...gy(s,t,n)}),{})}function xy(e,t,n){return by(e.keys,t,n)}function Vf(e,t,n){let o=xy(e,t,n);return ae(o)}function Iy(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join("")}function Oy(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join("")}function Ry(e){return e.toUpperCase()}function $y(e){return e.toLowerCase()}function wy(e,t,n){let o=wo(e.pattern);if(!_n(o))return{...e,pattern:qf(e.pattern,t)};let c=[...ui(o)].map((l)=>de(l)),f=_f(c,t),u=le(f);return ns([u],n)}function qf(e,t){return typeof e==="string"?t==="Uncapitalize"?Iy(e):t==="Capitalize"?Oy(e):t==="Uppercase"?Ry(e):t==="Lowercase"?$y(e):e:e.toString()}function _f(e,t){return e.map((n)=>dr(n,t))}function dr(e,t,n={}){return Ut(e)?Vf(e,t,n):Mt(e)?wy(e,t,n):ie(e)?le(_f(e.anyOf,t),n):Nt(e)?de(qf(e.const,t),n):F(e,n)}function Gf(e,t={}){return dr(e,"Capitalize",t)}function zf(e,t={}){return dr(e,"Lowercase",t)}function Jf(e,t={}){return dr(e,"Uncapitalize",t)}function Wf(e,t={}){return dr(e,"Uppercase",t)}function Ay(e,t,n){let o={};for(let i of globalThis.Object.getOwnPropertyNames(e))o[i]=On(e[i],t,Ee(n));return o}function Sy(e,t,n){return Ay(e.properties,t,n)}function Qf(e,t,n){let o=Sy(e,t,n);return ae(o)}function Fy(e,t){return e.map((n)=>Ta(n,t))}function Ey(e,t){return e.map((n)=>Ta(n,t))}function Cy(e,t){let{[t]:n,...o}=e;return o}function Ty(e,t){return t.reduce((n,o)=>Cy(n,o),e)}function Py(e,t,n){let o=Be(e,[we,"$id","required","properties"]),i=Ty(n,t);return he(i,o)}function jy(e){let t=e.reduce((n,o)=>Gi(o)?[...n,de(o)]:n,[]);return le(t)}function Ta(e,t){return Le(e)?mt(Fy(e.allOf,t)):ie(e)?le(Ey(e.anyOf,t)):ze(e)?Py(e,t,e.properties):he({})}function On(e,t,n){let o=We(t)?jy(t):t,i=Pe(t)?$t(t):t,s=qe(e),c=qe(t);return Ce(e)?Qf(e,i,n):Ut(t)?Yf(e,t,n):s&&c?Ae("Omit",[e,o],n):!s&&c?Ae("Omit",[e,o],n):s&&!c?Ae("Omit",[e,o],n):F({...Ta(e,i),...n})}function ky(e,t,n){return{[t]:On(e,[t],Ee(n))}}function Ny(e,t,n){return t.reduce((o,i)=>({...o,...ky(e,i,n)}),{})}function Uy(e,t,n){return Ny(e,t.keys,n)}function Yf(e,t,n){let o=Uy(e,t,n);return ae(o)}function My(e,t,n){let o={};for(let i of globalThis.Object.getOwnPropertyNames(e))o[i]=Rn(e[i],t,Ee(n));return o}function Ky(e,t,n){return My(e.properties,t,n)}function Zf(e,t,n){let o=Ky(e,t,n);return ae(o)}function Ly(e,t){return e.map((n)=>Pa(n,t))}function Dy(e,t){return e.map((n)=>Pa(n,t))}function By(e,t){let n={};for(let o of t)if(o in e)n[o]=e[o];return n}function vy(e,t,n){let o=Be(e,[we,"$id","required","properties"]),i=By(n,t);return he(i,o)}function Hy(e){let t=e.reduce((n,o)=>Gi(o)?[...n,de(o)]:n,[]);return le(t)}function Pa(e,t){return Le(e)?mt(Ly(e.allOf,t)):ie(e)?le(Dy(e.anyOf,t)):ze(e)?vy(e,t,e.properties):he({})}function Rn(e,t,n){let o=We(t)?Hy(t):t,i=Pe(t)?$t(t):t,s=qe(e),c=qe(t);return Ce(e)?Zf(e,i,n):Ut(t)?Xf(e,t,n):s&&c?Ae("Pick",[e,o],n):!s&&c?Ae("Pick",[e,o],n):s&&!c?Ae("Pick",[e,o],n):F({...Pa(e,i),...n})}function Vy(e,t,n){return{[t]:Rn(e,[t],Ee(n))}}function qy(e,t,n){return t.reduce((o,i)=>({...o,...Vy(e,i,n)}),{})}function _y(e,t,n){return qy(e,t.keys,n)}function Xf(e,t,n){let o=_y(e,t,n);return ae(o)}function Gy(e,t){return Ae("Partial",[Ae(e,t)])}function zy(e){return Ae("Partial",[Gt(e)])}function Jy(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=pt(e[n]);return t}function Wy(e,t){let n=Be(e,[we,"$id","required","properties"]),o=Jy(t);return he(o,n)}function eu(e){return e.map((t)=>tu(t))}function tu(e){return er(e)?Gy(e.target,e.parameters):qe(e)?zy(e.$ref):Le(e)?mt(eu(e.allOf)):ie(e)?le(eu(e.anyOf)):ze(e)?Wy(e,e.properties):Mn(e)?e:Ur(e)?e:nr(e)?e:Nt(e)?e:ei(e)?e:or(e)?e:Mr(e)?e:ti(e)?e:Kr(e)?e:he({})}function No(e,t){if(Ce(e))return ru(e,t);else return F({...tu(e),...t})}function Qy(e,t){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=No(e[o],Ee(t));return n}function Yy(e,t){return Qy(e.properties,t)}function ru(e,t){let n=Yy(e,t);return ae(n)}function Zy(e,t){return Ae("Required",[Ae(e,t)])}function Xy(e){return Ae("Required",[Gt(e)])}function eh(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=Be(e[n],[tt]);return t}function th(e,t){let n=Be(e,[we,"$id","required","properties"]),o=eh(t);return he(o,n)}function nu(e){return e.map((t)=>ou(t))}function ou(e){return er(e)?Zy(e.target,e.parameters):qe(e)?Xy(e.$ref):Le(e)?mt(nu(e.allOf)):ie(e)?le(nu(e.anyOf)):ze(e)?th(e,e.properties):Mn(e)?e:Ur(e)?e:nr(e)?e:Nt(e)?e:ei(e)?e:or(e)?e:Mr(e)?e:ti(e)?e:Kr(e)?e:he({})}function Uo(e,t){if(Ce(e))return iu(e,t);else return F({...ou(e),...t})}function rh(e,t){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Uo(e[o],t);return n}function nh(e,t){return rh(e.properties,t)}function iu(e,t){let n=nh(e,t);return ae(n)}function oh(e,t){return t.map((n)=>qe(n)?ja(e,n.$ref):Lt(e,n))}function ja(e,t){return t in e?qe(e[t])?ja(e,e[t].$ref):Lt(e,e[t]):Z()}function ih(e){return Eo(e[0])}function sh(e){return bn(e[0],e[1])}function ah(e){return Co(e[0])}function ch(e){return No(e[0])}function fh(e){return On(e[0],e[1])}function uh(e){return Rn(e[0],e[1])}function dh(e){return Uo(e[0])}function lh(e,t,n){let o=oh(e,n);return t==="Awaited"?ih(o):t==="Index"?sh(o):t==="KeyOf"?ah(o):t==="Partial"?ch(o):t==="Omit"?fh(o):t==="Pick"?uh(o):t==="Required"?dh(o):Z()}function ph(e,t){return Io(Lt(e,t))}function mh(e,t){return Oo(Lt(e,t))}function yh(e,t,n){return Ro(yi(e,t),Lt(e,n))}function hh(e,t,n){return Sr(yi(e,t),Lt(e,n))}function gh(e,t){return mt(yi(e,t))}function bh(e,t){return Fo(Lt(e,t))}function xh(e,t){return he(globalThis.Object.keys(t).reduce((n,o)=>({...n,[o]:Lt(e,t[o])}),{}))}function Ih(e,t){let[n,o]=[Lt(e,bs(t)),gs(t)],i=mo(t);return i.patternProperties[o]=n,i}function Oh(e,t){return qe(t)?{...ja(e,t.$ref),[we]:t[we]}:t}function Rh(e,t){return qt(yi(e,t))}function $h(e,t){return le(yi(e,t))}function yi(e,t){return t.map((n)=>Lt(e,n))}function Lt(e,t){return Ot(t)?F(Lt(e,Be(t,[tt])),t):go(t)?F(Lt(e,Be(t,[wr])),t):fe(t)?F(Oh(e,t),t):Xt(t)?F(ph(e,t.items),t):Un(t)?F(mh(e,t.items),t):er(t)?F(lh(e,t.target,t.parameters)):tr(t)?F(yh(e,t.parameters,t.returns),t):rr(t)?F(hh(e,t.parameters,t.returns),t):Le(t)?F(gh(e,t.allOf),t):Kn(t)?F(bh(e,t.items),t):ze(t)?F(xh(e,t.properties),t):Dn(t)?F(Ih(e,t)):Kt(t)?F(Rh(e,t.items||[]),t):ie(t)?F($h(e,t.anyOf),t):t}function wh(e,t){return t in e?Lt(e,e[t]):Z()}function su(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:wh(e,n)}),{})}class au{constructor(e){let t=su(e),n=this.WithIdentifiers(t);this.$defs=n}Import(e,t){let n={...this.$defs,[e]:F(this.$defs[e],t)};return F({[I]:"Import",$defs:n,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:{...e[n],$id:n}}),{})}}function cu(e){return new au(e)}function fu(e,t){return F({[I]:"Not",not:e},t)}function uu(e,t){return rr(e)?qt(e.parameters,t):Z()}var Ah=0;function du(e,t={}){if(Re(t.$id))t.$id=`T${Ah++}`;let n=mo(e({[I]:"This",$ref:`${t.$id}`}));return n.$id=t.$id,F({[Ar]:"Recursive",...n},t)}function lu(e,t){let n=Oe(e)?new globalThis.RegExp(e):e;return F({[I]:"RegExp",type:"RegExp",source:n.source,flags:n.flags},t)}function Sh(e){return Le(e)?e.allOf:ie(e)?e.anyOf:Kt(e)?e.items??[]:[]}function pu(e){return Sh(e)}function mu(e,t){return rr(e)?F(e.returns,t):Z(t)}class yu{constructor(e){this.schema=e}Decode(e){return new hu(this.schema,e)}}class hu{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let i={Encode:(s)=>t[we].Encode(e(s)),Decode:(s)=>this.decode(t[we].Decode(s))};return{...t,[we]:i}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[we]:n}}Encode(e){return fe(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}}function gu(e){return new yu(e)}function xs(e={}){return F({[I]:e[I]??"Unsafe"},e)}function bu(e){return F({[I]:"Void",type:"void"},e)}var Wt=ka;var Oc=P(hi(),1);function Th(e){switch(e.errorType){case S.ArrayContains:return"Expected array to contain at least one matching value";case S.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case S.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case S.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case S.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case S.ArrayUniqueItems:return"Expected array elements to be unique";case S.Array:return"Expected array";case S.AsyncIterator:return"Expected AsyncIterator";case S.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case S.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case S.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case S.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case S.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case S.BigInt:return"Expected bigint";case S.Boolean:return"Expected boolean";case S.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case S.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case S.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case S.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case S.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case S.Date:return"Expected Date";case S.Function:return"Expected function";case S.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case S.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case S.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case S.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case S.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case S.Integer:return"Expected integer";case S.IntersectUnevaluatedProperties:return"Unexpected property";case S.Intersect:return"Expected all values to match";case S.Iterator:return"Expected Iterator";case S.Literal:return`Expected ${typeof e.schema.const==="string"?`'${e.schema.const}'`:e.schema.const}`;case S.Never:return"Never";case S.Not:return"Value should not match";case S.Null:return"Expected null";case S.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case S.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case S.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case S.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case S.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case S.Number:return"Expected number";case S.Object:return"Expected object";case S.ObjectAdditionalProperties:return"Unexpected property";case S.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case S.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case S.ObjectRequiredProperty:return"Expected required property";case S.Promise:return"Expected Promise";case S.RegExp:return"Expected string to match regular expression";case S.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case S.StringFormat:return`Expected string to match '${e.schema.format}' format`;case S.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case S.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case S.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case S.String:return"Expected string";case S.Symbol:return"Expected symbol";case S.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case S.Tuple:return"Expected tuple";case S.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case S.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case S.Uint8Array:return"Expected Uint8Array";case S.Undefined:return"Expected undefined";case S.Union:return"Expected union value";case S.Void:return"Expected void";case S.Kind:return`Expected kind '${e.schema[I]}'`;default:return"Unknown error type"}}var Ph=Th;function Ru(){return Ph}class $u extends re{constructor(e){super(`Unable to dereference schema with $id '${e.$ref}'`);this.schema=e}}function jh(e,t){let n=t.find((o)=>o.$id===e.$ref);if(n===void 0)throw new $u(e);return Ie(n,t)}function Ft(e,t){if(!Qe(e.$id)||t.some((n)=>n.$id===e.$id))return t;return t.push(e),t}function Ie(e,t){return e[I]==="This"||e[I]==="Ref"?jh(e,t):e}class wu extends re{constructor(e){super("Unable to hash value");this.value=e}}var Dt;(function(e){e[e.Undefined=0]="Undefined",e[e.Null=1]="Null",e[e.Boolean=2]="Boolean",e[e.Number=3]="Number",e[e.String=4]="String",e[e.Object=5]="Object",e[e.Array=6]="Array",e[e.Date=7]="Date",e[e.Uint8Array=8]="Uint8Array",e[e.Symbol=9]="Symbol",e[e.BigInt=10]="BigInt"})(Dt||(Dt={}));var Mo=BigInt("14695981039346656037"),[kh,Nh]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Uh=Array.from({length:256}).map((e,t)=>BigInt(t)),Au=new Float64Array(1),Su=new DataView(Au.buffer),Fu=new Uint8Array(Au.buffer);function*Mh(e){let t=e===0?1:Math.ceil(Math.floor(Math.log2(e)+1)/8);for(let n=0;n<t;n++)yield e>>8*(t-1-n)&255}function Kh(e){ht(Dt.Array);for(let t of e)Ko(t)}function Lh(e){ht(Dt.Boolean),ht(e?1:0)}function Dh(e){ht(Dt.BigInt),Su.setBigInt64(0,e);for(let t of Fu)ht(t)}function Bh(e){ht(Dt.Date),Ko(e.getTime())}function vh(e){ht(Dt.Null)}function Hh(e){ht(Dt.Number),Su.setFloat64(0,e);for(let t of Fu)ht(t)}function Vh(e){ht(Dt.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())Ko(t),Ko(e[t])}function qh(e){ht(Dt.String);for(let t=0;t<e.length;t++)for(let n of Mh(e.charCodeAt(t)))ht(n)}function _h(e){ht(Dt.Symbol),Ko(e.description)}function Gh(e){ht(Dt.Uint8Array);for(let t=0;t<e.length;t++)ht(e[t])}function zh(e){return ht(Dt.Undefined)}function Ko(e){if(pe(e))return Kh(e);if(kn(e))return Lh(e);if(kt(e))return Dh(e);if($r(e))return Bh(e);if(jn(e))return vh(e);if(Q(e))return Hh(e);if(be(e))return Vh(e);if(Qe(e))return qh(e);if(Nn(e))return _h(e);if(yo(e))return Gh(e);if(Ge(e))return zh(e);throw new wu(e)}function ht(e){Mo=Mo^Uh[e],Mo=Mo*kh%Nh}function Lo(e){return Mo=BigInt("14695981039346656037"),Ko(e),Mo}class Eu extends re{constructor(e){super("Unknown type");this.schema=e}}function Jh(e){return e[I]==="Any"||e[I]==="Unknown"}function ee(e){return e!==void 0}function Wh(e,t,n){return!0}function Qh(e,t,n){return!0}function Yh(e,t,n){if(!pe(n))return!1;if(ee(e.minItems)&&!(n.length>=e.minItems))return!1;if(ee(e.maxItems)&&!(n.length<=e.maxItems))return!1;for(let s of n)if(!ot(e.items,t,s))return!1;if(e.uniqueItems===!0&&!function(){let s=new Set;for(let c of n){let f=Lo(c);if(s.has(f))return!1;else s.add(f)}return!0}())return!1;if(!(ee(e.contains)||Q(e.minContains)||Q(e.maxContains)))return!0;let o=ee(e.contains)?e.contains:Z(),i=n.reduce((s,c)=>ot(o,t,c)?s+1:s,0);if(i===0)return!1;if(Q(e.minContains)&&i<e.minContains)return!1;if(Q(e.maxContains)&&i>e.maxContains)return!1;return!0}function Zh(e,t,n){return vi(n)}function Xh(e,t,n){if(!kt(n))return!1;if(ee(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))return!1;if(ee(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))return!1;if(ee(e.maximum)&&!(n<=e.maximum))return!1;if(ee(e.minimum)&&!(n>=e.minimum))return!1;if(ee(e.multipleOf)&&n%e.multipleOf!==BigInt(0))return!1;return!0}function eg(e,t,n){return kn(n)}function tg(e,t,n){return ot(e.returns,t,n.prototype)}function rg(e,t,n){if(!$r(n))return!1;if(ee(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp))return!1;if(ee(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp))return!1;if(ee(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp))return!1;if(ee(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp))return!1;if(ee(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)return!1;return!0}function ng(e,t,n){return un(n)}function og(e,t,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref];return ot(i,[...t,...o],n)}function ig(e,t,n){if(!_i(n))return!1;if(ee(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))return!1;if(ee(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))return!1;if(ee(e.maximum)&&!(n<=e.maximum))return!1;if(ee(e.minimum)&&!(n>=e.minimum))return!1;if(ee(e.multipleOf)&&n%e.multipleOf!==0)return!1;return!0}function sg(e,t,n){let o=e.allOf.every((i)=>ot(i,t,n));if(e.unevaluatedProperties===!1){let i=new RegExp(Vr(e)),s=Object.getOwnPropertyNames(n).every((c)=>i.test(c));return o&&s}else if(Pe(e.unevaluatedProperties)){let i=new RegExp(Vr(e)),s=Object.getOwnPropertyNames(n).every((c)=>i.test(c)||ot(e.unevaluatedProperties,t,n[c]));return o&&s}else return o}function ag(e,t,n){return Vi(n)}function cg(e,t,n){return n===e.const}function fg(e,t,n){return!1}function ug(e,t,n){return!ot(e.not,t,n)}function dg(e,t,n){return jn(n)}function lg(e,t,n){if(!$e.IsNumberLike(n))return!1;if(ee(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))return!1;if(ee(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))return!1;if(ee(e.minimum)&&!(n>=e.minimum))return!1;if(ee(e.maximum)&&!(n<=e.maximum))return!1;if(ee(e.multipleOf)&&n%e.multipleOf!==0)return!1;return!0}function pg(e,t,n){if(!$e.IsObjectLike(n))return!1;if(ee(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))return!1;if(ee(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))return!1;let o=Object.getOwnPropertyNames(e.properties);for(let i of o){let s=e.properties[i];if(e.required&&e.required.includes(i)){if(!ot(s,t,n[i]))return!1;if((qr(s)||Jh(s))&&!(i in n))return!1}else if($e.IsExactOptionalProperty(n,i)&&!ot(s,t,n[i]))return!1}if(e.additionalProperties===!1){let i=Object.getOwnPropertyNames(n);if(e.required&&e.required.length===o.length&&i.length===o.length)return!0;else return i.every((s)=>o.includes(s))}else if(typeof e.additionalProperties==="object")return Object.getOwnPropertyNames(n).every((s)=>o.includes(s)||ot(e.additionalProperties,t,n[s]));else return!0}function mg(e,t,n){return qi(n)}function yg(e,t,n){if(!$e.IsRecordLike(n))return!1;if(ee(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))return!1;if(ee(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))return!1;let[o,i]=Object.entries(e.patternProperties)[0],s=new RegExp(o),c=Object.entries(n).every(([l,d])=>s.test(l)?ot(i,t,d):!0),f=typeof e.additionalProperties==="object"?Object.entries(n).every(([l,d])=>!s.test(l)?ot(e.additionalProperties,t,d):!0):!0,u=e.additionalProperties===!1?Object.getOwnPropertyNames(n).every((l)=>s.test(l)):!0;return c&&f&&u}function hg(e,t,n){return ot(Ie(e,t),t,n)}function gg(e,t,n){let o=new RegExp(e.source,e.flags);if(ee(e.minLength)){if(!(n.length>=e.minLength))return!1}if(ee(e.maxLength)){if(!(n.length<=e.maxLength))return!1}return o.test(n)}function bg(e,t,n){if(!Qe(n))return!1;if(ee(e.minLength)){if(!(n.length>=e.minLength))return!1}if(ee(e.maxLength)){if(!(n.length<=e.maxLength))return!1}if(ee(e.pattern)){if(!new RegExp(e.pattern).test(n))return!1}if(ee(e.format)){if(!cr(e.format))return!1;return ya(e.format)(n)}return!0}function xg(e,t,n){return Nn(n)}function Ig(e,t,n){return Qe(n)&&new RegExp(e.pattern).test(n)}function Og(e,t,n){return ot(Ie(e,t),t,n)}function Rg(e,t,n){if(!pe(n))return!1;if(e.items===void 0&&n.length!==0)return!1;if(n.length!==e.maxItems)return!1;if(!e.items)return!0;for(let o=0;o<e.items.length;o++)if(!ot(e.items[o],t,n[o]))return!1;return!0}function $g(e,t,n){return Ge(n)}function wg(e,t,n){return e.anyOf.some((o)=>ot(o,t,n))}function Ag(e,t,n){if(!yo(n))return!1;if(ee(e.maxByteLength)&&!(n.length<=e.maxByteLength))return!1;if(ee(e.minByteLength)&&!(n.length>=e.minByteLength))return!1;return!0}function Sg(e,t,n){return!0}function Fg(e,t,n){return $e.IsVoidLike(n)}function Eg(e,t,n){if(!qn(e[I]))return!1;return ga(e[I])(e,n)}function ot(e,t,n){let o=ee(e.$id)?Ft(e,t):t,i=e;switch(i[I]){case"Any":return Wh(i,o,n);case"Argument":return Qh(i,o,n);case"Array":return Yh(i,o,n);case"AsyncIterator":return Zh(i,o,n);case"BigInt":return Xh(i,o,n);case"Boolean":return eg(i,o,n);case"Constructor":return tg(i,o,n);case"Date":return rg(i,o,n);case"Function":return ng(i,o,n);case"Import":return og(i,o,n);case"Integer":return ig(i,o,n);case"Intersect":return sg(i,o,n);case"Iterator":return ag(i,o,n);case"Literal":return cg(i,o,n);case"Never":return fg(i,o,n);case"Not":return ug(i,o,n);case"Null":return dg(i,o,n);case"Number":return lg(i,o,n);case"Object":return pg(i,o,n);case"Promise":return mg(i,o,n);case"Record":return yg(i,o,n);case"Ref":return hg(i,o,n);case"RegExp":return gg(i,o,n);case"String":return bg(i,o,n);case"Symbol":return xg(i,o,n);case"TemplateLiteral":return Ig(i,o,n);case"This":return Og(i,o,n);case"Tuple":return Rg(i,o,n);case"Undefined":return $g(i,o,n);case"Union":return wg(i,o,n);case"Uint8Array":return Ag(i,o,n);case"Unknown":return Sg(i,o,n);case"Void":return Fg(i,o,n);default:if(!qn(i[I]))throw new Eu(i);return Eg(i,o,n)}}function ke(...e){return e.length===3?ot(e[0],e[1],e[2]):ot(e[0],[],e[1])}var S;(function(e){e[e.ArrayContains=0]="ArrayContains",e[e.ArrayMaxContains=1]="ArrayMaxContains",e[e.ArrayMaxItems=2]="ArrayMaxItems",e[e.ArrayMinContains=3]="ArrayMinContains",e[e.ArrayMinItems=4]="ArrayMinItems",e[e.ArrayUniqueItems=5]="ArrayUniqueItems",e[e.Array=6]="Array",e[e.AsyncIterator=7]="AsyncIterator",e[e.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",e[e.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",e[e.BigIntMaximum=10]="BigIntMaximum",e[e.BigIntMinimum=11]="BigIntMinimum",e[e.BigIntMultipleOf=12]="BigIntMultipleOf",e[e.BigInt=13]="BigInt",e[e.Boolean=14]="Boolean",e[e.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",e[e.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",e[e.DateMaximumTimestamp=17]="DateMaximumTimestamp",e[e.DateMinimumTimestamp=18]="DateMinimumTimestamp",e[e.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",e[e.Date=20]="Date",e[e.Function=21]="Function",e[e.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",e[e.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",e[e.IntegerMaximum=24]="IntegerMaximum",e[e.IntegerMinimum=25]="IntegerMinimum",e[e.IntegerMultipleOf=26]="IntegerMultipleOf",e[e.Integer=27]="Integer",e[e.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",e[e.Intersect=29]="Intersect",e[e.Iterator=30]="Iterator",e[e.Kind=31]="Kind",e[e.Literal=32]="Literal",e[e.Never=33]="Never",e[e.Not=34]="Not",e[e.Null=35]="Null",e[e.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",e[e.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",e[e.NumberMaximum=38]="NumberMaximum",e[e.NumberMinimum=39]="NumberMinimum",e[e.NumberMultipleOf=40]="NumberMultipleOf",e[e.Number=41]="Number",e[e.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",e[e.ObjectMaxProperties=43]="ObjectMaxProperties",e[e.ObjectMinProperties=44]="ObjectMinProperties",e[e.ObjectRequiredProperty=45]="ObjectRequiredProperty",e[e.Object=46]="Object",e[e.Promise=47]="Promise",e[e.RegExp=48]="RegExp",e[e.StringFormatUnknown=49]="StringFormatUnknown",e[e.StringFormat=50]="StringFormat",e[e.StringMaxLength=51]="StringMaxLength",e[e.StringMinLength=52]="StringMinLength",e[e.StringPattern=53]="StringPattern",e[e.String=54]="String",e[e.Symbol=55]="Symbol",e[e.TupleLength=56]="TupleLength",e[e.Tuple=57]="Tuple",e[e.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",e[e.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",e[e.Uint8Array=60]="Uint8Array",e[e.Undefined=61]="Undefined",e[e.Union=62]="Union",e[e.Void=63]="Void"})(S||(S={}));class Cu extends re{constructor(e){super("Unknown type");this.schema=e}}function _r(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function te(e){return e!==void 0}class Is{constructor(e){this.iterator=e}[Symbol.iterator](){return this.iterator}First(){let e=this.iterator.next();return e.done?void 0:e.value}}function B(e,t,n,o,i=[]){return{type:e,schema:t,path:n,value:o,message:Ru()({errorType:e,path:n,schema:t,value:o,errors:i}),errors:i}}function*Cg(e,t,n,o){}function*Tg(e,t,n,o){}function*Pg(e,t,n,o){if(!pe(o))return yield B(S.Array,e,n,o);if(te(e.minItems)&&!(o.length>=e.minItems))yield B(S.ArrayMinItems,e,n,o);if(te(e.maxItems)&&!(o.length<=e.maxItems))yield B(S.ArrayMaxItems,e,n,o);for(let c=0;c<o.length;c++)yield*it(e.items,t,`${n}/${c}`,o[c]);if(e.uniqueItems===!0&&!function(){let c=new Set;for(let f of o){let u=Lo(f);if(c.has(u))return!1;else c.add(u)}return!0}())yield B(S.ArrayUniqueItems,e,n,o);if(!(te(e.contains)||te(e.minContains)||te(e.maxContains)))return;let i=te(e.contains)?e.contains:Z(),s=o.reduce((c,f,u)=>it(i,t,`${n}${u}`,f).next().done===!0?c+1:c,0);if(s===0)yield B(S.ArrayContains,e,n,o);if(Q(e.minContains)&&s<e.minContains)yield B(S.ArrayMinContains,e,n,o);if(Q(e.maxContains)&&s>e.maxContains)yield B(S.ArrayMaxContains,e,n,o)}function*jg(e,t,n,o){if(!vi(o))yield B(S.AsyncIterator,e,n,o)}function*kg(e,t,n,o){if(!kt(o))return yield B(S.BigInt,e,n,o);if(te(e.exclusiveMaximum)&&!(o<e.exclusiveMaximum))yield B(S.BigIntExclusiveMaximum,e,n,o);if(te(e.exclusiveMinimum)&&!(o>e.exclusiveMinimum))yield B(S.BigIntExclusiveMinimum,e,n,o);if(te(e.maximum)&&!(o<=e.maximum))yield B(S.BigIntMaximum,e,n,o);if(te(e.minimum)&&!(o>=e.minimum))yield B(S.BigIntMinimum,e,n,o);if(te(e.multipleOf)&&o%e.multipleOf!==BigInt(0))yield B(S.BigIntMultipleOf,e,n,o)}function*Ng(e,t,n,o){if(!kn(o))yield B(S.Boolean,e,n,o)}function*Ug(e,t,n,o){yield*it(e.returns,t,n,o.prototype)}function*Mg(e,t,n,o){if(!$r(o))return yield B(S.Date,e,n,o);if(te(e.exclusiveMaximumTimestamp)&&!(o.getTime()<e.exclusiveMaximumTimestamp))yield B(S.DateExclusiveMaximumTimestamp,e,n,o);if(te(e.exclusiveMinimumTimestamp)&&!(o.getTime()>e.exclusiveMinimumTimestamp))yield B(S.DateExclusiveMinimumTimestamp,e,n,o);if(te(e.maximumTimestamp)&&!(o.getTime()<=e.maximumTimestamp))yield B(S.DateMaximumTimestamp,e,n,o);if(te(e.minimumTimestamp)&&!(o.getTime()>=e.minimumTimestamp))yield B(S.DateMinimumTimestamp,e,n,o);if(te(e.multipleOfTimestamp)&&o.getTime()%e.multipleOfTimestamp!==0)yield B(S.DateMultipleOfTimestamp,e,n,o)}function*Kg(e,t,n,o){if(!un(o))yield B(S.Function,e,n,o)}function*Lg(e,t,n,o){let i=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref];yield*it(s,[...t,...i],n,o)}function*Dg(e,t,n,o){if(!_i(o))return yield B(S.Integer,e,n,o);if(te(e.exclusiveMaximum)&&!(o<e.exclusiveMaximum))yield B(S.IntegerExclusiveMaximum,e,n,o);if(te(e.exclusiveMinimum)&&!(o>e.exclusiveMinimum))yield B(S.IntegerExclusiveMinimum,e,n,o);if(te(e.maximum)&&!(o<=e.maximum))yield B(S.IntegerMaximum,e,n,o);if(te(e.minimum)&&!(o>=e.minimum))yield B(S.IntegerMinimum,e,n,o);if(te(e.multipleOf)&&o%e.multipleOf!==0)yield B(S.IntegerMultipleOf,e,n,o)}function*Bg(e,t,n,o){let i=!1;for(let s of e.allOf)for(let c of it(s,t,n,o))i=!0,yield c;if(i)return yield B(S.Intersect,e,n,o);if(e.unevaluatedProperties===!1){let s=new RegExp(Vr(e));for(let c of Object.getOwnPropertyNames(o))if(!s.test(c))yield B(S.IntersectUnevaluatedProperties,e,`${n}/${c}`,o)}if(typeof e.unevaluatedProperties==="object"){let s=new RegExp(Vr(e));for(let c of Object.getOwnPropertyNames(o))if(!s.test(c)){let f=it(e.unevaluatedProperties,t,`${n}/${c}`,o[c]).next();if(!f.done)yield f.value}}}function*vg(e,t,n,o){if(!Vi(o))yield B(S.Iterator,e,n,o)}function*Hg(e,t,n,o){if(o!==e.const)yield B(S.Literal,e,n,o)}function*Vg(e,t,n,o){yield B(S.Never,e,n,o)}function*qg(e,t,n,o){if(it(e.not,t,n,o).next().done===!0)yield B(S.Not,e,n,o)}function*_g(e,t,n,o){if(!jn(o))yield B(S.Null,e,n,o)}function*Gg(e,t,n,o){if(!$e.IsNumberLike(o))return yield B(S.Number,e,n,o);if(te(e.exclusiveMaximum)&&!(o<e.exclusiveMaximum))yield B(S.NumberExclusiveMaximum,e,n,o);if(te(e.exclusiveMinimum)&&!(o>e.exclusiveMinimum))yield B(S.NumberExclusiveMinimum,e,n,o);if(te(e.maximum)&&!(o<=e.maximum))yield B(S.NumberMaximum,e,n,o);if(te(e.minimum)&&!(o>=e.minimum))yield B(S.NumberMinimum,e,n,o);if(te(e.multipleOf)&&o%e.multipleOf!==0)yield B(S.NumberMultipleOf,e,n,o)}function*zg(e,t,n,o){if(!$e.IsObjectLike(o))return yield B(S.Object,e,n,o);if(te(e.minProperties)&&!(Object.getOwnPropertyNames(o).length>=e.minProperties))yield B(S.ObjectMinProperties,e,n,o);if(te(e.maxProperties)&&!(Object.getOwnPropertyNames(o).length<=e.maxProperties))yield B(S.ObjectMaxProperties,e,n,o);let i=Array.isArray(e.required)?e.required:[],s=Object.getOwnPropertyNames(e.properties),c=Object.getOwnPropertyNames(o);for(let f of i){if(c.includes(f))continue;yield B(S.ObjectRequiredProperty,e.properties[f],`${n}/${_r(f)}`,void 0)}if(e.additionalProperties===!1){for(let f of c)if(!s.includes(f))yield B(S.ObjectAdditionalProperties,e,`${n}/${_r(f)}`,o[f])}if(typeof e.additionalProperties==="object")for(let f of c){if(s.includes(f))continue;yield*it(e.additionalProperties,t,`${n}/${_r(f)}`,o[f])}for(let f of s){let u=e.properties[f];if(e.required&&e.required.includes(f)){if(yield*it(u,t,`${n}/${_r(f)}`,o[f]),qr(e)&&!(f in o))yield B(S.ObjectRequiredProperty,u,`${n}/${_r(f)}`,void 0)}else if($e.IsExactOptionalProperty(o,f))yield*it(u,t,`${n}/${_r(f)}`,o[f])}}function*Jg(e,t,n,o){if(!qi(o))yield B(S.Promise,e,n,o)}function*Wg(e,t,n,o){if(!$e.IsRecordLike(o))return yield B(S.Object,e,n,o);if(te(e.minProperties)&&!(Object.getOwnPropertyNames(o).length>=e.minProperties))yield B(S.ObjectMinProperties,e,n,o);if(te(e.maxProperties)&&!(Object.getOwnPropertyNames(o).length<=e.maxProperties))yield B(S.ObjectMaxProperties,e,n,o);let[i,s]=Object.entries(e.patternProperties)[0],c=new RegExp(i);for(let[f,u]of Object.entries(o))if(c.test(f))yield*it(s,t,`${n}/${_r(f)}`,u);if(typeof e.additionalProperties==="object"){for(let[f,u]of Object.entries(o))if(!c.test(f))yield*it(e.additionalProperties,t,`${n}/${_r(f)}`,u)}if(e.additionalProperties===!1)for(let[f,u]of Object.entries(o)){if(c.test(f))continue;return yield B(S.ObjectAdditionalProperties,e,`${n}/${_r(f)}`,u)}}function*Qg(e,t,n,o){yield*it(Ie(e,t),t,n,o)}function*Yg(e,t,n,o){if(!Qe(o))return yield B(S.String,e,n,o);if(te(e.minLength)&&!(o.length>=e.minLength))yield B(S.StringMinLength,e,n,o);if(te(e.maxLength)&&!(o.length<=e.maxLength))yield B(S.StringMaxLength,e,n,o);if(!new RegExp(e.source,e.flags).test(o))return yield B(S.RegExp,e,n,o)}function*Zg(e,t,n,o){if(!Qe(o))return yield B(S.String,e,n,o);if(te(e.minLength)&&!(o.length>=e.minLength))yield B(S.StringMinLength,e,n,o);if(te(e.maxLength)&&!(o.length<=e.maxLength))yield B(S.StringMaxLength,e,n,o);if(Qe(e.pattern)){if(!new RegExp(e.pattern).test(o))yield B(S.StringPattern,e,n,o)}if(Qe(e.format)){if(!cr(e.format))yield B(S.StringFormatUnknown,e,n,o);else if(!ya(e.format)(o))yield B(S.StringFormat,e,n,o)}}function*Xg(e,t,n,o){if(!Nn(o))yield B(S.Symbol,e,n,o)}function*e0(e,t,n,o){if(!Qe(o))return yield B(S.String,e,n,o);if(!new RegExp(e.pattern).test(o))yield B(S.StringPattern,e,n,o)}function*t0(e,t,n,o){yield*it(Ie(e,t),t,n,o)}function*r0(e,t,n,o){if(!pe(o))return yield B(S.Tuple,e,n,o);if(e.items===void 0&&o.length!==0)return yield B(S.TupleLength,e,n,o);if(o.length!==e.maxItems)return yield B(S.TupleLength,e,n,o);if(!e.items)return;for(let i=0;i<e.items.length;i++)yield*it(e.items[i],t,`${n}/${i}`,o[i])}function*n0(e,t,n,o){if(!Ge(o))yield B(S.Undefined,e,n,o)}function*o0(e,t,n,o){if(ke(e,t,o))return;let i=e.anyOf.map((s)=>new Is(it(s,t,n,o)));yield B(S.Union,e,n,o,i)}function*i0(e,t,n,o){if(!yo(o))return yield B(S.Uint8Array,e,n,o);if(te(e.maxByteLength)&&!(o.length<=e.maxByteLength))yield B(S.Uint8ArrayMaxByteLength,e,n,o);if(te(e.minByteLength)&&!(o.length>=e.minByteLength))yield B(S.Uint8ArrayMinByteLength,e,n,o)}function*s0(e,t,n,o){}function*a0(e,t,n,o){if(!$e.IsVoidLike(o))yield B(S.Void,e,n,o)}function*c0(e,t,n,o){if(!ga(e[I])(e,o))yield B(S.Kind,e,n,o)}function*it(e,t,n,o){let i=te(e.$id)?[...t,e]:t,s=e;switch(s[I]){case"Any":return yield*Cg(s,i,n,o);case"Argument":return yield*Tg(s,i,n,o);case"Array":return yield*Pg(s,i,n,o);case"AsyncIterator":return yield*jg(s,i,n,o);case"BigInt":return yield*kg(s,i,n,o);case"Boolean":return yield*Ng(s,i,n,o);case"Constructor":return yield*Ug(s,i,n,o);case"Date":return yield*Mg(s,i,n,o);case"Function":return yield*Kg(s,i,n,o);case"Import":return yield*Lg(s,i,n,o);case"Integer":return yield*Dg(s,i,n,o);case"Intersect":return yield*Bg(s,i,n,o);case"Iterator":return yield*vg(s,i,n,o);case"Literal":return yield*Hg(s,i,n,o);case"Never":return yield*Vg(s,i,n,o);case"Not":return yield*qg(s,i,n,o);case"Null":return yield*_g(s,i,n,o);case"Number":return yield*Gg(s,i,n,o);case"Object":return yield*zg(s,i,n,o);case"Promise":return yield*Jg(s,i,n,o);case"Record":return yield*Wg(s,i,n,o);case"Ref":return yield*Qg(s,i,n,o);case"RegExp":return yield*Yg(s,i,n,o);case"String":return yield*Zg(s,i,n,o);case"Symbol":return yield*Xg(s,i,n,o);case"TemplateLiteral":return yield*e0(s,i,n,o);case"This":return yield*t0(s,i,n,o);case"Tuple":return yield*r0(s,i,n,o);case"Undefined":return yield*n0(s,i,n,o);case"Union":return yield*o0(s,i,n,o);case"Uint8Array":return yield*i0(s,i,n,o);case"Unknown":return yield*s0(s,i,n,o);case"Void":return yield*a0(s,i,n,o);default:if(!qn(s[I]))throw new Cu(e);return yield*c0(s,i,n,o)}}function Et(...e){let t=e.length===3?it(e[0],e[1],"",e[2]):it(e[0],[],"",e[1]);return new Is(t)}function f0(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=Qt(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=Qt(e[n]);return t}function u0(e){return e.map((t)=>Qt(t))}function d0(e){return e.slice()}function l0(e){return new Map(Qt([...e.entries()]))}function p0(e){return new Set(Qt([...e.entries()]))}function m0(e){return new Date(e.toISOString())}function y0(e){return e}function Qt(e){if(pe(e))return u0(e);if($r(e))return m0(e);if(jc(e))return d0(e);if(Tc(e))return l0(e);if(Pc(e))return p0(e);if(be(e))return f0(e);if(ho(e))return y0(e);throw Error("ValueClone: Unable to clone value")}class Yt extends re{constructor(e,t){super(t);this.schema=e}}function ce(e){return un(e)?e():Qt(e)}function h0(e,t){if(Y(e,"default"))return ce(e.default);else return{}}function g0(e,t){return{}}function b0(e,t){if(e.uniqueItems===!0&&!Y(e,"default"))throw new Yt(e,"Array with the uniqueItems constraint requires a default value");else if("contains"in e&&!Y(e,"default"))throw new Yt(e,"Array with the contains constraint requires a default value");else if("default"in e)return ce(e.default);else if(e.minItems!==void 0)return Array.from({length:e.minItems}).map((n)=>Bt(e.items,t));else return[]}function x0(e,t){if(Y(e,"default"))return ce(e.default);else return async function*(){}()}function I0(e,t){if(Y(e,"default"))return ce(e.default);else return BigInt(0)}function O0(e,t){if(Y(e,"default"))return ce(e.default);else return!1}function R0(e,t){if(Y(e,"default"))return ce(e.default);else{let n=Bt(e.returns,t);if(typeof n==="object"&&!Array.isArray(n))return class{constructor(){for(let[o,i]of Object.entries(n)){let s=this;s[o]=i}}};else return class{}}}function $0(e,t){if(Y(e,"default"))return ce(e.default);else if(e.minimumTimestamp!==void 0)return new Date(e.minimumTimestamp);else return new Date}function w0(e,t){if(Y(e,"default"))return ce(e.default);else return()=>Bt(e.returns,t)}function A0(e,t){let n=globalThis.Object.values(e.$defs),o=e.$defs[e.$ref];return Bt(o,[...t,...n])}function S0(e,t){if(Y(e,"default"))return ce(e.default);else if(e.minimum!==void 0)return e.minimum;else return 0}function F0(e,t){if(Y(e,"default"))return ce(e.default);else{let n=e.allOf.reduce((o,i)=>{let s=Bt(i,t);return typeof s==="object"?{...o,...s}:s},{});if(!ke(e,t,n))throw new Yt(e,"Intersect produced invalid value. Consider using a default value.");return n}}function E0(e,t){if(Y(e,"default"))return ce(e.default);else return function*(){}()}function C0(e,t){if(Y(e,"default"))return ce(e.default);else return e.const}function T0(e,t){if(Y(e,"default"))return ce(e.default);else throw new Yt(e,"Never types cannot be created. Consider using a default value.")}function P0(e,t){if(Y(e,"default"))return ce(e.default);else throw new Yt(e,"Not types must have a default value")}function j0(e,t){if(Y(e,"default"))return ce(e.default);else return null}function k0(e,t){if(Y(e,"default"))return ce(e.default);else if(e.minimum!==void 0)return e.minimum;else return 0}function N0(e,t){if(Y(e,"default"))return ce(e.default);else{let n=new Set(e.required),o={};for(let[i,s]of Object.entries(e.properties)){if(!n.has(i))continue;o[i]=Bt(s,t)}return o}}function U0(e,t){if(Y(e,"default"))return ce(e.default);else return Promise.resolve(Bt(e.item,t))}function M0(e,t){if(Y(e,"default"))return ce(e.default);else return{}}function K0(e,t){if(Y(e,"default"))return ce(e.default);else return Bt(Ie(e,t),t)}function L0(e,t){if(Y(e,"default"))return ce(e.default);else throw new Yt(e,"RegExp types cannot be created. Consider using a default value.")}function D0(e,t){if(e.pattern!==void 0)if(!Y(e,"default"))throw new Yt(e,"String types with patterns must specify a default value");else return ce(e.default);else if(e.format!==void 0)if(!Y(e,"default"))throw new Yt(e,"String types with formats must specify a default value");else return ce(e.default);else if(Y(e,"default"))return ce(e.default);else if(e.minLength!==void 0)return Array.from({length:e.minLength}).map(()=>" ").join("");else return""}function B0(e,t){if(Y(e,"default"))return ce(e.default);else if("value"in e)return Symbol.for(e.value);else return Symbol()}function v0(e,t){if(Y(e,"default"))return ce(e.default);if(!ts(e))throw new Yt(e,"Can only create template literals that produce a finite variants. Consider using a default value.");return Ao(e)[0]}function H0(e,t){if(Tu++>Q0)throw new Yt(e,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(Y(e,"default"))return ce(e.default);else return Bt(Ie(e,t),t)}function V0(e,t){if(Y(e,"default"))return ce(e.default);if(e.items===void 0)return[];else return Array.from({length:e.minItems}).map((n,o)=>Bt(e.items[o],t))}function q0(e,t){if(Y(e,"default"))return ce(e.default);else return}function _0(e,t){if(Y(e,"default"))return ce(e.default);else if(e.anyOf.length===0)throw Error("ValueCreate.Union: Cannot create Union with zero variants");else return Bt(e.anyOf[0],t)}function G0(e,t){if(Y(e,"default"))return ce(e.default);else if(e.minByteLength!==void 0)return new Uint8Array(e.minByteLength);else return new Uint8Array(0)}function z0(e,t){if(Y(e,"default"))return ce(e.default);else return{}}function J0(e,t){if(Y(e,"default"))return ce(e.default);else return}function W0(e,t){if(Y(e,"default"))return ce(e.default);else throw Error("User defined types must specify a default value")}function Bt(e,t){let n=Ft(e,t),o=e;switch(o[I]){case"Any":return h0(o,n);case"Argument":return g0(o,n);case"Array":return b0(o,n);case"AsyncIterator":return x0(o,n);case"BigInt":return I0(o,n);case"Boolean":return O0(o,n);case"Constructor":return R0(o,n);case"Date":return $0(o,n);case"Function":return w0(o,n);case"Import":return A0(o,n);case"Integer":return S0(o,n);case"Intersect":return F0(o,n);case"Iterator":return E0(o,n);case"Literal":return C0(o,n);case"Never":return T0(o,n);case"Not":return P0(o,n);case"Null":return j0(o,n);case"Number":return k0(o,n);case"Object":return N0(o,n);case"Promise":return U0(o,n);case"Record":return M0(o,n);case"Ref":return K0(o,n);case"RegExp":return L0(o,n);case"String":return D0(o,n);case"Symbol":return B0(o,n);case"TemplateLiteral":return v0(o,n);case"This":return H0(o,n);case"Tuple":return V0(o,n);case"Undefined":return q0(o,n);case"Union":return _0(o,n);case"Uint8Array":return G0(o,n);case"Unknown":return z0(o,n);case"Void":return J0(o,n);default:if(!qn(o[I]))throw new Yt(o,"Unknown type");return W0(o,n)}}var Q0=512,Tu=0;function gi(...e){return Tu=0,e.length===2?Bt(e[0],e[1]):Bt(e[0],[])}function Y0(e){return ln(e)&&e[I]!=="Unsafe"}function Z0(e,t,n){if(!pe(n))return n;return n.map((o)=>Ct(e.items,t,o))}function X0(e,t,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref];return Ct(i,[...t,...o],n)}function eb(e,t,n){let o=e.unevaluatedProperties,s=e.allOf.map((f)=>Ct(f,t,Qt(n))).reduce((f,u)=>be(u)?{...f,...u}:u,{});if(!be(n)||!be(s)||!ln(o))return s;let c=At(e);for(let f of Object.getOwnPropertyNames(n)){if(c.includes(f))continue;if(ke(o,t,n[f]))s[f]=Ct(o,t,n[f])}return s}function tb(e,t,n){if(!be(n)||pe(n))return n;let o=e.additionalProperties;for(let i of Object.getOwnPropertyNames(n)){if(Y(e.properties,i)){n[i]=Ct(e.properties[i],t,n[i]);continue}if(ln(o)&&ke(o,t,n[i])){n[i]=Ct(o,t,n[i]);continue}delete n[i]}return n}function rb(e,t,n){if(!be(n))return n;let o=e.additionalProperties,i=Object.getOwnPropertyNames(n),[s,c]=Object.entries(e.patternProperties)[0],f=new RegExp(s);for(let u of i){if(f.test(u)){n[u]=Ct(c,t,n[u]);continue}if(ln(o)&&ke(o,t,n[u])){n[u]=Ct(o,t,n[u]);continue}delete n[u]}return n}function nb(e,t,n){return Ct(Ie(e,t),t,n)}function ob(e,t,n){return Ct(Ie(e,t),t,n)}function ib(e,t,n){if(!pe(n))return n;if(Ge(e.items))return[];let o=Math.min(n.length,e.items.length);for(let i=0;i<o;i++)n[i]=Ct(e.items[i],t,n[i]);return n.length>o?n.slice(0,o):n}function sb(e,t,n){for(let o of e.anyOf)if(Y0(o)&&ke(o,t,n))return Ct(o,t,n);return n}function Ct(e,t,n){let o=Qe(e.$id)?Ft(e,t):t,i=e;switch(i[I]){case"Array":return Z0(i,o,n);case"Import":return X0(i,o,n);case"Intersect":return eb(i,o,n);case"Object":return tb(i,o,n);case"Record":return rb(i,o,n);case"Ref":return nb(i,o,n);case"This":return ob(i,o,n);case"Tuple":return ib(i,o,n);case"Union":return sb(i,o,n);default:return n}}function Pu(...e){return e.length===3?Ct(e[0],e[1],e[2]):Ct(e[0],[],e[1])}class bi extends re{constructor(e,t,n){super("Unable to decode value as it does not match the expected schema");this.schema=e,this.value=t,this.error=n}}class Jn extends re{constructor(e,t,n,o){super(o instanceof Error?o.message:"Unknown error");this.schema=e,this.path=t,this.value=n,this.error=o}}function Ne(e,t,n){try{return fe(e)?e[we].Decode(n):n}catch(o){throw new Jn(e,t,n,o)}}function ab(e,t,n,o){return pe(o)?Ne(e,n,o.map((i,s)=>lr(e.items,t,`${n}/${s}`,i))):Ne(e,n,o)}function cb(e,t,n,o){if(!be(o)||ho(o))return Ne(e,n,o);let i=ss(e),s=i.map((d)=>d[0]),c={...o};for(let[d,y]of i)if(d in c)c[d]=lr(y,t,`${n}/${d}`,c[d]);if(!fe(e.unevaluatedProperties))return Ne(e,n,c);let f=Object.getOwnPropertyNames(c),u=e.unevaluatedProperties,l={...c};for(let d of f)if(!s.includes(d))l[d]=Ne(u,`${n}/${d}`,l[d]);return Ne(e,n,l)}function fb(e,t,n,o){let i=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],c=lr(s,[...t,...i],n,o);return Ne(e,n,c)}function ub(e,t,n,o){return Ne(e,n,lr(e.not,t,n,o))}function db(e,t,n,o){if(!be(o))return Ne(e,n,o);let i=At(e),s={...o};for(let l of i){if(!Y(s,l))continue;if(Ge(s[l])&&(!Kr(e.properties[l])||$e.IsExactOptionalProperty(s,l)))continue;s[l]=lr(e.properties[l],t,`${n}/${l}`,s[l])}if(!Pe(e.additionalProperties))return Ne(e,n,s);let c=Object.getOwnPropertyNames(s),f=e.additionalProperties,u={...s};for(let l of c)if(!i.includes(l))u[l]=Ne(f,`${n}/${l}`,u[l]);return Ne(e,n,u)}function lb(e,t,n,o){if(!be(o))return Ne(e,n,o);let i=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(i),c={...o};for(let d of Object.getOwnPropertyNames(o))if(s.test(d))c[d]=lr(e.patternProperties[i],t,`${n}/${d}`,c[d]);if(!Pe(e.additionalProperties))return Ne(e,n,c);let f=Object.getOwnPropertyNames(c),u=e.additionalProperties,l={...c};for(let d of f)if(!s.test(d))l[d]=Ne(u,`${n}/${d}`,l[d]);return Ne(e,n,l)}function pb(e,t,n,o){let i=Ie(e,t);return Ne(e,n,lr(i,t,n,o))}function mb(e,t,n,o){let i=Ie(e,t);return Ne(e,n,lr(i,t,n,o))}function yb(e,t,n,o){return pe(o)&&pe(e.items)?Ne(e,n,e.items.map((i,s)=>lr(i,t,`${n}/${s}`,o[s]))):Ne(e,n,o)}function hb(e,t,n,o){for(let i of e.anyOf){if(!ke(i,t,o))continue;let s=lr(i,t,n,o);return Ne(e,n,s)}return Ne(e,n,o)}function lr(e,t,n,o){let i=Ft(e,t),s=e;switch(e[I]){case"Array":return ab(s,i,n,o);case"Import":return fb(s,i,n,o);case"Intersect":return cb(s,i,n,o);case"Not":return ub(s,i,n,o);case"Object":return db(s,i,n,o);case"Record":return lb(s,i,n,o);case"Ref":return pb(s,i,n,o);case"Symbol":return Ne(s,n,o);case"This":return mb(s,i,n,o);case"Tuple":return yb(s,i,n,o);case"Union":return hb(s,i,n,o);default:return Ne(s,n,o)}}function Os(e,t,n){return lr(e,t,"",n)}class xi extends re{constructor(e,t,n){super("The encoded value does not match the expected schema");this.schema=e,this.value=t,this.error=n}}class ju extends re{constructor(e,t,n,o){super(`${o instanceof Error?o.message:"Unknown error"}`);this.schema=e,this.path=t,this.value=n,this.error=o}}function ft(e,t,n){try{return fe(e)?e[we].Encode(n):n}catch(o){throw new ju(e,t,n,o)}}function gb(e,t,n,o){let i=ft(e,n,o);return pe(i)?i.map((s,c)=>pr(e.items,t,`${n}/${c}`,s)):i}function bb(e,t,n,o){let i=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],c=ft(e,n,o);return pr(s,[...t,...i],n,c)}function xb(e,t,n,o){let i=ft(e,n,o);if(!be(o)||ho(o))return i;let s=ss(e),c=s.map((y)=>y[0]),f={...i};for(let[y,b]of s)if(y in f)f[y]=pr(b,t,`${n}/${y}`,f[y]);if(!fe(e.unevaluatedProperties))return f;let u=Object.getOwnPropertyNames(f),l=e.unevaluatedProperties,d={...f};for(let y of u)if(!c.includes(y))d[y]=ft(l,`${n}/${y}`,d[y]);return d}function Ib(e,t,n,o){return ft(e.not,n,ft(e,n,o))}function Ob(e,t,n,o){let i=ft(e,n,o);if(!be(i))return i;let s=At(e),c={...i};for(let d of s){if(!Y(c,d))continue;if(Ge(c[d])&&(!Kr(e.properties[d])||$e.IsExactOptionalProperty(c,d)))continue;c[d]=pr(e.properties[d],t,`${n}/${d}`,c[d])}if(!Pe(e.additionalProperties))return c;let f=Object.getOwnPropertyNames(c),u=e.additionalProperties,l={...c};for(let d of f)if(!s.includes(d))l[d]=ft(u,`${n}/${d}`,l[d]);return l}function Rb(e,t,n,o){let i=ft(e,n,o);if(!be(o))return i;let s=Object.getOwnPropertyNames(e.patternProperties)[0],c=new RegExp(s),f={...i};for(let y of Object.getOwnPropertyNames(o))if(c.test(y))f[y]=pr(e.patternProperties[s],t,`${n}/${y}`,f[y]);if(!Pe(e.additionalProperties))return f;let u=Object.getOwnPropertyNames(f),l=e.additionalProperties,d={...f};for(let y of u)if(!c.test(y))d[y]=ft(l,`${n}/${y}`,d[y]);return d}function $b(e,t,n,o){let i=Ie(e,t),s=pr(i,t,n,o);return ft(e,n,s)}function wb(e,t,n,o){let i=Ie(e,t),s=pr(i,t,n,o);return ft(e,n,s)}function Ab(e,t,n,o){let i=ft(e,n,o);return pe(e.items)?e.items.map((s,c)=>pr(s,t,`${n}/${c}`,i[c])):[]}function Sb(e,t,n,o){for(let i of e.anyOf){if(!ke(i,t,o))continue;let s=pr(i,t,n,o);return ft(e,n,s)}for(let i of e.anyOf){let s=pr(i,t,n,o);if(!ke(e,t,s))continue;return ft(e,n,s)}return ft(e,n,o)}function pr(e,t,n,o){let i=Ft(e,t),s=e;switch(e[I]){case"Array":return gb(s,i,n,o);case"Import":return bb(s,i,n,o);case"Intersect":return xb(s,i,n,o);case"Not":return Ib(s,i,n,o);case"Object":return Ob(s,i,n,o);case"Record":return Rb(s,i,n,o);case"Ref":return $b(s,i,n,o);case"This":return wb(s,i,n,o);case"Tuple":return Ab(s,i,n,o);case"Union":return Sb(s,i,n,o);default:return ft(s,n,o)}}function Rs(e,t,n){return pr(e,t,"",n)}function Fb(e,t){return fe(e)||rt(e.items,t)}function Eb(e,t){return fe(e)||rt(e.items,t)}function Cb(e,t){return fe(e)||rt(e.returns,t)||e.parameters.some((n)=>rt(n,t))}function Tb(e,t){return fe(e)||rt(e.returns,t)||e.parameters.some((n)=>rt(n,t))}function Pb(e,t){return fe(e)||fe(e.unevaluatedProperties)||e.allOf.some((n)=>rt(n,t))}function jb(e,t){let n=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((i,s)=>[...i,e.$defs[s]],[]),o=e.$defs[e.$ref];return fe(e)||rt(o,[...n,...t])}function kb(e,t){return fe(e)||rt(e.items,t)}function Nb(e,t){return fe(e)||rt(e.not,t)}function Ub(e,t){return fe(e)||Object.values(e.properties).some((n)=>rt(n,t))||Pe(e.additionalProperties)&&rt(e.additionalProperties,t)}function Mb(e,t){return fe(e)||rt(e.item,t)}function Kb(e,t){let n=Object.getOwnPropertyNames(e.patternProperties)[0],o=e.patternProperties[n];return fe(e)||rt(o,t)||Pe(e.additionalProperties)&&fe(e.additionalProperties)}function Lb(e,t){if(fe(e))return!0;return rt(Ie(e,t),t)}function Db(e,t){if(fe(e))return!0;return rt(Ie(e,t),t)}function Bb(e,t){return fe(e)||!Ge(e.items)&&e.items.some((n)=>rt(n,t))}function vb(e,t){return fe(e)||e.anyOf.some((n)=>rt(n,t))}function rt(e,t){let n=Ft(e,t),o=e;if(e.$id&&Ua.has(e.$id))return!1;if(e.$id)Ua.add(e.$id);switch(e[I]){case"Array":return Fb(o,n);case"AsyncIterator":return Eb(o,n);case"Constructor":return Cb(o,n);case"Function":return Tb(o,n);case"Import":return jb(o,n);case"Intersect":return Pb(o,n);case"Iterator":return kb(o,n);case"Not":return Nb(o,n);case"Object":return Ub(o,n);case"Promise":return Mb(o,n);case"Record":return Kb(o,n);case"Ref":return Lb(o,n);case"This":return Db(o,n);case"Tuple":return Bb(o,n);case"Union":return vb(o,n);default:return fe(e)}}var Ua=new Set;function Do(e,t){return Ua.clear(),rt(e,t)}function Ma(...e){let[t,n,o]=e.length===3?[e[0],e[1],e[2]]:[e[0],[],e[1]];if(!ke(t,n,o))throw new bi(t,o,Et(t,n,o).First());return Do(t,n)?Os(t,n,o):o}function Gr(e,t){let n=Y(e,"default")?e.default:void 0,o=un(n)?n():Qt(n);return Ge(t)?o:be(t)&&be(o)?Object.assign(o,t):t}function Ka(e){return ln(e)&&"default"in e}function Hb(e,t,n){if(pe(n)){for(let i=0;i<n.length;i++)n[i]=bt(e.items,t,n[i]);return n}let o=Gr(e,n);if(!pe(o))return o;for(let i=0;i<o.length;i++)o[i]=bt(e.items,t,o[i]);return o}function Vb(e,t,n){return $r(n)?n:Gr(e,n)}function qb(e,t,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref];return bt(i,[...t,...o],n)}function _b(e,t,n){let o=Gr(e,n);return e.allOf.reduce((i,s)=>{let c=bt(s,t,o);return be(c)?{...i,...c}:c},{})}function Gb(e,t,n){let o=Gr(e,n);if(!be(o))return o;let i=Object.getOwnPropertyNames(e.properties);for(let s of i){let c=bt(e.properties[s],t,o[s]);if(Ge(c))continue;o[s]=bt(e.properties[s],t,o[s])}if(!Ka(e.additionalProperties))return o;for(let s of Object.getOwnPropertyNames(o)){if(i.includes(s))continue;o[s]=bt(e.additionalProperties,t,o[s])}return o}function zb(e,t,n){let o=Gr(e,n);if(!be(o))return o;let i=e.additionalProperties,[s,c]=Object.entries(e.patternProperties)[0],f=new RegExp(s);for(let u of Object.getOwnPropertyNames(o)){if(!(f.test(u)&&Ka(c)))continue;o[u]=bt(c,t,o[u])}if(!Ka(i))return o;for(let u of Object.getOwnPropertyNames(o)){if(f.test(u))continue;o[u]=bt(i,t,o[u])}return o}function Jb(e,t,n){return bt(Ie(e,t),t,Gr(e,n))}function Wb(e,t,n){return bt(Ie(e,t),t,n)}function Qb(e,t,n){let o=Gr(e,n);if(!pe(o)||Ge(e.items))return o;let[i,s]=[e.items,Math.max(e.items.length,o.length)];for(let c=0;c<s;c++)if(c<i.length)o[c]=bt(i[c],t,o[c]);return o}function Yb(e,t,n){let o=Gr(e,n);for(let i of e.anyOf){let s=bt(i,t,Qt(o));if(ke(i,t,s))return s}return o}function bt(e,t,n){let o=Ft(e,t),i=e;switch(i[I]){case"Array":return Hb(i,o,n);case"Date":return Vb(i,o,n);case"Import":return qb(i,o,n);case"Intersect":return _b(i,o,n);case"Object":return Gb(i,o,n);case"Record":return zb(i,o,n);case"Ref":return Jb(i,o,n);case"This":return Wb(i,o,n);case"Tuple":return Qb(i,o,n);case"Union":return Yb(i,o,n);default:return Gr(i,n)}}function Ii(...e){return e.length===3?bt(e[0],e[1],e[2]):bt(e[0],[],e[1])}function ku(...e){let[t,n,o]=e.length===3?[e[0],e[1],e[2]]:[e[0],[],e[1]],i=Do(t,n)?Rs(t,n,o):o;if(!ke(t,n,i))throw new xi(t,i,Et(t,n,i).First());return i}class Nu{constructor(e,t,n,o){this.schema=e,this.references=t,this.checkFunc=n,this.code=o,this.hasTransform=Do(e,t)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(e){return Et(this.schema,this.references,e)}Check(e){return this.checkFunc(e)}Decode(e){if(!this.checkFunc(e))throw new bi(this.schema,e,this.Errors(e).First());return this.hasTransform?Os(this.schema,this.references,e):e}Encode(e){let t=this.hasTransform?Rs(this.schema,this.references,e):e;if(!this.checkFunc(t))throw new xi(this.schema,e,this.Errors(e).First());return t}}var zr;(function(e){function t(s){return s===36}e.DollarSign=t;function n(s){return s===95}e.IsUnderscore=n;function o(s){return s>=65&&s<=90||s>=97&&s<=122}e.IsAlpha=o;function i(s){return s>=48&&s<=57}e.IsNumeric=i})(zr||(zr={}));var $s;(function(e){function t(s){if(s.length===0)return!1;return zr.IsNumeric(s.charCodeAt(0))}function n(s){if(t(s))return!1;for(let c=0;c<s.length;c++){let f=s.charCodeAt(c);if(!(zr.IsAlpha(f)||zr.IsNumeric(f)||zr.DollarSign(f)||zr.IsUnderscore(f)))return!1}return!0}function o(s){return s.replace(/'/g,"\\'")}function i(s,c){return n(c)?`${s}.${c}`:`${s}['${o(c)}']`}e.Encode=i})($s||($s={}));var La;(function(e){function t(n){let o=[];for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(zr.IsNumeric(s)||zr.IsAlpha(s))o.push(n.charAt(i));else o.push(`_${s}_`)}return o.join("").replace(/__/g,"_")}e.Encode=t})(La||(La={}));var Da;(function(e){function t(n){return n.replace(/'/g,"\\'")}e.Escape=t})(Da||(Da={}));class Uu extends re{constructor(e){super("Unknown type");this.schema=e}}class Ba extends re{constructor(e){super("Preflight validation check failed to guard for the given schema");this.schema=e}}var Wn;(function(e){function t(c,f,u){return $e.ExactOptionalPropertyTypes?`('${f}' in ${c} ? ${u} : true)`:`(${$s.Encode(c,f)} !== undefined ? ${u} : true)`}e.IsExactOptionalProperty=t;function n(c){return!$e.AllowArrayObject?`(typeof ${c} === 'object' && ${c} !== null && !Array.isArray(${c}))`:`(typeof ${c} === 'object' && ${c} !== null)`}e.IsObjectLike=n;function o(c){return!$e.AllowArrayObject?`(typeof ${c} === 'object' && ${c} !== null && !Array.isArray(${c}) && !(${c} instanceof Date) && !(${c} instanceof Uint8Array))`:`(typeof ${c} === 'object' && ${c} !== null && !(${c} instanceof Date) && !(${c} instanceof Uint8Array))`}e.IsRecordLike=o;function i(c){return $e.AllowNaN?`typeof ${c} === 'number'`:`Number.isFinite(${c})`}e.IsNumberLike=i;function s(c){return $e.AllowNullVoid?`(${c} === undefined || ${c} === null)`:`${c} === undefined`}e.IsVoidLike=s})(Wn||(Wn={}));var mr;(function(e){function t(h){return h[I]==="Any"||h[I]==="Unknown"}function*n(h,w,m){yield"true"}function*o(h,w,m){yield"true"}function*i(h,w,m){yield`Array.isArray(${m})`;let[O,A]=[fo("value","any"),fo("acc","number")];if(Q(h.maxItems))yield`${m}.length <= ${h.maxItems}`;if(Q(h.minItems))yield`${m}.length >= ${h.minItems}`;let C=gt(h.items,w,"value");if(yield`((array) => { for(const ${O} of array) if(!(${C})) { return false }; return true; })(${m})`,je(h.contains)||Q(h.minContains)||Q(h.maxContains)){let v=je(h.contains)?h.contains:Z(),X=gt(v,w,"value"),me=Q(h.minContains)?[`(count >= ${h.minContains})`]:[],Se=Q(h.maxContains)?[`(count <= ${h.maxContains})`]:[],Ke=`const count = value.reduce((${A}, ${O}) => ${X} ? acc + 1 : acc, 0)`,Ht=["(count > 0)",...me,...Se].join(" && ");yield`((${O}) => { ${Ke}; return ${Ht}})(${m})`}if(h.uniqueItems===!0)yield`((${O}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${m})`}function*s(h,w,m){yield`(typeof value === 'object' && Symbol.asyncIterator in ${m})`}function*c(h,w,m){if(yield`(typeof ${m} === 'bigint')`,kt(h.exclusiveMaximum))yield`${m} < BigInt(${h.exclusiveMaximum})`;if(kt(h.exclusiveMinimum))yield`${m} > BigInt(${h.exclusiveMinimum})`;if(kt(h.maximum))yield`${m} <= BigInt(${h.maximum})`;if(kt(h.minimum))yield`${m} >= BigInt(${h.minimum})`;if(kt(h.multipleOf))yield`(${m} % BigInt(${h.multipleOf})) === 0`}function*f(h,w,m){yield`(typeof ${m} === 'boolean')`}function*u(h,w,m){yield*kr(h.returns,w,`${m}.prototype`)}function*l(h,w,m){if(yield`(${m} instanceof Date) && Number.isFinite(${m}.getTime())`,Q(h.exclusiveMaximumTimestamp))yield`${m}.getTime() < ${h.exclusiveMaximumTimestamp}`;if(Q(h.exclusiveMinimumTimestamp))yield`${m}.getTime() > ${h.exclusiveMinimumTimestamp}`;if(Q(h.maximumTimestamp))yield`${m}.getTime() <= ${h.maximumTimestamp}`;if(Q(h.minimumTimestamp))yield`${m}.getTime() >= ${h.minimumTimestamp}`;if(Q(h.multipleOfTimestamp))yield`(${m}.getTime() % ${h.multipleOfTimestamp}) === 0`}function*d(h,w,m){yield`(typeof ${m} === 'function')`}function*y(h,w,m){let O=globalThis.Object.getOwnPropertyNames(h.$defs).reduce((A,C)=>[...A,h.$defs[C]],[]);yield*kr(Gt(h.$ref),[...w,...O],m)}function*b(h,w,m){if(yield`Number.isInteger(${m})`,Q(h.exclusiveMaximum))yield`${m} < ${h.exclusiveMaximum}`;if(Q(h.exclusiveMinimum))yield`${m} > ${h.exclusiveMinimum}`;if(Q(h.maximum))yield`${m} <= ${h.maximum}`;if(Q(h.minimum))yield`${m} >= ${h.minimum}`;if(Q(h.multipleOf))yield`(${m} % ${h.multipleOf}) === 0`}function*p(h,w,m){let O=h.allOf.map((A)=>gt(A,w,m)).join(" && ");if(h.unevaluatedProperties===!1){let A=lt(`${new RegExp(Vr(h))};`),C=`Object.getOwnPropertyNames(${m}).every(key => ${A}.test(key))`;yield`(${O} && ${C})`}else if(je(h.unevaluatedProperties)){let A=lt(`${new RegExp(Vr(h))};`),C=`Object.getOwnPropertyNames(${m}).every(key => ${A}.test(key) || ${gt(h.unevaluatedProperties,w,`${m}[key]`)})`;yield`(${O} && ${C})`}else yield`(${O})`}function*g(h,w,m){yield`(typeof value === 'object' && Symbol.iterator in ${m})`}function*R(h,w,m){if(typeof h.const==="number"||typeof h.const==="boolean")yield`(${m} === ${h.const})`;else yield`(${m} === '${Da.Escape(h.const)}')`}function*L(h,w,m){yield"false"}function*J(h,w,m){yield`(!${gt(h.not,w,m)})`}function*H(h,w,m){yield`(${m} === null)`}function*_(h,w,m){if(yield Wn.IsNumberLike(m),Q(h.exclusiveMaximum))yield`${m} < ${h.exclusiveMaximum}`;if(Q(h.exclusiveMinimum))yield`${m} > ${h.exclusiveMinimum}`;if(Q(h.maximum))yield`${m} <= ${h.maximum}`;if(Q(h.minimum))yield`${m} >= ${h.minimum}`;if(Q(h.multipleOf))yield`(${m} % ${h.multipleOf}) === 0`}function*j(h,w,m){if(yield Wn.IsObjectLike(m),Q(h.minProperties))yield`Object.getOwnPropertyNames(${m}).length >= ${h.minProperties}`;if(Q(h.maxProperties))yield`Object.getOwnPropertyNames(${m}).length <= ${h.maxProperties}`;let O=Object.getOwnPropertyNames(h.properties);for(let A of O){let C=$s.Encode(m,A),v=h.properties[A];if(h.required&&h.required.includes(A)){if(yield*kr(v,w,C),qr(v)||t(v))yield`('${A}' in ${m})`}else{let X=gt(v,w,C);yield Wn.IsExactOptionalProperty(m,A,X)}}if(h.additionalProperties===!1)if(h.required&&h.required.length===O.length)yield`Object.getOwnPropertyNames(${m}).length === ${O.length}`;else{let A=`[${O.map((C)=>`'${C}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${m}).every(key => ${A}.includes(key))`}if(typeof h.additionalProperties==="object"){let A=gt(h.additionalProperties,w,`${m}[key]`),C=`[${O.map((v)=>`'${v}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${m}).every(key => ${C}.includes(key) || ${A}))`}}function*k(h,w,m){yield`${m} instanceof Promise`}function*q(h,w,m){if(yield Wn.IsRecordLike(m),Q(h.minProperties))yield`Object.getOwnPropertyNames(${m}).length >= ${h.minProperties}`;if(Q(h.maxProperties))yield`Object.getOwnPropertyNames(${m}).length <= ${h.maxProperties}`;let[O,A]=Object.entries(h.patternProperties)[0],C=lt(`${new RegExp(O)}`),v=gt(A,w,"value"),X=je(h.additionalProperties)?gt(h.additionalProperties,w,m):h.additionalProperties===!1?"false":"true",me=`(${C}.test(key) ? ${v} : ${X})`;yield`(Object.entries(${m}).every(([key, value]) => ${me}))`}function*se(h,w,m){let O=Ie(h,w);if(Je.functions.has(h.$ref))return yield`${Rr(h.$ref)}(${m})`;yield*kr(O,w,m)}function*K(h,w,m){let O=lt(`${new RegExp(h.source,h.flags)};`);if(yield`(typeof ${m} === 'string')`,Q(h.maxLength))yield`${m}.length <= ${h.maxLength}`;if(Q(h.minLength))yield`${m}.length >= ${h.minLength}`;yield`${O}.test(${m})`}function*U(h,w,m){if(yield`(typeof ${m} === 'string')`,Q(h.maxLength))yield`${m}.length <= ${h.maxLength}`;if(Q(h.minLength))yield`${m}.length >= ${h.minLength}`;if(h.pattern!==void 0)yield`${lt(`${new RegExp(h.pattern)};`)}.test(${m})`;if(h.format!==void 0)yield`format('${h.format}', ${m})`}function*D(h,w,m){yield`(typeof ${m} === 'symbol')`}function*x(h,w,m){yield`(typeof ${m} === 'string')`,yield`${lt(`${new RegExp(h.pattern)};`)}.test(${m})`}function*M(h,w,m){yield`${Rr(h.$ref)}(${m})`}function*N(h,w,m){if(yield`Array.isArray(${m})`,h.items===void 0)return yield`${m}.length === 0`;yield`(${m}.length === ${h.maxItems})`;for(let O=0;O<h.items.length;O++)yield`${gt(h.items[O],w,`${m}[${O}]`)}`}function*V(h,w,m){yield`${m} === undefined`}function*G(h,w,m){yield`(${h.anyOf.map((A)=>gt(A,w,m)).join(" || ")})`}function*Me(h,w,m){if(yield`${m} instanceof Uint8Array`,Q(h.maxByteLength))yield`(${m}.length <= ${h.maxByteLength})`;if(Q(h.minByteLength))yield`(${m}.length >= ${h.minByteLength})`}function*z(h,w,m){yield"true"}function*co(h,w,m){yield Wn.IsVoidLike(m)}function*on(h,w,m){let O=Je.instances.size;Je.instances.set(O,h),yield`kind('${h[I]}', ${O}, ${m})`}function*kr(h,w,m,O=!0){let A=Qe(h.$id)?[...w,h]:w,C=h;if(O&&Qe(h.$id)){let v=Rr(h.$id);if(Je.functions.has(v))return yield`${v}(${m})`;else{Je.functions.set(v,"<deferred>");let X=sn(v,h,w,"value",!1);return Je.functions.set(v,X),yield`${v}(${m})`}}switch(C[I]){case"Any":return yield*n(C,A,m);case"Argument":return yield*o(C,A,m);case"Array":return yield*i(C,A,m);case"AsyncIterator":return yield*s(C,A,m);case"BigInt":return yield*c(C,A,m);case"Boolean":return yield*f(C,A,m);case"Constructor":return yield*u(C,A,m);case"Date":return yield*l(C,A,m);case"Function":return yield*d(C,A,m);case"Import":return yield*y(C,A,m);case"Integer":return yield*b(C,A,m);case"Intersect":return yield*p(C,A,m);case"Iterator":return yield*g(C,A,m);case"Literal":return yield*R(C,A,m);case"Never":return yield*L(C,A,m);case"Not":return yield*J(C,A,m);case"Null":return yield*H(C,A,m);case"Number":return yield*_(C,A,m);case"Object":return yield*j(C,A,m);case"Promise":return yield*k(C,A,m);case"Record":return yield*q(C,A,m);case"Ref":return yield*se(C,A,m);case"RegExp":return yield*K(C,A,m);case"String":return yield*U(C,A,m);case"Symbol":return yield*D(C,A,m);case"TemplateLiteral":return yield*x(C,A,m);case"This":return yield*M(C,A,m);case"Tuple":return yield*N(C,A,m);case"Undefined":return yield*V(C,A,m);case"Union":return yield*G(C,A,m);case"Uint8Array":return yield*Me(C,A,m);case"Unknown":return yield*z(C,A,m);case"Void":return yield*co(C,A,m);default:if(!qn(C[I]))throw new Uu(h);return yield*on(C,A,m)}}let Je={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function gt(h,w,m,O=!0){return`(${[...kr(h,w,m,O)].join(" && ")})`}function Rr(h){return`check_${La.Encode(h)}`}function lt(h){let w=`local_${Je.variables.size}`;return Je.variables.set(w,`const ${w} = ${h}`),w}function sn(h,w,m,O,A=!0){let[C,v]=[`
3
+ `,(Ke)=>"".padStart(Ke," ")],X=fo("value","any"),me=Nr("boolean"),Se=[...kr(w,m,O,A)].map((Ke)=>`${v(4)}${Ke}`).join(` &&${C}`);return`function ${h}(${X})${me} {${C}${v(2)}return (${C}${Se}${C}${v(2)})
4
+ }`}function fo(h,w){let m=Je.language==="typescript"?`: ${w}`:"";return`${h}${m}`}function Nr(h){return Je.language==="typescript"?`: ${h}`:""}function Ui(h,w,m){let O=sn("check",h,w,"value"),A=fo("value","any"),C=Nr("boolean"),v=[...Je.functions.values()],X=[...Je.variables.values()],me=Qe(h.$id)?`return function check(${A})${C} {
5
+ return ${Rr(h.$id)}(value)
6
+ }`:`return ${O}`;return[...X,...v,me].join(`
7
+ `)}function uo(...h){let w={language:"javascript"},[m,O,A]=h.length===2&&pe(h[1])?[h[0],h[1],w]:h.length===2&&!pe(h[1])?[h[0],[],h[1]]:h.length===3?[h[0],h[1],h[2]]:h.length===1?[h[0],[],w]:[null,[],w];if(Je.language=A.language,Je.variables.clear(),Je.functions.clear(),Je.instances.clear(),!je(m))throw new Ba(m);for(let C of O)if(!je(C))throw new Ba(C);return Ui(m,O,A)}e.Code=uo;function oa(h,w=[]){let m=uo(h,w,{language:"javascript"}),O=globalThis.Function("kind","format","hash",m),A=new Map(Je.instances);function C(Se,Ke,Ht){if(!qn(Se)||!A.has(Ke))return!1;let an=ga(Se),Zo=A.get(Ke);return an(Zo,Ht)}function v(Se,Ke){if(!cr(Se))return!1;return ya(Se)(Ke)}function X(Se){return Lo(Se)}let me=O(C,v,X);return new Nu(h,w,me,m)}e.Compile=oa})(mr||(mr={}));var vt=typeof Bun<"u";function ws(){try{if(typeof caches<"u"&&typeof caches.default<"u"||typeof WebSocketPair<"u")return!0}catch{return!1}return!1}var Va={aac:"audio/aac",abw:"application/x-abiword",ai:"application/postscript",arc:"application/octet-stream",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",dll:"application/octet-stream",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/x-icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",mid:"audio/midi",midi:"audio/midi",mp2:"audio/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",otf:"font/otf",png:"image/png",pdf:"application/pdf",ppt:"application/vnd.ms-powerpoint",rar:"application/x-rar-compressed",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"application/typescript",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/x-wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.ms-excel",xlsx_OLD:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"application/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3gp_DOES_NOT_CONTAIN_VIDEO":"audio/3gpp","3gp2":"video/3gpp2","3gp2_DOES_NOT_CONTAIN_VIDEO":"audio/3gpp2","7z":"application/x-7z-compressed"},Zb=(e)=>{let t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1)};var va,Ha;class Qn{constructor(e){if(this.path=e,vt)this.value=Bun.file(e);else{if(!va||!Ha){if(typeof window<"u"){console.warn("Browser environment does not support file");return}let t=(o)=>console.warn(Error(`[elysia] \`file\` require \`fs${o?"."+o:""}\` ${o?.includes(".")?"module ":""}which is not available in this environment`));if(typeof process>"u"||typeof process.getBuiltinModule!="function"){t();return}let n=process.getBuiltinModule("fs");if(!n){t();return}if(typeof n.createReadStream!="function"){t();return}if(typeof n.promises?.stat!="function"){t();return}va=n.createReadStream,Ha=n.promises.stat}this.value=va(e),this.stats=Ha(e)}}get type(){return Va[Zb(this.path)]||"application/octet-stream"}get length(){return vt?this.value.size:this.stats?.then((e)=>e.size)??0}}var Ss=(e,t)=>{let n=e.indexOf("/",11),o=e.indexOf("?",n);return o===-1?`${e.slice(0,n)}${t.charCodeAt(0)===47?"":"/"}${t}`:`${e.slice(0,n)}${t.charCodeAt(0)===47?"":"/"}${t}${e.slice(o)}`},Xb=(e)=>typeof e=="function"&&/^\s*class\s+/.test(e.toString())||e.toString&&e.toString().startsWith("[object ")&&e.toString()!=="[object Object]"||ue(Object.getPrototypeOf(e)),qa=(e)=>e&&typeof e=="object"&&!Array.isArray(e),et=(e,t,n)=>{let o=n?.skipKeys,i=n?.override??!0,s=n?.mergeArray??!1,c=n?.seen??new WeakSet;if(!qa(e)||!qa(t)||c.has(t))return e;c.add(t);for(let[f,u]of Object.entries(t))if(!(o?.includes(f)||["__proto__","constructor","prototype"].includes(f))){if(s&&Array.isArray(u)){e[f]=Array.isArray(e[f])?[...e[f],...u]:e[f]=u;continue}if(!qa(u)||!(f in e)||Xb(u)){if((i||!(f in e))&&!Object.isFrozen(e))try{e[f]=u}catch{}continue}if(!Object.isFrozen(e[f]))try{e[f]=et(e[f],u,{skipKeys:o,override:i,mergeArray:s,seen:c})}catch{}}return c.delete(t),e},Oi=(e,t)=>{let n=et(Object.assign({},e),t,{skipKeys:["properties"],mergeArray:!1});return n.properties&&delete n.properties,n},Ue=(e,t)=>{if(!t)return e;let n=[],o=[];if(e){Array.isArray(e)||(e=[e]);for(let i of e)n.push(i),i.checksum&&o.push(i.checksum)}if(t){Array.isArray(t)||(t=[t]);for(let i of t)o.includes(i.checksum)||n.push(i)}return n},ex=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],Fj=ex.reduce((e,t)=>(e[t]=!0,e),{}),As=(e)=>typeof e=="object"&&Object.keys(e).every((t)=>!isNaN(+t)),Ku=(e,t)=>As(e)&&As(t)?Object.assign({},e,t):e&&!As(e)&&As(t)?Object.assign({200:e},t):t??e,vo=(e,t)=>!e&&!t?{body:void 0,headers:void 0,params:void 0,query:void 0,cookie:void 0,response:void 0}:{body:t?.body??e?.body,headers:t?.headers??e?.headers,params:t?.params??e?.params,query:t?.query??e?.query,cookie:t?.cookie??e?.cookie,response:Ku(e?.response,t?.response)},Er=(e,t)=>{if(!t)return e??{};if(!e)return t??{};if(!Object.values(t).find((o)=>o!=null))return{...e};let n={...e,...t,body:t.body??e.body,headers:t.headers??e.headers,params:t.params??e.params,query:t.query??e.query,cookie:t.cookie??e.cookie,response:Ku(e.response,t.response),type:e.type||t.type,detail:et(t.detail??{},e.detail??{}),parse:Ue(e.parse,t.parse),transform:Ue(e.transform,t.transform),beforeHandle:Ue(Ue(Xe(e.resolve,"resolve"),e.beforeHandle),Ue(Xe(t.resolve,"resolve"),t.beforeHandle)),afterHandle:Ue(e.afterHandle,t.afterHandle),mapResponse:Ue(e.mapResponse,t.mapResponse),afterResponse:Ue(e.afterResponse,t.afterResponse),trace:Ue(e.trace,t.trace),error:Ue(e.error,t.error),standaloneSchema:e.standaloneSchema||t.standaloneSchema?e.standaloneSchema&&!t.standaloneSchema?e.standaloneSchema:t.standaloneSchema&&!e.standaloneSchema?t.standaloneSchema:[...e.standaloneSchema??[],...t.standaloneSchema??[]]:void 0};return n.resolve&&delete n.resolve,n},Lu=(e)=>{e.parse&&!Array.isArray(e.parse)&&(e.parse=[e.parse]),e.transform&&!Array.isArray(e.transform)&&(e.transform=[e.transform]),e.afterHandle&&!Array.isArray(e.afterHandle)&&(e.afterHandle=[e.afterHandle]),e.mapResponse&&!Array.isArray(e.mapResponse)&&(e.mapResponse=[e.mapResponse]),e.afterResponse&&!Array.isArray(e.afterResponse)&&(e.afterResponse=[e.afterResponse]),e.trace&&!Array.isArray(e.trace)&&(e.trace=[e.trace]),e.error&&!Array.isArray(e.error)&&(e.error=[e.error]);let t=[];return e.resolve&&(t=Xe(Array.isArray(e.resolve)?e.resolve:[e.resolve],"resolve"),delete e.resolve),e.beforeHandle&&(t.length?t=t.concat(Array.isArray(e.beforeHandle)?e.beforeHandle:[e.beforeHandle]):t=Array.isArray(e.beforeHandle)?e.beforeHandle:[e.beforeHandle]),t.length&&(e.beforeHandle=t),e},Ri=vt?"toJSON"in new Headers:!1,Fs=typeof setImmediate=="function",Wr=(e)=>{let t=9;for(let n=0;n<e.length;)t=Math.imul(t^e.charCodeAt(n++),387420489);return t=t^t>>>9},yr=(e,t)=>{if(!t)return;if(!Array.isArray(t)){let o=t;return e&&!o.checksum&&(o.checksum=e),o.scope==="scoped"&&(o.scope="local"),o}let n=[...t];for(let o of n)e&&!o.checksum&&(o.checksum=e),o.scope==="scoped"&&(o.scope="local");return n},_a=(e,t,n)=>({start:Ue(e.start,yr(n,t?.start)),request:Ue(e.request,yr(n,t?.request)),parse:Ue(e.parse,yr(n,t?.parse)),transform:Ue(e.transform,yr(n,t?.transform)),beforeHandle:Ue(Ue(Xe(e.resolve,"resolve"),e.beforeHandle),yr(n,Ue(Xe(t?.resolve,"resolve"),t?.beforeHandle))),afterHandle:Ue(e.afterHandle,yr(n,t?.afterHandle)),mapResponse:Ue(e.mapResponse,yr(n,t?.mapResponse)),afterResponse:Ue(e.afterResponse,yr(n,t?.afterResponse)),trace:Ue(e.trace,yr(n,t?.trace)),error:Ue(e.error,yr(n,t?.error)),stop:Ue(e.stop,yr(n,t?.stop))}),Du=(e,t,{skipIfHasType:n=!1})=>{if(!e)return e;if(!Array.isArray(e))return n?e.scope??=t:e.scope=t,e;for(let o of e)n?o.scope??=t:o.scope=t;return e},$n=(e)=>{if(!e)return e;if(!Array.isArray(e))switch(e.scope){case"global":case"scoped":return{...e};default:return{fn:e}}let t=[];for(let n of e)switch(n.scope){case"global":case"scoped":t.push({...n});break}return t},Ga=(e)=>({...e,type:e?.type,detail:e?.detail,parse:$n(e?.parse),transform:$n(e?.transform),beforeHandle:$n(e?.beforeHandle),afterHandle:$n(e?.afterHandle),mapResponse:$n(e?.mapResponse),afterResponse:$n(e?.afterResponse),error:$n(e?.error),trace:$n(e?.trace)}),Cr={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Enhance Your Calm":420,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},Es=Object.fromEntries(Object.entries(Cr).map(([e,t])=>[t,e]));function tx(e){let t=e;for(;t.endsWith("=");)t=t.slice(0,-1);return t}var Mu=new TextEncoder,Ho=async(e,t)=>{if(typeof e=="object"?e=JSON.stringify(e):typeof e!="string"&&(e=e+""),t==null)throw TypeError("Secret key must be provided");let n=await crypto.subtle.importKey("raw",Mu.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),o=await crypto.subtle.sign("HMAC",n,Mu.encode(e));return e+"."+tx(Buffer.from(o).toString("base64"))},rx=typeof crypto?.timingSafeEqual=="function"?(e,t)=>{let n=Buffer.from(e,"utf8"),o=Buffer.from(t,"utf8");return n.length!==o.length?!1:crypto.timingSafeEqual(n,o)}:(e,t)=>e===t,za=async(e,t)=>{if(typeof e!="string")throw TypeError("Signed cookie string must be provided.");let n=e.lastIndexOf(".");if(n===-1)return t===null?e:!1;let o=e.slice(0,n),i=await Ho(o,t);return rx(i,e)?o:!1},Bu=(e,t,n)=>{if(!e.standaloneValidator?.length||!Array.isArray(e.standaloneValidator)){e.standaloneValidator=[{[t]:n}];return}let o=e.standaloneValidator[e.standaloneValidator.length-1];t in o?e.standaloneValidator.push({[t]:n}):o[t]=n},nx=(e)=>{if(typeof e=="number")return e;if(e.length<16){if(e.trim().length===0)return null;let t=Number(e);return Number.isNaN(t)?null:t}if(e.length===16){if(e.trim().length===0)return null;let t=Number(e);return Number.isNaN(t)||t.toString()!==e?null:t}return null},Cs=(e)=>nx(e)!==null;class Ja{constructor(e=console.error,t=()=>{}){this.onError=e,this.onFinally=t,this.root=null,this.promises=[]}get size(){return this.promises.length}add(e){return this.promises.push(e),this.root||=this.drain(),this.promises.length===1&&this.then(this.onFinally),e}async drain(){for(;this.promises.length>0;){try{await this.promises[0]}catch(e){this.onError(e)}this.promises.shift()}this.root=null}then(e,t){return(this.root??Promise.resolve()).then(e,t)}}var Xe=(e,t)=>{if(!e)return e;if(!Array.isArray(e)){if(typeof e=="function"||typeof e=="string")return t?{fn:e,subType:t}:{fn:e};if("fn"in e)return e}let n=[];for(let o of e)typeof o=="function"||typeof o=="string"?n.push(t?{fn:o,subType:t}:{fn:o}):("fn"in o)&&n.push(o);return n},Wa=(e)=>(e.start&&(e.start=Xe(e.start)),e.request&&(e.request=Xe(e.request)),e.parse&&(e.parse=Xe(e.parse)),e.transform&&(e.transform=Xe(e.transform)),e.beforeHandle&&(e.beforeHandle=Xe(e.beforeHandle)),e.afterHandle&&(e.afterHandle=Xe(e.afterHandle)),e.mapResponse&&(e.mapResponse=Xe(e.mapResponse)),e.afterResponse&&(e.afterResponse=Xe(e.afterResponse)),e.trace&&(e.trace=Xe(e.trace)),e.error&&(e.error=Xe(e.error)),e.stop&&(e.stop=Xe(e.stop)),e),Qa=(e)=>{let t=Object.create(null);return e.start?.map&&(t.start=e.start.map((n)=>n.fn)),e.request?.map&&(t.request=e.request.map((n)=>n.fn)),e.parse?.map&&(t.parse=e.parse.map((n)=>n.fn)),e.transform?.map&&(t.transform=e.transform.map((n)=>n.fn)),e.beforeHandle?.map&&(t.beforeHandle=e.beforeHandle.map((n)=>n.fn)),e.afterHandle?.map&&(t.afterHandle=e.afterHandle.map((n)=>n.fn)),e.mapResponse?.map&&(t.mapResponse=e.mapResponse.map((n)=>n.fn)),e.afterResponse?.map&&(t.afterResponse=e.afterResponse.map((n)=>n.fn)),e.error?.map&&(t.error=e.error.map((n)=>n.fn)),e.stop?.map&&(t.stop=e.stop.map((n)=>n.fn)),e.trace?.map?t.trace=e.trace.map((n)=>n.fn):t.trace=[],t},Ts=(e)=>({body:e.body,cookie:e.cookie,headers:e.headers,query:e.query,set:e.set,server:e.server,path:e.path,route:e.route,url:e.url}),Qr=(e,t=302)=>Response.redirect(e,t),Jr=Symbol("ElysiaFormData"),Yr=Symbol("ElysiaRequestId"),Ya=(e)=>{let t=new FormData;if(t[Jr]={},e)for(let[n,o]of Object.entries(e)){if(Array.isArray(o)){t[Jr][n]=[];for(let i of o)o instanceof File?t.append(n,o,o.name):o instanceof Qn?t.append(n,o.value,o.value?.name):t.append(n,o),t[Jr][n].push(o);continue}o instanceof File?t.append(n,o,o.name):o instanceof Qn?t.append(n,o.value,o.value?.name):t.append(n,o),t[Jr][n]=o}return t},Zr=typeof crypto>"u"||ws()?()=>{let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<16;n++)e+=t.charAt(Math.floor(Math.random()*62));return e}:()=>{let e=crypto.randomUUID();return e.slice(0,8)+e.slice(24,32)},Za=(e)=>{if(!e.length)return[];let t=[];for(let n=0;n<e.length;n++){let o=e[n];o.checksum&&(t.includes(o.checksum)&&(e.splice(n,1),n--),t.push(o.checksum))}return e},Xr=(e,t="scoped")=>{if(e){if(t==="scoped"){for(let n of e)"scope"in n&&n.scope==="local"&&(n.scope="scoped");return}for(let n of e)"scope"in n&&(n.scope="global")}},Yn=(e)=>e.charCodeAt(e.length-1)===47?e.slice(0,e.length-1):e+"/",ue=(e)=>{if(!e)return!1;for(let t in e)return!0;return!1},Zn=(e,{dynamic:t=!1}={})=>{let n=encodeURIComponent(e).replace(/%2F/g,"/");return t&&(n=n.replace(/%3A/g,":").replace(/%3F/g,"?")),n},Ps=!!(typeof Bun>"u"||Bun.semver?.satisfies?.(Bun.version,">=1.2.14"));async function vu(e){if(e.bodyUsed||!e.body)return 0;let t=0,n=e.body.getReader();for(;;){let{done:o,value:i}=await n.read();if(o)break;t+=i.byteLength}return t}var Hu={headers:!0,cookie:!0,query:!0,params:!0,body:!0,response:!0};var Vu=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,Xn=Symbol("ElysiaErrorCode"),en=(Vu?.NODE_ENV??Vu?.ENV)==="production",ox={101:void 0,204:void 0,205:void 0,304:void 0,307:void 0,308:void 0};class ve{constructor(e,t){let n=t??(e in Es?Es[e]:e);this.code=Cr[e]??e,e in ox?this.response=void 0:this.response=n}}var Zt=(e,t)=>new ve(e,t);class Vo extends Error{constructor(e){super(e??"NOT_FOUND");this.code="NOT_FOUND",this.status=404}}class js extends Error{constructor(e){super("Bad Request",{cause:e});this.code="PARSE",this.status=400}}class eo extends Error{constructor(e,t){super(t??`"${e}" has invalid cookie signature`);this.key=e,this.code="INVALID_COOKIE_SIGNATURE",this.status=400}}var nt=(e)=>{if(!e)return e;let{message:t,path:n,value:o,type:i}=e;Array.isArray(n)&&(n=n[0]);let s=typeof n=="string"?n.slice(1).replaceAll("/","."):"unknown",c=n==="";switch(i){case 42:return{...e,summary:c?"Value should not be provided":`Property '${s}' should not be provided`};case 45:return{...e,summary:c?"Value is missing":`Property '${s}' is missing`};case 50:let f=t.indexOf("'"),u=t.slice(f+1,t.indexOf("'",f+1));return{...e,summary:c?"Value should be an email":`Property '${s}' should be ${u}`};case 54:return{...e,summary:`${t.slice(0,9).trim()} property '${s}' to be ${t.slice(8).trim()} but found: ${o}`};case 62:let l=e.schema.anyOf.map((d)=>`'${d?.format??d.type}'`).join(", ");return{...e,summary:c?`Value should be one of ${l}`:`Property '${s}' should be one of: ${l}`};default:return{summary:t,...e}}};class to extends Error{constructor(e,t,n=`"${e}" has invalid file type`){super(n);this.property=e,this.expected=t,this.message=n,this.code="INVALID_FILE_TYPE",this.status=422,Object.setPrototypeOf(this,to.prototype)}toResponse(e){return en?new Response(JSON.stringify({type:"validation",on:"body"}),{status:422,headers:{...e,"content-type":"application/json"}}):new Response(JSON.stringify({type:"validation",on:"body",summary:"Invalid file type",message:this.message,property:this.property,expected:this.expected}),{status:422,headers:{...e,"content-type":"application/json"}})}}class W extends Error{constructor(e,t,n,o=!1,i){let s="",c,f,u;if(t?.provider==="standard"||"~standard"in t||t.schema&&"~standard"in t.schema){let l=("~standard"in t?t:t.schema)["~standard"];c=(i??l.validate(n).issues)?.[0],en&&!o?s=JSON.stringify({type:"validation",on:e,found:n}):s=JSON.stringify({type:"validation",on:e,property:c.path?.[0]||"root",message:c?.message,summary:c?.problem,expected:f,found:n,errors:i},null,2),u=c?.message}else{n&&typeof n=="object"&&n instanceof ve&&(n=n.response),c=i?.First()??("Errors"in t?t.Errors(n).First():Et(t,n).First());let l=c?.path||"root",d=t?.schema??t;if(!en&&!o)try{f=gi(d)}catch(y){f={type:"Could not create expected value",message:y?.message,error:y}}u=c?.schema?.message||c?.schema?.error!==void 0?typeof c.schema.error=="function"?c.schema.error(en&&!o?{type:"validation",on:e,found:n}:{type:"validation",on:e,value:n,property:l,message:c?.message,summary:nt(c)?.summary,found:n,expected:f,errors:"Errors"in t?[...t.Errors(n)].map(nt):[...Et(t,n)].map(nt)},t):c.schema.error:void 0,u!==void 0?s=typeof u=="object"?JSON.stringify(u):u+"":en&&!o?s=JSON.stringify({type:"validation",on:e,found:n}):s=JSON.stringify({type:"validation",on:e,property:l,message:c?.message,summary:nt(c)?.summary,expected:f,found:n,errors:"Errors"in t?[...t.Errors(n)].map(nt):[...Et(t,n)].map(nt)},null,2)}super(s);this.type=e,this.validator=t,this.value=n,this.allowUnsafeValidationDetails=o,this.code="VALIDATION",this.status=422,this.valueError=c,this.expected=f,this.customError=u,Object.setPrototypeOf(this,W.prototype)}get messageValue(){return this.valueError}get all(){return this.validator?.provider==="standard"||"~standard"in this.validator||"schema"in this.validator&&this.validator.schema&&"~standard"in this.validator.schema?("~standard"in this.validator?this.validator:this.validator.schema)["~standard"].validate(this.value).issues?.map((e)=>({summary:e.message,path:e.path?.join(".")||"root",message:e.message,value:this.value}))||[]:("Errors"in this.validator)?[...this.validator.Errors(this.value)].filter((e)=>e).map((e)=>nt(e)):[...Et(this.validator,this.value)].map(nt)}static simplifyModel(e){let t="schema"in e?e.schema:e;try{return gi(t)}catch{return t}}get model(){return"~standard"in this.validator?this.validator:W.simplifyModel(this.validator)}toResponse(e){return new Response(this.message,{status:400,headers:{...e,"content-type":"application/json"}})}detail(e,t=this.allowUnsafeValidationDetails){if(!this.customError)return this.message;let n=this.value,o=this.expected,i=this.all;return en&&!t?{type:"validation",on:this.type,found:n,message:e}:{type:"validation",on:this.type,property:this.valueError?.path||"root",message:e,summary:nt(this.valueError)?.summary,found:n,expected:o,errors:i}}}var qo=(e,t)=>{try{return JSON.parse(e)}catch{throw new W("property",t,e)}};function _o(e,t){return qn(e)||xl(e,t),(n={})=>xs({...n,[I]:e})}var hr=(e)=>{try{let t=mr.Compile(e);return t.Create=()=>gi(e),t.Error=(n)=>new W("property",e,n,t.Errors(n)),t}catch{return{Check:(t)=>ke(e,t),CheckThrow:(t)=>{if(!ke(e,t))throw new W("property",e,t,Et(e,t))},Decode:(t)=>Ma(e,t),Create:()=>gi(e),Error:(t)=>new W("property",e,t,Et(e,t))}}},qu=(e)=>{if(typeof e=="string")switch(e.slice(-1)){case"k":return+e.slice(0,e.length-1)*1024;case"m":return+e.slice(0,e.length-1)*1048576;default:return+e}return e},ks=(e,t)=>e.startsWith(t)?!0:t.charCodeAt(t.length-1)===42&&t.charCodeAt(t.length-2)===47&&e.startsWith(t.slice(0,-1)),_u=!1,ix=()=>{_u||(console.warn("[Elysia] Attempt to validate file type without 'file-type'. This may lead to security risks. We recommend installing 'file-type' to properly validate file extension."),_u=!0)},Us=async()=>import("./index-2r6cmxxz.js").then((e)=>(Ns=e.fileTypeFromBlob,Ns)).catch(ix),Ns,sx=(e)=>Ns?Ns(e):Us().then((t)=>{if(t)return t(e)}),Ms=async(e,t,n=e?.name??"")=>{if(Array.isArray(e))return await Promise.all(e.map((i)=>Ms(i,t,n))),!0;if(!e)return!1;let o=await sx(e);if(!o)throw new to(n,t);if(typeof t=="string"&&!ks(o.mime,t))throw new to(n,t);for(let i=0;i<t.length;i++)if(ks(o.mime,t[i]))return!0;throw new to(n,t)},Ks=(e,t)=>{if(t instanceof Qn)return!0;if(!(t instanceof Blob)||e.minSize&&t.size<qu(e.minSize)||e.maxSize&&t.size>qu(e.maxSize))return!1;if(e.extension){if(typeof e.extension=="string")return ks(t.type,e.extension);for(let n=0;n<e.extension.length;n++)if(ks(t.type,e.extension[n]))return!0;return!1}return!0};var ec={date:Zu,time:Xa(!0),"date-time":Gu(!0),"iso-time":Xa(!1),"iso-date-time":Gu(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:mx,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:[^\s:@]+(?::[^\s@]*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:Ox,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:yx,int32:{type:"number",validate:bx},int64:{type:"number",validate:xx},float:{type:"number",validate:Ju},double:{type:"number",validate:Ju},password:!0,binary:!0};function ax(e){return e%4===0&&(e%100!==0||e%400===0)}var cx=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,fx=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Zu(e){let t=cx.exec(e);if(!t)return!1;let n=+t[1],o=+t[2],i=+t[3];return o>=1&&o<=12&&i>=1&&i<=(o===2&&ax(n)?29:fx[o])}var ux=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Xa(e){return function(t){let n=ux.exec(t);if(!n)return!1;let o=+n[1],i=+n[2],s=+n[3],c=n[4],f=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!c)return!1;if(o<=23&&i<=59&&s<60)return!0;let d=i-l*f,y=o-u*f-(d<0?1:0);return(y===23||y===-1)&&(d===59||d===-1)&&s<61}}var Ls=(e)=>e.charCodeAt(e.length-6)===32?e.slice(0,-6)+"+"+e.slice(-5):e,dx=/t|\s/i;function Gu(e){let t=Xa(e);return function(n){let o=n.split(dx);return o.length===2&&Zu(o[0])&&t(o[1])}}var lx=/\/|:/,px=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function mx(e){return lx.test(e)&&px.test(e)}var zu=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function yx(e){return zu.lastIndex=0,zu.test(e)}var hx=-2147483648,gx=2147483647;function bx(e){return Number.isInteger(e)&&e<=gx&&e>=hx}function xx(e){return Number.isInteger(e)}function Ju(){return!0}var Ix=/[^\\]\\Z/;function Ox(e){if(Ix.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var Wu=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,Qu=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,Yu=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,Rx=ec.date,$x=ec["date-time"];cr("date")||vr("date",(e)=>{let t=Ls(e).replace(/"/g,"");if(Wu.test(t)||Qu.test(t)||Yu.test(t)||Rx(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1}),cr("date-time")||vr("date-time",(e)=>{let t=e.replace(/"/g,"");if(Wu.test(t)||Qu.test(t)||Yu.test(t)||$x(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1}),Object.entries(ec).forEach((e)=>{let[t,n]=e;cr(t)||(n instanceof RegExp?vr(t,(o)=>n.test(o)):typeof n=="function"&&vr(t,n))}),cr("numeric")||vr("numeric",(e)=>!!e&&!isNaN(+e)),cr("integer")||vr("integer",(e)=>!!e&&Number.isInteger(+e)),cr("boolean")||vr("boolean",(e)=>e==="true"||e==="false"),cr("ObjectString")||vr("ObjectString",(e)=>{let t=e.charCodeAt(0);if((t===9||t===10||t===32)&&(t=e.trimStart().charCodeAt(0)),t!==123&&t!==91)return!1;try{return JSON.parse(e),!0}catch{return!1}}),cr("ArrayString")||vr("ArrayString",(e)=>{let t=e.charCodeAt(0);if((t===9||t===10||t===32)&&(t=e.trimStart().charCodeAt(0)),t!==123&&t!==91)return!1;try{return JSON.parse(e),!0}catch{return!1}});var r=Object.assign({},Wt);_o("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t)),_o("ArrayBuffer",(e,t)=>t instanceof ArrayBuffer);var wx=_o("Files",(e,t)=>{if(e.minItems&&e.minItems>1&&!Array.isArray(t))return!1;if(!Array.isArray(t))return Ks(e,t);if(e.minItems&&t.length<e.minItems||e.maxItems&&t.length>e.maxItems)return!1;for(let n=0;n<t.length;n++)if(!Ks(e,t[n]))return!1;return!0}),Ax=_o("ElysiaForm",({compiler:e,...t},n)=>{if(!(n instanceof FormData))return!1;if(e){if(!(Jr in n))throw new W("property",t,n);if(!e.Check(n[Jr]))throw e.Error(n[Jr])}return!0}),st={String:(e)=>Wt.String(e),Numeric:(e)=>{let t=Wt.Number(e),n=hr(t);return r.Transform(r.Union([r.String({format:"numeric",default:0}),r.Number(e)],e)).Decode((o)=>{let i=+o;if(isNaN(i))return o;if(e&&!n.Check(i))throw n.Error(i);return i}).Encode((o)=>o)},NumericEnum(e,t){let n=Wt.Enum(e,t),o=hr(n);return r.Transform(r.Union([r.String({format:"numeric"}),r.Number()],t)).Decode((i)=>{let s=+i;if(isNaN(s)||!o.Check(s))throw o.Error(s);return s}).Encode((i)=>i)},Integer:(e)=>{let t=Wt.Integer(e),n=hr(t);return r.Transform(r.Union([r.String({format:"integer",default:0}),Wt.Integer(e)],e)).Decode((o)=>{let i=+o;if(!n.Check(i))throw n.Error(i);return i}).Encode((o)=>o)},Date:(e)=>{let t=Wt.Date(e),n=hr(t),o=e?.default?new Date(e.default):void 0;return r.Transform(r.Union([Wt.Date(e),r.String({format:"date-time",default:o?.toISOString()}),r.String({format:"date",default:o?.toISOString()}),r.Number({default:o?.getTime()})],e)).Decode((i)=>{if(typeof i=="number"){let c=new Date(i);if(!n.Check(c))throw n.Error(c);return c}if(i instanceof Date)return i;let s=new Date(Ls(i));if(!s||isNaN(s.getTime()))throw new W("property",t,s);if(!n.Check(s))throw n.Error(s);return s}).Encode((i)=>{if(i instanceof Date)return i.toISOString();if(typeof i=="string"){let s=new Date(Ls(i));if(isNaN(s.getTime()))throw new W("property",t,i);return s.toISOString()}if(!n.Check(i))throw n.Error(i);return i})},BooleanString:(e)=>{let t=Wt.Boolean(e),n=hr(t);return r.Transform(r.Union([r.Boolean(e),r.String({format:"boolean",default:!1})],e)).Decode((o)=>{if(typeof o=="string")return o==="true";if(o!==void 0&&!n.Check(o))throw n.Error(o);return o}).Encode((o)=>o)},ObjectString:(e,t)=>{let n=r.Object(e,t),o=hr(n);return r.Transform(r.Union([r.String({format:"ObjectString",default:t?.default}),n],{elysiaMeta:"ObjectString"})).Decode((i)=>{if(typeof i=="string"){if(i.charCodeAt(0)!==123)throw new W("property",n,i);if(!o.Check(i=qo(i,n)))throw o.Error(i);return o.Decode(i)}return i}).Encode((i)=>{let s;if(typeof i=="string"&&(i=qo(s=i,n)),!o.Check(i))throw o.Error(i);return s??JSON.stringify(i)})},ArrayString:(e=r.String(),t)=>{let n=r.Array(e,t),o=hr(n),i=(s,c=!1)=>{if(s.charCodeAt(0)===91){if(!o.Check(s=qo(s,n)))throw o.Error(s);return o.Decode(s)}if(c)return s;throw new W("property",n,s)};return r.Transform(r.Union([r.String({format:"ArrayString",default:t?.default}),n],{elysiaMeta:"ArrayString"})).Decode((s)=>{if(Array.isArray(s)){let c=[];for(let f=0;f<s.length;f++){let u=s[f];if(typeof u=="string"){let l=i(u,!0);Array.isArray(l)?c=c.concat(l):c.push(l);continue}c.push(u)}return c}return typeof s=="string"?i(s):s}).Encode((s)=>{let c;if(typeof s=="string"&&(s=qo(c=s,n)),!o.Check(s))throw new W("property",n,s);return c??JSON.stringify(s)})},ArrayQuery:(e=r.String(),t)=>{let n=r.Array(e,t),o=hr(n),i=(s)=>s.indexOf(",")!==-1?o.Decode(s.split(",")):o.Decode([s]);return r.Transform(r.Union([r.String({default:t?.default}),n],{elysiaMeta:"ArrayQuery"})).Decode((s)=>{if(Array.isArray(s)){let c=[];for(let f=0;f<s.length;f++){let u=s[f];if(typeof u=="string"){let l=i(u);Array.isArray(l)?c=c.concat(l):c.push(l);continue}c.push(u)}return c}return typeof s=="string"?i(s):s}).Encode((s)=>{let c;if(typeof s=="string"&&(s=qo(c=s,n)),!o.Check(s))throw new W("property",n,s);return c??JSON.stringify(s)})},File:_o("File",Ks),Files:(e={})=>r.Transform(wx(e)).Decode((t)=>Array.isArray(t)?t:[t]).Encode((t)=>t),Nullable:(e,t)=>r.Union([e,r.Null()],{...t,nullable:!0}),MaybeEmpty:(e,t)=>r.Union([e,r.Null(),r.Undefined()],t),Cookie:(e,{domain:t,expires:n,httpOnly:o,maxAge:i,path:s,priority:c,sameSite:f,secure:u,secrets:l,sign:d,...y}={})=>{let b=r.Object(e,y);return b.config={domain:t,expires:n,httpOnly:o,maxAge:i,path:s,priority:c,sameSite:f,secure:u,secrets:l,sign:d},b},UnionEnum:(e,t={})=>{let n=e.every((o)=>typeof o=="string")?{type:"string"}:e.every((o)=>typeof o=="number")?{type:"number"}:e.every((o)=>o===null)?{type:"null"}:{};if(e.some((o)=>typeof o=="object"&&o!==null))throw Error("This type does not support objects or arrays");return{default:e[0],...t,[I]:"UnionEnum",...n,enum:e}},NoValidate:(e,t=!0)=>(e.noValidate=t,e),Form:(e,t={})=>{let n=r.Object(e,{default:Ya({}),...t}),o=hr(n);return r.Union([n,Ax({compiler:o})])},ArrayBuffer(e={}){return{default:[1,2,3],...e,[I]:"ArrayBuffer"}},Uint8Array:(e)=>{let t=Wt.Uint8Array(e),n=hr(t);return r.Transform(r.Union([r.ArrayBuffer(),Wt.Uint8Array(e)])).Decode((o)=>{if(o instanceof ArrayBuffer){if(!n.Check(o=new Uint8Array(o)))throw n.Error(o);return o}return o}).Encode((o)=>o)}};r.BooleanString=st.BooleanString,r.ObjectString=st.ObjectString,r.ArrayString=st.ArrayString,r.ArrayQuery=st.ArrayQuery,r.Numeric=st.Numeric,r.NumericEnum=st.NumericEnum,r.Integer=st.Integer,r.File=(e)=>(e?.type&&Us(),st.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"})),r.Files=(e)=>(e?.type&&Us(),st.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}})),r.Nullable=st.Nullable,r.MaybeEmpty=st.MaybeEmpty,r.Cookie=st.Cookie,r.Date=st.Date,r.UnionEnum=st.UnionEnum,r.NoValidate=st.NoValidate,r.Form=st.Form,r.ArrayBuffer=st.ArrayBuffer,r.Uint8Array=st.Uint8Array;var Sx=(e)=>{e.startsWith("async")&&(e=e.slice(5)),e=e.trimStart();let t=-1;if(e.charCodeAt(0)===40&&(t=e.indexOf("=>",e.indexOf(")")),t!==-1)){let i=t;for(;i>0&&e.charCodeAt(--i)!==41;);let s=e.slice(t+2);return s.charCodeAt(0)===32&&(s=s.trimStart()),[e.slice(1,i),s,{isArrowReturn:s.charCodeAt(0)!==123}]}if(/^(\w+)=>/g.test(e)&&(t=e.indexOf("=>"),t!==-1)){let i=e.slice(t+2);return i.charCodeAt(0)===32&&(i=i.trimStart()),[e.slice(0,t),i,{isArrowReturn:i.charCodeAt(0)!==123}]}if(e.startsWith("function")){t=e.indexOf("(");let i=e.indexOf(")");return[e.slice(t+1,i),e.slice(i+2),{isArrowReturn:!1}]}let n=e.indexOf("(");if(n!==-1){let i=e.indexOf(`
8
+ `,2),s=e.slice(0,i),c=s.lastIndexOf(")")+1,f=e.slice(i+1);return[s.slice(n,c),"{"+f,{isArrowReturn:!1}]}let o=e.split(`
9
+ `,2);return[o[0],o[1],{isArrowReturn:!1}]},Fx=(e)=>{let t=e.indexOf("{");if(t===-1)return[-1,0];let n=t+1,o=1;for(;n<e.length;n++){let i=e.charCodeAt(n);if(i===123?o++:i===125&&o--,o===0)break}return o!==0?[0,e.length]:[t,n+1]},Ex=(e)=>{let t=e.lastIndexOf("}");if(t===-1)return[-1,0];let n=t-1,o=1;for(;n>=0;n--){let i=e.charCodeAt(n);if(i===125?o++:i===123&&o--,o===0)break}return o!==0?[-1,0]:[n,t+1]},ed=(e)=>{for(;;){let t=e.indexOf(":");if(t===-1)break;let n=e.indexOf(",",t);n===-1&&(n=e.indexOf("}",t)-1),n===-2&&(n=e.length),e=e.slice(0,t)+e.slice(n)}return e},td=(e)=>{let t=!1;e.charCodeAt(0)===40&&(e=e.slice(1,-1)),e.charCodeAt(0)===123&&(t=!0,e=e.slice(1,-1)),e=e.replace(/( |\t|\n)/g,"").trim();let n=[];for(;;){let[i,s]=Fx(e);if(i===-1)break;n.push(e.slice(0,i-1)),e.charCodeAt(s)===44&&s++,e=e.slice(s)}e=ed(e),e&&(n=n.concat(e.split(",")));let o=Object.create(null);for(let i of n){if(i.indexOf(",")===-1){o[i]=!0;continue}for(let s of i.split(","))o[s.trim()]=!0}return{hasParenthesis:t,parameters:o}},Cx=(e,t)=>{let{parameters:n,hasParenthesis:o}=td(e);return n.query&&(t.query=!0),n.headers&&(t.headers=!0),n.body&&(t.body=!0),n.cookie&&(t.cookie=!0),n.set&&(t.set=!0),n.server&&(t.server=!0),n.route&&(t.route=!0),n.url&&(t.url=!0),n.path&&(t.path=!0),o?`{ ${Object.keys(n).join(", ")} }`:Object.keys(n).join(", ")},Xu=(e,t,n)=>{let o=new RegExp(`${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}[\\n\\t,; ]`);n!==void 0&&(o.lastIndex=n);let i=o.exec(t);return i?i.index:-1};var rd=(e,t,n=0)=>{if(n>5)return[];let o=[],i=t;for(;;){let s=Xu(" = "+e,i);if(s===-1&&(s=Xu("="+e,i)),s===-1){let l=i.indexOf(" = "+e);if(l===-1&&(l=i.indexOf("="+e)),l+3+e.length!==i.length)break;s=l}let c=i.slice(0,s),f=c.lastIndexOf(" "),u=c.slice(f!==-1?f+1:-1);if(u==="}"){let[l,d]=Ex(c);o.push(ed(i.slice(l,d))),i=i.slice(s+3+e.length);continue}for(;u.charCodeAt(0)===44;)u=u.slice(1);for(;u.charCodeAt(0)===9;)u=u.slice(1);u.includes("(")||o.push(u),i=i.slice(s+3+e.length)}for(let s of o){if(s.charCodeAt(0)===123)continue;let c=rd(s,t);c.length>0&&o.push(...c)}return o},Tx=(e)=>{if(!e)return;if(e.charCodeAt(0)!==123)return e;if(e=e.slice(2,-2),!e.includes(","))return e.indexOf("...")!==-1?e.slice(e.indexOf("...")+3):void 0;let t=e.indexOf("...");if(t!==-1)return e.slice(t+3).trimEnd()},Px=(e,t,n)=>{let o=(i,s)=>new RegExp(`${s}\\.(${i})|${s}\\["${i}"\\]|${s}\\['${i}'\\]`).test(e);for(let i of t)if(i){if(i.charCodeAt(0)===123){let s=td(i).parameters;s.query&&(n.query=!0),s.headers&&(n.headers=!0),s.body&&(n.body=!0),s.cookie&&(n.cookie=!0),s.set&&(n.set=!0),s.server&&(n.server=!0),s.url&&(n.url=!0),s.route&&(n.route=!0),s.path&&(n.path=!0);continue}if(!n.query&&(o("query",i)||e.includes("return "+i)||e.includes("return "+i+".query"))&&(n.query=!0),!n.headers&&o("headers",i)&&(n.headers=!0),!n.body&&o("body",i)&&(n.body=!0),!n.cookie&&o("cookie",i)&&(n.cookie=!0),!n.set&&o("set",i)&&(n.set=!0),!n.server&&o("server",i)&&(n.server=!0),!n.route&&o("route",i)&&(n.route=!0),!n.url&&o("url",i)&&(n.url=!0),!n.path&&o("path",i)&&(n.path=!0),n.query&&n.headers&&n.body&&n.cookie&&n.set&&n.server&&n.route&&n.url&&n.path)break}return t};var jx=(e,t,n)=>{try{let o=new RegExp(`\\w\\((?:.*?)?${e}(?:.*?)?\\)`,"gs"),i=new RegExp(`${e}(,|\\))`,"gs"),s=t.length,c;for(c=o.exec(t)+"";o.lastIndex!==0&&o.lastIndex<s+(c?c.length:0);){if(c&&i.test(c))return n.query=!0,n.headers=!0,n.body=!0,n.cookie=!0,n.set=!0,n.server=!0,n.url=!0,n.route=!0,n.path=!0,!0;c=o.exec(t)+""}let f=t.charCodeAt(o.lastIndex);return f===41||f===44?(n.query=!0,n.headers=!0,n.body=!0,n.cookie=!0,n.set=!0,n.server=!0,n.url=!0,n.route=!0,n.path=!0,!0):!1}catch{return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"),console.log("--- body ---"),console.log(t),console.log("--- context ---"),console.log(e),!0}},$i,Ds={},kx=(e)=>{e===null||ws()||(e===void 0&&(e=295000),$i&&clearTimeout($i),$i=setTimeout(()=>{Ds={},$i=void 0,vt&&Bun.gc(!1)},e),$i.unref?.())},Bs=(e,t)=>({body:e.body||t.body,cookie:e.cookie||t.cookie,headers:e.headers||t.headers,query:e.query||t.query,set:e.set||t.set,server:e.server||t.server,url:e.url||t.url,route:e.route||t.route,path:e.path||t.path}),ro=(e,t={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,url:!1,route:!1,path:!1},n={})=>{let o=[];e.request?.length&&o.push(...e.request),e.beforeHandle?.length&&o.push(...e.beforeHandle),e.parse?.length&&o.push(...e.parse),e.error?.length&&o.push(...e.error),e.transform?.length&&o.push(...e.transform),e.afterHandle?.length&&o.push(...e.afterHandle),e.mapResponse?.length&&o.push(...e.mapResponse),e.afterResponse?.length&&o.push(...e.afterResponse),e.handler&&typeof e.handler=="function"&&o.push(e.handler);for(let i=0;i<o.length;i++){let s=o[i];if(!s)continue;let c=typeof s=="object"?s.fn:s;if(typeof c!="function")continue;let f=c.toString(),u=Wr(f),l=Ds[u];if(l){t=Bs(t,l);continue}kx(n.gcTime);let d={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,url:!1,route:!1,path:!1},[y,b]=Sx(f),p=Cx(y,d),g=Tx(p);if(g){let R=rd(g,b.slice(1,-1));R.splice(0,-1,g);let L=b;L.charCodeAt(0)===123&&L.charCodeAt(b.length-1)===125&&(L=L.slice(1,-1).trim()),jx(g,L,d)||Px(L,R,d),!d.query&&L.includes("return "+g+".query")&&(d.query=!0)}if(Ds[u]||(Ds[u]=d),t=Bs(t,d),t.query&&t.headers&&t.body&&t.cookie&&t.set&&t.server&&t.url&&t.route&&t.path)break}return t};var Hs=P(ud(),1),ld=P(hi(),1);var Gx=(e)=>{let t=2166136261,n=e.length;for(let o=0;o<n;o++)t^=e.charCodeAt(o),t=Math.imul(t,16777619);return t>>>0};class Tt{constructor(e,t,n=Object.create(null)){this.name=e,this.jar=t,this.initial=n}get cookie(){return this.jar[this.name]??this.initial}set cookie(e){this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]=e,this.valueHash=void 0}get setCookie(){return this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]}set setCookie(e){this.cookie=e}get value(){return this.cookie.value}set value(e){let t=this.cookie.value;if(t!==e){if(typeof t=="object"&&t!==null&&typeof e=="object"&&e!==null)try{let n=JSON.stringify(e),o=Gx(n);if(this.valueHash!==void 0&&this.valueHash!==o)this.valueHash=o;else{if(JSON.stringify(t)===n){this.valueHash=o;return}this.valueHash=o}}catch{}this.name in this.jar||(this.jar[this.name]={...this.initial}),this.jar[this.name].value=e}}get expires(){return this.cookie.expires}set expires(e){this.setCookie.expires=e}get maxAge(){return this.cookie.maxAge}set maxAge(e){this.setCookie.maxAge=e}get domain(){return this.cookie.domain}set domain(e){this.setCookie.domain=e}get path(){return this.cookie.path}set path(e){this.setCookie.path=e}get secure(){return this.cookie.secure}set secure(e){this.setCookie.secure=e}get httpOnly(){return this.cookie.httpOnly}set httpOnly(e){this.setCookie.httpOnly=e}get sameSite(){return this.cookie.sameSite}set sameSite(e){this.setCookie.sameSite=e}get priority(){return this.cookie.priority}set priority(e){this.setCookie.priority=e}get partitioned(){return this.cookie.partitioned}set partitioned(e){this.setCookie.partitioned=e}get secrets(){return this.cookie.secrets}set secrets(e){this.setCookie.secrets=e}update(e){return this.setCookie=Object.assign(this.cookie,typeof e=="function"?e(this.cookie):e),this}set(e){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof e=="function"?e(this.cookie):e),this}remove(){if(this.value!==void 0)return this.set({expires:new Date(0),maxAge:0,value:""}),this}toString(){return typeof this.value=="object"?JSON.stringify(this.value):this.value?.toString()??""}}var dd=(e,t,n)=>(e.cookie||(e.cookie=Object.create(null)),new Proxy(t,{get(o,i){return i in t?new Tt(i,e.cookie,Object.assign({},n??{},t[i])):new Tt(i,e.cookie,Object.assign({},n))}})),Vs=async(e,t,{secrets:n,sign:o,...i}=Object.create(null))=>{if(!t)return dd(e,Object.create(null),i);let s=typeof n=="string";o&&o!==!0&&!Array.isArray(o)&&(o=[o]);let c=Object.create(null),f=Hs.parse(t);for(let[u,l]of Object.entries(f)){if(l===void 0||u==="__proto__"||u==="constructor"||u==="prototype")continue;let d=ld.default(l);if(o===!0||o?.includes(u)){if(!n)throw Error("No secret is provided to cookie plugin");if(s){if(typeof d!="string")throw new eo(u);let y=await za(d,n);if(y===!1)throw new eo(u);d=y}else{let y=!1;for(let b=0;b<n.length;b++){if(typeof d!="string")throw new eo(u);let p=await za(d,n[b]);if(p!==!1){y=!0,d=p;break}}if(!y)throw new eo(u)}}if(d){let y=d.charCodeAt(0),b=d.charCodeAt(d.length-1);if(y===123&&b===125||y===91&&b===93)try{d=JSON.parse(d)}catch{}}c[u]=Object.create(null),c[u].value=d}return dd(e,c,i)},wi=(e)=>{if(!e||!ue(e))return;let t=[];for(let[n,o]of Object.entries(e)){if(!n||!o)continue;let i=o.value;i!=null&&t.push(Hs.serialize(n,typeof i=="object"?JSON.stringify(i):i+"",o))}if(t.length!==0)return t.length===1?t[0]:t};var Te=(e,t,n)=>{if(!vt&&e instanceof Promise)return e.then((f)=>Te(f,t,n));let o=e.size,i=n?.headers.get("range");if(i){let f=/bytes=(\d*)-(\d*)/.exec(i);if(f){if(!f[1]&&!f[2])return new Response(null,{status:416,headers:qs(new Headers({"content-range":`bytes */${o}`}),t?.headers??{})});let u,l;if(!f[1]&&f[2]){let b=parseInt(f[2]);u=Math.max(0,o-b),l=o-1}else u=f[1]?parseInt(f[1]):0,l=f[2]?Math.min(parseInt(f[2]),o-1):o-1;if(u>=o||u>l)return new Response(null,{status:416,headers:qs(new Headers({"content-range":`bytes */${o}`}),t?.headers??{})});let d=l-u+1,y=new Headers({"accept-ranges":"bytes","content-range":`bytes ${u}-${l}/${o}`,"content-length":String(d)});return new Response(e.slice(u,l+1,e.type),{status:206,headers:qs(y,t?.headers??{})})}}let s=t&&(t.status===206||t.status===304||t.status===412||t.status===416),c=s?{}:{"accept-ranges":"bytes","content-range":o?`bytes 0-${o-1}/${o}`:void 0};if(!t&&!o)return new Response(e);if(!t)return new Response(e,{headers:c});if(t.headers instanceof Headers){for(let f of Object.keys(c))f in t.headers&&t.headers.append(f,c[f]);return s&&(t.headers.delete("content-length"),t.headers.delete("accept-ranges")),new Response(e,t)}return ue(t.headers)?new Response(e,{status:t.status,headers:Object.assign(c,t.headers)}):new Response(e,{status:t.status,headers:c})},nc=(e,t)=>{if(!e)return e;e.delete("set-cookie");for(let n=0;n<t.length;n++){let o=t[n].indexOf("=");e.append("set-cookie",`${t[n].slice(0,o)}=${t[n].slice(o+1)||""}`)}return e},zx=(e,t)=>{if(t?.headers){if(e)if(Ri)Object.assign(t.headers,e.headers.toJSON());else for(let[n,o]of e.headers.entries())n in t.headers&&(t.headers[n]=o);return t.status===200&&(t.status=e.status),t.headers["content-encoding"]&&delete t.headers["content-encoding"],t}if(!e)return{headers:{},status:t?.status??200};if(Ri)return t={headers:e.headers.toJSON(),status:t?.status??200},t.headers["content-encoding"]&&delete t.headers["content-encoding"],t;t={headers:{},status:t?.status??200};for(let[n,o]of e.headers.entries())n!=="content-encoding"&&n in t.headers&&(t.headers[n]=o);return t},pd=(e,t)=>t instanceof Blob?t.arrayBuffer().then((n)=>(e.enqueue(new Uint8Array(n)),!0)):t instanceof Uint8Array?(e.enqueue(t),!0):t instanceof ArrayBuffer?(e.enqueue(new Uint8Array(t)),!0):ArrayBuffer.isView(t)?(e.enqueue(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),!0):!1,Ai=({mapResponse:e,mapCompactResponse:t})=>async(n,o,i,s)=>{let c=n.next?.();if(o&&no(o),c instanceof Promise&&(c=await c),c?.value instanceof ReadableStream)n=c.value;else if(c&&(typeof c?.done>"u"||c?.done))return o?e(c.value,o,i):t(c.value,i);let f=!s&&(c?.value?.sse??n?.sse??o?.headers["content-type"]?.startsWith("text/event-stream")),u=f?(b)=>`data: ${b}
10
+
11
+ `:(b)=>b,l=f?"text/event-stream":c?.value&&typeof c?.value=="object"?"application/json":"text/plain";o?.headers?(o.headers["transfer-encoding"]||(o.headers["transfer-encoding"]="chunked"),o.headers["content-type"]||(o.headers["content-type"]=l),o.headers["cache-control"]||(o.headers["cache-control"]="no-cache")):o={status:200,headers:{"content-type":l,"transfer-encoding":"chunked","cache-control":"no-cache",connection:"keep-alive"}};let d=typeof n.next=="function"?n:n[Symbol.asyncIterator](),y=!1;return new Response(new ReadableStream({start(b){if(i?.signal?.addEventListener("abort",()=>{y=!0,d.return?.();try{b.close()}catch{}}),!(!c||c.value instanceof ReadableStream||c.value===void 0||c.value===null))if(c.value.toSSE)b.enqueue(c.value.toSSE());else{if(pd(b,c.value))return;if(typeof c.value=="object")try{b.enqueue(u(JSON.stringify(c.value)))}catch{b.enqueue(u(c.value.toString()))}else b.enqueue(u(c.value.toString()))}},async pull(b){if(y){try{b.close()}catch{}return}try{let{value:p,done:g}=await d.next();if(g||y){try{b.close()}catch{}return}if(p==null)return;if(p.toSSE)b.enqueue(p.toSSE());else{if(pd(b,p))return;if(typeof p=="object")try{b.enqueue(u(JSON.stringify(p)))}catch{b.enqueue(u(p.toString()))}else b.enqueue(u(p.toString()))}}catch(p){console.warn(p);try{b.close()}catch{}}},cancel(){y=!0,d.return?.()}}),o)};async function*Jx(e){let t=e.body;if(!t)return;let n=t.getReader(),o=new TextDecoder;try{for(;;){let{done:i,value:s}=await n.read();if(i)break;typeof s=="string"?yield s:yield o.decode(s)}}finally{n.releaseLock()}}var no=(e)=>{if(typeof e.status=="string"&&(e.status=Cr[e.status]),e.cookie&&ue(e.cookie)){let t=wi(e.cookie);t&&(e.headers["set-cookie"]=t)}e.headers["set-cookie"]&&Array.isArray(e.headers["set-cookie"])&&(e.headers=nc(new Headers(e.headers),e.headers["set-cookie"]))};function qs(e,t){let n=new Headers(e);if(t instanceof Headers)for(let o of t.keys())if(o==="set-cookie"){if(n.has("set-cookie"))continue;for(let i of t.getSetCookie())n.append("set-cookie",i)}else e.has(o)||n.set(o,t?.get(o)??"");else for(let o in t)o==="set-cookie"?n.append(o,t[o]):e.has(o)||n.set(o,t[o]);return n}function Wx(e,t){return typeof t=="string"&&(t=Cr[t]),e===200?t:e}var _s=(e)=>{let t=Ai(e);return(n,o,i)=>{let s=new Response(n.body,{headers:qs(n.headers,o.headers),status:Wx(n.status,o.status)});return!s.headers.has("content-length")&&s.headers.get("transfer-encoding")==="chunked"?t(Jx(s),zx(s,o),i,!0):s}};async function md(e,t=2){let n=[],o=!1,i=[];(async()=>{for await(let c of e)n.push(c),i.forEach((f)=>f.resolve()),i=[];o=!0,i.forEach((c)=>c.resolve())})();async function*s(){let c=0;for(;;)if(c<n.length)yield n[c++];else{if(o)return;await new Promise((f)=>i.push({resolve:f}))}}return Array.from({length:t},s)}var Gs=(e,t={headers:{}},n)=>{let o=e.path,i=Va[o.slice(o.lastIndexOf(".")+1)];return i&&(t.headers["content-type"]=i),e.stats&&t.status!==206&&t.status!==304&&t.status!==412&&t.status!==416?e.stats.then((s)=>{let c=s.size;return c!==void 0&&(t.headers["content-range"]=`bytes 0-${c-1}/${c}`,t.headers["content-length"]=c),Te(e.value,t,n)}):Te(e.value,t,n)},It=(e,t,n)=>{if(ue(t.headers)||t.status!==200||t.cookie)switch(no(t),e?.constructor?.name){case"String":return t.headers["content-type"]||(t.headers["content-type"]="text/plain"),new Response(e,t);case"Array":case"Object":return t.headers["content-type"]||(t.headers["content-type"]="application/json"),new Response(JSON.stringify(e),t);case"ElysiaFile":return Gs(e,t,n);case"File":return Te(e,t,n);case"Blob":return Te(e,t,n);case"ElysiaCustomStatusResponse":return t.status=e.code,It(e.response,t,n);case void 0:return e?new Response(JSON.stringify(e),t):new Response("",t);case"Response":return zs(e,t,n);case"Error":return An(e,t);case"Promise":return e.then((o)=>It(o,t,n));case"Function":return It(e(),t,n);case"Number":case"Boolean":return new Response(e.toString(),t);case"Cookie":return e instanceof Tt?new Response(e.value,t):new Response(e?.toString(),t);case"FormData":return new Response(e,t);default:if(e instanceof Response)return zs(e,t,n);if(e instanceof Promise)return e.then((o)=>It(o,t));if(e instanceof Error)return An(e,t);if(e instanceof ve)return t.status=e.code,It(e.response,t,n);if(typeof e?.next=="function"||e instanceof ReadableStream)return Si(e,t,n);if(typeof e?.then=="function")return e.then((o)=>It(o,t));if(Array.isArray(e))return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}});if(typeof e?.toResponse=="function")return It(e.toResponse(),t);if("charCodeAt"in e){let o=e.charCodeAt(0);if(o===123||o===91)return t.headers["Content-Type"]||(t.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),t)}return new Response(e,t)}return typeof e?.next=="function"||e instanceof ReadableStream?Si(e,t,n):gr(e,n)},xt=(e,t,n)=>{if(e!=null)if(ue(t.headers)||t.status!==200||t.cookie)switch(no(t),e?.constructor?.name){case"String":return t.headers["content-type"]||(t.headers["content-type"]="text/plain"),new Response(e,t);case"Array":case"Object":return t.headers["content-type"]||(t.headers["content-type"]="application/json"),new Response(JSON.stringify(e),t);case"ElysiaFile":return Gs(e,t,n);case"File":return Te(e,t,n);case"Blob":return Te(e,t,n);case"ElysiaCustomStatusResponse":return t.status=e.code,xt(e.response,t,n);case void 0:return e?new Response(JSON.stringify(e),t):void 0;case"Response":return zs(e,t,n);case"Promise":return e.then((o)=>xt(o,t));case"Error":return An(e,t);case"Function":return xt(e(),t);case"Number":case"Boolean":return new Response(e.toString(),t);case"FormData":return new Response(e);case"Cookie":return e instanceof Tt?new Response(e.value,t):new Response(e?.toString(),t);default:if(e instanceof Response)return zs(e,t,n);if(e instanceof Promise)return e.then((o)=>xt(o,t));if(e instanceof Error)return An(e,t);if(e instanceof ve)return t.status=e.code,xt(e.response,t,n);if(typeof e?.next=="function"||e instanceof ReadableStream)return Si(e,t,n);if(typeof e?.then=="function")return e.then((o)=>xt(o,t));if(typeof e?.toResponse=="function")return xt(e.toResponse(),t);if(Array.isArray(e))return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}});if("charCodeAt"in e){let o=e.charCodeAt(0);if(o===123||o===91)return t.headers["Content-Type"]||(t.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),t)}return new Response(e,t)}else switch(e?.constructor?.name){case"String":return t.headers["content-type"]||(t.headers["content-type"]="text/plain"),new Response(e);case"Array":case"Object":return t.headers["content-type"]||(t.headers["content-type"]="application/json"),new Response(JSON.stringify(e),t);case"ElysiaFile":return Gs(e,t,n);case"File":return Te(e,t,n);case"Blob":return Te(e,t,n);case"ElysiaCustomStatusResponse":return t.status=e.code,xt(e.response,t,n);case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e;case"Promise":return e.then((o)=>{let i=xt(o,t);if(i!==void 0)return i});case"Error":return An(e,t);case"Function":return gr(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof Tt?new Response(e.value,t):new Response(e?.toString(),t);case"FormData":return new Response(e);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then((o)=>xt(o,t));if(e instanceof Error)return An(e,t);if(e instanceof ve)return t.status=e.code,xt(e.response,t,n);if(typeof e?.next=="function"||e instanceof ReadableStream)return Si(e,t,n);if(typeof e?.then=="function")return e.then((o)=>xt(o,t));if(typeof e?.toResponse=="function")return xt(e.toResponse(),t);if(Array.isArray(e))return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}});if("charCodeAt"in e){let o=e.charCodeAt(0);if(o===123||o===91)return t.headers["Content-Type"]||(t.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),t)}return new Response(e)}},gr=(e,t)=>{switch(e?.constructor?.name){case"String":return new Response(e,{headers:{"Content-Type":"text/plain"}});case"Object":case"Array":return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}});case"ElysiaFile":return Gs(e,void 0,t);case"File":return Te(e,void 0,t);case"Blob":return Te(e,void 0,t);case"ElysiaCustomStatusResponse":return It(e.response,{status:e.code,headers:{}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e;case"Error":return An(e);case"Promise":return e.then((n)=>gr(n,t));case"Function":return gr(e(),t);case"Number":case"Boolean":return new Response(e.toString());case"FormData":return new Response(e);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then((n)=>gr(n,t));if(e instanceof Error)return An(e);if(e instanceof ve)return It(e.response,{status:e.code,headers:{}});if(typeof e?.next=="function"||e instanceof ReadableStream)return Si(e,void 0,t);if(typeof e?.then=="function")return e.then((n)=>gr(n,t));if(typeof e?.toResponse=="function")return gr(e.toResponse());if(Array.isArray(e))return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}});if("charCodeAt"in e){let n=e.charCodeAt(0);if(n===123||n===91)return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}})}return new Response(e)}},An=(e,t)=>{if(typeof e?.toResponse=="function"){let n=e.toResponse(),o=t??{headers:{},status:200,redirect:""},i=(s)=>(s instanceof Response&&(o.status=s.status),It(s,o));return typeof n?.then=="function"?n.then(i):i(n)}return new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:t?.status!==200?t?.status??500:500,headers:t?.headers})},yd=(e,t,n={})=>{if(typeof e=="function")return;let o=It(e,{headers:n});if(!t.parse?.length&&!t.transform?.length&&!t.beforeHandle?.length&&!t.afterHandle?.length)return()=>o.clone()},zs=_s({mapResponse:It,mapCompactResponse:gr}),Si=Ai({mapResponse:It,mapCompactResponse:gr});var Fi={name:"web-standard",isWebStandard:!0,handler:{mapResponse:It,mapEarlyResponse:xt,mapCompactResponse:gr,createStaticHandler:yd},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers={}
12
+ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
13
+ `,parser:{json(e){return e?`try{c.body=await c.request.json()}catch{}
14
+ `:`c.body=await c.request.json()
15
+ `},text(){return`c.body=await c.request.text()
16
+ `},urlencoded(){return`c.body=parseQuery(await c.request.text())
17
+ `},arrayBuffer(){return`c.body=await c.request.arrayBuffer()
18
+ `},formData(e){let t=`
19
+ c.body={}
20
+ `;return e?t+="let form;try{form=await c.request.formData()}catch{}":t+=`const form=await c.request.formData()
21
+ `,t+`const dangerousKeys=new Set(['__proto__','constructor','prototype'])
22
+ const isDangerousKey=(k)=>{if(dangerousKeys.has(k))return true;const m=k.match(/^(.+)\\[(\\d+)\\]$/);return m?dangerousKeys.has(m[1]):false}
23
+ const parseArrayKey=(k)=>{const m=k.match(/^(.+)\\[(\\d+)\\]$/);return m?{name:m[1],index:parseInt(m[2],10)}:null}
24
+ const grouped=new Map()
25
+ form.forEach((v,k)=>{const l=grouped.get(k);if(l)l.push(v);else grouped.set(k,[v])})
26
+ for(const [key,value] of grouped){if(c.body[key])continue
27
+ let finalValue
28
+ if(value.length===1){
29
+ const sv=value[0]
30
+ if(typeof sv==='string'&&(sv.charCodeAt(0)===123||sv.charCodeAt(0)===91)){
31
+ try{
32
+ const p=JSON.parse(sv)
33
+ if(p&&typeof p==='object')finalValue=p
34
+ }catch{}
35
+ }
36
+ if(finalValue===undefined)finalValue=sv
37
+ }else finalValue=value
38
+ if(Array.isArray(finalValue)){
39
+ const stringValue=finalValue.find((entry)=>typeof entry==='string')
40
+ const files=typeof File==='undefined'?[]:finalValue.filter((entry)=>entry instanceof File)
41
+ if(stringValue&&files.length&&stringValue.charCodeAt(0)===123){
42
+ try{
43
+ const parsed=JSON.parse(stringValue)
44
+ if(parsed&&typeof parsed==='object'&&!Array.isArray(parsed)){
45
+ if(!('file' in parsed)&&files.length===1)parsed.file=files[0]
46
+ else if(!('files' in parsed)&&files.length>1)parsed.files=files
47
+ finalValue=parsed
48
+ }
49
+ }catch{}
50
+ }
51
+ }
52
+ if(key.includes('.')||key.includes('[')){const keys=key.split('.')
53
+ const lastKey=keys.pop()
54
+ if(isDangerousKey(lastKey)||keys.some(isDangerousKey))continue
55
+ let current=c.body
56
+ for(const k of keys){const arrayInfo=parseArrayKey(k)
57
+ if(arrayInfo){if(!Array.isArray(current[arrayInfo.name]))current[arrayInfo.name]=[]
58
+ const existing=current[arrayInfo.name][arrayInfo.index]
59
+ const isFile=typeof File!=='undefined'&&existing instanceof File
60
+ if(!existing||typeof existing!=='object'||Array.isArray(existing)||isFile){
61
+ let parsed
62
+ if(typeof existing==='string'&&existing.charCodeAt(0)===123){
63
+ try{parsed=JSON.parse(existing)
64
+ if(!parsed||typeof parsed!=='object'||Array.isArray(parsed))parsed=undefined}catch{}
65
+ }
66
+ current[arrayInfo.name][arrayInfo.index]=parsed||{}
67
+ }
68
+ current=current[arrayInfo.name][arrayInfo.index]}else{if(!current[k]||typeof current[k]!=='object')current[k]={}
69
+ current=current[k]}}
70
+ const arrayInfo=parseArrayKey(lastKey)
71
+ if(arrayInfo){if(!Array.isArray(current[arrayInfo.name]))current[arrayInfo.name]=[]
72
+ current[arrayInfo.name][arrayInfo.index]=finalValue}else{current[lastKey]=finalValue}}else c.body[key]=finalValue}`}}},async stop(e,t){if(!e.server)throw Error("Elysia isn't running. Call `app.listen` to start the server.");if(e.server&&(await e.server.stop(t),e.server=null,e.event.stop?.length))for(let n=0;n<e.event.stop.length;n++)e.event.stop[n].fn(e)},composeGeneralHandler:{parameters:"r",createContext(e){let t="",n="",o=e.setHeaders;for(let c of Object.keys(e.decorator))t+=`,'${c}':decorator['${c}']`;let i=e.config.handler?.standardHostname??!0,s=!!e.event.trace?.length;return n+=`const u=r.url,s=u.indexOf('/',${i?11:7}),qi=u.indexOf('?',s+1),p=u.substring(s,qi===-1?undefined:qi)
73
+ `,s&&(n+=`const id=randomId()
74
+ `),n+="const c={request:r,store,qi,path:p,url:u,redirect,status,set:{headers:",n+=Object.keys(o??{}).length?"Object.assign({},app.setHeaders)":"Object.create(null)",n+=",status:200}",e.inference.server&&(n+=",get server(){return app.getServer()}"),s&&(n+=",[ELYSIA_REQUEST_ID]:id"),n+=t,n+=`}
75
+ `,n},error404(e,t,n=""){let o="if(route===null){"+n+(t?"":"c.set.status=404")+`
76
+ return `;return t?o+=`app.handleError(c,notFound,false,${this.parameters})`:o+=e?"c.response=c.responseValue=new Response(error404Message,{status:c.set.status===200?404:c.set.status,headers:c.set.headers})":"c.response=c.responseValue=error404.clone()",o+="}",{declare:t?"":`const error404Message=notFound.message.toString()
77
+ const error404=new Response(error404Message,{status:404})
78
+ `,code:o}}},composeError:{mapResponseContext:"",validationError:"set.headers['content-type']='application/json';return mapResponse(error.message,set)",unknownError:"set.status=error.status??set.status??500;return mapResponse(error.message,set)"},listen(){return()=>{throw Error("WebStandard does not support listen, you might want to export default Elysia.fetch instead")}}};var dt=(e,t,n)=>{if(ue(t.headers)||t.status!==200||t.cookie)switch(no(t),e?.constructor?.name){case"String":return new Response(e,t);case"Array":case"Object":return Response.json(e,t);case"ElysiaFile":return Te(e.value,t,n);case"File":return Te(e,t,n);case"Blob":return Te(e,t,n);case"ElysiaCustomStatusResponse":return t.status=e.code,dt(e.response,t,n);case void 0:return e?Response.json(e,t):new Response("",t);case"Response":return Js(e,t,n);case"Error":return Sn(e,t);case"Promise":return e.then((o)=>dt(o,t,n));case"Function":return dt(e(),t,n);case"Number":case"Boolean":return new Response(e.toString(),t);case"Cookie":return e instanceof Tt?new Response(e.value,t):new Response(e?.toString(),t);case"FormData":return new Response(e,t);default:if(e instanceof Response)return Js(e,t,n);if(e instanceof Promise)return e.then((o)=>dt(o,t));if(e instanceof Error)return Sn(e,t);if(e instanceof ve)return t.status=e.code,dt(e.response,t,n);if(typeof e?.next=="function"||e instanceof ReadableStream)return Ei(e,t,n);if(typeof e?.then=="function")return e.then((o)=>dt(o,t));if(Array.isArray(e))return Response.json(e);if(typeof e?.toResponse=="function")return dt(e.toResponse(),t);if("charCodeAt"in e){let o=e.charCodeAt(0);if(o===123||o===91)return Response.json(e,t)}return new Response(e,t)}return typeof e?.next=="function"||e instanceof ReadableStream?Ei(e,t,n):br(e,n)},ut=(e,t,n)=>{if(e!=null)if(ue(t.headers)||t.status!==200||t.cookie)switch(no(t),e?.constructor?.name){case"String":return new Response(e,t);case"Array":case"Object":return Response.json(e,t);case"ElysiaFile":return Te(e.value,t,n);case"File":return Te(e,t,n);case"Blob":return Te(e,t,n);case"ElysiaCustomStatusResponse":return t.status=e.code,ut(e.response,t,n);case void 0:return e?Response.json(e,t):void 0;case"Response":return Js(e,t,n);case"Promise":return e.then((o)=>ut(o,t));case"Error":return Sn(e,t);case"Function":return ut(e(),t);case"Number":case"Boolean":return new Response(e.toString(),t);case"FormData":return new Response(e);case"Cookie":return e instanceof Tt?new Response(e.value,t):new Response(e?.toString(),t);default:if(e instanceof Response)return Js(e,t,n);if(e instanceof Promise)return e.then((o)=>ut(o,t));if(e instanceof Error)return Sn(e,t);if(e instanceof ve)return t.status=e.code,ut(e.response,t,n);if(typeof e?.next=="function"||e instanceof ReadableStream)return Ei(e,t,n);if(typeof e?.then=="function")return e.then((o)=>ut(o,t));if(typeof e?.toResponse=="function")return ut(e.toResponse(),t);if(Array.isArray(e))return Response.json(e);if("charCodeAt"in e){let o=e.charCodeAt(0);if(o===123||o===91)return Response.json(e,t)}return new Response(e,t)}else switch(e?.constructor?.name){case"String":return new Response(e);case"Array":case"Object":return Response.json(e,t);case"ElysiaFile":return Te(e.value,t,n);case"File":return Te(e,t,n);case"Blob":return Te(e,t,n);case"ElysiaCustomStatusResponse":return t.status=e.code,ut(e.response,t,n);case void 0:return e?Response.json(e):new Response("");case"Response":return e;case"Promise":return e.then((o)=>{let i=ut(o,t);if(i!==void 0)return i});case"Error":return Sn(e,t);case"Function":return br(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof Tt?new Response(e.value,t):new Response(e?.toString(),t);case"FormData":return new Response(e);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then((o)=>ut(o,t));if(e instanceof Error)return Sn(e,t);if(e instanceof ve)return t.status=e.code,ut(e.response,t,n);if(typeof e?.next=="function"||e instanceof ReadableStream)return Ei(e,t,n);if(typeof e?.then=="function")return e.then((o)=>ut(o,t));if(typeof e?.toResponse=="function")return ut(e.toResponse(),t);if(Array.isArray(e))return Response.json(e);if("charCodeAt"in e){let o=e.charCodeAt(0);if(o===123||o===91)return Response.json(e,t)}return new Response(e)}},br=(e,t)=>{switch(e?.constructor?.name){case"String":return new Response(e);case"Object":case"Array":return Response.json(e);case"ElysiaFile":return Te(e.value,void 0,t);case"File":return Te(e,void 0,t);case"Blob":return Te(e,void 0,t);case"ElysiaCustomStatusResponse":return dt(e.response,{status:e.code,headers:{}});case void 0:return e?Response.json(e):new Response("");case"Response":return e;case"Error":return Sn(e);case"Promise":return e.then((n)=>br(n,t));case"Function":return br(e(),t);case"Number":case"Boolean":return new Response(e.toString());case"FormData":return new Response(e);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then((n)=>br(n,t));if(e instanceof Error)return Sn(e);if(e instanceof ve)return dt(e.response,{status:e.code,headers:{}});if(typeof e?.next=="function"||e instanceof ReadableStream)return Ei(e,void 0,t);if(typeof e?.then=="function")return e.then((n)=>br(n,t));if(typeof e?.toResponse=="function")return br(e.toResponse());if(Array.isArray(e))return Response.json(e);if("charCodeAt"in e){let n=e.charCodeAt(0);if(n===123||n===91)return Response.json(e)}return new Response(e)}},Sn=(e,t)=>{if(typeof e?.toResponse=="function"){let n=e.toResponse(),o=t??{headers:{},status:200,redirect:""},i=(s)=>(s instanceof Response&&(o.status=s.status),dt(s,o));return typeof n?.then=="function"?n.then(i):i(n)}return Response.json({name:e?.name,message:e?.message,cause:e?.cause},{status:t?.status!==200?t?.status??500:500,headers:t?.headers})},hd=(e,t,n={})=>{if(typeof e=="function")return;let o=dt(e,{headers:n});if(!t.parse?.length&&!t.transform?.length&&!t.beforeHandle?.length&&!t.afterHandle?.length)return()=>o.clone()},Js=_s({mapResponse:dt,mapCompactResponse:br}),Ei=Ai({mapResponse:dt,mapCompactResponse:br});var Sd=P(hi(),1);var oo=P(hi(),1),Go=1,zo=2,Jo=4,tn=8;function oc(e,t=0,n,o){let i=Object.create(null),s=0,c=e.length,f=t-1,u=f;for(let d=0;d<c;d++)switch(e.charCodeAt(d)){case 38:l(e,d),f=d,u=d,s=0;break;case 61:u<=f?u=d:s|=tn;break;case 43:u>f?s|=Jo:s|=Go;break;case 37:u>f?s|=tn:s|=zo;break}return f<c&&l(e,c),i;function l(d,y){let b=u>f,p=b?u:y,g=d.slice(f+1,p);if(!b&&g.length===0)return;let R=g;s&Go&&(R=R.replace(/\+/g," ")),s&zo&&(R=oo.default(R)||R);let L="";if(b){let H=d.slice(u+1,y);s&Jo&&(H=H.replace(/\+/g," ")),s&tn&&(H=oo.default(H)||H),L=H}let J=i[R];n&&n?.[R]?L.charCodeAt(0)===91?(o&&o?.[R]?L=JSON.parse(L):L=L.slice(1,-1).split(","),J===void 0?i[R]=L:Array.isArray(J)?J.push(...L):(i[R]=L,i[R].unshift(J))):J===void 0?i[R]=L:Array.isArray(J)?J.push(L):i[R]=[J,L]:i[R]=L}}function gd(e,t=0){let n=Object.create(null),o=0,i=e.length,s=t-1,c=s;for(let u=0;u<i;u++)switch(e.charCodeAt(u)){case 38:f(e,u),s=u,c=u,o=0;break;case 61:c<=s?c=u:o|=tn;break;case 43:c>s?o|=Jo:o|=Go;break;case 37:c>s?o|=tn:o|=zo;break}return s<i&&f(e,i),n;function f(u,l){let d=c>s,y=d?c:l,b=u.slice(s+1,y);if(!d&&b.length===0)return;let p=b;o&Go&&(p=p.replace(/\+/g," ")),o&zo&&(p=oo.default(p)||p);let g="";if(d){let L=u.slice(c+1,l);o&Jo&&(L=L.replace(/\+/g," ")),o&tn&&(L=oo.default(L)||L),g=L}let R=n[p];if(g.charCodeAt(0)===91&&g.charCodeAt(g.length-1)===93){try{g=JSON.parse(g)}catch{}R===void 0?n[p]=g:Array.isArray(R)?R.push(g):n[p]=[R,g]}else if(g.charCodeAt(0)===123&&g.charCodeAt(g.length-1)===125){try{g=JSON.parse(g)}catch{}R===void 0?n[p]=g:Array.isArray(R)?R.push(g):n[p]=[R,g]}else g.includes(",")&&(g=g.split(",")),R===void 0?n[p]=g:Array.isArray(R)?R.push(g):n[p]=[R,g]}}function Fn(e){let t=Object.create(null),n=0,o=e.length,i=-1,s=-1;for(let f=0;f<o;f++)switch(e.charCodeAt(f)){case 38:c(e,f),i=f,s=f,n=0;break;case 61:s<=i?s=f:n|=tn;break;case 43:s>i?n|=Jo:n|=Go;break;case 37:s>i?n|=tn:n|=zo;break}return i<o&&c(e,o),t;function c(f,u){let l=s>i,d=l?s:u,y=f.slice(i+1,d);if(!l&&y.length===0)return;let b=y;n&Go&&(b=b.replace(/\+/g," ")),n&zo&&(b=oo.default(b)||b);let p="";if(l){let R=f.slice(s+1,u);n&Jo&&(R=R.replace(/\+/g," ")),n&tn&&(R=oo.default(R)||R),p=R}let g=t[b];g===void 0?t[b]=p:Array.isArray(g)?g.push(p):t[b]=[g,p]}}var io=Symbol("ElysiaTrace"),rn=()=>{let{promise:e,resolve:t}=Promise.withResolvers(),{promise:n,resolve:o}=Promise.withResolvers(),{promise:i,resolve:s}=Promise.withResolvers(),c=[],f=[];return[(u)=>(u&&c.push(u),e),(u)=>{let l=[],d=[],y=null;for(let p=0;p<(u.total??0);p++){let{promise:g,resolve:R}=Promise.withResolvers(),{promise:L,resolve:J}=Promise.withResolvers(),{promise:H,resolve:_}=Promise.withResolvers(),j=[],k=[];l.push((q)=>(q&&j.push(q),g)),d.push((q)=>{let se={...q,end:L,error:H,index:p,onStop(K){return K&&k.push(K),L}};R(se);for(let K=0;K<j.length;K++)j[K](se);return(K=null)=>{let U=performance.now();K&&(y=K);let D={end:U,error:K,get elapsed(){return U-q.begin}};for(let x=0;x<k.length;x++)k[x](D);J(U),_(K)}})}let b={...u,end:n,error:i,onEvent(p){for(let g=0;g<l.length;g++)l[g](p)},onStop(p){return p&&f.push(p),n}};t(b);for(let p=0;p<c.length;p++)c[p](b);return{resolveChild:d,resolve(p=null){let g=performance.now();!p&&y&&(p=y);let R={end:g,error:p,get elapsed(){return g-u.begin}};for(let L=0;L<f.length;L++)f[L](R);o(g),s(p)}}}]},bd=(e)=>(t)=>{let[n,o]=rn(),[i,s]=rn(),[c,f]=rn(),[u,l]=rn(),[d,y]=rn(),[b,p]=rn(),[g,R]=rn(),[L,J]=rn(),[H,_]=rn();return e({id:t[Yr],context:t,set:t.set,onRequest:n,onParse:i,onTransform:c,onBeforeHandle:u,onHandle:d,onAfterHandle:b,onMapResponse:L,onAfterResponse:H,onError:g,time:Date.now(),store:t.store}),{request:o,parse:s,transform:f,beforeHandle:l,handle:y,afterHandle:p,error:R,mapResponse:J,afterResponse:_}};var Pt=Symbol.for("TypeBox.Kind"),Qx=Symbol.for("TypeBox.Hint"),Id=(e)=>/(\ |-|\t|\n|\.|\[|\]|\{|\})/.test(e)||!isNaN(+e[0]),Od=(e,t,n=!1)=>{if(typeof t==="number")return`${e}[${t}]`;if(Id(t))return`${e}${n?"?.":""}["${t}"]`;return`${e}${n?"?":""}.${t}`},Yx=(e)=>Id(e)?`"${e}"`:e,xd=(e,t=0,n)=>{if(n.type!=="string"||n.const||n.trusted)return e;let o="";for(let i=t-1;i>=0;i--)o+=`d.h${i}(`;return o+e+")".repeat(t)},Rd=(e)=>{if(!e.allOf||Pt in e&&(e[Pt]!=="Intersect"||e.type!=="object"))return e;let{allOf:t,...n}=e;if(n.properties={},Pt in n)n[Pt]="Object";for(let o of t){if(o.type!=="object")continue;let{properties:i,required:s,type:c,[Pt]:f,...u}=o;if(s)n.required=n.required?n.required.concat(s):s;Object.assign(n,u);for(let l in o.properties)n.properties[l]=Rd(o.properties[l])}return n},Zx=(e,t,n)=>{let o=e.patternProperties["^(.*)$"]??e.patternProperties[Object.keys(e.patternProperties)[0]];if(!o)return t;let i=n.array;n.array++;let s=`(()=>{const ar${i}s=Object.keys(${t}),ar${i}v={};for(let i=0;i<ar${i}s.length;i++){const ar${i}p=${t}[ar${i}s[i]];ar${i}v[ar${i}s[i]]=${Tr(o,`ar${i}p`,n)}`,c=n.optionalsInArray[i+1];if(c){for(let f=0;f<c.length;f++){let u=`ar${i}v[ar${i}s[i]]${c[f]}`;s+=`;if(${u}===undefined)delete ${u}`}n.optionalsInArray[i+1]=[]}return s+=`}return ar${i}v})()`,s},Xx=(e,t,n)=>{let o=n.array;n.array++;let i=t==="v"&&!n.unions.length,s="";if(!i)s="(()=>{";s+=`const ar${o}v=[`;for(let c=0;c<e.length;c++){if(c!==0)s+=",";s+=Tr(e[c],Od(t,c,n.parentIsOptional||n.fromUnion),n)}if(s+="];",!i)s+=`return ar${o}v})()`;return s};function Ws(e,t=new WeakMap){if(e===null||typeof e!=="object"||typeof e==="function")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){let n=Array(e.length);t.set(e,n);for(let o=0;o<e.length;o++)n[o]=Ws(e[o],t);return n}if(typeof e==="object"){let n=Object.keys(e).concat(Object.getOwnPropertySymbols(e)),o={};for(let i of n)o[i]=Ws(e[i],t);return o}return e}var eI=(e,t,n)=>{if(n.TypeCompiler===void 0){if(!n.typeCompilerWanred)console.warn(Error("[exact-mirror] TypeBox's TypeCompiler is required to use Union")),n.typeCompilerWanred=!0;return t}n.unionKeys[t]=1;let o=n.unions.length,i=n.unions[o]=[],s=`(()=>{
79
+ `,c=(u)=>{if(!(Pt in u)||!u.$ref)return u;if(u[Pt]==="This")return Ws(n.definitions[u.$ref]);else if(u[Pt]==="Ref")if(!n.modules)console.warn(Error("[exact-mirror] modules is required when using nested cyclic reference"));else return n.modules.Import(u.$ref);return u},f="";for(let u=0;u<e.length;u++){let l=c(e[u]);if(Array.isArray(l.anyOf))for(let d=0;d<l.anyOf.length;d++)l.anyOf[d]=c(l.anyOf[d]);else if(l.items)if(Array.isArray(l.items))for(let d=0;d<l.items.length;d++)l.items[d]=c(l.items[d]);else l.items=c(l.items);i.push(mr.Compile(l)),s+=`if(d.unions[${o}][${u}].Check(${t})){return ${Tr(l,t,{...n,recursion:n.recursion+1,parentIsOptional:!0,fromUnion:!0})}}
80
+ `,f+=(u?"":"let ")+"tmp="+Tr(l,t,{...n,recursion:n.recursion+1,parentIsOptional:!0,fromUnion:!0})+`
81
+ if(d.unions[${o}][${u}].Check(tmp))return tmp
82
+ `}if(f)s+=f;return s+=`return ${n.removeUnknownUnionType?"undefined":t}`,s+"})()"},Tr=(e,t,n)=>{if(!e)return"";let o=t==="v"&&!n.unions.length;if(Pt in e&&e[Pt]==="Import"&&e.$ref in e.$defs)return Tr(e.$defs[e.$ref],t,{...n,definitions:Object.assign(n.definitions,e.$defs)});if(o&&e.type!=="object"&&e.type!=="array"&&!e.anyOf)return`return ${xd("v",n.sanitize?.length,e)}`;if(n.recursion>=n.recursionLimit)return t;let i="";if(e.$id&&Qx in e)n.definitions[e.$id]=e;switch(e.type){case"object":if(e[Pt]==="Record"){i=Zx(e,t,n);break}if(e=Rd(e),i+="{",e.additionalProperties)i+=`...${t},`;let s=Object.keys(e.properties);for(let l=0;l<s.length;l++){let d=s[l],y=!e.required||e.required&&!e.required.includes(d)||Array.isArray(e.properties[d].anyOf),b=Od(t,d,n.parentIsOptional||n.fromUnion);if(y){let g=n.array;if(t.startsWith("ar")){let R=b.indexOf("."),L;if(R>=0)L=b.slice(R);else L=b.slice(t.length);if(L.startsWith("?."))if(L.charAt(2)==="[")L=L.slice(2);else L=L.slice(1);let J=n.optionalsInArray;if(J[g])J[g].push(L);else J[g]=[L]}else n.optionals.push(b)}let p=e.properties[d];if(l!==0)i+=",";i+=`${Yx(d)}:${y?`${b}===undefined?undefined:`:""}${Tr(p,b,{...n,recursion:n.recursion+1,parentIsOptional:y})}`}i+="}";break;case"array":if(e.items.type!=="object"&&e.items.type!=="array"){if(Array.isArray(e.items)){i=Xx(e.items,t,n);break}else if(o&&!Array.isArray(e.items.anyOf))return"return v";else if(Pt in e.items&&e.items.$ref&&(e.items[Pt]==="Ref"||e.items[Pt]==="This"))i=Tr(Ws(n.definitions[e.items.$ref]),t,{...n,parentIsOptional:!0,recursion:n.recursion+1});else if(!Array.isArray(e.items.anyOf)){i=t;break}}let c=n.array;n.array++;let f=t;if(o)i=`const ar${c}v=new Array(${t}.length);`;else f=`ar${c}s`,i=`((${f})=>{const ar${c}v=new Array(${f}.length);`;i+=`for(let i=0;i<${f}.length;i++){const ar${c}p=${f}[i];ar${c}v[i]=${Tr(e.items,`ar${c}p`,n)}`;let u=n.optionalsInArray[c+1];if(u){for(let l=0;l<u.length;l++){let d=`ar${c}v[i]${u[l]}`;i+=`;if(${d}===undefined)delete ${d}`}n.optionalsInArray[c+1]=[]}if(i+="}",!o)i+=`return ar${c}v})(${t})`;break;default:if(e.$ref&&e.$ref in n.definitions)return Tr(n.definitions[e.$ref],t,n);if(Array.isArray(e.anyOf)){i=eI(e.anyOf,t,n);break}i=xd(t,n.sanitize?.length,e);break}if(!o)return i;if(e.type==="array")i=`${i}const x=ar0v;`;else i=`const x=${i}
83
+ `;for(let s=0;s<n.optionals.length;s++){let c=n.optionals[s],f=c.slice(1);if(i+=`if(${c}===undefined`,n.unionKeys[c])i+=`||x${f}===undefined`;let u=f.charCodeAt(0)!==63&&e.type!=="array";i+=`)delete x${u?f.charCodeAt(0)===91?"?.":"?":""}${f}
84
+ `}return`${i}return x`},Qs=(e,{TypeCompiler:t,modules:n,definitions:o,sanitize:i,recursionLimit:s=8,removeUnknownUnionType:c=!1}={})=>{let f=[];if(typeof i==="function")i=[i];let u=Tr(e,"v",{optionals:[],optionalsInArray:[],array:0,parentIsOptional:!1,unions:f,unionKeys:{},TypeCompiler:t,modules:n,definitions:o??n?.$defs??{},sanitize:i,recursion:0,recursionLimit:s,removeUnknownUnionType:c});if(!f.length&&!i?.length)return Function("v",u);let l;if(i?.length){l={};for(let d=0;d<i.length;d++)l[`h${d}`]=i[d]}return Function("d",`return function mirror(v){${u}}`)({unions:f,...l})};var Ci=(e,t)=>{if(Array.isArray(t)){let n=e;for(let o of t)n=$d(n,o);return n}return $d(e,t)},$d=(e,t)=>{if(t.rootOnly&&t.excludeRoot)throw Error("Can't set both rootOnly and excludeRoot");if(t.rootOnly&&t.onlyFirst)throw Error("Can't set both rootOnly and onlyFirst");if(t.rootOnly&&t.untilObjectFound)throw Error("Can't set both rootOnly and untilObjectFound");let n=({s:o,isRoot:i,treeLvl:s})=>{if(!o)return o;let c=i&&t.excludeRoot,f=t.from[I];if(o.elysiaMeta)return t.from.elysiaMeta===o.elysiaMeta&&!c?t.to(o):o;let u=f&&o[I]===f;if(!c&&t.onlyFirst&&o.type===t.onlyFirst||i&&t.rootOnly)return u?t.to(o):o;if(!i&&t.untilObjectFound&&o.type==="object")return o;let l={isRoot:!1,treeLvl:s+1},d={...o};if(o.oneOf&&(d.oneOf=o.oneOf.map((y)=>n({...l,s:y}))),o.anyOf&&(d.anyOf=o.anyOf.map((y)=>n({...l,s:y}))),o.allOf&&(d.allOf=o.allOf.map((y)=>n({...l,s:y}))),o.not&&(d.not=n({...l,s:o.not})),o.properties){d.properties={};for(let[y,b]of Object.entries(o.properties))d.properties[y]=n({...l,s:b})}if(o.items){let y=o.items;d.items=Array.isArray(y)?y.map((b)=>n({...l,s:b})):n({...l,s:y})}return!c&&f&&d[I]===f?t.to(d):d};return n({s:e,isRoot:!0,treeLvl:0})};var ic,so=()=>(ic||(ic=[{from:r.Object({}),to:(e)=>r.ObjectString(e.properties||{},e),excludeRoot:!0},{from:r.Array(r.Any()),to:(e)=>r.ArrayString(e.items||r.Any(),e)}]),ic),sc,fc=()=>(sc||(sc=[{from:r.Object({}),to:(e)=>r.ObjectString(e.properties??{},e),excludeRoot:!0},{from:r.Array(r.Any()),to:(e)=>r.ArrayQuery(e.items??r.Any(),e)}]),sc),ac,Ti=()=>(ac||(ac=[{from:r.Number(),to:(e)=>r.Numeric(e),rootOnly:!0},{from:r.Boolean(),to:(e)=>r.BooleanString(e),rootOnly:!0}]),ac),cc,uc=()=>(cc||(cc=[{from:r.Object({}),to:(e)=>r.ObjectString(e.properties??{},e),onlyFirst:"object",excludeRoot:!0},{from:r.Array(r.Any()),to:(e)=>r.ArrayString(e.items??r.Any(),e),onlyFirst:"array",excludeRoot:!0}]),cc);var dc=(e)=>e?e?.[I]==="Import"&&e.References?e.References().some(dc):(e.schema&&(e=e.schema),!!e&&(tt in e)):!1,Pr=(e)=>{if(!e)return!1;let t=e?.schema??e;if(t[I]==="Import"&&e.References)return e.References().some(Pr);if(t.anyOf)return t.anyOf.some(Pr);if(t.someOf)return t.someOf.some(Pr);if(t.allOf)return t.allOf.some(Pr);if(t.not)return t.not.some(Pr);if(t.type==="object"){let n=t.properties;if("additionalProperties"in t)return t.additionalProperties;if("patternProperties"in t)return!1;for(let o of Object.keys(n)){let i=n[o];if(i.type==="object"){if(Pr(i))return!0}else if(i.anyOf){for(let s=0;s<i.anyOf.length;s++)if(Pr(i.anyOf[s]))return!0}return i.additionalProperties}return!1}return t.type==="array"&&t.items&&!Array.isArray(t.items)?Pr(t.items):!1},lc=(e,t,n)=>{if(e)return typeof e!="string"?e:n&&(e in n.$defs)?n.Import(e):t?.[e]},at=(e,t)=>{if(!t)return!1;if(I in t&&t[I]===e)return!0;if(I in t&&t[I]==="Import"&&t.$defs&&t.$ref){let n=t.$ref.replace("#/$defs/","");if(t.$defs[n])return at(e,t.$defs[n])}if(t.anyOf)return t.anyOf.some((n)=>at(e,n));if(t.oneOf)return t.oneOf.some((n)=>at(e,n));if(t.allOf)return t.allOf.some((n)=>at(e,n));if(t.type==="array"&&t.items)return e==="Files"&&I in t.items&&t.items[I]==="File"?!0:at(e,t.items);if(t.type==="object"){let n=t.properties;if(!n)return!1;for(let o of Object.keys(n))if(at(e,n[o]))return!0}return!1},xr=(e,t)=>{if(!t)return!1;let n=t?.schema??t;if(n.elysiaMeta===e)return!0;if(n[I]==="Import"&&t.References)return t.References().some((o)=>xr(e,o));if(n.anyOf)return n.anyOf.some((o)=>xr(e,o));if(n.someOf)return n.someOf.some((o)=>xr(e,o));if(n.allOf)return n.allOf.some((o)=>xr(e,o));if(n.not)return n.not.some((o)=>xr(e,o));if(n.type==="object"){let o=n.properties;if(!o)return!1;for(let i of Object.keys(o)){let s=o[i];if(s.type==="object"){if(xr(e,s))return!0}else if(s.anyOf){for(let c=0;c<s.anyOf.length;c++)if(xr(e,s.anyOf[c]))return!0}return n.elysiaMeta===e}return!1}return n.type==="array"&&n.items&&!Array.isArray(n.items)?xr(e,n.items):!1},En=(e,t)=>{if(!t)return!1;let n=t.schema??t;if(n[I]==="Import"&&t.References)return t.References().some((o)=>En(e,o));if(n.anyOf)return n.anyOf.some((o)=>En(e,o));if(n.allOf)return n.allOf.some((o)=>En(e,o));if(n.oneOf)return n.oneOf.some((o)=>En(e,o));if(n.type==="object"){let o=n.properties;if(!o)return!1;for(let i of Object.keys(o)){let s=o[i];if(e in s)return!0;if(s.type==="object"){if(En(e,s))return!0}else if(s.anyOf){for(let c=0;c<s.anyOf.length;c++)if(En(e,s.anyOf[c]))return!0}}return!1}return e in n},Ir=(e)=>{if(!e)return!1;if(e.oneOf){for(let t=0;t<e.oneOf.length;t++)if(Ir(e.oneOf[t]))return!0}if(e.anyOf){for(let t=0;t<e.anyOf.length;t++)if(Ir(e.anyOf[t]))return!0}if(e.oneOf){for(let t=0;t<e.oneOf.length;t++)if(Ir(e.oneOf[t]))return!0}if(e.allOf){for(let t=0;t<e.allOf.length;t++)if(Ir(e.allOf[t]))return!0}if(e.not&&Ir(e.not))return!0;if(e.type==="object"&&e.properties){let t=e.properties;for(let n of Object.keys(t)){let o=t[n];if(Ir(o)||o.type==="array"&&o.items&&Ir(o.items))return!0}}return e.type==="array"&&e.items&&Ir(e.items)?!0:e[I]==="Ref"&&("$ref"in e)},Or=(e)=>{if(!e)return!1;if(e.$ref&&e.$defs&&e.$ref in e.$defs&&Or(e.$defs[e.$ref]))return!0;if(e.oneOf){for(let t=0;t<e.oneOf.length;t++)if(Or(e.oneOf[t]))return!0}if(e.anyOf){for(let t=0;t<e.anyOf.length;t++)if(Or(e.anyOf[t]))return!0}if(e.allOf){for(let t=0;t<e.allOf.length;t++)if(Or(e.allOf[t]))return!0}if(e.not&&Or(e.not))return!0;if(e.type==="object"&&e.properties){let t=e.properties;for(let n of Object.keys(t)){let o=t[n];if(Or(o)||o.type==="array"&&o.items&&Or(o.items))return!0}}return e.type==="array"&&e.items&&Or(e.items)?!0:(we in e)},Wo=(e)=>(t)=>{if(typeof t=="object")try{return Pu(e,t)}catch{}return t},He=(e,{models:t={},dynamic:n=!1,modules:o,normalize:i=!1,additionalProperties:s=!1,forceAdditionalProperties:c=!1,coerce:f=!1,additionalCoerce:u=[],validators:l,sanitize:d}={})=>{if(l=l?.filter((j)=>j),!e){if(!l?.length)return;e=l[0],l=l.slice(1)}let y,b=(j)=>f?Ci(j,[{from:r.Number(),to:(k)=>r.Numeric(k),untilObjectFound:!0},{from:r.Boolean(),to:(k)=>r.BooleanString(k),untilObjectFound:!0},...Array.isArray(u)?u:[u]]):Ci(j,u),p=(j)=>{if(j&&typeof j!="string"&&"~standard"in j)return j;if(!j)return;let k;if(typeof j!="string")k=j;else if(k=o&&j in o.$defs?o.Import(j):t[j],!k)return;let q=Array.isArray(u)?u.length>0:!!u;if(I in k)if(k[I]==="Import")Ir(k.$defs[k.$ref])||(k=k.$defs[k.$ref]??t[k.$ref],(f||q)&&(k=b(k),("$id"in k)&&!k.$defs&&(k.$id=`${k.$id}_coerced_${Zr()}`)));else if(Ir(k)){let se=Zr();k=r.Module({...o?.$defs,[se]:k}).Import(se)}else(f||q)&&(k=b(k));return k},g=p(e),R=l;if("~standard"in g||l?.length&&l.some((j)=>j&&typeof j!="string"&&("~standard"in j))){let j=function(x,M=!1){let N=M?x:K.validate(x);if(N instanceof Promise)return N.then((G)=>j(G,!0));if(N.issues)return N;let V=[];return N&&typeof N=="object"&&V.push(N.value),k(x,0,V,N)},k=function(x,M,N,V){for(let G=M;G<U.length;G++){let Me=U[G].validate(x);if(Me instanceof Promise)return Me.then((z)=>{if(z.issues)return z;let co=[...N];return z&&typeof z=="object"&&co.push(z.value),k(x,G+1,co,z)});if(Me.issues)return Me;Me&&typeof Me=="object"&&N.push(Me.value),V=Me}return q(N,V)},q=function(x,M){if(!x.length)return{value:M};if(x.length===1)return{value:x[0]};if(x.length===2)return{value:et(x[0],x[1])};let N=et(x[0],x[1]);for(let V=2;V<x.length;V++)N=et(N,x[V]);return{value:N}};var L=j,J=k,H=q;let se=(x)=>{let M;if(i===!0||i==="exactMirror")try{M=Qs(x,{TypeCompiler:mr,sanitize:d?.(),modules:o})}catch{console.warn("Failed to create exactMirror. Please report the following code to https://github.com/elysiajs/elysia/issues"),console.warn(x),M=Wo(x)}let N=He(x,{models:t,modules:o,dynamic:n,normalize:i,additionalProperties:!0,forceAdditionalProperties:!0,coerce:f,additionalCoerce:u});return N.Decode=M,{validate:(V)=>N.Check(V)?{value:M?M(V):V}:{issues:[...N.Errors(V)]}}},K=g["~standard"]?g["~standard"]:se(g),U=[];if(l?.length){for(let x of l)if(x&&typeof x!="string"){if(x?.["~standard"]){U.push(x["~standard"]);continue}if(I in x){U.push(se(x));continue}}}let D={provider:"standard",schema:g,references:"",checkFunc:()=>{},code:"",Check:j,Errors:(x)=>j(x)?.then?.((M)=>M?.issues),Code:()=>"",Decode:j,Encode:(x)=>x,hasAdditionalProperties:!1,hasDefault:!1,isOptional:!1,hasTransform:!1,hasRef:!1};return D.parse=(x)=>{try{return D.Decode(D.Clean?.(x)??x)}catch{throw[...D.Errors(x)].map(nt)}},D.safeParse=(x)=>{try{return{success:!0,data:D.Decode(D.Clean?.(x)??x),error:null}}catch{let M=[..._.Errors(x)].map(nt);return{success:!1,data:null,error:M[0]?.summary,errors:M}}},D}else if(l?.length){let j=!1,k=R,{schema:q,notObjects:se}=tI([g,...k.map(p)]);se&&(g=r.Intersect([...q?[q]:[],...se.map((K)=>{let U=p(K);return U.type==="object"&&"additionalProperties"in U&&(!j&&U.additionalProperties===!1&&(j=!0),delete U.additionalProperties),U})]),g.type==="object"&&j&&(g.additionalProperties=!1))}else g.type==="object"&&(!("additionalProperties"in g)||c)?g.additionalProperties=s:g=Ci(g,{onlyFirst:"object",from:r.Object({}),to(j){return!j.properties||"additionalProperties"in j?j:r.Object(j.properties,{...j,additionalProperties:!1})}});if(n)if(I in g){let j={provider:"typebox",schema:g,references:"",checkFunc:()=>{},code:"",Check:(k)=>ke(g,k),Errors:(k)=>Et(g,k),Code:()=>"",Clean:Wo(g),Decode:(k)=>Ma(g,k),Encode:(k)=>ku(g,k),get hasAdditionalProperties(){return"~hasAdditionalProperties"in this?this["~hasAdditionalProperties"]:this["~hasAdditionalProperties"]=Pr(g)},get hasDefault(){return"~hasDefault"in this?this["~hasDefault"]:this["~hasDefault"]=En("default",g)},get isOptional(){return"~isOptional"in this?this["~isOptional"]:this["~isOptional"]=dc(g)},get hasTransform(){return"~hasTransform"in this?this["~hasTransform"]:this["~hasTransform"]=Or(g)},"~hasRef":y,get hasRef(){return"~hasRef"in this?this["~hasRef"]:this["~hasRef"]=Or(g)}};if(g.config&&(j.config=g.config,j?.schema?.config&&delete j.schema.config),i&&g.additionalProperties===!1)if(i===!0||i==="exactMirror")try{j.Clean=Qs(g,{TypeCompiler:mr,sanitize:d?.(),modules:o})}catch{console.warn("Failed to create exactMirror. Please report the following code to https://github.com/elysiajs/elysia/issues"),console.warn(g),j.Clean=Wo(g)}else j.Clean=Wo(g);return j.parse=(k)=>{try{return j.Decode(j.Clean?.(k)??k)}catch{throw[...j.Errors(k)].map(nt)}},j.safeParse=(k)=>{try{return{success:!0,data:j.Decode(j.Clean?.(k)??k),error:null}}catch{let q=[..._.Errors(k)].map(nt);return{success:!1,data:null,error:q[0]?.summary,errors:q}}},j}else{let j={provider:"standard",schema:g,references:"",checkFunc:()=>{},code:"",Check:(k)=>g["~standard"].validate(k),Errors(k){let q=g["~standard"].validate(k);if(q instanceof Promise)throw Error("Async validation is not supported in non-dynamic schema");return q.issues},Code:()=>"",Decode(k){let q=g["~standard"].validate(k);if(q instanceof Promise)throw Error("Async validation is not supported in non-dynamic schema");return q},Encode:(k)=>k,hasAdditionalProperties:!1,hasDefault:!1,isOptional:!1,hasTransform:!1,hasRef:!1};return j.parse=(k)=>{try{return j.Decode(j.Clean?.(k)??k)}catch{throw[...j.Errors(k)].map(nt)}},j.safeParse=(k)=>{try{return{success:!0,data:j.Decode(j.Clean?.(k)??k),error:null}}catch{let q=[..._.Errors(k)].map(nt);return{success:!1,data:null,error:q[0]?.summary,errors:q}}},j}let _;if(I in g)if(_=mr.Compile(g,Object.values(t).filter((j)=>(I in j))),_.provider="typebox",g.config&&(_.config=g.config,_?.schema?.config&&delete _.schema.config),i===!0||i==="exactMirror")try{_.Clean=Qs(g,{TypeCompiler:mr,sanitize:d?.(),modules:o})}catch{console.warn("Failed to create exactMirror. Please report the following code to https://github.com/elysiajs/elysia/issues"),console.dir(g,{depth:null}),_.Clean=Wo(g)}else i==="typebox"&&(_.Clean=Wo(g));else _={provider:"standard",schema:g,references:"",checkFunc(j){let k=g["~standard"].validate(j);if(k instanceof Promise)throw Error("Async validation is not supported in non-dynamic schema");return k},code:"",Check:(j)=>g["~standard"].validate(j),Errors(j){let k=g["~standard"].validate(j);if(k instanceof Promise)throw Error("Async validation is not supported in non-dynamic schema");return k.issues},Code:()=>"",Decode(j){let k=g["~standard"].validate(j);if(k instanceof Promise)throw Error("Async validation is not supported in non-dynamic schema");return k},Encode:(j)=>j,hasAdditionalProperties:!1,hasDefault:!1,isOptional:!1,hasTransform:!1,hasRef:!1};return _.parse=(j)=>{try{return _.Decode(_.Clean?.(j)??j)}catch{throw[..._.Errors(j)].map(nt)}},_.safeParse=(j)=>{try{return{success:!0,data:_.Decode(_.Clean?.(j)??j),error:null}}catch{let k=[..._.Errors(j)].map(nt);return{success:!1,data:null,error:k[0]?.summary,errors:k}}},I in g&&Object.assign(_,{get hasAdditionalProperties(){return"~hasAdditionalProperties"in this?this["~hasAdditionalProperties"]:this["~hasAdditionalProperties"]=Pr(_)},get hasDefault(){return"~hasDefault"in this?this["~hasDefault"]:this["~hasDefault"]=En("default",_)},get isOptional(){return"~isOptional"in this?this["~isOptional"]:this["~isOptional"]=dc(_)},get hasTransform(){return"~hasTransform"in this?this["~hasTransform"]:this["~hasTransform"]=Or(g)},get hasRef(){return"~hasRef"in this?this["~hasRef"]:this["~hasRef"]=Ir(g)},"~hasRef":y}),_},wd=(e)=>e[I]==="Union"||!e.schema&&!!e.anyOf,jr=(e)=>{if(!e)return;if(e.properties)return e.properties;let t=e.allOf??e.anyOf??e.oneOf;if(t){let n={};for(let o of t){let i=jr(o);i&&Object.assign(n,i)}return Object.keys(n).length>0?n:void 0}},tI=(e)=>{if(e.length===0)return{schema:void 0,notObjects:[]};if(e.length===1)return e[0].type==="object"?{schema:e[0],notObjects:[]}:{schema:void 0,notObjects:e};let t,n=[],o=!1,i=!1;for(let s of e){if(s.type!=="object"){n.push(s);continue}if("additionalProperties"in s&&(s.additionalProperties===!0?o=!0:s.additionalProperties===!1&&(i=!0)),!t){t=s;continue}t={...t,...s,properties:{...t.properties,...s.properties},required:[...t?.required??[],...s.required??[]]}}return t&&(t.required&&(t.required=[...new Set(t.required)]),i?t.additionalProperties=!1:o&&(t.additionalProperties=!0)),{schema:t,notObjects:n}},Ys=(e,{models:t={},modules:n,dynamic:o=!1,normalize:i=!1,additionalProperties:s=!1,validators:c=[],sanitize:f})=>{if(c=c.filter((d)=>d),!e){if(!c?.length)return;e=c[0],c=c.slice(1)}let u;if(typeof e!="string")u=e;else if(u=n&&e in n.$defs?n.Import(e):t[e],!u)return;if(!u)return;if(I in u||"~standard"in u)return{200:He(u,{modules:n,models:t,additionalProperties:s,dynamic:o,normalize:i,coerce:!1,additionalCoerce:[],validators:c.map((d)=>d[200]),sanitize:f})};let l={};return Object.keys(u).forEach((d)=>{if(isNaN(+d))return;let y=u[+d];if(typeof y=="string"){if(y in t){let b=t[y];if(!b)return;l[+d]=I in b||"~standard"in b?He(b,{modules:n,models:t,additionalProperties:s,dynamic:o,normalize:i,coerce:!1,additionalCoerce:[],validators:c.map((p)=>p[+d]),sanitize:f}):b}return}l[+d]=I in y||"~standard"in y?He(y,{modules:n,models:t,additionalProperties:s,dynamic:o,normalize:i,coerce:!1,additionalCoerce:[],validators:c.map((b)=>b[+d]),sanitize:f}):y}),l},Ad=({validator:e,modules:t,defaultConfig:n={},config:o,dynamic:i,normalize:s=!1,models:c,validators:f,sanitize:u})=>{let l=e?.provider?e:He(e,{modules:t,dynamic:i,models:c,normalize:s,additionalProperties:!0,coerce:!0,additionalCoerce:so(),validators:f,sanitize:u});return l?l.config=Oi(l.config,o):(l=He(r.Cookie(r.Any()),{modules:t,dynamic:i,models:c,additionalProperties:!0,validators:f,sanitize:u}),l.config=n),l},ao=(e)=>e&&e[I]==="Import"&&e.$defs[e.$ref][I]==="Object"?e.$defs[e.$ref]:e;var Ve=(e,t)=>t?e:"",rI=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],ki=({context:e="c",trace:t=[],addFn:n})=>{if(!t.length)return()=>({resolveChild(){return()=>{}},resolve(){}});for(let o=0;o<t.length;o++)n(`let report${o},reportChild${o},reportErr${o},reportErrChild${o};let trace${o}=${e}[ELYSIA_TRACE]?.[${o}]??trace[${o}](${e});
85
+ `);return(o,{name:i,total:s=0,alias:c}={})=>{i||(i="anonymous");let f=o==="error"?"reportErr":"report";for(let u=0;u<t.length;u++)n(`${c?"const ":""}${c??f}${u}=trace${u}.${o}({id,event:'${o}',name:'${i}',begin:performance.now(),total:${s}})
86
+ `),c&&n(`${f}${u}=${c}${u}
87
+ `);return{resolve(){for(let u=0;u<t.length;u++)n(`${c??f}${u}.resolve()
88
+ `)},resolveChild(u){for(let l=0;l<t.length;l++)n(`${f}Child${l}=${f}${l}.resolveChild?.shift()?.({id,event:'${o}',name:'${u}',begin:performance.now()})
89
+ `);return(l)=>{for(let d=0;d<t.length;d++)n(l?`if(${l} instanceof Error){${f}Child${d}?.(${l}) }else{${f}Child${d}?.()}`:`${f}Child${d}?.()
90
+ `)}}}}},Pi=({schema:e,name:t,type:n,typeAlias:o=n,normalize:i,ignoreTryCatch:s=!1})=>!i||!e.Clean?"":i===!0||i==="exactMirror"?s?`${t}=validator.${o}.Clean(${t})
91
+ `:`try{${t}=validator.${o}.Clean(${t})
92
+ }catch{}`:i==="typebox"?`${t}=validator.${o}.Clean(${t})
93
+ `:"",nI=({injectResponse:e="",normalize:t=!1,validator:n,encodeSchema:o=!1,isStaticResponse:i=!1,hasSanitize:s=!1,allowUnsafeValidationDetails:c=!1})=>({validate:(f,u=`c.${f}`,l)=>`c.set.status=422;throw new ValidationError('${f}',validator.${f},${u},${c}${l?","+l:""})`,response:(f="r")=>{if(i||!n.response)return"";let u=e+`
94
+ `;u+=`if(${f} instanceof ElysiaCustomStatusResponse){c.set.status=${f}.code
95
+ ${f}=${f}.response}if(${f} instanceof Response === false && typeof ${f}?.next !== 'function' && !(${f} instanceof ReadableStream))switch(c.set.status){`;for(let[l,d]of Object.entries(n.response)){if(u+=`
96
+ case ${l}:
97
+ `,d.provider==="standard"){u+=`let vare${l}=validator.response[${l}].Check(${f})
98
+ if(vare${l} instanceof Promise)vare${l}=await vare${l}
99
+ if(vare${l}.issues)throw new ValidationError('response',validator.response[${l}],${f},${c},vare${l}.issues)
100
+ ${f}=vare${l}.value
101
+ c.set.status=${l}
102
+ break
103
+ `;continue}let y=d.schema?.noValidate===!0;if(!y&&d.schema?.$ref&&d.schema?.$defs){let R=d.schema.$ref,L=typeof R=="string"&&R.includes("/")?R.split("/").pop():R;d.schema.$defs[L]?.noValidate===!0&&(y=!0)}let b=y||s,p=({ignoreTryCatch:R=!1}={})=>Pi({name:f,schema:d,type:"response",typeAlias:`response[${l}]`,normalize:t,ignoreTryCatch:R});b&&(u+=p());let g=!b&&t&&!y;o&&d.hasTransform&&!y?(u+=`try{${f}=validator.response[${l}].Encode(${f})
104
+ `,b||(u+=p({ignoreTryCatch:!0})),u+=`c.set.status=${l}}catch{`+(g?`try{
105
+ `+p({ignoreTryCatch:!0})+`${f}=validator.response[${l}].Encode(${f})
106
+ }catch{throw new ValidationError('response',validator.response[${l}],${f},${c})}`:`throw new ValidationError('response',validator.response[${l}],${f},${c})`)+"}"):(b||(u+=p()),y||(u+=`if(validator.response[${l}].Check(${f})===false)throw new ValidationError('response',validator.response[${l}],${f},${c})
107
+ c.set.status=${l}
108
+ `)),u+=`break
109
+ `}return u+"}"}}),Cn=(e)=>(e?.fn??e).constructor.name==="AsyncFunction",oI=/=>\s?response\.clone\(/,iI=/(?:return|=>)\s?\S+\(|a(?:sync|wait)/,_e=(e)=>{let t=typeof e=="object";if(t&&e.isAsync!==void 0)return e.isAsync;let n=t?e.fn:e;if(n.constructor.name==="AsyncFunction"||n.constructor.name==="AsyncGeneratorFunction")return!0;let o=n.toString();if(oI.test(o))return t&&(e.isAsync=!1),!1;let i=iI.test(o);return t&&(e.isAsync=i),i},ji=(e)=>{let t=typeof e=="object";if(t&&e.hasReturn!==void 0)return e.hasReturn;let n=t?e.fn.toString():e.toString(),o=n.indexOf(")"),i=n.indexOf("=>",o);if(i!==-1){let c=i+2,f;for(;c<n.length&&((f=n.charCodeAt(c))===32||f===9||f===10||f===13);)c++;if(c<n.length&&n.charCodeAt(c)!==123)return t&&(e.hasReturn=!0),!0}let s=n.includes("return");return t&&(e.hasReturn=s),s},Zs=(e)=>{let t=e?.fn??e;return t.constructor.name==="AsyncGeneratorFunction"||t.constructor.name==="GeneratorFunction"},Qo=(e,t,n=!1,o=`c.${t}`)=>`try{${e}}catch(error){if(error.constructor.name === 'TransformDecodeError'){c.set.status=422
110
+ throw error.error ?? new ValidationError('${t}',validator.${t},${o},${n})}}`,Xs=Fs?"setImmediate":"Promise.resolve().then",Fd=({app:e,path:t,method:n,hooks:o,validator:i,handler:s,allowMeta:c=!1,inference:f})=>{let u=e["~adapter"].composeHandler,l=e["~adapter"].handler,d=typeof s=="function";if(!d){s=l.mapResponse(s,{headers:e.setHeaders??{}});let w=s instanceof Response||s?.constructor?.name==="Response"&&typeof s?.clone=="function";if(o.parse?.length&&o.transform?.length&&o.beforeHandle?.length&&o.afterHandle?.length)return w?Function("a",`"use strict";
111
+ return function(){return a.clone()}`)(s):Function("a",`"use strict";
112
+ return function(){return a}`)(s);if(w){let m=s;s=()=>m.clone()}}let y=d?"handler(c)":"handler",b=!!o.trace?.length,p="";if(f=ro(Object.assign({handler:s},o),f,e.config.sucrose),u.declare){let w=u.declare(f);w&&(p+=w)}f.server&&(p+=`Object.defineProperty(c,'server',{get:function(){return getServer()}})
113
+ `),i.createBody?.(),i.createQuery?.(),i.createHeaders?.(),i.createParams?.(),i.createCookie?.(),i.createResponse?.();let g=!!i.body||!!i.headers||!!i.params||!!i.query||!!i.cookie||!!i.response,R=f.query||!!i.query,L=o.parse?.length===1&&o.parse[0].fn==="none",J=n!==""&&n!=="GET"&&n!=="HEAD"&&(f.body||!!i.body||!!o.parse?.length)&&!L,H=e.setHeaders,_=H&&!!Object.keys(H).length,j=f.headers||!!i.headers||u.preferWebstandardHeaders!==!0&&f.body,k=f.cookie||!!i.cookie,q=i.cookie?.config?Oi(i?.cookie?.config,e.config.cookie):e.config.cookie,se="",K=()=>{if(se)return se;if(q?.sign){if(q.secrets==="")throw Error(`cookie secret can't be an empty string at (${n}) ${t}`,{cause:`(${n}) ${t}`});if(!q.secrets)throw Error(`cookie secret must be defined (${n}) ${t}`,{cause:`(${n}) ${t}`});let w=q.secrets?typeof q.secrets=="string"?q.secrets:q.secrets[0]:void 0;if(se+=`const _setCookie = c.set.cookie
114
+ if(_setCookie){`,q.sign===!0)se+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,${w?JSON.stringify(w):"undefined"})}`;else{typeof q.sign=="string"&&(q.sign=[q.sign]);for(let m of q.sign)se+=`if(_setCookie[${JSON.stringify(m)}]?.value)c.set.cookie[${JSON.stringify(m)}].value=await signCookie(_setCookie[${JSON.stringify(m)}].value,${w?JSON.stringify(w):"undefined"})
115
+ `}se+=`}
116
+ `}return se},U=e.config.normalize,D=e.config.encodeSchema,x=e.config.allowUnsafeValidationDetails,M=nI({normalize:U,validator:i,encodeSchema:D,isStaticResponse:s instanceof Response,hasSanitize:!!e.config.sanitize,allowUnsafeValidationDetails:x});j&&(p+=u.headers),b&&(p+=`const id=c[ELYSIA_REQUEST_ID]
117
+ `);let N=ki({trace:o.trace,addFn:(w)=>{p+=w}});if(p+="try{",k){let w=(O,A)=>{let C=q?.[O]??A;return C===void 0?"":C?typeof C=="string"?`${O}:${JSON.stringify(C)},`:C instanceof Date?`${O}: new Date(${C.getTime()}),`:`${O}:${C},`:typeof A=="string"?`${O}:"${A}",`:`${O}:${A},`},m=q?`{secrets:${q.secrets!==void 0&&q.secrets!==null?typeof q.secrets=="string"?JSON.stringify(q.secrets):"["+q.secrets.map((O)=>JSON.stringify(O)).join(",")+"]":"undefined"},sign:${q.sign===!0?!0:q.sign!==void 0?typeof q.sign=="string"?JSON.stringify(q.sign):"["+q.sign.map((O)=>JSON.stringify(O)).join(",")+"]":"undefined"},`+w("domain")+w("expires")+w("httpOnly")+w("maxAge")+w("path","/")+w("priority")+w("sameSite")+w("secure")+"}":"undefined";j?p+=`
118
+ c.cookie=await parseCookie(c.set,c.headers.cookie,${m})
119
+ `:p+=`
120
+ c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${m})
121
+ `}if(R){let w={},m={},O=!1,A=!1;if(i.query?.schema){let C=ao(i.query?.schema),v=jr(C);if(v)for(let[X,me]of Object.entries(v))xr("ArrayQuery",me)&&(w[X]=!0,O=!0),xr("ObjectString",me)&&(m[X]=!0,A=!0)}p+=`if(c.qi===-1){c.query=Object.create(null)}else{c.query=parseQueryFromURL(c.url,c.qi+1${O?","+JSON.stringify(w):A?",undefined":""}${A?","+JSON.stringify(m):""})}`}let V=typeof s=="function"&&_e(s),G=b||o.afterResponse?.length?"c.response=c.responseValue= ":"",Me=Object.keys(i.response??{}),z=Me.length>1,co=Me.length===0||Me.length===1&&Me[0]==="200",on=k||J||V||!!o.parse?.length||!!o.afterHandle?.some(_e)||!!o.beforeHandle?.some(_e)||!!o.transform?.some(_e)||!!o.mapResponse?.some(_e)||i.body?.provider==="standard"||i.headers?.provider==="standard"||i.query?.provider==="standard"||i.params?.provider==="standard"||i.cookie?.provider==="standard"||Object.values(i.response??{}).find((w)=>w.provider==="standard"),kr=(typeof s=="function"?Zs(s):!1)||!!o.beforeHandle?.some(Zs)||!!o.afterHandle?.some(Zs)||!!o.transform?.some(Zs),Je=f.cookie||f.set||j||b||z||!co||d&&_||kr,gt,Rr=(w=!0)=>{if(gt!==void 0)return gt;if(!o.afterResponse?.length&&!b)return"";let m="";m+=`
122
+ ${Xs}(async()=>{if(c.responseValue){if(c.responseValue instanceof ElysiaCustomStatusResponse) c.set.status=c.responseValue.code
123
+ `+(w?`if(typeof afterHandlerStreamListener!=='undefined')for await(const v of afterHandlerStreamListener){}
124
+ `:"")+`}
125
+ `;let O=ki({trace:o.trace,addFn:(A)=>{m+=A}})("afterResponse",{total:o.afterResponse?.length});if(o.afterResponse?.length&&o.afterResponse)for(let A=0;A<o.afterResponse.length;A++){let C=O.resolveChild(o.afterResponse[A].fn.name),v=_e(o.afterResponse[A])?"await ":"";m+=`
126
+ ${v}e.afterResponse[${A}](c)
127
+ `,C()}return O.resolve(),m+=`})
128
+ `,gt=m},lt=(w="r")=>{let m=Rr(),O=`${kr&&on?"await ":""}${Je?"mapResponse":"mapCompactResponse"}(${G}${w}${Je?",c.set":""}${sn})
129
+ `;return m?`const _res=${O}`+m+"return _res":`return ${O}`},sn=u.mapResponseContext?`,${u.mapResponseContext}`:"";(b||f.route)&&(p+=`c.route=\`${t}\`
130
+ `),(b||o.afterResponse?.length)&&(p+=`let afterHandlerStreamListener
131
+ `);let fo=N("parse",{total:o.parse?.length});if(J){let w=!!o.parse?.length||f.body||i.body;u.parser.declare&&(p+=u.parser.declare),p+=`
132
+ try{`;let m=typeof o.parse=="string"?o.parse:Array.isArray(o.parse)&&o.parse.length===1?typeof o.parse[0]=="string"?o.parse[0]:typeof o.parse[0].fn=="string"?o.parse[0].fn:void 0:void 0;if(!m&&i.body&&!o.parse?.length){let O=i.body.schema;O&&O.anyOf&&O[I]==="Union"&&O.anyOf?.length===2&&O.anyOf?.find((A)=>A[I]==="ElysiaForm")&&(m="formdata")}if(m&&rI.includes(m)){let O=N("parse",{total:o.parse?.length}),A=!!i.body?.isOptional;switch(m){case"json":case"application/json":p+=u.parser.json(A);break;case"text":case"text/plain":p+=u.parser.text(A);break;case"urlencoded":case"application/x-www-form-urlencoded":p+=u.parser.urlencoded(A);break;case"arrayBuffer":case"application/octet-stream":p+=u.parser.arrayBuffer(A);break;case"formdata":case"multipart/form-data":p+=u.parser.formData(A);break;default:m in e["~parser"]&&(p+=j?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",p+=`
133
+ if(contentType){const index=contentType.indexOf(';')
134
+ if(index!==-1)contentType=contentType.substring(0,index)}
135
+ else{contentType=''}c.contentType=contentType
136
+ let result=parser['${m}'](c, contentType)
137
+ if(result instanceof Promise)result=await result
138
+ if(result instanceof ElysiaCustomStatusResponse)throw result
139
+ if(result!==undefined)c.body=result
140
+ delete c.contentType
141
+ `);break}O.resolve()}else if(w){p+=`
142
+ `,p+=`let contentType
143
+ if(c.request.body)`,p+=j?`contentType=c.headers['content-type']
144
+ `:`contentType=c.request.headers.get('content-type')
145
+ `;let O=!1;if(o.parse?.length)p+=`if(contentType){
146
+ const index=contentType.indexOf(';')
147
+
148
+ if(index!==-1)contentType=contentType.substring(0,index)}else{contentType=''}let used=false
149
+ c.contentType=contentType
150
+ `;else{O=!0;let C=!!i.body?.isOptional;p+=`if(contentType)switch(contentType.charCodeAt(12)){
151
+ case 106:`+u.parser.json(C)+`break
152
+ case 120:`+u.parser.urlencoded(C)+`break
153
+ case 111:`+u.parser.arrayBuffer(C)+`break
154
+ case 114:`+u.parser.formData(C)+`break
155
+ default:if(contentType.charCodeAt(0)===116){`+u.parser.text(C)+`}break
156
+ }`}let A=N("parse",{total:o.parse?.length});if(o.parse)for(let C=0;C<o.parse.length;C++){let v=`bo${C}`;if(C!==0&&(p+=`
157
+ if(!used){`),typeof o.parse[C].fn=="string"){let X=A.resolveChild(o.parse[C].fn),me=!!i.body?.isOptional;switch(o.parse[C].fn){case"json":case"application/json":O=!0,p+=u.parser.json(me);break;case"text":case"text/plain":O=!0,p+=u.parser.text(me);break;case"urlencoded":case"application/x-www-form-urlencoded":O=!0,p+=u.parser.urlencoded(me);break;case"arrayBuffer":case"application/octet-stream":O=!0,p+=u.parser.arrayBuffer(me);break;case"formdata":case"multipart/form-data":O=!0,p+=u.parser.formData(me);break;default:p+=`let ${v}=parser['${o.parse[C].fn}'](c,contentType)
158
+ if(${v} instanceof Promise)${v}=await ${v}
159
+ if(${v}!==undefined){c.body=${v};used=true;}
160
+ `}X()}else{let X=A.resolveChild(o.parse[C].fn.name);p+=`let ${v}=e.parse[${C}]
161
+ ${v}=${v}(c,contentType)
162
+ if(${v} instanceof Promise)${v}=await ${v}
163
+ if(${v}!==undefined){c.body=${v};used=true}`,X()}if(C!==0&&(p+="}"),O)break}if(A.resolve(),!O){let C=!!i.body?.isOptional;o.parse?.length&&(p+=`
164
+ if(!used){
165
+ `),p+=`switch(contentType){case 'application/json':
166
+ `+u.parser.json(C)+`break
167
+ case 'text/plain':`+u.parser.text(C)+`break
168
+ case 'application/x-www-form-urlencoded':`+u.parser.urlencoded(C)+`break
169
+ case 'application/octet-stream':`+u.parser.arrayBuffer(C)+`break
170
+ case 'multipart/form-data':`+u.parser.formData(C)+`break
171
+ `;for(let v of Object.keys(e["~parser"]))p+=`case '${v}':let bo${v}=parser['${v}'](c,contentType)
172
+ if(bo${v} instanceof Promise)bo${v}=await bo${v}
173
+ if(bo${v} instanceof ElysiaCustomStatusResponse){`+lt(`bo${v}`)+`}if(bo${v}!==undefined)c.body=bo${v}
174
+ break
175
+ `;o.parse?.length&&(p+="}"),p+="}"}o.parse?.length&&(p+=`
176
+ delete c.contentType`)}p+="}catch(error){throw new ParseError(error)}"}if(fo.resolve(),o?.transform||b){let w=N("transform",{total:o.transform?.length});if(o.transform?.length){p+=`let transformed
177
+ `;for(let m=0;m<o.transform.length;m++){let O=o.transform[m],A=w.resolveChild(O.fn.name);p+=_e(O)?`transformed=await e.transform[${m}](c)
178
+ `:`transformed=e.transform[${m}](c)
179
+ `,O.subType==="mapDerive"?p+="if(transformed instanceof ElysiaCustomStatusResponse){"+lt("transformed")+`}else{transformed.request=c.request
180
+ transformed.store=c.store
181
+ transformed.qi=c.qi
182
+ transformed.path=c.path
183
+ transformed.url=c.url
184
+ transformed.redirect=c.redirect
185
+ transformed.set=c.set
186
+ transformed.error=c.error
187
+ c=transformed}`:p+="if(transformed instanceof ElysiaCustomStatusResponse){"+lt("transformed")+`}else Object.assign(c,transformed)
188
+ `,A()}}w.resolve()}let Nr=[];if(i){if(i.headers){if(i.headers.hasDefault)for(let[w,m]of Object.entries(Ii(i.headers.schema,{}))){let O=typeof m=="object"?JSON.stringify(m):typeof m=="string"?`'${m}'`:m;O!==void 0&&(p+=`c.headers['${w}']??=${O}
189
+ `)}p+=Pi({name:"c.headers",schema:i.headers,type:"headers",normalize:U}),i.headers.isOptional&&(p+="if(isNotEmpty(c.headers)){"),i.headers?.provider==="standard"?p+=`let vah=validator.headers.Check(c.headers)
190
+ if(vah instanceof Promise)vah=await vah
191
+ if(vah.issues){`+M.validate("headers",void 0,"vah.issues")+`}else{c.headers=vah.value}
192
+ `:i.headers?.schema?.noValidate!==!0&&(p+="if(validator.headers.Check(c.headers) === false){"+M.validate("headers")+"}"),i.headers.hasTransform&&(p+=Qo(`c.headers=validator.headers.Decode(c.headers)
193
+ `,"headers",x)),i.headers.isOptional&&(p+="}")}if(i.params){if(i.params.hasDefault)for(let[w,m]of Object.entries(Ii(i.params.schema,{}))){let O=typeof m=="object"?JSON.stringify(m):typeof m=="string"?`'${m}'`:m;O!==void 0&&(p+=`c.params['${w}']??=${O}
194
+ `)}i.params.provider==="standard"?p+=`let vap=validator.params.Check(c.params)
195
+ if(vap instanceof Promise)vap=await vap
196
+ if(vap.issues){`+M.validate("params",void 0,"vap.issues")+`}else{c.params=vap.value}
197
+ `:i.params?.schema?.noValidate!==!0&&(p+="if(validator.params.Check(c.params)===false){"+M.validate("params")+"}"),i.params.hasTransform&&(p+=Qo(`c.params=validator.params.Decode(c.params)
198
+ `,"params",x))}if(i.query){if(I in i.query?.schema&&i.query.hasDefault)for(let[w,m]of Object.entries(Ii(i.query.schema,{}))){let O=typeof m=="object"?JSON.stringify(m):typeof m=="string"?`'${m}'`:m;O!==void 0&&(p+=`if(c.query['${w}']===undefined)c.query['${w}']=${O}
199
+ `)}p+=Pi({name:"c.query",schema:i.query,type:"query",normalize:U}),i.query.isOptional&&(p+="if(isNotEmpty(c.query)){"),i.query.provider==="standard"?p+=`let vaq=validator.query.Check(c.query)
200
+ if(vaq instanceof Promise)vaq=await vaq
201
+ if(vaq.issues){`+M.validate("query",void 0,"vaq.issues")+`}else{c.query=vaq.value}
202
+ `:i.query?.schema?.noValidate!==!0&&(p+="if(validator.query.Check(c.query)===false){"+M.validate("query")+"}"),i.query.hasTransform&&(p+=Qo(`c.query=validator.query.Decode(c.query)
203
+ `,"query",x),p+=Qo(`c.query=validator.query.Decode(c.query)
204
+ `,"query",x)),i.query.isOptional&&(p+="}")}if(J&&i.body){(i.body.hasTransform||i.body.isOptional)&&(p+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&(isNotEmpty(c.body)||c.body instanceof ArrayBuffer))
205
+ `);let w=wd(i.body.schema),m=!1;if(i.body.hasDefault){let O=Ii(i.body.schema,i.body.schema.type==="object"||ao(i.body.schema)[I]==="Object"?{}:void 0),A=ao(i.body.schema);if(!w&&O&&typeof O=="object"&&(at("File",A)||at("Files",A))){m=!0;for(let[v,X]of Object.entries(O))(X==="File"||X==="Files")&&delete O[v];ue(O)||(O=void 0)}let C=typeof O=="object"?JSON.stringify(O):typeof O=="string"?`'${O}'`:O;O!=null&&(Array.isArray(O)?p+=`if(!c.body)c.body=${C}
206
+ `:typeof O=="object"?p+=`c.body=Object.assign(${C},c.body)
207
+ `:p+=`c.body=${C}
208
+ `),p+=Pi({name:"c.body",schema:i.body,type:"body",normalize:U}),i.body.provider==="standard"?p+=`let vab=validator.body.Check(c.body)
209
+ if(vab instanceof Promise)vab=await vab
210
+ if(vab.issues){`+M.validate("body",void 0,"vab.issues")+`}else{c.body=vab.value}
211
+ `:i.body?.schema?.noValidate!==!0&&(i.body.isOptional?p+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+M.validate("body")+"}":p+="if(validator.body.Check(c.body)===false){"+M.validate("body")+"}")}else p+=Pi({name:"c.body",schema:i.body,type:"body",normalize:U}),i.body.provider==="standard"?p+=`let vab=validator.body.Check(c.body)
212
+ if(vab instanceof Promise)vab=await vab
213
+ if(vab.issues){`+M.validate("body",void 0,"vab.issues")+`}else{c.body=vab.value}
214
+ `:i.body?.schema?.noValidate!==!0&&(i.body.isOptional?p+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+M.validate("body")+"}":p+="if(validator.body.Check(c.body)===false){"+M.validate("body")+"}");if(i.body.hasTransform&&(p+=Qo(`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)
215
+ `,"body",x)),w&&i.body.schema.anyOf?.length){let O=Object.values(i.body.schema.anyOf);for(let A=0;A<O.length;A++){let C=O[A];if(at("File",C)||at("Files",C)){let v=He(C,{modules:e.definitions.typebox,dynamic:!e.config.aot,models:e.definitions.type,normalize:e.config.normalize,additionalCoerce:Ti(),sanitize:()=>e.config.sanitize});if(v){let X=Nr.length===0,me=jr(v.schema)??jr(C);if(!me)continue;let Se=Object.entries(me),Ke=X?`
216
+ `:" else ";Ke+=`if(fileUnions[${Nr.length}].Check(c.body)){`;let Ht="",an=0;for(let Zo=0;Zo<Se.length;Zo++){let[Rc,Mi]=Se[Zo];!Mi.extension||Mi[I]!=="File"&&Mi[I]!=="Files"||(an&&(Ht+=","),Ht+=`fileType(c.body.${Rc},${JSON.stringify(Mi.extension)},'body.${Rc}')`,an++)}Ht&&(an===1?Ke+=`await ${Ht}
217
+ `:an>1&&(Ke+=`await Promise.all([${Ht}])
218
+ `),Ke+="}",p+=Ke,Nr.push(v))}}}}else if(m||!w&&(at("File",ao(i.body.schema))||at("Files",ao(i.body.schema)))){let O="",A=jr(ao(i.body.schema)),C=0;if(A)for(let[v,X]of Object.entries(A))!X.extension||X[I]!=="File"&&X[I]!=="Files"||(C&&(O+=","),O+=`fileType(c.body.${v},${JSON.stringify(X.extension)},'body.${v}')`,C++);C&&(p+=`
219
+ `),C===1?p+=`await ${O}
220
+ `:C>1&&(p+=`await Promise.all([${O}])
221
+ `)}}i.cookie&&(i.cookie.config=Oi(i.cookie.config,e.config.cookie??{}),p+=`let cookieValue={}
222
+ for(const [key,value] of Object.entries(c.cookie))cookieValue[key]=value.value
223
+ `,i.cookie.isOptional&&(p+="if(isNotEmpty(c.cookie)){"),i.cookie.provider==="standard"?(p+=`let vac=validator.cookie.Check(cookieValue)
224
+ if(vac instanceof Promise)vac=await vac
225
+ if(vac.issues){`+M.validate("cookie",void 0,"vac.issues")+`}else{cookieValue=vac.value}
226
+ `,p+=`for(const k of Object.keys(cookieValue))c.cookie[k].value=cookieValue[k]
227
+ `):i.cookie?.schema?.noValidate!==!0&&(p+="if(validator.cookie.Check(cookieValue)===false){"+M.validate("cookie","cookieValue")+"}",i.cookie.hasTransform&&(p+=Qo("for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue))){c.cookie[key].value = value}","cookie",x))),i.cookie.isOptional&&(p+="}"))}if(o?.beforeHandle||b){let w=N("beforeHandle",{total:o.beforeHandle?.length}),m=!1;if(o.beforeHandle?.length)for(let O=0;O<o.beforeHandle.length;O++){let A=o.beforeHandle[O],C=w.resolveChild(A.fn.name),v=ji(A);if(A.subType==="resolve"||A.subType==="mapResolve")m||(m=!0,p+=`
228
+ let resolved
229
+ `),p+=_e(A)?`resolved=await e.beforeHandle[${O}](c);
230
+ `:`resolved=e.beforeHandle[${O}](c);
231
+ `,A.subType==="mapResolve"?p+="if(resolved instanceof ElysiaCustomStatusResponse){"+lt("resolved")+`}else{resolved.request=c.request
232
+ resolved.store=c.store
233
+ resolved.qi=c.qi
234
+ resolved.path=c.path
235
+ resolved.url=c.url
236
+ resolved.redirect=c.redirect
237
+ resolved.set=c.set
238
+ resolved.error=c.error
239
+ c=resolved}`:p+="if(resolved instanceof ElysiaCustomStatusResponse){"+lt("resolved")+`}else Object.assign(c, resolved)
240
+ `,C();else if(!v)p+=_e(A)?`await e.beforeHandle[${O}](c)
241
+ `:`e.beforeHandle[${O}](c)
242
+ `,C();else{if(p+=_e(A)?`be=await e.beforeHandle[${O}](c)
243
+ `:`be=e.beforeHandle[${O}](c)
244
+ `,C("be"),p+="if(be!==undefined){",w.resolve(),o.afterHandle?.length||b){N("handle",{name:d?s.name:void 0}).resolve();let me=N("afterHandle",{total:o.afterHandle?.length});if(o.afterHandle?.length)for(let Se=0;Se<o.afterHandle.length;Se++){let Ke=o.afterHandle[Se],Ht=ji(Ke),an=me.resolveChild(Ke.fn.name);p+=`c.response=c.responseValue=be
245
+ `,Ht?(p+=_e(Ke.fn)?`af=await e.afterHandle[${Se}](c)
246
+ `:`af=e.afterHandle[${Se}](c)
247
+ `,p+=`if(af!==undefined) c.response=c.responseValue=be=af
248
+ `):p+=_e(Ke.fn)?`await e.afterHandle[${Se}](c, be)
249
+ `:`e.afterHandle[${Se}](c, be)
250
+ `,an("af")}me.resolve()}i.response&&(p+=M.response("be"));let X=N("mapResponse",{total:o.mapResponse?.length});if(o.mapResponse?.length){p+=`c.response=c.responseValue=be
251
+ `;for(let me=0;me<o.mapResponse.length;me++){let Se=o.mapResponse[me],Ke=X.resolveChild(Se.fn.name);p+=`if(mr===undefined){mr=${Cn(Se)?"await ":""}e.mapResponse[${me}](c)
252
+ if(mr!==undefined)be=c.response=c.responseValue=mr}`,Ke()}}X.resolve(),p+=Rr(),p+=K(),p+=`return mapEarlyResponse(${G}be,c.set${sn})}
253
+ `}}w.resolve()}function Ui(w){let m=N("handle",{name:w,alias:"reportHandler"});return()=>{b&&(p+='if(r&&(r[Symbol.iterator]||r[Symbol.asyncIterator])&&typeof r.next==="function"){'+(on?"":"(async()=>{")+`const stream=await tee(r,3)
254
+ r=stream[0]
255
+ `+(o.afterHandle?.length?`c.response=c.responseValue=r
256
+ `:"")+`const listener=stream[1]
257
+ `+(b||o.afterResponse?.length?`afterHandlerStreamListener=stream[2]
258
+ `:"")+`${Xs}(async ()=>{if(listener)for await(const v of listener){}
259
+ `,m.resolve(),p+="})"+(on?"":"})()")+"}else{",m.resolve(),p+=`}
260
+ `)}}if(o.afterHandle?.length||b){let w=Ui(d?s.name:void 0);o.afterHandle?.length?p+=V?`let r=c.response=c.responseValue=await ${y}
261
+ `:`let r=c.response=c.responseValue=${y}
262
+ `:p+=V?`let r=await ${y}
263
+ `:`let r=${y}
264
+ `,w();let m=N("afterHandle",{total:o.afterHandle?.length});if(o.afterHandle?.length)for(let A=0;A<o.afterHandle.length;A++){let C=o.afterHandle[A],v=ji(C),X=m.resolveChild(C.fn.name);v?(p+=_e(C.fn)?`af=await e.afterHandle[${A}](c)
265
+ `:`af=e.afterHandle[${A}](c)
266
+ `,X("af"),i.response?(p+="if(af!==undefined){",m.resolve(),p+=M.response("af"),p+="c.response=c.responseValue=af}"):(p+="if(af!==undefined){",m.resolve(),p+="c.response=c.responseValue=af}")):(p+=_e(C.fn)?`await e.afterHandle[${A}](c)
267
+ `:`e.afterHandle[${A}](c)
268
+ `,X())}m.resolve(),o.afterHandle?.length&&(p+=`r=c.response
269
+ `),i.response&&(p+=M.response()),p+=K();let O=N("mapResponse",{total:o.mapResponse?.length});if(o.mapResponse?.length)for(let A=0;A<o.mapResponse.length;A++){let C=o.mapResponse[A],v=O.resolveChild(C.fn.name);p+=`mr=${Cn(C)?"await ":""}e.mapResponse[${A}](c)
270
+ if(mr!==undefined)r=c.response=c.responseValue=mr
271
+ `,v()}O.resolve(),p+=lt()}else{let w=Ui(d?s.name:void 0);if(i.response||o.mapResponse?.length||b){p+=V?`let r=await ${y}
272
+ `:`let r=${y}
273
+ `,w(),i.response&&(p+=M.response());let m=N("mapResponse",{total:o.mapResponse?.length});if(o.mapResponse?.length){p+=`
274
+ c.response=c.responseValue=r
275
+ `;for(let O=0;O<o.mapResponse.length;O++){let A=o.mapResponse[O],C=m.resolveChild(A.fn.name);p+=`
276
+ if(mr===undefined){mr=${Cn(A)?"await ":""}e.mapResponse[${O}](c)
277
+ if(mr!==undefined)r=c.response=c.responseValue=mr}
278
+ `,C()}}m.resolve(),p+=K(),s instanceof Response?(p+=Rr(),p+=f.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${G}${y}.clone(),c.set${sn})
279
+ else return ${y}.clone()`:`return ${y}.clone()`,p+=`
280
+ `):p+=lt()}else if(k||b){p+=V?`let r=await ${y}
281
+ `:`let r=${y}
282
+ `,w();let m=N("mapResponse",{total:o.mapResponse?.length});if(o.mapResponse?.length){p+=`c.response=c.responseValue= r
283
+ `;for(let O=0;O<o.mapResponse.length;O++){let A=o.mapResponse[O],C=m.resolveChild(A.fn.name);p+=`if(mr===undefined){mr=${Cn(A)?"await ":""}e.mapResponse[${O}](c)
284
+ if(mr!==undefined)r=c.response=c.responseValue=mr}`,C()}}m.resolve(),p+=K()+lt()}else{w();let m=V?`await ${y}`:y;s instanceof Response?(p+=Rr(),p+=f.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${G}${y}.clone(),c.set${sn})
285
+ else return ${y}.clone()
286
+ `:`return ${y}.clone()
287
+ `):p+=lt(m)}}if(p+=`
288
+ }catch(error){`,!on&&o.error?.length&&(p+="return(async()=>{"),p+=`const set=c.set
289
+ if(!set.status||set.status<300)set.status=error?.status||500
290
+ `,k&&(p+=K()),b&&o.trace)for(let w=0;w<o.trace.length;w++)p+=`report${w}?.resolve(error);reportChild${w}?.(error)
291
+ `;let uo=N("error",{total:o.error?.length});if(o.error?.length){p+=`c.error=error
292
+ `,g?p+=`if(error instanceof TypeBoxError){c.code="VALIDATION"
293
+ c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}`:p+=`c.code=error.code??error[ERROR_CODE]??"UNKNOWN"
294
+ `,p+=`let er
295
+ `,o.mapResponse?.length&&(p+=`let mep
296
+ `);for(let w=0;w<o.error.length;w++){let m=uo.resolveChild(o.error[w].fn.name);if(_e(o.error[w])?p+=`er=await e.error[${w}](c)
297
+ `:p+=`er=e.error[${w}](c)
298
+ if(er instanceof Promise)er=await er
299
+ `,m(),o.mapResponse?.length){let O=N("mapResponse",{total:o.mapResponse?.length});for(let A=0;A<o.mapResponse.length;A++){let C=o.mapResponse[A],v=O.resolveChild(C.fn.name);p+=`c.response=c.responseValue=er
300
+ mep=e.mapResponse[${A}](c)
301
+ if(mep instanceof Promise)mep=await mep
302
+ if(mep!==undefined)er=mep
303
+ `,v()}O.resolve()}if(p+=`er=mapEarlyResponse(er,set${sn})
304
+ `,p+="if(er){",b&&o.trace){for(let O=0;O<o.trace.length;O++)p+=`report${O}.resolve()
305
+ `;uo.resolve()}p+=Rr(!1),p+="return er}"}}uo.resolve(),p+="return handleError(c,error,true)",!on&&o.error?.length&&(p+="})()"),p+="}";let oa=u.inject?Object.keys(u.inject).join(",")+",":"",h="const {handler,handleError,hooks:e, "+Ve("validator,",g)+"mapResponse,mapCompactResponse,mapEarlyResponse,isNotEmpty,utils:{"+Ve("parseQuery,",J)+Ve("parseQueryFromURL,",R)+"},error:{"+Ve("ValidationError,",g)+Ve("ParseError",J)+"},fileType,schema,definitions,tee,ERROR_CODE,"+Ve("parseCookie,",k)+Ve("signCookie,",k)+Ve("decodeURIComponent,",R)+"ElysiaCustomStatusResponse,"+Ve("ELYSIA_TRACE,",b)+Ve("ELYSIA_REQUEST_ID,",b)+Ve("parser,",o.parse?.length)+Ve("getServer,",f.server)+Ve("fileUnions,",Nr.length)+oa+Ve("TypeBoxError",g)+`}=hooks
306
+ const trace=e.trace
307
+ return ${on?"async ":""}function handle(c){`;o.beforeHandle?.length&&(h+=`let be
308
+ `),o.afterHandle?.length&&(h+=`let af
309
+ `),o.mapResponse?.length&&(h+=`let mr
310
+ `),c&&(h+=`c.schema=schema
311
+ c.defs=definitions
312
+ `),p=h+p+"}",h="";try{return Function("hooks",`"use strict";
313
+ `+p)({handler:s,hooks:Qa(o),validator:g?i:void 0,handleError:e.handleError,mapResponse:l.mapResponse,mapCompactResponse:l.mapCompactResponse,mapEarlyResponse:l.mapEarlyResponse,isNotEmpty:ue,utils:{parseQuery:J?Fn:void 0,parseQueryFromURL:R?i.query?.provider==="standard"?gd:oc:void 0},error:{ValidationError:g?W:void 0,ParseError:J?js:void 0},fileType:Ms,schema:e.router.history,definitions:e.definitions.type,tee:md,ERROR_CODE:Xn,parseCookie:k?Vs:void 0,signCookie:k?Ho:void 0,Cookie:k?Tt:void 0,decodeURIComponent:R?Sd.default:void 0,ElysiaCustomStatusResponse:ve,ELYSIA_TRACE:b?io:void 0,ELYSIA_REQUEST_ID:b?Yr:void 0,getServer:f.server?()=>e.getServer():void 0,fileUnions:Nr.length?Nr:void 0,TypeBoxError:g?re:void 0,parser:e["~parser"],...u.inject})}catch(w){let m=Qa(o);return console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof s=="function"?s.toString():s,instruction:p,hooks:{...m,transform:m?.transform?.map?.((O)=>O.toString()),resolve:m?.resolve?.map?.((O)=>O.toString()),beforeHandle:m?.beforeHandle?.map?.((O)=>O.toString()),afterHandle:m?.afterHandle?.map?.((O)=>O.toString()),mapResponse:m?.mapResponse?.map?.((O)=>O.toString()),parse:m?.parse?.map?.((O)=>O.toString()),error:m?.error?.map?.((O)=>O.toString()),afterResponse:m?.afterResponse?.map?.((O)=>O.toString()),stop:m?.stop?.map?.((O)=>O.toString())},validator:i,definitions:e.definitions.type,error:w}),console.log("---"),typeof process?.exit=="function"&&process.exit(1),()=>new Response("Internal Server Error",{status:500})}},pc=(e,t)=>{let n="",o=ki({trace:e.event.trace,addFn:t??((i)=>{n+=i})})("request",{total:e.event.request?.length});if(e.event.request?.length){n+="try{";for(let i=0;i<e.event.request.length;i++){let s=e.event.request[i],c=ji(s),f=_e(s),u=o.resolveChild(e.event.request[i].fn.name);c?(n+=`re=mapEarlyResponse(${f?"await ":""}onRequest[${i}](c),c.set)
314
+ `,u("re"),n+=`if(re!==undefined)return re
315
+ `):(n+=`${f?"await ":""}onRequest[${i}](c)
316
+ `,u())}n+="}catch(error){return app.handleError(c,error,false)}"}return o.resolve(),n},mc=(e,t="map")=>{let n=e.extender.higherOrderFunctions;if(!n.length)return"return "+t;let o=e["~adapter"].composeGeneralHandler,i=t;for(let s=0;s<n.length;s++)i=`hoc[${s}](${i},${o.parameters})`;return`return function hocMap(${o.parameters}){return ${i}(${o.parameters})}`},ea=(e)=>{let t=e["~adapter"].composeGeneralHandler;e.router.http.build();let n=e["~adapter"].isWebStandard,o=e.event.trace?.length,i="",s=e.router,c=s.http.root.WS?"const route=router.find(r.method==='GET'&&r.headers.get('upgrade')==='websocket'?'WS':r.method,p)":"const route=router.find(r.method,p)";c+=s.http.root.ALL?`??router.find('ALL',p)
317
+ `:`
318
+ `,n&&(c+='if(r.method==="HEAD"){const route=router.find("GET",p);if(route){c.params=route.params;const _res=route.store.handler?route.store.handler(c):route.store.compile()(c);if(_res)return Promise.resolve(_res).then((_res)=>{if(!_res.headers)_res.headers=new Headers();return getResponseLength(_res).then((length)=>{_res.headers.set("content-length", length);return new Response(null,{status:_res.status,statusText:_res.statusText,headers:_res.headers});})});}}');let f=`c.error=notFound
319
+ `;if(e.event.afterResponse?.length&&!e.event.error){f=`
320
+ c.error=notFound
321
+ `;let g=e.event.afterResponse.some(_e)?"async":"";f+=`
322
+ ${Xs}(${g}()=>{if(c.responseValue instanceof ElysiaCustomStatusResponse) c.set.status=c.responseValue.code
323
+ `;for(let R=0;R<e.event.afterResponse.length;R++){let L=e.event.afterResponse[R].fn;f+=`
324
+ ${Cn(L)?"await ":""}afterResponse[${R}](c)
325
+ `}f+=`})
326
+ `}e.inference.query&&(f+=`
327
+ if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url,c.qi+1)}`);let u=t.error404(!!e.event.request?.length,!!e.event.error?.length,f);c+=u.code,c+=`
328
+ c.params=route.params
329
+ if(route.store.handler)return route.store.handler(c)
330
+ return route.store.compile()(c)
331
+ `;let l="";for(let[g,R]of Object.entries(s.static)){l+=`case'${g}':`,e.config.strictPath!==!0&&(l+=`case'${Yn(g)}':`);let L=Zn(g);g!==L&&(l+=`case'${L}':`),l+="switch(r.method){",(("GET"in R)||("WS"in R))&&(l+="case 'GET':",("WS"in R)&&(l+=`if(r.headers.get('upgrade')==='websocket')return ht[${R.WS}].composed(c)
332
+ `,("GET"in R)||("ALL"in R?l+=`return ht[${R.ALL}].composed(c)
333
+ `:l+=`break map
334
+ `)),("GET"in R)&&(l+=`return ht[${R.GET}].composed(c)
335
+ `)),n&&(("GET"in R)||("ALL"in R))&&!("HEAD"in R)&&(l+=`case 'HEAD':return Promise.resolve(ht[${R.GET??R.ALL}].composed(c)).then(_ht=>getResponseLength(_ht).then((length)=>{_ht.headers.set('content-length', length)
336
+ return new Response(null,{status:_ht.status,statusText:_ht.statusText,headers:_ht.headers})
337
+ }))
338
+ `);for(let[J,H]of Object.entries(R))J==="ALL"||J==="GET"||J==="WS"||(l+=`case '${J}':return ht[${H}].composed(c)
339
+ `);"ALL"in R?l+=`default:return ht[${R.ALL}].composed(c)
340
+ `:l+=`default:break map
341
+ `,l+="}"}let d=!!e.event.request?.some(_e),y=t.inject?Object.keys(t.inject).join(",")+",":"";i+=`
342
+ const {app,mapEarlyResponse,NotFoundError,randomId,handleError,status,redirect,getResponseLength,ElysiaCustomStatusResponse,`+Ve("parseQueryFromURL,",e.inference.query)+Ve("ELYSIA_TRACE,",o)+Ve("ELYSIA_REQUEST_ID,",o)+y+`}=data
343
+ const store=app.singleton.store
344
+ const decorator=app.singleton.decorator
345
+ const staticRouter=app.router.static.http
346
+ const ht=app.router.history
347
+ const router=app.router.http
348
+ const trace=app.event.trace?.map(x=>typeof x==='function'?x:x.fn)??[]
349
+ const notFound=new NotFoundError()
350
+ const hoc=app.extender.higherOrderFunctions.map(x=>x.fn)
351
+ `,e.event.request?.length&&(i+=`const onRequest=app.event.request.map(x=>x.fn)
352
+ `),e.event.afterResponse?.length&&(i+=`const afterResponse=app.event.afterResponse.map(x=>x.fn)
353
+ `),i+=u.declare,e.event.trace?.length&&(i+="const "+e.event.trace.map((g,R)=>`tr${R}=app.event.trace[${R}].fn`).join(",")+`
354
+ `),i+=`${d?"async ":""}function map(${t.parameters}){`,e.event.request?.length&&(i+=`let re
355
+ `),i+=t.createContext(e),e.event.trace?.length&&(i+="c[ELYSIA_TRACE]=["+e.event.trace.map((g,R)=>`tr${R}(c)`).join(",")+`]
356
+ `),i+=pc(e),l&&(i+=`
357
+ map: switch(p){
358
+ `+l+"}"),i+=c+`}
359
+ `+mc(e);let b=yc(e);e.handleError=b;let p=Function("data",`"use strict";
360
+ `+i)({app:e,mapEarlyResponse:e["~adapter"].handler.mapEarlyResponse,NotFoundError:Vo,randomId:Zr,handleError:b,status:Zt,redirect:Qr,getResponseLength:vu,ElysiaCustomStatusResponse:ve,parseQueryFromURL:e.inference.query?oc:void 0,ELYSIA_TRACE:o?io:void 0,ELYSIA_REQUEST_ID:o?Yr:void 0,...t.inject});return vt&&Bun.gc(!1),p},yc=(e)=>{let t=e.event,n="",o=e["~adapter"].composeError,i=o.inject?Object.keys(o.inject).join(",")+",":"",s=!!e.event.trace?.length;n+="const {mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,ValidationError,TransformDecodeError,"+Ve("onError,",e.event.error)+Ve("afterResponse,",e.event.afterResponse)+Ve("trace,",e.event.trace)+Ve("onMapResponse,",e.event.mapResponse)+Ve("ELYSIA_TRACE,",s)+Ve("ELYSIA_REQUEST_ID,",s)+i+`}=inject
361
+ `,n+="return async function(context,error,skipGlobal){",n+="",s&&(n+=`const id=context[ELYSIA_REQUEST_ID]
362
+ `);let c=ki({context:"context",trace:t.trace,addFn:(y)=>{n+=y}}),f=()=>{if(!t.afterResponse?.length&&!s)return"";let y="",b=t.afterResponse?.some(_e)?"async":"";y+=`
363
+ ${Xs}(${b}()=>{`;let p=ki({context:"context",trace:t.trace,addFn:(g)=>{y+=g}})("afterResponse",{total:t.afterResponse?.length,name:"context"});if(t.afterResponse?.length&&t.afterResponse)for(let g=0;g<t.afterResponse.length;g++){let R=t.afterResponse[g].fn,L=p.resolveChild(R.name);y+=`
364
+ ${Cn(R)?"await ":""}afterResponse[${g}](context)
365
+ `,L()}return p.resolve(),y+=`})
366
+ `,y};n+=`const set=context.set
367
+ let _r
368
+ if(!context.code)context.code=error.code??error[ERROR_CODE]
369
+ if(!(context.error instanceof Error))context.error=error
370
+ if(error instanceof ElysiaCustomStatusResponse){set.status=error.status=error.code
371
+ error.message=error.response}`,o.declare&&(n+=o.declare);let u=s||t.afterResponse?.length?"context.response = ":"";if(n+=`if(typeof error?.toResponse==='function'&&!(error instanceof ValidationError)&&!(error instanceof TransformDecodeError)){try{let raw=error.toResponse()
372
+ if(typeof raw?.then==='function')raw=await raw
373
+ if(raw instanceof Response)set.status=raw.status
374
+ context.response=context.responseValue=raw
375
+ }catch(toResponseError){
376
+ }
377
+ }
378
+ `,e.event.error)for(let y=0;y<e.event.error.length;y++){let b=e.event.error[y],p=`${_e(b)?"await ":""}onError[${y}](context)
379
+ `;if(n+="if(skipGlobal!==true&&!context.response){",ji(b)){n+=`_r=${p}
380
+ if(_r!==undefined){if(_r instanceof Response){`+f()+`return mapResponse(_r,set${o.mapResponseContext})}if(_r instanceof ElysiaCustomStatusResponse){error.status=error.code
381
+ error.message=error.response}if(set.status===200||!set.status)set.status=error.status
382
+ `;let g=c("mapResponse",{total:t.mapResponse?.length,name:"context"});if(t.mapResponse?.length)for(let R=0;R<t.mapResponse.length;R++){let L=t.mapResponse[R],J=g.resolveChild(L.fn.name);n+=`context.response=context.responseValue=_r
383
+ _r=${Cn(L)?"await ":""}onMapResponse[${R}](context)
384
+ `,J()}g.resolve(),n+=f()+`return mapResponse(${u}_r,set${o.mapResponseContext})}`}else n+=p;n+="}"}n+=`if(error instanceof ValidationError||error instanceof TransformDecodeError){
385
+ if(error.error)error=error.error
386
+ set.status=error.status??422
387
+ `+f()+o.validationError+`
388
+ }
389
+ `,n+="if(!context.response&&error instanceof Error){"+f()+o.unknownError+`
390
+ }`;let l=c("mapResponse",{total:t.mapResponse?.length,name:"context"});if(n+=`
391
+ if(!context.response)context.response=context.responseValue=error.message??error
392
+ `,t.mapResponse?.length){n+=`let mr
393
+ `;for(let y=0;y<t.mapResponse.length;y++){let b=t.mapResponse[y],p=l.resolveChild(b.fn.name);n+=`if(mr===undefined){mr=${Cn(b)?"await ":""}onMapResponse[${y}](context)
394
+ if(mr!==undefined)error=context.response=context.responseValue=mr}`,p()}}l.resolve(),n+=f()+`
395
+ return mapResponse(${u}error,set${o.mapResponseContext})}`;let d=(y)=>typeof y=="function"?y:y.fn;return Function("inject",`"use strict";
396
+ `+n)({mapResponse:e["~adapter"].handler.mapResponse,ERROR_CODE:Xn,ElysiaCustomStatusResponse:ve,ValidationError:W,TransformDecodeError:Jn,onError:e.event.error?.map(d),afterResponse:e.event.afterResponse?.map(d),trace:e.event.trace?.map(d),onMapResponse:e.event.mapResponse?.map(d),ELYSIA_TRACE:s?io:void 0,ELYSIA_REQUEST_ID:s?Yr:void 0,...o.inject})};var nn=(e,t)=>t?e:"",Ed=(e,t,n,o=!1)=>{let i="",s=e.setHeaders,c=!!e.event.trace?.length;c&&(i+=`const id=randomId()
397
+ `);let f=/[:*]/.test(t.path),u=`const u=request.url,s=u.indexOf('/',${e.config.handler?.standardHostname??!0?11:7}),qi=u.indexOf('?',s+1)
398
+ `,l=n.query||!!t.hooks.query||!!t.hooks.standaloneValidator?.find((y)=>y.query)||e.event.request?.length;l&&(i+=u);let d=n.path?f?"get path(){"+(l?"":u)+`if(qi===-1)return u.substring(s)
399
+ return u.substring(s,qi)
400
+ },`:`path:'${t.path}',`:"";i+=nn("const c=",!o)+"{request,store,"+nn("qi,",l)+nn("params:request.params,",f)+d+nn("url:request.url,",c||n.url||l)+"redirect,status,set:{headers:"+(ue(s)?"Object.assign({},app.setHeaders)":"Object.create(null)")+",status:200}",n.server&&(i+=",get server(){return app.getServer()}"),c&&(i+=",[ELYSIA_REQUEST_ID]:id");{let y="";for(let b of Object.keys(e.singleton.decorator))y+=`,'${b}':decorator['${b}']`;i+=y}return i+=`}
401
+ `,i},ta=(e,t)=>{let n=!!e.event.trace?.length,o=!!e.extender.higherOrderFunctions.length,i=ro(t.hooks,e.inference);i=ro({handler:t.handler},i);let s="const handler=data.handler,app=data.app,store=data.store,decorator=data.decorator,redirect=data.redirect,route=data.route,mapEarlyResponse=data.mapEarlyResponse,"+nn("randomId=data.randomId,",n)+nn("ELYSIA_REQUEST_ID=data.ELYSIA_REQUEST_ID,",n)+nn("ELYSIA_TRACE=data.ELYSIA_TRACE,",n)+nn("trace=data.trace,",n)+nn("hoc=data.hoc,",o)+`status=data.status
402
+ `;e.event.request?.length&&(s+=`const onRequest=app.event.request.map(x=>x.fn)
403
+ `),s+=`${e.event.request?.find(_e)?"async":""} function map(request){`;let c=i.query||!!t.hooks.query||!!t.hooks.standaloneValidator?.find((f)=>f.query);return n||c||e.event.request?.length?(s+=Ed(e,t,i),s+=pc(e),s+="return handler(c)}"):s+=`return handler(${Ed(e,t,i,!0)})}`,s+=mc(e),Function("data",s)({app:e,handler:t.compile?.()??t.composed,redirect:Qr,status:Zt,hoc:e.extender.higherOrderFunctions.map((f)=>f.fn),store:e.store,decorator:e.decorator,route:t.path,randomId:n?Zr:void 0,ELYSIA_TRACE:n?io:void 0,ELYSIA_REQUEST_ID:n?Yr:void 0,trace:n?e.event.trace?.map((f)=>f?.fn??f):void 0,mapEarlyResponse:ut})};var Cd=(e,t,n)=>{if(typeof e=="function"||e instanceof Blob)return;if(Ni(e))return()=>e;let o=dt(e instanceof Response?e.clone():e instanceof Promise?e.then((i)=>i instanceof Response?i.clone():Ni(i)?()=>i:i):e,n??{headers:{}});if(!t.parse?.length&&!t.transform?.length&&!t.beforeHandle?.length&&!t.afterHandle?.length)return o instanceof Promise?o.then((i)=>{if(i)return i.clone()}):()=>o.clone()};var hc={open(e){e.data.open?.(e)},message(e,t){e.data.message?.(e,t)},drain(e){e.data.drain?.(e)},close(e,t,n){e.data.close?.(e,t,n)},ping(e){e.data.ping?.(e)},pong(e){e.data.pong?.(e)}};class Yo{constructor(e,t,n=void 0){this.raw=e,this.data=t,this.body=n,this.validator=e.data?.validator,this.sendText=e.sendText.bind(e),this.sendBinary=e.sendBinary.bind(e),this.close=e.close.bind(e),this.terminate=e.terminate.bind(e),this.publishText=e.publishText.bind(e),this.publishBinary=e.publishBinary.bind(e),this.subscribe=e.subscribe.bind(e),this.unsubscribe=e.unsubscribe.bind(e),this.isSubscribed=e.isSubscribed.bind(e),this.cork=e.cork.bind(e),this.remoteAddress=e.remoteAddress,this.binaryType=e.binaryType,this.data=e.data,this.subscriptions=e.subscriptions,this.send=this.send.bind(this),this.ping=this.ping.bind(this),this.pong=this.pong.bind(this),this.publish=this.publish.bind(this)}send(e,t){return Buffer.isBuffer(e)?this.raw.send(e,t):this.validator?.Check(e)===!1?this.raw.send(new W("message",this.validator,e).message):(typeof e=="object"&&(e=JSON.stringify(e)),this.raw.send(e,t))}ping(e){return Buffer.isBuffer(e)?this.raw.ping(e):this.validator?.Check(e)===!1?this.raw.send(new W("message",this.validator,e).message):(typeof e=="object"&&(e=JSON.stringify(e)),this.raw.ping(e))}pong(e){return Buffer.isBuffer(e)?this.raw.pong(e):this.validator?.Check(e)===!1?this.raw.send(new W("message",this.validator,e).message):(typeof e=="object"&&(e=JSON.stringify(e)),this.raw.pong(e))}publish(e,t,n){return Buffer.isBuffer(t)?this.raw.publish(e,t,n):this.validator?.Check(t)===!1?this.raw.send(new W("message",this.validator,t).message):(typeof t=="object"&&(t=JSON.stringify(t)),this.raw.publish(e,t,n))}get readyState(){return this.raw.readyState}get id(){return this.data.id}}var Td=(e)=>{let t=typeof e=="function"?[e]:e;return async function(n,o){if(typeof o=="string"){let i=o?.charCodeAt(0);if(i===34||i===47||i===91||i===123)try{o=JSON.parse(o)}catch{}else Cs(o)?o=+o:o==="true"?o=!0:o==="false"?o=!1:o==="null"&&(o=null)}if(t)for(let i=0;i<t.length;i++){let s=t[i](n,o);if(s instanceof Promise&&(s=await s),s!==void 0)return s}return o}},Pd=(e)=>{let t=(n,o)=>{if(o instanceof Promise)return o.then((f)=>t(n,f));if(Buffer.isBuffer(o))return n.send(o.toString());if(o===void 0)return;let i=e?e.provider==="standard"?(f)=>e.schema["~standard"].validate(f).issues:(f)=>e.Check(f)===!1:void 0,s=(f)=>{if(i&&i(f)===!1)return n.send(new W("message",e,f).message);if(typeof f=="object")return n.send(JSON.stringify(f));n.send(f)};if(typeof o?.next!="function")return void s(o);let c=o.next();if(c instanceof Promise)return(async()=>{let f=await c;if(i&&i(f))return n.send(new W("message",e,f).message);if(s(f.value),!f.done)for await(let u of o)s(u)})();if(s(c.value),!c.done)for(let f of o)s(f)};return t};var sI=/:.+?\?(?=\/|$)/,Nd=(e)=>{let t=sI.exec(e);if(!t)return[e];let n=[],o=e.slice(0,t.index),i=t[0].slice(0,-1),s=e.slice(t.index+t[0].length);n.push(o.slice(0,-1)),n.push(o+i);for(let c of Nd(s))c&&(c.startsWith("/:")||n.push(o.slice(0,-1)+c),n.push(o+i+c));return n},Ni=(e)=>typeof e=="object"&&e!==null&&(e.toString()==="[object HTMLBundle]"||typeof e.index=="string"),Ud={GET:!0,HEAD:!0,OPTIONS:!0,DELETE:!0,PATCH:!0,POST:!0,PUT:!0},jd=(e)=>{if(!e.config.aot||e.config.systemRouter===!1)return;let t={},n=(i,s)=>{let c=encodeURI(i.path);t[c]?t[c][i.method]||(t[c][i.method]=s):t[c]={[i.method]:s}},o=e.routeTree;for(let i of e.router.history){if(typeof i.handler!="function")continue;let s=i.method;if(s==="GET"&&`WS_${i.path}`in o||s==="WS"||i.path.charCodeAt(i.path.length-1)===42||!(s in Ud))continue;if(s==="ALL"){`WS_${i.path}`in o||(t[i.path]=i.hooks?.config?.mount?i.hooks.trace||e.event.trace||e.extender.higherOrderFunctions?ta(e,i):i.hooks.mount||i.handler:i.handler);continue}let c,f=e.config.precompile?ta(e,i):(u)=>c?c(u):(c=ta(e,i))(u);for(let u of Nd(i.path))n({method:s,path:u},f)}return t},ra=(e,t)=>{if(!t)return e;for(let n of Object.keys(t))if(e[n]!==t[n]){if(!e[n]){e[n]=t[n];continue}if(e[n]&&t[n]){if(typeof e[n]=="function"||e[n]instanceof Response){e[n]=t[n];continue}e[n]={...e[n],...t[n]}}}return e},kd=(e)=>{for(let t of Object.keys(e))t.length>1&&t.charCodeAt(t.length-1)===47&&(e[t.slice(0,-1)]=e[t],delete e[t]);return e},Md={...Fi,name:"bun",handler:{mapResponse:dt,mapEarlyResponse:ut,mapCompactResponse:br,createStaticHandler:hd,createNativeStaticHandler:Cd},composeHandler:{...Fi.composeHandler,headers:Ri?`c.headers=c.request.headers.toJSON()
404
+ `:`c.headers={}
405
+ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
406
+ `},listen(e){return(t,n)=>{if(typeof Bun>"u")throw Error(".listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch");if(e.compile(),typeof t=="string"){if(!Cs(t))throw Error("Port must be a numeric value");t=parseInt(t)}let o=(c,{withAsync:f=!1}={})=>{let u={},l=[];for(let[d,y]of Object.entries(c))if(d=encodeURI(d),Ps){if(!y)continue;for(let[b,p]of Object.entries(y))if(!(!p||!(b in Ud))){if(p instanceof Promise){f&&(u[d]||(u[d]={}),l.push(p.then((g)=>{g instanceof Response&&(u[d][b]=g),Ni(g)&&(u[d][b]=g)})));continue}!(p instanceof Response)&&!Ni(p)||(u[d]||(u[d]={}),u[d][b]=p)}}else{if(!y)continue;if(y instanceof Promise){f&&(u[d]||(u[d]={}),l.push(y.then((b)=>{b instanceof Response&&(u[d]=b)})));continue}if(!(y instanceof Response))continue;u[d]=y}return f?Promise.all(l).then(()=>u):u},i=kd(ra(ra(o(e.router.response),jd(e)),e.config.serve?.routes)),s=typeof t=="object"?{development:!en,reusePort:!0,idleTimeout:30,...e.config.serve||{},...t||{},routes:i,websocket:{...e.config.websocket||{},...hc||{},...t.websocket||{}},fetch:e.fetch}:{development:!en,reusePort:!0,idleTimeout:30,...e.config.serve||{},routes:i,websocket:{...e.config.websocket||{},...hc||{}},port:t,fetch:e.fetch};if(e.server=Bun.serve(s),e.event.start)for(let c=0;c<e.event.start.length;c++)e.event.start[c].fn(e);n&&n(e.server),process.on("beforeExit",async()=>{if(e.server&&(await e.server.stop?.(),e.server=null,e.event.stop))for(let c=0;c<e.event.stop.length;c++)e.event.stop[c].fn(e)}),e.promisedModules.then(async()=>{e.config.aot,e.compile();let c=kd(ra(ra(await o(e.router.response,{withAsync:!0}),jd(e)),e.config.serve?.routes));e.server?.reload({...s,fetch:e.fetch,routes:c}),Bun?.gc(!1)})}},async stop(e,t){if(e.server){if(await e.server.stop(t),e.server=null,e.event.stop?.length)for(let n=0;n<e.event.stop.length;n++)e.event.stop[n].fn(e)}else console.log("Elysia isn't running. Call `app.listen` to start the server.",Error().stack)},ws(e,t,n){let{parse:o,body:i,response:s,...c}=n,f=He(i,{modules:e.definitions.typebox,models:e.definitions.type,normalize:e.config.normalize}),u=f?f.provider==="standard"?(d)=>f.schema["~standard"].validate(d).issues:(d)=>f.Check(d)===!1:void 0,l=He(s,{modules:e.definitions.typebox,models:e.definitions.type,normalize:e.config.normalize});e.route("WS",t,async(d)=>{let y=d.server??e.server,{set:b,path:p,qi:g,headers:R,query:L,params:J}=d;if(d.validator=l,n.upgrade)if(typeof n.upgrade=="function"){let K=n.upgrade(d);K instanceof Promise&&await K}else n.upgrade&&Object.assign(b.headers,n.upgrade);if(b.cookie&&ue(b.cookie)){let K=wi(b.cookie);K&&(b.headers["set-cookie"]=K)}b.headers["set-cookie"]&&Array.isArray(b.headers["set-cookie"])&&(b.headers=nc(new Headers(b.headers),b.headers["set-cookie"]));let H=Pd(l),_=Td(o),j;if(typeof n.beforeHandle=="function"){let K=n.beforeHandle(d);K instanceof Promise&&await K}let k=[...n.error?Array.isArray(n.error)?n.error:[n.error]:[],...(e.event.error??[]).map((K)=>typeof K=="function"?K:K.fn)].filter((K)=>K),q=k.length>0,se=q?async(K,U)=>{for(let D of k){let x=D(Object.assign(d,{error:U}));if(x instanceof Promise&&(x=await x),await H(K,x),x)break}}:()=>{};if(!y?.upgrade(d.request,{headers:ue(b.headers)?b.headers:void 0,data:{...d,get id(){return j||(j=Zr())},validator:l,ping(K,U){n.ping?.(K,U)},pong(K,U){n.pong?.(K,U)},open:async(K)=>{try{await H(K,n.open?.(new Yo(K,d)))}catch(U){se(K,U)}},message:async(K,U)=>{let D=await _(K,U);if(u&&u(D)){let x=new W("message",f,D);return q?se(K,x):void K.send(x.message)}try{await H(K,n.message?.(new Yo(K,d,D),D))}catch(x){se(K,x)}},drain:async(K)=>{try{await H(K,n.drain?.(new Yo(K,d)))}catch(U){se(K,U)}},close:async(K,U,D)=>{try{await H(K,n.close?.(new Yo(K,d),U,D))}catch(x){se(K,x)}}}}))return Zt(400,"Expected a websocket connection")},{...c,websocket:n})}};var na=vt?Bun.env:typeof process<"u"&&process?.env?process.env:{};var Bd=/^(.+)\[(\d+)\]$/,Kd=new Set(["__proto__","constructor","prototype"]),Ld=(e)=>{if(Kd.has(e))return!0;let t=e.match(Bd);return t?Kd.has(t[1]):!1},Dd=(e)=>{let t=e.match(Bd);return t?{name:t[1],index:parseInt(t[2],10)}:null},aI=(e)=>{if(!(typeof e!="string"||e.charCodeAt(0)!==123))try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return t}catch{return}},gc=(e,t,n)=>{let o=t.split("."),i=o.pop();if(Ld(i)||o.some(Ld))return;let s=e;for(let f of o){let u=Dd(f);if(u){Array.isArray(s[u.name])||(s[u.name]=[]);let l=s[u.name][u.index],d=typeof File<"u"&&l instanceof File;(!l||typeof l!="object"||Array.isArray(l)||d)&&(s[u.name][u.index]=aI(l)??{}),s=s[u.name][u.index]}else(!s[f]||typeof s[f]!="object")&&(s[f]={}),s=s[f]}let c=Dd(i);c?(Array.isArray(s[c.name])||(s[c.name]=[]),s[c.name][c.index]=n):s[i]=n},bc=(e)=>{if(e.length===1){let i=e[0];if(typeof i=="string"&&(i.charCodeAt(0)===123||i.charCodeAt(0)===91))try{let s=JSON.parse(i);if(s&&typeof s=="object")return s}catch{}return e[0]}let t=e.find((i)=>typeof i=="string");if(!t||typeof File>"u")return e;let n=e.filter((i)=>i instanceof File);if(!n.length||t.charCodeAt(0)!==123)return e;let o;try{o=JSON.parse(t)}catch{return e}return typeof o!="object"||o===null?e:(!("file"in o)&&n.length===1?o.file=n[0]:!("files"in o)&&n.length>1&&(o.files=n),o)},xc=(e,t)=>{let n=e.schema;if(!n)return;n.$defs?.[n.$ref]&&(n=n.$defs[n.$ref]);let o=jr(n);if(o)for(let[i,s]of Object.entries(o))t[i]??=s.default},Ic=(e)=>{let{mapResponse:t,mapEarlyResponse:n}=e["~adapter"].handler,o=e.setHeaders;return async(i)=>{let s=i.url,c=s.indexOf("/",11),f=s.indexOf("?",c+1),u=f===-1?s.substring(c):s.substring(c,f),l={cookie:{},status:200,headers:o?{...o}:{}},d=Object.assign({},e.singleton.decorator,{set:l,store:e.singleton.store,request:i,path:u,qi:f,error:Zt,status:Zt,redirect:Qr}),y;try{if(e.event.request)for(let U=0;U<e.event.request.length;U++){let D=e.event.request[U].fn,x=D(d);if(x instanceof Promise&&(x=await x),x=n(x,l),x)return d.response=x}let b=i.method==="GET"&&i.headers.get("upgrade")?.toLowerCase()==="websocket"?"WS":i.method,p=e.router.dynamic.find(i.method,u)??e.router.dynamic.find(b,u)??e.router.dynamic.find("ALL",u);if(!p)throw d.query=f===-1?{}:Fn(s.substring(f+1)),new Vo;let{handle:g,validator:R,content:L,route:J}=p.store;if(y=p.store.hooks,y.config?.mount)return await y.config.mount(i);let H;if(i.method!=="GET"&&i.method!=="HEAD")if(L)switch(L){case"application/json":H=await i.json();break;case"text/plain":H=await i.text();break;case"application/x-www-form-urlencoded":H=Fn(await i.text());break;case"application/octet-stream":H=await i.arrayBuffer();break;case"multipart/form-data":{H={};let U=await i.formData(),D=new Map;U.forEach((x,M)=>{let N=D.get(M);N?N.push(x):D.set(M,[x])});for(let[x,M]of D){if(H[x])continue;let N=bc(M);x.includes(".")||x.includes("[")?gc(H,x,N):H[x]=N}break}}else{let U;if(i.body&&(U=i.headers.get("content-type")),U){let D=U.indexOf(";");if(D!==-1&&(U=U.slice(0,D)),d.contentType=U,y.parse)for(let x=0;x<y.parse.length;x++){let M=y.parse[x].fn;if(typeof M=="string")switch(M){case"json":case"application/json":H=await i.json();break;case"text":case"text/plain":H=await i.text();break;case"urlencoded":case"application/x-www-form-urlencoded":H=Fn(await i.text());break;case"arrayBuffer":case"application/octet-stream":H=await i.arrayBuffer();break;case"formdata":case"multipart/form-data":{H={};let N=await i.formData(),V=new Map;N.forEach((G,Me)=>{let z=V.get(Me);z?z.push(G):V.set(Me,[G])});for(let[G,Me]of V){if(H[G])continue;let z=bc(Me);G.includes(".")||G.includes("[")?gc(H,G,z):H[G]=z}break}default:{let N=e["~parser"][M];if(N){let V=N(d,U);if(V instanceof Promise&&(V=await V),V){H=V;break}}break}}else{let N=M(d,U);if(N instanceof Promise&&(N=await N),N){H=N;break}}}if(delete d.contentType,H===void 0)switch(U){case"application/json":H=await i.json();break;case"text/plain":H=await i.text();break;case"application/x-www-form-urlencoded":H=Fn(await i.text());break;case"application/octet-stream":H=await i.arrayBuffer();break;case"multipart/form-data":{H={};let x=await i.formData(),M=new Map;x.forEach((N,V)=>{let G=M.get(V);G?G.push(N):M.set(V,[N])});for(let[N,V]of M){if(H[N])continue;let G=bc(V);N.includes(".")||N.includes("[")?gc(H,N,G):H[N]=G}break}}}}d.route=J,d.body=H,d.params=p?.params||void 0,d.query=f===-1?{}:Fn(s.substring(f+1)),d.headers={};for(let[U,D]of i.headers.entries())d.headers[U]=D;let _={domain:e.config.cookie?.domain??R?.cookie?.config.domain,expires:e.config.cookie?.expires??R?.cookie?.config.expires,httpOnly:e.config.cookie?.httpOnly??R?.cookie?.config.httpOnly,maxAge:e.config.cookie?.maxAge??R?.cookie?.config.maxAge,path:e.config.cookie?.path??R?.cookie?.config.path,priority:e.config.cookie?.priority??R?.cookie?.config.priority,partitioned:e.config.cookie?.partitioned??R?.cookie?.config.partitioned,sameSite:e.config.cookie?.sameSite??R?.cookie?.config.sameSite,secure:e.config.cookie?.secure??R?.cookie?.config.secure,secrets:e.config.cookie?.secrets??R?.cookie?.config.secrets,sign:e.config.cookie?.sign??R?.cookie?.config.sign},j=i.headers.get("cookie");d.cookie=await Vs(d.set,j,_);let k=R?.createHeaders?.();k&&xc(k,d.headers);let q=R?.createParams?.();q&&xc(q,d.params);let se=R?.createQuery?.();if(se&&xc(se,d.query),y.transform)for(let U=0;U<y.transform.length;U++){let D=y.transform[U],x=D.fn(d);if(x instanceof Promise&&(x=await x),x instanceof ve){let M=n(x,d.set);if(M)return d.response=M}D.subType==="derive"&&Object.assign(d,x)}if(R){if(k){let U=structuredClone(d.headers);for(let[D,x]of i.headers)U[D]=x;if(R.headers.Check(U)===!1)throw new W("header",R.headers,U)}else R.headers?.Decode&&(d.headers=R.headers.Decode(d.headers));if(q?.Check(d.params)===!1)throw new W("params",R.params,d.params);if(R.params?.Decode&&(d.params=R.params.Decode(d.params)),R.query?.schema){let U=R.query.schema;U.$defs?.[U.$ref]&&(U=U.$defs[U.$ref]);let D=jr(U);if(D)for(let x of Object.keys(D)){let M=D[x];(M.type==="array"||M.items?.type==="string")&&typeof d.query[x]=="string"&&d.query[x]&&(d.query[x]=d.query[x].split(","))}}if(se?.Check(d.query)===!1)throw new W("query",R.query,d.query);if(R.query?.Decode&&(d.query=R.query.Decode(d.query)),R.createCookie?.()){let U={};for(let[D,x]of Object.entries(d.cookie))U[D]=x.value;if(R.cookie.Check(U)===!1)throw new W("cookie",R.cookie,U);R.cookie?.Decode&&(U=R.cookie.Decode(U))}if(R.createBody?.()?.Check(H)===!1)throw new W("body",R.body,H);if(R.body?.Decode){let U=R.body.Decode(H);U instanceof Promise&&(U=await U),d.body=U?.value??U}}if(y.beforeHandle)for(let U=0;U<y.beforeHandle.length;U++){let D=y.beforeHandle[U],x=D.fn(d);if(x instanceof Promise&&(x=await x),x instanceof ve){let M=n(x,d.set);if(M)return d.response=M}if(D.subType==="resolve"){Object.assign(d,x);continue}if(x!==void 0){if(d.response=x,y.afterHandle)for(let N=0;N<y.afterHandle.length;N++){let V=y.afterHandle[N].fn(d);V instanceof Promise&&(V=await V),V&&(x=V)}let M=n(x,d.set);if(M)return d.response=M}}let K=typeof g=="function"?g(d):g;if(K instanceof Promise&&(K=await K),y.afterHandle?.length){d.response=K;for(let U=0;U<y.afterHandle.length;U++){let D=y.afterHandle[U].fn(d);D instanceof Promise&&(D=await D);let x=D instanceof ve,M=x?D.code:l.status?typeof l.status=="string"?Cr[l.status]:l.status:200;x&&(l.status=M,D=D.response);let N=R?.createResponse?.()?.[M];if(N?.Check(D)===!1)if(N?.Clean)try{let G=N.Clean(D);if(N?.Check(G)===!1)throw new W("response",N,D);D=G}catch(G){throw G instanceof W?G:new W("response",N,D)}else throw new W("response",N,D);if(N?.Encode&&(d.response=D=N.Encode(D)),N?.Clean)try{d.response=D=N.Clean(D)}catch{}let V=n(D,d.set);if(V!==void 0)return d.response=V}}else{let U=K instanceof ve,D=U?K.code:l.status?typeof l.status=="string"?Cr[l.status]:l.status:200;U&&(l.status=D,K=K.response);let x=R?.createResponse?.()?.[D];if(x?.Check(K)===!1)if(x?.Clean)try{let M=x.Clean(K);if(x?.Check(M)===!1)throw new W("response",x,K);K=M}catch(M){throw M instanceof W?M:new W("response",x,K)}else throw new W("response",x,K);if(x?.Encode&&(K=x.Encode(K)),x?.Clean)try{K=x.Clean(K)}catch{}}if(d.set.cookie&&_?.sign){let U=_.secrets?typeof _.secrets=="string"?_.secrets:_.secrets[0]:void 0;if(_.sign===!0){if(U)for(let[D,x]of Object.entries(d.set.cookie))d.set.cookie[D].value=await Ho(x.value,U)}else{let D=jr(R?.cookie?.schema);if(U)for(let x of _.sign)!D||!(x in D)||d.set.cookie[x]?.value&&(d.set.cookie[x].value=await Ho(d.set.cookie[x].value,U))}}return t(d.response=K,d.set)}catch(b){let p=b instanceof Jn&&b.error?b.error:b;return e.handleError(d,p)}finally{let b=y?y.afterResponse:e.event.afterResponse;b&&(Fs?setImmediate(async()=>{for(let p of b)await p.fn(d)}):Promise.resolve().then(async()=>{for(let p of b)await p.fn(d)}))}}},vd=(e)=>{let{mapResponse:t}=e["~adapter"].handler;return async(n,o)=>{let i=Object.assign(n,{error:o,code:o.code});if(i.set=n.set,typeof o?.toResponse=="function"&&!(o instanceof W)&&!(o instanceof Jn))try{let s=o.toResponse();typeof s?.then=="function"&&(s=await s),s instanceof Response&&(n.set.status=s.status),n.response=s}catch{}if(!n.response&&e.event.error)for(let s=0;s<e.event.error.length;s++){let c=e.event.error[s].fn(i);if(c instanceof Promise&&(c=await c),c!=null)return n.response=t(c,n.set)}if(n.response){if(e.event.mapResponse)for(let s=0;s<e.event.mapResponse.length;s++){let c=e.event.mapResponse[s].fn(i);c instanceof Promise&&(c=await c),c!=null&&(n.response=c)}return t(n.response,n.set)}return n.set.status=o.status??500,t(typeof o.cause=="string"?o.cause:o.message,n.set)}};var Hd;Hd=Symbol.dispose;var cI=class e{constructor(t={}){this.server=null,this.dependencies={},this["~Prefix"]="",this["~Singleton"]=null,this["~Definitions"]=null,this["~Metadata"]=null,this["~Ephemeral"]=null,this["~Volatile"]=null,this["~Routes"]=null,this.singleton={decorator:{},store:{},derive:{},resolve:{}},this.definitions={typebox:r.Module({}),type:{},error:{}},this.extender={macro:{},higherOrderFunctions:[]},this.validator={global:null,scoped:null,local:null,getCandidate(){return!this.global&&!this.scoped&&!this.local?{body:void 0,headers:void 0,params:void 0,query:void 0,cookie:void 0,response:void 0}:vo(vo(this.global,this.scoped),this.local)}},this.standaloneValidator={global:null,scoped:null,local:null},this.event={},this.router={"~http":void 0,get http(){return this["~http"]||(this["~http"]=new Tn({lazy:!0,onParam:Oc.default})),this["~http"]},"~dynamic":void 0,get dynamic(){return this["~dynamic"]||(this["~dynamic"]=new Tn({onParam:Oc.default})),this["~dynamic"]},static:{},response:{},history:[]},this.routeTree={},this.inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,path:!1,route:!1,url:!1},this["~parser"]={},this.handle=async(n)=>this.fetch(n),this.handleError=async(n,o)=>(this.handleError=this.config.aot?yc(this):vd(this))(n,o),this.listen=(n,o)=>(this["~adapter"].listen(this)(n,o),this),this.stop=async(n)=>(await this["~adapter"].stop?.(this,n),this),this[Hd]=()=>{this.server&&this.stop()},t.tags&&(t.detail?t.detail.tags=t.tags:t.detail={tags:t.tags}),this.config={aot:na.ELYSIA_AOT!=="false",nativeStaticResponse:!0,encodeSchema:!0,normalize:!0,...t,prefix:t.prefix?t.prefix.charCodeAt(0)===47?t.prefix:`/${t.prefix}`:void 0,cookie:{path:"/",...t?.cookie},experimental:t?.experimental??{},seed:t?.seed===void 0?"":t?.seed},this["~adapter"]=t.adapter??(typeof Bun<"u"?Md:Fi),t?.analytic&&(t?.name||t?.seed!==void 0)&&(this.telemetry={stack:Error().stack})}get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}getGlobalDefinitions(){return this.definitions}getServer(){return this.server}getParent(){return null}get promisedModules(){return this._promisedModules||(this._promisedModules=new Ja(console.error,()=>{})),this._promisedModules}env(t,n=na){if(He(t,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0,sanitize:()=>this.config.sanitize}).Check(n)===!1){let o=new W("env",t,n);throw Error(o.all.map((i)=>i.summary).join(`
407
+ `))}return this}wrap(t){return this.extender.higherOrderFunctions.push({checksum:Wr(JSON.stringify({name:this.config.name,seed:this.config.seed,content:t.toString()})),fn:t}),this}get models(){let t={};for(let n of Object.keys(this.definitions.type))t[n]=He(this.definitions.typebox.Import(n),{models:this.definitions.type});return t.modules=this.definitions.typebox,t}add(t,n,o,i,s){let c=s?.skipPrefix??!1,f=s?.allowMeta??!1;i??={},this.applyMacro(i);let u=[];if(i.standaloneValidator&&(u=u.concat(i.standaloneValidator)),this.standaloneValidator.local&&(u=u.concat(this.standaloneValidator.local)),this.standaloneValidator.scoped&&(u=u.concat(this.standaloneValidator.scoped)),this.standaloneValidator.global&&(u=u.concat(this.standaloneValidator.global)),n!==""&&n.charCodeAt(0)!==47&&(n="/"+n),this.config.prefix&&!c&&(n=this.config.prefix+n),i?.type)switch(i.type){case"text":i.type="text/plain";break;case"json":i.type="application/json";break;case"formdata":i.type="multipart/form-data";break;case"urlencoded":i.type="application/x-www-form-urlencoded";break;case"arrayBuffer":i.type="application/octet-stream";break;default:break}let l=this.validator.getCandidate(),d={body:i?.body??l?.body,headers:i?.headers??l?.headers,params:i?.params??l?.params,query:i?.query??l?.query,cookie:i?.cookie??l?.cookie,response:i?.response??l?.response},y=this.config.precompile===!0||typeof this.config.precompile=="object"&&this.config.precompile.compose===!0,b=()=>{let x=this.definitions.type,M=!this.config.aot,N=this.config.normalize,V=this.definitions.typebox,G=()=>this.config.sanitize,Me=()=>{if(d.cookie||u.find((z)=>z.cookie))return Ad({modules:V,validator:d.cookie,defaultConfig:this.config.cookie,normalize:N,config:d.cookie?.config??{},dynamic:M,models:x,validators:u.map((z)=>z.cookie),sanitize:G})};return y?{body:He(d.body,{modules:V,dynamic:M,models:x,normalize:N,additionalCoerce:(()=>{let z=lc(d.body,x,V);return z&&I in z&&(at("File",z)||at("Files",z))?uc():Ti()})(),validators:u.map((z)=>z.body),sanitize:G}),headers:He(d.headers,{modules:V,dynamic:M,models:x,additionalProperties:!0,coerce:!0,additionalCoerce:so(),validators:u.map((z)=>z.headers),sanitize:G}),params:He(d.params,{modules:V,dynamic:M,models:x,coerce:!0,additionalCoerce:so(),validators:u.map((z)=>z.params),sanitize:G}),query:He(d.query,{modules:V,dynamic:M,models:x,normalize:N,coerce:!0,additionalCoerce:fc(),validators:u.map((z)=>z.query),sanitize:G}),cookie:Me(),response:Ys(d.response,{modules:V,dynamic:M,models:x,normalize:N,validators:u.map((z)=>z.response),sanitize:G})}:{createBody(){return this.body?this.body:this.body=He(d.body,{modules:V,dynamic:M,models:x,normalize:N,additionalCoerce:(()=>{let z=lc(d.body,x,V);return z&&I in z&&(at("File",z)||at("Files",z))?uc():Ti()})(),validators:u.map((z)=>z.body),sanitize:G})},createHeaders(){return this.headers?this.headers:this.headers=He(d.headers,{modules:V,dynamic:M,models:x,normalize:N,additionalProperties:!N,coerce:!0,additionalCoerce:so(),validators:u.map((z)=>z.headers),sanitize:G})},createParams(){return this.params?this.params:this.params=He(d.params,{modules:V,dynamic:M,models:x,normalize:N,coerce:!0,additionalCoerce:so(),validators:u.map((z)=>z.params),sanitize:G})},createQuery(){return this.query?this.query:this.query=He(d.query,{modules:V,dynamic:M,models:x,normalize:N,coerce:!0,additionalCoerce:fc(),validators:u.map((z)=>z.query),sanitize:G})},createCookie(){return this.cookie?this.cookie:this.cookie=Me()},createResponse(){return this.response?this.response:this.response=Ys(d.response,{modules:V,dynamic:M,models:x,normalize:N,validators:u.map((z)=>z.response),sanitize:G})}}};(l.body||l.cookie||l.headers||l.params||l.query||l.response)&&(i=Er(i,l)),i.tags&&(i.detail?i.detail.tags=i.tags:i.detail={tags:i.tags}),ue(this.config.detail)&&(i.detail=et(Object.assign({},this.config.detail),i.detail));let p=ue(this.event)?Er(this.event,Wa(i)):{...Lu(Wa(i))};if(u.length&&Object.assign(p,{standaloneValidator:u}),this.config.aot===!1){let x=b();this.router.dynamic.add(t,n,{validator:x,hooks:p,content:i?.type,handle:o,route:n});let M=Zn(n,{dynamic:!0});if(n!==M&&this.router.dynamic.add(t,M,{validator:x,hooks:p,content:i?.type,handle:o,route:n}),!this.config.strictPath){let N=Yn(n);this.router.dynamic.add(t,N,{validator:x,hooks:p,content:i?.type,handle:o,route:n});let V=Zn(N);N!==V&&this.router.dynamic.add(t,N,{validator:x,hooks:p,content:i?.type,handle:o,route:n})}this.router.history.push({method:t,path:n,composed:null,handler:o,compile:void 0,hooks:p});return}let g=this["~adapter"].handler,R=typeof o!="function"?()=>{let x={redirect:Qr,request:this["~adapter"].isWebStandard?new Request(`http://ely.sia${n}`,{method:t}):void 0,server:null,set:{headers:Object.assign({},this.setHeaders)},status:Zt,store:this.store};try{this.event.request?.map((N)=>{if(typeof N.fn=="function")return N.fn(x);if(typeof N=="function")return N(x)})}catch(N){let V;x.error=N,this.event.error?.some((G)=>{if(typeof G.fn=="function")return V=G.fn(x);if(typeof G=="function")return V=G(x)}),V!==void 0&&(o=V)}let M=g.createNativeStaticHandler?.(o,p,x.set);return M instanceof Promise?M.then((N)=>{if(N)return N}):M?.()}:void 0,L=this.config.nativeStaticResponse===!0,J=(x)=>{!L||!R||(Ps?this.router.response[x]?this.router.response[x][t]=R():this.router.response[x]={[t]:R()}:this.router.response[x]=R())};J(n);let H,_=()=>{if(H)return H;let x=Fd({app:this,path:n,method:t,hooks:p,validator:b(),handler:typeof o!="function"&&typeof g.createStaticHandler!="function"?()=>o:o,allowMeta:f,inference:this.inference});return this.router.history[k]&&(H=this.router.history[k].composed=x),x},j;if(`${t}_${n}`in this.routeTree)for(let x=0;x<this.router.history.length;x++){let M=this.router.history[x];if(M.path===n&&M.method===t){j=x;break}}else this.routeTree[`${t}_${n}`]=this.router.history.length;let k=j??this.router.history.length,q=this.router.history,se=y?_():(x)=>H?H(x):(q[k].composed=_())(x);j!==void 0?this.router.history[j]=Object.assign({method:t,path:n,composed:se,compile:_,handler:o,hooks:p},u.length?{standaloneValidators:u}:void 0,i.webSocket?{websocket:i.websocket}:void 0):this.router.history.push(Object.assign({method:t,path:n,composed:se,compile:_,handler:o,hooks:p},i.webSocket?{websocket:i.websocket}:void 0));let K={handler:y?q[k].composed:void 0,compile(){return this.handler=_()}},U=this.router.static,D=n.indexOf(":")===-1&&n.indexOf("*")===-1;if(t==="WS"){if(D){n in U?U[n][t]=k:U[n]={[t]:k};return}this.router.http.add("WS",n,K),this.config.strictPath||this.router.http.add("WS",Yn(n),K);let x=Zn(n,{dynamic:!0});n!==x&&this.router.http.add("WS",x,K);return}if(D)n in U?U[n][t]=k:U[n]={[t]:k},this.config.strictPath||J(Yn(n));else{if(this.router.http.add(t,n,K),!this.config.strictPath){let M=Yn(n);J(M),this.router.http.add(t,M,K)}let x=Zn(n,{dynamic:!0});n!==x&&(this.router.http.add(t,x,K),J(x))}}headers(t){return t?(this.setHeaders||(this.setHeaders={}),this.setHeaders=et(this.setHeaders,t),this):this}onStart(t){return this.on("start",t),this}onRequest(t){return this.on("request",t),this}onParse(t,n){return n?this.on(t,"parse",n):typeof t=="string"?this.on("parse",this["~parser"][t]):this.on("parse",t)}parser(t,n){return this["~parser"][t]=n,this}onTransform(t,n){return n?this.on(t,"transform",n):this.on("transform",t)}resolve(t,n){n||(n=t,t={as:"local"});let o={subType:"resolve",fn:n};return this.onBeforeHandle(t,o)}mapResolve(t,n){n||(n=t,t={as:"local"});let o={subType:"mapResolve",fn:n};return this.onBeforeHandle(t,o)}onBeforeHandle(t,n){return n?this.on(t,"beforeHandle",n):this.on("beforeHandle",t)}onAfterHandle(t,n){return n?this.on(t,"afterHandle",n):this.on("afterHandle",t)}mapResponse(t,n){return n?this.on(t,"mapResponse",n):this.on("mapResponse",t)}onAfterResponse(t,n){return n?this.on(t,"afterResponse",n):this.on("afterResponse",t)}trace(t,n){n||(n=t,t={as:"local"}),Array.isArray(n)||(n=[n]);for(let o of n)this.on(t,"trace",bd(o));return this}error(t,n){switch(typeof t){case"string":return n.prototype[Xn]=t,this.definitions.error[t]=n,this;case"function":return this.definitions.error=t(this.definitions.error),this}for(let[o,i]of Object.entries(t))i.prototype[Xn]=o,this.definitions.error[o]=i;return this}onError(t,n){return n?this.on(t,"error",n):this.on("error",t)}onStop(t){return this.on("stop",t),this}on(t,n,o){let i;switch(typeof t){case"string":i=t,o=n;break;case"object":i=n,!Array.isArray(n)&&typeof n=="object"&&(o=n);break}Array.isArray(o)?o=Xe(o):typeof o=="function"?o=[{fn:o}]:o=[o];let s=o;for(let c of s)c.scope=typeof t=="string"?"local":t?.as??"local",(i==="resolve"||i==="derive")&&(c.subType=i);i!=="trace"&&(this.inference=ro({[i]:s.map((c)=>c.fn)},this.inference,this.config.sucrose));for(let c of s){let f=Du(c,"global",{skipIfHasType:!0});switch((this.config.name||this.config.seed)&&(f.checksum=Wr(this.config.name+JSON.stringify(this.config.seed))),i){case"start":this.event.start??=[],this.event.start.push(f);break;case"request":this.event.request??=[],this.event.request.push(f);break;case"parse":this.event.parse??=[],this.event.parse.push(f);break;case"transform":this.event.transform??=[],this.event.transform.push(f);break;case"derive":this.event.transform??=[],this.event.transform.push(Xe(f,"derive"));break;case"beforeHandle":this.event.beforeHandle??=[],this.event.beforeHandle.push(f);break;case"resolve":this.event.beforeHandle??=[],this.event.beforeHandle.push(Xe(f,"resolve"));break;case"afterHandle":this.event.afterHandle??=[],this.event.afterHandle.push(f);break;case"mapResponse":this.event.mapResponse??=[],this.event.mapResponse.push(f);break;case"afterResponse":this.event.afterResponse??=[],this.event.afterResponse.push(f);break;case"trace":this.event.trace??=[],this.event.trace.push(f);break;case"error":this.event.error??=[],this.event.error.push(f);break;case"stop":this.event.stop??=[],this.event.stop.push(f);break}}return this}as(t){return Xr(this.event.parse,t),Xr(this.event.transform,t),Xr(this.event.beforeHandle,t),Xr(this.event.afterHandle,t),Xr(this.event.mapResponse,t),Xr(this.event.afterResponse,t),Xr(this.event.trace,t),Xr(this.event.error,t),t==="scoped"?(this.validator.scoped=vo(this.validator.scoped,this.validator.local),this.validator.local=null,this.standaloneValidator.local!==null&&(this.standaloneValidator.scoped||=[],this.standaloneValidator.scoped.push(...this.standaloneValidator.local),this.standaloneValidator.local=null)):t==="global"&&(this.validator.global=vo(this.validator.global,vo(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null,this.standaloneValidator.local!==null&&(this.standaloneValidator.scoped||=[],this.standaloneValidator.scoped.push(...this.standaloneValidator.local),this.standaloneValidator.local=null),this.standaloneValidator.scoped!==null&&(this.standaloneValidator.global||=[],this.standaloneValidator.global.push(...this.standaloneValidator.scoped),this.standaloneValidator.scoped=null)),this}group(t,n,o){let i=new e({...this.config,prefix:""});i.singleton={...this.singleton},i.definitions={...this.definitions},i.getServer=()=>this.getServer(),i.inference=Ts(this.inference),i.extender={...this.extender},i["~parser"]=this["~parser"],i.standaloneValidator={local:[...this.standaloneValidator.local??[]],scoped:[...this.standaloneValidator.scoped??[]],global:[...this.standaloneValidator.global??[]]};let s=typeof n=="object",c=(s?o:n)(i);return this.singleton=et(this.singleton,i.singleton),this.definitions=et(this.definitions,i.definitions),c.event.request?.length&&(this.event.request=[...this.event.request||[],...c.event.request||[]]),c.event.mapResponse?.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...c.event.mapResponse||[]]),this.model(c.definitions.type),Object.values(i.router.history).forEach(({method:f,path:u,handler:l,hooks:d})=>{if(u=(s?"":this.config.prefix??"")+t+u,s){let{body:y,headers:b,query:p,params:g,cookie:R,response:L,...J}=n,H=d;this.applyMacro(J);let _=y||b||p||g||R||L;this.add(f,u,l,Er(J,{...H||{},error:H.error?Array.isArray(H.error)?[...H.error??[],...c.event.error??[]]:[H.error,...c.event.error??[]]:c.event.error,standaloneValidator:J.standaloneValidator||H.standaloneValidator||_?[...J.standaloneValidator??[],...H.standaloneValidator??[],..._?[{body:y,headers:b,query:p,params:g,cookie:R,response:L}]:[]]:void 0}),void 0)}else this.add(f,u,l,Er(d,{error:c.event.error}),{skipPrefix:!0})}),this}guard(t,n){if(!n){if(typeof t=="object"){this.applyMacro(t),t.detail&&(this.config.detail?this.config.detail=et(Object.assign({},this.config.detail),t.detail):this.config.detail=t.detail),t.tags&&(this.config.detail?this.config.detail.tags=t.tags:this.config.detail={tags:t.tags});let s=t.as??"local";if(t.schema==="standalone"){this.standaloneValidator[s]||(this.standaloneValidator[s]=[]);let c=t?.response?typeof t.response=="string"||I in t.response||"~standard"in t.response?{200:t.response}:t?.response:void 0;this.standaloneValidator[s].push({body:t.body,headers:t.headers,params:t.params,query:t.query,response:c,cookie:t.cookie})}else this.validator[s]={body:t.body??this.validator[s]?.body,headers:t.headers??this.validator[s]?.headers,params:t.params??this.validator[s]?.params,query:t.query??this.validator[s]?.query,response:t.response??this.validator[s]?.response,cookie:t.cookie??this.validator[s]?.cookie};return t.parse&&this.on({as:s},"parse",t.parse),t.transform&&this.on({as:s},"transform",t.transform),t.derive&&this.on({as:s},"derive",t.derive),t.beforeHandle&&this.on({as:s},"beforeHandle",t.beforeHandle),t.resolve&&this.on({as:s},"resolve",t.resolve),t.afterHandle&&this.on({as:s},"afterHandle",t.afterHandle),t.mapResponse&&this.on({as:s},"mapResponse",t.mapResponse),t.afterResponse&&this.on({as:s},"afterResponse",t.afterResponse),t.error&&this.on({as:s},"error",t.error),this}return this.guard({},t)}let o=new e({...this.config,prefix:""});o.singleton={...this.singleton},o.definitions={...this.definitions},o.inference=Ts(this.inference),o.extender={...this.extender},o.getServer=()=>this.getServer();let i=n(o);if(this.singleton=et(this.singleton,o.singleton),this.definitions=et(this.definitions,o.definitions),i.getServer=()=>this.server,i.event.request?.length&&(this.event.request=[...this.event.request||[],...i.event.request||[]]),i.event.mapResponse?.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...i.event.mapResponse||[]]),this.model(i.definitions.type),Object.values(o.router.history).forEach(({method:s,path:c,handler:f,hooks:u})=>{let{body:l,headers:d,query:y,params:b,cookie:p,response:g,...R}=t,L=l||d||y||b||p||g;this.add(s,c,f,Er(R,{...u||{},error:u.error?Array.isArray(u.error)?[...u.error??[],...i.event.error??[]]:[u.error,...i.event.error??[]]:i.event.error,standaloneValidator:L?[...u.standaloneValidator??[],{body:l,headers:d,query:y,params:b,cookie:p,response:g}]:u.standaloneValidator}))}),o.promisedModules.size>0){let s=o.router.history.length;for(let c of o.promisedModules.promises)this.promisedModules.add(c.then(()=>{let{body:f,headers:u,query:l,params:d,cookie:y,response:b,...p}=t,g=f||u||l||d||y||b,R=s;s=o.router.history.length;for(let L=R;L<o.router.history.length;L++){let{method:J,path:H,handler:_,hooks:j}=o.router.history[L];this.add(J,H,_,Er(p,{...j||{},error:j.error?Array.isArray(j.error)?[...j.error??[],...i.event.error??[]]:[j.error,...i.event.error??[]]:i.event.error,standaloneValidator:g?[...j.standaloneValidator??[],{body:f,headers:u,query:l,params:d,cookie:y,response:b}]:j.standaloneValidator}))}}))}return this}use(t){if(!t)return this;if(Array.isArray(t)){let n=this;for(let o of t)n=n.use(o);return n}return t instanceof Promise?(this.promisedModules.add(t.then((n)=>{if(typeof n=="function")return n(this);if(n instanceof e)return this._use(n).compile();if(n.constructor?.name==="Elysia")return this._use(n).compile();if(typeof n.default=="function")return n.default(this);if(n.default instanceof e)return this._use(n.default);if(n.constructor?.name==="Elysia")return this._use(n.default);if(n.constructor?.name==="_Elysia")return this._use(n.default);try{return this._use(n.default)}catch(o){throw console.error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.'),o}}).then((n)=>(n&&typeof n.compile=="function"&&n.compile(),n))),this):this._use(t)}propagatePromiseModules(t){if(t.promisedModules.size<=0)return this;for(let n of t.promisedModules.promises)this.promisedModules.add(n.then((o)=>{if(!o)return;let i=this._use(o);return i instanceof Promise?i.then((s)=>{s?s.compile():o.compile()}):o.compile()}));return this}_use(t){if(typeof t=="function"){let i=t(this);return i instanceof Promise?(this.promisedModules.add(i.then((s)=>{if(s instanceof e){s.getServer=()=>this.getServer(),s.getGlobalRoutes=()=>this.getGlobalRoutes(),s.getGlobalDefinitions=()=>this.getGlobalDefinitions(),s.model(this.definitions.type),s.error(this.definitions.error);for(let{method:c,path:f,handler:u,hooks:l}of Object.values(s.router.history))this.add(c,f,u,l,void 0);return s===this?void 0:(this.propagatePromiseModules(s),s)}return typeof s=="function"?s(this):typeof s.default=="function"?s.default(this):this._use(s)}).then((s)=>(s&&typeof s.compile=="function"&&s.compile(),s))),this):i}this.propagatePromiseModules(t);let n=t.config.name,o=t.config.seed;if(t.getParent=()=>this,t.getServer=()=>this.getServer(),t.getGlobalRoutes=()=>this.getGlobalRoutes(),t.getGlobalDefinitions=()=>this.getGlobalDefinitions(),t.standaloneValidator?.scoped&&(this.standaloneValidator.local?this.standaloneValidator.local=this.standaloneValidator.local.concat(t.standaloneValidator.scoped):this.standaloneValidator.local=t.standaloneValidator.scoped),t.standaloneValidator?.global&&(this.standaloneValidator.global?this.standaloneValidator.global=this.standaloneValidator.global.concat(t.standaloneValidator.global):this.standaloneValidator.global=t.standaloneValidator.global),ue(t["~parser"])&&(this["~parser"]={...t["~parser"],...this["~parser"]}),t.setHeaders&&this.headers(t.setHeaders),n){n in this.dependencies||(this.dependencies[n]=[]);let i=o!==void 0?Wr(n+JSON.stringify(o)):0;this.dependencies[n].some(({checksum:s})=>i===s)||(this.extender.macro={...this.extender.macro,...t.extender.macro},this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(t.extender.higherOrderFunctions))}else ue(t.extender.macro)&&(this.extender.macro={...this.extender.macro,...t.extender.macro}),t.extender.higherOrderFunctions.length&&(this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(t.extender.higherOrderFunctions));if(t.extender.higherOrderFunctions.length){Za(this.extender.higherOrderFunctions);let i=[];for(let s=0;s<this.extender.higherOrderFunctions.length;s++){let c=this.extender.higherOrderFunctions[s];c.checksum&&(i.includes(c.checksum)&&(this.extender.higherOrderFunctions.splice(s,1),s--),i.push(c.checksum))}i.length=0}this.inference=Bs(this.inference,t.inference),ue(t.singleton.decorator)&&this.decorate(t.singleton.decorator),ue(t.singleton.store)&&this.state(t.singleton.store),ue(t.definitions.type)&&this.model(t.definitions.type),ue(t.definitions.error)&&this.error(t.definitions.error),ue(t.extender.macro)&&(this.extender.macro={...this.extender.macro,...t.extender.macro});for(let{method:i,path:s,handler:c,hooks:f}of Object.values(t.router.history))this.add(i,s,c,f);if(n){n in this.dependencies||(this.dependencies[n]=[]);let i=o!==void 0?Wr(n+JSON.stringify(o)):0;if(this.dependencies[n].some(({checksum:s})=>i===s))return this;this.dependencies[n].push(this.config?.analytic?{name:t.config.name,seed:t.config.seed,checksum:i,dependencies:t.dependencies,stack:t.telemetry?.stack,routes:t.router.history,decorators:t.singleton,store:t.singleton.store,error:t.definitions.error,derive:t.event.transform?.filter((s)=>s?.subType==="derive").map((s)=>({fn:s.toString(),stack:Error().stack??""})),resolve:t.event.transform?.filter((s)=>s?.subType==="resolve").map((s)=>({fn:s.toString(),stack:Error().stack??""}))}:{name:t.config.name,seed:t.config.seed,checksum:i,dependencies:t.dependencies}),ue(t.event)&&(this.event=_a(this.event,Ga(t.event),i))}else ue(t.event)&&(this.event=_a(this.event,Ga(t.event)));return t.validator.global&&(this.validator.global=Er(this.validator.global,{...t.validator.global})),t.validator.scoped&&(this.validator.local=Er(this.validator.local,{...t.validator.scoped})),this}macro(t,n){if(typeof t=="string"&&!n)throw Error("Macro function is required");return typeof t=="string"?this.extender.macro[t]=n:this.extender.macro={...this.extender.macro,...t},this}applyMacro(t,n=t,{iteration:o=0,applied:i={}}={}){if(o>=16)return;let s=this.extender.macro;for(let[c,f]of Object.entries(n)){if(!(c in s))continue;let u=typeof s[c]=="function"?s[c](f):s[c];if(!u||typeof s[c]=="object"&&f===!1)return;let l=Wr(c+JSON.stringify(u.seed??f));if(!(l in i)){i[l]=!0;for(let[d,y]of Object.entries(u))if(d!=="seed"){if(d in Hu){Bu(t,d,y),delete t[c];continue}if(d==="introspect"){y?.(t),delete t[c];continue}if(d==="detail"){t.detail||(t.detail={}),t.detail=et(t.detail,y,{mergeArray:!0}),delete t[c];continue}if(d in s){this.applyMacro(t,{[d]:y},{applied:i,iteration:o+1}),delete t[c];continue}switch((d==="derive"||d==="resolve")&&typeof y=="function"&&(y={fn:y,subType:d}),typeof t[d]){case"function":t[d]=[t[d],y];break;case"object":Array.isArray(t[d])?t[d].push(y):t[d]=[t[d],y];break;case"undefined":t[d]=y;break}delete t[c]}}}}mount(t,n,o){if(t instanceof e||typeof t=="function"||t.length===0||t==="/"){let f=typeof t=="function"?t:t instanceof e?t.compile().fetch:n instanceof e?n.compile().fetch:typeof n=="function"?n:(()=>{throw Error("Invalid handler")})(),u=({request:l,path:d})=>f(new Request(Ss(l.url,d),l));return this.route("ALL","/*",u,{parse:"none",...o,detail:{...o?.detail,hide:!0},config:{mount:f}}),this}let i=n instanceof e?n.compile().fetch:typeof n=="function"?n:(()=>{throw Error("Invalid handler")})(),s=(typeof t=="string"&&this.config.prefix?this.config.prefix+t:t).length-(t.endsWith("*")?1:0),c=({request:f,path:u})=>i(new Request(Ss(f.url,u.slice(s)||"/"),f));return this.route("ALL",t,c,{parse:"none",...o,detail:{...o?.detail,hide:!0},config:{mount:i}}),this.route("ALL",t+(t.endsWith("/")?"*":"/*"),c,{parse:"none",...o,detail:{...o?.detail,hide:!0},config:{mount:i}}),this}get(t,n,o){return this.add("GET",t,n,o),this}post(t,n,o){return this.add("POST",t,n,o),this}put(t,n,o){return this.add("PUT",t,n,o),this}patch(t,n,o){return this.add("PATCH",t,n,o),this}delete(t,n,o){return this.add("DELETE",t,n,o),this}options(t,n,o){return this.add("OPTIONS",t,n,o),this}all(t,n,o){return this.add("ALL",t,n,o),this}head(t,n,o){return this.add("HEAD",t,n,o),this}connect(t,n,o){return this.add("CONNECT",t,n,o),this}route(t,n,o,i){return this.add(t.toUpperCase(),n,o,i,i?.config),this}ws(t,n){return this["~adapter"].ws?this["~adapter"].ws(this,t,n):console.warn("Current adapter doesn't support WebSocket"),this}state(t,n,o){n===void 0?(o=t,t={as:"append"},n=""):o===void 0&&(typeof t=="string"?(o=n,n=t,t={as:"append"}):typeof t=="object"&&(o=n,n=""));let{as:i}=t;if(typeof n!="string")return this;switch(typeof o){case"object":return!o||!ue(o)?this:n?((n in this.singleton.store)?this.singleton.store[n]=et(this.singleton.store[n],o,{override:i==="override"}):this.singleton.store[n]=o,this):o===null?this:(this.singleton.store=et(this.singleton.store,o,{override:i==="override"}),this);case"function":return n?(i==="override"||!(n in this.singleton.store))&&(this.singleton.store[n]=o):this.singleton.store=o(this.singleton.store),this;default:return(i==="override"||!(n in this.singleton.store))&&(this.singleton.store[n]=o),this}}decorate(t,n,o){n===void 0?(o=t,t={as:"append"},n=""):o===void 0&&(typeof t=="string"?(o=n,n=t,t={as:"append"}):typeof t=="object"&&(o=n,n=""));let{as:i}=t;if(typeof n!="string")return this;switch(typeof o){case"object":return n?((n in this.singleton.decorator)?this.singleton.decorator[n]=et(this.singleton.decorator[n],o,{override:i==="override"}):this.singleton.decorator[n]=o,this):o===null?this:(this.singleton.decorator=et(this.singleton.decorator,o,{override:i==="override"}),this);case"function":return n?(i==="override"||!(n in this.singleton.decorator))&&(this.singleton.decorator[n]=o):this.singleton.decorator=o(this.singleton.decorator),this;default:return(i==="override"||!(n in this.singleton.decorator))&&(this.singleton.decorator[n]=o),this}}derive(t,n){n||(n=t,t={as:"local"});let o={subType:"derive",fn:n};return this.onTransform(t,o)}model(t,n){let o=(i)=>{let s={};for(let c in i)"~standard"in i[c]||(s[c]=i[c]);return s};switch(typeof t){case"object":let i={},s=Object.entries(t);if(!s.length)return this;for(let[u,l]of s)u in this.definitions.type||("~standard"in l?this.definitions.type[u]=l:(i[u]=this.definitions.type[u]=l,i[u].$id??=`#/components/schemas/${u}`));return this.definitions.typebox=r.Module({...this.definitions.typebox.$defs,...i}),this;case"function":let c=t(this.definitions.type);return this.definitions.type=c,this.definitions.typebox=r.Module(o(c)),this;case"string":if(!n)break;if(this.definitions.type[t]=n,"~standard"in n)return this;let f={...n,id:n.$id??`#/components/schemas/${t}`};return this.definitions.typebox=r.Module({...this.definitions.typebox.$defs,...f}),this}return n?(this.definitions.type[t]=n,("~standard"in n)?this:(this.definitions.typebox=r.Module({...this.definitions.typebox.$defs,[t]:n}),this)):this}Ref(t){return r.Ref(t)}mapDerive(t,n){n||(n=t,t={as:"local"});let o={subType:"mapDerive",fn:n};return this.onTransform(t,o)}affix(t,n,o){if(o==="")return this;let i=["_","-"," "],s=(l)=>l[0].toUpperCase()+l.slice(1),c=t==="prefix"?(l,d)=>i.includes(l.at(-1)??"")?l+d:l+s(d):i.includes(o.at(-1)??"")?(l,d)=>d+l:(l,d)=>d+s(l),f=(l)=>{let d={};switch(l){case"decorator":for(let y in this.singleton.decorator)d[c(o,y)]=this.singleton.decorator[y];this.singleton.decorator=d;break;case"state":for(let y in this.singleton.store)d[c(o,y)]=this.singleton.store[y];this.singleton.store=d;break;case"model":for(let y in this.definitions.type)d[c(o,y)]=this.definitions.type[y];this.definitions.type=d;break;case"error":for(let y in this.definitions.error)d[c(o,y)]=this.definitions.error[y];this.definitions.error=d;break}},u=Array.isArray(n)?n:[n];for(let l of u.some((d)=>d==="all")?["decorator","state","model","error"]:u)f(l);return this}prefix(t,n){return this.affix("prefix",t,n)}suffix(t,n){return this.affix("suffix",t,n)}compile(){return this["~adapter"].beforeCompile?.(this),this["~adapter"].isWebStandard?(this._handle=this.config.aot?ea(this):Ic(this),Object.defineProperty(this,"fetch",{value:this._handle,configurable:!0,writable:!0}),typeof this.server?.reload=="function"&&this.server.reload({...this.server||{},fetch:this.fetch}),this):(typeof this.server?.reload=="function"&&this.server.reload(this.server||{}),this._handle=ea(this),this)}get fetch(){let t=this.config.aot?ea(this):Ic(this);return Object.defineProperty(this,"fetch",{value:t,configurable:!0,writable:!0}),t}get modules(){return this.promisedModules}},E=cI;
408
+ export{r,E};