UNPKG

directus-extension-encrypt-attr

Version:

Please enter a description for your extension

1 lines 131 kB
import e from"crypto";import t from"buffer";var n,r,i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),r={};for(const e of n)r[e]=t[e];return e.objectValues(r)},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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},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}(n||(n={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(r||(r={}));const u=n.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),s=e=>{switch(typeof e){case"undefined":return u.undefined;case"string":return u.string;case"number":return isNaN(e)?u.nan:u.number;case"boolean":return u.boolean;case"function":return u.function;case"bigint":return u.bigint;case"symbol":return u.symbol;case"object":return Array.isArray(e)?u.array:null===e?u.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?u.promise:"undefined"!=typeof Map&&e instanceof Map?u.map:"undefined"!=typeof Set&&e instanceof Set?u.set:"undefined"!=typeof Date&&e instanceof Date?u.date:u.object;default:return u.unknown}},o=n.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 c extends Error{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}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(const i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(r);else if("invalid_return_type"===i.code)r(i.returnTypeError);else if("invalid_arguments"===i.code)r(i.argumentsError);else if(0===i.path.length)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){const n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,n.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=(e=>e.message)){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}c.create=e=>new c(e);const l=(e,t)=>{let r;switch(e.code){case o.invalid_type:r=e.received===u.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case o.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,n.jsonStringifyReplacer)}`;break;case o.unrecognized_keys:r=`Unrecognized key(s) in object: ${n.joinValues(e.keys,", ")}`;break;case o.invalid_union:r="Invalid input";break;case o.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${n.joinValues(e.options)}`;break;case o.invalid_enum_value:r=`Invalid enum value. Expected ${n.joinValues(e.options)}, received '${e.received}'`;break;case o.invalid_arguments:r="Invalid function arguments";break;case o.invalid_return_type:r="Invalid function return type";break;case o.invalid_date:r="Invalid date";break;case o.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:n.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case o.too_small:r="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 o.too_big:r="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 o.custom:r="Invalid input";break;case o.invalid_intersection_types:r="Intersection results could not be merged";break;case o.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case o.not_finite:r="Number must be finite";break;default:r=t.defaultError,n.assertNever(e)}return{message:r}};let f=l;function d(){return f}const h=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],u={...i,path:a};let s="";const o=r.filter((e=>!!e)).slice().reverse();for(const e of o)s=e(u,{data:t,defaultError:s}).message;return{...i,path:a,message:i.message||s}};function p(e,t){const n=h({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,d(),l].filter((e=>!!e))});e.common.issues.push(n)}class v{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if("aborted"===r.status)return _;"dirty"===r.status&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t)n.push({key:await e.key,value:await e.value});return v.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:t,value:i}=r;if("aborted"===t.status)return _;if("aborted"===i.status)return _;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"===t.value||void 0===i.value&&!r.alwaysSet||(n[t.value]=i.value)}return{status:e.value,value:n}}}const _=Object.freeze({status:"aborted"}),m=e=>({status:"dirty",value:e}),g=e=>({status:"valid",value:e}),y=e=>"aborted"===e.status,b=e=>"dirty"===e.status,w=e=>"valid"===e.status,x=e=>"undefined"!=typeof Promise&&e instanceof Promise;var k;!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 j{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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(w(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 c(e.common.issues);return this._error=t,this._error}}};function Z(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:i};return{errorMap:(e,t)=>"invalid_type"!==e.code?{message:t.defaultError}:void 0===t.data?{message:null!=r?r:t.defaultError}:{message:null!=n?n:t.defaultError},description:i}}class O{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return s(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:s(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new v,ctx:{common:e.parent.common,data:e.data,parsedType:s(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(x(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:null!==(n=null==t?void 0:t.async)&&void 0!==n&&n,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:s(e)},i=this._parseSync({data:e,path:r.path,parent:r});return T(r,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:s(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(x(r)?r:Promise.resolve(r));return T(n,i)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,r)=>{const i=e(t),a=()=>r.addIssue({code:o.custom,...n(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then((e=>!!e||(a(),!1))):!!i||(a(),!1)}))}refinement(e,t){return this._refinement(((n,r)=>!!e(n)||(r.addIssue("function"==typeof t?t(n,r):t),!1)))}_refinement(e){return new pe({schema:this,typeName:Ze.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ve.create(this,this._def)}nullable(){return _e.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this,this._def)}promise(){return he.create(this,this._def)}or(e){return Q.create([this,e],this._def)}and(e){return ne.create(this,e,this._def)}transform(e){return new pe({...Z(this._def),schema:this,typeName:Ze.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new me({...Z(this._def),innerType:this,defaultValue:t,typeName:Ze.ZodDefault})}brand(){return new we({typeName:Ze.ZodBranded,type:this,...Z(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ge({...Z(this._def),innerType:this,catchValue:t,typeName:Ze.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return xe.create(this,e)}readonly(){return ke.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const S=/^c[^\s-]{8,}$/i,E=/^[a-z][a-z0-9]*$/,A=/^[0-9A-HJKMNP-TV-Z]{26}$/,I=/^[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,C=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let N;const R=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,P=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;class $ extends O{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==u.string){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.string,received:t.parsedType}),_}const t=new v;let r;for(const u of this._def.checks)if("min"===u.kind)e.data.length<u.value&&(r=this._getOrReturnCtx(e,r),p(r,{code:o.too_small,minimum:u.value,type:"string",inclusive:!0,exact:!1,message:u.message}),t.dirty());else if("max"===u.kind)e.data.length>u.value&&(r=this._getOrReturnCtx(e,r),p(r,{code:o.too_big,maximum:u.value,type:"string",inclusive:!0,exact:!1,message:u.message}),t.dirty());else if("length"===u.kind){const n=e.data.length>u.value,i=e.data.length<u.value;(n||i)&&(r=this._getOrReturnCtx(e,r),n?p(r,{code:o.too_big,maximum:u.value,type:"string",inclusive:!0,exact:!0,message:u.message}):i&&p(r,{code:o.too_small,minimum:u.value,type:"string",inclusive:!0,exact:!0,message:u.message}),t.dirty())}else if("email"===u.kind)C.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"email",code:o.invalid_string,message:u.message}),t.dirty());else if("emoji"===u.kind)N||(N=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),N.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"emoji",code:o.invalid_string,message:u.message}),t.dirty());else if("uuid"===u.kind)I.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"uuid",code:o.invalid_string,message:u.message}),t.dirty());else if("cuid"===u.kind)S.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"cuid",code:o.invalid_string,message:u.message}),t.dirty());else if("cuid2"===u.kind)E.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"cuid2",code:o.invalid_string,message:u.message}),t.dirty());else if("ulid"===u.kind)A.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"ulid",code:o.invalid_string,message:u.message}),t.dirty());else if("url"===u.kind)try{new URL(e.data)}catch(n){r=this._getOrReturnCtx(e,r),p(r,{validation:"url",code:o.invalid_string,message:u.message}),t.dirty()}else if("regex"===u.kind){u.regex.lastIndex=0;u.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"regex",code:o.invalid_string,message:u.message}),t.dirty())}else if("trim"===u.kind)e.data=e.data.trim();else if("includes"===u.kind)e.data.includes(u.value,u.position)||(r=this._getOrReturnCtx(e,r),p(r,{code:o.invalid_string,validation:{includes:u.value,position:u.position},message:u.message}),t.dirty());else if("toLowerCase"===u.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===u.kind)e.data=e.data.toUpperCase();else if("startsWith"===u.kind)e.data.startsWith(u.value)||(r=this._getOrReturnCtx(e,r),p(r,{code:o.invalid_string,validation:{startsWith:u.value},message:u.message}),t.dirty());else if("endsWith"===u.kind)e.data.endsWith(u.value)||(r=this._getOrReturnCtx(e,r),p(r,{code:o.invalid_string,validation:{endsWith:u.value},message:u.message}),t.dirty());else if("datetime"===u.kind){((s=u).precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):0===s.precision?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$")).test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:o.invalid_string,validation:"datetime",message:u.message}),t.dirty())}else"ip"===u.kind?(i=e.data,("v4"!==(a=u.version)&&a||!R.test(i))&&("v6"!==a&&a||!P.test(i))&&(r=this._getOrReturnCtx(e,r),p(r,{validation:"ip",code:o.invalid_string,message:u.message}),t.dirty())):n.assertNever(u);var i,a,s;return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement((t=>e.test(t)),{validation:t,code:o.invalid_string,...k.errToObj(n)})}_addCheck(e){return new $({...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)})}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)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}datetime(e){var t;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!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,...k.errToObj(null==e?void 0:e.message)})}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 $({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===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 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 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 L(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r;return parseInt(e.toFixed(i).replace(".",""))%parseInt(t.toFixed(i).replace(".",""))/Math.pow(10,i)}$.create=e=>{var t;return new $({checks:[],typeName:Ze.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...Z(e)})};class z extends O{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)!==u.number){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.number,received:t.parsedType}),_}let t;const r=new v;for(const i of this._def.checks)if("int"===i.kind)n.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),p(t,{code:o.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty());else if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty())}else"multipleOf"===i.kind?0!==L(e.data,i.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),p(t,{code:o.not_finite,message:i.message}),r.dirty()):n.assertNever(i);return{status:r.value,value:e.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,n,r){return new z({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:k.toString(r)}]})}_addCheck(e){return new z({...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((e=>"int"===e.kind||"multipleOf"===e.kind&&n.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}z.create=e=>new z({checks:[],typeName:Ze.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...Z(e)});class M extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==u.bigint){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.bigint,received:t.parsedType}),_}let t;const r=new v;for(const i of this._def.checks)if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty())}else"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):n.assertNever(i);return{status:r.value,value:e.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,n,r){return new M({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:k.toString(r)}]})}_addCheck(e){return new M({...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}}M.create=e=>{var t;return new M({checks:[],typeName:Ze.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...Z(e)})};class D extends O{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==u.boolean){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.boolean,received:t.parsedType}),_}return g(e.data)}}D.create=e=>new D({typeName:Ze.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...Z(e)});class U extends O{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==u.date){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.date,received:t.parsedType}),_}if(isNaN(e.data.getTime())){return p(this._getOrReturnCtx(e),{code:o.invalid_date}),_}const t=new v;let r;for(const i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(r=this._getOrReturnCtx(e,r),p(r,{code:o.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(r=this._getOrReturnCtx(e,r),p(r,{code:o.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):n.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new U({...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}}U.create=e=>new U({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Ze.ZodDate,...Z(e)});class B extends O{_parse(e){if(this._getType(e)!==u.symbol){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.symbol,received:t.parsedType}),_}return g(e.data)}}B.create=e=>new B({typeName:Ze.ZodSymbol,...Z(e)});class W extends O{_parse(e){if(this._getType(e)!==u.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.undefined,received:t.parsedType}),_}return g(e.data)}}W.create=e=>new W({typeName:Ze.ZodUndefined,...Z(e)});class V extends O{_parse(e){if(this._getType(e)!==u.null){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.null,received:t.parsedType}),_}return g(e.data)}}V.create=e=>new V({typeName:Ze.ZodNull,...Z(e)});class F extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return g(e.data)}}F.create=e=>new F({typeName:Ze.ZodAny,...Z(e)});class K extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return g(e.data)}}K.create=e=>new K({typeName:Ze.ZodUnknown,...Z(e)});class q extends O{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.never,received:t.parsedType}),_}}q.create=e=>new q({typeName:Ze.ZodNever,...Z(e)});class J extends O{_parse(e){if(this._getType(e)!==u.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.void,received:t.parsedType}),_}return g(e.data)}}J.create=e=>new J({typeName:Ze.ZodVoid,...Z(e)});class Y extends O{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==u.array)return p(t,{code:o.invalid_type,expected:u.array,received:t.parsedType}),_;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(p(t,{code:e?o.too_big:o.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(p(t,{code:o.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(p(t,{code:o.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map(((e,n)=>r.type._parseAsync(new j(t,e,t.path,n))))).then((e=>v.mergeArray(n,e)));const i=[...t.data].map(((e,n)=>r.type._parseSync(new j(t,e,t.path,n))));return v.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new Y({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new Y({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new Y({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}function G(e){if(e instanceof H){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=ve.create(G(r))}return new H({...e._def,shape:()=>t})}return e instanceof Y?new Y({...e._def,type:G(e.element)}):e instanceof ve?ve.create(G(e.unwrap())):e instanceof _e?_e.create(G(e.unwrap())):e instanceof re?re.create(e.items.map((e=>G(e)))):e}Y.create=(e,t)=>new Y({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ze.ZodArray,...Z(t)});class H extends O{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(),t=n.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==u.object){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.object,received:t.parsedType}),_}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof q&&"strip"===this._def.unknownKeys))for(const e in n.data)i.includes(e)||a.push(e);const s=[];for(const e of i){const t=r[e],i=n.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new j(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof q){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of a)s.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)a.length>0&&(p(n,{code:o.unrecognized_keys,keys:a}),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 a){const r=n.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new j(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of s){const n=await t.key;e.push({key:n,value:await t.value,alwaysSet:t.alwaysSet})}return e})).then((e=>v.mergeObjectSync(t,e))):v.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new H({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{var r,i,a,u;const s=null!==(a=null===(i=(r=this._def).errorMap)||void 0===i?void 0:i.call(r,t,n).message)&&void 0!==a?a:n.defaultError;return"unrecognized_keys"===t.code?{message:null!==(u=k.errToObj(e).message)&&void 0!==u?u:s}:{message:s}}}:{}})}strip(){return new H({...this._def,unknownKeys:"strip"})}passthrough(){return new H({...this._def,unknownKeys:"passthrough"})}extend(e){return new H({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new H({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ze.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new H({...this._def,catchall:e})}pick(e){const t={};return n.objectKeys(e).forEach((n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])})),new H({...this._def,shape:()=>t})}omit(e){const t={};return n.objectKeys(this.shape).forEach((n=>{e[n]||(t[n]=this.shape[n])})),new H({...this._def,shape:()=>t})}deepPartial(){return G(this)}partial(e){const t={};return n.objectKeys(this.shape).forEach((n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()})),new H({...this._def,shape:()=>t})}required(e){const t={};return n.objectKeys(this.shape).forEach((n=>{if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof ve;)e=e._def.innerType;t[n]=e}})),new H({...this._def,shape:()=>t})}keyof(){return le(n.objectKeys(this.shape))}}H.create=(e,t)=>new H({shape:()=>e,unknownKeys:"strip",catchall:q.create(),typeName:Ze.ZodObject,...Z(t)}),H.strictCreate=(e,t)=>new H({shape:()=>e,unknownKeys:"strict",catchall:q.create(),typeName:Ze.ZodObject,...Z(t)}),H.lazycreate=(e,t)=>new H({shape:e,unknownKeys:"strip",catchall:q.create(),typeName:Ze.ZodObject,...Z(t)});class Q extends O{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map((async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map((e=>new c(e.ctx.common.issues)));return p(t,{code:o.invalid_union,unionErrors:n}),_}));{let e;const r=[];for(const i of n){const n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=r.map((e=>new c(e)));return p(t,{code:o.invalid_union,unionErrors:i}),_}}get options(){return this._def.options}}Q.create=(e,t)=>new Q({options:e,typeName:Ze.ZodUnion,...Z(t)});const X=e=>e instanceof oe?X(e.schema):e instanceof pe?X(e.innerType()):e instanceof ce?[e.value]:e instanceof fe?e.options:e instanceof de?Object.keys(e.enum):e instanceof me?X(e._def.innerType):e instanceof W?[void 0]:e instanceof V?[null]:null;class ee extends O{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.object)return p(t,{code:o.invalid_type,expected:u.object,received:t.parsedType}),_;const n=this.discriminator,r=t.data[n],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}):(p(t,{code:o.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const n of t){const t=X(n.shape[e]);if(!t)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const i of t){if(r.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);r.set(i,n)}}return new ee({typeName:Ze.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...Z(n)})}}function te(e,t){const r=s(e),i=s(t);if(e===t)return{valid:!0,data:e};if(r===u.object&&i===u.object){const r=n.objectKeys(t),i=n.objectKeys(e).filter((e=>-1!==r.indexOf(e))),a={...e,...t};for(const n of i){const r=te(e[n],t[n]);if(!r.valid)return{valid:!1};a[n]=r.data}return{valid:!0,data:a}}if(r===u.array&&i===u.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let r=0;r<e.length;r++){const i=te(e[r],t[r]);if(!i.valid)return{valid:!1};n.push(i.data)}return{valid:!0,data:n}}return r===u.date&&i===u.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class ne extends O{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(y(e)||y(r))return _;const i=te(e.value,r.value);return i.valid?((b(e)||b(r))&&t.dirty(),{status:t.value,value:i.data}):(p(n,{code:o.invalid_intersection_types}),_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then((([e,t])=>r(e,t))):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ne.create=(e,t,n)=>new ne({left:e,right:t,typeName:Ze.ZodIntersection,...Z(n)});class re extends O{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==u.array)return p(n,{code:o.invalid_type,expected:u.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return p(n,{code:o.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:o.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map(((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new j(n,e,n.path,t)):null})).filter((e=>!!e));return n.common.async?Promise.all(r).then((e=>v.mergeArray(t,e))):v.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new re({...this._def,rest:e})}}re.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new re({items:e,typeName:Ze.ZodTuple,rest:null,...Z(t)})};class ie extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==u.object)return p(n,{code:o.invalid_type,expected:u.object,received:n.parsedType}),_;const r=[],i=this._def.keyType,a=this._def.valueType;for(const e in n.data)r.push({key:i._parse(new j(n,e,n.path,e)),value:a._parse(new j(n,n.data[e],n.path,e))});return n.common.async?v.mergeObjectAsync(t,r):v.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return new ie(t instanceof O?{keyType:e,valueType:t,typeName:Ze.ZodRecord,...Z(n)}:{keyType:$.create(),valueType:e,typeName:Ze.ZodRecord,...Z(t)})}}class ae extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==u.map)return p(n,{code:o.invalid_type,expected:u.map,received:n.parsedType}),_;const r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map((([e,t],a)=>({key:r._parse(new j(n,e,n.path,[a,"key"])),value:i._parse(new j(n,t,n.path,[a,"value"]))})));if(n.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const n of a){const r=await n.key,i=await n.value;if("aborted"===r.status||"aborted"===i.status)return _;"dirty"!==r.status&&"dirty"!==i.status||t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const n of a){const r=n.key,i=n.value;if("aborted"===r.status||"aborted"===i.status)return _;"dirty"!==r.status&&"dirty"!==i.status||t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}}ae.create=(e,t,n)=>new ae({valueType:t,keyType:e,typeName:Ze.ZodMap,...Z(n)});class ue extends O{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==u.set)return p(n,{code:o.invalid_type,expected:u.set,received:n.parsedType}),_;const r=this._def;null!==r.minSize&&n.data.size<r.minSize.value&&(p(n,{code:o.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&n.data.size>r.maxSize.value&&(p(n,{code:o.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function a(e){const n=new Set;for(const r of e){if("aborted"===r.status)return _;"dirty"===r.status&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}const s=[...n.data.values()].map(((e,t)=>i._parse(new j(n,e,n.path,t))));return n.common.async?Promise.all(s).then((e=>a(e))):a(s)}min(e,t){return new ue({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new ue({...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)}}ue.create=(e,t)=>new ue({valueType:e,minSize:null,maxSize:null,typeName:Ze.ZodSet,...Z(t)});class se extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.function)return p(t,{code:o.invalid_type,expected:u.function,received:t.parsedType}),_;function n(e,n){return h({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,d(),l].filter((e=>!!e)),issueData:{code:o.invalid_arguments,argumentsError:n}})}function r(e,n){return h({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,d(),l].filter((e=>!!e)),issueData:{code:o.invalid_return_type,returnTypeError:n}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof he){const e=this;return g((async function(...t){const u=new c([]),s=await e._def.args.parseAsync(t,i).catch((e=>{throw u.addIssue(n(t,e)),u})),o=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(o,i).catch((e=>{throw u.addIssue(r(o,e)),u}))}))}{const e=this;return g((function(...t){const u=e._def.args.safeParse(t,i);if(!u.success)throw new c([n(t,u.error)]);const s=Reflect.apply(a,this,u.data),o=e._def.returns.safeParse(s,i);if(!o.success)throw new c([r(s,o.error)]);return o.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new se({...this._def,args:re.create(e).rest(K.create())})}returns(e){return new se({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new se({args:e||re.create([]).rest(K.create()),returns:t||K.create(),typeName:Ze.ZodFunction,...Z(n)})}}class oe extends O{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})}}oe.create=(e,t)=>new oe({getter:e,typeName:Ze.ZodLazy,...Z(t)});class ce extends O{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:o.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}function le(e,t){return new fe({values:e,typeName:Ze.ZodEnum,...Z(t)})}ce.create=(e,t)=>new ce({value:e,typeName:Ze.ZodLiteral,...Z(t)});class fe extends O{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),r=this._def.values;return p(t,{expected:n.joinValues(r),received:t.parsedType,code:o.invalid_type}),_}if(-1===this._def.values.indexOf(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:o.invalid_enum_value,options:n}),_}return g(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return fe.create(e)}exclude(e){return fe.create(this.options.filter((t=>!e.includes(t))))}}fe.create=le;class de extends O{_parse(e){const t=n.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==u.string&&r.parsedType!==u.number){const e=n.objectValues(t);return p(r,{expected:n.joinValues(e),received:r.parsedType,code:o.invalid_type}),_}if(-1===t.indexOf(e.data)){const e=n.objectValues(t);return p(r,{received:r.data,code:o.invalid_enum_value,options:e}),_}return g(e.data)}get enum(){return this._def.values}}de.create=(e,t)=>new de({values:e,typeName:Ze.ZodNativeEnum,...Z(t)});class he extends O{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.promise&&!1===t.common.async)return p(t,{code:o.invalid_type,expected:u.promise,received:t.parsedType}),_;const n=t.parsedType===u.promise?t.data:Promise.resolve(t.data);return g(n.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}he.create=(e,t)=>new he({type:e,typeName:Ze.ZodPromise,...Z(t)});class pe extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ze.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:e=>{p(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===i.type){const e=i.transform(r.data,a);return r.common.issues.length?{status:"dirty",value:r.data}:r.common.async?Promise.resolve(e).then((e=>this._def.schema._parseAsync({data:e,path:r.path,parent:r}))):this._def.schema._parseSync({data:e,path:r.path,parent:r})}if("refinement"===i.type){const e=e=>{const t=i.refinement(e,a);if(r.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===r.common.async){const n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?_:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((n=>"aborted"===n.status?_:("dirty"===n.status&&t.dirty(),e(n.value).then((()=>({status:t.value,value:n.value}))))))}if("transform"===i.type){if(!1===r.common.async){const e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!w(e))return e;const n=i.transform(e.value,a);if(n instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:n}}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((e=>w(e)?Promise.resolve(i.transform(e.value,a)).then((e=>({status:t.value,value:e}))):e))}n.assertNever(i)}}pe.create=(e,t,n)=>new pe({schema:e,typeName:Ze.ZodEffects,effect:t,...Z(n)}),pe.createWithPreprocess=(e,t,n)=>new pe({schema:t,effect:{type:"preprocess",transform:e},typeName:Ze.ZodEffects,...Z(n)});class ve extends O{_parse(e){return this._getType(e)===u.undefined?g(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ve.create=(e,t)=>new ve({innerType:e,typeName:Ze.ZodOptional,...Z(t)});class _e extends O{_parse(e){return this._getType(e)===u.null?g(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_e.create=(e,t)=>new _e({innerType:e,typeName:Ze.ZodNullable,...Z(t)});class me extends O{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===u.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}me.create=(e,t)=>new me({innerType:e,typeName:Ze.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...Z(t)});class ge extends O{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return x(r)?r.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new c(n.common.issues)},input:n.data})}))):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new c(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ge.create=(e,t)=>new ge({innerType:e,typeName:Ze.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...Z(t)});class ye extends O{_parse(e){if(this._getType(e)!==u.nan){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:u.nan,received:t.parsedType}),_}return{status:"valid",value:e.data}}}ye.create=e=>new ye({typeName:Ze.ZodNaN,...Z(e)});const be=Symbol("zod_brand");class we extends O{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class xe extends O{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?_:"dirty"===e.status?(t.dirty(),m(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})(