authhero 0.2.3 → 0.2.5

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.
@@ -1 +1 @@
1
- var authhero=function(V){"use strict";var Qo=Object.defineProperty;var ds=V=>{throw TypeError(V)};var Xo=(V,L,k)=>L in V?Qo(V,L,{enumerable:!0,configurable:!0,writable:!0,value:k}):V[L]=k;var y=(V,L,k)=>Xo(V,typeof L!="symbol"?L+"":L,k),us=(V,L,k)=>L.has(V)||ds("Cannot "+k);var m=(V,L,k)=>(us(V,L,"read from private field"),k?k.call(V):L.get(V)),Y=(V,L,k)=>L.has(V)?ds("Cannot add the same private member more than once"):L instanceof WeakSet?L.add(V):L.set(V,k),M=(V,L,k,fn)=>(us(V,L,"write to private field"),fn?fn.call(V,k):L.set(V,k),k);var mt,fe,is,dn,un,Ue,Je,Re,W,F,me,Ee,ln,gt,_t,pn,hn,os,ge,cs;function L(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}typeof SuppressedError=="function"&&SuppressedError;function k(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function fn(n){return"_def"in n}function yt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function ls(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var i,o,d,u,l,p;const C=typeof s=="string"?a:s,D=C??{},{param:N}=D,R=L(D,["param"]),H=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),K=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),R),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||N?{param:Object.assign(Object.assign({},(p=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||p===void 0?void 0:p.param),N)}:void 0),se=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(H).length>0?{_internal:H}:void 0),Object.keys(K).length>0?{metadata:K}:void 0)}));if(k(this,"ZodObject")){const ae=this.extend;se.extend=function(...qe){var oe,ie,te,Oe,_e,Qe;const Xe=ae.apply(this,qe);return Xe._def.openapi={_internal:{extendedFrom:!((ie=(oe=this._def.openapi)===null||oe===void 0?void 0:oe._internal)===null||ie===void 0)&&ie.refId?{refId:(Oe=(te=this._def.openapi)===null||te===void 0?void 0:te._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(_e=this._def.openapi)===null||_e===void 0?void 0:_e._internal.extendedFrom},metadata:(Qe=Xe._def.openapi)===null||Qe===void 0?void 0:Qe.metadata},Xe}}return se},yt(n,"optional"),yt(n,"nullable"),yt(n,"default"),yt(n,"transform"),yt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var u,l;d._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}function mn(n,e){if(n==null||e===null||e===void 0)return n===e;if(n===e||n.valueOf()===e.valueOf())return!0;if(Array.isArray(n)&&(!Array.isArray(e)||n.length!==e.length)||!(n instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(n);return Object.keys(e).every(r=>t.indexOf(r)!==-1)&&t.every(r=>mn(n[r],e[r]))}class ps{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),r=this.buckets.get(t);if(!r){this.buckets.set(t,[e]);return}r.some(a=>mn(a,e))||r.push(e)}contains(e){const t=this.hashCodeOf(e),r=this.buckets.get(t);return r?r.some(s=>mn(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,r=0;for(const a of this.buckets.values())e+=1,t+=a.length,a.length>1&&(r+=1);const s=e/t;return{totalBuckets:e,collisions:r,totalValues:t,hashEffectiveness:s}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let r=0;r<e.length;r++)t^=this.hashCodeOf(e[r])*r;return t}if(typeof e=="string"){for(let r=0;r<e.length;r++)t^=e.charCodeAt(r)*r;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[r,s]of Object.entries(e))t^=this.hashCodeOf(r)+this.hashCodeOf(s??"");return t}}function vt(n){return n==null}function bt(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{t[r]=e(s)}),t}function hs(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{e.some(a=>a===r)||(t[r]=s)}),t}function et(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{e(s,r)||(t[r]=s)}),t}function dr(n){return n.filter(e=>!vt(e))}const Bn=mn;function fs(n){const e=new ps;return n.forEach(t=>e.put(t)),[...e.values()]}function ur(n){return typeof n=="string"}class ms{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const r=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:r}),r}registerParameter(e,t){var r,s,a;const i=this.schemaWithRefId(e,t),o=(r=i._def.openapi)===null||r===void 0?void 0:r.metadata,d=i.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(a=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&a!==void 0?a:e})}));return this._definitions.push({type:"parameter",schema:d}),d}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,r){return this._definitions.push({type:"component",componentType:e,name:t,component:r}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class gn{constructor(e){this.message=e}}class kt extends gn{constructor(e,t){super(e),this.data=t}}class _n extends gn{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 wt(n,e){try{return n()}catch(t){throw t instanceof _n?new _n(Object.assign(Object.assign({},t.data),e)):t}}class gs extends gn{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class U{static getMetadata(e){var t;const r=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:r._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:r.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:a},s==null?void 0:s.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),r=e._def.openapi?e._def.openapi:t._def.openapi;return r==null?void 0:r._internal}static getParamMetadata(e){var t,r;const s=this.unwrapChained(e),a=e._def.openapi?e._def.openapi:s._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:a==null?void 0:a._internal,metadata:Object.assign(Object.assign({},a==null?void 0:a.metadata),{param:Object.assign({description:i},(r=a==null?void 0:a.metadata)===null||r===void 0?void 0:r.param)})}}static buildSchemaMetadata(e){return et(hs(e,["param"]),vt)}static buildParameterMetadata(e){return et(e,vt)}static applySchemaMetadata(e,t){return et(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),vt)}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&&k(e,t)?e:k(e,"ZodOptional")||k(e,"ZodNullable")||k(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):k(e,"ZodDefault")||k(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):k(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):k(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return k(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class _s{transform(e,t,r){var s,a;const i=e._def.type;return Object.assign(Object.assign({},t("array")),{items:r(i),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(a=e._def.maxLength)===null||a===void 0?void 0:a.value})}}class ys{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class vs{transform(e,t,r,s,a){const i=[...e.options.values()],o=i.map(s);return t?{oneOf:r(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(i,e.discriminator,a)}}mapDiscriminator(e,t,r){if(e.some(a=>U.getRefId(a)===void 0))return;const s={};return e.forEach(a=>{var i;const o=U.getRefId(a),d=(i=a.shape)===null||i===void 0?void 0:i[t];if(k(d,"ZodEnum")||k(d,"ZodNativeEnum")){Object.values(d.enum).filter(ur).forEach(p=>{s[p]=r(o)});return}const u=d==null?void 0:d._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=r(o)}),{propertyName:t,mapping:s}}}class bs{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class ks{transform(e,t,r,s){const i={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:r([i],t)}:i}flattenIntersectionTypes(e){if(!k(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),r=this.flattenIntersectionTypes(e._def.right);return[...t,...r]}}class ws{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function xs(n){const t=Object.keys(n).filter(a=>typeof n[n[a]]!="number").map(a=>n[a]),r=t.filter(a=>typeof a=="number").length,s=r===0?"string":r===t.length?"numeric":"mixed";return{values:t,type:s}}class Os{transform(e,t){const{type:r,values:s}=xs(e._def.values);if(r==="mixed")throw new gn("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(r==="numeric"?"integer":"string")),{enum:s})}}class Ts{transform(e,t,r){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),r(e._def.checks))}}class js{transform(e,t,r,s){var a;const i=(a=U.getInternalMetadata(e))===null||a===void 0?void 0:a.extendedFrom,o=this.requiredKeysOf(e),d=bt(e._def.shape(),s);if(!i)return Object.assign(Object.assign(Object.assign(Object.assign({},r("object")),{properties:d,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=i.schema;s(u);const l=this.requiredKeysOf(u),p=bt(u==null?void 0:u._def.shape(),s),C=Object.fromEntries(Object.entries(d).filter(([R,H])=>!Bn(p[R],H))),D=o.filter(R=>!l.includes(R)),N=Object.assign(Object.assign(Object.assign(Object.assign({},r("object")),{default:t,properties:C}),D.length>0?{required:D}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${i.refId}`},N]}}generateAdditionalProperties(e,t){const r=e._def.unknownKeys,s=e._def.catchall;return k(s,"ZodNever")?r==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,r])=>!U.isOptionalSchema(r)).map(([t,r])=>t)}}class Zs{transform(e,t,r){const s=e._def.valueType,a=e._def.keyType,i=r(s);if(k(a,"ZodEnum")||k(a,"ZodNativeEnum")){const d=Object.values(a.enum).filter(ur).reduce((u,l)=>Object.assign(Object.assign({},u),{[l]:i}),{});return Object.assign(Object.assign({},t("object")),{properties:d})}return Object.assign(Object.assign({},t("object")),{additionalProperties:i})}}class Rs{transform(e,t){var r,s,a;const i=this.getZodStringCheck(e,"regex"),o=(r=this.getZodStringCheck(e,"length"))===null||r===void 0?void 0:r.value,d=Number.isFinite(e.minLength)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(a=e.maxLength)!==null&&a!==void 0?a:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??d,maxLength:o??u,format:this.mapStringFormat(e),pattern:i==null?void 0:i.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time"}getZodStringCheck(e,t){return e._def.checks.find(r=>r.kind===t)}}class Es{constructor(e){this.versionSpecifics=e}transform(e,t,r){const{items:s}=e._def,a=s.map(r);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(a))}}class Ss{transform(e,t,r){const a=this.flattenUnionTypes(e).map(i=>{const o=this.unwrapNullable(i);return r(o)});return{anyOf:t(a)}}flattenUnionTypes(e){return k(e,"ZodUnion")?e._def.options.flatMap(r=>this.flattenUnionTypes(r)):[e]}unwrapNullable(e){return k(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Cs{constructor(e){this.versionSpecifics=e,this.objectTransformer=new js,this.stringTransformer=new Rs,this.numberTransformer=new Ts,this.bigIntTransformer=new ys,this.literalTransformer=new ws,this.enumTransformer=new bs,this.nativeEnumTransformer=new Os,this.arrayTransformer=new _s,this.unionTransformer=new Ss,this.discriminatedUnionTransformer=new vs,this.intersectionTransformer=new ks,this.recordTransformer=new Zs,this.tupleTransformer=new Es(e)}transform(e,t,r,s,a){if(k(e,"ZodNull"))return this.versionSpecifics.nullType;if(k(e,"ZodUnknown")||k(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(k(e,"ZodObject"))return this.objectTransformer.transform(e,a,o=>this.versionSpecifics.mapNullableType(o,t),r);const i=this.transformSchemaWithoutDefault(e,t,r,s);return Object.assign(Object.assign({},i),{default:a})}transformSchemaWithoutDefault(e,t,r,s){if(k(e,"ZodUnknown")||k(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(k(e,"ZodString"))return this.stringTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodNumber"))return this.numberTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),i=>this.versionSpecifics.getNumberChecks(i));if(k(e,"ZodBigInt"))return this.bigIntTransformer.transform(i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(k(e,"ZodLiteral"))return this.literalTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodEnum"))return this.enumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodArray"))return this.arrayTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(k(e,"ZodTuple"))return this.tupleTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(k(e,"ZodUnion"))return this.unionTransformer.transform(e,i=>this.versionSpecifics.mapNullableOfArray(i,t),r);if(k(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),r,s);if(k(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),r);if(k(e,"ZodRecord"))return this.recordTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(k(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const a=U.getRefId(e);throw new gs({currentSchema:e._def,schemaName:a})}}class lr{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Cs(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 r={};return this.rawComponents.forEach(({componentType:s,name:a,component:i})=>{var o;(o=r[s])!==null&&o!==void 0||(r[s]={}),r[s][a]=i}),Object.assign(Object.assign({},r),{schemas:Object.assign(Object.assign({},(e=r.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=r.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,r)=>{if(!("type"in t))return"type"in r?-1:0;if(!("type"in r))return 1;const s=e.findIndex(i=>i===t.type),a=e.findIndex(i=>i===r.type);return s-a})}generateSingle(e){if(!("type"in e)){this.generateSchemaWithRef(e);return}switch(e.type){case"parameter":this.generateParameterDefinition(e.schema);return;case"schema":this.generateSchemaWithRef(e.schema);return;case"route":this.generateSingleRoute(e.route);return;case"component":this.rawComponents.push(e);return}}generateParameterDefinition(e){const t=U.getRefId(e),r=this.generateParameter(e);return t&&(this.paramRefs[t]=r),r}getParameterRef(e,t){var r,s,a,i,o;const d=(r=e==null?void 0:e.metadata)===null||r===void 0?void 0:r.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(a=e._internal)===null||a===void 0?void 0:a.refId]:void 0;if(!(!(!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId)||!u)){if(d&&u.in!==d.in||t!=null&&t.in&&u.in!==t.in)throw new kt(`Conflicting location for parameter ${u.name}`,{key:"in",values:dr([u.in,t==null?void 0:t.in,d==null?void 0:d.in])});if(d&&u.name!==d.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new kt("Conflicting names for parameter",{key:"name",values:dr([u.name,t==null?void 0:t.name,d==null?void 0:d.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var r;const s=U.getMetadata(e),a=(r=s==null?void 0:s.metadata)===null||r===void 0?void 0:r.param,i=this.getParameterRef(s,{in:t});if(i)return[i];if(k(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,l])=>{var p,C;const D=U.getMetadata(l),N=this.getParameterRef(D,{in:t,name:u});if(N)return N;const R=(p=D==null?void 0:D.metadata)===null||p===void 0?void 0:p.param;if(R!=null&&R.name&&R.name!==u)throw new kt("Conflicting names for parameter",{key:"name",values:[u,R.name]});if(R!=null&&R.in&&R.in!==t)throw new kt(`Conflicting location for parameter ${(C=R.name)!==null&&C!==void 0?C:u}`,{key:"in",values:[t,R.in]});return this.generateParameter(l.openapi({param:{name:u,in:t}}))})}if(a!=null&&a.in&&a.in!==t)throw new kt(`Conflicting location for parameter ${a.name}`,{key:"in",values:[t,a.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const r=U.getParamMetadata(e),s=(t=r==null?void 0:r.metadata)===null||t===void 0?void 0:t.param,a=!U.isOptionalSchema(e)&&!e.isNullable(),i=this.generateSchemaWithRef(e);return Object.assign({schema:i,required:a},s?U.buildParameterMetadata(s):{})}generateParameter(e){var t;const r=U.getMetadata(e),s=(t=r==null?void 0:r.metadata)===null||t===void 0?void 0:t.param,a=s==null?void 0:s.name,i=s==null?void 0:s.in;if(!a)throw new _n({missingField:"name"});if(!i)throw new _n({missingField:"in",paramName:a});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:i,name:a})}generateSchemaWithMetadata(e){var t;const r=U.unwrapChained(e),s=U.getMetadata(e),a=U.getDefaultValue(e),i=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(r,e.isNullable(),a);return s!=null&&s.metadata?U.applySchemaMetadata(i,s.metadata):et(i,vt)}constructReferencedOpenAPISchema(e){var t;const r=U.getMetadata(e),s=U.unwrapChained(e),a=U.getDefaultValue(e),i=e.isNullable();return!((t=r==null?void 0:r.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(r.metadata.type,i):this.toOpenAPISchema(s,i,a)}generateSimpleSchema(e){var t;const r=U.getMetadata(e),s=U.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const a=this.schemaRefs[s],i={$ref:this.generateSchemaRef(s)},o=et(U.buildSchemaMetadata((t=r==null?void 0:r.metadata)!==null&&t!==void 0?t:{}),(l,p)=>l===void 0||Bn(l,a[p]));if(o.type)return{allOf:[i,o]};const d=et(this.constructReferencedOpenAPISchema(e),(l,p)=>l===void 0||Bn(l,a[p])),u=U.applySchemaMetadata(d,o);return Object.keys(u).length>0?{allOf:[i,u]}:i}generateSchemaWithRef(e){const t=U.getRefId(e),r=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=r,{$ref:this.generateSchemaRef(t)}):r}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,r=L(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},r),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,r=this.cleanParameter(e.query),s=this.cleanParameter(e.params),a=this.cleanParameter(e.cookies),i=wt(()=>r?this.generateInlineParameters(r,"query"):[],{location:"query"}),o=wt(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),d=wt(()=>a?this.generateInlineParameters(a,"cookie"):[],{location:"cookie"}),u=wt(()=>{if(Array.isArray(t))return t.flatMap(p=>this.generateInlineParameters(p,"header"));const l=this.cleanParameter(t);return l?this.generateInlineParameters(l,"header"):[]},{location:"header"});return[...o,...i,...u,...d]}cleanParameter(e){if(e)return k(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:r,request:s,responses:a}=e,i=L(e,["method","path","request","responses"]),o=bt(a,p=>this.getResponse(p)),d=wt(()=>this.getParameters(s),{route:`${t} ${r}`}),u=this.getRequestBody(s==null?void 0:s.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},i),d.length>0?{parameters:[...i.parameters||[],...d]}:{}),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:r}=e,s=L(e,["content","headers"]);const a=t?{content:this.getBodyContent(t)}:{};if(!r)return Object.assign(Object.assign({},s),a);const i=k(r,"ZodObject")?this.getResponseHeaders(r):r;return Object.assign(Object.assign(Object.assign({},s),{headers:i}),a)}getResponseHeaders(e){const t=e._def.shape();return bt(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return bt(e,t=>{if(!t||!fn(t.schema))return t;const{schema:r}=t,s=L(t,["schema"]),a=this.generateSchemaWithRef(r);return Object.assign({schema:a},s)})}toOpenAPISchema(e,t,r){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),r)}}class Is{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=fs(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 Ps{constructor(e){const t=new Is;this.generator=new lr(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class Ns{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 As(n){return"type"in n&&n.type==="webhook"}class $s{constructor(e){this.definitions=e,this.webhookRefs={};const t=new Ns;this.generator=new lr(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(As).forEach(r=>this.generateSingleWebhook(r.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 pr=n=>{const e=n.split("/");return e[0]===""&&e.shift(),e},Ms=n=>{const{groups:e,path:t}=Ds(n),r=pr(t);return Ls(r,e)},Ds=n=>{const e=[];return n=n.replace(/\{[^}]+\}/g,(t,r)=>{const s=`@${r}`;return e.push([s,t]),s}),{groups:e,path:n}},Ls=(n,e)=>{for(let t=e.length-1;t>=0;t--){const[r]=e[t];for(let s=n.length-1;s>=0;s--)if(n[s].includes(r)){n[s]=n[s].replace(r,e[t][1]);break}}return n},yn={},hr=n=>{if(n==="*")return"*";const e=n.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(yn[n]||(e[2]?yn[n]=[n,e[1],new RegExp("^"+e[2]+"$")]:yn[n]=[n,e[1],!0]),yn[n]):null},Vs=n=>{try{return decodeURI(n)}catch{return n.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURI(e)}catch{return e}})}},fr=n=>{const e=n.url,t=e.indexOf("/",8);let r=t;for(;r<e.length;r++){const s=e.charCodeAt(r);if(s===37){const a=e.indexOf("?",r),i=e.slice(t,a===-1?void 0:a);return Vs(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}else if(s===63)break}return e.slice(t,r)},Us=n=>{const e=fr(n);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},Be=(...n)=>{let e="",t=!1;for(let r of n)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),r[0]!=="/"&&(r=`/${r}`),r==="/"&&t?e=`${e}/`:r!=="/"&&(e=`${e}${r}`),r==="/"&&e===""&&(e="/");return e},mr=n=>{if(!n.match(/\:.+\?$/))return null;const e=n.split("/"),t=[];let r="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))r+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&r===""?t.push("/"):t.push(r);const a=s.replace("?","");r+="/"+a,t.push(r)}else r+="/"+s}),t.filter((s,a,i)=>i.indexOf(s)===a)},Wn=n=>/[%+]/.test(n)?(n.indexOf("+")!==-1&&(n=n.replace(/\+/g," ")),/%/.test(n)?vn(n):n):n,gr=(n,e,t)=>{let r;if(!t&&e&&!/[%+]/.test(e)){let i=n.indexOf(`?${e}`,8);for(i===-1&&(i=n.indexOf(`&${e}`,8));i!==-1;){const o=n.charCodeAt(i+e.length+1);if(o===61){const d=i+e.length+2,u=n.indexOf("&",d);return Wn(n.slice(d,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";i=n.indexOf(`&${e}`,i+1)}if(r=/[%+]/.test(n),!r)return}const s={};r??(r=/[%+]/.test(n));let a=n.indexOf("?",8);for(;a!==-1;){const i=n.indexOf("&",a+1);let o=n.indexOf("=",a);o>i&&i!==-1&&(o=-1);let d=n.slice(a+1,o===-1?i===-1?void 0:i:o);if(r&&(d=Wn(d)),a=i,d==="")continue;let u;o===-1?u="":(u=n.slice(o+1,i===-1?void 0:i),r&&(u=Wn(u))),t?(s[d]&&Array.isArray(s[d])||(s[d]=[]),s[d].push(u)):s[d]??(s[d]=u)}return e?s[e]:s},qs=gr,Bs=(n,e)=>gr(n,e,!0),vn=decodeURIComponent,Ws=/^[\w!#$%&'*.^`|~+-]+$/,Hs=/^[ !#-:<-[\]-~]*$/,Fs=(n,e)=>n.trim().split(";").reduce((r,s)=>{s=s.trim();const a=s.indexOf("=");if(a===-1)return r;const i=s.substring(0,a).trim();if(!Ws.test(i))return r;let o=s.substring(a+1).trim();return o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Hs.test(o)&&(r[i]=vn(o)),r},{}),Ks=(n,e,t)=>{const r=n.req.raw.headers.get("Cookie");return r?Fs(r):{}},bn=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});y(this,"res");y(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})}},Gs=(n,e)=>new Response(n,{headers:{"Content-Type":e}}).formData(),zs=(n,e)=>async(t,r)=>{let s={};const a=t.req.header("Content-Type");switch(n){case"json":if(!a||!/^application\/([a-z-\.]+\+)?json/.test(a)){const o=`Invalid HTTP header: Content-Type=${a}`;throw new bn(400,{message:o})}try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new bn(400,{message:o})}break;case"form":{if(!a)break;if(t.req.bodyCache.formData){s=await t.req.bodyCache.formData;break}try{const o=await t.req.arrayBuffer(),d=await Gs(o,a),u={};d.forEach((l,p)=>{p.endsWith("[]")?u[p]===void 0?u[p]=[l]:Array.isArray(u[p])&&u[p].push(l):u[p]=l}),s=u,t.req.bodyCache.formData=d}catch(o){let d="Malformed FormData request.";throw d+=o instanceof Error?` ${o.message}`:` ${String(o)}`,new bn(400,{message:d})}break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,d])=>d.length===1?[o,d[0]]:[o,d]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=Ks(t);break}const i=await e(s,t);if(i instanceof Response)return i;t.req.addValidatedData(n,i),await r()};const tt=(n,e,t)=>zs(n,async(r,s)=>{const a=await e.safeParseAsync(r);if(t){const i=await t({data:r,...a},s);if(i){if(i instanceof Response)return i;if("response"in i)return i.response}}return a.success?a.data:s.json(a,400)});var Ys=async(n,e=Object.create(null))=>{const{all:t=!1,dot:r=!1}=e,a=(n instanceof _r?n.raw.headers:n.headers).get("Content-Type");return a!==null&&a.startsWith("multipart/form-data")||a!==null&&a.startsWith("application/x-www-form-urlencoded")?Js(n,{all:t,dot:r}):{}};async function Js(n,e){const t=await n.formData();return t?Qs(t,e):{}}function Qs(n,e){const t=Object.create(null);return n.forEach((r,s)=>{e.all||s.endsWith("[]")?Xs(t,s,r):t[s]=r}),e.dot&&Object.entries(t).forEach(([r,s])=>{r.includes(".")&&(ea(t,r,s),delete t[r])}),t}var Xs=(n,e,t)=>{n[e]!==void 0?Array.isArray(n[e])?n[e].push(t):n[e]=[n[e],t]:n[e]=t},ea=(n,e,t)=>{let r=n;const s=e.split(".");s.forEach((a,i)=>{i===s.length-1?r[a]=t:((!r[a]||typeof r[a]!="object"||Array.isArray(r[a])||r[a]instanceof File)&&(r[a]=Object.create(null)),r=r[a])})},_r=(is=class{constructor(n,e="/",t=[[]]){y(this,"raw");Y(this,mt);Y(this,fe);y(this,"routeIndex",0);y(this,"path");y(this,"bodyCache",{});y(this,"cachedBody",n=>{const{bodyCache:e,raw:t}=this,r=e[n];if(r)return r;const s=Object.keys(e)[0];return s?e[s].then(a=>(s==="json"&&(a=JSON.stringify(a)),new Response(a)[n]())):e[n]=t[n]()});this.raw=n,this.path=e,M(this,fe,t),M(this,mt,{})}param(n){return n?this.getDecodedParam(n):this.getAllDecodedParams()}getDecodedParam(n){const e=m(this,fe)[0][this.routeIndex][1][n],t=this.getParamValue(e);return t?/\%/.test(t)?vn(t):t:void 0}getAllDecodedParams(){const n={},e=Object.keys(m(this,fe)[0][this.routeIndex][1]);for(const t of e){const r=this.getParamValue(m(this,fe)[0][this.routeIndex][1][t]);r&&typeof r=="string"&&(n[t]=/\%/.test(r)?vn(r):r)}return n}getParamValue(n){return m(this,fe)[1]?m(this,fe)[1][n]:n}query(n){return qs(this.url,n)}queries(n){return Bs(this.url,n)}header(n){if(n)return this.raw.headers.get(n.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,r)=>{e[r]=t}),e}async parseBody(n){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await Ys(this,n))}json(){return this.cachedBody("json")}text(){return this.cachedBody("text")}arrayBuffer(){return this.cachedBody("arrayBuffer")}blob(){return this.cachedBody("blob")}formData(){return this.cachedBody("formData")}addValidatedData(n,e){m(this,mt)[n]=e}valid(n){return m(this,mt)[n]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return m(this,fe)[0].map(([[,n]])=>n)}get routePath(){return m(this,fe)[0].map(([[,n]])=>n)[this.routeIndex].path}},mt=new WeakMap,fe=new WeakMap,is),ta={Stringify:1,BeforeStream:2,Stream:3},yr=async(n,e,t,r,s)=>{const a=n.callbacks;return a!=null&&a.length?(s?s[0]+=n:s=[n],Promise.all(a.map(o=>o({phase:e,buffer:s,context:r}))).then(o=>Promise.all(o.filter(Boolean).map(d=>yr(d,e,!1,r,s))).then(()=>s[0]))):Promise.resolve(n)},na="text/plain; charset=UTF-8",Hn=(n,e={})=>(Object.entries(e).forEach(([t,r])=>n.set(t,r)),n),kn=(os=class{constructor(n,e){Y(this,dn);Y(this,un);y(this,"env",{});Y(this,Ue);y(this,"finalized",!1);y(this,"error");Y(this,Je,200);Y(this,Re);Y(this,W);Y(this,F);Y(this,me);Y(this,Ee,!0);Y(this,ln);Y(this,gt);Y(this,_t);Y(this,pn);Y(this,hn);y(this,"render",(...n)=>(m(this,gt)??M(this,gt,e=>this.html(e)),m(this,gt).call(this,...n)));y(this,"setLayout",n=>M(this,ln,n));y(this,"getLayout",()=>m(this,ln));y(this,"setRenderer",n=>{M(this,gt,n)});y(this,"header",(n,e,t)=>{if(e===void 0){m(this,W)?m(this,W).delete(n):m(this,F)&&delete m(this,F)[n.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(n);return}t!=null&&t.append?(m(this,W)||(M(this,Ee,!1),M(this,W,new Headers(m(this,F))),M(this,F,{})),m(this,W).append(n,e)):m(this,W)?m(this,W).set(n,e):(m(this,F)??M(this,F,{}),m(this,F)[n.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(n,e):this.res.headers.set(n,e))});y(this,"status",n=>{M(this,Ee,!1),M(this,Je,n)});y(this,"set",(n,e)=>{m(this,Ue)??M(this,Ue,{}),m(this,Ue)[n]=e});y(this,"get",n=>m(this,Ue)?m(this,Ue)[n]:void 0);y(this,"newResponse",(n,e,t)=>{if(m(this,Ee)&&!t&&!e&&m(this,Je)===200)return new Response(n,{headers:m(this,F)});if(e&&typeof e!="number"){const s=new Headers(e.headers);m(this,W)&&m(this,W).forEach((i,o)=>{o==="set-cookie"?s.append(o,i):s.set(o,i)});const a=Hn(s,m(this,F));return new Response(n,{headers:a,status:e.status??m(this,Je)})}const r=typeof e=="number"?e:m(this,Je);m(this,F)??M(this,F,{}),m(this,W)??M(this,W,new Headers),Hn(m(this,W),m(this,F)),m(this,me)&&(m(this,me).headers.forEach((s,a)=>{var i,o;a==="set-cookie"?(i=m(this,W))==null||i.append(a,s):(o=m(this,W))==null||o.set(a,s)}),Hn(m(this,W),m(this,F))),t??(t={});for(const[s,a]of Object.entries(t))if(typeof a=="string")m(this,W).set(s,a);else{m(this,W).delete(s);for(const i of a)m(this,W).append(s,i)}return new Response(n,{status:r,headers:m(this,W)})});y(this,"body",(n,e,t)=>typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e));y(this,"text",(n,e,t)=>{if(!m(this,F)){if(m(this,Ee)&&!t&&!e)return new Response(n);M(this,F,{})}return m(this,F)["content-type"]=na,typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)});y(this,"json",(n,e,t)=>{const r=JSON.stringify(n);return m(this,F)??M(this,F,{}),m(this,F)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)});y(this,"html",(n,e,t)=>(m(this,F)??M(this,F,{}),m(this,F)["content-type"]="text/html; charset=UTF-8",typeof n=="object"&&(n instanceof Promise||(n=n.toString()),n instanceof Promise)?n.then(r=>yr(r,ta.Stringify,!1,{})).then(r=>typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)):typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)));y(this,"redirect",(n,e)=>(m(this,W)??M(this,W,new Headers),m(this,W).set("Location",n),this.newResponse(null,e??302)));y(this,"notFound",()=>(m(this,_t)??M(this,_t,()=>new Response),m(this,_t).call(this,this)));M(this,dn,n),e&&(M(this,Re,e.executionCtx),this.env=e.env,M(this,_t,e.notFoundHandler),M(this,hn,e.path),M(this,pn,e.matchResult))}get req(){return m(this,un)??M(this,un,new _r(m(this,dn),m(this,hn),m(this,pn))),m(this,un)}get event(){if(m(this,Re)&&"respondWith"in m(this,Re))return m(this,Re);throw Error("This context has no FetchEvent")}get executionCtx(){if(m(this,Re))return m(this,Re);throw Error("This context has no ExecutionContext")}get res(){return M(this,Ee,!1),m(this,me)||M(this,me,new Response("404 Not Found",{status:404}))}set res(n){if(M(this,Ee,!1),m(this,me)&&n){m(this,me).headers.delete("content-type");for(const[e,t]of m(this,me).headers.entries())if(e==="set-cookie"){const r=m(this,me).headers.getSetCookie();n.headers.delete("set-cookie");for(const s of r)n.headers.append("set-cookie",s)}else n.headers.set(e,t)}M(this,me,n),this.finalized=!0}get var(){return{...m(this,Ue)}}},dn=new WeakMap,un=new WeakMap,Ue=new WeakMap,Je=new WeakMap,Re=new WeakMap,W=new WeakMap,F=new WeakMap,me=new WeakMap,Ee=new WeakMap,ln=new WeakMap,gt=new WeakMap,_t=new WeakMap,pn=new WeakMap,hn=new WeakMap,os),vr=(n,e,t)=>(r,s)=>{let a=-1;return i(0);async function i(o){if(o<=a)throw new Error("next() called multiple times");a=o;let d,u=!1,l;if(n[o]?(l=n[o][0][0],r instanceof kn&&(r.req.routeIndex=o)):l=o===n.length&&s||void 0,!l)r instanceof kn&&r.finalized===!1&&t&&(d=await t(r));else try{d=await l(r,()=>i(o+1))}catch(p){if(p instanceof Error&&r instanceof kn&&e)r.error=p,d=await e(p,r),u=!0;else throw p}return d&&(r.finalized===!1||u)&&(r.res=d),r}},G="ALL",ra="all",sa=["get","post","put","delete","options","patch"],br="Can not add a route since the matcher is already built.",kr=class extends Error{},aa=Symbol("composedHandler"),ia=n=>n.text("404 Not Found",404),wr=(n,e)=>"getResponse"in n?n.getResponse():(console.error(n),e.text("Internal Server Error",500)),xr=(cs=class{constructor(e={}){y(this,"get");y(this,"post");y(this,"put");y(this,"delete");y(this,"options");y(this,"patch");y(this,"all");y(this,"on");y(this,"use");y(this,"router");y(this,"getPath");y(this,"_basePath","/");Y(this,ge,"/");y(this,"routes",[]);y(this,"notFoundHandler",ia);y(this,"errorHandler",wr);y(this,"onError",e=>(this.errorHandler=e,this));y(this,"notFound",e=>(this.notFoundHandler=e,this));y(this,"fetch",(e,...t)=>this.dispatch(e,t[1],t[0],e.method));y(this,"request",(e,t,r,s)=>{if(e instanceof Request)return t!==void 0&&(e=new Request(e,t)),this.fetch(e,r,s);e=e.toString();const a=/^https?:\/\//.test(e)?e:`http://localhost${Be("/",e)}`,i=new Request(a,t);return this.fetch(i,r,s)});y(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(this.dispatch(e.request,e,void 0,e.request.method))})});[...sa,ra].forEach(s=>{this[s]=(a,...i)=>(typeof a=="string"?M(this,ge,a):this.addRoute(s,m(this,ge),a),i.forEach(o=>{typeof o!="string"&&this.addRoute(s,m(this,ge),o)}),this)}),this.on=(s,a,...i)=>{for(const o of[a].flat()){M(this,ge,o);for(const d of[s].flat())i.map(u=>{this.addRoute(d.toUpperCase(),m(this,ge),u)})}return this},this.use=(s,...a)=>(typeof s=="string"?M(this,ge,s):(M(this,ge,"*"),a.unshift(s)),a.forEach(i=>{this.addRoute(G,m(this,ge),i)}),this);const r=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=r?e.getPath??fr:Us}clone(){const e=new xr({router:this.router,getPath:this.getPath});return e.routes=this.routes,e}route(e,t){const r=this.basePath(e);return t.routes.map(s=>{let a;t.errorHandler===wr?a=s.handler:(a=async(i,o)=>(await vr([],t.errorHandler)(i,()=>s.handler(i,o))).res,a[aa]=s.handler),r.addRoute(s.method,s.path,a)}),this}basePath(e){const t=this.clone();return t._basePath=Be(this._basePath,e),t}mount(e,t,r){let s,a;r&&(typeof r=="function"?a=r:(a=r.optionHandler,s=r.replaceRequest));const i=a?d=>{const u=a(d);return Array.isArray(u)?u:[u]}:d=>{let u;try{u=d.executionCtx}catch{}return[d.env,u]};s||(s=(()=>{const d=Be(this._basePath,e),u=d==="/"?0:d.length;return l=>{const p=new URL(l.url);return p.pathname=p.pathname.slice(u)||"/",new Request(p,l)}})());const o=async(d,u)=>{const l=await t(s(d.req.raw),...i(d));if(l)return l;await u()};return this.addRoute(G,Be(e,"*"),o),this}addRoute(e,t,r){e=e.toUpperCase(),t=Be(this._basePath,t);const s={path:t,method:e,handler:r};this.router.add(e,t,[r,s]),this.routes.push(s)}matchRoute(e,t){return this.router.match(e,t)}handleError(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}dispatch(e,t,r,s){if(s==="HEAD")return(async()=>new Response(null,await this.dispatch(e,t,r,"GET")))();const a=this.getPath(e,{env:r}),i=this.matchRoute(s,a),o=new kn(e,{path:a,matchResult:i,env:r,executionCtx:t,notFoundHandler:this.notFoundHandler});if(i[0].length===1){let u;try{u=i[0][0][0][0](o,async()=>{o.res=await this.notFoundHandler(o)})}catch(l){return this.handleError(l,o)}return u instanceof Promise?u.then(l=>l||(o.finalized?o.res:this.notFoundHandler(o))).catch(l=>this.handleError(l,o)):u??this.notFoundHandler(o)}const d=vr(i[0],this.errorHandler,this.notFoundHandler);return(async()=>{try{const u=await d(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.handleError(u,o)}})()}},ge=new WeakMap,cs),wn="[^/]+",xt=".*",Ot="(?:|/.*)",Tt=Symbol(),oa=new Set(".\\+*[^]$()");function ca(n,e){return n.length===1?e.length===1?n<e?-1:1:-1:e.length===1||n===xt||n===Ot?1:e===xt||e===Ot?-1:n===wn?1:e===wn?-1:n.length===e.length?n<e?-1:1:e.length-n.length}var Fn=class{constructor(){y(this,"index");y(this,"varIndex");y(this,"children",Object.create(null))}insert(e,t,r,s,a){if(e.length===0){if(this.index!==void 0)throw Tt;if(a)return;this.index=t;return}const[i,...o]=e,d=i==="*"?o.length===0?["","",xt]:["","",wn]:i==="/*"?["","",Ot]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(d){const l=d[1];let p=d[2]||wn;if(l&&d[2]&&(p=p.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(p)))throw Tt;if(u=this.children[p],!u){if(Object.keys(this.children).some(C=>C!==xt&&C!==Ot))throw Tt;if(a)return;u=this.children[p]=new Fn,l!==""&&(u.varIndex=s.varIndex++)}!a&&l!==""&&r.push([l,u.varIndex])}else if(u=this.children[i],!u){if(Object.keys(this.children).some(l=>l.length>1&&l!==xt&&l!==Ot))throw Tt;if(a)return;u=this.children[i]=new Fn}u.insert(o,t,r,s,a)}buildRegExpStr(){const t=Object.keys(this.children).sort(ca).map(r=>{const s=this.children[r];return(typeof s.varIndex=="number"?`(${r})@${s.varIndex}`:oa.has(r)?`\\${r}`:r)+s.buildRegExpStr()});return typeof this.index=="number"&&t.unshift(`#${this.index}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},da=class{constructor(){y(this,"context",{varIndex:0});y(this,"root",new Fn)}insert(n,e,t){const r=[],s=[];for(let i=0;;){let o=!1;if(n=n.replace(/\{[^}]+\}/g,d=>{const u=`@\\${i}`;return s[i]=[u,d],i++,o=!0,u}),!o)break}const a=n.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=s.length-1;i>=0;i--){const[o]=s[i];for(let d=a.length-1;d>=0;d--)if(a[d].indexOf(o)!==-1){a[d]=a[d].replace(o,s[i][1]);break}}return this.root.insert(a,e,r,this.context,t),r}buildRegExp(){let n=this.root.buildRegExpStr();if(n==="")return[/^$/,[],[]];let e=0;const t=[],r=[];return n=n.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,a,i)=>typeof a<"u"?(t[++e]=Number(a),"$()"):(typeof i<"u"&&(r[Number(i)]=++e),"")),[new RegExp(`^${n}`),t,r]}},Or=[],ua=[/^$/,[],Object.create(null)],xn=Object.create(null);function Tr(n){return xn[n]??(xn[n]=new RegExp(n==="*"?"":`^${n.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function la(){xn=Object.create(null)}function pa(n){var u;const e=new da,t=[];if(n.length===0)return ua;const r=n.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,p],[C,D])=>l?1:C?-1:p.length-D.length),s=Object.create(null);for(let l=0,p=-1,C=r.length;l<C;l++){const[D,N,R]=r[l];D?s[N]=[R.map(([K])=>[K,Object.create(null)]),Or]:p++;let H;try{H=e.insert(N,p,D)}catch(K){throw K===Tt?new kr(N):K}D||(t[p]=R.map(([K,se])=>{const ae=Object.create(null);for(se-=1;se>=0;se--){const[qe,oe]=H[se];ae[qe]=oe}return[K,ae]}))}const[a,i,o]=e.buildRegExp();for(let l=0,p=t.length;l<p;l++)for(let C=0,D=t[l].length;C<D;C++){const N=(u=t[l][C])==null?void 0:u[1];if(!N)continue;const R=Object.keys(N);for(let H=0,K=R.length;H<K;H++)N[R[H]]=o[N[R[H]]]}const d=[];for(const l in i)d[l]=t[i[l]];return[a,d,s]}function nt(n,e){if(n){for(const t of Object.keys(n).sort((r,s)=>s.length-r.length))if(Tr(t).test(e))return[...n[t]]}}var ha=class{constructor(){y(this,"name","RegExpRouter");y(this,"middleware");y(this,"routes");this.middleware={[G]:Object.create(null)},this.routes={[G]:Object.create(null)}}add(n,e,t){var o;const{middleware:r,routes:s}=this;if(!r||!s)throw new Error(br);r[n]||[r,s].forEach(d=>{d[n]=Object.create(null),Object.keys(d[G]).forEach(u=>{d[n][u]=[...d[G][u]]})}),e==="/*"&&(e="*");const a=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const d=Tr(e);n===G?Object.keys(r).forEach(u=>{var l;(l=r[u])[e]||(l[e]=nt(r[u],e)||nt(r[G],e)||[])}):(o=r[n])[e]||(o[e]=nt(r[n],e)||nt(r[G],e)||[]),Object.keys(r).forEach(u=>{(n===G||n===u)&&Object.keys(r[u]).forEach(l=>{d.test(l)&&r[u][l].push([t,a])})}),Object.keys(s).forEach(u=>{(n===G||n===u)&&Object.keys(s[u]).forEach(l=>d.test(l)&&s[u][l].push([t,a]))});return}const i=mr(e)||[e];for(let d=0,u=i.length;d<u;d++){const l=i[d];Object.keys(s).forEach(p=>{var C;(n===G||n===p)&&((C=s[p])[l]||(C[l]=[...nt(r[p],l)||nt(r[G],l)||[]]),s[p][l].push([t,a-u+d+1]))})}}match(n,e){la();const t=this.buildAllMatchers();return this.match=(r,s)=>{const a=t[r]||t[G],i=a[2][s];if(i)return i;const o=s.match(a[0]);if(!o)return[[],Or];const d=o.indexOf("",1);return[a[1][d],o]},this.match(n,e)}buildAllMatchers(){const n=Object.create(null);return[...Object.keys(this.routes),...Object.keys(this.middleware)].forEach(e=>{n[e]||(n[e]=this.buildMatcher(e))}),this.middleware=this.routes=void 0,n}buildMatcher(n){const e=[];let t=n===G;return[this.middleware,this.routes].forEach(r=>{const s=r[n]?Object.keys(r[n]).map(a=>[a,r[n][a]]):[];s.length!==0?(t||(t=!0),e.push(...s)):n!==G&&e.push(...Object.keys(r[G]).map(a=>[a,r[G][a]]))}),t?pa(e):null}},fa=class{constructor(n){y(this,"name","SmartRouter");y(this,"routers",[]);y(this,"routes",[]);Object.assign(this,n)}add(n,e,t){if(!this.routes)throw new Error(br);this.routes.push([n,e,t])}match(n,e){if(!this.routes)throw new Error("Fatal error");const{routers:t,routes:r}=this,s=t.length;let a=0,i;for(;a<s;a++){const o=t[a];try{r.forEach(d=>{o.add(...d)}),i=o.match(n,e)}catch(d){if(d instanceof kr)continue;throw d}this.match=o.match.bind(o),this.routers=[o],this.routes=void 0;break}if(a===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.routes||this.routers.length!==1)throw new Error("No active router has been determined yet.");return this.routers[0]}},jr=class{constructor(n,e,t){y(this,"methods");y(this,"children");y(this,"patterns");y(this,"order",0);y(this,"name");y(this,"params",Object.create(null));if(this.children=t||Object.create(null),this.methods=[],this.name="",n&&e){const r=Object.create(null);r[n]={handler:e,possibleKeys:[],score:0,name:this.name},this.methods=[r]}this.patterns=[]}insert(n,e,t){this.name=`${n} ${e}`,this.order=++this.order;let r=this;const s=Ms(e),a=[];for(let d=0,u=s.length;d<u;d++){const l=s[d];if(Object.keys(r.children).includes(l)){r=r.children[l];const C=hr(l);C&&a.push(C[1]);continue}r.children[l]=new jr;const p=hr(l);p&&(r.patterns.push(p),a.push(p[1])),r=r.children[l]}r.methods.length||(r.methods=[]);const i=Object.create(null),o={handler:t,possibleKeys:a.filter((d,u,l)=>l.indexOf(d)===u),name:this.name,score:this.order};return i[n]=o,r.methods.push(i),r}gHSets(n,e,t,r){const s=[];for(let a=0,i=n.methods.length;a<i;a++){const o=n.methods[a],d=o[e]||o[G],u=Object.create(null);d!==void 0&&(d.params=Object.create(null),d.possibleKeys.forEach(l=>{const p=u[d.name];d.params[l]=r[l]&&!p?r[l]:t[l]??r[l],u[d.name]=!0}),s.push(d))}return s}search(n,e){const t=[];this.params=Object.create(null);let s=[this];const a=pr(e);for(let o=0,d=a.length;o<d;o++){const u=a[o],l=o===d-1,p=[];for(let C=0,D=s.length;C<D;C++){const N=s[C],R=N.children[u];R&&(R.params=N.params,l===!0?(R.children["*"]&&t.push(...this.gHSets(R.children["*"],n,N.params,Object.create(null))),t.push(...this.gHSets(R,n,N.params,Object.create(null)))):p.push(R));for(let H=0,K=N.patterns.length;H<K;H++){const se=N.patterns[H],ae={...N.params};if(se==="*"){const _e=N.children["*"];_e&&(t.push(...this.gHSets(_e,n,N.params,Object.create(null))),p.push(_e));continue}if(u==="")continue;const[qe,oe,ie]=se,te=N.children[qe],Oe=a.slice(o).join("/");if(ie instanceof RegExp&&ie.test(Oe)){ae[oe]=Oe,t.push(...this.gHSets(te,n,N.params,ae));continue}(ie===!0||ie instanceof RegExp&&ie.test(u))&&typeof qe=="string"&&(ae[oe]=u,l===!0?(t.push(...this.gHSets(te,n,ae,N.params)),te.children["*"]&&t.push(...this.gHSets(te.children["*"],n,ae,N.params))):(te.params=ae,p.push(te)))}}s=p}return[t.sort((o,d)=>o.score-d.score).map(({handler:o,params:d})=>[o,d])]}},ma=class{constructor(){y(this,"name","TrieRouter");y(this,"node");this.node=new jr}add(n,e,t){const r=mr(e);if(r){for(const s of r)this.node.insert(n,s,t);return}this.node.insert(n,e,t)}match(n,e){return this.node.search(n,e)}},ga=class extends xr{constructor(n={}){super(n),this.router=n.router??new fa({routers:[new ha,new ma]})}},A;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(A||(A={}));var Kn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Kn||(Kn={}));const v=A.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Se=n=>{switch(typeof n){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(n)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(n)?v.array:n===null?v.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?v.promise:typeof Map<"u"&&n instanceof Map?v.map:typeof Set<"u"&&n instanceof Set?v.set:typeof Date<"u"&&n instanceof Date?v.date:v.object;default:return v.unknown}},h=A.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"]),_a=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class ne extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof ne))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,A.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}ne.create=n=>new ne(n);const rt=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===v.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,A.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${A.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${A.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${A.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:A.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,A.assertNever(n)}return{message:t}};let Zr=rt;function ya(n){Zr=n}function On(){return Zr}const Tn=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},va=[];function g(n,e){const t=On(),r=Tn({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===rt?void 0:rt].filter(s=>!!s)});n.common.issues.push(r)}class J{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return j;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return J.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return j;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const j=Object.freeze({status:"aborted"}),st=n=>({status:"dirty",value:n}),X=n=>({status:"valid",value:n}),Gn=n=>n.status==="aborted",zn=n=>n.status==="dirty",jt=n=>n.status==="valid",Zt=n=>typeof Promise<"u"&&n instanceof Promise;function jn(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Rr(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var w;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var Rt,Et;class ye{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Er=(n,e)=>{if(jt(e))return{success:!0,data:e.value};if(!n.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 ne(n.common.issues);return this._error=t,this._error}}};function E(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var d,u;const{message:l}=n;return i.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:(d=l??r)!==null&&d!==void 0?d:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class I{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 Se(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new J,ctx:{common:e.parent.common,data:e.data,parsedType:Se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Zt(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Se(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Er(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={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:Se(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Zt(s)?s:Promise.resolve(s));return Er(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new ue({schema:this,typeName:O.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return be.create(this,this._def)}nullable(){return Ne.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return de.create(this,this._def)}promise(){return ct.create(this,this._def)}or(e){return Pt.create([this,e],this._def)}and(e){return Nt.create(this,e,this._def)}transform(e){return new ue({...E(this._def),schema:this,typeName:O.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Lt({...E(this._def),innerType:this,defaultValue:t,typeName:O.ZodDefault})}brand(){return new Qn({typeName:O.ZodBranded,type:this,...E(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Vt({...E(this._def),innerType:this,catchValue:t,typeName:O.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ut.create(this,e)}readonly(){return qt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ba=/^c[^\s-]{8,}$/i,ka=/^[0-9a-z]+$/,wa=/^[0-9A-HJKMNP-TV-Z]{26}$/,xa=/^[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,Oa=/^[a-z0-9_-]{21}$/i,Ta=/^[-+]?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)?)??$/,ja=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Za="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Yn;const Ra=/^(?:(?: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])$/,Ea=/^(([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})))$/,Sa=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Sr="((\\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])))",Ca=new RegExp(`^${Sr}$`);function Cr(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ia(n){return new RegExp(`^${Cr(n)}$`)}function Ir(n){let e=`${Sr}T${Cr(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Pa(n,e){return!!((e==="v4"||!e)&&Ra.test(n)||(e==="v6"||!e)&&Ea.test(n))}class ce extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_type,expected:v.string,received:a.parsedType}),j}const r=new J;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?g(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&g(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")ja.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"email",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Yn||(Yn=new RegExp(Za,"u")),Yn.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"emoji",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")xa.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"uuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Oa.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"nanoid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")ba.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")ka.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid2",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")wa.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ulid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),g(s,{validation:"url",code:h.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"regex",code:h.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Ir(a).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?Ca.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Ia(a).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?Ta.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"duration",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Pa(e.data,a.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ip",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Sa.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64",code:h.invalid_string,message:a.message}),r.dirty()):A.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...w.errToObj(r)})}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}datetime(e){var t,r;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:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...w.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,...w.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...w.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new ce({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ce({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ce({...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}}ce.create=n=>{var e;return new ce({checks:[],typeName:O.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...E(n)})};function Na(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Ce extends I{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)!==v.number){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_type,expected:v.number,received:a.parsedType}),j}let r;const s=new J;for(const a of this._def.checks)a.kind==="int"?A.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Na(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_finite,message:a.message}),s.dirty()):A.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new Ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new Ce({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.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"&&A.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ce.create=n=>new Ce({checks:[],typeName:O.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...E(n)});class Ie extends I{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)!==v.bigint){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_type,expected:v.bigint,received:a.parsedType}),j}let r;const s=new J;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):A.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new Ie({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new Ie({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.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}}Ie.create=n=>{var e;return new Ie({checks:[],typeName:O.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...E(n)})};class St extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.boolean,received:r.parsedType}),j}return X(e.data)}}St.create=n=>new St({typeName:O.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...E(n)});class We extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_type,expected:v.date,received:a.parsedType}),j}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_date}),j}const r=new J;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):A.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new We({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.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}}We.create=n=>new We({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:O.ZodDate,...E(n)});class Zn extends I{_parse(e){if(this._getType(e)!==v.symbol){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.symbol,received:r.parsedType}),j}return X(e.data)}}Zn.create=n=>new Zn({typeName:O.ZodSymbol,...E(n)});class Ct extends I{_parse(e){if(this._getType(e)!==v.undefined){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.undefined,received:r.parsedType}),j}return X(e.data)}}Ct.create=n=>new Ct({typeName:O.ZodUndefined,...E(n)});class It extends I{_parse(e){if(this._getType(e)!==v.null){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.null,received:r.parsedType}),j}return X(e.data)}}It.create=n=>new It({typeName:O.ZodNull,...E(n)});class at extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return X(e.data)}}at.create=n=>new at({typeName:O.ZodAny,...E(n)});class He extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return X(e.data)}}He.create=n=>new He({typeName:O.ZodUnknown,...E(n)});class Te extends I{_parse(e){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:v.never,received:t.parsedType}),j}}Te.create=n=>new Te({typeName:O.ZodNever,...E(n)});class Rn extends I{_parse(e){if(this._getType(e)!==v.undefined){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.void,received:r.parsedType}),j}return X(e.data)}}Rn.create=n=>new Rn({typeName:O.ZodVoid,...E(n)});class de extends I{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==v.array)return g(t,{code:h.invalid_type,expected:v.array,received:t.parsedType}),j;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(g(t,{code:i?h.too_big:h.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(g(t,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(g(t,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new ye(t,i,t.path,o)))).then(i=>J.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ye(t,i,t.path,o)));return J.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new de({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new de({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new de({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}de.create=(n,e)=>new de({type:n,minLength:null,maxLength:null,exactLength:null,typeName:O.ZodArray,...E(e)});function it(n){if(n instanceof q){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=be.create(it(r))}return new q({...n._def,shape:()=>e})}else return n instanceof de?new de({...n._def,type:it(n.element)}):n instanceof be?be.create(it(n.unwrap())):n instanceof Ne?Ne.create(it(n.unwrap())):n instanceof ve?ve.create(n.items.map(e=>it(e))):n}class q extends I{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=A.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==v.object){const u=this._getOrReturnCtx(e);return g(u,{code:h.invalid_type,expected:v.object,received:u.parsedType}),j}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Te&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const d=[];for(const u of i){const l=a[u],p=s.data[u];d.push({key:{status:"valid",value:u},value:l._parse(new ye(s,p,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Te){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)d.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(g(s,{code:h.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of o){const p=s.data[l];d.push({key:{status:"valid",value:l},value:u._parse(new ye(s,p,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of d){const p=await l.key,C=await l.value;u.push({key:p,value:C,alwaysSet:l.alwaysSet})}return u}).then(u=>J.mergeObjectSync(r,u)):J.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new q({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=w.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new q({...this._def,unknownKeys:"strip"})}passthrough(){return new q({...this._def,unknownKeys:"passthrough"})}extend(e){return new q({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new q({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:O.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new q({...this._def,catchall:e})}pick(e){const t={};return A.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new q({...this._def,shape:()=>t})}omit(e){const t={};return A.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new q({...this._def,shape:()=>t})}deepPartial(){return it(this)}partial(e){const t={};return A.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new q({...this._def,shape:()=>t})}required(e){const t={};return A.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof be;)a=a._def.innerType;t[r]=a}}),new q({...this._def,shape:()=>t})}keyof(){return Pr(A.objectKeys(this.shape))}}q.create=(n,e)=>new q({shape:()=>n,unknownKeys:"strip",catchall:Te.create(),typeName:O.ZodObject,...E(e)}),q.strictCreate=(n,e)=>new q({shape:()=>n,unknownKeys:"strict",catchall:Te.create(),typeName:O.ZodObject,...E(e)}),q.lazycreate=(n,e)=>new q({shape:n,unknownKeys:"strip",catchall:Te.create(),typeName:O.ZodObject,...E(e)});class Pt extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new ne(o.ctx.common.issues));return g(t,{code:h.invalid_union,unionErrors:i}),j}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new ne(d));return g(t,{code:h.invalid_union,unionErrors:o}),j}}get options(){return this._def.options}}Pt.create=(n,e)=>new Pt({options:n,typeName:O.ZodUnion,...E(e)});const je=n=>n instanceof $t?je(n.schema):n instanceof ue?je(n.innerType()):n instanceof Mt?[n.value]:n instanceof Pe?n.options:n instanceof Dt?A.objectValues(n.enum):n instanceof Lt?je(n._def.innerType):n instanceof Ct?[void 0]:n instanceof It?[null]:n instanceof be?[void 0,...je(n.unwrap())]:n instanceof Ne?[null,...je(n.unwrap())]:n instanceof Qn||n instanceof qt?je(n.unwrap()):n instanceof Vt?je(n._def.innerType):[];class En extends I{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.object)return g(t,{code:h.invalid_type,expected:v.object,received:t.parsedType}),j;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(g(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),j)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=je(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new En({typeName:O.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...E(r)})}}function Jn(n,e){const t=Se(n),r=Se(e);if(n===e)return{valid:!0,data:n};if(t===v.object&&r===v.object){const s=A.objectKeys(e),a=A.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i={...n,...e};for(const o of a){const d=Jn(n[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===v.array&&r===v.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],d=Jn(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===v.date&&r===v.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Nt extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(Gn(a)||Gn(i))return j;const o=Jn(a.value,i.value);return o.valid?((zn(a)||zn(i))&&t.dirty(),{status:t.value,value:o.data}):(g(r,{code:h.invalid_intersection_types}),j)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Nt.create=(n,e,t)=>new Nt({left:n,right:e,typeName:O.ZodIntersection,...E(t)});class ve extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.array)return g(r,{code:h.invalid_type,expected:v.array,received:r.parsedType}),j;if(r.data.length<this._def.items.length)return g(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new ye(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>J.mergeArray(t,i)):J.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ve({...this._def,rest:e})}}ve.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ve({items:n,typeName:O.ZodTuple,rest:null,...E(e)})};class At extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.object)return g(r,{code:h.invalid_type,expected:v.object,received:r.parsedType}),j;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ye(r,o,r.path,o)),value:i._parse(new ye(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?J.mergeObjectAsync(t,s):J.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof I?new At({keyType:e,valueType:t,typeName:O.ZodRecord,...E(r)}):new At({keyType:ce.create(),valueType:e,typeName:O.ZodRecord,...E(t)})}}class Sn extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.map)return g(r,{code:h.invalid_type,expected:v.map,received:r.parsedType}),j;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,d],u)=>({key:s._parse(new ye(r,o,r.path,[u,"key"])),value:a._parse(new ye(r,d,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return j;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return j;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}Sn.create=(n,e,t)=>new Sn({valueType:e,keyType:n,typeName:O.ZodMap,...E(t)});class Fe extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.set)return g(r,{code:h.invalid_type,expected:v.set,received:r.parsedType}),j;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(g(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(g(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const u=new Set;for(const l of d){if(l.status==="aborted")return j;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((d,u)=>a._parse(new ye(r,d,r.path,u)));return r.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new Fe({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Fe({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Fe.create=(n,e)=>new Fe({valueType:n,minSize:null,maxSize:null,typeName:O.ZodSet,...E(e)});class ot extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return g(t,{code:h.invalid_type,expected:v.function,received:t.parsedType}),j;function r(o,d){return Tn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,On(),rt].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:d}})}function s(o,d){return Tn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,On(),rt].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ct){const o=this;return X(async function(...d){const u=new ne([]),l=await o._def.args.parseAsync(d,a).catch(D=>{throw u.addIssue(r(d,D)),u}),p=await Reflect.apply(i,this,l);return await o._def.returns._def.type.parseAsync(p,a).catch(D=>{throw u.addIssue(s(p,D)),u})})}else{const o=this;return X(function(...d){const u=o._def.args.safeParse(d,a);if(!u.success)throw new ne([r(d,u.error)]);const l=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(l,a);if(!p.success)throw new ne([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ot({...this._def,args:ve.create(e).rest(He.create())})}returns(e){return new ot({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new ot({args:e||ve.create([]).rest(He.create()),returns:t||He.create(),typeName:O.ZodFunction,...E(r)})}}class $t extends I{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})}}$t.create=(n,e)=>new $t({getter:n,typeName:O.ZodLazy,...E(e)});class Mt extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return g(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:e.data}}get value(){return this._def.value}}Mt.create=(n,e)=>new Mt({value:n,typeName:O.ZodLiteral,...E(e)});function Pr(n,e){return new Pe({values:n,typeName:O.ZodEnum,...E(e)})}class Pe extends I{constructor(){super(...arguments),Rt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return g(t,{expected:A.joinValues(r),received:t.parsedType,code:h.invalid_type}),j}if(jn(this,Rt)||Rr(this,Rt,new Set(this._def.values)),!jn(this,Rt).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return g(t,{received:t.data,code:h.invalid_enum_value,options:r}),j}return X(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 Pe.create(e,{...this._def,...t})}exclude(e,t=this._def){return Pe.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Rt=new WeakMap,Pe.create=Pr;class Dt extends I{constructor(){super(...arguments),Et.set(this,void 0)}_parse(e){const t=A.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==v.string&&r.parsedType!==v.number){const s=A.objectValues(t);return g(r,{expected:A.joinValues(s),received:r.parsedType,code:h.invalid_type}),j}if(jn(this,Et)||Rr(this,Et,new Set(A.getValidEnumValues(this._def.values))),!jn(this,Et).has(e.data)){const s=A.objectValues(t);return g(r,{received:r.data,code:h.invalid_enum_value,options:s}),j}return X(e.data)}get enum(){return this._def.values}}Et=new WeakMap,Dt.create=(n,e)=>new Dt({values:n,typeName:O.ZodNativeEnum,...E(e)});class ct extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return g(t,{code:h.invalid_type,expected:v.promise,received:t.parsedType}),j;const r=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return X(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ct.create=(n,e)=>new ct({type:n,typeName:O.ZodPromise,...E(e)});class ue extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===O.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{g(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return j;const d=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return d.status==="aborted"?j:d.status==="dirty"||t.value==="dirty"?st(d.value):d});{if(t.value==="aborted")return j;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?j:o.status==="dirty"||t.value==="dirty"?st(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?j:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?j:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!jt(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>jt(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);A.assertNever(s)}}ue.create=(n,e,t)=>new ue({schema:n,typeName:O.ZodEffects,effect:e,...E(t)}),ue.createWithPreprocess=(n,e,t)=>new ue({schema:e,effect:{type:"preprocess",transform:n},typeName:O.ZodEffects,...E(t)});class be extends I{_parse(e){return this._getType(e)===v.undefined?X(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}be.create=(n,e)=>new be({innerType:n,typeName:O.ZodOptional,...E(e)});class Ne extends I{_parse(e){return this._getType(e)===v.null?X(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ne.create=(n,e)=>new Ne({innerType:n,typeName:O.ZodNullable,...E(e)});class Lt extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===v.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Lt.create=(n,e)=>new Lt({innerType:n,typeName:O.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...E(e)});class Vt extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Zt(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ne(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ne(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Vt.create=(n,e)=>new Vt({innerType:n,typeName:O.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...E(e)});class Cn extends I{_parse(e){if(this._getType(e)!==v.nan){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.nan,received:r.parsedType}),j}return{status:"valid",value:e.data}}}Cn.create=n=>new Cn({typeName:O.ZodNaN,...E(n)});const Aa=Symbol("zod_brand");class Qn extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ut extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?j:a.status==="dirty"?(t.dirty(),st(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?j:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new Ut({in:e,out:t,typeName:O.ZodPipeline})}}class qt extends I{_parse(e){const t=this._def.innerType._parse(e),r=s=>(jt(s)&&(s.value=Object.freeze(s.value)),s);return Zt(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}qt.create=(n,e)=>new qt({innerType:n,typeName:O.ZodReadonly,...E(e)});function Nr(n,e={},t){return n?at.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:d})}}):at.create()}const $a={object:q.lazycreate};var O;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(O||(O={}));const Ma=(n,e={message:`Input not instance of ${n.name}`})=>Nr(t=>t instanceof n,e),Ar=ce.create,$r=Ce.create,Da=Cn.create,La=Ie.create,Mr=St.create,Va=We.create,Ua=Zn.create,qa=Ct.create,Ba=It.create,Wa=at.create,Ha=He.create,Fa=Te.create,Ka=Rn.create,Ga=de.create,za=q.create,Ya=q.strictCreate,Ja=Pt.create,Qa=En.create,Xa=Nt.create,ei=ve.create,ti=At.create,ni=Sn.create,ri=Fe.create,si=ot.create,ai=$t.create,ii=Mt.create,oi=Pe.create,ci=Dt.create,di=ct.create,Dr=ue.create,ui=be.create,li=Ne.create,pi=ue.createWithPreprocess,hi=Ut.create;var z=Object.freeze({__proto__:null,defaultErrorMap:rt,setErrorMap:ya,getErrorMap:On,makeIssue:Tn,EMPTY_PATH:va,addIssueToContext:g,ParseStatus:J,INVALID:j,DIRTY:st,OK:X,isAborted:Gn,isDirty:zn,isValid:jt,isAsync:Zt,get util(){return A},get objectUtil(){return Kn},ZodParsedType:v,getParsedType:Se,ZodType:I,datetimeRegex:Ir,ZodString:ce,ZodNumber:Ce,ZodBigInt:Ie,ZodBoolean:St,ZodDate:We,ZodSymbol:Zn,ZodUndefined:Ct,ZodNull:It,ZodAny:at,ZodUnknown:He,ZodNever:Te,ZodVoid:Rn,ZodArray:de,ZodObject:q,ZodUnion:Pt,ZodDiscriminatedUnion:En,ZodIntersection:Nt,ZodTuple:ve,ZodRecord:At,ZodMap:Sn,ZodSet:Fe,ZodFunction:ot,ZodLazy:$t,ZodLiteral:Mt,ZodEnum:Pe,ZodNativeEnum:Dt,ZodPromise:ct,ZodEffects:ue,ZodTransformer:ue,ZodOptional:be,ZodNullable:Ne,ZodDefault:Lt,ZodCatch:Vt,ZodNaN:Cn,BRAND:Aa,ZodBranded:Qn,ZodPipeline:Ut,ZodReadonly:qt,custom:Nr,Schema:I,ZodSchema:I,late:$a,get ZodFirstPartyTypeKind(){return O},coerce:{string:n=>ce.create({...n,coerce:!0}),number:n=>Ce.create({...n,coerce:!0}),boolean:n=>St.create({...n,coerce:!0}),bigint:n=>Ie.create({...n,coerce:!0}),date:n=>We.create({...n,coerce:!0})},any:Wa,array:Ga,bigint:La,boolean:Mr,date:Va,discriminatedUnion:Qa,effect:Dr,enum:oi,function:si,instanceof:Ma,intersection:Xa,lazy:ai,literal:ii,map:ni,nan:Da,nativeEnum:ci,never:Fa,null:Ba,nullable:li,number:$r,object:za,oboolean:()=>Mr().optional(),onumber:()=>$r().optional(),optional:ui,ostring:()=>Ar().optional(),pipeline:hi,preprocess:pi,promise:di,record:ti,set:ri,strictObject:Ya,string:Ar,symbol:Ua,transformer:Dr,tuple:ei,undefined:qa,union:Ja,unknown:Ha,void:Ka,NEVER:j,ZodIssueCode:h,quotelessJson:_a,ZodError:ne}),Bt=class cr extends ga{constructor(t){super(t);y(this,"openAPIRegistry");y(this,"defaultHook");y(this,"openapi",({middleware:t,...r},s,a=this.defaultHook)=>{var u,l,p,C,D,N;this.openAPIRegistry.registerPath(r);const i=[];if((u=r.request)!=null&&u.query){const R=tt("query",r.request.query,a);i.push(R)}if((l=r.request)!=null&&l.params){const R=tt("param",r.request.params,a);i.push(R)}if((p=r.request)!=null&&p.headers){const R=tt("header",r.request.headers,a);i.push(R)}if((C=r.request)!=null&&C.cookies){const R=tt("cookie",r.request.cookies,a);i.push(R)}const o=(N=(D=r.request)==null?void 0:D.body)==null?void 0:N.content;if(o)for(const R of Object.keys(o)){if(!o[R])continue;const H=o[R].schema;if(H instanceof I){if(R.startsWith("application/json")){const K=tt("json",H,a);i.push(K)}if(R.startsWith("multipart/form-data")||R.startsWith("application/x-www-form-urlencoded")){const K=tt("form",H,a);i.push(K)}}}const d=t?Array.isArray(t)?t:[t]:[];return this.on([r.method],r.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...d,...i,s),this});y(this,"getOpenAPIDocument",t=>new Ps(this.openAPIRegistry.definitions).generateDocument(t));y(this,"getOpenAPI31Document",t=>new $s(this.openAPIRegistry.definitions).generateDocument(t));y(this,"doc",(t,r)=>this.get(t,s=>{const a=typeof r=="function"?r(s):r;try{const i=this.getOpenAPIDocument(a);return s.json(i)}catch(i){return s.json(i,500)}}));y(this,"doc31",(t,r)=>this.get(t,s=>{const a=typeof r=="function"?r(s):r;try{const i=this.getOpenAPI31Document(a);return s.json(i)}catch(i){return s.json(i,500)}}));this.openAPIRegistry=new ms,this.defaultHook=t==null?void 0:t.defaultHook}route(t,r){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,r),r instanceof cr?(r.openAPIRegistry.definitions.forEach(a=>{switch(a.type){case"component":return this.openAPIRegistry.registerComponent(a.componentType,a.name,a.component);case"route":return this.openAPIRegistry.registerPath({...a.route,path:Be(s,a.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...a.webhook,path:Be(s,a.webhook.path)});case"schema":return this.openAPIRegistry.register(a.schema._def.openapi._internal.refId,a.schema);case"parameter":return this.openAPIRegistry.registerParameter(a.schema._def.openapi._internal.refId,a.schema);default:{const i=a;throw new Error(`Unknown registry type: ${i}`)}}}),this):this}basePath(t){return new cr({...super.basePath(t),defaultHook:this.defaultHook})}},Ke=n=>{const e={...n,getRoutingPath(){return n.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};ls(z);function fi(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function mi(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function Wt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function gi(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var i,o,d,u,l,p;const C=typeof s=="string"?a:s,D=C??{},{param:N}=D,R=fi(D,["param"]),H=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),K=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),R),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||N?{param:Object.assign(Object.assign({},(p=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||p===void 0?void 0:p.param),N)}:void 0),se=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(H).length>0?{_internal:H}:void 0),Object.keys(K).length>0?{metadata:K}:void 0)}));if(mi(this,"ZodObject")){const ae=this.extend;se.extend=function(...qe){var oe,ie,te,Oe,_e,Qe;const Xe=ae.apply(this,qe);return Xe._def.openapi={_internal:{extendedFrom:!((ie=(oe=this._def.openapi)===null||oe===void 0?void 0:oe._internal)===null||ie===void 0)&&ie.refId?{refId:(Oe=(te=this._def.openapi)===null||te===void 0?void 0:te._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(_e=this._def.openapi)===null||_e===void 0?void 0:_e._internal.extendedFrom},metadata:(Qe=Xe._def.openapi)===null||Qe===void 0?void 0:Qe.metadata},Xe}}return se},Wt(n,"optional"),Wt(n,"nullable"),Wt(n,"default"),Wt(n,"transform"),Wt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var u,l;d._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var $;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})($||($={}));var Xn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Xn||(Xn={}));const b=$.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ae=n=>{switch(typeof n){case"undefined":return b.undefined;case"string":return b.string;case"number":return isNaN(n)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(n)?b.array:n===null?b.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?b.promise:typeof Map<"u"&&n instanceof Map?b.map:typeof Set<"u"&&n instanceof Set?b.set:typeof Date<"u"&&n instanceof Date?b.date:b.object;default:return b.unknown}},f=$.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"]),_i=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class re extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof re))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}re.create=n=>new re(n);const dt=(n,e)=>{let t;switch(n.code){case f.invalid_type:n.received===b.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,$.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${$.joinValues(n.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${$.joinValues(n.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${$.joinValues(n.options)}, received '${n.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:$.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case f.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case f.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,$.assertNever(n)}return{message:t}};let Lr=dt;function yi(n){Lr=n}function In(){return Lr}const Pn=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},vi=[];function _(n,e){const t=In(),r=Pn({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===dt?void 0:dt].filter(s=>!!s)});n.common.issues.push(r)}class Q{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return Z;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return Q.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return Z;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const Z=Object.freeze({status:"aborted"}),Nn=n=>({status:"dirty",value:n}),ee=n=>({status:"valid",value:n}),er=n=>n.status==="aborted",tr=n=>n.status==="dirty",Ht=n=>n.status==="valid",Ft=n=>typeof Promise<"u"&&n instanceof Promise;function An(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Vr(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var x;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(x||(x={}));var Kt,Gt;class ke{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ur=(n,e)=>{if(Ht(e))return{success:!0,data:e.value};if(!n.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 re(n.common.issues);return this._error=t,this._error}}};function S(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>{var o,d;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u??i.defaultError}:typeof i.data>"u"?{message:(o=u??r)!==null&&o!==void 0?o:i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:(d=u??t)!==null&&d!==void 0?d:i.defaultError}},description:s}}class P{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Q,ctx:{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ft(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Ur(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Ft(s)?s:Promise.resolve(s));return Ur(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:f.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new he({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xe.create(this,this._def)}nullable(){return Ve.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pe.create(this,this._def)}promise(){return ht.create(this,this._def)}or(e){return Qt.create([this,e],this._def)}and(e){return Xt.create(this,e,this._def)}transform(e){return new he({...S(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new sn({...S(this._def),innerType:this,defaultValue:t,typeName:T.ZodDefault})}brand(){return new sr({typeName:T.ZodBranded,type:this,...S(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new an({...S(this._def),innerType:this,catchValue:t,typeName:T.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return on.create(this,e)}readonly(){return cn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const bi=/^c[^\s-]{8,}$/i,ki=/^[0-9a-z]+$/,wi=/^[0-9A-HJKMNP-TV-Z]{26}$/,xi=/^[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,Oi=/^[a-z0-9_-]{21}$/i,Ti=/^[-+]?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)?)??$/,ji=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let nr;const Ri=/^(?:(?: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])$/,Ei=/^(([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})))$/,Si=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qr="((\\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])))",Ci=new RegExp(`^${qr}$`);function Br(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ii(n){return new RegExp(`^${Br(n)}$`)}function Wr(n){let e=`${qr}T${Br(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Pi(n,e){return!!((e==="v4"||!e)&&Ri.test(n)||(e==="v6"||!e)&&Ei.test(n))}class le extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_type,expected:b.string,received:s.parsedType}),Z}const t=new Q;let r;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:f.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:f.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(r=this._getOrReturnCtx(e,r),a?_(r,{code:f.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&_(r,{code:f.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")ji.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"email",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")nr||(nr=new RegExp(Zi,"u")),nr.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"emoji",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")xi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"uuid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")Oi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"nanoid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")bi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"cuid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")ki.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"cuid2",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")wi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"ulid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),_(r,{validation:"url",code:f.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"regex",code:f.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.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)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?Wr(s).test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?Ci.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Ii(s).test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?Ti.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"duration",code:f.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Pi(e.data,s.version)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"ip",code:f.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?Si.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"base64",code:f.invalid_string,message:s.message}),t.dirty()):$.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:f.invalid_string,...x.errToObj(r)})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...x.errToObj(e)})}url(e){return this._addCheck({kind:"url",...x.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...x.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...x.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...x.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...x.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...x.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...x.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...x.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...x.errToObj(e)})}datetime(e){var t,r;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:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...x.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,...x.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...x.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...x.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...x.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...x.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...x.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...x.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...x.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...x.errToObj(t)})}nonempty(e){return this.min(1,x.errToObj(e))}trim(){return new le({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new le({...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}}le.create=n=>{var e;return new le({checks:[],typeName:T.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};function Ni(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class $e extends P{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)!==b.number){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_type,expected:b.number,received:s.parsedType}),Z}let t;const r=new Q;for(const s of this._def.checks)s.kind==="int"?$.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),_(t,{code:f.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?Ni(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),_(t,{code:f.not_finite,message:s.message}),r.dirty()):$.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,r,s){return new $e({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:x.toString(s)}]})}_addCheck(e){return new $e({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:x.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:x.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.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"&&$.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}$e.create=n=>new $e({checks:[],typeName:T.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Me extends P{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)!==b.bigint){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_type,expected:b.bigint,received:s.parsedType}),Z}let t;const r=new Q;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):$.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,r,s){return new Me({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:x.toString(s)}]})}_addCheck(e){return new Me({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.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}}Me.create=n=>{var e;return new Me({checks:[],typeName:T.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};class zt extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.boolean,received:t.parsedType}),Z}return ee(e.data)}}zt.create=n=>new zt({typeName:T.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Ge extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_type,expected:b.date,received:s.parsedType}),Z}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_date}),Z}const t=new Q;let r;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:f.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:f.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):$.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ge({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:x.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:x.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}}Ge.create=n=>new Ge({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:T.ZodDate,...S(n)});class $n extends P{_parse(e){if(this._getType(e)!==b.symbol){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.symbol,received:t.parsedType}),Z}return ee(e.data)}}$n.create=n=>new $n({typeName:T.ZodSymbol,...S(n)});class Yt extends P{_parse(e){if(this._getType(e)!==b.undefined){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.undefined,received:t.parsedType}),Z}return ee(e.data)}}Yt.create=n=>new Yt({typeName:T.ZodUndefined,...S(n)});class Jt extends P{_parse(e){if(this._getType(e)!==b.null){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.null,received:t.parsedType}),Z}return ee(e.data)}}Jt.create=n=>new Jt({typeName:T.ZodNull,...S(n)});class ut extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return ee(e.data)}}ut.create=n=>new ut({typeName:T.ZodAny,...S(n)});class ze extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ee(e.data)}}ze.create=n=>new ze({typeName:T.ZodUnknown,...S(n)});class Ze extends P{_parse(e){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.never,received:t.parsedType}),Z}}Ze.create=n=>new Ze({typeName:T.ZodNever,...S(n)});class Mn extends P{_parse(e){if(this._getType(e)!==b.undefined){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.void,received:t.parsedType}),Z}return ee(e.data)}}Mn.create=n=>new Mn({typeName:T.ZodVoid,...S(n)});class pe extends P{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==b.array)return _(t,{code:f.invalid_type,expected:b.array,received:t.parsedType}),Z;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(_(t,{code:i?f.too_big:f.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(_(t,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(_(t,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new ke(t,i,t.path,o)))).then(i=>Q.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ke(t,i,t.path,o)));return Q.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new pe({...this._def,minLength:{value:e,message:x.toString(t)}})}max(e,t){return new pe({...this._def,maxLength:{value:e,message:x.toString(t)}})}length(e,t){return new pe({...this._def,exactLength:{value:e,message:x.toString(t)}})}nonempty(e){return this.min(1,e)}}pe.create=(n,e)=>new pe({type:n,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...S(e)});function lt(n){if(n instanceof B){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=xe.create(lt(r))}return new B({...n._def,shape:()=>e})}else return n instanceof pe?new pe({...n._def,type:lt(n.element)}):n instanceof xe?xe.create(lt(n.unwrap())):n instanceof Ve?Ve.create(lt(n.unwrap())):n instanceof we?we.create(n.items.map(e=>lt(e))):n}class B extends P{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=$.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==b.object){const d=this._getOrReturnCtx(e);return _(d,{code:f.invalid_type,expected:b.object,received:d.parsedType}),Z}const{status:t,ctx:r}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ze&&this._def.unknownKeys==="strip"))for(const d in r.data)a.includes(d)||i.push(d);const o=[];for(const d of a){const u=s[d],l=r.data[d];o.push({key:{status:"valid",value:d},value:u._parse(new ke(r,l,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof Ze){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of i)o.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")i.length>0&&(_(r,{code:f.unrecognized_keys,keys:i}),t.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of i){const l=r.data[u];o.push({key:{status:"valid",value:u},value:d._parse(new ke(r,l,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of o){const l=await u.key,p=await u.value;d.push({key:l,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>Q.mergeObjectSync(t,d)):Q.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return x.errToObj,new B({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=x.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new B({...this._def,unknownKeys:"strip"})}passthrough(){return new B({...this._def,unknownKeys:"passthrough"})}extend(e){return new B({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new B({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new B({...this._def,catchall:e})}pick(e){const t={};return $.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new B({...this._def,shape:()=>t})}omit(e){const t={};return $.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new B({...this._def,shape:()=>t})}deepPartial(){return lt(this)}partial(e){const t={};return $.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new B({...this._def,shape:()=>t})}required(e){const t={};return $.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof xe;)s=s._def.innerType;t[r]=s}}),new B({...this._def,shape:()=>t})}keyof(){return Hr($.objectKeys(this.shape))}}B.create=(n,e)=>new B({shape:()=>n,unknownKeys:"strip",catchall:Ze.create(),typeName:T.ZodObject,...S(e)}),B.strictCreate=(n,e)=>new B({shape:()=>n,unknownKeys:"strict",catchall:Ze.create(),typeName:T.ZodObject,...S(e)}),B.lazycreate=(n,e)=>new B({shape:n,unknownKeys:"strip",catchall:Ze.create(),typeName:T.ZodObject,...S(e)});class Qt extends P{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new re(o.ctx.common.issues));return _(t,{code:f.invalid_union,unionErrors:i}),Z}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new re(d));return _(t,{code:f.invalid_union,unionErrors:o}),Z}}get options(){return this._def.options}}Qt.create=(n,e)=>new Qt({options:n,typeName:T.ZodUnion,...S(e)});const De=n=>n instanceof tn?De(n.schema):n instanceof he?De(n.innerType()):n instanceof nn?[n.value]:n instanceof Le?n.options:n instanceof rn?$.objectValues(n.enum):n instanceof sn?De(n._def.innerType):n instanceof Yt?[void 0]:n instanceof Jt?[null]:n instanceof xe?[void 0,...De(n.unwrap())]:n instanceof Ve?[null,...De(n.unwrap())]:n instanceof sr||n instanceof cn?De(n.unwrap()):n instanceof an?De(n._def.innerType):[];class Dn extends P{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.object)return _(t,{code:f.invalid_type,expected:b.object,received:t.parsedType}),Z;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(_(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=De(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Dn({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...S(r)})}}function rr(n,e){const t=Ae(n),r=Ae(e);if(n===e)return{valid:!0,data:n};if(t===b.object&&r===b.object){const s=$.objectKeys(e),a=$.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i={...n,...e};for(const o of a){const d=rr(n[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===b.array&&r===b.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],d=rr(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===b.date&&r===b.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Xt extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(er(a)||er(i))return Z;const o=rr(a.value,i.value);return o.valid?((tr(a)||tr(i))&&t.dirty(),{status:t.value,value:o.data}):(_(r,{code:f.invalid_intersection_types}),Z)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Xt.create=(n,e,t)=>new Xt({left:n,right:e,typeName:T.ZodIntersection,...S(t)});class we extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.array)return _(r,{code:f.invalid_type,expected:b.array,received:r.parsedType}),Z;if(r.data.length<this._def.items.length)return _(r,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Z;!this._def.rest&&r.data.length>this._def.items.length&&(_(r,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new ke(r,a,r.path,i)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>Q.mergeArray(t,a)):Q.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new we({...this._def,rest:e})}}we.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new we({items:n,typeName:T.ZodTuple,rest:null,...S(e)})};class en extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.object)return _(r,{code:f.invalid_type,expected:b.object,received:r.parsedType}),Z;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ke(r,o,r.path,o)),value:i._parse(new ke(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?Q.mergeObjectAsync(t,s):Q.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof P?new en({keyType:e,valueType:t,typeName:T.ZodRecord,...S(r)}):new en({keyType:le.create(),valueType:e,typeName:T.ZodRecord,...S(t)})}}class Ln extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.map)return _(r,{code:f.invalid_type,expected:b.map,received:r.parsedType}),Z;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,d],u)=>({key:s._parse(new ke(r,o,r.path,[u,"key"])),value:a._parse(new ke(r,d,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return Z;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return Z;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}Ln.create=(n,e,t)=>new Ln({valueType:e,keyType:n,typeName:T.ZodMap,...S(t)});class Ye extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.set)return _(r,{code:f.invalid_type,expected:b.set,received:r.parsedType}),Z;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(_(r,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(_(r,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const u=new Set;for(const l of d){if(l.status==="aborted")return Z;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((d,u)=>a._parse(new ke(r,d,r.path,u)));return r.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new Ye({...this._def,minSize:{value:e,message:x.toString(t)}})}max(e,t){return new Ye({...this._def,maxSize:{value:e,message:x.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ye.create=(n,e)=>new Ye({valueType:n,minSize:null,maxSize:null,typeName:T.ZodSet,...S(e)});class pt extends P{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.function)return _(t,{code:f.invalid_type,expected:b.function,received:t.parsedType}),Z;function r(o,d){return Pn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,In(),dt].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:d}})}function s(o,d){return Pn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,In(),dt].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ht){const o=this;return ee(async function(...d){const u=new re([]),l=await o._def.args.parseAsync(d,a).catch(C=>{throw u.addIssue(r(d,C)),u}),p=await Reflect.apply(i,this,l);return await o._def.returns._def.type.parseAsync(p,a).catch(C=>{throw u.addIssue(s(p,C)),u})})}else{const o=this;return ee(function(...d){const u=o._def.args.safeParse(d,a);if(!u.success)throw new re([r(d,u.error)]);const l=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(l,a);if(!p.success)throw new re([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new pt({...this._def,args:we.create(e).rest(ze.create())})}returns(e){return new pt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new pt({args:e||we.create([]).rest(ze.create()),returns:t||ze.create(),typeName:T.ZodFunction,...S(r)})}}class tn extends P{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})}}tn.create=(n,e)=>new tn({getter:n,typeName:T.ZodLazy,...S(e)});class nn extends P{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),Z}return{status:"valid",value:e.data}}get value(){return this._def.value}}nn.create=(n,e)=>new nn({value:n,typeName:T.ZodLiteral,...S(e)});function Hr(n,e){return new Le({values:n,typeName:T.ZodEnum,...S(e)})}class Le extends P{constructor(){super(...arguments),Kt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{expected:$.joinValues(r),received:t.parsedType,code:f.invalid_type}),Z}if(An(this,Kt)||Vr(this,Kt,new Set(this._def.values)),!An(this,Kt).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{received:t.data,code:f.invalid_enum_value,options:r}),Z}return ee(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 Le.create(e,{...this._def,...t})}exclude(e,t=this._def){return Le.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Kt=new WeakMap,Le.create=Hr;class rn extends P{constructor(){super(...arguments),Gt.set(this,void 0)}_parse(e){const t=$.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==b.string&&r.parsedType!==b.number){const s=$.objectValues(t);return _(r,{expected:$.joinValues(s),received:r.parsedType,code:f.invalid_type}),Z}if(An(this,Gt)||Vr(this,Gt,new Set($.getValidEnumValues(this._def.values))),!An(this,Gt).has(e.data)){const s=$.objectValues(t);return _(r,{received:r.data,code:f.invalid_enum_value,options:s}),Z}return ee(e.data)}get enum(){return this._def.values}}Gt=new WeakMap,rn.create=(n,e)=>new rn({values:n,typeName:T.ZodNativeEnum,...S(e)});class ht extends P{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.promise&&t.common.async===!1)return _(t,{code:f.invalid_type,expected:b.promise,received:t.parsedType}),Z;const r=t.parsedType===b.promise?t.data:Promise.resolve(t.data);return ee(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ht.create=(n,e)=>new ht({type:n,typeName:T.ZodPromise,...S(e)});class he extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{_(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return Z;const d=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return d.status==="aborted"?Z:d.status==="dirty"||t.value==="dirty"?Nn(d.value):d});{if(t.value==="aborted")return Z;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?Z:o.status==="dirty"||t.value==="dirty"?Nn(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Z:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?Z:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ht(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Ht(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);$.assertNever(s)}}he.create=(n,e,t)=>new he({schema:n,typeName:T.ZodEffects,effect:e,...S(t)}),he.createWithPreprocess=(n,e,t)=>new he({schema:e,effect:{type:"preprocess",transform:n},typeName:T.ZodEffects,...S(t)});class xe extends P{_parse(e){return this._getType(e)===b.undefined?ee(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xe.create=(n,e)=>new xe({innerType:n,typeName:T.ZodOptional,...S(e)});class Ve extends P{_parse(e){return this._getType(e)===b.null?ee(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ve.create=(n,e)=>new Ve({innerType:n,typeName:T.ZodNullable,...S(e)});class sn extends P{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===b.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}sn.create=(n,e)=>new sn({innerType:n,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class an extends P{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ft(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}an.create=(n,e)=>new an({innerType:n,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class Vn extends P{_parse(e){if(this._getType(e)!==b.nan){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.nan,received:t.parsedType}),Z}return{status:"valid",value:e.data}}}Vn.create=n=>new Vn({typeName:T.ZodNaN,...S(n)});const Ai=Symbol("zod_brand");class sr extends P{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class on extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Z:s.status==="dirty"?(t.dirty(),Nn(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Z:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new on({in:e,out:t,typeName:T.ZodPipeline})}}class cn extends P{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Ht(s)&&(s.value=Object.freeze(s.value)),s);return Ft(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}cn.create=(n,e)=>new cn({innerType:n,typeName:T.ZodReadonly,...S(e)});function Fr(n,e={},t){return n?ut.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:d})}}):ut.create()}const $i={object:B.lazycreate};var T;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(T||(T={}));const Mi=(n,e={message:`Input not instance of ${n.name}`})=>Fr(t=>t instanceof n,e),Kr=le.create,Gr=$e.create,Di=Vn.create,Li=Me.create,zr=zt.create,Vi=Ge.create,Ui=$n.create,qi=Yt.create,Bi=Jt.create,Wi=ut.create,Hi=ze.create,Fi=Ze.create,Ki=Mn.create,Gi=pe.create,zi=B.create,Yi=B.strictCreate,Ji=Qt.create,Qi=Dn.create,Xi=Xt.create,eo=we.create,to=en.create,no=Ln.create,ro=Ye.create,so=pt.create,ao=tn.create,io=nn.create,oo=Le.create,co=rn.create,uo=ht.create,Yr=he.create,lo=xe.create,po=Ve.create,ho=he.createWithPreprocess,fo=on.create;var c=Object.freeze({__proto__:null,defaultErrorMap:dt,setErrorMap:yi,getErrorMap:In,makeIssue:Pn,EMPTY_PATH:vi,addIssueToContext:_,ParseStatus:Q,INVALID:Z,DIRTY:Nn,OK:ee,isAborted:er,isDirty:tr,isValid:Ht,isAsync:Ft,get util(){return $},get objectUtil(){return Xn},ZodParsedType:b,getParsedType:Ae,ZodType:P,datetimeRegex:Wr,ZodString:le,ZodNumber:$e,ZodBigInt:Me,ZodBoolean:zt,ZodDate:Ge,ZodSymbol:$n,ZodUndefined:Yt,ZodNull:Jt,ZodAny:ut,ZodUnknown:ze,ZodNever:Ze,ZodVoid:Mn,ZodArray:pe,ZodObject:B,ZodUnion:Qt,ZodDiscriminatedUnion:Dn,ZodIntersection:Xt,ZodTuple:we,ZodRecord:en,ZodMap:Ln,ZodSet:Ye,ZodFunction:pt,ZodLazy:tn,ZodLiteral:nn,ZodEnum:Le,ZodNativeEnum:rn,ZodPromise:ht,ZodEffects:he,ZodTransformer:he,ZodOptional:xe,ZodNullable:Ve,ZodDefault:sn,ZodCatch:an,ZodNaN:Vn,BRAND:Ai,ZodBranded:sr,ZodPipeline:on,ZodReadonly:cn,custom:Fr,Schema:P,ZodSchema:P,late:$i,get ZodFirstPartyTypeKind(){return T},coerce:{string:n=>le.create({...n,coerce:!0}),number:n=>$e.create({...n,coerce:!0}),boolean:n=>zt.create({...n,coerce:!0}),bigint:n=>Me.create({...n,coerce:!0}),date:n=>Ge.create({...n,coerce:!0})},any:Wi,array:Gi,bigint:Li,boolean:zr,date:Vi,discriminatedUnion:Qi,effect:Yr,enum:oo,function:so,instanceof:Mi,intersection:Xi,lazy:ao,literal:io,map:no,nan:Di,nativeEnum:co,never:Fi,null:Bi,nullable:po,number:Gr,object:zi,oboolean:()=>zr().optional(),onumber:()=>Gr().optional(),optional:lo,ostring:()=>Kr().optional(),pipeline:fo,preprocess:ho,promise:uo,record:to,set:ro,strictObject:Yi,string:Kr,symbol:Ui,transformer:Yr,tuple:eo,undefined:qi,union:Ji,unknown:Hi,void:Ki,NEVER:Z,ZodIssueCode:f,quotelessJson:_i,ZodError:re});gi(c);const mo=c.object({start:c.number(),limit:c.number(),length:c.number()}),ar=c.object({created_at:c.string(),updated_at:c.string()}),go=c.object({email:c.string().optional(),email_verified:c.boolean().optional(),name:c.string().optional(),username:c.string().optional(),given_name:c.string().optional(),phone_number:c.string().optional(),phone_verified:c.boolean().optional(),family_name:c.string().optional()}).catchall(c.any()),_o=c.object({connection:c.string(),user_id:c.string(),provider:c.string(),isSocial:c.boolean(),access_token:c.string().optional(),access_token_secret:c.string().optional(),refresh_token:c.string().optional(),profileData:go.optional()}),Jr=c.object({email:c.string().optional(),username:c.string().optional(),given_name:c.string().optional(),family_name:c.string().optional(),nickname:c.string().optional(),name:c.string().optional(),picture:c.string().optional(),locale:c.string().optional(),linked_to:c.string().optional(),profileData:c.string().optional(),user_id:c.string().optional()});Jr.extend({email_verified:c.boolean().default(!1),verify_email:c.boolean().optional(),last_ip:c.string().optional(),last_login:c.string().optional(),user_id:c.string().optional(),provider:c.string().default("email"),connection:c.string().default("email")}).extend(ar.shape).extend({user_id:c.string(),email:c.string(),is_social:c.boolean(),login_count:c.number(),identities:c.array(_o).optional()}),Jr.extend({email:c.string(),login_count:c.number(),multifactor:c.array(c.string()).optional(),last_ip:c.string().optional(),last_login:c.string().optional(),user_id:c.string()}).catchall(c.any());const yo=c.object({id:c.string(),name:c.string(),allowed_web_origins:c.string().transform(n=>n===null?"":n).default(""),allowed_callback_urls:c.string().transform(n=>n===null?"":n).default(""),allowed_logout_urls:c.string().transform(n=>n===null?"":n).default(""),email_validation:c.enum(["enabled","disabled","enforced"]).default("enforced"),client_secret:c.string().default(""),disable_sign_ups:c.boolean().default(!1)});c.object({created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)}).extend(yo.shape);var Qr=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(Qr||{}),Xr=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n))(Xr||{}),es=(n=>(n.S265="S256",n.plain="plain",n))(es||{});const Un=c.object({client_id:c.string(),vendor_id:c.string().optional(),response_type:c.nativeEnum(Qr).optional(),response_mode:c.nativeEnum(Xr).optional(),redirect_uri:c.string().optional(),audience:c.string().optional(),state:c.string().optional(),nonce:c.string().optional(),scope:c.string().optional(),code_challenge_method:c.nativeEnum(es).optional(),code_challenge:c.string().optional(),username:c.string().optional()});c.object({colors:c.object({primary:c.string(),page_background:c.object({type:c.string().optional(),start:c.string().optional(),end:c.string().optional(),angle_deg:c.number().optional()}).optional()}).optional(),logo_url:c.string().optional(),favicon_url:c.string().optional(),font:c.object({url:c.string()}).optional()});const vo=c.object({id:c.string().optional(),name:c.string(),client_id:c.string().optional(),client_secret:c.string().optional(),authorization_endpoint:c.string().optional(),response_type:c.custom().optional(),response_mode:c.custom().optional(),private_key:c.string().optional(),kid:c.string().optional(),team_id:c.string().optional(),token_endpoint:c.string().optional(),token_exchange_basic_auth:c.boolean().optional(),userinfo_endpoint:c.string().optional(),scope:c.string().optional()}),ts=c.object({id:c.string(),created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)}).extend(vo.shape),bo=c.object({domain:c.string(),dkim_private_key:c.string().optional(),dkim_public_key:c.string().optional(),email_api_key:c.string().optional(),email_service:c.union([c.literal("mailgun"),c.literal("mailchannels")]).optional()}),ns=c.object({id:c.string(),name:c.string(),domains:c.array(bo),allowed_callback_urls:c.array(c.string()),allowed_logout_urls:c.array(c.string()),allowed_web_origins:c.array(c.string()),email_validation:c.union([c.literal("enabled"),c.literal("disabled"),c.literal("enforced")]),tenant_id:c.string(),client_secret:c.string(),disable_sign_ups:c.boolean(),tenant:c.object({name:c.string(),audience:c.string().optional(),logo:c.string().optional(),primary_color:c.string().optional(),secondary_color:c.string().optional(),sender_email:c.string(),sender_name:c.string(),support_url:c.string().optional(),language:c.string().length(2).optional()})});ns.extend({connections:c.array(ts)}),ns.extend({connections:c.array(ts.partial())});const ko=c.enum(["password_reset","email_verification","otp","oauth2","oauth2_state","ticket"]);c.object({code_id:c.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:c.string().openapi({description:"The id of the login session that the code is connected to"}),code_type:ko,created_at:c.string(),expires_at:c.string(),used_at:c.string().optional()});const wo=c.object({domain:c.string(),dkim_private_key:c.string().optional(),dkim_public_key:c.string().optional(),email_api_key:c.string().optional(),email_service:c.enum(["mailgun","mailchannels"])});ar.extend({...wo.shape,id:c.string()}),c.object({trigger_id:c.enum(["post-user-registration","post-user-login"]),enabled:c.boolean().default(!1),url:c.string(),hook_id:c.string().optional()}).extend({...ar.shape,hook_id:c.string()});const xo=c.object({alg:c.string(),e:c.string(),kid:c.string(),kty:c.string(),n:c.string(),use:c.string().optional()}),Oo=c.object({keys:c.array(xo)}),rs=c.object({issuer:c.string(),authorization_endpoint:c.string(),token_endpoint:c.string(),device_authorization_endpoint:c.string(),userinfo_endpoint:c.string(),mfa_challenge_endpoint:c.string(),jwks_uri:c.string(),registration_endpoint:c.string(),revocation_endpoint:c.string(),scopes_supported:c.array(c.string()),response_types_supported:c.array(c.string()),code_challenge_methods_supported:c.array(c.string()),response_modes_supported:c.array(c.string()),subject_types_supported:c.array(c.string()),id_token_signing_alg_values_supported:c.array(c.string()),token_endpoint_auth_methods_supported:c.array(c.string()),claims_supported:c.array(c.string()),request_uri_parameter_supported:c.boolean(),request_parameter_supported:c.boolean(),token_endpoint_auth_signing_alg_values_supported:c.array(c.string())}),To=c.object({login_id:c.string().openapi({description:"This is is used as the state in the universal login"}),auth0Client:c.string().optional(),authParams:Un,expires_at:c.string(),deleted_at:c.string(),ip:c.string().optional()}).openapi({description:"This represents a login sesion"});c.object({...To.shape,created_at:c.string(),updated_at:c.string()});const jo=c.enum(["sapi","ssa","fsa","ss","ssa","fs","s","f","fp","slo","scoa","fcoa","seccft","cls","seacft","serft"]),Zo=c.object({name:c.string(),version:c.string(),env:c.object({node:c.string().optional()}).optional()});c.object({type:jo,date:c.string(),description:c.string().optional(),log_id:c.string().optional(),_id:c.string().optional(),ip:c.string(),user_agent:c.string(),details:c.any().optional(),isMobile:c.boolean(),user_id:c.string().optional(),user_name:c.string().optional(),connection:c.string().optional(),connection_id:c.string().optional(),client_id:c.string().optional(),client_name:c.string().optional(),audience:c.string().optional(),scope:c.array(c.string()).optional(),strategy:c.string().optional(),strategy_type:c.string().optional(),hostname:c.string().optional(),auth0_client:Zo.optional()});const Ro=c.object({user_id:c.string(),password:c.string(),algorithm:c.enum(["bcrypt","argon2id"]).default("argon2id")});c.object({...Ro.shape,created_at:c.string(),updated_at:c.string()});const Eo=c.object({session_id:c.string(),client_id:c.string(),expires_at:c.string(),used_at:c.string(),deleted_at:c.string().optional(),user_id:c.string()});c.object({created_at:c.string(),...Eo.shape}),c.object({private_key:c.string(),public_key:c.string(),kid:c.string(),created_at:c.string(),revoked_at:c.string().optional()}),c.object({kid:c.string().openapi({description:"The key id of the signing key"}),cert:c.string().openapi({description:"The public certificate of the signing key"}),fingerprint:c.string().openapi({description:"The cert fingerprint"}),thumbprint:c.string().openapi({description:"The cert thumbprint"}),pkcs7:c.string().optional().openapi({description:"The public certificate of the signing key in pkcs7 format"}),current:c.boolean().optional().openapi({description:"True if the key is the current key"}),next:c.boolean().optional().openapi({description:"True if the key is the next key"}),previous:c.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:c.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:c.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:c.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:c.string().optional().openapi({description:"The date and time when the key was revoked"})});const ir=c.object({name:c.string(),audience:c.string(),sender_email:c.string().email(),sender_name:c.string(),support_url:c.string().url().optional(),logo:c.string().url().optional(),primary_color:c.string().optional(),secondary_color:c.string().optional(),language:c.string().optional()}),qn=ir.extend({created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)});c.object({logoUrl:c.string(),loginBackgroundImage:c.string().nullish(),style:c.object({primaryColor:c.string(),buttonTextColor:c.string(),primaryHoverColor:c.string()}),supportEmail:c.string().nullable(),supportUrl:c.string().nullable(),name:c.string(),showGreyishBackground:c.boolean().optional(),termsAndConditionsUrl:c.string().nullable(),companyName:c.string().optional(),checkoutHideSocial:c.boolean().optional(),siteUrl:c.string().nullable(),manageSubscriptionsUrl:c.string().optional()});var ss=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(ss||{});const or=c.nativeEnum(ss);c.object({grant_type:or.refine(n=>n==="authorization_code"),code:c.string(),client_secret:c.string(),client_id:c.string()}),c.object({grant_type:or.refine(n=>n==="authorization_code"),code:c.string(),code_verifier:c.string(),client_id:c.string().optional(),redirect_uri:c.string()}),c.object({grant_type:or.refine(n=>n==="client_credentials"),scope:c.string().optional(),client_secret:c.string(),client_id:c.string(),audience:c.string().optional()}),c.object({access_token:c.string(),id_token:c.string().optional(),scope:c.string().optional(),state:c.string().optional(),refresh_token:c.string().optional(),token_type:c.string(),expires_in:c.number()}),c.object({code:c.string(),state:c.string().optional()});const So=c.object({button_border_radius:c.number(),button_border_weight:c.number(),buttons_style:c.enum(["pill"]),input_border_radius:c.number(),input_border_weight:c.number(),inputs_style:c.enum(["pill"]),show_widget_shadow:c.boolean(),widget_border_weight:c.number(),widget_corner_radius:c.number()}),Co=c.object({base_focus_color:c.string(),base_hover_color:c.string(),body_text:c.string(),captcha_widget_theme:c.enum(["auto"]),error:c.string(),header:c.string(),icons:c.string(),input_background:c.string(),input_border:c.string(),input_filled_text:c.string(),input_labels_placeholders:c.string(),links_focused_components:c.string(),primary_button:c.string(),primary_button_label:c.string(),secondary_button_border:c.string(),secondary_button_label:c.string(),success:c.string(),widget_background:c.string(),widget_border:c.string()}),ft=c.object({bold:c.boolean(),size:c.number()}),Io=c.object({body_text:ft,buttons_text:ft,font_url:c.string(),input_labels:ft,links:ft,links_style:c.enum(["normal"]),reference_text_size:c.number(),subtitle:ft,title:ft}),Po=c.object({background_color:c.string(),background_image_url:c.string(),page_layout:c.enum(["center"])}),No=c.object({header_text_alignment:c.enum(["center"]),logo_height:c.number(),logo_position:c.enum(["center"]),logo_url:c.string(),social_buttons_layout:c.enum(["bottom"])});c.object({borders:So,colors:Co,displayName:c.string(),fonts:Io,page_background:Po,widget:No}).extend({themeId:c.string()});const Ao=c.object({id:c.string(),expires_at:c.string(),auth0Client:c.string().optional(),authParams:Un});c.object({...Ao.shape,created_at:c.string(),updated_at:c.string()});const $o=c.object({id:c.string(),email:c.string(),code:c.string(),ip:c.string().optional(),send:c.enum(["code","link"]),authParams:Un,expires_at:c.string(),used_at:c.string().optional(),user_id:c.string().optional()});c.object({created_at:c.string(),...$o.shape});const Mo=c.object({authParams:Un,code:c.string(),user_id:c.string(),created_at:c.string(),expires_at:c.string(),used_at:c.string().optional()});c.object({...Mo.shape,created_at:c.string()});const Do=new Bt().openapi(Ke({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Oo}},description:"List of tenants"}}}),async n=>{const{env:e}=n,t=[{alg:"RS256",e:"AQAB",kid:"hZ42TWGWLdmyKfwGVA6c2",kty:"RSA",n:"nUd-mktFZQNfVwmXufxcVcvJo6Lkb-jDuymtfQunmEhWCctOccWx9e7LX7_9uN15ZnRS7XJInPMRs9KLYdZ0GCnE2HM_QbrEoHpdkCRgyTE-KzmoaEv_AOVGE_Kg0-0ct3r9Z7aJLDVAsxXl1C9y8Gr7ZYkq0c4DyZr9VT8nQiwZQERbfxXdXw-5RLj21S_Lm-LL-AjKvry_TDBLpfUFJV18SVsM07lY_V45TwykNewRdaGLspFIeGdG5j5eByV8ifzBqvzOSptSCsmOTtW-ceWUk0FPD7g_KKzjjbzenoB0TC8mBb_4vWZlHnuGIAs2YoTFglp9uNu7t_OVl3Svo6ZE6alzUnaNfZNeAi78KPHYQ4tDWPjpYNfGynsiD0nojkDSPCIak56jWNYjj614cPEBiv9MVQRiSbBxpiGhMoHlW_QCCPMcXygLAaRs_tUksqoH4QB80krifG2yHPgGDPjXK1_0cYzV80iOcQIeoceqhkSSc6YxzzgDrQcsV2k3bizRQSL83GWkpdHhTZn-Q_JzsW_bDY_f9fjigYbRnoDSgS7038VFIPc92StE41MdgvIQMomcyEE4lYK1uv1Mo6cnXbCZhm8tvddo7VKNorOB4nsiv8DGrWPlzQBca9VN4C1oE2mH-3WLFR7XEkBHWVouOdTWM2S3K9F10YtahkM"}];return n.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})}).openapi(Ke({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:rs}},description:"List of tenants"}}}),async n=>{const{env:e}=n,{ISSUER:t}=e,r=rs.parse({issuer:t,authorization_endpoint:`${t}authorize`,token_endpoint:`${t}oauth/token`,device_authorization_endpoint:`${t}oauth/device/code`,userinfo_endpoint:`${t}userinfo`,mfa_challenge_endpoint:`${t}mfa/challenge`,jwks_uri:`${t}.well-known/jwks.json`,registration_endpoint:`${t}oidc/register`,revocation_endpoint:`${t}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return n.json(r,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})});async function Lo({userAdapter:n,tenant_id:e,email:t}){var o;const{users:r}=await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),s=r.filter(d=>!(d.provider==="auth2"&&!d.email_verified));if(s.length===0)return;const a=s.filter(d=>!d.linked_to);if(a.length>0)return a.length>1&&console.error("More than one primary user found for same email"),a[0];const i=await n.get(e,(o=s[0])==null?void 0:o.linked_to);if(!i)throw new Error("Primary account not found");return i}function Vo(n){return async(e,t)=>{if(!t.email||!t.email_verified)return n.users.create(e,t);const r=await Lo({userAdapter:n.users,tenant_id:e,email:t.email});return r?(await n.users.create(e,{...t,linked_to:r.user_id}),r):n.users.create(e,t)}}async function Uo(n,e,t){for await(const r of e)(await fetch(r.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok}function qo(n,e){return async(t,r)=>{const{hooks:s}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await Uo(n,s,{tenant_id:t,user:r,trigger_id:"post-user-registration"}),r}}function Bo(n,e){return async(t,r)=>{let s=await Vo(e)(t,r);return await qo(n,e)(t,s),s}}function Wo(n,e){return{...e,users:{...e.users,create:Bo(n,e)}}}const Ho=z.object({page:z.string().min(0).optional().default("0").transform(n=>parseInt(n,10)).openapi({description:"The page number where 0 is the first page"}),per_page:z.string().min(1).optional().default("10").transform(n=>parseInt(n,10)).openapi({description:"The number of items per page"}),include_totals:z.string().optional().default("false").transform(n=>n==="true").openapi({description:"If the total number of items should be included in the response"}),sort:z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function Fo(n){if(!n)return;const[e="",t]=n.split(":");return{sort_by:e,sort_order:t==="1"?"asc":"desc"}}const Ko=mo.extend({tenants:z.array(qn)}),Go=new Bt().openapi(Ke({tags:["tenants"],method:"get",path:"/",request:{query:Ho},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:z.union([z.array(qn),Ko])}},description:"List of tenants"}}}),async n=>{const{page:e,per_page:t,include_totals:r,sort:s,q:a}=n.req.valid("query"),i=await n.env.data.tenants.list({page:e,per_page:t,include_totals:r,sort:Fo(s),q:a});return r?n.json(i):n.json(i.tenants)}).openapi(Ke({tags:["tenants"],method:"get",path:"/{id}",request:{params:z.object({id:z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:qn}},description:"A tenant"}}}),async n=>{const{id:e}=n.req.valid("param"),t=await n.env.data.tenants.get(e);if(!t)throw new bn(404);return console.log("tenant",t),n.json(t)}).openapi(Ke({tags:["tenants"],method:"delete",path:"/{id}",request:{params:z.object({id:z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{id:e}=n.req.valid("param");return await n.env.data.tenants.remove(e),n.text("OK")}).openapi(Ke({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:z.object(ir.shape).partial()}}},params:z.object({id:z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{id:e}=n.req.valid("param"),t=n.req.valid("json");return await n.env.data.tenants.update(e,t),n.text("OK")}).openapi(Ke({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:z.object(ir.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:qn}},description:"An tenant"}}}),async n=>{const e=n.req.valid("json"),t=await n.env.data.tenants.create(e);return n.json(t,{status:201})});let as=!1;function zo(n){n.use(async(e,t)=>(as||(n.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),as=!0),await t()))}function Yo(n){const e=new Bt;e.use(async(r,s)=>(r.env.data=Wo(r,n.dataAdapter),s()));const t=e.route("/api/v2/tenants",Go);return zo(t),t.doc("/api/v2/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function Jo(n){const e=new Bt;e.get("/",s=>s.text("Hello, authhero!"));const t=Yo(n);e.route("/api/v2",t);const r=new Bt().route("/.well-known",Do);return r.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",r),e}return V.init=Jo,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),V}({});
1
+ var authhero=function(U){"use strict";var tc=Object.defineProperty;var us=U=>{throw TypeError(U)};var nc=(U,L,k)=>L in U?tc(U,L,{enumerable:!0,configurable:!0,writable:!0,value:k}):U[L]=k;var y=(U,L,k)=>nc(U,typeof L!="symbol"?L+"":L,k),ls=(U,L,k)=>L.has(U)||us("Cannot "+k);var m=(U,L,k)=>(ls(U,L,"read from private field"),k?k.call(U):L.get(U)),Y=(U,L,k)=>L.has(U)?us("Cannot add the same private member more than once"):L instanceof WeakSet?L.add(U):L.set(U,k),$=(U,L,k,fn)=>(ls(U,L,"write to private field"),fn?fn.call(U,k):L.set(U,k),k);var mt,fe,os,dn,un,Ve,Je,Re,W,F,me,Se,ln,gt,_t,pn,hn,cs,ge,ds;function L(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}typeof SuppressedError=="function"&&SuppressedError;function k(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function fn(n){return"_def"in n}function yt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function ps(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var i,o,d,u,l,p;const C=typeof s=="string"?a:s,D=C??{},{param:P}=D,R=L(D,["param"]),H=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),K=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),R),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||P?{param:Object.assign(Object.assign({},(p=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||p===void 0?void 0:p.param),P)}:void 0),se=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(H).length>0?{_internal:H}:void 0),Object.keys(K).length>0?{metadata:K}:void 0)}));if(k(this,"ZodObject")){const ae=this.extend;se.extend=function(...qe){var oe,ie,te,Oe,_e,Qe;const Xe=ae.apply(this,qe);return Xe._def.openapi={_internal:{extendedFrom:!((ie=(oe=this._def.openapi)===null||oe===void 0?void 0:oe._internal)===null||ie===void 0)&&ie.refId?{refId:(Oe=(te=this._def.openapi)===null||te===void 0?void 0:te._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(_e=this._def.openapi)===null||_e===void 0?void 0:_e._internal.extendedFrom},metadata:(Qe=Xe._def.openapi)===null||Qe===void 0?void 0:Qe.metadata},Xe}}return se},yt(n,"optional"),yt(n,"nullable"),yt(n,"default"),yt(n,"transform"),yt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var u,l;d._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}function mn(n,e){if(n==null||e===null||e===void 0)return n===e;if(n===e||n.valueOf()===e.valueOf())return!0;if(Array.isArray(n)&&(!Array.isArray(e)||n.length!==e.length)||!(n instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(n);return Object.keys(e).every(r=>t.indexOf(r)!==-1)&&t.every(r=>mn(n[r],e[r]))}class hs{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),r=this.buckets.get(t);if(!r){this.buckets.set(t,[e]);return}r.some(a=>mn(a,e))||r.push(e)}contains(e){const t=this.hashCodeOf(e),r=this.buckets.get(t);return r?r.some(s=>mn(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,r=0;for(const a of this.buckets.values())e+=1,t+=a.length,a.length>1&&(r+=1);const s=e/t;return{totalBuckets:e,collisions:r,totalValues:t,hashEffectiveness:s}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let r=0;r<e.length;r++)t^=this.hashCodeOf(e[r])*r;return t}if(typeof e=="string"){for(let r=0;r<e.length;r++)t^=e.charCodeAt(r)*r;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[r,s]of Object.entries(e))t^=this.hashCodeOf(r)+this.hashCodeOf(s??"");return t}}function vt(n){return n==null}function bt(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{t[r]=e(s)}),t}function fs(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{e.some(a=>a===r)||(t[r]=s)}),t}function et(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{e(s,r)||(t[r]=s)}),t}function dr(n){return n.filter(e=>!vt(e))}const Bn=mn;function ms(n){const e=new hs;return n.forEach(t=>e.put(t)),[...e.values()]}function ur(n){return typeof n=="string"}class gs{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const r=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:r}),r}registerParameter(e,t){var r,s,a;const i=this.schemaWithRefId(e,t),o=(r=i._def.openapi)===null||r===void 0?void 0:r.metadata,d=i.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(a=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&a!==void 0?a:e})}));return this._definitions.push({type:"parameter",schema:d}),d}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,r){return this._definitions.push({type:"component",componentType:e,name:t,component:r}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class gn{constructor(e){this.message=e}}class kt extends gn{constructor(e,t){super(e),this.data=t}}class _n extends gn{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 wt(n,e){try{return n()}catch(t){throw t instanceof _n?new _n(Object.assign(Object.assign({},t.data),e)):t}}class _s extends gn{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class V{static getMetadata(e){var t;const r=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:r._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:r.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:a},s==null?void 0:s.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),r=e._def.openapi?e._def.openapi:t._def.openapi;return r==null?void 0:r._internal}static getParamMetadata(e){var t,r;const s=this.unwrapChained(e),a=e._def.openapi?e._def.openapi:s._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:a==null?void 0:a._internal,metadata:Object.assign(Object.assign({},a==null?void 0:a.metadata),{param:Object.assign({description:i},(r=a==null?void 0:a.metadata)===null||r===void 0?void 0:r.param)})}}static buildSchemaMetadata(e){return et(fs(e,["param"]),vt)}static buildParameterMetadata(e){return et(e,vt)}static applySchemaMetadata(e,t){return et(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),vt)}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&&k(e,t)?e:k(e,"ZodOptional")||k(e,"ZodNullable")||k(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):k(e,"ZodDefault")||k(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):k(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):k(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return k(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class ys{transform(e,t,r){var s,a;const i=e._def.type;return Object.assign(Object.assign({},t("array")),{items:r(i),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(a=e._def.maxLength)===null||a===void 0?void 0:a.value})}}class vs{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class bs{transform(e,t,r,s,a){const i=[...e.options.values()],o=i.map(s);return t?{oneOf:r(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(i,e.discriminator,a)}}mapDiscriminator(e,t,r){if(e.some(a=>V.getRefId(a)===void 0))return;const s={};return e.forEach(a=>{var i;const o=V.getRefId(a),d=(i=a.shape)===null||i===void 0?void 0:i[t];if(k(d,"ZodEnum")||k(d,"ZodNativeEnum")){Object.values(d.enum).filter(ur).forEach(p=>{s[p]=r(o)});return}const u=d==null?void 0:d._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=r(o)}),{propertyName:t,mapping:s}}}class ks{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class ws{transform(e,t,r,s){const i={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:r([i],t)}:i}flattenIntersectionTypes(e){if(!k(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),r=this.flattenIntersectionTypes(e._def.right);return[...t,...r]}}class xs{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function Os(n){const t=Object.keys(n).filter(a=>typeof n[n[a]]!="number").map(a=>n[a]),r=t.filter(a=>typeof a=="number").length,s=r===0?"string":r===t.length?"numeric":"mixed";return{values:t,type:s}}class Ts{transform(e,t){const{type:r,values:s}=Os(e._def.values);if(r==="mixed")throw new gn("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(r==="numeric"?"integer":"string")),{enum:s})}}class js{transform(e,t,r){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),r(e._def.checks))}}class Es{transform(e,t,r,s){var a;const i=(a=V.getInternalMetadata(e))===null||a===void 0?void 0:a.extendedFrom,o=this.requiredKeysOf(e),d=bt(e._def.shape(),s);if(!i)return Object.assign(Object.assign(Object.assign(Object.assign({},r("object")),{properties:d,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=i.schema;s(u);const l=this.requiredKeysOf(u),p=bt(u==null?void 0:u._def.shape(),s),C=Object.fromEntries(Object.entries(d).filter(([R,H])=>!Bn(p[R],H))),D=o.filter(R=>!l.includes(R)),P=Object.assign(Object.assign(Object.assign(Object.assign({},r("object")),{default:t,properties:C}),D.length>0?{required:D}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${i.refId}`},P]}}generateAdditionalProperties(e,t){const r=e._def.unknownKeys,s=e._def.catchall;return k(s,"ZodNever")?r==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,r])=>!V.isOptionalSchema(r)).map(([t,r])=>t)}}class Rs{transform(e,t,r){const s=e._def.valueType,a=e._def.keyType,i=r(s);if(k(a,"ZodEnum")||k(a,"ZodNativeEnum")){const d=Object.values(a.enum).filter(ur).reduce((u,l)=>Object.assign(Object.assign({},u),{[l]:i}),{});return Object.assign(Object.assign({},t("object")),{properties:d})}return Object.assign(Object.assign({},t("object")),{additionalProperties:i})}}class Ss{transform(e,t){var r,s,a;const i=this.getZodStringCheck(e,"regex"),o=(r=this.getZodStringCheck(e,"length"))===null||r===void 0?void 0:r.value,d=Number.isFinite(e.minLength)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(a=e.maxLength)!==null&&a!==void 0?a:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??d,maxLength:o??u,format:this.mapStringFormat(e),pattern:i==null?void 0:i.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time"}getZodStringCheck(e,t){return e._def.checks.find(r=>r.kind===t)}}class Zs{constructor(e){this.versionSpecifics=e}transform(e,t,r){const{items:s}=e._def,a=s.map(r);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(a))}}class Cs{transform(e,t,r){const a=this.flattenUnionTypes(e).map(i=>{const o=this.unwrapNullable(i);return r(o)});return{anyOf:t(a)}}flattenUnionTypes(e){return k(e,"ZodUnion")?e._def.options.flatMap(r=>this.flattenUnionTypes(r)):[e]}unwrapNullable(e){return k(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Is{constructor(e){this.versionSpecifics=e,this.objectTransformer=new Es,this.stringTransformer=new Ss,this.numberTransformer=new js,this.bigIntTransformer=new vs,this.literalTransformer=new xs,this.enumTransformer=new ks,this.nativeEnumTransformer=new Ts,this.arrayTransformer=new ys,this.unionTransformer=new Cs,this.discriminatedUnionTransformer=new bs,this.intersectionTransformer=new ws,this.recordTransformer=new Rs,this.tupleTransformer=new Zs(e)}transform(e,t,r,s,a){if(k(e,"ZodNull"))return this.versionSpecifics.nullType;if(k(e,"ZodUnknown")||k(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(k(e,"ZodObject"))return this.objectTransformer.transform(e,a,o=>this.versionSpecifics.mapNullableType(o,t),r);const i=this.transformSchemaWithoutDefault(e,t,r,s);return Object.assign(Object.assign({},i),{default:a})}transformSchemaWithoutDefault(e,t,r,s){if(k(e,"ZodUnknown")||k(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(k(e,"ZodString"))return this.stringTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodNumber"))return this.numberTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),i=>this.versionSpecifics.getNumberChecks(i));if(k(e,"ZodBigInt"))return this.bigIntTransformer.transform(i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(k(e,"ZodLiteral"))return this.literalTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodEnum"))return this.enumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(k(e,"ZodArray"))return this.arrayTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(k(e,"ZodTuple"))return this.tupleTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(k(e,"ZodUnion"))return this.unionTransformer.transform(e,i=>this.versionSpecifics.mapNullableOfArray(i,t),r);if(k(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),r,s);if(k(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),r);if(k(e,"ZodRecord"))return this.recordTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(k(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const a=V.getRefId(e);throw new _s({currentSchema:e._def,schemaName:a})}}class lr{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Is(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 r={};return this.rawComponents.forEach(({componentType:s,name:a,component:i})=>{var o;(o=r[s])!==null&&o!==void 0||(r[s]={}),r[s][a]=i}),Object.assign(Object.assign({},r),{schemas:Object.assign(Object.assign({},(e=r.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=r.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,r)=>{if(!("type"in t))return"type"in r?-1:0;if(!("type"in r))return 1;const s=e.findIndex(i=>i===t.type),a=e.findIndex(i=>i===r.type);return s-a})}generateSingle(e){if(!("type"in e)){this.generateSchemaWithRef(e);return}switch(e.type){case"parameter":this.generateParameterDefinition(e.schema);return;case"schema":this.generateSchemaWithRef(e.schema);return;case"route":this.generateSingleRoute(e.route);return;case"component":this.rawComponents.push(e);return}}generateParameterDefinition(e){const t=V.getRefId(e),r=this.generateParameter(e);return t&&(this.paramRefs[t]=r),r}getParameterRef(e,t){var r,s,a,i,o;const d=(r=e==null?void 0:e.metadata)===null||r===void 0?void 0:r.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(a=e._internal)===null||a===void 0?void 0:a.refId]:void 0;if(!(!(!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId)||!u)){if(d&&u.in!==d.in||t!=null&&t.in&&u.in!==t.in)throw new kt(`Conflicting location for parameter ${u.name}`,{key:"in",values:dr([u.in,t==null?void 0:t.in,d==null?void 0:d.in])});if(d&&u.name!==d.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new kt("Conflicting names for parameter",{key:"name",values:dr([u.name,t==null?void 0:t.name,d==null?void 0:d.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var r;const s=V.getMetadata(e),a=(r=s==null?void 0:s.metadata)===null||r===void 0?void 0:r.param,i=this.getParameterRef(s,{in:t});if(i)return[i];if(k(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,l])=>{var p,C;const D=V.getMetadata(l),P=this.getParameterRef(D,{in:t,name:u});if(P)return P;const R=(p=D==null?void 0:D.metadata)===null||p===void 0?void 0:p.param;if(R!=null&&R.name&&R.name!==u)throw new kt("Conflicting names for parameter",{key:"name",values:[u,R.name]});if(R!=null&&R.in&&R.in!==t)throw new kt(`Conflicting location for parameter ${(C=R.name)!==null&&C!==void 0?C:u}`,{key:"in",values:[t,R.in]});return this.generateParameter(l.openapi({param:{name:u,in:t}}))})}if(a!=null&&a.in&&a.in!==t)throw new kt(`Conflicting location for parameter ${a.name}`,{key:"in",values:[t,a.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const r=V.getParamMetadata(e),s=(t=r==null?void 0:r.metadata)===null||t===void 0?void 0:t.param,a=!V.isOptionalSchema(e)&&!e.isNullable(),i=this.generateSchemaWithRef(e);return Object.assign({schema:i,required:a},s?V.buildParameterMetadata(s):{})}generateParameter(e){var t;const r=V.getMetadata(e),s=(t=r==null?void 0:r.metadata)===null||t===void 0?void 0:t.param,a=s==null?void 0:s.name,i=s==null?void 0:s.in;if(!a)throw new _n({missingField:"name"});if(!i)throw new _n({missingField:"in",paramName:a});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:i,name:a})}generateSchemaWithMetadata(e){var t;const r=V.unwrapChained(e),s=V.getMetadata(e),a=V.getDefaultValue(e),i=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(r,e.isNullable(),a);return s!=null&&s.metadata?V.applySchemaMetadata(i,s.metadata):et(i,vt)}constructReferencedOpenAPISchema(e){var t;const r=V.getMetadata(e),s=V.unwrapChained(e),a=V.getDefaultValue(e),i=e.isNullable();return!((t=r==null?void 0:r.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(r.metadata.type,i):this.toOpenAPISchema(s,i,a)}generateSimpleSchema(e){var t;const r=V.getMetadata(e),s=V.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const a=this.schemaRefs[s],i={$ref:this.generateSchemaRef(s)},o=et(V.buildSchemaMetadata((t=r==null?void 0:r.metadata)!==null&&t!==void 0?t:{}),(l,p)=>l===void 0||Bn(l,a[p]));if(o.type)return{allOf:[i,o]};const d=et(this.constructReferencedOpenAPISchema(e),(l,p)=>l===void 0||Bn(l,a[p])),u=V.applySchemaMetadata(d,o);return Object.keys(u).length>0?{allOf:[i,u]}:i}generateSchemaWithRef(e){const t=V.getRefId(e),r=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=r,{$ref:this.generateSchemaRef(t)}):r}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,r=L(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},r),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,r=this.cleanParameter(e.query),s=this.cleanParameter(e.params),a=this.cleanParameter(e.cookies),i=wt(()=>r?this.generateInlineParameters(r,"query"):[],{location:"query"}),o=wt(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),d=wt(()=>a?this.generateInlineParameters(a,"cookie"):[],{location:"cookie"}),u=wt(()=>{if(Array.isArray(t))return t.flatMap(p=>this.generateInlineParameters(p,"header"));const l=this.cleanParameter(t);return l?this.generateInlineParameters(l,"header"):[]},{location:"header"});return[...o,...i,...u,...d]}cleanParameter(e){if(e)return k(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:r,request:s,responses:a}=e,i=L(e,["method","path","request","responses"]),o=bt(a,p=>this.getResponse(p)),d=wt(()=>this.getParameters(s),{route:`${t} ${r}`}),u=this.getRequestBody(s==null?void 0:s.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},i),d.length>0?{parameters:[...i.parameters||[],...d]}:{}),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:r}=e,s=L(e,["content","headers"]);const a=t?{content:this.getBodyContent(t)}:{};if(!r)return Object.assign(Object.assign({},s),a);const i=k(r,"ZodObject")?this.getResponseHeaders(r):r;return Object.assign(Object.assign(Object.assign({},s),{headers:i}),a)}getResponseHeaders(e){const t=e._def.shape();return bt(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return bt(e,t=>{if(!t||!fn(t.schema))return t;const{schema:r}=t,s=L(t,["schema"]),a=this.generateSchemaWithRef(r);return Object.assign({schema:a},s)})}toOpenAPISchema(e,t,r){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),r)}}class Ns{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=ms(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 Ps{constructor(e){const t=new Ns;this.generator=new lr(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class As{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 Ms(n){return"type"in n&&n.type==="webhook"}class $s{constructor(e){this.definitions=e,this.webhookRefs={};const t=new As;this.generator=new lr(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(Ms).forEach(r=>this.generateSingleWebhook(r.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 pr=n=>{const e=n.split("/");return e[0]===""&&e.shift(),e},Ds=n=>{const{groups:e,path:t}=Ls(n),r=pr(t);return Us(r,e)},Ls=n=>{const e=[];return n=n.replace(/\{[^}]+\}/g,(t,r)=>{const s=`@${r}`;return e.push([s,t]),s}),{groups:e,path:n}},Us=(n,e)=>{for(let t=e.length-1;t>=0;t--){const[r]=e[t];for(let s=n.length-1;s>=0;s--)if(n[s].includes(r)){n[s]=n[s].replace(r,e[t][1]);break}}return n},yn={},hr=n=>{if(n==="*")return"*";const e=n.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(yn[n]||(e[2]?yn[n]=[n,e[1],new RegExp("^"+e[2]+"$")]:yn[n]=[n,e[1],!0]),yn[n]):null},Vs=n=>{try{return decodeURI(n)}catch{return n.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURI(e)}catch{return e}})}},fr=n=>{const e=n.url,t=e.indexOf("/",8);let r=t;for(;r<e.length;r++){const s=e.charCodeAt(r);if(s===37){const a=e.indexOf("?",r),i=e.slice(t,a===-1?void 0:a);return Vs(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}else if(s===63)break}return e.slice(t,r)},qs=n=>{const e=fr(n);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},Be=(...n)=>{let e="",t=!1;for(let r of n)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),r[0]!=="/"&&(r=`/${r}`),r==="/"&&t?e=`${e}/`:r!=="/"&&(e=`${e}${r}`),r==="/"&&e===""&&(e="/");return e},mr=n=>{if(!n.match(/\:.+\?$/))return null;const e=n.split("/"),t=[];let r="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))r+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&r===""?t.push("/"):t.push(r);const a=s.replace("?","");r+="/"+a,t.push(r)}else r+="/"+s}),t.filter((s,a,i)=>i.indexOf(s)===a)},Wn=n=>/[%+]/.test(n)?(n.indexOf("+")!==-1&&(n=n.replace(/\+/g," ")),/%/.test(n)?vn(n):n):n,gr=(n,e,t)=>{let r;if(!t&&e&&!/[%+]/.test(e)){let i=n.indexOf(`?${e}`,8);for(i===-1&&(i=n.indexOf(`&${e}`,8));i!==-1;){const o=n.charCodeAt(i+e.length+1);if(o===61){const d=i+e.length+2,u=n.indexOf("&",d);return Wn(n.slice(d,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";i=n.indexOf(`&${e}`,i+1)}if(r=/[%+]/.test(n),!r)return}const s={};r??(r=/[%+]/.test(n));let a=n.indexOf("?",8);for(;a!==-1;){const i=n.indexOf("&",a+1);let o=n.indexOf("=",a);o>i&&i!==-1&&(o=-1);let d=n.slice(a+1,o===-1?i===-1?void 0:i:o);if(r&&(d=Wn(d)),a=i,d==="")continue;let u;o===-1?u="":(u=n.slice(o+1,i===-1?void 0:i),r&&(u=Wn(u))),t?(s[d]&&Array.isArray(s[d])||(s[d]=[]),s[d].push(u)):s[d]??(s[d]=u)}return e?s[e]:s},Bs=gr,Ws=(n,e)=>gr(n,e,!0),vn=decodeURIComponent,Hs=/^[\w!#$%&'*.^`|~+-]+$/,Fs=/^[ !#-:<-[\]-~]*$/,Ks=(n,e)=>n.trim().split(";").reduce((r,s)=>{s=s.trim();const a=s.indexOf("=");if(a===-1)return r;const i=s.substring(0,a).trim();if(!Hs.test(i))return r;let o=s.substring(a+1).trim();return o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Fs.test(o)&&(r[i]=vn(o)),r},{}),Gs=(n,e,t)=>{const r=n.req.raw.headers.get("Cookie");return r?Ks(r):{}},bn=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});y(this,"res");y(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})}},zs=(n,e)=>new Response(n,{headers:{"Content-Type":e}}).formData(),Ys=(n,e)=>async(t,r)=>{let s={};const a=t.req.header("Content-Type");switch(n){case"json":if(!a||!/^application\/([a-z-\.]+\+)?json/.test(a)){const o=`Invalid HTTP header: Content-Type=${a}`;throw new bn(400,{message:o})}try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new bn(400,{message:o})}break;case"form":{if(!a)break;if(t.req.bodyCache.formData){s=await t.req.bodyCache.formData;break}try{const o=await t.req.arrayBuffer(),d=await zs(o,a),u={};d.forEach((l,p)=>{p.endsWith("[]")?u[p]===void 0?u[p]=[l]:Array.isArray(u[p])&&u[p].push(l):u[p]=l}),s=u,t.req.bodyCache.formData=d}catch(o){let d="Malformed FormData request.";throw d+=o instanceof Error?` ${o.message}`:` ${String(o)}`,new bn(400,{message:d})}break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,d])=>d.length===1?[o,d[0]]:[o,d]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=Gs(t);break}const i=await e(s,t);if(i instanceof Response)return i;t.req.addValidatedData(n,i),await r()};const tt=(n,e,t)=>Ys(n,async(r,s)=>{const a=await e.safeParseAsync(r);if(t){const i=await t({data:r,...a},s);if(i){if(i instanceof Response)return i;if("response"in i)return i.response}}return a.success?a.data:s.json(a,400)});var Js=async(n,e=Object.create(null))=>{const{all:t=!1,dot:r=!1}=e,a=(n instanceof _r?n.raw.headers:n.headers).get("Content-Type");return a!==null&&a.startsWith("multipart/form-data")||a!==null&&a.startsWith("application/x-www-form-urlencoded")?Qs(n,{all:t,dot:r}):{}};async function Qs(n,e){const t=await n.formData();return t?Xs(t,e):{}}function Xs(n,e){const t=Object.create(null);return n.forEach((r,s)=>{e.all||s.endsWith("[]")?ea(t,s,r):t[s]=r}),e.dot&&Object.entries(t).forEach(([r,s])=>{r.includes(".")&&(ta(t,r,s),delete t[r])}),t}var ea=(n,e,t)=>{n[e]!==void 0?Array.isArray(n[e])?n[e].push(t):n[e]=[n[e],t]:n[e]=t},ta=(n,e,t)=>{let r=n;const s=e.split(".");s.forEach((a,i)=>{i===s.length-1?r[a]=t:((!r[a]||typeof r[a]!="object"||Array.isArray(r[a])||r[a]instanceof File)&&(r[a]=Object.create(null)),r=r[a])})},_r=(os=class{constructor(n,e="/",t=[[]]){y(this,"raw");Y(this,mt);Y(this,fe);y(this,"routeIndex",0);y(this,"path");y(this,"bodyCache",{});y(this,"cachedBody",n=>{const{bodyCache:e,raw:t}=this,r=e[n];if(r)return r;const s=Object.keys(e)[0];return s?e[s].then(a=>(s==="json"&&(a=JSON.stringify(a)),new Response(a)[n]())):e[n]=t[n]()});this.raw=n,this.path=e,$(this,fe,t),$(this,mt,{})}param(n){return n?this.getDecodedParam(n):this.getAllDecodedParams()}getDecodedParam(n){const e=m(this,fe)[0][this.routeIndex][1][n],t=this.getParamValue(e);return t?/\%/.test(t)?vn(t):t:void 0}getAllDecodedParams(){const n={},e=Object.keys(m(this,fe)[0][this.routeIndex][1]);for(const t of e){const r=this.getParamValue(m(this,fe)[0][this.routeIndex][1][t]);r&&typeof r=="string"&&(n[t]=/\%/.test(r)?vn(r):r)}return n}getParamValue(n){return m(this,fe)[1]?m(this,fe)[1][n]:n}query(n){return Bs(this.url,n)}queries(n){return Ws(this.url,n)}header(n){if(n)return this.raw.headers.get(n.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,r)=>{e[r]=t}),e}async parseBody(n){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await Js(this,n))}json(){return this.cachedBody("json")}text(){return this.cachedBody("text")}arrayBuffer(){return this.cachedBody("arrayBuffer")}blob(){return this.cachedBody("blob")}formData(){return this.cachedBody("formData")}addValidatedData(n,e){m(this,mt)[n]=e}valid(n){return m(this,mt)[n]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return m(this,fe)[0].map(([[,n]])=>n)}get routePath(){return m(this,fe)[0].map(([[,n]])=>n)[this.routeIndex].path}},mt=new WeakMap,fe=new WeakMap,os),na={Stringify:1,BeforeStream:2,Stream:3},yr=async(n,e,t,r,s)=>{const a=n.callbacks;return a!=null&&a.length?(s?s[0]+=n:s=[n],Promise.all(a.map(o=>o({phase:e,buffer:s,context:r}))).then(o=>Promise.all(o.filter(Boolean).map(d=>yr(d,e,!1,r,s))).then(()=>s[0]))):Promise.resolve(n)},ra="text/plain; charset=UTF-8",Hn=(n,e={})=>(Object.entries(e).forEach(([t,r])=>n.set(t,r)),n),kn=(cs=class{constructor(n,e){Y(this,dn);Y(this,un);y(this,"env",{});Y(this,Ve);y(this,"finalized",!1);y(this,"error");Y(this,Je,200);Y(this,Re);Y(this,W);Y(this,F);Y(this,me);Y(this,Se,!0);Y(this,ln);Y(this,gt);Y(this,_t);Y(this,pn);Y(this,hn);y(this,"render",(...n)=>(m(this,gt)??$(this,gt,e=>this.html(e)),m(this,gt).call(this,...n)));y(this,"setLayout",n=>$(this,ln,n));y(this,"getLayout",()=>m(this,ln));y(this,"setRenderer",n=>{$(this,gt,n)});y(this,"header",(n,e,t)=>{if(e===void 0){m(this,W)?m(this,W).delete(n):m(this,F)&&delete m(this,F)[n.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(n);return}t!=null&&t.append?(m(this,W)||($(this,Se,!1),$(this,W,new Headers(m(this,F))),$(this,F,{})),m(this,W).append(n,e)):m(this,W)?m(this,W).set(n,e):(m(this,F)??$(this,F,{}),m(this,F)[n.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(n,e):this.res.headers.set(n,e))});y(this,"status",n=>{$(this,Se,!1),$(this,Je,n)});y(this,"set",(n,e)=>{m(this,Ve)??$(this,Ve,{}),m(this,Ve)[n]=e});y(this,"get",n=>m(this,Ve)?m(this,Ve)[n]:void 0);y(this,"newResponse",(n,e,t)=>{if(m(this,Se)&&!t&&!e&&m(this,Je)===200)return new Response(n,{headers:m(this,F)});if(e&&typeof e!="number"){const s=new Headers(e.headers);m(this,W)&&m(this,W).forEach((i,o)=>{o==="set-cookie"?s.append(o,i):s.set(o,i)});const a=Hn(s,m(this,F));return new Response(n,{headers:a,status:e.status??m(this,Je)})}const r=typeof e=="number"?e:m(this,Je);m(this,F)??$(this,F,{}),m(this,W)??$(this,W,new Headers),Hn(m(this,W),m(this,F)),m(this,me)&&(m(this,me).headers.forEach((s,a)=>{var i,o;a==="set-cookie"?(i=m(this,W))==null||i.append(a,s):(o=m(this,W))==null||o.set(a,s)}),Hn(m(this,W),m(this,F))),t??(t={});for(const[s,a]of Object.entries(t))if(typeof a=="string")m(this,W).set(s,a);else{m(this,W).delete(s);for(const i of a)m(this,W).append(s,i)}return new Response(n,{status:r,headers:m(this,W)})});y(this,"body",(n,e,t)=>typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e));y(this,"text",(n,e,t)=>{if(!m(this,F)){if(m(this,Se)&&!t&&!e)return new Response(n);$(this,F,{})}return m(this,F)["content-type"]=ra,typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)});y(this,"json",(n,e,t)=>{const r=JSON.stringify(n);return m(this,F)??$(this,F,{}),m(this,F)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)});y(this,"html",(n,e,t)=>(m(this,F)??$(this,F,{}),m(this,F)["content-type"]="text/html; charset=UTF-8",typeof n=="object"&&(n instanceof Promise||(n=n.toString()),n instanceof Promise)?n.then(r=>yr(r,na.Stringify,!1,{})).then(r=>typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)):typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)));y(this,"redirect",(n,e)=>(m(this,W)??$(this,W,new Headers),m(this,W).set("Location",n),this.newResponse(null,e??302)));y(this,"notFound",()=>(m(this,_t)??$(this,_t,()=>new Response),m(this,_t).call(this,this)));$(this,dn,n),e&&($(this,Re,e.executionCtx),this.env=e.env,$(this,_t,e.notFoundHandler),$(this,hn,e.path),$(this,pn,e.matchResult))}get req(){return m(this,un)??$(this,un,new _r(m(this,dn),m(this,hn),m(this,pn))),m(this,un)}get event(){if(m(this,Re)&&"respondWith"in m(this,Re))return m(this,Re);throw Error("This context has no FetchEvent")}get executionCtx(){if(m(this,Re))return m(this,Re);throw Error("This context has no ExecutionContext")}get res(){return $(this,Se,!1),m(this,me)||$(this,me,new Response("404 Not Found",{status:404}))}set res(n){if($(this,Se,!1),m(this,me)&&n){m(this,me).headers.delete("content-type");for(const[e,t]of m(this,me).headers.entries())if(e==="set-cookie"){const r=m(this,me).headers.getSetCookie();n.headers.delete("set-cookie");for(const s of r)n.headers.append("set-cookie",s)}else n.headers.set(e,t)}$(this,me,n),this.finalized=!0}get var(){return{...m(this,Ve)}}},dn=new WeakMap,un=new WeakMap,Ve=new WeakMap,Je=new WeakMap,Re=new WeakMap,W=new WeakMap,F=new WeakMap,me=new WeakMap,Se=new WeakMap,ln=new WeakMap,gt=new WeakMap,_t=new WeakMap,pn=new WeakMap,hn=new WeakMap,cs),vr=(n,e,t)=>(r,s)=>{let a=-1;return i(0);async function i(o){if(o<=a)throw new Error("next() called multiple times");a=o;let d,u=!1,l;if(n[o]?(l=n[o][0][0],r instanceof kn&&(r.req.routeIndex=o)):l=o===n.length&&s||void 0,!l)r instanceof kn&&r.finalized===!1&&t&&(d=await t(r));else try{d=await l(r,()=>i(o+1))}catch(p){if(p instanceof Error&&r instanceof kn&&e)r.error=p,d=await e(p,r),u=!0;else throw p}return d&&(r.finalized===!1||u)&&(r.res=d),r}},G="ALL",sa="all",aa=["get","post","put","delete","options","patch"],br="Can not add a route since the matcher is already built.",kr=class extends Error{},ia=Symbol("composedHandler"),oa=n=>n.text("404 Not Found",404),wr=(n,e)=>"getResponse"in n?n.getResponse():(console.error(n),e.text("Internal Server Error",500)),xr=(ds=class{constructor(e={}){y(this,"get");y(this,"post");y(this,"put");y(this,"delete");y(this,"options");y(this,"patch");y(this,"all");y(this,"on");y(this,"use");y(this,"router");y(this,"getPath");y(this,"_basePath","/");Y(this,ge,"/");y(this,"routes",[]);y(this,"notFoundHandler",oa);y(this,"errorHandler",wr);y(this,"onError",e=>(this.errorHandler=e,this));y(this,"notFound",e=>(this.notFoundHandler=e,this));y(this,"fetch",(e,...t)=>this.dispatch(e,t[1],t[0],e.method));y(this,"request",(e,t,r,s)=>{if(e instanceof Request)return t!==void 0&&(e=new Request(e,t)),this.fetch(e,r,s);e=e.toString();const a=/^https?:\/\//.test(e)?e:`http://localhost${Be("/",e)}`,i=new Request(a,t);return this.fetch(i,r,s)});y(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(this.dispatch(e.request,e,void 0,e.request.method))})});[...aa,sa].forEach(s=>{this[s]=(a,...i)=>(typeof a=="string"?$(this,ge,a):this.addRoute(s,m(this,ge),a),i.forEach(o=>{typeof o!="string"&&this.addRoute(s,m(this,ge),o)}),this)}),this.on=(s,a,...i)=>{for(const o of[a].flat()){$(this,ge,o);for(const d of[s].flat())i.map(u=>{this.addRoute(d.toUpperCase(),m(this,ge),u)})}return this},this.use=(s,...a)=>(typeof s=="string"?$(this,ge,s):($(this,ge,"*"),a.unshift(s)),a.forEach(i=>{this.addRoute(G,m(this,ge),i)}),this);const r=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=r?e.getPath??fr:qs}clone(){const e=new xr({router:this.router,getPath:this.getPath});return e.routes=this.routes,e}route(e,t){const r=this.basePath(e);return t.routes.map(s=>{let a;t.errorHandler===wr?a=s.handler:(a=async(i,o)=>(await vr([],t.errorHandler)(i,()=>s.handler(i,o))).res,a[ia]=s.handler),r.addRoute(s.method,s.path,a)}),this}basePath(e){const t=this.clone();return t._basePath=Be(this._basePath,e),t}mount(e,t,r){let s,a;r&&(typeof r=="function"?a=r:(a=r.optionHandler,s=r.replaceRequest));const i=a?d=>{const u=a(d);return Array.isArray(u)?u:[u]}:d=>{let u;try{u=d.executionCtx}catch{}return[d.env,u]};s||(s=(()=>{const d=Be(this._basePath,e),u=d==="/"?0:d.length;return l=>{const p=new URL(l.url);return p.pathname=p.pathname.slice(u)||"/",new Request(p,l)}})());const o=async(d,u)=>{const l=await t(s(d.req.raw),...i(d));if(l)return l;await u()};return this.addRoute(G,Be(e,"*"),o),this}addRoute(e,t,r){e=e.toUpperCase(),t=Be(this._basePath,t);const s={path:t,method:e,handler:r};this.router.add(e,t,[r,s]),this.routes.push(s)}matchRoute(e,t){return this.router.match(e,t)}handleError(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}dispatch(e,t,r,s){if(s==="HEAD")return(async()=>new Response(null,await this.dispatch(e,t,r,"GET")))();const a=this.getPath(e,{env:r}),i=this.matchRoute(s,a),o=new kn(e,{path:a,matchResult:i,env:r,executionCtx:t,notFoundHandler:this.notFoundHandler});if(i[0].length===1){let u;try{u=i[0][0][0][0](o,async()=>{o.res=await this.notFoundHandler(o)})}catch(l){return this.handleError(l,o)}return u instanceof Promise?u.then(l=>l||(o.finalized?o.res:this.notFoundHandler(o))).catch(l=>this.handleError(l,o)):u??this.notFoundHandler(o)}const d=vr(i[0],this.errorHandler,this.notFoundHandler);return(async()=>{try{const u=await d(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.handleError(u,o)}})()}},ge=new WeakMap,ds),wn="[^/]+",xt=".*",Ot="(?:|/.*)",Tt=Symbol(),ca=new Set(".\\+*[^]$()");function da(n,e){return n.length===1?e.length===1?n<e?-1:1:-1:e.length===1||n===xt||n===Ot?1:e===xt||e===Ot?-1:n===wn?1:e===wn?-1:n.length===e.length?n<e?-1:1:e.length-n.length}var Fn=class{constructor(){y(this,"index");y(this,"varIndex");y(this,"children",Object.create(null))}insert(e,t,r,s,a){if(e.length===0){if(this.index!==void 0)throw Tt;if(a)return;this.index=t;return}const[i,...o]=e,d=i==="*"?o.length===0?["","",xt]:["","",wn]:i==="/*"?["","",Ot]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(d){const l=d[1];let p=d[2]||wn;if(l&&d[2]&&(p=p.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(p)))throw Tt;if(u=this.children[p],!u){if(Object.keys(this.children).some(C=>C!==xt&&C!==Ot))throw Tt;if(a)return;u=this.children[p]=new Fn,l!==""&&(u.varIndex=s.varIndex++)}!a&&l!==""&&r.push([l,u.varIndex])}else if(u=this.children[i],!u){if(Object.keys(this.children).some(l=>l.length>1&&l!==xt&&l!==Ot))throw Tt;if(a)return;u=this.children[i]=new Fn}u.insert(o,t,r,s,a)}buildRegExpStr(){const t=Object.keys(this.children).sort(da).map(r=>{const s=this.children[r];return(typeof s.varIndex=="number"?`(${r})@${s.varIndex}`:ca.has(r)?`\\${r}`:r)+s.buildRegExpStr()});return typeof this.index=="number"&&t.unshift(`#${this.index}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},ua=class{constructor(){y(this,"context",{varIndex:0});y(this,"root",new Fn)}insert(n,e,t){const r=[],s=[];for(let i=0;;){let o=!1;if(n=n.replace(/\{[^}]+\}/g,d=>{const u=`@\\${i}`;return s[i]=[u,d],i++,o=!0,u}),!o)break}const a=n.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=s.length-1;i>=0;i--){const[o]=s[i];for(let d=a.length-1;d>=0;d--)if(a[d].indexOf(o)!==-1){a[d]=a[d].replace(o,s[i][1]);break}}return this.root.insert(a,e,r,this.context,t),r}buildRegExp(){let n=this.root.buildRegExpStr();if(n==="")return[/^$/,[],[]];let e=0;const t=[],r=[];return n=n.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,a,i)=>typeof a<"u"?(t[++e]=Number(a),"$()"):(typeof i<"u"&&(r[Number(i)]=++e),"")),[new RegExp(`^${n}`),t,r]}},Or=[],la=[/^$/,[],Object.create(null)],xn=Object.create(null);function Tr(n){return xn[n]??(xn[n]=new RegExp(n==="*"?"":`^${n.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function pa(){xn=Object.create(null)}function ha(n){var u;const e=new ua,t=[];if(n.length===0)return la;const r=n.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,p],[C,D])=>l?1:C?-1:p.length-D.length),s=Object.create(null);for(let l=0,p=-1,C=r.length;l<C;l++){const[D,P,R]=r[l];D?s[P]=[R.map(([K])=>[K,Object.create(null)]),Or]:p++;let H;try{H=e.insert(P,p,D)}catch(K){throw K===Tt?new kr(P):K}D||(t[p]=R.map(([K,se])=>{const ae=Object.create(null);for(se-=1;se>=0;se--){const[qe,oe]=H[se];ae[qe]=oe}return[K,ae]}))}const[a,i,o]=e.buildRegExp();for(let l=0,p=t.length;l<p;l++)for(let C=0,D=t[l].length;C<D;C++){const P=(u=t[l][C])==null?void 0:u[1];if(!P)continue;const R=Object.keys(P);for(let H=0,K=R.length;H<K;H++)P[R[H]]=o[P[R[H]]]}const d=[];for(const l in i)d[l]=t[i[l]];return[a,d,s]}function nt(n,e){if(n){for(const t of Object.keys(n).sort((r,s)=>s.length-r.length))if(Tr(t).test(e))return[...n[t]]}}var fa=class{constructor(){y(this,"name","RegExpRouter");y(this,"middleware");y(this,"routes");this.middleware={[G]:Object.create(null)},this.routes={[G]:Object.create(null)}}add(n,e,t){var o;const{middleware:r,routes:s}=this;if(!r||!s)throw new Error(br);r[n]||[r,s].forEach(d=>{d[n]=Object.create(null),Object.keys(d[G]).forEach(u=>{d[n][u]=[...d[G][u]]})}),e==="/*"&&(e="*");const a=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const d=Tr(e);n===G?Object.keys(r).forEach(u=>{var l;(l=r[u])[e]||(l[e]=nt(r[u],e)||nt(r[G],e)||[])}):(o=r[n])[e]||(o[e]=nt(r[n],e)||nt(r[G],e)||[]),Object.keys(r).forEach(u=>{(n===G||n===u)&&Object.keys(r[u]).forEach(l=>{d.test(l)&&r[u][l].push([t,a])})}),Object.keys(s).forEach(u=>{(n===G||n===u)&&Object.keys(s[u]).forEach(l=>d.test(l)&&s[u][l].push([t,a]))});return}const i=mr(e)||[e];for(let d=0,u=i.length;d<u;d++){const l=i[d];Object.keys(s).forEach(p=>{var C;(n===G||n===p)&&((C=s[p])[l]||(C[l]=[...nt(r[p],l)||nt(r[G],l)||[]]),s[p][l].push([t,a-u+d+1]))})}}match(n,e){pa();const t=this.buildAllMatchers();return this.match=(r,s)=>{const a=t[r]||t[G],i=a[2][s];if(i)return i;const o=s.match(a[0]);if(!o)return[[],Or];const d=o.indexOf("",1);return[a[1][d],o]},this.match(n,e)}buildAllMatchers(){const n=Object.create(null);return[...Object.keys(this.routes),...Object.keys(this.middleware)].forEach(e=>{n[e]||(n[e]=this.buildMatcher(e))}),this.middleware=this.routes=void 0,n}buildMatcher(n){const e=[];let t=n===G;return[this.middleware,this.routes].forEach(r=>{const s=r[n]?Object.keys(r[n]).map(a=>[a,r[n][a]]):[];s.length!==0?(t||(t=!0),e.push(...s)):n!==G&&e.push(...Object.keys(r[G]).map(a=>[a,r[G][a]]))}),t?ha(e):null}},ma=class{constructor(n){y(this,"name","SmartRouter");y(this,"routers",[]);y(this,"routes",[]);Object.assign(this,n)}add(n,e,t){if(!this.routes)throw new Error(br);this.routes.push([n,e,t])}match(n,e){if(!this.routes)throw new Error("Fatal error");const{routers:t,routes:r}=this,s=t.length;let a=0,i;for(;a<s;a++){const o=t[a];try{r.forEach(d=>{o.add(...d)}),i=o.match(n,e)}catch(d){if(d instanceof kr)continue;throw d}this.match=o.match.bind(o),this.routers=[o],this.routes=void 0;break}if(a===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.routes||this.routers.length!==1)throw new Error("No active router has been determined yet.");return this.routers[0]}},jr=class{constructor(n,e,t){y(this,"methods");y(this,"children");y(this,"patterns");y(this,"order",0);y(this,"name");y(this,"params",Object.create(null));if(this.children=t||Object.create(null),this.methods=[],this.name="",n&&e){const r=Object.create(null);r[n]={handler:e,possibleKeys:[],score:0,name:this.name},this.methods=[r]}this.patterns=[]}insert(n,e,t){this.name=`${n} ${e}`,this.order=++this.order;let r=this;const s=Ds(e),a=[];for(let d=0,u=s.length;d<u;d++){const l=s[d];if(Object.keys(r.children).includes(l)){r=r.children[l];const C=hr(l);C&&a.push(C[1]);continue}r.children[l]=new jr;const p=hr(l);p&&(r.patterns.push(p),a.push(p[1])),r=r.children[l]}r.methods.length||(r.methods=[]);const i=Object.create(null),o={handler:t,possibleKeys:a.filter((d,u,l)=>l.indexOf(d)===u),name:this.name,score:this.order};return i[n]=o,r.methods.push(i),r}gHSets(n,e,t,r){const s=[];for(let a=0,i=n.methods.length;a<i;a++){const o=n.methods[a],d=o[e]||o[G],u=Object.create(null);d!==void 0&&(d.params=Object.create(null),d.possibleKeys.forEach(l=>{const p=u[d.name];d.params[l]=r[l]&&!p?r[l]:t[l]??r[l],u[d.name]=!0}),s.push(d))}return s}search(n,e){const t=[];this.params=Object.create(null);let s=[this];const a=pr(e);for(let o=0,d=a.length;o<d;o++){const u=a[o],l=o===d-1,p=[];for(let C=0,D=s.length;C<D;C++){const P=s[C],R=P.children[u];R&&(R.params=P.params,l===!0?(R.children["*"]&&t.push(...this.gHSets(R.children["*"],n,P.params,Object.create(null))),t.push(...this.gHSets(R,n,P.params,Object.create(null)))):p.push(R));for(let H=0,K=P.patterns.length;H<K;H++){const se=P.patterns[H],ae={...P.params};if(se==="*"){const _e=P.children["*"];_e&&(t.push(...this.gHSets(_e,n,P.params,Object.create(null))),p.push(_e));continue}if(u==="")continue;const[qe,oe,ie]=se,te=P.children[qe],Oe=a.slice(o).join("/");if(ie instanceof RegExp&&ie.test(Oe)){ae[oe]=Oe,t.push(...this.gHSets(te,n,P.params,ae));continue}(ie===!0||ie instanceof RegExp&&ie.test(u))&&typeof qe=="string"&&(ae[oe]=u,l===!0?(t.push(...this.gHSets(te,n,ae,P.params)),te.children["*"]&&t.push(...this.gHSets(te.children["*"],n,ae,P.params))):(te.params=ae,p.push(te)))}}s=p}return[t.sort((o,d)=>o.score-d.score).map(({handler:o,params:d})=>[o,d])]}},ga=class{constructor(){y(this,"name","TrieRouter");y(this,"node");this.node=new jr}add(n,e,t){const r=mr(e);if(r){for(const s of r)this.node.insert(n,s,t);return}this.node.insert(n,e,t)}match(n,e){return this.node.search(n,e)}},_a=class extends xr{constructor(n={}){super(n),this.router=n.router??new ma({routers:[new fa,new ga]})}},A;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(A||(A={}));var Kn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Kn||(Kn={}));const v=A.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ze=n=>{switch(typeof n){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(n)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(n)?v.array:n===null?v.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?v.promise:typeof Map<"u"&&n instanceof Map?v.map:typeof Set<"u"&&n instanceof Set?v.set:typeof Date<"u"&&n instanceof Date?v.date:v.object;default:return v.unknown}},h=A.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"]),ya=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class ne extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof ne))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,A.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}ne.create=n=>new ne(n);const rt=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===v.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,A.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${A.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${A.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${A.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:A.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,A.assertNever(n)}return{message:t}};let Er=rt;function va(n){Er=n}function On(){return Er}const Tn=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},ba=[];function g(n,e){const t=On(),r=Tn({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===rt?void 0:rt].filter(s=>!!s)});n.common.issues.push(r)}class J{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return j;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return J.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return j;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const j=Object.freeze({status:"aborted"}),st=n=>({status:"dirty",value:n}),X=n=>({status:"valid",value:n}),Gn=n=>n.status==="aborted",zn=n=>n.status==="dirty",jt=n=>n.status==="valid",Et=n=>typeof Promise<"u"&&n instanceof Promise;function jn(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Rr(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var w;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var Rt,St;class ye{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Sr=(n,e)=>{if(jt(e))return{success:!0,data:e.value};if(!n.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 ne(n.common.issues);return this._error=t,this._error}}};function S(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var d,u;const{message:l}=n;return i.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:(d=l??r)!==null&&d!==void 0?d:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class I{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 Ze(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new J,ctx:{common:e.parent.common,data:e.data,parsedType:Ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Et(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ze(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Sr(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={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:Ze(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Et(s)?s:Promise.resolve(s));return Sr(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new ue({schema:this,typeName:O.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return be.create(this,this._def)}nullable(){return Pe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return de.create(this,this._def)}promise(){return ct.create(this,this._def)}or(e){return Nt.create([this,e],this._def)}and(e){return Pt.create(this,e,this._def)}transform(e){return new ue({...S(this._def),schema:this,typeName:O.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Lt({...S(this._def),innerType:this,defaultValue:t,typeName:O.ZodDefault})}brand(){return new Qn({typeName:O.ZodBranded,type:this,...S(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ut({...S(this._def),innerType:this,catchValue:t,typeName:O.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Vt.create(this,e)}readonly(){return qt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ka=/^c[^\s-]{8,}$/i,wa=/^[0-9a-z]+$/,xa=/^[0-9A-HJKMNP-TV-Z]{26}$/,Oa=/^[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,Ta=/^[a-z0-9_-]{21}$/i,ja=/^[-+]?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)?)??$/,Ea=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ra="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Yn;const Sa=/^(?:(?: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])$/,Za=/^(([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})))$/,Ca=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Zr="((\\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])))",Ia=new RegExp(`^${Zr}$`);function Cr(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Na(n){return new RegExp(`^${Cr(n)}$`)}function Ir(n){let e=`${Zr}T${Cr(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Pa(n,e){return!!((e==="v4"||!e)&&Sa.test(n)||(e==="v6"||!e)&&Za.test(n))}class ce extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_type,expected:v.string,received:a.parsedType}),j}const r=new J;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?g(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&g(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Ea.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"email",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Yn||(Yn=new RegExp(Ra,"u")),Yn.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"emoji",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Oa.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"uuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Ta.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"nanoid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")ka.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")wa.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid2",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")xa.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ulid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),g(s,{validation:"url",code:h.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"regex",code:h.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Ir(a).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?Ia.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Na(a).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?ja.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"duration",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Pa(e.data,a.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ip",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Ca.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64",code:h.invalid_string,message:a.message}),r.dirty()):A.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...w.errToObj(r)})}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}datetime(e){var t,r;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:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...w.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,...w.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...w.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new ce({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ce({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ce({...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}}ce.create=n=>{var e;return new ce({checks:[],typeName:O.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};function Aa(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Ce extends I{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)!==v.number){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_type,expected:v.number,received:a.parsedType}),j}let r;const s=new J;for(const a of this._def.checks)a.kind==="int"?A.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Aa(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_finite,message:a.message}),s.dirty()):A.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new Ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new Ce({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.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"&&A.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ce.create=n=>new Ce({checks:[],typeName:O.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Ie extends I{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)!==v.bigint){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_type,expected:v.bigint,received:a.parsedType}),j}let r;const s=new J;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):A.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new Ie({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new Ie({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.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}}Ie.create=n=>{var e;return new Ie({checks:[],typeName:O.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};class Zt extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.boolean,received:r.parsedType}),j}return X(e.data)}}Zt.create=n=>new Zt({typeName:O.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class We extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_type,expected:v.date,received:a.parsedType}),j}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return g(a,{code:h.invalid_date}),j}const r=new J;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):A.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new We({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.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}}We.create=n=>new We({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:O.ZodDate,...S(n)});class En extends I{_parse(e){if(this._getType(e)!==v.symbol){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.symbol,received:r.parsedType}),j}return X(e.data)}}En.create=n=>new En({typeName:O.ZodSymbol,...S(n)});class Ct extends I{_parse(e){if(this._getType(e)!==v.undefined){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.undefined,received:r.parsedType}),j}return X(e.data)}}Ct.create=n=>new Ct({typeName:O.ZodUndefined,...S(n)});class It extends I{_parse(e){if(this._getType(e)!==v.null){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.null,received:r.parsedType}),j}return X(e.data)}}It.create=n=>new It({typeName:O.ZodNull,...S(n)});class at extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return X(e.data)}}at.create=n=>new at({typeName:O.ZodAny,...S(n)});class He extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return X(e.data)}}He.create=n=>new He({typeName:O.ZodUnknown,...S(n)});class Te extends I{_parse(e){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:v.never,received:t.parsedType}),j}}Te.create=n=>new Te({typeName:O.ZodNever,...S(n)});class Rn extends I{_parse(e){if(this._getType(e)!==v.undefined){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.void,received:r.parsedType}),j}return X(e.data)}}Rn.create=n=>new Rn({typeName:O.ZodVoid,...S(n)});class de extends I{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==v.array)return g(t,{code:h.invalid_type,expected:v.array,received:t.parsedType}),j;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(g(t,{code:i?h.too_big:h.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(g(t,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(g(t,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new ye(t,i,t.path,o)))).then(i=>J.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ye(t,i,t.path,o)));return J.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new de({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new de({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new de({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}de.create=(n,e)=>new de({type:n,minLength:null,maxLength:null,exactLength:null,typeName:O.ZodArray,...S(e)});function it(n){if(n instanceof q){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=be.create(it(r))}return new q({...n._def,shape:()=>e})}else return n instanceof de?new de({...n._def,type:it(n.element)}):n instanceof be?be.create(it(n.unwrap())):n instanceof Pe?Pe.create(it(n.unwrap())):n instanceof ve?ve.create(n.items.map(e=>it(e))):n}class q extends I{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=A.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==v.object){const u=this._getOrReturnCtx(e);return g(u,{code:h.invalid_type,expected:v.object,received:u.parsedType}),j}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Te&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const d=[];for(const u of i){const l=a[u],p=s.data[u];d.push({key:{status:"valid",value:u},value:l._parse(new ye(s,p,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Te){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)d.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(g(s,{code:h.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of o){const p=s.data[l];d.push({key:{status:"valid",value:l},value:u._parse(new ye(s,p,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of d){const p=await l.key,C=await l.value;u.push({key:p,value:C,alwaysSet:l.alwaysSet})}return u}).then(u=>J.mergeObjectSync(r,u)):J.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new q({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=w.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new q({...this._def,unknownKeys:"strip"})}passthrough(){return new q({...this._def,unknownKeys:"passthrough"})}extend(e){return new q({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new q({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:O.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new q({...this._def,catchall:e})}pick(e){const t={};return A.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new q({...this._def,shape:()=>t})}omit(e){const t={};return A.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new q({...this._def,shape:()=>t})}deepPartial(){return it(this)}partial(e){const t={};return A.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new q({...this._def,shape:()=>t})}required(e){const t={};return A.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof be;)a=a._def.innerType;t[r]=a}}),new q({...this._def,shape:()=>t})}keyof(){return Nr(A.objectKeys(this.shape))}}q.create=(n,e)=>new q({shape:()=>n,unknownKeys:"strip",catchall:Te.create(),typeName:O.ZodObject,...S(e)}),q.strictCreate=(n,e)=>new q({shape:()=>n,unknownKeys:"strict",catchall:Te.create(),typeName:O.ZodObject,...S(e)}),q.lazycreate=(n,e)=>new q({shape:n,unknownKeys:"strip",catchall:Te.create(),typeName:O.ZodObject,...S(e)});class Nt extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new ne(o.ctx.common.issues));return g(t,{code:h.invalid_union,unionErrors:i}),j}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new ne(d));return g(t,{code:h.invalid_union,unionErrors:o}),j}}get options(){return this._def.options}}Nt.create=(n,e)=>new Nt({options:n,typeName:O.ZodUnion,...S(e)});const je=n=>n instanceof Mt?je(n.schema):n instanceof ue?je(n.innerType()):n instanceof $t?[n.value]:n instanceof Ne?n.options:n instanceof Dt?A.objectValues(n.enum):n instanceof Lt?je(n._def.innerType):n instanceof Ct?[void 0]:n instanceof It?[null]:n instanceof be?[void 0,...je(n.unwrap())]:n instanceof Pe?[null,...je(n.unwrap())]:n instanceof Qn||n instanceof qt?je(n.unwrap()):n instanceof Ut?je(n._def.innerType):[];class Sn extends I{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.object)return g(t,{code:h.invalid_type,expected:v.object,received:t.parsedType}),j;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(g(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),j)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=je(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Sn({typeName:O.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...S(r)})}}function Jn(n,e){const t=Ze(n),r=Ze(e);if(n===e)return{valid:!0,data:n};if(t===v.object&&r===v.object){const s=A.objectKeys(e),a=A.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i={...n,...e};for(const o of a){const d=Jn(n[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===v.array&&r===v.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],d=Jn(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===v.date&&r===v.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Pt extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(Gn(a)||Gn(i))return j;const o=Jn(a.value,i.value);return o.valid?((zn(a)||zn(i))&&t.dirty(),{status:t.value,value:o.data}):(g(r,{code:h.invalid_intersection_types}),j)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Pt.create=(n,e,t)=>new Pt({left:n,right:e,typeName:O.ZodIntersection,...S(t)});class ve extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.array)return g(r,{code:h.invalid_type,expected:v.array,received:r.parsedType}),j;if(r.data.length<this._def.items.length)return g(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new ye(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>J.mergeArray(t,i)):J.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ve({...this._def,rest:e})}}ve.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ve({items:n,typeName:O.ZodTuple,rest:null,...S(e)})};class At extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.object)return g(r,{code:h.invalid_type,expected:v.object,received:r.parsedType}),j;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ye(r,o,r.path,o)),value:i._parse(new ye(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?J.mergeObjectAsync(t,s):J.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof I?new At({keyType:e,valueType:t,typeName:O.ZodRecord,...S(r)}):new At({keyType:ce.create(),valueType:e,typeName:O.ZodRecord,...S(t)})}}class Zn extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.map)return g(r,{code:h.invalid_type,expected:v.map,received:r.parsedType}),j;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,d],u)=>({key:s._parse(new ye(r,o,r.path,[u,"key"])),value:a._parse(new ye(r,d,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return j;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return j;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}Zn.create=(n,e,t)=>new Zn({valueType:e,keyType:n,typeName:O.ZodMap,...S(t)});class Fe extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.set)return g(r,{code:h.invalid_type,expected:v.set,received:r.parsedType}),j;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(g(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(g(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const u=new Set;for(const l of d){if(l.status==="aborted")return j;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((d,u)=>a._parse(new ye(r,d,r.path,u)));return r.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new Fe({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Fe({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Fe.create=(n,e)=>new Fe({valueType:n,minSize:null,maxSize:null,typeName:O.ZodSet,...S(e)});class ot extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return g(t,{code:h.invalid_type,expected:v.function,received:t.parsedType}),j;function r(o,d){return Tn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,On(),rt].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:d}})}function s(o,d){return Tn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,On(),rt].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ct){const o=this;return X(async function(...d){const u=new ne([]),l=await o._def.args.parseAsync(d,a).catch(D=>{throw u.addIssue(r(d,D)),u}),p=await Reflect.apply(i,this,l);return await o._def.returns._def.type.parseAsync(p,a).catch(D=>{throw u.addIssue(s(p,D)),u})})}else{const o=this;return X(function(...d){const u=o._def.args.safeParse(d,a);if(!u.success)throw new ne([r(d,u.error)]);const l=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(l,a);if(!p.success)throw new ne([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ot({...this._def,args:ve.create(e).rest(He.create())})}returns(e){return new ot({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new ot({args:e||ve.create([]).rest(He.create()),returns:t||He.create(),typeName:O.ZodFunction,...S(r)})}}class Mt extends I{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})}}Mt.create=(n,e)=>new Mt({getter:n,typeName:O.ZodLazy,...S(e)});class $t extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return g(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:e.data}}get value(){return this._def.value}}$t.create=(n,e)=>new $t({value:n,typeName:O.ZodLiteral,...S(e)});function Nr(n,e){return new Ne({values:n,typeName:O.ZodEnum,...S(e)})}class Ne extends I{constructor(){super(...arguments),Rt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return g(t,{expected:A.joinValues(r),received:t.parsedType,code:h.invalid_type}),j}if(jn(this,Rt)||Rr(this,Rt,new Set(this._def.values)),!jn(this,Rt).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return g(t,{received:t.data,code:h.invalid_enum_value,options:r}),j}return X(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 Ne.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ne.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Rt=new WeakMap,Ne.create=Nr;class Dt extends I{constructor(){super(...arguments),St.set(this,void 0)}_parse(e){const t=A.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==v.string&&r.parsedType!==v.number){const s=A.objectValues(t);return g(r,{expected:A.joinValues(s),received:r.parsedType,code:h.invalid_type}),j}if(jn(this,St)||Rr(this,St,new Set(A.getValidEnumValues(this._def.values))),!jn(this,St).has(e.data)){const s=A.objectValues(t);return g(r,{received:r.data,code:h.invalid_enum_value,options:s}),j}return X(e.data)}get enum(){return this._def.values}}St=new WeakMap,Dt.create=(n,e)=>new Dt({values:n,typeName:O.ZodNativeEnum,...S(e)});class ct extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return g(t,{code:h.invalid_type,expected:v.promise,received:t.parsedType}),j;const r=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return X(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ct.create=(n,e)=>new ct({type:n,typeName:O.ZodPromise,...S(e)});class ue extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===O.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{g(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return j;const d=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return d.status==="aborted"?j:d.status==="dirty"||t.value==="dirty"?st(d.value):d});{if(t.value==="aborted")return j;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?j:o.status==="dirty"||t.value==="dirty"?st(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?j:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?j:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!jt(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>jt(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);A.assertNever(s)}}ue.create=(n,e,t)=>new ue({schema:n,typeName:O.ZodEffects,effect:e,...S(t)}),ue.createWithPreprocess=(n,e,t)=>new ue({schema:e,effect:{type:"preprocess",transform:n},typeName:O.ZodEffects,...S(t)});class be extends I{_parse(e){return this._getType(e)===v.undefined?X(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}be.create=(n,e)=>new be({innerType:n,typeName:O.ZodOptional,...S(e)});class Pe extends I{_parse(e){return this._getType(e)===v.null?X(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Pe.create=(n,e)=>new Pe({innerType:n,typeName:O.ZodNullable,...S(e)});class Lt extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===v.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Lt.create=(n,e)=>new Lt({innerType:n,typeName:O.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class Ut extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Et(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ne(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ne(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Ut.create=(n,e)=>new Ut({innerType:n,typeName:O.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class Cn extends I{_parse(e){if(this._getType(e)!==v.nan){const r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:v.nan,received:r.parsedType}),j}return{status:"valid",value:e.data}}}Cn.create=n=>new Cn({typeName:O.ZodNaN,...S(n)});const Ma=Symbol("zod_brand");class Qn extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Vt extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?j:a.status==="dirty"?(t.dirty(),st(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?j:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new Vt({in:e,out:t,typeName:O.ZodPipeline})}}class qt extends I{_parse(e){const t=this._def.innerType._parse(e),r=s=>(jt(s)&&(s.value=Object.freeze(s.value)),s);return Et(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}qt.create=(n,e)=>new qt({innerType:n,typeName:O.ZodReadonly,...S(e)});function Pr(n,e={},t){return n?at.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:d})}}):at.create()}const $a={object:q.lazycreate};var O;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(O||(O={}));const Da=(n,e={message:`Input not instance of ${n.name}`})=>Pr(t=>t instanceof n,e),Ar=ce.create,Mr=Ce.create,La=Cn.create,Ua=Ie.create,$r=Zt.create,Va=We.create,qa=En.create,Ba=Ct.create,Wa=It.create,Ha=at.create,Fa=He.create,Ka=Te.create,Ga=Rn.create,za=de.create,Ya=q.create,Ja=q.strictCreate,Qa=Nt.create,Xa=Sn.create,ei=Pt.create,ti=ve.create,ni=At.create,ri=Zn.create,si=Fe.create,ai=ot.create,ii=Mt.create,oi=$t.create,ci=Ne.create,di=Dt.create,ui=ct.create,Dr=ue.create,li=be.create,pi=Pe.create,hi=ue.createWithPreprocess,fi=Vt.create;var z=Object.freeze({__proto__:null,defaultErrorMap:rt,setErrorMap:va,getErrorMap:On,makeIssue:Tn,EMPTY_PATH:ba,addIssueToContext:g,ParseStatus:J,INVALID:j,DIRTY:st,OK:X,isAborted:Gn,isDirty:zn,isValid:jt,isAsync:Et,get util(){return A},get objectUtil(){return Kn},ZodParsedType:v,getParsedType:Ze,ZodType:I,datetimeRegex:Ir,ZodString:ce,ZodNumber:Ce,ZodBigInt:Ie,ZodBoolean:Zt,ZodDate:We,ZodSymbol:En,ZodUndefined:Ct,ZodNull:It,ZodAny:at,ZodUnknown:He,ZodNever:Te,ZodVoid:Rn,ZodArray:de,ZodObject:q,ZodUnion:Nt,ZodDiscriminatedUnion:Sn,ZodIntersection:Pt,ZodTuple:ve,ZodRecord:At,ZodMap:Zn,ZodSet:Fe,ZodFunction:ot,ZodLazy:Mt,ZodLiteral:$t,ZodEnum:Ne,ZodNativeEnum:Dt,ZodPromise:ct,ZodEffects:ue,ZodTransformer:ue,ZodOptional:be,ZodNullable:Pe,ZodDefault:Lt,ZodCatch:Ut,ZodNaN:Cn,BRAND:Ma,ZodBranded:Qn,ZodPipeline:Vt,ZodReadonly:qt,custom:Pr,Schema:I,ZodSchema:I,late:$a,get ZodFirstPartyTypeKind(){return O},coerce:{string:n=>ce.create({...n,coerce:!0}),number:n=>Ce.create({...n,coerce:!0}),boolean:n=>Zt.create({...n,coerce:!0}),bigint:n=>Ie.create({...n,coerce:!0}),date:n=>We.create({...n,coerce:!0})},any:Ha,array:za,bigint:Ua,boolean:$r,date:Va,discriminatedUnion:Xa,effect:Dr,enum:ci,function:ai,instanceof:Da,intersection:ei,lazy:ii,literal:oi,map:ri,nan:La,nativeEnum:di,never:Ka,null:Wa,nullable:pi,number:Mr,object:Ya,oboolean:()=>$r().optional(),onumber:()=>Mr().optional(),optional:li,ostring:()=>Ar().optional(),pipeline:fi,preprocess:hi,promise:ui,record:ni,set:si,strictObject:Ja,string:Ar,symbol:qa,transformer:Dr,tuple:ti,undefined:Ba,union:Qa,unknown:Fa,void:Ga,NEVER:j,ZodIssueCode:h,quotelessJson:ya,ZodError:ne}),Bt=class cr extends _a{constructor(t){super(t);y(this,"openAPIRegistry");y(this,"defaultHook");y(this,"openapi",({middleware:t,...r},s,a=this.defaultHook)=>{var u,l,p,C,D,P;this.openAPIRegistry.registerPath(r);const i=[];if((u=r.request)!=null&&u.query){const R=tt("query",r.request.query,a);i.push(R)}if((l=r.request)!=null&&l.params){const R=tt("param",r.request.params,a);i.push(R)}if((p=r.request)!=null&&p.headers){const R=tt("header",r.request.headers,a);i.push(R)}if((C=r.request)!=null&&C.cookies){const R=tt("cookie",r.request.cookies,a);i.push(R)}const o=(P=(D=r.request)==null?void 0:D.body)==null?void 0:P.content;if(o)for(const R of Object.keys(o)){if(!o[R])continue;const H=o[R].schema;if(H instanceof I){if(R.startsWith("application/json")){const K=tt("json",H,a);i.push(K)}if(R.startsWith("multipart/form-data")||R.startsWith("application/x-www-form-urlencoded")){const K=tt("form",H,a);i.push(K)}}}const d=t?Array.isArray(t)?t:[t]:[];return this.on([r.method],r.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...d,...i,s),this});y(this,"getOpenAPIDocument",t=>new Ps(this.openAPIRegistry.definitions).generateDocument(t));y(this,"getOpenAPI31Document",t=>new $s(this.openAPIRegistry.definitions).generateDocument(t));y(this,"doc",(t,r)=>this.get(t,s=>{const a=typeof r=="function"?r(s):r;try{const i=this.getOpenAPIDocument(a);return s.json(i)}catch(i){return s.json(i,500)}}));y(this,"doc31",(t,r)=>this.get(t,s=>{const a=typeof r=="function"?r(s):r;try{const i=this.getOpenAPI31Document(a);return s.json(i)}catch(i){return s.json(i,500)}}));this.openAPIRegistry=new gs,this.defaultHook=t==null?void 0:t.defaultHook}route(t,r){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,r),r instanceof cr?(r.openAPIRegistry.definitions.forEach(a=>{switch(a.type){case"component":return this.openAPIRegistry.registerComponent(a.componentType,a.name,a.component);case"route":return this.openAPIRegistry.registerPath({...a.route,path:Be(s,a.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...a.webhook,path:Be(s,a.webhook.path)});case"schema":return this.openAPIRegistry.register(a.schema._def.openapi._internal.refId,a.schema);case"parameter":return this.openAPIRegistry.registerParameter(a.schema._def.openapi._internal.refId,a.schema);default:{const i=a;throw new Error(`Unknown registry type: ${i}`)}}}),this):this}basePath(t){return new cr({...super.basePath(t),defaultHook:this.defaultHook})}},Ke=n=>{const e={...n,getRoutingPath(){return n.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};ps(z);function mi(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function gi(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function Wt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function _i(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var i,o,d,u,l,p;const C=typeof s=="string"?a:s,D=C??{},{param:P}=D,R=mi(D,["param"]),H=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),K=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),R),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||P?{param:Object.assign(Object.assign({},(p=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||p===void 0?void 0:p.param),P)}:void 0),se=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(H).length>0?{_internal:H}:void 0),Object.keys(K).length>0?{metadata:K}:void 0)}));if(gi(this,"ZodObject")){const ae=this.extend;se.extend=function(...qe){var oe,ie,te,Oe,_e,Qe;const Xe=ae.apply(this,qe);return Xe._def.openapi={_internal:{extendedFrom:!((ie=(oe=this._def.openapi)===null||oe===void 0?void 0:oe._internal)===null||ie===void 0)&&ie.refId?{refId:(Oe=(te=this._def.openapi)===null||te===void 0?void 0:te._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(_e=this._def.openapi)===null||_e===void 0?void 0:_e._internal.extendedFrom},metadata:(Qe=Xe._def.openapi)===null||Qe===void 0?void 0:Qe.metadata},Xe}}return se},Wt(n,"optional"),Wt(n,"nullable"),Wt(n,"default"),Wt(n,"transform"),Wt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var u,l;d._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var M;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(M||(M={}));var Xn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Xn||(Xn={}));const b=M.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ae=n=>{switch(typeof n){case"undefined":return b.undefined;case"string":return b.string;case"number":return isNaN(n)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(n)?b.array:n===null?b.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?b.promise:typeof Map<"u"&&n instanceof Map?b.map:typeof Set<"u"&&n instanceof Set?b.set:typeof Date<"u"&&n instanceof Date?b.date:b.object;default:return b.unknown}},f=M.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"]),yi=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class re extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof re))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,M.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}re.create=n=>new re(n);const dt=(n,e)=>{let t;switch(n.code){case f.invalid_type:n.received===b.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,M.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${M.joinValues(n.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${M.joinValues(n.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${M.joinValues(n.options)}, received '${n.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:M.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case f.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case f.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,M.assertNever(n)}return{message:t}};let Lr=dt;function vi(n){Lr=n}function In(){return Lr}const Nn=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},bi=[];function _(n,e){const t=In(),r=Nn({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===dt?void 0:dt].filter(s=>!!s)});n.common.issues.push(r)}class Q{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return E;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return Q.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return E;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const E=Object.freeze({status:"aborted"}),Pn=n=>({status:"dirty",value:n}),ee=n=>({status:"valid",value:n}),er=n=>n.status==="aborted",tr=n=>n.status==="dirty",Ht=n=>n.status==="valid",Ft=n=>typeof Promise<"u"&&n instanceof Promise;function An(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Ur(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var x;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(x||(x={}));var Kt,Gt;class ke{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Vr=(n,e)=>{if(Ht(e))return{success:!0,data:e.value};if(!n.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 re(n.common.issues);return this._error=t,this._error}}};function Z(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>{var o,d;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u??i.defaultError}:typeof i.data>"u"?{message:(o=u??r)!==null&&o!==void 0?o:i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:(d=u??t)!==null&&d!==void 0?d:i.defaultError}},description:s}}class N{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Q,ctx:{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ft(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Vr(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Ft(s)?s:Promise.resolve(s));return Vr(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:f.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new he({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xe.create(this,this._def)}nullable(){return Ue.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pe.create(this,this._def)}promise(){return ht.create(this,this._def)}or(e){return Qt.create([this,e],this._def)}and(e){return Xt.create(this,e,this._def)}transform(e){return new he({...Z(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new sn({...Z(this._def),innerType:this,defaultValue:t,typeName:T.ZodDefault})}brand(){return new sr({typeName:T.ZodBranded,type:this,...Z(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new an({...Z(this._def),innerType:this,catchValue:t,typeName:T.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return on.create(this,e)}readonly(){return cn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ki=/^c[^\s-]{8,}$/i,wi=/^[0-9a-z]+$/,xi=/^[0-9A-HJKMNP-TV-Z]{26}$/,Oi=/^[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,Ti=/^[a-z0-9_-]{21}$/i,ji=/^[-+]?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)?)??$/,Ei=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ri="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let nr;const Si=/^(?:(?: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])$/,Zi=/^(([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})))$/,Ci=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qr="((\\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])))",Ii=new RegExp(`^${qr}$`);function Br(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ni(n){return new RegExp(`^${Br(n)}$`)}function Wr(n){let e=`${qr}T${Br(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Pi(n,e){return!!((e==="v4"||!e)&&Si.test(n)||(e==="v6"||!e)&&Zi.test(n))}class le extends N{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_type,expected:b.string,received:s.parsedType}),E}const t=new Q;let r;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:f.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:f.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(r=this._getOrReturnCtx(e,r),a?_(r,{code:f.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&_(r,{code:f.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Ei.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"email",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")nr||(nr=new RegExp(Ri,"u")),nr.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"emoji",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")Oi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"uuid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")Ti.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"nanoid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")ki.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"cuid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")wi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"cuid2",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")xi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"ulid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),_(r,{validation:"url",code:f.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"regex",code:f.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.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)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?Wr(s).test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?Ii.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Ni(s).test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:f.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?ji.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"duration",code:f.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Pi(e.data,s.version)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"ip",code:f.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?Ci.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"base64",code:f.invalid_string,message:s.message}),t.dirty()):M.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:f.invalid_string,...x.errToObj(r)})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...x.errToObj(e)})}url(e){return this._addCheck({kind:"url",...x.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...x.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...x.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...x.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...x.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...x.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...x.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...x.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...x.errToObj(e)})}datetime(e){var t,r;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:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...x.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,...x.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...x.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...x.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...x.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...x.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...x.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...x.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...x.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...x.errToObj(t)})}nonempty(e){return this.min(1,x.errToObj(e))}trim(){return new le({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new le({...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}}le.create=n=>{var e;return new le({checks:[],typeName:T.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...Z(n)})};function Ai(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Me extends N{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)!==b.number){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_type,expected:b.number,received:s.parsedType}),E}let t;const r=new Q;for(const s of this._def.checks)s.kind==="int"?M.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),_(t,{code:f.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?Ai(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),_(t,{code:f.not_finite,message:s.message}),r.dirty()):M.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,r,s){return new Me({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:x.toString(s)}]})}_addCheck(e){return new Me({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:x.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:x.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.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"&&M.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Me.create=n=>new Me({checks:[],typeName:T.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Z(n)});class $e extends N{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)!==b.bigint){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_type,expected:b.bigint,received:s.parsedType}),E}let t;const r=new Q;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),_(t,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):M.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,r,s){return new $e({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:x.toString(s)}]})}_addCheck(e){return new $e({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.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}}$e.create=n=>{var e;return new $e({checks:[],typeName:T.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...Z(n)})};class zt extends N{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.boolean,received:t.parsedType}),E}return ee(e.data)}}zt.create=n=>new zt({typeName:T.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Z(n)});class Ge extends N{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_type,expected:b.date,received:s.parsedType}),E}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return _(s,{code:f.invalid_date}),E}const t=new Q;let r;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:f.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:f.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):M.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ge({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:x.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:x.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}}Ge.create=n=>new Ge({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:T.ZodDate,...Z(n)});class Mn extends N{_parse(e){if(this._getType(e)!==b.symbol){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.symbol,received:t.parsedType}),E}return ee(e.data)}}Mn.create=n=>new Mn({typeName:T.ZodSymbol,...Z(n)});class Yt extends N{_parse(e){if(this._getType(e)!==b.undefined){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.undefined,received:t.parsedType}),E}return ee(e.data)}}Yt.create=n=>new Yt({typeName:T.ZodUndefined,...Z(n)});class Jt extends N{_parse(e){if(this._getType(e)!==b.null){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.null,received:t.parsedType}),E}return ee(e.data)}}Jt.create=n=>new Jt({typeName:T.ZodNull,...Z(n)});class ut extends N{constructor(){super(...arguments),this._any=!0}_parse(e){return ee(e.data)}}ut.create=n=>new ut({typeName:T.ZodAny,...Z(n)});class ze extends N{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ee(e.data)}}ze.create=n=>new ze({typeName:T.ZodUnknown,...Z(n)});class Ee extends N{_parse(e){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.never,received:t.parsedType}),E}}Ee.create=n=>new Ee({typeName:T.ZodNever,...Z(n)});class $n extends N{_parse(e){if(this._getType(e)!==b.undefined){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.void,received:t.parsedType}),E}return ee(e.data)}}$n.create=n=>new $n({typeName:T.ZodVoid,...Z(n)});class pe extends N{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==b.array)return _(t,{code:f.invalid_type,expected:b.array,received:t.parsedType}),E;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(_(t,{code:i?f.too_big:f.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(_(t,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(_(t,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new ke(t,i,t.path,o)))).then(i=>Q.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ke(t,i,t.path,o)));return Q.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new pe({...this._def,minLength:{value:e,message:x.toString(t)}})}max(e,t){return new pe({...this._def,maxLength:{value:e,message:x.toString(t)}})}length(e,t){return new pe({...this._def,exactLength:{value:e,message:x.toString(t)}})}nonempty(e){return this.min(1,e)}}pe.create=(n,e)=>new pe({type:n,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...Z(e)});function lt(n){if(n instanceof B){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=xe.create(lt(r))}return new B({...n._def,shape:()=>e})}else return n instanceof pe?new pe({...n._def,type:lt(n.element)}):n instanceof xe?xe.create(lt(n.unwrap())):n instanceof Ue?Ue.create(lt(n.unwrap())):n instanceof we?we.create(n.items.map(e=>lt(e))):n}class B extends N{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=M.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==b.object){const d=this._getOrReturnCtx(e);return _(d,{code:f.invalid_type,expected:b.object,received:d.parsedType}),E}const{status:t,ctx:r}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ee&&this._def.unknownKeys==="strip"))for(const d in r.data)a.includes(d)||i.push(d);const o=[];for(const d of a){const u=s[d],l=r.data[d];o.push({key:{status:"valid",value:d},value:u._parse(new ke(r,l,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof Ee){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of i)o.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")i.length>0&&(_(r,{code:f.unrecognized_keys,keys:i}),t.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of i){const l=r.data[u];o.push({key:{status:"valid",value:u},value:d._parse(new ke(r,l,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of o){const l=await u.key,p=await u.value;d.push({key:l,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>Q.mergeObjectSync(t,d)):Q.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return x.errToObj,new B({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=x.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new B({...this._def,unknownKeys:"strip"})}passthrough(){return new B({...this._def,unknownKeys:"passthrough"})}extend(e){return new B({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new B({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new B({...this._def,catchall:e})}pick(e){const t={};return M.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new B({...this._def,shape:()=>t})}omit(e){const t={};return M.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new B({...this._def,shape:()=>t})}deepPartial(){return lt(this)}partial(e){const t={};return M.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new B({...this._def,shape:()=>t})}required(e){const t={};return M.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof xe;)s=s._def.innerType;t[r]=s}}),new B({...this._def,shape:()=>t})}keyof(){return Hr(M.objectKeys(this.shape))}}B.create=(n,e)=>new B({shape:()=>n,unknownKeys:"strip",catchall:Ee.create(),typeName:T.ZodObject,...Z(e)}),B.strictCreate=(n,e)=>new B({shape:()=>n,unknownKeys:"strict",catchall:Ee.create(),typeName:T.ZodObject,...Z(e)}),B.lazycreate=(n,e)=>new B({shape:n,unknownKeys:"strip",catchall:Ee.create(),typeName:T.ZodObject,...Z(e)});class Qt extends N{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new re(o.ctx.common.issues));return _(t,{code:f.invalid_union,unionErrors:i}),E}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new re(d));return _(t,{code:f.invalid_union,unionErrors:o}),E}}get options(){return this._def.options}}Qt.create=(n,e)=>new Qt({options:n,typeName:T.ZodUnion,...Z(e)});const De=n=>n instanceof tn?De(n.schema):n instanceof he?De(n.innerType()):n instanceof nn?[n.value]:n instanceof Le?n.options:n instanceof rn?M.objectValues(n.enum):n instanceof sn?De(n._def.innerType):n instanceof Yt?[void 0]:n instanceof Jt?[null]:n instanceof xe?[void 0,...De(n.unwrap())]:n instanceof Ue?[null,...De(n.unwrap())]:n instanceof sr||n instanceof cn?De(n.unwrap()):n instanceof an?De(n._def.innerType):[];class Dn extends N{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.object)return _(t,{code:f.invalid_type,expected:b.object,received:t.parsedType}),E;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(_(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),E)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=De(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Dn({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...Z(r)})}}function rr(n,e){const t=Ae(n),r=Ae(e);if(n===e)return{valid:!0,data:n};if(t===b.object&&r===b.object){const s=M.objectKeys(e),a=M.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i={...n,...e};for(const o of a){const d=rr(n[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===b.array&&r===b.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],d=rr(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===b.date&&r===b.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Xt extends N{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(er(a)||er(i))return E;const o=rr(a.value,i.value);return o.valid?((tr(a)||tr(i))&&t.dirty(),{status:t.value,value:o.data}):(_(r,{code:f.invalid_intersection_types}),E)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Xt.create=(n,e,t)=>new Xt({left:n,right:e,typeName:T.ZodIntersection,...Z(t)});class we extends N{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.array)return _(r,{code:f.invalid_type,expected:b.array,received:r.parsedType}),E;if(r.data.length<this._def.items.length)return _(r,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&r.data.length>this._def.items.length&&(_(r,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new ke(r,a,r.path,i)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>Q.mergeArray(t,a)):Q.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new we({...this._def,rest:e})}}we.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new we({items:n,typeName:T.ZodTuple,rest:null,...Z(e)})};class en extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.object)return _(r,{code:f.invalid_type,expected:b.object,received:r.parsedType}),E;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ke(r,o,r.path,o)),value:i._parse(new ke(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?Q.mergeObjectAsync(t,s):Q.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof N?new en({keyType:e,valueType:t,typeName:T.ZodRecord,...Z(r)}):new en({keyType:le.create(),valueType:e,typeName:T.ZodRecord,...Z(t)})}}class Ln extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.map)return _(r,{code:f.invalid_type,expected:b.map,received:r.parsedType}),E;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,d],u)=>({key:s._parse(new ke(r,o,r.path,[u,"key"])),value:a._parse(new ke(r,d,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return E;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return E;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}Ln.create=(n,e,t)=>new Ln({valueType:e,keyType:n,typeName:T.ZodMap,...Z(t)});class Ye extends N{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.set)return _(r,{code:f.invalid_type,expected:b.set,received:r.parsedType}),E;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(_(r,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(_(r,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const u=new Set;for(const l of d){if(l.status==="aborted")return E;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((d,u)=>a._parse(new ke(r,d,r.path,u)));return r.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new Ye({...this._def,minSize:{value:e,message:x.toString(t)}})}max(e,t){return new Ye({...this._def,maxSize:{value:e,message:x.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ye.create=(n,e)=>new Ye({valueType:n,minSize:null,maxSize:null,typeName:T.ZodSet,...Z(e)});class pt extends N{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.function)return _(t,{code:f.invalid_type,expected:b.function,received:t.parsedType}),E;function r(o,d){return Nn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,In(),dt].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:d}})}function s(o,d){return Nn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,In(),dt].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ht){const o=this;return ee(async function(...d){const u=new re([]),l=await o._def.args.parseAsync(d,a).catch(C=>{throw u.addIssue(r(d,C)),u}),p=await Reflect.apply(i,this,l);return await o._def.returns._def.type.parseAsync(p,a).catch(C=>{throw u.addIssue(s(p,C)),u})})}else{const o=this;return ee(function(...d){const u=o._def.args.safeParse(d,a);if(!u.success)throw new re([r(d,u.error)]);const l=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(l,a);if(!p.success)throw new re([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new pt({...this._def,args:we.create(e).rest(ze.create())})}returns(e){return new pt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new pt({args:e||we.create([]).rest(ze.create()),returns:t||ze.create(),typeName:T.ZodFunction,...Z(r)})}}class tn extends N{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})}}tn.create=(n,e)=>new tn({getter:n,typeName:T.ZodLazy,...Z(e)});class nn extends N{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:e.data}}get value(){return this._def.value}}nn.create=(n,e)=>new nn({value:n,typeName:T.ZodLiteral,...Z(e)});function Hr(n,e){return new Le({values:n,typeName:T.ZodEnum,...Z(e)})}class Le extends N{constructor(){super(...arguments),Kt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{expected:M.joinValues(r),received:t.parsedType,code:f.invalid_type}),E}if(An(this,Kt)||Ur(this,Kt,new Set(this._def.values)),!An(this,Kt).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{received:t.data,code:f.invalid_enum_value,options:r}),E}return ee(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 Le.create(e,{...this._def,...t})}exclude(e,t=this._def){return Le.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Kt=new WeakMap,Le.create=Hr;class rn extends N{constructor(){super(...arguments),Gt.set(this,void 0)}_parse(e){const t=M.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==b.string&&r.parsedType!==b.number){const s=M.objectValues(t);return _(r,{expected:M.joinValues(s),received:r.parsedType,code:f.invalid_type}),E}if(An(this,Gt)||Ur(this,Gt,new Set(M.getValidEnumValues(this._def.values))),!An(this,Gt).has(e.data)){const s=M.objectValues(t);return _(r,{received:r.data,code:f.invalid_enum_value,options:s}),E}return ee(e.data)}get enum(){return this._def.values}}Gt=new WeakMap,rn.create=(n,e)=>new rn({values:n,typeName:T.ZodNativeEnum,...Z(e)});class ht extends N{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.promise&&t.common.async===!1)return _(t,{code:f.invalid_type,expected:b.promise,received:t.parsedType}),E;const r=t.parsedType===b.promise?t.data:Promise.resolve(t.data);return ee(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ht.create=(n,e)=>new ht({type:n,typeName:T.ZodPromise,...Z(e)});class he extends N{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{_(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return E;const d=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return d.status==="aborted"?E:d.status==="dirty"||t.value==="dirty"?Pn(d.value):d});{if(t.value==="aborted")return E;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?E:o.status==="dirty"||t.value==="dirty"?Pn(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?E:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?E:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ht(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Ht(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);M.assertNever(s)}}he.create=(n,e,t)=>new he({schema:n,typeName:T.ZodEffects,effect:e,...Z(t)}),he.createWithPreprocess=(n,e,t)=>new he({schema:e,effect:{type:"preprocess",transform:n},typeName:T.ZodEffects,...Z(t)});class xe extends N{_parse(e){return this._getType(e)===b.undefined?ee(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xe.create=(n,e)=>new xe({innerType:n,typeName:T.ZodOptional,...Z(e)});class Ue extends N{_parse(e){return this._getType(e)===b.null?ee(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ue.create=(n,e)=>new Ue({innerType:n,typeName:T.ZodNullable,...Z(e)});class sn extends N{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===b.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}sn.create=(n,e)=>new sn({innerType:n,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Z(e)});class an extends N{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ft(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}an.create=(n,e)=>new an({innerType:n,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Z(e)});class Un extends N{_parse(e){if(this._getType(e)!==b.nan){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:b.nan,received:t.parsedType}),E}return{status:"valid",value:e.data}}}Un.create=n=>new Un({typeName:T.ZodNaN,...Z(n)});const Mi=Symbol("zod_brand");class sr extends N{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class on extends N{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?E:s.status==="dirty"?(t.dirty(),Pn(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?E:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new on({in:e,out:t,typeName:T.ZodPipeline})}}class cn extends N{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Ht(s)&&(s.value=Object.freeze(s.value)),s);return Ft(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}cn.create=(n,e)=>new cn({innerType:n,typeName:T.ZodReadonly,...Z(e)});function Fr(n,e={},t){return n?ut.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:d})}}):ut.create()}const $i={object:B.lazycreate};var T;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(T||(T={}));const Di=(n,e={message:`Input not instance of ${n.name}`})=>Fr(t=>t instanceof n,e),Kr=le.create,Gr=Me.create,Li=Un.create,Ui=$e.create,zr=zt.create,Vi=Ge.create,qi=Mn.create,Bi=Yt.create,Wi=Jt.create,Hi=ut.create,Fi=ze.create,Ki=Ee.create,Gi=$n.create,zi=pe.create,Yi=B.create,Ji=B.strictCreate,Qi=Qt.create,Xi=Dn.create,eo=Xt.create,to=we.create,no=en.create,ro=Ln.create,so=Ye.create,ao=pt.create,io=tn.create,oo=nn.create,co=Le.create,uo=rn.create,lo=ht.create,Yr=he.create,po=xe.create,ho=Ue.create,fo=he.createWithPreprocess,mo=on.create;var c=Object.freeze({__proto__:null,defaultErrorMap:dt,setErrorMap:vi,getErrorMap:In,makeIssue:Nn,EMPTY_PATH:bi,addIssueToContext:_,ParseStatus:Q,INVALID:E,DIRTY:Pn,OK:ee,isAborted:er,isDirty:tr,isValid:Ht,isAsync:Ft,get util(){return M},get objectUtil(){return Xn},ZodParsedType:b,getParsedType:Ae,ZodType:N,datetimeRegex:Wr,ZodString:le,ZodNumber:Me,ZodBigInt:$e,ZodBoolean:zt,ZodDate:Ge,ZodSymbol:Mn,ZodUndefined:Yt,ZodNull:Jt,ZodAny:ut,ZodUnknown:ze,ZodNever:Ee,ZodVoid:$n,ZodArray:pe,ZodObject:B,ZodUnion:Qt,ZodDiscriminatedUnion:Dn,ZodIntersection:Xt,ZodTuple:we,ZodRecord:en,ZodMap:Ln,ZodSet:Ye,ZodFunction:pt,ZodLazy:tn,ZodLiteral:nn,ZodEnum:Le,ZodNativeEnum:rn,ZodPromise:ht,ZodEffects:he,ZodTransformer:he,ZodOptional:xe,ZodNullable:Ue,ZodDefault:sn,ZodCatch:an,ZodNaN:Un,BRAND:Mi,ZodBranded:sr,ZodPipeline:on,ZodReadonly:cn,custom:Fr,Schema:N,ZodSchema:N,late:$i,get ZodFirstPartyTypeKind(){return T},coerce:{string:n=>le.create({...n,coerce:!0}),number:n=>Me.create({...n,coerce:!0}),boolean:n=>zt.create({...n,coerce:!0}),bigint:n=>$e.create({...n,coerce:!0}),date:n=>Ge.create({...n,coerce:!0})},any:Hi,array:zi,bigint:Ui,boolean:zr,date:Vi,discriminatedUnion:Xi,effect:Yr,enum:co,function:ao,instanceof:Di,intersection:eo,lazy:io,literal:oo,map:ro,nan:Li,nativeEnum:uo,never:Ki,null:Wi,nullable:ho,number:Gr,object:Yi,oboolean:()=>zr().optional(),onumber:()=>Gr().optional(),optional:po,ostring:()=>Kr().optional(),pipeline:mo,preprocess:fo,promise:lo,record:no,set:so,strictObject:Ji,string:Kr,symbol:qi,transformer:Yr,tuple:to,undefined:Bi,union:Qi,unknown:Fi,void:Gi,NEVER:E,ZodIssueCode:f,quotelessJson:yi,ZodError:re});_i(c);const go=c.object({start:c.number(),limit:c.number(),length:c.number()}),ar=c.object({created_at:c.string(),updated_at:c.string()}),_o=c.object({email:c.string().optional(),email_verified:c.boolean().optional(),name:c.string().optional(),username:c.string().optional(),given_name:c.string().optional(),phone_number:c.string().optional(),phone_verified:c.boolean().optional(),family_name:c.string().optional()}).catchall(c.any()),yo=c.object({connection:c.string(),user_id:c.string(),provider:c.string(),isSocial:c.boolean(),access_token:c.string().optional(),access_token_secret:c.string().optional(),refresh_token:c.string().optional(),profileData:_o.optional()}),Jr=c.object({email:c.string().optional(),username:c.string().optional(),given_name:c.string().optional(),family_name:c.string().optional(),nickname:c.string().optional(),name:c.string().optional(),picture:c.string().optional(),locale:c.string().optional(),linked_to:c.string().optional(),profileData:c.string().optional(),user_id:c.string().optional()});Jr.extend({email_verified:c.boolean().default(!1),verify_email:c.boolean().optional(),last_ip:c.string().optional(),last_login:c.string().optional(),user_id:c.string().optional(),provider:c.string().default("email"),connection:c.string().default("email")}).extend(ar.shape).extend({user_id:c.string(),email:c.string(),is_social:c.boolean(),login_count:c.number(),identities:c.array(yo).optional()}),Jr.extend({email:c.string(),login_count:c.number(),multifactor:c.array(c.string()).optional(),last_ip:c.string().optional(),last_login:c.string().optional(),user_id:c.string()}).catchall(c.any());const vo=c.object({id:c.string(),name:c.string(),allowed_web_origins:c.string().transform(n=>n===null?"":n).default(""),allowed_callback_urls:c.string().transform(n=>n===null?"":n).default(""),allowed_logout_urls:c.string().transform(n=>n===null?"":n).default(""),email_validation:c.enum(["enabled","disabled","enforced"]).default("enforced"),client_secret:c.string().default(""),disable_sign_ups:c.boolean().default(!1)});c.object({created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)}).extend(vo.shape);var Qr=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(Qr||{}),Xr=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n))(Xr||{}),es=(n=>(n.S265="S256",n.plain="plain",n))(es||{});const Vn=c.object({client_id:c.string(),vendor_id:c.string().optional(),response_type:c.nativeEnum(Qr).optional(),response_mode:c.nativeEnum(Xr).optional(),redirect_uri:c.string().optional(),audience:c.string().optional(),state:c.string().optional(),nonce:c.string().optional(),scope:c.string().optional(),code_challenge_method:c.nativeEnum(es).optional(),code_challenge:c.string().optional(),username:c.string().optional()});c.object({colors:c.object({primary:c.string(),page_background:c.object({type:c.string().optional(),start:c.string().optional(),end:c.string().optional(),angle_deg:c.number().optional()}).optional()}).optional(),logo_url:c.string().optional(),favicon_url:c.string().optional(),font:c.object({url:c.string()}).optional()});const bo=c.object({id:c.string().optional(),name:c.string(),client_id:c.string().optional(),client_secret:c.string().optional(),authorization_endpoint:c.string().optional(),response_type:c.custom().optional(),response_mode:c.custom().optional(),private_key:c.string().optional(),kid:c.string().optional(),team_id:c.string().optional(),token_endpoint:c.string().optional(),token_exchange_basic_auth:c.boolean().optional(),userinfo_endpoint:c.string().optional(),scope:c.string().optional()}),ts=c.object({id:c.string(),created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)}).extend(bo.shape),ko=c.object({domain:c.string(),dkim_private_key:c.string().optional(),dkim_public_key:c.string().optional(),email_api_key:c.string().optional(),email_service:c.union([c.literal("mailgun"),c.literal("mailchannels")]).optional()}),ns=c.object({id:c.string(),name:c.string(),domains:c.array(ko),allowed_callback_urls:c.array(c.string()),allowed_logout_urls:c.array(c.string()),allowed_web_origins:c.array(c.string()),email_validation:c.union([c.literal("enabled"),c.literal("disabled"),c.literal("enforced")]),tenant_id:c.string(),client_secret:c.string(),disable_sign_ups:c.boolean(),tenant:c.object({name:c.string(),audience:c.string().optional(),logo:c.string().optional(),primary_color:c.string().optional(),secondary_color:c.string().optional(),sender_email:c.string(),sender_name:c.string(),support_url:c.string().optional(),language:c.string().length(2).optional()})});ns.extend({connections:c.array(ts)}),ns.extend({connections:c.array(ts.partial())});const wo=c.enum(["password_reset","email_verification","otp","oauth2","oauth2_state","ticket"]),xo=c.object({code_id:c.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:c.string().openapi({description:"The id of the login session that the code is connected to"}),code_type:wo,expires_at:c.string(),used_at:c.string().optional()});c.object({...xo.shape,created_at:c.string()});const Oo=c.object({domain:c.string(),dkim_private_key:c.string().optional(),dkim_public_key:c.string().optional(),email_api_key:c.string().optional(),email_service:c.enum(["mailgun","mailchannels"])});ar.extend({...Oo.shape,id:c.string()}),c.object({trigger_id:c.enum(["post-user-registration","post-user-login"]),enabled:c.boolean().default(!1),url:c.string(),hook_id:c.string().optional()}).extend({...ar.shape,hook_id:c.string()});const To=c.object({alg:c.string(),e:c.string(),kid:c.string(),kty:c.string(),n:c.string(),use:c.string().optional()}),jo=c.object({keys:c.array(To)}),rs=c.object({issuer:c.string(),authorization_endpoint:c.string(),token_endpoint:c.string(),device_authorization_endpoint:c.string(),userinfo_endpoint:c.string(),mfa_challenge_endpoint:c.string(),jwks_uri:c.string(),registration_endpoint:c.string(),revocation_endpoint:c.string(),scopes_supported:c.array(c.string()),response_types_supported:c.array(c.string()),code_challenge_methods_supported:c.array(c.string()),response_modes_supported:c.array(c.string()),subject_types_supported:c.array(c.string()),id_token_signing_alg_values_supported:c.array(c.string()),token_endpoint_auth_methods_supported:c.array(c.string()),claims_supported:c.array(c.string()),request_uri_parameter_supported:c.boolean(),request_parameter_supported:c.boolean(),token_endpoint_auth_signing_alg_values_supported:c.array(c.string())}),Eo=c.object({auth0Client:c.string().optional(),authParams:Vn,expires_at:c.string(),deleted_at:c.string().optional(),ip:c.string().optional()}).openapi({description:"This represents a login sesion"});c.object({...Eo.shape,login_id:c.string().openapi({description:"This is is used as the state in the universal login"}),created_at:c.string(),updated_at:c.string()});var ss=(n=>(n.SUCCESS_API_OPERATION="sapi",n.SUCCESS_SILENT_AUTH="ssa",n.FAILED_SILENT_AUTH="fsa",n.SUCCESS_SIGNUP="ss",n.FAILED_SIGNUP="fs",n.SUCCESS_LOGIN="s",n.FAILED_LOGIN="f",n.FAILED_LOGIN_INCORRECT_PASSWORD="fp",n.SUCCESS_LOGOUT="slo",n.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",n.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",n.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",n.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",n.CODE_LINK_SENT="cls",n.NOT_IMPLEMENTED_1="seccft",n))(ss||{});const Ro=c.enum(["sapi","ssa","fsa","ss","ssa","fs","s","f","fp","slo","scoa","fcoa","seccft","cls","seacft","serft"]),So=c.object({name:c.string(),version:c.string(),env:c.object({node:c.string().optional()}).optional()});c.object({type:Ro,date:c.string(),description:c.string().optional(),log_id:c.string().optional(),_id:c.string().optional(),ip:c.string(),user_agent:c.string(),details:c.any().optional(),isMobile:c.boolean(),user_id:c.string().optional(),user_name:c.string().optional(),connection:c.string().optional(),connection_id:c.string().optional(),client_id:c.string().optional(),client_name:c.string().optional(),audience:c.string().optional(),scope:c.array(c.string()).optional(),strategy:c.string().optional(),strategy_type:c.string().optional(),hostname:c.string().optional(),auth0_client:So.optional()});const Zo=c.object({user_id:c.string(),password:c.string(),algorithm:c.enum(["bcrypt","argon2id"]).default("argon2id")});c.object({...Zo.shape,created_at:c.string(),updated_at:c.string()});const Co=c.object({session_id:c.string(),client_id:c.string(),expires_at:c.string(),used_at:c.string(),deleted_at:c.string().optional(),user_id:c.string()});c.object({created_at:c.string(),...Co.shape}),c.object({private_key:c.string(),public_key:c.string(),kid:c.string(),created_at:c.string(),revoked_at:c.string().optional()}),c.object({kid:c.string().openapi({description:"The key id of the signing key"}),cert:c.string().openapi({description:"The public certificate of the signing key"}),fingerprint:c.string().openapi({description:"The cert fingerprint"}),thumbprint:c.string().openapi({description:"The cert thumbprint"}),pkcs7:c.string().optional().openapi({description:"The public certificate of the signing key in pkcs7 format"}),current:c.boolean().optional().openapi({description:"True if the key is the current key"}),next:c.boolean().optional().openapi({description:"True if the key is the next key"}),previous:c.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:c.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:c.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:c.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:c.string().optional().openapi({description:"The date and time when the key was revoked"})});const ir=c.object({name:c.string(),audience:c.string(),sender_email:c.string().email(),sender_name:c.string(),support_url:c.string().url().optional(),logo:c.string().url().optional(),primary_color:c.string().optional(),secondary_color:c.string().optional(),language:c.string().optional()}),qn=ir.extend({created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)});c.object({logoUrl:c.string(),loginBackgroundImage:c.string().nullish(),style:c.object({primaryColor:c.string(),buttonTextColor:c.string(),primaryHoverColor:c.string()}),supportEmail:c.string().nullable(),supportUrl:c.string().nullable(),name:c.string(),showGreyishBackground:c.boolean().optional(),termsAndConditionsUrl:c.string().nullable(),companyName:c.string().optional(),checkoutHideSocial:c.boolean().optional(),siteUrl:c.string().nullable(),manageSubscriptionsUrl:c.string().optional()});var as=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(as||{});const or=c.nativeEnum(as);c.object({grant_type:or.refine(n=>n==="authorization_code"),code:c.string(),client_secret:c.string(),client_id:c.string()}),c.object({grant_type:or.refine(n=>n==="authorization_code"),code:c.string(),code_verifier:c.string(),client_id:c.string().optional(),redirect_uri:c.string()}),c.object({grant_type:or.refine(n=>n==="client_credentials"),scope:c.string().optional(),client_secret:c.string(),client_id:c.string(),audience:c.string().optional()}),c.object({access_token:c.string(),id_token:c.string().optional(),scope:c.string().optional(),state:c.string().optional(),refresh_token:c.string().optional(),token_type:c.string(),expires_in:c.number()}),c.object({code:c.string(),state:c.string().optional()});const Io=c.object({button_border_radius:c.number(),button_border_weight:c.number(),buttons_style:c.enum(["pill"]),input_border_radius:c.number(),input_border_weight:c.number(),inputs_style:c.enum(["pill"]),show_widget_shadow:c.boolean(),widget_border_weight:c.number(),widget_corner_radius:c.number()}),No=c.object({base_focus_color:c.string(),base_hover_color:c.string(),body_text:c.string(),captcha_widget_theme:c.enum(["auto"]),error:c.string(),header:c.string(),icons:c.string(),input_background:c.string(),input_border:c.string(),input_filled_text:c.string(),input_labels_placeholders:c.string(),links_focused_components:c.string(),primary_button:c.string(),primary_button_label:c.string(),secondary_button_border:c.string(),secondary_button_label:c.string(),success:c.string(),widget_background:c.string(),widget_border:c.string()}),ft=c.object({bold:c.boolean(),size:c.number()}),Po=c.object({body_text:ft,buttons_text:ft,font_url:c.string(),input_labels:ft,links:ft,links_style:c.enum(["normal"]),reference_text_size:c.number(),subtitle:ft,title:ft}),Ao=c.object({background_color:c.string(),background_image_url:c.string(),page_layout:c.enum(["center"])}),Mo=c.object({header_text_alignment:c.enum(["center"]),logo_height:c.number(),logo_position:c.enum(["center"]),logo_url:c.string(),social_buttons_layout:c.enum(["bottom"])});c.object({borders:Io,colors:No,displayName:c.string(),fonts:Po,page_background:Ao,widget:Mo}).extend({themeId:c.string()});const $o=c.object({id:c.string(),expires_at:c.string(),auth0Client:c.string().optional(),authParams:Vn});c.object({...$o.shape,created_at:c.string(),updated_at:c.string()});const Do=c.object({id:c.string(),email:c.string(),code:c.string(),ip:c.string().optional(),send:c.enum(["code","link"]),authParams:Vn,expires_at:c.string(),used_at:c.string().optional(),user_id:c.string().optional()});c.object({created_at:c.string(),...Do.shape});const Lo=c.object({authParams:Vn,code:c.string(),user_id:c.string(),created_at:c.string(),expires_at:c.string(),used_at:c.string().optional()});c.object({...Lo.shape,created_at:c.string()});const Uo=new Bt().openapi(Ke({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:jo}},description:"List of tenants"}}}),async n=>{const{env:e}=n,t=[{alg:"RS256",e:"AQAB",kid:"hZ42TWGWLdmyKfwGVA6c2",kty:"RSA",n:"nUd-mktFZQNfVwmXufxcVcvJo6Lkb-jDuymtfQunmEhWCctOccWx9e7LX7_9uN15ZnRS7XJInPMRs9KLYdZ0GCnE2HM_QbrEoHpdkCRgyTE-KzmoaEv_AOVGE_Kg0-0ct3r9Z7aJLDVAsxXl1C9y8Gr7ZYkq0c4DyZr9VT8nQiwZQERbfxXdXw-5RLj21S_Lm-LL-AjKvry_TDBLpfUFJV18SVsM07lY_V45TwykNewRdaGLspFIeGdG5j5eByV8ifzBqvzOSptSCsmOTtW-ceWUk0FPD7g_KKzjjbzenoB0TC8mBb_4vWZlHnuGIAs2YoTFglp9uNu7t_OVl3Svo6ZE6alzUnaNfZNeAi78KPHYQ4tDWPjpYNfGynsiD0nojkDSPCIak56jWNYjj614cPEBiv9MVQRiSbBxpiGhMoHlW_QCCPMcXygLAaRs_tUksqoH4QB80krifG2yHPgGDPjXK1_0cYzV80iOcQIeoceqhkSSc6YxzzgDrQcsV2k3bizRQSL83GWkpdHhTZn-Q_JzsW_bDY_f9fjigYbRnoDSgS7038VFIPc92StE41MdgvIQMomcyEE4lYK1uv1Mo6cnXbCZhm8tvddo7VKNorOB4nsiv8DGrWPlzQBca9VN4C1oE2mH-3WLFR7XEkBHWVouOdTWM2S3K9F10YtahkM"}];return n.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})}).openapi(Ke({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:rs}},description:"List of tenants"}}}),async n=>{const{env:e}=n,{ISSUER:t}=e,r=rs.parse({issuer:t,authorization_endpoint:`${t}authorize`,token_endpoint:`${t}oauth/token`,device_authorization_endpoint:`${t}oauth/device/code`,userinfo_endpoint:`${t}userinfo`,mfa_challenge_endpoint:`${t}mfa/challenge`,jwks_uri:`${t}.well-known/jwks.json`,registration_endpoint:`${t}oidc/register`,revocation_endpoint:`${t}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return n.json(r,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})});async function Vo({userAdapter:n,tenant_id:e,email:t}){var o;const{users:r}=await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),s=r.filter(d=>!(d.provider==="auth2"&&!d.email_verified));if(s.length===0)return;const a=s.filter(d=>!d.linked_to);if(a.length>0)return a.length>1&&console.error("More than one primary user found for same email"),a[0];const i=await n.get(e,(o=s[0])==null?void 0:o.linked_to);if(!i)throw new Error("Primary account not found");return i}function qo(n){return async(e,t)=>{if(!t.email||!t.email_verified)return n.users.create(e,t);const r=await Vo({userAdapter:n.users,tenant_id:e,email:t.email});return r?(await n.users.create(e,{...t,linked_to:r.user_id}),r):n.users.create(e,t)}}function Bo(n,e){return{type:e.type,description:e.description||"",ip:n.req.header("x-real-ip")||"",user_agent:n.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:n.req.method,path:n.req.path,qs:n.req.queries(),body:e.body||n.var.body||""}},isMobile:!1,client_id:n.var.client_id,client_name:"",user_id:e.userId||n.var.user_id||"",hostname:n.req.header("host")||"",user_name:n.var.username||"",connection_id:"",connection:n.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}async function Wo(n,e,t){for await(const r of e)if(!(await fetch(r.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok){const a=Bo(n,{type:ss.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(n.var.tenant_id,a)}}function Ho(n,e){return async(t,r)=>{const{hooks:s}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await Wo(n,s,{tenant_id:t,user:r,trigger_id:"post-user-registration"}),r}}function Fo(n,e){return async(t,r)=>{let s=await qo(e)(t,r);return await Ho(n,e)(t,s),s}}function Ko(n,e){return{...e,users:{...e.users,create:Fo(n,e)}}}const Go=z.object({page:z.string().min(0).optional().default("0").transform(n=>parseInt(n,10)).openapi({description:"The page number where 0 is the first page"}),per_page:z.string().min(1).optional().default("10").transform(n=>parseInt(n,10)).openapi({description:"The number of items per page"}),include_totals:z.string().optional().default("false").transform(n=>n==="true").openapi({description:"If the total number of items should be included in the response"}),sort:z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function zo(n){if(!n)return;const[e="",t]=n.split(":");return{sort_by:e,sort_order:t==="1"?"asc":"desc"}}const Yo=go.extend({tenants:z.array(qn)}),Jo=new Bt().openapi(Ke({tags:["tenants"],method:"get",path:"/",request:{query:Go},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:z.union([z.array(qn),Yo])}},description:"List of tenants"}}}),async n=>{const{page:e,per_page:t,include_totals:r,sort:s,q:a}=n.req.valid("query"),i=await n.env.data.tenants.list({page:e,per_page:t,include_totals:r,sort:zo(s),q:a});return r?n.json(i):n.json(i.tenants)}).openapi(Ke({tags:["tenants"],method:"get",path:"/{id}",request:{params:z.object({id:z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:qn}},description:"A tenant"}}}),async n=>{const{id:e}=n.req.valid("param"),t=await n.env.data.tenants.get(e);if(!t)throw new bn(404);return console.log("tenant",t),n.json(t)}).openapi(Ke({tags:["tenants"],method:"delete",path:"/{id}",request:{params:z.object({id:z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{id:e}=n.req.valid("param");return await n.env.data.tenants.remove(e),n.text("OK")}).openapi(Ke({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:z.object(ir.shape).partial()}}},params:z.object({id:z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{id:e}=n.req.valid("param"),t=n.req.valid("json");return await n.env.data.tenants.update(e,t),n.text("OK")}).openapi(Ke({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:z.object(ir.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:qn}},description:"An tenant"}}}),async n=>{const e=n.req.valid("json"),t=await n.env.data.tenants.create(e);return n.json(t,{status:201})});let is=!1;function Qo(n){n.use(async(e,t)=>(is||(n.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),is=!0),await t()))}function Xo(n){const e=new Bt;e.use(async(r,s)=>(r.env.data=Ko(r,n.dataAdapter),s()));const t=e.route("/api/v2/tenants",Jo);return Qo(t),t.doc("/api/v2/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function ec(n){const e=new Bt;e.get("/",s=>s.text("Hello, authhero!"));const t=Xo(n);e.route("/api/v2",t);const r=new Bt().route("/.well-known",Uo);return r.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",r),e}return U.init=ec,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"}),U}({});