zmp-sdk
Version:
Zalo Mini App SDK
2 lines (1 loc) • 49.8 kB
JavaScript
var 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 a of e)t[a]=a;return t},e.getValidEnumValues=t=>{const a=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),s={};for(const e of a)s[e]=t[e];return e.objectValues(s)},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 a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.push(a);return t},e.find=(e,t)=>{for(const a of e)if(t(a))return a},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(e||(e={}));const t=e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),a=e=>{switch(typeof e){case"undefined":return t.undefined;case"string":return t.string;case"number":return isNaN(e)?t.nan:t.number;case"boolean":return t.boolean;case"function":return t.function;case"bigint":return t.bigint;case"symbol":return t.symbol;case"object":return Array.isArray(e)?t.array:null===e?t.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?t.promise:"undefined"!=typeof Map&&e instanceof Map?t.map:"undefined"!=typeof Set&&e instanceof Set?t.set:"undefined"!=typeof Date&&e instanceof Date?t.date:t.object;default:return t.unknown}},s=e.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),r=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class n 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},a={_errors:[]},s=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(s);else if("invalid_return_type"===r.code)s(r.returnTypeError);else if("invalid_arguments"===r.code)s(r.argumentsError);else if(0===r.path.length)a._errors.push(t(r));else{let e=a,s=0;for(;s<r.path.length;){const a=r.path[s];s===r.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(t(r))):e[a]=e[a]||{_errors:[]},e=e[a],s++}}};return s(this),a}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=(e=>e.message)){const t={},a=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):a.push(e(s));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}n.create=e=>new n(e);const i=(a,r)=>{let n;switch(a.code){case s.invalid_type:n=a.received===t.undefined?"Required":`Expected ${a.expected}, received ${a.received}`;break;case s.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(a.expected,e.jsonStringifyReplacer)}`;break;case s.unrecognized_keys:n=`Unrecognized key(s) in object: ${e.joinValues(a.keys,", ")}`;break;case s.invalid_union:n="Invalid input";break;case s.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${e.joinValues(a.options)}`;break;case s.invalid_enum_value:n=`Invalid enum value. Expected ${e.joinValues(a.options)}, received '${a.received}'`;break;case s.invalid_arguments:n="Invalid function arguments";break;case s.invalid_return_type:n="Invalid function return type";break;case s.invalid_date:n="Invalid date";break;case s.invalid_string:"object"==typeof a.validation?"startsWith"in a.validation?n=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?n=`Invalid input: must end with "${a.validation.endsWith}"`:e.assertNever(a.validation):n="regex"!==a.validation?`Invalid ${a.validation}`:"Invalid";break;case s.too_small:n="array"===a.type?`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:"string"===a.type?`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:"number"===a.type?`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:"date"===a.type?`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(a.minimum)}`:"Invalid input";break;case s.too_big:n="array"===a.type?`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:"string"===a.type?`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:"number"===a.type?`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:"date"===a.type?`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(a.maximum)}`:"Invalid input";break;case s.custom:n="Invalid input";break;case s.invalid_intersection_types:n="Intersection results could not be merged";break;case s.not_multiple_of:n=`Number must be a multiple of ${a.multipleOf}`;break;case s.not_finite:n="Number must be finite";break;default:n=r.defaultError,e.assertNever(a)}return{message:n}};let o=i;function d(e){o=e}function c(){return o}const u=e=>{const{data:t,path:a,errorMaps:s,issueData:r}=e,n=[...a,...r.path||[]],i={...r,path:n};let o="";const d=s.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...r,path:n,message:r.message||o}},l=[];function p(e,t){const a=u({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,c(),i].filter((e=>!!e))});e.common.issues.push(a)}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 a=[];for(const s of t){if("aborted"===s.status)return m;"dirty"===s.status&&e.dirty(),a.push(s.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const e of t)a.push({key:await e.key,value:await e.value});return h.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const s of t){const{key:t,value:r}=s;if("aborted"===t.status)return m;if("aborted"===r.status)return m;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),(void 0!==r.value||s.alwaysSet)&&(a[t.value]=r.value)}return{status:e.value,value:a}}}const m=Object.freeze({status:"aborted"}),f=e=>({status:"dirty",value:e}),y=e=>({status:"valid",value:e}),_=e=>"aborted"===e.status,v=e=>"dirty"===e.status,g=e=>"valid"===e.status,x=e=>"undefined"!=typeof Promise&&e instanceof Promise;var b;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(b||(b={}));class k{constructor(e,t,a,s){this.parent=e,this.data=t,this._path=a,this._key=s}get path(){return this._path.concat(this._key)}}const w=(e,t)=>{if(g(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,error:new n(e.common.issues)}};function Z(e){if(!e)return{};const{errorMap:t,invalid_type_error:a,required_error:s,description:r}=e;if(t&&(a||s))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:r};return{errorMap:(e,t)=>"invalid_type"!==e.code?{message:t.defaultError}:void 0===t.data?{message:null!=s?s:t.defaultError}:{message:null!=a?a:t.defaultError},description:r}}class T{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.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return a(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new h,ctx:{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(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 a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){var s;const r={common:{issues:[],async:null!==(s=null==t?void 0:t.async)&&void 0!==s&&s,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},n=this._parseSync({data:e,path:r.path,parent:r});return w(r,n)}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},r=this._parse({data:e,path:s.path,parent:s}),n=await(x(r)?r:Promise.resolve(r));return w(s,n)}refine(e,t){const a=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,r)=>{const n=e(t),i=()=>r.addIssue({code:s.custom,...a(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(i(),!1))):!!n||(i(),!1)}))}refinement(e,t){return this._refinement(((a,s)=>!!e(a)||(s.addIssue("function"==typeof t?t(a,s):t),!1)))}_refinement(e){return new ce({schema:this,typeName:xe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ue.create(this,this._def)}nullable(){return le.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return K.create(this,this._def)}promise(){return de.create(this,this._def)}or(e){return F.create([this,e],this._def)}and(e){return G.create(this,e,this._def)}transform(e){return new ce({...Z(this._def),schema:this,typeName:xe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new pe({...Z(this._def),innerType:this,defaultValue:t,typeName:xe.ZodDefault})}brand(){return new ye({typeName:xe.ZodBranded,type:this,...Z(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new he({...Z(this._def),innerType:this,catchValue:t,typeName:xe.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return _e.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const N=/^c[^\s-]{8,}$/i,O=/^[a-z][a-z0-9]*$/,S=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,E=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/;class j extends T{constructor(){super(...arguments),this._regex=(e,t,a)=>this.refinement((t=>e.test(t)),{validation:t,code:s.invalid_string,...b.errToObj(a)}),this.nonempty=e=>this.min(1,b.errToObj(e)),this.trim=()=>new j({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(a){this._def.coerce&&(a.data=String(a.data));if(this._getType(a)!==t.string){const e=this._getOrReturnCtx(a);return p(e,{code:s.invalid_type,expected:t.string,received:e.parsedType}),m}const r=new h;let n;for(const t of this._def.checks)if("min"===t.kind)a.data.length<t.value&&(n=this._getOrReturnCtx(a,n),p(n,{code:s.too_small,minimum:t.value,type:"string",inclusive:!0,exact:!1,message:t.message}),r.dirty());else if("max"===t.kind)a.data.length>t.value&&(n=this._getOrReturnCtx(a,n),p(n,{code:s.too_big,maximum:t.value,type:"string",inclusive:!0,exact:!1,message:t.message}),r.dirty());else if("length"===t.kind){const e=a.data.length>t.value,i=a.data.length<t.value;(e||i)&&(n=this._getOrReturnCtx(a,n),e?p(n,{code:s.too_big,maximum:t.value,type:"string",inclusive:!0,exact:!0,message:t.message}):i&&p(n,{code:s.too_small,minimum:t.value,type:"string",inclusive:!0,exact:!0,message:t.message}),r.dirty())}else if("email"===t.kind)E.test(a.data)||(n=this._getOrReturnCtx(a,n),p(n,{validation:"email",code:s.invalid_string,message:t.message}),r.dirty());else if("uuid"===t.kind)S.test(a.data)||(n=this._getOrReturnCtx(a,n),p(n,{validation:"uuid",code:s.invalid_string,message:t.message}),r.dirty());else if("cuid"===t.kind)N.test(a.data)||(n=this._getOrReturnCtx(a,n),p(n,{validation:"cuid",code:s.invalid_string,message:t.message}),r.dirty());else if("cuid2"===t.kind)O.test(a.data)||(n=this._getOrReturnCtx(a,n),p(n,{validation:"cuid2",code:s.invalid_string,message:t.message}),r.dirty());else if("url"===t.kind)try{new URL(a.data)}catch(e){n=this._getOrReturnCtx(a,n),p(n,{validation:"url",code:s.invalid_string,message:t.message}),r.dirty()}else if("regex"===t.kind){t.regex.lastIndex=0;t.regex.test(a.data)||(n=this._getOrReturnCtx(a,n),p(n,{validation:"regex",code:s.invalid_string,message:t.message}),r.dirty())}else if("trim"===t.kind)a.data=a.data.trim();else if("startsWith"===t.kind)a.data.startsWith(t.value)||(n=this._getOrReturnCtx(a,n),p(n,{code:s.invalid_string,validation:{startsWith:t.value},message:t.message}),r.dirty());else if("endsWith"===t.kind)a.data.endsWith(t.value)||(n=this._getOrReturnCtx(a,n),p(n,{code:s.invalid_string,validation:{endsWith:t.value},message:t.message}),r.dirty());else if("datetime"===t.kind){((i=t).precision?i.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}Z$`):0===i.precision?i.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$"):i.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(a.data)||(n=this._getOrReturnCtx(a,n),p(n,{code:s.invalid_string,validation:"datetime",message:t.message}),r.dirty())}else e.assertNever(t);var i;return{status:r.value,value:a.data}}_addCheck(e){return new j({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.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,...b.errToObj(null==e?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...b.errToObj(t)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...b.errToObj(t)})}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 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 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 C(e,t){const a=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,r=a>s?a:s;return parseInt(e.toFixed(r).replace(".",""))%parseInt(t.toFixed(r).replace(".",""))/Math.pow(10,r)}j.create=e=>{var t;return new j({checks:[],typeName:xe.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...Z(e)})};class I extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(a){this._def.coerce&&(a.data=Number(a.data));if(this._getType(a)!==t.number){const e=this._getOrReturnCtx(a);return p(e,{code:s.invalid_type,expected:t.number,received:e.parsedType}),m}let r;const n=new h;for(const t of this._def.checks)if("int"===t.kind)e.isInteger(a.data)||(r=this._getOrReturnCtx(a,r),p(r,{code:s.invalid_type,expected:"integer",received:"float",message:t.message}),n.dirty());else if("min"===t.kind){(t.inclusive?a.data<t.value:a.data<=t.value)&&(r=this._getOrReturnCtx(a,r),p(r,{code:s.too_small,minimum:t.value,type:"number",inclusive:t.inclusive,exact:!1,message:t.message}),n.dirty())}else if("max"===t.kind){(t.inclusive?a.data>t.value:a.data>=t.value)&&(r=this._getOrReturnCtx(a,r),p(r,{code:s.too_big,maximum:t.value,type:"number",inclusive:t.inclusive,exact:!1,message:t.message}),n.dirty())}else"multipleOf"===t.kind?0!==C(a.data,t.value)&&(r=this._getOrReturnCtx(a,r),p(r,{code:s.not_multiple_of,multipleOf:t.value,message:t.message}),n.dirty()):"finite"===t.kind?Number.isFinite(a.data)||(r=this._getOrReturnCtx(a,r),p(r,{code:s.not_finite,message:t.message}),n.dirty()):e.assertNever(t);return{status:n.value,value:a.data}}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,a,s){return new I({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:b.toString(s)}]})}_addCheck(e){return new I({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((t=>"int"===t.kind||"multipleOf"===t.kind&&e.isInteger(t.value)))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===t||a.value>t)&&(t=a.value):"max"===a.kind&&(null===e||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}I.create=e=>new I({checks:[],typeName:xe.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...Z(e)});class P extends T{_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==t.bigint){const a=this._getOrReturnCtx(e);return p(a,{code:s.invalid_type,expected:t.bigint,received:a.parsedType}),m}return y(e.data)}}P.create=e=>{var t;return new P({typeName:xe.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...Z(e)})};class R extends T{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==t.boolean){const a=this._getOrReturnCtx(e);return p(a,{code:s.invalid_type,expected:t.boolean,received:a.parsedType}),m}return y(e.data)}}R.create=e=>new R({typeName:xe.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...Z(e)});class A extends T{_parse(a){this._def.coerce&&(a.data=new Date(a.data));if(this._getType(a)!==t.date){const e=this._getOrReturnCtx(a);return p(e,{code:s.invalid_type,expected:t.date,received:e.parsedType}),m}if(isNaN(a.data.getTime())){return p(this._getOrReturnCtx(a),{code:s.invalid_date}),m}const r=new h;let n;for(const t of this._def.checks)"min"===t.kind?a.data.getTime()<t.value&&(n=this._getOrReturnCtx(a,n),p(n,{code:s.too_small,message:t.message,inclusive:!0,exact:!1,minimum:t.value,type:"date"}),r.dirty()):"max"===t.kind?a.data.getTime()>t.value&&(n=this._getOrReturnCtx(a,n),p(n,{code:s.too_big,message:t.message,inclusive:!0,exact:!1,maximum:t.value,type:"date"}),r.dirty()):e.assertNever(t);return{status:r.value,value:new Date(a.data.getTime())}}_addCheck(e){return new A({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:b.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}}A.create=e=>new A({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:xe.ZodDate,...Z(e)});class M extends T{_parse(e){if(this._getType(e)!==t.symbol){const a=this._getOrReturnCtx(e);return p(a,{code:s.invalid_type,expected:t.symbol,received:a.parsedType}),m}return y(e.data)}}M.create=e=>new M({typeName:xe.ZodSymbol,...Z(e)});class $ extends T{_parse(e){if(this._getType(e)!==t.undefined){const a=this._getOrReturnCtx(e);return p(a,{code:s.invalid_type,expected:t.undefined,received:a.parsedType}),m}return y(e.data)}}$.create=e=>new $({typeName:xe.ZodUndefined,...Z(e)});class D extends T{_parse(e){if(this._getType(e)!==t.null){const a=this._getOrReturnCtx(e);return p(a,{code:s.invalid_type,expected:t.null,received:a.parsedType}),m}return y(e.data)}}D.create=e=>new D({typeName:xe.ZodNull,...Z(e)});class L extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return y(e.data)}}L.create=e=>new L({typeName:xe.ZodAny,...Z(e)});class z extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return y(e.data)}}z.create=e=>new z({typeName:xe.ZodUnknown,...Z(e)});class V extends T{_parse(e){const a=this._getOrReturnCtx(e);return p(a,{code:s.invalid_type,expected:t.never,received:a.parsedType}),m}}V.create=e=>new V({typeName:xe.ZodNever,...Z(e)});class U extends T{_parse(e){if(this._getType(e)!==t.undefined){const a=this._getOrReturnCtx(e);return p(a,{code:s.invalid_type,expected:t.void,received:a.parsedType}),m}return y(e.data)}}U.create=e=>new U({typeName:xe.ZodVoid,...Z(e)});class K extends T{_parse(e){const{ctx:a,status:r}=this._processInputParams(e),n=this._def;if(a.parsedType!==t.array)return p(a,{code:s.invalid_type,expected:t.array,received:a.parsedType}),m;if(null!==n.exactLength){const e=a.data.length>n.exactLength.value,t=a.data.length<n.exactLength.value;(e||t)&&(p(a,{code:e?s.too_big:s.too_small,minimum:t?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&a.data.length<n.minLength.value&&(p(a,{code:s.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&a.data.length>n.maxLength.value&&(p(a,{code:s.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),a.common.async)return Promise.all([...a.data].map(((e,t)=>n.type._parseAsync(new k(a,e,a.path,t))))).then((e=>h.mergeArray(r,e)));const i=[...a.data].map(((e,t)=>n.type._parseSync(new k(a,e,a.path,t))));return h.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new K({...this._def,minLength:{value:e,message:b.toString(t)}})}max(e,t){return new K({...this._def,maxLength:{value:e,message:b.toString(t)}})}length(e,t){return new K({...this._def,exactLength:{value:e,message:b.toString(t)}})}nonempty(e){return this.min(1,e)}}var W;function B(e){if(e instanceof q){const t={};for(const a in e.shape){const s=e.shape[a];t[a]=ue.create(B(s))}return new q({...e._def,shape:()=>t})}return e instanceof K?K.create(B(e.element)):e instanceof ue?ue.create(B(e.unwrap())):e instanceof le?le.create(B(e.unwrap())):e instanceof Q?Q.create(e.items.map((e=>B(e)))):e}K.create=(e,t)=>new K({type:e,minLength:null,maxLength:null,exactLength:null,typeName:xe.ZodArray,...Z(t)}),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(W||(W={}));class q extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const t=this._def.shape(),a=e.objectKeys(t);return this._cached={shape:t,keys:a}}_parse(e){if(this._getType(e)!==t.object){const a=this._getOrReturnCtx(e);return p(a,{code:s.invalid_type,expected:t.object,received:a.parsedType}),m}const{status:a,ctx:r}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof V&&"strip"===this._def.unknownKeys))for(const e in r.data)i.includes(e)||o.push(e);const d=[];for(const e of i){const t=n[e],a=r.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new k(r,a,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof V){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)d.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)o.length>0&&(p(r,{code:s.unrecognized_keys,keys:o}),a.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 a=r.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new k(r,a,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of d){const a=await t.key;e.push({key:a,value:await t.value,alwaysSet:t.alwaysSet})}return e})).then((e=>h.mergeObjectSync(a,e))):h.mergeObjectSync(a,d)}get shape(){return this._def.shape()}strict(e){return new q({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,a)=>{var s,r,n,i;const o=null!==(n=null===(r=(s=this._def).errorMap)||void 0===r?void 0:r.call(s,t,a).message)&&void 0!==n?n:a.defaultError;return"unrecognized_keys"===t.code?{message:null!==(i=b.errToObj(e).message)&&void 0!==i?i:o}:{message:o}}}:{}})}strip(){return new q({...this._def,unknownKeys:"strip"})}passthrough(){return new q({...this._def,unknownKeys:"passthrough"})}extend(e){return new q({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new q({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>W.mergeShapes(this._def.shape(),e._def.shape()),typeName:xe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new q({...this._def,catchall:e})}pick(t){const a={};return e.objectKeys(t).forEach((e=>{t[e]&&this.shape[e]&&(a[e]=this.shape[e])})),new q({...this._def,shape:()=>a})}omit(t){const a={};return e.objectKeys(this.shape).forEach((e=>{t[e]||(a[e]=this.shape[e])})),new q({...this._def,shape:()=>a})}deepPartial(){return B(this)}partial(t){const a={};return e.objectKeys(this.shape).forEach((e=>{const s=this.shape[e];t&&!t[e]?a[e]=s:a[e]=s.optional()})),new q({...this._def,shape:()=>a})}required(t){const a={};return e.objectKeys(this.shape).forEach((e=>{if(t&&!t[e])a[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof ue;)t=t._def.innerType;a[e]=t}})),new q({...this._def,shape:()=>a})}keyof(){return ne(e.objectKeys(this.shape))}}q.create=(e,t)=>new q({shape:()=>e,unknownKeys:"strip",catchall:V.create(),typeName:xe.ZodObject,...Z(t)}),q.strictCreate=(e,t)=>new q({shape:()=>e,unknownKeys:"strict",catchall:V.create(),typeName:xe.ZodObject,...Z(t)}),q.lazycreate=(e,t)=>new q({shape:e,unknownKeys:"strip",catchall:V.create(),typeName:xe.ZodObject,...Z(t)});class F extends T{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;if(t.common.async)return Promise.all(a.map((async e=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const a of e)if("dirty"===a.result.status)return t.common.issues.push(...a.ctx.common.issues),a.result;const a=e.map((e=>new n(e.ctx.common.issues)));return p(t,{code:s.invalid_union,unionErrors:a}),m}));{let e;const r=[];for(const s of a){const a={...t,common:{...t.common,issues:[]},parent:null},n=s._parseSync({data:t.data,path:t.path,parent:a});if("valid"===n.status)return n;"dirty"!==n.status||e||(e={result:n,ctx:a}),a.common.issues.length&&r.push(a.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=r.map((e=>new n(e)));return p(t,{code:s.invalid_union,unionErrors:i}),m}}get options(){return this._def.options}}F.create=(e,t)=>new F({options:e,typeName:xe.ZodUnion,...Z(t)});const J=e=>e instanceof se?J(e.schema):e instanceof ce?J(e.innerType()):e instanceof re?[e.value]:e instanceof ie?e.options:e instanceof oe?Object.keys(e.enum):e instanceof pe?J(e._def.innerType):e instanceof $?[void 0]:e instanceof D?[null]:null;class Y extends T{_parse(e){const{ctx:a}=this._processInputParams(e);if(a.parsedType!==t.object)return p(a,{code:s.invalid_type,expected:t.object,received:a.parsedType}),m;const r=this.discriminator,n=a.data[r],i=this.optionsMap.get(n);return i?a.common.async?i._parseAsync({data:a.data,path:a.path,parent:a}):i._parseSync({data:a.data,path:a.path,parent:a}):(p(a,{code:s.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const s=new Map;for(const a of t){const t=J(a.shape[e]);if(!t)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const r of t){if(s.has(r))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(r)}`);s.set(r,a)}}return new Y({typeName:xe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...Z(a)})}}function H(s,r){const n=a(s),i=a(r);if(s===r)return{valid:!0,data:s};if(n===t.object&&i===t.object){const t=e.objectKeys(r),a=e.objectKeys(s).filter((e=>-1!==t.indexOf(e))),n={...s,...r};for(const e of a){const t=H(s[e],r[e]);if(!t.valid)return{valid:!1};n[e]=t.data}return{valid:!0,data:n}}if(n===t.array&&i===t.array){if(s.length!==r.length)return{valid:!1};const e=[];for(let t=0;t<s.length;t++){const a=H(s[t],r[t]);if(!a.valid)return{valid:!1};e.push(a.data)}return{valid:!0,data:e}}return n===t.date&&i===t.date&&+s==+r?{valid:!0,data:s}:{valid:!1}}class G extends T{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),r=(e,r)=>{if(_(e)||_(r))return m;const n=H(e.value,r.value);return n.valid?((v(e)||v(r))&&t.dirty(),{status:t.value,value:n.data}):(p(a,{code:s.invalid_intersection_types}),m)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then((([e,t])=>r(e,t))):r(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}G.create=(e,t,a)=>new G({left:e,right:t,typeName:xe.ZodIntersection,...Z(a)});class Q extends T{_parse(e){const{status:a,ctx:r}=this._processInputParams(e);if(r.parsedType!==t.array)return p(r,{code:s.invalid_type,expected:t.array,received:r.parsedType}),m;if(r.data.length<this._def.items.length)return p(r,{code:s.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&r.data.length>this._def.items.length&&(p(r,{code:s.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),a.dirty());const n=[...r.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new k(r,e,r.path,t)):null})).filter((e=>!!e));return r.common.async?Promise.all(n).then((e=>h.mergeArray(a,e))):h.mergeArray(a,n)}get items(){return this._def.items}rest(e){return new Q({...this._def,rest:e})}}Q.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Q({items:e,typeName:xe.ZodTuple,rest:null,...Z(t)})};class X extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:a,ctx:r}=this._processInputParams(e);if(r.parsedType!==t.object)return p(r,{code:s.invalid_type,expected:t.object,received:r.parsedType}),m;const n=[],i=this._def.keyType,o=this._def.valueType;for(const e in r.data)n.push({key:i._parse(new k(r,e,r.path,e)),value:o._parse(new k(r,r.data[e],r.path,e))});return r.common.async?h.mergeObjectAsync(a,n):h.mergeObjectSync(a,n)}get element(){return this._def.valueType}static create(e,t,a){return new X(t instanceof T?{keyType:e,valueType:t,typeName:xe.ZodRecord,...Z(a)}:{keyType:j.create(),valueType:e,typeName:xe.ZodRecord,...Z(t)})}}class ee extends T{_parse(e){const{status:a,ctx:r}=this._processInputParams(e);if(r.parsedType!==t.map)return p(r,{code:s.invalid_type,expected:t.map,received:r.parsedType}),m;const n=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map((([e,t],a)=>({key:n._parse(new k(r,e,r.path,[a,"key"])),value:i._parse(new k(r,t,r.path,[a,"value"]))})));if(r.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const t of o){const s=await t.key,r=await t.value;if("aborted"===s.status||"aborted"===r.status)return m;"dirty"!==s.status&&"dirty"!==r.status||a.dirty(),e.set(s.value,r.value)}return{status:a.value,value:e}}))}{const e=new Map;for(const t of o){const s=t.key,r=t.value;if("aborted"===s.status||"aborted"===r.status)return m;"dirty"!==s.status&&"dirty"!==r.status||a.dirty(),e.set(s.value,r.value)}return{status:a.value,value:e}}}}ee.create=(e,t,a)=>new ee({valueType:t,keyType:e,typeName:xe.ZodMap,...Z(a)});class te extends T{_parse(e){const{status:a,ctx:r}=this._processInputParams(e);if(r.parsedType!==t.set)return p(r,{code:s.invalid_type,expected:t.set,received:r.parsedType}),m;const n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(p(r,{code:s.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),a.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(p(r,{code:s.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),a.dirty());const i=this._def.valueType;function o(e){const t=new Set;for(const s of e){if("aborted"===s.status)return m;"dirty"===s.status&&a.dirty(),t.add(s.value)}return{status:a.value,value:t}}const d=[...r.data.values()].map(((e,t)=>i._parse(new k(r,e,r.path,t))));return r.common.async?Promise.all(d).then((e=>o(e))):o(d)}min(e,t){return new te({...this._def,minSize:{value:e,message:b.toString(t)}})}max(e,t){return new te({...this._def,maxSize:{value:e,message:b.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}te.create=(e,t)=>new te({valueType:e,minSize:null,maxSize:null,typeName:xe.ZodSet,...Z(t)});class ae extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:a}=this._processInputParams(e);if(a.parsedType!==t.function)return p(a,{code:s.invalid_type,expected:t.function,received:a.parsedType}),m;function r(e,t){return u({data:e,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,c(),i].filter((e=>!!e)),issueData:{code:s.invalid_arguments,argumentsError:t}})}function o(e,t){return u({data:e,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,c(),i].filter((e=>!!e)),issueData:{code:s.invalid_return_type,returnTypeError:t}})}const d={errorMap:a.common.contextualErrorMap},l=a.data;return this._def.returns instanceof de?y((async(...e)=>{const t=new n([]),a=await this._def.args.parseAsync(e,d).catch((a=>{throw t.addIssue(r(e,a)),t})),s=await l(...a);return await this._def.returns._def.type.parseAsync(s,d).catch((e=>{throw t.addIssue(o(s,e)),t}))})):y(((...e)=>{const t=this._def.args.safeParse(e,d);if(!t.success)throw new n([r(e,t.error)]);const a=l(...t.data),s=this._def.returns.safeParse(a,d);if(!s.success)throw new n([o(a,s.error)]);return s.data}))}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ae({...this._def,args:Q.create(e).rest(z.create())})}returns(e){return new ae({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new ae({args:e||Q.create([]).rest(z.create()),returns:t||z.create(),typeName:xe.ZodFunction,...Z(a)})}}class se extends T{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})}}se.create=(e,t)=>new se({getter:e,typeName:xe.ZodLazy,...Z(t)});class re extends T{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:s.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ne(e,t){return new ie({values:e,typeName:xe.ZodEnum,...Z(t)})}re.create=(e,t)=>new re({value:e,typeName:xe.ZodLiteral,...Z(t)});class ie extends T{_parse(t){if("string"!=typeof t.data){const a=this._getOrReturnCtx(t),r=this._def.values;return p(a,{expected:e.joinValues(r),received:a.parsedType,code:s.invalid_type}),m}if(-1===this._def.values.indexOf(t.data)){const e=this._getOrReturnCtx(t),a=this._def.values;return p(e,{received:e.data,code:s.invalid_enum_value,options:a}),m}return y(t.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return ie.create(e)}exclude(e){return ie.create(this.options.filter((t=>!e.includes(t))))}}ie.create=ne;class oe extends T{_parse(a){const r=e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(a);if(n.parsedType!==t.string&&n.parsedType!==t.number){const t=e.objectValues(r);return p(n,{expected:e.joinValues(t),received:n.parsedType,code:s.invalid_type}),m}if(-1===r.indexOf(a.data)){const t=e.objectValues(r);return p(n,{received:n.data,code:s.invalid_enum_value,options:t}),m}return y(a.data)}get enum(){return this._def.values}}oe.create=(e,t)=>new oe({values:e,typeName:xe.ZodNativeEnum,...Z(t)});class de extends T{unwrap(){return this._def.type}_parse(e){const{ctx:a}=this._processInputParams(e);if(a.parsedType!==t.promise&&!1===a.common.async)return p(a,{code:s.invalid_type,expected:t.promise,received:a.parsedType}),m;const r=a.parsedType===t.promise?a.data:Promise.resolve(a.data);return y(r.then((e=>this._def.type.parseAsync(e,{path:a.path,errorMap:a.common.contextualErrorMap}))))}}de.create=(e,t)=>new de({type:e,typeName:xe.ZodPromise,...Z(t)});class ce extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===xe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:a,ctx:s}=this._processInputParams(t),r=this._def.effect||null;if("preprocess"===r.type){const e=r.transform(s.data);return s.common.async?Promise.resolve(e).then((e=>this._def.schema._parseAsync({data:e,path:s.path,parent:s}))):this._def.schema._parseSync({data:e,path:s.path,parent:s})}const n={addIssue:e=>{p(s,e),e.fatal?a.abort():a.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),"refinement"===r.type){const e=e=>{const t=r.refinement(e,n);if(s.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===s.common.async){const t=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===t.status?m:("dirty"===t.status&&a.dirty(),e(t.value),{status:a.value,value:t.value})}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((t=>"aborted"===t.status?m:("dirty"===t.status&&a.dirty(),e(t.value).then((()=>({status:a.value,value:t.value}))))))}if("transform"===r.type){if(!1===s.common.async){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!g(e))return e;const t=r.transform(e.value,n);if(t instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:a.value,value:t}}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((e=>g(e)?Promise.resolve(r.transform(e.value,n)).then((e=>({status:a.value,value:e}))):e))}e.assertNever(r)}}ce.create=(e,t,a)=>new ce({schema:e,typeName:xe.ZodEffects,effect:t,...Z(a)}),ce.createWithPreprocess=(e,t,a)=>new ce({schema:t,effect:{type:"preprocess",transform:e},typeName:xe.ZodEffects,...Z(a)});class ue extends T{_parse(e){return this._getType(e)===t.undefined?y(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ue.create=(e,t)=>new ue({innerType:e,typeName:xe.ZodOptional,...Z(t)});class le extends T{_parse(e){return this._getType(e)===t.null?y(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}le.create=(e,t)=>new le({innerType:e,typeName:xe.ZodNullable,...Z(t)});class pe extends T{_parse(e){const{ctx:a}=this._processInputParams(e);let s=a.data;return a.parsedType===t.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:a.path,parent:a})}removeDefault(){return this._def.innerType}}pe.create=(e,t)=>new pe({innerType:e,typeName:xe.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...Z(t)});class he extends T{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t,common:{...t.common,issues:[]}}});return x(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue()}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue()}}removeCatch(){return this._def.innerType}}he.create=(e,t)=>new he({innerType:e,typeName:xe.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...Z(t)});class me extends T{_parse(e){if(this._getType(e)!==t.nan){const a=this._getOrReturnCtx(e);return p(a,{code:s.invalid_type,expected:t.nan,received:a.parsedType}),m}return{status:"valid",value:e.data}}}me.create=e=>new me({typeName:xe.ZodNaN,...Z(e)});const fe=Symbol("zod_brand");class ye extends T{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class _e extends T{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?m:"dirty"===e.status?(t.dirty(),f(e.value)):this._def.out._parseAsync({data:e.value,path:a.path,parent:a})})()}{const e=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?m:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:a.path,parent:a})}}static create(e,t){return new _e({in:e,out:t,typeName:xe.ZodPipeline})}}const ve=(e,t={},a)=>e?L.create().superRefine(((s,r)=>{if(!e(s)){const e="function"==typeof t?t(s):t,n="string"==typeof e?{message:e}:e;r.addIssue({code:"custom",...n,fatal:a})}})):L.create(),ge={object:q.lazycreate};var xe;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline"}(xe||(xe={}));const be=(e,t={message:`Input not instance of ${e.name}`})=>ve((t=>t instanceof e),t,!0),ke=j.create,we=I.create,Ze=me.create,Te=P.create,Ne=R.create,Oe=A.create,Se=M.create,Ee=$.create,je=D.create,Ce=L.create,Ie=z.create,Pe=V.create,Re=U.create,Ae=K.create,Me=q.create,$e=q.strictCreate,De=F.create,Le=Y.create,ze=G.create,Ve=Q.create,Ue=X.create,Ke=ee.create,We=te.create,Be=ae.create,qe=se.create,Fe=re.create,Je=ie.create,Ye=oe.create,He=de.create,Ge=ce.create,Qe=ue.create,Xe=le.create,et=ce.createWithPreprocess,tt=_e.create,at=()=>ke().optional(),st=()=>we().optional(),rt=()=>Ne().optional(),nt={string:e=>j.create({...e,coerce:!0}),number:e=>I.create({...e,coerce:!0}),boolean:e=>R.create({...e,coerce:!0}),bigint:e=>P.create({...e,coerce:!0}),date:e=>A.create({...e,coerce:!0})},it=m;var ot=Object.freeze({__proto__:null,defaultErrorMap:i,setErrorMap:d,getErrorMap:c,makeIssue:u,EMPTY_PATH:l,addIssueToContext:p,ParseStatus:h,INVALID:m,DIRTY:f,OK:y,isAborted:_,isDirty:v,isValid:g,isAsync:x,get util(){return e},ZodParsedType:t,getParsedType:a,ZodType:T,ZodString:j,ZodNumber:I,ZodBigInt:P,ZodBoolean:R,ZodDate:A,ZodSymbol:M,ZodUndefined:$,ZodNull:D,ZodAny:L,ZodUnknown:z,ZodNever:V,ZodVoid:U,ZodArray:K,get objectUtil(){return W},ZodObject:q,ZodUnion:F,ZodDiscriminatedUnion:Y,ZodIntersection:G,ZodTuple:Q,ZodRecord:X,ZodMap:ee,ZodSet:te,ZodFunction:ae,ZodLazy:se,ZodLiteral:re,ZodEnum:ie,ZodNativeEnum:oe,ZodPromise:de,ZodEffects:ce,ZodTransformer:ce,ZodOptional:ue,ZodNullable:le,ZodDefault:pe,ZodCatch:he,ZodNaN:me,BRAND:fe,ZodBranded:ye,ZodPipeline:_e,custom:ve,Schema:T,ZodSchema:T,late:ge,get ZodFirstPartyTypeKind(){return xe},coerce:nt,any:Ce,array:Ae,bigint:Te,boolean:Ne,date:Oe,discriminatedUnion:Le,effect:Ge,enum:Je,function:Be,instanceof:be,intersection:ze,lazy:qe,literal:Fe,map:Ke,nan:Ze,nativeEnum:Ye,never:Pe,null:je,nullable:Xe,number:we,object:Me,oboolean:rt,onumber:st,optional:Qe,ostring:at,pipeline:tt,preprocess:et,promise:He,record:Ue,set:We,strictObject:$e,string:ke,symbol:Se,transformer:Ge,tuple:Ve,undefined:Ee,union:De,unknown:Ie,void:Re,NEVER:it,ZodIssueCode:s,quotelessJson:r,ZodError:n});export{fe as BRAND,f as DIRTY,l as EMPTY_PATH,m as INVALID,it as NEVER,y as OK,h as ParseStatus,T as Schema,L as ZodAny,K as ZodArray,P as ZodBigInt,R as ZodBoolean,ye as ZodBranded,he as ZodCatch,A as ZodDate,pe as ZodDefault,Y as ZodDiscriminatedUnion,ce as ZodEffects,ie as ZodEnum,n as ZodError,xe as ZodFirstPartyTypeKind,ae as ZodFunction,G as ZodIntersection,s as ZodIssueCode,se as ZodLazy,re as ZodLiteral,ee as ZodMap,me as ZodNaN,oe as ZodNativeEnum,V as ZodNever,D as ZodNull,le as ZodNullable,I as ZodNumber,q as ZodObject,ue as ZodOptional,t as ZodParsedType,_e as ZodPipeline,de as ZodPromise,X as ZodRecord,T as ZodSchema,te as ZodSet,j as ZodString,M as ZodSymbol,ce as ZodTransformer,Q as ZodTuple,T as ZodType,$ as ZodUndefined,F as ZodUnion,z as ZodUnknown,U as ZodVoid,p as addIssueToContext,Ce as any,Ae as array,Te as bigint,Ne as boolean,nt as coerce,ve as custom,Oe as date,ot as default,i as defaultErrorMap,Le as discriminatedUnion,Ge as effect,Je as enum,Be as function,c as getErrorMap,a as getParsedType,be as instanceof,ze as intersection,_ as isAborted,x as isAsync,v as isDirty,g as isValid,ge as late,qe as lazy,Fe as literal,u as makeIssue,Ke as map,Ze as nan,Ye as nativeEnum,Pe as never,je as null,Xe as nullable,we as number,Me as object,W as objectUtil,rt as oboolean,st as onumber,Qe as optional,at as ostring,tt as pipeline,et as preprocess,He as promise,r as quotelessJson,Ue as record,We as set,d as setErrorMap,$e as strictObject,ke as string,Se as symbol,Ge as transformer,Ve as tuple,Ee as undefined,De as union,Ie as unknown,e as util,Re as void,ot as z};