Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elysia

Package Overview
Dependencies
Maintainers
1
Versions
429
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elysia - npm Package Compare versions

Comparing version 1.2.0-exp.0 to 1.2.0-exp.1

27

dist/cjs/cookies.js

@@ -1,26 +0,1 @@

"use strict";var Z=Object.create;var E=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var n in t)E(e,n,{get:t[n],enumerable:!0})},D=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of X(t))!te.call(e,o)&&o!==n&&E(e,o,{get:()=>t[o],enumerable:!(r=Q(t,o))||r.enumerable});return e};var re=(e,t,n)=>(n=e!=null?Z(ee(e)):{},D(t||!e||!e.__esModule?E(n,"default",{value:e,enumerable:!0}):n,e)),ae=e=>D(E({},"__esModule",{value:!0}),e);var Pe={};ne(Pe,{Cookie:()=>O,createCookieJar:()=>H,parseCookie:()=>He});module.exports=ae(Pe);var q=require("cookie"),W=re(require("fast-decode-uri-component"));var G=require("@sinclair/typebox"),Ce=require("@sinclair/typebox/value"),we=require("@sinclair/typebox/compiler");var T=require("@sinclair/typebox"),R=require("@sinclair/typebox/system"),c=require("@sinclair/typebox"),j=require("@sinclair/typebox/compiler"),y=require("@sinclair/typebox/value");var x={date:I,time:w(!0),"date-time":_(!0),"iso-time":w(!1),"iso-date-time":_(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:le,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(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(([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:Re,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:pe,int32:{type:"number",validate:he},int64:{type:"number",validate:ge},float:{type:"number",validate:B},double:{type:"number",validate:B},password:!0,binary:!0};function oe(e){return e%4===0&&(e%100!==0||e%400===0)}var ie=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,se=[0,31,28,31,30,31,30,31,31,30,31,30,31];function I(e){let t=ie.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],o=+t[3];return r>=1&&r<=12&&o>=1&&o<=(r===2&&oe(n)?29:se[r])}var ce=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function w(e){return function(n){let r=ce.exec(n);if(!r)return!1;let o=+r[1],a=+r[2],f=+r[3],g=r[4],u=r[5]==="-"?-1:1,m=+(r[6]||0),d=+(r[7]||0);if(m>23||d>59||e&&!g)return!1;if(o<=23&&a<=59&&f<60)return!0;let l=a-d*u,p=o-m*u-(l<0?1:0);return(p===23||p===-1)&&(l===59||l===-1)&&f<61}}var fe=/t|\s/i;function _(e){let t=w(e);return function(r){let o=r.split(fe);return o.length===2&&I(o[0])&&t(o[1])}}var ue=/\/|:/,de=/^(?:[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 le(e){return ue.test(e)&&de.test(e)}var M=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function pe(e){return M.lastIndex=0,M.test(e)}var ye=-(2**31),me=2**31-1;function he(e){return Number.isInteger(e)&&e<=me&&e>=ye}function ge(e){return Number.isInteger(e)}function B(){return!0}var be=/[^\\]\\Z/;function Re(e){if(be.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var S=require("@sinclair/typebox/value");var z=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,Be=Symbol("ElysiaErrorCode"),$=Symbol("ElysiaResponse"),L=(z?.NODE_ENV??z?.ENV)==="production";var k=class extends Error{constructor(n,r){super(r??`"${n}" has invalid cookie signature`);this.key=n;this.code="INVALID_COOKIE_SIGNATURE";this.status=400}},b=e=>{if(!e)return{summary:void 0};let{message:t,path:n,value:r,type:o}=e,a=n.slice(1).replaceAll("/","."),f=n==="";switch(o){case 42:return{...e,summary:f?"Value should not be provided":`Property '${a}' should not be provided`};case 45:return{...e,summary:f?"Value is missing":`Property '${a}' is missing`};case 50:let g=t.indexOf("'"),u=t.slice(g+1,t.indexOf("'",g+1));return{...e,summary:f?"Value should be an email":`Property '${a}' should be ${u}`};case 54:return{...e,summary:`${t.slice(0,9)} property '${a}' to be ${t.slice(8)} but found: ${r}`};case 62:let m=e.schema.anyOf.map(d=>`'${d?.format??d.type}'`).join(", ");return{...e,summary:f?`Value should be one of ${m}`:`Property '${a}' should be one of: ${m}`};default:return{summary:t,...e}}},s=class e extends Error{constructor(n,r,o){o&&typeof o=="object"&&$ in o&&(o=o.response);let a=L?void 0:"Errors"in r?r.Errors(o).First():S.Value.Errors(r,o).First(),f=a?.schema.error!==void 0?typeof a.schema.error=="function"?a.schema.error({type:n,validator:r,value:o,get errors(){return[...r.Errors(o)].map(b)}}):a.schema.error:void 0,g=a?.path||"root",u="";if(f!==void 0)u=typeof f=="object"?JSON.stringify(f):f+"";else if(L)u=JSON.stringify({type:"validation",on:n,summary:b(a).summary,message:a?.message,found:o});else{let m=r?.schema??r,d="Errors"in r?[...r.Errors(o)].map(b):[...S.Value.Errors(r,o)].map(b),l;try{l=S.Value.Create(m)}catch(p){l={type:"Could not create expected value",message:p?.message,error:p}}u=JSON.stringify({type:"validation",on:n,summary:d[0]?.summary,property:g,message:a?.message,expected:l,found:o,errors:d},null,2)}super(u);this.type=n;this.validator=r;this.value=o;this.code="VALIDATION";this.status=422;Object.setPrototypeOf(this,e.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(b):[...S.Value.Errors(this.validator,this.value)].map(b)}static simplifyModel(n){let r="schema"in n?n.schema:n;try{return S.Value.Create(r)}catch{return r}}get model(){return e.simplifyModel(this.validator)}toResponse(n){return new Response(this.message,{status:400,headers:{...n,"content-type":"application/json"}})}};var C=require("@sinclair/typebox/system"),K=require("@sinclair/typebox/compiler"),U=/(\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))/,V=/(?: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\([^)]+\)/,J=/^(?:(?:(?:(?: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)?)?$/,Te=x.date,Oe=x["date-time"];c.FormatRegistry.Has("date")||R.TypeSystem.Format("date",e=>{let t=e.replace(/"/g,"");if(U.test(t)||V.test(t)||J.test(t)||Te(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});c.FormatRegistry.Has("date-time")||R.TypeSystem.Format("date-time",e=>{let t=e.replace(/"/g,"");if(U.test(t)||V.test(t)||J.test(t)||Oe(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});Object.entries(x).forEach(e=>{let[t,n]=e;c.FormatRegistry.Has(t)||(n instanceof RegExp?R.TypeSystem.Format(t,r=>n.test(r)):typeof n=="function"&&R.TypeSystem.Format(t,n))});var i=Object.assign({},c.Type),v=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},F=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<v(e.minSize)||e.maxSize&&t.size>v(e.maxSize))return!1;if(e.extension)if(typeof e.extension=="string"){if(!t.type.startsWith(e.extension))return!1}else{for(let n=0;n<e.extension.length;n++)if(t.type.startsWith(e.extension[n]))return!0;return!1}return!0},ke=T.TypeRegistry.Get("Files")??R.TypeSystem.Type("File",F),Ee=T.TypeRegistry.Get("Files")??R.TypeSystem.Type("Files",(e,t)=>{if(!Array.isArray(t))return F(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(!F(e,t[n]))return!1;return!0});c.FormatRegistry.Has("numeric")||c.FormatRegistry.Set("numeric",e=>!!e&&!isNaN(+e));c.FormatRegistry.Has("boolean")||c.FormatRegistry.Set("boolean",e=>e==="true"||e==="false");c.FormatRegistry.Has("ObjectString")||c.FormatRegistry.Set("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}});c.FormatRegistry.Has("ArrayString")||c.FormatRegistry.Set("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}});T.TypeRegistry.Set("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t));var h={Numeric:e=>{let t=c.Type.Number(e);return i.Transform(i.Union([i.String({format:"numeric",default:0}),i.Number(e)],e)).Decode(n=>{let r=+n;if(isNaN(r))return n;if(e&&!y.Value.Check(t,r))throw new s("property",t,r);return r}).Encode(n=>n)},Date:e=>{let t=c.Type.Date(e);return i.Transform(i.Union([c.Type.Date(e),i.String({format:"date",default:new Date().toISOString()}),i.String({format:"date-time",default:new Date().toISOString()})],e)).Decode(n=>{if(n instanceof Date)return n;let r=new Date(n);if(!y.Value.Check(t,r))throw new s("property",t,r);return r}).Encode(n=>typeof n=="string"?new Date(n):n)},BooleanString:e=>{let t=c.Type.Boolean(e);return i.Transform(i.Union([i.String({format:"boolean",default:!1}),i.Boolean(e)],e)).Decode(n=>{if(typeof n=="string")return n==="true";if(e&&!y.Value.Check(t,n))throw new s("property",t,n);return n}).Encode(n=>n)},ObjectString:(e,t)=>{let n=i.Object(e,t),r=JSON.stringify(y.Value.Create(n)),o;try{o=j.TypeCompiler.Compile(n)}catch{}return i.Transform(i.Union([i.String({format:"ObjectString",default:r}),n])).Decode(a=>{if(typeof a=="string"){if(a.charCodeAt(0)!==123)throw new s("property",n,a);try{a=JSON.parse(a)}catch{throw new s("property",n,a)}if(o){if(!o.Check(a))throw new s("property",n,a);return o.Decode(a)}if(!y.Value.Check(n,a))throw new s("property",n,a);return y.Value.Decode(n,a)}return a}).Encode(a=>{if(typeof a=="string")try{a=JSON.parse(a)}catch{throw new s("property",n,a)}if(!y.Value.Check(n,a))throw new s("property",n,a);return JSON.stringify(a)})},ArrayString:(e={},t)=>{let n=i.Array(e,t),r=JSON.stringify(y.Value.Create(n)),o;try{o=j.TypeCompiler.Compile(n)}catch{}return i.Transform(i.Union([i.String({format:"ArrayString",default:r}),n])).Decode(a=>{if(typeof a=="string"){if(a.charCodeAt(0)!==91)throw new s("property",n,a);try{a=JSON.parse(a)}catch{throw new s("property",n,a)}if(o){if(!o.Check(a))throw new s("property",n,a);return o.Decode(a)}if(!y.Value.Check(n,a))throw new s("property",n,a);return y.Value.Decode(n,a)}return a}).Encode(a=>{if(typeof a=="string")try{a=JSON.parse(a)}catch{throw new s("property",n,a)}if(!y.Value.Check(n,a))throw new s("property",n,a);return JSON.stringify(a)})},File:ke,Files:(e={})=>i.Transform(Ee(e)).Decode(t=>Array.isArray(t)?t:[t]).Encode(t=>t),Nullable:e=>i.Union([e,i.Null()]),MaybeEmpty:e=>i.Union([e,i.Null(),i.Undefined()]),Cookie:(e,{domain:t,expires:n,httpOnly:r,maxAge:o,path:a,priority:f,sameSite:g,secure:u,secrets:m,sign:d,...l}={})=>{let p=i.Object(e,l);return p.config={domain:t,expires:n,httpOnly:r,maxAge:o,path:a,priority:f,sameSite:g,secure:u,secrets:m,sign:d},p},UnionEnum:(e,t={})=>{let n=e.every(r=>typeof r=="string")?{type:"string"}:e.every(r=>typeof r=="number")?{type:"number"}:e.every(r=>r===null)?{type:"null"}:{};if(e.some(r=>typeof r=="object"&&r!==null))throw new Error("This type does not support objects or arrays");return{default:e[0],...t,[T.Kind]:"UnionEnum",...n,enum:e}}};i.BooleanString=h.BooleanString;i.ObjectString=h.ObjectString;i.ArrayString=h.ArrayString;i.Numeric=h.Numeric;i.File=(e={})=>h.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"});i.Files=(e={})=>h.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});i.Nullable=e=>h.Nullable(e);i.MaybeEmpty=h.MaybeEmpty;i.Cookie=h.Cookie;i.Date=h.Date;i.UnionEnum=h.UnionEnum;var xe=require("cookie");var nt="toJSON"in new Headers;var Ae=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],ut=Ae.reduce((e,t)=>(e[t]=!0,e),{});var je=typeof Bun<"u",dt=je&&typeof Bun.hash=="function";var A={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},Se=Object.fromEntries(Object.entries(A).map(([e,t])=>[t,e]));function Fe(e){let t=e;for(;t.endsWith("=");)t=t.slice(0,-1);return t}var Y=new TextEncoder,Ne=async(e,t)=>{if(typeof e!="string")throw new TypeError("Cookie value must be provided as a string.");if(t===null)throw new TypeError("Secret key must be provided.");let n=await crypto.subtle.importKey("raw",Y.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,Y.encode(e));return e+"."+Fe(Buffer.from(r).toString("base64"))},N=async(e,t)=>{if(typeof e!="string")throw new TypeError("Signed cookie string must be provided.");if(t===null)throw new TypeError("Secret key must be provided.");let n=e.slice(0,e.lastIndexOf("."));return await Ne(n,t)===e?n:!1};var lt=Symbol("ElysiaFormData"),pt=Symbol("ElysiaRequestId");var O=class{constructor(t,n,r={}){this.name=t;this.jar=n;this.initial=r}get cookie(){return this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]}set cookie(t){this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]=t}get value(){return this.cookie.value}set value(t){this.cookie.value=t}get expires(){return this.cookie.expires}set expires(t){this.cookie.expires=t,console.log(this.cookie)}get maxAge(){return this.cookie.maxAge}set maxAge(t){this.cookie.maxAge=t}get domain(){return this.cookie.domain}set domain(t){this.cookie.domain=t}get path(){return this.cookie.path}set path(t){this.cookie.path=t}get secure(){return this.cookie.secure}set secure(t){this.cookie.secure=t}get httpOnly(){return this.cookie.httpOnly}set httpOnly(t){this.cookie.httpOnly=t}get sameSite(){return this.cookie.sameSite}set sameSite(t){this.cookie.sameSite=t}get priority(){return this.cookie.priority}set priority(t){this.cookie.priority=t}get partitioned(){return this.cookie.partitioned}set partitioned(t){this.cookie.partitioned=t}get secrets(){return this.cookie.secrets}set secrets(t){this.cookie.secrets=t}update(t){return this.cookie=Object.assign(this.cookie,typeof t=="function"?t(this.cookie):t),this}set(t){return this.cookie=Object.assign({...this.initial,value:this.value},typeof t=="function"?t(this.cookie):t),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()??""}},H=(e,t,n)=>(e.cookie||(e.cookie={}),new Proxy(t,{get(r,o){return o in t?new O(o,e.cookie,Object.assign({},n??{},t[o])):new O(o,e.cookie,Object.assign({},n))}})),He=async(e,t,{secrets:n,sign:r,...o}={})=>{if(!t)return H(e,{},o);let a=typeof n=="string";r&&r!==!0&&!Array.isArray(r)&&(r=[r]);let f={},g=(0,q.parse)(t);for(let[u,m]of Object.entries(g)){let d=(0,W.default)(m);if(r===!0||r?.includes(u)){if(!n)throw new Error("No secret is provided to cookie plugin");if(a){let l=await N(d,n);if(l===!1)throw new k(u);d=l}else{let l=!0;for(let p=0;p<n.length;p++){let P=await N(d,n[p]);if(P!==!1){l=!0,d=P;break}}if(!l)throw new k(u)}}f[u]={value:d}}return H(e,f,o)};0&&(module.exports={Cookie,createCookieJar,parseCookie});
/**
* @license
*
* MIT License
*
* Copyright (c) 2020 Evgeny Poberezkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
"use strict";var w=Object.create;var c=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var i in e)c(t,i,{get:e[i],enumerable:!0})},g=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of O(e))!b.call(t,o)&&o!==i&&c(t,o,{get:()=>e[o],enumerable:!(r=j(e,o))||r.enumerable});return t};var A=(t,e,i)=>(i=t!=null?w(E(t)):{},g(e||!t||!t.__esModule?c(i,"default",{value:t,enumerable:!0}):i,t)),R=t=>g(c({},"__esModule",{value:!0}),t);var P={};S(P,{Cookie:()=>l,createCookieJar:()=>k,parseCookie:()=>T});module.exports=R(P);var f=require("cookie"),y=A(require("fast-decode-uri-component")),h=require("./utils"),p=require("./error");class l{constructor(e,i,r={}){this.name=e;this.jar=i;this.initial=r}get cookie(){return this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]}set cookie(e){this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]=e}get value(){return this.cookie.value}set value(e){this.cookie.value=e}get expires(){return this.cookie.expires}set expires(e){this.cookie.expires=e,console.log(this.cookie)}get maxAge(){return this.cookie.maxAge}set maxAge(e){this.cookie.maxAge=e}get domain(){return this.cookie.domain}set domain(e){this.cookie.domain=e}get path(){return this.cookie.path}set path(e){this.cookie.path=e}get secure(){return this.cookie.secure}set secure(e){this.cookie.secure=e}get httpOnly(){return this.cookie.httpOnly}set httpOnly(e){this.cookie.httpOnly=e}get sameSite(){return this.cookie.sameSite}set sameSite(e){this.cookie.sameSite=e}get priority(){return this.cookie.priority}set priority(e){this.cookie.priority=e}get partitioned(){return this.cookie.partitioned}set partitioned(e){this.cookie.partitioned=e}get secrets(){return this.cookie.secrets}set secrets(e){this.cookie.secrets=e}update(e){return this.cookie=Object.assign(this.cookie,typeof e=="function"?e(this.cookie):e),this}set(e){return this.cookie=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()??""}}const k=(t,e,i)=>(t.cookie||(t.cookie={}),new Proxy(e,{get(r,o){return o in e?new l(o,t.cookie,Object.assign({},i??{},e[o])):new l(o,t.cookie,Object.assign({},i))}})),T=async(t,e,{secrets:i,sign:r,...o}={})=>{if(!e)return k(t,{},o);const C=typeof i=="string";r&&r!==!0&&!Array.isArray(r)&&(r=[r]);const d={},x=(0,f.parse)(e);for(const[a,v]of Object.entries(x)){let s=(0,y.default)(v);if(r===!0||r?.includes(a)){if(!i)throw new Error("No secret is provided to cookie plugin");if(C){const n=await(0,h.unsignCookie)(s,i);if(n===!1)throw new p.InvalidCookieSignature(a);s=n}else{let n=!0;for(let u=0;u<i.length;u++){const m=await(0,h.unsignCookie)(s,i[u]);if(m!==!1){n=!0,s=m;break}}if(!n)throw new p.InvalidCookieSignature(a)}}d[a]={value:s}}return k(t,d,o)};0&&(module.exports={Cookie,createCookieJar,parseCookie});

@@ -1,26 +0,1 @@

"use strict";var Ce=Object.create;var J=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var Ne=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},te=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of je(t))!He.call(e,o)&&o!==n&&J(e,o,{get:()=>t[o],enumerable:!(r=Ae(t,o))||r.enumerable});return e};var ne=(e,t,n)=>(n=e!=null?Ce(Fe(e)):{},te(t||!e||!e.__esModule?J(n,"default",{value:e,enumerable:!0}):n,e)),Pe=e=>te(J({},"__esModule",{value:!0}),e);var it={};Ne(it,{createDynamicErrorHandler:()=>st,createDynamicHandler:()=>ot});module.exports=Pe(it);var ke=require("cookie");var me=require("@sinclair/typebox"),et=require("@sinclair/typebox/value"),tt=require("@sinclair/typebox/compiler");var M=require("@sinclair/typebox"),_=require("@sinclair/typebox/system"),S=require("@sinclair/typebox"),Q=require("@sinclair/typebox/compiler"),E=require("@sinclair/typebox/value");var K={date:se,time:W(!0),"date-time":re(!0),"iso-time":W(!1),"iso-date-time":re(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ze,"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,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a-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:Ge,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:$e,int32:{type:"number",validate:Je},int64:{type:"number",validate:Ke},float:{type:"number",validate:oe},double:{type:"number",validate:oe},password:!0,binary:!0};function De(e){return e%4===0&&(e%100!==0||e%400===0)}var _e=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,ve=[0,31,28,31,30,31,30,31,31,30,31,30,31];function se(e){let t=_e.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],o=+t[3];return r>=1&&r<=12&&o>=1&&o<=(r===2&&De(n)?29:ve[r])}var Be=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function W(e){return function(n){let r=Be.exec(n);if(!r)return!1;let o=+r[1],a=+r[2],s=+r[3],i=r[4],f=r[5]==="-"?-1:1,b=+(r[6]||0),m=+(r[7]||0);if(b>23||m>59||e&&!i)return!1;if(o<=23&&a<=59&&s<60)return!0;let c=a-m*f,R=o-b*f-(c<0?1:0);return(R===23||R===-1)&&(c===59||c===-1)&&s<61}}var Me=/t|\s/i;function re(e){let t=W(e);return function(r){let o=r.split(Me);return o.length===2&&se(o[0])&&t(o[1])}}var Ie=/\/|:/,Le=/^(?:[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 ze(e){return Ie.test(e)&&Le.test(e)}var ae=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function $e(e){return ae.lastIndex=0,ae.test(e)}var Ve=-(2**31),Ue=2**31-1;function Je(e){return Number.isInteger(e)&&e<=Ue&&e>=Ve}function Ke(e){return Number.isInteger(e)}function oe(){return!0}var Ye=/[^\\]\\Z/;function Ge(e){if(Ye.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var B=require("@sinclair/typebox/value");var ie=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,dt=Symbol("ElysiaErrorCode"),A=Symbol("ElysiaResponse"),ce=(ie?.NODE_ENV??ie?.ENV)==="production";var Y=class extends Error{constructor(n){super(n??"NOT_FOUND");this.code="NOT_FOUND";this.status=404}};var $=class extends Error{constructor(n,r){super(r??`"${n}" has invalid cookie signature`);this.key=n;this.code="INVALID_COOKIE_SIGNATURE";this.status=400}},P=e=>{if(!e)return{summary:void 0};let{message:t,path:n,value:r,type:o}=e,a=n.slice(1).replaceAll("/","."),s=n==="";switch(o){case 42:return{...e,summary:s?"Value should not be provided":`Property '${a}' should not be provided`};case 45:return{...e,summary:s?"Value is missing":`Property '${a}' is missing`};case 50:let i=t.indexOf("'"),f=t.slice(i+1,t.indexOf("'",i+1));return{...e,summary:s?"Value should be an email":`Property '${a}' should be ${f}`};case 54:return{...e,summary:`${t.slice(0,9)} property '${a}' to be ${t.slice(8)} but found: ${r}`};case 62:let b=e.schema.anyOf.map(m=>`'${m?.format??m.type}'`).join(", ");return{...e,summary:s?`Value should be one of ${b}`:`Property '${a}' should be one of: ${b}`};default:return{summary:t,...e}}},h=class e extends Error{constructor(n,r,o){o&&typeof o=="object"&&A in o&&(o=o.response);let a=ce?void 0:"Errors"in r?r.Errors(o).First():B.Value.Errors(r,o).First(),s=a?.schema.error!==void 0?typeof a.schema.error=="function"?a.schema.error({type:n,validator:r,value:o,get errors(){return[...r.Errors(o)].map(P)}}):a.schema.error:void 0,i=a?.path||"root",f="";if(s!==void 0)f=typeof s=="object"?JSON.stringify(s):s+"";else if(ce)f=JSON.stringify({type:"validation",on:n,summary:P(a).summary,message:a?.message,found:o});else{let b=r?.schema??r,m="Errors"in r?[...r.Errors(o)].map(P):[...B.Value.Errors(r,o)].map(P),c;try{c=B.Value.Create(b)}catch(R){c={type:"Could not create expected value",message:R?.message,error:R}}f=JSON.stringify({type:"validation",on:n,summary:m[0]?.summary,property:i,message:a?.message,expected:c,found:o,errors:m},null,2)}super(f);this.type=n;this.validator=r;this.value=o;this.code="VALIDATION";this.status=422;Object.setPrototypeOf(this,e.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(P):[...B.Value.Errors(this.validator,this.value)].map(P)}static simplifyModel(n){let r="schema"in n?n.schema:n;try{return B.Value.Create(r)}catch{return r}}get model(){return e.simplifyModel(this.validator)}toResponse(n){return new Response(this.message,{status:400,headers:{...n,"content-type":"application/json"}})}};var G=require("@sinclair/typebox/system"),pe=require("@sinclair/typebox/compiler"),ue=/(\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))/,de=/(?: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\([^)]+\)/,le=/^(?:(?:(?:(?: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)?)?$/,We=K.date,Qe=K["date-time"];S.FormatRegistry.Has("date")||_.TypeSystem.Format("date",e=>{let t=e.replace(/"/g,"");if(ue.test(t)||de.test(t)||le.test(t)||We(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});S.FormatRegistry.Has("date-time")||_.TypeSystem.Format("date-time",e=>{let t=e.replace(/"/g,"");if(ue.test(t)||de.test(t)||le.test(t)||Qe(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});Object.entries(K).forEach(e=>{let[t,n]=e;S.FormatRegistry.Has(t)||(n instanceof RegExp?_.TypeSystem.Format(t,r=>n.test(r)):typeof n=="function"&&_.TypeSystem.Format(t,n))});var p=Object.assign({},S.Type),fe=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},Z=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<fe(e.minSize)||e.maxSize&&t.size>fe(e.maxSize))return!1;if(e.extension)if(typeof e.extension=="string"){if(!t.type.startsWith(e.extension))return!1}else{for(let n=0;n<e.extension.length;n++)if(t.type.startsWith(e.extension[n]))return!0;return!1}return!0},Ze=M.TypeRegistry.Get("Files")??_.TypeSystem.Type("File",Z),Xe=M.TypeRegistry.Get("Files")??_.TypeSystem.Type("Files",(e,t)=>{if(!Array.isArray(t))return Z(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(!Z(e,t[n]))return!1;return!0});S.FormatRegistry.Has("numeric")||S.FormatRegistry.Set("numeric",e=>!!e&&!isNaN(+e));S.FormatRegistry.Has("boolean")||S.FormatRegistry.Set("boolean",e=>e==="true"||e==="false");S.FormatRegistry.Has("ObjectString")||S.FormatRegistry.Set("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}});S.FormatRegistry.Has("ArrayString")||S.FormatRegistry.Set("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}});M.TypeRegistry.Set("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t));var C={Numeric:e=>{let t=S.Type.Number(e);return p.Transform(p.Union([p.String({format:"numeric",default:0}),p.Number(e)],e)).Decode(n=>{let r=+n;if(isNaN(r))return n;if(e&&!E.Value.Check(t,r))throw new h("property",t,r);return r}).Encode(n=>n)},Date:e=>{let t=S.Type.Date(e);return p.Transform(p.Union([S.Type.Date(e),p.String({format:"date",default:new Date().toISOString()}),p.String({format:"date-time",default:new Date().toISOString()})],e)).Decode(n=>{if(n instanceof Date)return n;let r=new Date(n);if(!E.Value.Check(t,r))throw new h("property",t,r);return r}).Encode(n=>typeof n=="string"?new Date(n):n)},BooleanString:e=>{let t=S.Type.Boolean(e);return p.Transform(p.Union([p.String({format:"boolean",default:!1}),p.Boolean(e)],e)).Decode(n=>{if(typeof n=="string")return n==="true";if(e&&!E.Value.Check(t,n))throw new h("property",t,n);return n}).Encode(n=>n)},ObjectString:(e,t)=>{let n=p.Object(e,t),r=JSON.stringify(E.Value.Create(n)),o;try{o=Q.TypeCompiler.Compile(n)}catch{}return p.Transform(p.Union([p.String({format:"ObjectString",default:r}),n])).Decode(a=>{if(typeof a=="string"){if(a.charCodeAt(0)!==123)throw new h("property",n,a);try{a=JSON.parse(a)}catch{throw new h("property",n,a)}if(o){if(!o.Check(a))throw new h("property",n,a);return o.Decode(a)}if(!E.Value.Check(n,a))throw new h("property",n,a);return E.Value.Decode(n,a)}return a}).Encode(a=>{if(typeof a=="string")try{a=JSON.parse(a)}catch{throw new h("property",n,a)}if(!E.Value.Check(n,a))throw new h("property",n,a);return JSON.stringify(a)})},ArrayString:(e={},t)=>{let n=p.Array(e,t),r=JSON.stringify(E.Value.Create(n)),o;try{o=Q.TypeCompiler.Compile(n)}catch{}return p.Transform(p.Union([p.String({format:"ArrayString",default:r}),n])).Decode(a=>{if(typeof a=="string"){if(a.charCodeAt(0)!==91)throw new h("property",n,a);try{a=JSON.parse(a)}catch{throw new h("property",n,a)}if(o){if(!o.Check(a))throw new h("property",n,a);return o.Decode(a)}if(!E.Value.Check(n,a))throw new h("property",n,a);return E.Value.Decode(n,a)}return a}).Encode(a=>{if(typeof a=="string")try{a=JSON.parse(a)}catch{throw new h("property",n,a)}if(!E.Value.Check(n,a))throw new h("property",n,a);return JSON.stringify(a)})},File:Ze,Files:(e={})=>p.Transform(Xe(e)).Decode(t=>Array.isArray(t)?t:[t]).Encode(t=>t),Nullable:e=>p.Union([e,p.Null()]),MaybeEmpty:e=>p.Union([e,p.Null(),p.Undefined()]),Cookie:(e,{domain:t,expires:n,httpOnly:r,maxAge:o,path:a,priority:s,sameSite:i,secure:f,secrets:b,sign:m,...c}={})=>{let R=p.Object(e,c);return R.config={domain:t,expires:n,httpOnly:r,maxAge:o,path:a,priority:s,sameSite:i,secure:f,secrets:b,sign:m},R},UnionEnum:(e,t={})=>{let n=e.every(r=>typeof r=="string")?{type:"string"}:e.every(r=>typeof r=="number")?{type:"number"}:e.every(r=>r===null)?{type:"null"}:{};if(e.some(r=>typeof r=="object"&&r!==null))throw new Error("This type does not support objects or arrays");return{default:e[0],...t,[M.Kind]:"UnionEnum",...n,enum:e}}};p.BooleanString=C.BooleanString;p.ObjectString=C.ObjectString;p.ArrayString=C.ArrayString;p.Numeric=C.Numeric;p.File=(e={})=>C.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"});p.Files=(e={})=>C.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});p.Nullable=e=>C.Nullable(e);p.MaybeEmpty=C.MaybeEmpty;p.Cookie=C.Cookie;p.Date=C.Date;p.UnionEnum=C.UnionEnum;var nt=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],Ht=nt.reduce((e,t)=>(e[t]=!0,e),{});var rt=typeof Bun<"u",Nt=rt&&typeof Bun.hash=="function";var D={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},qe=Object.fromEntries(Object.entries(D).map(([e,t])=>[t,e]));function at(e){let t=e;for(;t.endsWith("=");)t=t.slice(0,-1);return t}var ye=new TextEncoder,q=async(e,t)=>{if(typeof e!="string")throw new TypeError("Cookie value must be provided as a string.");if(t===null)throw new TypeError("Secret key must be provided.");let n=await crypto.subtle.importKey("raw",ye.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,ye.encode(e));return e+"."+at(Buffer.from(r).toString("base64"))},X=async(e,t)=>{if(typeof e!="string")throw new TypeError("Signed cookie string must be provided.");if(t===null)throw new TypeError("Secret key must be provided.");let n=e.slice(0,e.lastIndexOf("."));return await q(n,t)===e?n:!1};var he=(e,t=302)=>Response.redirect(e,t),Pt=Symbol("ElysiaFormData"),Dt=Symbol("ElysiaRequestId"),I=e=>{let t=new FormData;for(let[n,r]of Object.entries(e)){if(Array.isArray(r)){for(let o of r)r instanceof File&&t.append(n,r,r.name),t.append(n,o);continue}r instanceof File&&t.append(n,r,r.name),t.append(n,r)}return t};var be=require("cookie"),Re=ne(require("fast-decode-uri-component"));var H=class{constructor(t,n,r={}){this.name=t;this.jar=n;this.initial=r}get cookie(){return this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]}set cookie(t){this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]=t}get value(){return this.cookie.value}set value(t){this.cookie.value=t}get expires(){return this.cookie.expires}set expires(t){this.cookie.expires=t,console.log(this.cookie)}get maxAge(){return this.cookie.maxAge}set maxAge(t){this.cookie.maxAge=t}get domain(){return this.cookie.domain}set domain(t){this.cookie.domain=t}get path(){return this.cookie.path}set path(t){this.cookie.path=t}get secure(){return this.cookie.secure}set secure(t){this.cookie.secure=t}get httpOnly(){return this.cookie.httpOnly}set httpOnly(t){this.cookie.httpOnly=t}get sameSite(){return this.cookie.sameSite}set sameSite(t){this.cookie.sameSite=t}get priority(){return this.cookie.priority}set priority(t){this.cookie.priority=t}get partitioned(){return this.cookie.partitioned}set partitioned(t){this.cookie.partitioned=t}get secrets(){return this.cookie.secrets}set secrets(t){this.cookie.secrets=t}update(t){return this.cookie=Object.assign(this.cookie,typeof t=="function"?t(this.cookie):t),this}set(t){return this.cookie=Object.assign({...this.initial,value:this.value},typeof t=="function"?t(this.cookie):t),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()??""}},ge=(e,t,n)=>(e.cookie||(e.cookie={}),new Proxy(t,{get(r,o){return o in t?new H(o,e.cookie,Object.assign({},n??{},t[o])):new H(o,e.cookie,Object.assign({},n))}})),Se=async(e,t,{secrets:n,sign:r,...o}={})=>{if(!t)return ge(e,{},o);let a=typeof n=="string";r&&r!==!0&&!Array.isArray(r)&&(r=[r]);let s={},i=(0,be.parse)(t);for(let[f,b]of Object.entries(i)){let m=(0,Re.default)(b);if(r===!0||r?.includes(f)){if(!n)throw new Error("No secret is provided to cookie plugin");if(a){let c=await X(m,n);if(c===!1)throw new $(f);m=c}else{let c=!0;for(let R=0;R<n.length;R++){let y=await X(m,n[R]);if(y!==!1){c=!0,m=y;break}}if(!c)throw new $(f)}}s[f]={value:m}}return ge(e,s,o)};var Te="toJSON"in new Headers,L=e=>{if(!e)return!1;for(let t in e)return!0;return!1},V=(e,t)=>{let n=e.size;if(!t&&n||n&&t&&t.status!==206&&t.status!==304&&t.status!==412&&t.status!==416){if(t){if(t.headers instanceof Headers)if(Te)t.headers=t.headers.toJSON();else for(let[r,o]of t.headers.entries())r in t.headers&&(t.headers[r]=o);return new Response(e,{status:t.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`},t.headers)})}return new Response(e,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`}})}return new Response(e)},we=(e,t)=>{if(!e)return e;e.delete("set-cookie");for(let n=0;n<t.length;n++){let r=t[n].indexOf("=");e.append("set-cookie",`${t[n].slice(0,r)}=${t[n].slice(r+1)||""}`)}return e},Oe=e=>{if(!e||!L(e))return;let t=[];for(let[n,r]of Object.entries(e)){if(!n||!r)continue;let o=r.value;o!=null&&t.push((0,ke.serialize)(n,typeof o=="object"?JSON.stringify(o):o+"",r))}if(t.length!==0)return t.length===1?t[0]:t},j=async(e,t,n)=>{let r=e.next();return r instanceof Promise&&(r=await r),r.done?t?O(r.value,t,n):N(r.value,n):new Response(new ReadableStream({async start(o){let a=!1;if(n?.signal.addEventListener("abort",()=>{a=!0;try{o.close()}catch{}}),r.value!==void 0&&r.value!==null)if(typeof r.value=="object")try{o.enqueue(Buffer.from(JSON.stringify(r.value)))}catch{o.enqueue(Buffer.from(r.value.toString()))}else o.enqueue(Buffer.from(r.value.toString()));for await(let s of e){if(a)break;if(s!=null){if(typeof s=="object")try{o.enqueue(Buffer.from(JSON.stringify(s)))}catch{o.enqueue(Buffer.from(s.toString()))}else o.enqueue(Buffer.from(s.toString()));await new Promise(i=>setTimeout(()=>i(),0))}}try{o.close()}catch{}}}),{...t,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...t?.headers}})};async function*U(e){let t=e.body;if(!t)return;let n=t.getReader(),r=new TextDecoder;try{for(;;){let{done:o,value:a}=await n.read();if(o)break;yield r.decode(a)}}finally{n.releaseLock()}}var O=(e,t,n)=>{if(L(t.headers)||t.status!==200||t.redirect||t.cookie){if(typeof t.status=="string"&&(t.status=D[t.status]),t.redirect&&(t.headers.Location=t.redirect,(!t.status||t.status<300||t.status>=400)&&(t.status=302)),t.cookie&&L(t.cookie)){let r=Oe(t.cookie);r&&(t.headers["set-cookie"]=r)}switch(t.headers["set-cookie"]&&Array.isArray(t.headers["set-cookie"])&&(t.headers=we(new Headers(t.headers),t.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,t);case"Blob":return V(e,t);case"Array":return Response.json(e,t);case"Object":let r=e[A];if(r)return t.status=r,O(e.response,t,n);for(let a in Object.values(e))switch(a?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(I(e));default:break}return Response.json(e,t);case"ReadableStream":return t.headers["content-type"]?.startsWith("text/event-stream")||(t.headers["content-type"]="text/event-stream; charset=utf-8"),n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,t);case void 0:return e?Response.json(e,t):new Response("",t);case"Response":let o=!1;if(t.headers instanceof Headers)for(let a of t.headers.keys())if(a==="set-cookie"){if(o)continue;o=!0;for(let s of t.headers.getSetCookie())e.headers.append("set-cookie",s)}else e.headers.append(a,t.headers?.get(a)??"");else for(let a in t.headers)e.headers.append(a,t.headers[a]);return e.status!==t.status&&(t.status=e.status),e.headers.get("transfer-encoding")==="chunked"?j(U(e),t,n):e;case"Error":return F(e,t);case"Promise":return e.then(a=>O(a,t));case"Function":return O(e(),t);case"Number":case"Boolean":return new Response(e.toString(),t);case"Cookie":return e instanceof H?new Response(e.value,t):new Response(e?.toString(),t);case"FormData":return new Response(e,t);default:if(e instanceof Response){let a=!1;if(t.headers instanceof Headers)for(let s of t.headers.keys())if(s==="set-cookie"){if(a)continue;a=!0;for(let i of t.headers.getSetCookie())e.headers.append("set-cookie",i)}else e.headers.append(s,t.headers?.get(s)??"");else for(let s in t.headers)e.headers.append(s,t.headers[s]);if(Te)t.headers=e.headers.toJSON();else for(let[s,i]of e.headers.entries())s in t.headers&&(t.headers[s]=i);return e}if(e instanceof Promise)return e.then(a=>O(a,t));if(e instanceof Error)return F(e,t);if(typeof e?.next=="function")return j(e,t,n);if("toResponse"in e)return O(e.toResponse(),t);if("charCodeAt"in e){let a=e.charCodeAt(0);if(a===123||a===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 new Response(e);case"Blob":return V(e,t);case"Array":return Response.json(e);case"Object":let r=e[A];if(r)return t.status=r,O(e.response,t,n);for(let o in Object.values(e))switch(o?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(I(e),t);default:break}return Response.json(e,t);case"ReadableStream":return n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?j(U(e),t,n):e;case"Error":return F(e,t);case"Promise":return e.then(o=>{let a=N(o,n);return a!==void 0?a:new Response("")});case"Function":return N(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof H?new Response(e.value,t):new Response(e?.toString(),t);case"FormData":return new Response(e,t);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(o=>O(o,t));if(e instanceof Error)return F(e,t);if(typeof e?.next=="function")return j(e,t,n);if("toResponse"in e)return O(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)}},w=(e,t,n)=>{if(e!=null)if(L(t.headers)||t.status!==200||t.redirect||t.cookie){if(typeof t.status=="string"&&(t.status=D[t.status]),t.redirect&&(t.headers.Location=t.redirect,(!t.status||t.status<300||t.status>=400)&&(t.status=302)),t.cookie&&L(t.cookie)){let r=Oe(t.cookie);r&&(t.headers["set-cookie"]=r)}switch(t.headers["set-cookie"]&&Array.isArray(t.headers["set-cookie"])&&(t.headers=we(new Headers(t.headers),t.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,t);case"Blob":return V(e,t);case"Array":return Response.json(e,t);case"Object":let r=e[A];if(r)return t.status=r,w(e.response,t,n);for(let a in Object.values(e))switch(a?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(I(e),t);default:break}return Response.json(e,t);case"ReadableStream":return t.headers["content-type"]?.startsWith("text/event-stream")||(t.headers["content-type"]="text/event-stream; charset=utf-8"),n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,t);case void 0:return e?Response.json(e,t):void 0;case"Response":let o=!1;if(t.headers instanceof Headers)for(let a of t.headers.keys())if(a==="set-cookie"){if(o)continue;o=!0;for(let s of t.headers.getSetCookie())e.headers.append("set-cookie",s)}else e.headers.append(a,t.headers?.get(a)??"");else for(let a in t.headers)e.headers.append(a,t.headers[a]);return e.status!==t.status&&(t.status=e.status),e.headers.get("transfer-encoding")==="chunked"?j(U(e),t,n):e;case"Promise":return e.then(a=>{let s=w(a,t);if(s!==void 0)return s});case"Error":return F(e,t);case"Function":return w(e(),t);case"Number":case"Boolean":return new Response(e.toString(),t);case"FormData":return new Response(e);case"Cookie":return e instanceof H?new Response(e.value,t):new Response(e?.toString(),t);default:if(e instanceof Response){let a=!1;if(t.headers instanceof Headers)for(let s of t.headers.keys())if(s==="set-cookie"){if(a)continue;a=!0;for(let i of t.headers.getSetCookie())e.headers.append("set-cookie",i)}else e.headers.append(s,t.headers?.get(s)??"");else for(let s in t.headers)e.headers.append(s,t.headers[s]);return e.status!==t.status&&(t.status=e.status),e}if(e instanceof Promise)return e.then(a=>w(a,t));if(e instanceof Error)return F(e,t);if(typeof e?.next=="function")return j(e,t,n);if("toResponse"in e)return w(e.toResponse(),t);if("charCodeAt"in e){let a=e.charCodeAt(0);if(a===123||a===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 new Response(e);case"Blob":return V(e,t);case"Array":return Response.json(e);case"Object":let r=e[A];if(r)return t.status=r,w(e.response,t,n);for(let o in Object.values(e))switch(o?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(I(e),t);default:break}return Response.json(e,t);case"ReadableStream":return n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?j(U(e)):e;case"Promise":return e.then(o=>{let a=w(o,t);if(a!==void 0)return a});case"Error":return F(e,t);case"Function":return N(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof H?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=>w(o,t));if(e instanceof Error)return F(e,t);if(typeof e?.next=="function")return j(e,t,n);if("toResponse"in e)return w(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)}},N=(e,t)=>{switch(e?.constructor?.name){case"String":return new Response(e);case"Blob":return V(e);case"Array":return Response.json(e);case"Object":if(e[A])return O(e.response,{status:e[A],headers:{}});e:for(let n of Object.values(e))switch(n?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(I(e));case"Object":break e;default:break}return Response.json(e);case"ReadableStream":return t?.signal.addEventListener("abort",{handleEvent(){t?.signal.aborted||e.cancel(t)}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?j(U(e)):e;case"Error":return F(e);case"Promise":return e.then(n=>N(n,t));case"Function":return N(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=>N(n,t));if(e instanceof Error)return F(e);if(typeof e?.next=="function")return j(e,void 0,t);if("toResponse"in e)return N(e.toResponse());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)}},F=(e,t)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:t?.status!==200?t?.status??500:500,headers:t?.headers});var v=ne(require("fast-decode-uri-component")),z=/\+/g;function xe(e){let t={};if(typeof e!="string")return t;let n="",r="",o=-1,a=-1,s=0,i=e.length;for(let f=0;f<i;f++)switch(e.charCodeAt(f)){case 38:let b=a>o;b||(a=f),n=e.slice(o+1,a),(b||n.length>0)&&(s&1&&(n=n.replace(z," ")),s&2&&(n=(0,v.default)(n)||n),t[n]||(b&&(r=e.slice(a+1,f),s&4&&(r=r.replace(z," ")),s&8&&(r=(0,v.default)(r)||r)),t[n]=r)),n="",r="",o=f,a=f,s=0;break;case 61:a<=o?a=f:s|=8;break;case 43:a>o?s|=4:s|=1;break;case 37:a>o?s|=8:s|=2;break}if(o<i){let f=a>o;n=e.slice(o+1,f?a:i),(f||n.length>0)&&(s&1&&(n=n.replace(z," ")),s&2&&(n=(0,v.default)(n)||n),t[n]||(f&&(r=e.slice(a+1,i),s&4&&(r=r.replace(z," ")),s&8&&(r=(0,v.default)(r)||r)),t[n]=r))}return t}var ee=e=>{let t={};if(typeof e!="string")return t;let n=e.length,r="",o="",a=-1,s=-1,i=!1,f=!1,b=!1,m=!1,c=!1,R=0;for(let y=0;y<n+1;y++)switch(y!==n?R=e.charCodeAt(y):R=38,R){case 38:{if(c=s>a,c||(s=y),r=e.slice(a+1,s),c||r.length>0){b&&(r=r.replace(z," ")),i&&(r=(0,v.default)(r)||r),c&&(o=e.slice(s+1,y),m&&(o=o.replace(z," ")),f&&(o=(0,v.default)(o)||o));let g=t[r];g===void 0?t[r]=o:g.pop?g.push(o):t[r]=[g,o]}o="",a=y,s=y,i=!1,f=!1,b=!1,m=!1;break}case 61:s<=a?s=y:f=!0;break;case 43:s>a?m=!0:b=!0;break;case 37:s>a?f=!0:i=!0;break}return t};var ot=e=>async t=>{let n=t.url,r=n.indexOf("/",11),o=n.indexOf("?",r+1),a=o===-1?n.substring(r):n.substring(r,o),s={cookie:{},status:200,headers:{}},i=Object.assign({},e.singleton.decorator,{set:s,store:e.singleton.store,request:t,path:a,qi:o,redirect:he});try{for(let u=0;u<e.event.request.length;u++){let l=e.event.request[u].fn,d=l(i);if(d instanceof Promise&&(d=await d),d=w(d,s),d)return i.response=d}let f=e.router.dynamic.find(t.method,a)??e.router.dynamic.find("ALL",a);if(!f)throw new Y;let{handle:b,hooks:m,validator:c,content:R}=f.store,y;if(t.method!=="GET"&&t.method!=="HEAD")if(R)switch(R){case"application/json":y=await t.json();break;case"text/plain":y=await t.text();break;case"application/x-www-form-urlencoded":y=ee(await t.text());break;case"application/octet-stream":y=await t.arrayBuffer();break;case"multipart/form-data":y={};let u=await t.formData();for(let l of u.keys()){if(y[l])continue;let d=u.getAll(l);d.length===1?y[l]=d[0]:y[l]=d}break}else{let u=t.headers.get("content-type");if(u){let l=u.indexOf(";");l!==-1&&(u=u.slice(0,l)),i.contentType=u;for(let d=0;d<m.parse.length;d++){let k=m.parse[d].fn,T=k(i,u);if(T instanceof Promise&&(T=await T),T){y=T;break}}if(delete i.contentType,y===void 0)switch(u){case"application/json":y=await t.json();break;case"text/plain":y=await t.text();break;case"application/x-www-form-urlencoded":y=ee(await t.text());break;case"application/octet-stream":y=await t.arrayBuffer();break;case"multipart/form-data":y={};let d=await t.formData();for(let k of d.keys()){if(y[k])continue;let T=d.getAll(k);T.length===1?y[k]=T[0]:y[k]=T}break}}}i.body=y,i.params=f?.params||void 0,i.query=o===-1?{}:xe(n.substring(o+1)),i.headers={};for(let[u,l]of t.headers.entries())i.headers[u]=l;let g=Object.assign({},e.config?.cookie,c?.cookie?.config),Ee=t.headers.get("cookie");i.cookie=await Se(i.set,Ee,g?{secrets:g.secrets!==void 0?typeof g.secrets=="string"?g.secrets:g.secrets.join(","):void 0,sign:g.sign===!0?!0:g.sign!==void 0?typeof g.sign=="string"?g.sign:g.sign.join(","):void 0}:void 0);for(let u=0;u<m.transform.length;u++){let l=m.transform[u],d=l.fn(i);l.subType==="derive"?d instanceof Promise?Object.assign(i,await d):Object.assign(i,d):d instanceof Promise&&await d}if(c){if(c.createHeaders?.()){let u={};for(let l in t.headers)u[l]=t.headers.get(l);if(c.headers.Check(u)===!1)throw new h("header",c.headers,u)}else c.headers?.Decode&&(i.headers=c.headers.Decode(i.headers));if(c.createParams?.()?.Check(i.params)===!1)throw new h("params",c.params,i.params);if(c.params?.Decode&&(i.params=c.params.Decode(i.params)),c.createQuery?.()?.Check(i.query)===!1)throw new h("query",c.query,i.query);if(c.query?.Decode&&(i.query=c.query.Decode(i.query)),c.createCookie?.()){let u={};for(let[l,d]of Object.entries(i.cookie))u[l]=d.value;if(c.cookie.Check(u)===!1)throw new h("cookie",c.cookie,u);c.cookie?.Decode&&(u=c.cookie.Decode(u))}if(c.createBody?.()?.Check(y)===!1)throw new h("body",c.body,y);c.body?.Decode&&(i.body=c.body.Decode(y))}for(let u=0;u<m.beforeHandle.length;u++){let l=m.beforeHandle[u].fn(i);if(l instanceof Promise&&(l=await l),l!==void 0){i.response=l;for(let k=0;k<m.afterHandle.length;k++){let T=m.afterHandle[k].fn(i);T instanceof Promise&&(T=await T),T&&(l=T)}let d=w(l,i.set);if(d)return i.response=d}}let x=b(i);if(x instanceof Promise&&(x=await x),m.afterHandle.length){i.response=x;for(let u=0;u<m.afterHandle.length;u++){let l=m.afterHandle[u].fn(i);l instanceof Promise&&(l=await l);let d=w(l,i.set);if(d!==void 0){let k=c?.response?.[d.status];if(k?.Check(d)===!1)throw new h("response",k,d);return k?.Decode&&(x=k.Decode(x)),i.response=d}}}else{let u=x?.[A]??(s.status?typeof s.status=="string"?D[s.status]:s.status:200),l=c?.createResponse?.()?.[u];if(l?.Check(x)===!1)throw new h("response",l,x);l?.Decode&&(x=l.Decode(x))}if(i.set.cookie&&g?.sign){let u=g.secrets?typeof g.secrets=="string"?g.secrets:g.secrets[0]:void 0;if(g.sign===!0)for(let[l,d]of Object.entries(i.set.cookie))i.set.cookie[l].value=await q(d.value,"${secret}");else{let l=c?.cookie?.schema?.properties;for(let d of g.sign)d in l&&i.set.cookie[d]?.value&&(i.set.cookie[d].value=await q(i.set.cookie[d].value,u))}}return i.response=O(x,i.set)}catch(f){return f.status&&(s.status=f.status),e.handleError(i,f)}finally{for(let f of e.event.afterResponse)await f.fn(i)}},st=e=>async(t,n)=>{let r=Object.assign(t,{error:n,code:n.code});r.set=t.set;for(let o=0;o<e.event.error.length;o++){let s=e.event.error[o].fn(r);if(s instanceof Promise&&(s=await s),s!=null)return t.response=O(s,t.set)}return new Response(typeof n.cause=="string"?n.cause:n.message,{headers:t.set.headers,status:n.status??500})};0&&(module.exports={createDynamicErrorHandler,createDynamicHandler});
/**
* @license
*
* MIT License
*
* Copyright (c) 2020 Evgeny Poberezkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
"use strict";var E=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var S=(i,o)=>{for(var c in o)E(i,c,{get:o[c],enumerable:!0})},V=(i,o,c,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of O(o))!P.call(i,l)&&l!==c&&E(i,l,{get:()=>o[l],enumerable:!(h=j(o,l))||h.enumerable});return i};var L=i=>V(E({},"__esModule",{value:!0}),i);var B={};S(B,{createDynamicErrorHandler:()=>A,createDynamicHandler:()=>T});module.exports=L(B);var g=require("./handler"),m=require("./error"),x=require("./fast-querystring"),b=require("./utils"),v=require("./cookies");const T=i=>async o=>{const c=o.url,h=c.indexOf("/",11),l=c.indexOf("?",h+1),C=l===-1?c.substring(h):c.substring(h,l),p={cookie:{},status:200,headers:{}},e=Object.assign({},i.singleton.decorator,{set:p,store:i.singleton.store,request:o,path:C,qi:l,redirect:b.redirect});try{for(let s=0;s<i.event.request.length;s++){const n=i.event.request[s].fn;let t=n(e);if(t instanceof Promise&&(t=await t),t=(0,g.mapEarlyResponse)(t,p),t)return e.response=t}const w=i.router.dynamic.find(o.method,C)??i.router.dynamic.find("ALL",C);if(!w)throw new m.NotFoundError;const{handle:R,hooks:k,validator:a,content:D}=w.store;let r;if(o.method!=="GET"&&o.method!=="HEAD")if(D)switch(D){case"application/json":r=await o.json();break;case"text/plain":r=await o.text();break;case"application/x-www-form-urlencoded":r=(0,x.parseQuery)(await o.text());break;case"application/octet-stream":r=await o.arrayBuffer();break;case"multipart/form-data":r={};const s=await o.formData();for(const n of s.keys()){if(r[n])continue;const t=s.getAll(n);t.length===1?r[n]=t[0]:r[n]=t}break}else{let s=o.headers.get("content-type");if(s){const n=s.indexOf(";");n!==-1&&(s=s.slice(0,n)),e.contentType=s;for(let t=0;t<k.parse.length;t++){const d=k.parse[t].fn;let y=d(e,s);if(y instanceof Promise&&(y=await y),y){r=y;break}}if(delete e.contentType,r===void 0)switch(s){case"application/json":r=await o.json();break;case"text/plain":r=await o.text();break;case"application/x-www-form-urlencoded":r=(0,x.parseQuery)(await o.text());break;case"application/octet-stream":r=await o.arrayBuffer();break;case"multipart/form-data":r={};const t=await o.formData();for(const d of t.keys()){if(r[d])continue;const y=t.getAll(d);y.length===1?r[d]=y[0]:r[d]=y}break}}}e.body=r,e.params=w?.params||void 0,e.query=l===-1?{}:(0,x.parseQueryFromURL)(c.substring(l+1)),e.headers={};for(const[s,n]of o.headers.entries())e.headers[s]=n;const f=Object.assign({},i.config?.cookie,a?.cookie?.config),H=o.headers.get("cookie");e.cookie=await(0,v.parseCookie)(e.set,H,f?{secrets:f.secrets!==void 0?typeof f.secrets=="string"?f.secrets:f.secrets.join(","):void 0,sign:f.sign===!0?!0:f.sign!==void 0?typeof f.sign=="string"?f.sign:f.sign.join(","):void 0}:void 0);for(let s=0;s<k.transform.length;s++){const n=k.transform[s],t=n.fn(e);n.subType==="derive"?t instanceof Promise?Object.assign(e,await t):Object.assign(e,t):t instanceof Promise&&await t}if(a){if(a.createHeaders?.()){const s={};for(const n in o.headers)s[n]=o.headers.get(n);if(a.headers.Check(s)===!1)throw new m.ValidationError("header",a.headers,s)}else a.headers?.Decode&&(e.headers=a.headers.Decode(e.headers));if(a.createParams?.()?.Check(e.params)===!1)throw new m.ValidationError("params",a.params,e.params);if(a.params?.Decode&&(e.params=a.params.Decode(e.params)),a.createQuery?.()?.Check(e.query)===!1)throw new m.ValidationError("query",a.query,e.query);if(a.query?.Decode&&(e.query=a.query.Decode(e.query)),a.createCookie?.()){let s={};for(const[n,t]of Object.entries(e.cookie))s[n]=t.value;if(a.cookie.Check(s)===!1)throw new m.ValidationError("cookie",a.cookie,s);a.cookie?.Decode&&(s=a.cookie.Decode(s))}if(a.createBody?.()?.Check(r)===!1)throw new m.ValidationError("body",a.body,r);a.body?.Decode&&(e.body=a.body.Decode(r))}for(let s=0;s<k.beforeHandle.length;s++){let n=k.beforeHandle[s].fn(e);if(n instanceof Promise&&(n=await n),n!==void 0){e.response=n;for(let d=0;d<k.afterHandle.length;d++){let y=k.afterHandle[d].fn(e);y instanceof Promise&&(y=await y),y&&(n=y)}const t=(0,g.mapEarlyResponse)(n,e.set);if(t)return e.response=t}}let u=R(e);if(u instanceof Promise&&(u=await u),k.afterHandle.length){e.response=u;for(let s=0;s<k.afterHandle.length;s++){let n=k.afterHandle[s].fn(e);n instanceof Promise&&(n=await n);const t=(0,g.mapEarlyResponse)(n,e.set);if(t!==void 0){const d=a?.response?.[t.status];if(d?.Check(t)===!1)throw new m.ValidationError("response",d,t);return d?.Decode&&(u=d.Decode(u)),e.response=t}}}else{const s=u?.[m.ELYSIA_RESPONSE]??(p.status?typeof p.status=="string"?b.StatusMap[p.status]:p.status:200),n=a?.createResponse?.()?.[s];if(n?.Check(u)===!1)throw new m.ValidationError("response",n,u);n?.Decode&&(u=n.Decode(u))}if(e.set.cookie&&f?.sign){const s=f.secrets?typeof f.secrets=="string"?f.secrets:f.secrets[0]:void 0;if(f.sign===!0)for(const[n,t]of Object.entries(e.set.cookie))e.set.cookie[n].value=await(0,b.signCookie)(t.value,"${secret}");else{const n=a?.cookie?.schema?.properties;for(const t of f.sign)t in n&&e.set.cookie[t]?.value&&(e.set.cookie[t].value=await(0,b.signCookie)(e.set.cookie[t].value,s))}}return e.response=(0,g.mapResponse)(u,e.set)}catch(w){return w.status&&(p.status=w.status),i.handleError(e,w)}finally{for(const w of i.event.afterResponse)await w.fn(e)}},A=i=>async(o,c)=>{const h=Object.assign(o,{error:c,code:c.code});h.set=o.set;for(let l=0;l<i.event.error.length;l++){let p=i.event.error[l].fn(h);if(p instanceof Promise&&(p=await p),p!=null)return o.response=(0,g.mapResponse)(p,o.set)}return new Response(typeof c.cause=="string"?c.cause:c.message,{headers:o.set.headers,status:c.status??500})};0&&(module.exports={createDynamicErrorHandler,createDynamicHandler});

@@ -1,26 +0,1 @@

"use strict";var G=Object.create;var O=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},M=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of W(t))!Q.call(e,o)&&o!==n&&O(e,o,{get:()=>t[o],enumerable:!(a=q(t,o))||a.enumerable});return e};var ee=(e,t,n)=>(n=e!=null?G(Z(e)):{},M(t||!e||!e.__esModule?O(n,"default",{value:e,enumerable:!0}):n,e)),te=e=>M(O({},"__esModule",{value:!0}),e);var Fe={};X(Fe,{ELYSIA_RESPONSE:()=>w,ERROR_CODE:()=>Ae,InternalServerError:()=>P,InvalidCookieSignature:()=>x,NotFoundError:()=>D,ParseError:()=>_,ValidationError:()=>s,error:()=>je,isProduction:()=>H,mapValueError:()=>b});module.exports=te(Fe);var T=require("@sinclair/typebox/value");var K=require("@sinclair/typebox"),Ee=require("@sinclair/typebox/value"),xe=require("@sinclair/typebox/compiler");var S=require("@sinclair/typebox"),R=require("@sinclair/typebox/system"),c=require("@sinclair/typebox"),j=require("@sinclair/typebox/compiler"),u=require("@sinclair/typebox/value");var k={date:L,time:A(!0),"date-time":B(!0),"iso-time":A(!1),"iso-date-time":B(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:fe,"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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}:){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:he,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:ue,int32:{type:"number",validate:pe},int64:{type:"number",validate:ye},float:{type:"number",validate:z},double:{type:"number",validate:z},password:!0,binary:!0};function ne(e){return e%4===0&&(e%100!==0||e%400===0)}var re=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,ae=[0,31,28,31,30,31,30,31,31,30,31,30,31];function L(e){let t=re.exec(e);if(!t)return!1;let n=+t[1],a=+t[2],o=+t[3];return a>=1&&a<=12&&o>=1&&o<=(a===2&&ne(n)?29:ae[a])}var oe=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function A(e){return function(n){let a=oe.exec(n);if(!a)return!1;let o=+a[1],r=+a[2],f=+a[3],h=a[4],d=a[5]==="-"?-1:1,y=+(a[6]||0),p=+(a[7]||0);if(y>23||p>59||e&&!h)return!1;if(o<=23&&r<=59&&f<60)return!0;let m=r-p*d,g=o-y*d-(m<0?1:0);return(g===23||g===-1)&&(m===59||m===-1)&&f<61}}var ie=/t|\s/i;function B(e){let t=A(e);return function(a){let o=a.split(ie);return o.length===2&&L(o[0])&&t(o[1])}}var se=/\/|:/,ce=/^(?:[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 fe(e){return se.test(e)&&ce.test(e)}var I=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function ue(e){return I.lastIndex=0,I.test(e)}var de=-(2**31),le=2**31-1;function pe(e){return Number.isInteger(e)&&e<=le&&e>=de}function ye(e){return Number.isInteger(e)}function z(){return!0}var me=/[^\\]\\Z/;function he(e){if(me.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var E=require("@sinclair/typebox/system"),J=require("@sinclair/typebox/compiler"),v=/(\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))/,U=/(?: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\([^)]+\)/,V=/^(?:(?:(?:(?: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)?)?$/,ge=k.date,be=k["date-time"];c.FormatRegistry.Has("date")||R.TypeSystem.Format("date",e=>{let t=e.replace(/"/g,"");if(v.test(t)||U.test(t)||V.test(t)||ge(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});c.FormatRegistry.Has("date-time")||R.TypeSystem.Format("date-time",e=>{let t=e.replace(/"/g,"");if(v.test(t)||U.test(t)||V.test(t)||be(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});Object.entries(k).forEach(e=>{let[t,n]=e;c.FormatRegistry.Has(t)||(n instanceof RegExp?R.TypeSystem.Format(t,a=>n.test(a)):typeof n=="function"&&R.TypeSystem.Format(t,n))});var i=Object.assign({},c.Type),$=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},F=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<$(e.minSize)||e.maxSize&&t.size>$(e.maxSize))return!1;if(e.extension)if(typeof e.extension=="string"){if(!t.type.startsWith(e.extension))return!1}else{for(let n=0;n<e.extension.length;n++)if(t.type.startsWith(e.extension[n]))return!0;return!1}return!0},Re=S.TypeRegistry.Get("Files")??R.TypeSystem.Type("File",F),Se=S.TypeRegistry.Get("Files")??R.TypeSystem.Type("Files",(e,t)=>{if(!Array.isArray(t))return F(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(!F(e,t[n]))return!1;return!0});c.FormatRegistry.Has("numeric")||c.FormatRegistry.Set("numeric",e=>!!e&&!isNaN(+e));c.FormatRegistry.Has("boolean")||c.FormatRegistry.Set("boolean",e=>e==="true"||e==="false");c.FormatRegistry.Has("ObjectString")||c.FormatRegistry.Set("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}});c.FormatRegistry.Has("ArrayString")||c.FormatRegistry.Set("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}});S.TypeRegistry.Set("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t));var l={Numeric:e=>{let t=c.Type.Number(e);return i.Transform(i.Union([i.String({format:"numeric",default:0}),i.Number(e)],e)).Decode(n=>{let a=+n;if(isNaN(a))return n;if(e&&!u.Value.Check(t,a))throw new s("property",t,a);return a}).Encode(n=>n)},Date:e=>{let t=c.Type.Date(e);return i.Transform(i.Union([c.Type.Date(e),i.String({format:"date",default:new Date().toISOString()}),i.String({format:"date-time",default:new Date().toISOString()})],e)).Decode(n=>{if(n instanceof Date)return n;let a=new Date(n);if(!u.Value.Check(t,a))throw new s("property",t,a);return a}).Encode(n=>typeof n=="string"?new Date(n):n)},BooleanString:e=>{let t=c.Type.Boolean(e);return i.Transform(i.Union([i.String({format:"boolean",default:!1}),i.Boolean(e)],e)).Decode(n=>{if(typeof n=="string")return n==="true";if(e&&!u.Value.Check(t,n))throw new s("property",t,n);return n}).Encode(n=>n)},ObjectString:(e,t)=>{let n=i.Object(e,t),a=JSON.stringify(u.Value.Create(n)),o;try{o=j.TypeCompiler.Compile(n)}catch{}return i.Transform(i.Union([i.String({format:"ObjectString",default:a}),n])).Decode(r=>{if(typeof r=="string"){if(r.charCodeAt(0)!==123)throw new s("property",n,r);try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(o){if(!o.Check(r))throw new s("property",n,r);return o.Decode(r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return u.Value.Decode(n,r)}return r}).Encode(r=>{if(typeof r=="string")try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return JSON.stringify(r)})},ArrayString:(e={},t)=>{let n=i.Array(e,t),a=JSON.stringify(u.Value.Create(n)),o;try{o=j.TypeCompiler.Compile(n)}catch{}return i.Transform(i.Union([i.String({format:"ArrayString",default:a}),n])).Decode(r=>{if(typeof r=="string"){if(r.charCodeAt(0)!==91)throw new s("property",n,r);try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(o){if(!o.Check(r))throw new s("property",n,r);return o.Decode(r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return u.Value.Decode(n,r)}return r}).Encode(r=>{if(typeof r=="string")try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return JSON.stringify(r)})},File:Re,Files:(e={})=>i.Transform(Se(e)).Decode(t=>Array.isArray(t)?t:[t]).Encode(t=>t),Nullable:e=>i.Union([e,i.Null()]),MaybeEmpty:e=>i.Union([e,i.Null(),i.Undefined()]),Cookie:(e,{domain:t,expires:n,httpOnly:a,maxAge:o,path:r,priority:f,sameSite:h,secure:d,secrets:y,sign:p,...m}={})=>{let g=i.Object(e,m);return g.config={domain:t,expires:n,httpOnly:a,maxAge:o,path:r,priority:f,sameSite:h,secure:d,secrets:y,sign:p},g},UnionEnum:(e,t={})=>{let n=e.every(a=>typeof a=="string")?{type:"string"}:e.every(a=>typeof a=="number")?{type:"number"}:e.every(a=>a===null)?{type:"null"}:{};if(e.some(a=>typeof a=="object"&&a!==null))throw new Error("This type does not support objects or arrays");return{default:e[0],...t,[S.Kind]:"UnionEnum",...n,enum:e}}};i.BooleanString=l.BooleanString;i.ObjectString=l.ObjectString;i.ArrayString=l.ArrayString;i.Numeric=l.Numeric;i.File=(e={})=>l.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"});i.Files=(e={})=>l.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});i.Nullable=e=>l.Nullable(e);i.MaybeEmpty=l.MaybeEmpty;i.Cookie=l.Cookie;i.Date=l.Date;i.UnionEnum=l.UnionEnum;var ke=require("cookie");var Te=require("cookie"),Oe=ee(require("fast-decode-uri-component"));var tt="toJSON"in new Headers;var Ce=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],ft=Ce.reduce((e,t)=>(e[t]=!0,e),{});var we=typeof Bun<"u",ut=we&&typeof Bun.hash=="function";var C={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},N=Object.fromEntries(Object.entries(C).map(([e,t])=>[t,e]));var dt=new TextEncoder;var lt=Symbol("ElysiaFormData"),pt=Symbol("ElysiaRequestId");var Y=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,Ae=Symbol("ElysiaErrorCode"),w=Symbol("ElysiaResponse"),H=(Y?.NODE_ENV??Y?.ENV)==="production",je=(e,t)=>{let n=t??(e in N?N[e]:e);return{[w]:C[e]??e,response:n,_type:void 0,error:new Error(n)}},P=class extends Error{constructor(n){super(n??"INTERNAL_SERVER_ERROR");this.code="INTERNAL_SERVER_ERROR";this.status=500}},D=class extends Error{constructor(n){super(n??"NOT_FOUND");this.code="NOT_FOUND";this.status=404}},_=class extends Error{constructor(){super("Failed to parse body");this.code="PARSE";this.status=400}},x=class extends Error{constructor(n,a){super(a??`"${n}" has invalid cookie signature`);this.key=n;this.code="INVALID_COOKIE_SIGNATURE";this.status=400}},b=e=>{if(!e)return{summary:void 0};let{message:t,path:n,value:a,type:o}=e,r=n.slice(1).replaceAll("/","."),f=n==="";switch(o){case 42:return{...e,summary:f?"Value should not be provided":`Property '${r}' should not be provided`};case 45:return{...e,summary:f?"Value is missing":`Property '${r}' is missing`};case 50:let h=t.indexOf("'"),d=t.slice(h+1,t.indexOf("'",h+1));return{...e,summary:f?"Value should be an email":`Property '${r}' should be ${d}`};case 54:return{...e,summary:`${t.slice(0,9)} property '${r}' to be ${t.slice(8)} but found: ${a}`};case 62:let y=e.schema.anyOf.map(p=>`'${p?.format??p.type}'`).join(", ");return{...e,summary:f?`Value should be one of ${y}`:`Property '${r}' should be one of: ${y}`};default:return{summary:t,...e}}},s=class e extends Error{constructor(n,a,o){o&&typeof o=="object"&&w in o&&(o=o.response);let r=H?void 0:"Errors"in a?a.Errors(o).First():T.Value.Errors(a,o).First(),f=r?.schema.error!==void 0?typeof r.schema.error=="function"?r.schema.error({type:n,validator:a,value:o,get errors(){return[...a.Errors(o)].map(b)}}):r.schema.error:void 0,h=r?.path||"root",d="";if(f!==void 0)d=typeof f=="object"?JSON.stringify(f):f+"";else if(H)d=JSON.stringify({type:"validation",on:n,summary:b(r).summary,message:r?.message,found:o});else{let y=a?.schema??a,p="Errors"in a?[...a.Errors(o)].map(b):[...T.Value.Errors(a,o)].map(b),m;try{m=T.Value.Create(y)}catch(g){m={type:"Could not create expected value",message:g?.message,error:g}}d=JSON.stringify({type:"validation",on:n,summary:p[0]?.summary,property:h,message:r?.message,expected:m,found:o,errors:p},null,2)}super(d);this.type=n;this.validator=a;this.value=o;this.code="VALIDATION";this.status=422;Object.setPrototypeOf(this,e.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(b):[...T.Value.Errors(this.validator,this.value)].map(b)}static simplifyModel(n){let a="schema"in n?n.schema:n;try{return T.Value.Create(a)}catch{return a}}get model(){return e.simplifyModel(this.validator)}toResponse(n){return new Response(this.message,{status:400,headers:{...n,"content-type":"application/json"}})}};0&&(module.exports={ELYSIA_RESPONSE,ERROR_CODE,InternalServerError,InvalidCookieSignature,NotFoundError,ParseError,ValidationError,error,isProduction,mapValueError});
/**
* @license
*
* MIT License
*
* Copyright (c) 2020 Evgeny Poberezkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
"use strict";var f=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var N=(e,s)=>{for(var r in s)f(e,r,{get:s[r],enumerable:!0})},b=(e,s,r,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let t of g(s))!C.call(e,t)&&t!==r&&f(e,t,{get:()=>s[t],enumerable:!(o=x(s,t))||o.enumerable});return e};var I=e=>b(f({},"__esModule",{value:!0}),e);var A={};N(A,{ELYSIA_RESPONSE:()=>S,ERROR_CODE:()=>_,InternalServerError:()=>V,InvalidCookieSignature:()=>k,NotFoundError:()=>P,ParseError:()=>$,ValidationError:()=>y,error:()=>T,isProduction:()=>h,mapValueError:()=>p});module.exports=I(A);var c=require("@sinclair/typebox/value"),d=require("./utils");const O=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,_=Symbol("ElysiaErrorCode"),S=Symbol("ElysiaResponse"),h=(O?.NODE_ENV??O?.ENV)==="production",T=(e,s)=>{const r=s??(e in d.InvertedStatusMap?d.InvertedStatusMap[e]:e);return{[S]:d.StatusMap[e]??e,response:r,_type:void 0,error:new Error(r)}};class V extends Error{constructor(r){super(r??"INTERNAL_SERVER_ERROR");this.code="INTERNAL_SERVER_ERROR";this.status=500}}class P extends Error{constructor(r){super(r??"NOT_FOUND");this.code="NOT_FOUND";this.status=404}}class $ extends Error{constructor(){super("Failed to parse body");this.code="PARSE";this.status=400}}class k extends Error{constructor(r,o){super(o??`"${r}" has invalid cookie signature`);this.key=r;this.code="INVALID_COOKIE_SIGNATURE";this.status=400}}const p=e=>{if(!e)return{summary:void 0};const{message:s,path:r,value:o,type:t}=e,n=r.slice(1).replaceAll("/","."),a=r==="";switch(t){case 42:return{...e,summary:a?"Value should not be provided":`Property '${n}' should not be provided`};case 45:return{...e,summary:a?"Value is missing":`Property '${n}' is missing`};case 50:const m=s.indexOf("'"),i=s.slice(m+1,s.indexOf("'",m+1));return{...e,summary:a?"Value should be an email":`Property '${n}' should be ${i}`};case 54:return{...e,summary:`${s.slice(0,9)} property '${n}' to be ${s.slice(8)} but found: ${o}`};case 62:const E=e.schema.anyOf.map(u=>`'${u?.format??u.type}'`).join(", ");return{...e,summary:a?`Value should be one of ${E}`:`Property '${n}' should be one of: ${E}`};default:return{summary:s,...e}}};class y extends Error{constructor(r,o,t){t&&typeof t=="object"&&S in t&&(t=t.response);const n=h?void 0:"Errors"in o?o.Errors(t).First():c.Value.Errors(o,t).First(),a=n?.schema.error!==void 0?typeof n.schema.error=="function"?n.schema.error({type:r,validator:o,value:t,get errors(){return[...o.Errors(t)].map(p)}}):n.schema.error:void 0,m=n?.path||"root";let i="";if(a!==void 0)i=typeof a=="object"?JSON.stringify(a):a+"";else if(h)i=JSON.stringify({type:"validation",on:r,summary:p(n).summary,message:n?.message,found:t});else{const E=o?.schema??o,u="Errors"in o?[...o.Errors(t)].map(p):[...c.Value.Errors(o,t)].map(p);let l;try{l=c.Value.Create(E)}catch(R){l={type:"Could not create expected value",message:R?.message,error:R}}i=JSON.stringify({type:"validation",on:r,summary:u[0]?.summary,property:m,message:n?.message,expected:l,found:t,errors:u},null,2)}super(i);this.type=r;this.validator=o;this.value=t;this.code="VALIDATION";this.status=422;Object.setPrototypeOf(this,y.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(p):[...c.Value.Errors(this.validator,this.value)].map(p)}static simplifyModel(r){const o="schema"in r?r.schema:r;try{return c.Value.Create(o)}catch{return o}}get model(){return y.simplifyModel(this.validator)}toResponse(r){return new Response(this.message,{status:400,headers:{...r,"content-type":"application/json"}})}}0&&(module.exports={ELYSIA_RESPONSE,ERROR_CODE,InternalServerError,InvalidCookieSignature,NotFoundError,ParseError,ValidationError,error,isProduction,mapValueError});

2

dist/cjs/fast-querystring.js

@@ -1,1 +0,1 @@

"use strict";var p=Object.create;var d=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var K=(s,r)=>{for(var e in r)d(s,e,{get:r[e],enumerable:!0})},k=(s,r,e,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of P(r))!I.call(s,t)&&t!==e&&d(s,t,{get:()=>r[t],enumerable:!(l=x(r,t))||l.enumerable});return s};var R=(s,r,e)=>(e=s!=null?p(V(s)):{},k(r||!s||!s.__esModule?d(e,"default",{value:s,enumerable:!0}):e,s)),m=s=>k(d({},"__esModule",{value:!0}),s);var D={};K(D,{parseQuery:()=>B,parseQueryFromURL:()=>v});module.exports=m(D);var u=R(require("fast-decode-uri-component")),b=/\+/g;function v(s){let r={};if(typeof s!="string")return r;let e="",l="",t=-1,i=-1,a=0,o=s.length;for(let f=0;f<o;f++)switch(s.charCodeAt(f)){case 38:let n=i>t;n||(i=f),e=s.slice(t+1,i),(n||e.length>0)&&(a&1&&(e=e.replace(b," ")),a&2&&(e=(0,u.default)(e)||e),r[e]||(n&&(l=s.slice(i+1,f),a&4&&(l=l.replace(b," ")),a&8&&(l=(0,u.default)(l)||l)),r[e]=l)),e="",l="",t=f,i=f,a=0;break;case 61:i<=t?i=f:a|=8;break;case 43:i>t?a|=4:a|=1;break;case 37:i>t?a|=8:a|=2;break}if(t<o){let f=i>t;e=s.slice(t+1,f?i:o),(f||e.length>0)&&(a&1&&(e=e.replace(b," ")),a&2&&(e=(0,u.default)(e)||e),r[e]||(f&&(l=s.slice(i+1,o),a&4&&(l=l.replace(b," ")),a&8&&(l=(0,u.default)(l)||l)),r[e]=l))}return r}var B=s=>{let r={};if(typeof s!="string")return r;let e=s.length,l="",t="",i=-1,a=-1,o=!1,f=!1,n=!1,y=!1,g=!1,_=0;for(let c=0;c<e+1;c++)switch(c!==e?_=s.charCodeAt(c):_=38,_){case 38:{if(g=a>i,g||(a=c),l=s.slice(i+1,a),g||l.length>0){n&&(l=l.replace(b," ")),o&&(l=(0,u.default)(l)||l),g&&(t=s.slice(a+1,c),y&&(t=t.replace(b," ")),f&&(t=(0,u.default)(t)||t));let h=r[l];h===void 0?r[l]=t:h.pop?h.push(t):r[l]=[h,t]}t="",i=c,a=c,o=!1,f=!1,n=!1,y=!1;break}case 61:a<=i?a=c:f=!0;break;case 43:a>i?y=!0:n=!0;break;case 37:a>i?f=!0:o=!0;break}return r};0&&(module.exports={parseQuery,parseQueryFromURL});
"use strict";var p=Object.create;var d=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var K=(s,r)=>{for(var e in r)d(s,e,{get:r[e],enumerable:!0})},k=(s,r,e,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of P(r))!I.call(s,t)&&t!==e&&d(s,t,{get:()=>r[t],enumerable:!(l=x(r,t))||l.enumerable});return s};var R=(s,r,e)=>(e=s!=null?p(V(s)):{},k(r||!s||!s.__esModule?d(e,"default",{value:s,enumerable:!0}):e,s)),m=s=>k(d({},"__esModule",{value:!0}),s);var D={};K(D,{parseQuery:()=>B,parseQueryFromURL:()=>v});module.exports=m(D);var u=R(require("fast-decode-uri-component"));const b=/\+/g;function v(s){const r={};if(typeof s!="string")return r;let e="",l="",t=-1,i=-1,a=0;const o=s.length;for(let f=0;f<o;f++)switch(s.charCodeAt(f)){case 38:const n=i>t;n||(i=f),e=s.slice(t+1,i),(n||e.length>0)&&(a&1&&(e=e.replace(b," ")),a&2&&(e=(0,u.default)(e)||e),r[e]||(n&&(l=s.slice(i+1,f),a&4&&(l=l.replace(b," ")),a&8&&(l=(0,u.default)(l)||l)),r[e]=l)),e="",l="",t=f,i=f,a=0;break;case 61:i<=t?i=f:a|=8;break;case 43:i>t?a|=4:a|=1;break;case 37:i>t?a|=8:a|=2;break}if(t<o){const f=i>t;e=s.slice(t+1,f?i:o),(f||e.length>0)&&(a&1&&(e=e.replace(b," ")),a&2&&(e=(0,u.default)(e)||e),r[e]||(f&&(l=s.slice(i+1,o),a&4&&(l=l.replace(b," ")),a&8&&(l=(0,u.default)(l)||l)),r[e]=l))}return r}const B=s=>{const r={};if(typeof s!="string")return r;const e=s.length;let l="",t="",i=-1,a=-1,o=!1,f=!1,n=!1,y=!1,g=!1,_=0;for(let c=0;c<e+1;c++)switch(c!==e?_=s.charCodeAt(c):_=38,_){case 38:{if(g=a>i,g||(a=c),l=s.slice(i+1,a),g||l.length>0){n&&(l=l.replace(b," ")),o&&(l=(0,u.default)(l)||l),g&&(t=s.slice(a+1,c),y&&(t=t.replace(b," ")),f&&(t=(0,u.default)(t)||t));const h=r[l];h===void 0?r[l]=t:h.pop?h.push(t):r[l]=[h,t]}t="",i=c,a=c,o=!1,f=!1,n=!1,y=!1;break}case 61:a<=i?a=c:f=!0;break;case 43:a>i?y=!0:n=!0;break;case 37:a>i?f=!0:o=!0;break}return r};0&&(module.exports={parseQuery,parseQueryFromURL});

@@ -1,3 +0,2 @@

"use strict";var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var I=(a,t)=>{for(var n in t)r(a,n,{get:t[n],enumerable:!0})},A=(a,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of T(t))!v.call(a,d)&&d!==n&&r(a,d,{get:()=>t[d],enumerable:!(e=g(t,d))||e.enumerable});return a};var x=a=>A(r({},"__esModule",{value:!0}),a);var U={};I(U,{fullFormats:()=>y});module.exports=x(U);var y={date:_,time:i(!0),"date-time":l(!0),"iso-time":i(!1),"iso-date-time":l(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:D,"uri-reference":/^(?:[a-z][a-z0-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(?:#(?:[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:P,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:Z,int32:{type:"number",validate:w},int64:{type:"number",validate:F},float:{type:"number",validate:b},double:{type:"number",validate:b},password:!0,binary:!0};function N(a){return a%4===0&&(a%100!==0||a%400===0)}var h=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,M=[0,31,28,31,30,31,30,31,31,30,31,30,31];function _(a){let t=h.exec(a);if(!t)return!1;let n=+t[1],e=+t[2],d=+t[3];return e>=1&&e<=12&&d>=1&&d<=(e===2&&N(n)?29:M[e])}var E=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function i(a){return function(n){let e=E.exec(n);if(!e)return!1;let d=+e[1],o=+e[2],u=+e[3],p=e[4],s=e[5]==="-"?-1:1,z=+(e[6]||0),c=+(e[7]||0);if(z>23||c>59||a&&!p)return!1;if(d<=23&&o<=59&&u<60)return!0;let f=o-c*s,m=d-z*s-(f<0?1:0);return(m===23||m===-1)&&(f===59||f===-1)&&u<61}}var R=/t|\s/i;function l(a){let t=i(a);return function(e){let d=e.split(R);return d.length===2&&_(d[0])&&t(d[1])}}var j=/\/|:/,S=/^(?:[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 D(a){return j.test(a)&&S.test(a)}var $=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function Z(a){return $.lastIndex=0,$.test(a)}var H=-(2**31),Y=2**31-1;function w(a){return Number.isInteger(a)&&a<=Y&&a>=H}function F(a){return Number.isInteger(a)}function b(){return!0}var O=/[^\\]\\Z/;function P(a){if(O.test(a))return!1;try{return new RegExp(a),!0}catch{return!1}}0&&(module.exports={fullFormats});
/**
"use strict";var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var I=(a,t)=>{for(var n in t)r(a,n,{get:t[n],enumerable:!0})},A=(a,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of T(t))!v.call(a,d)&&d!==n&&r(a,d,{get:()=>t[d],enumerable:!(e=g(t,d))||e.enumerable});return a};var x=a=>A(r({},"__esModule",{value:!0}),a);var U={};I(U,{fullFormats:()=>y});module.exports=x(U);const y={date:l,time:i(!0),"date-time":$(!0),"iso-time":i(!1),"iso-date-time":$(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:D,"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]\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){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:P,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:Z,int32:{type:"number",validate:w},int64:{type:"number",validate:F},float:{type:"number",validate:_},double:{type:"number",validate:_},password:!0,binary:!0};function N(a){return a%4===0&&(a%100!==0||a%400===0)}const h=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,M=[0,31,28,31,30,31,30,31,31,30,31,30,31];function l(a){const t=h.exec(a);if(!t)return!1;const n=+t[1],e=+t[2],d=+t[3];return e>=1&&e<=12&&d>=1&&d<=(e===2&&N(n)?29:M[e])}const E=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function i(a){return function(n){const e=E.exec(n);if(!e)return!1;const d=+e[1],o=+e[2],u=+e[3],p=e[4],s=e[5]==="-"?-1:1,z=+(e[6]||0),c=+(e[7]||0);if(z>23||c>59||a&&!p)return!1;if(d<=23&&o<=59&&u<60)return!0;const f=o-c*s,m=d-z*s-(f<0?1:0);return(m===23||m===-1)&&(f===59||f===-1)&&u<61}}const R=/t|\s/i;function $(a){const t=i(a);return function(e){const d=e.split(R);return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a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function D(a){return j.test(a)&&S.test(a)}const b=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function Z(a){return b.lastIndex=0,b.test(a)}const H=-(2**31),Y=2**31-1;function w(a){return Number.isInteger(a)&&a<=Y&&a>=H}function F(a){return Number.isInteger(a)}function _(){return!0}const O=/[^\\]\\Z/;function P(a){if(O.test(a))return!1;try{return new RegExp(a),!0}catch{return!1}}/**
* @license

@@ -26,2 +25,2 @@ *

* SOFTWARE.
*/
*/0&&(module.exports={fullFormats});

@@ -1,26 +0,1 @@

"use strict";var re=Object.create;var D=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ce=(e,t)=>{for(var n in t)D(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of oe(t))!se.call(e,o)&&o!==n&&D(e,o,{get:()=>t[o],enumerable:!(r=ae(t,o))||r.enumerable});return e};var fe=(e,t,n)=>(n=e!=null?re(ie(e)):{},v(t||!e||!e.__esModule?D(n,"default",{value:e,enumerable:!0}):n,e)),ue=e=>v(D({},"__esModule",{value:!0}),e);var Ie={};ce(Ie,{createStaticHandler:()=>Be,errorToResponse:()=>m,isNotEmpty:()=>C,mapCompactResponse:()=>T,mapEarlyResponse:()=>g,mapResponse:()=>l,parseSetCookies:()=>L,serializeCookie:()=>$,streamResponse:()=>N});module.exports=ue(Ie);var te=require("cookie");var ee=require("@sinclair/typebox"),Ne=require("@sinclair/typebox/value"),He=require("@sinclair/typebox/compiler");var j=require("@sinclair/typebox"),x=require("@sinclair/typebox/system"),f=require("@sinclair/typebox"),I=require("@sinclair/typebox/compiler"),d=require("@sinclair/typebox/value");var _={date:K,time:B(!0),"date-time":U(!0),"iso-time":B(!1),"iso-date-time":U(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:be,"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\-._~!$&'"()*+,;=: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[1-9]?\d)){3}))|:)))$/i,regex:xe,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:Re,int32:{type:"number",validate:Oe},int64:{type:"number",validate:ke},float:{type:"number",validate:J},double:{type:"number",validate:J},password:!0,binary:!0};function de(e){return e%4===0&&(e%100!==0||e%400===0)}var le=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,pe=[0,31,28,31,30,31,30,31,31,30,31,30,31];function K(e){let t=le.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],o=+t[3];return r>=1&&r<=12&&o>=1&&o<=(r===2&&de(n)?29:pe[r])}var ye=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function B(e){return function(n){let r=ye.exec(n);if(!r)return!1;let o=+r[1],a=+r[2],i=+r[3],u=r[4],p=r[5]==="-"?-1:1,R=+(r[6]||0),h=+(r[7]||0);if(R>23||h>59||e&&!u)return!1;if(o<=23&&a<=59&&i<60)return!0;let S=a-h*p,O=o-R*p-(S<0?1:0);return(O===23||O===-1)&&(S===59||S===-1)&&i<61}}var me=/t|\s/i;function U(e){let t=B(e);return function(r){let o=r.split(me);return o.length===2&&K(o[0])&&t(o[1])}}var he=/\/|:/,ge=/^(?:[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 be(e){return he.test(e)&&ge.test(e)}var V=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function Re(e){return V.lastIndex=0,V.test(e)}var Se=-(2**31),Te=2**31-1;function Oe(e){return Number.isInteger(e)&&e<=Te&&e>=Se}function ke(e){return Number.isInteger(e)}function J(){return!0}var Ee=/[^\\]\\Z/;function xe(e){if(Ee.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var A=require("@sinclair/typebox/value");var Y=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,ve=Symbol("ElysiaErrorCode"),k=Symbol("ElysiaResponse"),G=(Y?.NODE_ENV??Y?.ENV)==="production";var E=e=>{if(!e)return{summary:void 0};let{message:t,path:n,value:r,type:o}=e,a=n.slice(1).replaceAll("/","."),i=n==="";switch(o){case 42:return{...e,summary:i?"Value should not be provided":`Property '${a}' should not be provided`};case 45:return{...e,summary:i?"Value is missing":`Property '${a}' is missing`};case 50:let u=t.indexOf("'"),p=t.slice(u+1,t.indexOf("'",u+1));return{...e,summary:i?"Value should be an email":`Property '${a}' should be ${p}`};case 54:return{...e,summary:`${t.slice(0,9)} property '${a}' to be ${t.slice(8)} but found: ${r}`};case 62:let R=e.schema.anyOf.map(h=>`'${h?.format??h.type}'`).join(", ");return{...e,summary:i?`Value should be one of ${R}`:`Property '${a}' should be one of: ${R}`};default:return{summary:t,...e}}},c=class e extends Error{constructor(n,r,o){o&&typeof o=="object"&&k in o&&(o=o.response);let a=G?void 0:"Errors"in r?r.Errors(o).First():A.Value.Errors(r,o).First(),i=a?.schema.error!==void 0?typeof a.schema.error=="function"?a.schema.error({type:n,validator:r,value:o,get errors(){return[...r.Errors(o)].map(E)}}):a.schema.error:void 0,u=a?.path||"root",p="";if(i!==void 0)p=typeof i=="object"?JSON.stringify(i):i+"";else if(G)p=JSON.stringify({type:"validation",on:n,summary:E(a).summary,message:a?.message,found:o});else{let R=r?.schema??r,h="Errors"in r?[...r.Errors(o)].map(E):[...A.Value.Errors(r,o)].map(E),S;try{S=A.Value.Create(R)}catch(O){S={type:"Could not create expected value",message:O?.message,error:O}}p=JSON.stringify({type:"validation",on:n,summary:h[0]?.summary,property:u,message:a?.message,expected:S,found:o,errors:h},null,2)}super(p);this.type=n;this.validator=r;this.value=o;this.code="VALIDATION";this.status=422;Object.setPrototypeOf(this,e.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(E):[...A.Value.Errors(this.validator,this.value)].map(E)}static simplifyModel(n){let r="schema"in n?n.schema:n;try{return A.Value.Create(r)}catch{return r}}get model(){return e.simplifyModel(this.validator)}toResponse(n){return new Response(this.message,{status:400,headers:{...n,"content-type":"application/json"}})}};var M=require("@sinclair/typebox/system"),X=require("@sinclair/typebox/compiler"),W=/(\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))/,Z=/(?: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\([^)]+\)/,Q=/^(?:(?:(?:(?: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)?)?$/,we=_.date,Ae=_["date-time"];f.FormatRegistry.Has("date")||x.TypeSystem.Format("date",e=>{let t=e.replace(/"/g,"");if(W.test(t)||Z.test(t)||Q.test(t)||we(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});f.FormatRegistry.Has("date-time")||x.TypeSystem.Format("date-time",e=>{let t=e.replace(/"/g,"");if(W.test(t)||Z.test(t)||Q.test(t)||Ae(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});Object.entries(_).forEach(e=>{let[t,n]=e;f.FormatRegistry.Has(t)||(n instanceof RegExp?x.TypeSystem.Format(t,r=>n.test(r)):typeof n=="function"&&x.TypeSystem.Format(t,n))});var s=Object.assign({},f.Type),q=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},z=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<q(e.minSize)||e.maxSize&&t.size>q(e.maxSize))return!1;if(e.extension)if(typeof e.extension=="string"){if(!t.type.startsWith(e.extension))return!1}else{for(let n=0;n<e.extension.length;n++)if(t.type.startsWith(e.extension[n]))return!0;return!1}return!0},je=j.TypeRegistry.Get("Files")??x.TypeSystem.Type("File",z),Fe=j.TypeRegistry.Get("Files")??x.TypeSystem.Type("Files",(e,t)=>{if(!Array.isArray(t))return z(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(!z(e,t[n]))return!1;return!0});f.FormatRegistry.Has("numeric")||f.FormatRegistry.Set("numeric",e=>!!e&&!isNaN(+e));f.FormatRegistry.Has("boolean")||f.FormatRegistry.Set("boolean",e=>e==="true"||e==="false");f.FormatRegistry.Has("ObjectString")||f.FormatRegistry.Set("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}});f.FormatRegistry.Has("ArrayString")||f.FormatRegistry.Set("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}});j.TypeRegistry.Set("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t));var y={Numeric:e=>{let t=f.Type.Number(e);return s.Transform(s.Union([s.String({format:"numeric",default:0}),s.Number(e)],e)).Decode(n=>{let r=+n;if(isNaN(r))return n;if(e&&!d.Value.Check(t,r))throw new c("property",t,r);return r}).Encode(n=>n)},Date:e=>{let t=f.Type.Date(e);return s.Transform(s.Union([f.Type.Date(e),s.String({format:"date",default:new Date().toISOString()}),s.String({format:"date-time",default:new Date().toISOString()})],e)).Decode(n=>{if(n instanceof Date)return n;let r=new Date(n);if(!d.Value.Check(t,r))throw new c("property",t,r);return r}).Encode(n=>typeof n=="string"?new Date(n):n)},BooleanString:e=>{let t=f.Type.Boolean(e);return s.Transform(s.Union([s.String({format:"boolean",default:!1}),s.Boolean(e)],e)).Decode(n=>{if(typeof n=="string")return n==="true";if(e&&!d.Value.Check(t,n))throw new c("property",t,n);return n}).Encode(n=>n)},ObjectString:(e,t)=>{let n=s.Object(e,t),r=JSON.stringify(d.Value.Create(n)),o;try{o=I.TypeCompiler.Compile(n)}catch{}return s.Transform(s.Union([s.String({format:"ObjectString",default:r}),n])).Decode(a=>{if(typeof a=="string"){if(a.charCodeAt(0)!==123)throw new c("property",n,a);try{a=JSON.parse(a)}catch{throw new c("property",n,a)}if(o){if(!o.Check(a))throw new c("property",n,a);return o.Decode(a)}if(!d.Value.Check(n,a))throw new c("property",n,a);return d.Value.Decode(n,a)}return a}).Encode(a=>{if(typeof a=="string")try{a=JSON.parse(a)}catch{throw new c("property",n,a)}if(!d.Value.Check(n,a))throw new c("property",n,a);return JSON.stringify(a)})},ArrayString:(e={},t)=>{let n=s.Array(e,t),r=JSON.stringify(d.Value.Create(n)),o;try{o=I.TypeCompiler.Compile(n)}catch{}return s.Transform(s.Union([s.String({format:"ArrayString",default:r}),n])).Decode(a=>{if(typeof a=="string"){if(a.charCodeAt(0)!==91)throw new c("property",n,a);try{a=JSON.parse(a)}catch{throw new c("property",n,a)}if(o){if(!o.Check(a))throw new c("property",n,a);return o.Decode(a)}if(!d.Value.Check(n,a))throw new c("property",n,a);return d.Value.Decode(n,a)}return a}).Encode(a=>{if(typeof a=="string")try{a=JSON.parse(a)}catch{throw new c("property",n,a)}if(!d.Value.Check(n,a))throw new c("property",n,a);return JSON.stringify(a)})},File:je,Files:(e={})=>s.Transform(Fe(e)).Decode(t=>Array.isArray(t)?t:[t]).Encode(t=>t),Nullable:e=>s.Union([e,s.Null()]),MaybeEmpty:e=>s.Union([e,s.Null(),s.Undefined()]),Cookie:(e,{domain:t,expires:n,httpOnly:r,maxAge:o,path:a,priority:i,sameSite:u,secure:p,secrets:R,sign:h,...S}={})=>{let O=s.Object(e,S);return O.config={domain:t,expires:n,httpOnly:r,maxAge:o,path:a,priority:i,sameSite:u,secure:p,secrets:R,sign:h},O},UnionEnum:(e,t={})=>{let n=e.every(r=>typeof r=="string")?{type:"string"}:e.every(r=>typeof r=="number")?{type:"number"}:e.every(r=>r===null)?{type:"null"}:{};if(e.some(r=>typeof r=="object"&&r!==null))throw new Error("This type does not support objects or arrays");return{default:e[0],...t,[j.Kind]:"UnionEnum",...n,enum:e}}};s.BooleanString=y.BooleanString;s.ObjectString=y.ObjectString;s.ArrayString=y.ArrayString;s.Numeric=y.Numeric;s.File=(e={})=>y.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"});s.Files=(e={})=>y.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});s.Nullable=e=>y.Nullable(e);s.MaybeEmpty=y.MaybeEmpty;s.Cookie=y.Cookie;s.Date=y.Date;s.UnionEnum=y.UnionEnum;var Pe=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],ct=Pe.reduce((e,t)=>(e[t]=!0,e),{});var De=typeof Bun<"u",ft=De&&typeof Bun.hash=="function";var H={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},Ce=Object.fromEntries(Object.entries(H).map(([e,t])=>[t,e]));var ut=new TextEncoder;var dt=Symbol("ElysiaFormData"),lt=Symbol("ElysiaRequestId"),F=e=>{let t=new FormData;for(let[n,r]of Object.entries(e)){if(Array.isArray(r)){for(let o of r)r instanceof File&&t.append(n,r,r.name),t.append(n,o);continue}r instanceof File&&t.append(n,r,r.name),t.append(n,r)}return t};var _e=require("cookie"),Me=fe(require("fast-decode-uri-component"));var w=class{constructor(t,n,r={}){this.name=t;this.jar=n;this.initial=r}get cookie(){return this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]}set cookie(t){this.name in this.jar||(this.jar[this.name]=this.initial),this.jar[this.name]=t}get value(){return this.cookie.value}set value(t){this.cookie.value=t}get expires(){return this.cookie.expires}set expires(t){this.cookie.expires=t,console.log(this.cookie)}get maxAge(){return this.cookie.maxAge}set maxAge(t){this.cookie.maxAge=t}get domain(){return this.cookie.domain}set domain(t){this.cookie.domain=t}get path(){return this.cookie.path}set path(t){this.cookie.path=t}get secure(){return this.cookie.secure}set secure(t){this.cookie.secure=t}get httpOnly(){return this.cookie.httpOnly}set httpOnly(t){this.cookie.httpOnly=t}get sameSite(){return this.cookie.sameSite}set sameSite(t){this.cookie.sameSite=t}get priority(){return this.cookie.priority}set priority(t){this.cookie.priority=t}get partitioned(){return this.cookie.partitioned}set partitioned(t){this.cookie.partitioned=t}get secrets(){return this.cookie.secrets}set secrets(t){this.cookie.secrets=t}update(t){return this.cookie=Object.assign(this.cookie,typeof t=="function"?t(this.cookie):t),this}set(t){return this.cookie=Object.assign({...this.initial,value:this.value},typeof t=="function"?t(this.cookie):t),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 ne="toJSON"in new Headers,C=e=>{if(!e)return!1;for(let t in e)return!0;return!1},P=(e,t)=>{let n=e.size;if(!t&&n||n&&t&&t.status!==206&&t.status!==304&&t.status!==412&&t.status!==416){if(t){if(t.headers instanceof Headers)if(ne)t.headers=t.headers.toJSON();else for(let[r,o]of t.headers.entries())r in t.headers&&(t.headers[r]=o);return new Response(e,{status:t.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`},t.headers)})}return new Response(e,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`}})}return new Response(e)},L=(e,t)=>{if(!e)return e;e.delete("set-cookie");for(let n=0;n<t.length;n++){let r=t[n].indexOf("=");e.append("set-cookie",`${t[n].slice(0,r)}=${t[n].slice(r+1)||""}`)}return e},$=e=>{if(!e||!C(e))return;let t=[];for(let[n,r]of Object.entries(e)){if(!n||!r)continue;let o=r.value;o!=null&&t.push((0,te.serialize)(n,typeof o=="object"?JSON.stringify(o):o+"",r))}if(t.length!==0)return t.length===1?t[0]:t},b=async(e,t,n)=>{let r=e.next();return r instanceof Promise&&(r=await r),r.done?t?l(r.value,t,n):T(r.value,n):new Response(new ReadableStream({async start(o){let a=!1;if(n?.signal.addEventListener("abort",()=>{a=!0;try{o.close()}catch{}}),r.value!==void 0&&r.value!==null)if(typeof r.value=="object")try{o.enqueue(Buffer.from(JSON.stringify(r.value)))}catch{o.enqueue(Buffer.from(r.value.toString()))}else o.enqueue(Buffer.from(r.value.toString()));for await(let i of e){if(a)break;if(i!=null){if(typeof i=="object")try{o.enqueue(Buffer.from(JSON.stringify(i)))}catch{o.enqueue(Buffer.from(i.toString()))}else o.enqueue(Buffer.from(i.toString()));await new Promise(u=>setTimeout(()=>u(),0))}}try{o.close()}catch{}}}),{...t,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...t?.headers}})};async function*N(e){let t=e.body;if(!t)return;let n=t.getReader(),r=new TextDecoder;try{for(;;){let{done:o,value:a}=await n.read();if(o)break;yield r.decode(a)}}finally{n.releaseLock()}}var l=(e,t,n)=>{if(C(t.headers)||t.status!==200||t.redirect||t.cookie){if(typeof t.status=="string"&&(t.status=H[t.status]),t.redirect&&(t.headers.Location=t.redirect,(!t.status||t.status<300||t.status>=400)&&(t.status=302)),t.cookie&&C(t.cookie)){let r=$(t.cookie);r&&(t.headers["set-cookie"]=r)}switch(t.headers["set-cookie"]&&Array.isArray(t.headers["set-cookie"])&&(t.headers=L(new Headers(t.headers),t.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,t);case"Blob":return P(e,t);case"Array":return Response.json(e,t);case"Object":let r=e[k];if(r)return t.status=r,l(e.response,t,n);for(let a in Object.values(e))switch(a?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(F(e));default:break}return Response.json(e,t);case"ReadableStream":return t.headers["content-type"]?.startsWith("text/event-stream")||(t.headers["content-type"]="text/event-stream; charset=utf-8"),n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,t);case void 0:return e?Response.json(e,t):new Response("",t);case"Response":let o=!1;if(t.headers instanceof Headers)for(let a of t.headers.keys())if(a==="set-cookie"){if(o)continue;o=!0;for(let i of t.headers.getSetCookie())e.headers.append("set-cookie",i)}else e.headers.append(a,t.headers?.get(a)??"");else for(let a in t.headers)e.headers.append(a,t.headers[a]);return e.status!==t.status&&(t.status=e.status),e.headers.get("transfer-encoding")==="chunked"?b(N(e),t,n):e;case"Error":return m(e,t);case"Promise":return e.then(a=>l(a,t));case"Function":return l(e(),t);case"Number":case"Boolean":return new Response(e.toString(),t);case"Cookie":return e instanceof w?new Response(e.value,t):new Response(e?.toString(),t);case"FormData":return new Response(e,t);default:if(e instanceof Response){let a=!1;if(t.headers instanceof Headers)for(let i of t.headers.keys())if(i==="set-cookie"){if(a)continue;a=!0;for(let u of t.headers.getSetCookie())e.headers.append("set-cookie",u)}else e.headers.append(i,t.headers?.get(i)??"");else for(let i in t.headers)e.headers.append(i,t.headers[i]);if(ne)t.headers=e.headers.toJSON();else for(let[i,u]of e.headers.entries())i in t.headers&&(t.headers[i]=u);return e}if(e instanceof Promise)return e.then(a=>l(a,t));if(e instanceof Error)return m(e,t);if(typeof e?.next=="function")return b(e,t,n);if("toResponse"in e)return l(e.toResponse(),t);if("charCodeAt"in e){let a=e.charCodeAt(0);if(a===123||a===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 new Response(e);case"Blob":return P(e,t);case"Array":return Response.json(e);case"Object":let r=e[k];if(r)return t.status=r,l(e.response,t,n);for(let o in Object.values(e))switch(o?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(F(e),t);default:break}return Response.json(e,t);case"ReadableStream":return n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?b(N(e),t,n):e;case"Error":return m(e,t);case"Promise":return e.then(o=>{let a=T(o,n);return a!==void 0?a:new Response("")});case"Function":return T(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof w?new Response(e.value,t):new Response(e?.toString(),t);case"FormData":return new Response(e,t);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(o=>l(o,t));if(e instanceof Error)return m(e,t);if(typeof e?.next=="function")return b(e,t,n);if("toResponse"in e)return l(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)}},g=(e,t,n)=>{if(e!=null)if(C(t.headers)||t.status!==200||t.redirect||t.cookie){if(typeof t.status=="string"&&(t.status=H[t.status]),t.redirect&&(t.headers.Location=t.redirect,(!t.status||t.status<300||t.status>=400)&&(t.status=302)),t.cookie&&C(t.cookie)){let r=$(t.cookie);r&&(t.headers["set-cookie"]=r)}switch(t.headers["set-cookie"]&&Array.isArray(t.headers["set-cookie"])&&(t.headers=L(new Headers(t.headers),t.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,t);case"Blob":return P(e,t);case"Array":return Response.json(e,t);case"Object":let r=e[k];if(r)return t.status=r,g(e.response,t,n);for(let a in Object.values(e))switch(a?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(F(e),t);default:break}return Response.json(e,t);case"ReadableStream":return t.headers["content-type"]?.startsWith("text/event-stream")||(t.headers["content-type"]="text/event-stream; charset=utf-8"),n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,t);case void 0:return e?Response.json(e,t):void 0;case"Response":let o=!1;if(t.headers instanceof Headers)for(let a of t.headers.keys())if(a==="set-cookie"){if(o)continue;o=!0;for(let i of t.headers.getSetCookie())e.headers.append("set-cookie",i)}else e.headers.append(a,t.headers?.get(a)??"");else for(let a in t.headers)e.headers.append(a,t.headers[a]);return e.status!==t.status&&(t.status=e.status),e.headers.get("transfer-encoding")==="chunked"?b(N(e),t,n):e;case"Promise":return e.then(a=>{let i=g(a,t);if(i!==void 0)return i});case"Error":return m(e,t);case"Function":return g(e(),t);case"Number":case"Boolean":return new Response(e.toString(),t);case"FormData":return new Response(e);case"Cookie":return e instanceof w?new Response(e.value,t):new Response(e?.toString(),t);default:if(e instanceof Response){let a=!1;if(t.headers instanceof Headers)for(let i of t.headers.keys())if(i==="set-cookie"){if(a)continue;a=!0;for(let u of t.headers.getSetCookie())e.headers.append("set-cookie",u)}else e.headers.append(i,t.headers?.get(i)??"");else for(let i in t.headers)e.headers.append(i,t.headers[i]);return e.status!==t.status&&(t.status=e.status),e}if(e instanceof Promise)return e.then(a=>g(a,t));if(e instanceof Error)return m(e,t);if(typeof e?.next=="function")return b(e,t,n);if("toResponse"in e)return g(e.toResponse(),t);if("charCodeAt"in e){let a=e.charCodeAt(0);if(a===123||a===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 new Response(e);case"Blob":return P(e,t);case"Array":return Response.json(e);case"Object":let r=e[k];if(r)return t.status=r,g(e.response,t,n);for(let o in Object.values(e))switch(o?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(F(e),t);default:break}return Response.json(e,t);case"ReadableStream":return n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?b(N(e)):e;case"Promise":return e.then(o=>{let a=g(o,t);if(a!==void 0)return a});case"Error":return m(e,t);case"Function":return T(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof w?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=>g(o,t));if(e instanceof Error)return m(e,t);if(typeof e?.next=="function")return b(e,t,n);if("toResponse"in e)return g(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=(e,t)=>{switch(e?.constructor?.name){case"String":return new Response(e);case"Blob":return P(e);case"Array":return Response.json(e);case"Object":if(e[k])return l(e.response,{status:e[k],headers:{}});e:for(let n of Object.values(e))switch(n?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response(F(e));case"Object":break e;default:break}return Response.json(e);case"ReadableStream":return t?.signal.addEventListener("abort",{handleEvent(){t?.signal.aborted||e.cancel(t)}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?b(N(e)):e;case"Error":return m(e);case"Promise":return e.then(n=>T(n,t));case"Function":return T(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=>T(n,t));if(e instanceof Error)return m(e);if(typeof e?.next=="function")return b(e,void 0,t);if("toResponse"in e)return T(e.toResponse());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)}},m=(e,t)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:t?.status!==200?t?.status??500:500,headers:t?.headers}),Be=(e,t,n={})=>{if(typeof e=="function")return;let r=l(e,{headers:n});if(t.parse.length===0&&t.transform.length===0&&t.beforeHandle.length===0&&t.afterHandle.length===0)return r.clone.bind(r)};0&&(module.exports={createStaticHandler,errorToResponse,isNotEmpty,mapCompactResponse,mapEarlyResponse,mapResponse,parseSetCookies,serializeCookie,streamResponse});
/**
* @license
*
* MIT License
*
* Copyright (c) 2020 Evgeny Poberezkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
"use strict";var w=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var E=(e,a)=>{for(var n in a)w(e,n,{get:a[n],enumerable:!0})},F=(e,a,n,t)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of j(a))!x.call(e,r)&&r!==n&&w(e,r,{get:()=>a[r],enumerable:!(t=C(a,r))||t.enumerable});return e};var O=e=>F(w({},"__esModule",{value:!0}),e);var A={};E(A,{createStaticHandler:()=>B,errorToResponse:()=>c,isNotEmpty:()=>h,mapCompactResponse:()=>d,mapEarlyResponse:()=>f,mapResponse:()=>i,parseSetCookies:()=>g,serializeCookie:()=>k,streamResponse:()=>m});module.exports=O(A);var v=require("cookie"),R=require("./utils"),S=require("./cookies"),y=require("./error");const p="toJSON"in new Headers,h=e=>{if(!e)return!1;for(const a in e)return!0;return!1},b=(e,a)=>{const n=e.size;if(!a&&n||n&&a&&a.status!==206&&a.status!==304&&a.status!==412&&a.status!==416){if(a){if(a.headers instanceof Headers)if(p)a.headers=a.headers.toJSON();else for(const[t,r]of a.headers.entries())t in a.headers&&(a.headers[t]=r);return new Response(e,{status:a.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`},a.headers)})}return new Response(e,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${n-1}/${n}`}})}return new Response(e)},g=(e,a)=>{if(!e)return e;e.delete("set-cookie");for(let n=0;n<a.length;n++){const t=a[n].indexOf("=");e.append("set-cookie",`${a[n].slice(0,t)}=${a[n].slice(t+1)||""}`)}return e},k=e=>{if(!e||!h(e))return;const a=[];for(const[n,t]of Object.entries(e)){if(!n||!t)continue;const r=t.value;r!=null&&a.push((0,v.serialize)(n,typeof r=="object"?JSON.stringify(r):r+"",t))}if(a.length!==0)return a.length===1?a[0]:a},u=async(e,a,n)=>{let t=e.next();return t instanceof Promise&&(t=await t),t.done?a?i(t.value,a,n):d(t.value,n):new Response(new ReadableStream({async start(r){let s=!1;if(n?.signal.addEventListener("abort",()=>{s=!0;try{r.close()}catch{}}),t.value!==void 0&&t.value!==null)if(typeof t.value=="object")try{r.enqueue(Buffer.from(JSON.stringify(t.value)))}catch{r.enqueue(Buffer.from(t.value.toString()))}else r.enqueue(Buffer.from(t.value.toString()));for await(const o of e){if(s)break;if(o!=null){if(typeof o=="object")try{r.enqueue(Buffer.from(JSON.stringify(o)))}catch{r.enqueue(Buffer.from(o.toString()))}else r.enqueue(Buffer.from(o.toString()));await new Promise(l=>setTimeout(()=>l(),0))}}try{r.close()}catch{}}}),{...a,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...a?.headers}})};async function*m(e){const a=e.body;if(!a)return;const n=a.getReader(),t=new TextDecoder;try{for(;;){const{done:r,value:s}=await n.read();if(r)break;yield t.decode(s)}}finally{n.releaseLock()}}const i=(e,a,n)=>{if(h(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=R.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&h(a.cookie)){const t=k(a.cookie);t&&(a.headers["set-cookie"]=t)}switch(a.headers["set-cookie"]&&Array.isArray(a.headers["set-cookie"])&&(a.headers=g(new Headers(a.headers),a.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,a);case"Blob":return b(e,a);case"Array":return Response.json(e,a);case"Object":const t=e[y.ELYSIA_RESPONSE];if(t)return a.status=t,i(e.response,a,n);for(const s in Object.values(e))switch(s?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response((0,R.form)(e));default:break}return Response.json(e,a);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream; charset=utf-8"),n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,a);case void 0:return e?Response.json(e,a):new Response("",a);case"Response":let r=!1;if(a.headers instanceof Headers)for(const s of a.headers.keys())if(s==="set-cookie"){if(r)continue;r=!0;for(const o of a.headers.getSetCookie())e.headers.append("set-cookie",o)}else e.headers.append(s,a.headers?.get(s)??"");else for(const s in a.headers)e.headers.append(s,a.headers[s]);return e.status!==a.status&&(a.status=e.status),e.headers.get("transfer-encoding")==="chunked"?u(m(e),a,n):e;case"Error":return c(e,a);case"Promise":return e.then(s=>i(s,a));case"Function":return i(e(),a);case"Number":case"Boolean":return new Response(e.toString(),a);case"Cookie":return e instanceof S.Cookie?new Response(e.value,a):new Response(e?.toString(),a);case"FormData":return new Response(e,a);default:if(e instanceof Response){let s=!1;if(a.headers instanceof Headers)for(const o of a.headers.keys())if(o==="set-cookie"){if(s)continue;s=!0;for(const l of a.headers.getSetCookie())e.headers.append("set-cookie",l)}else e.headers.append(o,a.headers?.get(o)??"");else for(const o in a.headers)e.headers.append(o,a.headers[o]);if(p)a.headers=e.headers.toJSON();else for(const[o,l]of e.headers.entries())o in a.headers&&(a.headers[o]=l);return e}if(e instanceof Promise)return e.then(s=>i(s,a));if(e instanceof Error)return c(e,a);if(typeof e?.next=="function")return u(e,a,n);if("toResponse"in e)return i(e.toResponse(),a);if("charCodeAt"in e){const s=e.charCodeAt(0);if(s===123||s===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e,a)}}else switch(e?.constructor?.name){case"String":return new Response(e);case"Blob":return b(e,a);case"Array":return Response.json(e);case"Object":const t=e[y.ELYSIA_RESPONSE];if(t)return a.status=t,i(e.response,a,n);for(const r in Object.values(e))switch(r?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response((0,R.form)(e),a);default:break}return Response.json(e,a);case"ReadableStream":return n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?u(m(e),a,n):e;case"Error":return c(e,a);case"Promise":return e.then(r=>{const s=d(r,n);return s!==void 0?s:new Response("")});case"Function":return d(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof S.Cookie?new Response(e.value,a):new Response(e?.toString(),a);case"FormData":return new Response(e,a);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(r=>i(r,a));if(e instanceof Error)return c(e,a);if(typeof e?.next=="function")return u(e,a,n);if("toResponse"in e)return i(e.toResponse(),a);if("charCodeAt"in e){const r=e.charCodeAt(0);if(r===123||r===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e)}},f=(e,a,n)=>{if(e!=null)if(h(a.headers)||a.status!==200||a.redirect||a.cookie){if(typeof a.status=="string"&&(a.status=R.StatusMap[a.status]),a.redirect&&(a.headers.Location=a.redirect,(!a.status||a.status<300||a.status>=400)&&(a.status=302)),a.cookie&&h(a.cookie)){const t=k(a.cookie);t&&(a.headers["set-cookie"]=t)}switch(a.headers["set-cookie"]&&Array.isArray(a.headers["set-cookie"])&&(a.headers=g(new Headers(a.headers),a.headers["set-cookie"])),e?.constructor?.name){case"String":return new Response(e,a);case"Blob":return b(e,a);case"Array":return Response.json(e,a);case"Object":const t=e[y.ELYSIA_RESPONSE];if(t)return a.status=t,f(e.response,a,n);for(const s in Object.values(e))switch(s?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response((0,R.form)(e),a);default:break}return Response.json(e,a);case"ReadableStream":return a.headers["content-type"]?.startsWith("text/event-stream")||(a.headers["content-type"]="text/event-stream; charset=utf-8"),n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,a);case void 0:return e?Response.json(e,a):void 0;case"Response":let r=!1;if(a.headers instanceof Headers)for(const s of a.headers.keys())if(s==="set-cookie"){if(r)continue;r=!0;for(const o of a.headers.getSetCookie())e.headers.append("set-cookie",o)}else e.headers.append(s,a.headers?.get(s)??"");else for(const s in a.headers)e.headers.append(s,a.headers[s]);return e.status!==a.status&&(a.status=e.status),e.headers.get("transfer-encoding")==="chunked"?u(m(e),a,n):e;case"Promise":return e.then(s=>{const o=f(s,a);if(o!==void 0)return o});case"Error":return c(e,a);case"Function":return f(e(),a);case"Number":case"Boolean":return new Response(e.toString(),a);case"FormData":return new Response(e);case"Cookie":return e instanceof S.Cookie?new Response(e.value,a):new Response(e?.toString(),a);default:if(e instanceof Response){let s=!1;if(a.headers instanceof Headers)for(const o of a.headers.keys())if(o==="set-cookie"){if(s)continue;s=!0;for(const l of a.headers.getSetCookie())e.headers.append("set-cookie",l)}else e.headers.append(o,a.headers?.get(o)??"");else for(const o in a.headers)e.headers.append(o,a.headers[o]);return e.status!==a.status&&(a.status=e.status),e}if(e instanceof Promise)return e.then(s=>f(s,a));if(e instanceof Error)return c(e,a);if(typeof e?.next=="function")return u(e,a,n);if("toResponse"in e)return f(e.toResponse(),a);if("charCodeAt"in e){const s=e.charCodeAt(0);if(s===123||s===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e,a)}}else switch(e?.constructor?.name){case"String":return new Response(e);case"Blob":return b(e,a);case"Array":return Response.json(e);case"Object":const t=e[y.ELYSIA_RESPONSE];if(t)return a.status=t,f(e.response,a,n);for(const r in Object.values(e))switch(r?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response((0,R.form)(e),a);default:break}return Response.json(e,a);case"ReadableStream":return n?.signal.addEventListener("abort",{handleEvent(){n?.signal.aborted||e.cancel(n)}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?u(m(e)):e;case"Promise":return e.then(r=>{const s=f(r,a);if(s!==void 0)return s});case"Error":return c(e,a);case"Function":return d(e(),n);case"Number":case"Boolean":return new Response(e.toString());case"Cookie":return e instanceof S.Cookie?new Response(e.value,a):new Response(e?.toString(),a);case"FormData":return new Response(e);default:if(e instanceof Response)return e;if(e instanceof Promise)return e.then(r=>f(r,a));if(e instanceof Error)return c(e,a);if(typeof e?.next=="function")return u(e,a,n);if("toResponse"in e)return f(e.toResponse(),a);if("charCodeAt"in e){const r=e.charCodeAt(0);if(r===123||r===91)return a.headers["Content-Type"]||(a.headers["Content-Type"]="application/json"),new Response(JSON.stringify(e),a)}return new Response(e)}},d=(e,a)=>{switch(e?.constructor?.name){case"String":return new Response(e);case"Blob":return b(e);case"Array":return Response.json(e);case"Object":if(e[y.ELYSIA_RESPONSE])return i(e.response,{status:e[y.ELYSIA_RESPONSE],headers:{}});e:for(const n of Object.values(e))switch(n?.constructor?.name){case"Blob":case"File":case"ArrayBuffer":case"FileRef":return new Response((0,R.form)(e));case"Object":break e;default:break}return Response.json(e);case"ReadableStream":return a?.signal.addEventListener("abort",{handleEvent(){a?.signal.aborted||e.cancel(a)}},{once:!0}),new Response(e,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:return e?new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}}):new Response("");case"Response":return e.headers.get("transfer-encoding")==="chunked"?u(m(e)):e;case"Error":return c(e);case"Promise":return e.then(n=>d(n,a));case"Function":return d(e(),a);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=>d(n,a));if(e instanceof Error)return c(e);if(typeof e?.next=="function")return u(e,void 0,a);if("toResponse"in e)return d(e.toResponse());if("charCodeAt"in e){const n=e.charCodeAt(0);if(n===123||n===91)return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}})}return new Response(e)}},c=(e,a)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:a?.status!==200?a?.status??500:500,headers:a?.headers}),B=(e,a,n={})=>{if(typeof e=="function")return;const t=i(e,{headers:n});if(a.parse.length===0&&a.transform.length===0&&a.beforeHandle.length===0&&a.afterHandle.length===0)return t.clone.bind(t)};0&&(module.exports={createStaticHandler,errorToResponse,isNotEmpty,mapCompactResponse,mapEarlyResponse,mapResponse,parseSetCookies,serializeCookie,streamResponse});

@@ -1,4 +0,4 @@

"use strict";var c=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var s in e)c(t,s,{get:e[s],enumerable:!0})},R=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!w.call(t,r)&&r!==s&&c(t,r,{get:()=>e[r],enumerable:!(o=y(e,r))||o.enumerable});return t};var S=t=>R(c({},"__esModule",{value:!0}),t);var L={};p(L,{bracketPairRange:()=>b,bracketPairRangeReverse:()=>k,extractMainParameter:()=>A,findAlias:()=>h,findParameterReference:()=>O,hasReturn:()=>P,inferBodyReference:()=>I,isContextPassToFunction:()=>q,removeColonAlias:()=>a,removeDefaultParameter:()=>H,retrieveRootParamters:()=>f,separateFunction:()=>g,sucrose:()=>E});module.exports=S(L);var P=t=>{let e=typeof t=="object"?t.fn.toString():typeof t=="string"?t.toString():t,s=e.indexOf(")");return e.charCodeAt(s+2)===61&&e.charCodeAt(s+5)!==123?!0:e.includes("return")},g=t=>{t.startsWith("async")&&(t=t.slice(5)),t=t.trimStart();let e=-1;if(t.charCodeAt(0)===40&&(e=t.indexOf("=>",t.indexOf(")")),e!==-1)){let r=e;for(;r>0&&t.charCodeAt(--r)!==41;);let n=t.slice(e+2);return n.charCodeAt(0)===32&&(n=n.trimStart()),[t.slice(1,r),n,{isArrowReturn:n.charCodeAt(0)!==123}]}if(t.startsWith("function")){e=t.indexOf("(");let r=t.indexOf(")");return[t.slice(e+1,r),t.slice(r+2),{isArrowReturn:!1}]}let s=t.indexOf("(");if(s!==-1){let r=t.indexOf(`
`,2),n=t.slice(0,r),i=n.lastIndexOf(")")+1,u=t.slice(r+1);return[n.slice(s,i),"{"+u,{isArrowReturn:!1}]}let o=t.split(`
`,2);return[o[0],o[1],{isArrowReturn:!1}]},b=t=>{let e=t.indexOf("{");if(e===-1)return[-1,0];let s=e+1,o=1;for(;s<t.length;s++){let r=t.charCodeAt(s);if(r===123?o++:r===125&&o--,o===0)break}return o!==0?[0,t.length]:[e,s+1]},k=t=>{let e=t.lastIndexOf("}");if(e===-1)return[-1,0];let s=e-1,o=1;for(;s>=0;s--){let r=t.charCodeAt(s);if(r===125?o++:r===123&&o--,o===0)break}return o!==0?[-1,0]:[s,e+1]},a=t=>{for(;;){let e=t.indexOf(":");if(e===-1)break;let s=t.indexOf(",",e);s===-1&&(s=t.indexOf("}",e)-1),s===-2&&(s=t.length),t=t.slice(0,e)+t.slice(s)}return t},f=t=>{let e=!1;t.charCodeAt(0)===40&&(t=t.slice(1,-1)),t.charCodeAt(0)===123&&(e=!0,t=t.slice(1,-1)),t=t.replace(/( |\t|\n)/g,"").trim();let s=[];for(;;){let[r,n]=b(t);if(r===-1)break;s.push(t.slice(0,r-1)),t.charCodeAt(n)===44&&n++,t=t.slice(n)}t=a(t),t&&(s=s.concat(t.split(",")));let o=[];for(let r of s){if(r.indexOf(",")===-1){o.push(r);continue}for(let n of r.split(","))o.push(n.trim())}return s=o,{hasParenthesis:e,parameters:s}},O=(t,e)=>{let{parameters:s,hasParenthesis:o}=f(t);return!e.query&&s.includes("query")&&(e.query=!0),!e.headers&&s.includes("headers")&&(e.headers=!0),!e.body&&s.includes("body")&&(e.body=!0),!e.cookie&&s.includes("cookie")&&(e.cookie=!0),!e.set&&s.includes("set")&&(e.set=!0),!e.server&&s.includes("server")&&(e.server=!0),o?`{ ${s.join(", ")} }`:s.join(", ")},C=(t,e,s)=>{let o=e.indexOf(t+`
`,s),r=e.indexOf(t+" ",s),n=e.indexOf(t+",",s),i=e.indexOf(t+";",s),u=e.indexOf(t+" ",s);return[o,r,n,i,u].filter(d=>d>0).sort((d,l)=>d-l)[0]||-1};var h=(t,e,s=0)=>{if(s>5)return[];let o=[],r=e;for(;;){let n=C(" = "+t,r);if(n===-1){let d=r.indexOf(" = "+t);if(d+3+t.length!==r.length)break;n=d}let i=r.slice(0,n),u=i.slice(i.lastIndexOf(" ")+1);if(u==="}"){let[d,l]=k(i);o.push(a(r.slice(d,l))),r=r.slice(n+3+t.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),r=r.slice(n+3+t.length)}for(let n of o){if(n.charCodeAt(0)===123)continue;let i=h(n,e);i.length>0&&o.push(...i)}return o},A=t=>{if(!t)return;if(t.charCodeAt(0)!==123)return t;if(t=t.slice(2,-2),!t.includes(","))return t.includes("...")?t.slice(t.indexOf("...")+3):void 0;let s=t.indexOf("...");if(s!==-1)return t.slice(s+3).trimEnd()},I=(t,e,s)=>{let o=(r,n)=>t.includes(n+"."+r)||t.includes(n+'["'+r+'"]')||t.includes(n+"['"+r+"']");for(let r of e)if(r){if(r.charCodeAt(0)===123){let n=f(r).parameters;!s.query&&n.includes("query")&&(s.query=!0),!s.headers&&n.includes("headers")&&(s.headers=!0),!s.body&&n.includes("body")&&(s.body=!0),!s.cookie&&n.includes("cookie")&&(s.cookie=!0),!s.set&&n.includes("set")&&(s.set=!0),!s.query&&n.includes("server")&&(s.server=!0);continue}if(!s.query&&o("query",r)&&(s.query=!0),(t.includes("return "+r)||t.includes("return "+r+".query"))&&(s.query=!0),!s.headers&&o("headers",r)&&(s.headers=!0),!s.body&&o("body",r)&&(s.body=!0),!s.cookie&&o("cookie",r)&&(s.cookie=!0),!s.set&&o("set",r)&&(s.set=!0),!s.server&&o("server",r)&&(s.server=!0),s.query&&s.headers&&s.body&&s.cookie&&s.set&&s.server)break}return e},H=t=>{for(;;){let e=t.indexOf("=");if(e===-1)break;let s=t.indexOf(",",e),o=t.indexOf("}",e),r=[s,o].filter(n=>n>0).sort((n,i)=>n-i)[0]||-1;if(r===-1){t=t.slice(0,e);break}t=t.slice(0,e)+t.slice(r)}return t.split(",").map(e=>e.trim()).join(", ")},q=(t,e,s)=>{try{let o=new RegExp(`(?:\\w)\\((?:.*)?${t}`,"gs");o.test(e);let r=e.charCodeAt(o.lastIndex);return r===41||r===44?(s.query=!0,s.headers=!0,s.body=!0,s.cookie=!0,s.set=!0,s.server=!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(e),console.log("--- context ---"),console.log(t),!0}},E=(t,e={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1})=>{let s=[];t.handler&&typeof t.handler=="function"&&s.push(t.handler),t.request?.length&&s.push(...t.request),t.beforeHandle?.length&&s.push(...t.beforeHandle),t.parse?.length&&s.push(...t.parse),t.error?.length&&s.push(...t.error),t.transform?.length&&s.push(...t.transform),t.afterHandle?.length&&s.push(...t.afterHandle),t.mapResponse?.length&&s.push(...t.mapResponse),t.afterResponse?.length&&s.push(...t.afterResponse);for(let o of s){if(!o)continue;let r="fn"in o?o.fn:o,[n,i,{isArrowReturn:u}]=g(r.toString()),d=O(n,e),l=A(d);if(l){let x=h(l,i);x.splice(0,-1,l),q(l,i,e)||I(i,x,e),!e.query&&i.includes("return "+l+".query")&&(e.query=!0)}if(e.query&&e.headers&&e.body&&e.cookie&&e.set&&e.server)break}return e};0&&(module.exports={bracketPairRange,bracketPairRangeReverse,extractMainParameter,findAlias,findParameterReference,hasReturn,inferBodyReference,isContextPassToFunction,removeColonAlias,removeDefaultParameter,retrieveRootParamters,separateFunction,sucrose});
"use strict";var c=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var s in e)c(t,s,{get:e[s],enumerable:!0})},R=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!w.call(t,r)&&r!==s&&c(t,r,{get:()=>e[r],enumerable:!(o=y(e,r))||o.enumerable});return t};var S=t=>R(c({},"__esModule",{value:!0}),t);var L={};p(L,{bracketPairRange:()=>b,bracketPairRangeReverse:()=>k,extractMainParameter:()=>A,findAlias:()=>h,findParameterReference:()=>O,hasReturn:()=>P,inferBodyReference:()=>I,isContextPassToFunction:()=>q,removeColonAlias:()=>a,removeDefaultParameter:()=>H,retrieveRootParamters:()=>f,separateFunction:()=>g,sucrose:()=>E});module.exports=S(L);const P=t=>{const e=typeof t=="object"?t.fn.toString():typeof t=="string"?t.toString():t,s=e.indexOf(")");return e.charCodeAt(s+2)===61&&e.charCodeAt(s+5)!==123?!0:e.includes("return")},g=t=>{t.startsWith("async")&&(t=t.slice(5)),t=t.trimStart();let e=-1;if(t.charCodeAt(0)===40&&(e=t.indexOf("=>",t.indexOf(")")),e!==-1)){let r=e;for(;r>0&&t.charCodeAt(--r)!==41;);let n=t.slice(e+2);return n.charCodeAt(0)===32&&(n=n.trimStart()),[t.slice(1,r),n,{isArrowReturn:n.charCodeAt(0)!==123}]}if(t.startsWith("function")){e=t.indexOf("(");const r=t.indexOf(")");return[t.slice(e+1,r),t.slice(r+2),{isArrowReturn:!1}]}const s=t.indexOf("(");if(s!==-1){const r=t.indexOf(`
`,2),n=t.slice(0,r),i=n.lastIndexOf(")")+1,u=t.slice(r+1);return[n.slice(s,i),"{"+u,{isArrowReturn:!1}]}const o=t.split(`
`,2);return[o[0],o[1],{isArrowReturn:!1}]},b=t=>{const e=t.indexOf("{");if(e===-1)return[-1,0];let s=e+1,o=1;for(;s<t.length;s++){const r=t.charCodeAt(s);if(r===123?o++:r===125&&o--,o===0)break}return o!==0?[0,t.length]:[e,s+1]},k=t=>{const e=t.lastIndexOf("}");if(e===-1)return[-1,0];let s=e-1,o=1;for(;s>=0;s--){const r=t.charCodeAt(s);if(r===125?o++:r===123&&o--,o===0)break}return o!==0?[-1,0]:[s,e+1]},a=t=>{for(;;){const e=t.indexOf(":");if(e===-1)break;let s=t.indexOf(",",e);s===-1&&(s=t.indexOf("}",e)-1),s===-2&&(s=t.length),t=t.slice(0,e)+t.slice(s)}return t},f=t=>{let e=!1;t.charCodeAt(0)===40&&(t=t.slice(1,-1)),t.charCodeAt(0)===123&&(e=!0,t=t.slice(1,-1)),t=t.replace(/( |\t|\n)/g,"").trim();let s=[];for(;;){let[r,n]=b(t);if(r===-1)break;s.push(t.slice(0,r-1)),t.charCodeAt(n)===44&&n++,t=t.slice(n)}t=a(t),t&&(s=s.concat(t.split(",")));const o=[];for(const r of s){if(r.indexOf(",")===-1){o.push(r);continue}for(const n of r.split(","))o.push(n.trim())}return s=o,{hasParenthesis:e,parameters:s}},O=(t,e)=>{const{parameters:s,hasParenthesis:o}=f(t);return!e.query&&s.includes("query")&&(e.query=!0),!e.headers&&s.includes("headers")&&(e.headers=!0),!e.body&&s.includes("body")&&(e.body=!0),!e.cookie&&s.includes("cookie")&&(e.cookie=!0),!e.set&&s.includes("set")&&(e.set=!0),!e.server&&s.includes("server")&&(e.server=!0),o?`{ ${s.join(", ")} }`:s.join(", ")},C=(t,e,s)=>{const o=e.indexOf(t+`
`,s),r=e.indexOf(t+" ",s),n=e.indexOf(t+",",s),i=e.indexOf(t+";",s),u=e.indexOf(t+" ",s);return[o,r,n,i,u].filter(d=>d>0).sort((d,l)=>d-l)[0]||-1},j=(t,e,s)=>{const o=e.indexOf(t+"]",s),r=e.indexOf(t+"'",s),n=e.indexOf(t+'"',s);return[o,r,n].filter(i=>i>0).sort((i,u)=>i-u)[0]||-1},h=(t,e,s=0)=>{if(s>5)return[];const o=[];let r=e;for(;;){let n=C(" = "+t,r);if(n===-1){const d=r.indexOf(" = "+t);if(d+3+t.length!==r.length)break;n=d}const i=r.slice(0,n);let u=i.slice(i.lastIndexOf(" ")+1);if(u==="}"){const[d,l]=k(i);o.push(a(r.slice(d,l))),r=r.slice(n+3+t.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),r=r.slice(n+3+t.length)}for(const n of o){if(n.charCodeAt(0)===123)continue;const i=h(n,e);i.length>0&&o.push(...i)}return o},A=t=>{if(!t)return;if(t.charCodeAt(0)!==123)return t;if(t=t.slice(2,-2),!t.includes(","))return t.includes("...")?t.slice(t.indexOf("...")+3):void 0;const s=t.indexOf("...");if(s!==-1)return t.slice(s+3).trimEnd()},I=(t,e,s)=>{const o=(r,n)=>t.includes(n+"."+r)||t.includes(n+'["'+r+'"]')||t.includes(n+"['"+r+"']");for(const r of e)if(r){if(r.charCodeAt(0)===123){const n=f(r).parameters;!s.query&&n.includes("query")&&(s.query=!0),!s.headers&&n.includes("headers")&&(s.headers=!0),!s.body&&n.includes("body")&&(s.body=!0),!s.cookie&&n.includes("cookie")&&(s.cookie=!0),!s.set&&n.includes("set")&&(s.set=!0),!s.query&&n.includes("server")&&(s.server=!0);continue}if(!s.query&&o("query",r)&&(s.query=!0),(t.includes("return "+r)||t.includes("return "+r+".query"))&&(s.query=!0),!s.headers&&o("headers",r)&&(s.headers=!0),!s.body&&o("body",r)&&(s.body=!0),!s.cookie&&o("cookie",r)&&(s.cookie=!0),!s.set&&o("set",r)&&(s.set=!0),!s.server&&o("server",r)&&(s.server=!0),s.query&&s.headers&&s.body&&s.cookie&&s.set&&s.server)break}return e},H=t=>{for(;;){const e=t.indexOf("=");if(e===-1)break;const s=t.indexOf(",",e),o=t.indexOf("}",e),r=[s,o].filter(n=>n>0).sort((n,i)=>n-i)[0]||-1;if(r===-1){t=t.slice(0,e);break}t=t.slice(0,e)+t.slice(r)}return t.split(",").map(e=>e.trim()).join(", ")},q=(t,e,s)=>{try{const o=new RegExp(`(?:\\w)\\((?:.*)?${t}`,"gs");o.test(e);const r=e.charCodeAt(o.lastIndex);return r===41||r===44?(s.query=!0,s.headers=!0,s.body=!0,s.cookie=!0,s.set=!0,s.server=!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(e),console.log("--- context ---"),console.log(t),!0}},E=(t,e={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1})=>{const s=[];t.handler&&typeof t.handler=="function"&&s.push(t.handler),t.request?.length&&s.push(...t.request),t.beforeHandle?.length&&s.push(...t.beforeHandle),t.parse?.length&&s.push(...t.parse),t.error?.length&&s.push(...t.error),t.transform?.length&&s.push(...t.transform),t.afterHandle?.length&&s.push(...t.afterHandle),t.mapResponse?.length&&s.push(...t.mapResponse),t.afterResponse?.length&&s.push(...t.afterResponse);for(const o of s){if(!o)continue;const r="fn"in o?o.fn:o,[n,i,{isArrowReturn:u}]=g(r.toString()),d=O(n,e),l=A(d);if(l){const x=h(l,i);x.splice(0,-1,l),q(l,i,e)||I(i,x,e),!e.query&&i.includes("return "+l+".query")&&(e.query=!0)}if(e.query&&e.headers&&e.body&&e.cookie&&e.set&&e.server)break}return e};0&&(module.exports={bracketPairRange,bracketPairRangeReverse,extractMainParameter,findAlias,findParameterReference,hasReturn,inferBodyReference,isContextPassToFunction,removeColonAlias,removeDefaultParameter,retrieveRootParamters,separateFunction,sucrose});

@@ -1,26 +0,1 @@

"use strict";var se=Object.create;var j=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var de=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ce(t))!ue.call(e,a)&&a!==n&&j(e,a,{get:()=>t[a],enumerable:!(o=ie(t,a))||o.enumerable});return e};var le=(e,t,n)=>(n=e!=null?se(fe(e)):{},V(t||!e||!e.__esModule?j(n,"default",{value:e,enumerable:!0}):n,e)),pe=e=>V(j({},"__esModule",{value:!0}),e);var Ue={};de(Ue,{ELYSIA_TRACE:()=>ze,createTracer:()=>$e});module.exports=pe(Ue);var re=require("@sinclair/typebox"),Be=require("@sinclair/typebox/value"),Me=require("@sinclair/typebox/compiler");var w=require("@sinclair/typebox"),E=require("@sinclair/typebox/system"),d=require("@sinclair/typebox"),z=require("@sinclair/typebox/compiler"),g=require("@sinclair/typebox/value");var F={date:q,time:I(!0),"date-time":J(!0),"iso-time":I(!1),"iso-date-time":J(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:Te,"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}|(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[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:Ae,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:ke,int32:{type:"number",validate:xe},int64:{type:"number",validate:we},float:{type:"number",validate:Y},double:{type:"number",validate:Y},password:!0,binary:!0};function ye(e){return e%4===0&&(e%100!==0||e%400===0)}var me=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,he=[0,31,28,31,30,31,30,31,31,30,31,30,31];function q(e){let t=me.exec(e);if(!t)return!1;let n=+t[1],o=+t[2],a=+t[3];return o>=1&&o<=12&&a>=1&&a<=(o===2&&ye(n)?29:he[o])}var ge=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function I(e){return function(n){let o=ge.exec(n);if(!o)return!1;let a=+o[1],r=+o[2],i=+o[3],m=o[4],c=o[5]==="-"?-1:1,l=+(o[6]||0),p=+(o[7]||0);if(l>23||p>59||e&&!m)return!1;if(a<=23&&r<=59&&i<60)return!0;let y=r-p*c,h=a-l*c-(y<0?1:0);return(h===23||h===-1)&&(y===59||y===-1)&&i<61}}var be=/t|\s/i;function J(e){let t=I(e);return function(o){let a=o.split(be);return a.length===2&&q(a[0])&&t(a[1])}}var Re=/\/|:/,Se=/^(?:[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 Te(e){return Re.test(e)&&Se.test(e)}var K=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function ke(e){return K.lastIndex=0,K.test(e)}var Oe=-(2**31),Ee=2**31-1;function xe(e){return Number.isInteger(e)&&e<=Ee&&e>=Oe}function we(e){return Number.isInteger(e)}function Y(){return!0}var Ce=/[^\\]\\Z/;function Ae(e){if(Ce.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var x=require("@sinclair/typebox/value");var G=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,Ye=Symbol("ElysiaErrorCode"),Z=Symbol("ElysiaResponse"),W=(G?.NODE_ENV??G?.ENV)==="production";var O=e=>{if(!e)return{summary:void 0};let{message:t,path:n,value:o,type:a}=e,r=n.slice(1).replaceAll("/","."),i=n==="";switch(a){case 42:return{...e,summary:i?"Value should not be provided":`Property '${r}' should not be provided`};case 45:return{...e,summary:i?"Value is missing":`Property '${r}' is missing`};case 50:let m=t.indexOf("'"),c=t.slice(m+1,t.indexOf("'",m+1));return{...e,summary:i?"Value should be an email":`Property '${r}' should be ${c}`};case 54:return{...e,summary:`${t.slice(0,9)} property '${r}' to be ${t.slice(8)} but found: ${o}`};case 62:let l=e.schema.anyOf.map(p=>`'${p?.format??p.type}'`).join(", ");return{...e,summary:i?`Value should be one of ${l}`:`Property '${r}' should be one of: ${l}`};default:return{summary:t,...e}}},u=class e extends Error{constructor(n,o,a){a&&typeof a=="object"&&Z in a&&(a=a.response);let r=W?void 0:"Errors"in o?o.Errors(a).First():x.Value.Errors(o,a).First(),i=r?.schema.error!==void 0?typeof r.schema.error=="function"?r.schema.error({type:n,validator:o,value:a,get errors(){return[...o.Errors(a)].map(O)}}):r.schema.error:void 0,m=r?.path||"root",c="";if(i!==void 0)c=typeof i=="object"?JSON.stringify(i):i+"";else if(W)c=JSON.stringify({type:"validation",on:n,summary:O(r).summary,message:r?.message,found:a});else{let l=o?.schema??o,p="Errors"in o?[...o.Errors(a)].map(O):[...x.Value.Errors(o,a)].map(O),y;try{y=x.Value.Create(l)}catch(h){y={type:"Could not create expected value",message:h?.message,error:h}}c=JSON.stringify({type:"validation",on:n,summary:p[0]?.summary,property:m,message:r?.message,expected:y,found:a,errors:p},null,2)}super(c);this.type=n;this.validator=o;this.value=a;this.code="VALIDATION";this.status=422;Object.setPrototypeOf(this,e.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(O):[...x.Value.Errors(this.validator,this.value)].map(O)}static simplifyModel(n){let o="schema"in n?n.schema:n;try{return x.Value.Create(o)}catch{return o}}get model(){return e.simplifyModel(this.validator)}toResponse(n){return new Response(this.message,{status:400,headers:{...n,"content-type":"application/json"}})}};var P=require("@sinclair/typebox/system"),ne=require("@sinclair/typebox/compiler"),X=/(\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))/,ee=/(?: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\([^)]+\)/,te=/^(?:(?:(?:(?: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)?)?$/,Fe=F.date,Pe=F["date-time"];d.FormatRegistry.Has("date")||E.TypeSystem.Format("date",e=>{let t=e.replace(/"/g,"");if(X.test(t)||ee.test(t)||te.test(t)||Fe(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});d.FormatRegistry.Has("date-time")||E.TypeSystem.Format("date-time",e=>{let t=e.replace(/"/g,"");if(X.test(t)||ee.test(t)||te.test(t)||Pe(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});Object.entries(F).forEach(e=>{let[t,n]=e;d.FormatRegistry.Has(t)||(n instanceof RegExp?E.TypeSystem.Format(t,o=>n.test(o)):typeof n=="function"&&E.TypeSystem.Format(t,n))});var s=Object.assign({},d.Type),Q=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},$=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<Q(e.minSize)||e.maxSize&&t.size>Q(e.maxSize))return!1;if(e.extension)if(typeof e.extension=="string"){if(!t.type.startsWith(e.extension))return!1}else{for(let n=0;n<e.extension.length;n++)if(t.type.startsWith(e.extension[n]))return!0;return!1}return!0},He=w.TypeRegistry.Get("Files")??E.TypeSystem.Type("File",$),Ne=w.TypeRegistry.Get("Files")??E.TypeSystem.Type("Files",(e,t)=>{if(!Array.isArray(t))return $(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(!$(e,t[n]))return!1;return!0});d.FormatRegistry.Has("numeric")||d.FormatRegistry.Set("numeric",e=>!!e&&!isNaN(+e));d.FormatRegistry.Has("boolean")||d.FormatRegistry.Set("boolean",e=>e==="true"||e==="false");d.FormatRegistry.Has("ObjectString")||d.FormatRegistry.Set("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}});d.FormatRegistry.Has("ArrayString")||d.FormatRegistry.Set("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}});w.TypeRegistry.Set("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t));var S={Numeric:e=>{let t=d.Type.Number(e);return s.Transform(s.Union([s.String({format:"numeric",default:0}),s.Number(e)],e)).Decode(n=>{let o=+n;if(isNaN(o))return n;if(e&&!g.Value.Check(t,o))throw new u("property",t,o);return o}).Encode(n=>n)},Date:e=>{let t=d.Type.Date(e);return s.Transform(s.Union([d.Type.Date(e),s.String({format:"date",default:new Date().toISOString()}),s.String({format:"date-time",default:new Date().toISOString()})],e)).Decode(n=>{if(n instanceof Date)return n;let o=new Date(n);if(!g.Value.Check(t,o))throw new u("property",t,o);return o}).Encode(n=>typeof n=="string"?new Date(n):n)},BooleanString:e=>{let t=d.Type.Boolean(e);return s.Transform(s.Union([s.String({format:"boolean",default:!1}),s.Boolean(e)],e)).Decode(n=>{if(typeof n=="string")return n==="true";if(e&&!g.Value.Check(t,n))throw new u("property",t,n);return n}).Encode(n=>n)},ObjectString:(e,t)=>{let n=s.Object(e,t),o=JSON.stringify(g.Value.Create(n)),a;try{a=z.TypeCompiler.Compile(n)}catch{}return s.Transform(s.Union([s.String({format:"ObjectString",default:o}),n])).Decode(r=>{if(typeof r=="string"){if(r.charCodeAt(0)!==123)throw new u("property",n,r);try{r=JSON.parse(r)}catch{throw new u("property",n,r)}if(a){if(!a.Check(r))throw new u("property",n,r);return a.Decode(r)}if(!g.Value.Check(n,r))throw new u("property",n,r);return g.Value.Decode(n,r)}return r}).Encode(r=>{if(typeof r=="string")try{r=JSON.parse(r)}catch{throw new u("property",n,r)}if(!g.Value.Check(n,r))throw new u("property",n,r);return JSON.stringify(r)})},ArrayString:(e={},t)=>{let n=s.Array(e,t),o=JSON.stringify(g.Value.Create(n)),a;try{a=z.TypeCompiler.Compile(n)}catch{}return s.Transform(s.Union([s.String({format:"ArrayString",default:o}),n])).Decode(r=>{if(typeof r=="string"){if(r.charCodeAt(0)!==91)throw new u("property",n,r);try{r=JSON.parse(r)}catch{throw new u("property",n,r)}if(a){if(!a.Check(r))throw new u("property",n,r);return a.Decode(r)}if(!g.Value.Check(n,r))throw new u("property",n,r);return g.Value.Decode(n,r)}return r}).Encode(r=>{if(typeof r=="string")try{r=JSON.parse(r)}catch{throw new u("property",n,r)}if(!g.Value.Check(n,r))throw new u("property",n,r);return JSON.stringify(r)})},File:He,Files:(e={})=>s.Transform(Ne(e)).Decode(t=>Array.isArray(t)?t:[t]).Encode(t=>t),Nullable:e=>s.Union([e,s.Null()]),MaybeEmpty:e=>s.Union([e,s.Null(),s.Undefined()]),Cookie:(e,{domain:t,expires:n,httpOnly:o,maxAge:a,path:r,priority:i,sameSite:m,secure:c,secrets:l,sign:p,...y}={})=>{let h=s.Object(e,y);return h.config={domain:t,expires:n,httpOnly:o,maxAge:a,path:r,priority:i,sameSite:m,secure:c,secrets:l,sign:p},h},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 new Error("This type does not support objects or arrays");return{default:e[0],...t,[w.Kind]:"UnionEnum",...n,enum:e}}};s.BooleanString=S.BooleanString;s.ObjectString=S.ObjectString;s.ArrayString=S.ArrayString;s.Numeric=S.Numeric;s.File=(e={})=>S.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"});s.Files=(e={})=>S.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});s.Nullable=e=>S.Nullable(e);s.MaybeEmpty=S.MaybeEmpty;s.Cookie=S.Cookie;s.Date=S.Date;s.UnionEnum=S.UnionEnum;var _e=require("cookie");var ve=require("cookie"),De=le(require("fast-decode-uri-component"));var bt="toJSON"in new Headers;var Ie=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],wt=Ie.reduce((e,t)=>(e[t]=!0,e),{});var Le=typeof Bun<"u",Ct=Le&&typeof Bun.hash=="function";var L={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},je=Object.fromEntries(Object.entries(L).map(([e,t])=>[t,e]));var At=new TextEncoder;var jt=Symbol("ElysiaFormData"),oe=Symbol("ElysiaRequestId");var ze=Symbol("ElysiaTrace"),T=()=>{let{promise:e,resolve:t}=Promise.withResolvers(),{promise:n,resolve:o}=Promise.withResolvers(),{promise:a,resolve:r}=Promise.withResolvers(),i=[],m=[];return[c=>(c&&i.push(c),e),c=>{let l=[],p=[],y=null;for(let f=0;f<(c.total??0);f++){let{promise:b,resolve:C}=Promise.withResolvers(),{promise:k,resolve:H}=Promise.withResolvers(),{promise:N,resolve:v}=Promise.withResolvers(),D=[],_=[];l.push(A=>(A&&D.push(A),b)),p.push(A=>{let U={...A,end:k,error:N,index:f,onStop(R){return R&&_.push(R),k}};C(U);for(let R=0;R<D.length;R++)D[R](U);return(R=null)=>{let B=performance.now();R&&(y=R);let ae={end:B,error:R,get elapsed(){return B-A.begin}};for(let M=0;M<_.length;M++)_[M](ae);H(B),v(R)}})}let h={...c,end:n,error:a,onEvent(f){for(let b=0;b<l.length;b++)l[b](f)},onStop(f){return f&&m.push(f),n}};t(h);for(let f=0;f<i.length;f++)i[f](h);return{resolveChild:p,resolve(f=null){let b=performance.now();!f&&y&&(f=y);let C={end:b,error:f,get elapsed(){return b-c.begin}};for(let k=0;k<m.length;k++)m[k](C);o(b),r(f)}}}]},$e=e=>t=>{let[n,o]=T(),[a,r]=T(),[i,m]=T(),[c,l]=T(),[p,y]=T(),[h,f]=T(),[b,C]=T(),[k,H]=T(),[N,v]=T();return e({id:t[oe],context:t,set:t.set,onRequest:n,onParse:a,onTransform:i,onBeforeHandle:c,onHandle:p,onAfterHandle:h,onMapResponse:k,onAfterResponse:N,onError:b}),{request:o,parse:r,transform:m,beforeHandle:l,handle:y,afterHandle:f,error:C,mapResponse:H,afterResponse:v}};0&&(module.exports={ELYSIA_TRACE,createTracer});
/**
* @license
*
* MIT License
*
* Copyright (c) 2020 Evgeny Poberezkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
"use strict";var H=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var L=(n,r)=>{for(var s in r)H(n,s,{get:r[s],enumerable:!0})},D=(n,r,s,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of q(r))!B.call(n,l)&&l!==s&&H(n,l,{get:()=>r[l],enumerable:!(u=A(r,l))||u.enumerable});return n};var I=n=>D(H({},"__esModule",{value:!0}),n);var W={};L(W,{ELYSIA_TRACE:()=>_,createTracer:()=>M});module.exports=I(W);var C=require("./utils");const _=Symbol("ElysiaTrace"),i=()=>{const{promise:n,resolve:r}=Promise.withResolvers(),{promise:s,resolve:u}=Promise.withResolvers(),{promise:l,resolve:g}=Promise.withResolvers(),p=[],d=[];return[a=>(a&&p.push(a),n),a=>{const m=[],E=[];let v=null;for(let e=0;e<(a.total??0);e++){const{promise:o,resolve:f}=Promise.withResolvers(),{promise:c,resolve:h}=Promise.withResolvers(),{promise:P,resolve:R}=Promise.withResolvers(),x=[],y=[];m.push(b=>(b&&x.push(b),o)),E.push(b=>{const F={...b,end:c,error:P,index:e,onStop(t){return t&&y.push(t),c}};f(F);for(let t=0;t<x.length;t++)x[t](F);return(t=null)=>{const S=performance.now();t&&(v=t);const k={end:S,error:t,get elapsed(){return S-b.begin}};for(let w=0;w<y.length;w++)y[w](k);h(S),R(t)}})}const T={...a,end:s,error:l,onEvent(e){for(let o=0;o<m.length;o++)m[o](e)},onStop(e){return e&&d.push(e),s}};r(T);for(let e=0;e<p.length;e++)p[e](T);return{resolveChild:E,resolve(e=null){const o=performance.now();!e&&v&&(e=v);const f={end:o,error:e,get elapsed(){return o-a.begin}};for(let c=0;c<d.length;c++)d[c](f);u(o),g(e)}}}]},M=n=>r=>{const[s,u]=i(),[l,g]=i(),[p,d]=i(),[a,m]=i(),[E,v]=i(),[T,e]=i(),[o,f]=i(),[c,h]=i(),[P,R]=i();return n({id:r[C.ELYSIA_REQUEST_ID],context:r,set:r.set,onRequest:s,onParse:l,onTransform:p,onBeforeHandle:a,onHandle:E,onAfterHandle:T,onMapResponse:c,onAfterResponse:P,onError:o}),{request:u,parse:g,transform:d,beforeHandle:m,handle:v,afterHandle:e,error:f,mapResponse:h,afterResponse:R}};0&&(module.exports={ELYSIA_TRACE,createTracer});

@@ -1,26 +0,1 @@

"use strict";var U=Object.create;var k=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},F=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of J(t))!Y.call(e,o)&&o!==n&&k(e,o,{get:()=>t[o],enumerable:!(a=V(t,o))||a.enumerable});return e};var q=(e,t,n)=>(n=e!=null?U(K(e)):{},F(t||!e||!e.__esModule?k(n,"default",{value:e,enumerable:!0}):n,e)),W=e=>F(k({},"__esModule",{value:!0}),e);var Ee={};G(Ee,{ElysiaType:()=>d,TypeCheck:()=>x.TypeCheck,TypeCompiler:()=>x.TypeCompiler,TypeSystem:()=>b.TypeSystem,TypeSystemDuplicateFormat:()=>b.TypeSystemDuplicateFormat,TypeSystemDuplicateTypeKind:()=>b.TypeSystemDuplicateTypeKind,TypeSystemPolicy:()=>b.TypeSystemPolicy,t:()=>i});module.exports=W(Ee);var O=require("@sinclair/typebox"),S=require("@sinclair/typebox/system"),c=require("@sinclair/typebox"),A=require("@sinclair/typebox/compiler"),u=require("@sinclair/typebox/value");var E={date:D,time:C(!0),"date-time":N(!0),"iso-time":C(!1),"iso-date-time":N(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ae,"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}|(?: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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:de,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:oe,int32:{type:"number",validate:ce},int64:{type:"number",validate:fe},float:{type:"number",validate:P},double:{type:"number",validate:P},password:!0,binary:!0};function Z(e){return e%4===0&&(e%100!==0||e%400===0)}var Q=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,X=[0,31,28,31,30,31,30,31,31,30,31,30,31];function D(e){let t=Q.exec(e);if(!t)return!1;let n=+t[1],a=+t[2],o=+t[3];return a>=1&&a<=12&&o>=1&&o<=(a===2&&Z(n)?29:X[a])}var ee=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function C(e){return function(n){let a=ee.exec(n);if(!a)return!1;let o=+a[1],r=+a[2],f=+a[3],h=a[4],l=a[5]==="-"?-1:1,y=+(a[6]||0),p=+(a[7]||0);if(y>23||p>59||e&&!h)return!1;if(o<=23&&r<=59&&f<60)return!0;let m=r-p*l,g=o-y*l-(m<0?1:0);return(g===23||g===-1)&&(m===59||m===-1)&&f<61}}var te=/t|\s/i;function N(e){let t=C(e);return function(a){let o=a.split(te);return o.length===2&&D(o[0])&&t(o[1])}}var ne=/\/|:/,re=/^(?:[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 ae(e){return ne.test(e)&&re.test(e)}var H=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function oe(e){return H.lastIndex=0,H.test(e)}var ie=-(2**31),se=2**31-1;function ce(e){return Number.isInteger(e)&&e<=se&&e>=ie}function fe(e){return Number.isInteger(e)}function P(){return!0}var ue=/[^\\]\\Z/;function de(e){if(ue.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var T=require("@sinclair/typebox/value");var M=require("@sinclair/typebox"),me=require("@sinclair/typebox/value"),he=require("@sinclair/typebox/compiler");var ye=require("cookie");var le=require("cookie"),pe=q(require("fast-decode-uri-component"));var Me="toJSON"in new Headers;var ge=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],Ve=ge.reduce((e,t)=>(e[t]=!0,e),{});var be=typeof Bun<"u",Je=be&&typeof Bun.hash=="function";var w={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},Re=Object.fromEntries(Object.entries(w).map(([e,t])=>[t,e]));var Ke=new TextEncoder;var Ye=Symbol("ElysiaFormData"),Ge=Symbol("ElysiaRequestId");var B=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,Ze=Symbol("ElysiaErrorCode"),_=Symbol("ElysiaResponse"),I=(B?.NODE_ENV??B?.ENV)==="production";var R=e=>{if(!e)return{summary:void 0};let{message:t,path:n,value:a,type:o}=e,r=n.slice(1).replaceAll("/","."),f=n==="";switch(o){case 42:return{...e,summary:f?"Value should not be provided":`Property '${r}' should not be provided`};case 45:return{...e,summary:f?"Value is missing":`Property '${r}' is missing`};case 50:let h=t.indexOf("'"),l=t.slice(h+1,t.indexOf("'",h+1));return{...e,summary:f?"Value should be an email":`Property '${r}' should be ${l}`};case 54:return{...e,summary:`${t.slice(0,9)} property '${r}' to be ${t.slice(8)} but found: ${a}`};case 62:let y=e.schema.anyOf.map(p=>`'${p?.format??p.type}'`).join(", ");return{...e,summary:f?`Value should be one of ${y}`:`Property '${r}' should be one of: ${y}`};default:return{summary:t,...e}}},s=class e extends Error{constructor(n,a,o){o&&typeof o=="object"&&_ in o&&(o=o.response);let r=I?void 0:"Errors"in a?a.Errors(o).First():T.Value.Errors(a,o).First(),f=r?.schema.error!==void 0?typeof r.schema.error=="function"?r.schema.error({type:n,validator:a,value:o,get errors(){return[...a.Errors(o)].map(R)}}):r.schema.error:void 0,h=r?.path||"root",l="";if(f!==void 0)l=typeof f=="object"?JSON.stringify(f):f+"";else if(I)l=JSON.stringify({type:"validation",on:n,summary:R(r).summary,message:r?.message,found:o});else{let y=a?.schema??a,p="Errors"in a?[...a.Errors(o)].map(R):[...T.Value.Errors(a,o)].map(R),m;try{m=T.Value.Create(y)}catch(g){m={type:"Could not create expected value",message:g?.message,error:g}}l=JSON.stringify({type:"validation",on:n,summary:p[0]?.summary,property:h,message:r?.message,expected:m,found:o,errors:p},null,2)}super(l);this.type=n;this.validator=a;this.value=o;this.code="VALIDATION";this.status=422;Object.setPrototypeOf(this,e.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(R):[...T.Value.Errors(this.validator,this.value)].map(R)}static simplifyModel(n){let a="schema"in n?n.schema:n;try{return T.Value.Create(a)}catch{return a}}get model(){return e.simplifyModel(this.validator)}toResponse(n){return new Response(this.message,{status:400,headers:{...n,"content-type":"application/json"}})}};var b=require("@sinclair/typebox/system"),x=require("@sinclair/typebox/compiler"),L=/(\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))/,$=/(?: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\([^)]+\)/,v=/^(?:(?:(?:(?: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)?)?$/,Se=E.date,Te=E["date-time"];c.FormatRegistry.Has("date")||S.TypeSystem.Format("date",e=>{let t=e.replace(/"/g,"");if(L.test(t)||$.test(t)||v.test(t)||Se(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});c.FormatRegistry.Has("date-time")||S.TypeSystem.Format("date-time",e=>{let t=e.replace(/"/g,"");if(L.test(t)||$.test(t)||v.test(t)||Te(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});Object.entries(E).forEach(e=>{let[t,n]=e;c.FormatRegistry.Has(t)||(n instanceof RegExp?S.TypeSystem.Format(t,a=>n.test(a)):typeof n=="function"&&S.TypeSystem.Format(t,n))});var i=Object.assign({},c.Type),z=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},j=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<z(e.minSize)||e.maxSize&&t.size>z(e.maxSize))return!1;if(e.extension)if(typeof e.extension=="string"){if(!t.type.startsWith(e.extension))return!1}else{for(let n=0;n<e.extension.length;n++)if(t.type.startsWith(e.extension[n]))return!0;return!1}return!0},Oe=O.TypeRegistry.Get("Files")??S.TypeSystem.Type("File",j),ke=O.TypeRegistry.Get("Files")??S.TypeSystem.Type("Files",(e,t)=>{if(!Array.isArray(t))return j(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(!j(e,t[n]))return!1;return!0});c.FormatRegistry.Has("numeric")||c.FormatRegistry.Set("numeric",e=>!!e&&!isNaN(+e));c.FormatRegistry.Has("boolean")||c.FormatRegistry.Set("boolean",e=>e==="true"||e==="false");c.FormatRegistry.Has("ObjectString")||c.FormatRegistry.Set("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}});c.FormatRegistry.Has("ArrayString")||c.FormatRegistry.Set("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}});O.TypeRegistry.Set("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t));var d={Numeric:e=>{let t=c.Type.Number(e);return i.Transform(i.Union([i.String({format:"numeric",default:0}),i.Number(e)],e)).Decode(n=>{let a=+n;if(isNaN(a))return n;if(e&&!u.Value.Check(t,a))throw new s("property",t,a);return a}).Encode(n=>n)},Date:e=>{let t=c.Type.Date(e);return i.Transform(i.Union([c.Type.Date(e),i.String({format:"date",default:new Date().toISOString()}),i.String({format:"date-time",default:new Date().toISOString()})],e)).Decode(n=>{if(n instanceof Date)return n;let a=new Date(n);if(!u.Value.Check(t,a))throw new s("property",t,a);return a}).Encode(n=>typeof n=="string"?new Date(n):n)},BooleanString:e=>{let t=c.Type.Boolean(e);return i.Transform(i.Union([i.String({format:"boolean",default:!1}),i.Boolean(e)],e)).Decode(n=>{if(typeof n=="string")return n==="true";if(e&&!u.Value.Check(t,n))throw new s("property",t,n);return n}).Encode(n=>n)},ObjectString:(e,t)=>{let n=i.Object(e,t),a=JSON.stringify(u.Value.Create(n)),o;try{o=A.TypeCompiler.Compile(n)}catch{}return i.Transform(i.Union([i.String({format:"ObjectString",default:a}),n])).Decode(r=>{if(typeof r=="string"){if(r.charCodeAt(0)!==123)throw new s("property",n,r);try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(o){if(!o.Check(r))throw new s("property",n,r);return o.Decode(r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return u.Value.Decode(n,r)}return r}).Encode(r=>{if(typeof r=="string")try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return JSON.stringify(r)})},ArrayString:(e={},t)=>{let n=i.Array(e,t),a=JSON.stringify(u.Value.Create(n)),o;try{o=A.TypeCompiler.Compile(n)}catch{}return i.Transform(i.Union([i.String({format:"ArrayString",default:a}),n])).Decode(r=>{if(typeof r=="string"){if(r.charCodeAt(0)!==91)throw new s("property",n,r);try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(o){if(!o.Check(r))throw new s("property",n,r);return o.Decode(r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return u.Value.Decode(n,r)}return r}).Encode(r=>{if(typeof r=="string")try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return JSON.stringify(r)})},File:Oe,Files:(e={})=>i.Transform(ke(e)).Decode(t=>Array.isArray(t)?t:[t]).Encode(t=>t),Nullable:e=>i.Union([e,i.Null()]),MaybeEmpty:e=>i.Union([e,i.Null(),i.Undefined()]),Cookie:(e,{domain:t,expires:n,httpOnly:a,maxAge:o,path:r,priority:f,sameSite:h,secure:l,secrets:y,sign:p,...m}={})=>{let g=i.Object(e,m);return g.config={domain:t,expires:n,httpOnly:a,maxAge:o,path:r,priority:f,sameSite:h,secure:l,secrets:y,sign:p},g},UnionEnum:(e,t={})=>{let n=e.every(a=>typeof a=="string")?{type:"string"}:e.every(a=>typeof a=="number")?{type:"number"}:e.every(a=>a===null)?{type:"null"}:{};if(e.some(a=>typeof a=="object"&&a!==null))throw new Error("This type does not support objects or arrays");return{default:e[0],...t,[O.Kind]:"UnionEnum",...n,enum:e}}};i.BooleanString=d.BooleanString;i.ObjectString=d.ObjectString;i.ArrayString=d.ArrayString;i.Numeric=d.Numeric;i.File=(e={})=>d.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"});i.Files=(e={})=>d.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});i.Nullable=e=>d.Nullable(e);i.MaybeEmpty=d.MaybeEmpty;i.Cookie=d.Cookie;i.Date=d.Date;i.UnionEnum=d.UnionEnum;0&&(module.exports={ElysiaType,TypeCheck,TypeCompiler,TypeSystem,TypeSystemDuplicateFormat,TypeSystemDuplicateTypeKind,TypeSystemPolicy,t});
/**
* @license
*
* MIT License
*
* Copyright (c) 2020 Evgeny Poberezkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
"use strict";var u=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var r in t)u(e,r,{get:t[r],enumerable:!0})},J=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of j(t))!U.call(e,s)&&s!==r&&u(e,s,{get:()=>t[s],enumerable:!(o=D(t,s))||o.enumerable});return e};var M=e=>J(u({},"__esModule",{value:!0}),e);var R={};V(R,{ElysiaType:()=>m,TypeCheck:()=>T.TypeCheck,TypeCompiler:()=>T.TypeCompiler,TypeSystem:()=>c.TypeSystem,TypeSystemDuplicateFormat:()=>c.TypeSystemDuplicateFormat,TypeSystemDuplicateTypeKind:()=>c.TypeSystemDuplicateTypeKind,TypeSystemPolicy:()=>c.TypeSystemPolicy,t:()=>n});module.exports=M(R);var l=require("@sinclair/typebox"),f=require("@sinclair/typebox/system"),a=require("@sinclair/typebox"),h=require("@sinclair/typebox/compiler"),y=require("@sinclair/typebox/value"),d=require("./formats"),p=require("./error"),c=require("@sinclair/typebox/system"),T=require("@sinclair/typebox/compiler");const b=/(\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))/,E=/(?: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\([^)]+\)/,O=/^(?:(?:(?:(?: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)?)?$/,B=d.fullFormats.date,I=d.fullFormats["date-time"];a.FormatRegistry.Has("date")||f.TypeSystem.Format("date",e=>{const t=e.replace(/"/g,"");if(b.test(t)||E.test(t)||O.test(t)||B(t)){const r=new Date(t);if(!Number.isNaN(r.getTime()))return!0}return!1}),a.FormatRegistry.Has("date-time")||f.TypeSystem.Format("date-time",e=>{const t=e.replace(/"/g,"");if(b.test(t)||E.test(t)||O.test(t)||I(t)){const r=new Date(t);if(!Number.isNaN(r.getTime()))return!0}return!1}),Object.entries(d.fullFormats).forEach(e=>{const[t,r]=e;a.FormatRegistry.Has(t)||(r instanceof RegExp?f.TypeSystem.Format(t,o=>r.test(o)):typeof r=="function"&&f.TypeSystem.Format(t,r))});const n=Object.assign({},a.Type),x=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},g=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<x(e.minSize)||e.maxSize&&t.size>x(e.maxSize))return!1;if(e.extension)if(typeof e.extension=="string"){if(!t.type.startsWith(e.extension))return!1}else{for(let r=0;r<e.extension.length;r++)if(t.type.startsWith(e.extension[r]))return!0;return!1}return!0},H=l.TypeRegistry.Get("Files")??f.TypeSystem.Type("File",g),P=l.TypeRegistry.Get("Files")??f.TypeSystem.Type("Files",(e,t)=>{if(!Array.isArray(t))return g(e,t);if(e.minItems&&t.length<e.minItems||e.maxItems&&t.length>e.maxItems)return!1;for(let r=0;r<t.length;r++)if(!g(e,t[r]))return!1;return!0});a.FormatRegistry.Has("numeric")||a.FormatRegistry.Set("numeric",e=>!!e&&!isNaN(+e)),a.FormatRegistry.Has("boolean")||a.FormatRegistry.Set("boolean",e=>e==="true"||e==="false"),a.FormatRegistry.Has("ObjectString")||a.FormatRegistry.Set("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}}),a.FormatRegistry.Has("ArrayString")||a.FormatRegistry.Set("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}}),l.TypeRegistry.Set("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t));const m={Numeric:e=>{const t=a.Type.Number(e);return n.Transform(n.Union([n.String({format:"numeric",default:0}),n.Number(e)],e)).Decode(r=>{const o=+r;if(isNaN(o))return r;if(e&&!y.Value.Check(t,o))throw new p.ValidationError("property",t,o);return o}).Encode(r=>r)},Date:e=>{const t=a.Type.Date(e);return n.Transform(n.Union([a.Type.Date(e),n.String({format:"date",default:new Date().toISOString()}),n.String({format:"date-time",default:new Date().toISOString()})],e)).Decode(r=>{if(r instanceof Date)return r;const o=new Date(r);if(!y.Value.Check(t,o))throw new p.ValidationError("property",t,o);return o}).Encode(r=>typeof r=="string"?new Date(r):r)},BooleanString:e=>{const t=a.Type.Boolean(e);return n.Transform(n.Union([n.String({format:"boolean",default:!1}),n.Boolean(e)],e)).Decode(r=>{if(typeof r=="string")return r==="true";if(e&&!y.Value.Check(t,r))throw new p.ValidationError("property",t,r);return r}).Encode(r=>r)},ObjectString:(e,t)=>{const r=n.Object(e,t),o=JSON.stringify(y.Value.Create(r));let s;try{s=h.TypeCompiler.Compile(r)}catch{}return n.Transform(n.Union([n.String({format:"ObjectString",default:o}),r])).Decode(i=>{if(typeof i=="string"){if(i.charCodeAt(0)!==123)throw new p.ValidationError("property",r,i);try{i=JSON.parse(i)}catch{throw new p.ValidationError("property",r,i)}if(s){if(!s.Check(i))throw new p.ValidationError("property",r,i);return s.Decode(i)}if(!y.Value.Check(r,i))throw new p.ValidationError("property",r,i);return y.Value.Decode(r,i)}return i}).Encode(i=>{if(typeof i=="string")try{i=JSON.parse(i)}catch{throw new p.ValidationError("property",r,i)}if(!y.Value.Check(r,i))throw new p.ValidationError("property",r,i);return JSON.stringify(i)})},ArrayString:(e={},t)=>{const r=n.Array(e,t),o=JSON.stringify(y.Value.Create(r));let s;try{s=h.TypeCompiler.Compile(r)}catch{}return n.Transform(n.Union([n.String({format:"ArrayString",default:o}),r])).Decode(i=>{if(typeof i=="string"){if(i.charCodeAt(0)!==91)throw new p.ValidationError("property",r,i);try{i=JSON.parse(i)}catch{throw new p.ValidationError("property",r,i)}if(s){if(!s.Check(i))throw new p.ValidationError("property",r,i);return s.Decode(i)}if(!y.Value.Check(r,i))throw new p.ValidationError("property",r,i);return y.Value.Decode(r,i)}return i}).Encode(i=>{if(typeof i=="string")try{i=JSON.parse(i)}catch{throw new p.ValidationError("property",r,i)}if(!y.Value.Check(r,i))throw new p.ValidationError("property",r,i);return JSON.stringify(i)})},File:H,Files:(e={})=>n.Transform(P(e)).Decode(t=>Array.isArray(t)?t:[t]).Encode(t=>t),Nullable:e=>n.Union([e,n.Null()]),MaybeEmpty:e=>n.Union([e,n.Null(),n.Undefined()]),Cookie:(e,{domain:t,expires:r,httpOnly:o,maxAge:s,path:i,priority:F,sameSite:w,secure:N,secrets:C,sign:A,...k}={})=>{const S=n.Object(e,k);return S.config={domain:t,expires:r,httpOnly:o,maxAge:s,path:i,priority:F,sameSite:w,secure:N,secrets:C,sign:A},S},UnionEnum:(e,t={})=>{const r=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 new Error("This type does not support objects or arrays");return{default:e[0],...t,[l.Kind]:"UnionEnum",...r,enum:e}}};n.BooleanString=m.BooleanString,n.ObjectString=m.ObjectString,n.ArrayString=m.ArrayString,n.Numeric=m.Numeric,n.File=(e={})=>m.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"}),n.Files=(e={})=>m.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}}),n.Nullable=e=>m.Nullable(e),n.MaybeEmpty=m.MaybeEmpty,n.Cookie=m.Cookie,n.Date=m.Date,n.UnionEnum=m.UnionEnum;0&&(module.exports={ElysiaType,TypeCheck,TypeCompiler,TypeSystem,TypeSystemDuplicateFormat,TypeSystemDuplicateTypeKind,TypeSystemPolicy,t});

@@ -1,26 +0,1 @@

"use strict";var ke=Object.create;var _=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty;var Ae=(e,t)=>{for(var n in t)_(e,n,{get:t[n],enumerable:!0})},Z=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xe(t))!we.call(e,o)&&o!==n&&_(e,o,{get:()=>t[o],enumerable:!(r=Ee(t,o))||r.enumerable});return e};var je=(e,t,n)=>(n=e!=null?ke(Ce(e)):{},Z(t||!e||!e.__esModule?_(n,"default",{value:e,enumerable:!0}):n,e)),Fe=e=>Z(_({},"__esModule",{value:!0}),e);var Et={};Ae(Et,{ELYSIA_FORM_DATA:()=>Rt,ELYSIA_REQUEST_ID:()=>St,InvertedStatusMap:()=>oe,PromiseGroup:()=>G,StatusMap:()=>B,asHookType:()=>ft,checksum:()=>it,classToObject:()=>z,cloneInference:()=>gt,createMacroManager:()=>pt,deduplicateChecksum:()=>Ot,filterGlobalHook:()=>ut,fnToContainer:()=>x,form:()=>le,getCookieValidator:()=>st,getResponseSchemaValidator:()=>rt,getSchemaValidator:()=>Y,injectChecksum:()=>E,isClass:()=>ye,isNumericString:()=>Se,lifeCycleToFn:()=>ht,localHookToLifeCycleStore:()=>mt,mergeCookie:()=>me,mergeDeep:()=>L,mergeHook:()=>nt,mergeLifeCycle:()=>ct,mergeObjectArray:()=>b,mergeResponse:()=>W,mergeSchemaValidator:()=>tt,primitiveHooks:()=>he,promoteEvent:()=>kt,randomId:()=>Tt,redirect:()=>bt,replaceSchemaType:()=>ge,replaceUrlPath:()=>Xe,signCookie:()=>Re,stringToStructureCoercions:()=>be,traceBackMacro:()=>lt,unsignCookie:()=>de});module.exports=Fe(Et);var j=require("@sinclair/typebox"),O=require("@sinclair/typebox/value"),q=require("@sinclair/typebox/compiler");var D=require("@sinclair/typebox"),N=require("@sinclair/typebox/system"),S=require("@sinclair/typebox"),v=require("@sinclair/typebox/compiler"),k=require("@sinclair/typebox/value");var M={date:te,time:$(!0),"date-time":Q(!0),"iso-time":$(!1),"iso-date-time":Q(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:Ie,"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]?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){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:Je,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:ze,int32:{type:"number",validate:ve},int64:{type:"number",validate:Ue},float:{type:"number",validate:ee},double:{type:"number",validate:ee},password:!0,binary:!0};function Ne(e){return e%4===0&&(e%100!==0||e%400===0)}var He=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Pe=[0,31,28,31,30,31,30,31,31,30,31,30,31];function te(e){let t=He.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],o=+t[3];return r>=1&&r<=12&&o>=1&&o<=(r===2&&Ne(n)?29:Pe[r])}var De=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function $(e){return function(n){let r=De.exec(n);if(!r)return!1;let o=+r[1],a=+r[2],i=+r[3],f=r[4],m=r[5]==="-"?-1:1,p=+(r[6]||0),c=+(r[7]||0);if(p>23||c>59||e&&!f)return!1;if(o<=23&&a<=59&&i<60)return!0;let l=a-c*m,u=o-p*m-(l<0?1:0);return(u===23||u===-1)&&(l===59||l===-1)&&i<61}}var _e=/t|\s/i;function Q(e){let t=$(e);return function(r){let o=r.split(_e);return o.length===2&&te(o[0])&&t(o[1])}}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@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Ie(e){return Me.test(e)&&Be.test(e)}var X=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function ze(e){return X.lastIndex=0,X.test(e)}var Le=-(2**31),$e=2**31-1;function ve(e){return Number.isInteger(e)&&e<=$e&&e>=Le}function Ue(e){return Number.isInteger(e)}function ee(){return!0}var Ve=/[^\\]\\Z/;function Je(e){if(Ve.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var P=require("@sinclair/typebox/value");var ne=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,At=Symbol("ElysiaErrorCode"),ae=Symbol("ElysiaResponse"),re=(ne?.NODE_ENV??ne?.ENV)==="production";var C=e=>{if(!e)return{summary:void 0};let{message:t,path:n,value:r,type:o}=e,a=n.slice(1).replaceAll("/","."),i=n==="";switch(o){case 42:return{...e,summary:i?"Value should not be provided":`Property '${a}' should not be provided`};case 45:return{...e,summary:i?"Value is missing":`Property '${a}' is missing`};case 50:let f=t.indexOf("'"),m=t.slice(f+1,t.indexOf("'",f+1));return{...e,summary:i?"Value should be an email":`Property '${a}' should be ${m}`};case 54:return{...e,summary:`${t.slice(0,9)} property '${a}' to be ${t.slice(8)} but found: ${r}`};case 62:let p=e.schema.anyOf.map(c=>`'${c?.format??c.type}'`).join(", ");return{...e,summary:i?`Value should be one of ${p}`:`Property '${a}' should be one of: ${p}`};default:return{summary:t,...e}}},R=class e extends Error{constructor(n,r,o){o&&typeof o=="object"&&ae in o&&(o=o.response);let a=re?void 0:"Errors"in r?r.Errors(o).First():P.Value.Errors(r,o).First(),i=a?.schema.error!==void 0?typeof a.schema.error=="function"?a.schema.error({type:n,validator:r,value:o,get errors(){return[...r.Errors(o)].map(C)}}):a.schema.error:void 0,f=a?.path||"root",m="";if(i!==void 0)m=typeof i=="object"?JSON.stringify(i):i+"";else if(re)m=JSON.stringify({type:"validation",on:n,summary:C(a).summary,message:a?.message,found:o});else{let p=r?.schema??r,c="Errors"in r?[...r.Errors(o)].map(C):[...P.Value.Errors(r,o)].map(C),l;try{l=P.Value.Create(p)}catch(u){l={type:"Could not create expected value",message:u?.message,error:u}}m=JSON.stringify({type:"validation",on:n,summary:c[0]?.summary,property:f,message:a?.message,expected:l,found:o,errors:c},null,2)}super(m);this.type=n;this.validator=r;this.value=o;this.code="VALIDATION";this.status=422;Object.setPrototypeOf(this,e.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(C):[...P.Value.Errors(this.validator,this.value)].map(C)}static simplifyModel(n){let r="schema"in n?n.schema:n;try{return P.Value.Create(r)}catch{return r}}get model(){return e.simplifyModel(this.validator)}toResponse(n){return new Response(this.message,{status:400,headers:{...n,"content-type":"application/json"}})}};var I=require("@sinclair/typebox/system"),ue=require("@sinclair/typebox/compiler"),se=/(\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))/,ce=/(?: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\([^)]+\)/,fe=/^(?:(?:(?:(?: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)?)?$/,Ke=M.date,Ye=M["date-time"];S.FormatRegistry.Has("date")||N.TypeSystem.Format("date",e=>{let t=e.replace(/"/g,"");if(se.test(t)||ce.test(t)||fe.test(t)||Ke(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});S.FormatRegistry.Has("date-time")||N.TypeSystem.Format("date-time",e=>{let t=e.replace(/"/g,"");if(se.test(t)||ce.test(t)||fe.test(t)||Ye(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});Object.entries(M).forEach(e=>{let[t,n]=e;S.FormatRegistry.Has(t)||(n instanceof RegExp?N.TypeSystem.Format(t,r=>n.test(r)):typeof n=="function"&&N.TypeSystem.Format(t,n))});var s=Object.assign({},S.Type),ie=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},U=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<ie(e.minSize)||e.maxSize&&t.size>ie(e.maxSize))return!1;if(e.extension)if(typeof e.extension=="string"){if(!t.type.startsWith(e.extension))return!1}else{for(let n=0;n<e.extension.length;n++)if(t.type.startsWith(e.extension[n]))return!0;return!1}return!0},Ge=D.TypeRegistry.Get("Files")??N.TypeSystem.Type("File",U),qe=D.TypeRegistry.Get("Files")??N.TypeSystem.Type("Files",(e,t)=>{if(!Array.isArray(t))return U(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(!U(e,t[n]))return!1;return!0});S.FormatRegistry.Has("numeric")||S.FormatRegistry.Set("numeric",e=>!!e&&!isNaN(+e));S.FormatRegistry.Has("boolean")||S.FormatRegistry.Set("boolean",e=>e==="true"||e==="false");S.FormatRegistry.Has("ObjectString")||S.FormatRegistry.Set("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}});S.FormatRegistry.Has("ArrayString")||S.FormatRegistry.Set("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}});D.TypeRegistry.Set("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t));var w={Numeric:e=>{let t=S.Type.Number(e);return s.Transform(s.Union([s.String({format:"numeric",default:0}),s.Number(e)],e)).Decode(n=>{let r=+n;if(isNaN(r))return n;if(e&&!k.Value.Check(t,r))throw new R("property",t,r);return r}).Encode(n=>n)},Date:e=>{let t=S.Type.Date(e);return s.Transform(s.Union([S.Type.Date(e),s.String({format:"date",default:new Date().toISOString()}),s.String({format:"date-time",default:new Date().toISOString()})],e)).Decode(n=>{if(n instanceof Date)return n;let r=new Date(n);if(!k.Value.Check(t,r))throw new R("property",t,r);return r}).Encode(n=>typeof n=="string"?new Date(n):n)},BooleanString:e=>{let t=S.Type.Boolean(e);return s.Transform(s.Union([s.String({format:"boolean",default:!1}),s.Boolean(e)],e)).Decode(n=>{if(typeof n=="string")return n==="true";if(e&&!k.Value.Check(t,n))throw new R("property",t,n);return n}).Encode(n=>n)},ObjectString:(e,t)=>{let n=s.Object(e,t),r=JSON.stringify(k.Value.Create(n)),o;try{o=v.TypeCompiler.Compile(n)}catch{}return s.Transform(s.Union([s.String({format:"ObjectString",default:r}),n])).Decode(a=>{if(typeof a=="string"){if(a.charCodeAt(0)!==123)throw new R("property",n,a);try{a=JSON.parse(a)}catch{throw new R("property",n,a)}if(o){if(!o.Check(a))throw new R("property",n,a);return o.Decode(a)}if(!k.Value.Check(n,a))throw new R("property",n,a);return k.Value.Decode(n,a)}return a}).Encode(a=>{if(typeof a=="string")try{a=JSON.parse(a)}catch{throw new R("property",n,a)}if(!k.Value.Check(n,a))throw new R("property",n,a);return JSON.stringify(a)})},ArrayString:(e={},t)=>{let n=s.Array(e,t),r=JSON.stringify(k.Value.Create(n)),o;try{o=v.TypeCompiler.Compile(n)}catch{}return s.Transform(s.Union([s.String({format:"ArrayString",default:r}),n])).Decode(a=>{if(typeof a=="string"){if(a.charCodeAt(0)!==91)throw new R("property",n,a);try{a=JSON.parse(a)}catch{throw new R("property",n,a)}if(o){if(!o.Check(a))throw new R("property",n,a);return o.Decode(a)}if(!k.Value.Check(n,a))throw new R("property",n,a);return k.Value.Decode(n,a)}return a}).Encode(a=>{if(typeof a=="string")try{a=JSON.parse(a)}catch{throw new R("property",n,a)}if(!k.Value.Check(n,a))throw new R("property",n,a);return JSON.stringify(a)})},File:Ge,Files:(e={})=>s.Transform(qe(e)).Decode(t=>Array.isArray(t)?t:[t]).Encode(t=>t),Nullable:e=>s.Union([e,s.Null()]),MaybeEmpty:e=>s.Union([e,s.Null(),s.Undefined()]),Cookie:(e,{domain:t,expires:n,httpOnly:r,maxAge:o,path:a,priority:i,sameSite:f,secure:m,secrets:p,sign:c,...l}={})=>{let u=s.Object(e,l);return u.config={domain:t,expires:n,httpOnly:r,maxAge:o,path:a,priority:i,sameSite:f,secure:m,secrets:p,sign:c},u},UnionEnum:(e,t={})=>{let n=e.every(r=>typeof r=="string")?{type:"string"}:e.every(r=>typeof r=="number")?{type:"number"}:e.every(r=>r===null)?{type:"null"}:{};if(e.some(r=>typeof r=="object"&&r!==null))throw new Error("This type does not support objects or arrays");return{default:e[0],...t,[D.Kind]:"UnionEnum",...n,enum:e}}};s.BooleanString=w.BooleanString;s.ObjectString=w.ObjectString;s.ArrayString=w.ArrayString;s.Numeric=w.Numeric;s.File=(e={})=>w.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"});s.Files=(e={})=>w.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});s.Nullable=e=>w.Nullable(e);s.MaybeEmpty=w.MaybeEmpty;s.Cookie=w.Cookie;s.Date=w.Date;s.UnionEnum=w.UnionEnum;var Qe=require("cookie");var We=require("cookie"),Ze=je(require("fast-decode-uri-component"));var Qt="toJSON"in new Headers,V=e=>{if(!e)return!1;for(let t in e)return!0;return!1};var Xe=(e,t)=>{let n=new URL(e);return n.pathname=t,n.toString()},ye=e=>typeof e=="function"&&/^\s*class\s+/.test(e.toString())||e.toString().startsWith("[object ")&&e.toString()!=="[object Object]"||V(Object.getPrototypeOf(e)),J=e=>e&&typeof e=="object"&&!Array.isArray(e),L=(e,t,{skipKeys:n,override:r=!0}={})=>{if(!J(e)||!J(t))return e;for(let[o,a]of Object.entries(t))if(!n?.includes(o)){if(!J(a)||!(o in e)||ye(a)){(r||!(o in e))&&(e[o]=a);continue}e[o]=L(e[o],a,{skipKeys:n,override:r})}return e},me=(e,t)=>{let{properties:n,...r}=e??{},{properties:o,...a}=t??{};return L(r,a)},b=(e=[],t=[])=>{if(!e)return[];if(!t)return e;let n=[],r=[];Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);for(let o of e)n.push(o),o.checksum&&r.push(o.checksum);for(let o of t)r.includes(o.checksum)||n.push(o);return n},he=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],et=he.reduce((e,t)=>(e[t]=!0,e),{}),W=(e,t)=>{let n=r=>typeof r=="object"&&Object.keys(r).every(Se);return n(e)&&n(t)?{...e,...t}:t??e},tt=(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:W(e?.response,t?.response)}),nt=(e,t)=>({...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:W(e?.response,t?.response),type:e?.type||t?.type,detail:L(t?.detail??{},e?.detail??{}),parse:b(e?.parse,t?.parse),transform:b(e?.transform,t?.transform),beforeHandle:b(e?.beforeHandle,t?.beforeHandle),afterHandle:b(e?.afterHandle,t?.afterHandle),mapResponse:b(e?.mapResponse,t?.mapResponse),afterResponse:b(e?.afterResponse,t?.afterResponse),trace:b(e?.trace,t?.trace),error:b(e?.error,t?.error)}),ge=(e,t,n=!0)=>{if(!Array.isArray(t))return T(e,t,n);for(let r of t)e=T(e,r,n);return e},T=(e,t,n=!0)=>{if(!e||t.untilObjectFound&&!n&&e.type==="object")return e;let r=t.from[j.Kind];if(e.oneOf){for(let i=0;i<e.oneOf.length;i++)e.oneOf[i]=T(e.oneOf[i],t,n);return e}if(e.anyOf){for(let i=0;i<e.anyOf.length;i++)e.anyOf[i]=T(e.anyOf[i],t,n);return e}if(e.allOf){for(let i=0;i<e.allOf.length;i++)e.allOf[i]=T(e.allOf[i],t,n);return e}if(e.not){for(let i=0;i<e.not.length;i++)e.not[i]=T(e.not[i],t,n);return e}let o=n&&!!t.excludeRoot;if(e[j.Kind]===r){let{anyOf:i,oneOf:f,allOf:m,not:p,properties:c,items:l,...u}=e,y=t.to(),g,h=d=>{if(c&&d.type==="object"){let H={};for(let[Te,Oe]of Object.entries(c))H[Te]=T(Oe,t,!1);return{...u,...d,properties:H}}if(l&&d.type==="array")return{...u,...d,items:T(l,t,!1)};let A={...u,...d};return delete A.required,c&&d.type==="string"&&d.format==="ObjectString"&&d.default==="{}"&&(g=s.ObjectString(c,u),A.default=JSON.stringify(O.Value.Create(s.Object(c))),A.properties=c),l&&d.type==="string"&&d.format==="ArrayString"&&d.default==="[]"&&(g=s.ArrayString(l,u),A.default=JSON.stringify(O.Value.Create(s.Array(l))),A.items=l),A};if(o){if(c){let d={};for(let[A,H]of Object.entries(c))d[A]=T(H,t,!1);return{...u,properties:d}}else if(l?.map)return{...u,items:l.map(d=>T(d,t,!1))};return u}if(y.anyOf)for(let d=0;d<y.anyOf.length;d++)y.anyOf[d]=h(y.anyOf[d]);else if(y.oneOf)for(let d=0;d<y.oneOf.length;d++)y.oneOf[d]=h(y.oneOf[d]);else if(y.allOf)for(let d=0;d<y.allOf.length;d++)y.allOf[d]=h(y.allOf[d]);else if(y.not)for(let d=0;d<y.not.length;d++)y.not[d]=h(y.not[d]);if(g&&(y[j.TransformKind]=g[j.TransformKind]),y.anyOf||y.oneOf||y.allOf||y.not)return y;if(c){let d={};for(let[A,H]of Object.entries(c))d[A]=T(H,t,!1);return{...u,...y,properties:d}}else if(l?.map)return{...u,...y,items:l.map(d=>T(d,t,!1))};return{...u,...y}}let a=e?.properties;if(a)for(let[i,f]of Object.entries(a))switch(f[j.Kind]){case r:let{anyOf:m,oneOf:p,allOf:c,not:l,type:u,...y}=f,g=t.to();if(g.anyOf)for(let h=0;h<g.anyOf.length;h++)g.anyOf[h]={...y,...g.anyOf[h]};else if(g.oneOf)for(let h=0;h<g.oneOf.length;h++)g.oneOf[h]={...y,...g.oneOf[h]};else if(g.allOf)for(let h=0;h<g.allOf.length;h++)g.allOf[h]={...y,...g.allOf[h]};else if(g.not)for(let h=0;h<g.not.length;h++)g.not[h]={...y,...g.not[h]};a[i]={...y,...T(y,t,!1)};break;case"Object":case"Union":a[i]=T(f,t,!1);break;default:if(f.items)for(let h=0;h<f.items.length;h++)f.items[h]=T(f.items[h],t,!1);else(f.anyOf||f.oneOf||f.allOf||f.not)&&(a[i]=T(f,t,!1));break}return e},Y=(e,{models:t={},dynamic:n=!1,normalize:r=!1,additionalProperties:o=!1,coerce:a=!1,additionalCoerce:i=[]}={})=>{if(!e||typeof e=="string"&&!(e in t))return;let f=typeof e=="string"?t[e]:e;a&&(f=ge(f,[{from:s.Number(),to:()=>s.Numeric(),untilObjectFound:!0},{from:s.Boolean(),to:()=>s.BooleanString(),untilObjectFound:!0},...Array.isArray(i)?i:[i]])),f.type==="object"&&!("additionalProperties"in f)&&(f.additionalProperties=o);let m=c=>O.Value.Clean(f,c);if(n){let c={schema:f,references:"",checkFunc:()=>{},code:"",Check:l=>O.Value.Check(f,l),Errors:l=>O.Value.Errors(f,l),Code:()=>"",Clean:m,Decode:l=>O.Value.Decode(f,l),Encode:l=>O.Value.Encode(f,l)};return r&&f.additionalProperties===!1&&(c.Clean=m),f.config&&(c.config=f.config,c?.schema?.config&&delete c.schema.config),c.parse=l=>{try{return c.Decode(l)}catch{throw[...c.Errors(l)].map(C)}},c.safeParse=l=>{try{return{success:!0,data:c.Decode(l),error:null}}catch{let y=[...p.Errors(l)].map(C);return{success:!1,data:null,error:y[0]?.summary,errors:y}}},c}let p=q.TypeCompiler.Compile(f,Object.values(t));return p.Clean=m,f.config&&(p.config=f.config,p?.schema?.config&&delete p.schema.config),p.parse=c=>{try{return p.Decode(c)}catch{throw[...p.Errors(c)].map(C)}},p.safeParse=c=>{try{return{success:!0,data:p.Decode(c),error:null}}catch{let u=[...p.Errors(c)].map(C);return{success:!1,data:null,error:u[0]?.summary,errors:u}}},p},rt=(e,{models:t={},dynamic:n=!1,normalize:r=!1,additionalProperties:o=!1})=>{if(!e||typeof e=="string"&&!(e in t))return;let a=typeof e=="string"?t[e]:e,i=(m,p)=>{let c=u=>!u||typeof u!="object"?O.Value.Clean(m,u):(Array.isArray(u)?u=O.Value.Clean(m,u):u=O.Value.Clean(m,u),u);if(n)return{schema:m,references:"",checkFunc:()=>{},code:"",Check:u=>O.Value.Check(m,u),Errors:u=>O.Value.Errors(m,u),Code:()=>"",Decode:u=>O.Value.Decode(m,u),Encode:u=>O.Value.Encode(m,u)};let l=q.TypeCompiler.Compile(m,p);return r&&m.additionalProperties===!1&&(l.Clean=c),l};if(j.Kind in a)return"additionalProperties"in a||(a.additionalProperties=o),{200:i(a,Object.values(t))};let f={};return Object.keys(a).forEach(m=>{let p=a[+m];if(typeof p=="string"){if(p in t){let c=t[p];c.type==="object"&&"additionalProperties"in c,f[+m]=j.Kind in c?i(c,Object.values(t)):c}return}p.type==="object"&&!("additionalProperties"in p)&&(p.additionalProperties=o),f[+m]=j.Kind in p?i(p,Object.values(t)):p}),f},at=typeof Bun<"u",ot=at&&typeof Bun.hash=="function",it=e=>{if(ot)return Bun.hash(e);let t=9;for(let n=0;n<e.length;)t=Math.imul(t^e.charCodeAt(n++),9**9);return t=t^t>>>9},K,be=()=>(K||(K=[{from:s.Object({}),to:()=>s.ObjectString({}),excludeRoot:!0},{from:s.Array(s.Any()),to:()=>s.ArrayString(s.Any())}]),K),st=({validator:e,defaultConfig:t={},config:n,dynamic:r,models:o})=>{let a=Y(e,{dynamic:r,models:o,additionalProperties:!0,coerce:!0,additionalCoerce:be()});return V(t)&&(a?a.config=me(a.config,n):(a=Y(s.Cookie({}),{dynamic:r,models:o,additionalProperties:!0}),a.config=t)),a},E=(e,t)=>{if(!t)return;if(!Array.isArray(t)){let r=t;return e&&!r.checksum&&(r.checksum=e),r.scope==="scoped"&&(r.scope="local"),r}let n=[...t];for(let r of n)e&&!r.checksum&&(r.checksum=e),r.scope==="scoped"&&(r.scope="local");return n},ct=(e,t,n)=>({start:b(e.start,E(n,t?.start)),request:b(e.request,E(n,t?.request)),parse:b(e.parse,E(n,t?.parse)),transform:b(e.transform,E(n,t?.transform)),beforeHandle:b(e.beforeHandle,E(n,t?.beforeHandle)),afterHandle:b(e.afterHandle,E(n,t?.afterHandle)),mapResponse:b(e.mapResponse,E(n,t?.mapResponse)),afterResponse:b(e.afterResponse,E(n,t?.afterResponse)),trace:b(e.trace,E(n,t?.trace)),error:b(e.error,E(n,t?.error)),stop:b(e.stop,E(n,t?.stop))}),ft=(e,t,{skipIfHasType:n=!1}={})=>{if(!e)return e;if(!Array.isArray(e))return n?e.scope??=t:e.scope=t,e;for(let r of e)n?r.scope??=t:r.scope=t;return e},F=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},ut=e=>({...e,type:e?.type,detail:e?.detail,parse:F(e?.parse),transform:F(e?.transform),beforeHandle:F(e?.beforeHandle),afterHandle:F(e?.afterHandle),mapResponse:F(e?.mapResponse),afterResponse:F(e?.afterResponse),error:F(e?.error),trace:F(e?.trace)}),B={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},oe=Object.fromEntries(Object.entries(B).map(([e,t])=>[t,e]));function dt(e){let t=e;for(;t.endsWith("=");)t=t.slice(0,-1);return t}var pe=new TextEncoder,Re=async(e,t)=>{if(typeof e!="string")throw new TypeError("Cookie value must be provided as a string.");if(t===null)throw new TypeError("Secret key must be provided.");let n=await crypto.subtle.importKey("raw",pe.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,pe.encode(e));return e+"."+dt(Buffer.from(r).toString("base64"))},de=async(e,t)=>{if(typeof e!="string")throw new TypeError("Signed cookie string must be provided.");if(t===null)throw new TypeError("Secret key must be provided.");let n=e.slice(0,e.lastIndexOf("."));return await Re(n,t)===e?n:!1},lt=(e,t)=>{if(!(!e||typeof e!="object"||!t))for(let[n,r]of Object.entries(t)){if(n in et||!(n in e))continue;let o=e[n];typeof o=="function"&&(o(r),delete t[n])}},pt=({globalHook:e,localHook:t})=>n=>(r,o)=>{if(typeof r=="function"&&(r={fn:r}),"fn"in r||Array.isArray(r)){t[n]||(t[n]=[]),typeof t[n]=="function"&&(t[n]=[t[n]]),Array.isArray(r)?t[n]=t[n].concat(r):t[n].push(r);return}let{insert:a="after",stack:i="local"}=r;typeof o=="function"&&(o={fn:o}),i==="global"?Array.isArray(o)?a==="before"?e[n]=o.concat(e[n]):e[n]=e[n].concat(o):a==="before"?e[n].unshift(o):e[n].push(o):(t[n]||(t[n]=[]),typeof t[n]=="function"&&(t[n]=[t[n]]),Array.isArray(o)?a==="before"?t[n]=o.concat(t[n]):t[n]=t[n].concat(o):a==="before"?t[n].unshift(o):t[n].push(o))},yt=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},Se=e=>yt(e)!==null,G=class{constructor(t=console.error){this.onError=t;this.root=null;this.promises=[]}get size(){return this.promises.length}add(t){return this.promises.push(t),this.root||=this.drain(),t}async drain(){for(;this.promises.length>0;){try{await this.promises[0]}catch(t){this.onError(t)}this.promises.shift()}this.root=null}then(t,n){return(this.root??Promise.resolve()).then(t,n)}},x=e=>{if(!e)return e;if(!Array.isArray(e)){if(typeof e=="function")return{fn:e};if("fn"in e)return e}let t=[];for(let n of e)typeof n=="function"?t.push({fn:n}):"fn"in n&&t.push(n);return t},mt=e=>({...e,start:x(e?.start),request:x(e?.request),parse:x(e?.parse),transform:x(e?.transform),beforeHandle:x(e?.beforeHandle),afterHandle:x(e?.afterHandle),mapResponse:x(e?.mapResponse),afterResponse:x(e?.afterResponse),trace:x(e?.trace),error:x(e?.error),stop:x(e?.stop)}),ht=e=>({...e,start:e.start?.map(t=>t.fn),request:e.request?.map(t=>t.fn),parse:e.parse?.map(t=>t.fn),transform:e.transform?.map(t=>t.fn),beforeHandle:e.beforeHandle?.map(t=>t.fn),afterHandle:e.afterHandle?.map(t=>t.fn),afterResponse:e.afterResponse?.map(t=>t.fn),mapResponse:e.mapResponse?.map(t=>t.fn),trace:e.trace?.map(t=>t.fn),error:e.error?.map(t=>t.fn),stop:e.stop?.map(t=>t.fn)}),gt=e=>({body:e.body,cookie:e.cookie,headers:e.headers,query:e.query,set:e.set,server:e.server}),bt=(e,t=302)=>Response.redirect(e,t),Rt=Symbol("ElysiaFormData"),St=Symbol("ElysiaRequestId"),le=e=>{let t=new FormData;for(let[n,r]of Object.entries(e)){if(Array.isArray(r)){for(let o of r)r instanceof File&&t.append(n,r,r.name),t.append(n,o);continue}r instanceof File&&t.append(n,r,r.name),t.append(n,r)}return t},Tt=()=>crypto.getRandomValues(new Uint32Array(1))[0],Ot=e=>{let t=[];for(let n=0;n<e.length;n++){let r=e[n];r.checksum&&(t.includes(r.checksum)&&(e.splice(n,1),n--),t.push(r.checksum))}return e},kt=(e,t="scoped")=>{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")},z=(e,t=new WeakMap)=>{if(typeof e!="object"||e===null)return e;if(Array.isArray(e))return e.map(a=>z(a,t));if(t.has(e))return t.get(e);let n={};for(let a of Object.keys(e)){let i=e[a];typeof i=="object"&&i!==null?n[a]=z(i,t):n[a]=i}let r=Object.getPrototypeOf(e);if(!r)return n;let o=Object.getOwnPropertyNames(r);for(let a of o){let i=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),a);if(i&&typeof i.get=="function"){if(a==="__proto__")continue;console.log(a),n[a]=z(e[a])}}return n};0&&(module.exports={ELYSIA_FORM_DATA,ELYSIA_REQUEST_ID,InvertedStatusMap,PromiseGroup,StatusMap,asHookType,checksum,classToObject,cloneInference,createMacroManager,deduplicateChecksum,filterGlobalHook,fnToContainer,form,getCookieValidator,getResponseSchemaValidator,getSchemaValidator,injectChecksum,isClass,isNumericString,lifeCycleToFn,localHookToLifeCycleStore,mergeCookie,mergeDeep,mergeHook,mergeLifeCycle,mergeObjectArray,mergeResponse,mergeSchemaValidator,primitiveHooks,promoteEvent,randomId,redirect,replaceSchemaType,replaceUrlPath,signCookie,stringToStructureCoercions,traceBackMacro,unsignCookie});
/**
* @license
*
* MIT License
*
* Copyright (c) 2020 Evgeny Poberezkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
"use strict";var P=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var X=(e,r)=>{for(var n in r)P(e,n,{get:r[n],enumerable:!0})},Z=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Q(r))!J.call(e,o)&&o!==n&&P(e,o,{get:()=>r[o],enumerable:!(t=W(r,o))||t.enumerable});return e};var $=e=>Z(P({},"__esModule",{value:!0}),e);var je={};X(je,{ELYSIA_FORM_DATA:()=>Ae,ELYSIA_REQUEST_ID:()=>Ce,InvertedStatusMap:()=>ye,PromiseGroup:()=>Te,StatusMap:()=>K,asHookType:()=>le,checksum:()=>ie,classToObject:()=>j,cloneInference:()=>Se,createMacroManager:()=>ge,deduplicateChecksum:()=>xe,filterGlobalHook:()=>pe,fnToContainer:()=>R,form:()=>ke,getCookieValidator:()=>fe,getResponseSchemaValidator:()=>oe,getSchemaValidator:()=>I,injectChecksum:()=>S,isClass:()=>D,isNumericString:()=>G,lifeCycleToFn:()=>Oe,localHookToLifeCycleStore:()=>he,mergeCookie:()=>v,mergeDeep:()=>w,mergeHook:()=>te,mergeLifeCycle:()=>ce,mergeObjectArray:()=>b,mergeResponse:()=>q,mergeSchemaValidator:()=>ne,primitiveHooks:()=>_,promoteEvent:()=>we,randomId:()=>He,redirect:()=>Re,replaceSchemaType:()=>V,replaceUrlPath:()=>ee,signCookie:()=>N,stringToStructureCoercions:()=>U,traceBackMacro:()=>me,unsignCookie:()=>de});module.exports=$(je);var C=require("@sinclair/typebox"),O=require("@sinclair/typebox/value"),M=require("@sinclair/typebox/compiler"),h=require("./type-system"),F=require("./handler"),x=require("./error");const ee=(e,r)=>{const n=new URL(e);return n.pathname=r,n.toString()},D=e=>typeof e=="function"&&/^\s*class\s+/.test(e.toString())||e.toString().startsWith("[object ")&&e.toString()!=="[object Object]"||(0,F.isNotEmpty)(Object.getPrototypeOf(e)),E=e=>e&&typeof e=="object"&&!Array.isArray(e),w=(e,r,{skipKeys:n,override:t=!0}={})=>{if(!E(e)||!E(r))return e;for(const[o,a]of Object.entries(r))if(!n?.includes(o)){if(!E(a)||!(o in e)||D(a)){(t||!(o in e))&&(e[o]=a);continue}e[o]=w(e[o],a,{skipKeys:n,override:t})}return e},v=(e,r)=>{const{properties:n,...t}=e??{},{properties:o,...a}=r??{};return w(t,a)},b=(e=[],r=[])=>{if(!e)return[];if(!r)return e;const n=[],t=[];Array.isArray(e)||(e=[e]),Array.isArray(r)||(r=[r]);for(const o of e)n.push(o),o.checksum&&t.push(o.checksum);for(const o of r)t.includes(o.checksum)||n.push(o);return n},_=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],re=_.reduce((e,r)=>(e[r]=!0,e),{}),q=(e,r)=>{const n=t=>typeof t=="object"&&Object.keys(t).every(G);return n(e)&&n(r)?{...e,...r}:r??e},ne=(e,r)=>({body:r?.body??e?.body,headers:r?.headers??e?.headers,params:r?.params??e?.params,query:r?.query??e?.query,cookie:r?.cookie??e?.cookie,response:q(e?.response,r?.response)}),te=(e,r)=>({...e,...r,body:r?.body??e?.body,headers:r?.headers??e?.headers,params:r?.params??e?.params,query:r?.query??e?.query,cookie:r?.cookie??e?.cookie,response:q(e?.response,r?.response),type:e?.type||r?.type,detail:w(r?.detail??{},e?.detail??{}),parse:b(e?.parse,r?.parse),transform:b(e?.transform,r?.transform),beforeHandle:b(e?.beforeHandle,r?.beforeHandle),afterHandle:b(e?.afterHandle,r?.afterHandle),mapResponse:b(e?.mapResponse,r?.mapResponse),afterResponse:b(e?.afterResponse,r?.afterResponse),trace:b(e?.trace,r?.trace),error:b(e?.error,r?.error)}),V=(e,r,n=!0)=>{if(!Array.isArray(r))return T(e,r,n);for(const t of r)e=T(e,t,n);return e},T=(e,r,n=!0)=>{if(!e||r.untilObjectFound&&!n&&e.type==="object")return e;const t=r.from[C.Kind];if(e.oneOf){for(let s=0;s<e.oneOf.length;s++)e.oneOf[s]=T(e.oneOf[s],r,n);return e}if(e.anyOf){for(let s=0;s<e.anyOf.length;s++)e.anyOf[s]=T(e.anyOf[s],r,n);return e}if(e.allOf){for(let s=0;s<e.allOf.length;s++)e.allOf[s]=T(e.allOf[s],r,n);return e}if(e.not){for(let s=0;s<e.not.length;s++)e.not[s]=T(e.not[s],r,n);return e}const o=n&&!!r.excludeRoot;if(e[C.Kind]===t){const{anyOf:s,oneOf:c,allOf:g,not:d,properties:f,items:y,...l}=e,p=r.to();let m;const u=i=>{if(f&&i.type==="object"){const H={};for(const[Y,z]of Object.entries(f))H[Y]=T(z,r,!1);return{...l,...i,properties:H}}if(y&&i.type==="array")return{...l,...i,items:T(y,r,!1)};const A={...l,...i};return delete A.required,f&&i.type==="string"&&i.format==="ObjectString"&&i.default==="{}"&&(m=h.t.ObjectString(f,l),A.default=JSON.stringify(O.Value.Create(h.t.Object(f))),A.properties=f),y&&i.type==="string"&&i.format==="ArrayString"&&i.default==="[]"&&(m=h.t.ArrayString(y,l),A.default=JSON.stringify(O.Value.Create(h.t.Array(y))),A.items=y),A};if(o){if(f){const i={};for(const[A,H]of Object.entries(f))i[A]=T(H,r,!1);return{...l,properties:i}}else if(y?.map)return{...l,items:y.map(i=>T(i,r,!1))};return l}if(p.anyOf)for(let i=0;i<p.anyOf.length;i++)p.anyOf[i]=u(p.anyOf[i]);else if(p.oneOf)for(let i=0;i<p.oneOf.length;i++)p.oneOf[i]=u(p.oneOf[i]);else if(p.allOf)for(let i=0;i<p.allOf.length;i++)p.allOf[i]=u(p.allOf[i]);else if(p.not)for(let i=0;i<p.not.length;i++)p.not[i]=u(p.not[i]);if(m&&(p[C.TransformKind]=m[C.TransformKind]),p.anyOf||p.oneOf||p.allOf||p.not)return p;if(f){const i={};for(const[A,H]of Object.entries(f))i[A]=T(H,r,!1);return{...l,...p,properties:i}}else if(y?.map)return{...l,...p,items:y.map(i=>T(i,r,!1))};return{...l,...p}}const a=e?.properties;if(a)for(const[s,c]of Object.entries(a))switch(c[C.Kind]){case t:const{anyOf:g,oneOf:d,allOf:f,not:y,type:l,...p}=c,m=r.to();if(m.anyOf)for(let u=0;u<m.anyOf.length;u++)m.anyOf[u]={...p,...m.anyOf[u]};else if(m.oneOf)for(let u=0;u<m.oneOf.length;u++)m.oneOf[u]={...p,...m.oneOf[u]};else if(m.allOf)for(let u=0;u<m.allOf.length;u++)m.allOf[u]={...p,...m.allOf[u]};else if(m.not)for(let u=0;u<m.not.length;u++)m.not[u]={...p,...m.not[u]};a[s]={...p,...T(p,r,!1)};break;case"Object":case"Union":a[s]=T(c,r,!1);break;default:if(c.items)for(let u=0;u<c.items.length;u++)c.items[u]=T(c.items[u],r,!1);else(c.anyOf||c.oneOf||c.allOf||c.not)&&(a[s]=T(c,r,!1));break}return e},I=(e,{models:r={},dynamic:n=!1,normalize:t=!1,additionalProperties:o=!1,coerce:a=!1,additionalCoerce:s=[]}={})=>{if(!e||typeof e=="string"&&!(e in r))return;let c=typeof e=="string"?r[e]:e;a&&(c=V(c,[{from:h.t.Number(),to:()=>h.t.Numeric(),untilObjectFound:!0},{from:h.t.Boolean(),to:()=>h.t.BooleanString(),untilObjectFound:!0},...Array.isArray(s)?s:[s]])),c.type==="object"&&!("additionalProperties"in c)&&(c.additionalProperties=o);const g=f=>O.Value.Clean(c,f);if(n){const f={schema:c,references:"",checkFunc:()=>{},code:"",Check:y=>O.Value.Check(c,y),Errors:y=>O.Value.Errors(c,y),Code:()=>"",Clean:g,Decode:y=>O.Value.Decode(c,y),Encode:y=>O.Value.Encode(c,y)};return t&&c.additionalProperties===!1&&(f.Clean=g),c.config&&(f.config=c.config,f?.schema?.config&&delete f.schema.config),f.parse=y=>{try{return f.Decode(y)}catch{throw[...f.Errors(y)].map(x.mapValueError)}},f.safeParse=y=>{try{return{success:!0,data:f.Decode(y),error:null}}catch{const p=[...d.Errors(y)].map(x.mapValueError);return{success:!1,data:null,error:p[0]?.summary,errors:p}}},f}const d=M.TypeCompiler.Compile(c,Object.values(r));return d.Clean=g,c.config&&(d.config=c.config,d?.schema?.config&&delete d.schema.config),d.parse=f=>{try{return d.Decode(f)}catch{throw[...d.Errors(f)].map(x.mapValueError)}},d.safeParse=f=>{try{return{success:!0,data:d.Decode(f),error:null}}catch{const l=[...d.Errors(f)].map(x.mapValueError);return{success:!1,data:null,error:l[0]?.summary,errors:l}}},d},oe=(e,{models:r={},dynamic:n=!1,normalize:t=!1,additionalProperties:o=!1})=>{if(!e||typeof e=="string"&&!(e in r))return;const a=typeof e=="string"?r[e]:e,s=(g,d)=>{const f=l=>!l||typeof l!="object"?O.Value.Clean(g,l):(Array.isArray(l)?l=O.Value.Clean(g,l):l=O.Value.Clean(g,l),l);if(n)return{schema:g,references:"",checkFunc:()=>{},code:"",Check:l=>O.Value.Check(g,l),Errors:l=>O.Value.Errors(g,l),Code:()=>"",Decode:l=>O.Value.Decode(g,l),Encode:l=>O.Value.Encode(g,l)};const y=M.TypeCompiler.Compile(g,d);return t&&g.additionalProperties===!1&&(y.Clean=f),y};if(C.Kind in a)return"additionalProperties"in a||(a.additionalProperties=o),{200:s(a,Object.values(r))};const c={};return Object.keys(a).forEach(g=>{const d=a[+g];if(typeof d=="string"){if(d in r){const f=r[d];f.type==="object"&&"additionalProperties"in f,c[+g]=C.Kind in f?s(f,Object.values(r)):f}return}d.type==="object"&&!("additionalProperties"in d)&&(d.additionalProperties=o),c[+g]=C.Kind in d?s(d,Object.values(r)):d}),c},ae=typeof Bun<"u",se=ae&&typeof Bun.hash=="function",ie=e=>{if(se)return Bun.hash(e);let r=9;for(let n=0;n<e.length;)r=Math.imul(r^e.charCodeAt(n++),9**9);return r=r^r>>>9};let L;const U=()=>(L||(L=[{from:h.t.Object({}),to:()=>h.t.ObjectString({}),excludeRoot:!0},{from:h.t.Array(h.t.Any()),to:()=>h.t.ArrayString(h.t.Any())}]),L),fe=({validator:e,defaultConfig:r={},config:n,dynamic:t,models:o})=>{let a=I(e,{dynamic:t,models:o,additionalProperties:!0,coerce:!0,additionalCoerce:U()});return(0,F.isNotEmpty)(r)&&(a?a.config=v(a.config,n):(a=I(h.t.Cookie({}),{dynamic:t,models:o,additionalProperties:!0}),a.config=r)),a},S=(e,r)=>{if(!r)return;if(!Array.isArray(r)){const t=r;return e&&!t.checksum&&(t.checksum=e),t.scope==="scoped"&&(t.scope="local"),t}const n=[...r];for(const t of n)e&&!t.checksum&&(t.checksum=e),t.scope==="scoped"&&(t.scope="local");return n},ce=(e,r,n)=>({start:b(e.start,S(n,r?.start)),request:b(e.request,S(n,r?.request)),parse:b(e.parse,S(n,r?.parse)),transform:b(e.transform,S(n,r?.transform)),beforeHandle:b(e.beforeHandle,S(n,r?.beforeHandle)),afterHandle:b(e.afterHandle,S(n,r?.afterHandle)),mapResponse:b(e.mapResponse,S(n,r?.mapResponse)),afterResponse:b(e.afterResponse,S(n,r?.afterResponse)),trace:b(e.trace,S(n,r?.trace)),error:b(e.error,S(n,r?.error)),stop:b(e.stop,S(n,r?.stop))}),le=(e,r,{skipIfHasType:n=!1}={})=>{if(!e)return e;if(!Array.isArray(e))return n?e.scope??=r:e.scope=r,e;for(const t of e)n?t.scope??=r:t.scope=r;return e},k=e=>{if(!e)return e;if(!Array.isArray(e))switch(e.scope){case"global":case"scoped":return{...e};default:return{fn:e}}const r=[];for(const n of e)switch(n.scope){case"global":case"scoped":r.push({...n});break}return r},pe=e=>({...e,type:e?.type,detail:e?.detail,parse:k(e?.parse),transform:k(e?.transform),beforeHandle:k(e?.beforeHandle),afterHandle:k(e?.afterHandle),mapResponse:k(e?.mapResponse),afterResponse:k(e?.afterResponse),error:k(e?.error),trace:k(e?.trace)}),K={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},ye=Object.fromEntries(Object.entries(K).map(([e,r])=>[r,e]));function ue(e){let r=e;for(;r.endsWith("=");)r=r.slice(0,-1);return r}const B=new TextEncoder,N=async(e,r)=>{if(typeof e!="string")throw new TypeError("Cookie value must be provided as a string.");if(r===null)throw new TypeError("Secret key must be provided.");const n=await crypto.subtle.importKey("raw",B.encode(r),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),t=await crypto.subtle.sign("HMAC",n,B.encode(e));return e+"."+ue(Buffer.from(t).toString("base64"))},de=async(e,r)=>{if(typeof e!="string")throw new TypeError("Signed cookie string must be provided.");if(r===null)throw new TypeError("Secret key must be provided.");const n=e.slice(0,e.lastIndexOf("."));return await N(n,r)===e?n:!1},me=(e,r)=>{if(!(!e||typeof e!="object"||!r))for(const[n,t]of Object.entries(r)){if(n in re||!(n in e))continue;const o=e[n];typeof o=="function"&&(o(t),delete r[n])}},ge=({globalHook:e,localHook:r})=>n=>(t,o)=>{if(typeof t=="function"&&(t={fn:t}),"fn"in t||Array.isArray(t)){r[n]||(r[n]=[]),typeof r[n]=="function"&&(r[n]=[r[n]]),Array.isArray(t)?r[n]=r[n].concat(t):r[n].push(t);return}const{insert:a="after",stack:s="local"}=t;typeof o=="function"&&(o={fn:o}),s==="global"?Array.isArray(o)?a==="before"?e[n]=o.concat(e[n]):e[n]=e[n].concat(o):a==="before"?e[n].unshift(o):e[n].push(o):(r[n]||(r[n]=[]),typeof r[n]=="function"&&(r[n]=[r[n]]),Array.isArray(o)?a==="before"?r[n]=o.concat(r[n]):r[n]=r[n].concat(o):a==="before"?r[n].unshift(o):r[n].push(o))},be=e=>{if(typeof e=="number")return e;if(e.length<16){if(e.trim().length===0)return null;const r=Number(e);return Number.isNaN(r)?null:r}if(e.length===16){if(e.trim().length===0)return null;const r=Number(e);return Number.isNaN(r)||r.toString()!==e?null:r}return null},G=e=>be(e)!==null;class Te{constructor(r=console.error){this.onError=r;this.root=null;this.promises=[]}get size(){return this.promises.length}add(r){return this.promises.push(r),this.root||=this.drain(),r}async drain(){for(;this.promises.length>0;){try{await this.promises[0]}catch(r){this.onError(r)}this.promises.shift()}this.root=null}then(r,n){return(this.root??Promise.resolve()).then(r,n)}}const R=e=>{if(!e)return e;if(!Array.isArray(e)){if(typeof e=="function")return{fn:e};if("fn"in e)return e}const r=[];for(const n of e)typeof n=="function"?r.push({fn:n}):"fn"in n&&r.push(n);return r},he=e=>({...e,start:R(e?.start),request:R(e?.request),parse:R(e?.parse),transform:R(e?.transform),beforeHandle:R(e?.beforeHandle),afterHandle:R(e?.afterHandle),mapResponse:R(e?.mapResponse),afterResponse:R(e?.afterResponse),trace:R(e?.trace),error:R(e?.error),stop:R(e?.stop)}),Oe=e=>({...e,start:e.start?.map(r=>r.fn),request:e.request?.map(r=>r.fn),parse:e.parse?.map(r=>r.fn),transform:e.transform?.map(r=>r.fn),beforeHandle:e.beforeHandle?.map(r=>r.fn),afterHandle:e.afterHandle?.map(r=>r.fn),afterResponse:e.afterResponse?.map(r=>r.fn),mapResponse:e.mapResponse?.map(r=>r.fn),trace:e.trace?.map(r=>r.fn),error:e.error?.map(r=>r.fn),stop:e.stop?.map(r=>r.fn)}),Se=e=>({body:e.body,cookie:e.cookie,headers:e.headers,query:e.query,set:e.set,server:e.server}),Re=(e,r=302)=>Response.redirect(e,r),Ae=Symbol("ElysiaFormData"),Ce=Symbol("ElysiaRequestId"),ke=e=>{const r=new FormData;for(const[n,t]of Object.entries(e)){if(Array.isArray(t)){for(const o of t)t instanceof File&&r.append(n,t,t.name),r.append(n,o);continue}t instanceof File&&r.append(n,t,t.name),r.append(n,t)}return r},He=()=>crypto.getRandomValues(new Uint32Array(1))[0],xe=e=>{const r=[];for(let n=0;n<e.length;n++){const t=e[n];t.checksum&&(r.includes(t.checksum)&&(e.splice(n,1),n--),r.push(t.checksum))}return e},we=(e,r="scoped")=>{if(r==="scoped"){for(const n of e)"scope"in n&&n.scope==="local"&&(n.scope="scoped");return}for(const n of e)"scope"in n&&(n.scope="global")},j=(e,r=new WeakMap)=>{if(typeof e!="object"||e===null)return e;if(Array.isArray(e))return e.map(a=>j(a,r));if(r.has(e))return r.get(e);const n={};for(const a of Object.keys(e)){const s=e[a];typeof s=="object"&&s!==null?n[a]=j(s,r):n[a]=s}const t=Object.getPrototypeOf(e);if(!t)return n;const o=Object.getOwnPropertyNames(t);for(const a of o){const s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),a);if(s&&typeof s.get=="function"){if(a==="__proto__")continue;console.log(a),n[a]=j(e[a])}}return n};0&&(module.exports={ELYSIA_FORM_DATA,ELYSIA_REQUEST_ID,InvertedStatusMap,PromiseGroup,StatusMap,asHookType,checksum,classToObject,cloneInference,createMacroManager,deduplicateChecksum,filterGlobalHook,fnToContainer,form,getCookieValidator,getResponseSchemaValidator,getSchemaValidator,injectChecksum,isClass,isNumericString,lifeCycleToFn,localHookToLifeCycleStore,mergeCookie,mergeDeep,mergeHook,mergeLifeCycle,mergeObjectArray,mergeResponse,mergeSchemaValidator,primitiveHooks,promoteEvent,randomId,redirect,replaceSchemaType,replaceUrlPath,signCookie,stringToStructureCoercions,traceBackMacro,unsignCookie});

@@ -1,26 +0,1 @@

"use strict";var J=Object.create;var k=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var q=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},F=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Y(t))!G.call(e,o)&&o!==n&&k(e,o,{get:()=>t[o],enumerable:!(a=K(t,o))||a.enumerable});return e};var Z=(e,t,n)=>(n=e!=null?J(W(e)):{},F(t||!e||!e.__esModule?k(n,"default",{value:e,enumerable:!0}):n,e)),Q=e=>F(k({},"__esModule",{value:!0}),e);var Ce={};q(Ce,{ElysiaWS:()=>j,websocket:()=>Ee});module.exports=Q(Ce);var T=require("@sinclair/typebox/value");var L=require("@sinclair/typebox"),Te=require("@sinclair/typebox/value"),ke=require("@sinclair/typebox/compiler");var S=require("@sinclair/typebox"),b=require("@sinclair/typebox/system"),c=require("@sinclair/typebox"),E=require("@sinclair/typebox/compiler"),u=require("@sinclair/typebox/value");var O={date:D,time:x(!0),"date-time":N(!0),"iso-time":x(!1),"iso-date-time":N(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ie,"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\-._~!$&'()*+,;=:]+)\]|(?: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))|(([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:pe,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:se,int32:{type:"number",validate:ue},int64:{type:"number",validate:de},float:{type:"number",validate:P},double:{type:"number",validate:P},password:!0,binary:!0};function X(e){return e%4===0&&(e%100!==0||e%400===0)}var ee=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,te=[0,31,28,31,30,31,30,31,31,30,31,30,31];function D(e){let t=ee.exec(e);if(!t)return!1;let n=+t[1],a=+t[2],o=+t[3];return a>=1&&a<=12&&o>=1&&o<=(a===2&&X(n)?29:te[a])}var ne=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function x(e){return function(n){let a=ne.exec(n);if(!a)return!1;let o=+a[1],r=+a[2],f=+a[3],h=a[4],d=a[5]==="-"?-1:1,y=+(a[6]||0),p=+(a[7]||0);if(y>23||p>59||e&&!h)return!1;if(o<=23&&r<=59&&f<60)return!0;let m=r-p*d,g=o-y*d-(m<0?1:0);return(g===23||g===-1)&&(m===59||m===-1)&&f<61}}var re=/t|\s/i;function N(e){let t=x(e);return function(a){let o=a.split(re);return o.length===2&&D(o[0])&&t(o[1])}}var ae=/\/|:/,oe=/^(?:[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 ie(e){return ae.test(e)&&oe.test(e)}var H=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function se(e){return H.lastIndex=0,H.test(e)}var ce=-(2**31),fe=2**31-1;function ue(e){return Number.isInteger(e)&&e<=fe&&e>=ce}function de(e){return Number.isInteger(e)}function P(){return!0}var le=/[^\\]\\Z/;function pe(e){if(le.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var w=require("@sinclair/typebox/system"),I=require("@sinclair/typebox/compiler"),_=/(\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))/,M=/(?: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\([^)]+\)/,v=/^(?:(?:(?:(?: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)?)?$/,ye=O.date,me=O["date-time"];c.FormatRegistry.Has("date")||b.TypeSystem.Format("date",e=>{let t=e.replace(/"/g,"");if(_.test(t)||M.test(t)||v.test(t)||ye(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});c.FormatRegistry.Has("date-time")||b.TypeSystem.Format("date-time",e=>{let t=e.replace(/"/g,"");if(_.test(t)||M.test(t)||v.test(t)||me(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return!0}return!1});Object.entries(O).forEach(e=>{let[t,n]=e;c.FormatRegistry.Has(t)||(n instanceof RegExp?b.TypeSystem.Format(t,a=>n.test(a)):typeof n=="function"&&b.TypeSystem.Format(t,n))});var i=Object.assign({},c.Type),B=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},C=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<B(e.minSize)||e.maxSize&&t.size>B(e.maxSize))return!1;if(e.extension)if(typeof e.extension=="string"){if(!t.type.startsWith(e.extension))return!1}else{for(let n=0;n<e.extension.length;n++)if(t.type.startsWith(e.extension[n]))return!0;return!1}return!0},he=S.TypeRegistry.Get("Files")??b.TypeSystem.Type("File",C),ge=S.TypeRegistry.Get("Files")??b.TypeSystem.Type("Files",(e,t)=>{if(!Array.isArray(t))return C(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(!C(e,t[n]))return!1;return!0});c.FormatRegistry.Has("numeric")||c.FormatRegistry.Set("numeric",e=>!!e&&!isNaN(+e));c.FormatRegistry.Has("boolean")||c.FormatRegistry.Set("boolean",e=>e==="true"||e==="false");c.FormatRegistry.Has("ObjectString")||c.FormatRegistry.Set("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}});c.FormatRegistry.Has("ArrayString")||c.FormatRegistry.Set("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}});S.TypeRegistry.Set("UnionEnum",(e,t)=>(typeof t=="number"||typeof t=="string"||t===null)&&e.enum.includes(t));var l={Numeric:e=>{let t=c.Type.Number(e);return i.Transform(i.Union([i.String({format:"numeric",default:0}),i.Number(e)],e)).Decode(n=>{let a=+n;if(isNaN(a))return n;if(e&&!u.Value.Check(t,a))throw new s("property",t,a);return a}).Encode(n=>n)},Date:e=>{let t=c.Type.Date(e);return i.Transform(i.Union([c.Type.Date(e),i.String({format:"date",default:new Date().toISOString()}),i.String({format:"date-time",default:new Date().toISOString()})],e)).Decode(n=>{if(n instanceof Date)return n;let a=new Date(n);if(!u.Value.Check(t,a))throw new s("property",t,a);return a}).Encode(n=>typeof n=="string"?new Date(n):n)},BooleanString:e=>{let t=c.Type.Boolean(e);return i.Transform(i.Union([i.String({format:"boolean",default:!1}),i.Boolean(e)],e)).Decode(n=>{if(typeof n=="string")return n==="true";if(e&&!u.Value.Check(t,n))throw new s("property",t,n);return n}).Encode(n=>n)},ObjectString:(e,t)=>{let n=i.Object(e,t),a=JSON.stringify(u.Value.Create(n)),o;try{o=E.TypeCompiler.Compile(n)}catch{}return i.Transform(i.Union([i.String({format:"ObjectString",default:a}),n])).Decode(r=>{if(typeof r=="string"){if(r.charCodeAt(0)!==123)throw new s("property",n,r);try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(o){if(!o.Check(r))throw new s("property",n,r);return o.Decode(r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return u.Value.Decode(n,r)}return r}).Encode(r=>{if(typeof r=="string")try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return JSON.stringify(r)})},ArrayString:(e={},t)=>{let n=i.Array(e,t),a=JSON.stringify(u.Value.Create(n)),o;try{o=E.TypeCompiler.Compile(n)}catch{}return i.Transform(i.Union([i.String({format:"ArrayString",default:a}),n])).Decode(r=>{if(typeof r=="string"){if(r.charCodeAt(0)!==91)throw new s("property",n,r);try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(o){if(!o.Check(r))throw new s("property",n,r);return o.Decode(r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return u.Value.Decode(n,r)}return r}).Encode(r=>{if(typeof r=="string")try{r=JSON.parse(r)}catch{throw new s("property",n,r)}if(!u.Value.Check(n,r))throw new s("property",n,r);return JSON.stringify(r)})},File:he,Files:(e={})=>i.Transform(ge(e)).Decode(t=>Array.isArray(t)?t:[t]).Encode(t=>t),Nullable:e=>i.Union([e,i.Null()]),MaybeEmpty:e=>i.Union([e,i.Null(),i.Undefined()]),Cookie:(e,{domain:t,expires:n,httpOnly:a,maxAge:o,path:r,priority:f,sameSite:h,secure:d,secrets:y,sign:p,...m}={})=>{let g=i.Object(e,m);return g.config={domain:t,expires:n,httpOnly:a,maxAge:o,path:r,priority:f,sameSite:h,secure:d,secrets:y,sign:p},g},UnionEnum:(e,t={})=>{let n=e.every(a=>typeof a=="string")?{type:"string"}:e.every(a=>typeof a=="number")?{type:"number"}:e.every(a=>a===null)?{type:"null"}:{};if(e.some(a=>typeof a=="object"&&a!==null))throw new Error("This type does not support objects or arrays");return{default:e[0],...t,[S.Kind]:"UnionEnum",...n,enum:e}}};i.BooleanString=l.BooleanString;i.ObjectString=l.ObjectString;i.ArrayString=l.ArrayString;i.Numeric=l.Numeric;i.File=(e={})=>l.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"});i.Files=(e={})=>l.Files({...e,elysiaMeta:"Files",default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});i.Nullable=e=>l.Nullable(e);i.MaybeEmpty=l.MaybeEmpty;i.Cookie=l.Cookie;i.Date=l.Date;i.UnionEnum=l.UnionEnum;var Se=require("cookie");var be=require("cookie"),Re=Z(require("fast-decode-uri-component"));var Xe="toJSON"in new Headers;var Oe=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],st=Oe.reduce((e,t)=>(e[t]=!0,e),{});var we=typeof Bun<"u",ct=we&&typeof Bun.hash=="function";var A={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},xe=Object.fromEntries(Object.entries(A).map(([e,t])=>[t,e]));var ft=new TextEncoder;var ut=Symbol("ElysiaFormData"),dt=Symbol("ElysiaRequestId");var $=()=>crypto.getRandomValues(new Uint32Array(1))[0];var U=typeof Bun<"u"?Bun.env:typeof process<"u"?process?.env:void 0,yt=Symbol("ElysiaErrorCode"),z=Symbol("ElysiaResponse"),V=(U?.NODE_ENV??U?.ENV)==="production";var R=e=>{if(!e)return{summary:void 0};let{message:t,path:n,value:a,type:o}=e,r=n.slice(1).replaceAll("/","."),f=n==="";switch(o){case 42:return{...e,summary:f?"Value should not be provided":`Property '${r}' should not be provided`};case 45:return{...e,summary:f?"Value is missing":`Property '${r}' is missing`};case 50:let h=t.indexOf("'"),d=t.slice(h+1,t.indexOf("'",h+1));return{...e,summary:f?"Value should be an email":`Property '${r}' should be ${d}`};case 54:return{...e,summary:`${t.slice(0,9)} property '${r}' to be ${t.slice(8)} but found: ${a}`};case 62:let y=e.schema.anyOf.map(p=>`'${p?.format??p.type}'`).join(", ");return{...e,summary:f?`Value should be one of ${y}`:`Property '${r}' should be one of: ${y}`};default:return{summary:t,...e}}},s=class e extends Error{constructor(n,a,o){o&&typeof o=="object"&&z in o&&(o=o.response);let r=V?void 0:"Errors"in a?a.Errors(o).First():T.Value.Errors(a,o).First(),f=r?.schema.error!==void 0?typeof r.schema.error=="function"?r.schema.error({type:n,validator:a,value:o,get errors(){return[...a.Errors(o)].map(R)}}):r.schema.error:void 0,h=r?.path||"root",d="";if(f!==void 0)d=typeof f=="object"?JSON.stringify(f):f+"";else if(V)d=JSON.stringify({type:"validation",on:n,summary:R(r).summary,message:r?.message,found:o});else{let y=a?.schema??a,p="Errors"in a?[...a.Errors(o)].map(R):[...T.Value.Errors(a,o)].map(R),m;try{m=T.Value.Create(y)}catch(g){m={type:"Could not create expected value",message:g?.message,error:g}}d=JSON.stringify({type:"validation",on:n,summary:p[0]?.summary,property:h,message:r?.message,expected:m,found:o,errors:p},null,2)}super(d);this.type=n;this.validator=a;this.value=o;this.code="VALIDATION";this.status=422;Object.setPrototypeOf(this,e.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(R):[...T.Value.Errors(this.validator,this.value)].map(R)}static simplifyModel(n){let a="schema"in n?n.schema:n;try{return T.Value.Create(a)}catch{return a}}get model(){return e.simplifyModel(this.validator)}toResponse(n){return new Response(this.message,{status:400,headers:{...n,"content-type":"application/json"}})}};var Ee={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)}},j=class{constructor(t,n){this.raw=t;this.data=n;this.validator=t.data.validator,t.data.id?this.id=t.data.id:this.id=$().toString()}get id(){return this.raw.data.id}set id(t){this.raw.data.id=t}get publish(){return(t,n=void 0,a)=>{if(this.validator?.Check(n)===!1)throw new s("message",this.validator,n);return typeof n=="object"&&(n=JSON.stringify(n)),this.raw.publish(t,n,a),this}}get send(){return t=>{if(this.validator?.Check(t)===!1)throw new s("message",this.validator,t);return Buffer.isBuffer(t)?(this.raw.send(t),this):(typeof t=="object"&&(t=JSON.stringify(t)),this.raw.send(t),this)}}get subscribe(){return t=>(this.raw.subscribe(t),this)}get unsubscribe(){return t=>(this.raw.unsubscribe(t),this)}get cork(){return t=>(this.raw.cork(t),this)}get close(){return()=>(this.raw.close(),this)}get terminate(){return this.raw.terminate.bind(this.raw)}get isSubscribed(){return this.raw.isSubscribed.bind(this.raw)}get remoteAddress(){return this.raw.remoteAddress}};0&&(module.exports={ElysiaWS,websocket});
/**
* @license
*
* MIT License
*
* Copyright (c) 2020 Evgeny Poberezkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
"use strict";var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var r in e)n(t,r,{get:e[r],enumerable:!0})},p=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of d(e))!h.call(t,s)&&s!==r&&n(t,s,{get:()=>e[s],enumerable:!(i=u(e,s))||i.enumerable});return t};var l=t=>p(n({},"__esModule",{value:!0}),t);var f={};c(f,{ElysiaWS:()=>b,websocket:()=>m});module.exports=l(f);var o=require("../error"),a=require("../utils");const m={open(t){t.data.open?.(t)},message(t,e){t.data.message?.(t,e)},drain(t){t.data.drain?.(t)},close(t,e,r){t.data.close?.(t,e,r)}};class b{constructor(e,r){this.raw=e;this.data=r;this.validator=e.data.validator,e.data.id?this.id=e.data.id:this.id=(0,a.randomId)().toString()}get id(){return this.raw.data.id}set id(e){this.raw.data.id=e}get publish(){return(e,r=void 0,i)=>{if(this.validator?.Check(r)===!1)throw new o.ValidationError("message",this.validator,r);return typeof r=="object"&&(r=JSON.stringify(r)),this.raw.publish(e,r,i),this}}get send(){return e=>{if(this.validator?.Check(e)===!1)throw new o.ValidationError("message",this.validator,e);return Buffer.isBuffer(e)?(this.raw.send(e),this):(typeof e=="object"&&(e=JSON.stringify(e)),this.raw.send(e),this)}}get subscribe(){return e=>(this.raw.subscribe(e),this)}get unsubscribe(){return e=>(this.raw.unsubscribe(e),this)}get cork(){return e=>(this.raw.cork(e),this)}get close(){return()=>(this.raw.close(),this)}get terminate(){return this.raw.terminate.bind(this.raw)}get isSubscribed(){return this.raw.isSubscribed.bind(this.raw)}get remoteAddress(){return this.raw.remoteAddress}}0&&(module.exports={ElysiaWS,websocket});
{
"name": "elysia",
"description": "Ergonomic Framework for Human",
"version": "1.2.0-exp.0",
"version": "1.2.0-exp.1",
"author": {

@@ -6,0 +6,0 @@ "name": "saltyAom",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc