bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
4 lines • 56.4 kB
JavaScript
import Pe from'dayjs';export{default as dayjs}from'dayjs';import Cr from'dayjs/plugin/weekOfYear.js';import {getRuntimeKey}from'hono/adapter';import {XMLParser}from'fast-xml-parser';import {validator}from'hono/validator';var Tr=Object.create;var ee=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var kr=Object.getOwnPropertyNames;var Nr=Object.getPrototypeOf,$r=Object.prototype.hasOwnProperty;var Rr=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),_r=(e,r)=>{for(var t in r)ee(e,t,{get:r[t],enumerable:true});},Pr=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of kr(r))!$r.call(e,i)&&i!==t&&ee(e,i,{get:()=>r[i],enumerable:!(n=Ar(r,i))||n.enumerable});return e};var jr=(e,r,t)=>(t=e!=null?Tr(Nr(e)):{},Pr(ee(t,"default",{value:e,enumerable:true}),e));var Ie=Rr((In,re)=>{var d=String,Ce=function(){return {isColorSupported:false,reset:d,bold:d,dim:d,italic:d,underline:d,inverse:d,hidden:d,strikethrough:d,black:d,red:d,green:d,yellow:d,blue:d,magenta:d,cyan:d,white:d,gray:d,bgBlack:d,bgRed:d,bgGreen:d,bgYellow:d,bgBlue:d,bgMagenta:d,bgCyan:d,bgWhite:d,blackBright:d,redBright:d,greenBright:d,yellowBright:d,blueBright:d,magentaBright:d,cyanBright:d,whiteBright:d,bgBlackBright:d,bgRedBright:d,bgGreenBright:d,bgYellowBright:d,bgBlueBright:d,bgMagentaBright:d,bgCyanBright:d,bgWhiteBright:d}};re.exports=Ce();re.exports.createColors=Ce;});Pe.extend(Cr);function je(e){return Pe(e).format("YYYY-MM-DD HH:mm:ss")}function _n(e){return (e?new Date(e):new Date).toISOString().replace("T"," ").split(".")[0]}function Pn(){return new Date().getTimezoneOffset()}function jn(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var O=jr(Ie());var Ue=(e,r)=>typeof e=="string"?[1,"1","true"].includes(e):!!(e||r);var Ir={cli_log_level:{key:"BKND_CLI_LOG_LEVEL",validate:e=>{if(typeof e=="string"&&["log","info","warn","error","debug"].includes(e.toLowerCase()))return e.toLowerCase()}},cli_create_ref:{key:"BKND_CLI_CREATE_REF",validate:e=>typeof e=="string"?e:void 0},cli_telemetry:{key:"BKND_CLI_TELEMETRY",validate:e=>{if(!(typeof e>"u"))return Ue(e,true)}},modules_debug:{key:"BKND_MODULES_DEBUG",validate:Ue}},De=(e,r,t)=>{try{let n=t?.source??process.env,i=Ir[e],o=n[i.key],s=i.validate(o);if(typeof s<"u")return t?.onValid?.(s),s;t?.onFallback?.(o);}catch{}return r};function Ur(){try{let e=process||{},r=e.argv||[],t=e.env||{};return !(t.NO_COLOR||r.includes("--no-color"))&&(!!t.FORCE_COLOR||r.includes("--color")||e.platform==="win32"||(e.stdout||{}).isTTY&&t.TERM!=="dumb"||!!t.CI)}catch{return false}}var B={critical:{prefix:"CRT",color:O.default.red,args_color:O.default.red,original:console.error},error:{prefix:"ERR",color:O.default.red,args_color:O.default.red,original:console.error},warn:{prefix:"WRN",color:O.default.yellow,args_color:O.default.yellow,original:console.warn},info:{prefix:"INF",color:O.default.cyan,original:console.info},log:{prefix:"LOG",color:O.default.dim,args_color:O.default.dim,original:console.log},debug:{prefix:"DBG",color:O.default.yellow,args_color:O.default.dim,original:console.debug}};function Dr(e,r){let t=Ur(),n=B[e],i=n.color(`[${n.prefix}]`),o=r.map(s=>"args_color"in n&&t&&typeof s=="string"?n.args_color(s):s);return n.original(i,O.default.gray(je()),...o)}var Le=De("cli_log_level","log"),M=globalThis.__consoleConfig??={level:Le},Se=Object.keys(B),_=new Proxy(M,{get:(e,r)=>{switch(r){case "original":return console;case "setLevel":return i=>{M.level=i;};case "resetLevel":return ()=>{M.level=Le;}}let t=Se.indexOf(M.level),n=Se.indexOf(r);return r in B&&n<=t?(...i)=>Dr(r,i):()=>null}});function Ln(e){for(let[r]of Object.entries(B))e[r]=_[r];}function Bn(){return (navigator.userAgent.indexOf("Opera")||navigator.userAgent.indexOf("OPR"))!==-1?"Opera":navigator.userAgent.indexOf("Edg")!==-1?"Edge":navigator.userAgent.indexOf("Chrome")!==-1?"Chrome":navigator.userAgent.indexOf("Safari")!==-1?"Safari":navigator.userAgent.indexOf("Firefox")!==-1?"Firefox":navigator.userAgent.indexOf("MSIE")!==-1||document.documentMode?"IE":"unknown"}function Fn(e){return Object.keys(e).map(r=>({key:r,value:e[r]}))}function ne(e){return !e||e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function Sr(e,r=" "){return !e||e.length===0?e:e.split(r).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(r)}function Me(e,r=false){let i="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"+(r?"!@#$%^&*()_+{}:\"<>?|[];',./`~":""),o="";for(let s=0;s<e;s++)o+=i[Math.floor(Math.random()*i.length)];return o}function ie(e){return !e||e.length===0?e:e.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ")}function z(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Lr(e){return /^[a-z]+(_[a-z]+)*$/.test(e)?"snake_case":/^[A-Z][a-zA-Z]*$/.test(e)?"PascalCase":/^[a-z][a-zA-Z]*$/.test(e)?"camelCase":/^[a-z]+(-[a-z]+)*$/.test(e)?"kebab-case":/^[A-Z]+(_[A-Z]+)*$/.test(e)?"SCREAMING_SNAKE_CASE":"unknown"}function Mr(e){switch(Lr(e)){case "snake_case":return ie(e);case "PascalCase":return te(z(e));case "camelCase":return ne(te(z(e)));case "kebab-case":return te(e);case "SCREAMING_SNAKE_CASE":return ie(e.toLowerCase());case "unknown":return ne(e)}}function qn(e){return Mr(e)}function te(e){return e.split("-").map(ne).join(" ")}function Kn(e,r=" "){return Sr(ie(e),r)}function Jn(e,r){return e.replace(/\{\$(\w+)\}/g,(t,n)=>n in r?r[n]:t)}function Vn(e,r){return r instanceof RegExp?r.test(e):typeof r=="string"&&r.startsWith("/")?new RegExp(r).test(e):typeof r=="string"?e.startsWith(r):false}function Yn(e){return String(e).normalize("NFKD").replace(/[\u0300-\u036f]/g,"").trim().toLowerCase().replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")}function Gn(e,r=50,t="..."){return e.length<=r?e:e.substring(0,r)+t}function Zn(e,r=2){return JSON.stringify(e,null,r)}function Je(e){return Object.prototype.toString.call(e)==="[object Object]"}function I(e){return e!==null&&typeof e=="object"}function Xn(e,r){let t=new Set(r),n={};for(let[i,o]of Object.entries(e))t.has(i)||(n[i]=o);return n}function Hn(e){return Object.entries(e).reduce((r,[t,n])=>{try{r[t]=JSON.parse(n);}catch{r[t]=n;}return r},{})}function ei(e,r){return Object.keys(r).reduce((t,n)=>(r[n]!==e[n]&&(t[n]=r[n]),t),{})}function Be(e,r=[]){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>Be(t,r)):Object.keys(e).reduce((t,n)=>{let i=r.includes(n)?n:z(n);return t[i]=Be(e[n],r),t},{})}function Br(e,r){let t={};for(let n in e)r.some(o=>n.includes(o))||(typeof e[n]=="object"&&e[n]!==null&&!Array.isArray(e[n])?t[n]=Br(e[n],r):t[n]=e[n]);return t}function zr(e,r){let t={};for(let[n,i]of Object.entries(e)){let o=r(i,n);typeof o<"u"&&(t[n]=o);}return t}var ri=zr;function ti(e,r){Object.entries(e).forEach(([t,n])=>{r(n,t);},{});}function ze(e,...r){if(!r.length)return e;let t=r.shift();if(I(e)&&I(t))for(let n in t)I(t[n])?(e[n]||Object.assign(e,{[n]:{}}),ze(e[n],t[n])):Object.assign(e,{[n]:t[n]});return ze(e,...r)}function Fr(e,r=""){let t=[];for(let n in e){let i=r?`${r}.${n}`:n;t.push(i),typeof e[n]=="object"&&e[n]!==null&&(t=t.concat(Fr(e[n],i)));}return t}function Fe(e,r="",t={}){for(let n in e)if(n in e){let i=r?`${r}.${n}`:n;typeof e[n]=="object"&&e[n]!==null&&!Array.isArray(e[n])?Fe(e[n],i,t):Array.isArray(e[n])?e[n].forEach((o,s)=>{let c=`${i}.${s}`;typeof o=="object"&&o!==null?Fe(o,c,t):t[c]=o;}):t[i]=e[n];}return t}function qr(e){let r=1;for(let t in e)if(typeof e[t]=="object"){let n=qr(e[t])+1;r=Math.max(n,r);}return r}function qe(e){return e&&Object.entries(e).reduce((r,[t,n])=>{if(n&&Array.isArray(n)&&n.some(i=>typeof i=="object")){let i=n.map(qe);i.length>0&&(r[t]=i);}else if(n&&typeof n=="object"&&!Array.isArray(n)){let i=qe(n);Object.keys(i).length>0&&(r[t]=i);}else n!==""&&n!==null&&n!==void 0&&(r[t]=n);return r},{})}function Kr(e,...r){for(let t of r)for(let[n,i]of Object.entries(t))i!==void 0&&(!Je(i)&&!Array.isArray(i)||Array.isArray(i)&&!Array.isArray(e[n])?e[n]=i:I(e[n])?Kr(e[n],i):e[n]=i);return e}function Jr(e,r,t){for(let[n,i]of Object.entries(r)){let o=t(e[n],i,n,e,r);if(o!==void 0){e[n]=o;continue}i!==void 0&&(!Je(i)&&!Array.isArray(i)||Array.isArray(i)&&!Array.isArray(e[n])?e[n]=i:I(e[n])?Jr(e[n],i,t):e[n]=i);}return e}function oe(e,r){let t=i=>{if(i!==Object(i))return "primitive";if(Array.isArray(i))return "array";if(i instanceof Map)return "map";if(i!=null&&[null,Object.prototype].includes(Object.getPrototypeOf(i)))return "plainObject";if(i instanceof Function)return "function";throw new Error(`deeply comparing an instance of type ${e.constructor?.name} is not supported.`)},n=t(e);if(n!==t(r))return false;if(n==="primitive")return e===r||Number.isNaN(e)&&Number.isNaN(r);if(n==="array")return e.length===r.length&&e.every((i,o)=>oe(i,r[o]));if(n==="map")return e.size===r.size&&[...e].every(([i,o])=>r.has(i)&&oe(o,r.get(i)));if(n==="plainObject"){let i=new Map(Object.entries(e)),o=new Map(Object.entries(r));return i.size===o.size&&[...i].every(([s,c])=>o.has(s)&&oe(c,o.get(s)))}else {if(n==="function")return e.toString()===r.toString();throw new Error("Unreachable")}}function Vr(e,r,t=void 0){let n=typeof r=="string"?r.split(/[.\[\]\"]+/).filter(i=>i):r;if(n.length===0)return e;try{let[i,...o]=n;return !i||!(i in e)?t:Vr(e[i],o,t)}catch{if(typeof t<"u")return t;throw new Error(`Invalid path: ${n.join(".")}`)}}function Ke(e,r=0,t=0){let n=r?`
`:"",i=f=>r?" ".repeat(r*f):"",o=i(t+1),s=i(t);if(e===null)return "null";if(e===void 0)return "undefined";let c=typeof e;if(c==="string")return JSON.stringify(e);if(c==="number"||c==="boolean")return String(e);if(Array.isArray(e)){let f=e.map(u=>Ke(u,r,t+1)).join(", "+(r?n+o:""));return "["+(r&&e.length?n+o:"")+f+(r&&e.length?n+s:"")+"]"}if(c==="object"){let f=Object.entries(e).map(([m,b])=>(/^[A-Za-z_$][\w$]*$/.test(m)?m:JSON.stringify(m))+": "+Ke(b,r,t+1)),u=f.join(", "+(r?n+o:""));return "{"+(r&&f.length?n+o:"")+u+(r&&f.length?n+s:"")+"}"}throw new TypeError(`Unsupported data type: ${c}`)}function ni(e,r){return r.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}function Yr(e){if(Object.isFrozen(e))return e;let r=Reflect.ownKeys(e);for(let t of r){let n=e[t];(n&&typeof n=="object"||typeof n=="function")&&Yr(n);}return Object.freeze(e)}var Ve=class e{marks=[];startTime;endTime=null;constructor(){this.startTime=performance.now();}static start(){return new e}mark(r){if(this.endTime!==null)throw new Error("Cannot add marks after perf measurement has been closed.");let t=performance.now(),n=this.marks.length>0?this.marks[this.marks.length-1].time:this.startTime,i=t-n;this.marks.push({mark:r,time:i});}close(){if(this.endTime!==null)throw new Error("Perf measurement has already been closed.");this.endTime=performance.now();}result(){if(this.endTime===null)throw new Error("Perf measurement has not been closed yet.");let r=this.endTime-this.startTime;return {total:Number.parseFloat(r.toFixed(2)),marks:this.marks.map(t=>({mark:t.mark,time:Number.parseFloat(t.time.toFixed(2))}))}}static async execute(r,t=1){let n=e.start();for(let i=0;i<t;i++)await r(),n.mark(`iteration-${i}`);return n.close(),n.result()}};var ae={video:["mp4","webm"],audio:["ogg"],image:["jpeg","png","gif","webp","bmp","tiff","avif","heic","heif"],text:["html","css","mdx","yaml","vcard","csv","vtt"],application:["zip","xml","toml","json","json5"],font:["woff","woff2","ttf","otf"]},p={vnd:"vnd.openxmlformats-officedocument",z:"application/x-7z-compressed",t:(e="plain")=>`text/${e}`,a:(e="octet-stream")=>`application/${e}`,i:e=>`image/${e}`,v:e=>`video/${e}`},se=new Map([["7z",p.z],["7zip",p.z],["ai",p.a("pdf")],["apk",p.a("vnd.android.package-archive")],["doc",p.a("msword")],["docx",`${p.vnd}.wordprocessingml.document`],["eps",p.a("postscript")],["epub",p.a("epub+zip")],["ini",p.t()],["ico",p.i("vnd.microsoft.icon")],["jar",p.a("java-archive")],["jsonld",p.a("ld+json")],["jpg",p.i("jpeg")],["js",p.t("javascript")],["log",p.t()],["m3u",p.t()],["m3u8",p.a("vnd.apple.mpegurl")],["manifest",p.t("cache-manifest")],["md",p.t("markdown")],["mkv",p.v("x-matroska")],["mp3",p.a("mpeg")],["mobi",p.a("x-mobipocket-ebook")],["ppt",p.a("powerpoint")],["pptx",`${p.vnd}.presentationml.presentation`],["qt",p.v("quicktime")],["svg",p.i("svg+xml")],["tif",p.i("tiff")],["tsv",p.t("tab-separated-values")],["tgz",p.a("x-tar")],["txt",p.t()],["text",p.t()],["vcd",p.a("x-cdlink")],["vcs",p.t("x-vcalendar")],["wav",p.a("x-wav")],["webmanifest",p.a("manifest+json")],["xls",p.a("vnd.ms-excel")],["xlsx",`${p.vnd}.spreadsheetml.sheet`],["yml",p.t("yaml")]]);function Ye(e){try{let r=e.split(".").pop();if(!r)return p.a();for(let[t,n]of Object.entries(ae))if(n.includes(r))return `${t}/${r}`;return se.get(r)}catch{return p.a()}}function Ge(e,r=[]){let t=e.toLowerCase();if(r.includes(t))return false;if(Object.entries(ae).flatMap(([n,i])=>i.map(o=>`${n}/${o}`)).includes(t))return true;for(let[n,i]of se.entries())if(i===t&&!r.includes(n))return true;return false}function We(e){let r=e.toLowerCase();for(let[t,n]of Object.entries(ae))for(let i of n)if(r===`${t}/${i}`)return i;for(let[t,n]of se.entries())if(n===r)return t;return ""}function Wr(){let e=globalThis;return e?.process?.env?.NEXT_RUNTIME==="nodejs"?"nextjs":e?.process?.env?.NEXT_RUNTIME==="edge"?"nextjs-edge":typeof window<"u"&&window.__NEXT_DATA__?"nextjs-client":getRuntimeKey()}var Qe={redirects_non_fq:true};function ci(e){return Wr().startsWith("nextjs")&&(Qe.redirects_non_fq=false),Qe[e]}function li(){try{return global?.process?.release?.name==="node"}catch{return false}}function fi(){try{return typeof Bun<"u"}catch{return false}}function ce(e,r){if(!e)throw new Error(r)}function Qr(e){let r="";typeof e=="string"?r=e:e instanceof Headers?r=e.get("Content-Disposition")||"":e instanceof Request&&(r=e.headers.get("Content-Disposition")||"");let t=r.match(/filename\*?=(?:UTF-8'')?("?)([^";]+)\1/);return t?t[2]:void 0}function Zr(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}function F(e){return typeof e=="object"&&e!==null&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"}function q(e){return F(e)&&typeof e.name=="string"&&typeof e.lastModified=="number"}function Xr(e){return typeof e=="object"&&e!==null&&Object.prototype.toString.call(e)==="[object ArrayBuffer]"}function Hr(e){return typeof e=="object"&&e!==null&&ArrayBuffer.isView(e)}var et={"89504E47":"image/png",FFD8FF:"image/jpeg",47494638:"image/gif","49492A00":"image/tiff","4D4D002A":"image/tiff","52494646????57454250":"image/webp","504B0304":"application/zip",25504446:"application/pdf","00000020667479706D70":"video/mp4","000001BA":"video/mpeg","000001B3":"video/mpeg","1A45DFA3":"video/webm","4F676753":"audio/ogg",494433:"audio/mpeg",FFF1:"audio/aac",FFF9:"audio/aac","52494646????41564920":"audio/wav","52494646????57415645":"audio/wave","52494646????415550":"audio/aiff"};async function rt(e){if(!e)return;let r;if(Zr(e)){let n=e.getReader(),{value:i}=await n.read();if(!i)return;r=new Uint8Array(i);}else if(F(e)||q(e))r=new Uint8Array(await e.slice(0,12).arrayBuffer());else if(Xr(e))r=new Uint8Array(e);else if(Hr(e))r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);else if(typeof e=="string")r=new TextEncoder().encode(e);else return;let t=Array.from(r.slice(0,12)).map(n=>n.toString(16).padStart(2,"0").toUpperCase()).join("");for(let[n,i]of Object.entries(et))if(new RegExp("^"+n.replace(/\?\?/g,"..")).test(t))return i}async function tt(e){let r=e.req.header("Content-Type")??"application/octet-stream";if(r?.startsWith("multipart/form-data")||r?.startsWith("application/x-www-form-urlencoded"))try{let t=await e.req.formData();if([...t.values()].length>0){let n=[...t.values()][0];return await Ze(n)}}catch(t){_.warn("Error parsing form data",t);}else try{let t=await e.req.blob();if(q(t))return t;if(F(t))return await Ze(t,{name:Qr(e.req.raw),type:r})}catch(t){_.warn("Error parsing blob",t);}throw new Error("No file found in request")}async function gi(e){let r=e.req.header("Content-Type")??"application/octet-stream";if(!r?.startsWith("multipart/form-data")&&!r?.startsWith("application/x-www-form-urlencoded")){let t=e.req.raw.body;if(t)return t}return tt(e)}async function yi(e,r){let t=q(e),n=t?e.type:r;ce(n&&typeof n=="string"&&n.startsWith("image/"),"type must be image/*");let i=t?await e.arrayBuffer():e;ce(i.byteLength>=128,"Buffer must be at least 128 bytes");let o=new DataView(i);if(n==="image/jpeg"){let s=2;for(;s<o.byteLength;){let c=o.getUint16(s);if(s+=2,c===65472||c===65474)return {width:o.getUint16(s+5),height:o.getUint16(s+3)};s+=o.getUint16(s);}}else {if(n==="image/png")return {width:o.getUint32(16),height:o.getUint32(20)};if(n==="image/gif")return {width:o.getUint16(6),height:o.getUint16(8)};if(n==="image/tiff"){let s=o.getUint16(0)===18761,c=o.getUint32(4,s),f=o.getUint32(c+18,s),u=o.getUint32(c+10,s);return {width:f,height:u}}}throw new Error("Unsupported image format")}async function Ze(e,r={}){if(q(e))return e;if(!F(e))throw new Error("Not a Blob");let t=Ge(r.type,["application/octet-stream"])?r.type:await rt(e),n=t?We(t):"",i=r.name||[Me(16),n].filter(Boolean).join(".");return new File([e],i,{type:t||Ye(i),lastModified:Date.now()})}function nt(e){return e?{...Object.fromEntries(e.entries())}:{}}function wi(e,r){let t=nt(e),n={};for(let i of r)t[i]&&(n[i]=t[i]);return n}function bi(e,r){let t=new Headers;for(let n of r)e.has(n)&&t.set(n,e.get(n));return t}var Oi=(e,r)=>{let t=e;for(let[n,i]of Object.entries(r)){let o=new RegExp(`/:${n}(?:{[^/]+})?`);t=t.replace(o,`/${i}`);}return t};function vi(e,r){let t="";function n(i){return r?.encode?encodeURIComponent(i):i}for(let i in e){let o=e[i];if(o!==void 0)if(Array.isArray(o))for(let s=0;s<o.length;s++)t.length>0&&(t+="&"),t+=`${n(i)}=${n(o[s])}`;else typeof o=="object"&&(o=JSON.stringify(o)),t.length>0&&(t+="&"),t+=`${n(i)}=${n(o)}`;}return (r?.prefix||"")+t}function Ei(e){function r(s){if(!s)return "";let c=decodeURIComponent(s);if(c==="false")return false;if(c==="true")return true;try{return JSON.parse(c)}catch{return +c*0===0?+c:c}}let t,n,i={},o=e.split("&");for(;t=o.shift();)t=t.split("="),n=t.shift(),i[n]!==void 0?i[n]=[].concat(i[n],r(t.shift())):i[n]=r(t.shift());return i}var it=(a=>(a[a.CONTINUE=100]="CONTINUE",a[a.PROCESSING=102]="PROCESSING",a[a.EARLY_HINTS=103]="EARLY_HINTS",a[a.OK=200]="OK",a[a.CREATED=201]="CREATED",a[a.ACCEPTED=202]="ACCEPTED",a[a.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",a[a.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",a[a.MULTI_STATUS=207]="MULTI_STATUS",a[a.ALREADY_REPORTED=208]="ALREADY_REPORTED",a[a.IM_USED=226]="IM_USED",a[a.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",a[a.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",a[a.FOUND=302]="FOUND",a[a.SEE_OTHER=303]="SEE_OTHER",a[a.USE_PROXY=305]="USE_PROXY",a[a.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",a[a.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",a[a.BAD_REQUEST=400]="BAD_REQUEST",a[a.UNAUTHORIZED=401]="UNAUTHORIZED",a[a.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",a[a.FORBIDDEN=403]="FORBIDDEN",a[a.NOT_FOUND=404]="NOT_FOUND",a[a.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",a[a.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",a[a.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",a[a.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",a[a.CONFLICT=409]="CONFLICT",a[a.GONE=410]="GONE",a[a.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",a[a.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",a[a.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",a[a.URI_TOO_LONG=414]="URI_TOO_LONG",a[a.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",a[a.RANGE_NOT_SATISFIABLE=416]="RANGE_NOT_SATISFIABLE",a[a.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",a[a.IM_A_TEAPOT=418]="IM_A_TEAPOT",a[a.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",a[a.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",a[a.LOCKED=423]="LOCKED",a[a.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",a[a.TOO_EARLY=425]="TOO_EARLY",a[a.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",a[a.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",a[a.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",a[a.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",a[a.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",a[a.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",a[a.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",a[a.BAD_GATEWAY=502]="BAD_GATEWAY",a[a.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",a[a.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",a[a.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",a[a.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",a[a.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",a[a.LOOP_DETECTED=508]="LOOP_DETECTED",a[a.NOT_EXTENDED=510]="NOT_EXTENDED",a[a.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED",a))(it||{}),ot=(i=>(i[i.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",i[i.NO_CONTENT=204]="NO_CONTENT",i[i.RESET_CONTENT=205]="RESET_CONTENT",i[i.NOT_MODIFIED=304]="NOT_MODIFIED",i))(ot||{});function ki(e){return new XMLParser().parse(e)}var st=["SHA-1","SHA-256","SHA-384","SHA-512"];async function le(e,r,t,n){if(!st.includes(e))throw new Error(`Invalid hash algorithm: ${e}`);let i=new TextEncoder().encode((t??"")+r+(n??"")),o=await crypto.subtle.digest(e,i);return Array.from(new Uint8Array(o)).map(c=>c.toString(16).padStart(2,"0")).join("")}var $i={sha256:async(e,r,t)=>le("SHA-256",e,r,t),sha1:async(e,r,t)=>le("SHA-1",e,r,t)};async function Ri(e){let r=typeof e=="string"?e:JSON.stringify(e);return await le("SHA-1",r)}function _i(e){let r=new Uint8Array(e);return crypto.getRandomValues(r),Array.from(r,t=>String.fromCharCode(33+t%94)).join("")}var y=[];for(let e=0;e<256;++e)y.push((e+256).toString(16).slice(1));function K(e,r=0){return (y[e[r+0]]+y[e[r+1]]+y[e[r+2]]+y[e[r+3]]+"-"+y[e[r+4]]+y[e[r+5]]+"-"+y[e[r+6]]+y[e[r+7]]+"-"+y[e[r+8]]+y[e[r+9]]+"-"+y[e[r+10]]+y[e[r+11]]+y[e[r+12]]+y[e[r+13]]+y[e[r+14]]+y[e[r+15]]).toLowerCase()}var fe,ct=new Uint8Array(16);function C(){if(!fe){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fe=crypto.getRandomValues.bind(crypto);}return fe(ct)}var lt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ue={randomUUID:lt};function ft(e,r,t){if(ue.randomUUID&&!r&&!e)return ue.randomUUID();e=e||{};let n=e.random??e.rng?.()??C();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){if(t=t||0,t<0||t+16>r.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let i=0;i<16;++i)r[t+i]=n[i];return r}return K(n)}var de=ft;var pe={};function ut(e,r,t){let n;if(e)n=Xe(e.random??e.rng?.()??C(),e.msecs,e.seq,r,t);else {let i=Date.now(),o=C();dt(pe,i,o),n=Xe(o,pe.msecs,pe.seq,r,t);}return r??K(n)}function dt(e,r,t){return e.msecs??=-1/0,e.seq??=0,r>e.msecs?(e.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],e.msecs=r):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function Xe(e,r,t,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!n)n=new Uint8Array(16),i=0;else if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return r??=Date.now(),t??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=r/1099511627776&255,n[i++]=r/4294967296&255,n[i++]=r/16777216&255,n[i++]=r/65536&255,n[i++]=r/256&255,n[i++]=r&255,n[i++]=112|t>>>28&15,n[i++]=t>>>20&255,n[i++]=128|t>>>14&63,n[i++]=t>>>6&255,n[i++]=t<<2&255|e[10]&3,n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}var me=ut;function Vi(){return de()}function Yi(){return me()}var pt={log:console.log,warn:console.warn,error:console.error};async function Qi(e,r=["log","warn","error"]){let t={log:console.log,warn:console.warn,error:console.error};mt(r);let n=()=>{Object.entries(t).forEach(([i,o])=>{console[i]=o;});};try{let i=await e();return n(),i}catch(i){throw n(),i}}function mt(e=["log","warn"]){e.forEach(r=>{console[r]=()=>null;}),_?.setLevel("critical");}function Zi(){Object.entries(pt).forEach(([e,r])=>{console[e]=r;}),_?.resetLevel();}function Xi(){let e=process.memoryUsage();return {rss:e.rss/1024/1024,heapUsed:e.heapUsed/1024/1024,external:e.external/1024/1024,arrayBuffers:e.arrayBuffers/1024/1024}}function eo(e,r,t){let n=Math.min(r,t),i=Math.max(r,t);return Math.max(n,Math.min(e,i))}function ro(e){return e==null?0:typeof e=="number"?e:Number.parseInt(e,10)}var to={fileSize:(e,r=2)=>{if(e===0)return "0 Bytes";let t=1024,n=r<0?0:r,i=["Bytes","KB","MB","GB","TB"],o=Math.floor(Math.log(e)/Math.log(t));return Number.parseFloat((e/t**o).toFixed(n))+" "+i[o]}};var Ne={};_r(Ne,{ArraySchema:()=>fr,ObjectSchema:()=>ir,RecordSchema:()=>sr,RefType:()=>ke,Schema:()=>E,StringSchema:()=>Z,allOf:()=>mr,any:()=>Oe,anyOf:()=>dr,array:()=>Te,boolean:()=>Ae,booleanSchema:()=>be,error:()=>h,fromSchema:()=>k,integer:()=>Ee,literal:()=>nr,makeOpts:()=>j,number:()=>ve,object:()=>D,oneOf:()=>pr,partialObject:()=>ar,record:()=>cr,recursive:()=>yr,ref:()=>hr,refId:()=>gr,s:()=>mn,strictObject:()=>or,string:()=>S,valid:()=>l});var ge=(e=[],r="")=>"/"+[r,...e.map(t=>String(t).replace(/\./g,"/"))].filter(Boolean).join("/"),tr=e=>e.split("/").slice(1);function ht(e,r,t=void 0){let n=typeof r=="string"?tr(r):ge(r);return G(e,n,t)}function G(e,r,t=void 0){let n=typeof r=="string"?r.split(/[.\[\]\"]+/).filter(i=>i):r;if(n.length===0)return e;try{let[i,...o]=n;return !i||!(i in e)?t:G(e[i],o,t)}catch{if(typeof t<"u")return t;throw new Error(`Invalid path: ${n.join(".")}`)}}var h=(e={},r,t,n)=>({valid:false,errors:[...e.errors??[],{keywordLocation:ge([...e.keywordPath??[],r]),instanceLocation:ge(e.instancePath),error:typeof t=="string"?t:`Invalid value for ${r}`,data:n}]}),l=()=>({valid:true,errors:[]}),j=(e,r,t)=>{let n=Array.isArray(r)?r:[r],i=t?Array.isArray(t)?t:[t]:[];return {...e,keywordPath:[...e.keywordPath??[],...n],instancePath:i?[...e.instancePath??[],...i]:e.instancePath}},V=(e={})=>({...e,errors:[]}),P=class extends Error{constructor(e){super(`Expected ${e}`);}},gt=class extends Error{constructor(e,r){super(`${e??"Invalid raw schema"}: ${JSON.stringify(r)}`),this.schema=r;}},yt=class extends Error{constructor(e,r){super(`${e}, got: '${JSON.stringify(r)}'`),this.value=r;}};function xt(e){return e===null}function g(e){return !Array.isArray(e)&&typeof e=="object"&&e!==null}function wt(e){return Object.prototype.toString.call(e)==="[object Object]"}function T(e){return typeof e=="string"}function $(e){return typeof e=="number"}function bt(e){return typeof e=="number"&&Number.isInteger(e)}function we(e){return typeof e=="boolean"}function R(e){return Array.isArray(e)}function Ot(e){return typeof e!="boolean"}function vt(e){return e!==void 0&&Ot(e)&&"type"in e}function w(e){return e instanceof E}function Et(e){return w(e)&&typeof e.toJSON()=="boolean"}function Tt(e,r,t){if(!e)throw new yt(r,t)}function N(e){if(R(e))return e.map(N).sort();if(g(e)){let r=Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,N(n)]);return Object.fromEntries(r)}return T(e)?e.normalize("NFC"):e}function At(e,r){return r.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var Y=class{constructor(e){this.root=e,this.cache=new Map;}cache;hasRef(e,r){return r!==void 0&&"$ref"in e&&T(e.$ref)}resolve(e){let r=this.cache.get(e);if(!r){if(r=ht(this.root,e),!w(r))throw new Error(`ref not found: ${e}`);if("$ref"in r&&r.$ref===e)throw new Error(`ref loop: ${e}`);this.cache.set(e,r);}return r}};function kt(e,r,t={}){let n=r;try{n=structuredClone(r);}catch{n=JSON.parse(JSON.stringify(r));}let i={resolver:t.resolver||new Y(e),depth:t.depth||0,dropUnknown:t.dropUnknown||false};return i.resolver.hasRef(e,n)?i.resolver.resolve(e.$ref).coerce(n,{...i,depth:i.depth+1}):n}var Nt=({type:e},r,t={})=>{if(e===void 0||r===void 0)return l();let n,i={string:T,number:$,integer:bt,object:g,array:R,boolean:we,null:xt};if(Array.isArray(e)){for(let o of e){if(!(o in i))throw new P(`Unknown type: ${o}`);if(i[o](r))return l()}n=`Expected one of: ${e.join(", ")}`;}else {if(!(e in i))throw new P(`Unknown type: ${e}`);i[e](r)||(n=`Expected ${e}`);}return n?h(t,"type",n,r):l()},$t=({const:e},r,t={})=>{let n=JSON.stringify(N(e)),i=JSON.stringify(N(r));return n!==i?h(t,"const",`Expected const: ${n}`,i):l()},Rt=({enum:e=[]},r,t={})=>{let n=JSON.stringify(e.map(N)),i=JSON.stringify(N(r));return n.includes(i)?l():h(t,"enum",`Expected enum: ${n}`,r)};function W(e,r,t={}){return e.map(n=>n.validate(r,V(t)).valid?n:void 0).filter(Boolean)}var _t=({anyOf:e=[]},r,t={})=>W(e,r,t).length>0?l():h(t,"anyOf","Expected at least one to match",r),Pt=({oneOf:e=[]},r,t={})=>W(e,r).length===1?l():h(t,"oneOf","Expected exactly one to match",r),jt=({allOf:e=[]},r,t={})=>W(e,r,t).length===e.length?l():h(t,"allOf","Expected all to match",r),Ct=({not:e},r,t={})=>r===void 0?l():w(e)&&e.validate(r,t).valid?h(t,"not","Expected not to match",r):l(),It=({if:e,then:r,else:t},n,i={})=>{if(e&&(r||t)){if(e.validate(n,V(i)).valid)return r?r.validate(n,V(i)):l();if(t)return t.validate(n,V(i))}return l()},Ut=({pattern:e=""},r,t={})=>{if(!T(r))return l();if(e instanceof RegExp){if(e.test(r))return l()}else if(new RegExp(e,"u").test(r))return l();return h(t,"pattern",`Expected string matching pattern ${e}`,r)},Dt=({minLength:e=0},r,t={})=>T(r)?[...N(r)].length>=e?l():h(t,"minLength",`Expected string with minimum length of ${e}`,r):l(),St=({maxLength:e=0},r,t={})=>T(r)?[...N(r)].length<=e?l():h(t,"maxLength",`Expected string with maximum length of ${e}`,r):l(),Lt=({multipleOf:e=0},r,t={})=>{if(!$(r))return l();if(!(Number.isFinite(r)&&Number.isFinite(e))||e<=0)throw new P("number");let n=r/e,i=Number.EPSILON*Math.max(1,Math.abs(n));return Math.abs(n-Math.round(n))<=i?l():h(t,"multipleOf",`Expected number being a multiple of ${e}`,r)},Mt=({maximum:e=0},r,t={})=>!$(r)||r<=e?l():h(t,"maximum",`Expected number less than or equal to ${e}`,r),Bt=({exclusiveMaximum:e=0},r,t={})=>!$(r)||r<e?l():h(t,"exclusiveMaximum",`Expected number less than ${e}`,r),zt=({minimum:e=0},r,t={})=>!$(r)||r>=e?l():h(t,"minimum",`Expected number greater than or equal to ${e}`,r),Ft=({exclusiveMinimum:e=0},r,t={})=>!$(r)||r>e?l():h(t,"exclusiveMinimum",`Expected number greater than ${e}`,r),qt=({properties:e={}},r,t={})=>{if(!g(r))return l();for(let[n,i]of Object.entries(r)){let o=e[n];if(!w(o))continue;let s=o.validate(i,j(t,["properties",n],n));if(!s.valid)return s}return l()},Kt=({properties:e={},additionalProperties:r,patternProperties:t},n,i={})=>{if(!g(n))return l();if(!w(r))throw new P("additionalProperties must be a boolean or a managed schema");let o=Object.keys(e),s=g(t)?Object.keys(n).filter(f=>Object.keys(t).some(u=>new RegExp(u).test(f))):[],c=Object.keys(n).filter(f=>!o.includes(f)&&!s.includes(f));if(c.length>0){if(Et(r)){if(r.toJSON()===true)return l();let f=c.reduce((u,m)=>(u[m]=n[m],u),{});return h(i,"additionalProperties","Additional properties are not allowed",f)}else if(w(r))for(let f of c){let u=r.validate(n[f],j(i,["additionalProperties"],f));if(!u.valid)return u}}return l()},Jt=({dependentRequired:e},r,t={})=>{if(!g(r))return l();let n=Object.keys(r).filter(i=>typeof r[i]!="function");if(g(e)){for(let[i,o]of Object.entries(e))if(n.includes(i)){for(let s of o)if(!n.includes(s))return h(t,"dependentRequired",`Expected dependent required property ${s}`,r)}}return l()},Vt=({required:e=[]},r,t={})=>{if(!g(r))return l();let n=Object.keys(r).filter(i=>typeof r[i]!="function");return e.every(i=>n.includes(i))?l():h(t,"required",`Expected object with required properties ${e.join(", ")}`,r)},Yt=({dependentSchemas:e},r,t={})=>{if(!g(r))return l();let n=Object.keys(r).filter(i=>typeof r[i]!="function");if(g(e)){for(let[i,o]of Object.entries(e))if(n.includes(i)){let s=o.validate(r,t);if(!s.valid)return s}}return l()},Gt=({minProperties:e=0},r,t={})=>g(r)?Object.keys(r).length>=e?l():h(t,"minProperties",`Expected object with at least ${e} properties`,r):l(),Wt=({maxProperties:e=0},r,t={})=>!g(r)||Object.keys(r).length<=e?l():h(t,"maxProperties",`Expected object with at most ${e} properties`,r),Qt=({patternProperties:e={}},r,t={})=>{if(!g(r))return l();if(!g(e))throw new P("patternProperties must be an object");for(let[n,i]of Object.entries(r))for(let[o,s]of Object.entries(e))if(new RegExp(o,"u").test(n)){let c=s.validate(i,j(t,["patternProperties"],n));if(!c.valid)return c}return l()},Zt=({propertyNames:e},r,t={})=>{if(!g(r)||e===void 0)return l();if(!w(e))throw new P("propertyNames must be a managed schema");for(let n of Object.keys(r)){let i=e.validate(n,j(t,["propertyNames"],n));if(!i.valid)return i}return l()},Xt=({items:e,prefixItems:r=[]},t,n={})=>{if(!R(t)||e===void 0)return l();if(!w(e))throw new P("items must be a managed schema");for(let[i,o]of t.slice(r.length).entries()){let s=e.validate(o,j(n,["items"],String(i)));if(!s.valid)return s}return l()},Ht=({minItems:e=0},r,t={})=>!R(r)||r.length>=e?l():h(t,"minItems",`Expected array with at least ${e} items`,r),en=({maxItems:e=0},r,t={})=>!R(r)||r.length<=e?l():h(t,"maxItems",`Expected array with at most ${e} items`,r),rn=({uniqueItems:e=false},r,t={})=>{if(!R(r)||!e)return l();let n=r.map(N);return new Set(n.map(i=>JSON.stringify(i))).size===r.length?l():h(t,"uniqueItems","Expected array with unique items",r)},tn=({contains:e,minContains:r,maxContains:t},n,i={})=>{if(!w(e))throw new Error("contains must be a managed schema");if(!R(n))return l();let o=n.filter(s=>e.validate(s).valid).length;return o<(r??1)?h(i,r?"minContains":"contains",`Expected array to contain at least ${r??1}, but found ${o}`,n):t!==void 0&&o>t?h(i,"maxContains",`Expected array to contain at most ${t}, but found ${o}`,n):l()},nn=({prefixItems:e=[]},r,t={})=>{if(!R(r))return l();for(let n=0;n<r.length;n++){let i=e[n]?.validate(r[n],j(t,String(n),String(n)));if(i&&i?.valid!==true)return i}return l()},He={email:e=>{if(e.length>318)return false;if(/^[a-z0-9!#$%&'*+/=?^_`{|}~-]{1,20}(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]{1,21}){0,2}@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,60}[a-z0-9])?){0,3}$/i.test(e))return true;if(!e.includes("@")||/(^\.|^"|\.@|\.\.)/.test(e))return false;let[r,t,...n]=e.split("@");return !r||!t||n.length!==0||r.length>64||t.length>253||!/^[a-z0-9.-]+$/i.test(t)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(r)?false:t.split(".").every(i=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(i))},hostname:e=>e.length>(e.endsWith(".")?254:253)?false:/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\.?$/i.test(e),date:e=>{if(e.length!==10)return false;if(e[5]==="0"&&e[6]==="2"){if(/^\d\d\d\d-02-(?:[012][1-8]|[12]0|[01]9)$/.test(e))return true;let r=e.match(/^(\d\d\d\d)-02-29$/);if(!r)return false;let t=Number(r[1]);return t%16===0||t%4===0&&t%25!==0}return e.endsWith("31")?/^\d\d\d\d-(?:0[13578]|1[02])-31$/.test(e):/^\d\d\d\d-(?:0[13-9]|1[012])-(?:[012][1-9]|[123]0)$/.test(e)},time:e=>{if(e.length>27||!/^(?:2[0-3]|[0-1]\d):[0-5]\d:(?:[0-5]\d|60)(?:\.\d+)?(?:z|[+-](?:2[0-3]|[0-1]\d)(?::?[0-5]\d)?)?$/i.test(e))return false;if(!/:60/.test(e))return true;let r=e.match(/([0-9.]+|[^0-9.])/g);if(!r)return false;let t=Number(r[0])*60+Number(r[2]);return r[5]==="+"?t+=24*60-Number(r[6]||0)*60-Number(r[8]||0):r[5]==="-"&&(t+=Number(r[6]||0)*60+Number(r[8]||0)),t%(24*60)===23*60+59},"date-time":e=>{if(e.length>38)return false;let r=/^\d\d\d\d-(?:0[1-9]|1[0-2])-(?:[0-2]\d|3[01])[t\s](?:2[0-3]|[0-1]\d):[0-5]\d:(?:[0-5]\d|60)(?:\.\d+)?(?:z|[+-](?:2[0-3]|[0-1]\d)(?::?[0-5]\d)?)$/i,t=e[5]==="0"&&e[6]==="2";if(t&&e[8]==="3"||!r.test(e))return false;if(e[17]==="6"){let n=e.slice(11).match(/([0-9.]+|[^0-9.])/g);if(!n)return false;let i=Number(n[0])*60+Number(n[2]);if(n[5]==="+"?i+=24*60-Number(n[6]||0)*60-Number(n[8]||0):n[5]==="-"&&(i+=Number(n[6]||0)*60+Number(n[8]||0)),i%(24*60)!==23*60+59)return false}if(t){if(/^\d\d\d\d-02-(?:[012][1-8]|[12]0|[01]9)/.test(e))return true;let n=e.match(/^(\d\d\d\d)-02-29/);if(!n)return false;let i=Number(n[1]??0);return i%16===0||i%4===0&&i%25!==0}return e[8]==="3"&&e[9]==="1"?/^\d\d\d\d-(?:0[13578]|1[02])-31/.test(e):/^\d\d\d\d-(?:0[13-9]|1[012])-(?:[012][1-9]|[123]0)/.test(e)},ipv4:e=>e.length<=15&&/^(?:(?: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\d?)$/.test(e),ipv6:e=>{if(e.length>45||e.length<2)return false;let r=0,t=0,n=0,i=false,o=false,s=0,c=true;for(let u=0;u<e.length;u++){let m=e.charCodeAt(u);if(u===1&&s===58&&m!==58)return false;if(m>=48&&m<=57){if(++n>4)return false}else if(m===46){if(r>6||t>=3||n===0||o)return false;t++,n=0;}else if(m===58){if(t>0||r>=7)return false;if(s===58){if(i)return false;i=true;}else u===0&&(c=false);r++,n=0,o=false;}else if(m>=97&&m<=102||m>=65&&m<=70){if(t>0||++n>4)return false;o=true;}else return false;s=m;}if(r<2||t>0&&(t!==3||n===0))return false;if(i&&e.length===2)return true;if(t>0&&!/(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/.test(e))return false;let f=t>0?6:7;return i?(c||n>0)&&r<f:r===f&&c&&n>0},uri:e=>/^[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|1\d\d|[1-9]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\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})?::)|v[0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\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})*)?$/i.test(e),"uri-reference":e=>/^(?:[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|1\d\d|[1-9]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\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})?::)|v[0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\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})*)?$/i.test(e),"uri-template":e=>/^(?:[^\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.test(e),"json-pointer":e=>/^(?:|\/(?:[^~]|~0|~1)*)$/.test(e),"relative-json-pointer":e=>/^(?:0|[1-9][0-9]*)(?:|#|\/(?:[^~]|~0|~1)*)$/.test(e),uuid:e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),duration:e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),regex:e=>{if(/[^\\]\\Z/.test(e))return false;try{return new RegExp(e,"u"),!0}catch{return false}}},on=({format:e},r,t={})=>!T(r)||!e?l():He[e]?He[e](r)?l():h(t,"format",`Expected format: ${e}`,r):l(),an={type:Nt,const:$t,enum:Rt,allOf:jt,anyOf:_t,oneOf:Pt,not:Ct,minLength:Dt,maxLength:St,pattern:Ut,format:on,minimum:zt,exclusiveMinimum:Ft,maximum:Mt,exclusiveMaximum:Bt,multipleOf:Lt,required:Vt,dependentRequired:Jt,dependentSchemas:Yt,minProperties:Gt,maxProperties:Wt,propertyNames:Zt,properties:qt,patternProperties:Qt,additionalProperties:Kt,minItems:Ht,maxItems:en,uniqueItems:rn,contains:tn,prefixItems:nn,items:Xt,if:It};function sn(e,r,t={}){let n={keywordPath:t.keywordPath||[],instancePath:t.instancePath||[],coerce:t.coerce||false,errors:t.errors||[],shortCircuit:t.shortCircuit||false,ignoreUnsupported:t.ignoreUnsupported||false,resolver:t.resolver||new Y(e),depth:t.depth?t.depth+1:0},i=structuredClone(t?.coerce&&e.coerce?e.coerce(r,{resolver:n.resolver,depth:n.depth}):r);if(t.ignoreUnsupported!==true){let o=["$defs"];for(let s of o)if(e[s])throw new Error(`${s} not implemented`)}if(n.resolver.hasRef(e,i)){let o=n.resolver.resolve(e.$ref).validate(i,{...n,errors:[]});o.valid||n.errors.push(...o.errors);}else for(let[o,s]of Object.entries(an)){if(e[o]===void 0||i===void 0)continue;let c=s(e,i,{...n,errors:[]});if(!c.valid){if(t.shortCircuit)return c;n.errors.push(...c.errors);}}return {valid:n.errors.length===0,errors:n.errors}}var x=Symbol.for("schema"),E=class{"~standard";[x];type;$id;$ref;$schema;title;description;readOnly;writeOnly;$comment;examples;constructor(e,r){let{type:t,validate:n,coerce:i,template:o,...s}=e||{};Object.assign(this,{type:t},s),this[x]={raw:e,optional:false,overrides:r},this["~standard"]={version:1,vendor:"jsonv-ts",validate:c=>{let f=this.validate(c);return f.valid?{value:c}:{issues:f.errors.map(u=>({message:u.error,path:tr(u.instanceLocation)}))}}};}template(e,r){let t=this,n=e;if(t.const!==void 0?n=t.const:n===void 0&&(t.default!==void 0&&(n=t.default),r?.withExtendedOptional&&t.enum!==void 0&&(n=t.enum[0])),r?.withOptional!==true&&n===void 0&&this.isOptional())return n;if(this[x].raw?.template){let o=this[x].raw.template(n,r);o!==void 0&&(n=o);}let i=this[x].overrides?.template?.(n,r);return i!==void 0&&(n=i),n}validate(e,r){let t={keywordPath:r?.keywordPath||[],instancePath:r?.instancePath||[],coerce:r?.coerce||false,errors:r?.errors||[],shortCircuit:r?.shortCircuit||false,ignoreUnsupported:r?.ignoreUnsupported||false,resolver:r?.resolver||new Y(this),depth:r?.depth?r.depth+1:0},n=this[x].raw?.validate;if(n!==void 0){let i=n(e,t);if(!i.valid)return i}return sn(this,e,t)}coerce(e,r){let t={...r,resolver:r?.resolver||new Y(this),depth:r?.depth?r.depth+1:0,dropUnknown:r?.dropUnknown||false},n=this[x].raw?.coerce;if(n!==void 0)return n(e,t);let i=this[x].overrides?.coerce?.(e,t)??e;return kt(this,i,t)}optional(){return this[x].optional=true,this}isOptional(){return this[x].optional}children(e){return []}*walk({instancePath:e=[],keywordPath:r=[],...t}={}){t.includeSelf!==false&&(yield new U(this,{instancePath:e,keywordPath:r,...t}));for(let n of this.children(t))yield*n.schema.walk({...t,instancePath:[...e,...n.instancePath],keywordPath:[...r,...n.keywordPath]});}*[Symbol.iterator](e){for(let r of this.walk(e))yield r;}toJSON(){let{toJSON:e,"~standard":r,...t}=this;return JSON.parse(JSON.stringify(t))}},U=class{constructor(e,r={}){this.schema=e,this.instancePath=r.instancePath||[],this.keywordPath=r.keywordPath||[];try{let t=G(r.data,this.instancePath);e.validate(t).valid&&(this.data=t);}catch{}}instancePath;keywordPath;data;appendInstancePath(e){return this.instancePath=[...this.instancePath,...e],this}appendKeywordPath(e){return this.keywordPath=[...this.keywordPath,...e],this}setData(e){return this.data=structuredClone(e),this}};function Q(e,r,t){return new class extends E{type=e}(r,t)}function be(e){return new class extends E{toJSON(){return e}validate(r,t){return e?l():h(t,"","Always fails",r)}}}var Oe=e=>Q(e?.type,e),nr=(e,r)=>Q(void 0,{...r,const:e}),ir=class ye extends E{type="object";properties;required;constructor(r,t){let n=[];for(let[o,s]of Object.entries(r||{}))Tt(w(s),"properties must be managed schemas",s),s[x].optional||n.push(o);let i=t?.additionalProperties===false?be(false):t?.additionalProperties;n=n.length>0?n:void 0,super({...t,additionalProperties:i,properties:r,required:n},{template:(o,s)=>{let c=structuredClone(g(o)?o:{}),f={...c};if(this.properties)for(let[u,m]of Object.entries(this.properties)){let b=G(c,u);if(m.isOptional()&&s?.withOptional!==true&&b===void 0&&o===void 0)continue;let v=m.template(b,s);v!==void 0&&(f[u]=v);}if(!(Object.keys(f).length===0&&!s?.withExtendedOptional))return f},coerce:(o,s)=>{let c=structuredClone(o),f=Object.keys(this.properties),u=f.length>0&&Object.values(this.properties).every(m=>!m[x].optional);if(wt(c)&&(s?.dropUnknown===true||u)&&(c=At(c,f)),typeof c=="string"&&c.match(/^\{/)&&(c=JSON.parse(c)),!(typeof c!="object"||c===null)){if(this.properties)for(let[m,b]of Object.entries(this.properties)){let v=c[m];v!==void 0&&(c[m]=b.coerce(v,s));}return c}}}),this.properties=r,this.required=n;}strict(){return new ye(this.properties,{...this[x].raw,additionalProperties:false})}partial(){let r={...this.properties};for(let[,t]of Object.entries(r))t[x].optional=true;return new ye(r,this[x].raw)}children(r){let t=[];for(let[n,i]of Object.entries(this.properties)){let o=new U(i,r);o.appendInstancePath([n]),o.appendKeywordPath(["properties",n]),t.push(o);}return t}},D=(e,r)=>new ir(e,r),or=(e,r)=>D(e,r).strict(),ar=(e,r)=>D(e,r).partial(),sr=class extends E{type="object";additionalProperties;constructor(e,r){super({...r,additionalProperties:e},{template:(t,n)=>n?.withExtendedOptional&&(t===void 0||!g(t))?{}:t}),this.additionalProperties=e;}children(e){let r=[],t=new U(this.additionalProperties,e);return t.appendKeywordPath(["additionalProperties"]),r.push(t),r}},cr=(e,r)=>new sr(e,r),Z=class extends E{type="string";constructor(e){super(e,{template:(r,t)=>t?.withExtendedOptional&&(r===void 0||!T(r))?"":r,coerce:r=>$(r)?String(r):r});}toJSON(){let{pattern:e,"~standard":r,...t}=this;return JSON.parse(JSON.stringify({...t,pattern:e instanceof RegExp?e.source:e}))}},S=e=>new Z(e),lr=(e,r,t)=>Q(e,t,{template:(n,i)=>i?.withExtendedOptional&&(n===void 0||!$(n))?t?.minimum??0:n,coerce:n=>{if(T(n)){let i=r.parseFn(n);if(!Number.isNaN(i))return i}return n}}),ve=e=>lr("number",{parseFn:Number},e),Ee=e=>lr("integer",{parseFn:Number.parseInt},e),fr=class extends E{constructor(e,r={}){super({...r,items:e},{template:t=>t===void 0||!Array.isArray(t)?[]:t,coerce:(t,n)=>{try{let i=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(i))return;if(w(this.items))for(let[o,s]of i.entries())i[o]=this.items.coerce(s,n);return i}catch{}return t}}),this.items=e,this.items=e;}type="array";children(e){let r=[];if(this.items){let t=new U(this.items,e);t.appendKeywordPath(["items"]),r.push(t);}return r}},Te=(e,r)=>new fr(e,r),Ae=e=>Q("boolean",e,{template:(r,t)=>t?.withExtendedOptional&&(r===void 0||!we(r))?false:r,coerce:r=>{if(T(r)&&["true","false","1","0"].includes(r))return r==="true"||r==="1";if($(r)){if(r===1)return true;if(r===0)return false}return r}}),J=Symbol.for("unionType"),ur=class extends E{[J];constructor(e,r,t){super({...t,[r]:e},{coerce:(n,i)=>{let o=t?.coerce;if(o!==void 0)return o.bind(this)(n,i);let s=W(e,n,{ignoreUnsupported:true,resolver:i?.resolver,coerce:true});return s.length>0?s[0].coerce(n,i):n}}),this[J]=r;}get schemas(){return this[this[J]]}children(e){let r=[];for(let[t,n]of this.schemas.entries()){let i=new U(n,e);i.appendKeywordPath([this[J],t]),r.push(i);}return r}},dr=(e,r)=>new ur(e,"anyOf",r),pr=(e,r)=>new ur(e,"oneOf",r);function er(e,r){return Array.isArray(e)?e.map(r):e!==void 0?[r(e)]:[]}function rr(e,r,t=n=>n){return Object.fromEntries(Object.entries(e).map(([n,i])=>[n,t(r(i),n)]))}function k(e){if(we(e))return be(e);let r=structuredClone(e);if(!g(r))throw new gt("non-object schemas not implemented",r);"properties"in r&&r.properties&&(r.properties=rr(r.properties,k,(o,s)=>"required"in r&&Array.isArray(r.required)&&r.required.includes(s)?o:o.optional()));let t=["patternProperties","dependentSchemas","$defs"];for(let o of t)o in r&&r[o]&&(r[o]=rr(r[o],k));let n=["additionalProperties","items","prefixItems","propertyNames","contains","not","if","then","else"];for(let o of n)o in r&&typeof r[o]<"u"&&(R(r[o])?r[o]=er(r[o],k):r[o]=k(r[o]));let i=["anyOf","oneOf","allOf"];for(let o of i)if(o in r){let{[o]:s}=r;r[o]=er(s,k);}if(vt(r))switch(r.type){case "string":return S(r);case "number":return ve(r);case "integer":return Ee(r);case "boolean":return Ae(r);case "object":{let{properties:o,...s}=r;return D(o,s)}case "array":{let{items:o,...s}=r;return Te(o,s)}}return Oe(r)}var xe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),he=e=>typeof globalThis.structuredClone=="function"?globalThis.structuredClone(e):JSON.parse(JSON.stringify(e)),cn=["maximum","exclusiveMaximum","maxLength","maxItems","maxProperties"],ln=["minimum","exclusiveMinimum","minLength","minItems","minProperties"];function fn(){return {type(e){let r=e.map(t=>Array.isArray(t)?new Set(t):new Set([t])).reduce((t,n)=>t?new Set([...t].filter(i=>n.has(i))):new Set(n));if(!r.size)throw new Error('Incompatible "type" in allOf');return r.size===1?[...r][0]:[...r]},enum(e){let r=e.map(t=>new Set(t)).reduce((t,n)=>new Set([...t].filter(i=>n.has(i))));if(!r.size)throw new Error('Incompatible "enum" in allOf');return [...r]},required(e){return [...new Set(e.flat())]},properties(e,r,t){return e.reduce((n,i)=>t(n,i),{})},patternProperties(e,r,t){return e.reduce((n,i)=>t(n,i),{})},$defs(e,r,t){return e.reduce((n,i)=>t(n,i),{})},definitions(e,r,t){return e.reduce((n,i)=>t(n,i),{})},...Object.fromEntries(cn.map(e=>[e,r=>Math.min(...r)])),...Object.fromEntries(ln.map(e=>[e,r=>Math.max(...r)]))}}function un(e){let r={...fn(),...e.resolvers};function t(n,i){if(Array.isArray(n)&&Array.isArray(i))return [...new Set([...n,...i])];if(xe(n)&&xe(i)){let o={...n};for(let[s,c]of Object.entries(i))if(s in o){let f=r[s];o[s]=f?f([o[s],c],s,t):he(c);}else o[s]=he(c);return o}return he(i)}return t}var dn=e=>e===true||e===false?e:null;function pn(e,r={}){let t=r.deep!==false,n=un(r);function i(o){if(Array.isArray(o))return o.map(i);if(!xe(o))return o;if(Array.isArray(o.allOf)){let c=o.allOf.map(i);if(c.some(A=>A===false))return false;let f=c.filter(A=>A!==true);if(!f.length)return true;let u=f.reduce((A,Er)=>n(A,Er),{}),m=dn(u);if(m!==null)return m;let b={...o};delete b.allOf;let v=n(u,t?i(b):b);return t?i(v):v}let s={};for(let[c,f]of Object.entries(o))s[c]=i(f);return s}return i(e)}var mr=(e,r)=>{let t=JSON.parse(JSON.stringify({...r,allOf:e}));return k(pn(t))},ke=class extends E{$ref;constructor(e,r){if(!r&&!w(e))throw new Error("Ref not set");if(w(e)&&!e.$id)throw new Error("Ref must have an $id");let t=r??e?.$id;super({$ref:t},{coerce:(n,i)=>{let o=i?.resolver?.resolve(this.$ref);if(!w(o))throw new Error(`Ref not found: ${this.$ref}`);return o.coerce(n,i)}}),this.$ref=t;}},hr=(e,r)=>new ke(e,r),gr=e=>new ke(void 0,e),yr=e=>e(new E({$ref:"#",coerce:(r,t)=>{let n=t?.resolver?.resolve("#");if(!w(n))throw new Error("Ref not found: #");return n.coerce(r,t)}})),mn={boolean:Ae,any:Oe,literal:nr,object:D,strictObject:or,partialObject:ar,record:cr,string:S,number:ve,integer:Ee,array:Te,anyOf:dr,oneOf:pr,allOf:mr,ref:hr,refId:gr,recursive:yr};var X=Symbol.for("jsonv"),wr=(e,r,t,n)=>{let i=validator(e,async(o,s)=>{let c=t?.coerce!==false?r.coerce(o,{dropUnknown:t?.dropUnknown}):o,f=r.validate(c);if(!f.valid)return s.json({...f,schema:r},400);if(n){let u=n({result:f,data:c},s);if(u)return u}return c});return t?.skipOpenAPI?i:Object.assign(i,{[X]:{type:"parameters",value:{target:e,schema:r}}})};function gn(e){return Object.prototype.toString.call(e)==="[object Object]"}function yn(e){return e!==null&&typeof e=="object"}function Re(e,...r){for(let t of r)for(let[n,i]of Object.entries(t))i!==void 0&&(!gn(i)&&!Array.isArray(i)||Array.isArray(i)&&!Array.isArray(e[n])?e[n]=i:yn(e[n])?Re(e[n],i):e[n]=i);return e}var xn={query:"query",param:"path",header:"header",cookie:"cookie"},wn={json:{type:"application/json"},form:{type:"multipart/form-data"}};function _e(e,r){let t=xn[r],n=wn[r];return t?{parameters:Object.entries(e.properties).map(([i,o])=>({name:i,in:t,required:e.required?.includes(i)||void 0,description:o?.description||void 0,schema:structuredClone(o.toJSON())}))}:n?{requestBody:{content:{[n.type]:{schema:structuredClone(e.toJSON()),example:e.examples?.[0]??e.template({},{withOptional:true,withExtendedOptional:true})}}}}:{}}var bn=e=>e.split("/").map(r=>{let t=r;if(t.startsWith(":")){let n=t.match(/^:([^{?]+)(?:{(.+)})?(\?)?$/);n?t=`{${n[1]}}`:(t=t.slice(1,t.length),t.endsWith("?")&&(t=t.slice(0,-1)),t=`{${t}}`);}return t}).join("/"),xr=e=>e.charAt(0).toUpperCase()+e.slice(1),$e=new Map,On=(e,r)=>{let t=`${e}:${r}`;if($e.has(t))return $e.get(t);let n=e;if(r==="/")return `${n}Index`;for(let i of r.split("/"))i.charCodeAt(0)===123?n+=`By${xr(i.slice(1,-1))}`:n+=xr(i);return $e.set(t,n),n},br=(e,r={})=>{let t=false;return async n=>{if(!t){t=true,r.paths=r.paths??{};for(let i of e.routes)if(X in i.handler){let o=i.method.toLowerCase(),s=bn(i.path),{type:c,value:f}=i.handler[X];r.paths[s]||(r.paths[s]={}),r.paths[s][o]||(r.paths[s][o]={responses:{},operationId:On(o,s)});let u=r.paths[s][o];switch(c){case "parameters":let{parameters:m,requestBody:b}=_e(f.schema,f.target);m&&(u.parameters||(u.parameters=[]),u.parameters.push(...m.filter(v=>{try{return !u.parameters.some(A=>A.name===v.name&&A.in===v.in)}catch{return true}}))),b&&(u.requestBody||(u.requestBody={}),Re(u.requestBody,b));break;case "route-doc":Re(r.paths[s][o],f);break}}}return n.json({openapi:"3.1.0",info:{title:"API",...r.info},...r})}},Or=e=>Object.assign(async(r,t)=>{await t();},{[X]:{type:"route-doc",value:e}});var L=class extends Z{},vr=e=>new L(e);var vn=e=>e,En=e=>e,Tn=S({pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$",minLength:2,maxLength:150}),H=class extends Error{constructor(t,n,i=[]){super(`Invalid schema given for ${JSON.stringify(n,null,2)}
Error: ${JSON.stringify(i[0],null,2)}`);this.schema=t;this.value=n;this.errors=i;}first(){return this.errors[0]}firstToString(){let t=this.first();return `${t.error} at ${t.instanceLocation}`}},An=e=>{let r=e.toJSON();return k(r)};function kn(e,r,t){let n=t?.clone?An(e):e,i=t?.coerce!==false?n.coerce(r,{dropUnknown:t?.coerceDropUnknown??false}):r;t?.withDefaults!==false&&(i=n.template(i,{withOptional:true,withExtendedOptional:t?.withExtendedDefaults??false}));let o=e.validate(i,{shortCircuit:true,ignoreUnsupported:true});if(!o.valid)if(t?.onError)t.onError(o.errors);else throw new H(n,r,o.errors);return i}export{_ as $console,st as HashAlgorithms,it as HttpStatus,ot as HttpStatusEmpty,H as InvalidSchemaError,Ve as Perf,L as SecretSchema,Zn as _jsonp,qn as autoFormatString,Ze as blobToFile,Ri as checksum,eo as clampNumber,Ln as colorizeConsole,je as datetimeStringLocal,_n as datetimeStringUTC,Ei as decodeSearch,Yr as deepFreeze,Or as describeRoute,Lr as detectCase,yi as detectImageDimensions,le as digest,mt as disableConsoleLog,Zi as enableConsoleLog,vi as encodeSearch,ro as ensureInt,Br as filterKeys,Fe as flattenObject,Xi as formatMemoryUsage,to as formatNumber,gi as getBodyFromContext,Bn as getBrowser,Qr as getContentName,tt as getFileFromContext,Fr as getFullPathKeys,Vr as getPath,Wr as getRuntimeKey,jn as getTimezone,Pn as getTimezoneOffset,$i as hash,nt as headersToObject,Mr as identifierToHumanReadable,ce as invariant,Xr as isArrayBuffer,Hr as isArrayBufferView,F as isBlob,fi as isBun,oe as isEqual,q as isFile,li as isNode,I as isObject,Je as isPlainObject,Zr as isReadableStream,wr as jsc,te as kebabToPascalWithSpaces,ei as keepChanged,En as mark,ze as mergeDeep,Kr as mergeObject,Jr as mergeObjectWith,qe as objectCleanEmpty,qr as objectDepth,ti as objectEach,Be as objectKeysPascalToKebab,Ke as objectToJsLiteral,Fn as objectToKeyValueArray,ri as objectTransform,Xn as omitKeys,br as openAPISpecs,kn as parse,z as pascalToKebab,Vn as patternMatch,ni as pick,wi as pickHeaders,bi as pickHeaders2,Me as randomString,Jn as replaceSimplePlaceholders,Oi as replaceUrlParam,ci as runtimeSupports,Ne as s,Hn as safelyParseObjectValues,_e as schemaToSpec,vr as secret,_i as secureRandomString,Yn as slugify,ie as snakeToPascalWithSpaces,Tn as stringIdentifier,vn as stripMark,zr as transformObject,Gn as truncate,ne as ucFirst,Sr as ucFirstAll,Kn as ucFirstAllSnakeToPascalWithSpaces,Vi as uuid,Yi as uuidv7,Qi as withDisabledConsole,ki as xmlToObject};