UNPKG

@directus-labs/liquidjs-operation

Version:

Render Liquid templates within Directus flows.

1 lines 137 kB
import{request as e}from"directus:api";var t,s;!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]])),i={};for(const e of s)i[e]=t[e];return e.objectValues(i)},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}(t||(t={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(s||(s={}));const i=t.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),n=e=>{switch(typeof e){case"undefined":return i.undefined;case"string":return i.string;case"number":return isNaN(e)?i.nan:i.number;case"boolean":return i.boolean;case"function":return i.function;case"bigint":return i.bigint;case"symbol":return i.symbol;case"object":return Array.isArray(e)?i.array:null===e?i.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?i.promise:"undefined"!=typeof Map&&e instanceof Map?i.map:"undefined"!=typeof Set&&e instanceof Set?i.set:"undefined"!=typeof Date&&e instanceof Date?i.date:i.object;default:return i.unknown}},r=t.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 a 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:[]},i=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(i);else if("invalid_return_type"===n.code)i(n.returnTypeError);else if("invalid_arguments"===n.code)i(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,i=0;for(;i<n.path.length;){const s=n.path[i];i===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],i++}}};return i(this),s}static assert(e){if(!(e instanceof a))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,t.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):s.push(e(i));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}a.create=e=>new a(e);const o=(e,s)=>{let n;switch(e.code){case r.invalid_type:n=e.received===i.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case r.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,t.jsonStringifyReplacer)}`;break;case r.unrecognized_keys:n=`Unrecognized key(s) in object: ${t.joinValues(e.keys,", ")}`;break;case r.invalid_union:n="Invalid input";break;case r.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${t.joinValues(e.options)}`;break;case r.invalid_enum_value:n=`Invalid enum value. Expected ${t.joinValues(e.options)}, received '${e.received}'`;break;case r.invalid_arguments:n="Invalid function arguments";break;case r.invalid_return_type:n="Invalid function return type";break;case r.invalid_date:n="Invalid date";break;case r.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:t.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case r.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case r.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case r.custom:n="Invalid input";break;case r.invalid_intersection_types:n="Intersection results could not be merged";break;case r.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case r.not_finite:n="Number must be finite";break;default:n=s.defaultError,t.assertNever(e)}return{message:n}};let l=o;function c(){return l}const u=e=>{const{data:t,path:s,errorMaps:i,issueData:n}=e,r=[...s,...n.path||[]],a={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const l=i.filter((e=>!!e)).slice().reverse();for(const e of l)o=e(a,{data:t,defaultError:o}).message;return{...n,path:r,message:o}};function d(e,t){const s=c(),i=u({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===o?void 0:o].filter((e=>!!e))});e.common.issues.push(i)}class h{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 i of t){if("aborted"===i.status)return p;"dirty"===i.status&&e.dirty(),s.push(i.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,i=await e.value;s.push({key:t,value:i})}return h.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const i of t){const{key:t,value:n}=i;if("aborted"===t.status)return p;if("aborted"===n.status)return p;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!i.alwaysSet||(s[t.value]=n.value)}return{status:e.value,value:s}}}const p=Object.freeze({status:"aborted"}),f=e=>({status:"dirty",value:e}),m=e=>({status:"valid",value:e}),g=e=>"aborted"===e.status,y=e=>"dirty"===e.status,v=e=>"valid"===e.status,_=e=>"undefined"!=typeof Promise&&e instanceof Promise;function b(e,t,s,i){if("a"===s&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?i:"a"===s?i.call(e):i?i.value:t.get(e)}function k(e,t,s,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!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"===i?n.call(e,s):n?n.value=s:t.set(e,s),s}var w,x,T;"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}(w||(w={}));class O{constructor(e,t,s,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const S=(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 a(e.common.issues);return this._error=t,this._error}}};function j(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:i,description:n}=e;if(t&&(s||i))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,a;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:i)&&void 0!==r?r:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(a=null!=o?o:s)&&void 0!==a?a:n.defaultError}},description:n}}class A{get description(){return this._def.description}_getType(e){return n(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:n(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new h,ctx:{common:e.parent.common,data:e.data,parsedType:n(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(_(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 i={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:n(e)},r=this._parseSync({data:e,path:i.path,parent:i});return S(i,r)}"~validate"(e){var t,s;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:n(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:i});return v(t)?{value:t.value}:{issues:i.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),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then((e=>v(e)?{value:e.value}:{issues:i.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:n(e)},i=this._parse({data:e,path:s.path,parent:s}),r=await(_(i)?i:Promise.resolve(i));return S(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,i)=>{const n=e(t),a=()=>i.addIssue({code:r.custom,...s(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(a(),!1))):!!n||(a(),!1)}))}refinement(e,t){return this._refinement(((s,i)=>!!e(s)||(i.addIssue("function"==typeof t?t(s,i):t),!1)))}_refinement(e){return new Ae({schema:this,typeName:Pe.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 Ee.create(this,this._def)}nullable(){return Fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ce.create(this)}promise(){return je.create(this,this._def)}or(e){return he.create([this,e],this._def)}and(e){return ge.create(this,e,this._def)}transform(e){return new Ae({...j(this._def),schema:this,typeName:Pe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ne({...j(this._def),innerType:this,defaultValue:t,typeName:Pe.ZodDefault})}brand(){return new Ce({typeName:Pe.ZodBranded,type:this,...j(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Le({...j(this._def),innerType:this,catchValue:t,typeName:Pe.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return ze.create(this,e)}readonly(){return $e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const E=/^c[^\s-]{8,}$/i,F=/^[0-9a-z]+$/,N=/^[0-9A-HJKMNP-TV-Z]{26}$/i,L=/^[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,Z=/^[a-z0-9_-]{21}$/i,R=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,C=/^[-+]?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)?)??$/,z=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let $;const I=/^(?:(?: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])$/,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])\/(3[0-2]|[12]?[0-9])$/,P=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,V=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,q=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,B="((\\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])))",U=new RegExp(`^${B}$`);function H(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 W(e){let t=`${B}T${H(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 K(e,t){if(!R.test(e))return!1;try{const[s]=e.split("."),i=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(i));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||!M.test(e))||!("v6"!==t&&t||!D.test(e))}class J extends A{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==i.string){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.string,received:t.parsedType}),p}const s=new h;let n;for(const i of this._def.checks)if("min"===i.kind)e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:r.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if("max"===i.kind)e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:r.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if("length"===i.kind){const t=e.data.length>i.value,a=e.data.length<i.value;(t||a)&&(n=this._getOrReturnCtx(e,n),t?d(n,{code:r.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&d(n,{code:r.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if("email"===i.kind)z.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"email",code:r.invalid_string,message:i.message}),s.dirty());else if("emoji"===i.kind)$||($=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),$.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"emoji",code:r.invalid_string,message:i.message}),s.dirty());else if("uuid"===i.kind)L.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"uuid",code:r.invalid_string,message:i.message}),s.dirty());else if("nanoid"===i.kind)Z.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"nanoid",code:r.invalid_string,message:i.message}),s.dirty());else if("cuid"===i.kind)E.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"cuid",code:r.invalid_string,message:i.message}),s.dirty());else if("cuid2"===i.kind)F.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"cuid2",code:r.invalid_string,message:i.message}),s.dirty());else if("ulid"===i.kind)N.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"ulid",code:r.invalid_string,message:i.message}),s.dirty());else if("url"===i.kind)try{new URL(e.data)}catch(t){n=this._getOrReturnCtx(e,n),d(n,{validation:"url",code:r.invalid_string,message:i.message}),s.dirty()}else if("regex"===i.kind){i.regex.lastIndex=0;i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"regex",code:r.invalid_string,message:i.message}),s.dirty())}else if("trim"===i.kind)e.data=e.data.trim();else if("includes"===i.kind)e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),d(n,{code:r.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),s.dirty());else if("toLowerCase"===i.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===i.kind)e.data=e.data.toUpperCase();else if("startsWith"===i.kind)e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),d(n,{code:r.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty());else if("endsWith"===i.kind)e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),d(n,{code:r.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty());else if("datetime"===i.kind){W(i).test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:r.invalid_string,validation:"datetime",message:i.message}),s.dirty())}else if("date"===i.kind){U.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:r.invalid_string,validation:"date",message:i.message}),s.dirty())}else if("time"===i.kind){new RegExp(`^${H(i)}$`).test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:r.invalid_string,validation:"time",message:i.message}),s.dirty())}else"duration"===i.kind?C.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"duration",code:r.invalid_string,message:i.message}),s.dirty()):"ip"===i.kind?(a=e.data,("v4"!==(o=i.version)&&o||!I.test(a))&&("v6"!==o&&o||!P.test(a))&&(n=this._getOrReturnCtx(e,n),d(n,{validation:"ip",code:r.invalid_string,message:i.message}),s.dirty())):"jwt"===i.kind?K(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"jwt",code:r.invalid_string,message:i.message}),s.dirty()):"cidr"===i.kind?Y(e.data,i.version)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"cidr",code:r.invalid_string,message:i.message}),s.dirty()):"base64"===i.kind?V.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"base64",code:r.invalid_string,message:i.message}),s.dirty()):"base64url"===i.kind?q.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"base64url",code:r.invalid_string,message:i.message}),s.dirty()):t.assertNever(i);var a,o;return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:r.invalid_string,...w.errToObj(s)})}_addCheck(e){return new J({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...w.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...w.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,...w.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,...w.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...w.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new J({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new J({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new J({...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 Q(e,t){const s=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=s>i?s:i;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}J.create=e=>{var t;return new J({checks:[],typeName:Pe.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...j(e)})};class G extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==i.number){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.number,received:t.parsedType}),p}let s;const n=new h;for(const i of this._def.checks)if("int"===i.kind)t.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:r.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty());else if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:r.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:r.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty())}else"multipleOf"===i.kind?0!==Q(e.data,i.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:r.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:r.not_finite,message:i.message}),n.dirty()):t.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,s,i){return new G({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:w.toString(i)}]})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"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((e=>"int"===e.kind||"multipleOf"===e.kind&&t.isInteger(e.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:Pe.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...j(e)});class X extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(t){return this._getInvalidInput(e)}if(this._getType(e)!==i.bigint)return this._getInvalidInput(e);let s;const n=new h;for(const i of this._def.checks)if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:r.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:r.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),d(s,{code:r.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):t.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.bigint,received:t.parsedType}),p}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,s,i){return new X({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:w.toString(i)}]})}_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:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"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:Pe.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...j(e)})};class ee extends A{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==i.boolean){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.boolean,received:t.parsedType}),p}return m(e.data)}}ee.create=e=>new ee({typeName:Pe.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...j(e)});class te extends A{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==i.date){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.date,received:t.parsedType}),p}if(isNaN(e.data.getTime())){return d(this._getOrReturnCtx(e),{code:r.invalid_date}),p}const s=new h;let n;for(const i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:r.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),s.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:r.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):t.assertNever(i);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new te({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"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}}te.create=e=>new te({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Pe.ZodDate,...j(e)});class se extends A{_parse(e){if(this._getType(e)!==i.symbol){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.symbol,received:t.parsedType}),p}return m(e.data)}}se.create=e=>new se({typeName:Pe.ZodSymbol,...j(e)});class ie extends A{_parse(e){if(this._getType(e)!==i.undefined){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.undefined,received:t.parsedType}),p}return m(e.data)}}ie.create=e=>new ie({typeName:Pe.ZodUndefined,...j(e)});class ne extends A{_parse(e){if(this._getType(e)!==i.null){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.null,received:t.parsedType}),p}return m(e.data)}}ne.create=e=>new ne({typeName:Pe.ZodNull,...j(e)});class re extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}}re.create=e=>new re({typeName:Pe.ZodAny,...j(e)});class ae extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}}ae.create=e=>new ae({typeName:Pe.ZodUnknown,...j(e)});class oe extends A{_parse(e){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.never,received:t.parsedType}),p}}oe.create=e=>new oe({typeName:Pe.ZodNever,...j(e)});class le extends A{_parse(e){if(this._getType(e)!==i.undefined){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.void,received:t.parsedType}),p}return m(e.data)}}le.create=e=>new le({typeName:Pe.ZodVoid,...j(e)});class ce extends A{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==i.array)return d(t,{code:r.invalid_type,expected:i.array,received:t.parsedType}),p;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;(e||i)&&(d(t,{code:e?r.too_big:r.too_small,minimum:i?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(d(t,{code:r.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(d(t,{code:r.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map(((e,s)=>n.type._parseAsync(new O(t,e,t.path,s))))).then((e=>h.mergeArray(s,e)));const a=[...t.data].map(((e,s)=>n.type._parseSync(new O(t,e,t.path,s))));return h.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new ce({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new ce({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new ce({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}function ue(e){if(e instanceof de){const t={};for(const s in e.shape){const i=e.shape[s];t[s]=Ee.create(ue(i))}return new de({...e._def,shape:()=>t})}return e instanceof ce?new ce({...e._def,type:ue(e.element)}):e instanceof Ee?Ee.create(ue(e.unwrap())):e instanceof Fe?Fe.create(ue(e.unwrap())):e instanceof ye?ye.create(e.items.map((e=>ue(e)))):e}ce.create=(e,t)=>new ce({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Pe.ZodArray,...j(t)});class de extends A{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),s=t.objectKeys(e);return this._cached={shape:e,keys:s}}_parse(e){if(this._getType(e)!==i.object){const t=this._getOrReturnCtx(e);return d(t,{code:r.invalid_type,expected:i.object,received:t.parsedType}),p}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof oe&&"strip"===this._def.unknownKeys))for(const e in s.data)a.includes(e)||o.push(e);const l=[];for(const e of a){const t=n[e],i=s.data[e];l.push({key:{status:"valid",value:e},value:t._parse(new O(s,i,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof oe){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)l.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)o.length>0&&(d(s,{code:r.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 i=s.data[t];l.push({key:{status:"valid",value:t},value:e._parse(new O(s,i,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of l){const s=await t.key,i=await t.value;e.push({key:s,value:i,alwaysSet:t.alwaysSet})}return e})).then((e=>h.mergeObjectSync(t,e))):h.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new de({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{var i,n,r,a;const o=null!==(r=null===(n=(i=this._def).errorMap)||void 0===n?void 0:n.call(i,t,s).message)&&void 0!==r?r:s.defaultError;return"unrecognized_keys"===t.code?{message:null!==(a=w.errToObj(e).message)&&void 0!==a?a:o}:{message:o}}}:{}})}strip(){return new de({...this._def,unknownKeys:"strip"})}passthrough(){return new de({...this._def,unknownKeys:"passthrough"})}extend(e){return new de({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new de({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Pe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new de({...this._def,catchall:e})}pick(e){const s={};return t.objectKeys(e).forEach((t=>{e[t]&&this.shape[t]&&(s[t]=this.shape[t])})),new de({...this._def,shape:()=>s})}omit(e){const s={};return t.objectKeys(this.shape).forEach((t=>{e[t]||(s[t]=this.shape[t])})),new de({...this._def,shape:()=>s})}deepPartial(){return ue(this)}partial(e){const s={};return t.objectKeys(this.shape).forEach((t=>{const i=this.shape[t];e&&!e[t]?s[t]=i:s[t]=i.optional()})),new de({...this._def,shape:()=>s})}required(e){const s={};return t.objectKeys(this.shape).forEach((t=>{if(e&&!e[t])s[t]=this.shape[t];else{let e=this.shape[t];for(;e instanceof Ee;)e=e._def.innerType;s[t]=e}})),new de({...this._def,shape:()=>s})}keyof(){return Te(t.objectKeys(this.shape))}}de.create=(e,t)=>new de({shape:()=>e,unknownKeys:"strip",catchall:oe.create(),typeName:Pe.ZodObject,...j(t)}),de.strictCreate=(e,t)=>new de({shape:()=>e,unknownKeys:"strict",catchall:oe.create(),typeName:Pe.ZodObject,...j(t)}),de.lazycreate=(e,t)=>new de({shape:e,unknownKeys:"strip",catchall:oe.create(),typeName:Pe.ZodObject,...j(t)});class he extends A{_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 a(e.ctx.common.issues)));return d(t,{code:r.invalid_union,unionErrors:s}),p}));{let e;const i=[];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&&i.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=i.map((e=>new a(e)));return d(t,{code:r.invalid_union,unionErrors:n}),p}}get options(){return this._def.options}}he.create=(e,t)=>new he({options:e,typeName:Pe.ZodUnion,...j(t)});const pe=e=>e instanceof we?pe(e.schema):e instanceof Ae?pe(e.innerType()):e instanceof xe?[e.value]:e instanceof Oe?e.options:e instanceof Se?t.objectValues(e.enum):e instanceof Ne?pe(e._def.innerType):e instanceof ie?[void 0]:e instanceof ne?[null]:e instanceof Ee?[void 0,...pe(e.unwrap())]:e instanceof Fe?[null,...pe(e.unwrap())]:e instanceof Ce||e instanceof $e?pe(e.unwrap()):e instanceof Le?pe(e._def.innerType):[];class fe extends A{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.object)return d(t,{code:r.invalid_type,expected:i.object,received:t.parsedType}),p;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(d(t,{code:r.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),p)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const i=new Map;for(const s of t){const t=pe(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(i.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);i.set(n,s)}}return new fe({typeName:Pe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...j(s)})}}function me(e,s){const r=n(e),a=n(s);if(e===s)return{valid:!0,data:e};if(r===i.object&&a===i.object){const i=t.objectKeys(s),n=t.objectKeys(e).filter((e=>-1!==i.indexOf(e))),r={...e,...s};for(const t of n){const i=me(e[t],s[t]);if(!i.valid)return{valid:!1};r[t]=i.data}return{valid:!0,data:r}}if(r===i.array&&a===i.array){if(e.length!==s.length)return{valid:!1};const t=[];for(let i=0;i<e.length;i++){const n=me(e[i],s[i]);if(!n.valid)return{valid:!1};t.push(n.data)}return{valid:!0,data:t}}return r===i.date&&a===i.date&&+e===+s?{valid:!0,data:e}:{valid:!1}}class ge extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),i=(e,i)=>{if(g(e)||g(i))return p;const n=me(e.value,i.value);return n.valid?((y(e)||y(i))&&t.dirty(),{status:t.value,value:n.data}):(d(s,{code:r.invalid_intersection_types}),p)};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])=>i(e,t))):i(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:Pe.ZodIntersection,...j(s)});class ye extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==i.array)return d(s,{code:r.invalid_type,expected:i.array,received:s.parsedType}),p;if(s.data.length<this._def.items.length)return d(s,{code:r.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),p;!this._def.rest&&s.data.length>this._def.items.length&&(d(s,{code:r.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map(((e,t)=>{const i=this._def.items[t]||this._def.rest;return i?i._parse(new O(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(n).then((e=>h.mergeArray(t,e))):h.mergeArray(t,n)}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:Pe.ZodTuple,rest:null,...j(t)})};class ve extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==i.object)return d(s,{code:r.invalid_type,expected:i.object,received:s.parsedType}),p;const n=[],a=this._def.keyType,o=this._def.valueType;for(const e in s.data)n.push({key:a._parse(new O(s,e,s.path,e)),value:o._parse(new O(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?h.mergeObjectAsync(t,n):h.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return new ve(t instanceof A?{keyType:e,valueType:t,typeName:Pe.ZodRecord,...j(s)}:{keyType:J.create(),valueType:e,typeName:Pe.ZodRecord,...j(t)})}}class _e extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==i.map)return d(s,{code:r.invalid_type,expected:i.map,received:s.parsedType}),p;const n=this._def.keyType,a=this._def.valueType,o=[...s.data.entries()].map((([e,t],i)=>({key:n._parse(new O(s,e,s.path,[i,"key"])),value:a._parse(new O(s,t,s.path,[i,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of o){const i=await s.key,n=await s.value;if("aborted"===i.status||"aborted"===n.status)return p;"dirty"!==i.status&&"dirty"!==n.status||t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const s of o){const i=s.key,n=s.value;if("aborted"===i.status||"aborted"===n.status)return p;"dirty"!==i.status&&"dirty"!==n.status||t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}}}}_e.create=(e,t,s)=>new _e({valueType:t,keyType:e,typeName:Pe.ZodMap,...j(s)});class be extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==i.set)return d(s,{code:r.invalid_type,expected:i.set,received:s.parsedType}),p;const n=this._def;null!==n.minSize&&s.data.size<n.minSize.value&&(d(s,{code:r.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&s.data.size>n.maxSize.value&&(d(s,{code:r.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function o(e){const s=new Set;for(const i of e){if("aborted"===i.status)return p;"dirty"===i.status&&t.dirty(),s.add(i.value)}return{status:t.value,value:s}}const l=[...s.data.values()].map(((e,t)=>a._parse(new O(s,e,s.path,t))));return s.common.async?Promise.all(l).then((e=>o(e))):o(l)}min(e,t){return new be({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new be({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}be.create=(e,t)=>new be({valueType:e,minSize:null,maxSize:null,typeName:Pe.ZodSet,...j(t)});class ke extends A{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.function)return d(t,{code:r.invalid_type,expected:i.function,received:t.parsedType}),p;function s(e,s){return u({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),o].filter((e=>!!e)),issueData:{code:r.invalid_arguments,argumentsError:s}})}function n(e,s){return u({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),o].filter((e=>!!e)),issueData:{code:r.invalid_return_type,returnTypeError:s}})}const l={errorMap:t.common.contextualErrorMap},h=t.data;if(this._def.returns instanceof je){const e=this;return m((async function(...t){const i=new a([]),r=await e._def.args.parseAsync(t,l).catch((e=>{throw i.addIssue(s(t,e)),i})),o=await Reflect.apply(h,this,r);return await e._def.returns._def.type.parseAsync(o,l).catch((e=>{throw i.addIssue(n(o,e)),i}))}))}{const e=this;return m((function(...t){const i=e._def.args.safeParse(t,l);if(!i.success)throw new a([s(t,i.error)]);const r=Reflect.apply(h,this,i.data),o=e._def.returns.safeParse(r,l);if(!o.success)throw new a([n(r,o.error)]);return o.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ke({...this._def,args:ye.create(e).rest(ae.create())})}returns(e){return new ke({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new ke({args:e||ye.create([]).rest(ae.create()),returns:t||ae.create(),typeName:Pe.ZodFunction,...j(s)})}}class we extends A{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:Pe.ZodLazy,...j(t)});class xe extends A{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return d(t,{received:t.data