authhero 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/authhero.cjs +1 -0
- package/dist/authhero.iife.js +1 -0
- package/package.json +10 -6
- package/vite.config.ts +36 -6
- package/dist/bun.d.ts +0 -8
- package/dist/bun.d.ts.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/routes/oauth2/index.d.ts +0 -2
- package/dist/routes/oauth2/index.d.ts.map +0 -1
- package/dist/routes/oauth2/well-known.d.ts +0 -55
- package/dist/routes/oauth2/well-known.d.ts.map +0 -1
- package/dist/types/Bindings.d.ts +0 -6
- package/dist/types/Bindings.d.ts.map +0 -1
- package/dist/types/JWKS.d.ts +0 -131
- package/dist/types/JWKS.d.ts.map +0 -1
- package/dist/types/Variables.d.ts +0 -2
- package/dist/types/Variables.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- /package/dist/{authhero.js → authhero.mjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var xr=Object.defineProperty;var Lt=r=>{throw TypeError(r)};var kr=(r,e,t)=>e in r?xr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var p=(r,e,t)=>kr(r,typeof e!="symbol"?e+"":e,t),Vt=(r,e,t)=>e.has(r)||Lt("Cannot "+t);var f=(r,e,t)=>(Vt(r,e,"read from private field"),t?t.call(r):e.get(r)),D=(r,e,t)=>e.has(r)?Lt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,n)=>(Vt(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ae(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function x(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function Or(r){return"_def"in r}function Ie(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function Tr(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,a){var i,o,c,u,d,h;const T=typeof s=="string"?a:s,S=T??{},{param:E}=S,b=Ae(S,["param"]),A=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),M=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),b),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||E?{param:Object.assign(Object.assign({},(h=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||h===void 0?void 0:h.param),E)}:void 0),K=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(M).length>0?{metadata:M}:void 0)}));if(x(this,"ZodObject")){const U=this.extend;K.extend=function(...ve){var se,z,Y,ye,le,Ot;const Tt=U.apply(this,ve);return Tt._def.openapi={_internal:{extendedFrom:!((z=(se=this._def.openapi)===null||se===void 0?void 0:se._internal)===null||z===void 0)&&z.refId?{refId:(ye=(Y=this._def.openapi)===null||Y===void 0?void 0:Y._internal)===null||ye===void 0?void 0:ye.refId,schema:this}:(le=this._def.openapi)===null||le===void 0?void 0:le._internal.extendedFrom},metadata:(Ot=Tt._def.openapi)===null||Ot===void 0?void 0:Ot.metadata},Tt}}return K},Ie(r,"optional"),Ie(r,"nullable"),Ie(r,"default"),Ie(r,"transform"),Ie(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,c])=>{var u,d;c._def.openapi=(d=(u=s[o])===null||u===void 0?void 0:u._def)===null||d===void 0?void 0:d.openapi}),a._def.openapi=void 0,a};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const a=n.apply(this,s);return a._def.openapi=void 0,a}}function lt(r,e){if(r==null||e===null||e===void 0)return r===e;if(r===e||r.valueOf()===e.valueOf())return!0;if(Array.isArray(r)&&(!Array.isArray(e)||r.length!==e.length)||!(r instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(r);return Object.keys(e).every(n=>t.indexOf(n)!==-1)&&t.every(n=>lt(r[n],e[n]))}class jr{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n){this.buckets.set(t,[e]);return}n.some(a=>lt(a,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>lt(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const a of this.buckets.values())e+=1,t+=a.length,a.length>1&&(n+=1);const s=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:s}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)t^=this.hashCodeOf(e[n])*n;return t}if(typeof e=="string"){for(let n=0;n<e.length;n++)t^=e.charCodeAt(n)*n;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[n,s]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(s??"");return t}}function $e(r){return r==null}function Le(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function Rr(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(a=>a===n)||(t[n]=s)}),t}function ke(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function Ut(r){return r.filter(e=>!$e(e))}const Ct=lt;function Er(r){const e=new jr;return r.forEach(t=>e.put(t)),[...e.values()]}function Xt(r){return typeof r=="string"}class Sr{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,s,a;const i=this.schemaWithRefId(e,t),o=(n=i._def.openapi)===null||n===void 0?void 0:n.metadata,c=i.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(a=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&a!==void 0?a:e})}));return this._definitions.push({type:"parameter",schema:c}),c}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:"component",componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class xt{constructor(e){this.message=e}}class Pe extends xt{constructor(e,t){super(e),this.data=t}}class ht extends xt{constructor(e){super(`Missing parameter data, please specify \`${e.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`ZodSchema.openapi\``),this.data=e}}function Ze(r,e){try{return r()}catch(t){throw t instanceof ht?new ht(Object.assign(Object.assign({},t.data),e)):t}}class Cr extends xt{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class C{static getMetadata(e){var t;const n=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:n._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:a},s==null?void 0:s.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),n=e._def.openapi?e._def.openapi:t._def.openapi;return n==null?void 0:n._internal}static getParamMetadata(e){var t,n;const s=this.unwrapChained(e),a=e._def.openapi?e._def.openapi:s._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:a==null?void 0:a._internal,metadata:Object.assign(Object.assign({},a==null?void 0:a.metadata),{param:Object.assign({description:i},(n=a==null?void 0:a.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return ke(Rr(e,["param"]),$e)}static buildParameterMetadata(e){return ke(e,$e)}static applySchemaMetadata(e,t){return ke(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),$e)}static getRefId(e){var t;return(t=this.getInternalMetadata(e))===null||t===void 0?void 0:t.refId}static unwrapChained(e){return this.unwrapUntil(e)}static getDefaultValue(e){const t=this.unwrapUntil(e,"ZodDefault");return t==null?void 0:t._def.defaultValue()}static unwrapUntil(e,t){return t&&x(e,t)?e:x(e,"ZodOptional")||x(e,"ZodNullable")||x(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):x(e,"ZodDefault")||x(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):x(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):x(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return x(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class Ir{transform(e,t,n){var s,a;const i=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(i),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(a=e._def.maxLength)===null||a===void 0?void 0:a.value})}}class Pr{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class Zr{transform(e,t,n,s,a){const i=[...e.options.values()],o=i.map(s);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(i,e.discriminator,a)}}mapDiscriminator(e,t,n){if(e.some(a=>C.getRefId(a)===void 0))return;const s={};return e.forEach(a=>{var i;const o=C.getRefId(a),c=(i=a.shape)===null||i===void 0?void 0:i[t];if(x(c,"ZodEnum")||x(c,"ZodNativeEnum")){Object.values(c.enum).filter(Xt).forEach(h=>{s[h]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=n(o)}),{propertyName:t,mapping:s}}}class Ar{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class Nr{transform(e,t,n,s){const i={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([i],t)}:i}flattenIntersectionTypes(e){if(!x(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class Dr{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function Mr(r){const t=Object.keys(r).filter(a=>typeof r[r[a]]!="number").map(a=>r[a]),n=t.filter(a=>typeof a=="number").length,s=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:s}}class $r{transform(e,t){const{type:n,values:s}=Mr(e._def.values);if(n==="mixed")throw new xt("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:s})}}class Lr{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class Vr{transform(e,t,n,s){var a;const i=(a=C.getInternalMetadata(e))===null||a===void 0?void 0:a.extendedFrom,o=this.requiredKeysOf(e),c=Le(e._def.shape(),s);if(!i)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=i.schema;s(u);const d=this.requiredKeysOf(u),h=Le(u==null?void 0:u._def.shape(),s),T=Object.fromEntries(Object.entries(c).filter(([b,A])=>!Ct(h[b],A))),S=o.filter(b=>!d.includes(b)),E=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:T}),S.length>0?{required:S}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${i.refId}`},E]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return x(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!C.isOptionalSchema(n)).map(([t,n])=>t)}}class Ur{transform(e,t,n){const s=e._def.valueType,a=e._def.keyType,i=n(s);if(x(a,"ZodEnum")||x(a,"ZodNativeEnum")){const c=Object.values(a.enum).filter(Xt).reduce((u,d)=>Object.assign(Object.assign({},u),{[d]:i}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:i})}}class Hr{transform(e,t){var n,s,a;const i=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(a=e.maxLength)!==null&&a!==void 0?a:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:i==null?void 0:i.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time"}getZodStringCheck(e,t){return e._def.checks.find(n=>n.kind===t)}}class qr{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:s}=e._def,a=s.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(a))}}class Wr{transform(e,t,n){const a=this.flattenUnionTypes(e).map(i=>{const o=this.unwrapNullable(i);return n(o)});return{anyOf:t(a)}}flattenUnionTypes(e){return x(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return x(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Br{constructor(e){this.versionSpecifics=e,this.objectTransformer=new Vr,this.stringTransformer=new Hr,this.numberTransformer=new Lr,this.bigIntTransformer=new Pr,this.literalTransformer=new Dr,this.enumTransformer=new Ar,this.nativeEnumTransformer=new $r,this.arrayTransformer=new Ir,this.unionTransformer=new Wr,this.discriminatedUnionTransformer=new Zr,this.intersectionTransformer=new Nr,this.recordTransformer=new Ur,this.tupleTransformer=new qr(e)}transform(e,t,n,s,a){if(x(e,"ZodNull"))return this.versionSpecifics.nullType;if(x(e,"ZodUnknown")||x(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(x(e,"ZodObject"))return this.objectTransformer.transform(e,a,o=>this.versionSpecifics.mapNullableType(o,t),n);const i=this.transformSchemaWithoutDefault(e,t,n,s);return Object.assign(Object.assign({},i),{default:a})}transformSchemaWithoutDefault(e,t,n,s){if(x(e,"ZodUnknown")||x(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(x(e,"ZodString"))return this.stringTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(x(e,"ZodNumber"))return this.numberTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),i=>this.versionSpecifics.getNumberChecks(i));if(x(e,"ZodBigInt"))return this.bigIntTransformer.transform(i=>this.versionSpecifics.mapNullableType(i,t));if(x(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(x(e,"ZodLiteral"))return this.literalTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(x(e,"ZodEnum"))return this.enumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(x(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(x(e,"ZodArray"))return this.arrayTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),n);if(x(e,"ZodTuple"))return this.tupleTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),n);if(x(e,"ZodUnion"))return this.unionTransformer.transform(e,i=>this.versionSpecifics.mapNullableOfArray(i,t),n);if(x(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),n,s);if(x(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),n);if(x(e,"ZodRecord"))return this.recordTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),n);if(x(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const a=C.getRefId(e);throw new Cr({currentSchema:e._def,schemaName:a})}}class zt{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Br(t),this.sortDefinitions()}generateDocumentData(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents(),paths:this.pathRefs}}generateComponents(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents()}}buildComponents(){var e,t;const n={};return this.rawComponents.forEach(({componentType:s,name:a,component:i})=>{var o;(o=n[s])!==null&&o!==void 0||(n[s]={}),n[s][a]=i}),Object.assign(Object.assign({},n),{schemas:Object.assign(Object.assign({},(e=n.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=n.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,n)=>{if(!("type"in t))return"type"in n?-1:0;if(!("type"in n))return 1;const s=e.findIndex(i=>i===t.type),a=e.findIndex(i=>i===n.type);return s-a})}generateSingle(e){if(!("type"in e)){this.generateSchemaWithRef(e);return}switch(e.type){case"parameter":this.generateParameterDefinition(e.schema);return;case"schema":this.generateSchemaWithRef(e.schema);return;case"route":this.generateSingleRoute(e.route);return;case"component":this.rawComponents.push(e);return}}generateParameterDefinition(e){const t=C.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,s,a,i,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(a=e._internal)===null||a===void 0?void 0:a.refId]:void 0;if(!(!(!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new Pe(`Conflicting location for parameter ${u.name}`,{key:"in",values:Ut([u.in,t==null?void 0:t.in,c==null?void 0:c.in])});if(c&&u.name!==c.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new Pe("Conflicting names for parameter",{key:"name",values:Ut([u.name,t==null?void 0:t.name,c==null?void 0:c.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var n;const s=C.getMetadata(e),a=(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param,i=this.getParameterRef(s,{in:t});if(i)return[i];if(x(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,d])=>{var h,T;const S=C.getMetadata(d),E=this.getParameterRef(S,{in:t,name:u});if(E)return E;const b=(h=S==null?void 0:S.metadata)===null||h===void 0?void 0:h.param;if(b!=null&&b.name&&b.name!==u)throw new Pe("Conflicting names for parameter",{key:"name",values:[u,b.name]});if(b!=null&&b.in&&b.in!==t)throw new Pe(`Conflicting location for parameter ${(T=b.name)!==null&&T!==void 0?T:u}`,{key:"in",values:[t,b.in]});return this.generateParameter(d.openapi({param:{name:u,in:t}}))})}if(a!=null&&a.in&&a.in!==t)throw new Pe(`Conflicting location for parameter ${a.name}`,{key:"in",values:[t,a.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=C.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,a=!C.isOptionalSchema(e)&&!e.isNullable(),i=this.generateSchemaWithRef(e);return Object.assign({schema:i,required:a},s?C.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=C.getMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,a=s==null?void 0:s.name,i=s==null?void 0:s.in;if(!a)throw new ht({missingField:"name"});if(!i)throw new ht({missingField:"in",paramName:a});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:i,name:a})}generateSchemaWithMetadata(e){var t;const n=C.unwrapChained(e),s=C.getMetadata(e),a=C.getDefaultValue(e),i=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),a);return s!=null&&s.metadata?C.applySchemaMetadata(i,s.metadata):ke(i,$e)}constructReferencedOpenAPISchema(e){var t;const n=C.getMetadata(e),s=C.unwrapChained(e),a=C.getDefaultValue(e),i=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,i):this.toOpenAPISchema(s,i,a)}generateSimpleSchema(e){var t;const n=C.getMetadata(e),s=C.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const a=this.schemaRefs[s],i={$ref:this.generateSchemaRef(s)},o=ke(C.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(d,h)=>d===void 0||Ct(d,a[h]));if(o.type)return{allOf:[i,o]};const c=ke(this.constructReferencedOpenAPISchema(e),(d,h)=>d===void 0||Ct(d,a[h])),u=C.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[i,u]}:i}generateSchemaWithRef(e){const t=C.getRefId(e),n=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=n,{$ref:this.generateSchemaRef(t)}):n}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,n=Ae(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),s=this.cleanParameter(e.params),a=this.cleanParameter(e.cookies),i=Ze(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=Ze(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=Ze(()=>a?this.generateInlineParameters(a,"cookie"):[],{location:"cookie"}),u=Ze(()=>{if(Array.isArray(t))return t.flatMap(h=>this.generateInlineParameters(h,"header"));const d=this.cleanParameter(t);return d?this.generateInlineParameters(d,"header"):[]},{location:"header"});return[...o,...i,...u,...c]}cleanParameter(e){if(e)return x(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:a}=e,i=Ae(e,["method","path","request","responses"]),o=Le(a,h=>this.getResponse(h)),c=Ze(()=>this.getParameters(s),{route:`${t} ${n}`}),u=this.getRequestBody(s==null?void 0:s.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},i),c.length>0?{parameters:[...i.parameters||[],...c]}:{}),u?{requestBody:u}:{}),{responses:o})}}generateSingleRoute(e){const t=this.generatePath(e);return this.pathRefs[e.path]=Object.assign(Object.assign({},this.pathRefs[e.path]),t),t}getResponse(e){var{content:t,headers:n}=e,s=Ae(e,["content","headers"]);const a=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),a);const i=x(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},s),{headers:i}),a)}getResponseHeaders(e){const t=e._def.shape();return Le(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return Le(e,t=>{if(!t||!Or(t.schema))return t;const{schema:n}=t,s=Ae(t,["schema"]),a=this.generateSchemaWithRef(n);return Object.assign({schema:a},s)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),n)}}class Fr{get nullType(){return{nullable:!0}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return Object.assign(Object.assign({},e?{type:e}:void 0),t?this.nullType:void 0)}mapTupleItems(e){const t=Er(e);return{items:t.length===1?t[0]:{anyOf:t},minItems:e.length,maxItems:e.length}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{minimum:Number(t.value),exclusiveMinimum:!0};case"max":return t.inclusive?{maximum:Number(t.value)}:{maximum:Number(t.value),exclusiveMaximum:!0};default:return{}}}))}}class Gr{constructor(e){const t=new Fr;this.generator=new zt(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class Kr{get nullType(){return{type:"null"}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return e?t?{type:Array.isArray(e)?[...e,"null"]:[e,"null"]}:{type:e}:{}}mapTupleItems(e){return{prefixItems:e}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{exclusiveMinimum:Number(t.value)};case"max":return t.inclusive?{maximum:Number(t.value)}:{exclusiveMaximum:Number(t.value)};default:return{}}}))}}function Yr(r){return"type"in r&&r.type==="webhook"}class Qr{constructor(e){this.definitions=e,this.webhookRefs={};const t=new Kr;this.generator=new zt(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(Yr).forEach(n=>this.generateSingleWebhook(n.webhook)),Object.assign(Object.assign(Object.assign({},e),t),{webhooks:this.webhookRefs})}generateComponents(){return this.generator.generateComponents()}generateSingleWebhook(e){const t=this.generator.generatePath(e);return this.webhookRefs[e.path]=Object.assign(Object.assign({},this.webhookRefs[e.path]),t),t}}var er=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},Jr=r=>{const{groups:e,path:t}=Xr(r),n=er(t);return zr(n,e)},Xr=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},zr=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let s=r.length-1;s>=0;s--)if(r[s].includes(n)){r[s]=r[s].replace(n,e[t][1]);break}}return r},ct={},Ht=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(ct[r]||(e[2]?ct[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:ct[r]=[r,e[1],!0]),ct[r]):null},en=r=>{try{return decodeURI(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURI(e)}catch{return e}})}},tr=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const s=e.charCodeAt(n);if(s===37){const a=e.indexOf("?",n),i=e.slice(t,a===-1?void 0:a);return en(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}else if(s===63)break}return e.slice(t,n)},tn=r=>{const e=tr(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},he=(...r)=>{let e="",t=!1;for(let n of r)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),n[0]!=="/"&&(n=`/${n}`),n==="/"&&t?e=`${e}/`:n!=="/"&&(e=`${e}${n}`),n==="/"&&e===""&&(e="/");return e},rr=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))n+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&n===""?t.push("/"):t.push(n);const a=s.replace("?","");n+="/"+a,t.push(n)}else n+="/"+s}),t.filter((s,a,i)=>i.indexOf(s)===a)},jt=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),/%/.test(r)?ft(r):r):r,nr=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let i=r.indexOf(`?${e}`,8);for(i===-1&&(i=r.indexOf(`&${e}`,8));i!==-1;){const o=r.charCodeAt(i+e.length+1);if(o===61){const c=i+e.length+2,u=r.indexOf("&",c);return jt(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";i=r.indexOf(`&${e}`,i+1)}if(n=/[%+]/.test(r),!n)return}const s={};n??(n=/[%+]/.test(r));let a=r.indexOf("?",8);for(;a!==-1;){const i=r.indexOf("&",a+1);let o=r.indexOf("=",a);o>i&&i!==-1&&(o=-1);let c=r.slice(a+1,o===-1?i===-1?void 0:i:o);if(n&&(c=jt(c)),a=i,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,i===-1?void 0:i),n&&(u=jt(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},rn=nr,nn=(r,e)=>nr(r,e,!0),ft=decodeURIComponent,sn=/^[\w!#$%&'*.^`|~+-]+$/,an=/^[ !#-:<-[\]-~]*$/,on=(r,e)=>r.trim().split(";").reduce((n,s)=>{s=s.trim();const a=s.indexOf("=");if(a===-1)return n;const i=s.substring(0,a).trim();if(!sn.test(i))return n;let o=s.substring(a+1).trim();return o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),an.test(o)&&(n[i]=ft(o)),n},{}),cn=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?on(n):{}},Rt=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});p(this,"res");p(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},un=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),dn=(r,e)=>async(t,n)=>{let s={};const a=t.req.header("Content-Type");switch(r){case"json":if(!a||!/^application\/([a-z-\.]+\+)?json/.test(a)){const o=`Invalid HTTP header: Content-Type=${a}`;throw new Rt(400,{message:o})}try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new Rt(400,{message:o})}break;case"form":{if(!a)break;if(t.req.bodyCache.formData){s=await t.req.bodyCache.formData;break}try{const o=await t.req.arrayBuffer(),c=await un(o,a),u={};c.forEach((d,h)=>{h.endsWith("[]")?u[h]===void 0?u[h]=[d]:Array.isArray(u[h])&&u[h].push(d):u[h]=d}),s=u,t.req.bodyCache.formData=c}catch(o){let c="Malformed FormData request.";throw c+=o instanceof Error?` ${o.message}`:` ${String(o)}`,new Rt(400,{message:c})}break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=cn(t);break}const i=await e(s,t);if(i instanceof Response)return i;t.req.addValidatedData(r,i),await n()};const _e=(r,e,t)=>dn(r,async(n,s)=>{const a=await e.safeParseAsync(n);if(t){const i=await t({data:n,...a},s);if(i){if(i instanceof Response)return i;if("response"in i)return i.response}}return a.success?a.data:s.json(a,400)});var ln=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,a=(r instanceof sr?r.raw.headers:r.headers).get("Content-Type");return a!==null&&a.startsWith("multipart/form-data")||a!==null&&a.startsWith("application/x-www-form-urlencoded")?hn(r,{all:t,dot:n}):{}};async function hn(r,e){const t=await r.formData();return t?fn(t,e):{}}function fn(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?pn(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(mn(t,n,s),delete t[n])}),t}var pn=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},mn=(r,e,t)=>{let n=r;const s=e.split(".");s.forEach((a,i)=>{i===s.length-1?n[a]=t:((!n[a]||typeof n[a]!="object"||Array.isArray(n[a])||n[a]instanceof File)&&(n[a]=Object.create(null)),n=n[a])})},Te,H,Yt,sr=(Yt=class{constructor(r,e="/",t=[[]]){p(this,"raw");D(this,Te);D(this,H);p(this,"routeIndex",0);p(this,"path");p(this,"bodyCache",{});p(this,"cachedBody",r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const s=Object.keys(e)[0];return s?e[s].then(a=>(s==="json"&&(a=JSON.stringify(a)),new Response(a)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,j(this,H,t),j(this,Te,{})}param(r){return r?this.getDecodedParam(r):this.getAllDecodedParams()}getDecodedParam(r){const e=f(this,H)[0][this.routeIndex][1][r],t=this.getParamValue(e);return t?/\%/.test(t)?ft(t):t:void 0}getAllDecodedParams(){const r={},e=Object.keys(f(this,H)[0][this.routeIndex][1]);for(const t of e){const n=this.getParamValue(f(this,H)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?ft(n):n)}return r}getParamValue(r){return f(this,H)[1]?f(this,H)[1][r]:r}query(r){return rn(this.url,r)}queries(r){return nn(this.url,r)}header(r){if(r)return this.raw.headers.get(r.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,n)=>{e[n]=t}),e}async parseBody(r){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await ln(this,r))}json(){return this.cachedBody("json")}text(){return this.cachedBody("text")}arrayBuffer(){return this.cachedBody("arrayBuffer")}blob(){return this.cachedBody("blob")}formData(){return this.cachedBody("formData")}addValidatedData(r,e){f(this,Te)[r]=e}valid(r){return f(this,Te)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return f(this,H)[0].map(([[,r]])=>r)}get routePath(){return f(this,H)[0].map(([[,r]])=>r)[this.routeIndex].path}},Te=new WeakMap,H=new WeakMap,Yt),gn={Stringify:1,BeforeStream:2,Stream:3},ar=async(r,e,t,n,s)=>{const a=r.callbacks;return a!=null&&a.length?(s?s[0]+=r:s=[r],Promise.all(a.map(o=>o({phase:e,buffer:s,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>ar(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},vn="text/plain; charset=UTF-8",Et=(r,e={})=>(Object.entries(e).forEach(([t,n])=>r.set(t,n)),r),rt,nt,ie,fe,te,I,Z,q,re,st,je,Re,at,it,Qt,ut=(Qt=class{constructor(r,e){D(this,rt);D(this,nt);p(this,"env",{});D(this,ie);p(this,"finalized",!1);p(this,"error");D(this,fe,200);D(this,te);D(this,I);D(this,Z);D(this,q);D(this,re,!0);D(this,st);D(this,je);D(this,Re);D(this,at);D(this,it);p(this,"render",(...r)=>(f(this,je)??j(this,je,e=>this.html(e)),f(this,je).call(this,...r)));p(this,"setLayout",r=>j(this,st,r));p(this,"getLayout",()=>f(this,st));p(this,"setRenderer",r=>{j(this,je,r)});p(this,"header",(r,e,t)=>{if(e===void 0){f(this,I)?f(this,I).delete(r):f(this,Z)&&delete f(this,Z)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(f(this,I)||(j(this,re,!1),j(this,I,new Headers(f(this,Z))),j(this,Z,{})),f(this,I).append(r,e)):f(this,I)?f(this,I).set(r,e):(f(this,Z)??j(this,Z,{}),f(this,Z)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});p(this,"status",r=>{j(this,re,!1),j(this,fe,r)});p(this,"set",(r,e)=>{f(this,ie)??j(this,ie,{}),f(this,ie)[r]=e});p(this,"get",r=>f(this,ie)?f(this,ie)[r]:void 0);p(this,"newResponse",(r,e,t)=>{if(f(this,re)&&!t&&!e&&f(this,fe)===200)return new Response(r,{headers:f(this,Z)});if(e&&typeof e!="number"){const s=new Headers(e.headers);f(this,I)&&f(this,I).forEach((i,o)=>{o==="set-cookie"?s.append(o,i):s.set(o,i)});const a=Et(s,f(this,Z));return new Response(r,{headers:a,status:e.status??f(this,fe)})}const n=typeof e=="number"?e:f(this,fe);f(this,Z)??j(this,Z,{}),f(this,I)??j(this,I,new Headers),Et(f(this,I),f(this,Z)),f(this,q)&&(f(this,q).headers.forEach((s,a)=>{var i,o;a==="set-cookie"?(i=f(this,I))==null||i.append(a,s):(o=f(this,I))==null||o.set(a,s)}),Et(f(this,I),f(this,Z))),t??(t={});for(const[s,a]of Object.entries(t))if(typeof a=="string")f(this,I).set(s,a);else{f(this,I).delete(s);for(const i of a)f(this,I).append(s,i)}return new Response(r,{status:n,headers:f(this,I)})});p(this,"body",(r,e,t)=>typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e));p(this,"text",(r,e,t)=>{if(!f(this,Z)){if(f(this,re)&&!t&&!e)return new Response(r);j(this,Z,{})}return f(this,Z)["content-type"]=vn,typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)});p(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return f(this,Z)??j(this,Z,{}),f(this,Z)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)});p(this,"html",(r,e,t)=>(f(this,Z)??j(this,Z,{}),f(this,Z)["content-type"]="text/html; charset=UTF-8",typeof r=="object"&&(r instanceof Promise||(r=r.toString()),r instanceof Promise)?r.then(n=>ar(n,gn.Stringify,!1,{})).then(n=>typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)):typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)));p(this,"redirect",(r,e)=>(f(this,I)??j(this,I,new Headers),f(this,I).set("Location",r),this.newResponse(null,e??302)));p(this,"notFound",()=>(f(this,Re)??j(this,Re,()=>new Response),f(this,Re).call(this,this)));j(this,rt,r),e&&(j(this,te,e.executionCtx),this.env=e.env,j(this,Re,e.notFoundHandler),j(this,it,e.path),j(this,at,e.matchResult))}get req(){return f(this,nt)??j(this,nt,new sr(f(this,rt),f(this,it),f(this,at))),f(this,nt)}get event(){if(f(this,te)&&"respondWith"in f(this,te))return f(this,te);throw Error("This context has no FetchEvent")}get executionCtx(){if(f(this,te))return f(this,te);throw Error("This context has no ExecutionContext")}get res(){return j(this,re,!1),f(this,q)||j(this,q,new Response("404 Not Found",{status:404}))}set res(r){if(j(this,re,!1),f(this,q)&&r){f(this,q).headers.delete("content-type");for(const[e,t]of f(this,q).headers.entries())if(e==="set-cookie"){const n=f(this,q).headers.getSetCookie();r.headers.delete("set-cookie");for(const s of n)r.headers.append("set-cookie",s)}else r.headers.set(e,t)}j(this,q,r),this.finalized=!0}get var(){return{...f(this,ie)}}},rt=new WeakMap,nt=new WeakMap,ie=new WeakMap,fe=new WeakMap,te=new WeakMap,I=new WeakMap,Z=new WeakMap,q=new WeakMap,re=new WeakMap,st=new WeakMap,je=new WeakMap,Re=new WeakMap,at=new WeakMap,it=new WeakMap,Qt),qt=(r,e,t)=>(n,s)=>{let a=-1;return i(0);async function i(o){if(o<=a)throw new Error("next() called multiple times");a=o;let c,u=!1,d;if(r[o]?(d=r[o][0][0],n instanceof ut&&(n.req.routeIndex=o)):d=o===r.length&&s||void 0,!d)n instanceof ut&&n.finalized===!1&&t&&(c=await t(n));else try{c=await d(n,()=>i(o+1))}catch(h){if(h instanceof Error&&n instanceof ut&&e)n.error=h,c=await e(h,n),u=!0;else throw h}return c&&(n.finalized===!1||u)&&(n.res=c),n}},N="ALL",yn="all",_n=["get","post","put","delete","options","patch"],ir="Can not add a route since the matcher is already built.",or=class extends Error{},bn=Symbol("composedHandler"),wn=r=>r.text("404 Not Found",404),Wt=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),W,Jt,cr=(Jt=class{constructor(e={}){p(this,"get");p(this,"post");p(this,"put");p(this,"delete");p(this,"options");p(this,"patch");p(this,"all");p(this,"on");p(this,"use");p(this,"router");p(this,"getPath");p(this,"_basePath","/");D(this,W,"/");p(this,"routes",[]);p(this,"notFoundHandler",wn);p(this,"errorHandler",Wt);p(this,"onError",e=>(this.errorHandler=e,this));p(this,"notFound",e=>(this.notFoundHandler=e,this));p(this,"fetch",(e,...t)=>this.dispatch(e,t[1],t[0],e.method));p(this,"request",(e,t,n,s)=>{if(e instanceof Request)return t!==void 0&&(e=new Request(e,t)),this.fetch(e,n,s);e=e.toString();const a=/^https?:\/\//.test(e)?e:`http://localhost${he("/",e)}`,i=new Request(a,t);return this.fetch(i,n,s)});p(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(this.dispatch(e.request,e,void 0,e.request.method))})});[..._n,yn].forEach(s=>{this[s]=(a,...i)=>(typeof a=="string"?j(this,W,a):this.addRoute(s,f(this,W),a),i.forEach(o=>{typeof o!="string"&&this.addRoute(s,f(this,W),o)}),this)}),this.on=(s,a,...i)=>{for(const o of[a].flat()){j(this,W,o);for(const c of[s].flat())i.map(u=>{this.addRoute(c.toUpperCase(),f(this,W),u)})}return this},this.use=(s,...a)=>(typeof s=="string"?j(this,W,s):(j(this,W,"*"),a.unshift(s)),a.forEach(i=>{this.addRoute(N,f(this,W),i)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??tr:tn}clone(){const e=new cr({router:this.router,getPath:this.getPath});return e.routes=this.routes,e}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{let a;t.errorHandler===Wt?a=s.handler:(a=async(i,o)=>(await qt([],t.errorHandler)(i,()=>s.handler(i,o))).res,a[bn]=s.handler),n.addRoute(s.method,s.path,a)}),this}basePath(e){const t=this.clone();return t._basePath=he(this._basePath,e),t}mount(e,t,n){let s,a;n&&(typeof n=="function"?a=n:(a=n.optionHandler,s=n.replaceRequest));const i=a?c=>{const u=a(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};s||(s=(()=>{const c=he(this._basePath,e),u=c==="/"?0:c.length;return d=>{const h=new URL(d.url);return h.pathname=h.pathname.slice(u)||"/",new Request(h,d)}})());const o=async(c,u)=>{const d=await t(s(c.req.raw),...i(c));if(d)return d;await u()};return this.addRoute(N,he(e,"*"),o),this}addRoute(e,t,n){e=e.toUpperCase(),t=he(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)}matchRoute(e,t){return this.router.match(e,t)}handleError(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}dispatch(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await this.dispatch(e,t,n,"GET")))();const a=this.getPath(e,{env:n}),i=this.matchRoute(s,a),o=new ut(e,{path:a,matchResult:i,env:n,executionCtx:t,notFoundHandler:this.notFoundHandler});if(i[0].length===1){let u;try{u=i[0][0][0][0](o,async()=>{o.res=await this.notFoundHandler(o)})}catch(d){return this.handleError(d,o)}return u instanceof Promise?u.then(d=>d||(o.finalized?o.res:this.notFoundHandler(o))).catch(d=>this.handleError(d,o)):u??this.notFoundHandler(o)}const c=qt(i[0],this.errorHandler,this.notFoundHandler);return(async()=>{try{const u=await c(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.handleError(u,o)}})()}},W=new WeakMap,Jt),pt="[^/]+",Ve=".*",Ue="(?:|/.*)",Ne=Symbol(),xn=new Set(".\\+*[^]$()");function kn(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===Ve||r===Ue?1:e===Ve||e===Ue?-1:r===pt?1:e===pt?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var It=class{constructor(){p(this,"index");p(this,"varIndex");p(this,"children",Object.create(null))}insert(e,t,n,s,a){if(e.length===0){if(this.index!==void 0)throw Ne;if(a)return;this.index=t;return}const[i,...o]=e,c=i==="*"?o.length===0?["","",Ve]:["","",pt]:i==="/*"?["","",Ue]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const d=c[1];let h=c[2]||pt;if(d&&c[2]&&(h=h.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(h)))throw Ne;if(u=this.children[h],!u){if(Object.keys(this.children).some(T=>T!==Ve&&T!==Ue))throw Ne;if(a)return;u=this.children[h]=new It,d!==""&&(u.varIndex=s.varIndex++)}!a&&d!==""&&n.push([d,u.varIndex])}else if(u=this.children[i],!u){if(Object.keys(this.children).some(d=>d.length>1&&d!==Ve&&d!==Ue))throw Ne;if(a)return;u=this.children[i]=new It}u.insert(o,t,n,s,a)}buildRegExpStr(){const t=Object.keys(this.children).sort(kn).map(n=>{const s=this.children[n];return(typeof s.varIndex=="number"?`(${n})@${s.varIndex}`:xn.has(n)?`\\${n}`:n)+s.buildRegExpStr()});return typeof this.index=="number"&&t.unshift(`#${this.index}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},On=class{constructor(){p(this,"context",{varIndex:0});p(this,"root",new It)}insert(r,e,t){const n=[],s=[];for(let i=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${i}`;return s[i]=[u,c],i++,o=!0,u}),!o)break}const a=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=s.length-1;i>=0;i--){const[o]=s[i];for(let c=a.length-1;c>=0;c--)if(a[c].indexOf(o)!==-1){a[c]=a[c].replace(o,s[i][1]);break}}return this.root.insert(a,e,n,this.context,t),n}buildRegExp(){let r=this.root.buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,a,i)=>typeof a<"u"?(t[++e]=Number(a),"$()"):(typeof i<"u"&&(n[Number(i)]=++e),"")),[new RegExp(`^${r}`),t,n]}},ur=[],Tn=[/^$/,[],Object.create(null)],dt=Object.create(null);function dr(r){return dt[r]??(dt[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function jn(){dt=Object.create(null)}function Rn(r){var u;const e=new On,t=[];if(r.length===0)return Tn;const n=r.map(d=>[!/\*|\/:/.test(d[0]),...d]).sort(([d,h],[T,S])=>d?1:T?-1:h.length-S.length),s=Object.create(null);for(let d=0,h=-1,T=n.length;d<T;d++){const[S,E,b]=n[d];S?s[E]=[b.map(([M])=>[M,Object.create(null)]),ur]:h++;let A;try{A=e.insert(E,h,S)}catch(M){throw M===Ne?new or(E):M}S||(t[h]=b.map(([M,K])=>{const U=Object.create(null);for(K-=1;K>=0;K--){const[ve,se]=A[K];U[ve]=se}return[M,U]}))}const[a,i,o]=e.buildRegExp();for(let d=0,h=t.length;d<h;d++)for(let T=0,S=t[d].length;T<S;T++){const E=(u=t[d][T])==null?void 0:u[1];if(!E)continue;const b=Object.keys(E);for(let A=0,M=b.length;A<M;A++)E[b[A]]=o[E[b[A]]]}const c=[];for(const d in i)c[d]=t[i[d]];return[a,c,s]}function be(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(dr(t).test(e))return[...r[t]]}}var En=class{constructor(){p(this,"name","RegExpRouter");p(this,"middleware");p(this,"routes");this.middleware={[N]:Object.create(null)},this.routes={[N]:Object.create(null)}}add(r,e,t){var o;const{middleware:n,routes:s}=this;if(!n||!s)throw new Error(ir);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[N]).forEach(u=>{c[r][u]=[...c[N][u]]})}),e==="/*"&&(e="*");const a=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=dr(e);r===N?Object.keys(n).forEach(u=>{var d;(d=n[u])[e]||(d[e]=be(n[u],e)||be(n[N],e)||[])}):(o=n[r])[e]||(o[e]=be(n[r],e)||be(n[N],e)||[]),Object.keys(n).forEach(u=>{(r===N||r===u)&&Object.keys(n[u]).forEach(d=>{c.test(d)&&n[u][d].push([t,a])})}),Object.keys(s).forEach(u=>{(r===N||r===u)&&Object.keys(s[u]).forEach(d=>c.test(d)&&s[u][d].push([t,a]))});return}const i=rr(e)||[e];for(let c=0,u=i.length;c<u;c++){const d=i[c];Object.keys(s).forEach(h=>{var T;(r===N||r===h)&&((T=s[h])[d]||(T[d]=[...be(n[h],d)||be(n[N],d)||[]]),s[h][d].push([t,a-u+c+1]))})}}match(r,e){jn();const t=this.buildAllMatchers();return this.match=(n,s)=>{const a=t[n]||t[N],i=a[2][s];if(i)return i;const o=s.match(a[0]);if(!o)return[[],ur];const c=o.indexOf("",1);return[a[1][c],o]},this.match(r,e)}buildAllMatchers(){const r=Object.create(null);return[...Object.keys(this.routes),...Object.keys(this.middleware)].forEach(e=>{r[e]||(r[e]=this.buildMatcher(e))}),this.middleware=this.routes=void 0,r}buildMatcher(r){const e=[];let t=r===N;return[this.middleware,this.routes].forEach(n=>{const s=n[r]?Object.keys(n[r]).map(a=>[a,n[r][a]]):[];s.length!==0?(t||(t=!0),e.push(...s)):r!==N&&e.push(...Object.keys(n[N]).map(a=>[a,n[N][a]]))}),t?Rn(e):null}},Sn=class{constructor(r){p(this,"name","SmartRouter");p(this,"routers",[]);p(this,"routes",[]);Object.assign(this,r)}add(r,e,t){if(!this.routes)throw new Error(ir);this.routes.push([r,e,t])}match(r,e){if(!this.routes)throw new Error("Fatal error");const{routers:t,routes:n}=this,s=t.length;let a=0,i;for(;a<s;a++){const o=t[a];try{n.forEach(c=>{o.add(...c)}),i=o.match(r,e)}catch(c){if(c instanceof or)continue;throw c}this.match=o.match.bind(o),this.routers=[o],this.routes=void 0;break}if(a===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.routes||this.routers.length!==1)throw new Error("No active router has been determined yet.");return this.routers[0]}},lr=class{constructor(r,e,t){p(this,"methods");p(this,"children");p(this,"patterns");p(this,"order",0);p(this,"name");p(this,"params",Object.create(null));if(this.children=t||Object.create(null),this.methods=[],this.name="",r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0,name:this.name},this.methods=[n]}this.patterns=[]}insert(r,e,t){this.name=`${r} ${e}`,this.order=++this.order;let n=this;const s=Jr(e),a=[];for(let c=0,u=s.length;c<u;c++){const d=s[c];if(Object.keys(n.children).includes(d)){n=n.children[d];const T=Ht(d);T&&a.push(T[1]);continue}n.children[d]=new lr;const h=Ht(d);h&&(n.patterns.push(h),a.push(h[1])),n=n.children[d]}n.methods.length||(n.methods=[]);const i=Object.create(null),o={handler:t,possibleKeys:a.filter((c,u,d)=>d.indexOf(c)===u),name:this.name,score:this.order};return i[r]=o,n.methods.push(i),n}gHSets(r,e,t,n){const s=[];for(let a=0,i=r.methods.length;a<i;a++){const o=r.methods[a],c=o[e]||o[N],u=Object.create(null);c!==void 0&&(c.params=Object.create(null),c.possibleKeys.forEach(d=>{const h=u[c.name];c.params[d]=n[d]&&!h?n[d]:t[d]??n[d],u[c.name]=!0}),s.push(c))}return s}search(r,e){const t=[];this.params=Object.create(null);let s=[this];const a=er(e);for(let o=0,c=a.length;o<c;o++){const u=a[o],d=o===c-1,h=[];for(let T=0,S=s.length;T<S;T++){const E=s[T],b=E.children[u];b&&(b.params=E.params,d===!0?(b.children["*"]&&t.push(...this.gHSets(b.children["*"],r,E.params,Object.create(null))),t.push(...this.gHSets(b,r,E.params,Object.create(null)))):h.push(b));for(let A=0,M=E.patterns.length;A<M;A++){const K=E.patterns[A],U={...E.params};if(K==="*"){const le=E.children["*"];le&&(t.push(...this.gHSets(le,r,E.params,Object.create(null))),h.push(le));continue}if(u==="")continue;const[ve,se,z]=K,Y=E.children[ve],ye=a.slice(o).join("/");if(z instanceof RegExp&&z.test(ye)){U[se]=ye,t.push(...this.gHSets(Y,r,E.params,U));continue}(z===!0||z instanceof RegExp&&z.test(u))&&typeof ve=="string"&&(U[se]=u,d===!0?(t.push(...this.gHSets(Y,r,U,E.params)),Y.children["*"]&&t.push(...this.gHSets(Y.children["*"],r,U,E.params))):(Y.params=U,h.push(Y)))}}s=h}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},Cn=class{constructor(){p(this,"name","TrieRouter");p(this,"node");this.node=new lr}add(r,e,t){const n=rr(e);if(n){for(const s of n)this.node.insert(r,s,t);return}this.node.insert(r,e,t)}match(r,e){return this.node.search(r,e)}},In=class extends cr{constructor(r={}){super(r),this.router=r.router??new Sn({routers:[new En,new Cn]})}},R;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(R||(R={}));var Pt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Pt||(Pt={}));const g=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ae=r=>{switch(typeof r){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(r)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(r)?g.array:r===null?g.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?g.promise:typeof Map<"u"&&r instanceof Map?g.map:typeof Set<"u"&&r instanceof Set?g.set:typeof Date<"u"&&r instanceof Date?g.date:g.object;default:return g.unknown}},l=R.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Pn=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class V extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof V))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}V.create=r=>new V(r);const Ee=(r,e)=>{let t;switch(r.code){case l.invalid_type:r.received===g.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,R.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${R.joinValues(r.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${R.joinValues(r.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${R.joinValues(r.options)}, received '${r.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:R.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case l.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case l.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,R.assertNever(r)}return{message:t}};let hr=Ee;function Zn(r){hr=r}function mt(){return hr}const gt=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},An=[];function m(r,e){const t=mt(),n=gt({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ee?void 0:Ee].filter(s=>!!s)});r.common.issues.push(n)}class ${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return _;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return $.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return _;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const _=Object.freeze({status:"aborted"}),xe=r=>({status:"dirty",value:r}),L=r=>({status:"valid",value:r}),Zt=r=>r.status==="aborted",At=r=>r.status==="dirty",He=r=>r.status==="valid",qe=r=>typeof Promise<"u"&&r instanceof Promise;function vt(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function fr(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var v;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(v||(v={}));var De,Me;class J{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Bt=(r,e)=>{if(He(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new V(r.common.issues);return this._error=t,this._error}}};function w(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var c,u;const{message:d}=r;return i.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:(c=d??n)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=d??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class k{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(qe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ae(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Bt(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ae(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(qe(s)?s:Promise.resolve(s));return Bt(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:l.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new G({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Q.create(this,this._def)}nullable(){return de.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return F.create(this,this._def)}promise(){return Ce.create(this,this._def)}or(e){return Ge.create([this,e],this._def)}and(e){return Ke.create(this,e,this._def)}transform(e){return new G({...w(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ze({...w(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new $t({typeName:y.ZodBranded,type:this,...w(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new et({...w(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ot.create(this,e)}readonly(){return tt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Nn=/^c[^\s-]{8,}$/i,Dn=/^[0-9a-z]+$/,Mn=/^[0-9A-HJKMNP-TV-Z]{26}$/,$n=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ln=/^[a-z0-9_-]{21}$/i,Vn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Un=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let St;const qn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Wn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Bn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,pr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Fn=new RegExp(`^${pr}$`);function mr(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Gn(r){return new RegExp(`^${mr(r)}$`)}function gr(r){let e=`${pr}T${mr(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Kn(r,e){return!!((e==="v4"||!e)&&qn.test(r)||(e==="v6"||!e)&&Wn.test(r))}class B extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:g.string,received:a.parsedType}),_}const n=new $;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?m(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&m(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Un.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")St||(St=new RegExp(Hn,"u")),St.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")$n.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Dn.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:l.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:l.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?gr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Fn.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Gn(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Vn.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Kn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:l.invalid_string,message:a.message}),n.dirty()):R.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:l.invalid_string,...v.errToObj(n)})}_addCheck(e){return new B({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...v.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...v.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...v.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new B({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new B({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new B({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}B.create=r=>{var e;return new B({checks:[],typeName:y.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...w(r)})};function Yn(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class oe extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:g.number,received:a.parsedType}),_}let n;const s=new $;for(const a of this._def.checks)a.kind==="int"?R.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Yn(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:l.not_finite,message:a.message}),s.dirty()):R.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,n,s){return new oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:v.toString(s)}]})}_addCheck(e){return new oe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&R.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}oe.create=r=>new oe({checks:[],typeName:y.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...w(r)});class ce extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==g.bigint){const a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:g.bigint,received:a.parsedType}),_}let n;const s=new $;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):R.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,n,s){return new ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:v.toString(s)}]})}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ce.create=r=>{var e;return new ce({checks:[],typeName:y.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...w(r)})};class We extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.boolean,received:n.parsedType}),_}return L(e.data)}}We.create=r=>new We({typeName:y.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...w(r)});class me extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:g.date,received:a.parsedType}),_}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_date}),_}const n=new $;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:l.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):R.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new me({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}me.create=r=>new me({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:y.ZodDate,...w(r)});class yt extends k{_parse(e){if(this._getType(e)!==g.symbol){const n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.symbol,received:n.parsedType}),_}return L(e.data)}}yt.create=r=>new yt({typeName:y.ZodSymbol,...w(r)});class Be extends k{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.undefined,received:n.parsedType}),_}return L(e.data)}}Be.create=r=>new Be({typeName:y.ZodUndefined,...w(r)});class Fe extends k{_parse(e){if(this._getType(e)!==g.null){const n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.null,received:n.parsedType}),_}return L(e.data)}}Fe.create=r=>new Fe({typeName:y.ZodNull,...w(r)});class Se extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return L(e.data)}}Se.create=r=>new Se({typeName:y.ZodAny,...w(r)});class pe extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return L(e.data)}}pe.create=r=>new pe({typeName:y.ZodUnknown,...w(r)});class ne extends k{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:l.invalid_type,expected:g.never,received:t.parsedType}),_}}ne.create=r=>new ne({typeName:y.ZodNever,...w(r)});class _t extends k{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.void,received:n.parsedType}),_}return L(e.data)}}_t.create=r=>new _t({typeName:y.ZodVoid,...w(r)});class F extends k{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==g.array)return m(t,{code:l.invalid_type,expected:g.array,received:t.parsedType}),_;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(m(t,{code:i?l.too_big:l.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(m(t,{code:l.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(m(t,{code:l.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new J(t,i,t.path,o)))).then(i=>$.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new J(t,i,t.path,o)));return $.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new F({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new F({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new F({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}}F.create=(r,e)=>new F({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...w(e)});function we(r){if(r instanceof P){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Q.create(we(n))}return new P({...r._def,shape:()=>e})}else return r instanceof F?new F({...r._def,type:we(r.element)}):r instanceof Q?Q.create(we(r.unwrap())):r instanceof de?de.create(we(r.unwrap())):r instanceof X?X.create(r.items.map(e=>we(e))):r}class P extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=R.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==g.object){const u=this._getOrReturnCtx(e);return m(u,{code:l.invalid_type,expected:g.object,received:u.parsedType}),_}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof ne&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const d=a[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new J(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof ne){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of o)c.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")o.length>0&&(m(s,{code:l.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of o){const h=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new J(s,h,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const h=await d.key,T=await d.value;u.push({key:h,value:T,alwaysSet:d.alwaysSet})}return u}).then(u=>$.mergeObjectSync(n,u)):$.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new P({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=v.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new P({...this._def,unknownKeys:"strip"})}passthrough(){return new P({...this._def,unknownKeys:"passthrough"})}extend(e){return new P({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new P({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new P({...this._def,catchall:e})}pick(e){const t={};return R.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new P({...this._def,shape:()=>t})}omit(e){const t={};return R.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new P({...this._def,shape:()=>t})}deepPartial(){return we(this)}partial(e){const t={};return R.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new P({...this._def,shape:()=>t})}required(e){const t={};return R.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Q;)a=a._def.innerType;t[n]=a}}),new P({...this._def,shape:()=>t})}keyof(){return vr(R.objectKeys(this.shape))}}P.create=(r,e)=>new P({shape:()=>r,unknownKeys:"strip",catchall:ne.create(),typeName:y.ZodObject,...w(e)});P.strictCreate=(r,e)=>new P({shape:()=>r,unknownKeys:"strict",catchall:ne.create(),typeName:y.ZodObject,...w(e)});P.lazycreate=(r,e)=>new P({shape:r,unknownKeys:"strip",catchall:ne.create(),typeName:y.ZodObject,...w(e)});class Ge extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new V(o.ctx.common.issues));return m(t,{code:l.invalid_union,unionErrors:i}),_}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},d=c._parseSync({data:t.data,path:t.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!a&&(a={result:d,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new V(c));return m(t,{code:l.invalid_union,unionErrors:o}),_}}get options(){return this._def.options}}Ge.create=(r,e)=>new Ge({options:r,typeName:y.ZodUnion,...w(e)});const ee=r=>r instanceof Qe?ee(r.schema):r instanceof G?ee(r.innerType()):r instanceof Je?[r.value]:r instanceof ue?r.options:r instanceof Xe?R.objectValues(r.enum):r instanceof ze?ee(r._def.innerType):r instanceof Be?[void 0]:r instanceof Fe?[null]:r instanceof Q?[void 0,...ee(r.unwrap())]:r instanceof de?[null,...ee(r.unwrap())]:r instanceof $t||r instanceof tt?ee(r.unwrap()):r instanceof et?ee(r._def.innerType):[];class kt extends k{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.object)return m(t,{code:l.invalid_type,expected:g.object,received:t.parsedType}),_;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=ee(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new kt({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...w(n)})}}function Nt(r,e){const t=ae(r),n=ae(e);if(r===e)return{valid:!0,data:r};if(t===g.object&&n===g.object){const s=R.objectKeys(e),a=R.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Nt(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===g.array&&n===g.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Nt(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===g.date&&n===g.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Ke extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Zt(a)||Zt(i))return _;const o=Nt(a.value,i.value);return o.valid?((At(a)||At(i))&&t.dirty(),{status:t.value,value:o.data}):(m(n,{code:l.invalid_intersection_types}),_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Ke.create=(r,e,t)=>new Ke({left:r,right:e,typeName:y.ZodIntersection,...w(t)});class X extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.array)return m(n,{code:l.invalid_type,expected:g.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return m(n,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new J(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>$.mergeArray(t,i)):$.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new X({...this._def,rest:e})}}X.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:r,typeName:y.ZodTuple,rest:null,...w(e)})};class Ye extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return m(n,{code:l.invalid_type,expected:g.object,received:n.parsedType}),_;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new J(n,o,n.path,o)),value:i._parse(new J(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?$.mergeObjectAsync(t,s):$.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof k?new Ye({keyType:e,valueType:t,typeName:y.ZodRecord,...w(n)}):new Ye({keyType:B.create(),valueType:e,typeName:y.ZodRecord,...w(t)})}}class bt extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.map)return m(n,{code:l.invalid_type,expected:g.map,received:n.parsedType}),_;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new J(n,o,n.path,[u,"key"])),value:a._parse(new J(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return _;(u.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(u.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return _;(u.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(u.value,d.value)}return{status:t.value,value:o}}}}bt.create=(r,e,t)=>new bt({valueType:e,keyType:r,typeName:y.ZodMap,...w(t)});class ge extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.set)return m(n,{code:l.invalid_type,expected:g.set,received:n.parsedType}),_;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(m(n,{code:l.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(m(n,{code:l.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const d of c){if(d.status==="aborted")return _;d.status==="dirty"&&t.dirty(),u.add(d.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>a._parse(new J(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new ge({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new ge({...this._def,maxSize:{value:e,message:v.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ge.create=(r,e)=>new ge({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,...w(e)});class Oe extends k{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.function)return m(t,{code:l.invalid_type,expected:g.function,received:t.parsedType}),_;function n(o,c){return gt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mt(),Ee].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function s(o,c){return gt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mt(),Ee].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ce){const o=this;return L(async function(...c){const u=new V([]),d=await o._def.args.parseAsync(c,a).catch(S=>{throw u.addIssue(n(c,S)),u}),h=await Reflect.apply(i,this,d);return await o._def.returns._def.type.parseAsync(h,a).catch(S=>{throw u.addIssue(s(h,S)),u})})}else{const o=this;return L(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new V([n(c,u.error)]);const d=Reflect.apply(i,this,u.data),h=o._def.returns.safeParse(d,a);if(!h.success)throw new V([s(d,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Oe({...this._def,args:X.create(e).rest(pe.create())})}returns(e){return new Oe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Oe({args:e||X.create([]).rest(pe.create()),returns:t||pe.create(),typeName:y.ZodFunction,...w(n)})}}class Qe extends k{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Qe.create=(r,e)=>new Qe({getter:r,typeName:y.ZodLazy,...w(e)});class Je extends k{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}Je.create=(r,e)=>new Je({value:r,typeName:y.ZodLiteral,...w(e)});function vr(r,e){return new ue({values:r,typeName:y.ZodEnum,...w(e)})}class ue extends k{constructor(){super(...arguments),De.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{expected:R.joinValues(n),received:t.parsedType,code:l.invalid_type}),_}if(vt(this,De)||fr(this,De,new Set(this._def.values)),!vt(this,De).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{received:t.data,code:l.invalid_enum_value,options:n}),_}return L(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ue.create(e,{...this._def,...t})}exclude(e,t=this._def){return ue.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}De=new WeakMap;ue.create=vr;class Xe extends k{constructor(){super(...arguments),Me.set(this,void 0)}_parse(e){const t=R.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==g.string&&n.parsedType!==g.number){const s=R.objectValues(t);return m(n,{expected:R.joinValues(s),received:n.parsedType,code:l.invalid_type}),_}if(vt(this,Me)||fr(this,Me,new Set(R.getValidEnumValues(this._def.values))),!vt(this,Me).has(e.data)){const s=R.objectValues(t);return m(n,{received:n.data,code:l.invalid_enum_value,options:s}),_}return L(e.data)}get enum(){return this._def.values}}Me=new WeakMap;Xe.create=(r,e)=>new Xe({values:r,typeName:y.ZodNativeEnum,...w(e)});class Ce extends k{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return m(t,{code:l.invalid_type,expected:g.promise,received:t.parsedType}),_;const n=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return L(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ce.create=(r,e)=>new Ce({type:r,typeName:y.ZodPromise,...w(e)});class G extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{m(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return _;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?_:c.status==="dirty"||t.value==="dirty"?xe(c.value):c});{if(t.value==="aborted")return _;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?_:o.status==="dirty"||t.value==="dirty"?xe(o.value):o}}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?_:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?_:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!He(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>He(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);R.assertNever(s)}}G.create=(r,e,t)=>new G({schema:r,typeName:y.ZodEffects,effect:e,...w(t)});G.createWithPreprocess=(r,e,t)=>new G({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,...w(t)});class Q extends k{_parse(e){return this._getType(e)===g.undefined?L(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Q.create=(r,e)=>new Q({innerType:r,typeName:y.ZodOptional,...w(e)});class de extends k{_parse(e){return this._getType(e)===g.null?L(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}de.create=(r,e)=>new de({innerType:r,typeName:y.ZodNullable,...w(e)});class ze extends k{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===g.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ze.create=(r,e)=>new ze({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...w(e)});class et extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qe(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new V(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new V(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}et.create=(r,e)=>new et({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...w(e)});class wt extends k{_parse(e){if(this._getType(e)!==g.nan){const n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}}wt.create=r=>new wt({typeName:y.ZodNaN,...w(r)});const Qn=Symbol("zod_brand");class $t extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ot extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?_:a.status==="dirty"?(t.dirty(),xe(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?_:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new ot({in:e,out:t,typeName:y.ZodPipeline})}}class tt extends k{_parse(e){const t=this._def.innerType._parse(e),n=s=>(He(s)&&(s.value=Object.freeze(s.value)),s);return qe(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}tt.create=(r,e)=>new tt({innerType:r,typeName:y.ZodReadonly,...w(e)});function yr(r,e={},t){return r?Se.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Se.create()}const Jn={object:P.lazycreate};var y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(y||(y={}));const Xn=(r,e={message:`Input not instance of ${r.name}`})=>yr(t=>t instanceof r,e),_r=B.create,br=oe.create,zn=wt.create,es=ce.create,wr=We.create,ts=me.create,rs=yt.create,ns=Be.create,ss=Fe.create,as=Se.create,is=pe.create,os=ne.create,cs=_t.create,us=F.create,ds=P.create,ls=P.strictCreate,hs=Ge.create,fs=kt.create,ps=Ke.create,ms=X.create,gs=Ye.create,vs=bt.create,ys=ge.create,_s=Oe.create,bs=Qe.create,ws=Je.create,xs=ue.create,ks=Xe.create,Os=Ce.create,Ft=G.create,Ts=Q.create,js=de.create,Rs=G.createWithPreprocess,Es=ot.create,Ss=()=>_r().optional(),Cs=()=>br().optional(),Is=()=>wr().optional(),Ps={string:r=>B.create({...r,coerce:!0}),number:r=>oe.create({...r,coerce:!0}),boolean:r=>We.create({...r,coerce:!0}),bigint:r=>ce.create({...r,coerce:!0}),date:r=>me.create({...r,coerce:!0})},Zs=_;var O=Object.freeze({__proto__:null,defaultErrorMap:Ee,setErrorMap:Zn,getErrorMap:mt,makeIssue:gt,EMPTY_PATH:An,addIssueToContext:m,ParseStatus:$,INVALID:_,DIRTY:xe,OK:L,isAborted:Zt,isDirty:At,isValid:He,isAsync:qe,get util(){return R},get objectUtil(){return Pt},ZodParsedType:g,getParsedType:ae,ZodType:k,datetimeRegex:gr,ZodString:B,ZodNumber:oe,ZodBigInt:ce,ZodBoolean:We,ZodDate:me,ZodSymbol:yt,ZodUndefined:Be,ZodNull:Fe,ZodAny:Se,ZodUnknown:pe,ZodNever:ne,ZodVoid:_t,ZodArray:F,ZodObject:P,ZodUnion:Ge,ZodDiscriminatedUnion:kt,ZodIntersection:Ke,ZodTuple:X,ZodRecord:Ye,ZodMap:bt,ZodSet:ge,ZodFunction:Oe,ZodLazy:Qe,ZodLiteral:Je,ZodEnum:ue,ZodNativeEnum:Xe,ZodPromise:Ce,ZodEffects:G,ZodTransformer:G,ZodOptional:Q,ZodNullable:de,ZodDefault:ze,ZodCatch:et,ZodNaN:wt,BRAND:Qn,ZodBranded:$t,ZodPipeline:ot,ZodReadonly:tt,custom:yr,Schema:k,ZodSchema:k,late:Jn,get ZodFirstPartyTypeKind(){return y},coerce:Ps,any:as,array:us,bigint:es,boolean:wr,date:ts,discriminatedUnion:fs,effect:Ft,enum:xs,function:_s,instanceof:Xn,intersection:ps,lazy:bs,literal:ws,map:vs,nan:zn,nativeEnum:ks,never:os,null:ss,nullable:js,number:br,object:ds,oboolean:Is,onumber:Cs,optional:Ts,ostring:Ss,pipeline:Es,preprocess:Rs,promise:Os,record:gs,set:ys,strictObject:ls,string:_r,symbol:rs,transformer:Ft,tuple:ms,undefined:ns,union:hs,unknown:is,void:cs,NEVER:Zs,ZodIssueCode:l,quotelessJson:Pn,ZodError:V}),Dt=class Mt extends In{constructor(t){super(t);p(this,"openAPIRegistry");p(this,"defaultHook");p(this,"openapi",({middleware:t,...n},s,a=this.defaultHook)=>{var u,d,h,T,S,E;this.openAPIRegistry.registerPath(n);const i=[];if((u=n.request)!=null&&u.query){const b=_e("query",n.request.query,a);i.push(b)}if((d=n.request)!=null&&d.params){const b=_e("param",n.request.params,a);i.push(b)}if((h=n.request)!=null&&h.headers){const b=_e("header",n.request.headers,a);i.push(b)}if((T=n.request)!=null&&T.cookies){const b=_e("cookie",n.request.cookies,a);i.push(b)}const o=(E=(S=n.request)==null?void 0:S.body)==null?void 0:E.content;if(o)for(const b of Object.keys(o)){if(!o[b])continue;const A=o[b].schema;if(A instanceof k){if(b.startsWith("application/json")){const M=_e("json",A,a);i.push(M)}if(b.startsWith("multipart/form-data")||b.startsWith("application/x-www-form-urlencoded")){const M=_e("form",A,a);i.push(M)}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...i,s),this});p(this,"getOpenAPIDocument",t=>new Gr(this.openAPIRegistry.definitions).generateDocument(t));p(this,"getOpenAPI31Document",t=>new Qr(this.openAPIRegistry.definitions).generateDocument(t));p(this,"doc",(t,n)=>this.get(t,s=>{const a=typeof n=="function"?n(s):n;try{const i=this.getOpenAPIDocument(a);return s.json(i)}catch(i){return s.json(i,500)}}));p(this,"doc31",(t,n)=>this.get(t,s=>{const a=typeof n=="function"?n(s):n;try{const i=this.getOpenAPI31Document(a);return s.json(i)}catch(i){return s.json(i,500)}}));this.openAPIRegistry=new Sr,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Mt?(n.openAPIRegistry.definitions.forEach(a=>{switch(a.type){case"component":return this.openAPIRegistry.registerComponent(a.componentType,a.name,a.component);case"route":return this.openAPIRegistry.registerPath({...a.route,path:he(s,a.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...a.webhook,path:he(s,a.webhook.path)});case"schema":return this.openAPIRegistry.register(a.schema._def.openapi._internal.refId,a.schema);case"parameter":return this.openAPIRegistry.registerParameter(a.schema._def.openapi._internal.refId,a.schema);default:{const i=a;throw new Error(`Unknown registry type: ${i}`)}}}),this):this}basePath(t){return new Mt({...super.basePath(t),defaultHook:this.defaultHook})}},Gt=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};Tr(O);const As=O.object({alg:O.string(),e:O.string(),kid:O.string(),kty:O.string(),n:O.string(),use:O.string().optional()}),Ns=O.object({keys:O.array(As)}),Kt=O.object({issuer:O.string(),authorization_endpoint:O.string(),token_endpoint:O.string(),device_authorization_endpoint:O.string(),userinfo_endpoint:O.string(),mfa_challenge_endpoint:O.string(),jwks_uri:O.string(),registration_endpoint:O.string(),revocation_endpoint:O.string(),scopes_supported:O.array(O.string()),response_types_supported:O.array(O.string()),code_challenge_methods_supported:O.array(O.string()),response_modes_supported:O.array(O.string()),subject_types_supported:O.array(O.string()),id_token_signing_alg_values_supported:O.array(O.string()),token_endpoint_auth_methods_supported:O.array(O.string()),claims_supported:O.array(O.string()),request_uri_parameter_supported:O.boolean(),request_parameter_supported:O.boolean(),token_endpoint_auth_signing_alg_values_supported:O.array(O.string())}),Ds=new Dt().openapi(Gt({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Ns}},description:"List of tenants"}}}),async r=>{const{env:e}=r,t=[{alg:"RS256",e:"AQAB",kid:"hZ42TWGWLdmyKfwGVA6c2",kty:"RSA",n:"nUd-mktFZQNfVwmXufxcVcvJo6Lkb-jDuymtfQunmEhWCctOccWx9e7LX7_9uN15ZnRS7XJInPMRs9KLYdZ0GCnE2HM_QbrEoHpdkCRgyTE-KzmoaEv_AOVGE_Kg0-0ct3r9Z7aJLDVAsxXl1C9y8Gr7ZYkq0c4DyZr9VT8nQiwZQERbfxXdXw-5RLj21S_Lm-LL-AjKvry_TDBLpfUFJV18SVsM07lY_V45TwykNewRdaGLspFIeGdG5j5eByV8ifzBqvzOSptSCsmOTtW-ceWUk0FPD7g_KKzjjbzenoB0TC8mBb_4vWZlHnuGIAs2YoTFglp9uNu7t_OVl3Svo6ZE6alzUnaNfZNeAi78KPHYQ4tDWPjpYNfGynsiD0nojkDSPCIak56jWNYjj614cPEBiv9MVQRiSbBxpiGhMoHlW_QCCPMcXygLAaRs_tUksqoH4QB80krifG2yHPgGDPjXK1_0cYzV80iOcQIeoceqhkSSc6YxzzgDrQcsV2k3bizRQSL83GWkpdHhTZn-Q_JzsW_bDY_f9fjigYbRnoDSgS7038VFIPc92StE41MdgvIQMomcyEE4lYK1uv1Mo6cnXbCZhm8tvddo7VKNorOB4nsiv8DGrWPlzQBca9VN4C1oE2mH-3WLFR7XEkBHWVouOdTWM2S3K9F10YtahkM"}];return r.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})}).openapi(Gt({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Kt}},description:"List of tenants"}}}),async r=>{const{env:e}=r,{ISSUER:t}=e,n=Kt.parse({issuer:t,authorization_endpoint:`${t}authorize`,token_endpoint:`${t}oauth/token`,device_authorization_endpoint:`${t}oauth/device/code`,userinfo_endpoint:`${t}userinfo`,mfa_challenge_endpoint:`${t}mfa/challenge`,jwks_uri:`${t}.well-known/jwks.json`,registration_endpoint:`${t}oidc/register`,revocation_endpoint:`${t}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return r.json(n,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})});function Ms(){const r=new Dt;r.get("/",t=>t.text("Hello, authhero!"));const e=new Dt().route("/.well-known",Ds);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),r.route("/",e),r}exports.init=Ms;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var authhero=function(I){"use strict";var Ps=Object.defineProperty;var xr=I=>{throw TypeError(I)};var Zs=(I,C,v)=>C in I?Ps(I,C,{enumerable:!0,configurable:!0,writable:!0,value:v}):I[C]=v;var m=(I,C,v)=>Zs(I,typeof C!="symbol"?C+"":C,v),kr=(I,C,v)=>C.has(I)||xr("Cannot "+v);var f=(I,C,v)=>(kr(I,C,"read from private field"),v?v.call(I):C.get(I)),$=(I,C,v)=>C.has(I)?xr("Cannot add the same private member more than once"):C instanceof WeakSet?C.add(I):C.set(I,v),R=(I,C,v,ut)=>(kr(I,C,"write to private field"),ut?ut.call(I,v):C.set(I,v),v);var Ee,F,_r,st,at,le,ve,ne,A,N,G,se,it,Se,Ce,ot,ct,br,K,wr;function C(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}typeof SuppressedError=="function"&&SuppressedError;function v(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ut(r){return"_def"in r}function Ze(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function Or(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,a){var i,o,c,u,d,h;const T=typeof s=="string"?a:s,S=T??{},{param:E}=S,w=C(S,["param"]),D=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),L=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),w),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||E?{param:Object.assign(Object.assign({},(h=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||h===void 0?void 0:h.param),E)}:void 0),z=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(D).length>0?{_internal:D}:void 0),Object.keys(L).length>0?{metadata:L}:void 0)}));if(v(this,"ZodObject")){const Y=this.extend;z.extend=function(...Ie){var he,ae,ee,Pe,ye,$t;const Lt=Y.apply(this,Ie);return Lt._def.openapi={_internal:{extendedFrom:!((ae=(he=this._def.openapi)===null||he===void 0?void 0:he._internal)===null||ae===void 0)&&ae.refId?{refId:(Pe=(ee=this._def.openapi)===null||ee===void 0?void 0:ee._internal)===null||Pe===void 0?void 0:Pe.refId,schema:this}:(ye=this._def.openapi)===null||ye===void 0?void 0:ye._internal.extendedFrom},metadata:($t=Lt._def.openapi)===null||$t===void 0?void 0:$t.metadata},Lt}}return z},Ze(r,"optional"),Ze(r,"nullable"),Ze(r,"default"),Ze(r,"transform"),Ze(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,c])=>{var u,d;c._def.openapi=(d=(u=s[o])===null||u===void 0?void 0:u._def)===null||d===void 0?void 0:d.openapi}),a._def.openapi=void 0,a};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const a=n.apply(this,s);return a._def.openapi=void 0,a}}function dt(r,e){if(r==null||e===null||e===void 0)return r===e;if(r===e||r.valueOf()===e.valueOf())return!0;if(Array.isArray(r)&&(!Array.isArray(e)||r.length!==e.length)||!(r instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(r);return Object.keys(e).every(n=>t.indexOf(n)!==-1)&&t.every(n=>dt(r[n],e[n]))}class Tr{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n){this.buckets.set(t,[e]);return}n.some(a=>dt(a,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>dt(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const a of this.buckets.values())e+=1,t+=a.length,a.length>1&&(n+=1);const s=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:s}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)t^=this.hashCodeOf(e[n])*n;return t}if(typeof e=="string"){for(let n=0;n<e.length;n++)t^=e.charCodeAt(n)*n;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[n,s]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(s??"");return t}}function Ae(r){return r==null}function Ne(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function jr(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(a=>a===n)||(t[n]=s)}),t}function _e(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function Ut(r){return r.filter(e=>!Ae(e))}const jt=dt;function Rr(r){const e=new Tr;return r.forEach(t=>e.put(t)),[...e.values()]}function Ht(r){return typeof r=="string"}class Er{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,s,a;const i=this.schemaWithRefId(e,t),o=(n=i._def.openapi)===null||n===void 0?void 0:n.metadata,c=i.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(a=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&a!==void 0?a:e})}));return this._definitions.push({type:"parameter",schema:c}),c}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:"component",componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class lt{constructor(e){this.message=e}}class De extends lt{constructor(e,t){super(e),this.data=t}}class ht extends lt{constructor(e){super(`Missing parameter data, please specify \`${e.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`ZodSchema.openapi\``),this.data=e}}function Me(r,e){try{return r()}catch(t){throw t instanceof ht?new ht(Object.assign(Object.assign({},t.data),e)):t}}class Sr extends lt{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class P{static getMetadata(e){var t;const n=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:n._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:a},s==null?void 0:s.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),n=e._def.openapi?e._def.openapi:t._def.openapi;return n==null?void 0:n._internal}static getParamMetadata(e){var t,n;const s=this.unwrapChained(e),a=e._def.openapi?e._def.openapi:s._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:a==null?void 0:a._internal,metadata:Object.assign(Object.assign({},a==null?void 0:a.metadata),{param:Object.assign({description:i},(n=a==null?void 0:a.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return _e(jr(e,["param"]),Ae)}static buildParameterMetadata(e){return _e(e,Ae)}static applySchemaMetadata(e,t){return _e(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Ae)}static getRefId(e){var t;return(t=this.getInternalMetadata(e))===null||t===void 0?void 0:t.refId}static unwrapChained(e){return this.unwrapUntil(e)}static getDefaultValue(e){const t=this.unwrapUntil(e,"ZodDefault");return t==null?void 0:t._def.defaultValue()}static unwrapUntil(e,t){return t&&v(e,t)?e:v(e,"ZodOptional")||v(e,"ZodNullable")||v(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):v(e,"ZodDefault")||v(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):v(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):v(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return v(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class Cr{transform(e,t,n){var s,a;const i=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(i),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(a=e._def.maxLength)===null||a===void 0?void 0:a.value})}}class Ir{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class Pr{transform(e,t,n,s,a){const i=[...e.options.values()],o=i.map(s);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(i,e.discriminator,a)}}mapDiscriminator(e,t,n){if(e.some(a=>P.getRefId(a)===void 0))return;const s={};return e.forEach(a=>{var i;const o=P.getRefId(a),c=(i=a.shape)===null||i===void 0?void 0:i[t];if(v(c,"ZodEnum")||v(c,"ZodNativeEnum")){Object.values(c.enum).filter(Ht).forEach(h=>{s[h]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=n(o)}),{propertyName:t,mapping:s}}}class Zr{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class Ar{transform(e,t,n,s){const i={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([i],t)}:i}flattenIntersectionTypes(e){if(!v(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class Nr{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function Dr(r){const t=Object.keys(r).filter(a=>typeof r[r[a]]!="number").map(a=>r[a]),n=t.filter(a=>typeof a=="number").length,s=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:s}}class Mr{transform(e,t){const{type:n,values:s}=Dr(e._def.values);if(n==="mixed")throw new lt("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:s})}}class $r{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class Lr{transform(e,t,n,s){var a;const i=(a=P.getInternalMetadata(e))===null||a===void 0?void 0:a.extendedFrom,o=this.requiredKeysOf(e),c=Ne(e._def.shape(),s);if(!i)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=i.schema;s(u);const d=this.requiredKeysOf(u),h=Ne(u==null?void 0:u._def.shape(),s),T=Object.fromEntries(Object.entries(c).filter(([w,D])=>!jt(h[w],D))),S=o.filter(w=>!d.includes(w)),E=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:T}),S.length>0?{required:S}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${i.refId}`},E]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return v(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!P.isOptionalSchema(n)).map(([t,n])=>t)}}class Vr{transform(e,t,n){const s=e._def.valueType,a=e._def.keyType,i=n(s);if(v(a,"ZodEnum")||v(a,"ZodNativeEnum")){const c=Object.values(a.enum).filter(Ht).reduce((u,d)=>Object.assign(Object.assign({},u),{[d]:i}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:i})}}class Ur{transform(e,t){var n,s,a;const i=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(a=e.maxLength)!==null&&a!==void 0?a:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:i==null?void 0:i.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time"}getZodStringCheck(e,t){return e._def.checks.find(n=>n.kind===t)}}class Hr{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:s}=e._def,a=s.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(a))}}class qr{transform(e,t,n){const a=this.flattenUnionTypes(e).map(i=>{const o=this.unwrapNullable(i);return n(o)});return{anyOf:t(a)}}flattenUnionTypes(e){return v(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return v(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Wr{constructor(e){this.versionSpecifics=e,this.objectTransformer=new Lr,this.stringTransformer=new Ur,this.numberTransformer=new $r,this.bigIntTransformer=new Ir,this.literalTransformer=new Nr,this.enumTransformer=new Zr,this.nativeEnumTransformer=new Mr,this.arrayTransformer=new Cr,this.unionTransformer=new qr,this.discriminatedUnionTransformer=new Pr,this.intersectionTransformer=new Ar,this.recordTransformer=new Vr,this.tupleTransformer=new Hr(e)}transform(e,t,n,s,a){if(v(e,"ZodNull"))return this.versionSpecifics.nullType;if(v(e,"ZodUnknown")||v(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(v(e,"ZodObject"))return this.objectTransformer.transform(e,a,o=>this.versionSpecifics.mapNullableType(o,t),n);const i=this.transformSchemaWithoutDefault(e,t,n,s);return Object.assign(Object.assign({},i),{default:a})}transformSchemaWithoutDefault(e,t,n,s){if(v(e,"ZodUnknown")||v(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(v(e,"ZodString"))return this.stringTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(v(e,"ZodNumber"))return this.numberTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),i=>this.versionSpecifics.getNumberChecks(i));if(v(e,"ZodBigInt"))return this.bigIntTransformer.transform(i=>this.versionSpecifics.mapNullableType(i,t));if(v(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(v(e,"ZodLiteral"))return this.literalTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(v(e,"ZodEnum"))return this.enumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(v(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(v(e,"ZodArray"))return this.arrayTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),n);if(v(e,"ZodTuple"))return this.tupleTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),n);if(v(e,"ZodUnion"))return this.unionTransformer.transform(e,i=>this.versionSpecifics.mapNullableOfArray(i,t),n);if(v(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),n,s);if(v(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),n);if(v(e,"ZodRecord"))return this.recordTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),n);if(v(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const a=P.getRefId(e);throw new Sr({currentSchema:e._def,schemaName:a})}}class qt{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Wr(t),this.sortDefinitions()}generateDocumentData(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents(),paths:this.pathRefs}}generateComponents(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents()}}buildComponents(){var e,t;const n={};return this.rawComponents.forEach(({componentType:s,name:a,component:i})=>{var o;(o=n[s])!==null&&o!==void 0||(n[s]={}),n[s][a]=i}),Object.assign(Object.assign({},n),{schemas:Object.assign(Object.assign({},(e=n.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=n.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,n)=>{if(!("type"in t))return"type"in n?-1:0;if(!("type"in n))return 1;const s=e.findIndex(i=>i===t.type),a=e.findIndex(i=>i===n.type);return s-a})}generateSingle(e){if(!("type"in e)){this.generateSchemaWithRef(e);return}switch(e.type){case"parameter":this.generateParameterDefinition(e.schema);return;case"schema":this.generateSchemaWithRef(e.schema);return;case"route":this.generateSingleRoute(e.route);return;case"component":this.rawComponents.push(e);return}}generateParameterDefinition(e){const t=P.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,s,a,i,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(a=e._internal)===null||a===void 0?void 0:a.refId]:void 0;if(!(!(!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new De(`Conflicting location for parameter ${u.name}`,{key:"in",values:Ut([u.in,t==null?void 0:t.in,c==null?void 0:c.in])});if(c&&u.name!==c.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new De("Conflicting names for parameter",{key:"name",values:Ut([u.name,t==null?void 0:t.name,c==null?void 0:c.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var n;const s=P.getMetadata(e),a=(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param,i=this.getParameterRef(s,{in:t});if(i)return[i];if(v(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,d])=>{var h,T;const S=P.getMetadata(d),E=this.getParameterRef(S,{in:t,name:u});if(E)return E;const w=(h=S==null?void 0:S.metadata)===null||h===void 0?void 0:h.param;if(w!=null&&w.name&&w.name!==u)throw new De("Conflicting names for parameter",{key:"name",values:[u,w.name]});if(w!=null&&w.in&&w.in!==t)throw new De(`Conflicting location for parameter ${(T=w.name)!==null&&T!==void 0?T:u}`,{key:"in",values:[t,w.in]});return this.generateParameter(d.openapi({param:{name:u,in:t}}))})}if(a!=null&&a.in&&a.in!==t)throw new De(`Conflicting location for parameter ${a.name}`,{key:"in",values:[t,a.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=P.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,a=!P.isOptionalSchema(e)&&!e.isNullable(),i=this.generateSchemaWithRef(e);return Object.assign({schema:i,required:a},s?P.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=P.getMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,a=s==null?void 0:s.name,i=s==null?void 0:s.in;if(!a)throw new ht({missingField:"name"});if(!i)throw new ht({missingField:"in",paramName:a});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:i,name:a})}generateSchemaWithMetadata(e){var t;const n=P.unwrapChained(e),s=P.getMetadata(e),a=P.getDefaultValue(e),i=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),a);return s!=null&&s.metadata?P.applySchemaMetadata(i,s.metadata):_e(i,Ae)}constructReferencedOpenAPISchema(e){var t;const n=P.getMetadata(e),s=P.unwrapChained(e),a=P.getDefaultValue(e),i=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,i):this.toOpenAPISchema(s,i,a)}generateSimpleSchema(e){var t;const n=P.getMetadata(e),s=P.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const a=this.schemaRefs[s],i={$ref:this.generateSchemaRef(s)},o=_e(P.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(d,h)=>d===void 0||jt(d,a[h]));if(o.type)return{allOf:[i,o]};const c=_e(this.constructReferencedOpenAPISchema(e),(d,h)=>d===void 0||jt(d,a[h])),u=P.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[i,u]}:i}generateSchemaWithRef(e){const t=P.getRefId(e),n=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=n,{$ref:this.generateSchemaRef(t)}):n}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,n=C(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),s=this.cleanParameter(e.params),a=this.cleanParameter(e.cookies),i=Me(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=Me(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=Me(()=>a?this.generateInlineParameters(a,"cookie"):[],{location:"cookie"}),u=Me(()=>{if(Array.isArray(t))return t.flatMap(h=>this.generateInlineParameters(h,"header"));const d=this.cleanParameter(t);return d?this.generateInlineParameters(d,"header"):[]},{location:"header"});return[...o,...i,...u,...c]}cleanParameter(e){if(e)return v(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:a}=e,i=C(e,["method","path","request","responses"]),o=Ne(a,h=>this.getResponse(h)),c=Me(()=>this.getParameters(s),{route:`${t} ${n}`}),u=this.getRequestBody(s==null?void 0:s.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},i),c.length>0?{parameters:[...i.parameters||[],...c]}:{}),u?{requestBody:u}:{}),{responses:o})}}generateSingleRoute(e){const t=this.generatePath(e);return this.pathRefs[e.path]=Object.assign(Object.assign({},this.pathRefs[e.path]),t),t}getResponse(e){var{content:t,headers:n}=e,s=C(e,["content","headers"]);const a=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),a);const i=v(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},s),{headers:i}),a)}getResponseHeaders(e){const t=e._def.shape();return Ne(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return Ne(e,t=>{if(!t||!ut(t.schema))return t;const{schema:n}=t,s=C(t,["schema"]),a=this.generateSchemaWithRef(n);return Object.assign({schema:a},s)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),n)}}class Br{get nullType(){return{nullable:!0}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return Object.assign(Object.assign({},e?{type:e}:void 0),t?this.nullType:void 0)}mapTupleItems(e){const t=Rr(e);return{items:t.length===1?t[0]:{anyOf:t},minItems:e.length,maxItems:e.length}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{minimum:Number(t.value),exclusiveMinimum:!0};case"max":return t.inclusive?{maximum:Number(t.value)}:{maximum:Number(t.value),exclusiveMaximum:!0};default:return{}}}))}}class Fr{constructor(e){const t=new Br;this.generator=new qt(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class Gr{get nullType(){return{type:"null"}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return e?t?{type:Array.isArray(e)?[...e,"null"]:[e,"null"]}:{type:e}:{}}mapTupleItems(e){return{prefixItems:e}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{exclusiveMinimum:Number(t.value)};case"max":return t.inclusive?{maximum:Number(t.value)}:{exclusiveMaximum:Number(t.value)};default:return{}}}))}}function Kr(r){return"type"in r&&r.type==="webhook"}class Yr{constructor(e){this.definitions=e,this.webhookRefs={};const t=new Gr;this.generator=new qt(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(Kr).forEach(n=>this.generateSingleWebhook(n.webhook)),Object.assign(Object.assign(Object.assign({},e),t),{webhooks:this.webhookRefs})}generateComponents(){return this.generator.generateComponents()}generateSingleWebhook(e){const t=this.generator.generatePath(e);return this.webhookRefs[e.path]=Object.assign(Object.assign({},this.webhookRefs[e.path]),t),t}}var Wt=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},Qr=r=>{const{groups:e,path:t}=Jr(r),n=Wt(t);return Xr(n,e)},Jr=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},Xr=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let s=r.length-1;s>=0;s--)if(r[s].includes(n)){r[s]=r[s].replace(n,e[t][1]);break}}return r},ft={},Bt=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(ft[r]||(e[2]?ft[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:ft[r]=[r,e[1],!0]),ft[r]):null},zr=r=>{try{return decodeURI(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURI(e)}catch{return e}})}},Ft=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const s=e.charCodeAt(n);if(s===37){const a=e.indexOf("?",n),i=e.slice(t,a===-1?void 0:a);return zr(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}else if(s===63)break}return e.slice(t,n)},en=r=>{const e=Ft(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},fe=(...r)=>{let e="",t=!1;for(let n of r)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),n[0]!=="/"&&(n=`/${n}`),n==="/"&&t?e=`${e}/`:n!=="/"&&(e=`${e}${n}`),n==="/"&&e===""&&(e="/");return e},Gt=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))n+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&n===""?t.push("/"):t.push(n);const a=s.replace("?","");n+="/"+a,t.push(n)}else n+="/"+s}),t.filter((s,a,i)=>i.indexOf(s)===a)},Rt=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),/%/.test(r)?pt(r):r):r,Kt=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let i=r.indexOf(`?${e}`,8);for(i===-1&&(i=r.indexOf(`&${e}`,8));i!==-1;){const o=r.charCodeAt(i+e.length+1);if(o===61){const c=i+e.length+2,u=r.indexOf("&",c);return Rt(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";i=r.indexOf(`&${e}`,i+1)}if(n=/[%+]/.test(r),!n)return}const s={};n??(n=/[%+]/.test(r));let a=r.indexOf("?",8);for(;a!==-1;){const i=r.indexOf("&",a+1);let o=r.indexOf("=",a);o>i&&i!==-1&&(o=-1);let c=r.slice(a+1,o===-1?i===-1?void 0:i:o);if(n&&(c=Rt(c)),a=i,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,i===-1?void 0:i),n&&(u=Rt(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},tn=Kt,rn=(r,e)=>Kt(r,e,!0),pt=decodeURIComponent,nn=/^[\w!#$%&'*.^`|~+-]+$/,sn=/^[ !#-:<-[\]-~]*$/,an=(r,e)=>r.trim().split(";").reduce((n,s)=>{s=s.trim();const a=s.indexOf("=");if(a===-1)return n;const i=s.substring(0,a).trim();if(!nn.test(i))return n;let o=s.substring(a+1).trim();return o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),sn.test(o)&&(n[i]=pt(o)),n},{}),on=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?an(n):{}},Et=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});m(this,"res");m(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},cn=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),un=(r,e)=>async(t,n)=>{let s={};const a=t.req.header("Content-Type");switch(r){case"json":if(!a||!/^application\/([a-z-\.]+\+)?json/.test(a)){const o=`Invalid HTTP header: Content-Type=${a}`;throw new Et(400,{message:o})}try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new Et(400,{message:o})}break;case"form":{if(!a)break;if(t.req.bodyCache.formData){s=await t.req.bodyCache.formData;break}try{const o=await t.req.arrayBuffer(),c=await cn(o,a),u={};c.forEach((d,h)=>{h.endsWith("[]")?u[h]===void 0?u[h]=[d]:Array.isArray(u[h])&&u[h].push(d):u[h]=d}),s=u,t.req.bodyCache.formData=c}catch(o){let c="Malformed FormData request.";throw c+=o instanceof Error?` ${o.message}`:` ${String(o)}`,new Et(400,{message:c})}break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=on(t);break}const i=await e(s,t);if(i instanceof Response)return i;t.req.addValidatedData(r,i),await n()};const be=(r,e,t)=>un(r,async(n,s)=>{const a=await e.safeParseAsync(n);if(t){const i=await t({data:n,...a},s);if(i){if(i instanceof Response)return i;if("response"in i)return i.response}}return a.success?a.data:s.json(a,400)});var dn=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,a=(r instanceof Yt?r.raw.headers:r.headers).get("Content-Type");return a!==null&&a.startsWith("multipart/form-data")||a!==null&&a.startsWith("application/x-www-form-urlencoded")?ln(r,{all:t,dot:n}):{}};async function ln(r,e){const t=await r.formData();return t?hn(t,e):{}}function hn(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?fn(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(pn(t,n,s),delete t[n])}),t}var fn=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},pn=(r,e,t)=>{let n=r;const s=e.split(".");s.forEach((a,i)=>{i===s.length-1?n[a]=t:((!n[a]||typeof n[a]!="object"||Array.isArray(n[a])||n[a]instanceof File)&&(n[a]=Object.create(null)),n=n[a])})},Yt=(_r=class{constructor(r,e="/",t=[[]]){m(this,"raw");$(this,Ee);$(this,F);m(this,"routeIndex",0);m(this,"path");m(this,"bodyCache",{});m(this,"cachedBody",r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const s=Object.keys(e)[0];return s?e[s].then(a=>(s==="json"&&(a=JSON.stringify(a)),new Response(a)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,R(this,F,t),R(this,Ee,{})}param(r){return r?this.getDecodedParam(r):this.getAllDecodedParams()}getDecodedParam(r){const e=f(this,F)[0][this.routeIndex][1][r],t=this.getParamValue(e);return t?/\%/.test(t)?pt(t):t:void 0}getAllDecodedParams(){const r={},e=Object.keys(f(this,F)[0][this.routeIndex][1]);for(const t of e){const n=this.getParamValue(f(this,F)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?pt(n):n)}return r}getParamValue(r){return f(this,F)[1]?f(this,F)[1][r]:r}query(r){return tn(this.url,r)}queries(r){return rn(this.url,r)}header(r){if(r)return this.raw.headers.get(r.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,n)=>{e[n]=t}),e}async parseBody(r){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await dn(this,r))}json(){return this.cachedBody("json")}text(){return this.cachedBody("text")}arrayBuffer(){return this.cachedBody("arrayBuffer")}blob(){return this.cachedBody("blob")}formData(){return this.cachedBody("formData")}addValidatedData(r,e){f(this,Ee)[r]=e}valid(r){return f(this,Ee)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return f(this,F)[0].map(([[,r]])=>r)}get routePath(){return f(this,F)[0].map(([[,r]])=>r)[this.routeIndex].path}},Ee=new WeakMap,F=new WeakMap,_r),mn={Stringify:1,BeforeStream:2,Stream:3},Qt=async(r,e,t,n,s)=>{const a=r.callbacks;return a!=null&&a.length?(s?s[0]+=r:s=[r],Promise.all(a.map(o=>o({phase:e,buffer:s,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Qt(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},gn="text/plain; charset=UTF-8",St=(r,e={})=>(Object.entries(e).forEach(([t,n])=>r.set(t,n)),r),mt=(br=class{constructor(r,e){$(this,st);$(this,at);m(this,"env",{});$(this,le);m(this,"finalized",!1);m(this,"error");$(this,ve,200);$(this,ne);$(this,A);$(this,N);$(this,G);$(this,se,!0);$(this,it);$(this,Se);$(this,Ce);$(this,ot);$(this,ct);m(this,"render",(...r)=>(f(this,Se)??R(this,Se,e=>this.html(e)),f(this,Se).call(this,...r)));m(this,"setLayout",r=>R(this,it,r));m(this,"getLayout",()=>f(this,it));m(this,"setRenderer",r=>{R(this,Se,r)});m(this,"header",(r,e,t)=>{if(e===void 0){f(this,A)?f(this,A).delete(r):f(this,N)&&delete f(this,N)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(f(this,A)||(R(this,se,!1),R(this,A,new Headers(f(this,N))),R(this,N,{})),f(this,A).append(r,e)):f(this,A)?f(this,A).set(r,e):(f(this,N)??R(this,N,{}),f(this,N)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});m(this,"status",r=>{R(this,se,!1),R(this,ve,r)});m(this,"set",(r,e)=>{f(this,le)??R(this,le,{}),f(this,le)[r]=e});m(this,"get",r=>f(this,le)?f(this,le)[r]:void 0);m(this,"newResponse",(r,e,t)=>{if(f(this,se)&&!t&&!e&&f(this,ve)===200)return new Response(r,{headers:f(this,N)});if(e&&typeof e!="number"){const s=new Headers(e.headers);f(this,A)&&f(this,A).forEach((i,o)=>{o==="set-cookie"?s.append(o,i):s.set(o,i)});const a=St(s,f(this,N));return new Response(r,{headers:a,status:e.status??f(this,ve)})}const n=typeof e=="number"?e:f(this,ve);f(this,N)??R(this,N,{}),f(this,A)??R(this,A,new Headers),St(f(this,A),f(this,N)),f(this,G)&&(f(this,G).headers.forEach((s,a)=>{var i,o;a==="set-cookie"?(i=f(this,A))==null||i.append(a,s):(o=f(this,A))==null||o.set(a,s)}),St(f(this,A),f(this,N))),t??(t={});for(const[s,a]of Object.entries(t))if(typeof a=="string")f(this,A).set(s,a);else{f(this,A).delete(s);for(const i of a)f(this,A).append(s,i)}return new Response(r,{status:n,headers:f(this,A)})});m(this,"body",(r,e,t)=>typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e));m(this,"text",(r,e,t)=>{if(!f(this,N)){if(f(this,se)&&!t&&!e)return new Response(r);R(this,N,{})}return f(this,N)["content-type"]=gn,typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)});m(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return f(this,N)??R(this,N,{}),f(this,N)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)});m(this,"html",(r,e,t)=>(f(this,N)??R(this,N,{}),f(this,N)["content-type"]="text/html; charset=UTF-8",typeof r=="object"&&(r instanceof Promise||(r=r.toString()),r instanceof Promise)?r.then(n=>Qt(n,mn.Stringify,!1,{})).then(n=>typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)):typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)));m(this,"redirect",(r,e)=>(f(this,A)??R(this,A,new Headers),f(this,A).set("Location",r),this.newResponse(null,e??302)));m(this,"notFound",()=>(f(this,Ce)??R(this,Ce,()=>new Response),f(this,Ce).call(this,this)));R(this,st,r),e&&(R(this,ne,e.executionCtx),this.env=e.env,R(this,Ce,e.notFoundHandler),R(this,ct,e.path),R(this,ot,e.matchResult))}get req(){return f(this,at)??R(this,at,new Yt(f(this,st),f(this,ct),f(this,ot))),f(this,at)}get event(){if(f(this,ne)&&"respondWith"in f(this,ne))return f(this,ne);throw Error("This context has no FetchEvent")}get executionCtx(){if(f(this,ne))return f(this,ne);throw Error("This context has no ExecutionContext")}get res(){return R(this,se,!1),f(this,G)||R(this,G,new Response("404 Not Found",{status:404}))}set res(r){if(R(this,se,!1),f(this,G)&&r){f(this,G).headers.delete("content-type");for(const[e,t]of f(this,G).headers.entries())if(e==="set-cookie"){const n=f(this,G).headers.getSetCookie();r.headers.delete("set-cookie");for(const s of n)r.headers.append("set-cookie",s)}else r.headers.set(e,t)}R(this,G,r),this.finalized=!0}get var(){return{...f(this,le)}}},st=new WeakMap,at=new WeakMap,le=new WeakMap,ve=new WeakMap,ne=new WeakMap,A=new WeakMap,N=new WeakMap,G=new WeakMap,se=new WeakMap,it=new WeakMap,Se=new WeakMap,Ce=new WeakMap,ot=new WeakMap,ct=new WeakMap,br),Jt=(r,e,t)=>(n,s)=>{let a=-1;return i(0);async function i(o){if(o<=a)throw new Error("next() called multiple times");a=o;let c,u=!1,d;if(r[o]?(d=r[o][0][0],n instanceof mt&&(n.req.routeIndex=o)):d=o===r.length&&s||void 0,!d)n instanceof mt&&n.finalized===!1&&t&&(c=await t(n));else try{c=await d(n,()=>i(o+1))}catch(h){if(h instanceof Error&&n instanceof mt&&e)n.error=h,c=await e(h,n),u=!0;else throw h}return c&&(n.finalized===!1||u)&&(n.res=c),n}},M="ALL",vn="all",yn=["get","post","put","delete","options","patch"],Xt="Can not add a route since the matcher is already built.",zt=class extends Error{},_n=Symbol("composedHandler"),bn=r=>r.text("404 Not Found",404),er=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),tr=(wr=class{constructor(e={}){m(this,"get");m(this,"post");m(this,"put");m(this,"delete");m(this,"options");m(this,"patch");m(this,"all");m(this,"on");m(this,"use");m(this,"router");m(this,"getPath");m(this,"_basePath","/");$(this,K,"/");m(this,"routes",[]);m(this,"notFoundHandler",bn);m(this,"errorHandler",er);m(this,"onError",e=>(this.errorHandler=e,this));m(this,"notFound",e=>(this.notFoundHandler=e,this));m(this,"fetch",(e,...t)=>this.dispatch(e,t[1],t[0],e.method));m(this,"request",(e,t,n,s)=>{if(e instanceof Request)return t!==void 0&&(e=new Request(e,t)),this.fetch(e,n,s);e=e.toString();const a=/^https?:\/\//.test(e)?e:`http://localhost${fe("/",e)}`,i=new Request(a,t);return this.fetch(i,n,s)});m(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(this.dispatch(e.request,e,void 0,e.request.method))})});[...yn,vn].forEach(s=>{this[s]=(a,...i)=>(typeof a=="string"?R(this,K,a):this.addRoute(s,f(this,K),a),i.forEach(o=>{typeof o!="string"&&this.addRoute(s,f(this,K),o)}),this)}),this.on=(s,a,...i)=>{for(const o of[a].flat()){R(this,K,o);for(const c of[s].flat())i.map(u=>{this.addRoute(c.toUpperCase(),f(this,K),u)})}return this},this.use=(s,...a)=>(typeof s=="string"?R(this,K,s):(R(this,K,"*"),a.unshift(s)),a.forEach(i=>{this.addRoute(M,f(this,K),i)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??Ft:en}clone(){const e=new tr({router:this.router,getPath:this.getPath});return e.routes=this.routes,e}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{let a;t.errorHandler===er?a=s.handler:(a=async(i,o)=>(await Jt([],t.errorHandler)(i,()=>s.handler(i,o))).res,a[_n]=s.handler),n.addRoute(s.method,s.path,a)}),this}basePath(e){const t=this.clone();return t._basePath=fe(this._basePath,e),t}mount(e,t,n){let s,a;n&&(typeof n=="function"?a=n:(a=n.optionHandler,s=n.replaceRequest));const i=a?c=>{const u=a(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};s||(s=(()=>{const c=fe(this._basePath,e),u=c==="/"?0:c.length;return d=>{const h=new URL(d.url);return h.pathname=h.pathname.slice(u)||"/",new Request(h,d)}})());const o=async(c,u)=>{const d=await t(s(c.req.raw),...i(c));if(d)return d;await u()};return this.addRoute(M,fe(e,"*"),o),this}addRoute(e,t,n){e=e.toUpperCase(),t=fe(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)}matchRoute(e,t){return this.router.match(e,t)}handleError(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}dispatch(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await this.dispatch(e,t,n,"GET")))();const a=this.getPath(e,{env:n}),i=this.matchRoute(s,a),o=new mt(e,{path:a,matchResult:i,env:n,executionCtx:t,notFoundHandler:this.notFoundHandler});if(i[0].length===1){let u;try{u=i[0][0][0][0](o,async()=>{o.res=await this.notFoundHandler(o)})}catch(d){return this.handleError(d,o)}return u instanceof Promise?u.then(d=>d||(o.finalized?o.res:this.notFoundHandler(o))).catch(d=>this.handleError(d,o)):u??this.notFoundHandler(o)}const c=Jt(i[0],this.errorHandler,this.notFoundHandler);return(async()=>{try{const u=await c(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.handleError(u,o)}})()}},K=new WeakMap,wr),gt="[^/]+",$e=".*",Le="(?:|/.*)",Ve=Symbol(),wn=new Set(".\\+*[^]$()");function xn(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$e||r===Le?1:e===$e||e===Le?-1:r===gt?1:e===gt?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Ct=class{constructor(){m(this,"index");m(this,"varIndex");m(this,"children",Object.create(null))}insert(e,t,n,s,a){if(e.length===0){if(this.index!==void 0)throw Ve;if(a)return;this.index=t;return}const[i,...o]=e,c=i==="*"?o.length===0?["","",$e]:["","",gt]:i==="/*"?["","",Le]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const d=c[1];let h=c[2]||gt;if(d&&c[2]&&(h=h.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(h)))throw Ve;if(u=this.children[h],!u){if(Object.keys(this.children).some(T=>T!==$e&&T!==Le))throw Ve;if(a)return;u=this.children[h]=new Ct,d!==""&&(u.varIndex=s.varIndex++)}!a&&d!==""&&n.push([d,u.varIndex])}else if(u=this.children[i],!u){if(Object.keys(this.children).some(d=>d.length>1&&d!==$e&&d!==Le))throw Ve;if(a)return;u=this.children[i]=new Ct}u.insert(o,t,n,s,a)}buildRegExpStr(){const t=Object.keys(this.children).sort(xn).map(n=>{const s=this.children[n];return(typeof s.varIndex=="number"?`(${n})@${s.varIndex}`:wn.has(n)?`\\${n}`:n)+s.buildRegExpStr()});return typeof this.index=="number"&&t.unshift(`#${this.index}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},kn=class{constructor(){m(this,"context",{varIndex:0});m(this,"root",new Ct)}insert(r,e,t){const n=[],s=[];for(let i=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${i}`;return s[i]=[u,c],i++,o=!0,u}),!o)break}const a=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=s.length-1;i>=0;i--){const[o]=s[i];for(let c=a.length-1;c>=0;c--)if(a[c].indexOf(o)!==-1){a[c]=a[c].replace(o,s[i][1]);break}}return this.root.insert(a,e,n,this.context,t),n}buildRegExp(){let r=this.root.buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,a,i)=>typeof a<"u"?(t[++e]=Number(a),"$()"):(typeof i<"u"&&(n[Number(i)]=++e),"")),[new RegExp(`^${r}`),t,n]}},rr=[],On=[/^$/,[],Object.create(null)],vt=Object.create(null);function nr(r){return vt[r]??(vt[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function Tn(){vt=Object.create(null)}function jn(r){var u;const e=new kn,t=[];if(r.length===0)return On;const n=r.map(d=>[!/\*|\/:/.test(d[0]),...d]).sort(([d,h],[T,S])=>d?1:T?-1:h.length-S.length),s=Object.create(null);for(let d=0,h=-1,T=n.length;d<T;d++){const[S,E,w]=n[d];S?s[E]=[w.map(([L])=>[L,Object.create(null)]),rr]:h++;let D;try{D=e.insert(E,h,S)}catch(L){throw L===Ve?new zt(E):L}S||(t[h]=w.map(([L,z])=>{const Y=Object.create(null);for(z-=1;z>=0;z--){const[Ie,he]=D[z];Y[Ie]=he}return[L,Y]}))}const[a,i,o]=e.buildRegExp();for(let d=0,h=t.length;d<h;d++)for(let T=0,S=t[d].length;T<S;T++){const E=(u=t[d][T])==null?void 0:u[1];if(!E)continue;const w=Object.keys(E);for(let D=0,L=w.length;D<L;D++)E[w[D]]=o[E[w[D]]]}const c=[];for(const d in i)c[d]=t[i[d]];return[a,c,s]}function we(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(nr(t).test(e))return[...r[t]]}}var Rn=class{constructor(){m(this,"name","RegExpRouter");m(this,"middleware");m(this,"routes");this.middleware={[M]:Object.create(null)},this.routes={[M]:Object.create(null)}}add(r,e,t){var o;const{middleware:n,routes:s}=this;if(!n||!s)throw new Error(Xt);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[M]).forEach(u=>{c[r][u]=[...c[M][u]]})}),e==="/*"&&(e="*");const a=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=nr(e);r===M?Object.keys(n).forEach(u=>{var d;(d=n[u])[e]||(d[e]=we(n[u],e)||we(n[M],e)||[])}):(o=n[r])[e]||(o[e]=we(n[r],e)||we(n[M],e)||[]),Object.keys(n).forEach(u=>{(r===M||r===u)&&Object.keys(n[u]).forEach(d=>{c.test(d)&&n[u][d].push([t,a])})}),Object.keys(s).forEach(u=>{(r===M||r===u)&&Object.keys(s[u]).forEach(d=>c.test(d)&&s[u][d].push([t,a]))});return}const i=Gt(e)||[e];for(let c=0,u=i.length;c<u;c++){const d=i[c];Object.keys(s).forEach(h=>{var T;(r===M||r===h)&&((T=s[h])[d]||(T[d]=[...we(n[h],d)||we(n[M],d)||[]]),s[h][d].push([t,a-u+c+1]))})}}match(r,e){Tn();const t=this.buildAllMatchers();return this.match=(n,s)=>{const a=t[n]||t[M],i=a[2][s];if(i)return i;const o=s.match(a[0]);if(!o)return[[],rr];const c=o.indexOf("",1);return[a[1][c],o]},this.match(r,e)}buildAllMatchers(){const r=Object.create(null);return[...Object.keys(this.routes),...Object.keys(this.middleware)].forEach(e=>{r[e]||(r[e]=this.buildMatcher(e))}),this.middleware=this.routes=void 0,r}buildMatcher(r){const e=[];let t=r===M;return[this.middleware,this.routes].forEach(n=>{const s=n[r]?Object.keys(n[r]).map(a=>[a,n[r][a]]):[];s.length!==0?(t||(t=!0),e.push(...s)):r!==M&&e.push(...Object.keys(n[M]).map(a=>[a,n[M][a]]))}),t?jn(e):null}},En=class{constructor(r){m(this,"name","SmartRouter");m(this,"routers",[]);m(this,"routes",[]);Object.assign(this,r)}add(r,e,t){if(!this.routes)throw new Error(Xt);this.routes.push([r,e,t])}match(r,e){if(!this.routes)throw new Error("Fatal error");const{routers:t,routes:n}=this,s=t.length;let a=0,i;for(;a<s;a++){const o=t[a];try{n.forEach(c=>{o.add(...c)}),i=o.match(r,e)}catch(c){if(c instanceof zt)continue;throw c}this.match=o.match.bind(o),this.routers=[o],this.routes=void 0;break}if(a===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.routes||this.routers.length!==1)throw new Error("No active router has been determined yet.");return this.routers[0]}},sr=class{constructor(r,e,t){m(this,"methods");m(this,"children");m(this,"patterns");m(this,"order",0);m(this,"name");m(this,"params",Object.create(null));if(this.children=t||Object.create(null),this.methods=[],this.name="",r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0,name:this.name},this.methods=[n]}this.patterns=[]}insert(r,e,t){this.name=`${r} ${e}`,this.order=++this.order;let n=this;const s=Qr(e),a=[];for(let c=0,u=s.length;c<u;c++){const d=s[c];if(Object.keys(n.children).includes(d)){n=n.children[d];const T=Bt(d);T&&a.push(T[1]);continue}n.children[d]=new sr;const h=Bt(d);h&&(n.patterns.push(h),a.push(h[1])),n=n.children[d]}n.methods.length||(n.methods=[]);const i=Object.create(null),o={handler:t,possibleKeys:a.filter((c,u,d)=>d.indexOf(c)===u),name:this.name,score:this.order};return i[r]=o,n.methods.push(i),n}gHSets(r,e,t,n){const s=[];for(let a=0,i=r.methods.length;a<i;a++){const o=r.methods[a],c=o[e]||o[M],u=Object.create(null);c!==void 0&&(c.params=Object.create(null),c.possibleKeys.forEach(d=>{const h=u[c.name];c.params[d]=n[d]&&!h?n[d]:t[d]??n[d],u[c.name]=!0}),s.push(c))}return s}search(r,e){const t=[];this.params=Object.create(null);let s=[this];const a=Wt(e);for(let o=0,c=a.length;o<c;o++){const u=a[o],d=o===c-1,h=[];for(let T=0,S=s.length;T<S;T++){const E=s[T],w=E.children[u];w&&(w.params=E.params,d===!0?(w.children["*"]&&t.push(...this.gHSets(w.children["*"],r,E.params,Object.create(null))),t.push(...this.gHSets(w,r,E.params,Object.create(null)))):h.push(w));for(let D=0,L=E.patterns.length;D<L;D++){const z=E.patterns[D],Y={...E.params};if(z==="*"){const ye=E.children["*"];ye&&(t.push(...this.gHSets(ye,r,E.params,Object.create(null))),h.push(ye));continue}if(u==="")continue;const[Ie,he,ae]=z,ee=E.children[Ie],Pe=a.slice(o).join("/");if(ae instanceof RegExp&&ae.test(Pe)){Y[he]=Pe,t.push(...this.gHSets(ee,r,E.params,Y));continue}(ae===!0||ae instanceof RegExp&&ae.test(u))&&typeof Ie=="string"&&(Y[he]=u,d===!0?(t.push(...this.gHSets(ee,r,Y,E.params)),ee.children["*"]&&t.push(...this.gHSets(ee.children["*"],r,Y,E.params))):(ee.params=Y,h.push(ee)))}}s=h}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},Sn=class{constructor(){m(this,"name","TrieRouter");m(this,"node");this.node=new sr}add(r,e,t){const n=Gt(e);if(n){for(const s of n)this.node.insert(r,s,t);return}this.node.insert(r,e,t)}match(r,e){return this.node.search(r,e)}},Cn=class extends tr{constructor(r={}){super(r),this.router=r.router??new En({routers:[new Rn,new Sn]})}},j;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(j||(j={}));var It;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(It||(It={}));const g=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ie=r=>{switch(typeof r){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(r)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(r)?g.array:r===null?g.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?g.promise:typeof Map<"u"&&r instanceof Map?g.map:typeof Set<"u"&&r instanceof Set?g.set:typeof Date<"u"&&r instanceof Date?g.date:g.object;default:return g.unknown}},l=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),In=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class H extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof H))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}H.create=r=>new H(r);const xe=(r,e)=>{let t;switch(r.code){case l.invalid_type:r.received===g.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,j.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${j.joinValues(r.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${j.joinValues(r.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${j.joinValues(r.options)}, received '${r.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:j.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case l.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case l.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,j.assertNever(r)}return{message:t}};let ar=xe;function Pn(r){ar=r}function yt(){return ar}const _t=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},Zn=[];function p(r,e){const t=yt(),n=_t({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===xe?void 0:xe].filter(s=>!!s)});r.common.issues.push(n)}class V{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return b;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return V.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return b;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const b=Object.freeze({status:"aborted"}),ke=r=>({status:"dirty",value:r}),U=r=>({status:"valid",value:r}),Pt=r=>r.status==="aborted",Zt=r=>r.status==="dirty",Ue=r=>r.status==="valid",He=r=>typeof Promise<"u"&&r instanceof Promise;function bt(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function ir(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));var qe,We;class Q{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const or=(r,e)=>{if(Ue(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new H(r.common.issues);return this._error=t,this._error}}};function x(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var c,u;const{message:d}=r;return i.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:(c=d??n)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=d??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class k{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ie(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new V,ctx:{common:e.parent.common,data:e.data,parsedType:ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(He(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ie(e)},a=this._parseSync({data:e,path:s.path,parent:s});return or(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ie(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(He(s)?s:Promise.resolve(s));return or(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:l.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new B({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return X.create(this,this._def)}nullable(){return de.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this,this._def)}promise(){return Re.create(this,this._def)}or(e){return Ke.create([this,e],this._def)}and(e){return Ye.create(this,e,this._def)}transform(e){return new B({...x(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new et({...x(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new Dt({typeName:_.ZodBranded,type:this,...x(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new tt({...x(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return rt.create(this,e)}readonly(){return nt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const An=/^c[^\s-]{8,}$/i,Nn=/^[0-9a-z]+$/,Dn=/^[0-9A-HJKMNP-TV-Z]{26}$/,Mn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,$n=/^[a-z0-9_-]{21}$/i,Ln=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Vn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Un="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let At;const Hn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,qn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Wn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,cr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Bn=new RegExp(`^${cr}$`);function ur(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Fn(r){return new RegExp(`^${ur(r)}$`)}function dr(r){let e=`${cr}T${ur(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Gn(r,e){return!!((e==="v4"||!e)&&Hn.test(r)||(e==="v6"||!e)&&qn.test(r))}class q extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const a=this._getOrReturnCtx(e);return p(a,{code:l.invalid_type,expected:g.string,received:a.parsedType}),b}const n=new V;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?p(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&p(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Vn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")At||(At=new RegExp(Un,"u")),At.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"emoji",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")$n.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"nanoid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")An.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid2",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Dn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ulid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:l.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:l.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?dr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Fn(a).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"duration",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Gn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ip",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Wn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64",code:l.invalid_string,message:a.message}),n.dirty()):j.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:l.invalid_string,...y.errToObj(n)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...y.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=r=>{var e;return new q({checks:[],typeName:_.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...x(r)})};function Kn(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class oe extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const a=this._getOrReturnCtx(e);return p(a,{code:l.invalid_type,expected:g.number,received:a.parsedType}),b}let n;const s=new V;for(const a of this._def.checks)a.kind==="int"?j.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:l.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Kn(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),p(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:l.not_finite,message:a.message}),s.dirty()):j.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,n,s){return new oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:y.toString(s)}]})}_addCheck(e){return new oe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&j.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}oe.create=r=>new oe({checks:[],typeName:_.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...x(r)});class ce extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==g.bigint){const a=this._getOrReturnCtx(e);return p(a,{code:l.invalid_type,expected:g.bigint,received:a.parsedType}),b}let n;const s=new V;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:l.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:l.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),p(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):j.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,n,s){return new ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:y.toString(s)}]})}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ce.create=r=>{var e;return new ce({checks:[],typeName:_.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...x(r)})};class Be extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const n=this._getOrReturnCtx(e);return p(n,{code:l.invalid_type,expected:g.boolean,received:n.parsedType}),b}return U(e.data)}}Be.create=r=>new Be({typeName:_.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...x(r)});class pe extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const a=this._getOrReturnCtx(e);return p(a,{code:l.invalid_type,expected:g.date,received:a.parsedType}),b}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return p(a,{code:l.invalid_date}),b}const n=new V;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:l.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):j.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new pe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}pe.create=r=>new pe({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:_.ZodDate,...x(r)});class wt extends k{_parse(e){if(this._getType(e)!==g.symbol){const n=this._getOrReturnCtx(e);return p(n,{code:l.invalid_type,expected:g.symbol,received:n.parsedType}),b}return U(e.data)}}wt.create=r=>new wt({typeName:_.ZodSymbol,...x(r)});class Fe extends k{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return p(n,{code:l.invalid_type,expected:g.undefined,received:n.parsedType}),b}return U(e.data)}}Fe.create=r=>new Fe({typeName:_.ZodUndefined,...x(r)});class Ge extends k{_parse(e){if(this._getType(e)!==g.null){const n=this._getOrReturnCtx(e);return p(n,{code:l.invalid_type,expected:g.null,received:n.parsedType}),b}return U(e.data)}}Ge.create=r=>new Ge({typeName:_.ZodNull,...x(r)});class Oe extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return U(e.data)}}Oe.create=r=>new Oe({typeName:_.ZodAny,...x(r)});class me extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return U(e.data)}}me.create=r=>new me({typeName:_.ZodUnknown,...x(r)});class te extends k{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:l.invalid_type,expected:g.never,received:t.parsedType}),b}}te.create=r=>new te({typeName:_.ZodNever,...x(r)});class xt extends k{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return p(n,{code:l.invalid_type,expected:g.void,received:n.parsedType}),b}return U(e.data)}}xt.create=r=>new xt({typeName:_.ZodVoid,...x(r)});class W extends k{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==g.array)return p(t,{code:l.invalid_type,expected:g.array,received:t.parsedType}),b;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(p(t,{code:i?l.too_big:l.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(p(t,{code:l.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(p(t,{code:l.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new Q(t,i,t.path,o)))).then(i=>V.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Q(t,i,t.path,o)));return V.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new W({...this._def,minLength:{value:e,message:y.toString(t)}})}max(e,t){return new W({...this._def,maxLength:{value:e,message:y.toString(t)}})}length(e,t){return new W({...this._def,exactLength:{value:e,message:y.toString(t)}})}nonempty(e){return this.min(1,e)}}W.create=(r,e)=>new W({type:r,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...x(e)});function Te(r){if(r instanceof Z){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=X.create(Te(n))}return new Z({...r._def,shape:()=>e})}else return r instanceof W?new W({...r._def,type:Te(r.element)}):r instanceof X?X.create(Te(r.unwrap())):r instanceof de?de.create(Te(r.unwrap())):r instanceof J?J.create(r.items.map(e=>Te(e))):r}class Z extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=j.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==g.object){const u=this._getOrReturnCtx(e);return p(u,{code:l.invalid_type,expected:g.object,received:u.parsedType}),b}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof te&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const d=a[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new Q(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof te){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of o)c.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")o.length>0&&(p(s,{code:l.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of o){const h=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new Q(s,h,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const h=await d.key,T=await d.value;u.push({key:h,value:T,alwaysSet:d.alwaysSet})}return u}).then(u=>V.mergeObjectSync(n,u)):V.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new Z({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=y.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Z({...this._def,unknownKeys:"strip"})}passthrough(){return new Z({...this._def,unknownKeys:"passthrough"})}extend(e){return new Z({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Z({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Z({...this._def,catchall:e})}pick(e){const t={};return j.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Z({...this._def,shape:()=>t})}omit(e){const t={};return j.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Z({...this._def,shape:()=>t})}deepPartial(){return Te(this)}partial(e){const t={};return j.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Z({...this._def,shape:()=>t})}required(e){const t={};return j.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof X;)a=a._def.innerType;t[n]=a}}),new Z({...this._def,shape:()=>t})}keyof(){return lr(j.objectKeys(this.shape))}}Z.create=(r,e)=>new Z({shape:()=>r,unknownKeys:"strip",catchall:te.create(),typeName:_.ZodObject,...x(e)}),Z.strictCreate=(r,e)=>new Z({shape:()=>r,unknownKeys:"strict",catchall:te.create(),typeName:_.ZodObject,...x(e)}),Z.lazycreate=(r,e)=>new Z({shape:r,unknownKeys:"strip",catchall:te.create(),typeName:_.ZodObject,...x(e)});class Ke extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new H(o.ctx.common.issues));return p(t,{code:l.invalid_union,unionErrors:i}),b}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},d=c._parseSync({data:t.data,path:t.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!a&&(a={result:d,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new H(c));return p(t,{code:l.invalid_union,unionErrors:o}),b}}get options(){return this._def.options}}Ke.create=(r,e)=>new Ke({options:r,typeName:_.ZodUnion,...x(e)});const re=r=>r instanceof Je?re(r.schema):r instanceof B?re(r.innerType()):r instanceof Xe?[r.value]:r instanceof ue?r.options:r instanceof ze?j.objectValues(r.enum):r instanceof et?re(r._def.innerType):r instanceof Fe?[void 0]:r instanceof Ge?[null]:r instanceof X?[void 0,...re(r.unwrap())]:r instanceof de?[null,...re(r.unwrap())]:r instanceof Dt||r instanceof nt?re(r.unwrap()):r instanceof tt?re(r._def.innerType):[];class kt extends k{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.object)return p(t,{code:l.invalid_type,expected:g.object,received:t.parsedType}),b;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),b)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=re(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new kt({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...x(n)})}}function Nt(r,e){const t=ie(r),n=ie(e);if(r===e)return{valid:!0,data:r};if(t===g.object&&n===g.object){const s=j.objectKeys(e),a=j.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Nt(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===g.array&&n===g.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Nt(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===g.date&&n===g.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Ye extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Pt(a)||Pt(i))return b;const o=Nt(a.value,i.value);return o.valid?((Zt(a)||Zt(i))&&t.dirty(),{status:t.value,value:o.data}):(p(n,{code:l.invalid_intersection_types}),b)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Ye.create=(r,e,t)=>new Ye({left:r,right:e,typeName:_.ZodIntersection,...x(t)});class J extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.array)return p(n,{code:l.invalid_type,expected:g.array,received:n.parsedType}),b;if(n.data.length<this._def.items.length)return p(n,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Q(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>V.mergeArray(t,i)):V.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new J({...this._def,rest:e})}}J.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new J({items:r,typeName:_.ZodTuple,rest:null,...x(e)})};class Qe extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return p(n,{code:l.invalid_type,expected:g.object,received:n.parsedType}),b;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Q(n,o,n.path,o)),value:i._parse(new Q(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?V.mergeObjectAsync(t,s):V.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof k?new Qe({keyType:e,valueType:t,typeName:_.ZodRecord,...x(n)}):new Qe({keyType:q.create(),valueType:e,typeName:_.ZodRecord,...x(t)})}}class Ot extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.map)return p(n,{code:l.invalid_type,expected:g.map,received:n.parsedType}),b;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Q(n,o,n.path,[u,"key"])),value:a._parse(new Q(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return b;(u.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(u.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return b;(u.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(u.value,d.value)}return{status:t.value,value:o}}}}Ot.create=(r,e,t)=>new Ot({valueType:e,keyType:r,typeName:_.ZodMap,...x(t)});class ge extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.set)return p(n,{code:l.invalid_type,expected:g.set,received:n.parsedType}),b;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(p(n,{code:l.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(p(n,{code:l.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const d of c){if(d.status==="aborted")return b;d.status==="dirty"&&t.dirty(),u.add(d.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>a._parse(new Q(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new ge({...this._def,minSize:{value:e,message:y.toString(t)}})}max(e,t){return new ge({...this._def,maxSize:{value:e,message:y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ge.create=(r,e)=>new ge({valueType:r,minSize:null,maxSize:null,typeName:_.ZodSet,...x(e)});class je extends k{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.function)return p(t,{code:l.invalid_type,expected:g.function,received:t.parsedType}),b;function n(o,c){return _t({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yt(),xe].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function s(o,c){return _t({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yt(),xe].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Re){const o=this;return U(async function(...c){const u=new H([]),d=await o._def.args.parseAsync(c,a).catch(S=>{throw u.addIssue(n(c,S)),u}),h=await Reflect.apply(i,this,d);return await o._def.returns._def.type.parseAsync(h,a).catch(S=>{throw u.addIssue(s(h,S)),u})})}else{const o=this;return U(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new H([n(c,u.error)]);const d=Reflect.apply(i,this,u.data),h=o._def.returns.safeParse(d,a);if(!h.success)throw new H([s(d,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new je({...this._def,args:J.create(e).rest(me.create())})}returns(e){return new je({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new je({args:e||J.create([]).rest(me.create()),returns:t||me.create(),typeName:_.ZodFunction,...x(n)})}}class Je extends k{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Je.create=(r,e)=>new Je({getter:r,typeName:_.ZodLazy,...x(e)});class Xe extends k{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:e.data}}get value(){return this._def.value}}Xe.create=(r,e)=>new Xe({value:r,typeName:_.ZodLiteral,...x(e)});function lr(r,e){return new ue({values:r,typeName:_.ZodEnum,...x(e)})}class ue extends k{constructor(){super(...arguments),qe.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{expected:j.joinValues(n),received:t.parsedType,code:l.invalid_type}),b}if(bt(this,qe)||ir(this,qe,new Set(this._def.values)),!bt(this,qe).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:l.invalid_enum_value,options:n}),b}return U(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ue.create(e,{...this._def,...t})}exclude(e,t=this._def){return ue.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}qe=new WeakMap,ue.create=lr;class ze extends k{constructor(){super(...arguments),We.set(this,void 0)}_parse(e){const t=j.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==g.string&&n.parsedType!==g.number){const s=j.objectValues(t);return p(n,{expected:j.joinValues(s),received:n.parsedType,code:l.invalid_type}),b}if(bt(this,We)||ir(this,We,new Set(j.getValidEnumValues(this._def.values))),!bt(this,We).has(e.data)){const s=j.objectValues(t);return p(n,{received:n.data,code:l.invalid_enum_value,options:s}),b}return U(e.data)}get enum(){return this._def.values}}We=new WeakMap,ze.create=(r,e)=>new ze({values:r,typeName:_.ZodNativeEnum,...x(e)});class Re extends k{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return p(t,{code:l.invalid_type,expected:g.promise,received:t.parsedType}),b;const n=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return U(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Re.create=(r,e)=>new Re({type:r,typeName:_.ZodPromise,...x(e)});class B extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{p(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return b;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?b:c.status==="dirty"||t.value==="dirty"?ke(c.value):c});{if(t.value==="aborted")return b;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?b:o.status==="dirty"||t.value==="dirty"?ke(o.value):o}}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?b:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?b:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ue(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Ue(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);j.assertNever(s)}}B.create=(r,e,t)=>new B({schema:r,typeName:_.ZodEffects,effect:e,...x(t)}),B.createWithPreprocess=(r,e,t)=>new B({schema:e,effect:{type:"preprocess",transform:r},typeName:_.ZodEffects,...x(t)});class X extends k{_parse(e){return this._getType(e)===g.undefined?U(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}X.create=(r,e)=>new X({innerType:r,typeName:_.ZodOptional,...x(e)});class de extends k{_parse(e){return this._getType(e)===g.null?U(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}de.create=(r,e)=>new de({innerType:r,typeName:_.ZodNullable,...x(e)});class et extends k{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===g.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}et.create=(r,e)=>new et({innerType:r,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...x(e)});class tt extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return He(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new H(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new H(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}tt.create=(r,e)=>new tt({innerType:r,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...x(e)});class Tt extends k{_parse(e){if(this._getType(e)!==g.nan){const n=this._getOrReturnCtx(e);return p(n,{code:l.invalid_type,expected:g.nan,received:n.parsedType}),b}return{status:"valid",value:e.data}}}Tt.create=r=>new Tt({typeName:_.ZodNaN,...x(r)});const Yn=Symbol("zod_brand");class Dt extends k{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class rt extends k{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?b:a.status==="dirty"?(t.dirty(),ke(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?b:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new rt({in:e,out:t,typeName:_.ZodPipeline})}}class nt extends k{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Ue(s)&&(s.value=Object.freeze(s.value)),s);return He(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}nt.create=(r,e)=>new nt({innerType:r,typeName:_.ZodReadonly,...x(e)});function hr(r,e={},t){return r?Oe.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Oe.create()}const Qn={object:Z.lazycreate};var _;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(_||(_={}));const Jn=(r,e={message:`Input not instance of ${r.name}`})=>hr(t=>t instanceof r,e),fr=q.create,pr=oe.create,Xn=Tt.create,zn=ce.create,mr=Be.create,es=pe.create,ts=wt.create,rs=Fe.create,ns=Ge.create,ss=Oe.create,as=me.create,is=te.create,os=xt.create,cs=W.create,us=Z.create,ds=Z.strictCreate,ls=Ke.create,hs=kt.create,fs=Ye.create,ps=J.create,ms=Qe.create,gs=Ot.create,vs=ge.create,ys=je.create,_s=Je.create,bs=Xe.create,ws=ue.create,xs=ze.create,ks=Re.create,gr=B.create,Os=X.create,Ts=de.create,js=B.createWithPreprocess,Rs=rt.create;var O=Object.freeze({__proto__:null,defaultErrorMap:xe,setErrorMap:Pn,getErrorMap:yt,makeIssue:_t,EMPTY_PATH:Zn,addIssueToContext:p,ParseStatus:V,INVALID:b,DIRTY:ke,OK:U,isAborted:Pt,isDirty:Zt,isValid:Ue,isAsync:He,get util(){return j},get objectUtil(){return It},ZodParsedType:g,getParsedType:ie,ZodType:k,datetimeRegex:dr,ZodString:q,ZodNumber:oe,ZodBigInt:ce,ZodBoolean:Be,ZodDate:pe,ZodSymbol:wt,ZodUndefined:Fe,ZodNull:Ge,ZodAny:Oe,ZodUnknown:me,ZodNever:te,ZodVoid:xt,ZodArray:W,ZodObject:Z,ZodUnion:Ke,ZodDiscriminatedUnion:kt,ZodIntersection:Ye,ZodTuple:J,ZodRecord:Qe,ZodMap:Ot,ZodSet:ge,ZodFunction:je,ZodLazy:Je,ZodLiteral:Xe,ZodEnum:ue,ZodNativeEnum:ze,ZodPromise:Re,ZodEffects:B,ZodTransformer:B,ZodOptional:X,ZodNullable:de,ZodDefault:et,ZodCatch:tt,ZodNaN:Tt,BRAND:Yn,ZodBranded:Dt,ZodPipeline:rt,ZodReadonly:nt,custom:hr,Schema:k,ZodSchema:k,late:Qn,get ZodFirstPartyTypeKind(){return _},coerce:{string:r=>q.create({...r,coerce:!0}),number:r=>oe.create({...r,coerce:!0}),boolean:r=>Be.create({...r,coerce:!0}),bigint:r=>ce.create({...r,coerce:!0}),date:r=>pe.create({...r,coerce:!0})},any:ss,array:cs,bigint:zn,boolean:mr,date:es,discriminatedUnion:hs,effect:gr,enum:ws,function:ys,instanceof:Jn,intersection:fs,lazy:_s,literal:bs,map:gs,nan:Xn,nativeEnum:xs,never:is,null:ns,nullable:Ts,number:pr,object:us,oboolean:()=>mr().optional(),onumber:()=>pr().optional(),optional:Os,ostring:()=>fr().optional(),pipeline:Rs,preprocess:js,promise:ks,record:ms,set:vs,strictObject:ds,string:fr,symbol:ts,transformer:gr,tuple:ps,undefined:rs,union:ls,unknown:as,void:os,NEVER:b,ZodIssueCode:l,quotelessJson:In,ZodError:H}),Mt=class Vt extends Cn{constructor(t){super(t);m(this,"openAPIRegistry");m(this,"defaultHook");m(this,"openapi",({middleware:t,...n},s,a=this.defaultHook)=>{var u,d,h,T,S,E;this.openAPIRegistry.registerPath(n);const i=[];if((u=n.request)!=null&&u.query){const w=be("query",n.request.query,a);i.push(w)}if((d=n.request)!=null&&d.params){const w=be("param",n.request.params,a);i.push(w)}if((h=n.request)!=null&&h.headers){const w=be("header",n.request.headers,a);i.push(w)}if((T=n.request)!=null&&T.cookies){const w=be("cookie",n.request.cookies,a);i.push(w)}const o=(E=(S=n.request)==null?void 0:S.body)==null?void 0:E.content;if(o)for(const w of Object.keys(o)){if(!o[w])continue;const D=o[w].schema;if(D instanceof k){if(w.startsWith("application/json")){const L=be("json",D,a);i.push(L)}if(w.startsWith("multipart/form-data")||w.startsWith("application/x-www-form-urlencoded")){const L=be("form",D,a);i.push(L)}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...i,s),this});m(this,"getOpenAPIDocument",t=>new Fr(this.openAPIRegistry.definitions).generateDocument(t));m(this,"getOpenAPI31Document",t=>new Yr(this.openAPIRegistry.definitions).generateDocument(t));m(this,"doc",(t,n)=>this.get(t,s=>{const a=typeof n=="function"?n(s):n;try{const i=this.getOpenAPIDocument(a);return s.json(i)}catch(i){return s.json(i,500)}}));m(this,"doc31",(t,n)=>this.get(t,s=>{const a=typeof n=="function"?n(s):n;try{const i=this.getOpenAPI31Document(a);return s.json(i)}catch(i){return s.json(i,500)}}));this.openAPIRegistry=new Er,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Vt?(n.openAPIRegistry.definitions.forEach(a=>{switch(a.type){case"component":return this.openAPIRegistry.registerComponent(a.componentType,a.name,a.component);case"route":return this.openAPIRegistry.registerPath({...a.route,path:fe(s,a.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...a.webhook,path:fe(s,a.webhook.path)});case"schema":return this.openAPIRegistry.register(a.schema._def.openapi._internal.refId,a.schema);case"parameter":return this.openAPIRegistry.registerParameter(a.schema._def.openapi._internal.refId,a.schema);default:{const i=a;throw new Error(`Unknown registry type: ${i}`)}}}),this):this}basePath(t){return new Vt({...super.basePath(t),defaultHook:this.defaultHook})}},vr=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};Or(O);const Es=O.object({alg:O.string(),e:O.string(),kid:O.string(),kty:O.string(),n:O.string(),use:O.string().optional()}),Ss=O.object({keys:O.array(Es)}),yr=O.object({issuer:O.string(),authorization_endpoint:O.string(),token_endpoint:O.string(),device_authorization_endpoint:O.string(),userinfo_endpoint:O.string(),mfa_challenge_endpoint:O.string(),jwks_uri:O.string(),registration_endpoint:O.string(),revocation_endpoint:O.string(),scopes_supported:O.array(O.string()),response_types_supported:O.array(O.string()),code_challenge_methods_supported:O.array(O.string()),response_modes_supported:O.array(O.string()),subject_types_supported:O.array(O.string()),id_token_signing_alg_values_supported:O.array(O.string()),token_endpoint_auth_methods_supported:O.array(O.string()),claims_supported:O.array(O.string()),request_uri_parameter_supported:O.boolean(),request_parameter_supported:O.boolean(),token_endpoint_auth_signing_alg_values_supported:O.array(O.string())}),Cs=new Mt().openapi(vr({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Ss}},description:"List of tenants"}}}),async r=>{const{env:e}=r,t=[{alg:"RS256",e:"AQAB",kid:"hZ42TWGWLdmyKfwGVA6c2",kty:"RSA",n:"nUd-mktFZQNfVwmXufxcVcvJo6Lkb-jDuymtfQunmEhWCctOccWx9e7LX7_9uN15ZnRS7XJInPMRs9KLYdZ0GCnE2HM_QbrEoHpdkCRgyTE-KzmoaEv_AOVGE_Kg0-0ct3r9Z7aJLDVAsxXl1C9y8Gr7ZYkq0c4DyZr9VT8nQiwZQERbfxXdXw-5RLj21S_Lm-LL-AjKvry_TDBLpfUFJV18SVsM07lY_V45TwykNewRdaGLspFIeGdG5j5eByV8ifzBqvzOSptSCsmOTtW-ceWUk0FPD7g_KKzjjbzenoB0TC8mBb_4vWZlHnuGIAs2YoTFglp9uNu7t_OVl3Svo6ZE6alzUnaNfZNeAi78KPHYQ4tDWPjpYNfGynsiD0nojkDSPCIak56jWNYjj614cPEBiv9MVQRiSbBxpiGhMoHlW_QCCPMcXygLAaRs_tUksqoH4QB80krifG2yHPgGDPjXK1_0cYzV80iOcQIeoceqhkSSc6YxzzgDrQcsV2k3bizRQSL83GWkpdHhTZn-Q_JzsW_bDY_f9fjigYbRnoDSgS7038VFIPc92StE41MdgvIQMomcyEE4lYK1uv1Mo6cnXbCZhm8tvddo7VKNorOB4nsiv8DGrWPlzQBca9VN4C1oE2mH-3WLFR7XEkBHWVouOdTWM2S3K9F10YtahkM"}];return r.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})}).openapi(vr({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:yr}},description:"List of tenants"}}}),async r=>{const{env:e}=r,{ISSUER:t}=e,n=yr.parse({issuer:t,authorization_endpoint:`${t}authorize`,token_endpoint:`${t}oauth/token`,device_authorization_endpoint:`${t}oauth/device/code`,userinfo_endpoint:`${t}userinfo`,mfa_challenge_endpoint:`${t}mfa/challenge`,jwks_uri:`${t}.well-known/jwks.json`,registration_endpoint:`${t}oidc/register`,revocation_endpoint:`${t}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return r.json(n,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})});function Is(){const r=new Mt;r.get("/",t=>t.text("Hello, authhero!"));const e=new Mt().route("/.well-known",Cs);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),r.route("/",e),r}return I.init=Is,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"}),I}({});
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "authhero",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"main": "dist/authhero.cjs",
|
|
5
|
+
"types": "dist/authhero.d.ts",
|
|
6
|
+
"module": "dist/authhero.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/authhero.cjs",
|
|
10
|
+
"import": "./dist/authhero.mjs",
|
|
11
|
+
"types": "./dist/authhero.d.ts"
|
|
12
|
+
}
|
|
9
13
|
},
|
|
10
14
|
"devDependencies": {
|
|
11
15
|
"@types/node": "^20.14.9",
|
package/vite.config.ts
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
|
+
import path from "path";
|
|
1
2
|
import { defineConfig } from "vite";
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
import dts from "vite-plugin-dts";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const getPackageName = () => {
|
|
5
|
+
return "authhero";
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const getPackageNameCamelCase = () => {
|
|
9
|
+
try {
|
|
10
|
+
return getPackageName().replace(/-./g, (char) => char[1].toUpperCase());
|
|
11
|
+
} catch (err) {
|
|
12
|
+
throw new Error("Name property in package.json is missing.");
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const fileName = {
|
|
17
|
+
es: `${getPackageName()}.mjs`,
|
|
18
|
+
cjs: `${getPackageName()}.cjs`,
|
|
19
|
+
iife: `${getPackageName()}.iife.js`,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const formats = Object.keys(fileName) as Array<keyof typeof fileName>;
|
|
23
|
+
|
|
24
|
+
module.exports = defineConfig({
|
|
25
|
+
base: "./",
|
|
7
26
|
build: {
|
|
8
|
-
|
|
27
|
+
outDir: "./dist",
|
|
28
|
+
lib: {
|
|
29
|
+
entry: path.resolve(__dirname, "src/index.ts"),
|
|
30
|
+
name: getPackageNameCamelCase(),
|
|
31
|
+
formats,
|
|
32
|
+
fileName: (format) => fileName[format],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
resolve: {
|
|
36
|
+
alias: [
|
|
37
|
+
{ find: "@", replacement: path.resolve(__dirname, "src") },
|
|
38
|
+
{ find: "@@", replacement: path.resolve(__dirname) },
|
|
39
|
+
],
|
|
9
40
|
},
|
|
10
|
-
plugins: [dts()],
|
|
11
41
|
});
|
package/dist/bun.d.ts
DELETED
package/dist/bun.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../src/bun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,QAAA,MAAM,GAAG;cAA+B,QAAQ;WAAK,CAAC;AAUtD,eAAe,GAAG,CAAC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAa,MAAM,SAAS,CAAC;AAG9C,MAAM,WAAW,cAAc;CAAG;AAElC,wBAAgB,IAAI;cAC0B,QAAQ;YAyBrD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/oauth2/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Bindings } from '../../types';
|
|
2
|
-
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
3
|
-
|
|
4
|
-
export declare const wellKnownRoutes: OpenAPIHono<{
|
|
5
|
-
Bindings: Bindings;
|
|
6
|
-
}, {
|
|
7
|
-
"/jwks.json": {
|
|
8
|
-
$get: {
|
|
9
|
-
input: {};
|
|
10
|
-
output: {
|
|
11
|
-
keys: {
|
|
12
|
-
alg: string;
|
|
13
|
-
e: string;
|
|
14
|
-
kid: string;
|
|
15
|
-
kty: string;
|
|
16
|
-
n: string;
|
|
17
|
-
use?: string | undefined;
|
|
18
|
-
}[];
|
|
19
|
-
};
|
|
20
|
-
outputFormat: "json";
|
|
21
|
-
status: 200;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
} & {
|
|
25
|
-
"/openid-configuration": {
|
|
26
|
-
$get: {
|
|
27
|
-
input: {};
|
|
28
|
-
output: {
|
|
29
|
-
issuer: string;
|
|
30
|
-
authorization_endpoint: string;
|
|
31
|
-
token_endpoint: string;
|
|
32
|
-
device_authorization_endpoint: string;
|
|
33
|
-
userinfo_endpoint: string;
|
|
34
|
-
mfa_challenge_endpoint: string;
|
|
35
|
-
jwks_uri: string;
|
|
36
|
-
registration_endpoint: string;
|
|
37
|
-
revocation_endpoint: string;
|
|
38
|
-
scopes_supported: string[];
|
|
39
|
-
response_types_supported: string[];
|
|
40
|
-
code_challenge_methods_supported: string[];
|
|
41
|
-
response_modes_supported: string[];
|
|
42
|
-
subject_types_supported: string[];
|
|
43
|
-
id_token_signing_alg_values_supported: string[];
|
|
44
|
-
token_endpoint_auth_methods_supported: string[];
|
|
45
|
-
claims_supported: string[];
|
|
46
|
-
request_uri_parameter_supported: boolean;
|
|
47
|
-
request_parameter_supported: boolean;
|
|
48
|
-
token_endpoint_auth_signing_alg_values_supported: string[];
|
|
49
|
-
};
|
|
50
|
-
outputFormat: "json";
|
|
51
|
-
status: 200;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
}, "/">;
|
|
55
|
-
//# sourceMappingURL=well-known.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"well-known.d.ts","sourceRoot":"","sources":["../../../src/routes/oauth2/well-known.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAE7D,eAAO,MAAM,eAAe;cAA+B,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0KhE,CAAC"}
|
package/dist/types/Bindings.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Bindings.d.ts","sourceRoot":"","sources":["../../src/types/Bindings.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IAGpB,6BAA6B,EAAE,MAAM,CAAC;CACvC,CAAC"}
|
package/dist/types/JWKS.d.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { z } from '@hono/zod-openapi';
|
|
2
|
-
|
|
3
|
-
export declare const jwksSchema: z.ZodObject<{
|
|
4
|
-
alg: z.ZodString;
|
|
5
|
-
e: z.ZodString;
|
|
6
|
-
kid: z.ZodString;
|
|
7
|
-
kty: z.ZodString;
|
|
8
|
-
n: z.ZodString;
|
|
9
|
-
use: z.ZodOptional<z.ZodString>;
|
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
alg: string;
|
|
12
|
-
e: string;
|
|
13
|
-
kid: string;
|
|
14
|
-
kty: string;
|
|
15
|
-
n: string;
|
|
16
|
-
use?: string | undefined;
|
|
17
|
-
}, {
|
|
18
|
-
alg: string;
|
|
19
|
-
e: string;
|
|
20
|
-
kid: string;
|
|
21
|
-
kty: string;
|
|
22
|
-
n: string;
|
|
23
|
-
use?: string | undefined;
|
|
24
|
-
}>;
|
|
25
|
-
export declare const jwksKeySchema: z.ZodObject<{
|
|
26
|
-
keys: z.ZodArray<z.ZodObject<{
|
|
27
|
-
alg: z.ZodString;
|
|
28
|
-
e: z.ZodString;
|
|
29
|
-
kid: z.ZodString;
|
|
30
|
-
kty: z.ZodString;
|
|
31
|
-
n: z.ZodString;
|
|
32
|
-
use: z.ZodOptional<z.ZodString>;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
alg: string;
|
|
35
|
-
e: string;
|
|
36
|
-
kid: string;
|
|
37
|
-
kty: string;
|
|
38
|
-
n: string;
|
|
39
|
-
use?: string | undefined;
|
|
40
|
-
}, {
|
|
41
|
-
alg: string;
|
|
42
|
-
e: string;
|
|
43
|
-
kid: string;
|
|
44
|
-
kty: string;
|
|
45
|
-
n: string;
|
|
46
|
-
use?: string | undefined;
|
|
47
|
-
}>, "many">;
|
|
48
|
-
}, "strip", z.ZodTypeAny, {
|
|
49
|
-
keys: {
|
|
50
|
-
alg: string;
|
|
51
|
-
e: string;
|
|
52
|
-
kid: string;
|
|
53
|
-
kty: string;
|
|
54
|
-
n: string;
|
|
55
|
-
use?: string | undefined;
|
|
56
|
-
}[];
|
|
57
|
-
}, {
|
|
58
|
-
keys: {
|
|
59
|
-
alg: string;
|
|
60
|
-
e: string;
|
|
61
|
-
kid: string;
|
|
62
|
-
kty: string;
|
|
63
|
-
n: string;
|
|
64
|
-
use?: string | undefined;
|
|
65
|
-
}[];
|
|
66
|
-
}>;
|
|
67
|
-
export declare const openIDConfigurationSchema: z.ZodObject<{
|
|
68
|
-
issuer: z.ZodString;
|
|
69
|
-
authorization_endpoint: z.ZodString;
|
|
70
|
-
token_endpoint: z.ZodString;
|
|
71
|
-
device_authorization_endpoint: z.ZodString;
|
|
72
|
-
userinfo_endpoint: z.ZodString;
|
|
73
|
-
mfa_challenge_endpoint: z.ZodString;
|
|
74
|
-
jwks_uri: z.ZodString;
|
|
75
|
-
registration_endpoint: z.ZodString;
|
|
76
|
-
revocation_endpoint: z.ZodString;
|
|
77
|
-
scopes_supported: z.ZodArray<z.ZodString, "many">;
|
|
78
|
-
response_types_supported: z.ZodArray<z.ZodString, "many">;
|
|
79
|
-
code_challenge_methods_supported: z.ZodArray<z.ZodString, "many">;
|
|
80
|
-
response_modes_supported: z.ZodArray<z.ZodString, "many">;
|
|
81
|
-
subject_types_supported: z.ZodArray<z.ZodString, "many">;
|
|
82
|
-
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString, "many">;
|
|
83
|
-
token_endpoint_auth_methods_supported: z.ZodArray<z.ZodString, "many">;
|
|
84
|
-
claims_supported: z.ZodArray<z.ZodString, "many">;
|
|
85
|
-
request_uri_parameter_supported: z.ZodBoolean;
|
|
86
|
-
request_parameter_supported: z.ZodBoolean;
|
|
87
|
-
token_endpoint_auth_signing_alg_values_supported: z.ZodArray<z.ZodString, "many">;
|
|
88
|
-
}, "strip", z.ZodTypeAny, {
|
|
89
|
-
issuer: string;
|
|
90
|
-
authorization_endpoint: string;
|
|
91
|
-
token_endpoint: string;
|
|
92
|
-
device_authorization_endpoint: string;
|
|
93
|
-
userinfo_endpoint: string;
|
|
94
|
-
mfa_challenge_endpoint: string;
|
|
95
|
-
jwks_uri: string;
|
|
96
|
-
registration_endpoint: string;
|
|
97
|
-
revocation_endpoint: string;
|
|
98
|
-
scopes_supported: string[];
|
|
99
|
-
response_types_supported: string[];
|
|
100
|
-
code_challenge_methods_supported: string[];
|
|
101
|
-
response_modes_supported: string[];
|
|
102
|
-
subject_types_supported: string[];
|
|
103
|
-
id_token_signing_alg_values_supported: string[];
|
|
104
|
-
token_endpoint_auth_methods_supported: string[];
|
|
105
|
-
claims_supported: string[];
|
|
106
|
-
request_uri_parameter_supported: boolean;
|
|
107
|
-
request_parameter_supported: boolean;
|
|
108
|
-
token_endpoint_auth_signing_alg_values_supported: string[];
|
|
109
|
-
}, {
|
|
110
|
-
issuer: string;
|
|
111
|
-
authorization_endpoint: string;
|
|
112
|
-
token_endpoint: string;
|
|
113
|
-
device_authorization_endpoint: string;
|
|
114
|
-
userinfo_endpoint: string;
|
|
115
|
-
mfa_challenge_endpoint: string;
|
|
116
|
-
jwks_uri: string;
|
|
117
|
-
registration_endpoint: string;
|
|
118
|
-
revocation_endpoint: string;
|
|
119
|
-
scopes_supported: string[];
|
|
120
|
-
response_types_supported: string[];
|
|
121
|
-
code_challenge_methods_supported: string[];
|
|
122
|
-
response_modes_supported: string[];
|
|
123
|
-
subject_types_supported: string[];
|
|
124
|
-
id_token_signing_alg_values_supported: string[];
|
|
125
|
-
token_endpoint_auth_methods_supported: string[];
|
|
126
|
-
claims_supported: string[];
|
|
127
|
-
request_uri_parameter_supported: boolean;
|
|
128
|
-
request_parameter_supported: boolean;
|
|
129
|
-
token_endpoint_auth_signing_alg_values_supported: string[];
|
|
130
|
-
}>;
|
|
131
|
-
//# sourceMappingURL=JWKS.d.ts.map
|
package/dist/types/JWKS.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JWKS.d.ts","sourceRoot":"","sources":["../../src/types/JWKS.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;EAOrB,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAExB,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBpC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Variables.d.ts","sourceRoot":"","sources":["../../src/types/Variables.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,EAAE,CAAC"}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
|
File without changes
|