directus-extension-api-docs 2.1.11 → 2.1.13
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/index.js +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t;!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),a={};for(const e of s)a[e]=t[e];return e.objectValues(a)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},e.find=(e,t)=>{for(const s of e)if(t(s))return s},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(e||(e={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(t||(t={}));const s=e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),a=e=>{switch(typeof e){case"undefined":return s.undefined;case"string":return s.string;case"number":return isNaN(e)?s.nan:s.number;case"boolean":return s.boolean;case"function":return s.function;case"bigint":return s.bigint;case"symbol":return s.symbol;case"object":return Array.isArray(e)?s.array:null===e?s.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?s.promise:"undefined"!=typeof Map&&e instanceof Map?s.map:"undefined"!=typeof Set&&e instanceof Set?s.set:"undefined"!=typeof Date&&e instanceof Date?s.date:s.object;default:return s.unknown}},n=e.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"]);class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}r.create=e=>new r(e);const i=(t,a)=>{let r;switch(t.code){case n.invalid_type:r=t.received===s.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case n.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case n.unrecognized_keys:r=`Unrecognized key(s) in object: ${e.joinValues(t.keys,", ")}`;break;case n.invalid_union:r="Invalid input";break;case n.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case n.invalid_enum_value:r=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case n.invalid_arguments:r="Invalid function arguments";break;case n.invalid_return_type:r="Invalid function return type";break;case n.invalid_date:r="Invalid date";break;case n.invalid_string:"object"==typeof t.validation?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,"number"==typeof t.validation.position&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):r="regex"!==t.validation?`Invalid ${t.validation}`:"Invalid";break;case n.too_small:r="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:"date"===t.type?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case n.too_big:r="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"bigint"===t.type?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"date"===t.type?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case n.custom:r="Invalid input";break;case n.invalid_intersection_types:r="Intersection results could not be merged";break;case n.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case n.not_finite:r="Number must be finite";break;default:r=a.defaultError,e.assertNever(t)}return{message:r}};let o=i;function d(){return o}const c=e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}};function u(e,t){const s=d(),a=c({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===i?void 0:i].filter((e=>!!e))});e.common.issues.push(a)}class l{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return h;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return l.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status)return h;if("aborted"===n.status)return h;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!a.alwaysSet||(s[t.value]=n.value)}return{status:e.value,value:s}}}const h=Object.freeze({status:"aborted"}),p=e=>({status:"dirty",value:e}),m=e=>({status:"valid",value:e}),f=e=>"aborted"===e.status,y=e=>"dirty"===e.status,v=e=>"valid"===e.status,g=e=>"undefined"!=typeof Promise&&e instanceof Promise;function _(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)}function b(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s}var k,x,w;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(k||(k={}));class Z{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}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 T=(e,t)=>{if(v(t))return{success:!0,data:t.value};if(!e.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 r(e.common.issues);return this._error=t,this._error}}};function O(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:n}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{var r,i;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:n.defaultError}:void 0===n.data?{message:null!==(r=null!=o?o:a)&&void 0!==r?r:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(i=null!=o?o:s)&&void 0!==i?i:n.defaultError}},description:n}}class j{get description(){return this._def.description}_getType(e){return a(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new l,ctx:{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(g(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 s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:null!==(s=null==t?void 0:t.async)&&void 0!==s&&s,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},r=this._parseSync({data:e,path:n.path,parent:n});return T(n,r)}"~validate"(e){var t,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:n});return v(t)?{value:t.value}:{issues:n.common.issues}}catch(e){(null===(s=null===(t=null==e?void 0:e.message)||void 0===t?void 0:t.toLowerCase())||void 0===s?void 0:s.includes("encountered"))&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then((e=>v(e)?{value:e.value}:{issues:n.common.issues}))}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},n=this._parse({data:e,path:s.path,parent:s}),r=await(g(n)?n:Promise.resolve(n));return T(s,r)}refine(e,t){const s=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const r=e(t),i=()=>a.addIssue({code:n.custom,...s(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then((e=>!!e||(i(),!1))):!!r||(i(),!1)}))}refinement(e,t){return this._refinement(((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1)))}_refinement(e){return new je({schema:this,typeName:Le.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}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),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Se.create(this,this._def)}nullable(){return Ce.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return de.create(this)}promise(){return Oe.create(this,this._def)}or(e){return le.create([this,e],this._def)}and(e){return fe.create(this,e,this._def)}transform(e){return new je({...O(this._def),schema:this,typeName:Le.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ne({...O(this._def),innerType:this,defaultValue:t,typeName:Le.ZodDefault})}brand(){return new Pe({typeName:Le.ZodBranded,type:this,...O(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ae({...O(this._def),innerType:this,catchValue:t,typeName:Le.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Re.create(this,e)}readonly(){return $e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const S=/^c[^\s-]{8,}$/i,C=/^[0-9a-z]+$/,N=/^[0-9A-HJKMNP-TV-Z]{26}$/i,A=/^[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,E=/^[a-z0-9_-]{21}$/i,I=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,P=/^[-+]?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)?)??$/,R=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let $;const M=/^(?:(?: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])$/,F=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,D=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,L=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,z=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,U="((\\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])))",K=new RegExp(`^${U}$`);function q(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function B(e){let t=`${U}T${q(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function W(e,t){if(!I.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return"object"==typeof n&&null!==n&&(!(!n.typ||!n.alg)&&(!t||n.alg===t))}catch(e){return!1}}function J(e,t){return!("v4"!==t&&t||!F.test(e))||!("v6"!==t&&t||!L.test(e))}class H extends j{_parse(t){this._def.coerce&&(t.data=String(t.data));if(this._getType(t)!==s.string){const e=this._getOrReturnCtx(t);return u(e,{code:n.invalid_type,expected:s.string,received:e.parsedType}),h}const a=new l;let r;for(const s of this._def.checks)if("min"===s.kind)t.data.length<s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("max"===s.kind)t.data.length>s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("length"===s.kind){const e=t.data.length>s.value,i=t.data.length<s.value;(e||i)&&(r=this._getOrReturnCtx(t,r),e?u(r,{code:n.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&u(r,{code:n.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if("email"===s.kind)R.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"email",code:n.invalid_string,message:s.message}),a.dirty());else if("emoji"===s.kind)$||($=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),$.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"emoji",code:n.invalid_string,message:s.message}),a.dirty());else if("uuid"===s.kind)A.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"uuid",code:n.invalid_string,message:s.message}),a.dirty());else if("nanoid"===s.kind)E.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"nanoid",code:n.invalid_string,message:s.message}),a.dirty());else if("cuid"===s.kind)S.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"cuid",code:n.invalid_string,message:s.message}),a.dirty());else if("cuid2"===s.kind)C.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"cuid2",code:n.invalid_string,message:s.message}),a.dirty());else if("ulid"===s.kind)N.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"ulid",code:n.invalid_string,message:s.message}),a.dirty());else if("url"===s.kind)try{new URL(t.data)}catch(e){r=this._getOrReturnCtx(t,r),u(r,{validation:"url",code:n.invalid_string,message:s.message}),a.dirty()}else if("regex"===s.kind){s.regex.lastIndex=0;s.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"regex",code:n.invalid_string,message:s.message}),a.dirty())}else if("trim"===s.kind)t.data=t.data.trim();else if("includes"===s.kind)t.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty());else if("toLowerCase"===s.kind)t.data=t.data.toLowerCase();else if("toUpperCase"===s.kind)t.data=t.data.toUpperCase();else if("startsWith"===s.kind)t.data.startsWith(s.value)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty());else if("endsWith"===s.kind)t.data.endsWith(s.value)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty());else if("datetime"===s.kind){B(s).test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:"datetime",message:s.message}),a.dirty())}else if("date"===s.kind){K.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:"date",message:s.message}),a.dirty())}else if("time"===s.kind){new RegExp(`^${q(s)}$`).test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:"time",message:s.message}),a.dirty())}else"duration"===s.kind?P.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"duration",code:n.invalid_string,message:s.message}),a.dirty()):"ip"===s.kind?(i=t.data,("v4"!==(o=s.version)&&o||!M.test(i))&&("v6"!==o&&o||!D.test(i))&&(r=this._getOrReturnCtx(t,r),u(r,{validation:"ip",code:n.invalid_string,message:s.message}),a.dirty())):"jwt"===s.kind?W(t.data,s.alg)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"jwt",code:n.invalid_string,message:s.message}),a.dirty()):"cidr"===s.kind?J(t.data,s.version)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"cidr",code:n.invalid_string,message:s.message}),a.dirty()):"base64"===s.kind?z.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"base64",code:n.invalid_string,message:s.message}),a.dirty()):"base64url"===s.kind?V.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"base64url",code:n.invalid_string,message:s.message}),a.dirty()):e.assertNever(s);var i,o;return{status:a.value,value:t.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:n.invalid_string,...k.errToObj(s)})}_addCheck(e){return new H({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...k.errToObj(e)})}url(e){return this._addCheck({kind:"url",...k.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...k.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...k.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...k.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...k.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...k.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...k.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...k.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...k.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...k.errToObj(e)})}datetime(e){var t,s;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(s=null==e?void 0:e.local)&&void 0!==s&&s,...k.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...k.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...k.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...k.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...k.errToObj(t)})}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new H({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new H({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new H({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isCIDR(){return!!this._def.checks.find((e=>"cidr"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get isBase64url(){return!!this._def.checks.find((e=>"base64url"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function Y(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}H.create=e=>{var t;return new H({checks:[],typeName:Le.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...O(e)})};class G extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){this._def.coerce&&(t.data=Number(t.data));if(this._getType(t)!==s.number){const e=this._getOrReturnCtx(t);return u(e,{code:n.invalid_type,expected:s.number,received:e.parsedType}),h}let a;const r=new l;for(const s of this._def.checks)if("int"===s.kind)e.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:n.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty());else if("min"===s.kind){(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty())}else if("max"===s.kind){(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty())}else"multipleOf"===s.kind?0!==Y(t.data,s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):"finite"===s.kind?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:n.not_finite,message:s.message}),r.dirty()):e.assertNever(s);return{status:r.value,value:t.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,s,a){return new G({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:k.toString(a)}]})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((t=>"int"===t.kind||"multipleOf"===t.kind&&e.isInteger(t.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}G.create=e=>new G({checks:[],typeName:Le.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...O(e)});class X extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch(e){return this._getInvalidInput(t)}if(this._getType(t)!==s.bigint)return this._getInvalidInput(t);let a;const r=new l;for(const s of this._def.checks)if("min"===s.kind){(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty())}else if("max"===s.kind){(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty())}else"multipleOf"===s.kind?t.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):e.assertNever(s);return{status:r.value,value:t.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.bigint,received:t.parsedType}),h}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,s,a){return new X({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:k.toString(a)}]})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}X.create=e=>{var t;return new X({checks:[],typeName:Le.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...O(e)})};class Q extends j{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==s.boolean){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.boolean,received:t.parsedType}),h}return m(e.data)}}Q.create=e=>new Q({typeName:Le.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...O(e)});class ee extends j{_parse(t){this._def.coerce&&(t.data=new Date(t.data));if(this._getType(t)!==s.date){const e=this._getOrReturnCtx(t);return u(e,{code:n.invalid_type,expected:s.date,received:e.parsedType}),h}if(isNaN(t.data.getTime())){return u(this._getOrReturnCtx(t),{code:n.invalid_date}),h}const a=new l;let r;for(const s of this._def.checks)"min"===s.kind?t.data.getTime()<s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):"max"===s.kind?t.data.getTime()>s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):e.assertNever(s);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}ee.create=e=>new ee({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Le.ZodDate,...O(e)});class te extends j{_parse(e){if(this._getType(e)!==s.symbol){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.symbol,received:t.parsedType}),h}return m(e.data)}}te.create=e=>new te({typeName:Le.ZodSymbol,...O(e)});class se extends j{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.undefined,received:t.parsedType}),h}return m(e.data)}}se.create=e=>new se({typeName:Le.ZodUndefined,...O(e)});class ae extends j{_parse(e){if(this._getType(e)!==s.null){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.null,received:t.parsedType}),h}return m(e.data)}}ae.create=e=>new ae({typeName:Le.ZodNull,...O(e)});class ne extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}}ne.create=e=>new ne({typeName:Le.ZodAny,...O(e)});class re extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}}re.create=e=>new re({typeName:Le.ZodUnknown,...O(e)});class ie extends j{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.never,received:t.parsedType}),h}}ie.create=e=>new ie({typeName:Le.ZodNever,...O(e)});class oe extends j{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.void,received:t.parsedType}),h}return m(e.data)}}oe.create=e=>new oe({typeName:Le.ZodVoid,...O(e)});class de extends j{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),r=this._def;if(t.parsedType!==s.array)return u(t,{code:n.invalid_type,expected:s.array,received:t.parsedType}),h;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,s=t.data.length<r.exactLength.value;(e||s)&&(u(t,{code:e?n.too_big:n.too_small,minimum:s?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(u(t,{code:n.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(u(t,{code:n.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map(((e,s)=>r.type._parseAsync(new Z(t,e,t.path,s))))).then((e=>l.mergeArray(a,e)));const i=[...t.data].map(((e,s)=>r.type._parseSync(new Z(t,e,t.path,s))));return l.mergeArray(a,i)}get element(){return this._def.type}min(e,t){return new de({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new de({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new de({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}function ce(e){if(e instanceof ue){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=Se.create(ce(a))}return new ue({...e._def,shape:()=>t})}return e instanceof de?new de({...e._def,type:ce(e.element)}):e instanceof Se?Se.create(ce(e.unwrap())):e instanceof Ce?Ce.create(ce(e.unwrap())):e instanceof ye?ye.create(e.items.map((e=>ce(e)))):e}de.create=(e,t)=>new de({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Le.ZodArray,...O(t)});class ue extends j{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const t=this._def.shape(),s=e.objectKeys(t);return this._cached={shape:t,keys:s}}_parse(e){if(this._getType(e)!==s.object){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.object,received:t.parsedType}),h}const{status:t,ctx:a}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&"strip"===this._def.unknownKeys))for(const e in a.data)i.includes(e)||o.push(e);const d=[];for(const e of i){const t=r[e],s=a.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new Z(a,s,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof ie){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)d.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)o.length>0&&(u(a,{code:n.unrecognized_keys,keys:o}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of o){const s=a.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new Z(a,s,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of d){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>l.mergeObjectSync(t,e))):l.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new ue({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{var a,n,r,i;const o=null!==(r=null===(n=(a=this._def).errorMap)||void 0===n?void 0:n.call(a,t,s).message)&&void 0!==r?r:s.defaultError;return"unrecognized_keys"===t.code?{message:null!==(i=k.errToObj(e).message)&&void 0!==i?i:o}:{message:o}}}:{}})}strip(){return new ue({...this._def,unknownKeys:"strip"})}passthrough(){return new ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Le.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ue({...this._def,catchall:e})}pick(t){const s={};return e.objectKeys(t).forEach((e=>{t[e]&&this.shape[e]&&(s[e]=this.shape[e])})),new ue({...this._def,shape:()=>s})}omit(t){const s={};return e.objectKeys(this.shape).forEach((e=>{t[e]||(s[e]=this.shape[e])})),new ue({...this._def,shape:()=>s})}deepPartial(){return ce(this)}partial(t){const s={};return e.objectKeys(this.shape).forEach((e=>{const a=this.shape[e];t&&!t[e]?s[e]=a:s[e]=a.optional()})),new ue({...this._def,shape:()=>s})}required(t){const s={};return e.objectKeys(this.shape).forEach((e=>{if(t&&!t[e])s[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Se;)t=t._def.innerType;s[e]=t}})),new ue({...this._def,shape:()=>s})}keyof(){return we(e.objectKeys(this.shape))}}ue.create=(e,t)=>new ue({shape:()=>e,unknownKeys:"strip",catchall:ie.create(),typeName:Le.ZodObject,...O(t)}),ue.strictCreate=(e,t)=>new ue({shape:()=>e,unknownKeys:"strict",catchall:ie.create(),typeName:Le.ZodObject,...O(t)}),ue.lazycreate=(e,t)=>new ue({shape:e,unknownKeys:"strip",catchall:ie.create(),typeName:Le.ZodObject,...O(t)});class le extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map((e=>new r(e.ctx.common.issues)));return u(t,{code:n.invalid_union,unionErrors:s}),h}));{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=a.map((e=>new r(e)));return u(t,{code:n.invalid_union,unionErrors:i}),h}}get options(){return this._def.options}}le.create=(e,t)=>new le({options:e,typeName:Le.ZodUnion,...O(t)});const he=t=>t instanceof ke?he(t.schema):t instanceof je?he(t.innerType()):t instanceof xe?[t.value]:t instanceof Ze?t.options:t instanceof Te?e.objectValues(t.enum):t instanceof Ne?he(t._def.innerType):t instanceof se?[void 0]:t instanceof ae?[null]:t instanceof Se?[void 0,...he(t.unwrap())]:t instanceof Ce?[null,...he(t.unwrap())]:t instanceof Pe||t instanceof $e?he(t.unwrap()):t instanceof Ae?he(t._def.innerType):[];class pe extends j{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.object)return u(t,{code:n.invalid_type,expected:s.object,received:t.parsedType}),h;const a=this.discriminator,r=t.data[a],i=this.optionsMap.get(r);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}):(u(t,{code:n.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),h)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=he(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new pe({typeName:Le.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...O(s)})}}function me(t,n){const r=a(t),i=a(n);if(t===n)return{valid:!0,data:t};if(r===s.object&&i===s.object){const s=e.objectKeys(n),a=e.objectKeys(t).filter((e=>-1!==s.indexOf(e))),r={...t,...n};for(const e of a){const s=me(t[e],n[e]);if(!s.valid)return{valid:!1};r[e]=s.data}return{valid:!0,data:r}}if(r===s.array&&i===s.array){if(t.length!==n.length)return{valid:!1};const e=[];for(let s=0;s<t.length;s++){const a=me(t[s],n[s]);if(!a.valid)return{valid:!1};e.push(a.data)}return{valid:!0,data:e}}return r===s.date&&i===s.date&&+t==+n?{valid:!0,data:t}:{valid:!1}}class fe extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(f(e)||f(a))return h;const r=me(e.value,a.value);return r.valid?((y(e)||y(a))&&t.dirty(),{status:t.value,value:r.data}):(u(s,{code:n.invalid_intersection_types}),h)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}fe.create=(e,t,s)=>new fe({left:e,right:t,typeName:Le.ZodIntersection,...O(s)});class ye extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.array)return u(a,{code:n.invalid_type,expected:s.array,received:a.parsedType}),h;if(a.data.length<this._def.items.length)return u(a,{code:n.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&a.data.length>this._def.items.length&&(u(a,{code:n.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...a.data].map(((e,t)=>{const s=this._def.items[t]||this._def.rest;return s?s._parse(new Z(a,e,a.path,t)):null})).filter((e=>!!e));return a.common.async?Promise.all(r).then((e=>l.mergeArray(t,e))):l.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ye({...this._def,rest:e})}}ye.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ye({items:e,typeName:Le.ZodTuple,rest:null,...O(t)})};class ve extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.object)return u(a,{code:n.invalid_type,expected:s.object,received:a.parsedType}),h;const r=[],i=this._def.keyType,o=this._def.valueType;for(const e in a.data)r.push({key:i._parse(new Z(a,e,a.path,e)),value:o._parse(new Z(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?l.mergeObjectAsync(t,r):l.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return new ve(t instanceof j?{keyType:e,valueType:t,typeName:Le.ZodRecord,...O(s)}:{keyType:H.create(),valueType:e,typeName:Le.ZodRecord,...O(t)})}}class ge extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.map)return u(a,{code:n.invalid_type,expected:s.map,received:a.parsedType}),h;const r=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map((([e,t],s)=>({key:r._parse(new Z(a,e,a.path,[s,"key"])),value:i._parse(new Z(a,t,a.path,[s,"value"]))})));if(a.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of o){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const s of o){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}ge.create=(e,t,s)=>new ge({valueType:t,keyType:e,typeName:Le.ZodMap,...O(s)});class _e extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.set)return u(a,{code:n.invalid_type,expected:s.set,received:a.parsedType}),h;const r=this._def;null!==r.minSize&&a.data.size<r.minSize.value&&(u(a,{code:n.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&a.data.size>r.maxSize.value&&(u(a,{code:n.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function o(e){const s=new Set;for(const a of e){if("aborted"===a.status)return h;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const d=[...a.data.values()].map(((e,t)=>i._parse(new Z(a,e,a.path,t))));return a.common.async?Promise.all(d).then((e=>o(e))):o(d)}min(e,t){return new _e({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new _e({...this._def,maxSize:{value:e,message:k.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_e.create=(e,t)=>new _e({valueType:e,minSize:null,maxSize:null,typeName:Le.ZodSet,...O(t)});class be extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.function)return u(t,{code:n.invalid_type,expected:s.function,received:t.parsedType}),h;function a(e,s){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,d(),i].filter((e=>!!e)),issueData:{code:n.invalid_arguments,argumentsError:s}})}function o(e,s){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,d(),i].filter((e=>!!e)),issueData:{code:n.invalid_return_type,returnTypeError:s}})}const l={errorMap:t.common.contextualErrorMap},p=t.data;if(this._def.returns instanceof Oe){const e=this;return m((async function(...t){const s=new r([]),n=await e._def.args.parseAsync(t,l).catch((e=>{throw s.addIssue(a(t,e)),s})),i=await Reflect.apply(p,this,n);return await e._def.returns._def.type.parseAsync(i,l).catch((e=>{throw s.addIssue(o(i,e)),s}))}))}{const e=this;return m((function(...t){const s=e._def.args.safeParse(t,l);if(!s.success)throw new r([a(t,s.error)]);const n=Reflect.apply(p,this,s.data),i=e._def.returns.safeParse(n,l);if(!i.success)throw new r([o(n,i.error)]);return i.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new be({...this._def,args:ye.create(e).rest(re.create())})}returns(e){return new be({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new be({args:e||ye.create([]).rest(re.create()),returns:t||re.create(),typeName:Le.ZodFunction,...O(s)})}}class ke extends j{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})}}ke.create=(e,t)=>new ke({getter:e,typeName:Le.ZodLazy,...O(t)});class xe extends j{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:n.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}}function we(e,t){return new Ze({values:e,typeName:Le.ZodEnum,...O(t)})}xe.create=(e,t)=>new xe({value:e,typeName:Le.ZodLiteral,...O(t)});class Ze extends j{constructor(){super(...arguments),x.set(this,void 0)}_parse(t){if("string"!=typeof t.data){const s=this._getOrReturnCtx(t),a=this._def.values;return u(s,{expected:e.joinValues(a),received:s.parsedType,code:n.invalid_type}),h}if(_(this,x,"f")||b(this,x,new Set(this._def.values),"f"),!_(this,x,"f").has(t.data)){const e=this._getOrReturnCtx(t),s=this._def.values;return u(e,{received:e.data,code:n.invalid_enum_value,options:s}),h}return m(t.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 Ze.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ze.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}x=new WeakMap,Ze.create=we;class Te extends j{constructor(){super(...arguments),w.set(this,void 0)}_parse(t){const a=e.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==s.string&&r.parsedType!==s.number){const t=e.objectValues(a);return u(r,{expected:e.joinValues(t),received:r.parsedType,code:n.invalid_type}),h}if(_(this,w,"f")||b(this,w,new Set(e.getValidEnumValues(this._def.values)),"f"),!_(this,w,"f").has(t.data)){const t=e.objectValues(a);return u(r,{received:r.data,code:n.invalid_enum_value,options:t}),h}return m(t.data)}get enum(){return this._def.values}}w=new WeakMap,Te.create=(e,t)=>new Te({values:e,typeName:Le.ZodNativeEnum,...O(t)});class Oe extends j{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.promise&&!1===t.common.async)return u(t,{code:n.invalid_type,expected:s.promise,received:t.parsedType}),h;const a=t.parsedType===s.promise?t.data:Promise.resolve(t.data);return m(a.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}Oe.create=(e,t)=>new Oe({type:e,typeName:Le.ZodPromise,...O(t)});class je extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:s,ctx:a}=this._processInputParams(t),n=this._def.effect||null,r={addIssue:e=>{u(a,e),e.fatal?s.abort():s.dirty()},get path(){return a.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){const e=n.transform(a.data,r);if(a.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===s.value)return h;const t=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===t.status?h:"dirty"===t.status||"dirty"===s.value?p(t.value):t}));{if("aborted"===s.value)return h;const t=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===t.status?h:"dirty"===t.status||"dirty"===s.value?p(t.value):t}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,r);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const t=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===t.status?h:("dirty"===t.status&&s.dirty(),e(t.value),{status:s.value,value:t.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((t=>"aborted"===t.status?h:("dirty"===t.status&&s.dirty(),e(t.value).then((()=>({status:s.value,value:t.value}))))))}if("transform"===n.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!v(e))return e;const t=n.transform(e.value,r);if(t instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:t}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>v(e)?Promise.resolve(n.transform(e.value,r)).then((e=>({status:s.value,value:e}))):e))}e.assertNever(n)}}je.create=(e,t,s)=>new je({schema:e,typeName:Le.ZodEffects,effect:t,...O(s)}),je.createWithPreprocess=(e,t,s)=>new je({schema:t,effect:{type:"preprocess",transform:e},typeName:Le.ZodEffects,...O(s)});class Se extends j{_parse(e){return this._getType(e)===s.undefined?m(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Se.create=(e,t)=>new Se({innerType:e,typeName:Le.ZodOptional,...O(t)});class Ce extends j{_parse(e){return this._getType(e)===s.null?m(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ce.create=(e,t)=>new Ce({innerType:e,typeName:Le.ZodNullable,...O(t)});class Ne extends j{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===s.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ne.create=(e,t)=>new Ne({innerType:e,typeName:Le.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...O(t)});class Ae extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return g(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new r(s.common.issues)},input:s.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new r(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ae.create=(e,t)=>new Ae({innerType:e,typeName:Le.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...O(t)});class Ee extends j{_parse(e){if(this._getType(e)!==s.nan){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.nan,received:t.parsedType}),h}return{status:"valid",value:e.data}}}Ee.create=e=>new Ee({typeName:Le.ZodNaN,...O(e)});const Ie=Symbol("zod_brand");class Pe extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Re extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),p(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})()}{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new Re({in:e,out:t,typeName:Le.ZodPipeline})}}class $e extends j{_parse(e){const t=this._def.innerType._parse(e),s=e=>(v(e)&&(e.value=Object.freeze(e.value)),e);return g(t)?t.then((e=>s(e))):s(t)}unwrap(){return this._def.innerType}}function Me(e,t){const s="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof s?{message:s}:s}function Fe(e,t={},s){return e?ne.create().superRefine(((a,n)=>{var r,i;const o=e(a);if(o instanceof Promise)return o.then((e=>{var r,i;if(!e){const e=Me(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}}));if(!o){const e=Me(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}})):ne.create()}$e.create=(e,t)=>new $e({innerType:e,typeName:Le.ZodReadonly,...O(t)});const De={object:ue.lazycreate};var Le;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Le||(Le={}));const ze=H.create,Ve=G.create,Ue=Ee.create,Ke=X.create,qe=Q.create,Be=ee.create,We=te.create,Je=se.create,He=ae.create,Ye=ne.create,Ge=re.create,Xe=ie.create,Qe=oe.create,et=de.create,tt=ue.create,st=ue.strictCreate,at=le.create,nt=pe.create,rt=fe.create,it=ye.create,ot=ve.create,dt=ge.create,ct=_e.create,ut=be.create,lt=ke.create,ht=xe.create,pt=Ze.create,mt=Te.create,ft=Oe.create,yt=je.create,vt=Se.create,gt=Ce.create,_t=je.createWithPreprocess,bt=Re.create,kt={string:e=>H.create({...e,coerce:!0}),number:e=>G.create({...e,coerce:!0}),boolean:e=>Q.create({...e,coerce:!0}),bigint:e=>X.create({...e,coerce:!0}),date:e=>ee.create({...e,coerce:!0})},xt=h;var wt=Object.freeze({__proto__:null,defaultErrorMap:i,setErrorMap:function(e){o=e},getErrorMap:d,makeIssue:c,EMPTY_PATH:[],addIssueToContext:u,ParseStatus:l,INVALID:h,DIRTY:p,OK:m,isAborted:f,isDirty:y,isValid:v,isAsync:g,get util(){return e},get objectUtil(){return t},ZodParsedType:s,getParsedType:a,ZodType:j,datetimeRegex:B,ZodString:H,ZodNumber:G,ZodBigInt:X,ZodBoolean:Q,ZodDate:ee,ZodSymbol:te,ZodUndefined:se,ZodNull:ae,ZodAny:ne,ZodUnknown:re,ZodNever:ie,ZodVoid:oe,ZodArray:de,ZodObject:ue,ZodUnion:le,ZodDiscriminatedUnion:pe,ZodIntersection:fe,ZodTuple:ye,ZodRecord:ve,ZodMap:ge,ZodSet:_e,ZodFunction:be,ZodLazy:ke,ZodLiteral:xe,ZodEnum:Ze,ZodNativeEnum:Te,ZodPromise:Oe,ZodEffects:je,ZodTransformer:je,ZodOptional:Se,ZodNullable:Ce,ZodDefault:Ne,ZodCatch:Ae,ZodNaN:Ee,BRAND:Ie,ZodBranded:Pe,ZodPipeline:Re,ZodReadonly:$e,custom:Fe,Schema:j,ZodSchema:j,late:De,get ZodFirstPartyTypeKind(){return Le},coerce:kt,any:Ye,array:et,bigint:Ke,boolean:qe,date:Be,discriminatedUnion:nt,effect:yt,enum:pt,function:ut,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>Fe((t=>t instanceof e),t),intersection:rt,lazy:lt,literal:ht,map:dt,nan:Ue,nativeEnum:mt,never:Xe,null:He,nullable:gt,number:Ve,object:tt,oboolean:()=>qe().optional(),onumber:()=>Ve().optional(),optional:vt,ostring:()=>ze().optional(),pipeline:bt,preprocess:_t,promise:ft,record:ot,set:ct,strictObject:st,string:ze,symbol:We,transformer:yt,tuple:it,undefined:Je,union:at,unknown:Ge,void:Qe,NEVER:xt,ZodIssueCode:n,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:r}),Zt=["interface","display","layout","module","panel","theme"],Tt=["hook","endpoint"],Ot=["operation"],jt="directus:extension",St=wt.object({app:wt.string(),api:wt.string()}),Ct=wt.object({request:wt.optional(wt.object({urls:wt.array(wt.string()),methods:wt.array(wt.union([wt.literal("GET"),wt.literal("POST"),wt.literal("PATCH"),wt.literal("PUT"),wt.literal("DELETE")]))})),log:wt.optional(wt.object({})),sleep:wt.optional(wt.object({}))}),Nt=wt.optional(wt.object({enabled:wt.boolean(),requestedScopes:Ct})),At=wt.union([wt.object({type:wt.enum(Tt),name:wt.string(),source:wt.string()}),wt.object({type:wt.enum(Zt),name:wt.string(),source:wt.string()}),wt.object({type:wt.enum(Ot),name:wt.string(),source:St})]),Et=wt.object({host:wt.string(),hidden:wt.boolean().optional()}),It=wt.object({type:wt.enum(Zt),path:wt.string(),source:wt.string()}),Pt=wt.object({type:wt.enum(Tt),path:wt.string(),source:wt.string(),sandbox:Nt}),Rt=wt.object({type:wt.enum(Ot),path:St,source:St,sandbox:Nt}),$t=wt.object({type:wt.literal("bundle"),partial:wt.boolean().optional(),path:St,entries:wt.array(At)});wt.array(At);var Mt=Et.and(wt.union([It,Pt,Rt,$t]));wt.object({name:wt.string(),version:wt.string(),type:wt.union([wt.literal("module"),wt.literal("commonjs")]).optional(),description:wt.string().optional(),icon:wt.string().optional(),dependencies:wt.record(wt.string()).optional(),devDependencies:wt.record(wt.string()).optional(),[jt]:Mt});const{findWorkspaceDir:Ft}=require("@pnpm/find-workspace-dir"),Dt=require("js-yaml"),Lt=require("path"),zt=require("fs"),Vt=()=>process.cwd(),Ut=process.env.EXTENSIONS_PATH||"./extensions";let Kt;async function qt(e,t){if(Kt)return JSON.parse(Kt);const{SpecificationService:s}=e,a=new s({accountability:{admin:!0},schema:t});return Kt=JSON.stringify(await a.oas.generate()),JSON.parse(Kt)}function Bt(e,t){return Object.entries(t).reduce(((e,[t,s])=>(e[t]=s&&"object"==typeof s?Bt(e[t]=e[t]||(Array.isArray(s)?[]:{}),s):s,e)),e)}const Wt=require("swagger-ui-express"),Jt=require("express-openapi-validator"),Ht=function(){const e=function(){const e={docsPath:"api-docs",info:{},tags:[],publishedTags:[],paths:{},components:{}};try{let t;try{const e=Lt.join(Vt(),Ut,"/oasconfig.yaml");t=Dt.load(zt.readFileSync(e,{encoding:"utf-8"}))}catch{const e=Lt.join(Vt(),Ut,"/endpoints/oasconfig.yaml");t=Dt.load(zt.readFileSync(e,{encoding:"utf-8"}))}return t.docsPath=t.docsPath||e.docsPath,t.info=t.info||e.info,t.tags=t.tags||e.tags,t.paths=t.paths||e.paths,t.components=t.components||e.components,t}catch{return e}}();try{const t=t=>{const s=Dt.load(zt.readFileSync(t,{encoding:"utf-8"}));e.tags=[...e.tags,...s.tags||[]],e.paths={...e.paths,...s.paths||{}},e.components=Bt(e.components||{},s.components||{})},s=Lt.join(Vt(),Ut),a=zt.readdirSync(s,{withFileTypes:!0});for(const e of a){const a=`${s}/${e.name}/oas.yaml`;e.isDirectory()&&zt.existsSync(a)&&t(a)}const n=Lt.join(Vt(),Ut,"/endpoints"),r=zt.readdirSync(n,{withFileTypes:!0});for(const e of r){const s=`${n}/${e.name}/oas.yaml`;e.isDirectory()&&zt.existsSync(s)&&t(s)}return e}catch(t){return e}}(),Yt=Ht.docsPath;var Gt={id:Yt,validate:async function(e,t,s,a){if(null==Ht?void 0:Ht.paths){const n=await qt(t,s);if(a)for(const e of a)n.paths[e]=Ht.paths[e];else n.paths=Ht.paths;Ht.components?n.components=Ht.components:(delete n.components.definitions,delete n.components.schemas),e.use(Jt.middleware({apiSpec:n})),e.use(((e,t,s,a)=>{s.status(e.status||500).json({message:e.message,errors:e.errors})}))}return e},handler:(e,{services:t,logger:s,getSchema:a})=>{const n={swaggerOptions:{url:`/${Yt}/oas`}};e.use("/",Wt.serve),e.get("/",Wt.setup({},n)),e.get("/oas",(async(e,n,r)=>{var i;try{const e=await a(),r=await qt(t,e),o=await async function(){try{const e=await Ft(".");return require(`${e||Vt()}/package.json`)}catch(e){return{}}}();r.info.title=Ht.info.title||(null==o?void 0:o.name)||r.info.title,r.info.version=Ht.info.version||(null==o?void 0:o.version)||r.info.version,r.info.description=Ht.info.description||(null==o?void 0:o.description)||r.info.description;try{for(const e in Ht.paths)r.paths[e]=Ht.paths[e];for(const e of Ht.tags)r.tags.push(e);r.components=Bt(Ht.components,r.components)}catch(e){s.info("No custom definitions")}(null==(i=Ht.publishedTags)?void 0:i.length)&&function(e,t){for(const s in t.paths)for(const a in t.paths[s]){let n=!1;const r=t.paths[s][a].tags||[];r.forEach((t=>{n=n||e.publishedTags.includes(t)})),t.paths[s][a].tags=r.filter((t=>e.publishedTags.includes(t))),n||delete t.paths[s][a]}t.tags=t.tags.filter((t=>e.publishedTags.includes(t.name)))}(Ht,r),n.json(r)}catch(e){return r(new Error(e.message||e[0].message))}}))}};module.exports=Gt;
|
|
1
|
+
"use strict";var e,t;!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),a={};for(const e of s)a[e]=t[e];return e.objectValues(a)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},e.find=(e,t)=>{for(const s of e)if(t(s))return s},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(e||(e={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(t||(t={}));const s=e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),a=e=>{switch(typeof e){case"undefined":return s.undefined;case"string":return s.string;case"number":return isNaN(e)?s.nan:s.number;case"boolean":return s.boolean;case"function":return s.function;case"bigint":return s.bigint;case"symbol":return s.symbol;case"object":return Array.isArray(e)?s.array:null===e?s.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?s.promise:"undefined"!=typeof Map&&e instanceof Map?s.map:"undefined"!=typeof Set&&e instanceof Set?s.set:"undefined"!=typeof Date&&e instanceof Date?s.date:s.object;default:return s.unknown}},n=e.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"]);class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}r.create=e=>new r(e);const i=(t,a)=>{let r;switch(t.code){case n.invalid_type:r=t.received===s.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case n.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case n.unrecognized_keys:r=`Unrecognized key(s) in object: ${e.joinValues(t.keys,", ")}`;break;case n.invalid_union:r="Invalid input";break;case n.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case n.invalid_enum_value:r=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case n.invalid_arguments:r="Invalid function arguments";break;case n.invalid_return_type:r="Invalid function return type";break;case n.invalid_date:r="Invalid date";break;case n.invalid_string:"object"==typeof t.validation?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,"number"==typeof t.validation.position&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):r="regex"!==t.validation?`Invalid ${t.validation}`:"Invalid";break;case n.too_small:r="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:"date"===t.type?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case n.too_big:r="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"bigint"===t.type?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"date"===t.type?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case n.custom:r="Invalid input";break;case n.invalid_intersection_types:r="Intersection results could not be merged";break;case n.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case n.not_finite:r="Number must be finite";break;default:r=a.defaultError,e.assertNever(t)}return{message:r}};let o=i;function d(){return o}const c=e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter(e=>!!e).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}};function u(e,t){const s=d(),a=c({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===i?void 0:i].filter(e=>!!e)});e.common.issues.push(a)}class l{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return h;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return l.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status)return h;if("aborted"===n.status)return h;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!a.alwaysSet||(s[t.value]=n.value)}return{status:e.value,value:s}}}const h=Object.freeze({status:"aborted"}),p=e=>({status:"dirty",value:e}),m=e=>({status:"valid",value:e}),f=e=>"aborted"===e.status,y=e=>"dirty"===e.status,g=e=>"valid"===e.status,v=e=>"undefined"!=typeof Promise&&e instanceof Promise;function _(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)}function b(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s}var k,x,w;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(k||(k={}));class Z{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}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 T=(e,t)=>{if(g(t))return{success:!0,data:t.value};if(!e.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 r(e.common.issues);return this._error=t,this._error}}};function O(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:n}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{var r,i;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:n.defaultError}:void 0===n.data?{message:null!==(r=null!=o?o:a)&&void 0!==r?r:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(i=null!=o?o:s)&&void 0!==i?i:n.defaultError}},description:n}}class j{get description(){return this._def.description}_getType(e){return a(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new l,ctx:{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(v(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 s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:null!==(s=null==t?void 0:t.async)&&void 0!==s&&s,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},r=this._parseSync({data:e,path:n.path,parent:n});return T(n,r)}"~validate"(e){var t,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:n});return g(t)?{value:t.value}:{issues:n.common.issues}}catch(e){(null===(s=null===(t=null==e?void 0:e.message)||void 0===t?void 0:t.toLowerCase())||void 0===s?void 0:s.includes("encountered"))&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(e=>g(e)?{value:e.value}:{issues:n.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},n=this._parse({data:e,path:s.path,parent:s}),r=await(v(n)?n:Promise.resolve(n));return T(s,r)}refine(e,t){const s=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,a)=>{const r=e(t),i=()=>a.addIssue({code:n.custom,...s(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then(e=>!!e||(i(),!1)):!!r||(i(),!1)})}refinement(e,t){return this._refinement((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1))}_refinement(e){return new Ce({schema:this,typeName:Ve.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}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),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Ne.create(this,this._def)}nullable(){return Ae.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ue.create(this)}promise(){return Se.create(this,this._def)}or(e){return pe.create([this,e],this._def)}and(e){return ge.create(this,e,this._def)}transform(e){return new Ce({...O(this._def),schema:this,typeName:Ve.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ee({...O(this._def),innerType:this,defaultValue:t,typeName:Ve.ZodDefault})}brand(){return new $e({typeName:Ve.ZodBranded,type:this,...O(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ie({...O(this._def),innerType:this,catchValue:t,typeName:Ve.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Me.create(this,e)}readonly(){return Fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const S=/^c[^\s-]{8,}$/i,C=/^[0-9a-z]+$/,N=/^[0-9A-HJKMNP-TV-Z]{26}$/i,A=/^[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,E=/^[a-z0-9_-]{21}$/i,I=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,P=/^[-+]?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)?)??$/,R=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let $;const M=/^(?:(?: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])$/,F=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,D=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,L=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,z=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,U="((\\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])))",K=new RegExp(`^${U}$`);function q(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function B(e){return new RegExp(`^${q(e)}$`)}function W(e){let t=`${U}T${q(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function J(e,t){return!("v4"!==t&&t||!M.test(e))||!("v6"!==t&&t||!D.test(e))}function H(e,t){if(!I.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return"object"==typeof n&&null!==n&&(!(!n.typ||!n.alg)&&(!t||n.alg===t))}catch(e){return!1}}function Y(e,t){return!("v4"!==t&&t||!F.test(e))||!("v6"!==t&&t||!L.test(e))}class G extends j{_parse(t){this._def.coerce&&(t.data=String(t.data));if(this._getType(t)!==s.string){const e=this._getOrReturnCtx(t);return u(e,{code:n.invalid_type,expected:s.string,received:e.parsedType}),h}const a=new l;let r;for(const s of this._def.checks)if("min"===s.kind)t.data.length<s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("max"===s.kind)t.data.length>s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("length"===s.kind){const e=t.data.length>s.value,i=t.data.length<s.value;(e||i)&&(r=this._getOrReturnCtx(t,r),e?u(r,{code:n.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&u(r,{code:n.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if("email"===s.kind)R.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"email",code:n.invalid_string,message:s.message}),a.dirty());else if("emoji"===s.kind)$||($=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),$.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"emoji",code:n.invalid_string,message:s.message}),a.dirty());else if("uuid"===s.kind)A.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"uuid",code:n.invalid_string,message:s.message}),a.dirty());else if("nanoid"===s.kind)E.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"nanoid",code:n.invalid_string,message:s.message}),a.dirty());else if("cuid"===s.kind)S.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"cuid",code:n.invalid_string,message:s.message}),a.dirty());else if("cuid2"===s.kind)C.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"cuid2",code:n.invalid_string,message:s.message}),a.dirty());else if("ulid"===s.kind)N.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"ulid",code:n.invalid_string,message:s.message}),a.dirty());else if("url"===s.kind)try{new URL(t.data)}catch(e){r=this._getOrReturnCtx(t,r),u(r,{validation:"url",code:n.invalid_string,message:s.message}),a.dirty()}else if("regex"===s.kind){s.regex.lastIndex=0;s.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"regex",code:n.invalid_string,message:s.message}),a.dirty())}else if("trim"===s.kind)t.data=t.data.trim();else if("includes"===s.kind)t.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty());else if("toLowerCase"===s.kind)t.data=t.data.toLowerCase();else if("toUpperCase"===s.kind)t.data=t.data.toUpperCase();else if("startsWith"===s.kind)t.data.startsWith(s.value)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty());else if("endsWith"===s.kind)t.data.endsWith(s.value)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty());else if("datetime"===s.kind){W(s).test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:"datetime",message:s.message}),a.dirty())}else if("date"===s.kind){K.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:"date",message:s.message}),a.dirty())}else if("time"===s.kind){B(s).test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:"time",message:s.message}),a.dirty())}else"duration"===s.kind?P.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"duration",code:n.invalid_string,message:s.message}),a.dirty()):"ip"===s.kind?J(t.data,s.version)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"ip",code:n.invalid_string,message:s.message}),a.dirty()):"jwt"===s.kind?H(t.data,s.alg)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"jwt",code:n.invalid_string,message:s.message}),a.dirty()):"cidr"===s.kind?Y(t.data,s.version)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"cidr",code:n.invalid_string,message:s.message}),a.dirty()):"base64"===s.kind?z.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"base64",code:n.invalid_string,message:s.message}),a.dirty()):"base64url"===s.kind?V.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"base64url",code:n.invalid_string,message:s.message}),a.dirty()):e.assertNever(s);return{status:a.value,value:t.data}}_regex(e,t,s){return this.refinement(t=>e.test(t),{validation:t,code:n.invalid_string,...k.errToObj(s)})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...k.errToObj(e)})}url(e){return this._addCheck({kind:"url",...k.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...k.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...k.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...k.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...k.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...k.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...k.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...k.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...k.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...k.errToObj(e)})}datetime(e){var t,s;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(s=null==e?void 0:e.local)&&void 0!==s&&s,...k.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...k.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...k.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...k.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...k.errToObj(t)})}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new G({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new G({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new G({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function X(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}G.create=e=>{var t;return new G({checks:[],typeName:Ve.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...O(e)})};class Q extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){this._def.coerce&&(t.data=Number(t.data));if(this._getType(t)!==s.number){const e=this._getOrReturnCtx(t);return u(e,{code:n.invalid_type,expected:s.number,received:e.parsedType}),h}let a;const r=new l;for(const s of this._def.checks)if("int"===s.kind)e.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:n.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty());else if("min"===s.kind){(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty())}else if("max"===s.kind){(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty())}else"multipleOf"===s.kind?0!==X(t.data,s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):"finite"===s.kind?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:n.not_finite,message:s.message}),r.dirty()):e.assertNever(s);return{status:r.value,value:t.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,s,a){return new Q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:k.toString(a)}]})}_addCheck(e){return new Q({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(t=>"int"===t.kind||"multipleOf"===t.kind&&e.isInteger(t.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Q.create=e=>new Q({checks:[],typeName:Ve.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...O(e)});class ee extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch(e){return this._getInvalidInput(t)}if(this._getType(t)!==s.bigint)return this._getInvalidInput(t);let a;const r=new l;for(const s of this._def.checks)if("min"===s.kind){(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty())}else if("max"===s.kind){(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty())}else"multipleOf"===s.kind?t.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):e.assertNever(s);return{status:r.value,value:t.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.bigint,received:t.parsedType}),h}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,s,a){return new ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:k.toString(a)}]})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}ee.create=e=>{var t;return new ee({checks:[],typeName:Ve.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...O(e)})};class te extends j{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==s.boolean){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.boolean,received:t.parsedType}),h}return m(e.data)}}te.create=e=>new te({typeName:Ve.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...O(e)});class se extends j{_parse(t){this._def.coerce&&(t.data=new Date(t.data));if(this._getType(t)!==s.date){const e=this._getOrReturnCtx(t);return u(e,{code:n.invalid_type,expected:s.date,received:e.parsedType}),h}if(isNaN(t.data.getTime())){return u(this._getOrReturnCtx(t),{code:n.invalid_date}),h}const a=new l;let r;for(const s of this._def.checks)"min"===s.kind?t.data.getTime()<s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):"max"===s.kind?t.data.getTime()>s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):e.assertNever(s);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(e){return new se({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}se.create=e=>new se({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Ve.ZodDate,...O(e)});class ae extends j{_parse(e){if(this._getType(e)!==s.symbol){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.symbol,received:t.parsedType}),h}return m(e.data)}}ae.create=e=>new ae({typeName:Ve.ZodSymbol,...O(e)});class ne extends j{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.undefined,received:t.parsedType}),h}return m(e.data)}}ne.create=e=>new ne({typeName:Ve.ZodUndefined,...O(e)});class re extends j{_parse(e){if(this._getType(e)!==s.null){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.null,received:t.parsedType}),h}return m(e.data)}}re.create=e=>new re({typeName:Ve.ZodNull,...O(e)});class ie extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}}ie.create=e=>new ie({typeName:Ve.ZodAny,...O(e)});class oe extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}}oe.create=e=>new oe({typeName:Ve.ZodUnknown,...O(e)});class de extends j{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.never,received:t.parsedType}),h}}de.create=e=>new de({typeName:Ve.ZodNever,...O(e)});class ce extends j{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.void,received:t.parsedType}),h}return m(e.data)}}ce.create=e=>new ce({typeName:Ve.ZodVoid,...O(e)});class ue extends j{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),r=this._def;if(t.parsedType!==s.array)return u(t,{code:n.invalid_type,expected:s.array,received:t.parsedType}),h;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,s=t.data.length<r.exactLength.value;(e||s)&&(u(t,{code:e?n.too_big:n.too_small,minimum:s?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(u(t,{code:n.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(u(t,{code:n.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((e,s)=>r.type._parseAsync(new Z(t,e,t.path,s)))).then(e=>l.mergeArray(a,e));const i=[...t.data].map((e,s)=>r.type._parseSync(new Z(t,e,t.path,s)));return l.mergeArray(a,i)}get element(){return this._def.type}min(e,t){return new ue({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new ue({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new ue({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}function le(e){if(e instanceof he){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=Ne.create(le(a))}return new he({...e._def,shape:()=>t})}return e instanceof ue?new ue({...e._def,type:le(e.element)}):e instanceof Ne?Ne.create(le(e.unwrap())):e instanceof Ae?Ae.create(le(e.unwrap())):e instanceof ve?ve.create(e.items.map(e=>le(e))):e}ue.create=(e,t)=>new ue({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ve.ZodArray,...O(t)});class he extends j{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const t=this._def.shape(),s=e.objectKeys(t);return this._cached={shape:t,keys:s}}_parse(e){if(this._getType(e)!==s.object){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.object,received:t.parsedType}),h}const{status:t,ctx:a}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof de&&"strip"===this._def.unknownKeys))for(const e in a.data)i.includes(e)||o.push(e);const d=[];for(const e of i){const t=r[e],s=a.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new Z(a,s,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof de){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)d.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)o.length>0&&(u(a,{code:n.unrecognized_keys,keys:o}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of o){const s=a.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new Z(a,s,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of d){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e}).then(e=>l.mergeObjectSync(t,e)):l.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new he({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{var a,n,r,i;const o=null!==(r=null===(n=(a=this._def).errorMap)||void 0===n?void 0:n.call(a,t,s).message)&&void 0!==r?r:s.defaultError;return"unrecognized_keys"===t.code?{message:null!==(i=k.errToObj(e).message)&&void 0!==i?i:o}:{message:o}}}:{}})}strip(){return new he({...this._def,unknownKeys:"strip"})}passthrough(){return new he({...this._def,unknownKeys:"passthrough"})}extend(e){return new he({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new he({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ve.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new he({...this._def,catchall:e})}pick(t){const s={};return e.objectKeys(t).forEach(e=>{t[e]&&this.shape[e]&&(s[e]=this.shape[e])}),new he({...this._def,shape:()=>s})}omit(t){const s={};return e.objectKeys(this.shape).forEach(e=>{t[e]||(s[e]=this.shape[e])}),new he({...this._def,shape:()=>s})}deepPartial(){return le(this)}partial(t){const s={};return e.objectKeys(this.shape).forEach(e=>{const a=this.shape[e];t&&!t[e]?s[e]=a:s[e]=a.optional()}),new he({...this._def,shape:()=>s})}required(t){const s={};return e.objectKeys(this.shape).forEach(e=>{if(t&&!t[e])s[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ne;)t=t._def.innerType;s[e]=t}}),new he({...this._def,shape:()=>s})}keyof(){return Te(e.objectKeys(this.shape))}}he.create=(e,t)=>new he({shape:()=>e,unknownKeys:"strip",catchall:de.create(),typeName:Ve.ZodObject,...O(t)}),he.strictCreate=(e,t)=>new he({shape:()=>e,unknownKeys:"strict",catchall:de.create(),typeName:Ve.ZodObject,...O(t)}),he.lazycreate=(e,t)=>new he({shape:e,unknownKeys:"strip",catchall:de.create(),typeName:Ve.ZodObject,...O(t)});class pe extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map(async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map(e=>new r(e.ctx.common.issues));return u(t,{code:n.invalid_union,unionErrors:s}),h});{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=a.map(e=>new r(e));return u(t,{code:n.invalid_union,unionErrors:i}),h}}get options(){return this._def.options}}pe.create=(e,t)=>new pe({options:e,typeName:Ve.ZodUnion,...O(t)});const me=t=>t instanceof we?me(t.schema):t instanceof Ce?me(t.innerType()):t instanceof Ze?[t.value]:t instanceof Oe?t.options:t instanceof je?e.objectValues(t.enum):t instanceof Ee?me(t._def.innerType):t instanceof ne?[void 0]:t instanceof re?[null]:t instanceof Ne?[void 0,...me(t.unwrap())]:t instanceof Ae?[null,...me(t.unwrap())]:t instanceof $e||t instanceof Fe?me(t.unwrap()):t instanceof Ie?me(t._def.innerType):[];class fe extends j{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.object)return u(t,{code:n.invalid_type,expected:s.object,received:t.parsedType}),h;const a=this.discriminator,r=t.data[a],i=this.optionsMap.get(r);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}):(u(t,{code:n.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),h)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=me(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new fe({typeName:Ve.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...O(s)})}}function ye(t,n){const r=a(t),i=a(n);if(t===n)return{valid:!0,data:t};if(r===s.object&&i===s.object){const s=e.objectKeys(n),a=e.objectKeys(t).filter(e=>-1!==s.indexOf(e)),r={...t,...n};for(const e of a){const s=ye(t[e],n[e]);if(!s.valid)return{valid:!1};r[e]=s.data}return{valid:!0,data:r}}if(r===s.array&&i===s.array){if(t.length!==n.length)return{valid:!1};const e=[];for(let s=0;s<t.length;s++){const a=ye(t[s],n[s]);if(!a.valid)return{valid:!1};e.push(a.data)}return{valid:!0,data:e}}return r===s.date&&i===s.date&&+t===+n?{valid:!0,data:t}:{valid:!1}}class ge extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(f(e)||f(a))return h;const r=ye(e.value,a.value);return r.valid?((y(e)||y(a))&&t.dirty(),{status:t.value,value:r.data}):(u(s,{code:n.invalid_intersection_types}),h)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([e,t])=>a(e,t)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ge.create=(e,t,s)=>new ge({left:e,right:t,typeName:Ve.ZodIntersection,...O(s)});class ve extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.array)return u(a,{code:n.invalid_type,expected:s.array,received:a.parsedType}),h;if(a.data.length<this._def.items.length)return u(a,{code:n.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&a.data.length>this._def.items.length&&(u(a,{code:n.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...a.data].map((e,t)=>{const s=this._def.items[t]||this._def.rest;return s?s._parse(new Z(a,e,a.path,t)):null}).filter(e=>!!e);return a.common.async?Promise.all(r).then(e=>l.mergeArray(t,e)):l.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ve({...this._def,rest:e})}}ve.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ve({items:e,typeName:Ve.ZodTuple,rest:null,...O(t)})};class _e extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.object)return u(a,{code:n.invalid_type,expected:s.object,received:a.parsedType}),h;const r=[],i=this._def.keyType,o=this._def.valueType;for(const e in a.data)r.push({key:i._parse(new Z(a,e,a.path,e)),value:o._parse(new Z(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?l.mergeObjectAsync(t,r):l.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return new _e(t instanceof j?{keyType:e,valueType:t,typeName:Ve.ZodRecord,...O(s)}:{keyType:G.create(),valueType:e,typeName:Ve.ZodRecord,...O(t)})}}class be extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.map)return u(a,{code:n.invalid_type,expected:s.map,received:a.parsedType}),h;const r=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map(([e,t],s)=>({key:r._parse(new Z(a,e,a.path,[s,"key"])),value:i._parse(new Z(a,t,a.path,[s,"value"]))}));if(a.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const s of o){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}})}{const e=new Map;for(const s of o){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}be.create=(e,t,s)=>new be({valueType:t,keyType:e,typeName:Ve.ZodMap,...O(s)});class ke extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.set)return u(a,{code:n.invalid_type,expected:s.set,received:a.parsedType}),h;const r=this._def;null!==r.minSize&&a.data.size<r.minSize.value&&(u(a,{code:n.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&a.data.size>r.maxSize.value&&(u(a,{code:n.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function o(e){const s=new Set;for(const a of e){if("aborted"===a.status)return h;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const d=[...a.data.values()].map((e,t)=>i._parse(new Z(a,e,a.path,t)));return a.common.async?Promise.all(d).then(e=>o(e)):o(d)}min(e,t){return new ke({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new ke({...this._def,maxSize:{value:e,message:k.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ke.create=(e,t)=>new ke({valueType:e,minSize:null,maxSize:null,typeName:Ve.ZodSet,...O(t)});class xe extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.function)return u(t,{code:n.invalid_type,expected:s.function,received:t.parsedType}),h;function a(e,s){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,d(),i].filter(e=>!!e),issueData:{code:n.invalid_arguments,argumentsError:s}})}function o(e,s){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,d(),i].filter(e=>!!e),issueData:{code:n.invalid_return_type,returnTypeError:s}})}const l={errorMap:t.common.contextualErrorMap},p=t.data;if(this._def.returns instanceof Se){const e=this;return m(async function(...t){const s=new r([]),n=await e._def.args.parseAsync(t,l).catch(e=>{throw s.addIssue(a(t,e)),s}),i=await Reflect.apply(p,this,n);return await e._def.returns._def.type.parseAsync(i,l).catch(e=>{throw s.addIssue(o(i,e)),s})})}{const e=this;return m(function(...t){const s=e._def.args.safeParse(t,l);if(!s.success)throw new r([a(t,s.error)]);const n=Reflect.apply(p,this,s.data),i=e._def.returns.safeParse(n,l);if(!i.success)throw new r([o(n,i.error)]);return i.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new xe({...this._def,args:ve.create(e).rest(oe.create())})}returns(e){return new xe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new xe({args:e||ve.create([]).rest(oe.create()),returns:t||oe.create(),typeName:Ve.ZodFunction,...O(s)})}}class we extends j{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})}}we.create=(e,t)=>new we({getter:e,typeName:Ve.ZodLazy,...O(t)});class Ze extends j{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:n.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Te(e,t){return new Oe({values:e,typeName:Ve.ZodEnum,...O(t)})}Ze.create=(e,t)=>new Ze({value:e,typeName:Ve.ZodLiteral,...O(t)});class Oe extends j{constructor(){super(...arguments),x.set(this,void 0)}_parse(t){if("string"!=typeof t.data){const s=this._getOrReturnCtx(t),a=this._def.values;return u(s,{expected:e.joinValues(a),received:s.parsedType,code:n.invalid_type}),h}if(_(this,x,"f")||b(this,x,new Set(this._def.values),"f"),!_(this,x,"f").has(t.data)){const e=this._getOrReturnCtx(t),s=this._def.values;return u(e,{received:e.data,code:n.invalid_enum_value,options:s}),h}return m(t.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 Oe.create(e,{...this._def,...t})}exclude(e,t=this._def){return Oe.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}x=new WeakMap,Oe.create=Te;class je extends j{constructor(){super(...arguments),w.set(this,void 0)}_parse(t){const a=e.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==s.string&&r.parsedType!==s.number){const t=e.objectValues(a);return u(r,{expected:e.joinValues(t),received:r.parsedType,code:n.invalid_type}),h}if(_(this,w,"f")||b(this,w,new Set(e.getValidEnumValues(this._def.values)),"f"),!_(this,w,"f").has(t.data)){const t=e.objectValues(a);return u(r,{received:r.data,code:n.invalid_enum_value,options:t}),h}return m(t.data)}get enum(){return this._def.values}}w=new WeakMap,je.create=(e,t)=>new je({values:e,typeName:Ve.ZodNativeEnum,...O(t)});class Se extends j{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.promise&&!1===t.common.async)return u(t,{code:n.invalid_type,expected:s.promise,received:t.parsedType}),h;const a=t.parsedType===s.promise?t.data:Promise.resolve(t.data);return m(a.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Se.create=(e,t)=>new Se({type:e,typeName:Ve.ZodPromise,...O(t)});class Ce extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ve.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:s,ctx:a}=this._processInputParams(t),n=this._def.effect||null,r={addIssue:e=>{u(a,e),e.fatal?s.abort():s.dirty()},get path(){return a.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){const e=n.transform(a.data,r);if(a.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===s.value)return h;const t=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===t.status?h:"dirty"===t.status||"dirty"===s.value?p(t.value):t});{if("aborted"===s.value)return h;const t=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===t.status?h:"dirty"===t.status||"dirty"===s.value?p(t.value):t}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,r);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const t=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===t.status?h:("dirty"===t.status&&s.dirty(),e(t.value),{status:s.value,value:t.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(t=>"aborted"===t.status?h:("dirty"===t.status&&s.dirty(),e(t.value).then(()=>({status:s.value,value:t.value}))))}if("transform"===n.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!g(e))return e;const t=n.transform(e.value,r);if(t instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:t}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>g(e)?Promise.resolve(n.transform(e.value,r)).then(e=>({status:s.value,value:e})):e)}e.assertNever(n)}}Ce.create=(e,t,s)=>new Ce({schema:e,typeName:Ve.ZodEffects,effect:t,...O(s)}),Ce.createWithPreprocess=(e,t,s)=>new Ce({schema:t,effect:{type:"preprocess",transform:e},typeName:Ve.ZodEffects,...O(s)});class Ne extends j{_parse(e){return this._getType(e)===s.undefined?m(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ne.create=(e,t)=>new Ne({innerType:e,typeName:Ve.ZodOptional,...O(t)});class Ae extends j{_parse(e){return this._getType(e)===s.null?m(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ae.create=(e,t)=>new Ae({innerType:e,typeName:Ve.ZodNullable,...O(t)});class Ee extends j{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===s.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ee.create=(e,t)=>new Ee({innerType:e,typeName:Ve.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...O(t)});class Ie extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return v(a)?a.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new r(s.common.issues)},input:s.data})})):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new r(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ie.create=(e,t)=>new Ie({innerType:e,typeName:Ve.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...O(t)});class Pe extends j{_parse(e){if(this._getType(e)!==s.nan){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.nan,received:t.parsedType}),h}return{status:"valid",value:e.data}}}Pe.create=e=>new Pe({typeName:Ve.ZodNaN,...O(e)});const Re=Symbol("zod_brand");class $e extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Me extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),p(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})()}{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new Me({in:e,out:t,typeName:Ve.ZodPipeline})}}class Fe extends j{_parse(e){const t=this._def.innerType._parse(e),s=e=>(g(e)&&(e.value=Object.freeze(e.value)),e);return v(t)?t.then(e=>s(e)):s(t)}unwrap(){return this._def.innerType}}function De(e,t){const s="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof s?{message:s}:s}function Le(e,t={},s){return e?ie.create().superRefine((a,n)=>{var r,i;const o=e(a);if(o instanceof Promise)return o.then(e=>{var r,i;if(!e){const e=De(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}});if(!o){const e=De(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}}):ie.create()}Fe.create=(e,t)=>new Fe({innerType:e,typeName:Ve.ZodReadonly,...O(t)});const ze={object:he.lazycreate};var Ve;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Ve||(Ve={}));const Ue=G.create,Ke=Q.create,qe=Pe.create,Be=ee.create,We=te.create,Je=se.create,He=ae.create,Ye=ne.create,Ge=re.create,Xe=ie.create,Qe=oe.create,et=de.create,tt=ce.create,st=ue.create,at=he.create,nt=he.strictCreate,rt=pe.create,it=fe.create,ot=ge.create,dt=ve.create,ct=_e.create,ut=be.create,lt=ke.create,ht=xe.create,pt=we.create,mt=Ze.create,ft=Oe.create,yt=je.create,gt=Se.create,vt=Ce.create,_t=Ne.create,bt=Ae.create,kt=Ce.createWithPreprocess,xt=Me.create,wt={string:e=>G.create({...e,coerce:!0}),number:e=>Q.create({...e,coerce:!0}),boolean:e=>te.create({...e,coerce:!0}),bigint:e=>ee.create({...e,coerce:!0}),date:e=>se.create({...e,coerce:!0})},Zt=h;var Tt=Object.freeze({__proto__:null,defaultErrorMap:i,setErrorMap:function(e){o=e},getErrorMap:d,makeIssue:c,EMPTY_PATH:[],addIssueToContext:u,ParseStatus:l,INVALID:h,DIRTY:p,OK:m,isAborted:f,isDirty:y,isValid:g,isAsync:v,get util(){return e},get objectUtil(){return t},ZodParsedType:s,getParsedType:a,ZodType:j,datetimeRegex:W,ZodString:G,ZodNumber:Q,ZodBigInt:ee,ZodBoolean:te,ZodDate:se,ZodSymbol:ae,ZodUndefined:ne,ZodNull:re,ZodAny:ie,ZodUnknown:oe,ZodNever:de,ZodVoid:ce,ZodArray:ue,ZodObject:he,ZodUnion:pe,ZodDiscriminatedUnion:fe,ZodIntersection:ge,ZodTuple:ve,ZodRecord:_e,ZodMap:be,ZodSet:ke,ZodFunction:xe,ZodLazy:we,ZodLiteral:Ze,ZodEnum:Oe,ZodNativeEnum:je,ZodPromise:Se,ZodEffects:Ce,ZodTransformer:Ce,ZodOptional:Ne,ZodNullable:Ae,ZodDefault:Ee,ZodCatch:Ie,ZodNaN:Pe,BRAND:Re,ZodBranded:$e,ZodPipeline:Me,ZodReadonly:Fe,custom:Le,Schema:j,ZodSchema:j,late:ze,get ZodFirstPartyTypeKind(){return Ve},coerce:wt,any:Xe,array:st,bigint:Be,boolean:We,date:Je,discriminatedUnion:it,effect:vt,enum:ft,function:ht,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>Le(t=>t instanceof e,t),intersection:ot,lazy:pt,literal:mt,map:ut,nan:qe,nativeEnum:yt,never:et,null:Ge,nullable:bt,number:Ke,object:at,oboolean:()=>We().optional(),onumber:()=>Ke().optional(),optional:_t,ostring:()=>Ue().optional(),pipeline:xt,preprocess:kt,promise:gt,record:ct,set:lt,strictObject:nt,string:Ue,symbol:He,transformer:vt,tuple:dt,undefined:Ye,union:rt,unknown:Qe,void:tt,NEVER:Zt,ZodIssueCode:n,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:r}),Ot=["interface","display","layout","module","panel","theme"],jt=["hook","endpoint"],St=["operation"],Ct="directus:extension",Nt=Tt.object({app:Tt.string(),api:Tt.string()}),At=Tt.object({request:Tt.optional(Tt.object({urls:Tt.array(Tt.string()),methods:Tt.array(Tt.union([Tt.literal("GET"),Tt.literal("POST"),Tt.literal("PATCH"),Tt.literal("PUT"),Tt.literal("DELETE")]))})),log:Tt.optional(Tt.object({})),sleep:Tt.optional(Tt.object({}))}),Et=Tt.optional(Tt.object({enabled:Tt.boolean(),requestedScopes:At})),It=Tt.union([Tt.object({type:Tt.enum(jt),name:Tt.string(),source:Tt.string()}),Tt.object({type:Tt.enum(Ot),name:Tt.string(),source:Tt.string()}),Tt.object({type:Tt.enum(St),name:Tt.string(),source:Nt})]),Pt=Tt.object({host:Tt.string(),hidden:Tt.boolean().optional()}),Rt=Tt.object({type:Tt.enum(Ot),path:Tt.string(),source:Tt.string()}),$t=Tt.object({type:Tt.enum(jt),path:Tt.string(),source:Tt.string(),sandbox:Et}),Mt=Tt.object({type:Tt.enum(St),path:Nt,source:Nt,sandbox:Et}),Ft=Tt.object({type:Tt.literal("bundle"),partial:Tt.boolean().optional(),path:Nt,entries:Tt.array(It)});Tt.array(It);var Dt=Pt.and(Tt.union([Rt,$t,Mt,Ft]));Tt.object({name:Tt.string(),version:Tt.string(),type:Tt.union([Tt.literal("module"),Tt.literal("commonjs")]).optional(),description:Tt.string().optional(),icon:Tt.string().optional(),dependencies:Tt.record(Tt.string()).optional(),devDependencies:Tt.record(Tt.string()).optional(),[Ct]:Dt});const{findWorkspaceDir:Lt}=require("@pnpm/find-workspace-dir"),zt=require("js-yaml"),Vt=require("path"),Ut=require("fs"),Kt=()=>process.cwd(),qt=process.env.EXTENSIONS_PATH||"./extensions";let Bt;async function Wt(e,t){if(Bt)return JSON.parse(Bt);const{SpecificationService:s}=e,a=new s({accountability:{admin:!0},schema:t});return Bt=JSON.stringify(await a.oas.generate()),JSON.parse(Bt)}function Jt(e,t){return Object.entries(t).reduce((e,[t,s])=>(e[t]=s&&"object"==typeof s?Jt(e[t]=e[t]||(Array.isArray(s)?[]:{}),s):s,e),e)}const Ht=require("swagger-ui-express"),Yt=require("express-openapi-validator"),Gt=function(){const e=function(){const e={docsPath:"api-docs",info:{},tags:[],publishedTags:[],paths:{},components:{}};try{let t;try{const e=Vt.join(Kt(),qt,"/oasconfig.yaml");t=zt.load(Ut.readFileSync(e,{encoding:"utf-8"}))}catch{const e=Vt.join(Kt(),qt,"/endpoints/oasconfig.yaml");t=zt.load(Ut.readFileSync(e,{encoding:"utf-8"}))}return t.docsPath=t.docsPath||e.docsPath,t.info=t.info||e.info,t.tags=t.tags||e.tags,t.paths=t.paths||e.paths,t.components=t.components||e.components,t}catch{return e}}();try{const t=t=>{const s=zt.load(Ut.readFileSync(t,{encoding:"utf-8"}));e.tags=[...e.tags,...s.tags||[]],e.paths={...e.paths,...s.paths||{}},e.components=Jt(e.components||{},s.components||{})},s=Vt.join(Kt(),qt),a=Ut.readdirSync(s,{withFileTypes:!0});for(const e of a){const a=`${s}/${e.name}/oas.yaml`;e.isDirectory()&&Ut.existsSync(a)&&t(a)}const n=Vt.join(Kt(),qt,"/endpoints"),r=Ut.readdirSync(n,{withFileTypes:!0});for(const e of r){const s=`${n}/${e.name}/oas.yaml`;e.isDirectory()&&Ut.existsSync(s)&&t(s)}return e}catch(t){return e}}(),Xt=Gt.docsPath;var Qt={id:Xt,validate:async function(e,t,s,a){if(Gt?.paths){const n=await Wt(t,s);if(a)for(const e of a)n.paths[e]=Gt.paths[e];else n.paths=Gt.paths;Gt.components?n.components=Gt.components:(delete n.components.definitions,delete n.components.schemas),e.use(Yt.middleware({apiSpec:n})),e.use((e,t,s,a)=>{s.status(e.status||500).json({message:e.message,errors:e.errors})})}return e},handler:(e,{services:t,logger:s,getSchema:a})=>{const n={swaggerOptions:{url:`/${Xt}/oas`}};e.use("/",Ht.serve),e.get("/",Ht.setup({},n)),e.get("/oas",async(e,n,r)=>{try{const e=await a(),r=await Wt(t,e),i=await async function(){try{const e=await Lt(".");return require(`${e||Kt()}/package.json`)}catch(e){return{}}}();r.info.title=Gt.info.title||i?.name||r.info.title,r.info.version=Gt.info.version||i?.version||r.info.version,r.info.description=Gt.info.description||i?.description||r.info.description;try{for(const e in Gt.paths)r.paths[e]=Gt.paths[e];for(const e of Gt.tags)r.tags.push(e);r.components=Jt(Gt.components,r.components)}catch(e){s.info("No custom definitions")}Gt.publishedTags?.length&&function(e,t){for(const s in t.paths)for(const a in t.paths[s]){let n=!1;const r=t.paths[s][a].tags||[];r.forEach(t=>{n=n||e.publishedTags.includes(t)}),t.paths[s][a].tags=r.filter(t=>e.publishedTags.includes(t)),n||delete t.paths[s][a]}t.tags=t.tags.filter(t=>e.publishedTags.includes(t.name))}(Gt,r),n.json(r)}catch(e){return r(new Error(e.message||e[0].message))}})}};module.exports=Qt;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "directus-extension-api-docs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.13",
|
|
4
4
|
"description": "directus extension for swagger interface and openapi including custom endpoints definitions // custom endpoint validations middleware based on openapi",
|
|
5
5
|
"licence": "MIT",
|
|
6
6
|
"icon": "api",
|
|
@@ -40,32 +40,32 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@pnpm/find-workspace-dir": "^7.0.3",
|
|
43
|
-
"express-openapi-validator": "^5.
|
|
43
|
+
"express-openapi-validator": "^5.5.8",
|
|
44
44
|
"js-yaml": "^4.1.0",
|
|
45
45
|
"swagger-ui-express": "^5.0.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@directus/extensions-sdk": "^13.
|
|
48
|
+
"@directus/extensions-sdk": "^13.1.1",
|
|
49
49
|
"@directus/types": "^12.2.2",
|
|
50
|
-
"@types/express": "^4.17.
|
|
50
|
+
"@types/express": "^4.17.23",
|
|
51
51
|
"@types/jest": "^29.5.14",
|
|
52
|
-
"@types/node": "^18.19.
|
|
52
|
+
"@types/node": "^18.19.123",
|
|
53
53
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
54
54
|
"@typescript-eslint/parser": "^5.62.0",
|
|
55
55
|
"eslint": "^8.57.1",
|
|
56
|
-
"eslint-config-prettier": "^8.10.
|
|
57
|
-
"eslint-plugin-import": "^2.
|
|
58
|
-
"eslint-plugin-prettier": "^4.2.
|
|
56
|
+
"eslint-config-prettier": "^8.10.2",
|
|
57
|
+
"eslint-plugin-import": "^2.32.0",
|
|
58
|
+
"eslint-plugin-prettier": "^4.2.5",
|
|
59
59
|
"express": "^4.21.2",
|
|
60
60
|
"jest": "^29.7.0",
|
|
61
61
|
"jest-extended": "^3.2.4",
|
|
62
62
|
"openapi-schema-validator": "^12.1.3",
|
|
63
63
|
"pinia": "^2.3.1",
|
|
64
|
-
"pino": "^9.
|
|
64
|
+
"pino": "^9.9.0",
|
|
65
65
|
"prettier": "^2.8.8",
|
|
66
|
-
"ts-jest": "^29.
|
|
66
|
+
"ts-jest": "^29.4.1",
|
|
67
67
|
"ts-node": "^10.9.2",
|
|
68
68
|
"typescript": "^4.9.5",
|
|
69
|
-
"vue": "^3.5.
|
|
69
|
+
"vue": "^3.5.19"
|
|
70
70
|
}
|
|
71
71
|
}
|