authhero 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/authhero.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var z0=Object.defineProperty;var fh=r=>{throw TypeError(r)};var G0=(r,e,t)=>e in r?z0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var se=(r,e,t)=>G0(r,typeof e!="symbol"?e+"":e,t),Wu=(r,e,t)=>e.has(r)||fh("Cannot "+t);var w=(r,e,t)=>(Wu(r,e,"read from private field"),t?t.call(r):e.get(r)),Ae=(r,e,t)=>e.has(r)?fh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ue=(r,e,t,n)=>(Wu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),je=(r,e,t)=>(Wu(r,e,"access private method"),t);var hh=(r,e,t,n)=>({set _(s){ue(r,e,s,t)},get _(){return w(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ai(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function we(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function J0(r){return"_def"in r}function xi(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function Y0(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const R=typeof s=="string"?i:s,C=R??{},{param:p}=C,y=Ai(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof s=="string"?{refId:s}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),y),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(we(this,"ZodObject")){const N=this.extend;P.extend=function(...ve){var Le,qe,Ze,tt,pt,Rt;const I=N.apply(this,ve);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(pt=this._def.openapi)===null||pt===void 0?void 0:pt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},xi(r,"optional"),xi(r,"nullable"),xi(r,"default"),xi(r,"transform"),xi(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}function Po(r,e){if(r==null||e===null||e===void 0)return r===e;if(r===e||r.valueOf()===e.valueOf())return!0;if(Array.isArray(r)&&(!Array.isArray(e)||r.length!==e.length)||!(r instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(r);return Object.keys(e).every(n=>t.indexOf(n)!==-1)&&t.every(n=>Po(r[n],e[n]))}class X0{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n){this.buckets.set(t,[e]);return}n.some(i=>Po(i,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>Po(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const i of this.buckets.values())e+=1,t+=i.length,i.length>1&&(n+=1);const s=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:s}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)t^=this.hashCodeOf(e[n])*n;return t}if(typeof e=="string"){for(let n=0;n<e.length;n++)t^=e.charCodeAt(n)*n;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[n,s]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(s??"");return t}}function Ri(r){return r==null}function Pi(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function Q0(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function js(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function ph(r){return r.filter(e=>!Ri(e))}const ll=Po;function ev(r){const e=new X0;return r.forEach(t=>e.put(t)),[...e.values()]}function gm(r){return typeof r=="string"}class tv{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,s,i;const a=this.schemaWithRefId(e,t),o=(n=a._def.openapi)===null||n===void 0?void 0:n.metadata,c=a.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(i=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&i!==void 0?i:e})}));return this._definitions.push({type:"parameter",schema:c}),c}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:"component",componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class Gc{constructor(e){this.message=e}}class _i extends Gc{constructor(e,t){super(e),this.data=t}}class $o extends Gc{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 wi(r,e){try{return r()}catch(t){throw t instanceof $o?new $o(Object.assign(Object.assign({},t.data),e)):t}}class rv extends Gc{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class Ke{static getMetadata(e){var t;const n=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:n._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:i},s==null?void 0:s.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),n=e._def.openapi?e._def.openapi:t._def.openapi;return n==null?void 0:n._internal}static getParamMetadata(e){var t,n;const s=this.unwrapChained(e),i=e._def.openapi?e._def.openapi:s._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:i==null?void 0:i._internal,metadata:Object.assign(Object.assign({},i==null?void 0:i.metadata),{param:Object.assign({description:a},(n=i==null?void 0:i.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return js(Q0(e,["param"]),Ri)}static buildParameterMetadata(e){return js(e,Ri)}static applySchemaMetadata(e,t){return js(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Ri)}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&&we(e,t)?e:we(e,"ZodOptional")||we(e,"ZodNullable")||we(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):we(e,"ZodDefault")||we(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):we(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):we(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return we(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class nv{transform(e,t,n){var s,i;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(i=e._def.maxLength)===null||i===void 0?void 0:i.value})}}class sv{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class iv{transform(e,t,n,s,i){const a=[...e.options.values()],o=a.map(s);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(a,e.discriminator,i)}}mapDiscriminator(e,t,n){if(e.some(i=>Ke.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=Ke.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(we(c,"ZodEnum")||we(c,"ZodNativeEnum")){Object.values(c.enum).filter(gm).forEach(m=>{s[m]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=n(o)}),{propertyName:t,mapping:s}}}class av{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class ov{transform(e,t,n,s){const a={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!we(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class cv{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function uv(r){const t=Object.keys(r).filter(i=>typeof r[r[i]]!="number").map(i=>r[i]),n=t.filter(i=>typeof i=="number").length,s=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:s}}class lv{transform(e,t){const{type:n,values:s}=uv(e._def.values);if(n==="mixed")throw new Gc("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:s})}}class dv{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class fv{transform(e,t,n,s){var i;const a=(i=Ke.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=Pi(e._def.shape(),s);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=a.schema;s(u);const f=this.requiredKeysOf(u),m=Pi(u==null?void 0:u._def.shape(),s),R=Object.fromEntries(Object.entries(c).filter(([y,A])=>!ll(m[y],A))),C=o.filter(y=>!f.includes(y)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:R}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return we(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!Ke.isOptionalSchema(n)).map(([t,n])=>t)}}class hv{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(we(i,"ZodEnum")||we(i,"ZodNativeEnum")){const c=Object.values(i.enum).filter(gm).reduce((u,f)=>Object.assign(Object.assign({},u),{[f]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class pv{transform(e,t){var n,s,i;const a=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(i=e.maxLength)!==null&&i!==void 0?i:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:a==null?void 0:a.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time"}getZodStringCheck(e,t){return e._def.checks.find(n=>n.kind===t)}}class mv{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:s}=e._def,i=s.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(i))}}class yv{transform(e,t,n){const i=this.flattenUnionTypes(e).map(a=>{const o=this.unwrapNullable(a);return n(o)});return{anyOf:t(i)}}flattenUnionTypes(e){return we(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return we(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class gv{constructor(e){this.versionSpecifics=e,this.objectTransformer=new fv,this.stringTransformer=new pv,this.numberTransformer=new dv,this.bigIntTransformer=new sv,this.literalTransformer=new cv,this.enumTransformer=new av,this.nativeEnumTransformer=new lv,this.arrayTransformer=new nv,this.unionTransformer=new yv,this.discriminatedUnionTransformer=new iv,this.intersectionTransformer=new ov,this.recordTransformer=new hv,this.tupleTransformer=new mv(e)}transform(e,t,n,s,i){if(we(e,"ZodNull"))return this.versionSpecifics.nullType;if(we(e,"ZodUnknown")||we(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(we(e,"ZodObject"))return this.objectTransformer.transform(e,i,o=>this.versionSpecifics.mapNullableType(o,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,s);return Object.assign(Object.assign({},a),{default:i})}transformSchemaWithoutDefault(e,t,n,s){if(we(e,"ZodUnknown")||we(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(we(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(we(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(we(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(we(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(we(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(we(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(we(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(we(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(we(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=Ke.getRefId(e);throw new rv({currentSchema:e._def,schemaName:i})}}class vm{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new gv(t),this.sortDefinitions()}generateDocumentData(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents(),paths:this.pathRefs}}generateComponents(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents()}}buildComponents(){var e,t;const n={};return this.rawComponents.forEach(({componentType:s,name:i,component:a})=>{var o;(o=n[s])!==null&&o!==void 0||(n[s]={}),n[s][i]=a}),Object.assign(Object.assign({},n),{schemas:Object.assign(Object.assign({},(e=n.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=n.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,n)=>{if(!("type"in t))return"type"in n?-1:0;if(!("type"in n))return 1;const s=e.findIndex(a=>a===t.type),i=e.findIndex(a=>a===n.type);return s-i})}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=Ke.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,s,i,a,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(i=e._internal)===null||i===void 0?void 0:i.refId]:void 0;if(!(!(!((a=e==null?void 0:e._internal)===null||a===void 0)&&a.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new _i(`Conflicting location for parameter ${u.name}`,{key:"in",values:ph([u.in,t==null?void 0:t.in,c==null?void 0:c.in])});if(c&&u.name!==c.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new _i("Conflicting names for parameter",{key:"name",values:ph([u.name,t==null?void 0:t.name,c==null?void 0:c.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var n;const s=Ke.getMetadata(e),i=(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param,a=this.getParameterRef(s,{in:t});if(a)return[a];if(we(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,R;const C=Ke.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const y=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(y!=null&&y.name&&y.name!==u)throw new _i("Conflicting names for parameter",{key:"name",values:[u,y.name]});if(y!=null&&y.in&&y.in!==t)throw new _i(`Conflicting location for parameter ${(R=y.name)!==null&&R!==void 0?R:u}`,{key:"in",values:[t,y.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(i!=null&&i.in&&i.in!==t)throw new _i(`Conflicting location for parameter ${i.name}`,{key:"in",values:[t,i.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=Ke.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!Ke.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?Ke.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=Ke.getMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=s==null?void 0:s.name,a=s==null?void 0:s.in;if(!i)throw new $o({missingField:"name"});if(!a)throw new $o({missingField:"in",paramName:i});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:a,name:i})}generateSchemaWithMetadata(e){var t;const n=Ke.unwrapChained(e),s=Ke.getMetadata(e),i=Ke.getDefaultValue(e),a=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),i);return s!=null&&s.metadata?Ke.applySchemaMetadata(a,s.metadata):js(a,Ri)}constructReferencedOpenAPISchema(e){var t;const n=Ke.getMetadata(e),s=Ke.unwrapChained(e),i=Ke.getDefaultValue(e),a=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,a):this.toOpenAPISchema(s,a,i)}generateSimpleSchema(e){var t;const n=Ke.getMetadata(e),s=Ke.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=js(Ke.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||ll(f,i[m]));if(o.type)return{allOf:[a,o]};const c=js(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||ll(f,i[m])),u=Ke.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=Ke.getRefId(e),n=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=n,{$ref:this.generateSchemaRef(t)}):n}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,n=Ai(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),s=this.cleanParameter(e.params),i=this.cleanParameter(e.cookies),a=wi(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=wi(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=wi(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=wi(()=>{if(Array.isArray(t))return t.flatMap(m=>this.generateInlineParameters(m,"header"));const f=this.cleanParameter(t);return f?this.generateInlineParameters(f,"header"):[]},{location:"header"});return[...o,...a,...u,...c]}cleanParameter(e){if(e)return we(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=Ai(e,["method","path","request","responses"]),o=Pi(i,m=>this.getResponse(m)),c=wi(()=>this.getParameters(s),{route:`${t} ${n}`}),u=this.getRequestBody(s==null?void 0:s.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},a),c.length>0?{parameters:[...a.parameters||[],...c]}:{}),u?{requestBody:u}:{}),{responses:o})}}generateSingleRoute(e){const t=this.generatePath(e);return this.pathRefs[e.path]=Object.assign(Object.assign({},this.pathRefs[e.path]),t),t}getResponse(e){var{content:t,headers:n}=e,s=Ai(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=we(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},s),{headers:a}),i)}getResponseHeaders(e){const t=e._def.shape();return Pi(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return Pi(e,t=>{if(!t||!J0(t.schema))return t;const{schema:n}=t,s=Ai(t,["schema"]),i=this.generateSchemaWithRef(n);return Object.assign({schema:i},s)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),n)}}class vv{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=ev(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 bv{constructor(e){const t=new vv;this.generator=new vm(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class xv{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 _v(r){return"type"in r&&r.type==="webhook"}class wv{constructor(e){this.definitions=e,this.webhookRefs={};const t=new xv;this.generator=new vm(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(_v).forEach(n=>this.generateSingleWebhook(n.webhook)),Object.assign(Object.assign(Object.assign({},e),t),{webhooks:this.webhookRefs})}generateComponents(){return this.generator.generateComponents()}generateSingleWebhook(e){const t=this.generator.generatePath(e);return this.webhookRefs[e.path]=Object.assign(Object.assign({},this.webhookRefs[e.path]),t),t}}var bm=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},kv=r=>{const{groups:e,path:t}=Sv(r),n=bm(t);return Av(n,e)},Sv=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},Av=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let s=r.length-1;s>=0;s--)if(r[s].includes(n)){r[s]=r[s].replace(n,e[t][1]);break}}return r},bo={},mh=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(bo[r]||(e[2]?bo[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:bo[r]=[r,e[1],!0]),bo[r]):null},xm=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},Ov=r=>xm(r,decodeURI),_m=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const s=e.charCodeAt(n);if(s===37){const i=e.indexOf("?",n),a=e.slice(t,i===-1?void 0:i);return Ov(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},Ev=r=>{const e=_m(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},nn=(...r)=>{let e="",t=!1;for(let n of r)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),n[0]!=="/"&&(n=`/${n}`),n==="/"&&t?e=`${e}/`:n!=="/"&&(e=`${e}${n}`),n==="/"&&e===""&&(e="/");return e},wm=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))n+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&n===""?t.push("/"):t.push(n);const i=s.replace("?","");n+="/"+i,t.push(n)}else n+="/"+s}),t.filter((s,i,a)=>a.indexOf(s)===i)},Ku=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?Qd(r):r):r,km=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let a=r.indexOf(`?${e}`,8);for(a===-1&&(a=r.indexOf(`&${e}`,8));a!==-1;){const o=r.charCodeAt(a+e.length+1);if(o===61){const c=a+e.length+2,u=r.indexOf("&",c);return Ku(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";a=r.indexOf(`&${e}`,a+1)}if(n=/[%+]/.test(r),!n)return}const s={};n??(n=/[%+]/.test(r));let i=r.indexOf("?",8);for(;i!==-1;){const a=r.indexOf("&",i+1);let o=r.indexOf("=",i);o>a&&a!==-1&&(o=-1);let c=r.slice(i+1,o===-1?a===-1?void 0:a:o);if(n&&(c=Ku(c)),i=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=Ku(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},Iv=km,Cv=(r,e)=>km(r,e,!0),Qd=decodeURIComponent,jv=/^[\w!#$%&'*.^`|~+-]+$/,Tv=/^[ !#-:<-[\]-~]*$/,Nv=(r,e)=>{const t=r.trim().split(";"),n={};for(let s of t){s=s.trim();const i=s.indexOf("=");if(i===-1)continue;const a=s.substring(0,i).trim();if(!jv.test(a))continue;let o=s.substring(i+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Tv.test(o)&&(n[a]=Qd(o))}return n},Bv=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?Nv(n):{}},De=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});se(this,"res");se(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})}},Rv=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),Pv=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,$v=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Zv=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Dv=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!Pv.test(i))break;try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new De(400,{message:o})}break;case"form":{if(!i||!($v.test(i)||Zv.test(i)))break;let o;if(t.req.bodyCache.formData)o=await t.req.bodyCache.formData;else try{const u=await t.req.arrayBuffer();o=await Rv(u,i),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new De(400,{message:f})}const c={};o.forEach((u,f)=>{f.endsWith("[]")?(c[f]??(c[f]=[])).push(u):Array.isArray(c[f])?c[f].push(u):f in c?c[f]=[c[f],u]:c[f]=u}),s=c;break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=Bv(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const xs=(r,e,t)=>Dv(r,async(n,s)=>{const i=await e.safeParseAsync(n);if(t){const a=await t({data:n,...i,target:r},s);if(a){if(a instanceof Response)return a;if("response"in a)return a.response}}return i.success?i.data:s.json(i,400)});var Mv=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,i=(r instanceof Sm?r.raw.headers:r.headers).get("Content-Type");return i!=null&&i.startsWith("multipart/form-data")||i!=null&&i.startsWith("application/x-www-form-urlencoded")?Vv(r,{all:t,dot:n}):{}};async function Vv(r,e){const t=await r.formData();return t?Uv(t,e):{}}function Uv(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?Lv(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(qv(t,n,s),delete t[n])}),t}var Lv=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},qv=(r,e,t)=>{let n=r;const s=e.split(".");s.forEach((i,a)=>{a===s.length-1?n[i]=t:((!n[i]||typeof n[i]!="object"||Array.isArray(n[i])||n[i]instanceof File)&&(n[i]=Object.create(null)),n=n[i])})},yh=r=>xm(r,Qd),$s,tr,Xr,Am,Om,dl,cn,cm,Sm=(cm=class{constructor(r,e="/",t=[[]]){Ae(this,Xr);se(this,"raw");Ae(this,$s);Ae(this,tr);se(this,"routeIndex",0);se(this,"path");se(this,"bodyCache",{});Ae(this,cn,r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const s=Object.keys(e)[0];return s?e[s].then(i=>(s==="json"&&(i=JSON.stringify(i)),new Response(i)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,ue(this,tr,t),ue(this,$s,{})}param(r){return r?je(this,Xr,Am).call(this,r):je(this,Xr,Om).call(this)}query(r){return Iv(this.url,r)}queries(r){return Cv(this.url,r)}header(r){if(r)return this.raw.headers.get(r.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,n)=>{e[n]=t}),e}async parseBody(r){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await Mv(this,r))}json(){return w(this,cn).call(this,"json")}text(){return w(this,cn).call(this,"text")}arrayBuffer(){return w(this,cn).call(this,"arrayBuffer")}blob(){return w(this,cn).call(this,"blob")}formData(){return w(this,cn).call(this,"formData")}addValidatedData(r,e){w(this,$s)[r]=e}valid(r){return w(this,$s)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return w(this,tr)[0].map(([[,r]])=>r)}get routePath(){return w(this,tr)[0].map(([[,r]])=>r)[this.routeIndex].path}},$s=new WeakMap,tr=new WeakMap,Xr=new WeakSet,Am=function(r){const e=w(this,tr)[0][this.routeIndex][1][r],t=je(this,Xr,dl).call(this,e);return t?/\%/.test(t)?yh(t):t:void 0},Om=function(){const r={},e=Object.keys(w(this,tr)[0][this.routeIndex][1]);for(const t of e){const n=je(this,Xr,dl).call(this,w(this,tr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?yh(n):n)}return r},dl=function(r){return w(this,tr)[1]?w(this,tr)[1][r]:r},cn=new WeakMap,cm),Hv={Stringify:1,BeforeStream:2,Stream:3},Em=async(r,e,t,n,s)=>{typeof r=="object"&&!(r instanceof String)&&(r instanceof Promise||(r=r.toString()),r instanceof Promise&&(r=await r));const i=r.callbacks;return i!=null&&i.length?(s?s[0]+=r:s=[r],Promise.all(i.map(o=>o({phase:e,buffer:s,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Em(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},Fv="text/plain; charset=UTF-8",zu=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Ha,Fa,Pr,qn,$r,Ge,Qe,br,Zr,Wa,Zs,Ds,Ka,za,At,Ut,um,Im=(um=class{constructor(r,e){Ae(this,At);Ae(this,Ha);Ae(this,Fa);se(this,"env",{});Ae(this,Pr);se(this,"finalized",!1);se(this,"error");Ae(this,qn,200);Ae(this,$r);Ae(this,Ge);Ae(this,Qe);Ae(this,br);Ae(this,Zr,!0);Ae(this,Wa);Ae(this,Zs);Ae(this,Ds);Ae(this,Ka);Ae(this,za);se(this,"render",(...r)=>(w(this,Zs)??ue(this,Zs,e=>this.html(e)),w(this,Zs).call(this,...r)));se(this,"setLayout",r=>ue(this,Wa,r));se(this,"getLayout",()=>w(this,Wa));se(this,"setRenderer",r=>{ue(this,Zs,r)});se(this,"header",(r,e,t)=>{if(e===void 0){w(this,Ge)?w(this,Ge).delete(r):w(this,Qe)&&delete w(this,Qe)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(w(this,Ge)||(ue(this,Zr,!1),ue(this,Ge,new Headers(w(this,Qe))),ue(this,Qe,{})),w(this,Ge).append(r,e)):w(this,Ge)?w(this,Ge).set(r,e):(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});se(this,"status",r=>{ue(this,Zr,!1),ue(this,qn,r)});se(this,"set",(r,e)=>{w(this,Pr)??ue(this,Pr,new Map),w(this,Pr).set(r,e)});se(this,"get",r=>w(this,Pr)?w(this,Pr).get(r):void 0);se(this,"newResponse",(...r)=>je(this,At,Ut).call(this,...r));se(this,"body",(r,e,t)=>typeof e=="number"?je(this,At,Ut).call(this,r,e,t):je(this,At,Ut).call(this,r,e));se(this,"text",(r,e,t)=>{if(!w(this,Qe)){if(w(this,Zr)&&!t&&!e)return new Response(r);ue(this,Qe,{})}return w(this,Qe)["content-type"]=Fv,typeof e=="number"?je(this,At,Ut).call(this,r,e,t):je(this,At,Ut).call(this,r,e)});se(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?je(this,At,Ut).call(this,n,e,t):je(this,At,Ut).call(this,n,e)});se(this,"html",(r,e,t)=>(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Em(r,Hv.Stringify,!1,{}).then(n=>typeof e=="number"?je(this,At,Ut).call(this,n,e,t):je(this,At,Ut).call(this,n,e)):typeof e=="number"?je(this,At,Ut).call(this,r,e,t):je(this,At,Ut).call(this,r,e)));se(this,"redirect",(r,e)=>(w(this,Ge)??ue(this,Ge,new Headers),w(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));se(this,"notFound",()=>(w(this,Ds)??ue(this,Ds,()=>new Response),w(this,Ds).call(this,this)));ue(this,Ha,r),e&&(ue(this,$r,e.executionCtx),this.env=e.env,ue(this,Ds,e.notFoundHandler),ue(this,za,e.path),ue(this,Ka,e.matchResult))}get req(){return w(this,Fa)??ue(this,Fa,new Sm(w(this,Ha),w(this,za),w(this,Ka))),w(this,Fa)}get event(){if(w(this,$r)&&"respondWith"in w(this,$r))return w(this,$r);throw Error("This context has no FetchEvent")}get executionCtx(){if(w(this,$r))return w(this,$r);throw Error("This context has no ExecutionContext")}get res(){return ue(this,Zr,!1),w(this,br)||ue(this,br,new Response("404 Not Found",{status:404}))}set res(r){if(ue(this,Zr,!1),w(this,br)&&r)try{for(const[e,t]of w(this,br).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=w(this,br).headers.getSetCookie();r.headers.delete("set-cookie");for(const s of n)r.headers.append("set-cookie",s)}else r.headers.set(e,t)}catch(e){if(e instanceof TypeError&&e.message.includes("immutable")){this.res=new Response(r.body,{headers:r.headers,status:r.status});return}else throw e}ue(this,br,r),this.finalized=!0}get var(){return w(this,Pr)?Object.fromEntries(w(this,Pr)):{}}},Ha=new WeakMap,Fa=new WeakMap,Pr=new WeakMap,qn=new WeakMap,$r=new WeakMap,Ge=new WeakMap,Qe=new WeakMap,br=new WeakMap,Zr=new WeakMap,Wa=new WeakMap,Zs=new WeakMap,Ds=new WeakMap,Ka=new WeakMap,za=new WeakMap,At=new WeakSet,Ut=function(r,e,t){if(w(this,Zr)&&!t&&!e&&w(this,qn)===200)return new Response(r,{headers:w(this,Qe)});if(e&&typeof e!="number"){const s=new Headers(e.headers);w(this,Ge)&&w(this,Ge).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=zu(s,w(this,Qe));return new Response(r,{headers:i,status:e.status??w(this,qn)})}const n=typeof e=="number"?e:w(this,qn);w(this,Qe)??ue(this,Qe,{}),w(this,Ge)??ue(this,Ge,new Headers),zu(w(this,Ge),w(this,Qe)),w(this,br)&&(w(this,br).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=w(this,Ge))==null||a.append(i,s):(o=w(this,Ge))==null||o.set(i,s)}),zu(w(this,Ge),w(this,Qe))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")w(this,Ge).set(s,i);else{w(this,Ge).delete(s);for(const a of i)w(this,Ge).append(s,a)}return new Response(r,{status:n,headers:w(this,Ge)})},um),gh=(r,e,t)=>(n,s)=>{let i=-1;const a=n instanceof Im;return o(0);async function o(c){if(c<=i)throw new Error("next() called multiple times");i=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&s||void 0,!m)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await m(n,()=>o(c+1))}catch(R){if(R instanceof Error&&a&&e)n.error=R,u=await e(R,n),f=!0;else throw R}return u&&(n.finalized===!1||f)&&(n.res=u),n}},st="ALL",Wv="all",Kv=["get","post","put","delete","options","patch"],Cm="Can not add a route since the matcher is already built.",jm=class extends Error{},zv=Symbol("composedHandler"),Gv=r=>r.text("404 Not Found",404),vh=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),rr,it,Nm,Dr,Pn,Ao,Oo,lm,Tm=(lm=class{constructor(e={}){Ae(this,it);se(this,"get");se(this,"post");se(this,"put");se(this,"delete");se(this,"options");se(this,"patch");se(this,"all");se(this,"on");se(this,"use");se(this,"router");se(this,"getPath");se(this,"_basePath","/");Ae(this,rr,"/");se(this,"routes",[]);Ae(this,Dr,Gv);se(this,"errorHandler",vh);se(this,"onError",e=>(this.errorHandler=e,this));se(this,"notFound",e=>(ue(this,Dr,e),this));se(this,"fetch",(e,...t)=>je(this,it,Oo).call(this,e,t[1],t[0],e.method));se(this,"request",(e,t,n,s)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,s):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${nn("/",e)}`,t),n,s)));se(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(je(this,it,Oo).call(this,e.request,e,void 0,e.request.method))})});[...Kv,Wv].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?ue(this,rr,i):je(this,it,Pn).call(this,s,w(this,rr),i),a.forEach(o=>{je(this,it,Pn).call(this,s,w(this,rr),o)}),this)}),this.on=(s,i,...a)=>{for(const o of[i].flat()){ue(this,rr,o);for(const c of[s].flat())a.map(u=>{je(this,it,Pn).call(this,c.toUpperCase(),w(this,rr),u)})}return this},this.use=(s,...i)=>(typeof s=="string"?ue(this,rr,s):(ue(this,rr,"*"),i.unshift(s)),i.forEach(a=>{je(this,it,Pn).call(this,st,w(this,rr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??_m:Ev}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{var a;let i;t.errorHandler===vh?i=s.handler:(i=async(o,c)=>(await gh([],t.errorHandler)(o,()=>s.handler(o,c))).res,i[zv]=s.handler),je(a=n,it,Pn).call(a,s.method,s.path,i)}),this}basePath(e){const t=je(this,it,Nm).call(this);return t._basePath=nn(this._basePath,e),t}mount(e,t,n){let s,i;n&&(typeof n=="function"?i=n:(i=n.optionHandler,s=n.replaceRequest));const a=i?c=>{const u=i(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};s||(s=(()=>{const c=nn(this._basePath,e),u=c==="/"?0:c.length;return f=>{const m=new URL(f.url);return m.pathname=m.pathname.slice(u)||"/",new Request(m,f)}})());const o=async(c,u)=>{const f=await t(s(c.req.raw),...a(c));if(f)return f;await u()};return je(this,it,Pn).call(this,st,nn(e,"*"),o),this}},rr=new WeakMap,it=new WeakSet,Nm=function(){const e=new Tm({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Dr=new WeakMap,Pn=function(e,t,n){e=e.toUpperCase(),t=nn(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)},Ao=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Oo=function(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await je(this,it,Oo).call(this,e,t,n,"GET")))();const i=this.getPath(e,{env:n}),a=this.router.match(s,i),o=new Im(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:w(this,Dr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await w(this,Dr).call(this,o)})}catch(f){return je(this,it,Ao).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:w(this,Dr).call(this,o))).catch(f=>je(this,it,Ao).call(this,f,o)):u??w(this,Dr).call(this,o)}const c=gh(a[0],this.errorHandler,w(this,Dr));return(async()=>{try{const u=await c(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return je(this,it,Ao).call(this,u,o)}})()},lm),Zo="[^/]+",$i=".*",Zi="(?:|/.*)",Oi=Symbol(),Jv=new Set(".\\+*[^]$()");function Yv(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$i||r===Zi?1:e===$i||e===Zi?-1:r===Zo?1:e===Zo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Hn,Fn,nr,dm,fl=(dm=class{constructor(){Ae(this,Hn);Ae(this,Fn);Ae(this,nr,Object.create(null))}insert(e,t,n,s,i){if(e.length===0){if(w(this,Hn)!==void 0)throw Oi;if(i)return;ue(this,Hn,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",$i]:["","",Zo]:a==="/*"?["","",Zi]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||Zo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw Oi;if(u=w(this,nr)[m],!u){if(Object.keys(w(this,nr)).some(R=>R!==$i&&R!==Zi))throw Oi;if(i)return;u=w(this,nr)[m]=new fl,f!==""&&ue(u,Fn,s.varIndex++)}!i&&f!==""&&n.push([f,w(u,Fn)])}else if(u=w(this,nr)[a],!u){if(Object.keys(w(this,nr)).some(f=>f.length>1&&f!==$i&&f!==Zi))throw Oi;if(i)return;u=w(this,nr)[a]=new fl}u.insert(o,t,n,s,i)}buildRegExpStr(){const t=Object.keys(w(this,nr)).sort(Yv).map(n=>{const s=w(this,nr)[n];return(typeof w(s,Fn)=="number"?`(${n})@${w(s,Fn)}`:Jv.has(n)?`\\${n}`:n)+s.buildRegExpStr()});return typeof w(this,Hn)=="number"&&t.unshift(`#${w(this,Hn)}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},Hn=new WeakMap,Fn=new WeakMap,nr=new WeakMap,dm),zc,Ga,fm,Xv=(fm=class{constructor(){Ae(this,zc,{varIndex:0});Ae(this,Ga,new fl)}insert(r,e,t){const n=[],s=[];for(let a=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${a}`;return s[a]=[u,c],a++,o=!0,u}),!o)break}const i=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=s.length-1;a>=0;a--){const[o]=s[a];for(let c=i.length-1;c>=0;c--)if(i[c].indexOf(o)!==-1){i[c]=i[c].replace(o,s[a][1]);break}}return w(this,Ga).insert(i,e,n,w(this,zc),t),n}buildRegExp(){let r=w(this,Ga).buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,i,a)=>i!==void 0?(t[++e]=Number(i),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},zc=new WeakMap,Ga=new WeakMap,fm),Bm=[],Qv=[/^$/,[],Object.create(null)],Eo=Object.create(null);function Rm(r){return Eo[r]??(Eo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function eb(){Eo=Object.create(null)}function tb(r){var u;const e=new Xv,t=[];if(r.length===0)return Qv;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[R,C])=>f?1:R?-1:m.length-C.length),s=Object.create(null);for(let f=0,m=-1,R=n.length;f<R;f++){const[C,p,y]=n[f];C?s[p]=[y.map(([O])=>[O,Object.create(null)]),Bm]:m++;let A;try{A=e.insert(p,m,C)}catch(O){throw O===Oi?new jm(p):O}C||(t[m]=y.map(([O,P])=>{const N=Object.create(null);for(P-=1;P>=0;P--){const[ve,Le]=A[P];N[ve]=Le}return[O,N]}))}const[i,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let R=0,C=t[f].length;R<C;R++){const p=(u=t[f][R])==null?void 0:u[1];if(!p)continue;const y=Object.keys(p);for(let A=0,O=y.length;A<O;A++)p[y[A]]=o[p[y[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[i,c,s]}function _s(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(Rm(t).test(e))return[...r[t]]}}var un,ln,oi,Pm,$m,hm,rb=(hm=class{constructor(){Ae(this,oi);se(this,"name","RegExpRouter");Ae(this,un);Ae(this,ln);ue(this,un,{[st]:Object.create(null)}),ue(this,ln,{[st]:Object.create(null)})}add(r,e,t){var o;const n=w(this,un),s=w(this,ln);if(!n||!s)throw new Error(Cm);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[st]).forEach(u=>{c[r][u]=[...c[st][u]]})}),e==="/*"&&(e="*");const i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Rm(e);r===st?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=_s(n[u],e)||_s(n[st],e)||[])}):(o=n[r])[e]||(o[e]=_s(n[r],e)||_s(n[st],e)||[]),Object.keys(n).forEach(u=>{(r===st||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,i])})}),Object.keys(s).forEach(u=>{(r===st||r===u)&&Object.keys(s[u]).forEach(f=>c.test(f)&&s[u][f].push([t,i]))});return}const a=wm(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(s).forEach(m=>{var R;(r===st||r===m)&&((R=s[m])[f]||(R[f]=[..._s(n[m],f)||_s(n[st],f)||[]]),s[m][f].push([t,i-u+c+1]))})}}match(r,e){eb();const t=je(this,oi,Pm).call(this);return this.match=(n,s)=>{const i=t[n]||t[st],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],Bm];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}},un=new WeakMap,ln=new WeakMap,oi=new WeakSet,Pm=function(){const r=Object.create(null);return Object.keys(w(this,ln)).concat(Object.keys(w(this,un))).forEach(e=>{r[e]||(r[e]=je(this,oi,$m).call(this,e))}),ue(this,un,ue(this,ln,void 0)),r},$m=function(r){const e=[];let t=r===st;return[w(this,un),w(this,ln)].forEach(n=>{const s=n[r]?Object.keys(n[r]).map(i=>[i,n[r][i]]):[];s.length!==0?(t||(t=!0),e.push(...s)):r!==st&&e.push(...Object.keys(n[st]).map(i=>[i,n[st][i]]))}),t?tb(e):null},hm),dn,Mr,pm,nb=(pm=class{constructor(r){se(this,"name","SmartRouter");Ae(this,dn,[]);Ae(this,Mr,[]);ue(this,dn,r.routers)}add(r,e,t){if(!w(this,Mr))throw new Error(Cm);w(this,Mr).push([r,e,t])}match(r,e){if(!w(this,Mr))throw new Error("Fatal error");const t=w(this,dn),n=w(this,Mr),s=t.length;let i=0,a;for(;i<s;i++){const o=t[i];try{for(let c=0,u=n.length;c<u;c++)o.add(...n[c]);a=o.match(r,e)}catch(c){if(c instanceof jm)continue;throw c}this.match=o.match.bind(o),ue(this,dn,[o]),ue(this,Mr,void 0);break}if(i===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(w(this,Mr)||w(this,dn).length!==1)throw new Error("No active router has been determined yet.");return w(this,dn)[0]}},dn=new WeakMap,Mr=new WeakMap,pm),fn,vt,Wn,Ms,Ot,Vr,$n,mm,Zm=(mm=class{constructor(r,e,t){Ae(this,Vr);Ae(this,fn);Ae(this,vt);Ae(this,Wn);Ae(this,Ms,0);Ae(this,Ot,Object.create(null));if(ue(this,vt,t||Object.create(null)),ue(this,fn,[]),r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},ue(this,fn,[n])}ue(this,Wn,[])}insert(r,e,t){ue(this,Ms,++hh(this,Ms)._);let n=this;const s=kv(e),i=[];for(let c=0,u=s.length;c<u;c++){const f=s[c];if(Object.keys(w(n,vt)).includes(f)){n=w(n,vt)[f];const R=mh(f);R&&i.push(R[1]);continue}w(n,vt)[f]=new Zm;const m=mh(f);m&&(w(n,Wn).push(m),i.push(m[1])),n=w(n,vt)[f]}const a=Object.create(null),o={handler:t,possibleKeys:i.filter((c,u,f)=>f.indexOf(c)===u),score:w(this,Ms)};return a[r]=o,w(n,fn).push(a),n}search(r,e){const t=[];ue(this,Ot,Object.create(null));let s=[this];const i=bm(e);for(let o=0,c=i.length;o<c;o++){const u=i[o],f=o===c-1,m=[];for(let R=0,C=s.length;R<C;R++){const p=s[R],y=w(p,vt)[u];y&&(ue(y,Ot,w(p,Ot)),f?(w(y,vt)["*"]&&t.push(...je(this,Vr,$n).call(this,w(y,vt)["*"],r,w(p,Ot),Object.create(null))),t.push(...je(this,Vr,$n).call(this,y,r,w(p,Ot),Object.create(null)))):m.push(y));for(let A=0,O=w(p,Wn).length;A<O;A++){const P=w(p,Wn)[A],N={...w(p,Ot)};if(P==="*"){const pt=w(p,vt)["*"];pt&&(t.push(...je(this,Vr,$n).call(this,pt,r,w(p,Ot),Object.create(null))),m.push(pt));continue}if(u==="")continue;const[ve,Le,qe]=P,Ze=w(p,vt)[ve],tt=i.slice(o).join("/");if(qe instanceof RegExp&&qe.test(tt)){N[Le]=tt,t.push(...je(this,Vr,$n).call(this,Ze,r,w(p,Ot),N));continue}(qe===!0||qe.test(u))&&(N[Le]=u,f?(t.push(...je(this,Vr,$n).call(this,Ze,r,N,w(p,Ot))),w(Ze,vt)["*"]&&t.push(...je(this,Vr,$n).call(this,w(Ze,vt)["*"],r,N,w(p,Ot)))):(ue(Ze,Ot,N),m.push(Ze)))}}s=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},fn=new WeakMap,vt=new WeakMap,Wn=new WeakMap,Ms=new WeakMap,Ot=new WeakMap,Vr=new WeakSet,$n=function(r,e,t,n){const s=[];for(let i=0,a=w(r,fn).length;i<a;i++){const o=w(r,fn)[i],c=o[e]||o[st],u={};if(c!==void 0){c.params=Object.create(null);for(let f=0,m=c.possibleKeys.length;f<m;f++){const R=c.possibleKeys[f],C=u[c.score];c.params[R]=n[R]&&!C?n[R]:t[R]??n[R],u[c.score]=!0}s.push(c)}}return s},mm),Kn,ym,sb=(ym=class{constructor(){se(this,"name","TrieRouter");Ae(this,Kn);ue(this,Kn,new Zm)}add(r,e,t){const n=wm(e);if(n){for(let s=0,i=n.length;s<i;s++)w(this,Kn).insert(r,n[s],t);return}w(this,Kn).insert(r,e,t)}match(r,e){return w(this,Kn).search(r,e)}},Kn=new WeakMap,ym),ib=class extends Tm{constructor(r={}){super(r),this.router=r.router??new nb({routers:[new rb,new sb]})}},Be;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Be||(Be={}));var hl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(hl||(hl={}));const z=Be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),sn=r=>{switch(typeof r){case"undefined":return z.undefined;case"string":return z.string;case"number":return isNaN(r)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(r)?z.array:r===null?z.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?z.promise:typeof Map<"u"&&r instanceof Map?z.map:typeof Set<"u"&&r instanceof Set?z.set:typeof Date<"u"&&r instanceof Date?z.date:z.object;default:return z.unknown}},Z=Be.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"]),ab=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let or=class Dm extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof Dm))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};or.create=r=>new or(r);const Vs=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Be.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Be.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Be.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Be.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Be.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,Be.assertNever(r)}return{message:t}};let Mm=Vs;function ob(r){Mm=r}function Do(){return Mm}const Mo=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},cb=[];function H(r,e){const t=Do(),n=Mo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Vs?void 0:Vs].filter(s=>!!s)});r.common.issues.push(n)}let Ct=class Vm{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return Vm.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),Os=r=>({status:"dirty",value:r}),xt=r=>({status:"valid",value:r}),pl=r=>r.status==="aborted",ml=r=>r.status==="dirty",Li=r=>r.status==="valid",qi=r=>typeof Promise<"u"&&r instanceof Promise;function Vo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Um(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ae||(ae={}));var Ei,Ii;let Sr=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const bh=(r,e)=>{if(Li(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new or(r.common.issues);return this._error=t,this._error}}};function be(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}let Se=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return sn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ct,ctx:{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(qi(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},i=this._parseSync({data:e,path:s.path,parent:s});return bh(s,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(qi(s)?s:Promise.resolve(s));return bh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:Z.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new dr({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qn.create(this,this._def)}promise(){return qs.create(this,this._def)}or(e){return Ji.create([this,e],this._def)}and(e){return Yi.create(this,e,this._def)}transform(e){return new dr({...be(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ta({...be(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new ef({typeName:de.ZodBranded,type:this,...be(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ra({...be(this._def),innerType:this,catchValue:t,typeName:de.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return tf.create(this,e)}readonly(){return na.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const ub=/^c[^\s-]{8,}$/i,lb=/^[0-9a-z]+$/,db=/^[0-9A-HJKMNP-TV-Z]{26}$/,fb=/^[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,hb=/^[a-z0-9_-]{21}$/i,pb=/^[-+]?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)?)??$/,mb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Gu;const gb=/^(?:(?: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])$/,vb=/^(([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})))$/,bb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Lm="((\\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])))",xb=new RegExp(`^${Lm}$`);function qm(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function _b(r){return new RegExp(`^${qm(r)}$`)}function Hm(r){let e=`${Lm}T${qm(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function wb(r,e){return!!((e==="v4"||!e)&&gb.test(r)||(e==="v6"||!e)&&vb.test(r))}let Us=class Ci extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.string,received:i.parsedType}),pe}const n=new Ct;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?H(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&H(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")mb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"email",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Gu||(Gu=new RegExp(yb,"u")),Gu.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"emoji",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")fb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"uuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")hb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"nanoid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")ub.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")lb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid2",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")db.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"ulid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),H(s,{validation:"url",code:Z.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"regex",code:Z.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Hm(i).test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?xb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?_b(i).test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?pb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"duration",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?wb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"ip",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?bb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"base64",code:Z.invalid_string,message:i.message}),n.dirty()):Be.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:Z.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Ci({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ae.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ae.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ae.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ae.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ae.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ae.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ae.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ae.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ae.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ae.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ae.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...ae.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ae.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ae.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ae.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ae.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ae.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ae.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ae.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ae.errToObj(t)})}nonempty(e){return this.min(1,ae.errToObj(e))}trim(){return new Ci({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ci({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ci({...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}};Us.create=r=>{var e;return new Us({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};function kb(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}let Hi=class yl extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.number,received:i.parsedType}),pe}let n;const s=new Ct;for(const i of this._def.checks)i.kind==="int"?Be.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?kb(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_finite,message:i.message}),s.dirty()):Be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,s){return new yl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new yl({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ae.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ae.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ae.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ae.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Be.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Hi.create=r=>new Hi({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let Fi=class gl extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==z.bigint){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.bigint,received:i.parsedType}),pe}let n;const s=new Ct;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,s){return new gl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new gl({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Fi.create=r=>{var e;return new Fi({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};let Wi=class extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.boolean,received:n.parsedType}),pe}return xt(e.data)}};Wi.create=r=>new Wi({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let Ki=class Fm extends Se{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.date,received:i.parsedType}),pe}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_date}),pe}const n=new Ct;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Be.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Fm({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ae.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Ki.create=r=>new Ki({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,...be(r)});let Uo=class extends Se{_parse(e){if(this._getType(e)!==z.symbol){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.symbol,received:n.parsedType}),pe}return xt(e.data)}};Uo.create=r=>new Uo({typeName:de.ZodSymbol,...be(r)});let zi=class extends Se{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.undefined,received:n.parsedType}),pe}return xt(e.data)}};zi.create=r=>new zi({typeName:de.ZodUndefined,...be(r)});let Gi=class extends Se{_parse(e){if(this._getType(e)!==z.null){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.null,received:n.parsedType}),pe}return xt(e.data)}};Gi.create=r=>new Gi({typeName:de.ZodNull,...be(r)});let Ls=class extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return xt(e.data)}};Ls.create=r=>new Ls({typeName:de.ZodAny,...be(r)});let zn=class extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xt(e.data)}};zn.create=r=>new zn({typeName:de.ZodUnknown,...be(r)});let Hr=class extends Se{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:Z.invalid_type,expected:z.never,received:t.parsedType}),pe}};Hr.create=r=>new Hr({typeName:de.ZodNever,...be(r)});let Lo=class extends Se{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.void,received:n.parsedType}),pe}return xt(e.data)}};Lo.create=r=>new Lo({typeName:de.ZodVoid,...be(r)});let Qn=class Io extends Se{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==z.array)return H(t,{code:Z.invalid_type,expected:z.array,received:t.parsedType}),pe;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(H(t,{code:a?Z.too_big:Z.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(H(t,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(H(t,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Sr(t,a,t.path,o)))).then(a=>Ct.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Sr(t,a,t.path,o)));return Ct.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new Io({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new Io({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new Io({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};Qn.create=(r,e)=>new Qn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,...be(e)});function ks(r){if(r instanceof Wt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(ks(n))}return new Wt({...r._def,shape:()=>e})}else return r instanceof Qn?new Qn({...r._def,type:ks(r.element)}):r instanceof xr?xr.create(ks(r.unwrap())):r instanceof vn?vn.create(ks(r.unwrap())):r instanceof gn?gn.create(r.items.map(e=>ks(e))):r}let Wt=class Xt extends Se{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=Be.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==z.object){const u=this._getOrReturnCtx(e);return H(u,{code:Z.invalid_type,expected:z.object,received:u.parsedType}),pe}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Hr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Sr(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Hr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")o.length>0&&(H(s,{code:Z.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Sr(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,R=await f.value;u.push({key:m,value:R,alwaysSet:f.alwaysSet})}return u}).then(u=>Ct.mergeObjectSync(n,u)):Ct.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ae.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:de.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){const t={};return Be.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}omit(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return ks(this)}partial(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof xr;)i=i._def.innerType;t[n]=i}}),new Xt({...this._def,shape:()=>t})}keyof(){return Ym(Be.objectKeys(this.shape))}};Wt.create=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,...be(e)});Wt.strictCreate=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strict",catchall:Hr.create(),typeName:de.ZodObject,...be(e)});Wt.lazycreate=(r,e)=>new Wt({shape:r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,...be(e)});let Ji=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new or(o.ctx.common.issues));return H(t,{code:Z.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new or(c));return H(t,{code:Z.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Ji.create=(r,e)=>new Ji({options:r,typeName:de.ZodUnion,...be(e)});const Br=r=>r instanceof Xi?Br(r.schema):r instanceof dr?Br(r.innerType()):r instanceof Qi?[r.value]:r instanceof Ja?r.options:r instanceof ea?Be.objectValues(r.enum):r instanceof ta?Br(r._def.innerType):r instanceof zi?[void 0]:r instanceof Gi?[null]:r instanceof xr?[void 0,...Br(r.unwrap())]:r instanceof vn?[null,...Br(r.unwrap())]:r instanceof ef||r instanceof na?Br(r.unwrap()):r instanceof ra?Br(r._def.innerType):[];let Wm=class Km extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return H(t,{code:Z.invalid_type,expected:z.object,received:t.parsedType}),pe;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=Br(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Km({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...be(n)})}};function vl(r,e){const t=sn(r),n=sn(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&n===z.object){const s=Be.objectKeys(e),i=Be.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=vl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===z.array&&n===z.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=vl(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===z.date&&n===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Yi=class extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(pl(i)||pl(a))return pe;const o=vl(i.value,a.value);return o.valid?((ml(i)||ml(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:Z.invalid_intersection_types}),pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Yi.create=(r,e,t)=>new Yi({left:r,right:e,typeName:de.ZodIntersection,...be(t)});let gn=class zm extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return H(n,{code:Z.invalid_type,expected:z.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return H(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Sr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>Ct.mergeArray(t,a)):Ct.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new zm({...this._def,rest:e})}};gn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gn({items:r,typeName:de.ZodTuple,rest:null,...be(e)})};let Gm=class bl extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return H(n,{code:Z.invalid_type,expected:z.object,received:n.parsedType}),pe;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Sr(n,o,n.path,o)),value:a._parse(new Sr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?Ct.mergeObjectAsync(t,s):Ct.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Se?new bl({keyType:e,valueType:t,typeName:de.ZodRecord,...be(n)}):new bl({keyType:Us.create(),valueType:e,typeName:de.ZodRecord,...be(t)})}},qo=class extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.map)return H(n,{code:Z.invalid_type,expected:z.map,received:n.parsedType}),pe;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Sr(n,o,n.path,[u,"key"])),value:i._parse(new Sr(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}};qo.create=(r,e,t)=>new qo({valueType:e,keyType:r,typeName:de.ZodMap,...be(t)});let Ho=class xl extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return H(n,{code:Z.invalid_type,expected:z.set,received:n.parsedType}),pe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(H(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(H(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return pe;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Sr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new xl({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new xl({...this._def,maxSize:{value:e,message:ae.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ho.create=(r,e)=>new Ho({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,...be(e)});let Jm=class Co extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return H(t,{code:Z.invalid_type,expected:z.function,received:t.parsedType}),pe;function n(o,c){return Mo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Do(),Vs].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return Mo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Do(),Vs].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qs){const o=this;return xt(async function(...c){const u=new or([]),f=await o._def.args.parseAsync(c,i).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return xt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new or([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new or([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Co({...this._def,args:gn.create(e).rest(zn.create())})}returns(e){return new Co({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Co({args:e||gn.create([]).rest(zn.create()),returns:t||zn.create(),typeName:de.ZodFunction,...be(n)})}},Xi=class extends Se{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})}};Xi.create=(r,e)=>new Xi({getter:r,typeName:de.ZodLazy,...be(e)});let Qi=class extends Se{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qi.create=(r,e)=>new Qi({value:r,typeName:de.ZodLiteral,...be(e)});function Ym(r,e){return new Ja({values:r,typeName:de.ZodEnum,...be(e)})}let Ja=class _l extends Se{constructor(){super(...arguments),Ei.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Be.joinValues(n),received:t.parsedType,code:Z.invalid_type}),pe}if(Vo(this,Ei)||Um(this,Ei,new Set(this._def.values)),!Vo(this,Ei).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:Z.invalid_enum_value,options:n}),pe}return xt(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 _l.create(e,{...this._def,...t})}exclude(e,t=this._def){return _l.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Ei=new WeakMap;Ja.create=Ym;let ea=class extends Se{constructor(){super(...arguments),Ii.set(this,void 0)}_parse(e){const t=Be.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){const s=Be.objectValues(t);return H(n,{expected:Be.joinValues(s),received:n.parsedType,code:Z.invalid_type}),pe}if(Vo(this,Ii)||Um(this,Ii,new Set(Be.getValidEnumValues(this._def.values))),!Vo(this,Ii).has(e.data)){const s=Be.objectValues(t);return H(n,{received:n.data,code:Z.invalid_enum_value,options:s}),pe}return xt(e.data)}get enum(){return this._def.values}};Ii=new WeakMap;ea.create=(r,e)=>new ea({values:r,typeName:de.ZodNativeEnum,...be(e)});let qs=class extends Se{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.promise&&t.common.async===!1)return H(t,{code:Z.invalid_type,expected:z.promise,received:t.parsedType}),pe;const n=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return xt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qs.create=(r,e)=>new qs({type:r,typeName:de.ZodPromise,...be(e)});let dr=class extends Se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===de.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return pe;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?pe:c.status==="dirty"||t.value==="dirty"?Os(c.value):c});{if(t.value==="aborted")return pe;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?pe:o.status==="dirty"||t.value==="dirty"?Os(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Li(a))return a;const o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Li(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Be.assertNever(s)}};dr.create=(r,e,t)=>new dr({schema:r,typeName:de.ZodEffects,effect:e,...be(t)});dr.createWithPreprocess=(r,e,t)=>new dr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,...be(t)});let xr=class extends Se{_parse(e){return this._getType(e)===z.undefined?xt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(r,e)=>new xr({innerType:r,typeName:de.ZodOptional,...be(e)});let vn=class extends Se{_parse(e){return this._getType(e)===z.null?xt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(r,e)=>new vn({innerType:r,typeName:de.ZodNullable,...be(e)});let ta=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ta.create=(r,e)=>new ta({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...be(e)});let ra=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ra.create=(r,e)=>new ra({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...be(e)});let Fo=class extends Se{_parse(e){if(this._getType(e)!==z.nan){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};Fo.create=r=>new Fo({typeName:de.ZodNaN,...be(r)});const Sb=Symbol("zod_brand");let ef=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},tf=class Xm extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?pe:i.status==="dirty"?(t.dirty(),Os(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Xm({in:e,out:t,typeName:de.ZodPipeline})}},na=class extends Se{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Li(s)&&(s.value=Object.freeze(s.value)),s);return qi(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};na.create=(r,e)=>new na({innerType:r,typeName:de.ZodReadonly,...be(e)});function Qm(r,e={},t){return r?Ls.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Ls.create()}const Ab={object:Wt.lazycreate};var de;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(de||(de={}));const Ob=(r,e={message:`Input not instance of ${r.name}`})=>Qm(t=>t instanceof r,e),ey=Us.create,ty=Hi.create,Eb=Fo.create,Ib=Fi.create,ry=Wi.create,Cb=Ki.create,jb=Uo.create,Tb=zi.create,Nb=Gi.create,Bb=Ls.create,Rb=zn.create,Pb=Hr.create,$b=Lo.create,Zb=Qn.create,Db=Wt.create,Mb=Wt.strictCreate,Vb=Ji.create,Ub=Wm.create,Lb=Yi.create,qb=gn.create,Hb=Gm.create,Fb=qo.create,Wb=Ho.create,Kb=Jm.create,zb=Xi.create,Gb=Qi.create,Jb=Ja.create,Yb=ea.create,Xb=qs.create,xh=dr.create,Qb=xr.create,ex=vn.create,tx=dr.createWithPreprocess,rx=tf.create,nx=()=>ey().optional(),sx=()=>ty().optional(),ix=()=>ry().optional(),ax={string:r=>Us.create({...r,coerce:!0}),number:r=>Hi.create({...r,coerce:!0}),boolean:r=>Wi.create({...r,coerce:!0}),bigint:r=>Fi.create({...r,coerce:!0}),date:r=>Ki.create({...r,coerce:!0})},ox=pe;var v=Object.freeze({__proto__:null,defaultErrorMap:Vs,setErrorMap:ob,getErrorMap:Do,makeIssue:Mo,EMPTY_PATH:cb,addIssueToContext:H,ParseStatus:Ct,INVALID:pe,DIRTY:Os,OK:xt,isAborted:pl,isDirty:ml,isValid:Li,isAsync:qi,get util(){return Be},get objectUtil(){return hl},ZodParsedType:z,getParsedType:sn,ZodType:Se,datetimeRegex:Hm,ZodString:Us,ZodNumber:Hi,ZodBigInt:Fi,ZodBoolean:Wi,ZodDate:Ki,ZodSymbol:Uo,ZodUndefined:zi,ZodNull:Gi,ZodAny:Ls,ZodUnknown:zn,ZodNever:Hr,ZodVoid:Lo,ZodArray:Qn,ZodObject:Wt,ZodUnion:Ji,ZodDiscriminatedUnion:Wm,ZodIntersection:Yi,ZodTuple:gn,ZodRecord:Gm,ZodMap:qo,ZodSet:Ho,ZodFunction:Jm,ZodLazy:Xi,ZodLiteral:Qi,ZodEnum:Ja,ZodNativeEnum:ea,ZodPromise:qs,ZodEffects:dr,ZodTransformer:dr,ZodOptional:xr,ZodNullable:vn,ZodDefault:ta,ZodCatch:ra,ZodNaN:Fo,BRAND:Sb,ZodBranded:ef,ZodPipeline:tf,ZodReadonly:na,custom:Qm,Schema:Se,ZodSchema:Se,late:Ab,get ZodFirstPartyTypeKind(){return de},coerce:ax,any:Bb,array:Zb,bigint:Ib,boolean:ry,date:Cb,discriminatedUnion:Ub,effect:xh,enum:Jb,function:Kb,instanceof:Ob,intersection:Lb,lazy:zb,literal:Gb,map:Fb,nan:Eb,nativeEnum:Yb,never:Pb,null:Nb,nullable:ex,number:ty,object:Db,oboolean:ix,onumber:sx,optional:Qb,ostring:nx,pipeline:rx,preprocess:tx,promise:Xb,record:Hb,set:Wb,strictObject:Mb,string:ey,symbol:jb,transformer:xh,tuple:qb,undefined:Tb,union:Vb,unknown:Rb,void:$b,NEVER:ox,ZodIssueCode:Z,quotelessJson:ab,ZodError:or}),jt=class wl extends ib{constructor(t){super(t);se(this,"openAPIRegistry");se(this,"defaultHook");se(this,"openapi",({middleware:t,...n},s,i=this.defaultHook)=>{var u,f,m,R,C,p,y,A,O,P;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const N=xs("query",n.request.query,i);a.push(N)}if((f=n.request)!=null&&f.params){const N=xs("param",n.request.params,i);a.push(N)}if((m=n.request)!=null&&m.headers){const N=xs("header",n.request.headers,i);a.push(N)}if((R=n.request)!=null&&R.cookies){const N=xs("cookie",n.request.cookies,i);a.push(N)}const o=(p=(C=n.request)==null?void 0:C.body)==null?void 0:p.content;if(o)for(const N of Object.keys(o)){if(!o[N])continue;const ve=o[N].schema;if(ve instanceof Se){if(wh(N)){const Le=xs("json",ve,i);if((A=(y=n.request)==null?void 0:y.body)!=null&&A.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&wh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("json",{}),await tt()};a.push(qe)}}if(kh(N)){const Le=xs("form",ve,i);if((P=(O=n.request)==null?void 0:O.body)!=null&&P.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&kh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("form",{}),await tt()};a.push(qe)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,s),this});se(this,"getOpenAPIDocument",t=>{const s=new bv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?_h(s,this._basePath):s});se(this,"getOpenAPI31Document",t=>{const s=new wv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?_h(s,this._basePath):s});se(this,"doc",(t,n)=>this.get(t,s=>{const i=typeof n=="function"?n(s):n;try{const a=this.getOpenAPIDocument(i);return s.json(a)}catch(a){return s.json(a,500)}}));se(this,"doc31",(t,n)=>this.get(t,s=>{const i=typeof n=="function"?n(s):n;try{const a=this.getOpenAPI31Document(i);return s.json(a)}catch(a){return s.json(a,500)}}));this.openAPIRegistry=new tv,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof wl?(n.openAPIRegistry.definitions.forEach(i=>{switch(i.type){case"component":return this.openAPIRegistry.registerComponent(i.componentType,i.name,i.component);case"route":return this.openAPIRegistry.registerPath({...i.route,path:nn(s,i.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...i.webhook,path:nn(s,i.webhook.path)});case"schema":return this.openAPIRegistry.register(i.schema._def.openapi._internal.refId,i.schema);case"parameter":return this.openAPIRegistry.registerParameter(i.schema._def.openapi._internal.refId,i.schema);default:{const a=i;throw new Error(`Unknown registry type: ${a}`)}}}),this):this}basePath(t){return new wl({...super.basePath(t),defaultHook:this.defaultHook})}},ke=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};Y0(v);function _h(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[nn(e,n)]=r.paths[n]}),{...r,paths:t}}function wh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function kh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function cx(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function ux(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ki(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function lx(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const R=typeof s=="string"?i:s,C=R??{},{param:p}=C,y=cx(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof s=="string"?{refId:s}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),y),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(ux(this,"ZodObject")){const N=this.extend;P.extend=function(...ve){var Le,qe,Ze,tt,pt,Rt;const I=N.apply(this,ve);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(pt=this._def.openapi)===null||pt===void 0?void 0:pt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},ki(r,"optional"),ki(r,"nullable"),ki(r,"default"),ki(r,"transform"),ki(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}new Set(".\\+*[^]$()");var Re;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Re||(Re={}));var kl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(kl||(kl={}));const G=Re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),an=r=>{switch(typeof r){case"undefined":return G.undefined;case"string":return G.string;case"number":return isNaN(r)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(r)?G.array:r===null?G.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?G.promise:typeof Map<"u"&&r instanceof Map?G.map:typeof Set<"u"&&r instanceof Set?G.set:typeof Date<"u"&&r instanceof Date?G.date:G.object;default:return G.unknown}},D=Re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),dx=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Zt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof Zt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Zt.create=r=>new Zt(r);const Hs=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Re.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Re.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Re.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Re.joinValues(r.options)}, received '${r.received}'`;break;case D.invalid_arguments:t="Invalid function arguments";break;case D.invalid_return_type:t="Invalid function return type";break;case D.invalid_date:t="Invalid date";break;case D.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Re.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case D.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case D.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case D.custom:t="Invalid input";break;case D.invalid_intersection_types:t="Intersection results could not be merged";break;case D.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case D.not_finite:t="Number must be finite";break;default:t=e.defaultError,Re.assertNever(r)}return{message:t}};let ny=Hs;function fx(r){ny=r}function Wo(){return ny}const Ko=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},hx=[];function F(r,e){const t=Wo(),n=Ko({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hs?void 0:Hs].filter(s=>!!s)});r.common.issues.push(n)}class yt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return ye;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return yt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ye;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const ye=Object.freeze({status:"aborted"}),zo=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),Sl=r=>r.status==="aborted",Al=r=>r.status==="dirty",sa=r=>r.status==="valid",ia=r=>typeof Promise<"u"&&r instanceof Promise;function Go(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function sy(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var oe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(oe||(oe={}));var ji,Ti;class Ar{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Sh=(r,e)=>{if(sa(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Zt(r.common.issues);return this._error=t,this._error}}};function xe(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,a)=>{var o,c;const{message:u}=r;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:s}}class Oe{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return an(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new yt,ctx:{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ia(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Sh(s,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(ia(s)?s:Promise.resolve(s));return Sh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:D.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new fr({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _r.create(this,this._def)}nullable(){return wn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cr.create(this,this._def)}promise(){return Ws.create(this,this._def)}or(e){return ua.create([this,e],this._def)}and(e){return la.create(this,e,this._def)}transform(e){return new fr({...xe(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ma({...xe(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new rf({typeName:fe.ZodBranded,type:this,...xe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ya({...xe(this._def),innerType:this,catchValue:t,typeName:fe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ya.create(this,e)}readonly(){return ga.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const px=/^c[^\s-]{8,}$/i,mx=/^[0-9a-z]+$/,yx=/^[0-9A-HJKMNP-TV-Z]{26}$/,gx=/^[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,vx=/^[a-z0-9_-]{21}$/i,bx=/^[-+]?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)?)??$/,xx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_x="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ju;const wx=/^(?:(?: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])$/,kx=/^(([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})))$/,Sx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,iy="((\\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])))",Ax=new RegExp(`^${iy}$`);function ay(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ox(r){return new RegExp(`^${ay(r)}$`)}function oy(r){let e=`${iy}T${ay(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ex(r,e){return!!((e==="v4"||!e)&&wx.test(r)||(e==="v6"||!e)&&kx.test(r))}class sr extends Oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.string,received:s.parsedType}),ye}const t=new yt;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.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&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?F(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&F(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")xx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Ju||(Ju=new RegExp(_x,"u")),Ju.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")gx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")vx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")px.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")mx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")yx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:D.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:D.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)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.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)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?oy(s).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Ox(s).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?bx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Ex(e.data,s.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?Sx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:D.invalid_string,message:s.message}),t.dirty()):Re.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:D.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new sr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...oe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...oe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...oe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...oe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...oe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...oe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...oe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...oe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...oe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...oe.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...oe.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...oe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...oe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...oe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...oe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...oe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...oe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...oe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...oe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...oe.errToObj(t)})}nonempty(e){return this.min(1,oe.errToObj(e))}trim(){return new sr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new sr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new sr({...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}}sr.create=r=>{var e;return new sr({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};function Ix(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class bn extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.number,received:s.parsedType}),ye}let t;const n=new yt;for(const s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Ix(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_finite,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,s){return new bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new bn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:oe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:oe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:oe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:oe.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Re.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}bn.create=r=>new bn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class xn extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==G.bigint){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.bigint,received:s.parsedType}),ye}let t;const n=new yt;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),F(t,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,s){return new xn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new xn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}xn.create=r=>{var e;return new xn({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};class aa extends Oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.boolean,received:t.parsedType}),ye}return _t(e.data)}}aa.create=r=>new aa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class es extends Oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.date,received:s.parsedType}),ye}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_date}),ye}const t=new yt;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Re.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new es({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:oe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:oe.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}es.create=r=>new es({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...xe(r)});class Jo extends Oe{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.symbol,received:t.parsedType}),ye}return _t(e.data)}}Jo.create=r=>new Jo({typeName:fe.ZodSymbol,...xe(r)});class oa extends Oe{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.undefined,received:t.parsedType}),ye}return _t(e.data)}}oa.create=r=>new oa({typeName:fe.ZodUndefined,...xe(r)});class ca extends Oe{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.null,received:t.parsedType}),ye}return _t(e.data)}}ca.create=r=>new ca({typeName:fe.ZodNull,...xe(r)});class Fs extends Oe{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}}Fs.create=r=>new Fs({typeName:fe.ZodAny,...xe(r)});class Gn extends Oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}}Gn.create=r=>new Gn({typeName:fe.ZodUnknown,...xe(r)});class Fr extends Oe{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.never,received:t.parsedType}),ye}}Fr.create=r=>new Fr({typeName:fe.ZodNever,...xe(r)});class Yo extends Oe{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.void,received:t.parsedType}),ye}return _t(e.data)}}Yo.create=r=>new Yo({typeName:fe.ZodVoid,...xe(r)});class cr extends Oe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==G.array)return F(t,{code:D.invalid_type,expected:G.array,received:t.parsedType}),ye;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(F(t,{code:a?D.too_big:D.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(F(t,{code:D.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(F(t,{code:D.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>yt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ar(t,a,t.path,o)));return yt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new cr({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new cr({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new cr({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}cr.create=(r,e)=>new cr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...xe(e)});function Ss(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Ss(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof cr?new cr({...r._def,type:Ss(r.element)}):r instanceof _r?_r.create(Ss(r.unwrap())):r instanceof wn?wn.create(Ss(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>Ss(e))):r}class Je extends Oe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Re.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const c=this._getOrReturnCtx(e);return F(c,{code:D.invalid_type,expected:G.object,received:c.parsedType}),ye}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const c in n.data)i.includes(c)||a.push(c);const o=[];for(const c of i){const u=s[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Ar(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Fr){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")a.length>0&&(F(n,{code:D.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const f=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Ar(n,f,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const f=await u.key,m=await u.value;c.push({key:f,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>yt.mergeObjectSync(t,c)):yt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=oe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(e){return new Je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Je({...this._def,catchall:e})}pick(e){const t={};return Re.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}omit(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return Ss(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Je({...this._def,shape:()=>t})}required(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof _r;)s=s._def.innerType;t[n]=s}}),new Je({...this._def,shape:()=>t})}keyof(){return cy(Re.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...xe(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:fe.ZodObject,...xe(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...xe(e)});class ua extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Zt(o.ctx.common.issues));return F(t,{code:D.invalid_union,unionErrors:a}),ye}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Zt(c));return F(t,{code:D.invalid_union,unionErrors:o}),ye}}get options(){return this._def.options}}ua.create=(r,e)=>new ua({options:r,typeName:fe.ZodUnion,...xe(e)});const rn=r=>r instanceof fa?rn(r.schema):r instanceof fr?rn(r.innerType()):r instanceof ha?[r.value]:r instanceof _n?r.options:r instanceof pa?Re.objectValues(r.enum):r instanceof ma?rn(r._def.innerType):r instanceof oa?[void 0]:r instanceof ca?[null]:r instanceof _r?[void 0,...rn(r.unwrap())]:r instanceof wn?[null,...rn(r.unwrap())]:r instanceof rf||r instanceof ga?rn(r.unwrap()):r instanceof ya?rn(r._def.innerType):[];class Jc extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return F(t,{code:D.invalid_type,expected:G.object,received:t.parsedType}),ye;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ye)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=rn(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Jc({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...xe(n)})}}function Ol(r,e){const t=an(r),n=an(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const s=Re.objectKeys(e),i=Re.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Ol(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Ol(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class la extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Sl(i)||Sl(a))return ye;const o=Ol(i.value,a.value);return o.valid?((Al(i)||Al(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:D.invalid_intersection_types}),ye)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}la.create=(r,e,t)=>new la({left:r,right:e,typeName:fe.ZodIntersection,...xe(t)});class Or extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:D.invalid_type,expected:G.array,received:n.parsedType}),ye;if(n.data.length<this._def.items.length)return F(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ye;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((i,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Ar(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>yt.mergeArray(t,i)):yt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Or({...this._def,rest:e})}}Or.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Or({items:r,typeName:fe.ZodTuple,rest:null,...xe(e)})};class da extends Oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return F(n,{code:D.invalid_type,expected:G.object,received:n.parsedType}),ye;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Ar(n,o,n.path,o)),value:a._parse(new Ar(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?yt.mergeObjectAsync(t,s):yt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Oe?new da({keyType:e,valueType:t,typeName:fe.ZodRecord,...xe(n)}):new da({keyType:sr.create(),valueType:e,typeName:fe.ZodRecord,...xe(t)})}}class Xo extends Oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return F(n,{code:D.invalid_type,expected:G.map,received:n.parsedType}),ye;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ar(n,o,n.path,[u,"key"])),value:i._parse(new Ar(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Xo.create=(r,e,t)=>new Xo({valueType:e,keyType:r,typeName:fe.ZodMap,...xe(t)});class ts extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:D.invalid_type,expected:G.set,received:n.parsedType}),ye;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(F(n,{code:D.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(F(n,{code:D.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ye;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ar(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ts({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new ts({...this._def,maxSize:{value:e,message:oe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ts.create=(r,e)=>new ts({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...xe(e)});class Ts extends Oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return F(t,{code:D.invalid_type,expected:G.function,received:t.parsedType}),ye;function n(o,c){return Ko({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wo(),Hs].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function s(o,c){return Ko({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wo(),Hs].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ws){const o=this;return _t(async function(...c){const u=new Zt([]),f=await o._def.args.parseAsync(c,i).catch(R=>{throw u.addIssue(n(c,R)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(R=>{throw u.addIssue(s(m,R)),u})})}else{const o=this;return _t(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Zt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Zt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ts({...this._def,args:Or.create(e).rest(Gn.create())})}returns(e){return new Ts({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ts({args:e||Or.create([]).rest(Gn.create()),returns:t||Gn.create(),typeName:fe.ZodFunction,...xe(n)})}}class fa extends Oe{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}fa.create=(r,e)=>new fa({getter:r,typeName:fe.ZodLazy,...xe(e)});class ha extends Oe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),ye}return{status:"valid",value:e.data}}get value(){return this._def.value}}ha.create=(r,e)=>new ha({value:r,typeName:fe.ZodLiteral,...xe(e)});function cy(r,e){return new _n({values:r,typeName:fe.ZodEnum,...xe(e)})}class _n extends Oe{constructor(){super(...arguments),ji.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Re.joinValues(n),received:t.parsedType,code:D.invalid_type}),ye}if(Go(this,ji)||sy(this,ji,new Set(this._def.values)),!Go(this,ji).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:D.invalid_enum_value,options:n}),ye}return _t(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return _n.create(e,{...this._def,...t})}exclude(e,t=this._def){return _n.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}ji=new WeakMap;_n.create=cy;class pa extends Oe{constructor(){super(...arguments),Ti.set(this,void 0)}_parse(e){const t=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const s=Re.objectValues(t);return F(n,{expected:Re.joinValues(s),received:n.parsedType,code:D.invalid_type}),ye}if(Go(this,Ti)||sy(this,Ti,new Set(Re.getValidEnumValues(this._def.values))),!Go(this,Ti).has(e.data)){const s=Re.objectValues(t);return F(n,{received:n.data,code:D.invalid_enum_value,options:s}),ye}return _t(e.data)}get enum(){return this._def.values}}Ti=new WeakMap;pa.create=(r,e)=>new pa({values:r,typeName:fe.ZodNativeEnum,...xe(e)});class Ws extends Oe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return F(t,{code:D.invalid_type,expected:G.promise,received:t.parsedType}),ye;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return _t(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ws.create=(r,e)=>new Ws({type:r,typeName:fe.ZodPromise,...xe(e)});class fr extends Oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ye;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ye:c.status==="dirty"||t.value==="dirty"?zo(c.value):c});{if(t.value==="aborted")return ye;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ye:o.status==="dirty"||t.value==="dirty"?zo(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!sa(a))return a;const o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>sa(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Re.assertNever(s)}}fr.create=(r,e,t)=>new fr({schema:r,typeName:fe.ZodEffects,effect:e,...xe(t)});fr.createWithPreprocess=(r,e,t)=>new fr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...xe(t)});class _r extends Oe{_parse(e){return this._getType(e)===G.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_r.create=(r,e)=>new _r({innerType:r,typeName:fe.ZodOptional,...xe(e)});class wn extends Oe{_parse(e){return this._getType(e)===G.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wn.create=(r,e)=>new wn({innerType:r,typeName:fe.ZodNullable,...xe(e)});class ma extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ma.create=(r,e)=>new ma({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xe(e)});class ya extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ia(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ya.create=(r,e)=>new ya({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xe(e)});class Qo extends Oe{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.nan,received:t.parsedType}),ye}return{status:"valid",value:e.data}}}Qo.create=r=>new Qo({typeName:fe.ZodNaN,...xe(r)});const Cx=Symbol("zod_brand");class rf extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ya extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),zo(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ya({in:e,out:t,typeName:fe.ZodPipeline})}}class ga extends Oe{_parse(e){const t=this._def.innerType._parse(e),n=s=>(sa(s)&&(s.value=Object.freeze(s.value)),s);return ia(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodReadonly,...xe(e)});function uy(r,e={},t){return r?Fs.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Fs.create()}const jx={object:Je.lazycreate};var fe;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(fe||(fe={}));const Tx=(r,e={message:`Input not instance of ${r.name}`})=>uy(t=>t instanceof r,e),ly=sr.create,dy=bn.create,Nx=Qo.create,Bx=xn.create,fy=aa.create,Rx=es.create,Px=Jo.create,$x=oa.create,Zx=ca.create,Dx=Fs.create,Mx=Gn.create,Vx=Fr.create,Ux=Yo.create,Lx=cr.create,qx=Je.create,Hx=Je.strictCreate,Fx=ua.create,Wx=Jc.create,Kx=la.create,zx=Or.create,Gx=da.create,Jx=Xo.create,Yx=ts.create,Xx=Ts.create,Qx=fa.create,e_=ha.create,t_=_n.create,r_=pa.create,n_=Ws.create,Ah=fr.create,s_=_r.create,i_=wn.create,a_=fr.createWithPreprocess,o_=Ya.create,c_=()=>ly().optional(),u_=()=>dy().optional(),l_=()=>fy().optional(),d_={string:r=>sr.create({...r,coerce:!0}),number:r=>bn.create({...r,coerce:!0}),boolean:r=>aa.create({...r,coerce:!0}),bigint:r=>xn.create({...r,coerce:!0}),date:r=>es.create({...r,coerce:!0})},f_=ye;var d=Object.freeze({__proto__:null,defaultErrorMap:Hs,setErrorMap:fx,getErrorMap:Wo,makeIssue:Ko,EMPTY_PATH:hx,addIssueToContext:F,ParseStatus:yt,INVALID:ye,DIRTY:zo,OK:_t,isAborted:Sl,isDirty:Al,isValid:sa,isAsync:ia,get util(){return Re},get objectUtil(){return kl},ZodParsedType:G,getParsedType:an,ZodType:Oe,datetimeRegex:oy,ZodString:sr,ZodNumber:bn,ZodBigInt:xn,ZodBoolean:aa,ZodDate:es,ZodSymbol:Jo,ZodUndefined:oa,ZodNull:ca,ZodAny:Fs,ZodUnknown:Gn,ZodNever:Fr,ZodVoid:Yo,ZodArray:cr,ZodObject:Je,ZodUnion:ua,ZodDiscriminatedUnion:Jc,ZodIntersection:la,ZodTuple:Or,ZodRecord:da,ZodMap:Xo,ZodSet:ts,ZodFunction:Ts,ZodLazy:fa,ZodLiteral:ha,ZodEnum:_n,ZodNativeEnum:pa,ZodPromise:Ws,ZodEffects:fr,ZodTransformer:fr,ZodOptional:_r,ZodNullable:wn,ZodDefault:ma,ZodCatch:ya,ZodNaN:Qo,BRAND:Cx,ZodBranded:rf,ZodPipeline:Ya,ZodReadonly:ga,custom:uy,Schema:Oe,ZodSchema:Oe,late:jx,get ZodFirstPartyTypeKind(){return fe},coerce:d_,any:Dx,array:Lx,bigint:Bx,boolean:fy,date:Rx,discriminatedUnion:Wx,effect:Ah,enum:t_,function:Xx,instanceof:Tx,intersection:Kx,lazy:Qx,literal:e_,map:Jx,nan:Nx,nativeEnum:r_,never:Vx,null:Zx,nullable:i_,number:dy,object:qx,oboolean:l_,onumber:u_,optional:s_,ostring:c_,pipeline:o_,preprocess:a_,promise:n_,record:Gx,set:Yx,strictObject:Hx,string:ly,symbol:Px,transformer:Ah,tuple:zx,undefined:$x,union:Fx,unknown:Mx,void:Ux,NEVER:f_,ZodIssueCode:D,quotelessJson:dx,ZodError:Zt});lx(d);const jn=d.object({start:d.number(),limit:d.number(),length:d.number()}),nf=d.object({created_at:d.string(),updated_at:d.string()}),hy=d.object({email:d.string().optional(),email_verified:d.boolean().optional(),name:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),phone_number:d.string().optional(),phone_verified:d.boolean().optional(),family_name:d.string().optional()}).catchall(d.any()),py=d.object({connection:d.string(),user_id:d.string(),provider:d.string(),isSocial:d.boolean(),access_token:d.string().optional(),access_token_secret:d.string().optional(),refresh_token:d.string().optional(),profileData:hy.optional()}),Yc=d.object({email:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),family_name:d.string().optional(),nickname:d.string().optional(),name:d.string().optional(),picture:d.string().optional(),locale:d.string().optional(),linked_to:d.string().optional(),profileData:d.string().optional(),user_id:d.string().optional(),app_metadata:d.any().default({}).optional(),user_metadata:d.any().default({}).optional()}),ec=Yc.extend({email_verified:d.boolean().default(!1),verify_email:d.boolean().optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string().optional(),provider:d.string().default("email"),connection:d.string().default("email")}),sf=d.object({...ec.shape,...nf.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(py).optional()}),vr=sf,h_=Yc.extend({email:d.string(),login_count:d.number(),multifactor:d.array(d.string()).optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string()}).catchall(d.any()),p_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let m_=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=p_[t[r]&63];return e};const my=d.object({audience:d.string().optional(),recipient:d.string().optional(),createUpnClaim:d.boolean().optional(),mapUnknownClaimsAsIs:d.boolean().optional(),passthroughClaimsWithNoMapping:d.boolean().optional(),mapIdentities:d.boolean().optional(),signatureAlgorithm:d.string().optional(),digestAlgorithm:d.string().optional(),issuer:d.string().optional(),destination:d.string().optional(),lifetimeInSeconds:d.number().optional(),signResponse:d.boolean().optional(),nameIdentifierFormat:d.string().optional(),nameIdentifierProbes:d.array(d.string()).optional(),authnContextClassRef:d.string().optional(),mappings:d.record(d.string()).optional()}),tc=d.object({id:d.string(),name:d.string(),callbacks:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:d.array(d.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:d.object({samlp:my.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:d.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:d.string().default(()=>m_()).optional(),disable_sign_ups:d.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Mn=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...tc.shape});var af=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(af||{}),of=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(of||{}),cf=(r=>(r.S265="S256",r.plain="plain",r))(cf||{});const yy=d.object({client_id:d.string(),vendor_id:d.string().optional(),act_as:d.string().optional(),response_type:d.nativeEnum(af).optional(),response_mode:d.nativeEnum(of).optional(),redirect_uri:d.string().optional(),audience:d.string().optional(),state:d.string().optional(),nonce:d.string().optional(),scope:d.string().optional(),prompt:d.string().optional(),code_challenge_method:d.nativeEnum(cf).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),El=d.object({colors:d.object({primary:d.string(),page_background:d.object({type:d.string().optional(),start:d.string().optional(),end:d.string().optional(),angle_deg:d.number().optional()}).optional()}).optional(),logo_url:d.string().optional(),favicon_url:d.string().optional(),font:d.object({url:d.string()}).optional()}),rc=d.object({id:d.string().optional(),name:d.string(),strategy:d.enum(["google-oauth2","facebook","vipps","freja","apple","email","Username-Password-Authentication","oidc","oauth2","custom"]).optional(),options:d.object({kid:d.string().optional(),team_id:d.string().optional(),realms:d.string().optional(),client_id:d.string().optional(),client_secret:d.string().optional(),app_secret:d.string().optional(),scope:d.string().optional(),authorization_endpoint:d.string().default("").optional(),token_endpoint:d.string().default("").optional(),userinfo_endpoint:d.string().default("").optional(),jwks_uri:d.string().default("").optional(),discovery_url:d.string().default("").optional(),issuer:d.string().default("").optional()}).default({}).optional(),enabled_clients:d.array(d.string()).default([]).optional(),response_type:d.custom().optional(),response_mode:d.custom().optional()}),Vn=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(rc.shape),nc=d.object({name:d.string(),audience:d.string(),sender_email:d.string().email(),sender_name:d.string(),support_url:d.string().url().optional(),logo:d.string().url().optional(),primary_color:d.string().optional(),secondary_color:d.string().optional(),language:d.string().optional()}),Ns=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...nc.shape}),y_=d.object({logoUrl:d.string(),loginBackgroundImage:d.string().nullish(),style:d.object({primaryColor:d.string(),buttonTextColor:d.string(),primaryHoverColor:d.string()}),supportEmail:d.string().nullable(),supportUrl:d.string().nullable(),name:d.string(),showGreyishBackground:d.boolean().optional(),termsAndConditionsUrl:d.string().nullable(),companyName:d.string().optional(),checkoutHideSocial:d.boolean().optional(),siteUrl:d.string().nullable(),manageSubscriptionsUrl:d.string().optional()}),g_=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.union([d.literal("mailgun"),d.literal("mailchannels")]).optional()});d.object({...Mn.shape,domains:d.array(g_),tenant:Ns,connections:d.array(Vn)});const gy=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),vy=d.object({code_id:d.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:d.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:d.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:gy,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()}),v_=d.object({...vy.shape,created_at:d.string()}),by=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.enum(["mailgun","mailchannels"])}),b_=nf.extend({...by.shape,id:d.string()}),sc=d.object({trigger_id:d.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:d.boolean().default(!1),url:d.string(),hook_id:d.string().optional(),synchronous:d.boolean().default(!1),priority:d.number().optional()}),Es=sc.extend({...nf.shape,hook_id:d.string()}),uf=d.object({alg:d.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:d.string(),kid:d.string(),kty:d.enum(["RSA","EC","oct"]),n:d.string(),x5t:d.string().optional(),x5c:d.array(d.string()).optional(),use:d.enum(["sig","enc"]).optional()}),xy=d.object({keys:d.array(uf)}),Il=d.object({issuer:d.string(),authorization_endpoint:d.string(),token_endpoint:d.string(),device_authorization_endpoint:d.string(),userinfo_endpoint:d.string(),mfa_challenge_endpoint:d.string(),jwks_uri:d.string(),registration_endpoint:d.string(),revocation_endpoint:d.string(),scopes_supported:d.array(d.string()),response_types_supported:d.array(d.string()),code_challenge_methods_supported:d.array(d.string()),response_modes_supported:d.array(d.string()),subject_types_supported:d.array(d.string()),id_token_signing_alg_values_supported:d.array(d.string()),token_endpoint_auth_methods_supported:d.array(d.string()),claims_supported:d.array(d.string()),request_uri_parameter_supported:d.boolean(),request_parameter_supported:d.boolean(),token_endpoint_auth_signing_alg_values_supported:d.array(d.string())}),_y=d.object({auth0Client:d.string().optional(),authParams:yy,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional()}).openapi({description:"This represents a login sesion"}),x_=d.object({..._y.shape,login_id:d.string().openapi({description:"This is is used as the state in the universal login"}),created_at:d.string(),updated_at:d.string()});var Xc=(r=>(r.FAILED_SILENT_AUTH="fsa",r.FAILED_SIGNUP="fs",r.FAILED_LOGIN="f",r.FAILED_LOGIN_INCORRECT_PASSWORD="fp",r.FAILED_CHANGE_PASSWORD="fcp",r.FAILED_BY_CONNECTOR="fc",r.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",r.FAILED_HOOK="fh",r.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",r.SUCCESS_API_OPERATION="sapi",r.SUCCESS_CHANGE_PASSWORD="scp",r.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",r.SUCCESS_CHANGE_USERNAME="scu",r.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",r.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",r.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",r.SUCCESS_LOGIN="s",r.SUCCESS_LOGOUT="slo",r.SUCCESS_SIGNUP="ss",r.SUCCESS_SILENT_AUTH="ssa",r.SUCCESS_VERIFICATION_EMAIL="sv",r.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",r.CODE_LINK_SENT="cls",r))(Xc||{});const __=d.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),wy=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),ic=d.object({type:__,date:d.string(),description:d.string().optional(),log_id:d.string().optional(),_id:d.string().optional(),ip:d.string(),user_agent:d.string(),details:d.any().optional(),isMobile:d.boolean(),user_id:d.string().optional(),user_name:d.string().optional(),connection:d.string().optional(),connection_id:d.string().optional(),client_id:d.string().optional(),client_name:d.string().optional(),audience:d.string().optional(),scope:d.array(d.string()).optional(),strategy:d.string().optional(),strategy_type:d.string().optional(),hostname:d.string().optional(),auth0_client:wy.optional()}),ky=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")}),w_=d.object({...ky.shape,created_at:d.string(),updated_at:d.string()}),Sy=d.object({session_id:d.string(),client_id:d.string(),expires_at:d.string(),used_at:d.string(),deleted_at:d.string().optional(),user_id:d.string()}),lf=d.object({created_at:d.string(),...Sy.shape}),Cl=d.object({kid:d.string().openapi({description:"The key id of the signing key"}),cert:d.string().openapi({description:"The public certificate of the signing key"}),fingerprint:d.string().openapi({description:"The cert fingerprint"}),thumbprint:d.string().openapi({description:"The cert thumbprint"}),pkcs7:d.string().optional().openapi({description:"The private key in pkcs7 format"}),current:d.boolean().optional().openapi({description:"True if the key is the current key"}),next:d.boolean().optional().openapi({description:"True if the key is the next key"}),previous:d.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:d.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:d.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:d.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:d.string().optional().openapi({description:"The date and time when the key was revoked"})});var df=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(df||{});const ff=d.nativeEnum(df),k_=d.object({grant_type:ff.refine(r=>r==="authorization_code"),code:d.string(),client_secret:d.string(),client_id:d.string()}),S_=d.object({grant_type:ff.refine(r=>r==="authorization_code"),code:d.string(),code_verifier:d.string(),client_id:d.string().optional(),redirect_uri:d.string()}),A_=d.object({grant_type:ff.refine(r=>r==="client_credentials"),scope:d.string().optional(),client_secret:d.string(),client_id:d.string(),audience:d.string().optional()});d.object({access_token:d.string(),id_token:d.string().optional(),scope:d.string().optional(),state:d.string().optional(),refresh_token:d.string().optional(),token_type:d.string(),expires_in:d.number()});d.object({code:d.string(),state:d.string().optional()});const Ay=d.object({button_border_radius:d.number(),button_border_weight:d.number(),buttons_style:d.enum(["pill"]),input_border_radius:d.number(),input_border_weight:d.number(),inputs_style:d.enum(["pill"]),show_widget_shadow:d.boolean(),widget_border_weight:d.number(),widget_corner_radius:d.number()}),Oy=d.object({base_focus_color:d.string(),base_hover_color:d.string(),body_text:d.string(),captcha_widget_theme:d.enum(["auto"]),error:d.string(),header:d.string(),icons:d.string(),input_background:d.string(),input_border:d.string(),input_filled_text:d.string(),input_labels_placeholders:d.string(),links_focused_components:d.string(),primary_button:d.string(),primary_button_label:d.string(),secondary_button_border:d.string(),secondary_button_label:d.string(),success:d.string(),widget_background:d.string(),widget_border:d.string()}),Zn=d.object({bold:d.boolean(),size:d.number()}),Ey=d.object({body_text:Zn,buttons_text:Zn,font_url:d.string(),input_labels:Zn,links:Zn,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Zn,title:Zn}),Iy=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),Cy=d.object({header_text_alignment:d.enum(["center"]),logo_height:d.number(),logo_position:d.enum(["center"]),logo_url:d.string(),social_buttons_layout:d.enum(["bottom"])}),jy=d.object({borders:Ay,colors:Oy,displayName:d.string(),fonts:Ey,page_background:Iy,widget:Cy}),O_=jy.extend({themeId:d.string()}),jo=d.object({universal_login_experience:d.enum(["new","classic"]).default("new"),identifier_first:d.boolean().default(!0),password_first:d.boolean().default(!1),webauthn_platform_first_factor:d.boolean()});function E_(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}var ac=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function I_(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function C_(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
1
+ "use strict";var z0=Object.defineProperty;var fh=r=>{throw TypeError(r)};var G0=(r,e,t)=>e in r?z0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var se=(r,e,t)=>G0(r,typeof e!="symbol"?e+"":e,t),Wu=(r,e,t)=>e.has(r)||fh("Cannot "+t);var w=(r,e,t)=>(Wu(r,e,"read from private field"),t?t.call(r):e.get(r)),Ae=(r,e,t)=>e.has(r)?fh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ue=(r,e,t,n)=>(Wu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),je=(r,e,t)=>(Wu(r,e,"access private method"),t);var hh=(r,e,t,n)=>({set _(s){ue(r,e,s,t)},get _(){return w(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ai(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function we(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function J0(r){return"_def"in r}function xi(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function Y0(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const R=typeof s=="string"?i:s,C=R??{},{param:p}=C,y=Ai(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof s=="string"?{refId:s}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),y),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(we(this,"ZodObject")){const N=this.extend;P.extend=function(...ve){var Le,qe,Ze,tt,pt,Rt;const I=N.apply(this,ve);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(pt=this._def.openapi)===null||pt===void 0?void 0:pt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},xi(r,"optional"),xi(r,"nullable"),xi(r,"default"),xi(r,"transform"),xi(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}function Po(r,e){if(r==null||e===null||e===void 0)return r===e;if(r===e||r.valueOf()===e.valueOf())return!0;if(Array.isArray(r)&&(!Array.isArray(e)||r.length!==e.length)||!(r instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(r);return Object.keys(e).every(n=>t.indexOf(n)!==-1)&&t.every(n=>Po(r[n],e[n]))}class X0{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n){this.buckets.set(t,[e]);return}n.some(i=>Po(i,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>Po(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const i of this.buckets.values())e+=1,t+=i.length,i.length>1&&(n+=1);const s=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:s}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)t^=this.hashCodeOf(e[n])*n;return t}if(typeof e=="string"){for(let n=0;n<e.length;n++)t^=e.charCodeAt(n)*n;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[n,s]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(s??"");return t}}function Ri(r){return r==null}function Pi(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function Q0(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function js(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function ph(r){return r.filter(e=>!Ri(e))}const ll=Po;function ev(r){const e=new X0;return r.forEach(t=>e.put(t)),[...e.values()]}function gm(r){return typeof r=="string"}class tv{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,s,i;const a=this.schemaWithRefId(e,t),o=(n=a._def.openapi)===null||n===void 0?void 0:n.metadata,c=a.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(i=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&i!==void 0?i:e})}));return this._definitions.push({type:"parameter",schema:c}),c}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:"component",componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class Gc{constructor(e){this.message=e}}class _i extends Gc{constructor(e,t){super(e),this.data=t}}class $o extends Gc{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 wi(r,e){try{return r()}catch(t){throw t instanceof $o?new $o(Object.assign(Object.assign({},t.data),e)):t}}class rv extends Gc{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class Ke{static getMetadata(e){var t;const n=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:n._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:i},s==null?void 0:s.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),n=e._def.openapi?e._def.openapi:t._def.openapi;return n==null?void 0:n._internal}static getParamMetadata(e){var t,n;const s=this.unwrapChained(e),i=e._def.openapi?e._def.openapi:s._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:i==null?void 0:i._internal,metadata:Object.assign(Object.assign({},i==null?void 0:i.metadata),{param:Object.assign({description:a},(n=i==null?void 0:i.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return js(Q0(e,["param"]),Ri)}static buildParameterMetadata(e){return js(e,Ri)}static applySchemaMetadata(e,t){return js(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Ri)}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&&we(e,t)?e:we(e,"ZodOptional")||we(e,"ZodNullable")||we(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):we(e,"ZodDefault")||we(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):we(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):we(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return we(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class nv{transform(e,t,n){var s,i;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(i=e._def.maxLength)===null||i===void 0?void 0:i.value})}}class sv{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class iv{transform(e,t,n,s,i){const a=[...e.options.values()],o=a.map(s);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(a,e.discriminator,i)}}mapDiscriminator(e,t,n){if(e.some(i=>Ke.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=Ke.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(we(c,"ZodEnum")||we(c,"ZodNativeEnum")){Object.values(c.enum).filter(gm).forEach(m=>{s[m]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=n(o)}),{propertyName:t,mapping:s}}}class av{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class ov{transform(e,t,n,s){const a={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!we(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class cv{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function uv(r){const t=Object.keys(r).filter(i=>typeof r[r[i]]!="number").map(i=>r[i]),n=t.filter(i=>typeof i=="number").length,s=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:s}}class lv{transform(e,t){const{type:n,values:s}=uv(e._def.values);if(n==="mixed")throw new Gc("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:s})}}class dv{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class fv{transform(e,t,n,s){var i;const a=(i=Ke.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=Pi(e._def.shape(),s);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=a.schema;s(u);const f=this.requiredKeysOf(u),m=Pi(u==null?void 0:u._def.shape(),s),R=Object.fromEntries(Object.entries(c).filter(([y,A])=>!ll(m[y],A))),C=o.filter(y=>!f.includes(y)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:R}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return we(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!Ke.isOptionalSchema(n)).map(([t,n])=>t)}}class hv{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(we(i,"ZodEnum")||we(i,"ZodNativeEnum")){const c=Object.values(i.enum).filter(gm).reduce((u,f)=>Object.assign(Object.assign({},u),{[f]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class pv{transform(e,t){var n,s,i;const a=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(i=e.maxLength)!==null&&i!==void 0?i:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:a==null?void 0:a.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time"}getZodStringCheck(e,t){return e._def.checks.find(n=>n.kind===t)}}class mv{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:s}=e._def,i=s.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(i))}}class yv{transform(e,t,n){const i=this.flattenUnionTypes(e).map(a=>{const o=this.unwrapNullable(a);return n(o)});return{anyOf:t(i)}}flattenUnionTypes(e){return we(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return we(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class gv{constructor(e){this.versionSpecifics=e,this.objectTransformer=new fv,this.stringTransformer=new pv,this.numberTransformer=new dv,this.bigIntTransformer=new sv,this.literalTransformer=new cv,this.enumTransformer=new av,this.nativeEnumTransformer=new lv,this.arrayTransformer=new nv,this.unionTransformer=new yv,this.discriminatedUnionTransformer=new iv,this.intersectionTransformer=new ov,this.recordTransformer=new hv,this.tupleTransformer=new mv(e)}transform(e,t,n,s,i){if(we(e,"ZodNull"))return this.versionSpecifics.nullType;if(we(e,"ZodUnknown")||we(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(we(e,"ZodObject"))return this.objectTransformer.transform(e,i,o=>this.versionSpecifics.mapNullableType(o,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,s);return Object.assign(Object.assign({},a),{default:i})}transformSchemaWithoutDefault(e,t,n,s){if(we(e,"ZodUnknown")||we(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(we(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(we(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(we(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(we(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(we(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(we(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(we(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(we(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(we(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=Ke.getRefId(e);throw new rv({currentSchema:e._def,schemaName:i})}}class vm{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new gv(t),this.sortDefinitions()}generateDocumentData(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents(),paths:this.pathRefs}}generateComponents(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents()}}buildComponents(){var e,t;const n={};return this.rawComponents.forEach(({componentType:s,name:i,component:a})=>{var o;(o=n[s])!==null&&o!==void 0||(n[s]={}),n[s][i]=a}),Object.assign(Object.assign({},n),{schemas:Object.assign(Object.assign({},(e=n.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=n.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,n)=>{if(!("type"in t))return"type"in n?-1:0;if(!("type"in n))return 1;const s=e.findIndex(a=>a===t.type),i=e.findIndex(a=>a===n.type);return s-i})}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=Ke.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,s,i,a,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(i=e._internal)===null||i===void 0?void 0:i.refId]:void 0;if(!(!(!((a=e==null?void 0:e._internal)===null||a===void 0)&&a.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new _i(`Conflicting location for parameter ${u.name}`,{key:"in",values:ph([u.in,t==null?void 0:t.in,c==null?void 0:c.in])});if(c&&u.name!==c.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new _i("Conflicting names for parameter",{key:"name",values:ph([u.name,t==null?void 0:t.name,c==null?void 0:c.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var n;const s=Ke.getMetadata(e),i=(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param,a=this.getParameterRef(s,{in:t});if(a)return[a];if(we(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,R;const C=Ke.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const y=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(y!=null&&y.name&&y.name!==u)throw new _i("Conflicting names for parameter",{key:"name",values:[u,y.name]});if(y!=null&&y.in&&y.in!==t)throw new _i(`Conflicting location for parameter ${(R=y.name)!==null&&R!==void 0?R:u}`,{key:"in",values:[t,y.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(i!=null&&i.in&&i.in!==t)throw new _i(`Conflicting location for parameter ${i.name}`,{key:"in",values:[t,i.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=Ke.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!Ke.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?Ke.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=Ke.getMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=s==null?void 0:s.name,a=s==null?void 0:s.in;if(!i)throw new $o({missingField:"name"});if(!a)throw new $o({missingField:"in",paramName:i});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:a,name:i})}generateSchemaWithMetadata(e){var t;const n=Ke.unwrapChained(e),s=Ke.getMetadata(e),i=Ke.getDefaultValue(e),a=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),i);return s!=null&&s.metadata?Ke.applySchemaMetadata(a,s.metadata):js(a,Ri)}constructReferencedOpenAPISchema(e){var t;const n=Ke.getMetadata(e),s=Ke.unwrapChained(e),i=Ke.getDefaultValue(e),a=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,a):this.toOpenAPISchema(s,a,i)}generateSimpleSchema(e){var t;const n=Ke.getMetadata(e),s=Ke.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=js(Ke.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||ll(f,i[m]));if(o.type)return{allOf:[a,o]};const c=js(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||ll(f,i[m])),u=Ke.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=Ke.getRefId(e),n=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=n,{$ref:this.generateSchemaRef(t)}):n}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,n=Ai(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),s=this.cleanParameter(e.params),i=this.cleanParameter(e.cookies),a=wi(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=wi(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=wi(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=wi(()=>{if(Array.isArray(t))return t.flatMap(m=>this.generateInlineParameters(m,"header"));const f=this.cleanParameter(t);return f?this.generateInlineParameters(f,"header"):[]},{location:"header"});return[...o,...a,...u,...c]}cleanParameter(e){if(e)return we(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=Ai(e,["method","path","request","responses"]),o=Pi(i,m=>this.getResponse(m)),c=wi(()=>this.getParameters(s),{route:`${t} ${n}`}),u=this.getRequestBody(s==null?void 0:s.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},a),c.length>0?{parameters:[...a.parameters||[],...c]}:{}),u?{requestBody:u}:{}),{responses:o})}}generateSingleRoute(e){const t=this.generatePath(e);return this.pathRefs[e.path]=Object.assign(Object.assign({},this.pathRefs[e.path]),t),t}getResponse(e){var{content:t,headers:n}=e,s=Ai(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=we(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},s),{headers:a}),i)}getResponseHeaders(e){const t=e._def.shape();return Pi(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return Pi(e,t=>{if(!t||!J0(t.schema))return t;const{schema:n}=t,s=Ai(t,["schema"]),i=this.generateSchemaWithRef(n);return Object.assign({schema:i},s)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),n)}}class vv{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=ev(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 bv{constructor(e){const t=new vv;this.generator=new vm(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class xv{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 _v(r){return"type"in r&&r.type==="webhook"}class wv{constructor(e){this.definitions=e,this.webhookRefs={};const t=new xv;this.generator=new vm(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(_v).forEach(n=>this.generateSingleWebhook(n.webhook)),Object.assign(Object.assign(Object.assign({},e),t),{webhooks:this.webhookRefs})}generateComponents(){return this.generator.generateComponents()}generateSingleWebhook(e){const t=this.generator.generatePath(e);return this.webhookRefs[e.path]=Object.assign(Object.assign({},this.webhookRefs[e.path]),t),t}}var bm=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},kv=r=>{const{groups:e,path:t}=Sv(r),n=bm(t);return Av(n,e)},Sv=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},Av=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let s=r.length-1;s>=0;s--)if(r[s].includes(n)){r[s]=r[s].replace(n,e[t][1]);break}}return r},bo={},mh=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(bo[r]||(e[2]?bo[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:bo[r]=[r,e[1],!0]),bo[r]):null},xm=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},Ov=r=>xm(r,decodeURI),_m=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const s=e.charCodeAt(n);if(s===37){const i=e.indexOf("?",n),a=e.slice(t,i===-1?void 0:i);return Ov(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},Ev=r=>{const e=_m(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},nn=(...r)=>{let e="",t=!1;for(let n of r)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),n[0]!=="/"&&(n=`/${n}`),n==="/"&&t?e=`${e}/`:n!=="/"&&(e=`${e}${n}`),n==="/"&&e===""&&(e="/");return e},wm=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))n+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&n===""?t.push("/"):t.push(n);const i=s.replace("?","");n+="/"+i,t.push(n)}else n+="/"+s}),t.filter((s,i,a)=>a.indexOf(s)===i)},Ku=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?Qd(r):r):r,km=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let a=r.indexOf(`?${e}`,8);for(a===-1&&(a=r.indexOf(`&${e}`,8));a!==-1;){const o=r.charCodeAt(a+e.length+1);if(o===61){const c=a+e.length+2,u=r.indexOf("&",c);return Ku(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";a=r.indexOf(`&${e}`,a+1)}if(n=/[%+]/.test(r),!n)return}const s={};n??(n=/[%+]/.test(r));let i=r.indexOf("?",8);for(;i!==-1;){const a=r.indexOf("&",i+1);let o=r.indexOf("=",i);o>a&&a!==-1&&(o=-1);let c=r.slice(i+1,o===-1?a===-1?void 0:a:o);if(n&&(c=Ku(c)),i=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=Ku(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},Iv=km,Cv=(r,e)=>km(r,e,!0),Qd=decodeURIComponent,jv=/^[\w!#$%&'*.^`|~+-]+$/,Tv=/^[ !#-:<-[\]-~]*$/,Nv=(r,e)=>{const t=r.trim().split(";"),n={};for(let s of t){s=s.trim();const i=s.indexOf("=");if(i===-1)continue;const a=s.substring(0,i).trim();if(!jv.test(a))continue;let o=s.substring(i+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Tv.test(o)&&(n[a]=Qd(o))}return n},Bv=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?Nv(n):{}},De=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});se(this,"res");se(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})}},Rv=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),Pv=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,$v=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Zv=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Dv=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!Pv.test(i))break;try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new De(400,{message:o})}break;case"form":{if(!i||!($v.test(i)||Zv.test(i)))break;let o;if(t.req.bodyCache.formData)o=await t.req.bodyCache.formData;else try{const u=await t.req.arrayBuffer();o=await Rv(u,i),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new De(400,{message:f})}const c={};o.forEach((u,f)=>{f.endsWith("[]")?(c[f]??(c[f]=[])).push(u):Array.isArray(c[f])?c[f].push(u):f in c?c[f]=[c[f],u]:c[f]=u}),s=c;break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=Bv(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const xs=(r,e,t)=>Dv(r,async(n,s)=>{const i=await e.safeParseAsync(n);if(t){const a=await t({data:n,...i,target:r},s);if(a){if(a instanceof Response)return a;if("response"in a)return a.response}}return i.success?i.data:s.json(i,400)});var Mv=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,i=(r instanceof Sm?r.raw.headers:r.headers).get("Content-Type");return i!=null&&i.startsWith("multipart/form-data")||i!=null&&i.startsWith("application/x-www-form-urlencoded")?Vv(r,{all:t,dot:n}):{}};async function Vv(r,e){const t=await r.formData();return t?Uv(t,e):{}}function Uv(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?Lv(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(qv(t,n,s),delete t[n])}),t}var Lv=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},qv=(r,e,t)=>{let n=r;const s=e.split(".");s.forEach((i,a)=>{a===s.length-1?n[i]=t:((!n[i]||typeof n[i]!="object"||Array.isArray(n[i])||n[i]instanceof File)&&(n[i]=Object.create(null)),n=n[i])})},yh=r=>xm(r,Qd),$s,tr,Xr,Am,Om,dl,cn,cm,Sm=(cm=class{constructor(r,e="/",t=[[]]){Ae(this,Xr);se(this,"raw");Ae(this,$s);Ae(this,tr);se(this,"routeIndex",0);se(this,"path");se(this,"bodyCache",{});Ae(this,cn,r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const s=Object.keys(e)[0];return s?e[s].then(i=>(s==="json"&&(i=JSON.stringify(i)),new Response(i)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,ue(this,tr,t),ue(this,$s,{})}param(r){return r?je(this,Xr,Am).call(this,r):je(this,Xr,Om).call(this)}query(r){return Iv(this.url,r)}queries(r){return Cv(this.url,r)}header(r){if(r)return this.raw.headers.get(r.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,n)=>{e[n]=t}),e}async parseBody(r){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await Mv(this,r))}json(){return w(this,cn).call(this,"json")}text(){return w(this,cn).call(this,"text")}arrayBuffer(){return w(this,cn).call(this,"arrayBuffer")}blob(){return w(this,cn).call(this,"blob")}formData(){return w(this,cn).call(this,"formData")}addValidatedData(r,e){w(this,$s)[r]=e}valid(r){return w(this,$s)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return w(this,tr)[0].map(([[,r]])=>r)}get routePath(){return w(this,tr)[0].map(([[,r]])=>r)[this.routeIndex].path}},$s=new WeakMap,tr=new WeakMap,Xr=new WeakSet,Am=function(r){const e=w(this,tr)[0][this.routeIndex][1][r],t=je(this,Xr,dl).call(this,e);return t?/\%/.test(t)?yh(t):t:void 0},Om=function(){const r={},e=Object.keys(w(this,tr)[0][this.routeIndex][1]);for(const t of e){const n=je(this,Xr,dl).call(this,w(this,tr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?yh(n):n)}return r},dl=function(r){return w(this,tr)[1]?w(this,tr)[1][r]:r},cn=new WeakMap,cm),Hv={Stringify:1,BeforeStream:2,Stream:3},Em=async(r,e,t,n,s)=>{typeof r=="object"&&!(r instanceof String)&&(r instanceof Promise||(r=r.toString()),r instanceof Promise&&(r=await r));const i=r.callbacks;return i!=null&&i.length?(s?s[0]+=r:s=[r],Promise.all(i.map(o=>o({phase:e,buffer:s,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Em(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},Fv="text/plain; charset=UTF-8",zu=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Ha,Fa,Pr,qn,$r,Ge,Qe,br,Zr,Wa,Zs,Ds,Ka,za,At,Ut,um,Im=(um=class{constructor(r,e){Ae(this,At);Ae(this,Ha);Ae(this,Fa);se(this,"env",{});Ae(this,Pr);se(this,"finalized",!1);se(this,"error");Ae(this,qn,200);Ae(this,$r);Ae(this,Ge);Ae(this,Qe);Ae(this,br);Ae(this,Zr,!0);Ae(this,Wa);Ae(this,Zs);Ae(this,Ds);Ae(this,Ka);Ae(this,za);se(this,"render",(...r)=>(w(this,Zs)??ue(this,Zs,e=>this.html(e)),w(this,Zs).call(this,...r)));se(this,"setLayout",r=>ue(this,Wa,r));se(this,"getLayout",()=>w(this,Wa));se(this,"setRenderer",r=>{ue(this,Zs,r)});se(this,"header",(r,e,t)=>{if(e===void 0){w(this,Ge)?w(this,Ge).delete(r):w(this,Qe)&&delete w(this,Qe)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(w(this,Ge)||(ue(this,Zr,!1),ue(this,Ge,new Headers(w(this,Qe))),ue(this,Qe,{})),w(this,Ge).append(r,e)):w(this,Ge)?w(this,Ge).set(r,e):(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});se(this,"status",r=>{ue(this,Zr,!1),ue(this,qn,r)});se(this,"set",(r,e)=>{w(this,Pr)??ue(this,Pr,new Map),w(this,Pr).set(r,e)});se(this,"get",r=>w(this,Pr)?w(this,Pr).get(r):void 0);se(this,"newResponse",(...r)=>je(this,At,Ut).call(this,...r));se(this,"body",(r,e,t)=>typeof e=="number"?je(this,At,Ut).call(this,r,e,t):je(this,At,Ut).call(this,r,e));se(this,"text",(r,e,t)=>{if(!w(this,Qe)){if(w(this,Zr)&&!t&&!e)return new Response(r);ue(this,Qe,{})}return w(this,Qe)["content-type"]=Fv,typeof e=="number"?je(this,At,Ut).call(this,r,e,t):je(this,At,Ut).call(this,r,e)});se(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?je(this,At,Ut).call(this,n,e,t):je(this,At,Ut).call(this,n,e)});se(this,"html",(r,e,t)=>(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Em(r,Hv.Stringify,!1,{}).then(n=>typeof e=="number"?je(this,At,Ut).call(this,n,e,t):je(this,At,Ut).call(this,n,e)):typeof e=="number"?je(this,At,Ut).call(this,r,e,t):je(this,At,Ut).call(this,r,e)));se(this,"redirect",(r,e)=>(w(this,Ge)??ue(this,Ge,new Headers),w(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));se(this,"notFound",()=>(w(this,Ds)??ue(this,Ds,()=>new Response),w(this,Ds).call(this,this)));ue(this,Ha,r),e&&(ue(this,$r,e.executionCtx),this.env=e.env,ue(this,Ds,e.notFoundHandler),ue(this,za,e.path),ue(this,Ka,e.matchResult))}get req(){return w(this,Fa)??ue(this,Fa,new Sm(w(this,Ha),w(this,za),w(this,Ka))),w(this,Fa)}get event(){if(w(this,$r)&&"respondWith"in w(this,$r))return w(this,$r);throw Error("This context has no FetchEvent")}get executionCtx(){if(w(this,$r))return w(this,$r);throw Error("This context has no ExecutionContext")}get res(){return ue(this,Zr,!1),w(this,br)||ue(this,br,new Response("404 Not Found",{status:404}))}set res(r){if(ue(this,Zr,!1),w(this,br)&&r)try{for(const[e,t]of w(this,br).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=w(this,br).headers.getSetCookie();r.headers.delete("set-cookie");for(const s of n)r.headers.append("set-cookie",s)}else r.headers.set(e,t)}catch(e){if(e instanceof TypeError&&e.message.includes("immutable")){this.res=new Response(r.body,{headers:r.headers,status:r.status});return}else throw e}ue(this,br,r),this.finalized=!0}get var(){return w(this,Pr)?Object.fromEntries(w(this,Pr)):{}}},Ha=new WeakMap,Fa=new WeakMap,Pr=new WeakMap,qn=new WeakMap,$r=new WeakMap,Ge=new WeakMap,Qe=new WeakMap,br=new WeakMap,Zr=new WeakMap,Wa=new WeakMap,Zs=new WeakMap,Ds=new WeakMap,Ka=new WeakMap,za=new WeakMap,At=new WeakSet,Ut=function(r,e,t){if(w(this,Zr)&&!t&&!e&&w(this,qn)===200)return new Response(r,{headers:w(this,Qe)});if(e&&typeof e!="number"){const s=new Headers(e.headers);w(this,Ge)&&w(this,Ge).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=zu(s,w(this,Qe));return new Response(r,{headers:i,status:e.status??w(this,qn)})}const n=typeof e=="number"?e:w(this,qn);w(this,Qe)??ue(this,Qe,{}),w(this,Ge)??ue(this,Ge,new Headers),zu(w(this,Ge),w(this,Qe)),w(this,br)&&(w(this,br).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=w(this,Ge))==null||a.append(i,s):(o=w(this,Ge))==null||o.set(i,s)}),zu(w(this,Ge),w(this,Qe))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")w(this,Ge).set(s,i);else{w(this,Ge).delete(s);for(const a of i)w(this,Ge).append(s,a)}return new Response(r,{status:n,headers:w(this,Ge)})},um),gh=(r,e,t)=>(n,s)=>{let i=-1;const a=n instanceof Im;return o(0);async function o(c){if(c<=i)throw new Error("next() called multiple times");i=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&s||void 0,!m)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await m(n,()=>o(c+1))}catch(R){if(R instanceof Error&&a&&e)n.error=R,u=await e(R,n),f=!0;else throw R}return u&&(n.finalized===!1||f)&&(n.res=u),n}},st="ALL",Wv="all",Kv=["get","post","put","delete","options","patch"],Cm="Can not add a route since the matcher is already built.",jm=class extends Error{},zv=Symbol("composedHandler"),Gv=r=>r.text("404 Not Found",404),vh=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),rr,it,Nm,Dr,Pn,Ao,Oo,lm,Tm=(lm=class{constructor(e={}){Ae(this,it);se(this,"get");se(this,"post");se(this,"put");se(this,"delete");se(this,"options");se(this,"patch");se(this,"all");se(this,"on");se(this,"use");se(this,"router");se(this,"getPath");se(this,"_basePath","/");Ae(this,rr,"/");se(this,"routes",[]);Ae(this,Dr,Gv);se(this,"errorHandler",vh);se(this,"onError",e=>(this.errorHandler=e,this));se(this,"notFound",e=>(ue(this,Dr,e),this));se(this,"fetch",(e,...t)=>je(this,it,Oo).call(this,e,t[1],t[0],e.method));se(this,"request",(e,t,n,s)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,s):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${nn("/",e)}`,t),n,s)));se(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(je(this,it,Oo).call(this,e.request,e,void 0,e.request.method))})});[...Kv,Wv].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?ue(this,rr,i):je(this,it,Pn).call(this,s,w(this,rr),i),a.forEach(o=>{je(this,it,Pn).call(this,s,w(this,rr),o)}),this)}),this.on=(s,i,...a)=>{for(const o of[i].flat()){ue(this,rr,o);for(const c of[s].flat())a.map(u=>{je(this,it,Pn).call(this,c.toUpperCase(),w(this,rr),u)})}return this},this.use=(s,...i)=>(typeof s=="string"?ue(this,rr,s):(ue(this,rr,"*"),i.unshift(s)),i.forEach(a=>{je(this,it,Pn).call(this,st,w(this,rr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??_m:Ev}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{var a;let i;t.errorHandler===vh?i=s.handler:(i=async(o,c)=>(await gh([],t.errorHandler)(o,()=>s.handler(o,c))).res,i[zv]=s.handler),je(a=n,it,Pn).call(a,s.method,s.path,i)}),this}basePath(e){const t=je(this,it,Nm).call(this);return t._basePath=nn(this._basePath,e),t}mount(e,t,n){let s,i;n&&(typeof n=="function"?i=n:(i=n.optionHandler,s=n.replaceRequest));const a=i?c=>{const u=i(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};s||(s=(()=>{const c=nn(this._basePath,e),u=c==="/"?0:c.length;return f=>{const m=new URL(f.url);return m.pathname=m.pathname.slice(u)||"/",new Request(m,f)}})());const o=async(c,u)=>{const f=await t(s(c.req.raw),...a(c));if(f)return f;await u()};return je(this,it,Pn).call(this,st,nn(e,"*"),o),this}},rr=new WeakMap,it=new WeakSet,Nm=function(){const e=new Tm({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Dr=new WeakMap,Pn=function(e,t,n){e=e.toUpperCase(),t=nn(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)},Ao=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Oo=function(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await je(this,it,Oo).call(this,e,t,n,"GET")))();const i=this.getPath(e,{env:n}),a=this.router.match(s,i),o=new Im(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:w(this,Dr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await w(this,Dr).call(this,o)})}catch(f){return je(this,it,Ao).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:w(this,Dr).call(this,o))).catch(f=>je(this,it,Ao).call(this,f,o)):u??w(this,Dr).call(this,o)}const c=gh(a[0],this.errorHandler,w(this,Dr));return(async()=>{try{const u=await c(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return je(this,it,Ao).call(this,u,o)}})()},lm),Zo="[^/]+",$i=".*",Zi="(?:|/.*)",Oi=Symbol(),Jv=new Set(".\\+*[^]$()");function Yv(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$i||r===Zi?1:e===$i||e===Zi?-1:r===Zo?1:e===Zo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Hn,Fn,nr,dm,fl=(dm=class{constructor(){Ae(this,Hn);Ae(this,Fn);Ae(this,nr,Object.create(null))}insert(e,t,n,s,i){if(e.length===0){if(w(this,Hn)!==void 0)throw Oi;if(i)return;ue(this,Hn,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",$i]:["","",Zo]:a==="/*"?["","",Zi]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||Zo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw Oi;if(u=w(this,nr)[m],!u){if(Object.keys(w(this,nr)).some(R=>R!==$i&&R!==Zi))throw Oi;if(i)return;u=w(this,nr)[m]=new fl,f!==""&&ue(u,Fn,s.varIndex++)}!i&&f!==""&&n.push([f,w(u,Fn)])}else if(u=w(this,nr)[a],!u){if(Object.keys(w(this,nr)).some(f=>f.length>1&&f!==$i&&f!==Zi))throw Oi;if(i)return;u=w(this,nr)[a]=new fl}u.insert(o,t,n,s,i)}buildRegExpStr(){const t=Object.keys(w(this,nr)).sort(Yv).map(n=>{const s=w(this,nr)[n];return(typeof w(s,Fn)=="number"?`(${n})@${w(s,Fn)}`:Jv.has(n)?`\\${n}`:n)+s.buildRegExpStr()});return typeof w(this,Hn)=="number"&&t.unshift(`#${w(this,Hn)}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},Hn=new WeakMap,Fn=new WeakMap,nr=new WeakMap,dm),zc,Ga,fm,Xv=(fm=class{constructor(){Ae(this,zc,{varIndex:0});Ae(this,Ga,new fl)}insert(r,e,t){const n=[],s=[];for(let a=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${a}`;return s[a]=[u,c],a++,o=!0,u}),!o)break}const i=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=s.length-1;a>=0;a--){const[o]=s[a];for(let c=i.length-1;c>=0;c--)if(i[c].indexOf(o)!==-1){i[c]=i[c].replace(o,s[a][1]);break}}return w(this,Ga).insert(i,e,n,w(this,zc),t),n}buildRegExp(){let r=w(this,Ga).buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,i,a)=>i!==void 0?(t[++e]=Number(i),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},zc=new WeakMap,Ga=new WeakMap,fm),Bm=[],Qv=[/^$/,[],Object.create(null)],Eo=Object.create(null);function Rm(r){return Eo[r]??(Eo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function eb(){Eo=Object.create(null)}function tb(r){var u;const e=new Xv,t=[];if(r.length===0)return Qv;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[R,C])=>f?1:R?-1:m.length-C.length),s=Object.create(null);for(let f=0,m=-1,R=n.length;f<R;f++){const[C,p,y]=n[f];C?s[p]=[y.map(([O])=>[O,Object.create(null)]),Bm]:m++;let A;try{A=e.insert(p,m,C)}catch(O){throw O===Oi?new jm(p):O}C||(t[m]=y.map(([O,P])=>{const N=Object.create(null);for(P-=1;P>=0;P--){const[ve,Le]=A[P];N[ve]=Le}return[O,N]}))}const[i,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let R=0,C=t[f].length;R<C;R++){const p=(u=t[f][R])==null?void 0:u[1];if(!p)continue;const y=Object.keys(p);for(let A=0,O=y.length;A<O;A++)p[y[A]]=o[p[y[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[i,c,s]}function _s(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(Rm(t).test(e))return[...r[t]]}}var un,ln,oi,Pm,$m,hm,rb=(hm=class{constructor(){Ae(this,oi);se(this,"name","RegExpRouter");Ae(this,un);Ae(this,ln);ue(this,un,{[st]:Object.create(null)}),ue(this,ln,{[st]:Object.create(null)})}add(r,e,t){var o;const n=w(this,un),s=w(this,ln);if(!n||!s)throw new Error(Cm);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[st]).forEach(u=>{c[r][u]=[...c[st][u]]})}),e==="/*"&&(e="*");const i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Rm(e);r===st?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=_s(n[u],e)||_s(n[st],e)||[])}):(o=n[r])[e]||(o[e]=_s(n[r],e)||_s(n[st],e)||[]),Object.keys(n).forEach(u=>{(r===st||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,i])})}),Object.keys(s).forEach(u=>{(r===st||r===u)&&Object.keys(s[u]).forEach(f=>c.test(f)&&s[u][f].push([t,i]))});return}const a=wm(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(s).forEach(m=>{var R;(r===st||r===m)&&((R=s[m])[f]||(R[f]=[..._s(n[m],f)||_s(n[st],f)||[]]),s[m][f].push([t,i-u+c+1]))})}}match(r,e){eb();const t=je(this,oi,Pm).call(this);return this.match=(n,s)=>{const i=t[n]||t[st],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],Bm];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}},un=new WeakMap,ln=new WeakMap,oi=new WeakSet,Pm=function(){const r=Object.create(null);return Object.keys(w(this,ln)).concat(Object.keys(w(this,un))).forEach(e=>{r[e]||(r[e]=je(this,oi,$m).call(this,e))}),ue(this,un,ue(this,ln,void 0)),r},$m=function(r){const e=[];let t=r===st;return[w(this,un),w(this,ln)].forEach(n=>{const s=n[r]?Object.keys(n[r]).map(i=>[i,n[r][i]]):[];s.length!==0?(t||(t=!0),e.push(...s)):r!==st&&e.push(...Object.keys(n[st]).map(i=>[i,n[st][i]]))}),t?tb(e):null},hm),dn,Mr,pm,nb=(pm=class{constructor(r){se(this,"name","SmartRouter");Ae(this,dn,[]);Ae(this,Mr,[]);ue(this,dn,r.routers)}add(r,e,t){if(!w(this,Mr))throw new Error(Cm);w(this,Mr).push([r,e,t])}match(r,e){if(!w(this,Mr))throw new Error("Fatal error");const t=w(this,dn),n=w(this,Mr),s=t.length;let i=0,a;for(;i<s;i++){const o=t[i];try{for(let c=0,u=n.length;c<u;c++)o.add(...n[c]);a=o.match(r,e)}catch(c){if(c instanceof jm)continue;throw c}this.match=o.match.bind(o),ue(this,dn,[o]),ue(this,Mr,void 0);break}if(i===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(w(this,Mr)||w(this,dn).length!==1)throw new Error("No active router has been determined yet.");return w(this,dn)[0]}},dn=new WeakMap,Mr=new WeakMap,pm),fn,vt,Wn,Ms,Ot,Vr,$n,mm,Zm=(mm=class{constructor(r,e,t){Ae(this,Vr);Ae(this,fn);Ae(this,vt);Ae(this,Wn);Ae(this,Ms,0);Ae(this,Ot,Object.create(null));if(ue(this,vt,t||Object.create(null)),ue(this,fn,[]),r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},ue(this,fn,[n])}ue(this,Wn,[])}insert(r,e,t){ue(this,Ms,++hh(this,Ms)._);let n=this;const s=kv(e),i=[];for(let c=0,u=s.length;c<u;c++){const f=s[c];if(Object.keys(w(n,vt)).includes(f)){n=w(n,vt)[f];const R=mh(f);R&&i.push(R[1]);continue}w(n,vt)[f]=new Zm;const m=mh(f);m&&(w(n,Wn).push(m),i.push(m[1])),n=w(n,vt)[f]}const a=Object.create(null),o={handler:t,possibleKeys:i.filter((c,u,f)=>f.indexOf(c)===u),score:w(this,Ms)};return a[r]=o,w(n,fn).push(a),n}search(r,e){const t=[];ue(this,Ot,Object.create(null));let s=[this];const i=bm(e);for(let o=0,c=i.length;o<c;o++){const u=i[o],f=o===c-1,m=[];for(let R=0,C=s.length;R<C;R++){const p=s[R],y=w(p,vt)[u];y&&(ue(y,Ot,w(p,Ot)),f?(w(y,vt)["*"]&&t.push(...je(this,Vr,$n).call(this,w(y,vt)["*"],r,w(p,Ot),Object.create(null))),t.push(...je(this,Vr,$n).call(this,y,r,w(p,Ot),Object.create(null)))):m.push(y));for(let A=0,O=w(p,Wn).length;A<O;A++){const P=w(p,Wn)[A],N={...w(p,Ot)};if(P==="*"){const pt=w(p,vt)["*"];pt&&(t.push(...je(this,Vr,$n).call(this,pt,r,w(p,Ot),Object.create(null))),m.push(pt));continue}if(u==="")continue;const[ve,Le,qe]=P,Ze=w(p,vt)[ve],tt=i.slice(o).join("/");if(qe instanceof RegExp&&qe.test(tt)){N[Le]=tt,t.push(...je(this,Vr,$n).call(this,Ze,r,w(p,Ot),N));continue}(qe===!0||qe.test(u))&&(N[Le]=u,f?(t.push(...je(this,Vr,$n).call(this,Ze,r,N,w(p,Ot))),w(Ze,vt)["*"]&&t.push(...je(this,Vr,$n).call(this,w(Ze,vt)["*"],r,N,w(p,Ot)))):(ue(Ze,Ot,N),m.push(Ze)))}}s=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},fn=new WeakMap,vt=new WeakMap,Wn=new WeakMap,Ms=new WeakMap,Ot=new WeakMap,Vr=new WeakSet,$n=function(r,e,t,n){const s=[];for(let i=0,a=w(r,fn).length;i<a;i++){const o=w(r,fn)[i],c=o[e]||o[st],u={};if(c!==void 0){c.params=Object.create(null);for(let f=0,m=c.possibleKeys.length;f<m;f++){const R=c.possibleKeys[f],C=u[c.score];c.params[R]=n[R]&&!C?n[R]:t[R]??n[R],u[c.score]=!0}s.push(c)}}return s},mm),Kn,ym,sb=(ym=class{constructor(){se(this,"name","TrieRouter");Ae(this,Kn);ue(this,Kn,new Zm)}add(r,e,t){const n=wm(e);if(n){for(let s=0,i=n.length;s<i;s++)w(this,Kn).insert(r,n[s],t);return}w(this,Kn).insert(r,e,t)}match(r,e){return w(this,Kn).search(r,e)}},Kn=new WeakMap,ym),ib=class extends Tm{constructor(r={}){super(r),this.router=r.router??new nb({routers:[new rb,new sb]})}},Be;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Be||(Be={}));var hl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(hl||(hl={}));const z=Be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),sn=r=>{switch(typeof r){case"undefined":return z.undefined;case"string":return z.string;case"number":return isNaN(r)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(r)?z.array:r===null?z.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?z.promise:typeof Map<"u"&&r instanceof Map?z.map:typeof Set<"u"&&r instanceof Set?z.set:typeof Date<"u"&&r instanceof Date?z.date:z.object;default:return z.unknown}},Z=Be.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"]),ab=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let or=class Dm extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof Dm))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};or.create=r=>new or(r);const Vs=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Be.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Be.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Be.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Be.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Be.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,Be.assertNever(r)}return{message:t}};let Mm=Vs;function ob(r){Mm=r}function Do(){return Mm}const Mo=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},cb=[];function H(r,e){const t=Do(),n=Mo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Vs?void 0:Vs].filter(s=>!!s)});r.common.issues.push(n)}let Ct=class Vm{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return Vm.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),Os=r=>({status:"dirty",value:r}),xt=r=>({status:"valid",value:r}),pl=r=>r.status==="aborted",ml=r=>r.status==="dirty",Li=r=>r.status==="valid",qi=r=>typeof Promise<"u"&&r instanceof Promise;function Vo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Um(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ae||(ae={}));var Ei,Ii;let Sr=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const bh=(r,e)=>{if(Li(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new or(r.common.issues);return this._error=t,this._error}}};function be(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}let Se=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return sn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ct,ctx:{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(qi(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},i=this._parseSync({data:e,path:s.path,parent:s});return bh(s,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(qi(s)?s:Promise.resolve(s));return bh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:Z.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new dr({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qn.create(this,this._def)}promise(){return qs.create(this,this._def)}or(e){return Ji.create([this,e],this._def)}and(e){return Yi.create(this,e,this._def)}transform(e){return new dr({...be(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ta({...be(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new ef({typeName:de.ZodBranded,type:this,...be(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ra({...be(this._def),innerType:this,catchValue:t,typeName:de.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return tf.create(this,e)}readonly(){return na.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const ub=/^c[^\s-]{8,}$/i,lb=/^[0-9a-z]+$/,db=/^[0-9A-HJKMNP-TV-Z]{26}$/,fb=/^[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,hb=/^[a-z0-9_-]{21}$/i,pb=/^[-+]?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)?)??$/,mb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Gu;const gb=/^(?:(?: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])$/,vb=/^(([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})))$/,bb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Lm="((\\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])))",xb=new RegExp(`^${Lm}$`);function qm(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function _b(r){return new RegExp(`^${qm(r)}$`)}function Hm(r){let e=`${Lm}T${qm(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function wb(r,e){return!!((e==="v4"||!e)&&gb.test(r)||(e==="v6"||!e)&&vb.test(r))}let Us=class Ci extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.string,received:i.parsedType}),pe}const n=new Ct;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?H(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&H(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")mb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"email",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Gu||(Gu=new RegExp(yb,"u")),Gu.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"emoji",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")fb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"uuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")hb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"nanoid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")ub.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")lb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid2",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")db.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"ulid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),H(s,{validation:"url",code:Z.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"regex",code:Z.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Hm(i).test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?xb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?_b(i).test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?pb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"duration",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?wb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"ip",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?bb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"base64",code:Z.invalid_string,message:i.message}),n.dirty()):Be.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:Z.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Ci({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ae.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ae.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ae.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ae.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ae.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ae.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ae.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ae.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ae.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ae.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ae.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...ae.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ae.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ae.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ae.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ae.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ae.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ae.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ae.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ae.errToObj(t)})}nonempty(e){return this.min(1,ae.errToObj(e))}trim(){return new Ci({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ci({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ci({...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}};Us.create=r=>{var e;return new Us({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};function kb(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}let Hi=class yl extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.number,received:i.parsedType}),pe}let n;const s=new Ct;for(const i of this._def.checks)i.kind==="int"?Be.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?kb(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_finite,message:i.message}),s.dirty()):Be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,s){return new yl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new yl({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ae.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ae.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ae.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ae.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Be.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Hi.create=r=>new Hi({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let Fi=class gl extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==z.bigint){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.bigint,received:i.parsedType}),pe}let n;const s=new Ct;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,s){return new gl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new gl({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Fi.create=r=>{var e;return new Fi({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};let Wi=class extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.boolean,received:n.parsedType}),pe}return xt(e.data)}};Wi.create=r=>new Wi({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let Ki=class Fm extends Se{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.date,received:i.parsedType}),pe}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_date}),pe}const n=new Ct;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Be.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Fm({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ae.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Ki.create=r=>new Ki({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,...be(r)});let Uo=class extends Se{_parse(e){if(this._getType(e)!==z.symbol){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.symbol,received:n.parsedType}),pe}return xt(e.data)}};Uo.create=r=>new Uo({typeName:de.ZodSymbol,...be(r)});let zi=class extends Se{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.undefined,received:n.parsedType}),pe}return xt(e.data)}};zi.create=r=>new zi({typeName:de.ZodUndefined,...be(r)});let Gi=class extends Se{_parse(e){if(this._getType(e)!==z.null){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.null,received:n.parsedType}),pe}return xt(e.data)}};Gi.create=r=>new Gi({typeName:de.ZodNull,...be(r)});let Ls=class extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return xt(e.data)}};Ls.create=r=>new Ls({typeName:de.ZodAny,...be(r)});let zn=class extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xt(e.data)}};zn.create=r=>new zn({typeName:de.ZodUnknown,...be(r)});let Hr=class extends Se{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:Z.invalid_type,expected:z.never,received:t.parsedType}),pe}};Hr.create=r=>new Hr({typeName:de.ZodNever,...be(r)});let Lo=class extends Se{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.void,received:n.parsedType}),pe}return xt(e.data)}};Lo.create=r=>new Lo({typeName:de.ZodVoid,...be(r)});let Qn=class Io extends Se{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==z.array)return H(t,{code:Z.invalid_type,expected:z.array,received:t.parsedType}),pe;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(H(t,{code:a?Z.too_big:Z.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(H(t,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(H(t,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Sr(t,a,t.path,o)))).then(a=>Ct.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Sr(t,a,t.path,o)));return Ct.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new Io({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new Io({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new Io({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};Qn.create=(r,e)=>new Qn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,...be(e)});function ks(r){if(r instanceof Wt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(ks(n))}return new Wt({...r._def,shape:()=>e})}else return r instanceof Qn?new Qn({...r._def,type:ks(r.element)}):r instanceof xr?xr.create(ks(r.unwrap())):r instanceof vn?vn.create(ks(r.unwrap())):r instanceof gn?gn.create(r.items.map(e=>ks(e))):r}let Wt=class Xt extends Se{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=Be.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==z.object){const u=this._getOrReturnCtx(e);return H(u,{code:Z.invalid_type,expected:z.object,received:u.parsedType}),pe}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Hr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Sr(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Hr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")o.length>0&&(H(s,{code:Z.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Sr(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,R=await f.value;u.push({key:m,value:R,alwaysSet:f.alwaysSet})}return u}).then(u=>Ct.mergeObjectSync(n,u)):Ct.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ae.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:de.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){const t={};return Be.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}omit(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return ks(this)}partial(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof xr;)i=i._def.innerType;t[n]=i}}),new Xt({...this._def,shape:()=>t})}keyof(){return Ym(Be.objectKeys(this.shape))}};Wt.create=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,...be(e)});Wt.strictCreate=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strict",catchall:Hr.create(),typeName:de.ZodObject,...be(e)});Wt.lazycreate=(r,e)=>new Wt({shape:r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,...be(e)});let Ji=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new or(o.ctx.common.issues));return H(t,{code:Z.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new or(c));return H(t,{code:Z.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Ji.create=(r,e)=>new Ji({options:r,typeName:de.ZodUnion,...be(e)});const Br=r=>r instanceof Xi?Br(r.schema):r instanceof dr?Br(r.innerType()):r instanceof Qi?[r.value]:r instanceof Ja?r.options:r instanceof ea?Be.objectValues(r.enum):r instanceof ta?Br(r._def.innerType):r instanceof zi?[void 0]:r instanceof Gi?[null]:r instanceof xr?[void 0,...Br(r.unwrap())]:r instanceof vn?[null,...Br(r.unwrap())]:r instanceof ef||r instanceof na?Br(r.unwrap()):r instanceof ra?Br(r._def.innerType):[];let Wm=class Km extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return H(t,{code:Z.invalid_type,expected:z.object,received:t.parsedType}),pe;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=Br(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Km({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...be(n)})}};function vl(r,e){const t=sn(r),n=sn(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&n===z.object){const s=Be.objectKeys(e),i=Be.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=vl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===z.array&&n===z.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=vl(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===z.date&&n===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Yi=class extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(pl(i)||pl(a))return pe;const o=vl(i.value,a.value);return o.valid?((ml(i)||ml(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:Z.invalid_intersection_types}),pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Yi.create=(r,e,t)=>new Yi({left:r,right:e,typeName:de.ZodIntersection,...be(t)});let gn=class zm extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return H(n,{code:Z.invalid_type,expected:z.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return H(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Sr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>Ct.mergeArray(t,a)):Ct.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new zm({...this._def,rest:e})}};gn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gn({items:r,typeName:de.ZodTuple,rest:null,...be(e)})};let Gm=class bl extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return H(n,{code:Z.invalid_type,expected:z.object,received:n.parsedType}),pe;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Sr(n,o,n.path,o)),value:a._parse(new Sr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?Ct.mergeObjectAsync(t,s):Ct.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Se?new bl({keyType:e,valueType:t,typeName:de.ZodRecord,...be(n)}):new bl({keyType:Us.create(),valueType:e,typeName:de.ZodRecord,...be(t)})}},qo=class extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.map)return H(n,{code:Z.invalid_type,expected:z.map,received:n.parsedType}),pe;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Sr(n,o,n.path,[u,"key"])),value:i._parse(new Sr(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}};qo.create=(r,e,t)=>new qo({valueType:e,keyType:r,typeName:de.ZodMap,...be(t)});let Ho=class xl extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return H(n,{code:Z.invalid_type,expected:z.set,received:n.parsedType}),pe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(H(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(H(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return pe;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Sr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new xl({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new xl({...this._def,maxSize:{value:e,message:ae.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ho.create=(r,e)=>new Ho({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,...be(e)});let Jm=class Co extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return H(t,{code:Z.invalid_type,expected:z.function,received:t.parsedType}),pe;function n(o,c){return Mo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Do(),Vs].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return Mo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Do(),Vs].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qs){const o=this;return xt(async function(...c){const u=new or([]),f=await o._def.args.parseAsync(c,i).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return xt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new or([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new or([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Co({...this._def,args:gn.create(e).rest(zn.create())})}returns(e){return new Co({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Co({args:e||gn.create([]).rest(zn.create()),returns:t||zn.create(),typeName:de.ZodFunction,...be(n)})}},Xi=class extends Se{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})}};Xi.create=(r,e)=>new Xi({getter:r,typeName:de.ZodLazy,...be(e)});let Qi=class extends Se{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qi.create=(r,e)=>new Qi({value:r,typeName:de.ZodLiteral,...be(e)});function Ym(r,e){return new Ja({values:r,typeName:de.ZodEnum,...be(e)})}let Ja=class _l extends Se{constructor(){super(...arguments),Ei.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Be.joinValues(n),received:t.parsedType,code:Z.invalid_type}),pe}if(Vo(this,Ei)||Um(this,Ei,new Set(this._def.values)),!Vo(this,Ei).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:Z.invalid_enum_value,options:n}),pe}return xt(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 _l.create(e,{...this._def,...t})}exclude(e,t=this._def){return _l.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Ei=new WeakMap;Ja.create=Ym;let ea=class extends Se{constructor(){super(...arguments),Ii.set(this,void 0)}_parse(e){const t=Be.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){const s=Be.objectValues(t);return H(n,{expected:Be.joinValues(s),received:n.parsedType,code:Z.invalid_type}),pe}if(Vo(this,Ii)||Um(this,Ii,new Set(Be.getValidEnumValues(this._def.values))),!Vo(this,Ii).has(e.data)){const s=Be.objectValues(t);return H(n,{received:n.data,code:Z.invalid_enum_value,options:s}),pe}return xt(e.data)}get enum(){return this._def.values}};Ii=new WeakMap;ea.create=(r,e)=>new ea({values:r,typeName:de.ZodNativeEnum,...be(e)});let qs=class extends Se{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.promise&&t.common.async===!1)return H(t,{code:Z.invalid_type,expected:z.promise,received:t.parsedType}),pe;const n=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return xt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qs.create=(r,e)=>new qs({type:r,typeName:de.ZodPromise,...be(e)});let dr=class extends Se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===de.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return pe;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?pe:c.status==="dirty"||t.value==="dirty"?Os(c.value):c});{if(t.value==="aborted")return pe;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?pe:o.status==="dirty"||t.value==="dirty"?Os(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Li(a))return a;const o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Li(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Be.assertNever(s)}};dr.create=(r,e,t)=>new dr({schema:r,typeName:de.ZodEffects,effect:e,...be(t)});dr.createWithPreprocess=(r,e,t)=>new dr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,...be(t)});let xr=class extends Se{_parse(e){return this._getType(e)===z.undefined?xt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(r,e)=>new xr({innerType:r,typeName:de.ZodOptional,...be(e)});let vn=class extends Se{_parse(e){return this._getType(e)===z.null?xt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(r,e)=>new vn({innerType:r,typeName:de.ZodNullable,...be(e)});let ta=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ta.create=(r,e)=>new ta({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...be(e)});let ra=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ra.create=(r,e)=>new ra({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...be(e)});let Fo=class extends Se{_parse(e){if(this._getType(e)!==z.nan){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};Fo.create=r=>new Fo({typeName:de.ZodNaN,...be(r)});const Sb=Symbol("zod_brand");let ef=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},tf=class Xm extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?pe:i.status==="dirty"?(t.dirty(),Os(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Xm({in:e,out:t,typeName:de.ZodPipeline})}},na=class extends Se{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Li(s)&&(s.value=Object.freeze(s.value)),s);return qi(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};na.create=(r,e)=>new na({innerType:r,typeName:de.ZodReadonly,...be(e)});function Qm(r,e={},t){return r?Ls.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Ls.create()}const Ab={object:Wt.lazycreate};var de;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(de||(de={}));const Ob=(r,e={message:`Input not instance of ${r.name}`})=>Qm(t=>t instanceof r,e),ey=Us.create,ty=Hi.create,Eb=Fo.create,Ib=Fi.create,ry=Wi.create,Cb=Ki.create,jb=Uo.create,Tb=zi.create,Nb=Gi.create,Bb=Ls.create,Rb=zn.create,Pb=Hr.create,$b=Lo.create,Zb=Qn.create,Db=Wt.create,Mb=Wt.strictCreate,Vb=Ji.create,Ub=Wm.create,Lb=Yi.create,qb=gn.create,Hb=Gm.create,Fb=qo.create,Wb=Ho.create,Kb=Jm.create,zb=Xi.create,Gb=Qi.create,Jb=Ja.create,Yb=ea.create,Xb=qs.create,xh=dr.create,Qb=xr.create,ex=vn.create,tx=dr.createWithPreprocess,rx=tf.create,nx=()=>ey().optional(),sx=()=>ty().optional(),ix=()=>ry().optional(),ax={string:r=>Us.create({...r,coerce:!0}),number:r=>Hi.create({...r,coerce:!0}),boolean:r=>Wi.create({...r,coerce:!0}),bigint:r=>Fi.create({...r,coerce:!0}),date:r=>Ki.create({...r,coerce:!0})},ox=pe;var v=Object.freeze({__proto__:null,defaultErrorMap:Vs,setErrorMap:ob,getErrorMap:Do,makeIssue:Mo,EMPTY_PATH:cb,addIssueToContext:H,ParseStatus:Ct,INVALID:pe,DIRTY:Os,OK:xt,isAborted:pl,isDirty:ml,isValid:Li,isAsync:qi,get util(){return Be},get objectUtil(){return hl},ZodParsedType:z,getParsedType:sn,ZodType:Se,datetimeRegex:Hm,ZodString:Us,ZodNumber:Hi,ZodBigInt:Fi,ZodBoolean:Wi,ZodDate:Ki,ZodSymbol:Uo,ZodUndefined:zi,ZodNull:Gi,ZodAny:Ls,ZodUnknown:zn,ZodNever:Hr,ZodVoid:Lo,ZodArray:Qn,ZodObject:Wt,ZodUnion:Ji,ZodDiscriminatedUnion:Wm,ZodIntersection:Yi,ZodTuple:gn,ZodRecord:Gm,ZodMap:qo,ZodSet:Ho,ZodFunction:Jm,ZodLazy:Xi,ZodLiteral:Qi,ZodEnum:Ja,ZodNativeEnum:ea,ZodPromise:qs,ZodEffects:dr,ZodTransformer:dr,ZodOptional:xr,ZodNullable:vn,ZodDefault:ta,ZodCatch:ra,ZodNaN:Fo,BRAND:Sb,ZodBranded:ef,ZodPipeline:tf,ZodReadonly:na,custom:Qm,Schema:Se,ZodSchema:Se,late:Ab,get ZodFirstPartyTypeKind(){return de},coerce:ax,any:Bb,array:Zb,bigint:Ib,boolean:ry,date:Cb,discriminatedUnion:Ub,effect:xh,enum:Jb,function:Kb,instanceof:Ob,intersection:Lb,lazy:zb,literal:Gb,map:Fb,nan:Eb,nativeEnum:Yb,never:Pb,null:Nb,nullable:ex,number:ty,object:Db,oboolean:ix,onumber:sx,optional:Qb,ostring:nx,pipeline:rx,preprocess:tx,promise:Xb,record:Hb,set:Wb,strictObject:Mb,string:ey,symbol:jb,transformer:xh,tuple:qb,undefined:Tb,union:Vb,unknown:Rb,void:$b,NEVER:ox,ZodIssueCode:Z,quotelessJson:ab,ZodError:or}),jt=class wl extends ib{constructor(t){super(t);se(this,"openAPIRegistry");se(this,"defaultHook");se(this,"openapi",({middleware:t,...n},s,i=this.defaultHook)=>{var u,f,m,R,C,p,y,A,O,P;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const N=xs("query",n.request.query,i);a.push(N)}if((f=n.request)!=null&&f.params){const N=xs("param",n.request.params,i);a.push(N)}if((m=n.request)!=null&&m.headers){const N=xs("header",n.request.headers,i);a.push(N)}if((R=n.request)!=null&&R.cookies){const N=xs("cookie",n.request.cookies,i);a.push(N)}const o=(p=(C=n.request)==null?void 0:C.body)==null?void 0:p.content;if(o)for(const N of Object.keys(o)){if(!o[N])continue;const ve=o[N].schema;if(ve instanceof Se){if(wh(N)){const Le=xs("json",ve,i);if((A=(y=n.request)==null?void 0:y.body)!=null&&A.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&wh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("json",{}),await tt()};a.push(qe)}}if(kh(N)){const Le=xs("form",ve,i);if((P=(O=n.request)==null?void 0:O.body)!=null&&P.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&kh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("form",{}),await tt()};a.push(qe)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,s),this});se(this,"getOpenAPIDocument",t=>{const s=new bv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?_h(s,this._basePath):s});se(this,"getOpenAPI31Document",t=>{const s=new wv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?_h(s,this._basePath):s});se(this,"doc",(t,n)=>this.get(t,s=>{const i=typeof n=="function"?n(s):n;try{const a=this.getOpenAPIDocument(i);return s.json(a)}catch(a){return s.json(a,500)}}));se(this,"doc31",(t,n)=>this.get(t,s=>{const i=typeof n=="function"?n(s):n;try{const a=this.getOpenAPI31Document(i);return s.json(a)}catch(a){return s.json(a,500)}}));this.openAPIRegistry=new tv,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof wl?(n.openAPIRegistry.definitions.forEach(i=>{switch(i.type){case"component":return this.openAPIRegistry.registerComponent(i.componentType,i.name,i.component);case"route":return this.openAPIRegistry.registerPath({...i.route,path:nn(s,i.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...i.webhook,path:nn(s,i.webhook.path)});case"schema":return this.openAPIRegistry.register(i.schema._def.openapi._internal.refId,i.schema);case"parameter":return this.openAPIRegistry.registerParameter(i.schema._def.openapi._internal.refId,i.schema);default:{const a=i;throw new Error(`Unknown registry type: ${a}`)}}}),this):this}basePath(t){return new wl({...super.basePath(t),defaultHook:this.defaultHook})}},ke=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};Y0(v);function _h(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[nn(e,n)]=r.paths[n]}),{...r,paths:t}}function wh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function kh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function cx(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function ux(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ki(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function lx(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const R=typeof s=="string"?i:s,C=R??{},{param:p}=C,y=cx(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof s=="string"?{refId:s}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),y),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(ux(this,"ZodObject")){const N=this.extend;P.extend=function(...ve){var Le,qe,Ze,tt,pt,Rt;const I=N.apply(this,ve);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(pt=this._def.openapi)===null||pt===void 0?void 0:pt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},ki(r,"optional"),ki(r,"nullable"),ki(r,"default"),ki(r,"transform"),ki(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}new Set(".\\+*[^]$()");var Re;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Re||(Re={}));var kl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(kl||(kl={}));const G=Re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),an=r=>{switch(typeof r){case"undefined":return G.undefined;case"string":return G.string;case"number":return isNaN(r)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(r)?G.array:r===null?G.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?G.promise:typeof Map<"u"&&r instanceof Map?G.map:typeof Set<"u"&&r instanceof Set?G.set:typeof Date<"u"&&r instanceof Date?G.date:G.object;default:return G.unknown}},D=Re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),dx=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Zt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof Zt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Zt.create=r=>new Zt(r);const Hs=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Re.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Re.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Re.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Re.joinValues(r.options)}, received '${r.received}'`;break;case D.invalid_arguments:t="Invalid function arguments";break;case D.invalid_return_type:t="Invalid function return type";break;case D.invalid_date:t="Invalid date";break;case D.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Re.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case D.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case D.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case D.custom:t="Invalid input";break;case D.invalid_intersection_types:t="Intersection results could not be merged";break;case D.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case D.not_finite:t="Number must be finite";break;default:t=e.defaultError,Re.assertNever(r)}return{message:t}};let ny=Hs;function fx(r){ny=r}function Wo(){return ny}const Ko=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},hx=[];function F(r,e){const t=Wo(),n=Ko({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hs?void 0:Hs].filter(s=>!!s)});r.common.issues.push(n)}class yt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return ye;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return yt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ye;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const ye=Object.freeze({status:"aborted"}),zo=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),Sl=r=>r.status==="aborted",Al=r=>r.status==="dirty",sa=r=>r.status==="valid",ia=r=>typeof Promise<"u"&&r instanceof Promise;function Go(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function sy(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var oe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(oe||(oe={}));var ji,Ti;class Ar{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Sh=(r,e)=>{if(sa(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Zt(r.common.issues);return this._error=t,this._error}}};function xe(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,a)=>{var o,c;const{message:u}=r;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:s}}class Oe{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return an(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new yt,ctx:{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ia(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Sh(s,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(ia(s)?s:Promise.resolve(s));return Sh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:D.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new fr({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _r.create(this,this._def)}nullable(){return wn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cr.create(this,this._def)}promise(){return Ws.create(this,this._def)}or(e){return ua.create([this,e],this._def)}and(e){return la.create(this,e,this._def)}transform(e){return new fr({...xe(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ma({...xe(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new rf({typeName:fe.ZodBranded,type:this,...xe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ya({...xe(this._def),innerType:this,catchValue:t,typeName:fe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ya.create(this,e)}readonly(){return ga.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const px=/^c[^\s-]{8,}$/i,mx=/^[0-9a-z]+$/,yx=/^[0-9A-HJKMNP-TV-Z]{26}$/,gx=/^[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,vx=/^[a-z0-9_-]{21}$/i,bx=/^[-+]?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)?)??$/,xx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_x="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ju;const wx=/^(?:(?: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])$/,kx=/^(([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})))$/,Sx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,iy="((\\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])))",Ax=new RegExp(`^${iy}$`);function ay(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ox(r){return new RegExp(`^${ay(r)}$`)}function oy(r){let e=`${iy}T${ay(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ex(r,e){return!!((e==="v4"||!e)&&wx.test(r)||(e==="v6"||!e)&&kx.test(r))}class sr extends Oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.string,received:s.parsedType}),ye}const t=new yt;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.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&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?F(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&F(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")xx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Ju||(Ju=new RegExp(_x,"u")),Ju.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")gx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")vx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")px.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")mx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")yx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:D.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:D.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)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.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)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?oy(s).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Ox(s).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?bx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Ex(e.data,s.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?Sx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:D.invalid_string,message:s.message}),t.dirty()):Re.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:D.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new sr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...oe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...oe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...oe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...oe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...oe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...oe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...oe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...oe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...oe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...oe.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...oe.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...oe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...oe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...oe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...oe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...oe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...oe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...oe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...oe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...oe.errToObj(t)})}nonempty(e){return this.min(1,oe.errToObj(e))}trim(){return new sr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new sr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new sr({...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}}sr.create=r=>{var e;return new sr({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};function Ix(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class bn extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.number,received:s.parsedType}),ye}let t;const n=new yt;for(const s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Ix(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_finite,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,s){return new bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new bn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:oe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:oe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:oe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:oe.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Re.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}bn.create=r=>new bn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class xn extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==G.bigint){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.bigint,received:s.parsedType}),ye}let t;const n=new yt;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),F(t,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,s){return new xn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new xn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}xn.create=r=>{var e;return new xn({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};class aa extends Oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.boolean,received:t.parsedType}),ye}return _t(e.data)}}aa.create=r=>new aa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class es extends Oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.date,received:s.parsedType}),ye}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_date}),ye}const t=new yt;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Re.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new es({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:oe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:oe.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}es.create=r=>new es({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...xe(r)});class Jo extends Oe{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.symbol,received:t.parsedType}),ye}return _t(e.data)}}Jo.create=r=>new Jo({typeName:fe.ZodSymbol,...xe(r)});class oa extends Oe{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.undefined,received:t.parsedType}),ye}return _t(e.data)}}oa.create=r=>new oa({typeName:fe.ZodUndefined,...xe(r)});class ca extends Oe{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.null,received:t.parsedType}),ye}return _t(e.data)}}ca.create=r=>new ca({typeName:fe.ZodNull,...xe(r)});class Fs extends Oe{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}}Fs.create=r=>new Fs({typeName:fe.ZodAny,...xe(r)});class Gn extends Oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}}Gn.create=r=>new Gn({typeName:fe.ZodUnknown,...xe(r)});class Fr extends Oe{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.never,received:t.parsedType}),ye}}Fr.create=r=>new Fr({typeName:fe.ZodNever,...xe(r)});class Yo extends Oe{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.void,received:t.parsedType}),ye}return _t(e.data)}}Yo.create=r=>new Yo({typeName:fe.ZodVoid,...xe(r)});class cr extends Oe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==G.array)return F(t,{code:D.invalid_type,expected:G.array,received:t.parsedType}),ye;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(F(t,{code:a?D.too_big:D.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(F(t,{code:D.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(F(t,{code:D.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>yt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ar(t,a,t.path,o)));return yt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new cr({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new cr({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new cr({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}cr.create=(r,e)=>new cr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...xe(e)});function Ss(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Ss(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof cr?new cr({...r._def,type:Ss(r.element)}):r instanceof _r?_r.create(Ss(r.unwrap())):r instanceof wn?wn.create(Ss(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>Ss(e))):r}class Je extends Oe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Re.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const c=this._getOrReturnCtx(e);return F(c,{code:D.invalid_type,expected:G.object,received:c.parsedType}),ye}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const c in n.data)i.includes(c)||a.push(c);const o=[];for(const c of i){const u=s[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Ar(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Fr){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")a.length>0&&(F(n,{code:D.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const f=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Ar(n,f,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const f=await u.key,m=await u.value;c.push({key:f,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>yt.mergeObjectSync(t,c)):yt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=oe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(e){return new Je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Je({...this._def,catchall:e})}pick(e){const t={};return Re.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}omit(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return Ss(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Je({...this._def,shape:()=>t})}required(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof _r;)s=s._def.innerType;t[n]=s}}),new Je({...this._def,shape:()=>t})}keyof(){return cy(Re.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...xe(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:fe.ZodObject,...xe(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...xe(e)});class ua extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Zt(o.ctx.common.issues));return F(t,{code:D.invalid_union,unionErrors:a}),ye}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Zt(c));return F(t,{code:D.invalid_union,unionErrors:o}),ye}}get options(){return this._def.options}}ua.create=(r,e)=>new ua({options:r,typeName:fe.ZodUnion,...xe(e)});const rn=r=>r instanceof fa?rn(r.schema):r instanceof fr?rn(r.innerType()):r instanceof ha?[r.value]:r instanceof _n?r.options:r instanceof pa?Re.objectValues(r.enum):r instanceof ma?rn(r._def.innerType):r instanceof oa?[void 0]:r instanceof ca?[null]:r instanceof _r?[void 0,...rn(r.unwrap())]:r instanceof wn?[null,...rn(r.unwrap())]:r instanceof rf||r instanceof ga?rn(r.unwrap()):r instanceof ya?rn(r._def.innerType):[];class Jc extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return F(t,{code:D.invalid_type,expected:G.object,received:t.parsedType}),ye;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ye)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=rn(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Jc({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...xe(n)})}}function Ol(r,e){const t=an(r),n=an(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const s=Re.objectKeys(e),i=Re.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Ol(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Ol(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class la extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Sl(i)||Sl(a))return ye;const o=Ol(i.value,a.value);return o.valid?((Al(i)||Al(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:D.invalid_intersection_types}),ye)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}la.create=(r,e,t)=>new la({left:r,right:e,typeName:fe.ZodIntersection,...xe(t)});class Or extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:D.invalid_type,expected:G.array,received:n.parsedType}),ye;if(n.data.length<this._def.items.length)return F(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ye;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((i,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Ar(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>yt.mergeArray(t,i)):yt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Or({...this._def,rest:e})}}Or.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Or({items:r,typeName:fe.ZodTuple,rest:null,...xe(e)})};class da extends Oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return F(n,{code:D.invalid_type,expected:G.object,received:n.parsedType}),ye;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Ar(n,o,n.path,o)),value:a._parse(new Ar(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?yt.mergeObjectAsync(t,s):yt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Oe?new da({keyType:e,valueType:t,typeName:fe.ZodRecord,...xe(n)}):new da({keyType:sr.create(),valueType:e,typeName:fe.ZodRecord,...xe(t)})}}class Xo extends Oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return F(n,{code:D.invalid_type,expected:G.map,received:n.parsedType}),ye;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ar(n,o,n.path,[u,"key"])),value:i._parse(new Ar(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Xo.create=(r,e,t)=>new Xo({valueType:e,keyType:r,typeName:fe.ZodMap,...xe(t)});class ts extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:D.invalid_type,expected:G.set,received:n.parsedType}),ye;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(F(n,{code:D.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(F(n,{code:D.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ye;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ar(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ts({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new ts({...this._def,maxSize:{value:e,message:oe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ts.create=(r,e)=>new ts({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...xe(e)});class Ts extends Oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return F(t,{code:D.invalid_type,expected:G.function,received:t.parsedType}),ye;function n(o,c){return Ko({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wo(),Hs].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function s(o,c){return Ko({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wo(),Hs].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ws){const o=this;return _t(async function(...c){const u=new Zt([]),f=await o._def.args.parseAsync(c,i).catch(R=>{throw u.addIssue(n(c,R)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(R=>{throw u.addIssue(s(m,R)),u})})}else{const o=this;return _t(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Zt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Zt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ts({...this._def,args:Or.create(e).rest(Gn.create())})}returns(e){return new Ts({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ts({args:e||Or.create([]).rest(Gn.create()),returns:t||Gn.create(),typeName:fe.ZodFunction,...xe(n)})}}class fa extends Oe{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}fa.create=(r,e)=>new fa({getter:r,typeName:fe.ZodLazy,...xe(e)});class ha extends Oe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),ye}return{status:"valid",value:e.data}}get value(){return this._def.value}}ha.create=(r,e)=>new ha({value:r,typeName:fe.ZodLiteral,...xe(e)});function cy(r,e){return new _n({values:r,typeName:fe.ZodEnum,...xe(e)})}class _n extends Oe{constructor(){super(...arguments),ji.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Re.joinValues(n),received:t.parsedType,code:D.invalid_type}),ye}if(Go(this,ji)||sy(this,ji,new Set(this._def.values)),!Go(this,ji).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:D.invalid_enum_value,options:n}),ye}return _t(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return _n.create(e,{...this._def,...t})}exclude(e,t=this._def){return _n.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}ji=new WeakMap;_n.create=cy;class pa extends Oe{constructor(){super(...arguments),Ti.set(this,void 0)}_parse(e){const t=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const s=Re.objectValues(t);return F(n,{expected:Re.joinValues(s),received:n.parsedType,code:D.invalid_type}),ye}if(Go(this,Ti)||sy(this,Ti,new Set(Re.getValidEnumValues(this._def.values))),!Go(this,Ti).has(e.data)){const s=Re.objectValues(t);return F(n,{received:n.data,code:D.invalid_enum_value,options:s}),ye}return _t(e.data)}get enum(){return this._def.values}}Ti=new WeakMap;pa.create=(r,e)=>new pa({values:r,typeName:fe.ZodNativeEnum,...xe(e)});class Ws extends Oe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return F(t,{code:D.invalid_type,expected:G.promise,received:t.parsedType}),ye;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return _t(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ws.create=(r,e)=>new Ws({type:r,typeName:fe.ZodPromise,...xe(e)});class fr extends Oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ye;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ye:c.status==="dirty"||t.value==="dirty"?zo(c.value):c});{if(t.value==="aborted")return ye;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ye:o.status==="dirty"||t.value==="dirty"?zo(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!sa(a))return a;const o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>sa(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Re.assertNever(s)}}fr.create=(r,e,t)=>new fr({schema:r,typeName:fe.ZodEffects,effect:e,...xe(t)});fr.createWithPreprocess=(r,e,t)=>new fr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...xe(t)});class _r extends Oe{_parse(e){return this._getType(e)===G.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_r.create=(r,e)=>new _r({innerType:r,typeName:fe.ZodOptional,...xe(e)});class wn extends Oe{_parse(e){return this._getType(e)===G.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wn.create=(r,e)=>new wn({innerType:r,typeName:fe.ZodNullable,...xe(e)});class ma extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ma.create=(r,e)=>new ma({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xe(e)});class ya extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ia(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ya.create=(r,e)=>new ya({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xe(e)});class Qo extends Oe{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.nan,received:t.parsedType}),ye}return{status:"valid",value:e.data}}}Qo.create=r=>new Qo({typeName:fe.ZodNaN,...xe(r)});const Cx=Symbol("zod_brand");class rf extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ya extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),zo(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ya({in:e,out:t,typeName:fe.ZodPipeline})}}class ga extends Oe{_parse(e){const t=this._def.innerType._parse(e),n=s=>(sa(s)&&(s.value=Object.freeze(s.value)),s);return ia(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodReadonly,...xe(e)});function uy(r,e={},t){return r?Fs.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Fs.create()}const jx={object:Je.lazycreate};var fe;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(fe||(fe={}));const Tx=(r,e={message:`Input not instance of ${r.name}`})=>uy(t=>t instanceof r,e),ly=sr.create,dy=bn.create,Nx=Qo.create,Bx=xn.create,fy=aa.create,Rx=es.create,Px=Jo.create,$x=oa.create,Zx=ca.create,Dx=Fs.create,Mx=Gn.create,Vx=Fr.create,Ux=Yo.create,Lx=cr.create,qx=Je.create,Hx=Je.strictCreate,Fx=ua.create,Wx=Jc.create,Kx=la.create,zx=Or.create,Gx=da.create,Jx=Xo.create,Yx=ts.create,Xx=Ts.create,Qx=fa.create,e_=ha.create,t_=_n.create,r_=pa.create,n_=Ws.create,Ah=fr.create,s_=_r.create,i_=wn.create,a_=fr.createWithPreprocess,o_=Ya.create,c_=()=>ly().optional(),u_=()=>dy().optional(),l_=()=>fy().optional(),d_={string:r=>sr.create({...r,coerce:!0}),number:r=>bn.create({...r,coerce:!0}),boolean:r=>aa.create({...r,coerce:!0}),bigint:r=>xn.create({...r,coerce:!0}),date:r=>es.create({...r,coerce:!0})},f_=ye;var d=Object.freeze({__proto__:null,defaultErrorMap:Hs,setErrorMap:fx,getErrorMap:Wo,makeIssue:Ko,EMPTY_PATH:hx,addIssueToContext:F,ParseStatus:yt,INVALID:ye,DIRTY:zo,OK:_t,isAborted:Sl,isDirty:Al,isValid:sa,isAsync:ia,get util(){return Re},get objectUtil(){return kl},ZodParsedType:G,getParsedType:an,ZodType:Oe,datetimeRegex:oy,ZodString:sr,ZodNumber:bn,ZodBigInt:xn,ZodBoolean:aa,ZodDate:es,ZodSymbol:Jo,ZodUndefined:oa,ZodNull:ca,ZodAny:Fs,ZodUnknown:Gn,ZodNever:Fr,ZodVoid:Yo,ZodArray:cr,ZodObject:Je,ZodUnion:ua,ZodDiscriminatedUnion:Jc,ZodIntersection:la,ZodTuple:Or,ZodRecord:da,ZodMap:Xo,ZodSet:ts,ZodFunction:Ts,ZodLazy:fa,ZodLiteral:ha,ZodEnum:_n,ZodNativeEnum:pa,ZodPromise:Ws,ZodEffects:fr,ZodTransformer:fr,ZodOptional:_r,ZodNullable:wn,ZodDefault:ma,ZodCatch:ya,ZodNaN:Qo,BRAND:Cx,ZodBranded:rf,ZodPipeline:Ya,ZodReadonly:ga,custom:uy,Schema:Oe,ZodSchema:Oe,late:jx,get ZodFirstPartyTypeKind(){return fe},coerce:d_,any:Dx,array:Lx,bigint:Bx,boolean:fy,date:Rx,discriminatedUnion:Wx,effect:Ah,enum:t_,function:Xx,instanceof:Tx,intersection:Kx,lazy:Qx,literal:e_,map:Jx,nan:Nx,nativeEnum:r_,never:Vx,null:Zx,nullable:i_,number:dy,object:qx,oboolean:l_,onumber:u_,optional:s_,ostring:c_,pipeline:o_,preprocess:a_,promise:n_,record:Gx,set:Yx,strictObject:Hx,string:ly,symbol:Px,transformer:Ah,tuple:zx,undefined:$x,union:Fx,unknown:Mx,void:Ux,NEVER:f_,ZodIssueCode:D,quotelessJson:dx,ZodError:Zt});lx(d);const jn=d.object({start:d.number(),limit:d.number(),length:d.number()}),nf=d.object({created_at:d.string(),updated_at:d.string()}),hy=d.object({email:d.string().optional(),email_verified:d.boolean().optional(),name:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),phone_number:d.string().optional(),phone_verified:d.boolean().optional(),family_name:d.string().optional()}).catchall(d.any()),py=d.object({connection:d.string(),user_id:d.string(),provider:d.string(),isSocial:d.boolean(),access_token:d.string().optional(),access_token_secret:d.string().optional(),refresh_token:d.string().optional(),profileData:hy.optional()}),Yc=d.object({email:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),family_name:d.string().optional(),nickname:d.string().optional(),name:d.string().optional(),picture:d.string().optional(),locale:d.string().optional(),linked_to:d.string().optional(),profileData:d.string().optional(),user_id:d.string().optional(),app_metadata:d.any().default({}).optional(),user_metadata:d.any().default({}).optional()}),ec=Yc.extend({email_verified:d.boolean().default(!1),verify_email:d.boolean().optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string().optional(),provider:d.string().default("email"),connection:d.string().default("email")}),sf=d.object({...ec.shape,...nf.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(py).optional()}),vr=sf,h_=Yc.extend({email:d.string(),login_count:d.number(),multifactor:d.array(d.string()).optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string()}).catchall(d.any()),p_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let m_=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=p_[t[r]&63];return e};const my=d.object({audience:d.string().optional(),recipient:d.string().optional(),createUpnClaim:d.boolean().optional(),mapUnknownClaimsAsIs:d.boolean().optional(),passthroughClaimsWithNoMapping:d.boolean().optional(),mapIdentities:d.boolean().optional(),signatureAlgorithm:d.string().optional(),digestAlgorithm:d.string().optional(),issuer:d.string().optional(),destination:d.string().optional(),lifetimeInSeconds:d.number().optional(),signResponse:d.boolean().optional(),nameIdentifierFormat:d.string().optional(),nameIdentifierProbes:d.array(d.string()).optional(),authnContextClassRef:d.string().optional(),mappings:d.record(d.string()).optional()}),tc=d.object({id:d.string(),name:d.string(),callbacks:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:d.array(d.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:d.object({samlp:my.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:d.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:d.string().default(()=>m_()).optional(),disable_sign_ups:d.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Mn=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...tc.shape});var af=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(af||{}),of=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(of||{}),cf=(r=>(r.S265="S256",r.plain="plain",r))(cf||{});const yy=d.object({client_id:d.string(),vendor_id:d.string().optional(),act_as:d.string().optional(),response_type:d.nativeEnum(af).optional(),response_mode:d.nativeEnum(of).optional(),redirect_uri:d.string().optional(),audience:d.string().optional(),state:d.string().optional(),nonce:d.string().optional(),scope:d.string().optional(),prompt:d.string().optional(),code_challenge_method:d.nativeEnum(cf).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),El=d.object({colors:d.object({primary:d.string(),page_background:d.object({type:d.string().optional(),start:d.string().optional(),end:d.string().optional(),angle_deg:d.number().optional()}).optional()}).optional(),logo_url:d.string().optional(),favicon_url:d.string().optional(),font:d.object({url:d.string()}).optional()}),rc=d.object({id:d.string().optional(),name:d.string(),strategy:d.enum(["google-oauth2","facebook","vipps","freja","apple","email","auth0","authhero","Username-Password-Authentication","oidc","oauth2","custom"]),options:d.object({kid:d.string().optional(),team_id:d.string().optional(),realms:d.string().optional(),client_id:d.string().optional(),client_secret:d.string().optional(),app_secret:d.string().optional(),scope:d.string().optional(),authorization_endpoint:d.string().default("").optional(),token_endpoint:d.string().default("").optional(),userinfo_endpoint:d.string().default("").optional(),jwks_uri:d.string().default("").optional(),discovery_url:d.string().default("").optional(),issuer:d.string().default("").optional()}).default({}).optional(),enabled_clients:d.array(d.string()).default([]).optional(),response_type:d.custom().optional(),response_mode:d.custom().optional()}),Vn=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(rc.shape),nc=d.object({name:d.string(),audience:d.string(),sender_email:d.string().email(),sender_name:d.string(),support_url:d.string().url().optional(),logo:d.string().url().optional(),primary_color:d.string().optional(),secondary_color:d.string().optional(),language:d.string().optional()}),Ns=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...nc.shape}),y_=d.object({logoUrl:d.string(),loginBackgroundImage:d.string().nullish(),style:d.object({primaryColor:d.string(),buttonTextColor:d.string(),primaryHoverColor:d.string()}),supportEmail:d.string().nullable(),supportUrl:d.string().nullable(),name:d.string(),showGreyishBackground:d.boolean().optional(),termsAndConditionsUrl:d.string().nullable(),companyName:d.string().optional(),checkoutHideSocial:d.boolean().optional(),siteUrl:d.string().nullable(),manageSubscriptionsUrl:d.string().optional()}),g_=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.union([d.literal("mailgun"),d.literal("mailchannels")]).optional()});d.object({...Mn.shape,domains:d.array(g_),tenant:Ns,connections:d.array(Vn)});const gy=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),vy=d.object({code_id:d.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:d.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:d.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:gy,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()}),v_=d.object({...vy.shape,created_at:d.string()}),by=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.enum(["mailgun","mailchannels"])}),b_=nf.extend({...by.shape,id:d.string()}),sc=d.object({trigger_id:d.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:d.boolean().default(!1),url:d.string(),hook_id:d.string().optional(),synchronous:d.boolean().default(!1),priority:d.number().optional()}),Es=sc.extend({...nf.shape,hook_id:d.string()}),uf=d.object({alg:d.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:d.string(),kid:d.string(),kty:d.enum(["RSA","EC","oct"]),n:d.string(),x5t:d.string().optional(),x5c:d.array(d.string()).optional(),use:d.enum(["sig","enc"]).optional()}),xy=d.object({keys:d.array(uf)}),Il=d.object({issuer:d.string(),authorization_endpoint:d.string(),token_endpoint:d.string(),device_authorization_endpoint:d.string(),userinfo_endpoint:d.string(),mfa_challenge_endpoint:d.string(),jwks_uri:d.string(),registration_endpoint:d.string(),revocation_endpoint:d.string(),scopes_supported:d.array(d.string()),response_types_supported:d.array(d.string()),code_challenge_methods_supported:d.array(d.string()),response_modes_supported:d.array(d.string()),subject_types_supported:d.array(d.string()),id_token_signing_alg_values_supported:d.array(d.string()),token_endpoint_auth_methods_supported:d.array(d.string()),claims_supported:d.array(d.string()),request_uri_parameter_supported:d.boolean(),request_parameter_supported:d.boolean(),token_endpoint_auth_signing_alg_values_supported:d.array(d.string())}),_y=d.object({auth0Client:d.string().optional(),authParams:yy,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional()}).openapi({description:"This represents a login sesion"}),x_=d.object({..._y.shape,login_id:d.string().openapi({description:"This is is used as the state in the universal login"}),created_at:d.string(),updated_at:d.string()});var Xc=(r=>(r.FAILED_SILENT_AUTH="fsa",r.FAILED_SIGNUP="fs",r.FAILED_LOGIN="f",r.FAILED_LOGIN_INCORRECT_PASSWORD="fp",r.FAILED_CHANGE_PASSWORD="fcp",r.FAILED_BY_CONNECTOR="fc",r.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",r.FAILED_HOOK="fh",r.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",r.SUCCESS_API_OPERATION="sapi",r.SUCCESS_CHANGE_PASSWORD="scp",r.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",r.SUCCESS_CHANGE_USERNAME="scu",r.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",r.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",r.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",r.SUCCESS_LOGIN="s",r.SUCCESS_LOGOUT="slo",r.SUCCESS_SIGNUP="ss",r.SUCCESS_SILENT_AUTH="ssa",r.SUCCESS_VERIFICATION_EMAIL="sv",r.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",r.CODE_LINK_SENT="cls",r))(Xc||{});const __=d.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),wy=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),ic=d.object({type:__,date:d.string(),description:d.string().optional(),log_id:d.string().optional(),_id:d.string().optional(),ip:d.string(),user_agent:d.string(),details:d.any().optional(),isMobile:d.boolean(),user_id:d.string().optional(),user_name:d.string().optional(),connection:d.string().optional(),connection_id:d.string().optional(),client_id:d.string().optional(),client_name:d.string().optional(),audience:d.string().optional(),scope:d.array(d.string()).optional(),strategy:d.string().optional(),strategy_type:d.string().optional(),hostname:d.string().optional(),auth0_client:wy.optional()}),ky=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")}),w_=d.object({...ky.shape,created_at:d.string(),updated_at:d.string()}),Sy=d.object({session_id:d.string(),client_id:d.string(),expires_at:d.string(),used_at:d.string(),deleted_at:d.string().optional(),user_id:d.string()}),lf=d.object({created_at:d.string(),...Sy.shape}),Cl=d.object({kid:d.string().openapi({description:"The key id of the signing key"}),cert:d.string().openapi({description:"The public certificate of the signing key"}),fingerprint:d.string().openapi({description:"The cert fingerprint"}),thumbprint:d.string().openapi({description:"The cert thumbprint"}),pkcs7:d.string().optional().openapi({description:"The private key in pkcs7 format"}),current:d.boolean().optional().openapi({description:"True if the key is the current key"}),next:d.boolean().optional().openapi({description:"True if the key is the next key"}),previous:d.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:d.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:d.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:d.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:d.string().optional().openapi({description:"The date and time when the key was revoked"})});var df=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(df||{});const ff=d.nativeEnum(df),k_=d.object({grant_type:ff.refine(r=>r==="authorization_code"),code:d.string(),client_secret:d.string(),client_id:d.string()}),S_=d.object({grant_type:ff.refine(r=>r==="authorization_code"),code:d.string(),code_verifier:d.string(),client_id:d.string().optional(),redirect_uri:d.string()}),A_=d.object({grant_type:ff.refine(r=>r==="client_credentials"),scope:d.string().optional(),client_secret:d.string(),client_id:d.string(),audience:d.string().optional()});d.object({access_token:d.string(),id_token:d.string().optional(),scope:d.string().optional(),state:d.string().optional(),refresh_token:d.string().optional(),token_type:d.string(),expires_in:d.number()});d.object({code:d.string(),state:d.string().optional()});const Ay=d.object({button_border_radius:d.number(),button_border_weight:d.number(),buttons_style:d.enum(["pill"]),input_border_radius:d.number(),input_border_weight:d.number(),inputs_style:d.enum(["pill"]),show_widget_shadow:d.boolean(),widget_border_weight:d.number(),widget_corner_radius:d.number()}),Oy=d.object({base_focus_color:d.string(),base_hover_color:d.string(),body_text:d.string(),captcha_widget_theme:d.enum(["auto"]),error:d.string(),header:d.string(),icons:d.string(),input_background:d.string(),input_border:d.string(),input_filled_text:d.string(),input_labels_placeholders:d.string(),links_focused_components:d.string(),primary_button:d.string(),primary_button_label:d.string(),secondary_button_border:d.string(),secondary_button_label:d.string(),success:d.string(),widget_background:d.string(),widget_border:d.string()}),Zn=d.object({bold:d.boolean(),size:d.number()}),Ey=d.object({body_text:Zn,buttons_text:Zn,font_url:d.string(),input_labels:Zn,links:Zn,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Zn,title:Zn}),Iy=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),Cy=d.object({header_text_alignment:d.enum(["center"]),logo_height:d.number(),logo_position:d.enum(["center"]),logo_url:d.string(),social_buttons_layout:d.enum(["bottom"])}),jy=d.object({borders:Ay,colors:Oy,displayName:d.string(),fonts:Ey,page_background:Iy,widget:Cy}),O_=jy.extend({themeId:d.string()}),jo=d.object({universal_login_experience:d.enum(["new","classic"]).default("new"),identifier_first:d.boolean().default(!0),password_first:d.boolean().default(!1),webauthn_platform_first_factor:d.boolean()});function E_(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}var ac=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function I_(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function C_(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
2
2
  Copyright (C) Microsoft. All rights reserved.
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
@@ -114,7 +114,7 @@ PERFORMANCE OF THIS SOFTWARE.
114
114
  `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let s=this.pad(t++),i="";const a=e[Me.VALUE];a&&(i=` ${a}`),n.push(`${s}${e[Me.NAME]}:${i}`),s=this.pad(t);for(const o in e){if(typeof o=="symbol")continue;const c=e[o],u=o?`${o}: `:"";if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`${s}${u}${c}`);else if(c instanceof Date)n.push(`${s}${u}${c.toUTCString()}`);else if(Array.isArray(c))for(const f of c)f[Me.NAME]=o,n.push(...this.serializeObj(f,t));else if(c instanceof Me)c[Me.NAME]=o,n.push(...this.serializeObj(c,t));else if(q.isBufferSource(c))o?(n.push(`${s}${u}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){const f=c.toTextObject();f[Me.NAME]=o,n.push(...this.serializeObj(f,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){const n=this.pad(t),s=q.toUint8Array(e),i=[];for(let a=0;a<s.length;){const o=[];for(let c=0;c<16&&a<s.length;c++){c===8&&o.push("");const u=s[a++].toString(16).padStart(2,"0");o.push(u)}i.push(`${n}${o.join(" ")}`)}return i}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}hs.oidSerializer=Nn;hs.algorithmSerializer=o1;class Bn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=L.serialize(t),this.onInit(t)}else{const t=L.parse(e[0],e[1]);this.rawData=q.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof Bn?Ty(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return L.toString(this.rawData);case"text":return hs.serialize(this.toTextObject());case"hex":return te.ToHex(this.rawData);case"base64":return te.ToBase64(this.rawData);case"base64url":return te.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new Me(this.getTextName(),{},e)}}Bn.NAME="ASN";class Gt extends Bn{constructor(...e){let t;q.isBufferSource(e[0])?t=q.toArrayBuffer(e[0]):t=L.serialize(new Kt({extnID:e[0],critical:e[1],extnValue:new $e(q.toArrayBuffer(e[2]))})),super(t,Kt)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[Me.NAME]===Gt.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}var h0;class hn{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[h0]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(hn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(hn.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=hn.DEFAULT){const t=this.items.get(e.toLowerCase());if(!t)throw new Error(`Cannot get Crypto by name '${e}'`);return t}set(e,t){if(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(hn.DEFAULT,e);return this}}h0=Symbol.toStringTag;hn.DEFAULT="default";const ut=new hn,c1=/^[0-2](?:\.[1-9][0-9]*)+$/;function u1(r){return new RegExp(c1).test(r)}class p0{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return u1(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const Tt=new p0;Tt.register("CN","2.5.4.3");Tt.register("L","2.5.4.7");Tt.register("ST","2.5.4.8");Tt.register("O","2.5.4.10");Tt.register("OU","2.5.4.11");Tt.register("C","2.5.4.6");Tt.register("DC","0.9.2342.19200300.100.1.25");Tt.register("E","1.2.840.113549.1.9.1");Tt.register("G","2.5.4.42");Tt.register("I","2.5.4.43");Tt.register("SN","2.5.4.4");Tt.register("T","2.5.4.12");function l1(r,e){return`\\${te.ToHex(te.FromUtf8String(e)).toUpperCase()}`}function d1(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,l1)}class Ht{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,t={}){this.extraNames=new p0,this.asn=new et;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const s=t[n];this.extraNames.register(n,s)}typeof e=="string"?this.asn=this.fromString(e):e instanceof et?this.asn=e:q.isBufferSource(e)?this.asn=L.parse(e,et):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||Tt.findId(e),n=[];for(const s of this.asn)for(const i of s)i.type===t&&n.push(i.value.toString());return n}getName(e){return this.extraNames.get(e)||Tt.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,s=t.value.anyValue?`#${te.ToHex(t.value.anyValue)}`:d1(t.value.toString());return`${n}=${s}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const s={};for(const i of n){const a=this.getName(i.type)||i.type;(e=s[a])!==null&&e!==void 0||(s[a]=[]),s[a].push(i.value.anyValue?`#${te.ToHex(i.value.anyValue)}`:i.value.toString())}t.push(s)}return t}fromString(e){const t=new et,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let s=null,i=",";for(;s=n.exec(`${e},`);){let[,a,o]=s;const c=o[o.length-1];(c===","||c==="+")&&(o=o.slice(0,o.length-1),s[3]=c);const u=s[3];a=this.getTypeOid(a);const f=this.createAttribute(a,o);i==="+"?t[t.length-1].push(f):t.push(new Gs([f])),i=u}return t}fromJSON(e){const t=new et;for(const n of e){const s=new Gs;for(const i in n){const a=this.getTypeOid(i),o=n[i];for(const c of o){const u=this.createAttribute(a,c);s.push(u)}}t.push(s)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,t){const n=new yu({type:e});if(typeof t=="object")for(const s in t)switch(s){case"ia5String":n.value.ia5String=t[s];break;case"utf8String":n.value.utf8String=t[s];break;case"universalString":n.value.universalString=t[s];break;case"bmpString":n.value.bmpString=t[s];break;case"printableString":n.value.printableString=t[s];break}else if(t[0]==="#")n.value.anyValue=te.FromHex(t.slice(1));else{const s=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=s:Ht.isPrintableString(s)?n.value.printableString=s:n.value.utf8String=s}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
115
115
  `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return L.serialize(this.asn)}async getThumbprint(...e){var t;let n,s="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(s=e[0]||s,n=e[1]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(s,this.toArrayBuffer())}}const m0="Cannot initialize GeneralName from ASN.1 data.",Wp=`${m0} Unsupported string format in use.`,f1=`${m0} Value doesn't match to GUID regular expression.`,Kp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,zp="1.3.6.1.4.1.311.25.1",Gp="1.3.6.1.4.1.311.20.2.3",el="dns",tl="dn",rl="email",nl="ip",sl="url",il="guid",al="upn",_o="id";class pn extends Bn{constructor(...e){let t;if(e.length===2)switch(e[0]){case tl:{const n=new Ht(e[1]).toArrayBuffer(),s=L.parse(n,et);t=new ge({directoryName:s});break}case el:t=new ge({dNSName:e[1]});break;case rl:t=new ge({rfc822Name:e[1]});break;case il:{const n=new RegExp(Kp,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const s=n.slice(1).map((i,a)=>a<3?te.ToHex(new Uint8Array(te.FromHex(i)).reverse()):i).join("");t=new ge({otherName:new ba({typeId:zp,value:L.serialize(new $e(te.FromHex(s)))})});break}case nl:t=new ge({iPAddress:e[1]});break;case _o:t=new ge({registeredID:e[1]});break;case al:{t=new ge({otherName:new ba({typeId:Gp,value:L.serialize(Tg.toASN(e[1]))})});break}case sl:t=new ge({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else q.isBufferSource(e[0])?t=L.parse(e[0],ge):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=el,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=rl,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=nl,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=sl,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=_o,this.value=e.registeredID;else if(e.directoryName!=null)this.type=tl,this.value=new Ht(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===zp){this.type=il;const t=L.parse(e.otherName.value,$e),n=new RegExp(Kp,"i").exec(te.ToHex(t));if(!n)throw new Error(f1);this.value=n.slice(1).map((s,i)=>i<3?te.ToHex(new Uint8Array(te.FromHex(s)).reverse()):s).join("-")}else if(e.otherName.typeId===Gp)this.type=al,this.value=L.parse(e.otherName.value,ft).toString();else throw new Error(Wp);else throw new Error(Wp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case tl:case el:case il:case nl:case _o:case al:case sl:e=this.type.toUpperCase();break;case rl:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===_o&&(t=Nn.toString(t)),new Me(e,void 0,t)}}class Ea extends Bn{constructor(e){let t;if(e instanceof bt)t=e;else if(Array.isArray(e)){const n=[];for(const s of e)if(s instanceof ge)n.push(s);else{const i=L.parse(new pn(s.type,s.value).rawData,ge);n.push(i)}t=new bt(n)}else if(q.isBufferSource(e))t=L.parse(e,bt);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let s=null;try{s=new pn(n)}catch{continue}t.push(s)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const n=t.toTextObject();let s=e[n[Me.NAME]];Array.isArray(s)||(s=[],e[n[Me.NAME]]=s),s.push(n)}return e}}Ea.NAME="GeneralNames";const Ui="-{5}",Ia="\\n",h1=`[^${Ia}]+`,p1=`${Ui}BEGIN (${h1}(?=${Ui}))${Ui}`,m1=`${Ui}END \\1${Ui}`,ni="\\n",y1=`[^:${Ia}]+`,g1=`(?:[^${Ia}]+${ni}(?: +[^${Ia}]+${ni})*)`,v1="[a-zA-Z0-9=+/]+",b1=`(?:${v1}${ni})+`,Jp=`${p1}${ni}(?:((?:${y1}: ${g1})+))?${ni}?(${b1})${m1}`;class $t{static isPem(e){return typeof e=="string"&&new RegExp(Jp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Jp,"g"),n=[];let s=null;for(;s=t.exec(e);){const i=s[3].replace(new RegExp(`[${Ia}]+`,"g"),""),a={type:s[1],headers:[],rawData:te.FromBase64(i)},o=s[2];if(o){const c=o.split(new RegExp(ni,"g"));let u=null;for(const f of c){const[m,R]=f.split(/:(.*)/);if(R===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=m.trim()}else u&&a.headers.push(u),u={key:m,value:R.trim()}}u&&a.headers.push(u)}n.push(a)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){const t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){const n=new Array;return t?e.forEach(s=>{if(!q.isBufferSource(s))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:q.toArrayBuffer(s)}))}):e.forEach(s=>{if(!("type"in s))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(s))}),n.join(`
116
116
  `)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:q.toArrayBuffer(e)})}}static encodeStruct(e){var t;const n=e.type.toLocaleUpperCase(),s=[];if(s.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const u of e.headers)s.push(`${u.key}: ${u.value}`);s.push("")}const i=te.ToBase64(e.rawData);let a,o=0;const c=Array();for(;o<i.length&&(i.length-o<64?a=i.substring(o):(a=i.substring(o,o+64),o+=64),a.length!==0);)if(c.push(a),a.length<64)break;return s.push(...c),s.push(`-----END ${n}-----`),s.join(`
117
- `)}}$t.CertificateTag="CERTIFICATE";$t.CrlTag="CRL";$t.CertificateRequestTag="CERTIFICATE REQUEST";$t.PublicKeyTag="PUBLIC KEY";$t.PrivateKeyTag="PRIVATE KEY";class Jr extends Bn{static isAsnEncoded(e){return q.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if($t.isPem(e))return $t.decode(e)[0];if(te.isHex(e))return te.FromHex(e);if(te.isBase64(e))return te.FromBase64(e);if(te.isBase64Url(e))return te.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=te.ToBinary(e);return $t.isPem(t)?$t.decode(t)[0]:te.isHex(t)?te.FromHex(t):te.isBase64(t)?te.FromBase64(t):te.isBase64Url(t)?te.FromBase64Url(t):q.toArrayBuffer(e)}}constructor(...e){Jr.isAsnEncoded(e[0])?super(Jr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return $t.encode(this.rawData,this.tag);default:return super.toString(e)}}}class ur extends Jr{static async create(e,t=ut.get()){if(e instanceof ur)return e;if(hn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new ur(n)}else{if(e.publicKey)return e.publicKey;if(q.isBufferSource(e))return new ur(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Jr.isAsnEncoded(e)?super(e,ir):super(e),this.tag=$t.PublicKeyTag}async export(...e){let t,n=["verify"],s={hash:"SHA-256",...this.algorithm};e.length>1?(s=e[0]||s,n=e[1]||n,t=e[2]||ut.get()):t=e[0]||ut.get();let i=this.rawData;const a=L.parse(this.rawData,ir);return a.algorithm.algorithm===Vi&&(i=x1(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=ht.resolve(fs),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case us:{const s=L.parse(e.subjectPublicKey,Kf),i=q.toUint8Array(s.modulus);n.publicExponent=q.toUint8Array(s.publicExponent),n.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,s="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(s=e[0]||s,n=e[1]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(s,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=ut.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=ut.get();const s=L.parse(this.rawData,ir);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,ir);switch(e.Algorithm=hs.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case ka:e["EC Point"]=t.subjectPublicKey;break;case us:default:e["Raw Data"]=t.subjectPublicKey}return e}}function x1(r,e){return r.algorithm=new Y({algorithm:us,parameters:null}),e=L.serialize(r),e}class Ca extends Gt{static async create(e,t=!1,n=ut.get()){if("name"in e&&"serialNumber"in e)return new Ca(e,t);const i=await(await ur.create(e,n)).getKeyIdentifier(n);return new Ca(te.ToHex(i),t)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Ln({keyIdentifier:new If(te.FromHex(e[0]))});super(Ml,e[1],L.serialize(t))}else{const t=e[0],n=t.name instanceof Ea?L.parse(t.name.rawData,bt):t.name,s=new Ln({authorityCertIssuer:n,authorityCertSerialNumber:te.FromHex(t.serialNumber)});super(Ml,e[1],L.serialize(s))}}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Ln);t.keyIdentifier&&(this.keyId=te.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?te.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,Ln);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Ea(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Ca.NAME="Authority Key Identifier";class Yf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,lc);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new lc({cA:e[0],pathLenConstraint:e[1]});super(Rg,e[2],L.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}Yf.NAME="Basic Constraints";var Yp;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(Yp||(Yp={}));class Xf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,pc);this.usages=t.map(n=>n)}else{const t=new pc(e[0]);super(Zg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>Nn.toString(t)).join(", "),e}}Xf.NAME="Extended Key Usages";var Vc;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Vc||(Vc={}));class Qf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,Qu);this.usages=t.toNumber()}else{const t=new Qu(e[0]);super(Dg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,Qu);return e[""]=t.toJSON().join(", "),e}}Qf.NAME="Key Usages";class mo extends Gt{static async create(e,t=!1,n=ut.get()){const i=await(await ur.create(e,n)).getKeyIdentifier(n);return new mo(te.ToHex(i),t)}constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,yn);this.keyId=te.ToHex(t)}else{const t=typeof e[0]=="string"?te.FromHex(e[0]):e[0],n=new yn(t);super(Lg,e[1],L.serialize(n)),this.keyId=te.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,yn);return e[""]=t,e}}mo.NAME="Subject Key Identifier";class y0 extends Gt{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(Ug,e[1],new Ea(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,ed);this.names=new Ea(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}y0.NAME="Subject Alternative Name";class Jt{static register(e,t){this.items.set(e,t)}static create(e){const t=new Gt(e),n=this.items.get(t.type);return n?new n(e):t}}Jt.items=new Map;class g0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0])){super(e[0]);const n=L.parse(this.value,fc);this.policies=n.map(s=>s.policyIdentifier)}else{const n=e[0],s=(t=e[1])!==null&&t!==void 0?t:!1,i=new fc(n.map(a=>new vu({policyIdentifier:a})));super(Pg,s,L.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Me("",{},Nn.toString(t))),e}}g0.NAME="Certificate Policies";Jt.register(Pg,g0);class v0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const s=e[0].map(a=>new li({distributionPoint:new is({fullName:[new ge({uniformResourceIdentifier:a})]})})),i=new Rs(s);super(Hl,e[1],L.serialize(i))}else{const n=new Rs(e[0]);super(Hl,e[1],L.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Rs);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const s={};return t.distributionPoint&&(s[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(i=>new pn(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}v0.NAME="CRL Distribution Points";class b0 extends Gt{constructor(...e){var t,n,s,i;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Is){const a=new Is(e[0]);super(Dl,e[1],L.serialize(a))}else{const a=e[0],o=new Is;ko(o,a,Rh,"ocsp"),ko(o,a,Ph,"caIssuers"),ko(o,a,$h,"timeStamping"),ko(o,a,Zh,"caRepository"),super(Dl,e[1],L.serialize(o))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(s=this.timeStamping)!==null&&s!==void 0||(this.timeStamping=[]),(i=this.caRepository)!==null&&i!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],L.parse(e.extnValue,Is).forEach(n=>{switch(n.accessMethod){case Rh:this.ocsp.push(new pn(n.accessLocation));break;case Ph:this.caIssuers.push(new pn(n.accessLocation));break;case $h:this.timeStamping.push(new pn(n.accessLocation));break;case Zh:this.caRepository.push(new pn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&wo(e,"OCSP",this.ocsp),this.caIssuers.length&&wo(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&wo(e,"Time Stamping",this.timeStamping),this.caRepository.length&&wo(e,"CA Repository",this.caRepository),e}}b0.NAME="Authority Info Access";function wo(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new Me("");t.forEach((s,i)=>{const a=s.toTextObject(),o=`${a[Me.NAME]} ${i+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function ko(r,e,t,n){const s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(a=>{typeof a=="string"&&(a=new pn("url",a)),r.push(new to({accessMethod:t,accessLocation:L.parse(a.rawData,ge)}))})}class gi extends Bn{constructor(...e){let t;if(q.isBufferSource(e[0]))t=q.toArrayBuffer(e[0]);else{const n=e[0],s=Array.isArray(e[1])?e[1].map(i=>q.toArrayBuffer(i)):[];t=L.serialize(new Kr({type:n,values:s}))}super(t,Kr)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Me("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[Me.NAME]===gi.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}gi.NAME="Attribute";class x0 extends gi{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=new Dc({printableString:e[0]});super(l0,[L.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],Dc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Me.VALUE]=this.password,e}}x0.NAME="Challenge Password";class eh extends gi{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new kn;for(const i of n)s.push(L.parse(i.rawData,Kt));super(Jf,[L.serialize(s)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],kn);this.items=t.map(n=>Jt.create(L.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[Me.NAME]]=n;return e}}eh.NAME="Extensions";class Uu{static register(e,t){this.items.set(e,t)}static create(e){const t=new gi(e),n=this.items.get(t.type);return n?new n(e):t}}Uu.items=new Map;const yo="crypto.signatureFormatter";class _1{toAsnSignature(e,t){return q.toArrayBuffer(t)}toWebSignature(e,t){return q.toArrayBuffer(t)}}var Ro;let Hd=Ro=class{static createPssParams(e,t){const n=Ro.getHashAlgorithm(e);return n?new ds({hashAlgorithm:n,maskGenAlgorithm:new Y({algorithm:Nu,parameters:L.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=ht.resolve(fs);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new Y({algorithm:Ic,parameters:null});case"sha-256":return new Y({algorithm:_d,parameters:null});case"sha-384":return new Y({algorithm:Cc,parameters:null});case"sha-512":return new Y({algorithm:jc,parameters:null})}}else return new Y({algorithm:us,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=Ro.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new Y({algorithm:Vi,parameters:L.serialize(t)})}else return new Y({algorithm:Vi,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case us:return{name:"RSASSA-PKCS1-v1_5"};case Ic:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case _d:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Cc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case jc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Vi:if(e.parameters){const t=L.parse(e.parameters,ds);return{name:"RSA-PSS",hash:ht.resolve(fs).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Hd=Ro=l([$u()],Hd);ht.registerSingleton(po,Hd);let Fd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Y({algorithm:Tc});case"sha-256":return new Y({algorithm:Nc});case"sha-384":return new Y({algorithm:Bc});case"sha-512":return new Y({algorithm:Rc})}return null}toWebAlgorithm(e){switch(e.algorithm){case Tc:return{name:"SHA-1"};case Nc:return{name:"SHA-256"};case Bc:return{name:"SHA-384"};case Rc:return{name:"SHA-512"}}return null}};Fd=l([$u()],Fd);ht.registerSingleton(po,Fd);class Ft{addPadding(e,t){const n=q.toUint8Array(t),s=new Uint8Array(e);return s.set(n,e-n.length),s}removePadding(e,t=!1){let n=q.toUint8Array(e);for(let s=0;s<n.length;s++)if(n[s]){n=n.slice(s);break}if(t&&n[0]>127){const s=new Uint8Array(n.length+1);return s.set(n,1),s.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,s=Ft.namedCurveSize.get(n)||Ft.defaultNamedCurveSize,i=new Ec,a=q.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),L.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=L.parse(t,Ec),s=e.namedCurve,i=Ft.namedCurveSize.get(s)||Ft.defaultNamedCurveSize,a=this.addPadding(i,this.removePadding(n.r)),o=this.addPadding(i,this.removePadding(n.s));return R_(a,o)}return null}}Ft.namedCurveSize=new Map;Ft.defaultNamedCurveSize=32;const ol="1.3.101.110",Xp="1.3.101.111",cl="1.3.101.112",Qp="1.3.101.113";let Wd=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=cl;break;case"x25519":t=ol;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=cl;break;case"ed448":t=Qp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=ol;break;case"x448":t=Xp;break}}return t?new Y({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case cl:return{name:"Ed25519"};case Qp:return{name:"EdDSA",namedCurve:"Ed448"};case ol:return{name:"X25519"};case Xp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Wd=l([$u()],Wd);ht.registerSingleton(po,Wd);class w1 extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,Aa):super(e),this.tag=$t.CertificateRequestTag}onInit(e){this.tbs=L.serialize(e.certificationRequestInfo),this.publicKey=new ur(e.certificationRequestInfo.subjectPKInfo);const t=ht.resolve(fs);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>Uu.create(L.serialize(s)));const n=this.getAttribute(Jf);this.extensions=[],n instanceof eh&&(this.extensions=n.items),this.subjectName=new Ht(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(const t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=ut.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),s=ht.resolveAll(yo).reverse();let i=null;for(const o of s)if(i=o.toWebSignature(t,this.signature),i)break;if(!i)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,Aa),n=t.certificationRequestInfo,s=new Me("",{Version:`${as[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const i=new Me("");for(const a of this.attributes){const o=a.toTextObject();i[o[Me.NAME]]=o}s.Attributes=i}return e.Data=s,e.Signature=new Me("",{Algorithm:hs.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}w1.NAME="PKCS#10 Certificate Request";class th extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,os):super(e),this.tag=$t.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=L.serialize(t),this.serialNumber=te.ToHex(t.serialNumber),this.subjectName=new Ht(t.subject),this.subject=new Ht(t.subject).toString(),this.issuerName=new Ht(t.issuer),this.issuer=this.issuerName.toString();const n=ht.resolve(fs);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const s=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!s)throw new Error("Cannot get 'notBefore' value");this.notBefore=s;const i=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!i)throw new Error("Cannot get 'notAfter' value");this.notAfter=i,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(a=>Jt.create(L.serialize(a)))),this.publicKey=new ur(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=ut.get()){let n,s;const i=e.publicKey;try{if(!i)n={...this.publicKey.algorithm,...this.signatureAlgorithm},s=await this.publicKey.export(n,["verify"],t);else if("publicKey"in i)n={...i.publicKey.algorithm,...this.signatureAlgorithm},s=await i.publicKey.export(n,["verify"],t);else if(i instanceof ur)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(q.isBufferSource(i)){const u=new ur(i);n={...u.algorithm,...this.signatureAlgorithm},s=await u.export(n,["verify"],t)}else n={...i.algorithm,...this.signatureAlgorithm},s=i}catch{return!1}const a=ht.resolveAll(yo).reverse();let o=null;for(const u of a)if(o=u.toWebSignature(n,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const c=await t.subtle.verify(this.signatureAlgorithm,s,o,this.tbs);if(e.signatureOnly)return c;{const f=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<f&&f<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=ut.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=ut.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,os),n=t.tbsCertificate,s=new Me("",{Version:`${as[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":hs.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Me("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(s["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(s["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const i=new Me("");for(const a of this.extensions){const o=a.toTextObject();i[o[Me.NAME]]=o}s.Extensions=i}return e.Data=s,e.Signature=new Me("",{Algorithm:hs.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}th.NAME="Certificate";class k1{static async createSelfSigned(e,t=ut.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=ut.get()){var n;let s;e.publicKey instanceof ur?s=e.publicKey.rawData:"publicKey"in e.publicKey?s=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?s=e.publicKey:s=await t.subtle.exportKey("spki",e.publicKey);const i=e.serialNumber?q.toUint8Array(te.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));i[0]>127&&(i[0]&=127),i.length>1&&i[0]===0&&(i[1]|=128);const a=e.notBefore||new Date,o=e.notAfter||new Date(a.getTime()+31536e6),c=new os({tbsCertificate:new Vt({version:as.v3,serialNumber:i,validity:new ro({notBefore:a,notAfter:o}),extensions:new kn(((n=e.extensions)===null||n===void 0?void 0:n.map(A=>L.parse(A.rawData,Kt)))||[]),subjectPublicKeyInfo:L.parse(s,ir)})});if(e.subject){const A=e.subject instanceof Ht?e.subject:new Ht(e.subject);c.tbsCertificate.subject=L.parse(A.toArrayBuffer(),et)}if(e.issuer){const A=e.issuer instanceof Ht?e.issuer:new Ht(e.issuer);c.tbsCertificate.issuer=L.parse(A.toArrayBuffer(),et)}const u={hash:"SHA-256"},f="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},m=ht.resolve(fs);c.tbsCertificate.signature=c.signatureAlgorithm=m.toAsnAlgorithm(f);const R=L.serialize(c.tbsCertificate),C="signingKey"in e?await t.subtle.sign(f,e.signingKey,R):e.signature,p=ht.resolveAll(yo).reverse();let y=null;for(const A of p)if(y=A.toAsnSignature(f,C),y)break;if(!y)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=y,new th(L.serialize(c))}}var em;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(em||(em={}));Jt.register(Rg,Yf);Jt.register(Zg,Xf);Jt.register(Dg,Qf);Jt.register(Lg,mo);Jt.register(Ml,Ca);Jt.register(Ug,y0);Jt.register(Hl,v0);Jt.register(Dl,b0);Uu.register(l0,x0);Uu.register(Jf,eh);ht.registerSingleton(yo,_1);ht.registerSingleton(yo,Ft);Ft.namedCurveSize.set("P-256",32);Ft.namedCurveSize.set("K-256",32);Ft.namedCurveSize.set("P-384",48);Ft.namedCurveSize.set("P-521",66);const So=60*5;function S1(r){return new jt().openapi(ke({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:xy}},description:"List of tenants"}}}),async t=>{const n=await t.env.data.keys.list(),s=await Promise.all(n.map(async i=>{const o=await new th(i.cert).publicKey.export(),c=await crypto.subtle.exportKey("jwk",o);return uf.parse({...c,kid:i.kid})}));return t.json({keys:s},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})}).openapi(ke({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Il}},description:"List of tenants"}}}),async t=>{const{issuer:n}=r,s=Il.parse({issuer:n,authorization_endpoint:`${n}authorize`,token_endpoint:`${n}oauth/token`,device_authorization_endpoint:`${n}oauth/device/code`,userinfo_endpoint:`${n}userinfo`,mfa_challenge_endpoint:`${n}mfa/challenge`,jwks_uri:`${n}.well-known/jwks.json`,registration_endpoint:`${n}oidc/register`,revocation_endpoint:`${n}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 t.json(s,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})})}async function _0(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function A1({userAdapter:r,tenant_id:e,email:t}){var o;const{users:n}=await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),s=n.filter(c=>!(c.provider==="auth2"&&!c.email_verified));if(s.length===0)return;const i=s.filter(c=>!c.linked_to);if(i.length>0)return i.length>1&&console.error("More than one primary user found for same email"),i[0];const a=await r.get(e,(o=s[0])==null?void 0:o.linked_to);if(!a)throw new Error("Primary account not found");return a}function O1(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await A1({userAdapter:r.users,tenant_id:e,email:t.email});return n?(await r.users.create(e,{...t,linked_to:n.user_id}),n):r.users.create(e,t)}}function w0(r,e){return{type:e.type,description:e.description||"",ip:r.req.header("x-real-ip")||"",user_agent:r.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:r.req.method,path:r.req.path,qs:r.req.queries(),body:e.body||r.var.body||""}},isMobile:!1,client_id:r.var.client_id,client_name:"",user_id:e.userId||r.var.user_id||"",hostname:r.req.header("host")||"",user_name:r.var.username||"",connection_id:"",connection:r.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}async function E1(r,e,t){for await(const n of e)if(!(await fetch(n.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok){const i=w0(r,{type:Xc.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,i)}}function I1(r,e){return async(t,n)=>{const{hooks:s}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await E1(r,s,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function C1(r,e){return async(t,n)=>{let s=await O1(e)(t,n);return await I1(r,e)(t,s),s}}function j1(r,e){return{...e,users:{...e.users,create:C1(r,e)}}}const T1=new jt().openapi(ke({tags:["branding"],method:"get",path:"/",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:El}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.branding.get(e);return t?r.json(t):r.json({})}).openapi(ke({tags:["branding"],method:"patch",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(El.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});function N1(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var k0={exports:{}};const B1={},R1=Object.freeze(Object.defineProperty({__proto__:null,default:B1},Symbol.toStringTag,{value:"Module"})),P1=C_(R1);(function(r){/**
117
+ `)}}$t.CertificateTag="CERTIFICATE";$t.CrlTag="CRL";$t.CertificateRequestTag="CERTIFICATE REQUEST";$t.PublicKeyTag="PUBLIC KEY";$t.PrivateKeyTag="PRIVATE KEY";class Jr extends Bn{static isAsnEncoded(e){return q.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if($t.isPem(e))return $t.decode(e)[0];if(te.isHex(e))return te.FromHex(e);if(te.isBase64(e))return te.FromBase64(e);if(te.isBase64Url(e))return te.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=te.ToBinary(e);return $t.isPem(t)?$t.decode(t)[0]:te.isHex(t)?te.FromHex(t):te.isBase64(t)?te.FromBase64(t):te.isBase64Url(t)?te.FromBase64Url(t):q.toArrayBuffer(e)}}constructor(...e){Jr.isAsnEncoded(e[0])?super(Jr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return $t.encode(this.rawData,this.tag);default:return super.toString(e)}}}class ur extends Jr{static async create(e,t=ut.get()){if(e instanceof ur)return e;if(hn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new ur(n)}else{if(e.publicKey)return e.publicKey;if(q.isBufferSource(e))return new ur(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Jr.isAsnEncoded(e)?super(e,ir):super(e),this.tag=$t.PublicKeyTag}async export(...e){let t,n=["verify"],s={hash:"SHA-256",...this.algorithm};e.length>1?(s=e[0]||s,n=e[1]||n,t=e[2]||ut.get()):t=e[0]||ut.get();let i=this.rawData;const a=L.parse(this.rawData,ir);return a.algorithm.algorithm===Vi&&(i=x1(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=ht.resolve(fs),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case us:{const s=L.parse(e.subjectPublicKey,Kf),i=q.toUint8Array(s.modulus);n.publicExponent=q.toUint8Array(s.publicExponent),n.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,s="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(s=e[0]||s,n=e[1]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(s,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=ut.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=ut.get();const s=L.parse(this.rawData,ir);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,ir);switch(e.Algorithm=hs.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case ka:e["EC Point"]=t.subjectPublicKey;break;case us:default:e["Raw Data"]=t.subjectPublicKey}return e}}function x1(r,e){return r.algorithm=new Y({algorithm:us,parameters:null}),e=L.serialize(r),e}class Ca extends Gt{static async create(e,t=!1,n=ut.get()){if("name"in e&&"serialNumber"in e)return new Ca(e,t);const i=await(await ur.create(e,n)).getKeyIdentifier(n);return new Ca(te.ToHex(i),t)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Ln({keyIdentifier:new If(te.FromHex(e[0]))});super(Ml,e[1],L.serialize(t))}else{const t=e[0],n=t.name instanceof Ea?L.parse(t.name.rawData,bt):t.name,s=new Ln({authorityCertIssuer:n,authorityCertSerialNumber:te.FromHex(t.serialNumber)});super(Ml,e[1],L.serialize(s))}}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Ln);t.keyIdentifier&&(this.keyId=te.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?te.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,Ln);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Ea(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Ca.NAME="Authority Key Identifier";class Yf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,lc);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new lc({cA:e[0],pathLenConstraint:e[1]});super(Rg,e[2],L.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}Yf.NAME="Basic Constraints";var Yp;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(Yp||(Yp={}));class Xf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,pc);this.usages=t.map(n=>n)}else{const t=new pc(e[0]);super(Zg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>Nn.toString(t)).join(", "),e}}Xf.NAME="Extended Key Usages";var Vc;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Vc||(Vc={}));class Qf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,Qu);this.usages=t.toNumber()}else{const t=new Qu(e[0]);super(Dg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,Qu);return e[""]=t.toJSON().join(", "),e}}Qf.NAME="Key Usages";class mo extends Gt{static async create(e,t=!1,n=ut.get()){const i=await(await ur.create(e,n)).getKeyIdentifier(n);return new mo(te.ToHex(i),t)}constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,yn);this.keyId=te.ToHex(t)}else{const t=typeof e[0]=="string"?te.FromHex(e[0]):e[0],n=new yn(t);super(Lg,e[1],L.serialize(n)),this.keyId=te.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,yn);return e[""]=t,e}}mo.NAME="Subject Key Identifier";class y0 extends Gt{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(Ug,e[1],new Ea(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,ed);this.names=new Ea(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}y0.NAME="Subject Alternative Name";class Jt{static register(e,t){this.items.set(e,t)}static create(e){const t=new Gt(e),n=this.items.get(t.type);return n?new n(e):t}}Jt.items=new Map;class g0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0])){super(e[0]);const n=L.parse(this.value,fc);this.policies=n.map(s=>s.policyIdentifier)}else{const n=e[0],s=(t=e[1])!==null&&t!==void 0?t:!1,i=new fc(n.map(a=>new vu({policyIdentifier:a})));super(Pg,s,L.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Me("",{},Nn.toString(t))),e}}g0.NAME="Certificate Policies";Jt.register(Pg,g0);class v0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const s=e[0].map(a=>new li({distributionPoint:new is({fullName:[new ge({uniformResourceIdentifier:a})]})})),i=new Rs(s);super(Hl,e[1],L.serialize(i))}else{const n=new Rs(e[0]);super(Hl,e[1],L.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Rs);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const s={};return t.distributionPoint&&(s[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(i=>new pn(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}v0.NAME="CRL Distribution Points";class b0 extends Gt{constructor(...e){var t,n,s,i;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Is){const a=new Is(e[0]);super(Dl,e[1],L.serialize(a))}else{const a=e[0],o=new Is;ko(o,a,Rh,"ocsp"),ko(o,a,Ph,"caIssuers"),ko(o,a,$h,"timeStamping"),ko(o,a,Zh,"caRepository"),super(Dl,e[1],L.serialize(o))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(s=this.timeStamping)!==null&&s!==void 0||(this.timeStamping=[]),(i=this.caRepository)!==null&&i!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],L.parse(e.extnValue,Is).forEach(n=>{switch(n.accessMethod){case Rh:this.ocsp.push(new pn(n.accessLocation));break;case Ph:this.caIssuers.push(new pn(n.accessLocation));break;case $h:this.timeStamping.push(new pn(n.accessLocation));break;case Zh:this.caRepository.push(new pn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&wo(e,"OCSP",this.ocsp),this.caIssuers.length&&wo(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&wo(e,"Time Stamping",this.timeStamping),this.caRepository.length&&wo(e,"CA Repository",this.caRepository),e}}b0.NAME="Authority Info Access";function wo(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new Me("");t.forEach((s,i)=>{const a=s.toTextObject(),o=`${a[Me.NAME]} ${i+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function ko(r,e,t,n){const s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(a=>{typeof a=="string"&&(a=new pn("url",a)),r.push(new to({accessMethod:t,accessLocation:L.parse(a.rawData,ge)}))})}class gi extends Bn{constructor(...e){let t;if(q.isBufferSource(e[0]))t=q.toArrayBuffer(e[0]);else{const n=e[0],s=Array.isArray(e[1])?e[1].map(i=>q.toArrayBuffer(i)):[];t=L.serialize(new Kr({type:n,values:s}))}super(t,Kr)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Me("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[Me.NAME]===gi.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}gi.NAME="Attribute";class x0 extends gi{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=new Dc({printableString:e[0]});super(l0,[L.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],Dc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Me.VALUE]=this.password,e}}x0.NAME="Challenge Password";class eh extends gi{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new kn;for(const i of n)s.push(L.parse(i.rawData,Kt));super(Jf,[L.serialize(s)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],kn);this.items=t.map(n=>Jt.create(L.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[Me.NAME]]=n;return e}}eh.NAME="Extensions";class Uu{static register(e,t){this.items.set(e,t)}static create(e){const t=new gi(e),n=this.items.get(t.type);return n?new n(e):t}}Uu.items=new Map;const yo="crypto.signatureFormatter";class _1{toAsnSignature(e,t){return q.toArrayBuffer(t)}toWebSignature(e,t){return q.toArrayBuffer(t)}}var Ro;let Hd=Ro=class{static createPssParams(e,t){const n=Ro.getHashAlgorithm(e);return n?new ds({hashAlgorithm:n,maskGenAlgorithm:new Y({algorithm:Nu,parameters:L.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=ht.resolve(fs);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new Y({algorithm:Ic,parameters:null});case"sha-256":return new Y({algorithm:_d,parameters:null});case"sha-384":return new Y({algorithm:Cc,parameters:null});case"sha-512":return new Y({algorithm:jc,parameters:null})}}else return new Y({algorithm:us,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=Ro.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new Y({algorithm:Vi,parameters:L.serialize(t)})}else return new Y({algorithm:Vi,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case us:return{name:"RSASSA-PKCS1-v1_5"};case Ic:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case _d:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Cc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case jc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Vi:if(e.parameters){const t=L.parse(e.parameters,ds);return{name:"RSA-PSS",hash:ht.resolve(fs).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Hd=Ro=l([$u()],Hd);ht.registerSingleton(po,Hd);let Fd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Y({algorithm:Tc});case"sha-256":return new Y({algorithm:Nc});case"sha-384":return new Y({algorithm:Bc});case"sha-512":return new Y({algorithm:Rc})}return null}toWebAlgorithm(e){switch(e.algorithm){case Tc:return{name:"SHA-1"};case Nc:return{name:"SHA-256"};case Bc:return{name:"SHA-384"};case Rc:return{name:"SHA-512"}}return null}};Fd=l([$u()],Fd);ht.registerSingleton(po,Fd);class Ft{addPadding(e,t){const n=q.toUint8Array(t),s=new Uint8Array(e);return s.set(n,e-n.length),s}removePadding(e,t=!1){let n=q.toUint8Array(e);for(let s=0;s<n.length;s++)if(n[s]){n=n.slice(s);break}if(t&&n[0]>127){const s=new Uint8Array(n.length+1);return s.set(n,1),s.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,s=Ft.namedCurveSize.get(n)||Ft.defaultNamedCurveSize,i=new Ec,a=q.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),L.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=L.parse(t,Ec),s=e.namedCurve,i=Ft.namedCurveSize.get(s)||Ft.defaultNamedCurveSize,a=this.addPadding(i,this.removePadding(n.r)),o=this.addPadding(i,this.removePadding(n.s));return R_(a,o)}return null}}Ft.namedCurveSize=new Map;Ft.defaultNamedCurveSize=32;const ol="1.3.101.110",Xp="1.3.101.111",cl="1.3.101.112",Qp="1.3.101.113";let Wd=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=cl;break;case"x25519":t=ol;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=cl;break;case"ed448":t=Qp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=ol;break;case"x448":t=Xp;break}}return t?new Y({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case cl:return{name:"Ed25519"};case Qp:return{name:"EdDSA",namedCurve:"Ed448"};case ol:return{name:"X25519"};case Xp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Wd=l([$u()],Wd);ht.registerSingleton(po,Wd);class w1 extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,Aa):super(e),this.tag=$t.CertificateRequestTag}onInit(e){this.tbs=L.serialize(e.certificationRequestInfo),this.publicKey=new ur(e.certificationRequestInfo.subjectPKInfo);const t=ht.resolve(fs);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>Uu.create(L.serialize(s)));const n=this.getAttribute(Jf);this.extensions=[],n instanceof eh&&(this.extensions=n.items),this.subjectName=new Ht(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(const t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=ut.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),s=ht.resolveAll(yo).reverse();let i=null;for(const o of s)if(i=o.toWebSignature(t,this.signature),i)break;if(!i)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,Aa),n=t.certificationRequestInfo,s=new Me("",{Version:`${as[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const i=new Me("");for(const a of this.attributes){const o=a.toTextObject();i[o[Me.NAME]]=o}s.Attributes=i}return e.Data=s,e.Signature=new Me("",{Algorithm:hs.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}w1.NAME="PKCS#10 Certificate Request";class th extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,os):super(e),this.tag=$t.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=L.serialize(t),this.serialNumber=te.ToHex(t.serialNumber),this.subjectName=new Ht(t.subject),this.subject=new Ht(t.subject).toString(),this.issuerName=new Ht(t.issuer),this.issuer=this.issuerName.toString();const n=ht.resolve(fs);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const s=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!s)throw new Error("Cannot get 'notBefore' value");this.notBefore=s;const i=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!i)throw new Error("Cannot get 'notAfter' value");this.notAfter=i,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(a=>Jt.create(L.serialize(a)))),this.publicKey=new ur(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=ut.get()){let n,s;const i=e.publicKey;try{if(!i)n={...this.publicKey.algorithm,...this.signatureAlgorithm},s=await this.publicKey.export(n,["verify"],t);else if("publicKey"in i)n={...i.publicKey.algorithm,...this.signatureAlgorithm},s=await i.publicKey.export(n,["verify"],t);else if(i instanceof ur)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(q.isBufferSource(i)){const u=new ur(i);n={...u.algorithm,...this.signatureAlgorithm},s=await u.export(n,["verify"],t)}else n={...i.algorithm,...this.signatureAlgorithm},s=i}catch{return!1}const a=ht.resolveAll(yo).reverse();let o=null;for(const u of a)if(o=u.toWebSignature(n,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const c=await t.subtle.verify(this.signatureAlgorithm,s,o,this.tbs);if(e.signatureOnly)return c;{const f=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<f&&f<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=ut.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=ut.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,os),n=t.tbsCertificate,s=new Me("",{Version:`${as[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":hs.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Me("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(s["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(s["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const i=new Me("");for(const a of this.extensions){const o=a.toTextObject();i[o[Me.NAME]]=o}s.Extensions=i}return e.Data=s,e.Signature=new Me("",{Algorithm:hs.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}th.NAME="Certificate";class k1{static async createSelfSigned(e,t=ut.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=ut.get()){var n;let s;e.publicKey instanceof ur?s=e.publicKey.rawData:"publicKey"in e.publicKey?s=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?s=e.publicKey:s=await t.subtle.exportKey("spki",e.publicKey);const i=e.serialNumber?q.toUint8Array(te.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));i[0]>127&&(i[0]&=127),i.length>1&&i[0]===0&&(i[1]|=128);const a=e.notBefore||new Date,o=e.notAfter||new Date(a.getTime()+31536e6),c=new os({tbsCertificate:new Vt({version:as.v3,serialNumber:i,validity:new ro({notBefore:a,notAfter:o}),extensions:new kn(((n=e.extensions)===null||n===void 0?void 0:n.map(A=>L.parse(A.rawData,Kt)))||[]),subjectPublicKeyInfo:L.parse(s,ir)})});if(e.subject){const A=e.subject instanceof Ht?e.subject:new Ht(e.subject);c.tbsCertificate.subject=L.parse(A.toArrayBuffer(),et)}if(e.issuer){const A=e.issuer instanceof Ht?e.issuer:new Ht(e.issuer);c.tbsCertificate.issuer=L.parse(A.toArrayBuffer(),et)}const u={hash:"SHA-256"},f="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},m=ht.resolve(fs);c.tbsCertificate.signature=c.signatureAlgorithm=m.toAsnAlgorithm(f);const R=L.serialize(c.tbsCertificate),C="signingKey"in e?await t.subtle.sign(f,e.signingKey,R):e.signature,p=ht.resolveAll(yo).reverse();let y=null;for(const A of p)if(y=A.toAsnSignature(f,C),y)break;if(!y)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=y,new th(L.serialize(c))}}var em;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(em||(em={}));Jt.register(Rg,Yf);Jt.register(Zg,Xf);Jt.register(Dg,Qf);Jt.register(Lg,mo);Jt.register(Ml,Ca);Jt.register(Ug,y0);Jt.register(Hl,v0);Jt.register(Dl,b0);Uu.register(l0,x0);Uu.register(Jf,eh);ht.registerSingleton(yo,_1);ht.registerSingleton(yo,Ft);Ft.namedCurveSize.set("P-256",32);Ft.namedCurveSize.set("K-256",32);Ft.namedCurveSize.set("P-384",48);Ft.namedCurveSize.set("P-521",66);const So=60*5;function S1(){return new jt().openapi(ke({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:xy}},description:"List of tenants"}}}),async e=>{const t=await e.env.data.keys.list(),n=await Promise.all(t.map(async s=>{const a=await new th(s.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",a);return uf.parse({...o,kid:s.kid})}));return e.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})}).openapi(ke({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Il}},description:"List of tenants"}}}),async e=>{const t=e.env.ISSUER,n=Il.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 e.json(n,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})})}async function _0(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function A1({userAdapter:r,tenant_id:e,email:t}){var o;const{users:n}=await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),s=n.filter(c=>!(c.provider==="auth2"&&!c.email_verified));if(s.length===0)return;const i=s.filter(c=>!c.linked_to);if(i.length>0)return i.length>1&&console.error("More than one primary user found for same email"),i[0];const a=await r.get(e,(o=s[0])==null?void 0:o.linked_to);if(!a)throw new Error("Primary account not found");return a}function O1(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await A1({userAdapter:r.users,tenant_id:e,email:t.email});return n?(await r.users.create(e,{...t,linked_to:n.user_id}),n):r.users.create(e,t)}}function w0(r,e){return{type:e.type,description:e.description||"",ip:r.req.header("x-real-ip")||"",user_agent:r.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:r.req.method,path:r.req.path,qs:r.req.queries(),body:e.body||r.var.body||""}},isMobile:!1,client_id:r.var.client_id,client_name:"",user_id:e.userId||r.var.user_id||"",hostname:r.req.header("host")||"",user_name:r.var.username||"",connection_id:"",connection:r.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}async function E1(r,e,t){for await(const n of e)if(!(await fetch(n.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok){const i=w0(r,{type:Xc.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,i)}}function I1(r,e){return async(t,n)=>{const{hooks:s}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await E1(r,s,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function C1(r,e){return async(t,n)=>{let s=await O1(e)(t,n);return await I1(r,e)(t,s),s}}function j1(r,e){return{...e,users:{...e.users,create:C1(r,e)}}}const T1=new jt().openapi(ke({tags:["branding"],method:"get",path:"/",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:El}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.branding.get(e);return t?r.json(t):r.json({})}).openapi(ke({tags:["branding"],method:"patch",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(El.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});function N1(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var k0={exports:{}};const B1={},R1=Object.freeze(Object.defineProperty({__proto__:null,default:B1},Symbol.toStringTag,{value:"Module"})),P1=C_(R1);(function(r){/**
118
118
  * @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
119
119
  * Released under the Apache License, Version 2.0
120
120
  * see: https://github.com/dcodeIO/bcrypt.js for details
@@ -122,4 +122,4 @@ PERFORMANCE OF THIS SOFTWARE.
122
122
  `,s=0;for(;s<t.length;)s+64<=t.length?n+=t.substr(s,64)+`\r
123
123
  `:n+=t.substr(s)+`\r
124
124
  `,s+=64;return n+=`-----END ${r} KEY-----\r
125
- `,n}async function Q1(r){const e=await r.publicKey.export(),t=await crypto.subtle.exportKey("jwk",e),n=JSON.stringify(t,Object.keys(t).sort()),i=new TextEncoder().encode(n);return zd(await Y1(i))}const ek=1e3*60*60*24,tk=new jt().openapi(ke({tags:["keys"],method:"get",path:"/signing",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.array(Cl)}},description:"List of keys"}}}),async r=>{const t=(await r.env.data.keys.list()).filter(n=>"cert"in n).map(n=>n);return r.json(t)}).openapi(ke({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({kid:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Cl}},description:"The requested key"}}}),async r=>{const{kid:e}=r.req.valid("param"),n=(await r.env.data.keys.list()).find(s=>s.kid===e);if(!n)throw new De(404,{message:"Key not found"});return r.json(n)}).openapi(ke({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const e=await r.env.data.keys.list();for await(const n of e)await r.env.data.keys.update(n.kid,{revoked_at:new Date(Date.now()+ek).toISOString()});const t=await sm({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ke({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({kid:v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const{kid:e}=r.req.valid("param");if(!await r.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new De(404,{message:"Key not found"});const n=await sm({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(n),r.text("OK")}),rk=new jt().openapi(ke({tags:["users"],method:"get",path:"/",request:{query:v.object({email:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:v.array(sf)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),s=(await _0(r.env.data.users,e,t)).filter(i=>!i.linked_to);return r.json(s)}),nk=jn.extend({clients:v.array(Mn)}),sk=new jt().openapi(ke({tags:["clients"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([nk,v.array(Mn)])}},description:"List of clients"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s,sort:i,q:a}=r.req.valid("query"),c=(await r.env.data.applications.list(e,{page:t,per_page:n,include_totals:s,sort:vi(i),q:a})).applications;return s?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(ke({tags:["clients"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=(await r.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(i=>i.id===t);if(!s)throw new De(404);return r.json(s)}).openapi(ke({tags:["clients"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.applications.remove(e,t))throw new De(404,{message:"Application not found"});return r.text("OK")}).openapi(ke({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(tc.shape).partial()}}},params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"The update application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=r.req.valid("json");await r.env.data.applications.update(e,t,s);const i=await r.env.data.applications.get(e,t);if(!i)throw new De(404,{message:"Application not found"});return r.json(i)}).openapi(ke({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(tc.shape)}}},headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:v.object(Mn.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||Kd(),client_secret:t.client_secret||Kd()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});var Pe;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Pe||(Pe={}));var Gd;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Gd||(Gd={}));const J=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),on=r=>{switch(typeof r){case"undefined":return J.undefined;case"string":return J.string;case"number":return isNaN(r)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(r)?J.array:r===null?J.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?J.promise:typeof Map<"u"&&r instanceof Map?J.map:typeof Set<"u"&&r instanceof Set?J.set:typeof Date<"u"&&r instanceof Date?J.date:J.object;default:return J.unknown}},M=Pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ik=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Dt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof Dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const si=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===J.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.joinValues(r.options)}, received '${r.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Pe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case M.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case M.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,Pe.assertNever(r)}return{message:t}};let O0=si;function ak(r){O0=r}function Uc(){return O0}const Lc=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},ok=[];function W(r,e){const t=Uc(),n=Lc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===si?void 0:si].filter(s=>!!s)});r.common.issues.push(n)}class gt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return me;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return gt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return me;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const me=Object.freeze({status:"aborted"}),Cs=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Jd=r=>r.status==="aborted",Yd=r=>r.status==="dirty",ja=r=>r.status==="valid",Ta=r=>typeof Promise<"u"&&r instanceof Promise;function qc(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function E0(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ce;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ce||(ce={}));var Ni,Bi;class Ir{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const im=(r,e)=>{if(ja(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Dt(r.common.issues);return this._error=t,this._error}}};function _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class Ee{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return on(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gt,ctx:{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ta(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},i=this._parseSync({data:e,path:s.path,parent:s});return im(s,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Ta(s)?s:Promise.resolve(s));return im(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:M.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new hr({schema:this,typeName:he.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return kr.create(this,this._def)}nullable(){return Cn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lr.create(this,this._def)}promise(){return ai.create(this,this._def)}or(e){return Pa.create([this,e],this._def)}and(e){return $a.create(this,e,this._def)}transform(e){return new hr({..._e(this._def),schema:this,typeName:he.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ua({..._e(this._def),innerType:this,defaultValue:t,typeName:he.ZodDefault})}brand(){return new rh({typeName:he.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new La({..._e(this._def),innerType:this,catchValue:t,typeName:he.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return go.create(this,e)}readonly(){return qa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ck=/^c[^\s-]{8,}$/i,uk=/^[0-9a-z]+$/,lk=/^[0-9A-HJKMNP-TV-Z]{26}$/,dk=/^[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,fk=/^[a-z0-9_-]{21}$/i,hk=/^[-+]?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)?)??$/,pk=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,mk="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ul;const yk=/^(?:(?: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])$/,gk=/^(([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})))$/,vk=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,I0="((\\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])))",bk=new RegExp(`^${I0}$`);function C0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function xk(r){return new RegExp(`^${C0(r)}$`)}function j0(r){let e=`${I0}T${C0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function _k(r,e){return!!((e==="v4"||!e)&&yk.test(r)||(e==="v6"||!e)&&gk.test(r))}class ar extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.string,received:i.parsedType}),me}const n=new gt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")pk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"email",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")ul||(ul=new RegExp(mk,"u")),ul.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"emoji",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")dk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"uuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")fk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"nanoid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")ck.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")uk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid2",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")lk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ulid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),W(s,{validation:"url",code:M.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"regex",code:M.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?j0(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?bk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?xk(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?hk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"duration",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?_k(e.data,i.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ip",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?vk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64",code:M.invalid_string,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:M.invalid_string,...ce.errToObj(n)})}_addCheck(e){return new ar({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ce.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ce.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ce.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ce.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ce.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ce.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ce.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ce.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ce.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ce.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ce.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,...ce.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ce.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ce.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ce.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ce.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ce.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ce.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ce.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ce.errToObj(t)})}nonempty(e){return this.min(1,ce.errToObj(e))}trim(){return new ar({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ar({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ar({...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}}ar.create=r=>{var e;return new ar({checks:[],typeName:he.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function wk(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class On extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==J.number){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.number,received:i.parsedType}),me}let n;const s=new gt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?wk(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_finite,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,s){return new On({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new On({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ce.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ce.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ce.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ce.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Pe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}On.create=r=>new On({checks:[],typeName:he.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class En extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==J.bigint){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.bigint,received:i.parsedType}),me}let n;const s=new gt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,s){return new En({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new En({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.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}}En.create=r=>{var e;return new En({checks:[],typeName:he.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};class Na extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.boolean,received:n.parsedType}),me}return wt(e.data)}}Na.create=r=>new Na({typeName:he.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class ms extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.date,received:i.parsedType}),me}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_date}),me}const n=new gt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ms({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ce.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ce.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}}ms.create=r=>new ms({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:he.ZodDate,..._e(r)});class Hc extends Ee{_parse(e){if(this._getType(e)!==J.symbol){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.symbol,received:n.parsedType}),me}return wt(e.data)}}Hc.create=r=>new Hc({typeName:he.ZodSymbol,..._e(r)});class Ba extends Ee{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.undefined,received:n.parsedType}),me}return wt(e.data)}}Ba.create=r=>new Ba({typeName:he.ZodUndefined,..._e(r)});class Ra extends Ee{_parse(e){if(this._getType(e)!==J.null){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.null,received:n.parsedType}),me}return wt(e.data)}}Ra.create=r=>new Ra({typeName:he.ZodNull,..._e(r)});class ii extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}ii.create=r=>new ii({typeName:he.ZodAny,..._e(r)});class Xn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}Xn.create=r=>new Xn({typeName:he.ZodUnknown,..._e(r)});class Yr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:J.never,received:t.parsedType}),me}}Yr.create=r=>new Yr({typeName:he.ZodNever,..._e(r)});class Fc extends Ee{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.void,received:n.parsedType}),me}return wt(e.data)}}Fc.create=r=>new Fc({typeName:he.ZodVoid,..._e(r)});class lr extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==J.array)return W(t,{code:M.invalid_type,expected:J.array,received:t.parsedType}),me;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(W(t,{code:a?M.too_big:M.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(W(t,{code:M.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(W(t,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Ir(t,a,t.path,o)))).then(a=>gt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ir(t,a,t.path,o)));return gt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new lr({...this._def,minLength:{value:e,message:ce.toString(t)}})}max(e,t){return new lr({...this._def,maxLength:{value:e,message:ce.toString(t)}})}length(e,t){return new lr({...this._def,exactLength:{value:e,message:ce.toString(t)}})}nonempty(e){return this.min(1,e)}}lr.create=(r,e)=>new lr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:he.ZodArray,..._e(e)});function As(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=kr.create(As(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof lr?new lr({...r._def,type:As(r.element)}):r instanceof kr?kr.create(As(r.unwrap())):r instanceof Cn?Cn.create(As(r.unwrap())):r instanceof Cr?Cr.create(r.items.map(e=>As(e))):r}class Ye extends Ee{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Pe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==J.object){const u=this._getOrReturnCtx(e);return W(u,{code:M.invalid_type,expected:J.object,received:u.parsedType}),me}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Yr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Ir(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Yr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")o.length>0&&(W(s,{code:M.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Ir(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,R=await f.value;u.push({key:m,value:R,alwaysSet:f.alwaysSet})}return u}).then(u=>gt.mergeObjectSync(n,u)):gt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ce.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:he.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ye({...this._def,catchall:e})}pick(e){const t={};return Pe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}deepPartial(){return As(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Ye({...this._def,shape:()=>t})}required(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof kr;)i=i._def.innerType;t[n]=i}}),new Ye({...this._def,shape:()=>t})}keyof(){return T0(Pe.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,..._e(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Yr.create(),typeName:he.ZodObject,..._e(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,..._e(e)});class Pa extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Dt(o.ctx.common.issues));return W(t,{code:M.invalid_union,unionErrors:a}),me}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Dt(c));return W(t,{code:M.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Pa.create=(r,e)=>new Pa({options:r,typeName:he.ZodUnion,..._e(e)});const Rr=r=>r instanceof Da?Rr(r.schema):r instanceof hr?Rr(r.innerType()):r instanceof Ma?[r.value]:r instanceof In?r.options:r instanceof Va?Pe.objectValues(r.enum):r instanceof Ua?Rr(r._def.innerType):r instanceof Ba?[void 0]:r instanceof Ra?[null]:r instanceof kr?[void 0,...Rr(r.unwrap())]:r instanceof Cn?[null,...Rr(r.unwrap())]:r instanceof rh||r instanceof qa?Rr(r.unwrap()):r instanceof La?Rr(r._def.innerType):[];class Lu extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return W(t,{code:M.invalid_type,expected:J.object,received:t.parsedType}),me;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=Rr(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Lu({typeName:he.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._e(n)})}}function Xd(r,e){const t=on(r),n=on(e);if(r===e)return{valid:!0,data:r};if(t===J.object&&n===J.object){const s=Pe.objectKeys(e),i=Pe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Xd(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===J.array&&n===J.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Xd(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===J.date&&n===J.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class $a extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Jd(i)||Jd(a))return me;const o=Xd(i.value,a.value);return o.valid?((Yd(i)||Yd(a))&&t.dirty(),{status:t.value,value:o.data}):(W(n,{code:M.invalid_intersection_types}),me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}$a.create=(r,e,t)=>new $a({left:r,right:e,typeName:he.ZodIntersection,..._e(t)});class Cr extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return W(n,{code:M.invalid_type,expected:J.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return W(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Ir(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>gt.mergeArray(t,a)):gt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Cr({...this._def,rest:e})}}Cr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Cr({items:r,typeName:he.ZodTuple,rest:null,..._e(e)})};class Za extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.object)return W(n,{code:M.invalid_type,expected:J.object,received:n.parsedType}),me;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Ir(n,o,n.path,o)),value:a._parse(new Ir(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?gt.mergeObjectAsync(t,s):gt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new Za({keyType:e,valueType:t,typeName:he.ZodRecord,..._e(n)}):new Za({keyType:ar.create(),valueType:e,typeName:he.ZodRecord,..._e(t)})}}class Wc extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.map)return W(n,{code:M.invalid_type,expected:J.map,received:n.parsedType}),me;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ir(n,o,n.path,[u,"key"])),value:i._parse(new Ir(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Wc.create=(r,e,t)=>new Wc({valueType:e,keyType:r,typeName:he.ZodMap,..._e(t)});class ys extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return W(n,{code:M.invalid_type,expected:J.set,received:n.parsedType}),me;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:M.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(W(n,{code:M.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return me;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ir(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ys({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new ys({...this._def,maxSize:{value:e,message:ce.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ys.create=(r,e)=>new ys({valueType:r,minSize:null,maxSize:null,typeName:he.ZodSet,..._e(e)});class Ps extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return W(t,{code:M.invalid_type,expected:J.function,received:t.parsedType}),me;function n(o,c){return Lc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Uc(),si].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function s(o,c){return Lc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Uc(),si].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ai){const o=this;return wt(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,i).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return wt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Dt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ps({...this._def,args:Cr.create(e).rest(Xn.create())})}returns(e){return new Ps({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ps({args:e||Cr.create([]).rest(Xn.create()),returns:t||Xn.create(),typeName:he.ZodFunction,..._e(n)})}}class Da extends Ee{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Da.create=(r,e)=>new Da({getter:r,typeName:he.ZodLazy,..._e(e)});class Ma extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return W(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ma.create=(r,e)=>new Ma({value:r,typeName:he.ZodLiteral,..._e(e)});function T0(r,e){return new In({values:r,typeName:he.ZodEnum,..._e(e)})}class In extends Ee{constructor(){super(...arguments),Ni.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:Pe.joinValues(n),received:t.parsedType,code:M.invalid_type}),me}if(qc(this,Ni)||E0(this,Ni,new Set(this._def.values)),!qc(this,Ni).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:M.invalid_enum_value,options:n}),me}return wt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return In.create(e,{...this._def,...t})}exclude(e,t=this._def){return In.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Ni=new WeakMap;In.create=T0;class Va extends Ee{constructor(){super(...arguments),Bi.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){const s=Pe.objectValues(t);return W(n,{expected:Pe.joinValues(s),received:n.parsedType,code:M.invalid_type}),me}if(qc(this,Bi)||E0(this,Bi,new Set(Pe.getValidEnumValues(this._def.values))),!qc(this,Bi).has(e.data)){const s=Pe.objectValues(t);return W(n,{received:n.data,code:M.invalid_enum_value,options:s}),me}return wt(e.data)}get enum(){return this._def.values}}Bi=new WeakMap;Va.create=(r,e)=>new Va({values:r,typeName:he.ZodNativeEnum,..._e(e)});class ai extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.promise&&t.common.async===!1)return W(t,{code:M.invalid_type,expected:J.promise,received:t.parsedType}),me;const n=t.parsedType===J.promise?t.data:Promise.resolve(t.data);return wt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ai.create=(r,e)=>new ai({type:r,typeName:he.ZodPromise,..._e(e)});class hr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===he.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{W(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return me;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?me:c.status==="dirty"||t.value==="dirty"?Cs(c.value):c});{if(t.value==="aborted")return me;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?me:o.status==="dirty"||t.value==="dirty"?Cs(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ja(a))return a;const o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ja(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(s)}}hr.create=(r,e,t)=>new hr({schema:r,typeName:he.ZodEffects,effect:e,..._e(t)});hr.createWithPreprocess=(r,e,t)=>new hr({schema:e,effect:{type:"preprocess",transform:r},typeName:he.ZodEffects,..._e(t)});class kr extends Ee{_parse(e){return this._getType(e)===J.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}kr.create=(r,e)=>new kr({innerType:r,typeName:he.ZodOptional,..._e(e)});class Cn extends Ee{_parse(e){return this._getType(e)===J.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Cn.create=(r,e)=>new Cn({innerType:r,typeName:he.ZodNullable,..._e(e)});class Ua extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===J.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ua.create=(r,e)=>new Ua({innerType:r,typeName:he.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});class La extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ta(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}La.create=(r,e)=>new La({innerType:r,typeName:he.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});class Kc extends Ee{_parse(e){if(this._getType(e)!==J.nan){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.nan,received:n.parsedType}),me}return{status:"valid",value:e.data}}}Kc.create=r=>new Kc({typeName:he.ZodNaN,..._e(r)});const kk=Symbol("zod_brand");class rh extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class go extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?me:i.status==="dirty"?(t.dirty(),Cs(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new go({in:e,out:t,typeName:he.ZodPipeline})}}class qa extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=s=>(ja(s)&&(s.value=Object.freeze(s.value)),s);return Ta(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}qa.create=(r,e)=>new qa({innerType:r,typeName:he.ZodReadonly,..._e(e)});function N0(r,e={},t){return r?ii.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):ii.create()}const Sk={object:Ye.lazycreate};var he;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(he||(he={}));const Ak=(r,e={message:`Input not instance of ${r.name}`})=>N0(t=>t instanceof r,e),B0=ar.create,R0=On.create,Ok=Kc.create,Ek=En.create,P0=Na.create,Ik=ms.create,Ck=Hc.create,jk=Ba.create,Tk=Ra.create,Nk=ii.create,Bk=Xn.create,Rk=Yr.create,Pk=Fc.create,$k=lr.create,Zk=Ye.create,Dk=Ye.strictCreate,Mk=Pa.create,Vk=Lu.create,Uk=$a.create,Lk=Cr.create,qk=Za.create,Hk=Wc.create,Fk=ys.create,Wk=Ps.create,Kk=Da.create,zk=Ma.create,Gk=In.create,Jk=Va.create,Yk=ai.create,am=hr.create,Xk=kr.create,Qk=Cn.create,eS=hr.createWithPreprocess,tS=go.create,rS=()=>B0().optional(),nS=()=>R0().optional(),sS=()=>P0().optional(),iS={string:r=>ar.create({...r,coerce:!0}),number:r=>On.create({...r,coerce:!0}),boolean:r=>Na.create({...r,coerce:!0}),bigint:r=>En.create({...r,coerce:!0}),date:r=>ms.create({...r,coerce:!0})},aS=me;var Lt=Object.freeze({__proto__:null,defaultErrorMap:si,setErrorMap:ak,getErrorMap:Uc,makeIssue:Lc,EMPTY_PATH:ok,addIssueToContext:W,ParseStatus:gt,INVALID:me,DIRTY:Cs,OK:wt,isAborted:Jd,isDirty:Yd,isValid:ja,isAsync:Ta,get util(){return Pe},get objectUtil(){return Gd},ZodParsedType:J,getParsedType:on,ZodType:Ee,datetimeRegex:j0,ZodString:ar,ZodNumber:On,ZodBigInt:En,ZodBoolean:Na,ZodDate:ms,ZodSymbol:Hc,ZodUndefined:Ba,ZodNull:Ra,ZodAny:ii,ZodUnknown:Xn,ZodNever:Yr,ZodVoid:Fc,ZodArray:lr,ZodObject:Ye,ZodUnion:Pa,ZodDiscriminatedUnion:Lu,ZodIntersection:$a,ZodTuple:Cr,ZodRecord:Za,ZodMap:Wc,ZodSet:ys,ZodFunction:Ps,ZodLazy:Da,ZodLiteral:Ma,ZodEnum:In,ZodNativeEnum:Va,ZodPromise:ai,ZodEffects:hr,ZodTransformer:hr,ZodOptional:kr,ZodNullable:Cn,ZodDefault:Ua,ZodCatch:La,ZodNaN:Kc,BRAND:kk,ZodBranded:rh,ZodPipeline:go,ZodReadonly:qa,custom:N0,Schema:Ee,ZodSchema:Ee,late:Sk,get ZodFirstPartyTypeKind(){return he},coerce:iS,any:Nk,array:$k,bigint:Ek,boolean:P0,date:Ik,discriminatedUnion:Vk,effect:am,enum:Gk,function:Wk,instanceof:Ak,intersection:Uk,lazy:Kk,literal:zk,map:Hk,nan:Ok,nativeEnum:Jk,never:Rk,null:Tk,nullable:Qk,number:R0,object:Zk,oboolean:sS,onumber:nS,optional:Xk,ostring:rS,pipeline:tS,preprocess:eS,promise:Yk,record:qk,set:Fk,strictObject:Dk,string:B0,symbol:Ck,transformer:am,tuple:Lk,undefined:jk,union:Mk,unknown:Bk,void:Pk,NEVER:aS,ZodIssueCode:M,quotelessJson:ik,ZodError:Dt});Lt.object({start:Lt.number(),limit:Lt.number(),length:Lt.number()});Yc.extend({email:Lt.string(),login_count:Lt.number(),multifactor:Lt.array(Lt.string()).optional(),last_ip:Lt.string().optional(),last_login:Lt.string().optional(),user_id:Lt.string()}).catchall(Lt.any());const oS=jn.extend({tenants:v.array(Ns)}),cS=new jt().openapi(ke({tags:["tenants"],method:"get",path:"/",request:{query:ps},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:v.union([v.array(Ns),oS])}},description:"List of tenants"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),a=await r.env.data.tenants.list({page:e,per_page:t,include_totals:n,sort:vi(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(ke({tags:["tenants"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Ns}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new De(404);return console.log("tenant",t),r.json(t)}).openapi(ke({tags:["tenants"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param");return await r.env.data.tenants.remove(e),r.text("OK")}).openapi(ke({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(nc.shape).partial()}}},params:v.object({id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param"),t=r.req.valid("json");return await r.env.data.tenants.update(e,t),r.text("OK")}).openapi(ke({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(nc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Ns}},description:"An tenant"}}}),async r=>{const e=r.req.valid("json"),t=await r.env.data.tenants.create(e);return r.json(t,{status:201})}),uS=jn.extend({logs:v.array(ic)}),lS=new jt().openapi(ke({tags:["logs"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(ic),uS])}},description:"List of log rows"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header"),o=await r.env.data.logs.list(a,{page:e,per_page:t,include_totals:n,sort:vi(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(ke({tags:["logs"],method:"get",path:"/{id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ic}},description:"A log entry"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.logs.get(e,t);if(!n)throw new De(404);return r.json(n)}),dS=jn.extend({hooks:v.array(Es)}),fS=new jt().openapi(ke({tags:["hooks"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(Es),dS])}},description:"List of hooks"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s,sort:i,q:a}=r.req.valid("query"),o=await r.env.data.hooks.list(e,{page:t,per_page:n,include_totals:s,sort:vi(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(ke({tags:["hooks"],method:"post",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(sc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Es}},description:"The created hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.hooks.create(e,t);return r.json(n,{status:201})}).openapi(ke({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()}),body:{content:{"application/json":{schema:v.object(sc.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Es.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=r.req.valid("json");await r.env.data.hooks.update(e,t,n);const s=await r.env.data.hooks.get(e,t);if(!s)throw new De(404,{message:"Hook not found"});return r.json(s)}).openapi(ke({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Es}},description:"A hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=await r.env.data.hooks.get(e,t);if(!n)throw new De(404,{message:"Hook not found"});return r.json(n)}).openapi(ke({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param");if(!await r.env.data.hooks.remove(e,t))throw new De(404,{message:"Hook not found"});return r.text("OK")}),hS=jn.extend({connections:v.array(Vn)}),pS=new jt().openapi(ke({tags:["connections"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(Vn),hS])}},description:"List of connectionss"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s=!1,sort:i,q:a}=r.req.valid("query"),o=await r.env.data.connections.list(e,{page:t,per_page:n,include_totals:s,sort:vi(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(ke({tags:["connections"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vn}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.connections.get(e,t);if(!n)throw new De(404);return r.json(n)}).openapi(ke({tags:["connections"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.connections.remove(e,t))throw new De(404,{message:"Connection not found"});return r.text("OK")}).openapi(ke({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(rc.shape).partial()}}},params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Vn}},description:"The updated connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=r.req.valid("json");if(!await r.env.data.connections.update(e,t,n))throw new De(404,{message:"Connection not found"});const i=await r.env.data.connections.get(e,t);if(!i)throw new De(404,{message:"Connection not found"});return r.json(i)}).openapi(ke({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(rc.shape)}}},headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Vn}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.connections.create(e,t);return r.json(n,{status:201})}),mS=new jt().openapi(ke({tags:["prompts"],method:"get",path:"/",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:jo}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.promptSettings.get(e);return t?r.json(t):r.json(jo.parse({}))}).openapi(ke({tags:["prompts"],method:"patch",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(jo.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.promptSettings.get(e);return Object.assign(n,t),await r.env.data.promptSettings.set(e,n),r.json(n)});let om=!1;function yS(r){r.use(async(e,t)=>(om||(r.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"}}}}),om=!0),await t()))}v.object({alg:v.literal("RS256"),kty:v.literal("RSA"),use:v.literal("sig"),n:v.string(),e:v.string(),kid:v.string(),x5t:v.string(),x5c:v.array(v.string())});async function gS(r){try{const e=await r.JWKS_SERVICE.fetch(r.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new De(500,{message:"Failed to fetch jwks: "+e.message+", "+JSON.stringify(r)})}}async function vS(r,e){const n=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),s=new Uint8Array(Array.from(e.signature).map(c=>c.charCodeAt(0))),a=(await gS(r.env)).find(c=>c.kid===e.header.kid);if(!a)return console.log("No matching kid found"),!1;const o=await crypto.subtle.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",o,s,n)}function bS(r){const[e,t,n]=r.split(".");if(!e||!t||!n)return null;const s=JSON.parse(atob(e)),i=JSON.parse(atob(t)),a=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return{header:s,payload:i,signature:a,raw:{header:e,payload:t,signature:n}}}function xS(r){return async(e,t)=>{var s,i;const n=r.openAPIRegistry.definitions.find(a=>"route"in a&&a.route.path===e.req.path&&a.route.method.toUpperCase()===e.req.method);if(n&&"route"in n){const a=(i=(s=n.route.security)==null?void 0:s[0])==null?void 0:i.Bearer,o=e.req.header("authorization")||"",[c,u]=o.split(" ");if((c==null?void 0:c.toLowerCase())!=="bearer"||!u)throw new De(401,{message:"Missing bearer token"});const f=bS(u);if(!f||!await vS(e,f))throw new De(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub);const m=f.payload.permissions||[];if(a!=null&&a.length&&!a.some(R=>m.includes(R)))throw new De(403,{message:"Unauthorized"})}return await t()}}function _S(r){const e=new jt;e.use(xS(e)),e.use(async(n,s)=>(n.env.data=j1(n,r.dataAdapter),s()));const t=e.route("/api/v2/branding",T1).route("/api/v2/users",G1).route("/api/v2/keys",tk).route("/api/v2/users-by-email",rk).route("/api/v2/clients",sk).route("/api/v2/tenants",cS).route("/api/v2/logs",lS).route("/api/v2/hooks",fS).route("/api/v2/connections",pS).route("/api/v2/prompts",mS);return yS(t),t.doc("/api/v2/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function wS(r){const e=new jt;e.get("/",s=>s.json({name:"authhero"}));const t=_S(r);e.route("/api/v2",t);const n=new jt().route("/.well-known",S1(r));return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",n),{app:e,managementApp:t,oauthApp:n}}exports.Auth0Client=wy;exports.AuthorizationResponseMode=of;exports.AuthorizationResponseType=af;exports.CodeChallengeMethod=cf;exports.GrantType=df;exports.LogTypes=Xc;exports.applicationInsertSchema=tc;exports.applicationSchema=Mn;exports.auth0UserResponseSchema=vr;exports.authParamsSchema=yy;exports.authorizationCodeGrantTypeParamsSchema=k_;exports.baseUserSchema=Yc;exports.bordersSchema=Ay;exports.brandingSchema=El;exports.clientCredentialGrantTypeParamsSchema=A_;exports.codeInsertSchema=vy;exports.codeSchema=v_;exports.codeTypeSchema=gy;exports.colorsSchema=Oy;exports.connectionInsertSchema=rc;exports.connectionSchema=Vn;exports.domainInsertSchema=by;exports.domainSchema=b_;exports.fontDetailsSchema=Zn;exports.fontsSchema=Ey;exports.hookInsertSchema=sc;exports.hookSchema=Es;exports.identitySchema=py;exports.init=wS;exports.jwksKeySchema=xy;exports.jwksSchema=uf;exports.logSchema=ic;exports.loginInsertSchema=_y;exports.loginSchema=x_;exports.openIDConfigurationSchema=Il;exports.pageBackgroundSchema=Iy;exports.parseUserId=E_;exports.passwordInsertSchema=ky;exports.passwordSchema=w_;exports.pkceAuthorizationCodeGrantTypeParamsSchema=S_;exports.profileDataSchema=hy;exports.promptSettingSchema=jo;exports.samlpAddon=my;exports.sessionInsertSchema=Sy;exports.sessionSchema=lf;exports.signingKeySchema=Cl;exports.tenantInsertSchema=nc;exports.tenantSchema=Ns;exports.themeInsertSchema=jy;exports.themeSchema=O_;exports.totalsSchema=jn;exports.userInsertSchema=ec;exports.userResponseSchema=h_;exports.userSchema=sf;exports.vendorSettingsSchema=y_;exports.widgetSchema=Cy;
125
+ `,n}async function Q1(r){const e=await r.publicKey.export(),t=await crypto.subtle.exportKey("jwk",e),n=JSON.stringify(t,Object.keys(t).sort()),i=new TextEncoder().encode(n);return zd(await Y1(i))}const ek=1e3*60*60*24,tk=new jt().openapi(ke({tags:["keys"],method:"get",path:"/signing",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.array(Cl)}},description:"List of keys"}}}),async r=>{const t=(await r.env.data.keys.list()).filter(n=>"cert"in n).map(n=>n);return r.json(t)}).openapi(ke({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({kid:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Cl}},description:"The requested key"}}}),async r=>{const{kid:e}=r.req.valid("param"),n=(await r.env.data.keys.list()).find(s=>s.kid===e);if(!n)throw new De(404,{message:"Key not found"});return r.json(n)}).openapi(ke({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const e=await r.env.data.keys.list();for await(const n of e)await r.env.data.keys.update(n.kid,{revoked_at:new Date(Date.now()+ek).toISOString()});const t=await sm({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ke({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({kid:v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const{kid:e}=r.req.valid("param");if(!await r.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new De(404,{message:"Key not found"});const n=await sm({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(n),r.text("OK")}),rk=new jt().openapi(ke({tags:["users"],method:"get",path:"/",request:{query:v.object({email:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:v.array(sf)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),s=(await _0(r.env.data.users,e,t)).filter(i=>!i.linked_to);return r.json(s)}),nk=jn.extend({clients:v.array(Mn)}),sk=new jt().openapi(ke({tags:["clients"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([nk,v.array(Mn)])}},description:"List of clients"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s,sort:i,q:a}=r.req.valid("query"),c=(await r.env.data.applications.list(e,{page:t,per_page:n,include_totals:s,sort:vi(i),q:a})).applications;return s?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(ke({tags:["clients"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=(await r.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(i=>i.id===t);if(!s)throw new De(404);return r.json(s)}).openapi(ke({tags:["clients"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.applications.remove(e,t))throw new De(404,{message:"Application not found"});return r.text("OK")}).openapi(ke({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(tc.shape).partial()}}},params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"The update application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=r.req.valid("json");await r.env.data.applications.update(e,t,s);const i=await r.env.data.applications.get(e,t);if(!i)throw new De(404,{message:"Application not found"});return r.json(i)}).openapi(ke({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(tc.shape)}}},headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:v.object(Mn.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||Kd(),client_secret:t.client_secret||Kd()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});var Pe;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Pe||(Pe={}));var Gd;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Gd||(Gd={}));const J=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),on=r=>{switch(typeof r){case"undefined":return J.undefined;case"string":return J.string;case"number":return isNaN(r)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(r)?J.array:r===null?J.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?J.promise:typeof Map<"u"&&r instanceof Map?J.map:typeof Set<"u"&&r instanceof Set?J.set:typeof Date<"u"&&r instanceof Date?J.date:J.object;default:return J.unknown}},M=Pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ik=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Dt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof Dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const si=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===J.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.joinValues(r.options)}, received '${r.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Pe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case M.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case M.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,Pe.assertNever(r)}return{message:t}};let O0=si;function ak(r){O0=r}function Uc(){return O0}const Lc=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},ok=[];function W(r,e){const t=Uc(),n=Lc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===si?void 0:si].filter(s=>!!s)});r.common.issues.push(n)}class gt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return me;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return gt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return me;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const me=Object.freeze({status:"aborted"}),Cs=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Jd=r=>r.status==="aborted",Yd=r=>r.status==="dirty",ja=r=>r.status==="valid",Ta=r=>typeof Promise<"u"&&r instanceof Promise;function qc(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function E0(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ce;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ce||(ce={}));var Ni,Bi;class Ir{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const im=(r,e)=>{if(ja(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Dt(r.common.issues);return this._error=t,this._error}}};function _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class Ee{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return on(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gt,ctx:{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ta(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},i=this._parseSync({data:e,path:s.path,parent:s});return im(s,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Ta(s)?s:Promise.resolve(s));return im(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:M.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new hr({schema:this,typeName:he.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return kr.create(this,this._def)}nullable(){return Cn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lr.create(this,this._def)}promise(){return ai.create(this,this._def)}or(e){return Pa.create([this,e],this._def)}and(e){return $a.create(this,e,this._def)}transform(e){return new hr({..._e(this._def),schema:this,typeName:he.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ua({..._e(this._def),innerType:this,defaultValue:t,typeName:he.ZodDefault})}brand(){return new rh({typeName:he.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new La({..._e(this._def),innerType:this,catchValue:t,typeName:he.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return go.create(this,e)}readonly(){return qa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ck=/^c[^\s-]{8,}$/i,uk=/^[0-9a-z]+$/,lk=/^[0-9A-HJKMNP-TV-Z]{26}$/,dk=/^[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,fk=/^[a-z0-9_-]{21}$/i,hk=/^[-+]?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)?)??$/,pk=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,mk="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ul;const yk=/^(?:(?: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])$/,gk=/^(([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})))$/,vk=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,I0="((\\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])))",bk=new RegExp(`^${I0}$`);function C0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function xk(r){return new RegExp(`^${C0(r)}$`)}function j0(r){let e=`${I0}T${C0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function _k(r,e){return!!((e==="v4"||!e)&&yk.test(r)||(e==="v6"||!e)&&gk.test(r))}class ar extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.string,received:i.parsedType}),me}const n=new gt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")pk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"email",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")ul||(ul=new RegExp(mk,"u")),ul.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"emoji",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")dk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"uuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")fk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"nanoid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")ck.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")uk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid2",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")lk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ulid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),W(s,{validation:"url",code:M.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"regex",code:M.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?j0(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?bk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?xk(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?hk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"duration",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?_k(e.data,i.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ip",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?vk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64",code:M.invalid_string,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:M.invalid_string,...ce.errToObj(n)})}_addCheck(e){return new ar({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ce.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ce.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ce.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ce.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ce.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ce.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ce.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ce.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ce.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ce.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ce.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,...ce.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ce.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ce.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ce.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ce.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ce.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ce.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ce.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ce.errToObj(t)})}nonempty(e){return this.min(1,ce.errToObj(e))}trim(){return new ar({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ar({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ar({...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}}ar.create=r=>{var e;return new ar({checks:[],typeName:he.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function wk(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class On extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==J.number){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.number,received:i.parsedType}),me}let n;const s=new gt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?wk(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_finite,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,s){return new On({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new On({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ce.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ce.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ce.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ce.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Pe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}On.create=r=>new On({checks:[],typeName:he.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class En extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==J.bigint){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.bigint,received:i.parsedType}),me}let n;const s=new gt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,s){return new En({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new En({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.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}}En.create=r=>{var e;return new En({checks:[],typeName:he.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};class Na extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.boolean,received:n.parsedType}),me}return wt(e.data)}}Na.create=r=>new Na({typeName:he.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class ms extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.date,received:i.parsedType}),me}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_date}),me}const n=new gt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ms({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ce.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ce.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}}ms.create=r=>new ms({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:he.ZodDate,..._e(r)});class Hc extends Ee{_parse(e){if(this._getType(e)!==J.symbol){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.symbol,received:n.parsedType}),me}return wt(e.data)}}Hc.create=r=>new Hc({typeName:he.ZodSymbol,..._e(r)});class Ba extends Ee{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.undefined,received:n.parsedType}),me}return wt(e.data)}}Ba.create=r=>new Ba({typeName:he.ZodUndefined,..._e(r)});class Ra extends Ee{_parse(e){if(this._getType(e)!==J.null){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.null,received:n.parsedType}),me}return wt(e.data)}}Ra.create=r=>new Ra({typeName:he.ZodNull,..._e(r)});class ii extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}ii.create=r=>new ii({typeName:he.ZodAny,..._e(r)});class Xn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}Xn.create=r=>new Xn({typeName:he.ZodUnknown,..._e(r)});class Yr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:J.never,received:t.parsedType}),me}}Yr.create=r=>new Yr({typeName:he.ZodNever,..._e(r)});class Fc extends Ee{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.void,received:n.parsedType}),me}return wt(e.data)}}Fc.create=r=>new Fc({typeName:he.ZodVoid,..._e(r)});class lr extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==J.array)return W(t,{code:M.invalid_type,expected:J.array,received:t.parsedType}),me;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(W(t,{code:a?M.too_big:M.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(W(t,{code:M.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(W(t,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Ir(t,a,t.path,o)))).then(a=>gt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ir(t,a,t.path,o)));return gt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new lr({...this._def,minLength:{value:e,message:ce.toString(t)}})}max(e,t){return new lr({...this._def,maxLength:{value:e,message:ce.toString(t)}})}length(e,t){return new lr({...this._def,exactLength:{value:e,message:ce.toString(t)}})}nonempty(e){return this.min(1,e)}}lr.create=(r,e)=>new lr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:he.ZodArray,..._e(e)});function As(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=kr.create(As(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof lr?new lr({...r._def,type:As(r.element)}):r instanceof kr?kr.create(As(r.unwrap())):r instanceof Cn?Cn.create(As(r.unwrap())):r instanceof Cr?Cr.create(r.items.map(e=>As(e))):r}class Ye extends Ee{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Pe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==J.object){const u=this._getOrReturnCtx(e);return W(u,{code:M.invalid_type,expected:J.object,received:u.parsedType}),me}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Yr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Ir(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Yr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")o.length>0&&(W(s,{code:M.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Ir(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,R=await f.value;u.push({key:m,value:R,alwaysSet:f.alwaysSet})}return u}).then(u=>gt.mergeObjectSync(n,u)):gt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ce.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:he.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ye({...this._def,catchall:e})}pick(e){const t={};return Pe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}deepPartial(){return As(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Ye({...this._def,shape:()=>t})}required(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof kr;)i=i._def.innerType;t[n]=i}}),new Ye({...this._def,shape:()=>t})}keyof(){return T0(Pe.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,..._e(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Yr.create(),typeName:he.ZodObject,..._e(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,..._e(e)});class Pa extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Dt(o.ctx.common.issues));return W(t,{code:M.invalid_union,unionErrors:a}),me}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Dt(c));return W(t,{code:M.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Pa.create=(r,e)=>new Pa({options:r,typeName:he.ZodUnion,..._e(e)});const Rr=r=>r instanceof Da?Rr(r.schema):r instanceof hr?Rr(r.innerType()):r instanceof Ma?[r.value]:r instanceof In?r.options:r instanceof Va?Pe.objectValues(r.enum):r instanceof Ua?Rr(r._def.innerType):r instanceof Ba?[void 0]:r instanceof Ra?[null]:r instanceof kr?[void 0,...Rr(r.unwrap())]:r instanceof Cn?[null,...Rr(r.unwrap())]:r instanceof rh||r instanceof qa?Rr(r.unwrap()):r instanceof La?Rr(r._def.innerType):[];class Lu extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return W(t,{code:M.invalid_type,expected:J.object,received:t.parsedType}),me;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=Rr(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Lu({typeName:he.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._e(n)})}}function Xd(r,e){const t=on(r),n=on(e);if(r===e)return{valid:!0,data:r};if(t===J.object&&n===J.object){const s=Pe.objectKeys(e),i=Pe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Xd(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===J.array&&n===J.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Xd(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===J.date&&n===J.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class $a extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Jd(i)||Jd(a))return me;const o=Xd(i.value,a.value);return o.valid?((Yd(i)||Yd(a))&&t.dirty(),{status:t.value,value:o.data}):(W(n,{code:M.invalid_intersection_types}),me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}$a.create=(r,e,t)=>new $a({left:r,right:e,typeName:he.ZodIntersection,..._e(t)});class Cr extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return W(n,{code:M.invalid_type,expected:J.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return W(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Ir(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>gt.mergeArray(t,a)):gt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Cr({...this._def,rest:e})}}Cr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Cr({items:r,typeName:he.ZodTuple,rest:null,..._e(e)})};class Za extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.object)return W(n,{code:M.invalid_type,expected:J.object,received:n.parsedType}),me;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Ir(n,o,n.path,o)),value:a._parse(new Ir(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?gt.mergeObjectAsync(t,s):gt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new Za({keyType:e,valueType:t,typeName:he.ZodRecord,..._e(n)}):new Za({keyType:ar.create(),valueType:e,typeName:he.ZodRecord,..._e(t)})}}class Wc extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.map)return W(n,{code:M.invalid_type,expected:J.map,received:n.parsedType}),me;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ir(n,o,n.path,[u,"key"])),value:i._parse(new Ir(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Wc.create=(r,e,t)=>new Wc({valueType:e,keyType:r,typeName:he.ZodMap,..._e(t)});class ys extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return W(n,{code:M.invalid_type,expected:J.set,received:n.parsedType}),me;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:M.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(W(n,{code:M.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return me;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ir(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ys({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new ys({...this._def,maxSize:{value:e,message:ce.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ys.create=(r,e)=>new ys({valueType:r,minSize:null,maxSize:null,typeName:he.ZodSet,..._e(e)});class Ps extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return W(t,{code:M.invalid_type,expected:J.function,received:t.parsedType}),me;function n(o,c){return Lc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Uc(),si].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function s(o,c){return Lc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Uc(),si].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ai){const o=this;return wt(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,i).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return wt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Dt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ps({...this._def,args:Cr.create(e).rest(Xn.create())})}returns(e){return new Ps({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ps({args:e||Cr.create([]).rest(Xn.create()),returns:t||Xn.create(),typeName:he.ZodFunction,..._e(n)})}}class Da extends Ee{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Da.create=(r,e)=>new Da({getter:r,typeName:he.ZodLazy,..._e(e)});class Ma extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return W(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ma.create=(r,e)=>new Ma({value:r,typeName:he.ZodLiteral,..._e(e)});function T0(r,e){return new In({values:r,typeName:he.ZodEnum,..._e(e)})}class In extends Ee{constructor(){super(...arguments),Ni.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:Pe.joinValues(n),received:t.parsedType,code:M.invalid_type}),me}if(qc(this,Ni)||E0(this,Ni,new Set(this._def.values)),!qc(this,Ni).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:M.invalid_enum_value,options:n}),me}return wt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return In.create(e,{...this._def,...t})}exclude(e,t=this._def){return In.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Ni=new WeakMap;In.create=T0;class Va extends Ee{constructor(){super(...arguments),Bi.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){const s=Pe.objectValues(t);return W(n,{expected:Pe.joinValues(s),received:n.parsedType,code:M.invalid_type}),me}if(qc(this,Bi)||E0(this,Bi,new Set(Pe.getValidEnumValues(this._def.values))),!qc(this,Bi).has(e.data)){const s=Pe.objectValues(t);return W(n,{received:n.data,code:M.invalid_enum_value,options:s}),me}return wt(e.data)}get enum(){return this._def.values}}Bi=new WeakMap;Va.create=(r,e)=>new Va({values:r,typeName:he.ZodNativeEnum,..._e(e)});class ai extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.promise&&t.common.async===!1)return W(t,{code:M.invalid_type,expected:J.promise,received:t.parsedType}),me;const n=t.parsedType===J.promise?t.data:Promise.resolve(t.data);return wt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ai.create=(r,e)=>new ai({type:r,typeName:he.ZodPromise,..._e(e)});class hr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===he.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{W(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return me;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?me:c.status==="dirty"||t.value==="dirty"?Cs(c.value):c});{if(t.value==="aborted")return me;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?me:o.status==="dirty"||t.value==="dirty"?Cs(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ja(a))return a;const o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ja(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(s)}}hr.create=(r,e,t)=>new hr({schema:r,typeName:he.ZodEffects,effect:e,..._e(t)});hr.createWithPreprocess=(r,e,t)=>new hr({schema:e,effect:{type:"preprocess",transform:r},typeName:he.ZodEffects,..._e(t)});class kr extends Ee{_parse(e){return this._getType(e)===J.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}kr.create=(r,e)=>new kr({innerType:r,typeName:he.ZodOptional,..._e(e)});class Cn extends Ee{_parse(e){return this._getType(e)===J.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Cn.create=(r,e)=>new Cn({innerType:r,typeName:he.ZodNullable,..._e(e)});class Ua extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===J.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ua.create=(r,e)=>new Ua({innerType:r,typeName:he.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});class La extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ta(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}La.create=(r,e)=>new La({innerType:r,typeName:he.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});class Kc extends Ee{_parse(e){if(this._getType(e)!==J.nan){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.nan,received:n.parsedType}),me}return{status:"valid",value:e.data}}}Kc.create=r=>new Kc({typeName:he.ZodNaN,..._e(r)});const kk=Symbol("zod_brand");class rh extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class go extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?me:i.status==="dirty"?(t.dirty(),Cs(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new go({in:e,out:t,typeName:he.ZodPipeline})}}class qa extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=s=>(ja(s)&&(s.value=Object.freeze(s.value)),s);return Ta(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}qa.create=(r,e)=>new qa({innerType:r,typeName:he.ZodReadonly,..._e(e)});function N0(r,e={},t){return r?ii.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):ii.create()}const Sk={object:Ye.lazycreate};var he;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(he||(he={}));const Ak=(r,e={message:`Input not instance of ${r.name}`})=>N0(t=>t instanceof r,e),B0=ar.create,R0=On.create,Ok=Kc.create,Ek=En.create,P0=Na.create,Ik=ms.create,Ck=Hc.create,jk=Ba.create,Tk=Ra.create,Nk=ii.create,Bk=Xn.create,Rk=Yr.create,Pk=Fc.create,$k=lr.create,Zk=Ye.create,Dk=Ye.strictCreate,Mk=Pa.create,Vk=Lu.create,Uk=$a.create,Lk=Cr.create,qk=Za.create,Hk=Wc.create,Fk=ys.create,Wk=Ps.create,Kk=Da.create,zk=Ma.create,Gk=In.create,Jk=Va.create,Yk=ai.create,am=hr.create,Xk=kr.create,Qk=Cn.create,eS=hr.createWithPreprocess,tS=go.create,rS=()=>B0().optional(),nS=()=>R0().optional(),sS=()=>P0().optional(),iS={string:r=>ar.create({...r,coerce:!0}),number:r=>On.create({...r,coerce:!0}),boolean:r=>Na.create({...r,coerce:!0}),bigint:r=>En.create({...r,coerce:!0}),date:r=>ms.create({...r,coerce:!0})},aS=me;var Lt=Object.freeze({__proto__:null,defaultErrorMap:si,setErrorMap:ak,getErrorMap:Uc,makeIssue:Lc,EMPTY_PATH:ok,addIssueToContext:W,ParseStatus:gt,INVALID:me,DIRTY:Cs,OK:wt,isAborted:Jd,isDirty:Yd,isValid:ja,isAsync:Ta,get util(){return Pe},get objectUtil(){return Gd},ZodParsedType:J,getParsedType:on,ZodType:Ee,datetimeRegex:j0,ZodString:ar,ZodNumber:On,ZodBigInt:En,ZodBoolean:Na,ZodDate:ms,ZodSymbol:Hc,ZodUndefined:Ba,ZodNull:Ra,ZodAny:ii,ZodUnknown:Xn,ZodNever:Yr,ZodVoid:Fc,ZodArray:lr,ZodObject:Ye,ZodUnion:Pa,ZodDiscriminatedUnion:Lu,ZodIntersection:$a,ZodTuple:Cr,ZodRecord:Za,ZodMap:Wc,ZodSet:ys,ZodFunction:Ps,ZodLazy:Da,ZodLiteral:Ma,ZodEnum:In,ZodNativeEnum:Va,ZodPromise:ai,ZodEffects:hr,ZodTransformer:hr,ZodOptional:kr,ZodNullable:Cn,ZodDefault:Ua,ZodCatch:La,ZodNaN:Kc,BRAND:kk,ZodBranded:rh,ZodPipeline:go,ZodReadonly:qa,custom:N0,Schema:Ee,ZodSchema:Ee,late:Sk,get ZodFirstPartyTypeKind(){return he},coerce:iS,any:Nk,array:$k,bigint:Ek,boolean:P0,date:Ik,discriminatedUnion:Vk,effect:am,enum:Gk,function:Wk,instanceof:Ak,intersection:Uk,lazy:Kk,literal:zk,map:Hk,nan:Ok,nativeEnum:Jk,never:Rk,null:Tk,nullable:Qk,number:R0,object:Zk,oboolean:sS,onumber:nS,optional:Xk,ostring:rS,pipeline:tS,preprocess:eS,promise:Yk,record:qk,set:Fk,strictObject:Dk,string:B0,symbol:Ck,transformer:am,tuple:Lk,undefined:jk,union:Mk,unknown:Bk,void:Pk,NEVER:aS,ZodIssueCode:M,quotelessJson:ik,ZodError:Dt});Lt.object({start:Lt.number(),limit:Lt.number(),length:Lt.number()});Yc.extend({email:Lt.string(),login_count:Lt.number(),multifactor:Lt.array(Lt.string()).optional(),last_ip:Lt.string().optional(),last_login:Lt.string().optional(),user_id:Lt.string()}).catchall(Lt.any());const oS=jn.extend({tenants:v.array(Ns)}),cS=new jt().openapi(ke({tags:["tenants"],method:"get",path:"/",request:{query:ps},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:v.union([v.array(Ns),oS])}},description:"List of tenants"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),a=await r.env.data.tenants.list({page:e,per_page:t,include_totals:n,sort:vi(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(ke({tags:["tenants"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Ns}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new De(404);return console.log("tenant",t),r.json(t)}).openapi(ke({tags:["tenants"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param");return await r.env.data.tenants.remove(e),r.text("OK")}).openapi(ke({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(nc.shape).partial()}}},params:v.object({id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param"),t=r.req.valid("json");return await r.env.data.tenants.update(e,t),r.text("OK")}).openapi(ke({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(nc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Ns}},description:"An tenant"}}}),async r=>{const e=r.req.valid("json"),t=await r.env.data.tenants.create(e);return r.json(t,{status:201})}),uS=jn.extend({logs:v.array(ic)}),lS=new jt().openapi(ke({tags:["logs"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(ic),uS])}},description:"List of log rows"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header"),o=await r.env.data.logs.list(a,{page:e,per_page:t,include_totals:n,sort:vi(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(ke({tags:["logs"],method:"get",path:"/{id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ic}},description:"A log entry"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.logs.get(e,t);if(!n)throw new De(404);return r.json(n)}),dS=jn.extend({hooks:v.array(Es)}),fS=new jt().openapi(ke({tags:["hooks"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(Es),dS])}},description:"List of hooks"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s,sort:i,q:a}=r.req.valid("query"),o=await r.env.data.hooks.list(e,{page:t,per_page:n,include_totals:s,sort:vi(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(ke({tags:["hooks"],method:"post",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(sc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Es}},description:"The created hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.hooks.create(e,t);return r.json(n,{status:201})}).openapi(ke({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()}),body:{content:{"application/json":{schema:v.object(sc.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Es.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=r.req.valid("json");await r.env.data.hooks.update(e,t,n);const s=await r.env.data.hooks.get(e,t);if(!s)throw new De(404,{message:"Hook not found"});return r.json(s)}).openapi(ke({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Es}},description:"A hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=await r.env.data.hooks.get(e,t);if(!n)throw new De(404,{message:"Hook not found"});return r.json(n)}).openapi(ke({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param");if(!await r.env.data.hooks.remove(e,t))throw new De(404,{message:"Hook not found"});return r.text("OK")}),hS=jn.extend({connections:v.array(Vn)}),pS=new jt().openapi(ke({tags:["connections"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(Vn),hS])}},description:"List of connectionss"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s=!1,sort:i,q:a}=r.req.valid("query"),o=await r.env.data.connections.list(e,{page:t,per_page:n,include_totals:s,sort:vi(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(ke({tags:["connections"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vn}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.connections.get(e,t);if(!n)throw new De(404);return r.json(n)}).openapi(ke({tags:["connections"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.connections.remove(e,t))throw new De(404,{message:"Connection not found"});return r.text("OK")}).openapi(ke({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(rc.shape).partial()}}},params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Vn}},description:"The updated connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=r.req.valid("json");if(!await r.env.data.connections.update(e,t,n))throw new De(404,{message:"Connection not found"});const i=await r.env.data.connections.get(e,t);if(!i)throw new De(404,{message:"Connection not found"});return r.json(i)}).openapi(ke({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(rc.shape)}}},headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Vn}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.connections.create(e,t);return r.json(n,{status:201})}),mS=new jt().openapi(ke({tags:["prompts"],method:"get",path:"/",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:jo}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.promptSettings.get(e);return t?r.json(t):r.json(jo.parse({}))}).openapi(ke({tags:["prompts"],method:"patch",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(jo.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.promptSettings.get(e);return Object.assign(n,t),await r.env.data.promptSettings.set(e,n),r.json(n)});let om=!1;function yS(r){r.use(async(e,t)=>(om||(r.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"}}}}),om=!0),await t()))}v.object({alg:v.literal("RS256"),kty:v.literal("RSA"),use:v.literal("sig"),n:v.string(),e:v.string(),kid:v.string(),x5t:v.string(),x5c:v.array(v.string())});async function gS(r){try{const e=await r.JWKS_SERVICE.fetch(r.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new De(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function vS(r,e){const n=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),s=new Uint8Array(Array.from(e.signature).map(c=>c.charCodeAt(0))),a=(await gS(r.env)).find(c=>c.kid===e.header.kid);if(!a)return console.log("No matching kid found"),!1;const o=await crypto.subtle.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",o,s,n)}function bS(r){const[e,t,n]=r.split(".");if(!e||!t||!n)return null;const s=JSON.parse(atob(e)),i=JSON.parse(atob(t)),a=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return{header:s,payload:i,signature:a,raw:{header:e,payload:t,signature:n}}}function xS(r){return async(e,t)=>{var s,i;const n=r.openAPIRegistry.definitions.find(a=>"route"in a&&a.route.path===e.req.path&&a.route.method.toUpperCase()===e.req.method);if(n&&"route"in n){const a=(i=(s=n.route.security)==null?void 0:s[0])==null?void 0:i.Bearer,o=e.req.header("authorization")||"",[c,u]=o.split(" ");if((c==null?void 0:c.toLowerCase())!=="bearer"||!u)throw new De(401,{message:"Missing bearer token"});const f=bS(u);if(!f||!await vS(e,f))throw new De(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub);const m=f.payload.permissions||[];if(a!=null&&a.length&&!a.some(R=>m.includes(R)))throw new De(403,{message:"Unauthorized"})}return await t()}}function _S(r){const e=new jt;e.use(xS(e)),e.use(async(n,s)=>(n.env.data=j1(n,r.dataAdapter),s()));const t=e.route("/branding",T1).route("/users",G1).route("/keys",tk).route("/users-by-email",rk).route("/clients",sk).route("/tenants",cS).route("/logs",lS).route("/hooks",fS).route("/connections",pS).route("/prompts",mS);return yS(t),t.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function wS(r){const e=new jt;e.get("/",s=>s.json({name:"authhero"}));const t=_S(r);e.route("/api/v2",t);const n=new jt().route("/.well-known",S1());return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",n),{app:e,managementApp:t,oauthApp:n}}exports.Auth0Client=wy;exports.AuthorizationResponseMode=of;exports.AuthorizationResponseType=af;exports.CodeChallengeMethod=cf;exports.GrantType=df;exports.LogTypes=Xc;exports.applicationInsertSchema=tc;exports.applicationSchema=Mn;exports.auth0UserResponseSchema=vr;exports.authParamsSchema=yy;exports.authorizationCodeGrantTypeParamsSchema=k_;exports.baseUserSchema=Yc;exports.bordersSchema=Ay;exports.brandingSchema=El;exports.clientCredentialGrantTypeParamsSchema=A_;exports.codeInsertSchema=vy;exports.codeSchema=v_;exports.codeTypeSchema=gy;exports.colorsSchema=Oy;exports.connectionInsertSchema=rc;exports.connectionSchema=Vn;exports.domainInsertSchema=by;exports.domainSchema=b_;exports.fontDetailsSchema=Zn;exports.fontsSchema=Ey;exports.hookInsertSchema=sc;exports.hookSchema=Es;exports.identitySchema=py;exports.init=wS;exports.jwksKeySchema=xy;exports.jwksSchema=uf;exports.logSchema=ic;exports.loginInsertSchema=_y;exports.loginSchema=x_;exports.openIDConfigurationSchema=Il;exports.pageBackgroundSchema=Iy;exports.parseUserId=E_;exports.passwordInsertSchema=ky;exports.passwordSchema=w_;exports.pkceAuthorizationCodeGrantTypeParamsSchema=S_;exports.profileDataSchema=hy;exports.promptSettingSchema=jo;exports.samlpAddon=my;exports.sessionInsertSchema=Sy;exports.sessionSchema=lf;exports.signingKeySchema=Cl;exports.tenantInsertSchema=nc;exports.tenantSchema=Ns;exports.themeInsertSchema=jy;exports.themeSchema=O_;exports.totalsSchema=jn;exports.userInsertSchema=ec;exports.userResponseSchema=h_;exports.userSchema=sf;exports.vendorSettingsSchema=y_;exports.widgetSchema=Cy;