authhero 0.20.1 → 0.20.2

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/dist/authhero.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var iv=Object.defineProperty;var yh=r=>{throw TypeError(r)};var sv=(r,e,t)=>e in r?iv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ne=(r,e,t)=>sv(r,typeof e!="symbol"?e+"":e,t),Xu=(r,e,t)=>e.has(r)||yh("Cannot "+t);var w=(r,e,t)=>(Xu(r,e,"read from private field"),t?t.call(r):e.get(r)),Oe=(r,e,t)=>e.has(r)?yh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ue=(r,e,t,n)=>(Xu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Te=(r,e,t)=>(Xu(r,e,"access private method"),t);var gh=(r,e,t,n)=>({set _(i){ue(r,e,i,t)},get _(){return w(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function As(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 i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function Se(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function av(r){return"_def"in r}function xs(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function ov(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=As(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=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(O).length>0?{metadata:O}:void 0)}));if(Se(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},xs(r,"optional"),xs(r,"nullable"),xs(r,"default"),xs(r,"transform"),xs(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}function Zo(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=>Zo(r[n],e[n]))}class cv{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(s=>Zo(s,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(i=>Zo(i,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const s of this.buckets.values())e+=1,t+=s.length,s.length>1&&(n+=1);const i=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:i}}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,i]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(i??"");return t}}function Rs(r){return r==null}function Ps(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{t[n]=e(i)}),t}function uv(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e.some(s=>s===n)||(t[n]=i)}),t}function ji(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e(i,n)||(t[n]=i)}),t}function vh(r){return r.filter(e=>!Rs(e))}const yl=Zo;function lv(r){const e=new cv;return r.forEach(t=>e.put(t)),[...e.values()]}function wm(r){return typeof r=="string"}class dv{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(i=>i.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,i,s;const a=this.schemaWithRefId(e,t),o=(n=a._def.openapi)===null||n===void 0?void 0:n.metadata,c=a.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(s=(i=o==null?void 0:o.param)===null||i===void 0?void 0:i.name)!==null&&s!==void 0?s: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 tu{constructor(e){this.message=e}}class _s extends tu{constructor(e,t){super(e),this.data=t}}class Mo extends tu{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 ws(r,e){try{return r()}catch(t){throw t instanceof Mo?new Mo(Object.assign(Object.assign({},t.data),e)):t}}class fv extends tu{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class We{static getMetadata(e){var t;const n=this.unwrapChained(e),i=e._def.openapi?e._def.openapi:n._def.openapi,s=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:i==null?void 0:i._internal,metadata:Object.assign({description:s},i==null?void 0:i.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 i=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:i._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:i.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign(Object.assign({},s==null?void 0:s.metadata),{param:Object.assign({description:a},(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return ji(uv(e,["param"]),Rs)}static buildParameterMetadata(e){return ji(e,Rs)}static applySchemaMetadata(e,t){return ji(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Rs)}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&&Se(e,t)?e:Se(e,"ZodOptional")||Se(e,"ZodNullable")||Se(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):Se(e,"ZodDefault")||Se(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):Se(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):Se(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return Se(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class hv{transform(e,t,n){var i,s;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:(i=e._def.minLength)===null||i===void 0?void 0:i.value,maxItems:(s=e._def.maxLength)===null||s===void 0?void 0:s.value})}}class pv{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class mv{transform(e,t,n,i,s){const a=[...e.options.values()],o=a.map(i);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(a,e.discriminator,s)}}mapDiscriminator(e,t,n){if(e.some(s=>We.getRefId(s)===void 0))return;const i={};return e.forEach(s=>{var a;const o=We.getRefId(s),c=(a=s.shape)===null||a===void 0?void 0:a[t];if(Se(c,"ZodEnum")||Se(c,"ZodNativeEnum")){Object.values(c.enum).filter(wm).forEach(m=>{i[m]=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`);i[u]=n(o)}),{propertyName:t,mapping:i}}}class yv{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class gv{transform(e,t,n,i){const a={allOf:this.flattenIntersectionTypes(e).map(i)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!Se(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class vv{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function bv(r){const t=Object.keys(r).filter(s=>typeof r[r[s]]!="number").map(s=>r[s]),n=t.filter(s=>typeof s=="number").length,i=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:i}}class xv{transform(e,t){const{type:n,values:i}=bv(e._def.values);if(n==="mixed")throw new tu("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:i})}}class _v{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class wv{transform(e,t,n,i){var s;const a=(s=We.getInternalMetadata(e))===null||s===void 0?void 0:s.extendedFrom,o=this.requiredKeysOf(e),c=Ps(e._def.shape(),i);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,i));const u=a.schema;i(u);const f=this.requiredKeysOf(u),m=Ps(u==null?void 0:u._def.shape(),i),B=Object.fromEntries(Object.entries(c).filter(([g,A])=>!yl(m[g],A))),C=o.filter(g=>!f.includes(g)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:B}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,i));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,i=e._def.catchall;return Se(i,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(i)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!We.isOptionalSchema(n)).map(([t,n])=>t)}}class kv{transform(e,t,n){const i=e._def.valueType,s=e._def.keyType,a=n(i);if(Se(s,"ZodEnum")||Se(s,"ZodNativeEnum")){const c=Object.values(s.enum).filter(wm).reduce((u,f)=>Object.assign(Object.assign({},u),{[f]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class Sv{transform(e,t){var n,i,s;const a=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(i=e.minLength)!==null&&i!==void 0?i:void 0,u=Number.isFinite(e.maxLength)&&(s=e.maxLength)!==null&&s!==void 0?s:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:a==null?void 0:a.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 Av{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:i}=e._def,s=i.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(s))}}class Ov{transform(e,t,n){const s=this.flattenUnionTypes(e).map(a=>{const o=this.unwrapNullable(a);return n(o)});return{anyOf:t(s)}}flattenUnionTypes(e){return Se(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return Se(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Ev{constructor(e){this.versionSpecifics=e,this.objectTransformer=new wv,this.stringTransformer=new Sv,this.numberTransformer=new _v,this.bigIntTransformer=new pv,this.literalTransformer=new vv,this.enumTransformer=new yv,this.nativeEnumTransformer=new xv,this.arrayTransformer=new hv,this.unionTransformer=new Ov,this.discriminatedUnionTransformer=new mv,this.intersectionTransformer=new gv,this.recordTransformer=new kv,this.tupleTransformer=new Av(e)}transform(e,t,n,i,s){if(Se(e,"ZodNull"))return this.versionSpecifics.nullType;if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodObject"))return this.objectTransformer.transform(e,s,o=>this.versionSpecifics.mapNullableType(o,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,i);return Object.assign(Object.assign({},a),{default:s})}transformSchemaWithoutDefault(e,t,n,i){if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(Se(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(Se(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,i);if(Se(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const s=We.getRefId(e);throw new fv({currentSchema:e._def,schemaName:s})}}class km{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Ev(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:i,name:s,component:a})=>{var o;(o=n[i])!==null&&o!==void 0||(n[i]={}),n[i][s]=a}),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 i=e.findIndex(a=>a===t.type),s=e.findIndex(a=>a===n.type);return i-s})}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=We.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,i,s,a,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId?this.paramRefs[(s=e._internal)===null||s===void 0?void 0:s.refId]:void 0;if(!(!(!((a=e==null?void 0:e._internal)===null||a===void 0)&&a.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new _s(`Conflicting location for parameter ${u.name}`,{key:"in",values:vh([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 _s("Conflicting names for parameter",{key:"name",values:vh([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 i=We.getMetadata(e),s=(n=i==null?void 0:i.metadata)===null||n===void 0?void 0:n.param,a=this.getParameterRef(i,{in:t});if(a)return[a];if(Se(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,B;const C=We.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const g=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(g!=null&&g.name&&g.name!==u)throw new _s("Conflicting names for parameter",{key:"name",values:[u,g.name]});if(g!=null&&g.in&&g.in!==t)throw new _s(`Conflicting location for parameter ${(B=g.name)!==null&&B!==void 0?B:u}`,{key:"in",values:[t,g.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(s!=null&&s.in&&s.in!==t)throw new _s(`Conflicting location for parameter ${s.name}`,{key:"in",values:[t,s.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=We.getParamMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=!We.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:s},i?We.buildParameterMetadata(i):{})}generateParameter(e){var t;const n=We.getMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=i==null?void 0:i.name,a=i==null?void 0:i.in;if(!s)throw new Mo({missingField:"name"});if(!a)throw new Mo({missingField:"in",paramName:s});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:a,name:s})}generateSchemaWithMetadata(e){var t;const n=We.unwrapChained(e),i=We.getMetadata(e),s=We.getDefaultValue(e),a=!((t=i==null?void 0:i.metadata)===null||t===void 0)&&t.type?{type:i==null?void 0:i.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),s);return i!=null&&i.metadata?We.applySchemaMetadata(a,i.metadata):ji(a,Rs)}constructReferencedOpenAPISchema(e){var t;const n=We.getMetadata(e),i=We.unwrapChained(e),s=We.getDefaultValue(e),a=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,a):this.toOpenAPISchema(i,a,s)}generateSimpleSchema(e){var t;const n=We.getMetadata(e),i=We.getRefId(e);if(!i||!this.schemaRefs[i])return this.generateSchemaWithMetadata(e);const s=this.schemaRefs[i],a={$ref:this.generateSchemaRef(i)},o=ji(We.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||yl(f,s[m]));if(o.type)return{allOf:[a,o]};const c=ji(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||yl(f,s[m])),u=We.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=We.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=As(e,["content"]),i=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:i})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),i=this.cleanParameter(e.params),s=this.cleanParameter(e.cookies),a=ws(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=ws(()=>i?this.generateInlineParameters(i,"path"):[],{location:"path"}),c=ws(()=>s?this.generateInlineParameters(s,"cookie"):[],{location:"cookie"}),u=ws(()=>{if(Array.isArray(t))return t.flatMap(m=>this.generateInlineParameters(m,"header"));const f=this.cleanParameter(t);return f?this.generateInlineParameters(f,"header"):[]},{location:"header"});return[...o,...a,...u,...c]}cleanParameter(e){if(e)return Se(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:i,responses:s}=e,a=As(e,["method","path","request","responses"]),o=Ps(s,m=>this.getResponse(m)),c=ws(()=>this.getParameters(i),{route:`${t} ${n}`}),u=this.getRequestBody(i==null?void 0:i.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},a),c.length>0?{parameters:[...a.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,i=As(e,["content","headers"]);const s=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},i),s);const a=Se(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},i),{headers:a}),s)}getResponseHeaders(e){const t=e._def.shape();return Ps(t,i=>this.generateSimpleParameter(i))}getBodyContent(e){return Ps(e,t=>{if(!t||!av(t.schema))return t;const{schema:n}=t,i=As(t,["schema"]),s=this.generateSchemaWithRef(n);return Object.assign({schema:s},i)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,i=>this.generateSchemaWithRef(i),i=>this.generateSchemaRef(i),n)}}class Iv{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=lv(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 Cv{constructor(e){const t=new Iv;this.generator=new km(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class jv{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 Tv(r){return"type"in r&&r.type==="webhook"}class Nv{constructor(e){this.definitions=e,this.webhookRefs={};const t=new jv;this.generator=new km(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(Tv).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 Sm=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},Bv=r=>{const{groups:e,path:t}=Rv(r),n=Sm(t);return Pv(n,e)},Rv=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const i=`@${n}`;return e.push([i,t]),i}),{groups:e,path:r}},Pv=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let i=r.length-1;i>=0;i--)if(r[i].includes(n)){r[i]=r[i].replace(n,e[t][1]);break}}return r},bo={},bh=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(bo[r]||(e[2]?bo[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:bo[r]=[r,e[1],!0]),bo[r]):null},Am=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},$v=r=>Am(r,decodeURI),Om=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const i=e.charCodeAt(n);if(i===37){const s=e.indexOf("?",n),a=e.slice(t,s===-1?void 0:s);return $v(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(i===63)break}return e.slice(t,n)},Dv=r=>{const e=Om(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},nn=(...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},Em=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(i=>{if(i!==""&&!/\:/.test(i))n+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){t.length===0&&n===""?t.push("/"):t.push(n);const s=i.replace("?","");n+="/"+s,t.push(n)}else n+="/"+i}),t.filter((i,s,a)=>a.indexOf(i)===s)},Qu=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?af(r):r):r,Im=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let a=r.indexOf(`?${e}`,8);for(a===-1&&(a=r.indexOf(`&${e}`,8));a!==-1;){const o=r.charCodeAt(a+e.length+1);if(o===61){const c=a+e.length+2,u=r.indexOf("&",c);return Qu(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";a=r.indexOf(`&${e}`,a+1)}if(n=/[%+]/.test(r),!n)return}const i={};n??(n=/[%+]/.test(r));let s=r.indexOf("?",8);for(;s!==-1;){const a=r.indexOf("&",s+1);let o=r.indexOf("=",s);o>a&&a!==-1&&(o=-1);let c=r.slice(s+1,o===-1?a===-1?void 0:a:o);if(n&&(c=Qu(c)),s=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=Qu(u))),t?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(u)):i[c]??(i[c]=u)}return e?i[e]:i},Zv=Im,Mv=(r,e)=>Im(r,e,!0),af=decodeURIComponent,Uv=/^[\w!#$%&'*.^`|~+-]+$/,Vv=/^[ !#-:<-[\]-~]*$/,Lv=(r,e)=>{const t=r.trim().split(";"),n={};for(let i of t){i=i.trim();const s=i.indexOf("=");if(s===-1)continue;const a=i.substring(0,s).trim();if(!Uv.test(a))continue;let o=i.substring(s+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Vv.test(o)&&(n[a]=af(o))}return n},qv=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?Lv(n):{}},ye=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});ne(this,"res");ne(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})}},Hv=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),Fv=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Kv=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Wv=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,zv=(r,e)=>async(t,n)=>{let i={};const s=t.req.header("Content-Type");switch(r){case"json":if(!s||!Fv.test(s))break;try{i=await t.req.json()}catch{const o="Malformed JSON in request body";throw new ye(400,{message:o})}break;case"form":{if(!s||!(Kv.test(s)||Wv.test(s)))break;let o;if(t.req.bodyCache.formData)o=await t.req.bodyCache.formData;else try{const u=await t.req.arrayBuffer();o=await Hv(u,s),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new ye(400,{message:f})}const c={};o.forEach((u,f)=>{f.endsWith("[]")?(c[f]??(c[f]=[])).push(u):Array.isArray(c[f])?c[f].push(u):f in c?c[f]=[c[f],u]:c[f]=u}),i=c;break}case"query":i=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":i=t.req.param();break;case"header":i=t.req.header();break;case"cookie":i=qv(t);break}const a=await e(i,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const xi=(r,e,t)=>zv(r,async(n,i)=>{const s=await e.safeParseAsync(n);if(t){const a=await t({data:n,...s,target:r},i);if(a){if(a instanceof Response)return a;if("response"in a)return a.response}}return s.success?s.data:i.json(s,400)});var Gv=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,s=(r instanceof Cm?r.raw.headers:r.headers).get("Content-Type");return s!=null&&s.startsWith("multipart/form-data")||s!=null&&s.startsWith("application/x-www-form-urlencoded")?Jv(r,{all:t,dot:n}):{}};async function Jv(r,e){const t=await r.formData();return t?Yv(t,e):{}}function Yv(r,e){const t=Object.create(null);return r.forEach((n,i)=>{e.all||i.endsWith("[]")?Xv(t,i,n):t[i]=n}),e.dot&&Object.entries(t).forEach(([n,i])=>{n.includes(".")&&(Qv(t,n,i),delete t[n])}),t}var Xv=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},Qv=(r,e,t)=>{let n=r;const i=e.split(".");i.forEach((s,a)=>{a===i.length-1?n[s]=t:((!n[s]||typeof n[s]!="object"||Array.isArray(n[s])||n[s]instanceof File)&&(n[s]=Object.create(null)),n=n[s])})},xh=r=>Am(r,af),$i,tr,Xr,jm,Tm,gl,cn,hm,Cm=(hm=class{constructor(r,e="/",t=[[]]){Oe(this,Xr);ne(this,"raw");Oe(this,$i);Oe(this,tr);ne(this,"routeIndex",0);ne(this,"path");ne(this,"bodyCache",{});Oe(this,cn,r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const i=Object.keys(e)[0];return i?e[i].then(s=>(i==="json"&&(s=JSON.stringify(s)),new Response(s)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,ue(this,tr,t),ue(this,$i,{})}param(r){return r?Te(this,Xr,jm).call(this,r):Te(this,Xr,Tm).call(this)}query(r){return Zv(this.url,r)}queries(r){return Mv(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 Gv(this,r))}json(){return w(this,cn).call(this,"json")}text(){return w(this,cn).call(this,"text")}arrayBuffer(){return w(this,cn).call(this,"arrayBuffer")}blob(){return w(this,cn).call(this,"blob")}formData(){return w(this,cn).call(this,"formData")}addValidatedData(r,e){w(this,$i)[r]=e}valid(r){return w(this,$i)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return w(this,tr)[0].map(([[,r]])=>r)}get routePath(){return w(this,tr)[0].map(([[,r]])=>r)[this.routeIndex].path}},$i=new WeakMap,tr=new WeakMap,Xr=new WeakSet,jm=function(r){const e=w(this,tr)[0][this.routeIndex][1][r],t=Te(this,Xr,gl).call(this,e);return t?/\%/.test(t)?xh(t):t:void 0},Tm=function(){const r={},e=Object.keys(w(this,tr)[0][this.routeIndex][1]);for(const t of e){const n=Te(this,Xr,gl).call(this,w(this,tr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?xh(n):n)}return r},gl=function(r){return w(this,tr)[1]?w(this,tr)[1][r]:r},cn=new WeakMap,hm),eb={Stringify:1,BeforeStream:2,Stream:3},Nm=async(r,e,t,n,i)=>{typeof r=="object"&&!(r instanceof String)&&(r instanceof Promise||(r=r.toString()),r instanceof Promise&&(r=await r));const s=r.callbacks;return s!=null&&s.length?(i?i[0]+=r:i=[r],Promise.all(s.map(o=>o({phase:e,buffer:i,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Nm(c,e,!1,n,i))).then(()=>i[0]))):Promise.resolve(r)},tb="text/plain; charset=UTF-8",el=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Ha,Fa,Pr,qn,$r,Ge,Qe,br,Dr,Ka,Di,Zi,Wa,za,Ot,Vt,pm,Bm=(pm=class{constructor(r,e){Oe(this,Ot);Oe(this,Ha);Oe(this,Fa);ne(this,"env",{});Oe(this,Pr);ne(this,"finalized",!1);ne(this,"error");Oe(this,qn,200);Oe(this,$r);Oe(this,Ge);Oe(this,Qe);Oe(this,br);Oe(this,Dr,!0);Oe(this,Ka);Oe(this,Di);Oe(this,Zi);Oe(this,Wa);Oe(this,za);ne(this,"render",(...r)=>(w(this,Di)??ue(this,Di,e=>this.html(e)),w(this,Di).call(this,...r)));ne(this,"setLayout",r=>ue(this,Ka,r));ne(this,"getLayout",()=>w(this,Ka));ne(this,"setRenderer",r=>{ue(this,Di,r)});ne(this,"header",(r,e,t)=>{if(e===void 0){w(this,Ge)?w(this,Ge).delete(r):w(this,Qe)&&delete w(this,Qe)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(w(this,Ge)||(ue(this,Dr,!1),ue(this,Ge,new Headers(w(this,Qe))),ue(this,Qe,{})),w(this,Ge).append(r,e)):w(this,Ge)?w(this,Ge).set(r,e):(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});ne(this,"status",r=>{ue(this,Dr,!1),ue(this,qn,r)});ne(this,"set",(r,e)=>{w(this,Pr)??ue(this,Pr,new Map),w(this,Pr).set(r,e)});ne(this,"get",r=>w(this,Pr)?w(this,Pr).get(r):void 0);ne(this,"newResponse",(...r)=>Te(this,Ot,Vt).call(this,...r));ne(this,"body",(r,e,t)=>typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e));ne(this,"text",(r,e,t)=>{if(!w(this,Qe)){if(w(this,Dr)&&!t&&!e)return new Response(r);ue(this,Qe,{})}return w(this,Qe)["content-type"]=tb,typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)});ne(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)});ne(this,"html",(r,e,t)=>(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Nm(r,eb.Stringify,!1,{}).then(n=>typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)):typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)));ne(this,"redirect",(r,e)=>(w(this,Ge)??ue(this,Ge,new Headers),w(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));ne(this,"notFound",()=>(w(this,Zi)??ue(this,Zi,()=>new Response),w(this,Zi).call(this,this)));ue(this,Ha,r),e&&(ue(this,$r,e.executionCtx),this.env=e.env,ue(this,Zi,e.notFoundHandler),ue(this,za,e.path),ue(this,Wa,e.matchResult))}get req(){return w(this,Fa)??ue(this,Fa,new Cm(w(this,Ha),w(this,za),w(this,Wa))),w(this,Fa)}get event(){if(w(this,$r)&&"respondWith"in w(this,$r))return w(this,$r);throw Error("This context has no FetchEvent")}get executionCtx(){if(w(this,$r))return w(this,$r);throw Error("This context has no ExecutionContext")}get res(){return ue(this,Dr,!1),w(this,br)||ue(this,br,new Response("404 Not Found",{status:404}))}set res(r){if(ue(this,Dr,!1),w(this,br)&&r)try{for(const[e,t]of w(this,br).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=w(this,br).headers.getSetCookie();r.headers.delete("set-cookie");for(const i of n)r.headers.append("set-cookie",i)}else r.headers.set(e,t)}catch(e){if(e instanceof TypeError&&e.message.includes("immutable")){this.res=new Response(r.body,{headers:r.headers,status:r.status});return}else throw e}ue(this,br,r),this.finalized=!0}get var(){return w(this,Pr)?Object.fromEntries(w(this,Pr)):{}}},Ha=new WeakMap,Fa=new WeakMap,Pr=new WeakMap,qn=new WeakMap,$r=new WeakMap,Ge=new WeakMap,Qe=new WeakMap,br=new WeakMap,Dr=new WeakMap,Ka=new WeakMap,Di=new WeakMap,Zi=new WeakMap,Wa=new WeakMap,za=new WeakMap,Ot=new WeakSet,Vt=function(r,e,t){if(w(this,Dr)&&!t&&!e&&w(this,qn)===200)return new Response(r,{headers:w(this,Qe)});if(e&&typeof e!="number"){const i=new Headers(e.headers);w(this,Ge)&&w(this,Ge).forEach((a,o)=>{o==="set-cookie"?i.append(o,a):i.set(o,a)});const s=el(i,w(this,Qe));return new Response(r,{headers:s,status:e.status??w(this,qn)})}const n=typeof e=="number"?e:w(this,qn);w(this,Qe)??ue(this,Qe,{}),w(this,Ge)??ue(this,Ge,new Headers),el(w(this,Ge),w(this,Qe)),w(this,br)&&(w(this,br).headers.forEach((i,s)=>{var a,o;s==="set-cookie"?(a=w(this,Ge))==null||a.append(s,i):(o=w(this,Ge))==null||o.set(s,i)}),el(w(this,Ge),w(this,Qe))),t??(t={});for(const[i,s]of Object.entries(t))if(typeof s=="string")w(this,Ge).set(i,s);else{w(this,Ge).delete(i);for(const a of s)w(this,Ge).append(i,a)}return new Response(r,{status:n,headers:w(this,Ge)})},pm),_h=(r,e,t)=>(n,i)=>{let s=-1;const a=n instanceof Bm;return o(0);async function o(c){if(c<=s)throw new Error("next() called multiple times");s=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&i||void 0,!m)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await m(n,()=>o(c+1))}catch(B){if(B instanceof Error&&a&&e)n.error=B,u=await e(B,n),f=!0;else throw B}return u&&(n.finalized===!1||f)&&(n.res=u),n}},it="ALL",rb="all",nb=["get","post","put","delete","options","patch"],Rm="Can not add a route since the matcher is already built.",Pm=class extends Error{},ib=Symbol("composedHandler"),sb=r=>r.text("404 Not Found",404),wh=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),rr,st,Dm,Zr,Pn,Ao,Oo,mm,$m=(mm=class{constructor(e={}){Oe(this,st);ne(this,"get");ne(this,"post");ne(this,"put");ne(this,"delete");ne(this,"options");ne(this,"patch");ne(this,"all");ne(this,"on");ne(this,"use");ne(this,"router");ne(this,"getPath");ne(this,"_basePath","/");Oe(this,rr,"/");ne(this,"routes",[]);Oe(this,Zr,sb);ne(this,"errorHandler",wh);ne(this,"onError",e=>(this.errorHandler=e,this));ne(this,"notFound",e=>(ue(this,Zr,e),this));ne(this,"fetch",(e,...t)=>Te(this,st,Oo).call(this,e,t[1],t[0],e.method));ne(this,"request",(e,t,n,i)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,i):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${nn("/",e)}`,t),n,i)));ne(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(Te(this,st,Oo).call(this,e.request,e,void 0,e.request.method))})});[...nb,rb].forEach(i=>{this[i]=(s,...a)=>(typeof s=="string"?ue(this,rr,s):Te(this,st,Pn).call(this,i,w(this,rr),s),a.forEach(o=>{Te(this,st,Pn).call(this,i,w(this,rr),o)}),this)}),this.on=(i,s,...a)=>{for(const o of[s].flat()){ue(this,rr,o);for(const c of[i].flat())a.map(u=>{Te(this,st,Pn).call(this,c.toUpperCase(),w(this,rr),u)})}return this},this.use=(i,...s)=>(typeof i=="string"?ue(this,rr,i):(ue(this,rr,"*"),s.unshift(i)),s.forEach(a=>{Te(this,st,Pn).call(this,it,w(this,rr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??Om:Dv}route(e,t){const n=this.basePath(e);return t.routes.map(i=>{var a;let s;t.errorHandler===wh?s=i.handler:(s=async(o,c)=>(await _h([],t.errorHandler)(o,()=>i.handler(o,c))).res,s[ib]=i.handler),Te(a=n,st,Pn).call(a,i.method,i.path,s)}),this}basePath(e){const t=Te(this,st,Dm).call(this);return t._basePath=nn(this._basePath,e),t}mount(e,t,n){let i,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,i=n.replaceRequest));const a=s?c=>{const u=s(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};i||(i=(()=>{const c=nn(this._basePath,e),u=c==="/"?0:c.length;return f=>{const m=new URL(f.url);return m.pathname=m.pathname.slice(u)||"/",new Request(m,f)}})());const o=async(c,u)=>{const f=await t(i(c.req.raw),...a(c));if(f)return f;await u()};return Te(this,st,Pn).call(this,it,nn(e,"*"),o),this}},rr=new WeakMap,st=new WeakSet,Dm=function(){const e=new $m({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Zr=new WeakMap,Pn=function(e,t,n){e=e.toUpperCase(),t=nn(this._basePath,t);const i={path:t,method:e,handler:n};this.router.add(e,t,[n,i]),this.routes.push(i)},Ao=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Oo=function(e,t,n,i){if(i==="HEAD")return(async()=>new Response(null,await Te(this,st,Oo).call(this,e,t,n,"GET")))();const s=this.getPath(e,{env:n}),a=this.router.match(i,s),o=new Bm(e,{path:s,matchResult:a,env:n,executionCtx:t,notFoundHandler:w(this,Zr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await w(this,Zr).call(this,o)})}catch(f){return Te(this,st,Ao).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:w(this,Zr).call(this,o))).catch(f=>Te(this,st,Ao).call(this,f,o)):u??w(this,Zr).call(this,o)}const c=_h(a[0],this.errorHandler,w(this,Zr));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 Te(this,st,Ao).call(this,u,o)}})()},mm),Uo="[^/]+",$s=".*",Ds="(?:|/.*)",Os=Symbol(),ab=new Set(".\\+*[^]$()");function ob(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$s||r===Ds?1:e===$s||e===Ds?-1:r===Uo?1:e===Uo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Hn,Fn,nr,ym,vl=(ym=class{constructor(){Oe(this,Hn);Oe(this,Fn);Oe(this,nr,Object.create(null))}insert(e,t,n,i,s){if(e.length===0){if(w(this,Hn)!==void 0)throw Os;if(s)return;ue(this,Hn,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",$s]:["","",Uo]:a==="/*"?["","",Ds]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||Uo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw Os;if(u=w(this,nr)[m],!u){if(Object.keys(w(this,nr)).some(B=>B!==$s&&B!==Ds))throw Os;if(s)return;u=w(this,nr)[m]=new vl,f!==""&&ue(u,Fn,i.varIndex++)}!s&&f!==""&&n.push([f,w(u,Fn)])}else if(u=w(this,nr)[a],!u){if(Object.keys(w(this,nr)).some(f=>f.length>1&&f!==$s&&f!==Ds))throw Os;if(s)return;u=w(this,nr)[a]=new vl}u.insert(o,t,n,i,s)}buildRegExpStr(){const t=Object.keys(w(this,nr)).sort(ob).map(n=>{const i=w(this,nr)[n];return(typeof w(i,Fn)=="number"?`(${n})@${w(i,Fn)}`:ab.has(n)?`\\${n}`:n)+i.buildRegExpStr()});return typeof w(this,Hn)=="number"&&t.unshift(`#${w(this,Hn)}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},Hn=new WeakMap,Fn=new WeakMap,nr=new WeakMap,ym),eu,Ga,gm,cb=(gm=class{constructor(){Oe(this,eu,{varIndex:0});Oe(this,Ga,new vl)}insert(r,e,t){const n=[],i=[];for(let a=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${a}`;return i[a]=[u,c],a++,o=!0,u}),!o)break}const s=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=i.length-1;a>=0;a--){const[o]=i[a];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(o)!==-1){s[c]=s[c].replace(o,i[a][1]);break}}return w(this,Ga).insert(s,e,n,w(this,eu),t),n}buildRegExp(){let r=w(this,Ga).buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,s,a)=>s!==void 0?(t[++e]=Number(s),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},eu=new WeakMap,Ga=new WeakMap,gm),Zm=[],ub=[/^$/,[],Object.create(null)],Eo=Object.create(null);function Mm(r){return Eo[r]??(Eo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function lb(){Eo=Object.create(null)}function db(r){var u;const e=new cb,t=[];if(r.length===0)return ub;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[B,C])=>f?1:B?-1:m.length-C.length),i=Object.create(null);for(let f=0,m=-1,B=n.length;f<B;f++){const[C,p,g]=n[f];C?i[p]=[g.map(([O])=>[O,Object.create(null)]),Zm]:m++;let A;try{A=e.insert(p,m,C)}catch(O){throw O===Os?new Pm(p):O}C||(t[m]=g.map(([O,P])=>{const N=Object.create(null);for(P-=1;P>=0;P--){const[xe,Le]=A[P];N[xe]=Le}return[O,N]}))}const[s,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let B=0,C=t[f].length;B<C;B++){const p=(u=t[f][B])==null?void 0:u[1];if(!p)continue;const g=Object.keys(p);for(let A=0,O=g.length;A<O;A++)p[g[A]]=o[p[g[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[s,c,i]}function _i(r,e){if(r){for(const t of Object.keys(r).sort((n,i)=>i.length-n.length))if(Mm(t).test(e))return[...r[t]]}}var un,ln,os,Um,Vm,vm,fb=(vm=class{constructor(){Oe(this,os);ne(this,"name","RegExpRouter");Oe(this,un);Oe(this,ln);ue(this,un,{[it]:Object.create(null)}),ue(this,ln,{[it]:Object.create(null)})}add(r,e,t){var o;const n=w(this,un),i=w(this,ln);if(!n||!i)throw new Error(Rm);n[r]||[n,i].forEach(c=>{c[r]=Object.create(null),Object.keys(c[it]).forEach(u=>{c[r][u]=[...c[it][u]]})}),e==="/*"&&(e="*");const s=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Mm(e);r===it?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=_i(n[u],e)||_i(n[it],e)||[])}):(o=n[r])[e]||(o[e]=_i(n[r],e)||_i(n[it],e)||[]),Object.keys(n).forEach(u=>{(r===it||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,s])})}),Object.keys(i).forEach(u=>{(r===it||r===u)&&Object.keys(i[u]).forEach(f=>c.test(f)&&i[u][f].push([t,s]))});return}const a=Em(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(i).forEach(m=>{var B;(r===it||r===m)&&((B=i[m])[f]||(B[f]=[..._i(n[m],f)||_i(n[it],f)||[]]),i[m][f].push([t,s-u+c+1]))})}}match(r,e){lb();const t=Te(this,os,Um).call(this);return this.match=(n,i)=>{const s=t[n]||t[it],a=s[2][i];if(a)return a;const o=i.match(s[0]);if(!o)return[[],Zm];const c=o.indexOf("",1);return[s[1][c],o]},this.match(r,e)}},un=new WeakMap,ln=new WeakMap,os=new WeakSet,Um=function(){const r=Object.create(null);return Object.keys(w(this,ln)).concat(Object.keys(w(this,un))).forEach(e=>{r[e]||(r[e]=Te(this,os,Vm).call(this,e))}),ue(this,un,ue(this,ln,void 0)),r},Vm=function(r){const e=[];let t=r===it;return[w(this,un),w(this,ln)].forEach(n=>{const i=n[r]?Object.keys(n[r]).map(s=>[s,n[r][s]]):[];i.length!==0?(t||(t=!0),e.push(...i)):r!==it&&e.push(...Object.keys(n[it]).map(s=>[s,n[it][s]]))}),t?db(e):null},vm),dn,Mr,bm,hb=(bm=class{constructor(r){ne(this,"name","SmartRouter");Oe(this,dn,[]);Oe(this,Mr,[]);ue(this,dn,r.routers)}add(r,e,t){if(!w(this,Mr))throw new Error(Rm);w(this,Mr).push([r,e,t])}match(r,e){if(!w(this,Mr))throw new Error("Fatal error");const t=w(this,dn),n=w(this,Mr),i=t.length;let s=0,a;for(;s<i;s++){const o=t[s];try{for(let c=0,u=n.length;c<u;c++)o.add(...n[c]);a=o.match(r,e)}catch(c){if(c instanceof Pm)continue;throw c}this.match=o.match.bind(o),ue(this,dn,[o]),ue(this,Mr,void 0);break}if(s===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(w(this,Mr)||w(this,dn).length!==1)throw new Error("No active router has been determined yet.");return w(this,dn)[0]}},dn=new WeakMap,Mr=new WeakMap,bm),fn,bt,Kn,Mi,Et,Ur,$n,xm,Lm=(xm=class{constructor(r,e,t){Oe(this,Ur);Oe(this,fn);Oe(this,bt);Oe(this,Kn);Oe(this,Mi,0);Oe(this,Et,Object.create(null));if(ue(this,bt,t||Object.create(null)),ue(this,fn,[]),r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},ue(this,fn,[n])}ue(this,Kn,[])}insert(r,e,t){ue(this,Mi,++gh(this,Mi)._);let n=this;const i=Bv(e),s=[];for(let c=0,u=i.length;c<u;c++){const f=i[c];if(Object.keys(w(n,bt)).includes(f)){n=w(n,bt)[f];const B=bh(f);B&&s.push(B[1]);continue}w(n,bt)[f]=new Lm;const m=bh(f);m&&(w(n,Kn).push(m),s.push(m[1])),n=w(n,bt)[f]}const a=Object.create(null),o={handler:t,possibleKeys:s.filter((c,u,f)=>f.indexOf(c)===u),score:w(this,Mi)};return a[r]=o,w(n,fn).push(a),n}search(r,e){const t=[];ue(this,Et,Object.create(null));let i=[this];const s=Sm(e);for(let o=0,c=s.length;o<c;o++){const u=s[o],f=o===c-1,m=[];for(let B=0,C=i.length;B<C;B++){const p=i[B],g=w(p,bt)[u];g&&(ue(g,Et,w(p,Et)),f?(w(g,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(g,bt)["*"],r,w(p,Et),Object.create(null))),t.push(...Te(this,Ur,$n).call(this,g,r,w(p,Et),Object.create(null)))):m.push(g));for(let A=0,O=w(p,Kn).length;A<O;A++){const P=w(p,Kn)[A],N={...w(p,Et)};if(P==="*"){const mt=w(p,bt)["*"];mt&&(t.push(...Te(this,Ur,$n).call(this,mt,r,w(p,Et),Object.create(null))),m.push(mt));continue}if(u==="")continue;const[xe,Le,qe]=P,Ze=w(p,bt)[xe],tt=s.slice(o).join("/");if(qe instanceof RegExp&&qe.test(tt)){N[Le]=tt,t.push(...Te(this,Ur,$n).call(this,Ze,r,w(p,Et),N));continue}(qe===!0||qe.test(u))&&(N[Le]=u,f?(t.push(...Te(this,Ur,$n).call(this,Ze,r,N,w(p,Et))),w(Ze,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(Ze,bt)["*"],r,N,w(p,Et)))):(ue(Ze,Et,N),m.push(Ze)))}}i=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},fn=new WeakMap,bt=new WeakMap,Kn=new WeakMap,Mi=new WeakMap,Et=new WeakMap,Ur=new WeakSet,$n=function(r,e,t,n){const i=[];for(let s=0,a=w(r,fn).length;s<a;s++){const o=w(r,fn)[s],c=o[e]||o[it],u={};if(c!==void 0){c.params=Object.create(null);for(let f=0,m=c.possibleKeys.length;f<m;f++){const B=c.possibleKeys[f],C=u[c.score];c.params[B]=n[B]&&!C?n[B]:t[B]??n[B],u[c.score]=!0}i.push(c)}}return i},xm),Wn,_m,pb=(_m=class{constructor(){ne(this,"name","TrieRouter");Oe(this,Wn);ue(this,Wn,new Lm)}add(r,e,t){const n=Em(e);if(n){for(let i=0,s=n.length;i<s;i++)w(this,Wn).insert(r,n[i],t);return}w(this,Wn).insert(r,e,t)}match(r,e){return w(this,Wn).search(r,e)}},Wn=new WeakMap,_m),mb=class extends $m{constructor(r={}){super(r),this.router=r.router??new hb({routers:[new fb,new pb]})}},Re;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Re||(Re={}));var bl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(bl||(bl={}));const z=Re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),sn=r=>{switch(typeof r){case"undefined":return z.undefined;case"string":return z.string;case"number":return isNaN(r)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(r)?z.array:r===null?z.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?z.promise:typeof Map<"u"&&r instanceof Map?z.map:typeof Set<"u"&&r instanceof Set?z.set:typeof Date<"u"&&r instanceof Date?z.date:z.object;default:return z.unknown}},D=Re.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"]),yb=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let or=class qm 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(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof qm))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};or.create=r=>new or(r);const Ui=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Re.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Re.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Re.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Re.joinValues(r.options)}, received '${r.received}'`;break;case D.invalid_arguments:t="Invalid function arguments";break;case D.invalid_return_type:t="Invalid function return type";break;case D.invalid_date:t="Invalid date";break;case D.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}"`:Re.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case D.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 D.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 D.custom:t="Invalid input";break;case D.invalid_intersection_types:t="Intersection results could not be merged";break;case D.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case D.not_finite:t="Number must be finite";break;default:t=e.defaultError,Re.assertNever(r)}return{message:t}};let Hm=Ui;function gb(r){Hm=r}function Vo(){return Hm}const Lo=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},vb=[];function H(r,e){const t=Vo(),n=Lo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ui?void 0:Ui].filter(i=>!!i)});r.common.issues.push(n)}let jt=class Fm{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 i of t){if(i.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return Fm.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),Oi=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),xl=r=>r.status==="aborted",_l=r=>r.status==="dirty",Ls=r=>r.status==="valid",qs=r=>typeof Promise<"u"&&r instanceof Promise;function qo(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 Km(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!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 ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ae||(ae={}));var Es,Is;let Sr=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 kh=(r,e)=>{if(Ls(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 or(r.common.issues);return this._error=t,this._error}}};function _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=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:i}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:i}}let Ae=class{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 sn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new jt,ctx:{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(qs(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 i={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:sn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return kh(i,s)}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:sn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(qs(i)?i:Promise.resolve(i));return kh(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:D.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new dr({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qn.create(this,this._def)}promise(){return qi.create(this,this._def)}or(e){return Js.create([this,e],this._def)}and(e){return Ys.create(this,e,this._def)}transform(e){return new dr({..._e(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ta({..._e(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new of({typeName:de.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ra({..._e(this._def),innerType:this,catchValue:t,typeName:de.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return cf.create(this,e)}readonly(){return na.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const bb=/^c[^\s-]{8,}$/i,xb=/^[0-9a-z]+$/,_b=/^[0-9A-HJKMNP-TV-Z]{26}$/,wb=/^[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,kb=/^[a-z0-9_-]{21}$/i,Sb=/^[-+]?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)?)??$/,Ab=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ob="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let tl;const Eb=/^(?:(?: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])$/,Ib=/^(([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})))$/,Cb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wm="((\\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])))",jb=new RegExp(`^${Wm}$`);function zm(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 Tb(r){return new RegExp(`^${zm(r)}$`)}function Gm(r){let e=`${Wm}T${zm(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 Nb(r,e){return!!((e==="v4"||!e)&&Eb.test(r)||(e==="v6"||!e)&&Ib.test(r))}let Vi=class Cs extends Ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.string,received:s.parsedType}),pe}const n=new jt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Ab.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"email",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")tl||(tl=new RegExp(Ob,"u")),tl.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"emoji",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")wb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"uuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")kb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"nanoid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")bb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")xb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid2",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")_b.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ulid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),H(i,{validation:"url",code:D.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"regex",code:D.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Gm(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?jb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Tb(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Sb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"duration",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Nb(e.data,s.version)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ip",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Cb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"base64",code:D.invalid_string,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:D.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Cs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ae.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ae.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ae.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ae.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ae.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ae.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ae.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ae.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ae.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ae.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,...ae.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,...ae.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ae.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ae.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ae.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ae.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ae.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ae.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ae.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ae.errToObj(t)})}nonempty(e){return this.min(1,ae.errToObj(e))}trim(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Cs({...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}};Vi.create=r=>{var e;return new Vi({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function Bb(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}let Hs=class wl extends Ae{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)!==z.number){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.number,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Bb(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_finite,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new wl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new wl({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ae.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ae.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ae.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ae.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"&&Re.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)}};Hs.create=r=>new Hs({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Fs=class kl extends Ae{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)!==z.bigint){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.bigint,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new kl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new kl({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.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}};Fs.create=r=>{var e;return new Fs({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};let Ks=class extends Ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.boolean,received:n.parsedType}),pe}return _t(e.data)}};Ks.create=r=>new Ks({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Ws=class Jm extends Ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.date,received:s.parsedType}),pe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_date}),pe}const n=new jt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Re.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Jm({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ae.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}};Ws.create=r=>new Ws({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,..._e(r)});let Ho=class extends Ae{_parse(e){if(this._getType(e)!==z.symbol){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.symbol,received:n.parsedType}),pe}return _t(e.data)}};Ho.create=r=>new Ho({typeName:de.ZodSymbol,..._e(r)});let zs=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.undefined,received:n.parsedType}),pe}return _t(e.data)}};zs.create=r=>new zs({typeName:de.ZodUndefined,..._e(r)});let Gs=class extends Ae{_parse(e){if(this._getType(e)!==z.null){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.null,received:n.parsedType}),pe}return _t(e.data)}};Gs.create=r=>new Gs({typeName:de.ZodNull,..._e(r)});let Li=class extends Ae{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}};Li.create=r=>new Li({typeName:de.ZodAny,..._e(r)});let zn=class extends Ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}};zn.create=r=>new zn({typeName:de.ZodUnknown,..._e(r)});let Hr=class extends Ae{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:z.never,received:t.parsedType}),pe}};Hr.create=r=>new Hr({typeName:de.ZodNever,..._e(r)});let Fo=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.void,received:n.parsedType}),pe}return _t(e.data)}};Fo.create=r=>new Fo({typeName:de.ZodVoid,..._e(r)});let Qn=class Io extends Ae{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==z.array)return H(t,{code:D.invalid_type,expected:z.array,received:t.parsedType}),pe;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(H(t,{code:a?D.too_big:D.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(H(t,{code:D.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(H(t,{code:D.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Sr(t,a,t.path,o)))).then(a=>jt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Sr(t,a,t.path,o)));return jt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Io({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new Io({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new Io({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};Qn.create=(r,e)=>new Qn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,..._e(e)});function ki(r){if(r instanceof Kt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(ki(n))}return new Kt({...r._def,shape:()=>e})}else return r instanceof Qn?new Qn({...r._def,type:ki(r.element)}):r instanceof xr?xr.create(ki(r.unwrap())):r instanceof vn?vn.create(ki(r.unwrap())):r instanceof gn?gn.create(r.items.map(e=>ki(e))):r}let Kt=class Xt extends Ae{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=Re.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==z.object){const u=this._getOrReturnCtx(e);return H(u,{code:D.invalid_type,expected:z.object,received:u.parsedType}),pe}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Hr&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=s[u],m=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Sr(i,m,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Hr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")o.length>0&&(H(i,{code:D.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 f of o){const m=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Sr(i,m,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,B=await f.value;u.push({key:m,value:B,alwaysSet:f.alwaysSet})}return u}).then(u=>jt.mergeObjectSync(n,u)):jt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ae.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:de.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){const t={};return Re.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}omit(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return ki(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof xr;)s=s._def.innerType;t[n]=s}}),new Xt({...this._def,shape:()=>t})}keyof(){return ry(Re.objectKeys(this.shape))}};Kt.create=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.strictCreate=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strict",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.lazycreate=(r,e)=>new Kt({shape:r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});let Js=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new or(o.ctx.common.issues));return H(t,{code:D.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new or(c));return H(t,{code:D.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Js.create=(r,e)=>new Js({options:r,typeName:de.ZodUnion,..._e(e)});const Br=r=>r instanceof Xs?Br(r.schema):r instanceof dr?Br(r.innerType()):r instanceof Qs?[r.value]:r instanceof Ja?r.options:r instanceof ea?Re.objectValues(r.enum):r instanceof ta?Br(r._def.innerType):r instanceof zs?[void 0]:r instanceof Gs?[null]:r instanceof xr?[void 0,...Br(r.unwrap())]:r instanceof vn?[null,...Br(r.unwrap())]:r instanceof of||r instanceof na?Br(r.unwrap()):r instanceof ra?Br(r._def.innerType):[];let Ym=class Xm extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return H(t,{code:D.invalid_type,expected:z.object,received:t.parsedType}),pe;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=Br(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new Xm({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,..._e(n)})}};function Sl(r,e){const t=sn(r),n=sn(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&n===z.object){const i=Re.objectKeys(e),s=Re.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=Sl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===z.array&&n===z.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=Sl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===z.date&&n===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Ys=class extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(xl(s)||xl(a))return pe;const o=Sl(s.value,a.value);return o.valid?((_l(s)||_l(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:D.invalid_intersection_types}),pe)};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(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ys.create=(r,e,t)=>new Ys({left:r,right:e,typeName:de.ZodIntersection,..._e(t)});let gn=class Qm extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return H(n,{code:D.invalid_type,expected:z.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return H(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Sr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>jt.mergeArray(t,a)):jt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qm({...this._def,rest:e})}};gn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gn({items:r,typeName:de.ZodTuple,rest:null,..._e(e)})};let ey=class Al extends Ae{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!==z.object)return H(n,{code:D.invalid_type,expected:z.object,received:n.parsedType}),pe;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Sr(n,o,n.path,o)),value:a._parse(new Sr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?jt.mergeObjectAsync(t,i):jt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ae?new Al({keyType:e,valueType:t,typeName:de.ZodRecord,..._e(n)}):new Al({keyType:Vi.create(),valueType:e,typeName:de.ZodRecord,..._e(t)})}},Ko=class extends Ae{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!==z.map)return H(n,{code:D.invalid_type,expected:z.map,received:n.parsedType}),pe;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Sr(n,o,n.path,[u,"key"])),value:s._parse(new Sr(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}};Ko.create=(r,e,t)=>new Ko({valueType:e,keyType:r,typeName:de.ZodMap,..._e(t)});let Wo=class Ol extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return H(n,{code:D.invalid_type,expected:z.set,received:n.parsedType}),pe;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(H(n,{code:D.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(H(n,{code:D.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return pe;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Sr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Ol({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new Ol({...this._def,maxSize:{value:e,message:ae.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Wo.create=(r,e)=>new Wo({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,..._e(e)});let ty=class Co extends Ae{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return H(t,{code:D.invalid_type,expected:z.function,received:t.parsedType}),pe;function n(o,c){return Lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function i(o,c){return Lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qi){const o=this;return _t(async function(...c){const u=new or([]),f=await o._def.args.parseAsync(c,s).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(C=>{throw u.addIssue(i(m,C)),u})})}else{const o=this;return _t(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new or([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new or([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Co({...this._def,args:gn.create(e).rest(zn.create())})}returns(e){return new Co({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Co({args:e||gn.create([]).rest(zn.create()),returns:t||zn.create(),typeName:de.ZodFunction,..._e(n)})}},Xs=class extends Ae{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})}};Xs.create=(r,e)=>new Xs({getter:r,typeName:de.ZodLazy,..._e(e)});let Qs=class extends Ae{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qs.create=(r,e)=>new Qs({value:r,typeName:de.ZodLiteral,..._e(e)});function ry(r,e){return new Ja({values:r,typeName:de.ZodEnum,..._e(e)})}let Ja=class El extends Ae{constructor(){super(...arguments),Es.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Re.joinValues(n),received:t.parsedType,code:D.invalid_type}),pe}if(qo(this,Es)||Km(this,Es,new Set(this._def.values)),!qo(this,Es).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:D.invalid_enum_value,options:n}),pe}return _t(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 El.create(e,{...this._def,...t})}exclude(e,t=this._def){return El.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Es=new WeakMap;Ja.create=ry;let ea=class extends Ae{constructor(){super(...arguments),Is.set(this,void 0)}_parse(e){const t=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){const i=Re.objectValues(t);return H(n,{expected:Re.joinValues(i),received:n.parsedType,code:D.invalid_type}),pe}if(qo(this,Is)||Km(this,Is,new Set(Re.getValidEnumValues(this._def.values))),!qo(this,Is).has(e.data)){const i=Re.objectValues(t);return H(n,{received:n.data,code:D.invalid_enum_value,options:i}),pe}return _t(e.data)}get enum(){return this._def.values}};Is=new WeakMap;ea.create=(r,e)=>new ea({values:r,typeName:de.ZodNativeEnum,..._e(e)});let qi=class extends Ae{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.promise&&t.common.async===!1)return H(t,{code:D.invalid_type,expected:z.promise,received:t.parsedType}),pe;const n=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return _t(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qi.create=(r,e)=>new qi({type:r,typeName:de.ZodPromise,..._e(e)});let dr=class extends Ae{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===de.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return pe;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?pe:c.status==="dirty"||t.value==="dirty"?Oi(c.value):c});{if(t.value==="aborted")return pe;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?pe:o.status==="dirty"||t.value==="dirty"?Oi(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);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"?pe:(o.status==="dirty"&&t.dirty(),a(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"?pe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ls(a))return a;const o=i.transform(a.value,s);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(a=>Ls(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Re.assertNever(i)}};dr.create=(r,e,t)=>new dr({schema:r,typeName:de.ZodEffects,effect:e,..._e(t)});dr.createWithPreprocess=(r,e,t)=>new dr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,..._e(t)});let xr=class extends Ae{_parse(e){return this._getType(e)===z.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(r,e)=>new xr({innerType:r,typeName:de.ZodOptional,..._e(e)});let vn=class extends Ae{_parse(e){return this._getType(e)===z.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(r,e)=>new vn({innerType:r,typeName:de.ZodNullable,..._e(e)});let ta=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ta.create=(r,e)=>new ta({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});let ra=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qs(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ra.create=(r,e)=>new ra({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});let zo=class extends Ae{_parse(e){if(this._getType(e)!==z.nan){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};zo.create=r=>new zo({typeName:de.ZodNaN,..._e(r)});const Rb=Symbol("zod_brand");let of=class extends Ae{_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}},cf=class ny extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),Oi(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?pe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new ny({in:e,out:t,typeName:de.ZodPipeline})}},na=class extends Ae{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Ls(i)&&(i.value=Object.freeze(i.value)),i);return qs(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};na.create=(r,e)=>new na({innerType:r,typeName:de.ZodReadonly,..._e(e)});function iy(r,e={},t){return r?Li.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Li.create()}const Pb={object:Kt.lazycreate};var de;(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"})(de||(de={}));const $b=(r,e={message:`Input not instance of ${r.name}`})=>iy(t=>t instanceof r,e),sy=Vi.create,ay=Hs.create,Db=zo.create,Zb=Fs.create,oy=Ks.create,Mb=Ws.create,Ub=Ho.create,Vb=zs.create,Lb=Gs.create,qb=Li.create,Hb=zn.create,Fb=Hr.create,Kb=Fo.create,Wb=Qn.create,zb=Kt.create,Gb=Kt.strictCreate,Jb=Js.create,Yb=Ym.create,Xb=Ys.create,Qb=gn.create,ex=ey.create,tx=Ko.create,rx=Wo.create,nx=ty.create,ix=Xs.create,sx=Qs.create,ax=Ja.create,ox=ea.create,cx=qi.create,Sh=dr.create,ux=xr.create,lx=vn.create,dx=dr.createWithPreprocess,fx=cf.create,hx=()=>sy().optional(),px=()=>ay().optional(),mx=()=>oy().optional(),yx={string:r=>Vi.create({...r,coerce:!0}),number:r=>Hs.create({...r,coerce:!0}),boolean:r=>Ks.create({...r,coerce:!0}),bigint:r=>Fs.create({...r,coerce:!0}),date:r=>Ws.create({...r,coerce:!0})},gx=pe;var y=Object.freeze({__proto__:null,defaultErrorMap:Ui,setErrorMap:gb,getErrorMap:Vo,makeIssue:Lo,EMPTY_PATH:vb,addIssueToContext:H,ParseStatus:jt,INVALID:pe,DIRTY:Oi,OK:_t,isAborted:xl,isDirty:_l,isValid:Ls,isAsync:qs,get util(){return Re},get objectUtil(){return bl},ZodParsedType:z,getParsedType:sn,ZodType:Ae,datetimeRegex:Gm,ZodString:Vi,ZodNumber:Hs,ZodBigInt:Fs,ZodBoolean:Ks,ZodDate:Ws,ZodSymbol:Ho,ZodUndefined:zs,ZodNull:Gs,ZodAny:Li,ZodUnknown:zn,ZodNever:Hr,ZodVoid:Fo,ZodArray:Qn,ZodObject:Kt,ZodUnion:Js,ZodDiscriminatedUnion:Ym,ZodIntersection:Ys,ZodTuple:gn,ZodRecord:ey,ZodMap:Ko,ZodSet:Wo,ZodFunction:ty,ZodLazy:Xs,ZodLiteral:Qs,ZodEnum:Ja,ZodNativeEnum:ea,ZodPromise:qi,ZodEffects:dr,ZodTransformer:dr,ZodOptional:xr,ZodNullable:vn,ZodDefault:ta,ZodCatch:ra,ZodNaN:zo,BRAND:Rb,ZodBranded:of,ZodPipeline:cf,ZodReadonly:na,custom:iy,Schema:Ae,ZodSchema:Ae,late:Pb,get ZodFirstPartyTypeKind(){return de},coerce:yx,any:qb,array:Wb,bigint:Zb,boolean:oy,date:Mb,discriminatedUnion:Yb,effect:Sh,enum:ax,function:nx,instanceof:$b,intersection:Xb,lazy:ix,literal:sx,map:tx,nan:Db,nativeEnum:ox,never:Fb,null:Lb,nullable:lx,number:ay,object:zb,oboolean:mx,onumber:px,optional:ux,ostring:hx,pipeline:fx,preprocess:dx,promise:cx,record:ex,set:rx,strictObject:Gb,string:sy,symbol:Ub,transformer:Sh,tuple:Qb,undefined:Vb,union:Jb,unknown:Hb,void:Kb,NEVER:gx,ZodIssueCode:D,quotelessJson:yb,ZodError:or}),dt=class Il extends mb{constructor(t){super(t);ne(this,"openAPIRegistry");ne(this,"defaultHook");ne(this,"openapi",({middleware:t,...n},i,s=this.defaultHook)=>{var u,f,m,B,C,p,g,A,O,P;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const N=xi("query",n.request.query,s);a.push(N)}if((f=n.request)!=null&&f.params){const N=xi("param",n.request.params,s);a.push(N)}if((m=n.request)!=null&&m.headers){const N=xi("header",n.request.headers,s);a.push(N)}if((B=n.request)!=null&&B.cookies){const N=xi("cookie",n.request.cookies,s);a.push(N)}const o=(p=(C=n.request)==null?void 0:C.body)==null?void 0:p.content;if(o)for(const N of Object.keys(o)){if(!o[N])continue;const xe=o[N].schema;if(xe instanceof Ae){if(Oh(N)){const Le=xi("json",xe,s);if((A=(g=n.request)==null?void 0:g.body)!=null&&A.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Oh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("json",{}),await tt()};a.push(qe)}}if(Eh(N)){const Le=xi("form",xe,s);if((P=(O=n.request)==null?void 0:O.body)!=null&&P.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Eh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("form",{}),await tt()};a.push(qe)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,i),this});ne(this,"getOpenAPIDocument",t=>{const i=new Cv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Ah(i,this._basePath):i});ne(this,"getOpenAPI31Document",t=>{const i=new Nv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Ah(i,this._basePath):i});ne(this,"doc",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPIDocument(s);return i.json(a)}catch(a){return i.json(a,500)}}));ne(this,"doc31",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPI31Document(s);return i.json(a)}catch(a){return i.json(a,500)}}));this.openAPIRegistry=new dv,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const i=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Il?(n.openAPIRegistry.definitions.forEach(s=>{switch(s.type){case"component":return this.openAPIRegistry.registerComponent(s.componentType,s.name,s.component);case"route":return this.openAPIRegistry.registerPath({...s.route,path:nn(i,s.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...s.webhook,path:nn(i,s.webhook.path)});case"schema":return this.openAPIRegistry.register(s.schema._def.openapi._internal.refId,s.schema);case"parameter":return this.openAPIRegistry.registerParameter(s.schema._def.openapi._internal.refId,s.schema);default:{const a=s;throw new Error(`Unknown registry type: ${a}`)}}}),this):this}basePath(t){return new Il({...super.basePath(t),defaultHook:this.defaultHook})}},ve=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};ov(y);function Ah(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[nn(e,n)]=r.paths[n]}),{...r,paths:t}}function Oh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function Eh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function vx(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 i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function bx(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ks(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function xx(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=vx(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=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(O).length>0?{metadata:O}:void 0)}));if(bx(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},ks(r,"optional"),ks(r,"nullable"),ks(r,"default"),ks(r,"transform"),ks(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var Pe;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Pe||(Pe={}));var Cl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Cl||(Cl={}));const G=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),an=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}},Z=Pe.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"]),_x=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Dt 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(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof Dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const Hi=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.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}"`:Pe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.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 Z.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 Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,Pe.assertNever(r)}return{message:t}};let cy=Hi;function wx(r){cy=r}function Go(){return cy}const Jo=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},kx=[];function F(r,e){const t=Go(),n=Jo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hi?void 0:Hi].filter(i=>!!i)});r.common.issues.push(n)}class gt{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 i of t){if(i.status==="aborted")return ge;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return gt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return ge;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const ge=Object.freeze({status:"aborted"}),Yo=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),jl=r=>r.status==="aborted",Tl=r=>r.status==="dirty",ia=r=>r.status==="valid",sa=r=>typeof Promise<"u"&&r instanceof Promise;function Xo(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 uy(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!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 oe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(oe||(oe={}));var js,Ts;class Ar{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 Ih=(r,e)=>{if(ia(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 Dt(r.common.issues);return this._error=t,this._error}}};function we(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=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:i}:{errorMap:(s,a)=>{var o,c;const{message:u}=r;return s.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:i}}class Ee{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 an(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gt,ctx:{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(sa(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 i={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:an(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Ih(i,s)}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:an(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(sa(i)?i:Promise.resolve(i));return Ih(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:Z.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new fr({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _r.create(this,this._def)}nullable(){return wn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cr.create(this,this._def)}promise(){return Ki.create(this,this._def)}or(e){return ua.create([this,e],this._def)}and(e){return la.create(this,e,this._def)}transform(e){return new fr({...we(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ma({...we(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new uf({typeName:fe.ZodBranded,type:this,...we(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ya({...we(this._def),innerType:this,catchValue:t,typeName:fe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ya.create(this,e)}readonly(){return ga.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Sx=/^c[^\s-]{8,}$/i,Ax=/^[0-9a-z]+$/,Ox=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ex=/^[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,Ix=/^[a-z0-9_-]{21}$/i,Cx=/^[-+]?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)?)??$/,jx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let rl;const Nx=/^(?:(?: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])$/,Bx=/^(([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})))$/,Rx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ly="((\\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])))",Px=new RegExp(`^${ly}$`);function dy(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 $x(r){return new RegExp(`^${dy(r)}$`)}function fy(r){let e=`${ly}T${dy(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 Dx(r,e){return!!((e==="v4"||!e)&&Nx.test(r)||(e==="v6"||!e)&&Bx.test(r))}class ir extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.string,received:i.parsedType}),ge}const t=new gt;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="length"){const s=e.data.length>i.value,a=e.data.length<i.value;(s||a)&&(n=this._getOrReturnCtx(e,n),s?F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if(i.kind==="email")jx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="emoji")rl||(rl=new RegExp(Tx,"u")),rl.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="uuid")Ex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="nanoid")Ix.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid")Sx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid2")Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="ulid")Ox.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:Z.invalid_string,message:i.message}),t.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:Z.invalid_string,message:i.message}),t.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty()):i.kind==="datetime"?fy(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"datetime",message:i.message}),t.dirty()):i.kind==="date"?Px.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"date",message:i.message}),t.dirty()):i.kind==="time"?$x(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"time",message:i.message}),t.dirty()):i.kind==="duration"?Cx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="ip"?Dx(e.data,i.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="base64"?Rx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:Z.invalid_string,message:i.message}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Z.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new ir({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...oe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...oe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...oe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...oe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...oe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...oe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...oe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...oe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...oe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...oe.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,...oe.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,...oe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...oe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...oe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...oe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...oe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...oe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...oe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...oe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...oe.errToObj(t)})}nonempty(e){return this.min(1,oe.errToObj(e))}trim(){return new ir({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ir({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ir({...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}}ir.create=r=>{var e;return new ir({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};function Zx(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class bn extends Ee{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 i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.number,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?Zx(e.data,i.value)!==0&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_finite,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new bn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:oe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:oe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:oe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:oe.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"&&Pe.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)}}bn.create=r=>new bn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class xn extends Ee{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 i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.bigint,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new xn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new xn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.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}}xn.create=r=>{var e;return new xn({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};class aa extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.boolean,received:t.parsedType}),ge}return wt(e.data)}}aa.create=r=>new aa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class ei extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.date,received:i.parsedType}),ge}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_date}),ge}const t=new gt;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:oe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:oe.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}}ei.create=r=>new ei({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...we(r)});class Qo extends Ee{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.symbol,received:t.parsedType}),ge}return wt(e.data)}}Qo.create=r=>new Qo({typeName:fe.ZodSymbol,...we(r)});class oa extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.undefined,received:t.parsedType}),ge}return wt(e.data)}}oa.create=r=>new oa({typeName:fe.ZodUndefined,...we(r)});class ca extends Ee{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.null,received:t.parsedType}),ge}return wt(e.data)}}ca.create=r=>new ca({typeName:fe.ZodNull,...we(r)});class Fi extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Fi.create=r=>new Fi({typeName:fe.ZodAny,...we(r)});class Gn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}Gn.create=r=>new Gn({typeName:fe.ZodUnknown,...we(r)});class Fr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.never,received:t.parsedType}),ge}}Fr.create=r=>new Fr({typeName:fe.ZodNever,...we(r)});class ec extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.void,received:t.parsedType}),ge}return wt(e.data)}}ec.create=r=>new ec({typeName:fe.ZodVoid,...we(r)});class cr extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==G.array)return F(t,{code:Z.invalid_type,expected:G.array,received:t.parsedType}),ge;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(F(t,{code:a?Z.too_big:Z.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(F(t,{code:Z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(F(t,{code:Z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>gt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Ar(t,a,t.path,o)));return gt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new cr({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new cr({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new cr({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}cr.create=(r,e)=>new cr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...we(e)});function Si(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Si(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof cr?new cr({...r._def,type:Si(r.element)}):r instanceof _r?_r.create(Si(r.unwrap())):r instanceof wn?wn.create(Si(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>Si(e))):r}class Je extends Ee{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=Pe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const c=this._getOrReturnCtx(e);return F(c,{code:Z.invalid_type,expected:G.object,received:c.parsedType}),ge}const{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const c in n.data)s.includes(c)||a.push(c);const o=[];for(const c of s){const u=i[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Ar(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Fr){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")a.length>0&&(F(n,{code:Z.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const f=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Ar(n,f,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const f=await u.key,m=await u.value;c.push({key:f,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>gt.mergeObjectSync(t,c)):gt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=oe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(e){return new Je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Je({...this._def,catchall:e})}pick(e){const t={};return Pe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return Si(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Je({...this._def,shape:()=>t})}required(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof _r;)i=i._def.innerType;t[n]=i}}),new Je({...this._def,shape:()=>t})}keyof(){return hy(Pe.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});class ua extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Dt(o.ctx.common.issues));return F(t,{code:Z.invalid_union,unionErrors:a}),ge}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new Dt(c));return F(t,{code:Z.invalid_union,unionErrors:o}),ge}}get options(){return this._def.options}}ua.create=(r,e)=>new ua({options:r,typeName:fe.ZodUnion,...we(e)});const rn=r=>r instanceof fa?rn(r.schema):r instanceof fr?rn(r.innerType()):r instanceof ha?[r.value]:r instanceof _n?r.options:r instanceof pa?Pe.objectValues(r.enum):r instanceof ma?rn(r._def.innerType):r instanceof oa?[void 0]:r instanceof ca?[null]:r instanceof _r?[void 0,...rn(r.unwrap())]:r instanceof wn?[null,...rn(r.unwrap())]:r instanceof uf||r instanceof ga?rn(r.unwrap()):r instanceof ya?rn(r._def.innerType):[];class ru extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return F(t,{code:Z.invalid_type,expected:G.object,received:t.parsedType}),ge;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ge)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=rn(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new ru({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...we(n)})}}function Nl(r,e){const t=an(r),n=an(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const i=Pe.objectKeys(e),s=Pe.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=Nl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=Nl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class la extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(jl(s)||jl(a))return ge;const o=Nl(s.value,a.value);return o.valid?((Tl(s)||Tl(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:Z.invalid_intersection_types}),ge)};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(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}la.create=(r,e,t)=>new la({left:r,right:e,typeName:fe.ZodIntersection,...we(t)});class Or extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:Z.invalid_type,expected:G.array,received:n.parsedType}),ge;if(n.data.length<this._def.items.length)return F(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ge;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((s,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Ar(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>gt.mergeArray(t,s)):gt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Or({...this._def,rest:e})}}Or.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Or({items:r,typeName:fe.ZodTuple,rest:null,...we(e)})};class da extends Ee{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 F(n,{code:Z.invalid_type,expected:G.object,received:n.parsedType}),ge;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Ar(n,o,n.path,o)),value:a._parse(new Ar(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?gt.mergeObjectAsync(t,i):gt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new da({keyType:e,valueType:t,typeName:fe.ZodRecord,...we(n)}):new da({keyType:ir.create(),valueType:e,typeName:fe.ZodRecord,...we(t)})}}class tc extends Ee{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 F(n,{code:Z.invalid_type,expected:G.map,received:n.parsedType}),ge;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Ar(n,o,n.path,[u,"key"])),value:s._parse(new Ar(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}tc.create=(r,e,t)=>new tc({valueType:e,keyType:r,typeName:fe.ZodMap,...we(t)});class ti extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:Z.invalid_type,expected:G.set,received:n.parsedType}),ge;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(F(n,{code:Z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(F(n,{code:Z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ge;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Ar(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ti({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new ti({...this._def,maxSize:{value:e,message:oe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ti.create=(r,e)=>new ti({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...we(e)});class Ti extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return F(t,{code:Z.invalid_type,expected:G.function,received:t.parsedType}),ge;function n(o,c){return Jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Go(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function i(o,c){return Jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Go(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ki){const o=this;return wt(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,s).catch(B=>{throw u.addIssue(n(c,B)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(B=>{throw u.addIssue(i(m,B)),u})})}else{const o=this;return wt(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new Dt([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ti({...this._def,args:Or.create(e).rest(Gn.create())})}returns(e){return new Ti({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ti({args:e||Or.create([]).rest(Gn.create()),returns:t||Gn.create(),typeName:fe.ZodFunction,...we(n)})}}class fa extends Ee{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})}}fa.create=(r,e)=>new fa({getter:r,typeName:fe.ZodLazy,...we(e)});class ha extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),ge}return{status:"valid",value:e.data}}get value(){return this._def.value}}ha.create=(r,e)=>new ha({value:r,typeName:fe.ZodLiteral,...we(e)});function hy(r,e){return new _n({values:r,typeName:fe.ZodEnum,...we(e)})}class _n extends Ee{constructor(){super(...arguments),js.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Pe.joinValues(n),received:t.parsedType,code:Z.invalid_type}),ge}if(Xo(this,js)||uy(this,js,new Set(this._def.values)),!Xo(this,js).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:Z.invalid_enum_value,options:n}),ge}return wt(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 _n.create(e,{...this._def,...t})}exclude(e,t=this._def){return _n.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}js=new WeakMap;_n.create=hy;class pa extends Ee{constructor(){super(...arguments),Ts.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const i=Pe.objectValues(t);return F(n,{expected:Pe.joinValues(i),received:n.parsedType,code:Z.invalid_type}),ge}if(Xo(this,Ts)||uy(this,Ts,new Set(Pe.getValidEnumValues(this._def.values))),!Xo(this,Ts).has(e.data)){const i=Pe.objectValues(t);return F(n,{received:n.data,code:Z.invalid_enum_value,options:i}),ge}return wt(e.data)}get enum(){return this._def.values}}Ts=new WeakMap;pa.create=(r,e)=>new pa({values:r,typeName:fe.ZodNativeEnum,...we(e)});class Ki extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return F(t,{code:Z.invalid_type,expected:G.promise,received:t.parsedType}),ge;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return wt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ki.create=(r,e)=>new Ki({type:r,typeName:fe.ZodPromise,...we(e)});class fr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ge;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ge:c.status==="dirty"||t.value==="dirty"?Yo(c.value):c});{if(t.value==="aborted")return ge;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ge:o.status==="dirty"||t.value==="dirty"?Yo(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);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"?ge:(o.status==="dirty"&&t.dirty(),a(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"?ge:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ia(a))return a;const o=i.transform(a.value,s);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(a=>ia(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(i)}}fr.create=(r,e,t)=>new fr({schema:r,typeName:fe.ZodEffects,effect:e,...we(t)});fr.createWithPreprocess=(r,e,t)=>new fr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...we(t)});class _r extends Ee{_parse(e){return this._getType(e)===G.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_r.create=(r,e)=>new _r({innerType:r,typeName:fe.ZodOptional,...we(e)});class wn extends Ee{_parse(e){return this._getType(e)===G.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wn.create=(r,e)=>new wn({innerType:r,typeName:fe.ZodNullable,...we(e)});class ma extends Ee{_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}}ma.create=(r,e)=>new ma({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...we(e)});class ya extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return sa(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ya.create=(r,e)=>new ya({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...we(e)});class rc extends Ee{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.nan,received:t.parsedType}),ge}return{status:"valid",value:e.data}}}rc.create=r=>new rc({typeName:fe.ZodNaN,...we(r)});const Mx=Symbol("zod_brand");class uf extends Ee{_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 Ya extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),Yo(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Ya({in:e,out:t,typeName:fe.ZodPipeline})}}class ga extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=i=>(ia(i)&&(i.value=Object.freeze(i.value)),i);return sa(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodReadonly,...we(e)});function py(r,e={},t){return r?Fi.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Fi.create()}const Ux={object:Je.lazycreate};var fe;(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"})(fe||(fe={}));const Vx=(r,e={message:`Input not instance of ${r.name}`})=>py(t=>t instanceof r,e),my=ir.create,yy=bn.create,Lx=rc.create,qx=xn.create,gy=aa.create,Hx=ei.create,Fx=Qo.create,Kx=oa.create,Wx=ca.create,zx=Fi.create,Gx=Gn.create,Jx=Fr.create,Yx=ec.create,Xx=cr.create,Qx=Je.create,e_=Je.strictCreate,t_=ua.create,r_=ru.create,n_=la.create,i_=Or.create,s_=da.create,a_=tc.create,o_=ti.create,c_=Ti.create,u_=fa.create,l_=ha.create,d_=_n.create,f_=pa.create,h_=Ki.create,Ch=fr.create,p_=_r.create,m_=wn.create,y_=fr.createWithPreprocess,g_=Ya.create,v_=()=>my().optional(),b_=()=>yy().optional(),x_=()=>gy().optional(),__={string:r=>ir.create({...r,coerce:!0}),number:r=>bn.create({...r,coerce:!0}),boolean:r=>aa.create({...r,coerce:!0}),bigint:r=>xn.create({...r,coerce:!0}),date:r=>ei.create({...r,coerce:!0})},w_=ge;var d=Object.freeze({__proto__:null,defaultErrorMap:Hi,setErrorMap:wx,getErrorMap:Go,makeIssue:Jo,EMPTY_PATH:kx,addIssueToContext:F,ParseStatus:gt,INVALID:ge,DIRTY:Yo,OK:wt,isAborted:jl,isDirty:Tl,isValid:ia,isAsync:sa,get util(){return Pe},get objectUtil(){return Cl},ZodParsedType:G,getParsedType:an,ZodType:Ee,datetimeRegex:fy,ZodString:ir,ZodNumber:bn,ZodBigInt:xn,ZodBoolean:aa,ZodDate:ei,ZodSymbol:Qo,ZodUndefined:oa,ZodNull:ca,ZodAny:Fi,ZodUnknown:Gn,ZodNever:Fr,ZodVoid:ec,ZodArray:cr,ZodObject:Je,ZodUnion:ua,ZodDiscriminatedUnion:ru,ZodIntersection:la,ZodTuple:Or,ZodRecord:da,ZodMap:tc,ZodSet:ti,ZodFunction:Ti,ZodLazy:fa,ZodLiteral:ha,ZodEnum:_n,ZodNativeEnum:pa,ZodPromise:Ki,ZodEffects:fr,ZodTransformer:fr,ZodOptional:_r,ZodNullable:wn,ZodDefault:ma,ZodCatch:ya,ZodNaN:rc,BRAND:Mx,ZodBranded:uf,ZodPipeline:Ya,ZodReadonly:ga,custom:py,Schema:Ee,ZodSchema:Ee,late:Ux,get ZodFirstPartyTypeKind(){return fe},coerce:__,any:zx,array:Xx,bigint:qx,boolean:gy,date:Hx,discriminatedUnion:r_,effect:Ch,enum:d_,function:c_,instanceof:Vx,intersection:n_,lazy:u_,literal:l_,map:a_,nan:Lx,nativeEnum:f_,never:Jx,null:Wx,nullable:m_,number:yy,object:Qx,oboolean:x_,onumber:b_,optional:p_,ostring:v_,pipeline:g_,preprocess:y_,promise:h_,record:s_,set:o_,strictObject:e_,string:my,symbol:Fx,transformer:Ch,tuple:i_,undefined:Kx,union:t_,unknown:Gx,void:Yx,NEVER:w_,ZodIssueCode:Z,quotelessJson:_x,ZodError:Dt});xx(d);const jn=d.object({start:d.number(),limit:d.number(),length:d.number()}),lf=d.object({created_at:d.string(),updated_at:d.string()}),vy=d.object({email:d.string().optional(),email_verified:d.boolean().optional(),name:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),phone_number:d.string().optional(),phone_verified:d.boolean().optional(),family_name:d.string().optional()}).catchall(d.any()),by=d.object({connection:d.string(),user_id:d.string(),provider:d.string(),isSocial:d.boolean(),access_token:d.string().optional(),access_token_secret:d.string().optional(),refresh_token:d.string().optional(),profileData:vy.optional()}),nu=d.object({email:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),family_name:d.string().optional(),nickname:d.string().optional(),name:d.string().optional(),picture:d.string().optional(),locale:d.string().optional(),linked_to:d.string().optional(),profileData:d.string().optional(),user_id:d.string().optional(),app_metadata:d.any().default({}).optional(),user_metadata:d.any().default({}).optional()}),nc=nu.extend({email_verified:d.boolean().default(!1),verify_email:d.boolean().optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string().optional(),provider:d.string().default("email"),connection:d.string().default("email")}),df=d.object({...nc.shape,...lf.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(by).optional()}),vr=df,k_=nu.extend({email:d.string(),login_count:d.number(),multifactor:d.array(d.string()).optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string()}).catchall(d.any()),S_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let A_=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=S_[t[r]&63];return e};const xy=d.object({audience:d.string().optional(),recipient:d.string().optional(),createUpnClaim:d.boolean().optional(),mapUnknownClaimsAsIs:d.boolean().optional(),passthroughClaimsWithNoMapping:d.boolean().optional(),mapIdentities:d.boolean().optional(),signatureAlgorithm:d.string().optional(),digestAlgorithm:d.string().optional(),issuer:d.string().optional(),destination:d.string().optional(),lifetimeInSeconds:d.number().optional(),signResponse:d.boolean().optional(),nameIdentifierFormat:d.string().optional(),nameIdentifierProbes:d.array(d.string()).optional(),authnContextClassRef:d.string().optional(),mappings:d.record(d.string()).optional()}),ic=d.object({id:d.string(),name:d.string(),callbacks:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:d.array(d.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:d.object({samlp:xy.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:d.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:d.string().default(()=>A_()).optional(),disable_sign_ups:d.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Mn=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...ic.shape});var ff=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(ff||{}),hf=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(hf||{}),pf=(r=>(r.S256="S256",r.Plain="plain",r))(pf||{});const _y=d.object({client_id:d.string(),vendor_id:d.string().optional(),act_as:d.string().optional(),response_type:d.nativeEnum(ff).optional(),response_mode:d.nativeEnum(hf).optional(),redirect_uri:d.string().optional(),audience:d.string().optional(),state:d.string().optional(),nonce:d.string().optional(),scope:d.string().optional(),prompt:d.string().optional(),code_challenge_method:d.nativeEnum(pf).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),Bl=d.object({colors:d.object({primary:d.string(),page_background:d.object({type:d.string().optional(),start:d.string().optional(),end:d.string().optional(),angle_deg:d.number().optional()}).optional()}).optional(),logo_url:d.string().optional(),favicon_url:d.string().optional(),font:d.object({url:d.string()}).optional()}),sc=d.object({id:d.string().optional(),name:d.string(),strategy:d.enum(["google-oauth2","facebook","vipps","freja","apple","email","auth0","authhero","Username-Password-Authentication","oidc","oauth2","custom"]),options:d.object({kid:d.string().optional(),team_id:d.string().optional(),realms:d.string().optional(),client_id:d.string().optional(),client_secret:d.string().optional(),app_secret:d.string().optional(),scope:d.string().optional(),authorization_endpoint:d.string().default("").optional(),token_endpoint:d.string().default("").optional(),userinfo_endpoint:d.string().default("").optional(),jwks_uri:d.string().default("").optional(),discovery_url:d.string().default("").optional(),issuer:d.string().default("").optional()}).default({}).optional(),enabled_clients:d.array(d.string()).default([]).optional(),response_type:d.custom().optional(),response_mode:d.custom().optional()}),Un=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(sc.shape),ac=d.object({name:d.string(),audience:d.string(),sender_email:d.string().email(),sender_name:d.string(),support_url:d.string().url().optional(),logo:d.string().url().optional(),primary_color:d.string().optional(),secondary_color:d.string().optional(),language:d.string().optional()}),Ni=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...ac.shape}),O_=d.object({logoUrl:d.string(),loginBackgroundImage:d.string().nullish(),style:d.object({primaryColor:d.string(),buttonTextColor:d.string(),primaryHoverColor:d.string()}),supportEmail:d.string().nullable(),supportUrl:d.string().nullable(),name:d.string(),showGreyishBackground:d.boolean().optional(),termsAndConditionsUrl:d.string().nullable(),companyName:d.string().optional(),checkoutHideSocial:d.boolean().optional(),siteUrl:d.string().nullable(),manageSubscriptionsUrl:d.string().optional()}),E_=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.union([d.literal("mailgun"),d.literal("mailchannels")]).optional()});d.object({...Mn.shape,domains:d.array(E_),tenant:Ni,connections:d.array(Un)});const wy=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),ky=d.object({code_id:d.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:d.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:d.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:wy,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()}),I_=d.object({...ky.shape,created_at:d.string()}),Sy=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.enum(["mailgun","mailchannels"])}),C_=lf.extend({...Sy.shape,id:d.string()}),oc=d.object({trigger_id:d.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:d.boolean().default(!1),url:d.string(),hook_id:d.string().optional(),synchronous:d.boolean().default(!1),priority:d.number().optional()}),Ei=oc.extend({...lf.shape,hook_id:d.string()}),mf=d.object({alg:d.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:d.string(),kid:d.string(),kty:d.enum(["RSA","EC","oct"]),n:d.string(),x5t:d.string().optional(),x5c:d.array(d.string()).optional(),use:d.enum(["sig","enc"]).optional()}),Ay=d.object({keys:d.array(mf)}),Rl=d.object({issuer:d.string(),authorization_endpoint:d.string(),token_endpoint:d.string(),device_authorization_endpoint:d.string(),userinfo_endpoint:d.string(),mfa_challenge_endpoint:d.string(),jwks_uri:d.string(),registration_endpoint:d.string(),revocation_endpoint:d.string(),scopes_supported:d.array(d.string()),response_types_supported:d.array(d.string()),code_challenge_methods_supported:d.array(d.string()),response_modes_supported:d.array(d.string()),subject_types_supported:d.array(d.string()),id_token_signing_alg_values_supported:d.array(d.string()),token_endpoint_auth_methods_supported:d.array(d.string()),claims_supported:d.array(d.string()),request_uri_parameter_supported:d.boolean(),request_parameter_supported:d.boolean(),token_endpoint_auth_signing_alg_values_supported:d.array(d.string())}),Oy=d.object({auth0Client:d.string().optional(),authParams:_y,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional(),useragent:d.string().optional()}).openapi({description:"This represents a login sesion"}),j_=d.object({...Oy.shape,login_id:d.string().openapi({description:"This is is used as the state in the universal login"}),created_at:d.string(),updated_at:d.string()});var iu=(r=>(r.FAILED_SILENT_AUTH="fsa",r.FAILED_SIGNUP="fs",r.FAILED_LOGIN="f",r.FAILED_LOGIN_INCORRECT_PASSWORD="fp",r.FAILED_CHANGE_PASSWORD="fcp",r.FAILED_BY_CONNECTOR="fc",r.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",r.FAILED_HOOK="fh",r.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",r.SUCCESS_API_OPERATION="sapi",r.SUCCESS_CHANGE_PASSWORD="scp",r.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",r.SUCCESS_CHANGE_USERNAME="scu",r.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",r.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",r.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",r.SUCCESS_LOGIN="s",r.SUCCESS_LOGOUT="slo",r.SUCCESS_SIGNUP="ss",r.SUCCESS_SILENT_AUTH="ssa",r.SUCCESS_VERIFICATION_EMAIL="sv",r.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",r.CODE_LINK_SENT="cls",r))(iu||{});const T_=d.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),Ey=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),cc=d.object({type:T_,date:d.string(),description:d.string().optional(),log_id:d.string().optional(),_id:d.string().optional(),ip:d.string(),user_agent:d.string(),details:d.any().optional(),isMobile:d.boolean(),user_id:d.string().optional(),user_name:d.string().optional(),connection:d.string().optional(),connection_id:d.string().optional(),client_id:d.string().optional(),client_name:d.string().optional(),audience:d.string().optional(),scope:d.array(d.string()).optional(),strategy:d.string().optional(),strategy_type:d.string().optional(),hostname:d.string().optional(),auth0_client:Ey.optional()}),Iy=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")}),N_=d.object({...Iy.shape,created_at:d.string(),updated_at:d.string()}),Cy=d.object({session_id:d.string(),client_id:d.string(),expires_at:d.string(),used_at:d.string(),deleted_at:d.string().optional(),user_id:d.string()}),yf=d.object({created_at:d.string(),...Cy.shape}),Pl=d.object({kid:d.string().openapi({description:"The key id of the signing key"}),cert:d.string().openapi({description:"The public certificate of the signing key"}),fingerprint:d.string().openapi({description:"The cert fingerprint"}),thumbprint:d.string().openapi({description:"The cert thumbprint"}),pkcs7:d.string().optional().openapi({description:"The private key in pkcs7 format"}),current:d.boolean().optional().openapi({description:"True if the key is the current key"}),next:d.boolean().optional().openapi({description:"True if the key is the next key"}),previous:d.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:d.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:d.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:d.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:d.string().optional().openapi({description:"The date and time when the key was revoked"})});var uc=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(uc||{});d.object({access_token:d.string(),id_token:d.string().optional(),scope:d.string().optional(),state:d.string().optional(),refresh_token:d.string().optional(),token_type:d.string(),expires_in:d.number()});d.object({code:d.string(),state:d.string().optional()});const jy=d.object({button_border_radius:d.number(),button_border_weight:d.number(),buttons_style:d.enum(["pill"]),input_border_radius:d.number(),input_border_weight:d.number(),inputs_style:d.enum(["pill"]),show_widget_shadow:d.boolean(),widget_border_weight:d.number(),widget_corner_radius:d.number()}),Ty=d.object({base_focus_color:d.string(),base_hover_color:d.string(),body_text:d.string(),captcha_widget_theme:d.enum(["auto"]),error:d.string(),header:d.string(),icons:d.string(),input_background:d.string(),input_border:d.string(),input_filled_text:d.string(),input_labels_placeholders:d.string(),links_focused_components:d.string(),primary_button:d.string(),primary_button_label:d.string(),secondary_button_border:d.string(),secondary_button_label:d.string(),success:d.string(),widget_background:d.string(),widget_border:d.string()}),Dn=d.object({bold:d.boolean(),size:d.number()}),Ny=d.object({body_text:Dn,buttons_text:Dn,font_url:d.string(),input_labels:Dn,links:Dn,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Dn,title:Dn}),By=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),Ry=d.object({header_text_alignment:d.enum(["center"]),logo_height:d.number(),logo_position:d.enum(["center"]),logo_url:d.string(),social_buttons_layout:d.enum(["bottom"])}),Py=d.object({borders:jy,colors:Ty,displayName:d.string(),fonts:Ny,page_background:By,widget:Ry}),B_=Py.extend({themeId:d.string()}),jo=d.object({universal_login_experience:d.enum(["new","classic"]).default("new"),identifier_first:d.boolean().default(!0),password_first:d.boolean().default(!1),webauthn_platform_first_factor:d.boolean()}),To=d.object({name:d.string(),enabled:d.boolean().optional().default(!0),default_from_address:d.string().optional(),credentials:d.union([d.object({accessKeyId:d.string(),secretAccessKey:d.string(),region:d.string()}),d.object({smtp_host:d.array(d.string()),smtp_port:d.number(),smtp_user:d.string(),smtp_pass:d.string()}),d.object({api_key:d.string(),domain:d.string().optional()}),d.object({connectionString:d.string()}),d.object({tenantId:d.string(),clientId:d.string(),clientSecret:d.string()})]),settings:d.object({}).optional()});function R_(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}const P_=new dt().openapi(ve({tags:["branding"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Bl}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.branding.get(e);return t?r.json(t):r.json({})}).openapi(ve({tags:["branding"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(Bl.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});var lc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $_(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function D_(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}function Z_(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var $y={exports:{}};const M_={},U_=Object.freeze(Object.defineProperty({__proto__:null,default:M_},Symbol.toStringTag,{value:"Module"})),V_=D_(U_);(function(r){/**
1
+ "use strict";var iv=Object.defineProperty;var yh=r=>{throw TypeError(r)};var sv=(r,e,t)=>e in r?iv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ne=(r,e,t)=>sv(r,typeof e!="symbol"?e+"":e,t),Xu=(r,e,t)=>e.has(r)||yh("Cannot "+t);var w=(r,e,t)=>(Xu(r,e,"read from private field"),t?t.call(r):e.get(r)),Oe=(r,e,t)=>e.has(r)?yh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ue=(r,e,t,n)=>(Xu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Te=(r,e,t)=>(Xu(r,e,"access private method"),t);var gh=(r,e,t,n)=>({set _(i){ue(r,e,i,t)},get _(){return w(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function As(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 i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function Se(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function av(r){return"_def"in r}function xs(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function ov(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=As(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=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(O).length>0?{metadata:O}:void 0)}));if(Se(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},xs(r,"optional"),xs(r,"nullable"),xs(r,"default"),xs(r,"transform"),xs(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}function Zo(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=>Zo(r[n],e[n]))}class cv{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(s=>Zo(s,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(i=>Zo(i,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const s of this.buckets.values())e+=1,t+=s.length,s.length>1&&(n+=1);const i=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:i}}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,i]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(i??"");return t}}function Rs(r){return r==null}function Ps(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{t[n]=e(i)}),t}function uv(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e.some(s=>s===n)||(t[n]=i)}),t}function ji(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e(i,n)||(t[n]=i)}),t}function vh(r){return r.filter(e=>!Rs(e))}const yl=Zo;function lv(r){const e=new cv;return r.forEach(t=>e.put(t)),[...e.values()]}function wm(r){return typeof r=="string"}class dv{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(i=>i.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,i,s;const a=this.schemaWithRefId(e,t),o=(n=a._def.openapi)===null||n===void 0?void 0:n.metadata,c=a.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(s=(i=o==null?void 0:o.param)===null||i===void 0?void 0:i.name)!==null&&s!==void 0?s: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 tu{constructor(e){this.message=e}}class _s extends tu{constructor(e,t){super(e),this.data=t}}class Mo extends tu{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 ws(r,e){try{return r()}catch(t){throw t instanceof Mo?new Mo(Object.assign(Object.assign({},t.data),e)):t}}class fv extends tu{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class We{static getMetadata(e){var t;const n=this.unwrapChained(e),i=e._def.openapi?e._def.openapi:n._def.openapi,s=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:i==null?void 0:i._internal,metadata:Object.assign({description:s},i==null?void 0:i.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 i=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:i._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:i.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign(Object.assign({},s==null?void 0:s.metadata),{param:Object.assign({description:a},(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return ji(uv(e,["param"]),Rs)}static buildParameterMetadata(e){return ji(e,Rs)}static applySchemaMetadata(e,t){return ji(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Rs)}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&&Se(e,t)?e:Se(e,"ZodOptional")||Se(e,"ZodNullable")||Se(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):Se(e,"ZodDefault")||Se(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):Se(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):Se(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return Se(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class hv{transform(e,t,n){var i,s;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:(i=e._def.minLength)===null||i===void 0?void 0:i.value,maxItems:(s=e._def.maxLength)===null||s===void 0?void 0:s.value})}}class pv{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class mv{transform(e,t,n,i,s){const a=[...e.options.values()],o=a.map(i);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(a,e.discriminator,s)}}mapDiscriminator(e,t,n){if(e.some(s=>We.getRefId(s)===void 0))return;const i={};return e.forEach(s=>{var a;const o=We.getRefId(s),c=(a=s.shape)===null||a===void 0?void 0:a[t];if(Se(c,"ZodEnum")||Se(c,"ZodNativeEnum")){Object.values(c.enum).filter(wm).forEach(m=>{i[m]=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`);i[u]=n(o)}),{propertyName:t,mapping:i}}}class yv{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class gv{transform(e,t,n,i){const a={allOf:this.flattenIntersectionTypes(e).map(i)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!Se(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class vv{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function bv(r){const t=Object.keys(r).filter(s=>typeof r[r[s]]!="number").map(s=>r[s]),n=t.filter(s=>typeof s=="number").length,i=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:i}}class xv{transform(e,t){const{type:n,values:i}=bv(e._def.values);if(n==="mixed")throw new tu("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:i})}}class _v{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class wv{transform(e,t,n,i){var s;const a=(s=We.getInternalMetadata(e))===null||s===void 0?void 0:s.extendedFrom,o=this.requiredKeysOf(e),c=Ps(e._def.shape(),i);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,i));const u=a.schema;i(u);const f=this.requiredKeysOf(u),m=Ps(u==null?void 0:u._def.shape(),i),B=Object.fromEntries(Object.entries(c).filter(([g,A])=>!yl(m[g],A))),C=o.filter(g=>!f.includes(g)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:B}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,i));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,i=e._def.catchall;return Se(i,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(i)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!We.isOptionalSchema(n)).map(([t,n])=>t)}}class kv{transform(e,t,n){const i=e._def.valueType,s=e._def.keyType,a=n(i);if(Se(s,"ZodEnum")||Se(s,"ZodNativeEnum")){const c=Object.values(s.enum).filter(wm).reduce((u,f)=>Object.assign(Object.assign({},u),{[f]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class Sv{transform(e,t){var n,i,s;const a=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(i=e.minLength)!==null&&i!==void 0?i:void 0,u=Number.isFinite(e.maxLength)&&(s=e.maxLength)!==null&&s!==void 0?s:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:a==null?void 0:a.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 Av{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:i}=e._def,s=i.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(s))}}class Ov{transform(e,t,n){const s=this.flattenUnionTypes(e).map(a=>{const o=this.unwrapNullable(a);return n(o)});return{anyOf:t(s)}}flattenUnionTypes(e){return Se(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return Se(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Ev{constructor(e){this.versionSpecifics=e,this.objectTransformer=new wv,this.stringTransformer=new Sv,this.numberTransformer=new _v,this.bigIntTransformer=new pv,this.literalTransformer=new vv,this.enumTransformer=new yv,this.nativeEnumTransformer=new xv,this.arrayTransformer=new hv,this.unionTransformer=new Ov,this.discriminatedUnionTransformer=new mv,this.intersectionTransformer=new gv,this.recordTransformer=new kv,this.tupleTransformer=new Av(e)}transform(e,t,n,i,s){if(Se(e,"ZodNull"))return this.versionSpecifics.nullType;if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodObject"))return this.objectTransformer.transform(e,s,o=>this.versionSpecifics.mapNullableType(o,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,i);return Object.assign(Object.assign({},a),{default:s})}transformSchemaWithoutDefault(e,t,n,i){if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(Se(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(Se(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,i);if(Se(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const s=We.getRefId(e);throw new fv({currentSchema:e._def,schemaName:s})}}class km{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Ev(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:i,name:s,component:a})=>{var o;(o=n[i])!==null&&o!==void 0||(n[i]={}),n[i][s]=a}),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 i=e.findIndex(a=>a===t.type),s=e.findIndex(a=>a===n.type);return i-s})}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=We.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,i,s,a,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId?this.paramRefs[(s=e._internal)===null||s===void 0?void 0:s.refId]:void 0;if(!(!(!((a=e==null?void 0:e._internal)===null||a===void 0)&&a.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new _s(`Conflicting location for parameter ${u.name}`,{key:"in",values:vh([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 _s("Conflicting names for parameter",{key:"name",values:vh([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 i=We.getMetadata(e),s=(n=i==null?void 0:i.metadata)===null||n===void 0?void 0:n.param,a=this.getParameterRef(i,{in:t});if(a)return[a];if(Se(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,B;const C=We.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const g=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(g!=null&&g.name&&g.name!==u)throw new _s("Conflicting names for parameter",{key:"name",values:[u,g.name]});if(g!=null&&g.in&&g.in!==t)throw new _s(`Conflicting location for parameter ${(B=g.name)!==null&&B!==void 0?B:u}`,{key:"in",values:[t,g.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(s!=null&&s.in&&s.in!==t)throw new _s(`Conflicting location for parameter ${s.name}`,{key:"in",values:[t,s.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=We.getParamMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=!We.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:s},i?We.buildParameterMetadata(i):{})}generateParameter(e){var t;const n=We.getMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=i==null?void 0:i.name,a=i==null?void 0:i.in;if(!s)throw new Mo({missingField:"name"});if(!a)throw new Mo({missingField:"in",paramName:s});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:a,name:s})}generateSchemaWithMetadata(e){var t;const n=We.unwrapChained(e),i=We.getMetadata(e),s=We.getDefaultValue(e),a=!((t=i==null?void 0:i.metadata)===null||t===void 0)&&t.type?{type:i==null?void 0:i.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),s);return i!=null&&i.metadata?We.applySchemaMetadata(a,i.metadata):ji(a,Rs)}constructReferencedOpenAPISchema(e){var t;const n=We.getMetadata(e),i=We.unwrapChained(e),s=We.getDefaultValue(e),a=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,a):this.toOpenAPISchema(i,a,s)}generateSimpleSchema(e){var t;const n=We.getMetadata(e),i=We.getRefId(e);if(!i||!this.schemaRefs[i])return this.generateSchemaWithMetadata(e);const s=this.schemaRefs[i],a={$ref:this.generateSchemaRef(i)},o=ji(We.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||yl(f,s[m]));if(o.type)return{allOf:[a,o]};const c=ji(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||yl(f,s[m])),u=We.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=We.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=As(e,["content"]),i=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:i})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),i=this.cleanParameter(e.params),s=this.cleanParameter(e.cookies),a=ws(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=ws(()=>i?this.generateInlineParameters(i,"path"):[],{location:"path"}),c=ws(()=>s?this.generateInlineParameters(s,"cookie"):[],{location:"cookie"}),u=ws(()=>{if(Array.isArray(t))return t.flatMap(m=>this.generateInlineParameters(m,"header"));const f=this.cleanParameter(t);return f?this.generateInlineParameters(f,"header"):[]},{location:"header"});return[...o,...a,...u,...c]}cleanParameter(e){if(e)return Se(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:i,responses:s}=e,a=As(e,["method","path","request","responses"]),o=Ps(s,m=>this.getResponse(m)),c=ws(()=>this.getParameters(i),{route:`${t} ${n}`}),u=this.getRequestBody(i==null?void 0:i.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},a),c.length>0?{parameters:[...a.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,i=As(e,["content","headers"]);const s=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},i),s);const a=Se(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},i),{headers:a}),s)}getResponseHeaders(e){const t=e._def.shape();return Ps(t,i=>this.generateSimpleParameter(i))}getBodyContent(e){return Ps(e,t=>{if(!t||!av(t.schema))return t;const{schema:n}=t,i=As(t,["schema"]),s=this.generateSchemaWithRef(n);return Object.assign({schema:s},i)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,i=>this.generateSchemaWithRef(i),i=>this.generateSchemaRef(i),n)}}class Iv{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=lv(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 Cv{constructor(e){const t=new Iv;this.generator=new km(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class jv{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 Tv(r){return"type"in r&&r.type==="webhook"}class Nv{constructor(e){this.definitions=e,this.webhookRefs={};const t=new jv;this.generator=new km(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(Tv).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 Sm=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},Bv=r=>{const{groups:e,path:t}=Rv(r),n=Sm(t);return Pv(n,e)},Rv=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const i=`@${n}`;return e.push([i,t]),i}),{groups:e,path:r}},Pv=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let i=r.length-1;i>=0;i--)if(r[i].includes(n)){r[i]=r[i].replace(n,e[t][1]);break}}return r},bo={},bh=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(bo[r]||(e[2]?bo[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:bo[r]=[r,e[1],!0]),bo[r]):null},Am=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},$v=r=>Am(r,decodeURI),Om=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const i=e.charCodeAt(n);if(i===37){const s=e.indexOf("?",n),a=e.slice(t,s===-1?void 0:s);return $v(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(i===63)break}return e.slice(t,n)},Dv=r=>{const e=Om(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},nn=(...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},Em=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(i=>{if(i!==""&&!/\:/.test(i))n+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){t.length===0&&n===""?t.push("/"):t.push(n);const s=i.replace("?","");n+="/"+s,t.push(n)}else n+="/"+i}),t.filter((i,s,a)=>a.indexOf(i)===s)},Qu=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?af(r):r):r,Im=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let a=r.indexOf(`?${e}`,8);for(a===-1&&(a=r.indexOf(`&${e}`,8));a!==-1;){const o=r.charCodeAt(a+e.length+1);if(o===61){const c=a+e.length+2,u=r.indexOf("&",c);return Qu(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";a=r.indexOf(`&${e}`,a+1)}if(n=/[%+]/.test(r),!n)return}const i={};n??(n=/[%+]/.test(r));let s=r.indexOf("?",8);for(;s!==-1;){const a=r.indexOf("&",s+1);let o=r.indexOf("=",s);o>a&&a!==-1&&(o=-1);let c=r.slice(s+1,o===-1?a===-1?void 0:a:o);if(n&&(c=Qu(c)),s=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=Qu(u))),t?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(u)):i[c]??(i[c]=u)}return e?i[e]:i},Zv=Im,Mv=(r,e)=>Im(r,e,!0),af=decodeURIComponent,Uv=/^[\w!#$%&'*.^`|~+-]+$/,Vv=/^[ !#-:<-[\]-~]*$/,Lv=(r,e)=>{const t=r.trim().split(";"),n={};for(let i of t){i=i.trim();const s=i.indexOf("=");if(s===-1)continue;const a=i.substring(0,s).trim();if(!Uv.test(a))continue;let o=i.substring(s+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Vv.test(o)&&(n[a]=af(o))}return n},qv=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?Lv(n):{}},ye=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});ne(this,"res");ne(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})}},Hv=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),Fv=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Kv=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Wv=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,zv=(r,e)=>async(t,n)=>{let i={};const s=t.req.header("Content-Type");switch(r){case"json":if(!s||!Fv.test(s))break;try{i=await t.req.json()}catch{const o="Malformed JSON in request body";throw new ye(400,{message:o})}break;case"form":{if(!s||!(Kv.test(s)||Wv.test(s)))break;let o;if(t.req.bodyCache.formData)o=await t.req.bodyCache.formData;else try{const u=await t.req.arrayBuffer();o=await Hv(u,s),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new ye(400,{message:f})}const c={};o.forEach((u,f)=>{f.endsWith("[]")?(c[f]??(c[f]=[])).push(u):Array.isArray(c[f])?c[f].push(u):f in c?c[f]=[c[f],u]:c[f]=u}),i=c;break}case"query":i=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":i=t.req.param();break;case"header":i=t.req.header();break;case"cookie":i=qv(t);break}const a=await e(i,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const xi=(r,e,t)=>zv(r,async(n,i)=>{const s=await e.safeParseAsync(n);if(t){const a=await t({data:n,...s,target:r},i);if(a){if(a instanceof Response)return a;if("response"in a)return a.response}}return s.success?s.data:i.json(s,400)});var Gv=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,s=(r instanceof Cm?r.raw.headers:r.headers).get("Content-Type");return s!=null&&s.startsWith("multipart/form-data")||s!=null&&s.startsWith("application/x-www-form-urlencoded")?Jv(r,{all:t,dot:n}):{}};async function Jv(r,e){const t=await r.formData();return t?Yv(t,e):{}}function Yv(r,e){const t=Object.create(null);return r.forEach((n,i)=>{e.all||i.endsWith("[]")?Xv(t,i,n):t[i]=n}),e.dot&&Object.entries(t).forEach(([n,i])=>{n.includes(".")&&(Qv(t,n,i),delete t[n])}),t}var Xv=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},Qv=(r,e,t)=>{let n=r;const i=e.split(".");i.forEach((s,a)=>{a===i.length-1?n[s]=t:((!n[s]||typeof n[s]!="object"||Array.isArray(n[s])||n[s]instanceof File)&&(n[s]=Object.create(null)),n=n[s])})},xh=r=>Am(r,af),$i,tr,Xr,jm,Tm,gl,cn,hm,Cm=(hm=class{constructor(r,e="/",t=[[]]){Oe(this,Xr);ne(this,"raw");Oe(this,$i);Oe(this,tr);ne(this,"routeIndex",0);ne(this,"path");ne(this,"bodyCache",{});Oe(this,cn,r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const i=Object.keys(e)[0];return i?e[i].then(s=>(i==="json"&&(s=JSON.stringify(s)),new Response(s)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,ue(this,tr,t),ue(this,$i,{})}param(r){return r?Te(this,Xr,jm).call(this,r):Te(this,Xr,Tm).call(this)}query(r){return Zv(this.url,r)}queries(r){return Mv(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 Gv(this,r))}json(){return w(this,cn).call(this,"json")}text(){return w(this,cn).call(this,"text")}arrayBuffer(){return w(this,cn).call(this,"arrayBuffer")}blob(){return w(this,cn).call(this,"blob")}formData(){return w(this,cn).call(this,"formData")}addValidatedData(r,e){w(this,$i)[r]=e}valid(r){return w(this,$i)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return w(this,tr)[0].map(([[,r]])=>r)}get routePath(){return w(this,tr)[0].map(([[,r]])=>r)[this.routeIndex].path}},$i=new WeakMap,tr=new WeakMap,Xr=new WeakSet,jm=function(r){const e=w(this,tr)[0][this.routeIndex][1][r],t=Te(this,Xr,gl).call(this,e);return t?/\%/.test(t)?xh(t):t:void 0},Tm=function(){const r={},e=Object.keys(w(this,tr)[0][this.routeIndex][1]);for(const t of e){const n=Te(this,Xr,gl).call(this,w(this,tr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?xh(n):n)}return r},gl=function(r){return w(this,tr)[1]?w(this,tr)[1][r]:r},cn=new WeakMap,hm),eb={Stringify:1,BeforeStream:2,Stream:3},Nm=async(r,e,t,n,i)=>{typeof r=="object"&&!(r instanceof String)&&(r instanceof Promise||(r=r.toString()),r instanceof Promise&&(r=await r));const s=r.callbacks;return s!=null&&s.length?(i?i[0]+=r:i=[r],Promise.all(s.map(o=>o({phase:e,buffer:i,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Nm(c,e,!1,n,i))).then(()=>i[0]))):Promise.resolve(r)},tb="text/plain; charset=UTF-8",el=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Ha,Fa,Pr,qn,$r,Ge,Qe,br,Dr,Ka,Di,Zi,Wa,za,Ot,Vt,pm,Bm=(pm=class{constructor(r,e){Oe(this,Ot);Oe(this,Ha);Oe(this,Fa);ne(this,"env",{});Oe(this,Pr);ne(this,"finalized",!1);ne(this,"error");Oe(this,qn,200);Oe(this,$r);Oe(this,Ge);Oe(this,Qe);Oe(this,br);Oe(this,Dr,!0);Oe(this,Ka);Oe(this,Di);Oe(this,Zi);Oe(this,Wa);Oe(this,za);ne(this,"render",(...r)=>(w(this,Di)??ue(this,Di,e=>this.html(e)),w(this,Di).call(this,...r)));ne(this,"setLayout",r=>ue(this,Ka,r));ne(this,"getLayout",()=>w(this,Ka));ne(this,"setRenderer",r=>{ue(this,Di,r)});ne(this,"header",(r,e,t)=>{if(e===void 0){w(this,Ge)?w(this,Ge).delete(r):w(this,Qe)&&delete w(this,Qe)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(w(this,Ge)||(ue(this,Dr,!1),ue(this,Ge,new Headers(w(this,Qe))),ue(this,Qe,{})),w(this,Ge).append(r,e)):w(this,Ge)?w(this,Ge).set(r,e):(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});ne(this,"status",r=>{ue(this,Dr,!1),ue(this,qn,r)});ne(this,"set",(r,e)=>{w(this,Pr)??ue(this,Pr,new Map),w(this,Pr).set(r,e)});ne(this,"get",r=>w(this,Pr)?w(this,Pr).get(r):void 0);ne(this,"newResponse",(...r)=>Te(this,Ot,Vt).call(this,...r));ne(this,"body",(r,e,t)=>typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e));ne(this,"text",(r,e,t)=>{if(!w(this,Qe)){if(w(this,Dr)&&!t&&!e)return new Response(r);ue(this,Qe,{})}return w(this,Qe)["content-type"]=tb,typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)});ne(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)});ne(this,"html",(r,e,t)=>(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Nm(r,eb.Stringify,!1,{}).then(n=>typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)):typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)));ne(this,"redirect",(r,e)=>(w(this,Ge)??ue(this,Ge,new Headers),w(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));ne(this,"notFound",()=>(w(this,Zi)??ue(this,Zi,()=>new Response),w(this,Zi).call(this,this)));ue(this,Ha,r),e&&(ue(this,$r,e.executionCtx),this.env=e.env,ue(this,Zi,e.notFoundHandler),ue(this,za,e.path),ue(this,Wa,e.matchResult))}get req(){return w(this,Fa)??ue(this,Fa,new Cm(w(this,Ha),w(this,za),w(this,Wa))),w(this,Fa)}get event(){if(w(this,$r)&&"respondWith"in w(this,$r))return w(this,$r);throw Error("This context has no FetchEvent")}get executionCtx(){if(w(this,$r))return w(this,$r);throw Error("This context has no ExecutionContext")}get res(){return ue(this,Dr,!1),w(this,br)||ue(this,br,new Response("404 Not Found",{status:404}))}set res(r){if(ue(this,Dr,!1),w(this,br)&&r)try{for(const[e,t]of w(this,br).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=w(this,br).headers.getSetCookie();r.headers.delete("set-cookie");for(const i of n)r.headers.append("set-cookie",i)}else r.headers.set(e,t)}catch(e){if(e instanceof TypeError&&e.message.includes("immutable")){this.res=new Response(r.body,{headers:r.headers,status:r.status});return}else throw e}ue(this,br,r),this.finalized=!0}get var(){return w(this,Pr)?Object.fromEntries(w(this,Pr)):{}}},Ha=new WeakMap,Fa=new WeakMap,Pr=new WeakMap,qn=new WeakMap,$r=new WeakMap,Ge=new WeakMap,Qe=new WeakMap,br=new WeakMap,Dr=new WeakMap,Ka=new WeakMap,Di=new WeakMap,Zi=new WeakMap,Wa=new WeakMap,za=new WeakMap,Ot=new WeakSet,Vt=function(r,e,t){if(w(this,Dr)&&!t&&!e&&w(this,qn)===200)return new Response(r,{headers:w(this,Qe)});if(e&&typeof e!="number"){const i=new Headers(e.headers);w(this,Ge)&&w(this,Ge).forEach((a,o)=>{o==="set-cookie"?i.append(o,a):i.set(o,a)});const s=el(i,w(this,Qe));return new Response(r,{headers:s,status:e.status??w(this,qn)})}const n=typeof e=="number"?e:w(this,qn);w(this,Qe)??ue(this,Qe,{}),w(this,Ge)??ue(this,Ge,new Headers),el(w(this,Ge),w(this,Qe)),w(this,br)&&(w(this,br).headers.forEach((i,s)=>{var a,o;s==="set-cookie"?(a=w(this,Ge))==null||a.append(s,i):(o=w(this,Ge))==null||o.set(s,i)}),el(w(this,Ge),w(this,Qe))),t??(t={});for(const[i,s]of Object.entries(t))if(typeof s=="string")w(this,Ge).set(i,s);else{w(this,Ge).delete(i);for(const a of s)w(this,Ge).append(i,a)}return new Response(r,{status:n,headers:w(this,Ge)})},pm),_h=(r,e,t)=>(n,i)=>{let s=-1;const a=n instanceof Bm;return o(0);async function o(c){if(c<=s)throw new Error("next() called multiple times");s=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&i||void 0,!m)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await m(n,()=>o(c+1))}catch(B){if(B instanceof Error&&a&&e)n.error=B,u=await e(B,n),f=!0;else throw B}return u&&(n.finalized===!1||f)&&(n.res=u),n}},it="ALL",rb="all",nb=["get","post","put","delete","options","patch"],Rm="Can not add a route since the matcher is already built.",Pm=class extends Error{},ib=Symbol("composedHandler"),sb=r=>r.text("404 Not Found",404),wh=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),rr,st,Dm,Zr,Pn,Ao,Oo,mm,$m=(mm=class{constructor(e={}){Oe(this,st);ne(this,"get");ne(this,"post");ne(this,"put");ne(this,"delete");ne(this,"options");ne(this,"patch");ne(this,"all");ne(this,"on");ne(this,"use");ne(this,"router");ne(this,"getPath");ne(this,"_basePath","/");Oe(this,rr,"/");ne(this,"routes",[]);Oe(this,Zr,sb);ne(this,"errorHandler",wh);ne(this,"onError",e=>(this.errorHandler=e,this));ne(this,"notFound",e=>(ue(this,Zr,e),this));ne(this,"fetch",(e,...t)=>Te(this,st,Oo).call(this,e,t[1],t[0],e.method));ne(this,"request",(e,t,n,i)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,i):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${nn("/",e)}`,t),n,i)));ne(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(Te(this,st,Oo).call(this,e.request,e,void 0,e.request.method))})});[...nb,rb].forEach(i=>{this[i]=(s,...a)=>(typeof s=="string"?ue(this,rr,s):Te(this,st,Pn).call(this,i,w(this,rr),s),a.forEach(o=>{Te(this,st,Pn).call(this,i,w(this,rr),o)}),this)}),this.on=(i,s,...a)=>{for(const o of[s].flat()){ue(this,rr,o);for(const c of[i].flat())a.map(u=>{Te(this,st,Pn).call(this,c.toUpperCase(),w(this,rr),u)})}return this},this.use=(i,...s)=>(typeof i=="string"?ue(this,rr,i):(ue(this,rr,"*"),s.unshift(i)),s.forEach(a=>{Te(this,st,Pn).call(this,it,w(this,rr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??Om:Dv}route(e,t){const n=this.basePath(e);return t.routes.map(i=>{var a;let s;t.errorHandler===wh?s=i.handler:(s=async(o,c)=>(await _h([],t.errorHandler)(o,()=>i.handler(o,c))).res,s[ib]=i.handler),Te(a=n,st,Pn).call(a,i.method,i.path,s)}),this}basePath(e){const t=Te(this,st,Dm).call(this);return t._basePath=nn(this._basePath,e),t}mount(e,t,n){let i,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,i=n.replaceRequest));const a=s?c=>{const u=s(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};i||(i=(()=>{const c=nn(this._basePath,e),u=c==="/"?0:c.length;return f=>{const m=new URL(f.url);return m.pathname=m.pathname.slice(u)||"/",new Request(m,f)}})());const o=async(c,u)=>{const f=await t(i(c.req.raw),...a(c));if(f)return f;await u()};return Te(this,st,Pn).call(this,it,nn(e,"*"),o),this}},rr=new WeakMap,st=new WeakSet,Dm=function(){const e=new $m({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Zr=new WeakMap,Pn=function(e,t,n){e=e.toUpperCase(),t=nn(this._basePath,t);const i={path:t,method:e,handler:n};this.router.add(e,t,[n,i]),this.routes.push(i)},Ao=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Oo=function(e,t,n,i){if(i==="HEAD")return(async()=>new Response(null,await Te(this,st,Oo).call(this,e,t,n,"GET")))();const s=this.getPath(e,{env:n}),a=this.router.match(i,s),o=new Bm(e,{path:s,matchResult:a,env:n,executionCtx:t,notFoundHandler:w(this,Zr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await w(this,Zr).call(this,o)})}catch(f){return Te(this,st,Ao).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:w(this,Zr).call(this,o))).catch(f=>Te(this,st,Ao).call(this,f,o)):u??w(this,Zr).call(this,o)}const c=_h(a[0],this.errorHandler,w(this,Zr));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 Te(this,st,Ao).call(this,u,o)}})()},mm),Uo="[^/]+",$s=".*",Ds="(?:|/.*)",Os=Symbol(),ab=new Set(".\\+*[^]$()");function ob(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$s||r===Ds?1:e===$s||e===Ds?-1:r===Uo?1:e===Uo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Hn,Fn,nr,ym,vl=(ym=class{constructor(){Oe(this,Hn);Oe(this,Fn);Oe(this,nr,Object.create(null))}insert(e,t,n,i,s){if(e.length===0){if(w(this,Hn)!==void 0)throw Os;if(s)return;ue(this,Hn,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",$s]:["","",Uo]:a==="/*"?["","",Ds]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||Uo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw Os;if(u=w(this,nr)[m],!u){if(Object.keys(w(this,nr)).some(B=>B!==$s&&B!==Ds))throw Os;if(s)return;u=w(this,nr)[m]=new vl,f!==""&&ue(u,Fn,i.varIndex++)}!s&&f!==""&&n.push([f,w(u,Fn)])}else if(u=w(this,nr)[a],!u){if(Object.keys(w(this,nr)).some(f=>f.length>1&&f!==$s&&f!==Ds))throw Os;if(s)return;u=w(this,nr)[a]=new vl}u.insert(o,t,n,i,s)}buildRegExpStr(){const t=Object.keys(w(this,nr)).sort(ob).map(n=>{const i=w(this,nr)[n];return(typeof w(i,Fn)=="number"?`(${n})@${w(i,Fn)}`:ab.has(n)?`\\${n}`:n)+i.buildRegExpStr()});return typeof w(this,Hn)=="number"&&t.unshift(`#${w(this,Hn)}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},Hn=new WeakMap,Fn=new WeakMap,nr=new WeakMap,ym),eu,Ga,gm,cb=(gm=class{constructor(){Oe(this,eu,{varIndex:0});Oe(this,Ga,new vl)}insert(r,e,t){const n=[],i=[];for(let a=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${a}`;return i[a]=[u,c],a++,o=!0,u}),!o)break}const s=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=i.length-1;a>=0;a--){const[o]=i[a];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(o)!==-1){s[c]=s[c].replace(o,i[a][1]);break}}return w(this,Ga).insert(s,e,n,w(this,eu),t),n}buildRegExp(){let r=w(this,Ga).buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,s,a)=>s!==void 0?(t[++e]=Number(s),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},eu=new WeakMap,Ga=new WeakMap,gm),Zm=[],ub=[/^$/,[],Object.create(null)],Eo=Object.create(null);function Mm(r){return Eo[r]??(Eo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function lb(){Eo=Object.create(null)}function db(r){var u;const e=new cb,t=[];if(r.length===0)return ub;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[B,C])=>f?1:B?-1:m.length-C.length),i=Object.create(null);for(let f=0,m=-1,B=n.length;f<B;f++){const[C,p,g]=n[f];C?i[p]=[g.map(([O])=>[O,Object.create(null)]),Zm]:m++;let A;try{A=e.insert(p,m,C)}catch(O){throw O===Os?new Pm(p):O}C||(t[m]=g.map(([O,P])=>{const N=Object.create(null);for(P-=1;P>=0;P--){const[xe,Le]=A[P];N[xe]=Le}return[O,N]}))}const[s,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let B=0,C=t[f].length;B<C;B++){const p=(u=t[f][B])==null?void 0:u[1];if(!p)continue;const g=Object.keys(p);for(let A=0,O=g.length;A<O;A++)p[g[A]]=o[p[g[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[s,c,i]}function _i(r,e){if(r){for(const t of Object.keys(r).sort((n,i)=>i.length-n.length))if(Mm(t).test(e))return[...r[t]]}}var un,ln,os,Um,Vm,vm,fb=(vm=class{constructor(){Oe(this,os);ne(this,"name","RegExpRouter");Oe(this,un);Oe(this,ln);ue(this,un,{[it]:Object.create(null)}),ue(this,ln,{[it]:Object.create(null)})}add(r,e,t){var o;const n=w(this,un),i=w(this,ln);if(!n||!i)throw new Error(Rm);n[r]||[n,i].forEach(c=>{c[r]=Object.create(null),Object.keys(c[it]).forEach(u=>{c[r][u]=[...c[it][u]]})}),e==="/*"&&(e="*");const s=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Mm(e);r===it?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=_i(n[u],e)||_i(n[it],e)||[])}):(o=n[r])[e]||(o[e]=_i(n[r],e)||_i(n[it],e)||[]),Object.keys(n).forEach(u=>{(r===it||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,s])})}),Object.keys(i).forEach(u=>{(r===it||r===u)&&Object.keys(i[u]).forEach(f=>c.test(f)&&i[u][f].push([t,s]))});return}const a=Em(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(i).forEach(m=>{var B;(r===it||r===m)&&((B=i[m])[f]||(B[f]=[..._i(n[m],f)||_i(n[it],f)||[]]),i[m][f].push([t,s-u+c+1]))})}}match(r,e){lb();const t=Te(this,os,Um).call(this);return this.match=(n,i)=>{const s=t[n]||t[it],a=s[2][i];if(a)return a;const o=i.match(s[0]);if(!o)return[[],Zm];const c=o.indexOf("",1);return[s[1][c],o]},this.match(r,e)}},un=new WeakMap,ln=new WeakMap,os=new WeakSet,Um=function(){const r=Object.create(null);return Object.keys(w(this,ln)).concat(Object.keys(w(this,un))).forEach(e=>{r[e]||(r[e]=Te(this,os,Vm).call(this,e))}),ue(this,un,ue(this,ln,void 0)),r},Vm=function(r){const e=[];let t=r===it;return[w(this,un),w(this,ln)].forEach(n=>{const i=n[r]?Object.keys(n[r]).map(s=>[s,n[r][s]]):[];i.length!==0?(t||(t=!0),e.push(...i)):r!==it&&e.push(...Object.keys(n[it]).map(s=>[s,n[it][s]]))}),t?db(e):null},vm),dn,Mr,bm,hb=(bm=class{constructor(r){ne(this,"name","SmartRouter");Oe(this,dn,[]);Oe(this,Mr,[]);ue(this,dn,r.routers)}add(r,e,t){if(!w(this,Mr))throw new Error(Rm);w(this,Mr).push([r,e,t])}match(r,e){if(!w(this,Mr))throw new Error("Fatal error");const t=w(this,dn),n=w(this,Mr),i=t.length;let s=0,a;for(;s<i;s++){const o=t[s];try{for(let c=0,u=n.length;c<u;c++)o.add(...n[c]);a=o.match(r,e)}catch(c){if(c instanceof Pm)continue;throw c}this.match=o.match.bind(o),ue(this,dn,[o]),ue(this,Mr,void 0);break}if(s===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(w(this,Mr)||w(this,dn).length!==1)throw new Error("No active router has been determined yet.");return w(this,dn)[0]}},dn=new WeakMap,Mr=new WeakMap,bm),fn,bt,Kn,Mi,Et,Ur,$n,xm,Lm=(xm=class{constructor(r,e,t){Oe(this,Ur);Oe(this,fn);Oe(this,bt);Oe(this,Kn);Oe(this,Mi,0);Oe(this,Et,Object.create(null));if(ue(this,bt,t||Object.create(null)),ue(this,fn,[]),r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},ue(this,fn,[n])}ue(this,Kn,[])}insert(r,e,t){ue(this,Mi,++gh(this,Mi)._);let n=this;const i=Bv(e),s=[];for(let c=0,u=i.length;c<u;c++){const f=i[c];if(Object.keys(w(n,bt)).includes(f)){n=w(n,bt)[f];const B=bh(f);B&&s.push(B[1]);continue}w(n,bt)[f]=new Lm;const m=bh(f);m&&(w(n,Kn).push(m),s.push(m[1])),n=w(n,bt)[f]}const a=Object.create(null),o={handler:t,possibleKeys:s.filter((c,u,f)=>f.indexOf(c)===u),score:w(this,Mi)};return a[r]=o,w(n,fn).push(a),n}search(r,e){const t=[];ue(this,Et,Object.create(null));let i=[this];const s=Sm(e);for(let o=0,c=s.length;o<c;o++){const u=s[o],f=o===c-1,m=[];for(let B=0,C=i.length;B<C;B++){const p=i[B],g=w(p,bt)[u];g&&(ue(g,Et,w(p,Et)),f?(w(g,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(g,bt)["*"],r,w(p,Et),Object.create(null))),t.push(...Te(this,Ur,$n).call(this,g,r,w(p,Et),Object.create(null)))):m.push(g));for(let A=0,O=w(p,Kn).length;A<O;A++){const P=w(p,Kn)[A],N={...w(p,Et)};if(P==="*"){const mt=w(p,bt)["*"];mt&&(t.push(...Te(this,Ur,$n).call(this,mt,r,w(p,Et),Object.create(null))),m.push(mt));continue}if(u==="")continue;const[xe,Le,qe]=P,Ze=w(p,bt)[xe],tt=s.slice(o).join("/");if(qe instanceof RegExp&&qe.test(tt)){N[Le]=tt,t.push(...Te(this,Ur,$n).call(this,Ze,r,w(p,Et),N));continue}(qe===!0||qe.test(u))&&(N[Le]=u,f?(t.push(...Te(this,Ur,$n).call(this,Ze,r,N,w(p,Et))),w(Ze,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(Ze,bt)["*"],r,N,w(p,Et)))):(ue(Ze,Et,N),m.push(Ze)))}}i=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},fn=new WeakMap,bt=new WeakMap,Kn=new WeakMap,Mi=new WeakMap,Et=new WeakMap,Ur=new WeakSet,$n=function(r,e,t,n){const i=[];for(let s=0,a=w(r,fn).length;s<a;s++){const o=w(r,fn)[s],c=o[e]||o[it],u={};if(c!==void 0){c.params=Object.create(null);for(let f=0,m=c.possibleKeys.length;f<m;f++){const B=c.possibleKeys[f],C=u[c.score];c.params[B]=n[B]&&!C?n[B]:t[B]??n[B],u[c.score]=!0}i.push(c)}}return i},xm),Wn,_m,pb=(_m=class{constructor(){ne(this,"name","TrieRouter");Oe(this,Wn);ue(this,Wn,new Lm)}add(r,e,t){const n=Em(e);if(n){for(let i=0,s=n.length;i<s;i++)w(this,Wn).insert(r,n[i],t);return}w(this,Wn).insert(r,e,t)}match(r,e){return w(this,Wn).search(r,e)}},Wn=new WeakMap,_m),mb=class extends $m{constructor(r={}){super(r),this.router=r.router??new hb({routers:[new fb,new pb]})}},Re;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Re||(Re={}));var bl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(bl||(bl={}));const z=Re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),sn=r=>{switch(typeof r){case"undefined":return z.undefined;case"string":return z.string;case"number":return isNaN(r)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(r)?z.array:r===null?z.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?z.promise:typeof Map<"u"&&r instanceof Map?z.map:typeof Set<"u"&&r instanceof Set?z.set:typeof Date<"u"&&r instanceof Date?z.date:z.object;default:return z.unknown}},D=Re.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"]),yb=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let or=class qm 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(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof qm))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};or.create=r=>new or(r);const Ui=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Re.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Re.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Re.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Re.joinValues(r.options)}, received '${r.received}'`;break;case D.invalid_arguments:t="Invalid function arguments";break;case D.invalid_return_type:t="Invalid function return type";break;case D.invalid_date:t="Invalid date";break;case D.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}"`:Re.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case D.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 D.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 D.custom:t="Invalid input";break;case D.invalid_intersection_types:t="Intersection results could not be merged";break;case D.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case D.not_finite:t="Number must be finite";break;default:t=e.defaultError,Re.assertNever(r)}return{message:t}};let Hm=Ui;function gb(r){Hm=r}function Vo(){return Hm}const Lo=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},vb=[];function H(r,e){const t=Vo(),n=Lo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ui?void 0:Ui].filter(i=>!!i)});r.common.issues.push(n)}let jt=class Fm{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 i of t){if(i.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return Fm.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),Oi=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),xl=r=>r.status==="aborted",_l=r=>r.status==="dirty",Ls=r=>r.status==="valid",qs=r=>typeof Promise<"u"&&r instanceof Promise;function qo(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 Km(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!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 ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ae||(ae={}));var Es,Is;let Sr=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 kh=(r,e)=>{if(Ls(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 or(r.common.issues);return this._error=t,this._error}}};function _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=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:i}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:i}}let Ae=class{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 sn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new jt,ctx:{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(qs(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 i={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:sn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return kh(i,s)}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:sn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(qs(i)?i:Promise.resolve(i));return kh(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:D.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new dr({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qn.create(this,this._def)}promise(){return qi.create(this,this._def)}or(e){return Js.create([this,e],this._def)}and(e){return Ys.create(this,e,this._def)}transform(e){return new dr({..._e(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ta({..._e(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new of({typeName:de.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ra({..._e(this._def),innerType:this,catchValue:t,typeName:de.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return cf.create(this,e)}readonly(){return na.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const bb=/^c[^\s-]{8,}$/i,xb=/^[0-9a-z]+$/,_b=/^[0-9A-HJKMNP-TV-Z]{26}$/,wb=/^[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,kb=/^[a-z0-9_-]{21}$/i,Sb=/^[-+]?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)?)??$/,Ab=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ob="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let tl;const Eb=/^(?:(?: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])$/,Ib=/^(([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})))$/,Cb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wm="((\\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])))",jb=new RegExp(`^${Wm}$`);function zm(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 Tb(r){return new RegExp(`^${zm(r)}$`)}function Gm(r){let e=`${Wm}T${zm(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 Nb(r,e){return!!((e==="v4"||!e)&&Eb.test(r)||(e==="v6"||!e)&&Ib.test(r))}let Vi=class Cs extends Ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.string,received:s.parsedType}),pe}const n=new jt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Ab.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"email",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")tl||(tl=new RegExp(Ob,"u")),tl.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"emoji",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")wb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"uuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")kb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"nanoid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")bb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")xb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid2",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")_b.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ulid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),H(i,{validation:"url",code:D.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"regex",code:D.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Gm(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?jb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Tb(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Sb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"duration",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Nb(e.data,s.version)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ip",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Cb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"base64",code:D.invalid_string,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:D.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Cs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ae.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ae.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ae.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ae.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ae.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ae.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ae.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ae.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ae.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ae.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,...ae.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,...ae.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ae.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ae.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ae.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ae.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ae.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ae.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ae.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ae.errToObj(t)})}nonempty(e){return this.min(1,ae.errToObj(e))}trim(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Cs({...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}};Vi.create=r=>{var e;return new Vi({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function Bb(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}let Hs=class wl extends Ae{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)!==z.number){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.number,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Bb(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_finite,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new wl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new wl({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ae.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ae.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ae.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ae.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"&&Re.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)}};Hs.create=r=>new Hs({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Fs=class kl extends Ae{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)!==z.bigint){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.bigint,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new kl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new kl({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.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}};Fs.create=r=>{var e;return new Fs({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};let Ks=class extends Ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.boolean,received:n.parsedType}),pe}return _t(e.data)}};Ks.create=r=>new Ks({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Ws=class Jm extends Ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.date,received:s.parsedType}),pe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_date}),pe}const n=new jt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Re.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Jm({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ae.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}};Ws.create=r=>new Ws({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,..._e(r)});let Ho=class extends Ae{_parse(e){if(this._getType(e)!==z.symbol){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.symbol,received:n.parsedType}),pe}return _t(e.data)}};Ho.create=r=>new Ho({typeName:de.ZodSymbol,..._e(r)});let zs=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.undefined,received:n.parsedType}),pe}return _t(e.data)}};zs.create=r=>new zs({typeName:de.ZodUndefined,..._e(r)});let Gs=class extends Ae{_parse(e){if(this._getType(e)!==z.null){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.null,received:n.parsedType}),pe}return _t(e.data)}};Gs.create=r=>new Gs({typeName:de.ZodNull,..._e(r)});let Li=class extends Ae{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}};Li.create=r=>new Li({typeName:de.ZodAny,..._e(r)});let zn=class extends Ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}};zn.create=r=>new zn({typeName:de.ZodUnknown,..._e(r)});let Hr=class extends Ae{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:z.never,received:t.parsedType}),pe}};Hr.create=r=>new Hr({typeName:de.ZodNever,..._e(r)});let Fo=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.void,received:n.parsedType}),pe}return _t(e.data)}};Fo.create=r=>new Fo({typeName:de.ZodVoid,..._e(r)});let Qn=class Io extends Ae{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==z.array)return H(t,{code:D.invalid_type,expected:z.array,received:t.parsedType}),pe;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(H(t,{code:a?D.too_big:D.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(H(t,{code:D.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(H(t,{code:D.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Sr(t,a,t.path,o)))).then(a=>jt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Sr(t,a,t.path,o)));return jt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Io({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new Io({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new Io({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};Qn.create=(r,e)=>new Qn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,..._e(e)});function ki(r){if(r instanceof Kt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(ki(n))}return new Kt({...r._def,shape:()=>e})}else return r instanceof Qn?new Qn({...r._def,type:ki(r.element)}):r instanceof xr?xr.create(ki(r.unwrap())):r instanceof vn?vn.create(ki(r.unwrap())):r instanceof gn?gn.create(r.items.map(e=>ki(e))):r}let Kt=class Xt extends Ae{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=Re.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==z.object){const u=this._getOrReturnCtx(e);return H(u,{code:D.invalid_type,expected:z.object,received:u.parsedType}),pe}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Hr&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=s[u],m=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Sr(i,m,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Hr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")o.length>0&&(H(i,{code:D.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 f of o){const m=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Sr(i,m,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,B=await f.value;u.push({key:m,value:B,alwaysSet:f.alwaysSet})}return u}).then(u=>jt.mergeObjectSync(n,u)):jt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ae.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:de.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){const t={};return Re.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}omit(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return ki(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof xr;)s=s._def.innerType;t[n]=s}}),new Xt({...this._def,shape:()=>t})}keyof(){return ry(Re.objectKeys(this.shape))}};Kt.create=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.strictCreate=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strict",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.lazycreate=(r,e)=>new Kt({shape:r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});let Js=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new or(o.ctx.common.issues));return H(t,{code:D.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new or(c));return H(t,{code:D.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Js.create=(r,e)=>new Js({options:r,typeName:de.ZodUnion,..._e(e)});const Br=r=>r instanceof Xs?Br(r.schema):r instanceof dr?Br(r.innerType()):r instanceof Qs?[r.value]:r instanceof Ja?r.options:r instanceof ea?Re.objectValues(r.enum):r instanceof ta?Br(r._def.innerType):r instanceof zs?[void 0]:r instanceof Gs?[null]:r instanceof xr?[void 0,...Br(r.unwrap())]:r instanceof vn?[null,...Br(r.unwrap())]:r instanceof of||r instanceof na?Br(r.unwrap()):r instanceof ra?Br(r._def.innerType):[];let Ym=class Xm extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return H(t,{code:D.invalid_type,expected:z.object,received:t.parsedType}),pe;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=Br(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new Xm({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,..._e(n)})}};function Sl(r,e){const t=sn(r),n=sn(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&n===z.object){const i=Re.objectKeys(e),s=Re.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=Sl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===z.array&&n===z.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=Sl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===z.date&&n===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Ys=class extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(xl(s)||xl(a))return pe;const o=Sl(s.value,a.value);return o.valid?((_l(s)||_l(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:D.invalid_intersection_types}),pe)};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(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ys.create=(r,e,t)=>new Ys({left:r,right:e,typeName:de.ZodIntersection,..._e(t)});let gn=class Qm extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return H(n,{code:D.invalid_type,expected:z.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return H(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Sr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>jt.mergeArray(t,a)):jt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qm({...this._def,rest:e})}};gn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gn({items:r,typeName:de.ZodTuple,rest:null,..._e(e)})};let ey=class Al extends Ae{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!==z.object)return H(n,{code:D.invalid_type,expected:z.object,received:n.parsedType}),pe;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Sr(n,o,n.path,o)),value:a._parse(new Sr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?jt.mergeObjectAsync(t,i):jt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ae?new Al({keyType:e,valueType:t,typeName:de.ZodRecord,..._e(n)}):new Al({keyType:Vi.create(),valueType:e,typeName:de.ZodRecord,..._e(t)})}},Ko=class extends Ae{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!==z.map)return H(n,{code:D.invalid_type,expected:z.map,received:n.parsedType}),pe;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Sr(n,o,n.path,[u,"key"])),value:s._parse(new Sr(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}};Ko.create=(r,e,t)=>new Ko({valueType:e,keyType:r,typeName:de.ZodMap,..._e(t)});let Wo=class Ol extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return H(n,{code:D.invalid_type,expected:z.set,received:n.parsedType}),pe;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(H(n,{code:D.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(H(n,{code:D.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return pe;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Sr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Ol({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new Ol({...this._def,maxSize:{value:e,message:ae.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Wo.create=(r,e)=>new Wo({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,..._e(e)});let ty=class Co extends Ae{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return H(t,{code:D.invalid_type,expected:z.function,received:t.parsedType}),pe;function n(o,c){return Lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function i(o,c){return Lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qi){const o=this;return _t(async function(...c){const u=new or([]),f=await o._def.args.parseAsync(c,s).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(C=>{throw u.addIssue(i(m,C)),u})})}else{const o=this;return _t(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new or([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new or([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Co({...this._def,args:gn.create(e).rest(zn.create())})}returns(e){return new Co({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Co({args:e||gn.create([]).rest(zn.create()),returns:t||zn.create(),typeName:de.ZodFunction,..._e(n)})}},Xs=class extends Ae{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})}};Xs.create=(r,e)=>new Xs({getter:r,typeName:de.ZodLazy,..._e(e)});let Qs=class extends Ae{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qs.create=(r,e)=>new Qs({value:r,typeName:de.ZodLiteral,..._e(e)});function ry(r,e){return new Ja({values:r,typeName:de.ZodEnum,..._e(e)})}let Ja=class El extends Ae{constructor(){super(...arguments),Es.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Re.joinValues(n),received:t.parsedType,code:D.invalid_type}),pe}if(qo(this,Es)||Km(this,Es,new Set(this._def.values)),!qo(this,Es).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:D.invalid_enum_value,options:n}),pe}return _t(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 El.create(e,{...this._def,...t})}exclude(e,t=this._def){return El.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Es=new WeakMap;Ja.create=ry;let ea=class extends Ae{constructor(){super(...arguments),Is.set(this,void 0)}_parse(e){const t=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){const i=Re.objectValues(t);return H(n,{expected:Re.joinValues(i),received:n.parsedType,code:D.invalid_type}),pe}if(qo(this,Is)||Km(this,Is,new Set(Re.getValidEnumValues(this._def.values))),!qo(this,Is).has(e.data)){const i=Re.objectValues(t);return H(n,{received:n.data,code:D.invalid_enum_value,options:i}),pe}return _t(e.data)}get enum(){return this._def.values}};Is=new WeakMap;ea.create=(r,e)=>new ea({values:r,typeName:de.ZodNativeEnum,..._e(e)});let qi=class extends Ae{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.promise&&t.common.async===!1)return H(t,{code:D.invalid_type,expected:z.promise,received:t.parsedType}),pe;const n=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return _t(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qi.create=(r,e)=>new qi({type:r,typeName:de.ZodPromise,..._e(e)});let dr=class extends Ae{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===de.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return pe;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?pe:c.status==="dirty"||t.value==="dirty"?Oi(c.value):c});{if(t.value==="aborted")return pe;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?pe:o.status==="dirty"||t.value==="dirty"?Oi(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);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"?pe:(o.status==="dirty"&&t.dirty(),a(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"?pe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ls(a))return a;const o=i.transform(a.value,s);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(a=>Ls(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Re.assertNever(i)}};dr.create=(r,e,t)=>new dr({schema:r,typeName:de.ZodEffects,effect:e,..._e(t)});dr.createWithPreprocess=(r,e,t)=>new dr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,..._e(t)});let xr=class extends Ae{_parse(e){return this._getType(e)===z.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(r,e)=>new xr({innerType:r,typeName:de.ZodOptional,..._e(e)});let vn=class extends Ae{_parse(e){return this._getType(e)===z.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(r,e)=>new vn({innerType:r,typeName:de.ZodNullable,..._e(e)});let ta=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ta.create=(r,e)=>new ta({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});let ra=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qs(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ra.create=(r,e)=>new ra({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});let zo=class extends Ae{_parse(e){if(this._getType(e)!==z.nan){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};zo.create=r=>new zo({typeName:de.ZodNaN,..._e(r)});const Rb=Symbol("zod_brand");let of=class extends Ae{_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}},cf=class ny extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),Oi(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?pe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new ny({in:e,out:t,typeName:de.ZodPipeline})}},na=class extends Ae{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Ls(i)&&(i.value=Object.freeze(i.value)),i);return qs(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};na.create=(r,e)=>new na({innerType:r,typeName:de.ZodReadonly,..._e(e)});function iy(r,e={},t){return r?Li.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Li.create()}const Pb={object:Kt.lazycreate};var de;(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"})(de||(de={}));const $b=(r,e={message:`Input not instance of ${r.name}`})=>iy(t=>t instanceof r,e),sy=Vi.create,ay=Hs.create,Db=zo.create,Zb=Fs.create,oy=Ks.create,Mb=Ws.create,Ub=Ho.create,Vb=zs.create,Lb=Gs.create,qb=Li.create,Hb=zn.create,Fb=Hr.create,Kb=Fo.create,Wb=Qn.create,zb=Kt.create,Gb=Kt.strictCreate,Jb=Js.create,Yb=Ym.create,Xb=Ys.create,Qb=gn.create,ex=ey.create,tx=Ko.create,rx=Wo.create,nx=ty.create,ix=Xs.create,sx=Qs.create,ax=Ja.create,ox=ea.create,cx=qi.create,Sh=dr.create,ux=xr.create,lx=vn.create,dx=dr.createWithPreprocess,fx=cf.create,hx=()=>sy().optional(),px=()=>ay().optional(),mx=()=>oy().optional(),yx={string:r=>Vi.create({...r,coerce:!0}),number:r=>Hs.create({...r,coerce:!0}),boolean:r=>Ks.create({...r,coerce:!0}),bigint:r=>Fs.create({...r,coerce:!0}),date:r=>Ws.create({...r,coerce:!0})},gx=pe;var y=Object.freeze({__proto__:null,defaultErrorMap:Ui,setErrorMap:gb,getErrorMap:Vo,makeIssue:Lo,EMPTY_PATH:vb,addIssueToContext:H,ParseStatus:jt,INVALID:pe,DIRTY:Oi,OK:_t,isAborted:xl,isDirty:_l,isValid:Ls,isAsync:qs,get util(){return Re},get objectUtil(){return bl},ZodParsedType:z,getParsedType:sn,ZodType:Ae,datetimeRegex:Gm,ZodString:Vi,ZodNumber:Hs,ZodBigInt:Fs,ZodBoolean:Ks,ZodDate:Ws,ZodSymbol:Ho,ZodUndefined:zs,ZodNull:Gs,ZodAny:Li,ZodUnknown:zn,ZodNever:Hr,ZodVoid:Fo,ZodArray:Qn,ZodObject:Kt,ZodUnion:Js,ZodDiscriminatedUnion:Ym,ZodIntersection:Ys,ZodTuple:gn,ZodRecord:ey,ZodMap:Ko,ZodSet:Wo,ZodFunction:ty,ZodLazy:Xs,ZodLiteral:Qs,ZodEnum:Ja,ZodNativeEnum:ea,ZodPromise:qi,ZodEffects:dr,ZodTransformer:dr,ZodOptional:xr,ZodNullable:vn,ZodDefault:ta,ZodCatch:ra,ZodNaN:zo,BRAND:Rb,ZodBranded:of,ZodPipeline:cf,ZodReadonly:na,custom:iy,Schema:Ae,ZodSchema:Ae,late:Pb,get ZodFirstPartyTypeKind(){return de},coerce:yx,any:qb,array:Wb,bigint:Zb,boolean:oy,date:Mb,discriminatedUnion:Yb,effect:Sh,enum:ax,function:nx,instanceof:$b,intersection:Xb,lazy:ix,literal:sx,map:tx,nan:Db,nativeEnum:ox,never:Fb,null:Lb,nullable:lx,number:ay,object:zb,oboolean:mx,onumber:px,optional:ux,ostring:hx,pipeline:fx,preprocess:dx,promise:cx,record:ex,set:rx,strictObject:Gb,string:sy,symbol:Ub,transformer:Sh,tuple:Qb,undefined:Vb,union:Jb,unknown:Hb,void:Kb,NEVER:gx,ZodIssueCode:D,quotelessJson:yb,ZodError:or}),dt=class Il extends mb{constructor(t){super(t);ne(this,"openAPIRegistry");ne(this,"defaultHook");ne(this,"openapi",({middleware:t,...n},i,s=this.defaultHook)=>{var u,f,m,B,C,p,g,A,O,P;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const N=xi("query",n.request.query,s);a.push(N)}if((f=n.request)!=null&&f.params){const N=xi("param",n.request.params,s);a.push(N)}if((m=n.request)!=null&&m.headers){const N=xi("header",n.request.headers,s);a.push(N)}if((B=n.request)!=null&&B.cookies){const N=xi("cookie",n.request.cookies,s);a.push(N)}const o=(p=(C=n.request)==null?void 0:C.body)==null?void 0:p.content;if(o)for(const N of Object.keys(o)){if(!o[N])continue;const xe=o[N].schema;if(xe instanceof Ae){if(Oh(N)){const Le=xi("json",xe,s);if((A=(g=n.request)==null?void 0:g.body)!=null&&A.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Oh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("json",{}),await tt()};a.push(qe)}}if(Eh(N)){const Le=xi("form",xe,s);if((P=(O=n.request)==null?void 0:O.body)!=null&&P.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Eh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("form",{}),await tt()};a.push(qe)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,i),this});ne(this,"getOpenAPIDocument",t=>{const i=new Cv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Ah(i,this._basePath):i});ne(this,"getOpenAPI31Document",t=>{const i=new Nv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Ah(i,this._basePath):i});ne(this,"doc",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPIDocument(s);return i.json(a)}catch(a){return i.json(a,500)}}));ne(this,"doc31",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPI31Document(s);return i.json(a)}catch(a){return i.json(a,500)}}));this.openAPIRegistry=new dv,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const i=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Il?(n.openAPIRegistry.definitions.forEach(s=>{switch(s.type){case"component":return this.openAPIRegistry.registerComponent(s.componentType,s.name,s.component);case"route":return this.openAPIRegistry.registerPath({...s.route,path:nn(i,s.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...s.webhook,path:nn(i,s.webhook.path)});case"schema":return this.openAPIRegistry.register(s.schema._def.openapi._internal.refId,s.schema);case"parameter":return this.openAPIRegistry.registerParameter(s.schema._def.openapi._internal.refId,s.schema);default:{const a=s;throw new Error(`Unknown registry type: ${a}`)}}}),this):this}basePath(t){return new Il({...super.basePath(t),defaultHook:this.defaultHook})}},ve=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};ov(y);function Ah(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[nn(e,n)]=r.paths[n]}),{...r,paths:t}}function Oh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function Eh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function vx(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 i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function bx(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ks(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function xx(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=vx(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=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(O).length>0?{metadata:O}:void 0)}));if(bx(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},ks(r,"optional"),ks(r,"nullable"),ks(r,"default"),ks(r,"transform"),ks(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var Pe;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Pe||(Pe={}));var Cl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Cl||(Cl={}));const G=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),an=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}},Z=Pe.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"]),_x=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Dt 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(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof Dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const Hi=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.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}"`:Pe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.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 Z.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 Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,Pe.assertNever(r)}return{message:t}};let cy=Hi;function wx(r){cy=r}function Go(){return cy}const Jo=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},kx=[];function F(r,e){const t=Go(),n=Jo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hi?void 0:Hi].filter(i=>!!i)});r.common.issues.push(n)}class gt{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 i of t){if(i.status==="aborted")return ge;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return gt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return ge;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const ge=Object.freeze({status:"aborted"}),Yo=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),jl=r=>r.status==="aborted",Tl=r=>r.status==="dirty",ia=r=>r.status==="valid",sa=r=>typeof Promise<"u"&&r instanceof Promise;function Xo(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 uy(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!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 oe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(oe||(oe={}));var js,Ts;class Ar{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 Ih=(r,e)=>{if(ia(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 Dt(r.common.issues);return this._error=t,this._error}}};function we(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=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:i}:{errorMap:(s,a)=>{var o,c;const{message:u}=r;return s.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:i}}class Ee{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 an(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gt,ctx:{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(sa(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 i={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:an(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Ih(i,s)}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:an(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(sa(i)?i:Promise.resolve(i));return Ih(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:Z.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new fr({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _r.create(this,this._def)}nullable(){return wn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cr.create(this,this._def)}promise(){return Ki.create(this,this._def)}or(e){return ua.create([this,e],this._def)}and(e){return la.create(this,e,this._def)}transform(e){return new fr({...we(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ma({...we(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new uf({typeName:fe.ZodBranded,type:this,...we(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ya({...we(this._def),innerType:this,catchValue:t,typeName:fe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ya.create(this,e)}readonly(){return ga.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Sx=/^c[^\s-]{8,}$/i,Ax=/^[0-9a-z]+$/,Ox=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ex=/^[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,Ix=/^[a-z0-9_-]{21}$/i,Cx=/^[-+]?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)?)??$/,jx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let rl;const Nx=/^(?:(?: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])$/,Bx=/^(([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})))$/,Rx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ly="((\\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])))",Px=new RegExp(`^${ly}$`);function dy(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 $x(r){return new RegExp(`^${dy(r)}$`)}function fy(r){let e=`${ly}T${dy(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 Dx(r,e){return!!((e==="v4"||!e)&&Nx.test(r)||(e==="v6"||!e)&&Bx.test(r))}class ir extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.string,received:i.parsedType}),ge}const t=new gt;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="length"){const s=e.data.length>i.value,a=e.data.length<i.value;(s||a)&&(n=this._getOrReturnCtx(e,n),s?F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if(i.kind==="email")jx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="emoji")rl||(rl=new RegExp(Tx,"u")),rl.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="uuid")Ex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="nanoid")Ix.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid")Sx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid2")Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="ulid")Ox.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:Z.invalid_string,message:i.message}),t.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:Z.invalid_string,message:i.message}),t.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty()):i.kind==="datetime"?fy(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"datetime",message:i.message}),t.dirty()):i.kind==="date"?Px.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"date",message:i.message}),t.dirty()):i.kind==="time"?$x(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"time",message:i.message}),t.dirty()):i.kind==="duration"?Cx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="ip"?Dx(e.data,i.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="base64"?Rx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:Z.invalid_string,message:i.message}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Z.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new ir({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...oe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...oe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...oe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...oe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...oe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...oe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...oe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...oe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...oe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...oe.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,...oe.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,...oe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...oe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...oe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...oe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...oe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...oe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...oe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...oe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...oe.errToObj(t)})}nonempty(e){return this.min(1,oe.errToObj(e))}trim(){return new ir({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ir({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ir({...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}}ir.create=r=>{var e;return new ir({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};function Zx(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class bn extends Ee{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 i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.number,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?Zx(e.data,i.value)!==0&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_finite,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new bn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:oe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:oe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:oe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:oe.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"&&Pe.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)}}bn.create=r=>new bn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class xn extends Ee{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 i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.bigint,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new xn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new xn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.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}}xn.create=r=>{var e;return new xn({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};class aa extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.boolean,received:t.parsedType}),ge}return wt(e.data)}}aa.create=r=>new aa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class ei extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.date,received:i.parsedType}),ge}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_date}),ge}const t=new gt;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:oe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:oe.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}}ei.create=r=>new ei({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...we(r)});class Qo extends Ee{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.symbol,received:t.parsedType}),ge}return wt(e.data)}}Qo.create=r=>new Qo({typeName:fe.ZodSymbol,...we(r)});class oa extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.undefined,received:t.parsedType}),ge}return wt(e.data)}}oa.create=r=>new oa({typeName:fe.ZodUndefined,...we(r)});class ca extends Ee{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.null,received:t.parsedType}),ge}return wt(e.data)}}ca.create=r=>new ca({typeName:fe.ZodNull,...we(r)});class Fi extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Fi.create=r=>new Fi({typeName:fe.ZodAny,...we(r)});class Gn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}Gn.create=r=>new Gn({typeName:fe.ZodUnknown,...we(r)});class Fr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.never,received:t.parsedType}),ge}}Fr.create=r=>new Fr({typeName:fe.ZodNever,...we(r)});class ec extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.void,received:t.parsedType}),ge}return wt(e.data)}}ec.create=r=>new ec({typeName:fe.ZodVoid,...we(r)});class cr extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==G.array)return F(t,{code:Z.invalid_type,expected:G.array,received:t.parsedType}),ge;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(F(t,{code:a?Z.too_big:Z.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(F(t,{code:Z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(F(t,{code:Z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>gt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Ar(t,a,t.path,o)));return gt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new cr({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new cr({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new cr({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}cr.create=(r,e)=>new cr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...we(e)});function Si(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Si(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof cr?new cr({...r._def,type:Si(r.element)}):r instanceof _r?_r.create(Si(r.unwrap())):r instanceof wn?wn.create(Si(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>Si(e))):r}class Je extends Ee{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=Pe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const c=this._getOrReturnCtx(e);return F(c,{code:Z.invalid_type,expected:G.object,received:c.parsedType}),ge}const{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const c in n.data)s.includes(c)||a.push(c);const o=[];for(const c of s){const u=i[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Ar(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Fr){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")a.length>0&&(F(n,{code:Z.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const f=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Ar(n,f,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const f=await u.key,m=await u.value;c.push({key:f,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>gt.mergeObjectSync(t,c)):gt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=oe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(e){return new Je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Je({...this._def,catchall:e})}pick(e){const t={};return Pe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return Si(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Je({...this._def,shape:()=>t})}required(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof _r;)i=i._def.innerType;t[n]=i}}),new Je({...this._def,shape:()=>t})}keyof(){return hy(Pe.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});class ua extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Dt(o.ctx.common.issues));return F(t,{code:Z.invalid_union,unionErrors:a}),ge}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new Dt(c));return F(t,{code:Z.invalid_union,unionErrors:o}),ge}}get options(){return this._def.options}}ua.create=(r,e)=>new ua({options:r,typeName:fe.ZodUnion,...we(e)});const rn=r=>r instanceof fa?rn(r.schema):r instanceof fr?rn(r.innerType()):r instanceof ha?[r.value]:r instanceof _n?r.options:r instanceof pa?Pe.objectValues(r.enum):r instanceof ma?rn(r._def.innerType):r instanceof oa?[void 0]:r instanceof ca?[null]:r instanceof _r?[void 0,...rn(r.unwrap())]:r instanceof wn?[null,...rn(r.unwrap())]:r instanceof uf||r instanceof ga?rn(r.unwrap()):r instanceof ya?rn(r._def.innerType):[];class ru extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return F(t,{code:Z.invalid_type,expected:G.object,received:t.parsedType}),ge;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ge)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=rn(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new ru({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...we(n)})}}function Nl(r,e){const t=an(r),n=an(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const i=Pe.objectKeys(e),s=Pe.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=Nl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=Nl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class la extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(jl(s)||jl(a))return ge;const o=Nl(s.value,a.value);return o.valid?((Tl(s)||Tl(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:Z.invalid_intersection_types}),ge)};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(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}la.create=(r,e,t)=>new la({left:r,right:e,typeName:fe.ZodIntersection,...we(t)});class Or extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:Z.invalid_type,expected:G.array,received:n.parsedType}),ge;if(n.data.length<this._def.items.length)return F(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ge;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((s,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Ar(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>gt.mergeArray(t,s)):gt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Or({...this._def,rest:e})}}Or.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Or({items:r,typeName:fe.ZodTuple,rest:null,...we(e)})};class da extends Ee{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 F(n,{code:Z.invalid_type,expected:G.object,received:n.parsedType}),ge;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Ar(n,o,n.path,o)),value:a._parse(new Ar(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?gt.mergeObjectAsync(t,i):gt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new da({keyType:e,valueType:t,typeName:fe.ZodRecord,...we(n)}):new da({keyType:ir.create(),valueType:e,typeName:fe.ZodRecord,...we(t)})}}class tc extends Ee{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 F(n,{code:Z.invalid_type,expected:G.map,received:n.parsedType}),ge;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Ar(n,o,n.path,[u,"key"])),value:s._parse(new Ar(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}tc.create=(r,e,t)=>new tc({valueType:e,keyType:r,typeName:fe.ZodMap,...we(t)});class ti extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:Z.invalid_type,expected:G.set,received:n.parsedType}),ge;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(F(n,{code:Z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(F(n,{code:Z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ge;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Ar(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ti({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new ti({...this._def,maxSize:{value:e,message:oe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ti.create=(r,e)=>new ti({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...we(e)});class Ti extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return F(t,{code:Z.invalid_type,expected:G.function,received:t.parsedType}),ge;function n(o,c){return Jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Go(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function i(o,c){return Jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Go(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ki){const o=this;return wt(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,s).catch(B=>{throw u.addIssue(n(c,B)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(B=>{throw u.addIssue(i(m,B)),u})})}else{const o=this;return wt(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new Dt([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ti({...this._def,args:Or.create(e).rest(Gn.create())})}returns(e){return new Ti({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ti({args:e||Or.create([]).rest(Gn.create()),returns:t||Gn.create(),typeName:fe.ZodFunction,...we(n)})}}class fa extends Ee{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})}}fa.create=(r,e)=>new fa({getter:r,typeName:fe.ZodLazy,...we(e)});class ha extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),ge}return{status:"valid",value:e.data}}get value(){return this._def.value}}ha.create=(r,e)=>new ha({value:r,typeName:fe.ZodLiteral,...we(e)});function hy(r,e){return new _n({values:r,typeName:fe.ZodEnum,...we(e)})}class _n extends Ee{constructor(){super(...arguments),js.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Pe.joinValues(n),received:t.parsedType,code:Z.invalid_type}),ge}if(Xo(this,js)||uy(this,js,new Set(this._def.values)),!Xo(this,js).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:Z.invalid_enum_value,options:n}),ge}return wt(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 _n.create(e,{...this._def,...t})}exclude(e,t=this._def){return _n.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}js=new WeakMap;_n.create=hy;class pa extends Ee{constructor(){super(...arguments),Ts.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const i=Pe.objectValues(t);return F(n,{expected:Pe.joinValues(i),received:n.parsedType,code:Z.invalid_type}),ge}if(Xo(this,Ts)||uy(this,Ts,new Set(Pe.getValidEnumValues(this._def.values))),!Xo(this,Ts).has(e.data)){const i=Pe.objectValues(t);return F(n,{received:n.data,code:Z.invalid_enum_value,options:i}),ge}return wt(e.data)}get enum(){return this._def.values}}Ts=new WeakMap;pa.create=(r,e)=>new pa({values:r,typeName:fe.ZodNativeEnum,...we(e)});class Ki extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return F(t,{code:Z.invalid_type,expected:G.promise,received:t.parsedType}),ge;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return wt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ki.create=(r,e)=>new Ki({type:r,typeName:fe.ZodPromise,...we(e)});class fr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ge;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ge:c.status==="dirty"||t.value==="dirty"?Yo(c.value):c});{if(t.value==="aborted")return ge;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ge:o.status==="dirty"||t.value==="dirty"?Yo(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);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"?ge:(o.status==="dirty"&&t.dirty(),a(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"?ge:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ia(a))return a;const o=i.transform(a.value,s);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(a=>ia(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(i)}}fr.create=(r,e,t)=>new fr({schema:r,typeName:fe.ZodEffects,effect:e,...we(t)});fr.createWithPreprocess=(r,e,t)=>new fr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...we(t)});class _r extends Ee{_parse(e){return this._getType(e)===G.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_r.create=(r,e)=>new _r({innerType:r,typeName:fe.ZodOptional,...we(e)});class wn extends Ee{_parse(e){return this._getType(e)===G.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wn.create=(r,e)=>new wn({innerType:r,typeName:fe.ZodNullable,...we(e)});class ma extends Ee{_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}}ma.create=(r,e)=>new ma({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...we(e)});class ya extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return sa(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ya.create=(r,e)=>new ya({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...we(e)});class rc extends Ee{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.nan,received:t.parsedType}),ge}return{status:"valid",value:e.data}}}rc.create=r=>new rc({typeName:fe.ZodNaN,...we(r)});const Mx=Symbol("zod_brand");class uf extends Ee{_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 Ya extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),Yo(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Ya({in:e,out:t,typeName:fe.ZodPipeline})}}class ga extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=i=>(ia(i)&&(i.value=Object.freeze(i.value)),i);return sa(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodReadonly,...we(e)});function py(r,e={},t){return r?Fi.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Fi.create()}const Ux={object:Je.lazycreate};var fe;(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"})(fe||(fe={}));const Vx=(r,e={message:`Input not instance of ${r.name}`})=>py(t=>t instanceof r,e),my=ir.create,yy=bn.create,Lx=rc.create,qx=xn.create,gy=aa.create,Hx=ei.create,Fx=Qo.create,Kx=oa.create,Wx=ca.create,zx=Fi.create,Gx=Gn.create,Jx=Fr.create,Yx=ec.create,Xx=cr.create,Qx=Je.create,e_=Je.strictCreate,t_=ua.create,r_=ru.create,n_=la.create,i_=Or.create,s_=da.create,a_=tc.create,o_=ti.create,c_=Ti.create,u_=fa.create,l_=ha.create,d_=_n.create,f_=pa.create,h_=Ki.create,Ch=fr.create,p_=_r.create,m_=wn.create,y_=fr.createWithPreprocess,g_=Ya.create,v_=()=>my().optional(),b_=()=>yy().optional(),x_=()=>gy().optional(),__={string:r=>ir.create({...r,coerce:!0}),number:r=>bn.create({...r,coerce:!0}),boolean:r=>aa.create({...r,coerce:!0}),bigint:r=>xn.create({...r,coerce:!0}),date:r=>ei.create({...r,coerce:!0})},w_=ge;var d=Object.freeze({__proto__:null,defaultErrorMap:Hi,setErrorMap:wx,getErrorMap:Go,makeIssue:Jo,EMPTY_PATH:kx,addIssueToContext:F,ParseStatus:gt,INVALID:ge,DIRTY:Yo,OK:wt,isAborted:jl,isDirty:Tl,isValid:ia,isAsync:sa,get util(){return Pe},get objectUtil(){return Cl},ZodParsedType:G,getParsedType:an,ZodType:Ee,datetimeRegex:fy,ZodString:ir,ZodNumber:bn,ZodBigInt:xn,ZodBoolean:aa,ZodDate:ei,ZodSymbol:Qo,ZodUndefined:oa,ZodNull:ca,ZodAny:Fi,ZodUnknown:Gn,ZodNever:Fr,ZodVoid:ec,ZodArray:cr,ZodObject:Je,ZodUnion:ua,ZodDiscriminatedUnion:ru,ZodIntersection:la,ZodTuple:Or,ZodRecord:da,ZodMap:tc,ZodSet:ti,ZodFunction:Ti,ZodLazy:fa,ZodLiteral:ha,ZodEnum:_n,ZodNativeEnum:pa,ZodPromise:Ki,ZodEffects:fr,ZodTransformer:fr,ZodOptional:_r,ZodNullable:wn,ZodDefault:ma,ZodCatch:ya,ZodNaN:rc,BRAND:Mx,ZodBranded:uf,ZodPipeline:Ya,ZodReadonly:ga,custom:py,Schema:Ee,ZodSchema:Ee,late:Ux,get ZodFirstPartyTypeKind(){return fe},coerce:__,any:zx,array:Xx,bigint:qx,boolean:gy,date:Hx,discriminatedUnion:r_,effect:Ch,enum:d_,function:c_,instanceof:Vx,intersection:n_,lazy:u_,literal:l_,map:a_,nan:Lx,nativeEnum:f_,never:Jx,null:Wx,nullable:m_,number:yy,object:Qx,oboolean:x_,onumber:b_,optional:p_,ostring:v_,pipeline:g_,preprocess:y_,promise:h_,record:s_,set:o_,strictObject:e_,string:my,symbol:Fx,transformer:Ch,tuple:i_,undefined:Kx,union:t_,unknown:Gx,void:Yx,NEVER:w_,ZodIssueCode:Z,quotelessJson:_x,ZodError:Dt});xx(d);const jn=d.object({start:d.number(),limit:d.number(),length:d.number()}),lf=d.object({created_at:d.string(),updated_at:d.string()}),vy=d.object({email:d.string().optional(),email_verified:d.boolean().optional(),name:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),phone_number:d.string().optional(),phone_verified:d.boolean().optional(),family_name:d.string().optional()}).catchall(d.any()),by=d.object({connection:d.string(),user_id:d.string(),provider:d.string(),isSocial:d.boolean(),access_token:d.string().optional(),access_token_secret:d.string().optional(),refresh_token:d.string().optional(),profileData:vy.optional()}),nu=d.object({email:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),family_name:d.string().optional(),nickname:d.string().optional(),name:d.string().optional(),picture:d.string().optional(),locale:d.string().optional(),linked_to:d.string().optional(),profileData:d.string().optional(),user_id:d.string().optional(),app_metadata:d.any().default({}).optional(),user_metadata:d.any().default({}).optional()}),nc=nu.extend({email_verified:d.boolean().default(!1),verify_email:d.boolean().optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string().optional(),provider:d.string().default("email"),connection:d.string().default("email")}),df=d.object({...nc.shape,...lf.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(by).optional()}),vr=df,k_=nu.extend({email:d.string(),login_count:d.number(),multifactor:d.array(d.string()).optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string()}).catchall(d.any()),S_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let A_=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=S_[t[r]&63];return e};const xy=d.object({audience:d.string().optional(),recipient:d.string().optional(),createUpnClaim:d.boolean().optional(),mapUnknownClaimsAsIs:d.boolean().optional(),passthroughClaimsWithNoMapping:d.boolean().optional(),mapIdentities:d.boolean().optional(),signatureAlgorithm:d.string().optional(),digestAlgorithm:d.string().optional(),issuer:d.string().optional(),destination:d.string().optional(),lifetimeInSeconds:d.number().optional(),signResponse:d.boolean().optional(),nameIdentifierFormat:d.string().optional(),nameIdentifierProbes:d.array(d.string()).optional(),authnContextClassRef:d.string().optional(),mappings:d.record(d.string()).optional()}),ic=d.object({id:d.string(),name:d.string(),callbacks:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:d.array(d.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:d.object({samlp:xy.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:d.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:d.string().default(()=>A_()).optional(),disable_sign_ups:d.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Mn=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...ic.shape});var ff=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(ff||{}),hf=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(hf||{}),pf=(r=>(r.S256="S256",r.Plain="plain",r))(pf||{});const _y=d.object({client_id:d.string(),vendor_id:d.string().optional(),act_as:d.string().optional(),response_type:d.nativeEnum(ff).optional(),response_mode:d.nativeEnum(hf).optional(),redirect_uri:d.string().optional(),audience:d.string().optional(),state:d.string().optional(),nonce:d.string().optional(),scope:d.string().optional(),prompt:d.string().optional(),code_challenge_method:d.nativeEnum(pf).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),Bl=d.object({colors:d.object({primary:d.string(),page_background:d.object({type:d.string().optional(),start:d.string().optional(),end:d.string().optional(),angle_deg:d.number().optional()}).optional()}).optional(),logo_url:d.string().optional(),favicon_url:d.string().optional(),font:d.object({url:d.string()}).optional()}),sc=d.object({id:d.string().optional(),name:d.string(),strategy:d.enum(["google-oauth2","facebook","vipps","freja","apple","email","auth0","authhero","Username-Password-Authentication","oidc","oauth2","custom"]),options:d.object({kid:d.string().optional(),team_id:d.string().optional(),realms:d.string().optional(),client_id:d.string().optional(),client_secret:d.string().optional(),app_secret:d.string().optional(),scope:d.string().optional(),authorization_endpoint:d.string().default("").optional(),token_endpoint:d.string().default("").optional(),userinfo_endpoint:d.string().default("").optional(),jwks_uri:d.string().default("").optional(),discovery_url:d.string().default("").optional(),issuer:d.string().default("").optional()}).default({}).optional(),enabled_clients:d.array(d.string()).default([]).optional(),response_type:d.custom().optional(),response_mode:d.custom().optional()}),Un=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(sc.shape),ac=d.object({name:d.string(),audience:d.string(),sender_email:d.string().email(),sender_name:d.string(),support_url:d.string().url().optional(),logo:d.string().url().optional(),primary_color:d.string().optional(),secondary_color:d.string().optional(),language:d.string().optional()}),Ni=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...ac.shape}),O_=d.object({logoUrl:d.string(),loginBackgroundImage:d.string().nullish(),style:d.object({primaryColor:d.string(),buttonTextColor:d.string(),primaryHoverColor:d.string()}),supportEmail:d.string().nullable(),supportUrl:d.string().nullable(),name:d.string(),showGreyishBackground:d.boolean().optional(),termsAndConditionsUrl:d.string().nullable(),companyName:d.string().optional(),checkoutHideSocial:d.boolean().optional(),siteUrl:d.string().nullable(),manageSubscriptionsUrl:d.string().optional()}),E_=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.union([d.literal("mailgun"),d.literal("mailchannels")]).optional()});d.object({...Mn.shape,domains:d.array(E_),tenant:Ni,connections:d.array(Un)});const wy=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),ky=d.object({code_id:d.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:d.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:d.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:wy,code_verifier:d.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()}),I_=d.object({...ky.shape,created_at:d.string()}),Sy=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.enum(["mailgun","mailchannels"])}),C_=lf.extend({...Sy.shape,id:d.string()}),oc=d.object({trigger_id:d.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:d.boolean().default(!1),url:d.string(),hook_id:d.string().optional(),synchronous:d.boolean().default(!1),priority:d.number().optional()}),Ei=oc.extend({...lf.shape,hook_id:d.string()}),mf=d.object({alg:d.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:d.string(),kid:d.string(),kty:d.enum(["RSA","EC","oct"]),n:d.string(),x5t:d.string().optional(),x5c:d.array(d.string()).optional(),use:d.enum(["sig","enc"]).optional()}),Ay=d.object({keys:d.array(mf)}),Rl=d.object({issuer:d.string(),authorization_endpoint:d.string(),token_endpoint:d.string(),device_authorization_endpoint:d.string(),userinfo_endpoint:d.string(),mfa_challenge_endpoint:d.string(),jwks_uri:d.string(),registration_endpoint:d.string(),revocation_endpoint:d.string(),scopes_supported:d.array(d.string()),response_types_supported:d.array(d.string()),code_challenge_methods_supported:d.array(d.string()),response_modes_supported:d.array(d.string()),subject_types_supported:d.array(d.string()),id_token_signing_alg_values_supported:d.array(d.string()),token_endpoint_auth_methods_supported:d.array(d.string()),claims_supported:d.array(d.string()),request_uri_parameter_supported:d.boolean(),request_parameter_supported:d.boolean(),token_endpoint_auth_signing_alg_values_supported:d.array(d.string())}),Oy=d.object({auth0Client:d.string().optional(),authParams:_y,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional(),useragent:d.string().optional()}).openapi({description:"This represents a login sesion"}),j_=d.object({...Oy.shape,login_id:d.string().openapi({description:"This is is used as the state in the universal login"}),created_at:d.string(),updated_at:d.string()});var iu=(r=>(r.FAILED_SILENT_AUTH="fsa",r.FAILED_SIGNUP="fs",r.FAILED_LOGIN="f",r.FAILED_LOGIN_INCORRECT_PASSWORD="fp",r.FAILED_CHANGE_PASSWORD="fcp",r.FAILED_BY_CONNECTOR="fc",r.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",r.FAILED_HOOK="fh",r.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",r.SUCCESS_API_OPERATION="sapi",r.SUCCESS_CHANGE_PASSWORD="scp",r.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",r.SUCCESS_CHANGE_USERNAME="scu",r.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",r.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",r.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",r.SUCCESS_LOGIN="s",r.SUCCESS_LOGOUT="slo",r.SUCCESS_SIGNUP="ss",r.SUCCESS_SILENT_AUTH="ssa",r.SUCCESS_VERIFICATION_EMAIL="sv",r.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",r.CODE_LINK_SENT="cls",r))(iu||{});const T_=d.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),Ey=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),cc=d.object({type:T_,date:d.string(),description:d.string().optional(),log_id:d.string().optional(),_id:d.string().optional(),ip:d.string(),user_agent:d.string(),details:d.any().optional(),isMobile:d.boolean(),user_id:d.string().optional(),user_name:d.string().optional(),connection:d.string().optional(),connection_id:d.string().optional(),client_id:d.string().optional(),client_name:d.string().optional(),audience:d.string().optional(),scope:d.array(d.string()).optional(),strategy:d.string().optional(),strategy_type:d.string().optional(),hostname:d.string().optional(),auth0_client:Ey.optional()}),Iy=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")}),N_=d.object({...Iy.shape,created_at:d.string(),updated_at:d.string()}),Cy=d.object({session_id:d.string(),client_id:d.string(),expires_at:d.string(),used_at:d.string(),deleted_at:d.string().optional(),user_id:d.string()}),yf=d.object({created_at:d.string(),...Cy.shape}),Pl=d.object({kid:d.string().openapi({description:"The key id of the signing key"}),cert:d.string().openapi({description:"The public certificate of the signing key"}),fingerprint:d.string().openapi({description:"The cert fingerprint"}),thumbprint:d.string().openapi({description:"The cert thumbprint"}),pkcs7:d.string().optional().openapi({description:"The private key in pkcs7 format"}),current:d.boolean().optional().openapi({description:"True if the key is the current key"}),next:d.boolean().optional().openapi({description:"True if the key is the next key"}),previous:d.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:d.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:d.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:d.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:d.string().optional().openapi({description:"The date and time when the key was revoked"})});var uc=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(uc||{});d.object({access_token:d.string(),id_token:d.string().optional(),scope:d.string().optional(),state:d.string().optional(),refresh_token:d.string().optional(),token_type:d.string(),expires_in:d.number()});d.object({code:d.string(),state:d.string().optional()});const jy=d.object({button_border_radius:d.number(),button_border_weight:d.number(),buttons_style:d.enum(["pill"]),input_border_radius:d.number(),input_border_weight:d.number(),inputs_style:d.enum(["pill"]),show_widget_shadow:d.boolean(),widget_border_weight:d.number(),widget_corner_radius:d.number()}),Ty=d.object({base_focus_color:d.string(),base_hover_color:d.string(),body_text:d.string(),captcha_widget_theme:d.enum(["auto"]),error:d.string(),header:d.string(),icons:d.string(),input_background:d.string(),input_border:d.string(),input_filled_text:d.string(),input_labels_placeholders:d.string(),links_focused_components:d.string(),primary_button:d.string(),primary_button_label:d.string(),secondary_button_border:d.string(),secondary_button_label:d.string(),success:d.string(),widget_background:d.string(),widget_border:d.string()}),Dn=d.object({bold:d.boolean(),size:d.number()}),Ny=d.object({body_text:Dn,buttons_text:Dn,font_url:d.string(),input_labels:Dn,links:Dn,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Dn,title:Dn}),By=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),Ry=d.object({header_text_alignment:d.enum(["center"]),logo_height:d.number(),logo_position:d.enum(["center"]),logo_url:d.string(),social_buttons_layout:d.enum(["bottom"])}),Py=d.object({borders:jy,colors:Ty,displayName:d.string(),fonts:Ny,page_background:By,widget:Ry}),B_=Py.extend({themeId:d.string()}),jo=d.object({universal_login_experience:d.enum(["new","classic"]).default("new"),identifier_first:d.boolean().default(!0),password_first:d.boolean().default(!1),webauthn_platform_first_factor:d.boolean()}),To=d.object({name:d.string(),enabled:d.boolean().optional().default(!0),default_from_address:d.string().optional(),credentials:d.union([d.object({accessKeyId:d.string(),secretAccessKey:d.string(),region:d.string()}),d.object({smtp_host:d.array(d.string()),smtp_port:d.number(),smtp_user:d.string(),smtp_pass:d.string()}),d.object({api_key:d.string(),domain:d.string().optional()}),d.object({connectionString:d.string()}),d.object({tenantId:d.string(),clientId:d.string(),clientSecret:d.string()})]),settings:d.object({}).optional()});function R_(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}const P_=new dt().openapi(ve({tags:["branding"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Bl}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.branding.get(e);return t?r.json(t):r.json({})}).openapi(ve({tags:["branding"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(Bl.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});var lc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $_(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function D_(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}function Z_(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var $y={exports:{}};const M_={},U_=Object.freeze(Object.defineProperty({__proto__:null,default:M_},Symbol.toStringTag,{value:"Module"})),V_=D_(U_);(function(r){/**
2
2
  * @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
3
3
  * Released under the Apache License, Version 2.0
4
4
  * see: https://github.com/dcodeIO/bcrypt.js for details
@@ -1587,6 +1587,7 @@ export declare const codeInsertSchema: z.ZodObject<{
1587
1587
  "oauth2_state",
1588
1588
  "ticket"
1589
1589
  ]>;
1590
+ code_verifier: z.ZodOptional<z.ZodString>;
1590
1591
  expires_at: z.ZodString;
1591
1592
  used_at: z.ZodOptional<z.ZodString>;
1592
1593
  user_id: z.ZodOptional<z.ZodString>;
@@ -1597,6 +1598,7 @@ export declare const codeInsertSchema: z.ZodObject<{
1597
1598
  expires_at: string;
1598
1599
  user_id?: string | undefined;
1599
1600
  connection_id?: string | undefined;
1601
+ code_verifier?: string | undefined;
1600
1602
  used_at?: string | undefined;
1601
1603
  }, {
1602
1604
  code_id: string;
@@ -1605,6 +1607,7 @@ export declare const codeInsertSchema: z.ZodObject<{
1605
1607
  expires_at: string;
1606
1608
  user_id?: string | undefined;
1607
1609
  connection_id?: string | undefined;
1610
+ code_verifier?: string | undefined;
1608
1611
  used_at?: string | undefined;
1609
1612
  }>;
1610
1613
  export type CodeInsert = z.infer<typeof codeInsertSchema>;
@@ -1621,6 +1624,7 @@ export declare const codeSchema: z.ZodObject<{
1621
1624
  "oauth2_state",
1622
1625
  "ticket"
1623
1626
  ]>;
1627
+ code_verifier: z.ZodOptional<z.ZodString>;
1624
1628
  expires_at: z.ZodString;
1625
1629
  used_at: z.ZodOptional<z.ZodString>;
1626
1630
  user_id: z.ZodOptional<z.ZodString>;
@@ -1632,6 +1636,7 @@ export declare const codeSchema: z.ZodObject<{
1632
1636
  expires_at: string;
1633
1637
  user_id?: string | undefined;
1634
1638
  connection_id?: string | undefined;
1639
+ code_verifier?: string | undefined;
1635
1640
  used_at?: string | undefined;
1636
1641
  }, {
1637
1642
  created_at: string;
@@ -1641,6 +1646,7 @@ export declare const codeSchema: z.ZodObject<{
1641
1646
  expires_at: string;
1642
1647
  user_id?: string | undefined;
1643
1648
  connection_id?: string | undefined;
1649
+ code_verifier?: string | undefined;
1644
1650
  used_at?: string | undefined;
1645
1651
  }>;
1646
1652
  export type Code = z.infer<typeof codeSchema>;
package/dist/authhero.mjs CHANGED
@@ -8162,6 +8162,9 @@ const f_ = d.enum([
8162
8162
  description: "The connection that the code is connected to"
8163
8163
  }),
8164
8164
  code_type: f_,
8165
+ code_verifier: d.string().optional().openapi({
8166
+ description: "The code verifier used in PKCE in outbound flows"
8167
+ }),
8165
8168
  expires_at: d.string(),
8166
8169
  used_at: d.string().optional(),
8167
8170
  user_id: d.string().optional()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authhero",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -24,14 +24,14 @@
24
24
  "vite": "^5.4.11",
25
25
  "vite-plugin-dts": "^4.3.0",
26
26
  "vitest": "^2.1.5",
27
- "@authhero/kysely-adapter": "^0.24.2"
27
+ "@authhero/kysely-adapter": "^0.24.3"
28
28
  },
29
29
  "dependencies": {
30
30
  "@peculiar/x509": "^1.12.3",
31
31
  "bcrypt": "^5.1.1",
32
32
  "bcryptjs": "^2.4.3",
33
33
  "oslo": "^1.2.1",
34
- "@authhero/adapter-interfaces": "^0.29.0"
34
+ "@authhero/adapter-interfaces": "^0.29.1"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@hono/zod-openapi": "^0.18.0",